1
0

ipc.cpp 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633
  1. /** (c) Nullsoft, Inc. C O N F I D E N T I A L
  2. ** Filename:
  3. ** Project:
  4. ** Description:
  5. ** Author:
  6. ** Created:
  7. **/
  8. #include "Main.h"
  9. #include "language.h"
  10. #define APSTUDIO_INVOKED
  11. #include "resource.h"
  12. #include "../Plugins/General/gen_ml/ml.h"
  13. #include "../Plugins/General/gen_ff/ff_ipc.h"
  14. #include "../nu/ns_wc.h"
  15. #include "menuv5.h"
  16. #include "vis.h"
  17. #include "minizip/unzip.h"
  18. #include "wa_dlg.h"
  19. #include "CurrentSongCOM.h"
  20. #include "SkinCOM.h"
  21. #include "ExternalCOM.h"
  22. #include "api.h"
  23. #include "tagz.h"
  24. #include "Browser.h"
  25. #include "../nu/AutoWide.h"
  26. #include "../nu/AutoWideFn.h"
  27. #include "../nu/AutoChar.h"
  28. #include "../nu/AutoCharFn.h"
  29. #include <api/syscb/callbacks/metacb.h>
  30. #include "./skinwindow.h"
  31. #include "JSAPI2_ExternalObject.h"
  32. #include "JSAPI2_CallbackManager.h"
  33. #include "stats.h"
  34. #include "..\WAT\WAT.h"
  35. extern std::vector<prefsDlgRec*> g_piprefsdlgs;
  36. int unique_loword_command = _APS_NEXT_COMMAND_VALUE;
  37. //extern "C" wa_inflate_struct inflate_struct;
  38. wa_inflate_struct inflate_struct =
  39. {
  40. (int (*)(void *))inflateReset,
  41. (int (*)(void *, const char *, int))inflateInit_,
  42. (int (*)(void *, int))inflate,
  43. (int (*)(void *))inflateEnd,
  44. crc32,
  45. };
  46. LRESULT wa_register_ipc(WPARAM data)
  47. {
  48. if (data)
  49. {
  50. typedef struct _regipcrec
  51. {
  52. char *name;
  53. struct _regipcrec *next;
  54. }
  55. regipcrec;
  56. int cnt = 65537;
  57. static regipcrec *root = NULL;
  58. regipcrec *p = root, *lp = root;
  59. while (p)
  60. {
  61. if (!lstrcmpiA(p->name, (char*)data)) break;
  62. lp = p;
  63. p = p->next;
  64. cnt++;
  65. }
  66. if (!p)
  67. {
  68. if (!lp) // first item
  69. {
  70. root = (regipcrec *)calloc(1, sizeof(regipcrec));
  71. if (!root) return 0;
  72. root->next = 0;
  73. root->name = _strdup((char*)data);
  74. }
  75. else
  76. {
  77. lp->next = (regipcrec *)calloc(1, sizeof(regipcrec));
  78. if (!lp->next) return 0;
  79. lp->next->next = 0;
  80. lp->next->name = _strdup((char*)data);
  81. }
  82. }
  83. return cnt;
  84. }
  85. return 0;
  86. }
  87. // used to delay / filter out quick IPC_SETDIALOGBOXPARENT messages
  88. // to try to prevent the aero-peek buttons failing / part loading
  89. #define AEROPEEK 0xC0DE+4
  90. VOID CALLBACK DialogBoxParentChanged(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
  91. {
  92. KillTimer(hwnd, idEvent);
  93. OnTaskbarButtonCreated(FALSE);
  94. }
  95. // IPC handler (for frontends and ourself)
  96. LRESULT Main_OnIPC(HWND hwnd, int which, WPARAM data)
  97. {
  98. LRESULT returnValue = 0;
  99. if (VideoIPCProcedure(which, data, &returnValue))
  100. return returnValue;
  101. static int ldata;
  102. static char fn[FILENAME_SIZE];
  103. static wchar_t fnW[FILENAME_SIZE];
  104. switch (which)
  105. {
  106. case IPC_GET_API_SERVICE:
  107. return reinterpret_cast<LRESULT>((api_service *)WASABI_API_SVC);
  108. case IPC_USE_REGISTRY:
  109. return !config_no_registry;
  110. case IPC_GET_DISPATCH_OBJECT:
  111. {
  112. ExternalCOM *external;
  113. return (SUCCEEDED(JSAPI1_GetExternal(&external))) ? reinterpret_cast<LRESULT>((IDispatch*)external) : NULL;
  114. }
  115. case IPC_REGISTER_LOWORD_COMMAND:
  116. if (data == 0)
  117. return unique_loword_command++;
  118. else
  119. {
  120. LRESULT temp = unique_loword_command;
  121. unique_loword_command+=data;
  122. return temp;
  123. }
  124. case IPC_METADATA_CHANGED:
  125. {
  126. CurrentSongCOM *currentSongCOM;
  127. if(SUCCEEDED(JSAPI1_GetCurrentSongCOM(&currentSongCOM)))
  128. {
  129. currentSongCOM->MetadataChanged((char *)data);
  130. currentSongCOM->Release();
  131. }
  132. break;
  133. }
  134. case IPC_FF_ONCOLORTHEMECHANGED:
  135. case IPC_SKIN_CHANGED:
  136. {
  137. WADlg_init(hMainWindow);
  138. JSAPI1_SkinChanged();
  139. break;
  140. }
  141. case IPC_GET_RANDFUNC:
  142. switch(data)
  143. {
  144. case 0:
  145. return reinterpret_cast<LRESULT>(warand);
  146. case 1 :
  147. return reinterpret_cast<LRESULT>(warandf);
  148. }
  149. break;
  150. case IPC_USE_UXTHEME_FUNC:
  151. switch(data)
  152. {
  153. case IPC_ISWINTHEMEPRESENT:
  154. return !IsWinXPTheme();
  155. case IPC_ISAEROCOMPOSITIONACTIVE:
  156. return !IsAero();
  157. default:
  158. if(IsWindow((HWND)data))
  159. DoWinXPStyle((HWND)data);
  160. return 0;
  161. }
  162. break;
  163. case IPC_USES_RECYCLEBIN:
  164. return config_playlist_recyclebin;
  165. case IPC_IS_AOT:
  166. return config_aot;
  167. case IPC_IS_EXIT_ENABLED:
  168. return g_exit_disabled == 0;
  169. case IPC_PUSH_DISABLE_EXIT:
  170. g_exit_disabled++;
  171. return g_exit_disabled;
  172. case IPC_POP_DISABLE_EXIT:
  173. g_exit_disabled--;
  174. return g_exit_disabled;
  175. case IPC_REGISTER_WINAMP_IPCMESSAGE:
  176. return wa_register_ipc(data);
  177. case IPC_WRITECONFIG:
  178. if (data >= 0 && data <= 2) config_write(data);
  179. return 0;
  180. case IPC_HOOK_OKTOQUIT:
  181. // do nothing, but let people hook it
  182. return 1;
  183. case IPC_ALLOW_PLAYTRACKING:
  184. // keep a track of the old state since we can use it to see
  185. // if we need to ignore showing the video window on tag edit
  186. last_no_notify_play = no_notify_play;
  187. no_notify_play = !data;
  188. break;
  189. case IPC_SETDRAWBORDERS:
  190. disable_skin_borders = !data;
  191. break;
  192. case IPC_DISABLESKINCURSORS:
  193. disable_skin_cursors = data;
  194. break;
  195. case IPC_GETSKINCURSORS:
  196. return ((INT)data >= 0 && (INT)data < N_CURSORS && config_usecursors && !disable_skin_cursors) ? (LRESULT)Skin_Cursors[(INT)data] : NULL;
  197. case IPC_STATS_LIBRARY_ITEMCNT:
  198. stats.SetStat(Stats::LIBRARY_SIZE, data);
  199. return 0;
  200. case IPC_GETOUTPUTPLUGIN:
  201. return reinterpret_cast<LRESULT>(config_outname);
  202. case IPC_GETLANGUAGEPACKINSTANCE:
  203. // changed to check on LOWORD(data) in 5.51+ since we can take extra params in hiword for data==5
  204. if (LOWORD(data) == 1) return (language_pack_instance == hMainInstance);
  205. else if (LOWORD(data) == 2) return reinterpret_cast<LRESULT>(LANGDIR);
  206. else if (LOWORD(data) == 3) return reinterpret_cast<LRESULT>(lang_directory);
  207. else if (LOWORD(data) == 4)
  208. {
  209. static wchar_t lngfilename[MAX_PATH] = {0};
  210. // cache the result once done - no point in re-generating it when not needed
  211. if(!lngfilename[0])
  212. {
  213. if(config_langpack[0])
  214. {
  215. // strip off the lng/wlz from the file so it matches with the config display
  216. lstrcpynW(lngfilename, config_langpack, MAX_PATH);
  217. wchar_t* p = extensionW(lngfilename);
  218. if(p) *CharPrevW(lngfilename, p) = 0;
  219. }
  220. else
  221. {
  222. // otherwise set it to the default
  223. lstrcpynW(lngfilename, L"English (US)", MAX_PATH);
  224. }
  225. }
  226. return reinterpret_cast<LRESULT>(lngfilename);
  227. }
  228. else if (LOWORD(data) == 5)
  229. {
  230. return reinterpret_cast<LRESULT>(langManager->GetLanguageIdentifier(HIWORD(data)));
  231. }
  232. return reinterpret_cast<LRESULT>(language_pack_instance);
  233. case IPC_SET_PE_WIDTHHEIGHT:
  234. {
  235. POINT *pt = (POINT *)data;
  236. config_pe_width = pt->x;
  237. if (config_pe_height != 14)
  238. {
  239. config_pe_height = pt->y;
  240. if (hPLVisWindow)
  241. {
  242. int x, y, w, h;
  243. x = config_pe_width - 150 - 75 + 2;
  244. y = config_pe_height - 26;
  245. w = (config_pe_width >= 350 && config_pe_height != 14 ? 72 : 0);
  246. h = 16;
  247. SetWindowPos(hPLVisWindow, 0, x, y, w, h, SWP_NOZORDER | SWP_NOACTIVATE);
  248. }
  249. }
  250. else
  251. config_pe_height_ws = pt->y;
  252. // update the position of the tooltip on window resize
  253. set_pl_wnd_tooltip();
  254. return 0;
  255. }
  256. case IPC_TRANSLATEACCELERATOR:
  257. return 0;
  258. case IPC_FORMAT_TITLE:
  259. if (data)
  260. {
  261. waFormatTitle *p = (waFormatTitle*)data;
  262. FormatTitle(p);
  263. }
  264. return 0;
  265. case IPC_FORMAT_TITLE_EXTENDED:
  266. if (data)
  267. {
  268. waFormatTitleExtended *p = (waFormatTitleExtended *)data;
  269. FormatTitleExtended(p);
  270. }
  271. return 0;
  272. case IPC_HOOK_TITLES:
  273. return 0;
  274. case IPC_HOOK_TITLESW:
  275. if (data)
  276. {
  277. waHookTitleStructW *hts = (waHookTitleStructW *)data;
  278. return FormatTitle(hts);
  279. }
  280. // hookable
  281. return 0;
  282. case IPC_FF_ISMAINWND:
  283. return 0;
  284. case IPC_ISVISRUNNING:
  285. return vis_running();
  286. case IPC_SETRATING:
  287. {
  288. LRESULT ret = sendMlIpc(ML_IPC_SETRATING, data);
  289. if (!ret)
  290. {
  291. wchar_t fn[FILENAME_SIZE] = {0};
  292. if (!PlayList_getitem2W(PlayList_getPosition(), fn, NULL))
  293. {
  294. wchar_t buf[64] = {0};
  295. if (data > 0)
  296. StringCchPrintfW(buf, 64, L"%d", data);
  297. else
  298. buf[0] = 0;
  299. in_set_extended_fileinfoW(fn, L"rating", buf);
  300. in_write_extended_fileinfo();
  301. }
  302. }
  303. return ret;
  304. }
  305. case IPC_GETRATING:
  306. {
  307. LRESULT ret = sendMlIpc(ML_IPC_GETRATING, 0);
  308. // deal with no ml being present and querying the rating of a file from the tag (if possible)
  309. // as well as getting a zero rating which could mean that it's not present in the library
  310. if (!ret && !got_ml)
  311. {
  312. wchar_t fn[FILENAME_SIZE] = {0};
  313. if (!PlayList_getitem2W(PlayList_getPosition(), fn, NULL))
  314. {
  315. wchar_t buf[64] = {0};
  316. in_get_extended_fileinfoW(fn, L"rating", buf, 64);
  317. ret = _wtoi(buf);
  318. }
  319. }
  320. return ret;
  321. }
  322. case IPC_GETVISWND:
  323. return reinterpret_cast<LRESULT>(hExternalVisWindow);
  324. case IPC_SETVISWND:
  325. if (hExternalVisWindow != (HWND)data)
  326. {
  327. hExternalVisWindow = (HWND)data;
  328. vis_setextwindow(hExternalVisWindow);
  329. }
  330. break;
  331. case IPC_GETTIMEDISPLAYMODE:
  332. return config_timeleftmode;
  333. case IPC_ISDOUBLESIZE:
  334. return config_dsize;
  335. case IPC_SPAWNEQPRESETMENU:
  336. if (data)
  337. {
  338. waSpawnMenuParms *p = (waSpawnMenuParms*)data;
  339. int x = DoTrackPopup(GetSubMenu(top_menu, 1), TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RETURNCMD, p->xpos, p->ypos, p->wnd);
  340. if (x) SendMessageW(hEQWindow, WM_COMMAND, x, 0);
  341. }
  342. return 0;
  343. case IPC_SETPLEDITCOLORS:
  344. if (data)
  345. {
  346. waSetPlColorsStruct *p = (waSetPlColorsStruct *)data;
  347. if (p->numElems && p->elems) memcpy(Skin_PLColors, p->elems, 4*min(p->numElems, sizeof(Skin_PLColors) / sizeof(Skin_PLColors[0])));
  348. if (p->bm) draw_set_plbm(p->bm);
  349. draw_reinit_plfont(0);
  350. if (config_pe_open) InvalidateRect(hPLWindow, NULL, FALSE);
  351. }
  352. return 0;
  353. case IPC_ADDBOOKMARK:
  354. {
  355. static char *narrowBMfile=0;
  356. static char *narrowBMfile8=0;
  357. if (!data && !narrowBMfile)
  358. narrowBMfile = _strdup(AutoCharFn(BOOKMARKFILE));
  359. if(data == 666 && !narrowBMfile8)
  360. narrowBMfile8 = _strdup(AutoCharFn(BOOKMARKFILE8));
  361. return (data == 666?reinterpret_cast<LRESULT>(narrowBMfile8):reinterpret_cast<LRESULT>(narrowBMfile));
  362. }
  363. case IPC_ADDBOOKMARKW:
  364. return (data == 666?reinterpret_cast<LRESULT>(BOOKMARKFILE8):reinterpret_cast<LRESULT>(BOOKMARKFILE));
  365. case IPC_OPENPREFSTOPAGE:
  366. if (data != -1) prefs_last_page = data;
  367. prefs_dialog(1);
  368. return 0;
  369. case IPC_ISMAINWNDVISIBLE: return config_mw_open;
  370. case IPC_GETSADATAFUNC:
  371. if (data == 0) return reinterpret_cast<LRESULT>(export_sa_get_deprecated);
  372. else if (data == 1) return reinterpret_cast<LRESULT>(export_sa_setreq);
  373. else if (data == 2) return reinterpret_cast<LRESULT>(export_sa_get);
  374. return 0;
  375. case IPC_GETVUDATAFUNC:
  376. if (data == 0) return reinterpret_cast<LRESULT>(export_vu_get);
  377. return 0;
  378. case IPC_CB_MISC:
  379. switch (data)
  380. {
  381. case IPC_CB_MISC_STATUS:
  382. if (NULL != g_dialog_box_parent)
  383. {
  384. wchar_t title[512] = {0};
  385. GetWindowTextW(hMainWindow, title, sizeof(title));
  386. SetWindowTextW(g_dialog_box_parent, title);
  387. }
  388. break;
  389. }
  390. return 0;
  391. case IPC_CB_GETTOOLTIP:
  392. return 0;
  393. case IPC_CB_GETTOOLTIPW:
  394. return 0;
  395. case IPC_GETWND:
  396. if (data == IPC_GETWND_EQ) return reinterpret_cast<LRESULT>(hEQWindow);
  397. if (data == IPC_GETWND_PE) return reinterpret_cast<LRESULT>(hPLWindow);
  398. //if (data == IPC_GETWND_MB) return reinterpret_cast<LRESULT>(hMBWindow);
  399. //if (data == IPC_GETWND_VIDEO) return reinterpret_cast<LRESULT>(hVideoWindow);
  400. return 0;
  401. case IPC_ISWNDVISIBLE:
  402. if (data == IPC_GETWND_EQ) return config_eq_open;
  403. if (data == IPC_GETWND_PE) return config_pe_open;
  404. //if (data == IPC_GETWND_MB) return config_mb_open;
  405. //if (data == IPC_GETWND_VIDEO) return config_video_open;
  406. return 0;
  407. case IPC_GET_EXTLIST:
  408. if (data == 1) return reinterpret_cast<LRESULT>(in_getfltstr());
  409. return reinterpret_cast<LRESULT>(in_getextlist());
  410. case IPC_GET_EXTLISTW:
  411. if (data == 1) return reinterpret_cast<LRESULT>(in_getfltstrW(FALSE));
  412. return reinterpret_cast<LRESULT>(in_getextlistW());
  413. case IPC_GET_PLAYLIST_EXTLISTW:
  414. {
  415. if (!data)
  416. {
  417. static wchar_t extStr[1024] = {0};
  418. if (!extStr[0])
  419. {
  420. playlistManager->GetExtensionList(extStr, ARRAYSIZE(extStr));
  421. }
  422. return reinterpret_cast<LRESULT>(extStr);
  423. }
  424. else if (data == 1)
  425. {
  426. static wchar_t fltStr[1024] = {0};
  427. if (!fltStr[0])
  428. {
  429. playlistManager->GetFilterList(fltStr, ARRAYSIZE(fltStr));
  430. }
  431. return reinterpret_cast<LRESULT>(fltStr);
  432. }
  433. else if (data == 2)
  434. {
  435. // TODO if a playlist writer service is implemented then update
  436. // this so we're not using a hard-coded implementation
  437. static wchar_t extSaveStr[1024] = {L"*.M3U;*.PLS;*.M3U8\0\0"};
  438. return reinterpret_cast<LRESULT>(extSaveStr);
  439. }
  440. else if (data == 3)
  441. {
  442. // TODO if a playlist writer service is implemented then update
  443. // this so we're not using a hard-coded implementation
  444. static wchar_t fltSaveStr[1024] = {0};
  445. if (!fltSaveStr[0])
  446. {
  447. wchar_t *fStr = fltSaveStr;
  448. ZeroMemory(fltSaveStr, sizeof(fltSaveStr));
  449. getStringW(IDS_PLAYLIST_FILTER_STRING, fltSaveStr, MAX_PATH);
  450. // store the filter string with | separators so that parts can be translated as needed
  451. // (\0 or more \0000 will work but it's not reliable to work with that - the pipe is a
  452. // a work around from mfc apps wanting to do what we want for language support)
  453. while(fStr && *fStr)
  454. {
  455. wchar_t* rfsStr = 0;
  456. if(*fStr == L'|')
  457. {
  458. rfsStr = fStr;
  459. }
  460. fStr = CharNextW(fStr);
  461. if(rfsStr)
  462. {
  463. *rfsStr = 0;
  464. }
  465. }
  466. }
  467. return reinterpret_cast<LRESULT>(fltSaveStr);
  468. }
  469. return 0;
  470. }
  471. case IPC_GET_GENSKINBITMAP:
  472. {
  473. if (!data) return reinterpret_cast<LRESULT>(draw_LBitmap(MAKEINTRESOURCE(IDB_GENEX), L"genex.bmp"));
  474. if (data == 1)
  475. {
  476. return reinterpret_cast<LRESULT>(GetFontName());
  477. }
  478. else if (data == 2)
  479. {
  480. return atoi(getString(IDS_PLFONT_CHARSET, NULL, 0));
  481. }
  482. else if (data == 3)
  483. {
  484. return ScaleY(config_pe_fontsize);
  485. }
  486. else if (data == 4)
  487. {
  488. return Skin_PLColors[1];
  489. }
  490. return 0;
  491. }
  492. case IPC_REMOVE_PREFS_DLG:
  493. {
  494. prefsDlgRec *t = (prefsDlgRec *)data;
  495. //g_piprefsdlgs.eraseObject(t);
  496. auto it = std::find(g_piprefsdlgs.begin(), g_piprefsdlgs.end(), t);
  497. if (it != g_piprefsdlgs.end())
  498. {
  499. g_piprefsdlgs.erase(it);
  500. }
  501. prefs_liveDlgRemove(t);
  502. }
  503. return 0;
  504. case IPC_ADD_PREFS_DLG:
  505. case IPC_ADD_PREFS_DLGW:
  506. {
  507. prefsDlgRec *p = (prefsDlgRec *)data;
  508. p->next = (which == IPC_ADD_PREFS_DLG ? 0 : PREFS_UNICODE);
  509. // we use the dialog proc for the preferences to determine the hinstance of the module and
  510. // use that to then determine if we have gen_crasher.dll or not to move to the very bottom
  511. MEMORY_BASIC_INFORMATION mbi = {0};
  512. if(VirtualQuery(p->proc, &mbi, sizeof(mbi)))
  513. {
  514. if (GetModuleHandleW(L"gen_crasher.dll") == (HINSTANCE)mbi.AllocationBase)
  515. {
  516. p->where = -2;
  517. }
  518. }
  519. g_piprefsdlgs.push_back(p);
  520. prefs_liveDlgAdd(p);
  521. }
  522. return 0;
  523. case IPC_UPDATE_PREFS_DLG:
  524. case IPC_UPDATE_PREFS_DLGW:
  525. {
  526. prefsDlgRec *p = (prefsDlgRec *)data;
  527. p->next = (which == IPC_UPDATE_PREFS_DLG ? 0 : PREFS_UNICODE);
  528. prefs_liveDlgUpdate(p);
  529. }
  530. return 0;
  531. case IPC_ADJUST_OPTIONSMENUPOS:
  532. if (data == -1) g_mm_optionsbase_adj--;
  533. if (data == 1) g_mm_optionsbase_adj++;
  534. return g_mm_optionsbase_adj;
  535. case IPC_ADJUST_FFWINDOWSMENUPOS:
  536. if (data == -1) g_mm_ffwindowsbase_adj--;
  537. if (data == 1) g_mm_ffwindowsbase_adj++;
  538. return g_mm_ffwindowsbase_adj;
  539. case IPC_ADJUST_FFOPTIONSMENUPOS:
  540. if (data == -1) g_mm_ffoptionsbase_adj--;
  541. if (data == 1) g_mm_ffoptionsbase_adj++;
  542. return g_mm_ffoptionsbase_adj;
  543. case IPC_GET_HMENU:
  544. if (data == -1) return reinterpret_cast<LRESULT>(top_menu);
  545. if (data == 0) return reinterpret_cast<LRESULT>(main_menu);
  546. if (data > 0 && data < 11) return reinterpret_cast<LRESULT>(GetSubMenu(v5_top_menu, data - 1));
  547. return 0;
  548. case IPC_GETUNCOMPRESSINTERFACE:
  549. if (data == 0x10100000)
  550. return reinterpret_cast<LRESULT>(&inflate_struct);
  551. return reinterpret_cast<LRESULT>(uncompress);
  552. case IPC_ENABLEDISABLE_ALL_WINDOWS:
  553. EnableWindow(hwnd, data != 0xdeadbeef);
  554. EnableWindow(hPLWindow, data != 0xdeadbeef);
  555. EnableWindow(hEQWindow, data != 0xdeadbeef);
  556. //EnableWindow(hMBWindow,data!=0xdeadbeef);
  557. //EnableWindow(hVideoWindow,data!=0xdeadbeef);
  558. return 0;
  559. case IPC_RESTARTWINAMP:
  560. case IPC_RESTARTSAFEWINAMP:
  561. {
  562. g_restartonquit = (1 + (which == IPC_RESTARTSAFEWINAMP));
  563. Main_OnClose(hwnd);
  564. }
  565. return 0;
  566. case IPC_UPDTITLE:
  567. g_need_titleupd = 1;
  568. return 0;
  569. case IPC_REFRESHPLCACHE:
  570. {
  571. const wchar_t *prefix = (const wchar_t *)data;
  572. int t = PlayList_getlength();
  573. int x;
  574. if (prefix)
  575. {
  576. wchar_t filename[FILENAME_SIZE] = {0};
  577. int prefixLen = lstrlenW(prefix);
  578. for (x = 0; x < t; x ++)
  579. {
  580. PlayList_getitem(x, filename, 0);
  581. if (!_wcsnicmp(prefix, filename, prefixLen))
  582. PlayList_setcached(x, 0);
  583. }
  584. }
  585. else
  586. {
  587. for (x = 0; x < t; x ++)
  588. PlayList_setcached(x, 0);
  589. }
  590. return 0;
  591. }
  592. case IPC_CHANGECURRENTFILE:
  593. PlayList_setcurrent(AutoWideFn((const char *)data), PlayList_gettitle(AutoWide((const char*)data), 1));
  594. SendMessageW(hPLWindow, WM_USER + 1, 0, 0);
  595. return 0;
  596. case IPC_CHANGECURRENTFILEW:
  597. PlayList_setcurrent((const wchar_t *)data, PlayList_gettitle((const wchar_t *)data, 1));
  598. SendMessageW(hPLWindow, WM_USER + 1, 0, 0);
  599. return 0;
  600. case IPC_ISFULLSTOP:
  601. return g_fullstop;
  602. case IPC_GETEQDATA:
  603. ldata = data;
  604. if (data >= 0 && data <= 9) return eq_tab[data];
  605. if (data == 10) return config_preamp;
  606. if (data == 11) return config_use_eq;
  607. if (data == 12) return config_autoload_eq;
  608. return 0;
  609. case IPC_SETEQDATA:
  610. {
  611. int thisone = ldata; // compatability mode, shouldnt use anymore
  612. if ((data & 0xFF000000) == 0xDB000000) thisone = (data >> 16) & 0xFF;
  613. data &= 0xFFFF;
  614. if (thisone >= 0 && thisone <= 9) eq_tab[thisone] = (unsigned char)data;
  615. else if (thisone == 10) config_preamp = (unsigned char)data;
  616. else if (thisone == 11) config_use_eq = (unsigned char)data;
  617. else if (thisone == 12) config_autoload_eq = (unsigned char)data;
  618. if (thisone == 11 || thisone == 12) draw_eq_onauto(config_use_eq, config_autoload_eq, 0, 0);
  619. if (thisone != 12) eq_set(config_use_eq, (char *)eq_tab, config_preamp);
  620. if (config_eq_open)
  621. {
  622. if (thisone >= 0 && thisone <= 10)
  623. {
  624. draw_eq_slid(thisone == 10 ? 0 : thisone + 1, data, 0);
  625. draw_eq_graphthingy();
  626. }
  627. }
  628. PostMessageW(hMainWindow, WM_WA_IPC, IPC_CB_MISC_EQ, IPC_CB_MISC);
  629. }
  630. return 0;
  631. case IPC_GETLISTPOS:
  632. return PlayList_getPosition();
  633. case IPC_GETNEXTLISTPOS:
  634. return PlayList_getNextPosition();
  635. case IPC_GETINFO:
  636. if (data == 0) return g_srate;
  637. if (data == 1) return g_brate;
  638. if (data == 2) return g_nch;
  639. if (data == 5) return g_srate_exact;
  640. return 0;
  641. case IPC_SETSKIN:
  642. if (data && lstrlenA((char *)data))
  643. {
  644. AutoWide dataW((char *)data);
  645. if (_wcsicmp(config_skin, dataW))
  646. {
  647. StringCchCopyW(config_skin, MAX_PATH, dataW);
  648. }
  649. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_REFRESHSKIN, 0);
  650. }
  651. return 0;
  652. case IPC_SETSKINW:
  653. if (data && lstrlenW((wchar_t *)data))
  654. {
  655. if (_wcsicmp(config_skin, (wchar_t *)data))
  656. {
  657. StringCchCopyW(config_skin, MAX_PATH, (wchar_t *)data);
  658. }
  659. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_REFRESHSKIN, 0);
  660. }
  661. return 0;
  662. case IPC_GETSKINW:
  663. {
  664. if (data)
  665. StringCchCopyW((wchar_t *)data, MAX_PATH, skin_directory);
  666. return (LRESULT)config_skin;
  667. }
  668. case IPC_GETSKIN:
  669. {
  670. if (data)
  671. WideCharToMultiByteSZ(CP_ACP, 0, skin_directory, -1, (char *)data, MAX_PATH, 0, 0);
  672. static char config_skinA[MAX_PATH];
  673. WideCharToMultiByteSZ(CP_ACP, 0, config_skin, -1, config_skinA, MAX_PATH,0 ,0);
  674. return (LRESULT)config_skinA;
  675. }
  676. case IPC_EXECPLUG:
  677. if (data) vis_start(hwnd, AutoWide((char *)data));
  678. return 0;
  679. case IPC_GETPLAYLISTFILE:
  680. {
  681. if (!PlayList_getitem2(data, fn, NULL)) return (LRESULT)fn;
  682. return 0;
  683. }
  684. case IPC_GETPLAYLISTFILEW:
  685. {
  686. if (!PlayList_getitem2W(data, fnW, NULL)) return (LRESULT)fnW;
  687. return 0;
  688. }
  689. case IPC_GETPLAYLISTTITLE:
  690. {
  691. if (!PlayList_getitem2(data, NULL, fn)) return (LRESULT)fn;
  692. return 0;
  693. }
  694. case IPC_GETPLAYLISTTITLEW:
  695. {
  696. if (!PlayList_getitem2W(data, NULL, fnW)) return (LRESULT)fnW;
  697. return 0;
  698. }
  699. case IPC_GETVERSION:
  700. return APP_VERSION_NUM;
  701. case IPC_GETVERSIONSTRING:
  702. return (LRESULT)app_version_string;
  703. case IPC_OPEN_URL:
  704. {
  705. char *url = (char *)data;
  706. if ((url[0] == 'h' || url[0] == 'H') && url[1] == 0) // unicode!
  707. {
  708. myOpenURL(NULL, (wchar_t *)url);
  709. }
  710. else // ANSI
  711. {
  712. // copes with trying to open local files e.g. local help
  713. // as above checking would otherwise force it always to
  714. // be treated as ansi even if sent as a unicode file:///
  715. if(PathFileExistsW((wchar_t *)url))
  716. {
  717. myOpenURL(NULL, (wchar_t *)url);
  718. }
  719. else
  720. {
  721. myOpenURL(NULL, AutoWide(url));
  722. }
  723. }
  724. return 0;
  725. }
  726. case IPC_GETREGISTEREDVERSION:
  727. if (((unsigned int) data) > 0xffff)
  728. {
  729. unsigned long *p = (unsigned long *)data;
  730. p[2] = 0;
  731. static unsigned long key[4] = { 31337, 0xf00d, 0xdead, 0xbeef}; //fucko: hide this a bit
  732. tealike_crappy_code(p, key);
  733. p[2] = 2;
  734. }
  735. else if (!data)
  736. {
  737. prefs_last_page = 20;
  738. prefs_dialog(1);
  739. }
  740. return 0;
  741. case IPC_IS_SAFEMODE:
  742. if (g_safeMode == 2)
  743. return 2;
  744. return (!g_safeMode);
  745. case IPC_SETPLAYLISTPOS:
  746. PlayList_setposition(data);
  747. InvalidateRect(hPLWindow, NULL, FALSE);
  748. return 0;
  749. case IPC_GETLISTLENGTH:
  750. return PlayList_getlength();
  751. case IPC_SETVOLUME:
  752. if (data == -666) return config_volume;
  753. config_volume = (unsigned char)data;
  754. if (config_volume < 0) config_volume = 0;
  755. if (config_volume > 255) config_volume = 255;
  756. in_setvol(config_volume);
  757. draw_volumebar(config_volume, 0);
  758. update_volume_text(-2);
  759. return 0;
  760. case IPC_SETPANNING:
  761. if (data == -666) return config_pan;
  762. config_pan = (char)data;
  763. if (config_pan < -127) config_pan = -127;
  764. if (config_pan > 127) config_pan = 127;
  765. draw_panbar(config_pan, 0);
  766. in_setpan(config_pan);
  767. update_panning_text(-2);
  768. return 0;
  769. case IPC_WRITEPLAYLIST:
  770. if (plneedsave)
  771. {
  772. plneedsave = 0;
  773. savem3ufn(OLD_M3U_FILE, 0, 1);
  774. savem3ufn(M3U_FILE, 0, 1);
  775. }
  776. return PlayList_getlength() ? PlayList_getPosition() : -1;
  777. case IPC_INFOBOX:
  778. {
  779. infoBoxParam *p = (infoBoxParam*)data;
  780. int a = in_infobox(p->parent, AutoWideFn(p->filename));
  781. MSG msg;
  782. Sleep(100);
  783. while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE)); //eat return
  784. return a;
  785. }
  786. case IPC_INFOBOXW:
  787. {
  788. infoBoxParamW *p = (infoBoxParamW*)data;
  789. int a = in_infobox(p->parent, p->filename);
  790. MSG msg;
  791. Sleep(100);
  792. while (PeekMessage(&msg, NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE)); //eat return
  793. return a;
  794. }
  795. case IPC_GETMLINIFILE:
  796. {
  797. static char *narrowMLINIfile=0;
  798. if (!narrowMLINIfile)
  799. narrowMLINIfile = _strdup(AutoCharFn(ML_INI_FILE));
  800. return reinterpret_cast<LRESULT>(narrowMLINIfile);
  801. }
  802. case IPC_GETMLINIFILEW:
  803. return reinterpret_cast<LRESULT>(ML_INI_FILE);
  804. case IPC_GETSHAREDDLLDIRECTORYW:
  805. return reinterpret_cast<LRESULT>(SHAREDDIR);
  806. case IPC_GETINIFILE:
  807. {
  808. static char *narrowINIfile=0;
  809. if (!narrowINIfile)
  810. narrowINIfile = _strdup(AutoCharFn(INI_FILE));
  811. return reinterpret_cast<LRESULT>(narrowINIfile);
  812. }
  813. case IPC_GETINIFILEW:
  814. return reinterpret_cast<LRESULT>(INI_FILE);
  815. case IPC_GETINIDIRECTORY:
  816. {
  817. static char *narrowINIdir=0;
  818. if (!narrowINIdir)
  819. narrowINIdir = _strdup(AutoCharFn(CONFIGDIR));
  820. return reinterpret_cast<LRESULT>(narrowINIdir);
  821. }
  822. case IPC_GETINIDIRECTORYW:
  823. return reinterpret_cast<LRESULT>(CONFIGDIR);
  824. case IPC_GETPLUGINDIRECTORY:
  825. {
  826. static char *narrowPlugindir=0;
  827. if (!narrowPlugindir)
  828. narrowPlugindir = _strdup(AutoCharFn(PLUGINDIR));
  829. return reinterpret_cast<LRESULT>(narrowPlugindir);
  830. }
  831. case IPC_GETPLUGINDIRECTORYW:
  832. return reinterpret_cast<LRESULT>(PLUGINDIR);
  833. case IPC_GETM3UDIRECTORY:
  834. {
  835. static char *narrowM3Udir=0;
  836. if (!narrowM3Udir)
  837. narrowM3Udir = _strdup(AutoCharFn(M3UDIR));
  838. return reinterpret_cast<LRESULT>(narrowM3Udir);
  839. }
  840. case IPC_GETM3UDIRECTORYW:
  841. return reinterpret_cast<LRESULT>(M3UDIR);
  842. case IPC_GETVISDIRECTORYW:
  843. return reinterpret_cast<LRESULT>(VISDIR);
  844. case IPC_GETSKINDIRECTORYW:
  845. return reinterpret_cast<LRESULT>(SKINDIR);
  846. case IPC_GETDSPDIRECTORYW:
  847. return reinterpret_cast<LRESULT>(DSPDIR);
  848. case IPC_OPENURLBOX:
  849. return getNewLocation( -1, (HWND)data);
  850. //FG> 5/19/03 -- added an ipc call similar to WINAMP_FILE_PLAY but with a parent HWND param, like OPENURLBOX
  851. case IPC_OPENFILEBOX:
  852. getNewFile(1, (HWND)data, 0);
  853. plEditRefresh();
  854. return 1;
  855. //FG> 5/19/03 -- added an ipc call similar to WINAMP_FILE_DIR but with a parent HWND param, like OPENURLBOX
  856. case IPC_OPENDIRBOX:
  857. {
  858. BROWSEINFOW bi = {0};
  859. wchar_t name[MAX_PATH] = {0};
  860. bi.hwndOwner = (HWND)data;
  861. bi.pszDisplayName = name;
  862. bi.lpszTitle = L"__foo";
  863. bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
  864. bi.lpfn = BrowseCallbackProc;
  865. ITEMIDLIST *idlist = SHBrowseForFolderW(&bi);
  866. if (idlist)
  867. {
  868. wchar_t path[MAX_PATH] = {0};
  869. SHGetPathFromIDListW(idlist, path);
  870. Shell_Free(idlist);
  871. WASABI_API_APP->path_setWorkingPath(path);
  872. PlayList_delete();
  873. PlayList_adddir(path, (config_rofiob&2) ? 0 : 1);
  874. if (config_rofiob&1) PlayList_sort(2, 0);
  875. BeginPlayback();
  876. plEditRefresh();
  877. }
  878. return 1;
  879. }
  880. case IPC_SPAWNBUTTONPOPUP:
  881. {
  882. HMENU hmenu = NULL;
  883. switch (data)
  884. {
  885. case 0:
  886. {
  887. hmenu = GetSubMenu(GetSubMenu(top_menu, 3), 7);
  888. UpdateAudioCDMenus(hmenu);
  889. }
  890. break;
  891. case 1: hmenu = GetSubMenu(GetSubMenu(top_menu, 3), 2); break;
  892. case 2: hmenu = GetSubMenu(GetSubMenu(top_menu, 3), 6); break;
  893. case 3: hmenu = GetSubMenu(GetSubMenu(top_menu, 3), 4); break;
  894. case 4: hmenu = GetSubMenu(GetSubMenu(top_menu, 3), 3); break;
  895. case 5: hmenu = GetSubMenu(GetSubMenu(top_menu, 3), 5); break;
  896. }
  897. if (hmenu != NULL)
  898. {
  899. DWORD msgpos = GetMessagePos();
  900. POINTS pt = MAKEPOINTS(msgpos);
  901. DoTrackPopup(hmenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, hwnd);
  902. }
  903. return 1;
  904. }
  905. //FG> 5/19/03 -- added ipc call to set the parent HWND for open operations (file, dir, url) call with NULL to reset
  906. case IPC_UPDATEDIALOGBOXPARENT:
  907. {
  908. if (g_dialog_box_parent == (HWND)data && IsWindow((HWND)data))
  909. {
  910. RefreshIconicThumbnail();
  911. return 0;
  912. }
  913. // run through otherwise to force an update of things
  914. }
  915. case IPC_SETDIALOGBOXPARENT:
  916. {
  917. UnregisterThumbnailTab(g_dialog_box_parent);
  918. g_dialog_box_parent = (HWND)data;
  919. HWND new_parent = (IsWindow(g_dialog_box_parent) ? g_dialog_box_parent : hMainWindow);
  920. if (IsWindow(prefs_hwnd))
  921. SetWindowLongPtrW(prefs_hwnd, 0xFFFFFFF8, (LONG_PTR)new_parent);
  922. if (IsWindow(about_hwnd))
  923. SetWindowLongPtrW(about_hwnd, 0xFFFFFFF8, (LONG_PTR)new_parent);
  924. if (IsWindow(jump_hwnd))
  925. SetWindowLongPtrW(jump_hwnd, 0xFFFFFFF8, (LONG_PTR)new_parent);
  926. if (IsWindow(jump_hwnd2))
  927. SetWindowLongPtrW(jump_hwnd2, 0xFFFFFFF8, (LONG_PTR)new_parent);
  928. KillTimer(hMainWindow, AEROPEEK);
  929. SetTimer(hMainWindow, AEROPEEK, 250, DialogBoxParentChanged);
  930. return 1;
  931. }
  932. case IPC_GETDIALOGBOXPARENT:
  933. return reinterpret_cast<LRESULT>(IsWindow(g_dialog_box_parent) ? g_dialog_box_parent : hMainWindow);
  934. case IPC_GETPREFSWND:
  935. return reinterpret_cast<LRESULT>((IsWindow(prefs_hwnd) ? prefs_hwnd : NULL));
  936. case IPC_INITIAL_SHOW_STATE:
  937. return g_showcode;
  938. case IPC_PLAYFILE:
  939. {
  940. static char *filename;
  941. if (data > 0xffff)
  942. {
  943. enqueueFileWithMetaStruct *p = (enqueueFileWithMetaStruct*)data;
  944. if ( p->title )
  945. {
  946. wa::strings::wa_string l_ext( p->filename );
  947. PlayList_append_withinfo( AutoWideFn( p->filename ), AutoWide( p->title ), PathFindExtensionW( l_ext.GetW().c_str() ), p->length, 0 );
  948. }
  949. else
  950. PlayList_appendthing(AutoWideFn(p->filename), 0, 0);
  951. plEditRefresh();
  952. }
  953. else if (!data)
  954. {
  955. if (filename)
  956. {
  957. PlayList_appendthing(AutoWideFn(filename), 0, 0);
  958. GlobalFree(filename);
  959. filename = 0;
  960. plEditRefresh();
  961. }
  962. }
  963. else
  964. {
  965. static int i;
  966. if (!i) filename = (char *) GlobalAlloc(GPTR, MAX_PATH);
  967. filename[i++] = (char)data;
  968. }
  969. return 1;
  970. }
  971. case IPC_PLAYFILEW:
  972. {
  973. if ( data > 0xffff )
  974. {
  975. enqueueFileWithMetaStructW *p = (enqueueFileWithMetaStructW *)data;
  976. if ( p->title )
  977. PlayList_append_withinfo( p->filename, p->title, p->ext, p->length, 0 );
  978. else
  979. PlayList_appendthing( p->filename, 0, 0 );
  980. plEditRefresh();
  981. }
  982. return 1;
  983. }
  984. case IPC_PLAYFILEW_NDE:
  985. {
  986. if (data > 0xffff)
  987. {
  988. enqueueFileWithMetaStructW *p = (enqueueFileWithMetaStructW *)data;
  989. if (p->title)
  990. PlayList_append_withinfo(p->filename, p->title, p->ext, p->length, 1);
  991. else
  992. PlayList_appendthing(p->filename, 0, 1);
  993. plEditRefresh();
  994. }
  995. return 1;
  996. }
  997. case IPC_PLAYFILEW_NDE_TITLE:
  998. {
  999. if (data > 0xffff)
  1000. {
  1001. enqueueFileWithMetaStructW *p = (enqueueFileWithMetaStructW *)data;
  1002. if (p->title)
  1003. PlayList_append_withinfo(p->filename, p->title, p->ext, p->length, 3);
  1004. else
  1005. PlayList_appendthing(p->filename, 0, 3);
  1006. plEditRefresh();
  1007. }
  1008. return 1;
  1009. }
  1010. case IPC_CHDIR:
  1011. {
  1012. static char *filename;
  1013. static int i;
  1014. if (!data)
  1015. {
  1016. if (filename)
  1017. {
  1018. filename[i] = 0;
  1019. i = 0;
  1020. SetCurrentDirectoryA(filename);
  1021. GlobalFree(filename);
  1022. filename = 0;
  1023. }
  1024. }
  1025. else
  1026. {
  1027. if (!i) filename = (char *) GlobalAlloc(GPTR, MAX_PATH);
  1028. filename[i++] = (char)data;
  1029. }
  1030. return 1;
  1031. }
  1032. case IPC_DELETE_INT:
  1033. case IPC_DELETE:
  1034. {
  1035. int x = PlayList_getlength() > 0 ? 1 : 0;
  1036. PlayList_delete();
  1037. PlayList_randpos(0);
  1038. plEditRefresh();
  1039. return x;
  1040. }
  1041. case IPC_STARTPLAY_INT:
  1042. case IPC_STARTPLAY:
  1043. BeginPlayback();
  1044. plEditRefresh();
  1045. return 1;
  1046. case IPC_ISPLAYING:
  1047. return (playing ? 1 : 0) | (paused ? 2 : 0);
  1048. case IPC_GETOUTPUTTIME:
  1049. if (!data)
  1050. {
  1051. if (playing) return in_getouttime();
  1052. else return -1;
  1053. }
  1054. else if (data == 1)
  1055. {
  1056. if (!playing || !in_mod) return PlayList_getcurrentlength();
  1057. else return in_mod->GetLength() / 1000;
  1058. }
  1059. else if (data == 2)
  1060. {
  1061. if (!playing || !in_mod) return PlayList_getcurrentlength() * 1000;
  1062. else return in_mod->GetLength();
  1063. }
  1064. return 0;
  1065. case IPC_GETMODULENAME:
  1066. return 0;
  1067. case IPC_JUMPTOTIME:
  1068. if (playing && in_mod && in_mod->is_seekable && !PlayList_ishidden(PlayList_getPosition()))
  1069. {
  1070. int t = data;
  1071. if (t < 0) t = 0;
  1072. if (in_seek(t) < 0)
  1073. {
  1074. SendMessageW(hwnd, WM_WA_MPEG_EOF, 0, 0);
  1075. return 1;
  1076. }
  1077. else
  1078. {
  1079. ui_drawtime(in_getouttime() / 1000, 0);
  1080. }
  1081. return 0;
  1082. }
  1083. return -1;
  1084. case IPC_EX_ISRIGHTEXE:
  1085. return stat_isit;
  1086. case IPC_GETHTTPGETTER:
  1087. return (LRESULT)httpRetrieveFile;
  1088. case IPC_GETHTTPGETTERW:
  1089. return (LRESULT)httpRetrieveFileW;
  1090. case IPC_INETAVAILABLE:
  1091. return isInetAvailable();
  1092. case IPC_GET_SHUFFLE:
  1093. return !!config_shuffle;
  1094. case IPC_GET_MANUALPLADVANCE:
  1095. return !config_pladv;
  1096. case IPC_GET_STOP_AFTER_CURRENT:
  1097. return !g_stopaftercur;
  1098. case IPC_GET_REPEAT:
  1099. return !!config_repeat;
  1100. case IPC_SET_SHUFFLE:
  1101. if (!!config_shuffle != !!data)
  1102. {
  1103. SendMessageW(hwnd, WM_COMMAND, WINAMP_FILE_SHUFFLE, 0);
  1104. }
  1105. break;
  1106. case IPC_SET_REPEAT:
  1107. if (!!config_repeat != !!data)
  1108. {
  1109. SendMessageW(hwnd, WM_COMMAND, WINAMP_FILE_REPEAT, 0);
  1110. }
  1111. break;
  1112. case IPC_SET_MANUALPLADVANCE:
  1113. if ((!!config_pladv) != (!data))
  1114. {
  1115. SendMessageW(hwnd, WM_COMMAND, WINAMP_FILE_MANUALPLADVANCE, 0);
  1116. }
  1117. break;
  1118. case IPC_IS_FULLSCREEN:
  1119. return vis_fullscreen;
  1120. case IPC_SET_VIS_FS_FLAG:
  1121. vis_fullscreen = !!data;
  1122. break;
  1123. case IPC_GET_EMBEDIF:
  1124. if (data) return reinterpret_cast<LRESULT>(embedWindow((embedWindowState*)data));
  1125. else return reinterpret_cast<LRESULT>(embedWindow);
  1126. case IPC_SKINWINDOW:
  1127. {
  1128. SKINWINDOWPARAM *swp = (SKINWINDOWPARAM*)data;
  1129. if (NULL == swp || swp->cbSize != sizeof(SKINWINDOWPARAM))
  1130. return 0;
  1131. return SkinWindow(swp->hwndToSkin, swp->windowGuid, swp->flagsEx, swp->callbackFF);
  1132. }
  1133. break;
  1134. case IPC_EMBED_ENUM:
  1135. EnterCriticalSection(&embedcs);
  1136. {
  1137. embedEnumStruct *parms = (embedEnumStruct*)data;
  1138. embedWindowState *p = embedwndlist;
  1139. while (p)
  1140. {
  1141. int x = parms->enumProc(p, parms);
  1142. if (x)
  1143. {
  1144. LeaveCriticalSection(&embedcs);
  1145. return x;
  1146. }
  1147. p = p->link;
  1148. }
  1149. }
  1150. LeaveCriticalSection(&embedcs);
  1151. return 0;
  1152. case IPC_EMBED_ISVALID:
  1153. EnterCriticalSection(&embedcs);
  1154. {
  1155. embedWindowState *p = embedwndlist;
  1156. embedWindowState *parm = (embedWindowState*)data;
  1157. while (p)
  1158. {
  1159. if (p == parm)
  1160. {
  1161. LeaveCriticalSection(&embedcs);
  1162. return 1;
  1163. }
  1164. p = p->link;
  1165. }
  1166. }
  1167. LeaveCriticalSection(&embedcs);
  1168. return 0;
  1169. case IPC_EMBED_ADD_LEGACY:
  1170. EnterCriticalSection(&embedcs);
  1171. {
  1172. embedWindowState *parms = (embedWindowState*)data;
  1173. if (!parms || (((unsigned int)parms) < 65536) || !IsWindow(parms->me)) return 1;
  1174. EMBEDWND *pew = (EMBEDWND*)calloc(1, sizeof(EMBEDWND));
  1175. SetPropW(parms->me, EMBEDWND_PROPW, pew);
  1176. // this makes sure that JTFE won't mess with the windows
  1177. SetPropA(parms->me, "WnShdProcIgnore", (HANDLE)1);
  1178. // do this just incase it's missed off by the plug-in
  1179. parms->flags |= EMBED_FLAGS_LEGACY_WND;
  1180. SetWindowLongPtrW(parms->me, GWLP_USERDATA, (LONG_PTR)parms);
  1181. EnterCriticalSection(&embedcs);
  1182. GUID temp = GUID_NULL;
  1183. if (parms->flags & EMBED_FLAGS_GUID)
  1184. temp = parms->guid;
  1185. memset(parms->extra_data, 0, sizeof(parms->extra_data));
  1186. if (parms->flags & EMBED_FLAGS_GUID)
  1187. parms->guid = temp;
  1188. parms->link = embedwndlist;
  1189. embedwndlist = parms;
  1190. embedwndlist_cnt++;
  1191. LeaveCriticalSection(&embedcs);
  1192. }
  1193. LeaveCriticalSection(&embedcs);
  1194. return 0;
  1195. case IPC_EMBED_REMOVE_LEGACY:
  1196. EnterCriticalSection(&embedcs);
  1197. {
  1198. embedWindowState *parm = (embedWindowState*)data;
  1199. if (parm)
  1200. {
  1201. EnterCriticalSection(&embedcs);
  1202. embedWindowState *p=embedwndlist;
  1203. if (p == parm)
  1204. {
  1205. embedwndlist = parm->link;// remove ourselves
  1206. embedwndlist_cnt--;
  1207. }
  1208. else
  1209. {
  1210. while (p)
  1211. {
  1212. if (p->link == parm)
  1213. {
  1214. p->link = parm->link;
  1215. embedwndlist_cnt--;
  1216. break;
  1217. }
  1218. p=p->link;
  1219. }
  1220. }
  1221. LeaveCriticalSection(&embedcs);
  1222. EMBEDWND *pew = GetEmbedWnd(parm->me);
  1223. if (pew)
  1224. {
  1225. RemovePropW(parm->me, EMBEDWND_PROPW);
  1226. free(pew);
  1227. }
  1228. }
  1229. }
  1230. LeaveCriticalSection(&embedcs);
  1231. return 0;
  1232. case IPC_EMBED_UPDATE_LEGACY_POS:
  1233. EnterCriticalSection(&embedcs);
  1234. {
  1235. embedWindowState *p = embedwndlist;
  1236. embedWindowState *parm = (embedWindowState*)data;
  1237. while (p)
  1238. {
  1239. if (p == parm)
  1240. {
  1241. CopyRect(&p->r, &parm->r);
  1242. return 1;
  1243. }
  1244. p = p->link;
  1245. }
  1246. }
  1247. LeaveCriticalSection(&embedcs);
  1248. return 0;
  1249. case IPC_GET_EMBED_SNAPFUNC:
  1250. if (data) return reinterpret_cast<LRESULT>(SnapWindowToAllWindows);
  1251. else return reinterpret_cast<LRESULT>(SnapToScreen);
  1252. case IPC_GET_EXTENDED_FILE_INFO_HOOKABLE:
  1253. {
  1254. }
  1255. // fall through
  1256. case IPC_GET_EXTENDED_FILE_INFO:
  1257. {
  1258. extendedFileInfoStruct *efis = (extendedFileInfoStruct *)data;
  1259. if (efis && efis->filename)
  1260. return in_get_extended_fileinfo(efis->filename, efis->metadata, efis->ret, efis->retlen);
  1261. else
  1262. return 0;
  1263. }
  1264. case IPC_GET_EXTENDED_FILE_INFOW_HOOKABLE:
  1265. {
  1266. extendedFileInfoStructW *efis = (extendedFileInfoStructW *)data;
  1267. if (JSAPI2::callbackManager.OverrideMetadata(efis->filename, efis->metadata, efis->ret, efis->retlen))
  1268. return 1;
  1269. }
  1270. // fall through
  1271. case IPC_GET_EXTENDED_FILE_INFOW:
  1272. {
  1273. extendedFileInfoStructW *efis = (extendedFileInfoStructW *)data;
  1274. if (efis && efis->filename)
  1275. return in_get_extended_fileinfoW(efis->filename, efis->metadata, efis->ret, efis->retlen);
  1276. else
  1277. return 0;
  1278. }
  1279. case IPC_GET_BASIC_FILE_INFO:
  1280. {
  1281. basicFileInfoStruct *bfis = (basicFileInfoStruct*)data;
  1282. if (bfis->quickCheck == 2 && config_riol == 1) bfis->quickCheck = 0;
  1283. AutoWideFn wfn(bfis->filename);
  1284. if (PathIsURLW(wfn))
  1285. {
  1286. const wchar_t *cachedTitle = PlayList_GetCachedTitle(wfn);
  1287. if (cachedTitle && cachedTitle[0])
  1288. {
  1289. lstrcpynA(bfis->title, AutoChar(cachedTitle), bfis->titlelen);
  1290. bfis->length = PlayList_get_lastlen();
  1291. return 0;
  1292. }
  1293. }
  1294. lstrcpynA(bfis->title, AutoChar(remove_urlcodesW(PlayList_gettitle(wfn, !bfis->quickCheck))), bfis->titlelen);
  1295. bfis->length = PlayList_get_lastlen();
  1296. return 0;
  1297. }
  1298. case IPC_GET_BASIC_FILE_INFOW:
  1299. {
  1300. basicFileInfoStructW *bfis = (basicFileInfoStructW *)data;
  1301. if ( bfis->quickCheck == 2 && config_riol == 1 ) bfis->quickCheck = 0;
  1302. if ( bfis->filename && *bfis->filename && PathIsURLW( bfis->filename ) )
  1303. {
  1304. const wchar_t *cachedTitle = PlayList_GetCachedTitle( bfis->filename );
  1305. if ( cachedTitle && cachedTitle[ 0 ] )
  1306. {
  1307. lstrcpynW( bfis->title, cachedTitle, bfis->titlelen );
  1308. bfis->length = PlayList_get_lastlen();
  1309. return 0;
  1310. }
  1311. }
  1312. lstrcpynW( bfis->title, remove_urlcodesW( PlayList_gettitle( bfis->filename, !bfis->quickCheck ) ), bfis->titlelen );
  1313. bfis->length = PlayList_get_lastlen();
  1314. return 0;
  1315. }
  1316. case IPC_SET_EXTENDED_FILE_INFO:
  1317. {
  1318. extendedFileInfoStruct *efis = (extendedFileInfoStruct *)data;
  1319. return in_set_extended_fileinfo(efis->filename, efis->metadata, efis->ret);
  1320. }
  1321. case IPC_SET_EXTENDED_FILE_INFOW:
  1322. {
  1323. extendedFileInfoStructW *efis = (extendedFileInfoStructW *)data;
  1324. return in_set_extended_fileinfoW(efis->filename, efis->metadata, efis->ret);
  1325. }
  1326. case IPC_WRITE_EXTENDED_FILE_INFO:
  1327. return in_write_extended_fileinfo();
  1328. case IPC_CONVERTFILE:
  1329. return convert_file((convertFileStruct *)data);
  1330. case IPC_CONVERTFILEW:
  1331. return convert_fileW((convertFileStructW *)data);
  1332. case IPC_CONVERT_TEST:
  1333. return convert_file_test((convertFileStructW *)data);
  1334. case IPC_CONVERTFILE_END:
  1335. convert_end((convertFileStruct *)data);
  1336. break;
  1337. case IPC_CONVERTFILEW_END:
  1338. convert_endW((convertFileStructW *)data);
  1339. break;
  1340. case IPC_CONVERT_CONFIG:
  1341. return reinterpret_cast<LRESULT>(convert_config((convertConfigStruct *)data));
  1342. case IPC_CONVERT_CONFIG_END:
  1343. convert_config_end((convertConfigStruct *)data);
  1344. break;
  1345. case IPC_CONVERT_CONFIG_ENUMFMTS:
  1346. convert_enumfmts((converterEnumFmtStruct *)data);
  1347. break;
  1348. case IPC_CONVERT_SET_PRIORITY:
  1349. convert_setPriority((convertSetPriority *)data);
  1350. break;
  1351. case IPC_CONVERT_SET_PRIORITYW:
  1352. convert_setPriorityW((convertSetPriorityW *)data);
  1353. break;
  1354. case IPC_CONVERT_CONFIG_SET_ITEM:
  1355. return convert_setConfigItem((convertConfigItem*)data);
  1356. case IPC_CONVERT_CONFIG_GET_ITEM:
  1357. return convert_getConfigItem((convertConfigItem*)data);
  1358. case IPC_PLCMD:
  1359. PE_Cmd((windowCommand*)data);
  1360. break;
  1361. case IPC_GETDROPTARGET:
  1362. return reinterpret_cast<LRESULT>(Ole_getDropTarget());
  1363. #ifdef BURN_SUPPORT
  1364. #if !defined(_WIN64)
  1365. case IPC_BURN_CD:
  1366. return burn_start((burnCDStruct *)data);
  1367. #endif
  1368. #endif
  1369. case IPC_GET_NEXT_PLITEM:
  1370. return -1;
  1371. case IPC_GET_PREVIOUS_PLITEM:
  1372. return -1;
  1373. case IPC_IS_WNDSHADE:
  1374. if (data == -1) return config_windowshade;
  1375. if (data == IPC_GETWND_PE) return config_pe_height == 14;
  1376. if (data == IPC_GETWND_EQ) return config_eq_ws;
  1377. return 0;
  1378. case IPC_SPAWNFILEMENU:
  1379. {
  1380. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1381. return V5_File_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1382. }
  1383. case IPC_SPAWNPLAYMENU:
  1384. {
  1385. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1386. return V5_Play_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1387. }
  1388. case IPC_SPAWNOPTIONSMENU:
  1389. {
  1390. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1391. return V5_Options_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1392. }
  1393. case IPC_SPAWNWINDOWSMENU:
  1394. {
  1395. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1396. return V5_Windows_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1397. }
  1398. case IPC_SPAWNHELPMENU:
  1399. {
  1400. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1401. return V5_Help_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1402. }
  1403. case IPC_SPAWNPEFILEMENU:
  1404. {
  1405. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1406. return V5_PE_File_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1407. }
  1408. case IPC_SPAWNPEPLAYLISTMENU:
  1409. {
  1410. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1411. return V5_PE_Playlist_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1412. }
  1413. case IPC_SPAWNPESORTMENU:
  1414. {
  1415. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1416. return V5_PE_Sort_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1417. }
  1418. case IPC_SPAWNPEHELPMENU:
  1419. {
  1420. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1421. return V5_PE_Help_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1422. }
  1423. case IPC_SPAWNMLFILEMENU:
  1424. {
  1425. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1426. return V5_ML_File_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1427. }
  1428. case IPC_SPAWNMLVIEWMENU:
  1429. {
  1430. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1431. return V5_ML_View_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1432. }
  1433. case IPC_SPAWNMLHELPMENU:
  1434. {
  1435. waSpawnMenuParms2 *p = (waSpawnMenuParms2*)data;
  1436. return V5_ML_Help_Menu(p->wnd, p->xpos, p->ypos, p->width, p->height);
  1437. }
  1438. case IPC_SPAWNPELISTOFPLAYLISTS:
  1439. {
  1440. waSpawnMenuParms *p = (waSpawnMenuParms*)data;
  1441. return V5_PE_ListOfPlaylists_Menu(p->xpos, p->ypos);
  1442. }
  1443. case IPC_GET_UNIQUE_DISPATCH_ID:
  1444. return JSAPI1_GenerateUniqueDispatchId();
  1445. case IPC_ADD_DISPATCH_OBJECT:
  1446. {
  1447. DispatchInfo *info = (DispatchInfo*)data;
  1448. if (NULL != info)
  1449. {
  1450. ExternalCOM *external;
  1451. if (SUCCEEDED(JSAPI1_GetExternal(&external)))
  1452. {
  1453. info->id = external->AddDispatch(info->name, info->dispatch);
  1454. external->Release();
  1455. }
  1456. else
  1457. {
  1458. info->id = 0;
  1459. }
  1460. }
  1461. return 0;
  1462. }
  1463. case IPC_REMOVE_DISPATCH_OBJECT:
  1464. {
  1465. ExternalCOM *external;
  1466. if (SUCCEEDED(JSAPI1_GetExternal(&external)))
  1467. {
  1468. external->RemoveDispatch((DWORD)data);
  1469. external->Release();
  1470. }
  1471. }
  1472. return 0;
  1473. case IPC_GET_PROXY_STRING:
  1474. return reinterpret_cast<LRESULT>(config_proxy);
  1475. case IPC_PLAYLIST_GET_NEXT_SELECTED:
  1476. return PlayList_GetNextSelected(data);
  1477. case IPC_PLAYLIST_GET_SELECTED_COUNT:
  1478. return PlayList_GetSelectedCount();
  1479. case IPC_FILE_TAG_MAY_HAVE_UPDATED:
  1480. {
  1481. extern In_Module *g_in_infobox;
  1482. if (!g_in_infobox)
  1483. PlayList_UpdateTitle(AutoWideFn((const char *)data));
  1484. return 0;
  1485. }
  1486. case IPC_FILE_TAG_MAY_UPDATEW:
  1487. {
  1488. // issue sys callback
  1489. WASABI_API_SYSCB->syscb_issueCallback(SysCallback::META, MetadataCallback::FILE_MAY_UPDATE, (intptr_t)data);
  1490. return 0;
  1491. }
  1492. case IPC_FILE_TAG_MAY_HAVE_UPDATEDW:
  1493. {
  1494. extern In_Module *g_in_infobox;
  1495. if (!g_in_infobox)
  1496. PlayList_UpdateTitle((const wchar_t *)data);
  1497. // issue sys callback
  1498. WASABI_API_SYSCB->syscb_issueCallback(SysCallback::META, MetadataCallback::FILE_UPDATED, (intptr_t)data);
  1499. return 0;
  1500. }
  1501. case IPC_SET_JTF_COMPARATOR:
  1502. SetJumpComparator((void *)data);
  1503. return 0;
  1504. case IPC_SET_JTF_COMPARATOR_W:
  1505. SetJumpComparatorW((void *)data);
  1506. return 0;
  1507. case IPC_SET_JTF_DRAWTEXT:
  1508. jtf_drawtext=reinterpret_cast<int (WINAPI *)(HDC, LPCWSTR, int, LPRECT, UINT)>(data);
  1509. return 0;
  1510. case IPC_SET_JTF_LOAD_MODE:
  1511. if (data == -666) return config_jtf_check;
  1512. config_jtf_check = data;
  1513. _w_i("jtf_check", config_jtf_check);
  1514. return 0;
  1515. case IPC_UPDATE_URL:
  1516. {
  1517. ReplyMessage(0);
  1518. char *url=(char *)data;
  1519. UpdateWindow_Show(url);
  1520. free(url);
  1521. return 0;
  1522. }
  1523. case IPC_GETPLAYITEM_START:
  1524. return PlayList_GetItem_Start(PlayList_getPosition());
  1525. case IPC_GETPLAYITEM_END:
  1526. return PlayList_GetItem_End(PlayList_getPosition());
  1527. case IPC_GET_PLAYING_FILENAME:
  1528. return reinterpret_cast<LRESULT>(FileName);
  1529. case IPC_GET_PLAYING_TITLE:
  1530. return reinterpret_cast<LRESULT>(FileTitle);
  1531. case IPC_COPY_EXTENDED_FILE_INFO:
  1532. {
  1533. copyFileInfoStruct *copy = (copyFileInfoStruct *)data;
  1534. CopyExtendedFileInfo(AutoWideFn(copy->source), AutoWideFn(copy->dest));
  1535. return 0;
  1536. }
  1537. case IPC_COPY_EXTENDED_FILE_INFOW:
  1538. {
  1539. copyFileInfoStructW *copy = (copyFileInfoStructW *)data;
  1540. CopyExtendedFileInfo(copy->source, copy->dest);
  1541. return 0;
  1542. }
  1543. case IPC_CANPLAY:
  1544. {
  1545. int a=0;
  1546. return (LRESULT)in_setmod_noplay((const wchar_t *)data, &a);
  1547. }
  1548. // disabled 30 May 2012 as per email from Tejas w.r.t. to Rovi deal ending
  1549. // if called it will now act like a failure and return 1 by default handling
  1550. /*case IPC_FETCH_ALBUMART:
  1551. {
  1552. extern int RetrieveAlbumArt(artFetchData * data);
  1553. return RetrieveAlbumArt((artFetchData *)data);
  1554. }*/
  1555. case IPC_JSAPI2_GET_DISPATCH_OBJECT:
  1556. return (LRESULT)new JSAPI2::ExternalObject((const wchar_t *)data);
  1557. case IPC_HANDLE_URI:
  1558. {
  1559. const wchar_t *cmd = (const wchar_t *)data;
  1560. if (cmd)
  1561. {
  1562. if (cmd[0] == '\"')
  1563. {
  1564. wchar_t temp[1024] = {0};
  1565. GetParameter(cmd, temp, 1024);
  1566. HandleFilename(temp);
  1567. }
  1568. else
  1569. HandleFilename(cmd);
  1570. return 0;
  1571. }
  1572. }
  1573. case IPC_GET_D3DX9:
  1574. {
  1575. HMODULE d3dx_lib = FindD3DX9();
  1576. return (LRESULT)d3dx_lib;
  1577. }
  1578. case IPC_GET_FILEREGISTRAR_OBJECT:
  1579. {
  1580. IFileTypeRegistrar *registrar = 0;
  1581. if (GetRegistrar(&registrar, !data) == 0 && registrar)
  1582. return (LRESULT)registrar;
  1583. return 0;
  1584. }
  1585. } // switch(which)
  1586. return 1;
  1587. }
  1588. // Main_OnIPC()