wa2frontend.cpp 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  1. #include <precomp.h>
  2. /*------------------------------------------------------------------------------------------------
  3. Winamp 2.9/5 frontend class
  4. ------------------------------------------------------------------------------------------------*/
  5. #include <stdio.h>
  6. #include "main.h"
  7. #include "wa2frontend.h"
  8. #include "../winamp/wa_ipc.h"
  9. #include "../winamp/ipc_pe.h"
  10. #include "../gen_ml/ml.h"
  11. #include "../gen_ml/main.h"
  12. #include "../gen_hotkeys/wa_hotkeys.h"
  13. #include "../nu/AutoChar.h"
  14. #include "resource.h"
  15. #include "../Agave/Language/api_language.h"
  16. #define WINAMP_EDIT_ID3 40188
  17. Winamp2FrontEnd wa2;
  18. void Winamp2FrontEnd::init(HWND hwndParent)
  19. {
  20. // find Winamp's HWND so we can talk to it
  21. hwnd_winamp = hwndParent; //FindWindow("Winamp v1.x",NULL);
  22. // check that hwnd_winamp isnt null and that we know about this specific ipc version
  23. getVersion();
  24. // more init
  25. enabled = 1;
  26. visible = 1;
  27. *(void **)&export_sa_get=(void*)SendMessageW(hwnd_winamp,WM_WA_IPC,2,IPC_GETSADATAFUNC);
  28. *(void **)&export_sa_setreq=(void *)SendMessageW(hwnd_winamp,WM_WA_IPC,1,IPC_GETSADATAFUNC);
  29. *(void **)&export_sa_get_deprecated=(void*)SendMessageW(hwnd_winamp,WM_WA_IPC,0,IPC_GETSADATAFUNC);
  30. *(void **)&export_vu_get=(void*)SendMessageW(hwnd_winamp,WM_WA_IPC,0,IPC_GETVUDATAFUNC);
  31. if (reinterpret_cast<intptr_t>(export_vu_get) == -1)
  32. export_vu_get=0;
  33. hwnd_playlist = getWnd(IPC_GETWND_PE);
  34. }
  35. //-----------------------------------------------------------------------------------------------
  36. Winamp2FrontEnd::Winamp2FrontEnd()
  37. {
  38. m_version = (char *)malloc(64);
  39. *m_version = 0;
  40. enabled = visible = foundvis =
  41. saved_video =
  42. #ifdef MINIBROWSER_SUPPORT
  43. saved_mb =
  44. #endif
  45. saved_pe = saved_eq = saved_main = 0;
  46. got_length_cache = 0;
  47. cached_length = -1;
  48. cached_length_time = 0;
  49. got_pos_cache = 0;
  50. cached_pos = -1;
  51. cached_pos_time = 0;
  52. video_ideal_height = -1;
  53. video_ideal_width = -1;
  54. hwnd_winamp = hwnd_playlist = NULL;
  55. export_sa_get = 0;
  56. export_sa_setreq = 0;
  57. export_sa_get_deprecated = 0;
  58. export_vu_get = 0;
  59. }
  60. //-----------------------------------------------------------------------------------------------
  61. Winamp2FrontEnd::~Winamp2FrontEnd()
  62. {
  63. setWindowsVisible(1);
  64. free(m_version);
  65. }
  66. //-----------------------------------------------------------------------------------------------
  67. const char *Winamp2FrontEnd::getVersion()
  68. {
  69. if (hwnd_winamp == NULL)
  70. {
  71. char err[16] = {0};
  72. MessageBoxA(NULL, WASABI_API_LNGSTRING(IDS_COULD_NOT_FIND_WINAMP),
  73. WASABI_API_LNGSTRING_BUF(IDS_ERROR,err,16), 0);
  74. m_version = "Winamp not found";
  75. return m_version;
  76. }
  77. if (hwnd_winamp == NULL)
  78. return NULL;
  79. if (*m_version == 0)
  80. {
  81. // get version number
  82. int version = SendMessageW(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION);
  83. // check that we support this version of the ipc
  84. //assert(((version & 0xFF) >> 8) > 0x20);
  85. // format the version number into a string
  86. wsprintfA(m_version, "%d.%d%d", (version & 0xF000) >> 12, version & (0xF0 >> 4), version & 0xF);
  87. }
  88. return m_version;
  89. }
  90. //-----------------------------------------------------------------------------------------------
  91. void Winamp2FrontEnd::userButton(int button, int modifier)
  92. {
  93. if (!IsWindow(hwnd_winamp)) return;
  94. int mod = 0;
  95. switch (modifier)
  96. {
  97. case WA2_USERBUTTONMOD_NONE : break;
  98. case WA2_USERBUTTONMOD_SHIFT: mod = 100; break;
  99. case WA2_USERBUTTONMOD_CTRL : mod = 110; break;
  100. }
  101. switch (button)
  102. {
  103. case WA2_USERBUTTON_PREV: SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON1 + mod,0); break;
  104. case WA2_USERBUTTON_PLAY: SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON2 + mod,0); break;
  105. case WA2_USERBUTTON_PAUSE: SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON3 + mod,0); break;
  106. case WA2_USERBUTTON_STOP: SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON4 + mod,0); break;
  107. case WA2_USERBUTTON_NEXT: SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON5 + mod,0); break;
  108. }
  109. }
  110. //-----------------------------------------------------------------------------------------------
  111. void Winamp2FrontEnd::setOnTop(int ontop)
  112. {
  113. if (!!ontop == !!isOnTop()) return;
  114. toggleOnTop();
  115. }
  116. //-----------------------------------------------------------------------------------------------
  117. void Winamp2FrontEnd::toggleOnTop()
  118. {
  119. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_AOT, 0);
  120. }
  121. //-----------------------------------------------------------------------------------------------
  122. void Winamp2FrontEnd::enqueueFile(const wchar_t *file)
  123. {
  124. if (!IsWindow(hwnd_winamp)) return;
  125. COPYDATASTRUCT cds;
  126. cds.dwData = IPC_PLAYFILEW;
  127. cds.lpData = (void *)file;
  128. cds.cbData = sizeof(wchar_t) * (wcslen(file)+1);
  129. SendMessageW(hwnd_winamp,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds);
  130. }
  131. //-----------------------------------------------------------------------------------------------
  132. int Winamp2FrontEnd::isPlaying()
  133. {
  134. if (!IsWindow(hwnd_winamp)) return 0;
  135. return SendMessageW(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING) == 1;
  136. }
  137. //-----------------------------------------------------------------------------------------------
  138. int Winamp2FrontEnd::isPaused()
  139. {
  140. if (!IsWindow(hwnd_winamp)) return 0;
  141. return SendMessageW(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING) == 3;
  142. }
  143. //-----------------------------------------------------------------------------------------------
  144. int Winamp2FrontEnd::isStopped()
  145. {
  146. if (!IsWindow(hwnd_winamp)) return 1;
  147. return SendMessageW(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING) == 0;
  148. }
  149. //-----------------------------------------------------------------------------------------------
  150. int Winamp2FrontEnd::getPosition()
  151. {
  152. if ( !IsWindow( hwnd_winamp ) )
  153. return 0;
  154. if ( got_pos_cache && GetTickCount() < cached_pos_time + 20 )
  155. return cached_pos;
  156. got_pos_cache = 1;
  157. cached_pos_time = GetTickCount();
  158. return cached_pos = SendMessageW( hwnd_winamp, WM_WA_IPC, 0, IPC_GETOUTPUTTIME );
  159. }
  160. //-----------------------------------------------------------------------------------------------
  161. int Winamp2FrontEnd::getLength()
  162. {
  163. if ( got_length_cache && GetTickCount() < cached_length_time + 3000 )
  164. return cached_length;
  165. if ( !IsWindow( hwnd_winamp ) )
  166. return 0;
  167. int l = SendMessageW( hwnd_winamp, WM_WA_IPC, 1, IPC_GETOUTPUTTIME );
  168. if ( l == -1 )
  169. cached_length = -1;
  170. else
  171. cached_length = l * 1000;
  172. got_length_cache = 1;
  173. cached_length_time = GetTickCount();
  174. return cached_length;
  175. }
  176. //-----------------------------------------------------------------------------------------------
  177. int Winamp2FrontEnd::seekTo(int ms)
  178. {
  179. got_pos_cache = 0;
  180. if (!IsWindow(hwnd_winamp)) return 0;
  181. return SendMessageW(hwnd_winamp,WM_WA_IPC,ms,IPC_JUMPTOTIME);
  182. }
  183. //-----------------------------------------------------------------------------------------------
  184. void Winamp2FrontEnd::setVolume(int v)
  185. {
  186. if (!IsWindow(hwnd_winamp)) return;
  187. SendMessageW(hwnd_winamp,WM_WA_IPC,v,IPC_SETVOLUME);
  188. }
  189. //-----------------------------------------------------------------------------------------------
  190. int Winamp2FrontEnd::getVolume()
  191. {
  192. if (!IsWindow(hwnd_winamp)) return 255;
  193. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)-666,IPC_SETVOLUME);
  194. }
  195. //-----------------------------------------------------------------------------------------------
  196. void Winamp2FrontEnd::setPanning(int p)
  197. {
  198. if (!IsWindow(hwnd_winamp)) return;
  199. SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)p,IPC_SETPANNING);
  200. }
  201. //-----------------------------------------------------------------------------------------------
  202. int Winamp2FrontEnd::getPanning()
  203. {
  204. if (!IsWindow(hwnd_winamp)) return 0;
  205. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)-666,IPC_SETPANNING);
  206. }
  207. //-----------------------------------------------------------------------------------------------
  208. int Winamp2FrontEnd::getInfo( int what )
  209. {
  210. if ( !IsWindow( hwnd_winamp ) )
  211. return 0;
  212. return SendMessageW( hwnd_winamp, WM_WA_IPC, (WPARAM)what, IPC_GETINFO );
  213. }
  214. //-----------------------------------------------------------------------------------------------
  215. int Winamp2FrontEnd::getEqData(int what)
  216. {
  217. if (!IsWindow(hwnd_winamp)) return 0;
  218. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)what,IPC_GETEQDATA);
  219. }
  220. //-----------------------------------------------------------------------------------------------
  221. void Winamp2FrontEnd::setEqData(int what, int val)
  222. {
  223. if (!IsWindow(hwnd_winamp)) return;
  224. //SendMessageW(hwnd_winamp,WM_WA_IPC,what,IPC_GETEQDATA); // f this :)
  225. SendMessageW(hwnd_winamp,WM_WA_IPC,0xDB000000 | ((what&0xFF) << 16) | (val&0xFFFF),IPC_SETEQDATA);
  226. }
  227. //-----------------------------------------------------------------------------------------------
  228. int Winamp2FrontEnd::getShuffle()
  229. {
  230. if (!IsWindow(hwnd_winamp)) return 0;
  231. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_SHUFFLE);
  232. }
  233. //-----------------------------------------------------------------------------------------------
  234. int Winamp2FrontEnd::getRepeat()
  235. {
  236. if (!IsWindow(hwnd_winamp)) return 0;
  237. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_REPEAT);
  238. }
  239. //-----------------------------------------------------------------------------------------------
  240. void Winamp2FrontEnd::setShuffle(int shuffle)
  241. {
  242. if (!IsWindow(hwnd_winamp)) return;
  243. SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)shuffle,IPC_SET_SHUFFLE);
  244. }
  245. //-----------------------------------------------------------------------------------------------
  246. void Winamp2FrontEnd::setRepeat(int repeat)
  247. {
  248. if (!IsWindow(hwnd_winamp)) return;
  249. SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)repeat,IPC_SET_REPEAT);
  250. }
  251. //-----------------------------------------------------------------------------------------------
  252. void Winamp2FrontEnd::setManualPlaylistAdvance(int manual)
  253. {
  254. if (!IsWindow(hwnd_winamp)) return;
  255. SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)manual,IPC_SET_MANUALPLADVANCE);
  256. }
  257. //-----------------------------------------------------------------------------------------------
  258. int Winamp2FrontEnd::getManualPlaylistAdvance()
  259. {
  260. if (!IsWindow(hwnd_winamp)) return 0;
  261. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_MANUALPLADVANCE);
  262. }
  263. //-----------------------------------------------------------------------------------------------
  264. void Winamp2FrontEnd::enableWindows( int enabled )
  265. {
  266. if ( !IsWindow( hwnd_winamp ) )
  267. return;
  268. SendMessageW( hwnd_winamp, WM_WA_IPC, enabled ? 0 : 0xdeadbeef, IPC_ENABLEDISABLE_ALL_WINDOWS );
  269. }
  270. //-----------------------------------------------------------------------------------------------
  271. int Winamp2FrontEnd::areWindowsEnabled()
  272. {
  273. if ( !IsWindow( hwnd_winamp ) )
  274. return 1;
  275. return 1; // todo !!
  276. }
  277. //-----------------------------------------------------------------------------------------------
  278. int _IsWindowVisible( HWND w )
  279. {
  280. if ( !IsWindowVisible( w ) )
  281. return 0;
  282. RECT r;
  283. GetWindowRect( w, &r );
  284. return !( r.left >= 3000 && r.top >= 3000 );
  285. }
  286. int Winamp2FrontEnd::isMainWindowVisible()
  287. {
  288. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)0, IPC_ISMAINWNDVISIBLE);
  289. }
  290. //-----------------------------------------------------------------------------------------------
  291. void Winamp2FrontEnd::setWindowsVisible(int v)
  292. {
  293. if (visible == v)
  294. return;
  295. if (!IsWindow(hwnd_winamp))
  296. return;
  297. if (v)
  298. {
  299. if (saved_main && ! isMainWindowVisible())
  300. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_MAIN_WINDOW, 0);
  301. if (saved_eq && !isWindowVisible(IPC_GETWND_EQ))
  302. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_EQ, 0);
  303. #ifdef MINIBROWSER_SUPPORT
  304. if (saved_mb && !isWindowVisible(IPC_GETWND_MB))
  305. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_MINIBROWSER, 0);
  306. #endif
  307. if (saved_pe && !isWindowVisible(IPC_GETWND_PE))
  308. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_PLEDIT, 0);
  309. if (saved_video && !isWindowVisible(IPC_GETWND_VIDEO))
  310. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_VIDEO, 0);
  311. }
  312. else
  313. {
  314. if (isMainWindowVisible())
  315. {
  316. saved_main = 1;
  317. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_MAIN_WINDOW, 0);
  318. }
  319. else
  320. saved_main = 0;
  321. if (isWindowVisible(IPC_GETWND_EQ))
  322. {
  323. saved_eq = 1;
  324. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_EQ, 0);
  325. }
  326. else
  327. saved_eq = 0;
  328. #ifdef MINIBROWSER_SUPPORT
  329. if (isWindowVisible(IPC_GETWND_MB))
  330. {
  331. saved_mb = 1;
  332. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_MINIBROWSER, 0);
  333. }
  334. else saved_mb = 0;
  335. #endif
  336. if (isWindowVisible(IPC_GETWND_PE))
  337. {
  338. saved_pe = 1;
  339. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_PLEDIT, 0);
  340. }
  341. else
  342. saved_pe = 0;
  343. if (isWindowVisible(IPC_GETWND_VIDEO))
  344. {
  345. saved_video = 1;
  346. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_OPTIONS_VIDEO, 0);
  347. }
  348. else saved_video = 0;
  349. }
  350. visible = v;
  351. }
  352. //-----------------------------------------------------------------------------------------------
  353. int Winamp2FrontEnd::areWindowsVisible()
  354. {
  355. if (!IsWindow(hwnd_winamp))
  356. return 1;
  357. return visible;
  358. }
  359. //-----------------------------------------------------------------------------------------------
  360. HWND Winamp2FrontEnd::getWnd(int wnd)
  361. {
  362. if (!IsWindow(hwnd_winamp))
  363. return NULL;
  364. return (HWND)SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)wnd,IPC_GETWND);
  365. }
  366. //-----------------------------------------------------------------------------------------------
  367. int Winamp2FrontEnd::getPlaylistLength()
  368. {
  369. if (!IsWindow(hwnd_winamp)) return 0;
  370. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GETLISTLENGTH);
  371. }
  372. //-----------------------------------------------------------------------------------------------
  373. int Winamp2FrontEnd::getCurPlaylistEntry()
  374. {
  375. if (!IsWindow(hwnd_winamp)) return 0;
  376. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GETLISTPOS);
  377. }
  378. //-----------------------------------------------------------------------------------------------
  379. const wchar_t *Winamp2FrontEnd::getTitle(int plentry)
  380. {
  381. if (!IsWindow(hwnd_winamp)) return NULL;
  382. return (const wchar_t *)SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)plentry,IPC_GETPLAYLISTTITLEW);
  383. }
  384. //-----------------------------------------------------------------------------------------------
  385. const char *Winamp2FrontEnd::getFile(int plentry)
  386. {
  387. if (!IsWindow(hwnd_winamp)) return NULL;
  388. return (const char *)SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)plentry,IPC_GETPLAYLISTFILE);
  389. }
  390. const wchar_t *Winamp2FrontEnd::getFileW(int plentry)
  391. {
  392. if (!IsWindow(hwnd_winamp)) return NULL;
  393. return (const wchar_t *)SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)plentry,IPC_GETPLAYLISTFILEW);
  394. }
  395. //-----------------------------------------------------------------------------------------------
  396. void Winamp2FrontEnd::playAudioCD(int cd)
  397. {
  398. if (!IsWindow(hwnd_winamp)) return;
  399. SendMessageW(hwnd_winamp,WM_COMMAND,ID_MAIN_PLAY_AUDIOCD1+cd,0);
  400. }
  401. //-----------------------------------------------------------------------------------------------
  402. void Winamp2FrontEnd::openFileDialog(HWND w)
  403. {
  404. if (!IsWindow(hwnd_winamp)) return;
  405. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)w, IPC_OPENFILEBOX);
  406. }
  407. //-----------------------------------------------------------------------------------------------
  408. void Winamp2FrontEnd::openUrlDialog(HWND w)
  409. {
  410. if (!IsWindow(hwnd_winamp)) return;
  411. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON2_CTRL, 0);
  412. }
  413. //-----------------------------------------------------------------------------------------------
  414. void Winamp2FrontEnd::openDirectoryDialog(HWND w)
  415. {
  416. if (!IsWindow(hwnd_winamp)) return;
  417. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)w, IPC_OPENDIRBOX);
  418. }
  419. //-----------------------------------------------------------------------------------------------
  420. void Winamp2FrontEnd::ejectPopupMenu()
  421. {
  422. if (!IsWindow(hwnd_winamp)) return;
  423. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)0, IPC_SPAWNBUTTONPOPUP);
  424. }
  425. //-----------------------------------------------------------------------------------------------
  426. void Winamp2FrontEnd::previousPopupMenu()
  427. {
  428. if (!IsWindow(hwnd_winamp)) return;
  429. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)1, IPC_SPAWNBUTTONPOPUP);
  430. }
  431. //-----------------------------------------------------------------------------------------------
  432. void Winamp2FrontEnd::nextPopupMenu()
  433. {
  434. if (!IsWindow(hwnd_winamp)) return;
  435. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)2, IPC_SPAWNBUTTONPOPUP);
  436. }
  437. //-----------------------------------------------------------------------------------------------
  438. void Winamp2FrontEnd::pausePopupMenu()
  439. {
  440. if (!IsWindow(hwnd_winamp)) return;
  441. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)3, IPC_SPAWNBUTTONPOPUP);
  442. }
  443. //-----------------------------------------------------------------------------------------------
  444. void Winamp2FrontEnd::playPopupMenu()
  445. {
  446. if (!IsWindow(hwnd_winamp)) return;
  447. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)4, IPC_SPAWNBUTTONPOPUP);
  448. }
  449. //-----------------------------------------------------------------------------------------------
  450. void Winamp2FrontEnd::stopPopupMenu()
  451. {
  452. if (!IsWindow(hwnd_winamp)) return;
  453. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)5, IPC_SPAWNBUTTONPOPUP);
  454. }
  455. //-----------------------------------------------------------------------------------------------
  456. void Winamp2FrontEnd::setDialogBoxParent(HWND w)
  457. {
  458. if (!IsWindow(hwnd_winamp)) return;
  459. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)w, IPC_SETDIALOGBOXPARENT);
  460. }
  461. void Winamp2FrontEnd::updateDialogBoxParent(HWND w)
  462. {
  463. if (!IsWindow(hwnd_winamp)) return;
  464. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)w, IPC_UPDATEDIALOGBOXPARENT);
  465. }
  466. //-----------------------------------------------------------------------------------------------
  467. int Winamp2FrontEnd::isOnTop()
  468. {
  469. if (!IsWindow(hwnd_winamp)) return 0;
  470. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_IS_AOT);
  471. }
  472. //-----------------------------------------------------------------------------------------------
  473. void Winamp2FrontEnd::triggerPopupMenu(int x, int y)
  474. {
  475. if (!IsWindow(hwnd_winamp)) return;
  476. HMENU hMenu = (HMENU)SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_HMENU);
  477. DoTrackPopup(hMenu, TPM_RIGHTBUTTON, x, y, hwnd_winamp);
  478. }
  479. //-----------------------------------------------------------------------------------------------
  480. void Winamp2FrontEnd::triggerEQPresetMenu(int x, int y)
  481. {
  482. waSpawnMenuParms p = {hwnd_winamp, x, y};
  483. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNEQPRESETMENU);
  484. }
  485. //-----------------------------------------------------------------------------------------------
  486. int Winamp2FrontEnd::triggerFileMenu(int x, int y, int width, int height)
  487. {
  488. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  489. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNFILEMENU);
  490. }
  491. //-----------------------------------------------------------------------------------------------
  492. int Winamp2FrontEnd::triggerPlayMenu(int x, int y, int width, int height)
  493. {
  494. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  495. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNPLAYMENU);
  496. }
  497. //-----------------------------------------------------------------------------------------------
  498. int Winamp2FrontEnd::triggerOptionsMenu(int x, int y, int width, int height)
  499. {
  500. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  501. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNOPTIONSMENU);
  502. }
  503. //-----------------------------------------------------------------------------------------------
  504. int Winamp2FrontEnd::triggerWindowsMenu(int x, int y, int width, int height)
  505. {
  506. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  507. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNWINDOWSMENU);
  508. }
  509. //-----------------------------------------------------------------------------------------------
  510. int Winamp2FrontEnd::triggerHelpMenu(int x, int y, int width, int height)
  511. {
  512. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  513. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNHELPMENU);
  514. }
  515. //-----------------------------------------------------------------------------------------------
  516. int Winamp2FrontEnd::triggerPEFileMenu(int x, int y, int width, int height)
  517. {
  518. int IPC_GETMLWINDOW=SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)&"LibraryGetWnd",IPC_REGISTER_WINAMP_IPCMESSAGE);
  519. if (IPC_GETMLWINDOW > 65536) SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)-1, IPC_GETMLWINDOW);
  520. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  521. p.wnd = getWnd(IPC_GETWND_PE);
  522. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNPEFILEMENU);
  523. }
  524. //-----------------------------------------------------------------------------------------------
  525. int Winamp2FrontEnd::triggerPEPlaylistMenu(int x, int y, int width, int height)
  526. {
  527. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  528. p.wnd = getWnd(IPC_GETWND_PE);
  529. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNPEPLAYLISTMENU);
  530. }
  531. //-----------------------------------------------------------------------------------------------
  532. int Winamp2FrontEnd::triggerPESortMenu(int x, int y, int width, int height)
  533. {
  534. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  535. p.wnd = getWnd(IPC_GETWND_PE);
  536. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNPESORTMENU);
  537. }
  538. //-----------------------------------------------------------------------------------------------
  539. int Winamp2FrontEnd::triggerPEHelpMenu(int x, int y, int width, int height)
  540. {
  541. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  542. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNPEHELPMENU);
  543. }
  544. //-----------------------------------------------------------------------------------------------
  545. int Winamp2FrontEnd::triggerPEListOfListsMenu(int x, int y)
  546. {
  547. int IPC_GETMLWINDOW=SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)&"LibraryGetWnd",IPC_REGISTER_WINAMP_IPCMESSAGE);
  548. if (IPC_GETMLWINDOW > 65536) SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)-1, IPC_GETMLWINDOW);
  549. waSpawnMenuParms p = {hwnd_winamp, x, y};
  550. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNPELISTOFPLAYLISTS);
  551. }
  552. //-----------------------------------------------------------------------------------------------
  553. int Winamp2FrontEnd::triggerMLFileMenu(int x, int y, int width, int height)
  554. {
  555. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  556. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNMLFILEMENU);
  557. }
  558. //-----------------------------------------------------------------------------------------------
  559. int Winamp2FrontEnd::triggerMLViewMenu(int x, int y, int width, int height)
  560. {
  561. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  562. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNMLVIEWMENU);
  563. }
  564. //-----------------------------------------------------------------------------------------------
  565. int Winamp2FrontEnd::triggerMLHelpMenu(int x, int y, int width, int height)
  566. {
  567. waSpawnMenuParms2 p = {hwnd_winamp, x, y, width, height};
  568. return SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&p, IPC_SPAWNMLHELPMENU);
  569. }
  570. //-----------------------------------------------------------------------------------------------
  571. HMENU Winamp2FrontEnd::getPopupMenu()
  572. {
  573. if (!IsWindow(hwnd_winamp)) return NULL;
  574. return (HMENU)SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_HMENU);
  575. }
  576. //-----------------------------------------------------------------------------------------------
  577. HMENU Winamp2FrontEnd::getTopMenu()
  578. {
  579. if (!IsWindow(hwnd_winamp)) return NULL;
  580. return (HMENU)SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)-1,IPC_GET_HMENU);
  581. }
  582. //-----------------------------------------------------------------------------------------------
  583. int Winamp2FrontEnd::adjustOptionsPopupMenu(int direction)
  584. {
  585. if (!IsWindow(hwnd_winamp)) return 0;
  586. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)direction,IPC_ADJUST_OPTIONSMENUPOS);
  587. }
  588. //-----------------------------------------------------------------------------------------------
  589. HMENU Winamp2FrontEnd::getMenuBarMenu(int which)
  590. {
  591. if (!IsWindow(hwnd_winamp)) return NULL;
  592. return (HMENU)SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)which+1,IPC_GET_HMENU);
  593. }
  594. //-----------------------------------------------------------------------------------------------
  595. int Winamp2FrontEnd::adjustFFWindowsMenu(int direction)
  596. {
  597. if (!IsWindow(hwnd_winamp)) return 0;
  598. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)direction,IPC_ADJUST_FFWINDOWSMENUPOS);
  599. }
  600. //-----------------------------------------------------------------------------------------------
  601. int Winamp2FrontEnd::adjustFFOptionsMenu(int direction)
  602. {
  603. if (!IsWindow(hwnd_winamp)) return 0;
  604. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)direction,IPC_ADJUST_FFOPTIONSMENUPOS);
  605. }
  606. //-----------------------------------------------------------------------------------------------
  607. HWND Winamp2FrontEnd::getMainWindow()
  608. {
  609. return hwnd_winamp;
  610. }
  611. //-----------------------------------------------------------------------------------------------
  612. void Winamp2FrontEnd::quit()
  613. {
  614. if (!IsWindow(hwnd_winamp)) return;
  615. SendMessageW(hwnd_winamp,WM_CLOSE,0,0);
  616. }
  617. //-----------------------------------------------------------------------------------------------
  618. int Winamp2FrontEnd::isWindowVisible(intptr_t which)
  619. {
  620. return SendMessageW(hwnd_winamp, WM_WA_IPC, which, IPC_ISWNDVISIBLE);
  621. }
  622. //-----------------------------------------------------------------------------------------------
  623. void Winamp2FrontEnd::setWindowVisible(intptr_t which, int visible)
  624. {
  625. int state = isWindowVisible(which);
  626. if (!state == !visible) return;
  627. int id = 0;
  628. switch (which)
  629. {
  630. case IPC_GETWND_EQ:
  631. DebugStringW(L"Showing EQ!!\n");
  632. id = WINAMP_OPTIONS_EQ;
  633. break;
  634. case IPC_GETWND_PE:
  635. id = WINAMP_OPTIONS_PLEDIT;
  636. break;
  637. #ifdef MINIBROWSER_SUPPORT
  638. case IPC_GETWND_MB:
  639. id = WINAMP_OPTIONS_MINIBROWSER;
  640. break;
  641. #endif
  642. case IPC_GETWND_VIDEO:
  643. id = WINAMP_OPTIONS_VIDEO;
  644. break;
  645. }
  646. SendMessageW(hwnd_winamp, WM_COMMAND, id, 0);
  647. }
  648. //-----------------------------------------------------------------------------------------------
  649. void Winamp2FrontEnd::sendPlCmd(int which, int x, int y, int menu_align_flag)
  650. {
  651. windowCommand wc = {which, x, y, menu_align_flag};
  652. SendMessageW(hwnd_winamp, WM_WA_IPC, (intptr_t)&wc, IPC_PLCMD);
  653. }
  654. #ifdef MINIBROWSER_SUPPORT
  655. //-----------------------------------------------------------------------------------------------
  656. void Winamp2FrontEnd::sendMbCmd(int which, int x, int y, int menu_align_flag)
  657. {
  658. windowCommand wc = {which, x, y, menu_align_flag};
  659. SendMessageW(hwnd_winamp, WM_WA_IPC, (intptr_t)&wc, IPC_MBCMD);
  660. }
  661. #endif
  662. //-----------------------------------------------------------------------------------------------
  663. void Winamp2FrontEnd::sendVidCmd(int which, int x, int y, int menu_align_flag)
  664. {
  665. windowCommand wc = {which, x, y, menu_align_flag};
  666. SendMessageW(hwnd_winamp, WM_WA_IPC, (intptr_t)&wc, IPC_VIDCMD);
  667. }
  668. //-----------------------------------------------------------------------------------------------
  669. #define WINAMP_VISPLUGIN 40192
  670. void Winamp2FrontEnd::toggleVis()
  671. {
  672. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_VISPLUGIN, 0);
  673. }
  674. //-----------------------------------------------------------------------------------------------
  675. int Winamp2FrontEnd::isVisRunning()
  676. {
  677. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_ISVISRUNNING);
  678. }
  679. //-----------------------------------------------------------------------------------------------
  680. HWND Winamp2FrontEnd::getVisWnd()
  681. {
  682. return (HWND)SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETVISWND);
  683. }
  684. //-----------------------------------------------------------------------------------------------
  685. IDropTarget *Winamp2FrontEnd::getDropTarget()
  686. {
  687. return (IDropTarget *)SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETDROPTARGET);
  688. }
  689. //-----------------------------------------------------------------------------------------------
  690. int Winamp2FrontEnd::getSamplerate()
  691. {
  692. int realRate = SendMessageW(hwnd_winamp,WM_WA_IPC,5,IPC_GETINFO);
  693. if (realRate == 1)
  694. return 1000*SendMessageW(hwnd_winamp,WM_WA_IPC,0,IPC_GETINFO);
  695. else
  696. return realRate;
  697. }
  698. //-----------------------------------------------------------------------------------------------
  699. int Winamp2FrontEnd::getBitrate()
  700. {
  701. return SendMessageW(hwnd_winamp,WM_WA_IPC,1,IPC_GETINFO);
  702. }
  703. //-----------------------------------------------------------------------------------------------
  704. int Winamp2FrontEnd::getChannels()
  705. {
  706. return SendMessageW(hwnd_winamp,WM_WA_IPC,2,IPC_GETINFO);
  707. }
  708. //-----------------------------------------------------------------------------------------------
  709. int Winamp2FrontEnd::isValidEmbedWndState(embedWindowState *ws)
  710. {
  711. return SendMessageW(hwnd_winamp, WM_WA_IPC, (intptr_t)ws, IPC_EMBED_ISVALID);
  712. }
  713. //-----------------------------------------------------------------------------------------------
  714. int Winamp2FrontEnd::PE_getNumItems()
  715. {
  716. return SendMessageW(hwnd_playlist, WM_USER, IPC_PE_GETINDEXTOTAL, 0);
  717. }
  718. //-----------------------------------------------------------------------------------------------
  719. fileinfo2 *Winamp2FrontEnd::PE_getFileTitle(int index)
  720. {
  721. static fileinfo2 fi;
  722. fi.fileindex = index;
  723. *(fi.filetitle) = 0;
  724. *(fi.filelength) = 0;
  725. SendMessageW(hwnd_playlist, WM_USER, IPC_PE_GETINDEXTITLE, (LPARAM)&fi);
  726. return &fi;
  727. }
  728. //-----------------------------------------------------------------------------------------------
  729. fileinfo2W *Winamp2FrontEnd::PE_getFileTitleW(int index)
  730. {
  731. static fileinfo2W fi;
  732. fi.fileindex = index;
  733. *(fi.filetitle) = 0;
  734. *(fi.filelength) = 0;
  735. SendMessageW(hwnd_playlist, WM_USER, IPC_PE_GETINDEXTITLEW, (LPARAM)&fi);
  736. return &fi;
  737. }
  738. //-----------------------------------------------------------------------------------------------
  739. int Winamp2FrontEnd::PE_getCurrentIndex()
  740. {
  741. //return SendMessageW(hwnd_playlist, WM_USER, IPC_PE_GETCURINDEX, 0);
  742. return SendMessageW(hwnd_winamp, WM_USER, 0, IPC_GETLISTPOS);
  743. }
  744. //-----------------------------------------------------------------------------------------------
  745. void Winamp2FrontEnd::PE_setCurrentIndex(int i)
  746. {
  747. SendMessageW(hwnd_winamp, WM_WA_IPC, i, IPC_SETPLAYLISTPOS);
  748. }
  749. //-----------------------------------------------------------------------------------------------
  750. HWND Winamp2FrontEnd::getMediaLibrary()
  751. {
  752. int IPC_GETMLWINDOW=SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)&"LibraryGetWnd",IPC_REGISTER_WINAMP_IPCMESSAGE);
  753. return IPC_GETMLWINDOW > 65536 ? (HWND)SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETMLWINDOW) : NULL;
  754. }
  755. //-----------------------------------------------------------------------------------------------
  756. void Winamp2FrontEnd::ensureMediaLibraryLoaded()
  757. {
  758. int IPC_GETMLWINDOW=SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)&"LibraryGetWnd",IPC_REGISTER_WINAMP_IPCMESSAGE);
  759. if (IPC_GETMLWINDOW > 65536) SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)-1, IPC_GETMLWINDOW);
  760. }
  761. //-----------------------------------------------------------------------------------------------
  762. int Winamp2FrontEnd::hasVideoSupport()
  763. {
  764. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_HAS_VIDEO_SUPPORT);
  765. }
  766. //-----------------------------------------------------------------------------------------------
  767. int Winamp2FrontEnd::isPlayingVideo()
  768. {
  769. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_IS_PLAYING_VIDEO) > 0;
  770. }
  771. //-----------------------------------------------------------------------------------------------
  772. int Winamp2FrontEnd::isPlayingVideoFullscreen()
  773. {
  774. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_IS_FULLSCREEN);
  775. }
  776. //-----------------------------------------------------------------------------------------------
  777. int Winamp2FrontEnd::isDoubleSize()
  778. {
  779. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_ISDOUBLESIZE);
  780. }
  781. //-----------------------------------------------------------------------------------------------
  782. int Winamp2FrontEnd::getTimeDisplayMode()
  783. {
  784. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETTIMEDISPLAYMODE);
  785. }
  786. //-----------------------------------------------------------------------------------------------
  787. void Winamp2FrontEnd::switchSkin(const wchar_t *skinname)
  788. {
  789. static StringW wideSkinName;
  790. wideSkinName=skinname;
  791. PostMessage(hwnd_winamp, WM_WA_IPC, (intptr_t)wideSkinName.getValue(), IPC_SETSKINW);
  792. }
  793. //-----------------------------------------------------------------------------------------------
  794. void Winamp2FrontEnd::visNext()
  795. {
  796. PostMessage(hwnd_winamp, WM_COMMAND, ID_VIS_NEXT, 0);
  797. }
  798. //-----------------------------------------------------------------------------------------------
  799. void Winamp2FrontEnd::visFullscreen()
  800. {
  801. PostMessage(hwnd_winamp, WM_COMMAND, ID_VIS_FS, 0);
  802. }
  803. //-----------------------------------------------------------------------------------------------
  804. void Winamp2FrontEnd::visPrev()
  805. {
  806. PostMessage(hwnd_winamp, WM_COMMAND, ID_VIS_PREV, 0);
  807. }
  808. //-----------------------------------------------------------------------------------------------
  809. void Winamp2FrontEnd::visRandom(int set)
  810. {
  811. PostMessage(hwnd_winamp, WM_COMMAND, ID_VIS_RANDOM | (set << 16), 0);
  812. }
  813. //-----------------------------------------------------------------------------------------------
  814. void Winamp2FrontEnd::pollVisRandom()
  815. {
  816. PostMessage(hwnd_winamp, WM_COMMAND, ID_VIS_RANDOM | 0xFFFF0000, 0);
  817. }
  818. //-----------------------------------------------------------------------------------------------
  819. void Winamp2FrontEnd::visConfig()
  820. {
  821. PostMessage(hwnd_winamp, WM_COMMAND, ID_VIS_CFG, 0);
  822. }
  823. //-----------------------------------------------------------------------------------------------
  824. void Winamp2FrontEnd::visMenu()
  825. {
  826. PostMessage(hwnd_winamp, WM_COMMAND, ID_VIS_MENU, 0);
  827. }
  828. //-----------------------------------------------------------------------------------------------
  829. void Winamp2FrontEnd::getIdealVideoSize(int *w, int *h)
  830. {
  831. if (w) *w = video_ideal_width;
  832. if (h) *h = video_ideal_height;
  833. }
  834. //-----------------------------------------------------------------------------------------------
  835. int Winamp2FrontEnd::getStopOnVideoClose()
  836. {
  837. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETSTOPONVIDEOCLOSE);
  838. }
  839. //-----------------------------------------------------------------------------------------------
  840. void Winamp2FrontEnd::setStopOnVideoClose(int stop)
  841. {
  842. SendMessageW(hwnd_winamp, WM_WA_IPC, stop, IPC_SETSTOPONVIDEOCLOSE);
  843. }
  844. //-----------------------------------------------------------------------------------------------
  845. int Winamp2FrontEnd::GetVideoResize()
  846. {
  847. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETVIDEORESIZE);
  848. }
  849. void Winamp2FrontEnd::SetVideoResize(int stop)
  850. {
  851. SendMessageW(hwnd_winamp, WM_WA_IPC, stop, IPC_SETVIDEORESIZE);
  852. }
  853. //-----------------------------------------------------------------------------------------------
  854. BOOL CALLBACK findVisWndProc(HWND hwnd, LPARAM lParam)
  855. {
  856. Winamp2FrontEnd *fe = (Winamp2FrontEnd*)lParam;
  857. if (hwnd == fe->getVisWnd())
  858. {
  859. fe->setFoundVis(); return FALSE;
  860. }
  861. return TRUE;
  862. }
  863. //-----------------------------------------------------------------------------------------------
  864. int Winamp2FrontEnd::isVis(HWND hwnd)
  865. {
  866. if (hwnd == wa2.getVisWnd()) return 1;
  867. foundvis = 0;
  868. EnumChildWindows(hwnd, findVisWndProc, (LPARAM)this);
  869. return foundvis;
  870. }
  871. //-----------------------------------------------------------------------------------------------
  872. HWND Winamp2FrontEnd::getPreferencesWindow()
  873. {
  874. return (HWND)SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETPREFSWND);
  875. }
  876. //-----------------------------------------------------------------------------------------------
  877. void Winamp2FrontEnd::setPlEditWidthHeight(int width, int height)
  878. {
  879. POINT pt={width, height};
  880. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&pt, IPC_SET_PE_WIDTHHEIGHT);
  881. }
  882. //-----------------------------------------------------------------------------------------------
  883. HINSTANCE Winamp2FrontEnd::getLanguagePackInstance()
  884. {
  885. return (HINSTANCE)SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETLANGUAGEPACKINSTANCE);
  886. }
  887. //-----------------------------------------------------------------------------------------------
  888. void Winamp2FrontEnd::openTrackInfo()
  889. {
  890. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_EDIT_ID3, 0);
  891. }
  892. //-----------------------------------------------------------------------------------------------
  893. const char *Winamp2FrontEnd::getOutputPlugin()
  894. {
  895. return (const char *)SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETOUTPUTPLUGIN);
  896. }
  897. //-----------------------------------------------------------------------------------------------
  898. void Winamp2FrontEnd::setDrawBorders(int d)
  899. {
  900. SendMessageW(hwnd_winamp, WM_WA_IPC, d, IPC_SETDRAWBORDERS);
  901. }
  902. //-----------------------------------------------------------------------------------------------
  903. void Winamp2FrontEnd::disableSkinnedCursors(int disable)
  904. {
  905. SendMessageW(hwnd_winamp, WM_WA_IPC, disable, IPC_DISABLESKINCURSORS);
  906. }
  907. //-----------------------------------------------------------------------------------------------
  908. int Winamp2FrontEnd::getMetaData(const wchar_t *filename, const wchar_t *name, wchar_t *data, int data_len)
  909. {
  910. if (!_wcsnicmp(filename, L"file://", 7))
  911. filename+=7;
  912. extendedFileInfoStructW efis=
  913. {
  914. filename,
  915. name,
  916. data,
  917. data_len,
  918. };
  919. return SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)&efis,IPC_GET_EXTENDED_FILE_INFOW_HOOKABLE);
  920. }
  921. //------------------------------------------------------------------------------------------------
  922. void Winamp2FrontEnd::invalidateCache()
  923. {
  924. got_length_cache = 0;
  925. got_pos_cache = 0;
  926. }
  927. //------------------------------------------------------------------------------------------------
  928. void Winamp2FrontEnd::registerGlobalHotkey(const char *name, int msg, int wparam, int lparam, int flags, const char *id)
  929. {
  930. int m_genhotkeys_add_ipc=SendMessageW(hwnd_winamp,WM_WA_IPC,(WPARAM)&"GenHotkeysAdd",IPC_REGISTER_WINAMP_IPCMESSAGE);
  931. genHotkeysAddStruct hs={0,};
  932. hs.name = (char *)name;
  933. hs.uMsg = msg;
  934. hs.wParam = wparam;
  935. hs.lParam = lparam;
  936. hs.flags = flags;
  937. hs.id = (char *)id;
  938. if (m_genhotkeys_add_ipc > 65536) SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&hs, m_genhotkeys_add_ipc);
  939. }
  940. //------------------------------------------------------------------------------------------------
  941. const char *Winamp2FrontEnd::getVideoInfoString()
  942. {
  943. return (const char *)SendMessageW(hwnd_winamp, WM_WA_IPC, 4, IPC_GETINFO);
  944. }
  945. //------------------------------------------------------------------------------------------------
  946. void Winamp2FrontEnd::playFile(const wchar_t *file)
  947. {
  948. SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_DELETE);
  949. COPYDATASTRUCT cds;
  950. cds.dwData = IPC_PLAYFILEW;
  951. cds.lpData = (void *)file;
  952. cds.cbData = sizeof(wchar_t) * (wcslen(file)+1); // +1 to get the NULL, missing forever
  953. SendMessageW(hwnd_winamp, WM_COPYDATA, (WPARAM)hwnd_winamp, (LPARAM)&cds);
  954. SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_STARTPLAY);
  955. }
  956. void Winamp2FrontEnd::clearPlaylist()
  957. {
  958. SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_DELETE);
  959. }
  960. //------------------------------------------------------------------------------------------------
  961. void Winamp2FrontEnd::rewind5s()
  962. {
  963. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_REW5S, 0);
  964. }
  965. //------------------------------------------------------------------------------------------------
  966. void Winamp2FrontEnd::forward5s()
  967. {
  968. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_FFWD5S, 0);
  969. }
  970. //------------------------------------------------------------------------------------------------
  971. void Winamp2FrontEnd::endOfPlaylist()
  972. {
  973. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON5_CTRL, 0);
  974. }
  975. //------------------------------------------------------------------------------------------------
  976. void Winamp2FrontEnd::startOfPlaylist()
  977. {
  978. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON1_CTRL, 0);
  979. }
  980. //------------------------------------------------------------------------------------------------
  981. void Winamp2FrontEnd::stopWithFade()
  982. {
  983. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON4_SHIFT, 0);
  984. }
  985. //------------------------------------------------------------------------------------------------
  986. void Winamp2FrontEnd::stopAfterCurrent()
  987. {
  988. SendMessageW(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON4_CTRL, 0);
  989. }
  990. //------------------------------------------------------------------------------------------------
  991. int Winamp2FrontEnd::isWindowShade(int whichwnd)
  992. {
  993. return SendMessageW(hwnd_winamp, WM_WA_IPC, whichwnd, IPC_IS_WNDSHADE);
  994. }
  995. //------------------------------------------------------------------------------------------------
  996. int Winamp2FrontEnd::getCurTrackRating()
  997. {
  998. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GETRATING);
  999. }
  1000. void Winamp2FrontEnd::setCurTrackRating(int rating)
  1001. {
  1002. SendMessageW(hwnd_winamp, WM_WA_IPC, rating, IPC_SETRATING);
  1003. }
  1004. //------------------------------------------------------------------------------------------------
  1005. int Winamp2FrontEnd::isExitEnabled()
  1006. {
  1007. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_IS_EXIT_ENABLED);
  1008. }
  1009. //------------------------------------------------------------------------------------------------
  1010. int Winamp2FrontEnd::pushExitDisabled()
  1011. {
  1012. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_PUSH_DISABLE_EXIT);
  1013. }
  1014. //------------------------------------------------------------------------------------------------
  1015. int Winamp2FrontEnd::popExitDisabled()
  1016. {
  1017. return SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_POP_DISABLE_EXIT);
  1018. }
  1019. void Winamp2FrontEnd::GetFileInfo(const wchar_t *filename, wchar_t *title, int titleCch, int *length)
  1020. {
  1021. basicFileInfoStructW infoStruct = {0};
  1022. infoStruct.filename = filename;
  1023. infoStruct.title = title;
  1024. infoStruct.titlelen = titleCch;
  1025. SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&infoStruct, IPC_GET_BASIC_FILE_INFOW);
  1026. *length = infoStruct.length;
  1027. }
  1028. const wchar_t *Winamp2FrontEnd::GetCurrentTitle()
  1029. {
  1030. return (const wchar_t *)SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GET_PLAYING_TITLE);
  1031. }
  1032. const wchar_t *Winamp2FrontEnd::GetCurrentFile()
  1033. {
  1034. return (const wchar_t *)SendMessageW(hwnd_winamp, WM_WA_IPC, 0, IPC_GET_PLAYING_FILENAME);
  1035. }
  1036. void *Winamp2FrontEnd::CanPlay(const wchar_t *fn)
  1037. {
  1038. return (void *)SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)fn, IPC_CANPLAY);
  1039. }
  1040. bool Winamp2FrontEnd::IsPlaylist(const wchar_t *fn)
  1041. {
  1042. return AGAVE_API_PLAYLISTMANAGER->CanLoad(fn);
  1043. }
  1044. HWND GetMainContainerHWND();
  1045. bool Winamp2FrontEnd::GetAlbumArt(const wchar_t *filename)
  1046. {
  1047. // disabled 30 May 2012 as per email from Tejas w.r.t. to Rovi deal ending
  1048. #if 0
  1049. if (!_wcsnicmp(filename, L"file://", 7))
  1050. filename+=7;
  1051. artFetchData fetch = {sizeof(artFetchData), GetMainContainerHWND(), };
  1052. wchar_t artist[512]=L"", album[512]=L"", gracenoteFileId[512]=L"", year[5]=L"";
  1053. getMetaData(filename, L"albumartist", artist, 512);
  1054. if (!WCSICMP(artist, L"")) //Add artist if albumartist not available
  1055. getMetaData(filename, L"artist", artist, 512);
  1056. getMetaData(filename, L"album", album, 512);
  1057. getMetaData(filename, L"GracenoteFileID", gracenoteFileId, 512);
  1058. getMetaData(filename, L"year", year, 5);
  1059. fetch.artist=artist;
  1060. fetch.album=album;
  1061. fetch.gracenoteFileId=gracenoteFileId;
  1062. fetch.year=_wtoi(year);
  1063. int r = SendMessageW(hwnd_winamp, WM_WA_IPC, (WPARAM)&fetch, IPC_FETCH_ALBUMART);
  1064. if(r == 0 && fetch.imgData && fetch.imgDataLen) // success, save art in correct location
  1065. {
  1066. AGAVE_API_ALBUMART->SetAlbumArt(filename,L"cover",0,0,fetch.imgData,fetch.imgDataLen,fetch.type);
  1067. WASABI_API_MEMMGR->sysFree(fetch.imgData);
  1068. return true;
  1069. }
  1070. #endif
  1071. return false;
  1072. }
  1073. static void code(long* v, long* k)
  1074. {
  1075. unsigned long y = v[0], z = v[1], sum = 0, /* set up */
  1076. delta = 0x9e3779b9, n = 32 ; /* key schedule constant*/
  1077. while (n-- > 0)
  1078. { /* basic cycle start */
  1079. sum += delta;
  1080. y += ((z << 4) + k[0]) ^(z + sum) ^((z >> 5) + k[1]);
  1081. z += ((y << 4) + k[2]) ^(y + sum) ^((y >> 5) + k[3]); /* end cycle */
  1082. }
  1083. v[0] = y; v[1] = z;
  1084. }
  1085. static int getRegVer()
  1086. {
  1087. int *x = (int*)malloc(32);
  1088. long s[3];
  1089. long ss[2] = {GetTickCount(), (int)x + (int)s}; // fucko: better challenge, too
  1090. long tealike_key[4] = { 31337, 0xf00d, 0xdead, 0xbeef}; //fucko: hide this a bit
  1091. free(x);
  1092. s[0] = ss[0];
  1093. s[1] = ss[1];
  1094. s[2] = 0;
  1095. SendMessageW(plugin.hwndParent, WM_WA_IPC, (WPARAM)s, IPC_GETREGISTEREDVERSION);
  1096. code(ss, tealike_key);
  1097. if (memcmp(s, ss, 8)) return 0;
  1098. return s[2];
  1099. }
  1100. bool Winamp2FrontEnd::IsWinampPro()
  1101. {
  1102. return !!getRegVer();
  1103. }
  1104. void Winamp2FrontEnd::openUrl(const wchar_t *url)
  1105. {
  1106. SendMessageW(plugin.hwndParent, WM_WA_IPC, (WPARAM)url, IPC_OPEN_URL);
  1107. }
  1108. #include "../gen_ml/menu.h"
  1109. LRESULT sendMlIpc(int msg, WPARAM param)
  1110. {
  1111. static LRESULT IPC_GETMLWINDOW;
  1112. if (!IPC_GETMLWINDOW) IPC_GETMLWINDOW = SendMessageW(plugin.hwndParent, WM_WA_IPC, (WPARAM)&"LibraryGetWnd", IPC_REGISTER_WINAMP_IPCMESSAGE);
  1113. HWND mlwnd = (HWND)SendMessageW(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETMLWINDOW);
  1114. if (param == 0 && msg == 0) return (LRESULT)mlwnd;
  1115. if (IsWindow(mlwnd))
  1116. return SendMessageW(mlwnd, WM_ML_IPC, param, msg);
  1117. return 0;
  1118. }
  1119. BOOL DoTrackPopup(HMENU hMenu, UINT fuFlags, int x, int y, HWND hwnd)
  1120. {
  1121. if(hMenu == NULL)
  1122. {
  1123. return NULL;
  1124. }
  1125. HWND ml_wnd = (HWND)sendMlIpc(0, 0);
  1126. if (IsWindow(ml_wnd))
  1127. {
  1128. return Menu_TrackPopup(ml_wnd, hMenu, fuFlags, x, y, hwnd, NULL);
  1129. }
  1130. else
  1131. {
  1132. return TrackPopupMenu(hMenu, fuFlags, x, y, 0, hwnd, NULL);
  1133. }
  1134. }