IPC.cpp 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588
  1. #include "main.h"
  2. #include <time.h>
  3. #include <winuser.h>
  4. #include <assert.h>
  5. #include "./ml.h"
  6. #include "../winamp/wa_ipc.h"
  7. #include "../winamp/ipc_pe.h"
  8. #include "./resource.h"
  9. #include "./comboskin.h"
  10. #include "./childwnd.h"
  11. #include "./sendto.h"
  12. #include "./navigation.h"
  13. #include "../nu/AutoWide.h"
  14. #include "../nu/ns_wc.h"
  15. #include "api__gen_ml.h"
  16. #include "./ml_ipc_0313.h"
  17. #include "./ml_imageloader.h"
  18. #include "./ml_imagefilter.h"
  19. #include "./ml_imagelist.h"
  20. #include "./ml_rating.h"
  21. #include "./ml_ratingcolumn.h"
  22. #include "./ml_cloud.h"
  23. #include "./ml_cloudcolumn.h"
  24. #include "./skinning.h"
  25. #include "./fileview.h"
  26. extern HWND m_curview_hwnd;
  27. extern "C" HWND g_ownerwnd;
  28. int queryEditOther(HWND hwnd, char *query, char *viewname, int mode);
  29. extern C_ItemList m_plugins;
  30. extern HNAVCTRL hNavigation;
  31. extern HMLIMGFLTRMNGR hmlifMngr;
  32. extern HMLIMGLST hmlilRating;
  33. extern HMLIMGLST hmlilCloud;
  34. static wchar_t playBuf[64], enqueueBuf[64];
  35. #define WEBINFO_PREFFERED_HEIGHT 100
  36. #define MAX_MENU_DEPTH 10
  37. typedef struct _NAVMENUBUILDER
  38. {
  39. HMENU hMenu[MAX_MENU_DEPTH];
  40. HNAVITEM hParent[MAX_MENU_DEPTH];
  41. INT level;
  42. NAVITEM_I nis;
  43. INT maxNum;
  44. INT offset;
  45. INT counter;
  46. } NAVMENUBUILDER;
  47. static INT GetNavImageIndexFromTag(HMLIMGLST hmlil, INT_PTR tag)
  48. {
  49. if (!hmlil) return -1;
  50. switch(tag)
  51. {
  52. case MLTREEIMAGE_NONE:
  53. case MLTREEIMAGE_DEFAULT:
  54. case MLTREEIMAGE_BRANCH:
  55. return -1;
  56. case MLTREEIMAGE_BRANCH_EXPANDED:
  57. case MLTREEIMAGE_BRANCH_COLLAPSED:
  58. case MLTREEIMAGE_BRANCH_NOCHILD:
  59. break;
  60. }
  61. return MLImageListI_GetIndexFromTag(hmlil, tag);
  62. }
  63. static BOOL CALLBACK EnumerateNavItemsCB(HNAVITEM hItem, LPARAM lParam)
  64. {
  65. NAVMENUBUILDER *pnmb;
  66. HNAVITEM hParent;
  67. if (!lParam || !hItem) return FALSE;
  68. pnmb = (NAVMENUBUILDER*)lParam;
  69. pnmb->counter++;
  70. if (pnmb->maxNum > 0 && pnmb->counter == pnmb->maxNum) return FALSE;
  71. if (!NavItemI_GetIndirect(hItem, &pnmb->nis)) return FALSE;
  72. if (pnmb->nis.pszText) FixAmpsW(pnmb->nis.pszText, pnmb->nis.cchTextMax);
  73. hParent = NavItemI_GetParent(hItem);
  74. while (hParent != pnmb->hParent[pnmb->level])
  75. {
  76. pnmb->level--;
  77. if (pnmb->level < 0) return FALSE;
  78. }
  79. if (NIS_HASCHILDREN_I & pnmb->nis.style)
  80. {
  81. pnmb->level++;
  82. if (pnmb->level == MAX_MENU_DEPTH) return FALSE;
  83. pnmb->hMenu[pnmb->level] = CreatePopupMenu();
  84. pnmb->hParent[pnmb->level] = hItem;
  85. // this will add a separator into the parent menu if we have a more than 1 child menu (ml_pmp can do this)
  86. if(pnmb->level > 1 && GetMenuItemCount(pnmb->hMenu[pnmb->level-1]) == 1) AppendMenuW(pnmb->hMenu[pnmb->level-1], MF_SEPARATOR, 0, 0);
  87. AppendMenuW(pnmb->hMenu[pnmb->level-1], MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)pnmb->hMenu[pnmb->level], pnmb->nis.pszText);
  88. AppendMenuW(pnmb->hMenu[pnmb->level], MF_ENABLED | MF_STRING, pnmb->nis.id + pnmb->offset, pnmb->nis.pszText);
  89. }
  90. else
  91. {
  92. // if we've got a 'root' item for the current level then add a separator
  93. if(pnmb->level && GetMenuItemCount(pnmb->hMenu[pnmb->level]) == 1) AppendMenuW(pnmb->hMenu[pnmb->level], MF_SEPARATOR, 0, 0);
  94. AppendMenuW(pnmb->hMenu[pnmb->level], MF_ENABLED | MF_STRING, pnmb->nis.id + pnmb->offset, pnmb->nis.pszText);
  95. }
  96. return TRUE;
  97. }
  98. static INT_PTR getPlRating(HWND hwndML, INT_PTR plindex)
  99. {
  100. const wchar_t *filename = (const wchar_t *)SendMessage(plugin.hwndParent, WM_WA_IPC, plindex, IPC_GETPLAYLISTFILEW);
  101. if (!filename) return 0;
  102. return SendMessage(hwndML, WM_ML_IPC, (WPARAM)filename, ML_IPC_GET_FILE_RATINGW);
  103. }
  104. static INT_PTR SetPlRating(HWND hwndML, int plindex, int rating)
  105. {
  106. const wchar_t *filename = (const wchar_t *)SendMessage(plugin.hwndParent, WM_WA_IPC, plindex, IPC_GETPLAYLISTFILEW);
  107. if (!filename) return 0;
  108. file_set_ratingW data;
  109. data.fileName = filename;
  110. data.newRating = rating;
  111. return (INT_PTR)SendMessage(hwndML, WM_ML_IPC, (WPARAM)&data, ML_IPC_SET_FILE_RATINGW);
  112. }
  113. INT_PTR IPC_PL_SetRating(HWND hwndML, INT_PTR param)
  114. {
  115. pl_set_rating *psr = (pl_set_rating *)param;
  116. if (psr) return SetPlRating(hwndML, psr->plentry, psr->rating);
  117. return 0;
  118. }
  119. static INT_PTR IPC_InsertView(UINT msg, INT_PTR param)
  120. {
  121. INT insertAfterId = 0, parentId = 0;
  122. BOOL converted = FALSE;
  123. HNAVITEM hItem = 0, hParentItem = 0, hInsertAfter = 0;
  124. NAVITEM_I nis = {0};
  125. switch(msg)
  126. {
  127. case ML_IPC_TREEITEM_ADD:
  128. case ML_IPC_TREEITEM_INSERT:
  129. if (((MLTREEITEM*)param)->title)
  130. {
  131. nis.pszText = AutoWideDup(((MLTREEITEM*)param)->title);
  132. converted = TRUE;
  133. }
  134. case ML_IPC_TREEITEM_INSERTW:
  135. case ML_IPC_TREEITEM_ADDW:
  136. if (ML_IPC_TREEITEM_ADD == msg || ML_IPC_TREEITEM_ADDW == msg)
  137. nis.id = (INT)((MLTREEITEMW*)param)->id;
  138. else
  139. insertAfterId= (INT)((MLTREEITEMW*)param)->id;
  140. if (!converted)
  141. nis.pszText = ((MLTREEITEMW*)param)->title;
  142. parentId = (INT)((MLTREEITEMW*)param)->parentId;
  143. nis.style |= (((MLTREEITEMW*)param)->hasChildren) ? NIS_HASCHILDREN_I : 0;
  144. nis.iImage = ((MLTREEITEMW*)param)->imageIndex;
  145. break;
  146. case ML_IPC_ADDTREEITEM_EX:
  147. nis.iImage = ((mlAddTreeItemStructEx*)param)->imageIndex;
  148. case ML_IPC_ADDTREEITEM:
  149. if (((mlAddTreeItemStruct*)param)->title)
  150. {
  151. nis.pszText = AutoWideDup(((mlAddTreeItemStruct*)param)->title);
  152. converted = TRUE;
  153. }
  154. parentId= (INT)((mlAddTreeItemStruct*)param)->parent_id;
  155. nis.style |= (((mlAddTreeItemStruct*)param)->has_children) ? NIS_HASCHILDREN_I : 0;
  156. break;
  157. }
  158. nis.iImage = GetNavImageIndexFromTag(NavCtrlI_GetImageList(hNavigation), nis.iImage);
  159. nis.iSelectedImage = nis.iImage;
  160. nis.styleMask |= NIS_HASCHILDREN_I;
  161. if (nis.id) nis.mask |= NIMF_ITEMID_I;
  162. if (nis.iImage) nis.mask |= NIMF_IMAGE_I;
  163. if (nis.iSelectedImage) nis.mask |= NIMF_IMAGESEL_I;
  164. if (nis.style) nis.mask |= NIMF_STYLE_I;
  165. if (nis.pszText) nis.mask |= NIMF_TEXT_I;
  166. if (nis.state) nis.mask |= NIMF_STATE_I;
  167. hInsertAfter = NavCtrlI_FindItem(hNavigation, insertAfterId);
  168. hParentItem = NavCtrlI_FindItem(hNavigation, parentId);
  169. hItem = NavCtrlI_InsertItem(hNavigation, hInsertAfter, hParentItem, &nis);
  170. if (converted && nis.pszText) free(nis.pszText);
  171. if (hItem)
  172. {
  173. if (ML_IPC_ADDTREEITEM ==msg || ML_IPC_ADDTREEITEM_EX == msg)
  174. ((mlAddTreeItemStruct*)param)->this_id = NavItemI_GetId(hItem);
  175. else
  176. ((MLTREEITEMW*)param)->id = NavItemI_GetId(hItem);
  177. }
  178. return (INT_PTR)hItem;
  179. }
  180. static BOOL IPC_SetView(int msg, INT_PTR param)
  181. {
  182. HNAVITEM hItem;
  183. switch(msg)
  184. {
  185. case ML_IPC_SETTREEITEM:
  186. case ML_IPC_SETTREEITEM_EX:
  187. hItem = NavCtrlI_FindItem(hNavigation, (INT)((mlAddTreeItemStruct*)param)->this_id);
  188. if (!hItem) return FALSE;
  189. if (!NavItemI_SetText(hItem, AutoWide(((mlAddTreeItemStruct*)param)->title)) ||
  190. !NavItemI_SetStyle(hItem, (((mlAddTreeItemStruct*)param)->has_children) ? NIS_HASCHILDREN_I : 0, NIS_HASCHILDREN_I))
  191. return FALSE;
  192. if (ML_IPC_SETTREEITEM_EX == msg)
  193. {
  194. INT mlilIndex = GetNavImageIndexFromTag(NavCtrlI_GetImageList(hNavigation), ((mlAddTreeItemStructEx*)param)->imageIndex);
  195. if (!NavItemI_SetImageIndex(hItem, mlilIndex, IMAGE_NORMAL_I) || !NavItemI_SetImageIndex(hItem, mlilIndex, IMAGE_SELECTED_I)) return FALSE;
  196. }
  197. return TRUE;
  198. case ML_IPC_TREEITEM_SETINFO:
  199. case ML_IPC_TREEITEM_SETINFOW:
  200. hItem = (((MLTREEITEMINFO*)param)->handle) ?
  201. (HNAVITEM)((MLTREEITEMINFO*)param)->handle :
  202. NavCtrlI_FindItem(hNavigation, (INT)((MLTREEITEMINFO*)param)->item.id);
  203. if (!hItem) return FALSE;
  204. if (MLTI_TEXT & ((MLTREEITEMINFO*)param)->mask)
  205. {
  206. if (!NavItemI_SetText(hItem, (ML_IPC_TREEITEM_SETINFOW == msg) ? ((MLTREEITEMINFOW*)param)->item.title :
  207. AutoWide(((MLTREEITEMINFO*)param)->item.title))) return FALSE;
  208. }
  209. if (MLTI_ID & ((MLTREEITEMINFO*)param)->mask &&
  210. ! NavItemI_SetId(hItem, (INT)((MLTREEITEMINFO*)param)->item.id)) return FALSE;
  211. if (MLTI_CHILDREN & ((MLTREEITEMINFO*)param)->mask &&
  212. !NavItemI_SetStyle(hItem, (((MLTREEITEMINFO*)param)->item.hasChildren) ? NIS_HASCHILDREN_I : 0, NIS_HASCHILDREN_I)) return FALSE;
  213. if (MLTI_IMAGE & ((MLTREEITEMINFO*)param)->mask)
  214. {
  215. INT mlilIndex = GetNavImageIndexFromTag(NavCtrlI_GetImageList(hNavigation), ((MLTREEITEMINFO*)param)->item.imageIndex);
  216. if (!NavItemI_SetImageIndex(hItem, mlilIndex, IMAGE_NORMAL_I) || !NavItemI_SetImageIndex(hItem, mlilIndex, IMAGE_SELECTED_I)) return FALSE;
  217. }
  218. }
  219. return FALSE;
  220. }
  221. static BOOL IPC_GetView(INT msg, INT_PTR param)
  222. {
  223. HNAVITEM hItem;
  224. hItem = (((MLTREEITEMINFO*)param)->handle) ?
  225. (HNAVITEM)((MLTREEITEMINFO*)param)->handle :
  226. NavCtrlI_FindItem(hNavigation, (INT)((MLTREEITEMINFO*)param)->item.id);
  227. if (!hItem) return FALSE;
  228. if (MLTI_ID & ((MLTREEITEMINFO*)param)->mask) ((MLTREEITEMINFO*)param)->item.id = NavItemI_GetId(hItem);
  229. if (MLTI_CHILDREN & ((MLTREEITEMINFO*)param)->mask) ((MLTREEITEMINFO*)param)->item.hasChildren = NavItemI_HasChildren(hItem);
  230. /// TODO: index <--> tag
  231. if (MLTI_IMAGE & ((MLTREEITEMINFO*)param)->mask)
  232. {
  233. INT_PTR tag;
  234. ((MLTREEITEMINFO*)param)->item.id = (MLImageListI_GetTagFromIndex(NavCtrlI_GetImageList(hNavigation),
  235. NavItemI_GetImageIndex(hItem, IMAGE_NORMAL_I),
  236. &tag)) ? (INT)tag : -1;
  237. }
  238. if (MLTI_TEXT & ((MLTREEITEMINFO*)param)->mask)
  239. {
  240. if (ML_IPC_TREEITEM_GETINFO == msg)
  241. {
  242. wchar_t buffer[4096] = {0};
  243. if (!NavItemI_GetText(hItem, buffer, 4096)) return FALSE;
  244. if (!WideCharToMultiByte(CP_ACP, 0, buffer, -1,
  245. ((MLTREEITEMINFO*)param)->item.title,
  246. (INT)((MLTREEITEMINFO*)param)->item.titleLen, NULL, NULL)) return FALSE;
  247. }
  248. else
  249. {
  250. if (!NavItemI_GetText(hItem, ((MLTREEITEMINFOW*)param)->item.title, (INT)((MLTREEITEMINFOW*)param)->item.titleLen)) return FALSE;
  251. }
  252. }
  253. return TRUE;
  254. }
  255. static INT_PTR IPC_SendToWinamp(INT_PTR param)
  256. {
  257. mlSendToWinampStruct *p = (mlSendToWinampStruct*)param;
  258. if (p->data)
  259. {
  260. int enq = p->enqueue & 1;
  261. if (!(p->enqueue & 2) && g_config->ReadInt(L"enqueuedef", 0)) enq ^= 1;
  262. switch (p->type)
  263. {
  264. case ML_TYPE_ITEMRECORDLIST:
  265. case ML_TYPE_CDTRACKS:
  266. main_playItemRecordList((itemRecordList*)p->data, enq);
  267. break;
  268. case ML_TYPE_ITEMRECORDLISTW:
  269. main_playItemRecordListW((itemRecordListW *)p->data, enq);
  270. break;
  271. case ML_TYPE_STREAMNAMES:
  272. case ML_TYPE_FILENAMES:
  273. {
  274. char *list = (char*)p->data;
  275. int cnt = 0;
  276. if (list) while (*list)
  277. {
  278. if (!cnt && !enq) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_DELETE);
  279. cnt++;
  280. COPYDATASTRUCT cds;
  281. cds.dwData = IPC_PLAYFILE;
  282. cds.lpData = (void *) list;
  283. cds.cbData =(INT)strlen((char *) cds.lpData) + 1; // include space for null char
  284. SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
  285. list += strlen(list) + 1;
  286. }
  287. if (cnt && !enq) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_STARTPLAY);
  288. }
  289. break;
  290. case ML_TYPE_STREAMNAMESW:
  291. case ML_TYPE_FILENAMESW:
  292. {
  293. wchar_t *list = (wchar_t*)p->data;
  294. int cnt = 0;
  295. if ( list )
  296. {
  297. while ( *list )
  298. {
  299. if ( !cnt && !enq ) SendMessage( plugin.hwndParent, WM_WA_IPC, 0, IPC_DELETE );
  300. cnt++;
  301. COPYDATASTRUCT cds;
  302. cds.dwData = IPC_PLAYFILEW;
  303. cds.lpData = (void *)list;
  304. cds.cbData = (INT)( sizeof( wchar_t ) * wcslen( (wchar_t *)cds.lpData ) + sizeof( wchar_t ) ); // include space for null char
  305. SendMessage( plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds );
  306. list += wcslen( list ) + 1;
  307. }
  308. }
  309. if (cnt && !enq)
  310. SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_STARTPLAY);
  311. }
  312. break;
  313. }
  314. }
  315. return 0;
  316. }
  317. typedef struct __DRAGTARGET
  318. {
  319. HWND hwnd;
  320. UINT state;
  321. INT testResult;
  322. } DRAGTARGET;
  323. typedef enum
  324. {
  325. DRAGSTATE_NOTSUPPORTED = -2,
  326. DRAGSTATE_UNKNOWN = -1,
  327. DRAGSTATE_REJECTED = 0,
  328. DRAGSTATE_ACCEPTED = 1,
  329. } DRAGSTATE;
  330. static DRAGTARGET dragTarget;
  331. static UINT WAML_NOTIFY_DRAGDROP = 0;
  332. static INT_PTR IPC_HandleDrag(HWND hwndML, mlDropItemStruct *pdip)
  333. {
  334. if (NULL == pdip)
  335. {
  336. SetCursor(LoadCursor(NULL, IDC_NO));
  337. return 0;
  338. }
  339. HWND hTarget = (NULL != pdip) ? WindowFromPoint(pdip->p) : NULL;
  340. if (0 == WAML_NOTIFY_DRAGDROP)
  341. {
  342. WAML_NOTIFY_DRAGDROP = RegisterWindowMessageW(WAMLM_DRAGDROP);
  343. if (0 == WAML_NOTIFY_DRAGDROP)
  344. {
  345. if (0 == (ML_HANDLEDRAG_FLAG_NOCURSOR & pdip->flags))
  346. SetCursor(LoadCursor(NULL, IDC_NO));
  347. return 0;
  348. }
  349. }
  350. if (NULL != dragTarget.hwnd && hTarget != dragTarget.hwnd)
  351. {
  352. if (DRAGSTATE_NOTSUPPORTED != dragTarget.state &&
  353. DRAGSTATE_UNKNOWN != dragTarget.state)
  354. SendMessageW(dragTarget.hwnd, WAML_NOTIFY_DRAGDROP, DRAGDROP_DRAGLEAVE, 0L);
  355. dragTarget.hwnd = NULL;
  356. dragTarget.state = DRAGSTATE_UNKNOWN;
  357. dragTarget.testResult = 0;
  358. }
  359. if (NULL == dragTarget.hwnd && NULL != hTarget)
  360. {
  361. DWORD targetPid;
  362. GetWindowThreadProcessId(hTarget, &targetPid);
  363. if (GetCurrentProcessId() != targetPid)
  364. {
  365. if (0 == (ML_HANDLEDRAG_FLAG_NOCURSOR & pdip->flags))
  366. SetCursor(LoadCursor(NULL, IDC_NO));
  367. return 0;
  368. }
  369. dragTarget.hwnd = hTarget;
  370. }
  371. if (NULL != dragTarget.hwnd)
  372. {
  373. switch(dragTarget.state)
  374. {
  375. case DRAGSTATE_UNKNOWN:
  376. pdip->result = 0;
  377. if (SendMessageW(dragTarget.hwnd, WAML_NOTIFY_DRAGDROP, DRAGDROP_DRAGENTER, (LPARAM)pdip))
  378. {
  379. dragTarget.testResult = pdip->result;
  380. dragTarget.state = (dragTarget.testResult > 0) ? DRAGSTATE_ACCEPTED : DRAGSTATE_REJECTED;
  381. if (0 == (ML_HANDLEDRAG_FLAG_NOCURSOR & pdip->flags))
  382. SetCursor((dragTarget.testResult > 0) ? hDragNDropCursor : LoadCursor(NULL, IDC_NO));
  383. return 0;
  384. }
  385. else
  386. dragTarget.state = DRAGSTATE_NOTSUPPORTED;
  387. break;
  388. case DRAGSTATE_REJECTED:
  389. pdip->result = dragTarget.testResult;
  390. return 0;
  391. case DRAGSTATE_ACCEPTED:
  392. SendMessageW(dragTarget.hwnd, WAML_NOTIFY_DRAGDROP, DRAGDROP_DRAGOVER, (LPARAM)pdip);
  393. dragTarget.testResult = pdip->result;
  394. if (0 == (ML_HANDLEDRAG_FLAG_NOCURSOR & pdip->flags))
  395. SetCursor((dragTarget.testResult > 0) ? hDragNDropCursor : LoadCursor(NULL, IDC_NO));
  396. return 0;
  397. }
  398. }
  399. pdip->result = handleDragDropMove(hwndML, pdip->type, pdip->p, !(pdip->flags & ML_HANDLEDRAG_FLAG_NOCURSOR)) > 0 ? 1 : -1;
  400. return 0;
  401. }
  402. static INT_PTR IPC_HandleDrop(INT_PTR param)
  403. {
  404. if (param)
  405. {
  406. extern HNAVITEM g_treedrag_lastSel;
  407. if (g_treedrag_lastSel)
  408. {
  409. NavItemI_SetState(g_treedrag_lastSel, 0, NIS_DROPHILITED_I);
  410. g_treedrag_lastSel = 0;
  411. }
  412. mlDropItemStruct *m = (mlDropItemStruct *)param;
  413. if (!m->data) return 0;
  414. HWND h = WindowFromPoint(m->p);
  415. if (!h) return 0;;
  416. if (NULL != dragTarget.hwnd)
  417. {
  418. BOOL bProcessed = FALSE;
  419. if (DRAGSTATE_NOTSUPPORTED != dragTarget.state &&
  420. DRAGSTATE_UNKNOWN != dragTarget.state)
  421. {
  422. if (h != dragTarget.hwnd)
  423. SendMessageW(dragTarget.hwnd, WAML_NOTIFY_DRAGDROP, DRAGDROP_DRAGLEAVE, 0L);
  424. else
  425. {
  426. bProcessed = TRUE;
  427. if (DRAGSTATE_ACCEPTED == dragTarget.state)
  428. SendMessageW(dragTarget.hwnd, WAML_NOTIFY_DRAGDROP, DRAGDROP_DROP, (LPARAM)m);
  429. }
  430. }
  431. dragTarget.hwnd = NULL;
  432. dragTarget.state = DRAGSTATE_UNKNOWN;
  433. dragTarget.testResult = 0;
  434. if (bProcessed)
  435. return 0;
  436. }
  437. extern HWND wa3wnd_fixwnd(HWND);
  438. h = wa3wnd_fixwnd(h);
  439. itemRecordList *obj = (itemRecordList *)m->data; // may not be valid heh
  440. if (IsChild(plugin.hwndParent, h)) h = plugin.hwndParent;
  441. else if (g_PEWindow && IsChild(g_PEWindow, h)) h = g_PEWindow;
  442. else
  443. {
  444. HWND vid = (HWND)SendMessage(plugin.hwndParent, WM_WA_IPC, IPC_GETWND_VIDEO, IPC_GETWND);
  445. if (vid)
  446. {
  447. if (h == vid || IsChild(vid, h)) h = plugin.hwndParent;
  448. }
  449. }
  450. if (h == plugin.hwndParent)
  451. {
  452. int enqueue = (!!g_config->ReadInt(L"enqueuedef", 0)) ^(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
  453. if (m->type == ML_TYPE_ITEMRECORDLIST || m->type == ML_TYPE_CDTRACKS)
  454. main_playItemRecordList((itemRecordList *)m->data, enqueue);
  455. else if (m->type == ML_TYPE_ITEMRECORDLISTW)
  456. main_playItemRecordListW((itemRecordListW *)m->data, enqueue);
  457. else if (m->type == ML_TYPE_FILENAMES || m->type == ML_TYPE_STREAMNAMES)
  458. {
  459. if (!enqueue) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_DELETE);
  460. char *p = (char*)m->data;
  461. while (p && *p)
  462. {
  463. COPYDATASTRUCT cds;
  464. cds.dwData = IPC_PLAYFILE;
  465. cds.lpData = (void *) p;
  466. cds.cbData =(INT) strlen((char *) cds.lpData) + 1; // include space for null char
  467. SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
  468. p += strlen(p) + 1;
  469. }
  470. if (!enqueue) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_STARTPLAY);
  471. }
  472. else if (m->type == ML_TYPE_FILENAMESW || m->type == ML_TYPE_STREAMNAMESW)
  473. {
  474. if (!enqueue) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_DELETE);
  475. wchar_t *p = (wchar_t*)m->data;
  476. while (p && *p)
  477. {
  478. COPYDATASTRUCT cds;
  479. cds.dwData = IPC_PLAYFILEW;
  480. cds.lpData = (void *) p;
  481. cds.cbData =(INT)sizeof(wchar_t) * wcslen((wchar_t *) cds.lpData) + sizeof(wchar_t); // include space for null char
  482. SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
  483. p += wcslen(p) + 1;
  484. }
  485. if (!enqueue) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_STARTPLAY);
  486. }
  487. else if (m->type == ML_TYPE_PLAYLIST)
  488. {
  489. if (!enqueue) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_DELETE);
  490. mlPlaylist *p = (mlPlaylist *)m->data;
  491. COPYDATASTRUCT cds;
  492. cds.dwData = IPC_PLAYFILEW;
  493. cds.lpData = (void *) p->filename;
  494. cds.cbData = sizeof(wchar_t)*(wcslen(p->filename) + 1);// include space for null char
  495. SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
  496. if (!enqueue) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_STARTPLAY);
  497. }
  498. else if (m->type == ML_TYPE_PLAYLISTS)
  499. {
  500. if (!enqueue) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_DELETE);
  501. mlPlaylist **playlists = (mlPlaylist **)m->data;
  502. while (playlists && *playlists)
  503. {
  504. mlPlaylist *p = *playlists;
  505. COPYDATASTRUCT cds;
  506. cds.dwData = IPC_PLAYFILEW;
  507. cds.lpData = (void *) p->filename;
  508. cds.cbData = sizeof(wchar_t)*(wcslen(p->filename) + 1);// include space for null char
  509. SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
  510. playlists++;
  511. }
  512. if (!enqueue) SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_STARTPLAY);
  513. }
  514. }
  515. else if (h == g_PEWindow)
  516. {
  517. POINT p = m->p;
  518. ScreenToClient(g_PEWindow, &p);
  519. LRESULT idx = SendMessage(g_PEWindow, WM_USER, IPC_PE_GETIDXFROMPOINT, (LPARAM) & p);
  520. SendMessage(g_PEWindow, WM_USER, IPC_PE_SAVEEND, (LPARAM)idx);
  521. if (m->type == ML_TYPE_ITEMRECORDLIST || m->type == ML_TYPE_CDTRACKS)
  522. main_playItemRecordList((itemRecordList *)m->data, 1);
  523. else if (m->type == ML_TYPE_ITEMRECORDLISTW)
  524. main_playItemRecordListW((itemRecordListW *)m->data, 1);
  525. else if (m->type == ML_TYPE_FILENAMES || m->type == ML_TYPE_STREAMNAMES)
  526. {
  527. char *fileName = (char*)m->data;
  528. while (fileName && *fileName)
  529. {
  530. COPYDATASTRUCT cds;
  531. cds.dwData = IPC_PLAYFILE;
  532. cds.lpData = (void *)fileName;
  533. cds.cbData = (INT)strlen((char *) cds.lpData) + 1; // include space for null char
  534. SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
  535. fileName += strlen(fileName) + 1;
  536. }
  537. }
  538. else if (m->type == ML_TYPE_FILENAMESW || m->type == ML_TYPE_STREAMNAMESW)
  539. {
  540. wchar_t *fileName = (wchar_t*)m->data;
  541. while (fileName && *fileName)
  542. {
  543. COPYDATASTRUCT cds;
  544. cds.dwData = IPC_PLAYFILEW;
  545. cds.lpData = (void *)fileName;
  546. cds.cbData = (INT)sizeof(wchar_t) * wcslen((wchar_t *) cds.lpData) + sizeof(wchar_t); // include space for null char
  547. SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
  548. fileName += wcslen(fileName) + 1;
  549. }
  550. }
  551. else if (m->type == ML_TYPE_PLAYLIST)
  552. {
  553. mlPlaylist *pl = (mlPlaylist *)m->data;
  554. COPYDATASTRUCT cds;
  555. cds.dwData = IPC_PLAYFILEW;
  556. cds.lpData = (void *) pl->filename;
  557. cds.cbData = sizeof(wchar_t)*(wcslen(pl->filename) + 1);// include space for null char
  558. SendMessage(plugin.hwndParent, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
  559. }
  560. SendMessage(g_PEWindow, WM_USER, IPC_PE_RESTOREEND, 0);
  561. }
  562. else if (h == NavCtrlI_GetHWND(hNavigation))
  563. {
  564. HNAVITEM hItemHit, hItemSel;
  565. POINT pt = m->p;
  566. MapWindowPoints(HWND_DESKTOP, h, &pt, 1);
  567. hItemHit = NavCtrlI_HitTest(hNavigation, &pt, NULL);
  568. hItemSel = NavCtrlI_GetSelection(hNavigation);
  569. if (hItemHit == hItemSel) m->result = -1;
  570. else
  571. {
  572. INT itemId = NavItemI_GetId(hItemHit);
  573. if (itemId && plugin_SendMessage(ML_MSG_TREE_ONDROPTARGET, itemId, m->type, NULL) > 0)
  574. plugin_SendMessage(ML_MSG_TREE_ONDROPTARGET, itemId, m->type, (INT_PTR)m->data);
  575. }
  576. }
  577. else{
  578. // TODO: verify this is correct against NAV api usage
  579. // try to send to the current view if all else failed
  580. // e.g. dragging a playlist view onto bookmarks page
  581. HNAVITEM hItemSel = NavCtrlI_GetSelection(hNavigation);
  582. INT itemId = NavItemI_GetId(hItemSel);
  583. if(itemId && plugin_SendMessage(ML_MSG_TREE_ONDROPTARGET, itemId, m->type, NULL) > 0)
  584. plugin_SendMessage(ML_MSG_TREE_ONDROPTARGET, itemId, m->type, (INT_PTR)m->data);
  585. }
  586. }
  587. return 0;
  588. }
  589. static INT_PTR IPC_GetTree(INT_PTR param)
  590. {
  591. mlGetTreeStruct *mgts;
  592. HNAVITEM hStartItem = NULL, hStartItem2 = NULL;
  593. NAVMENUBUILDER nmb;
  594. wchar_t buffer[1024] = {0};
  595. if (!param) return NULL;
  596. mgts = (mlGetTreeStruct *)param;
  597. hStartItem = NavCtrlI_FindItem(hNavigation, mgts->item_start);
  598. if (hStartItem) hStartItem2 = NavItemI_GetChild(hStartItem);
  599. nmb.level = 0;
  600. nmb.hMenu[0] = CreatePopupMenu();
  601. nmb.hParent[0] = NavItemI_GetParent(hStartItem2);
  602. nmb.maxNum = mgts->max_numitems;
  603. nmb.offset = mgts->cmd_offset;
  604. nmb.counter = 0;
  605. nmb.nis.mask = NIMF_TEXT_I | NIMF_STYLE_I | NIMF_ITEMID_I;
  606. nmb.nis.styleMask = NIS_HASCHILDREN_I;
  607. nmb.nis.cchTextMax = sizeof(buffer)/sizeof(wchar_t);
  608. nmb.nis.pszText = buffer;
  609. if(hStartItem2 || !mgts->item_start) NavCtrlI_EnumItems(hNavigation, EnumerateNavItemsCB, hStartItem2, (LPARAM)&nmb);
  610. return (INT_PTR)nmb.hMenu[0];
  611. }
  612. static INT_PTR IPC_GetRating(HWND hwndML, INT_PTR param)
  613. {
  614. LRESULT plindex = SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETLISTPOS);
  615. return getPlRating(hwndML, plindex);
  616. }
  617. static INT_PTR IPC_SetRating(HWND hwndML, INT_PTR param)
  618. {
  619. INT_PTR rating = min(5, max(0, param));
  620. LRESULT plindex = SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETLISTPOS);
  621. SetPlRating(hwndML, (INT)plindex, (INT)rating);
  622. SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_UPDTITLE);
  623. return 1;
  624. }
  625. static INT IPC_RegisterNavigationImage(INT_PTR param)
  626. {
  627. HMLIMGLST hmlilNavigation;
  628. MLIMAGESOURCE_I is;
  629. INT_PTR tag;
  630. INT mlilIndex;
  631. if (!param) return -1;
  632. hmlilNavigation = NavCtrlI_GetImageList(hNavigation);
  633. if (!hmlilNavigation) return -1;
  634. ZeroMemory(&is, sizeof(MLIMAGESOURCE_I));
  635. is.hInst = ((MLTREEIMAGE*)param)->hinst;
  636. is.bpp = 24;
  637. is.lpszName = MAKEINTRESOURCEW(((MLTREEIMAGE*)param)->resourceId);
  638. is.type = SRC_TYPE_BMP_I;
  639. is.flags = ISF_FORCE_BPP_I;
  640. tag = ((MLTREEIMAGE*)param)->imageIndex;
  641. if (-1 != tag)
  642. {
  643. mlilIndex = MLImageListI_GetIndexFromTag(hmlilNavigation, tag);
  644. if (-1 != mlilIndex)
  645. {
  646. if (!MLImageListI_Replace(hmlilNavigation, mlilIndex, &is,
  647. GUID_NULL, tag)) tag = -1;
  648. }
  649. }
  650. else mlilIndex = -1;
  651. if (-1 == mlilIndex)
  652. {
  653. if ( -1 == tag)
  654. {
  655. static INT_PTR tagCounter = 8000;
  656. tag = tagCounter++;
  657. }
  658. mlilIndex = MLImageListI_Add(hmlilNavigation, &is, MLIF_FILTER1_UID, tag);
  659. if (-1 == mlilIndex) tag = -1;
  660. }
  661. return (INT)tag;
  662. }
  663. INT_PTR OnGetCurrentView(void)
  664. {
  665. return (INT_PTR)m_curview_hwnd;
  666. }
  667. static BOOL OnFlickerFixIPC(FLICKERFIX * pff)
  668. {
  669. return (pff) ? FlickerFixWindow(pff->hwnd, pff->mode) : FALSE;
  670. }
  671. static HBITMAP OnIPC_MLImageLoader_LoadDib(MLIMAGESOURCE *pmlis)
  672. {
  673. return (pmlis && pmlis->cbSize == sizeof(MLIMAGESOURCE)) ?
  674. MLImageLoaderI_LoadDib((MLIMAGESOURCE_I*)&pmlis->hInst) :
  675. NULL;
  676. }
  677. static BOOL OnIPC_MLImageLoader_CopyStruct(MLIMAGESOURCECOPY* pmlisCopy)
  678. {
  679. return (pmlisCopy && pmlisCopy->dest && pmlisCopy->src &&
  680. pmlisCopy->dest->cbSize == sizeof(MLIMAGESOURCE) &&
  681. pmlisCopy->dest->cbSize == sizeof(MLIMAGESOURCE)) ?
  682. MLImageLoaderI_CopyData((MLIMAGESOURCE_I*)&pmlisCopy->dest->hInst, (MLIMAGESOURCE_I*)&pmlisCopy->src->hInst) :
  683. FALSE;
  684. }
  685. static BOOL OnIPC_MLImageLoader_FreeStruct(MLIMAGESOURCE *pmlis)
  686. {
  687. return (pmlis && pmlis->cbSize == sizeof(MLIMAGESOURCE)) ?
  688. MLImageLoaderI_FreeData((MLIMAGESOURCE_I*)&pmlis->hInst) :
  689. FALSE;
  690. }
  691. static BOOL OnIPC_MLImageLoader_CheckExist(MLIMAGESOURCE *pmlis)
  692. {
  693. return (NULL != pmlis && pmlis->cbSize == sizeof(MLIMAGESOURCE)) ?
  694. MLImageLoaderI_CheckExist((MLIMAGESOURCE_I*)&pmlis->hInst) :
  695. FALSE;
  696. }
  697. static HMLIMGLST OnIPC_MLImageList_Create(MLIMAGELISTCREATE *pmlilCreate)
  698. {
  699. return (pmlilCreate) ? MLImageListI_Create(pmlilCreate->cx, pmlilCreate->cy, pmlilCreate->flags, pmlilCreate->cInitial, pmlilCreate->cGrow, pmlilCreate->cCacheSize, hmlifMngr) : NULL;
  700. }
  701. static BOOL OnIPC_MLImageList_Destroy(HMLIMGLST hmlil)
  702. {
  703. return MLImageListI_Destroy(hmlil);
  704. }
  705. static HIMAGELIST OnIPC_MLImageList_GetRealList(HMLIMGLST hmlil)
  706. {
  707. return MLImageListI_GetRealList(hmlil);
  708. }
  709. static INT OnIPC_MLImageList_GetRealIndex(MLIMAGELISTREALINDEX *pmlilRealIdx)
  710. {
  711. return (pmlilRealIdx && pmlilRealIdx->cbSize == sizeof(MLIMAGELISTREALINDEX)) ?
  712. MLImageListI_GetRealIndex(pmlilRealIdx->hmlil, pmlilRealIdx->mlilIndex, pmlilRealIdx->rgbBk, pmlilRealIdx->rgbFg) : -1;
  713. }
  714. static INT OnIPC_MLImageList_Add(MLIMAGELISTITEM *pmlilItem)
  715. {
  716. MLIMAGESOURCE_I *pis;
  717. if (!pmlilItem || pmlilItem->cbSize != sizeof(MLIMAGELISTITEM)) return -1;
  718. if (pmlilItem->pmlImgSource)
  719. {
  720. if (pmlilItem->pmlImgSource->cbSize != sizeof(MLIMAGESOURCE)) return -1;
  721. pis = (MLIMAGESOURCE_I*)(&pmlilItem->pmlImgSource->hInst);
  722. }
  723. else pis = NULL;
  724. pmlilItem->mlilIndex = MLImageListI_Add(pmlilItem->hmlil, pis, pmlilItem->filterUID, pmlilItem->nTag);
  725. return pmlilItem->mlilIndex;
  726. }
  727. static BOOL OnIPC_MLImageList_Replace(MLIMAGELISTITEM *pmlilItem)
  728. {
  729. MLIMAGESOURCE_I *pis;
  730. if (!pmlilItem || pmlilItem->cbSize != sizeof(MLIMAGELISTITEM)) return -1;
  731. if (pmlilItem->pmlImgSource)
  732. {
  733. if (pmlilItem->pmlImgSource->cbSize != sizeof(MLIMAGESOURCE)) return -1;
  734. pis = (MLIMAGESOURCE_I*)((INT*)pmlilItem->pmlImgSource + 1);
  735. }
  736. else pis = NULL;
  737. return MLImageListI_Replace(pmlilItem->hmlil, pmlilItem->mlilIndex, pis, pmlilItem->filterUID, pmlilItem->nTag);
  738. }
  739. static BOOL OnIPC_MLImageList_Remove(MLIMAGELISTITEM *pmlilItem)
  740. {
  741. return (pmlilItem) ? MLImageListI_Remove(pmlilItem->hmlil, pmlilItem->mlilIndex) : FALSE;
  742. }
  743. static BOOL OnIPC_MLImageList_GetImageSize(MLIMAGELISTIMAGESIZE *pmlilImageSize)
  744. {
  745. return (pmlilImageSize) ? MLImageListI_GetImageSize(pmlilImageSize->hmlil, &pmlilImageSize->cx, &pmlilImageSize->cy) : FALSE;
  746. }
  747. static INT OnIPC_MLImageList_GetImageCount(HMLIMGLST hmlil)
  748. {
  749. return MLImageListI_GetImageCount(hmlil);
  750. }
  751. static BOOL OnIPC_MLImageList_GetIndexFromTag(MLIMAGELISTTAG *pmlilTag)
  752. {
  753. if (!pmlilTag) return FALSE;
  754. pmlilTag->mlilIndex = MLImageListI_GetIndexFromTag(pmlilTag->hmlil, pmlilTag->nTag);
  755. return (-1 != pmlilTag->mlilIndex);
  756. }
  757. static BOOL OnIPC_MLImageList_GetTagFromIndex(MLIMAGELISTTAG *pmlilTag)
  758. {
  759. return (pmlilTag) ? MLImageListI_GetTagFromIndex(pmlilTag->hmlil, pmlilTag->mlilIndex, &pmlilTag->nTag) : FALSE;
  760. }
  761. static BOOL OnIPC_MLImageList_CheckItemExist(MLIMAGELISTITEM *pmlilItem)
  762. {
  763. return (pmlilItem) ? MLImageListI_CheckItemExist(pmlilItem->hmlil, pmlilItem->mlilIndex) : FALSE;
  764. }
  765. static BOOL OnIPC_MLImageFilter_Register(MLIMAGEFILTERINFO* pmlif)
  766. {
  767. return (pmlif && pmlif->cbSize == sizeof(MLIMAGEFILTERINFO)) ?
  768. MLImageFilterI_Register(hmlifMngr, (MLIMAGEFILTERINFO_I*)((INT*)pmlif +1)) : FALSE;
  769. }
  770. static BOOL OnIPC_MLImageFilter_Unregister(const GUID* pUID)
  771. {
  772. return (pUID) ? MLImageFilterI_Unregister(hmlifMngr, *pUID) : FALSE;
  773. }
  774. static BOOL OnIPC_MLImageFilter_GetInfo(MLIMAGEFILTERINFO* pmlif)
  775. {
  776. return (pmlif && pmlif->cbSize == sizeof(MLIMAGEFILTERINFO)) ?
  777. MLImageFilterI_GetInfo(hmlifMngr, (MLIMAGEFILTERINFO_I*)((INT*)pmlif +1)) : FALSE;
  778. }
  779. static BOOL OnIPC_MLImageFilter_ApplyEx(MLIMAGEFILTERAPPLYEX* pmlifApplyEx)
  780. {
  781. if (!pmlifApplyEx || pmlifApplyEx->cbSize != sizeof(MLIMAGEFILTERAPPLYEX)) return FALSE;
  782. return MLImageFilterI_ApplyEx(hmlifMngr, &pmlifApplyEx->filterUID, pmlifApplyEx->pData, pmlifApplyEx->cx,
  783. pmlifApplyEx->cy, pmlifApplyEx->bpp, pmlifApplyEx->rgbBk, pmlifApplyEx->rgbFg, pmlifApplyEx->imageTag);
  784. }
  785. static INT OnIPC_MLNavCtrl_BeginUpdate(UINT fRememberPos)
  786. {
  787. return NavCtrlI_BeginUpdate(hNavigation, fRememberPos);
  788. }
  789. static BOOL OnIPC_MLNavCtrl_DeleteItem(HNAVITEM hItem)
  790. {
  791. return NavCtrlI_DeleteItem(hNavigation, hItem);
  792. }
  793. static INT OnIPC_MLNavCtrl_EndUpdate(void)
  794. {
  795. return NavCtrlI_EndUpdate(hNavigation);
  796. }
  797. static BOOL OnIPC_MLNavCtrl_EnumItems(NAVCTRLENUMPARAMS *pnavEnumParams)
  798. {
  799. return (pnavEnumParams) ? NavCtrlI_EnumItems(hNavigation, (NAVENUMPROC_I)pnavEnumParams->enumProc,
  800. pnavEnumParams->hItemStart, pnavEnumParams->lParam) : FALSE;
  801. }
  802. HNAVITEM OnIPC_MLNavCtrl_FindItemById(INT itemId)
  803. {
  804. return NavCtrlI_FindItem(hNavigation, itemId);
  805. }
  806. static HNAVITEM OnIPC_MLNavCtrl_FindItemByName(NAVCTRLFINDPARAMS *pnavFindParams)
  807. {
  808. if (!pnavFindParams) return NULL;
  809. return (!pnavFindParams->fFullNameSearch) ?
  810. NavCtrlI_FindItemByName(hNavigation, pnavFindParams->Locale, pnavFindParams->compFlags, pnavFindParams->pszName, pnavFindParams->cchLength) :
  811. NavCtrlI_FindItemByFullName(hNavigation, pnavFindParams->Locale, pnavFindParams->compFlags, pnavFindParams->pszName, pnavFindParams->cchLength, pnavFindParams->fAncestorOk);
  812. }
  813. static HMLIMGLST OnIPC_MLNavCtrl_GetImageList(void)
  814. {
  815. return NavCtrlI_GetImageList(hNavigation);
  816. }
  817. static HNAVITEM OnIPC_MLNavCtrl_GetFirst(void)
  818. {
  819. return NavCtrlI_GetRoot(hNavigation);
  820. }
  821. static INT OnIPC_MLNavCtrl_GetIndent(void)
  822. {
  823. return NavCtrlI_GetIndent(hNavigation);
  824. }
  825. static DWORD OnIPC_MLNavCtrl_GetStyle(void)
  826. {
  827. return NavCtrlI_GetStyle(hNavigation);
  828. }
  829. static HNAVITEM OnIPC_MLNavCtrl_GetSelection(void)
  830. {
  831. return NavCtrlI_GetSelection(hNavigation);
  832. }
  833. static HWND OnIPC_MLNavCtrl_GetHWND(void)
  834. {
  835. return NavCtrlI_GetHWND(hNavigation);
  836. }
  837. static HNAVITEM OnIPC_MLNavCtrl_HitTest(NAVHITTEST *pnavHit)
  838. {
  839. if (!pnavHit) return NULL;
  840. pnavHit->hItem = NavCtrlI_HitTest(hNavigation, &pnavHit->pt, &pnavHit->flags);
  841. return pnavHit->hItem;
  842. }
  843. static HNAVITEM OnIPC_MLNavCtrl_InsertItem(NAVINSERTSTRUCT *pnavInsert)
  844. {
  845. if (!hNavigation || !pnavInsert || pnavInsert->item.cbSize != sizeof(NAVITEM)) return NULL;
  846. return NavCtrlI_InsertItem(hNavigation, pnavInsert->hInsertAfter, pnavInsert->hParent, (NAVITEM_I*)&pnavInsert->item.mask);
  847. }
  848. static BOOL OnIPC_MLNavItem_EnsureVisible(HNAVITEM hItem)
  849. {
  850. return NavItemI_EnsureVisible(hItem);
  851. }
  852. static BOOL OnIPC_MLNavItem_Expand(NAVITEMEXPAND *pnavExpand)
  853. {
  854. return (pnavExpand) ? NavItemI_Expand(pnavExpand->hItem, pnavExpand->fCmdExpand) : FALSE;
  855. }
  856. static HNAVITEM OnIPC_MLNavItem_GetChild(HNAVITEM hItem)
  857. {
  858. return NavItemI_GetChild(hItem);
  859. }
  860. static INT OnIPC_MLNavItem_GetChildrenCount(HNAVITEM hItem)
  861. {
  862. return NavItemI_GetChildrenCount(hItem);
  863. }
  864. static INT OnIPC_MLNavItem_GetFullName(NAVITEMFULLNAME* pnavFullName)
  865. {
  866. return (pnavFullName) ? NavItemI_GetFullName(pnavFullName->hItem, pnavFullName->pszText, pnavFullName->cchTextMax) : 0;
  867. }
  868. static BOOL OnIPC_MLNavItem_GetInfo(NAVITEM *pnavItem)
  869. {
  870. return (pnavItem && pnavItem->cbSize == sizeof(NAVITEM)) ? NavItemI_GetIndirect(pnavItem->hItem, (NAVITEM_I*)&pnavItem->mask) : FALSE;
  871. }
  872. static HNAVITEM OnIPC_MLNavItem_GetNext(HNAVITEM hItem)
  873. {
  874. return NavItemI_GetNext(hItem);
  875. }
  876. static WORD OnIPC_MLNavItem_GetOrder(HNAVITEM hItem)
  877. {
  878. return NavItemI_GetOrder(hItem);
  879. }
  880. static HNAVITEM OnIPC_MLNavItem_GetParent(HNAVITEM hItem)
  881. {
  882. return NavItemI_GetParent(hItem);
  883. }
  884. static HNAVITEM OnIPC_MLNavItem_GetPrevious(HNAVITEM hItem)
  885. {
  886. return NavItemI_GetPrevious(hItem);
  887. }
  888. static BOOL OnIPC_MLNavItem_GetRect(NAVITEMGETRECT *pnavRect)
  889. {
  890. return (pnavRect) ? NavItemI_GetRect(pnavRect->hItem, &pnavRect->rc, pnavRect->fItem) : FALSE;
  891. }
  892. static UINT OnIPC_MLNavItem_GetState(HNAVITEM hItem)
  893. {
  894. return NavItemI_GetState(hItem, 0xFFFFFFFF);
  895. }
  896. static BOOL OnIPC_MLNavItem_HasChildrenReal(HNAVITEM hItem)
  897. {
  898. return NavItemI_HasChildrenReal(hItem);
  899. }
  900. static BOOL OnIPC_MLNavItem_Invalidate(NAVITEMINAVLIDATE *pnavInvalidate)
  901. {
  902. return (pnavInvalidate) ? NavItemI_Invalidate(pnavInvalidate->hItem, pnavInvalidate->prc, pnavInvalidate->fErase) : FALSE;
  903. }
  904. static BOOL OnIPC_MLNavItem_Move(NAVITEMMOVE *pnavMove)
  905. {
  906. return (pnavMove) ? NavItemI_Move(pnavMove->hItem, pnavMove->hItemDest, pnavMove->fAfter) : FALSE;
  907. }
  908. static BOOL OnIPC_MLNavItem_Select(HNAVITEM hItem)
  909. {
  910. return NavItemI_Select(hItem);
  911. }
  912. static BOOL OnIPC_MLNavItem_SetInfo(NAVITEM *pnavItem)
  913. {
  914. return (pnavItem && pnavItem->cbSize == sizeof(NAVITEM)) ? NavItemI_SetIndirect(pnavItem->hItem, (NAVITEM_I*)&pnavItem->mask) : FALSE;
  915. }
  916. static WORD OnIPC_MLNavItem_SetOrder(NAVITEMORDER *pnavOrder)
  917. {
  918. return (pnavOrder) ? NavItemI_SetOrder(pnavOrder->hItem, pnavOrder->order, pnavOrder->flags) : 0xFFFF;
  919. }
  920. static BOOL OnIPC_MLNavItem_EditTitle(HNAVITEM hItem)
  921. {
  922. return NavItemI_EditTitle(hItem);
  923. }
  924. static BOOL OnIPC_MLNavCtrl_EndEditTitle(BOOL fCancel)
  925. {
  926. return NavCtrlI_EndEditTitle(hNavigation, fCancel);
  927. }
  928. static BOOL OnIPC_MLRating_Draw(RATINGDRAWPARAMS *prdp)
  929. {
  930. if (!prdp) return FALSE;
  931. return MLRatingI_Draw(prdp->hdcDst, prdp->maxValue, prdp->value, prdp->trackingValue,
  932. (prdp->hMLIL) ? prdp->hMLIL : hmlilRating,
  933. (prdp->hMLIL) ? prdp->index : 0,
  934. &prdp->rc, prdp->fStyle);
  935. }
  936. static INT OnIPC_MLRating_Hittest(RATINGHITTESTPARAMS *prhtp)
  937. {
  938. LONG result;
  939. if (!prhtp) return FALSE;
  940. result = MLRatingI_HitTest(prhtp->pt, prhtp->maxValue,
  941. (prhtp->hMLIL) ? prhtp->hMLIL : hmlilRating,
  942. &prhtp->rc, prhtp->fStyle);
  943. prhtp->hitFlags = HIWORD(result);
  944. prhtp->value = LOWORD(result);
  945. return prhtp->value;
  946. }
  947. static BOOL OnIPC_MLRating_CalcRect(RECT *prc)
  948. {
  949. return (prc) ? MLRatingI_CalcMinRect(prc->top, (prc->left) ? (HMLIMGLST)(LONG_PTR)prc->left : hmlilRating, prc) : FALSE;
  950. }
  951. static BOOL OnIPC_MLCloud_Draw(CLOUDDRAWPARAMS *prdp)
  952. {
  953. if (!prdp) return FALSE;
  954. return MLCloudI_Draw(prdp->hdcDst, prdp->value, (prdp->hMLIL) ? prdp->hMLIL : hmlilCloud,
  955. (prdp->hMLIL) ? prdp->index : 0, &prdp->rc);
  956. }
  957. static BOOL OnIPC_MLCloud_CalcRect(RECT *prc)
  958. {
  959. return (prc) ? MLCloudI_CalcMinRect((prc->left) ? (HMLIMGLST)(LONG_PTR)prc->left : hmlilCloud, prc) : FALSE;
  960. }
  961. static BOOL OnIPC_SkinWindow(MLSKINWINDOW* pmlsw)
  962. {
  963. return (pmlsw) ? SkinWindowEx(pmlsw->hwndToSkin, pmlsw->skinType, pmlsw->style) : FALSE;
  964. }
  965. static BOOL OnIPC_UnskinWindow(HWND hwndToUnskin)
  966. {
  967. return UnskinWindow(hwndToUnskin);
  968. }
  969. static BOOL OnIPC_TrackSkinnedPopup(MLSKINNEDPOPUP *pmlsp)
  970. {
  971. if (pmlsp && pmlsp->cbSize == sizeof(MLSKINNEDPOPUP))
  972. {
  973. return MediaLibrary_TrackPopupEx(pmlsp->hmenu, pmlsp->fuFlags, pmlsp->x, pmlsp->y, pmlsp->hwnd, pmlsp->lptpm,
  974. pmlsp->hmlil, pmlsp->width, pmlsp->skinStyle, pmlsp->customProc, pmlsp->customParam);
  975. }
  976. else
  977. return FALSE;
  978. }
  979. static HANDLE OnIPC_InitSkinnedPopupHook(MLSKINNEDPOPUP *pmlsp)
  980. {
  981. if (pmlsp && pmlsp->cbSize == sizeof(MLSKINNEDPOPUP))
  982. {
  983. return MediaLibrary_InitSkinnedPopupHook(pmlsp->hwnd, pmlsp->hmlil, pmlsp->width, pmlsp->skinStyle,
  984. pmlsp->customProc, pmlsp->customParam);
  985. }
  986. return NULL;
  987. }
  988. static BOOL OnIPC_RemoveSkinnedPopupHook(HANDLE hPopupHook)
  989. {
  990. RemoveSkinnedPopupHook(hPopupHook);
  991. return TRUE;
  992. }
  993. static BOOL OnIPC_RatingColumn_Paint(RATINGCOLUMNPAINT *prcp)
  994. {
  995. return (prcp) ? MLRatingColumnI_Paint((RATINGCOLUMNPAINT_I*)prcp) : FALSE;
  996. }
  997. static BOOL OnIPC_RatingColumn_OnClick(RATINGCOLUMN *pRating)
  998. {
  999. return (pRating) ? MLRatingColumnI_Click((RATINGCOLUMN_I*)pRating) : FALSE;
  1000. }
  1001. static BOOL OnIPC_RatingColumn_OnTrack(RATINGCOLUMN *pRating)
  1002. {
  1003. if (!pRating) return FALSE;
  1004. MLRatingColumnI_Track((RATINGCOLUMN_I*)pRating);
  1005. return TRUE;
  1006. }
  1007. static BOOL OnIPC_RatingColumn_CancelTracking(BOOL bRedrawNow)
  1008. {
  1009. MLRatingColumnI_CancelTracking(bRedrawNow);
  1010. return TRUE;
  1011. }
  1012. static BOOL OnIPC_RatingColumn_BeginDrag(RATINGCOLUMN *pRating)
  1013. {
  1014. return (pRating) ? MLRatingColumnI_BeginDrag((RATINGCOLUMN_I*)pRating) : FALSE;
  1015. }
  1016. static BOOL OnIPC_RatingColumn_OnDrag(POINT *ppt)
  1017. {
  1018. return (ppt) ? MLRatingColumnI_Drag(*ppt) : FALSE;
  1019. }
  1020. static BOOL OnIPC_RatingColumn_OnEndDrag(RATINGCOLUMN *pRating)
  1021. {
  1022. return (pRating) ? MLRatingColumnI_EndDrag((RATINGCOLUMN_I*)pRating) : FALSE;
  1023. }
  1024. static BOOL OnIPC_RatingColumn_Animate(RATINGCOLUMN *pRating)
  1025. {
  1026. if (!pRating) return FALSE;
  1027. MLRatingColumnI_Animate(pRating->hwndList, pRating->iItem, pRating->iSubItem);
  1028. return TRUE;
  1029. }
  1030. static INT OnIPC_RatingColumn_GetMinWidth()
  1031. {
  1032. return MLRatingColumnI_GetMinWidth();
  1033. }
  1034. static BOOL OnIPC_CloudColumn_GetWidth(INT *width)
  1035. {
  1036. if (!width) return FALSE;
  1037. *width = MLCloudColumnI_GetWidth(*width);
  1038. return TRUE;
  1039. }
  1040. static BOOL OnIPC_CloudColumn_Paint(RATINGCOLUMNPAINT *prcp)
  1041. {
  1042. return (prcp) ? MLCloudColumnI_Paint((CLOUDCOLUMNPAINT_I*)prcp) : FALSE;
  1043. }
  1044. static INT OnIPC_CloudColumn_GetMinWidth()
  1045. {
  1046. return MLCloudColumnI_GetMinWidth();
  1047. }
  1048. static BOOL OnIPC_RatingColumn_FillBackString(RATINGBACKTEXT *prbt)
  1049. {
  1050. if (!prbt) return FALSE;
  1051. MLRatingColumnI_FillBackString(prbt->pszText, prbt->cchTextMax, prbt->nColumnWidth, prbt->fStyle);
  1052. return TRUE;
  1053. }
  1054. static BOOL OnIPC_RatingColumn_GetWidth(RATINGWIDTH *prw)
  1055. {
  1056. if (!prw) return FALSE;
  1057. prw->width = MLRatingColumnI_GetWidth(prw->width, prw->fStyle);
  1058. return TRUE;
  1059. }
  1060. static HWND OnIPC_CreateWebInfo(WEBINFOCREATE *pWebInfoCreate)
  1061. {
  1062. if (!pWebInfoCreate) return NULL;
  1063. if (-1 == pWebInfoCreate->cy) pWebInfoCreate->cy = WEBINFO_PREFFERED_HEIGHT;
  1064. return CreateWebInfoWindow(pWebInfoCreate->hwndParent, pWebInfoCreate->uMsgQuery,
  1065. pWebInfoCreate->x, pWebInfoCreate->y, pWebInfoCreate->cx, pWebInfoCreate->cy, pWebInfoCreate->ctrlId);
  1066. }
  1067. static HWND OnIPC_CreateFileView(MLFILEVIEWCREATESTRUCT *pfvcs)
  1068. {
  1069. if (!pfvcs) return NULL;
  1070. return FileView_CreateDialog(pfvcs->hwndParent, pfvcs->fStyle, pfvcs->hwndInsertAfter, pfvcs->x, pfvcs->y, pfvcs->cx, pfvcs->cy);
  1071. }
  1072. INT_PTR pluginHandleIpcMessage(HWND hwndML, int msg, INT_PTR param)
  1073. {
  1074. switch (msg)
  1075. {
  1076. case ML_IPC_PL_GETRATING: return getPlRating(hwndML, param);
  1077. case ML_IPC_PL_SETRATING: return IPC_PL_SetRating(hwndML, param);
  1078. case ML_IPC_GETRATING: return IPC_GetRating(hwndML, param);
  1079. case ML_IPC_SETRATING: return IPC_SetRating(hwndML, param);
  1080. case ML_IPC_OPENPREFS:
  1081. {
  1082. extern prefsDlgRecW myPrefsItem;
  1083. SendMessage(plugin.hwndParent, WM_WA_IPC, (WPARAM)&myPrefsItem, IPC_OPENPREFSTOPAGE);
  1084. }
  1085. return 1;
  1086. case ML_IPC_GETTREE: return IPC_GetTree(param);
  1087. case ML_IPC_TREEITEM_INSERT:
  1088. case ML_IPC_TREEITEM_INSERTW:
  1089. case ML_IPC_ADDTREEITEM_EX:
  1090. case ML_IPC_ADDTREEITEM:
  1091. case ML_IPC_TREEITEM_ADD:
  1092. case ML_IPC_TREEITEM_ADDW: return IPC_InsertView(msg, param);
  1093. case ML_IPC_SETTREEITEM_EX:
  1094. case ML_IPC_SETTREEITEM:
  1095. case ML_IPC_TREEITEM_SETINFO:
  1096. case ML_IPC_TREEITEM_SETINFOW: return (INT_PTR)IPC_SetView(msg, param);
  1097. case ML_IPC_TREEITEM_GETINFO:
  1098. case ML_IPC_TREEITEM_GETINFOW: return (INT_PTR)IPC_GetView(msg, param);
  1099. case ML_IPC_GETCURTREEITEM: return (INT_PTR)NavItemI_GetId(NavCtrlI_GetSelection(hNavigation));
  1100. case ML_IPC_TREEITEM_GETSELECTED: return (INT_PTR)NavCtrlI_GetSelection(hNavigation);
  1101. case ML_IPC_SETCURTREEITEM: return (INT_PTR)NavItemI_Select(NavCtrlI_FindItem(hNavigation, (INT)param));
  1102. case ML_IPC_TREEITEM_SELECT: return (INT_PTR)NavItemI_Select((HNAVITEM)param);
  1103. case ML_IPC_DELTREEITEM: return (INT_PTR)NavCtrlI_DeleteItem(hNavigation, NavCtrlI_FindItem(hNavigation, (INT)param));
  1104. case ML_IPC_TREEITEM_DELETE: return (INT_PTR)NavCtrlI_DeleteItem(hNavigation, (HNAVITEM)param);
  1105. case ML_IPC_TREEITEM_GETHANDLE: return (INT_PTR)NavCtrlI_FindItem(hNavigation, (INT)param);
  1106. case ML_IPC_TREEITEM_GETCHILD: return (INT_PTR)((MLTI_ROOT == param) ? NavCtrlI_GetRoot(hNavigation) : NavItemI_GetChild((HNAVITEM)param));
  1107. case ML_IPC_TREEITEM_GETNEXT: return (INT_PTR)NavItemI_GetNext((HNAVITEM)param);
  1108. case ML_IPC_TREEITEM_GETCHILD_ID: return (INT_PTR)NavItemI_GetId(NavItemI_GetChild(NavCtrlI_FindItem(hNavigation, (INT)param)));
  1109. case ML_IPC_TREEITEM_GETNEXT_ID: return (INT_PTR)NavItemI_GetId(NavItemI_GetNext(NavCtrlI_FindItem(hNavigation, (INT)param)));
  1110. case ML_IPC_TREEITEM_GETROOT: return (INT_PTR)NavCtrlI_GetRoot(hNavigation);
  1111. case ML_IPC_ADDTREEIMAGE:
  1112. case ML_IPC_TREEIMAGE_ADD: return (INT_PTR)IPC_RegisterNavigationImage(param);
  1113. case ML_IPC_GET_VIEW_BUTTON_TEXT:
  1114. {
  1115. if (!playBuf[0]) WASABI_API_LNGSTRINGW_BUF(IDS_PLAY, playBuf, ARRAYSIZE(playBuf));
  1116. if (!enqueueBuf[0]) WASABI_API_LNGSTRINGW_BUF(IDS_ENQUEUE, enqueueBuf, ARRAYSIZE(enqueueBuf));
  1117. viewButtons *view = (viewButtons*)param;
  1118. if (view)
  1119. {
  1120. view->play = playBuf;
  1121. view->enqueue = enqueueBuf;
  1122. }
  1123. break;
  1124. }
  1125. case ML_IPC_HANDLEDRAG: return IPC_HandleDrag(hwndML, (mlDropItemStruct*)param);
  1126. case ML_IPC_HANDLEDROP: // hmm, not sure bout this one =)
  1127. return IPC_HandleDrop(param);
  1128. case ML_IPC_SKIN_COMBOBOX: return (param) ? (INT_PTR)(new ComboSkin((HWND)param)) : NULL;
  1129. case ML_IPC_UNSKIN_COMBOBOX: if (param) delete reinterpret_cast<ComboSkin*>(param); return (NULL != param);
  1130. case ML_IPC_SKIN_LISTVIEW: return (SkinWindowEx((HWND)param, SKINNEDWND_TYPE_LISTVIEW, SWS_USESKINCOLORS | SWS_USESKINCURSORS | SWLVS_FULLROWSELECT | SWLVS_DOUBLEBUFFER)) ? param : NULL;
  1131. case ML_IPC_UNSKIN_LISTVIEW: return UnskinWindow((HWND)param);
  1132. case ML_IPC_LISTVIEW_UPDATE: return MLSkinnedScrollWnd_UpdateBars((HWND)param, TRUE);
  1133. case ML_IPC_LISTVIEW_DISABLEHSCROLL:return MLSkinnedScrollWnd_ShowHorzBar((HWND)param, FALSE);
  1134. case ML_IPC_LISTVIEW_DISABLEVSCROLL:return MLSkinnedScrollWnd_ShowVertBar((HWND)param, FALSE);
  1135. case ML_IPC_LISTVIEW_SHOWSORT:
  1136. if (param && ((LV_SKIN_SHOWSORT*)param)->listView)
  1137. {
  1138. if (((LV_SKIN_SHOWSORT*)param)->showSort) return TRUE;
  1139. return SendMessageW((HWND)((LV_SKIN_SHOWSORT*)param)->listView, WM_ML_IPC,
  1140. MAKEWPARAM((((LV_SKIN_SHOWSORT*)param)->showSort) ? 0 : -1, TRUE),
  1141. ML_IPC_SKINNEDLISTVIEW_DISPLAYSORT);
  1142. }
  1143. return 0;
  1144. case ML_IPC_LISTVIEW_SORT:
  1145. if (param && ((LV_SKIN_SORT*)param)->listView)
  1146. {
  1147. return SendMessageW((HWND)((LV_SKIN_SHOWSORT*)param)->listView, WM_ML_IPC,
  1148. MAKEWPARAM(((LV_SKIN_SORT*)param)->columnIndex, ((LV_SKIN_SORT*)param)->ascending),
  1149. ML_IPC_SKINNEDLISTVIEW_DISPLAYSORT);
  1150. }
  1151. return 0;
  1152. case ML_IPC_SENDTOWINAMP:
  1153. return IPC_SendToWinamp(param);
  1154. case ML_IPC_SKIN_WADLG_GETFUNC:
  1155. switch (param)
  1156. {
  1157. case 1: return (INT_PTR)WADlg_getColor;
  1158. case 2: return (INT_PTR)WADlg_handleDialogMsgs;
  1159. case 3: return (INT_PTR)WADlg_DrawChildWindowBorders;
  1160. case 4: return (INT_PTR)WADlg_getBitmap;
  1161. case 32: return (INT_PTR)childresize_init;
  1162. case 33: return (INT_PTR)childresize_resize;
  1163. case 66:
  1164. if (g_config->ReadInt(L"plfont_everywhere", 1))
  1165. {
  1166. INT height = (INT)SendMessageW(plugin.hwndParent, WM_WA_IPC, 3, IPC_GET_GENSKINBITMAP);
  1167. DWORD charset = (DWORD)SendMessageW(plugin.hwndParent, WM_WA_IPC, 2, IPC_GET_GENSKINBITMAP);
  1168. char *fontname = (char*)SendMessageW(plugin.hwndParent, WM_WA_IPC, 1, IPC_GET_GENSKINBITMAP);
  1169. return (INT_PTR)CreateFontA(-height, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, charset, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, fontname);
  1170. }
  1171. return 0;
  1172. }
  1173. break;
  1174. case ML_IPC_ADDTOSENDTO:
  1175. if (param)
  1176. {
  1177. mlAddToSendToStruct *p = (mlAddToSendToStruct *)param;
  1178. if (p->context)
  1179. {
  1180. SendToMenu *a = (SendToMenu*)p->context;
  1181. a->onAddItem(p);
  1182. }
  1183. }
  1184. break;
  1185. case ML_IPC_ADDTOSENDTOW:
  1186. if (param)
  1187. {
  1188. mlAddToSendToStructW *p = (mlAddToSendToStructW *)param;
  1189. if (p->context)
  1190. {
  1191. SendToMenu *a = (SendToMenu*)p->context;
  1192. a->onAddItem(p);
  1193. }
  1194. }
  1195. break;
  1196. case ML_IPC_BRANCHSENDTO:
  1197. if (param)
  1198. {
  1199. mlAddToSendToStructW *p = (mlAddToSendToStructW *)param;
  1200. if (p->context)
  1201. {
  1202. SendToMenu *a = (SendToMenu*)p->context;
  1203. if (p->desc)
  1204. a->endBranch(p->desc);
  1205. else
  1206. a->startBranch();
  1207. }
  1208. }
  1209. break;
  1210. case ML_IPC_ADDTOBRANCH:
  1211. if (param)
  1212. {
  1213. mlAddToSendToStructW *p = (mlAddToSendToStructW *)param;
  1214. if (p->context)
  1215. {
  1216. SendToMenu *a = (SendToMenu*)p->context;
  1217. a->addItemToBranch(p);
  1218. }
  1219. }
  1220. break;
  1221. ///////////// plugin adding/removing
  1222. case ML_IPC_ADD_PLUGIN:
  1223. case ML_IPC_REMOVE_PLUGIN:
  1224. if (param)
  1225. {
  1226. winampMediaLibraryPlugin *p = (winampMediaLibraryPlugin *)param;
  1227. int x, l = m_plugins.GetSize();
  1228. for (x = 0; x < l && m_plugins.Get(x) != (void *)param; x ++);
  1229. if (x < l)
  1230. {
  1231. if (msg == ML_IPC_ADD_PLUGIN) return -1;
  1232. m_plugins.Del(x); // remove this plugin
  1233. return 1;
  1234. }
  1235. if (msg == ML_IPC_REMOVE_PLUGIN) return -1; //plugin not found to delete
  1236. if (p->version > MLHDR_VER && p->version < MLHDR_VER_OLD /*|| p->hDllInstance*/) return -1; //benski> cut the hDllInstance == 0 requirement, BUT you have to do a LoadLibrary to fake it out
  1237. if (msg == ML_IPC_ADD_PLUGIN && p->hDllInstance)
  1238. {
  1239. // if they set the hDllInstance, do a LoadLibrary to increment the reference count
  1240. // that way we can FreeLibrary it safely later
  1241. TCHAR filename[MAX_PATH] = {0};
  1242. GetModuleFileName(p->hDllInstance, filename, MAX_PATH);
  1243. HMODULE dummyLoad = LoadLibraryW(filename);
  1244. assert(dummyLoad == p->hDllInstance);
  1245. }
  1246. p->hwndLibraryParent = hwndML;
  1247. p->hwndWinampParent = plugin.hwndParent;
  1248. m_plugins.Add(p);
  1249. return 1;
  1250. }
  1251. return -1;
  1252. case ML_IPC_SEND_PLUGIN_MESSAGE:
  1253. if (param)
  1254. {
  1255. pluginMessage *m = (pluginMessage*)param;
  1256. return plugin_SendMessage(m->messageType, m->param1, m->param2, m->param3);
  1257. }
  1258. return -1;
  1259. /*
  1260. case ML_IPC_GRACENOTE:
  1261. switch (param)
  1262. {
  1263. case GRACENOTE_TUID: return(INT_PTR)gracenoteGetTuid();
  1264. case GRACENOTE_IS_WORKING: return(INT_PTR)gracenoteIsWorking();
  1265. case GRACENOTE_DO_TIMER_STUFF: return(INT_PTR)gracenoteDoTimerStuff();
  1266. case GRACENOTE_CANCEL_REQUEST: gracenoteCancelRequest(); return 1;
  1267. }
  1268. break;
  1269. */
  1270. case ML_IPC_REFRESH_PREFS:
  1271. refreshPrefs(param);
  1272. return 1;
  1273. case ML_IPC_GETCURRENTVIEW:
  1274. return OnGetCurrentView();
  1275. case ML_IPC_ENSURE_VISIBLE:
  1276. if (!IsVisible())
  1277. toggleVisible();
  1278. return 1;
  1279. case ML_IPC_IS_VISIBLE:
  1280. return IsVisible() ? 1 : 0;
  1281. case ML_IPC_GET_PARENTAL_RATING: // TODO: store this in api_config
  1282. return g_config->ReadInt(L"tvrating", 7);
  1283. case ML_IPC_TOGGLE_VISIBLE:
  1284. toggleVisible();
  1285. return 1;
  1286. case ML_IPC_FOCUS_TREE:
  1287. SetFocus(NavCtrlI_GetHWND(hNavigation));
  1288. return 1;
  1289. case ML_IPC_FLICKERFIX: return (param) ? OnFlickerFixIPC((FLICKERFIX*)param) : FALSE;
  1290. case ML_IPC_GETVERSION: return PLUGIN_VERSION;
  1291. case ML_IPC_SHOW_HELP: return MediaLibrary_OpenHelpUrl((const wchar_t*)param);
  1292. case ML_IPC_IMAGELOADER_LOADDIB: return (INT_PTR)OnIPC_MLImageLoader_LoadDib((MLIMAGESOURCE*)param);
  1293. case ML_IPC_IMAGELOADER_COPYSTRUCT: return (INT_PTR)OnIPC_MLImageLoader_CopyStruct((MLIMAGESOURCECOPY*)param);
  1294. case ML_IPC_IMAGELOADER_FREESTRUCT: return (INT_PTR)OnIPC_MLImageLoader_FreeStruct((MLIMAGESOURCE*)param);
  1295. case ML_IPC_IMAGELOADER_CHECKEXIST: return (INT_PTR)OnIPC_MLImageLoader_CheckExist((MLIMAGESOURCE*)param);
  1296. case ML_IPC_IMAGELIST_CREATE: return (INT_PTR)OnIPC_MLImageList_Create((MLIMAGELISTCREATE*)param);
  1297. case ML_IPC_IMAGELIST_DESTROY: return (INT_PTR)OnIPC_MLImageList_Destroy((HMLIMGLST)param);
  1298. case ML_IPC_IMAGELIST_GETREALLIST: return (INT_PTR)OnIPC_MLImageList_GetRealList((HMLIMGLST)param);
  1299. case ML_IPC_IMAGELIST_GETREALINDEX: return (INT_PTR)OnIPC_MLImageList_GetRealIndex((MLIMAGELISTREALINDEX*)param);
  1300. case ML_IPC_IMAGELIST_ADD: return (INT_PTR)OnIPC_MLImageList_Add((MLIMAGELISTITEM*)param);
  1301. case ML_IPC_IMAGELIST_REPLACE: return (INT_PTR)OnIPC_MLImageList_Replace((MLIMAGELISTITEM*)param);
  1302. case ML_IPC_IMAGELIST_REMOVE: return (INT_PTR)OnIPC_MLImageList_Remove((MLIMAGELISTITEM*)param);
  1303. case ML_IPC_IMAGELIST_GETIMAGESIZE: return (INT_PTR)OnIPC_MLImageList_GetImageSize((MLIMAGELISTIMAGESIZE*)param);
  1304. case ML_IPC_IMAGELIST_GETIMAGECOUNT: return (INT_PTR)OnIPC_MLImageList_GetImageCount((HMLIMGLST)param);
  1305. case ML_IPC_IMAGELIST_GETINDEXFROMTAG: return (INT_PTR)OnIPC_MLImageList_GetIndexFromTag((MLIMAGELISTTAG*)param);
  1306. case ML_IPC_IMAGELIST_GETTAGFROMINDEX: return (INT_PTR)OnIPC_MLImageList_GetTagFromIndex((MLIMAGELISTTAG*)param);
  1307. case ML_IPC_IMAGELIST_CHECKEXIST: return (INT_PTR)OnIPC_MLImageList_CheckItemExist((MLIMAGELISTITEM*)param);
  1308. case ML_IPC_IMAGEFILTER_REGISTER: return (INT_PTR)OnIPC_MLImageFilter_Register((MLIMAGEFILTERINFO*)param);
  1309. case ML_IPC_IMAGEFILTER_UNREGISTER: return (INT_PTR)OnIPC_MLImageFilter_Unregister((const GUID*)param);
  1310. case ML_IPC_IMAGEFILTER_GETINFO: return (INT_PTR)OnIPC_MLImageFilter_GetInfo((MLIMAGEFILTERINFO*)param);
  1311. case ML_IPC_IMAGEFILTER_APPLYEX: return (INT_PTR)OnIPC_MLImageFilter_ApplyEx((MLIMAGEFILTERAPPLYEX*)param);
  1312. case ML_IPC_NAVCTRL_BEGINUPDATE: return (INT_PTR)OnIPC_MLNavCtrl_BeginUpdate((UINT)param);
  1313. case ML_IPC_NAVCTRL_DELETEITEM: return (INT_PTR)OnIPC_MLNavCtrl_DeleteItem((HNAVITEM)param);
  1314. case ML_IPC_NAVCTRL_ENDUPDATE: return (INT_PTR)OnIPC_MLNavCtrl_EndUpdate();
  1315. case ML_IPC_NAVCTRL_ENUMITEMS: return (INT_PTR)OnIPC_MLNavCtrl_EnumItems((NAVCTRLENUMPARAMS*)param);
  1316. case ML_IPC_NAVCTRL_FINDITEMBYID: return (INT_PTR)OnIPC_MLNavCtrl_FindItemById((INT)param);
  1317. case ML_IPC_NAVCTRL_FINDITEMBYNAME: return (INT_PTR)OnIPC_MLNavCtrl_FindItemByName((NAVCTRLFINDPARAMS*)param);
  1318. case ML_IPC_NAVCTRL_GETIMAGELIST: return (INT_PTR)OnIPC_MLNavCtrl_GetImageList();
  1319. case ML_IPC_NAVCTRL_GETFIRST: return (INT_PTR)OnIPC_MLNavCtrl_GetFirst();
  1320. case ML_IPC_NAVCTRL_GETINDENT: return (INT_PTR)OnIPC_MLNavCtrl_GetIndent();
  1321. case ML_IPC_NAVCTRL_GETSELECTION: return (INT_PTR)OnIPC_MLNavCtrl_GetSelection();
  1322. case ML_IPC_NAVCTRL_GETHWND: return (INT_PTR)OnIPC_MLNavCtrl_GetHWND();
  1323. case ML_IPC_NAVCTRL_HITTEST: return (INT_PTR)OnIPC_MLNavCtrl_HitTest((NAVHITTEST*)param);
  1324. case ML_IPC_NAVCTRL_INSERTITEM: return (INT_PTR)OnIPC_MLNavCtrl_InsertItem((NAVINSERTSTRUCT*)param);
  1325. case ML_IPC_NAVCTRL_ENDEDITTITLE: return (INT_PTR)OnIPC_MLNavCtrl_EndEditTitle((BOOL)param);
  1326. case ML_IPC_NAVCTRL_GETSTYLE: return (INT_PTR)OnIPC_MLNavCtrl_GetStyle();
  1327. case ML_IPC_NAVITEM_EDITTITLE: return (INT_PTR)OnIPC_MLNavItem_EditTitle((HNAVITEM)param);
  1328. case ML_IPC_NAVITEM_ENSUREVISIBLE: return (INT_PTR)OnIPC_MLNavItem_EnsureVisible((HNAVITEM)param);
  1329. case ML_IPC_NAVITEM_EXPAND: return (INT_PTR)OnIPC_MLNavItem_Expand((NAVITEMEXPAND*)param);
  1330. case ML_IPC_NAVITEM_GETCHILD: return (INT_PTR)OnIPC_MLNavItem_GetChild((HNAVITEM)param);
  1331. case ML_IPC_NAVITEM_GETCHILDRENCOUNT: return (INT_PTR)OnIPC_MLNavItem_GetChildrenCount((HNAVITEM)param);
  1332. case ML_IPC_NAVITEM_GETFULLNAME: return (INT_PTR)OnIPC_MLNavItem_GetFullName((NAVITEMFULLNAME*)param);
  1333. case ML_IPC_NAVITEM_GETINFO: return (INT_PTR)OnIPC_MLNavItem_GetInfo((NAVITEM*)param);
  1334. case ML_IPC_NAVITEM_GETNEXT: return (INT_PTR)OnIPC_MLNavItem_GetNext((HNAVITEM)param);
  1335. case ML_IPC_NAVITEM_GETORDER: return (INT_PTR)OnIPC_MLNavItem_GetOrder((HNAVITEM)param);
  1336. case ML_IPC_NAVITEM_GETPARENT: return (INT_PTR)OnIPC_MLNavItem_GetParent((HNAVITEM)param);
  1337. case ML_IPC_NAVITEM_GETPREVIOUS: return (INT_PTR)OnIPC_MLNavItem_GetPrevious((HNAVITEM)param);
  1338. case ML_IPC_NAVITEM_GETRECT: return (INT_PTR)OnIPC_MLNavItem_GetRect((NAVITEMGETRECT*)param);
  1339. case ML_IPC_NAVITEM_GETSTATE: return (INT_PTR)OnIPC_MLNavItem_GetState((HNAVITEM)param);
  1340. case ML_IPC_NAVITEM_HASCHILDRENREAL:return (INT_PTR)OnIPC_MLNavItem_HasChildrenReal((HNAVITEM)param);
  1341. case ML_IPC_NAVITEM_INVALIDATE: return (INT_PTR)OnIPC_MLNavItem_Invalidate((NAVITEMINAVLIDATE*)param);
  1342. case ML_IPC_NAVITEM_MOVE: return (INT_PTR)OnIPC_MLNavItem_Move((NAVITEMMOVE*)param);
  1343. case ML_IPC_NAVITEM_SELECT: return (INT_PTR)OnIPC_MLNavItem_Select((HNAVITEM)param);
  1344. case ML_IPC_NAVITEM_SETINFO: return (INT_PTR)OnIPC_MLNavItem_SetInfo((NAVITEM*)param);
  1345. case ML_IPC_NAVITEM_SETORDER: return (INT_PTR)OnIPC_MLNavItem_SetOrder((NAVITEMORDER*)param);
  1346. case ML_IPC_RATING_DRAW: return (INT_PTR)OnIPC_MLRating_Draw((RATINGDRAWPARAMS*)param);
  1347. case ML_IPC_RATING_HITTEST: return (INT_PTR)OnIPC_MLRating_Hittest((RATINGHITTESTPARAMS*)param);
  1348. case ML_IPC_RATING_CALCRECT: return (INT_PTR)OnIPC_MLRating_CalcRect((RECT*)param);
  1349. case ML_IPC_CLOUD_DRAW: return (INT_PTR)OnIPC_MLCloud_Draw((CLOUDDRAWPARAMS*)param);
  1350. case ML_IPC_CLOUD_CALCRECT: return (INT_PTR)OnIPC_MLCloud_CalcRect((RECT*)param);
  1351. case ML_IPC_SKINWINDOW: return (INT_PTR)OnIPC_SkinWindow((MLSKINWINDOW*)param);
  1352. case ML_IPC_UNSKINWINDOW: return (INT_PTR)OnIPC_UnskinWindow((HWND)param);
  1353. case ML_IPC_TRACKSKINNEDPOPUPEX: return (INT_PTR)OnIPC_TrackSkinnedPopup((MLSKINNEDPOPUP*)param);
  1354. case ML_IPC_INITSKINNEDPOPUPHOOK: return (INT_PTR)OnIPC_InitSkinnedPopupHook((MLSKINNEDPOPUP*)param);
  1355. case ML_IPC_REMOVESKINNEDPOPUPHOOK: return (INT_PTR)OnIPC_RemoveSkinnedPopupHook((HANDLE)param);
  1356. case ML_IPC_RATINGCOLUMN_PAINT: return (INT_PTR)OnIPC_RatingColumn_Paint((RATINGCOLUMNPAINT*)param);
  1357. case ML_IPC_RATINGCOLUMN_CLICK: return (INT_PTR)OnIPC_RatingColumn_OnClick((RATINGCOLUMN*)param);
  1358. case ML_IPC_RATINGCOLUMN_TRACK: return (INT_PTR)OnIPC_RatingColumn_OnTrack((RATINGCOLUMN*)param);
  1359. case ML_IPC_RATINGCOLUMN_CANCELTRACKING: return (INT_PTR)OnIPC_RatingColumn_CancelTracking((BOOL)param);
  1360. case ML_IPC_RATINGCOLUMN_BEGINDRAG: return (INT_PTR)OnIPC_RatingColumn_BeginDrag((RATINGCOLUMN*)param);
  1361. case ML_IPC_RATINGCOLUMN_DRAG: return (INT_PTR)OnIPC_RatingColumn_OnDrag((POINT*)param);
  1362. case ML_IPC_RATINGCOLUMN_ENDDRAG: return (INT_PTR)OnIPC_RatingColumn_OnEndDrag((RATINGCOLUMN*)param);
  1363. case ML_IPC_RATINGCOLUMN_ANIMATE: return (INT_PTR)OnIPC_RatingColumn_Animate((RATINGCOLUMN*)param);
  1364. case ML_IPC_RATINGCOLUMN_GETMINWIDTH: return (INT_PTR)OnIPC_RatingColumn_GetMinWidth();
  1365. case ML_IPC_RATINGCOLUMN_FILLBACKSTRING: return (INT_PTR)OnIPC_RatingColumn_FillBackString((RATINGBACKTEXT*)param);
  1366. case ML_IPC_RATINGCOLUMN_GETWIDTH: return (INT_PTR)OnIPC_RatingColumn_GetWidth((RATINGWIDTH*)param);
  1367. case ML_IPC_CLOUDCOLUMN_PAINT: return (INT_PTR)OnIPC_CloudColumn_Paint((RATINGCOLUMNPAINT*)param);
  1368. case ML_IPC_CLOUDCOLUMN_GETMINWIDTH: return (INT_PTR)OnIPC_CloudColumn_GetMinWidth();
  1369. case ML_IPC_CLOUDCOLUMN_GETWIDTH: return (INT_PTR)OnIPC_CloudColumn_GetWidth((INT*)param);
  1370. case ML_IPC_CREATEWEBINFO: return (INT_PTR)OnIPC_CreateWebInfo((WEBINFOCREATE*)param);
  1371. case ML_IPC_CREATEFILEVIEW: return (INT_PTR)OnIPC_CreateFileView((MLFILEVIEWCREATESTRUCT*)param);
  1372. }
  1373. return 0;
  1374. }