main.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. #include "../../Library/ml_pmp/pmp.h"
  2. #include "../Winamp/wa_ipc.h"
  3. #include <vector>
  4. #include "../nu/AutoWide.h"
  5. #include "../nu/AutoChar.h"
  6. #include "../nu/Alias.h"
  7. #include <api/service/waServiceFactory.h>
  8. #include "api.h"
  9. #include "resource.h"
  10. #include "androiddevice.h"
  11. #include "deviceprovider.h"
  12. #include <devguid.h>
  13. #include <shlobj.h>
  14. #include <shlwapi.h>
  15. #include <strsafe.h>
  16. #define PLUGIN_VERSION L"1.72"
  17. static int Init();
  18. static void Quit();
  19. static bool doRegisterForDevNotification(void);
  20. static intptr_t MessageProc(int msg, intptr_t param1, intptr_t param2, intptr_t param3);
  21. extern PMPDevicePlugin plugin = {PMPHDR_VER,0,Init,Quit,MessageProc};
  22. // start-android
  23. static const wchar_t *winampini;
  24. static std::vector<wchar_t*> blacklist;
  25. bool loading_devices[26] = {0,};
  26. static HDEVNOTIFY hDevNotify;
  27. std::vector<AndroidDevice*> devices;
  28. HWND config;
  29. static DeviceProvider *deviceProvider = NULL;
  30. static UINT_PTR rescanTimer = 0;
  31. static void blacklistLoad() {
  32. wchar_t keyname[64] = {0};
  33. int l = GetPrivateProfileIntW(L"pmp_android", L"blacklistnum", 0, winampini);
  34. for(int i=l>100?l-100:0; i<l; i++) {
  35. wchar_t buf[100] = {0};
  36. StringCchPrintfW(keyname, 64, L"blacklist-%d", i);
  37. GetPrivateProfileStringW(L"pmp_android", keyname, L"", buf, 100, winampini);
  38. if(buf[0])
  39. {
  40. blacklist.push_back(_wcsdup(buf));
  41. }
  42. }
  43. }
  44. static void blacklistSave() {
  45. wchar_t buf[64] = {0};
  46. StringCchPrintfW(buf, 64, L"%d", blacklist.size());
  47. WritePrivateProfileStringW(L"pmp_android", L"blacklistnum", buf, winampini);
  48. for(size_t i=0; i<blacklist.size(); i++)
  49. {
  50. StringCchPrintfW(buf, 64, L"blacklist-%d", i);
  51. WritePrivateProfileStringW(L"pmp_android", buf, (const wchar_t*)blacklist.at(i), winampini);
  52. }
  53. }
  54. static wchar_t *makeBlacklistString(wchar_t drive) {
  55. wchar_t path[4]={drive,L":\\"};
  56. wchar_t name[100]=L"";
  57. wchar_t buf[FIELD_LENGTH]=L"";
  58. DWORD serial=0;
  59. UINT olderrmode=SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
  60. GetVolumeInformation(path,name,100,&serial,NULL,NULL,NULL,0);
  61. if(serial)
  62. {
  63. StringCchPrintf(buf, FIELD_LENGTH, L"s:%d",serial);
  64. SetErrorMode(olderrmode);
  65. return _wcsdup(buf);
  66. }
  67. {
  68. ULARGE_INTEGER tfree={0,}, total={0,}, freeb={0,};
  69. GetDiskFreeSpaceEx(path, &tfree, &total, &freeb);
  70. StringCchPrintf(buf, FIELD_LENGTH, L"n:%s,%d,%d", name, total.HighPart, total.LowPart);
  71. SetErrorMode(olderrmode);
  72. return _wcsdup(buf);
  73. }
  74. }
  75. static bool blacklistCheck(wchar_t drive)
  76. {
  77. wchar_t *s = makeBlacklistString(drive);
  78. if (s)
  79. {
  80. for(size_t i=0; i<blacklist.size(); i++)
  81. {
  82. if(!wcscmp(s,(wchar_t*)blacklist.at(i)))
  83. {
  84. free(s);
  85. return true;
  86. }
  87. }
  88. free(s);
  89. }
  90. return false;
  91. }
  92. static bool blacklistAdd(const wchar_t drive)
  93. {
  94. wchar_t *s = makeBlacklistString(drive);
  95. if (s)
  96. {
  97. for(size_t i=0; i<blacklist.size(); i++)
  98. {
  99. if(!wcscmp(s,(wchar_t*)blacklist.at(i)))
  100. {
  101. free(s);
  102. return false;
  103. }
  104. }
  105. blacklist.push_back(s);
  106. }
  107. return true;
  108. }
  109. static BOOL
  110. Device_IsiPod(const wchar_t drive)
  111. {
  112. const wchar_t test[] = {drive, L":\\iPod_Control"};
  113. WIN32_FIND_DATAW findData;
  114. HANDLE file = FindFirstFileW(test, &findData);
  115. if (INVALID_HANDLE_VALUE != file)
  116. {
  117. FindClose(file);
  118. if (0 != (FILE_ATTRIBUTE_DIRECTORY & findData.dwFileAttributes))
  119. return TRUE;
  120. }
  121. return FALSE;
  122. }
  123. static BOOL
  124. Device_IsAndroid(const wchar_t drive)
  125. {
  126. const wchar_t test[] = {drive, L":\\Android"};
  127. WIN32_FIND_DATAW findData;
  128. HANDLE file = FindFirstFileW(test, &findData);
  129. if (INVALID_HANDLE_VALUE != file)
  130. {
  131. FindClose(file);
  132. if (0 != (FILE_ATTRIBUTE_DIRECTORY & findData.dwFileAttributes))
  133. return TRUE;
  134. }
  135. return FALSE;
  136. }
  137. static BOOL
  138. Device_IsSizeOk(const wchar_t drive)
  139. {
  140. const wchar_t test[] = {drive, L":\\"};
  141. ULARGE_INTEGER total;
  142. if (0 == GetDiskFreeSpaceExW(test, NULL, &total, NULL) ||
  143. total.HighPart == 0 && total.LowPart == 0)
  144. {
  145. return FALSE;
  146. }
  147. return TRUE;
  148. }
  149. static BOOL
  150. Device_IsOkToConnect(const wchar_t drive)
  151. {
  152. const wchar_t test[] = {drive, TEXT(":\\Winamp\\")TAG_CACHE};
  153. wchar_t title[128] = {0};
  154. wchar_t message[1024] = {0};
  155. int result;
  156. if (FALSE != PathFileExistsW(test))
  157. return TRUE;
  158. StringCbPrintfW(message, sizeof(message), WASABI_API_LNGSTRINGW(IDS_REMOVEABLE_DRIVE_DETECTED),
  159. towupper(drive));
  160. WASABI_API_LNGSTRINGW_BUF(IDS_WINAMP_PMP_SUPPORT,title,ARRAYSIZE(title));
  161. result = MessageBoxW(NULL, message, title,
  162. MB_YESNO | MB_SETFOREGROUND | MB_TOPMOST |
  163. MB_ICONINFORMATION);
  164. if(IDNO == result)
  165. {
  166. return FALSE;
  167. }
  168. return TRUE;
  169. }
  170. static Nullsoft::Utility::LockGuard connect_guard;
  171. static int ThreadFunc_Load(HANDLE handle, void *user_data, intptr_t id)
  172. {
  173. wchar_t drive = (wchar_t)id;
  174. if (FALSE == Device_IsOkToConnect(drive))
  175. {
  176. Nullsoft::Utility::AutoLock connect_lock(connect_guard);
  177. blacklistAdd(drive);
  178. blacklistSave();
  179. }
  180. else
  181. {
  182. pmpDeviceLoading load;
  183. Device * d = new AndroidDevice(drive,&load);
  184. }
  185. loading_devices[drive-'A'] = false;
  186. deviceProvider->DecrementActivity();
  187. return 0;
  188. }
  189. //#include <WinIoCtl.h>
  190. void connectDrive(wchar_t drive, bool checkSize=true, bool checkBlacklist=true)
  191. {
  192. Nullsoft::Utility::AutoLock connect_lock(connect_guard);
  193. // capitalize
  194. if (drive >= 'a' && drive <= 'z')
  195. drive = drive - 32;
  196. // reject invalid drive letters
  197. if (drive < 'A' || drive > 'Z')
  198. return;
  199. if(checkBlacklist && blacklistCheck(drive))
  200. return;
  201. // if device is taken already ignore
  202. for (std::vector<AndroidDevice*>::const_iterator e = devices.begin(); e != devices.end(); e++)
  203. {
  204. if ((*e)->drive == drive)
  205. return;
  206. }
  207. if (loading_devices[drive-'A'])
  208. return;
  209. loading_devices[drive-'A'] = true;
  210. if(FALSE == checkSize || FALSE != Device_IsSizeOk(drive))
  211. {
  212. if (FALSE != Device_IsAndroid(drive) &&
  213. FALSE == Device_IsiPod(drive))
  214. {
  215. deviceProvider->IncrementActivity();
  216. if (NULL != WASABI_API_THREADPOOL &&
  217. 0 == WASABI_API_THREADPOOL->RunFunction(0, ThreadFunc_Load, 0,
  218. (int)drive, api_threadpool::FLAG_LONG_EXECUTION))
  219. {
  220. return;
  221. }
  222. deviceProvider->DecrementActivity();
  223. }
  224. }
  225. loading_devices[drive-'A'] = false;
  226. }
  227. static void autoDetectCallback(wchar_t drive,UINT type)
  228. {
  229. if(type == DRIVE_REMOVABLE)
  230. {
  231. connectDrive(drive, true, true);
  232. }
  233. }
  234. // end-android
  235. static int Init()
  236. {
  237. WasabiInit();
  238. // start-android
  239. winampini = (const wchar_t*)SendMessage(plugin.hwndWinampParent,WM_WA_IPC,0,IPC_GETINIFILEW);
  240. // need to have this initialised before we try to do anything with localisation features
  241. WASABI_API_START_LANG(plugin.hDllInstance,PmpAndroidLangGUID);
  242. // end-android
  243. static wchar_t szDescription[256];
  244. StringCchPrintfW(szDescription, ARRAYSIZE(szDescription),
  245. WASABI_API_LNGSTRINGW(IDS_NULLSOFT_ANDROID_DEVICE_PLUGIN), PLUGIN_VERSION);
  246. plugin.description = szDescription;
  247. /** load up the backlist */
  248. blacklistLoad();
  249. if (NULL != AGAVE_API_DEVICEMANAGER &&
  250. NULL == deviceProvider)
  251. {
  252. if (SUCCEEDED(DeviceProvider::CreateInstance(&deviceProvider)) &&
  253. FAILED(deviceProvider->Register(AGAVE_API_DEVICEMANAGER)))
  254. {
  255. deviceProvider->Release();
  256. deviceProvider = NULL;
  257. }
  258. }
  259. /* Our device shows up as a normal drive */
  260. if (NULL == deviceProvider ||
  261. FAILED(deviceProvider->BeginDiscovery(AGAVE_API_DEVICEMANAGER)))
  262. {
  263. SendMessage(plugin.hwndPortablesParent,WM_PMP_IPC,(WPARAM)autoDetectCallback,PMP_IPC_ENUM_ACTIVE_DRIVES);
  264. }
  265. return 0;
  266. }
  267. static void Quit()
  268. {
  269. if (NULL != deviceProvider)
  270. {
  271. deviceProvider->Unregister();
  272. deviceProvider->Release();
  273. deviceProvider = NULL;
  274. }
  275. WasabiQuit();
  276. UnregisterDeviceNotification(hDevNotify);
  277. AndroidDevice::CloseDatabase();
  278. }
  279. static wchar_t FirstDriveFromMask(ULONG *unitmask) {
  280. char i;
  281. ULONG adj = 0x1, mask = *unitmask;
  282. for(i=0; i<26; ++i) {
  283. if(mask & 0x1) {
  284. *unitmask -= adj;
  285. break;
  286. }
  287. adj = adj << 1;
  288. mask = mask >> 1;
  289. }
  290. return (i+L'A');
  291. }
  292. static int GetNumberOfDrivesFromMask(ULONG unitmask) {
  293. int count = 0;
  294. for(int i=0; i<26; ++i)
  295. {
  296. if(unitmask & 0x1)
  297. count++;
  298. unitmask = unitmask >> 1;
  299. }
  300. return count;
  301. }
  302. static void CALLBACK RescanOnTimer(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
  303. {
  304. KillTimer(hwnd, idEvent);
  305. if (idEvent == rescanTimer)
  306. rescanTimer = 0;
  307. if (NULL == deviceProvider ||
  308. FAILED(deviceProvider->BeginDiscovery(AGAVE_API_DEVICEMANAGER)))
  309. {
  310. PostMessage(plugin.hwndPortablesParent,WM_PMP_IPC,(WPARAM)autoDetectCallback,PMP_IPC_ENUM_ACTIVE_DRIVES);
  311. }
  312. }
  313. int wmDeviceChange(WPARAM wParam, LPARAM lParam)
  314. {
  315. UINT olderrmode=SetErrorMode(SEM_FAILCRITICALERRORS);
  316. if(wParam==DBT_DEVICEARRIVAL || wParam==DBT_DEVICEREMOVECOMPLETE)
  317. { // something has been inserted or removed
  318. PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)lParam;
  319. if(lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
  320. { // its a volume
  321. PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb;
  322. if((!(lpdbv->dbcv_flags & DBTF_MEDIA) && !(lpdbv->dbcv_flags & DBTF_NET)))
  323. { // its not a network drive or a CD/floppy, game on!
  324. ULONG dbcv_unitmask = lpdbv->dbcv_unitmask;
  325. // see just how many drives have been flagged on the action
  326. // eg one android drive could have multiple partitions that we handle
  327. int count = GetNumberOfDrivesFromMask(dbcv_unitmask);
  328. for(int j = 0; j < count; j++)
  329. {
  330. wchar_t drive = FirstDriveFromMask(&dbcv_unitmask);
  331. if((wParam == DBT_DEVICEARRIVAL) && !blacklistCheck(drive))
  332. { // connected
  333. connectDrive(drive);
  334. //send a message as if the user just selected a drive from the combo box, this way the fields are refreshed to the correct device's settings
  335. SendMessage(config, WM_COMMAND,MAKEWPARAM(IDC_DRIVESELECT,CBN_SELCHANGE),0);
  336. }
  337. else
  338. { // removal
  339. for(size_t i=0; i < devices.size(); i++)
  340. {
  341. AndroidDevice * d = (AndroidDevice*)devices.at(i);
  342. if(d->drive == drive)
  343. {
  344. devices.erase(devices.begin() + i);
  345. if(config) SendMessage(config,WM_USER,0,0); //refresh fields
  346. if(config) SendMessage(config,WM_COMMAND, MAKEWPARAM(IDC_DRIVESELECT,CBN_SELCHANGE),0); //update to correct device change as if the user had clicked on the combo box themself
  347. SendMessage(plugin.hwndPortablesParent,WM_PMP_IPC,(intptr_t)d,PMP_IPC_DEVICEDISCONNECTED);
  348. delete d;
  349. i--;
  350. }
  351. }
  352. }
  353. }
  354. }
  355. }
  356. }
  357. else
  358. {
  359. rescanTimer = SetTimer(NULL, rescanTimer, 10000, RescanOnTimer);
  360. }
  361. SetErrorMode(olderrmode);
  362. return 0;
  363. }
  364. static int IsDriveConnectedToPMP(wchar_t drive)
  365. {
  366. for(size_t i = 0; i < devices.size(); i++)
  367. {
  368. if(((AndroidDevice*)devices.at(i))->drive == drive)
  369. {
  370. return 1;
  371. }
  372. }
  373. return 0;
  374. }
  375. static INT_PTR CALLBACK config_dialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  376. {
  377. switch(uMsg)
  378. {
  379. case WM_INITDIALOG:
  380. {
  381. for(wchar_t d=L'A'; d<='Z'; d++)
  382. {
  383. wchar_t drive[3] = {d,L':',0}, drv[4] = {d,L':','\\',0};
  384. UINT uDriveType = GetDriveType(drv);
  385. if(uDriveType == DRIVE_REMOVABLE || uDriveType == DRIVE_CDROM || uDriveType == DRIVE_FIXED) {
  386. int position = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_ADDSTRING,0,(LPARAM)drive);
  387. SendDlgItemMessage(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_SETITEMDATA,position,d);
  388. }
  389. }
  390. SendDlgItemMessage(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_SETCURSEL,0,0);
  391. SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_COMBO_MANUALCONNECT,CBN_SELCHANGE),0);
  392. }
  393. break;
  394. case WM_CLOSE:
  395. EndDialog(hwndDlg,0);
  396. break;
  397. case WM_COMMAND:
  398. switch(LOWORD(wParam)) {
  399. case IDC_COMBO_MANUALCONNECT:
  400. {
  401. if(HIWORD(wParam)==CBN_SELCHANGE) {
  402. int indx = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_GETCURSEL,0,0);
  403. wchar_t drive = (wchar_t)SendDlgItemMessage(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_GETITEMDATA,indx,0);
  404. if(indx >= 0)
  405. {
  406. int connected = IsDriveConnectedToPMP(drive), isblacklisted = blacklistCheck(drive);
  407. EnableWindow(GetDlgItem(hwndDlg, IDC_MANUALCONNECT), !connected && !isblacklisted);
  408. EnableWindow(GetDlgItem(hwndDlg, IDC_MANUALDISCONNECT), connected);
  409. EnableWindow(GetDlgItem(hwndDlg, IDC_MANUALBLACKLIST), TRUE);
  410. SetDlgItemText(hwndDlg, IDC_MANUALBLACKLIST, WASABI_API_LNGSTRINGW(isblacklisted ? IDS_UNBLACKLIST_DRIVE : IDS_BLACKLIST_DRIVE));
  411. }
  412. }
  413. }
  414. break;
  415. case IDC_MANUALCONNECT:
  416. {
  417. char titleStr[32] = {0};
  418. if(MessageBoxA(hwndDlg, WASABI_API_LNGSTRING(IDS_MANUAL_CONNECT_PROMPT),
  419. WASABI_API_LNGSTRING_BUF(IDS_WARNING,titleStr,32), MB_YESNO) == IDYES)
  420. {
  421. int indx = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_GETCURSEL,0,0);
  422. wchar_t drive = (wchar_t)SendDlgItemMessage(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_GETITEMDATA,indx,0);
  423. if(drive >= L'A' && drive <= L'Z') {
  424. wchar_t *bl = makeBlacklistString(drive);
  425. if (bl)
  426. {
  427. for(size_t i=0; i<blacklist.size(); i++)
  428. {
  429. if(!wcscmp(bl,(wchar_t*)blacklist.at(i)))
  430. {
  431. free(blacklist.at(i));
  432. blacklist.erase(blacklist.begin() + i);
  433. break;
  434. }
  435. }
  436. free(bl);
  437. }
  438. connectDrive(drive,false);
  439. // should do a better check here incase of failure, etc
  440. EnableWindow(GetDlgItem(hwndDlg, IDC_MANUALCONNECT), FALSE);
  441. EnableWindow(GetDlgItem(hwndDlg, IDC_MANUALDISCONNECT), TRUE);
  442. }
  443. }
  444. }
  445. break;
  446. case IDC_MANUALDISCONNECT:
  447. {
  448. int indx = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_GETCURSEL,0,0);
  449. wchar_t drive = (wchar_t)SendDlgItemMessage(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_GETITEMDATA,indx,0);
  450. if(drive >= L'A' && drive <= L'Z')
  451. {
  452. for(size_t i=0; i < devices.size(); i++)
  453. {
  454. AndroidDevice * d = (AndroidDevice*)devices.at(i);
  455. if(d->drive == drive)
  456. {
  457. devices.erase(devices.begin() + i);
  458. if(config) SendMessage(config,WM_USER,0,0); //refresh fields
  459. if(config) SendMessage(config,WM_COMMAND, MAKEWPARAM(IDC_DRIVESELECT,CBN_SELCHANGE),0); //update to correct device change as if the user had clicked on the combo box themself
  460. SendMessage(plugin.hwndPortablesParent,WM_PMP_IPC,(intptr_t)d,PMP_IPC_DEVICEDISCONNECTED);
  461. SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_COMBO_MANUALCONNECT,CBN_SELCHANGE),0);
  462. delete d;
  463. i--;
  464. }
  465. }
  466. }
  467. }
  468. break;
  469. case IDC_MANUALBLACKLIST:
  470. {
  471. int indx = (int)SendDlgItemMessageW(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_GETCURSEL,0,0);
  472. wchar_t drive = (wchar_t)SendDlgItemMessage(hwndDlg,IDC_COMBO_MANUALCONNECT,CB_GETITEMDATA,indx,0);
  473. if(drive >= L'A' && drive <= L'Z') {
  474. wchar_t *bl = makeBlacklistString(drive);
  475. if (bl)
  476. {
  477. if(!blacklistCheck(drive)) {
  478. blacklist.push_back(bl);
  479. // see if we've got a connected drive and prompt to remove it or wait till restart
  480. if(IsDriveConnectedToPMP(drive)) {
  481. wchar_t title[96] = {0};
  482. GetWindowText(hwndDlg, title, 96);
  483. if(MessageBox(hwndDlg,WASABI_API_LNGSTRINGW(IDS_DRIVE_CONNECTED_DISCONNECT_Q),title,MB_YESNO)==IDYES){
  484. SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_MANUALDISCONNECT,0),0);
  485. }
  486. }
  487. }
  488. else
  489. {
  490. for(size_t i=0; i < blacklist.size(); i++)
  491. {
  492. if(!wcscmp(bl,(wchar_t*)blacklist.at(i)))
  493. {
  494. free(blacklist.at(i));
  495. blacklist.erase(blacklist.begin() + i);
  496. break;
  497. }
  498. }
  499. free(bl);
  500. }
  501. }
  502. SendMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_COMBO_MANUALCONNECT,CBN_SELCHANGE),0);
  503. }
  504. }
  505. break;
  506. case IDOK:
  507. case IDCANCEL:
  508. blacklistSave();
  509. EndDialog(hwndDlg,0);
  510. break;
  511. }
  512. break;
  513. }
  514. return 0;
  515. }
  516. static intptr_t MessageProc(int msg, intptr_t param1, intptr_t param2, intptr_t param3)
  517. {
  518. switch(msg) {
  519. case PMP_DEVICECHANGE:
  520. return wmDeviceChange(param1,param2);
  521. case PMP_CONFIG:
  522. WASABI_API_DIALOGBOXW(IDD_CONFIG_GLOBAL,(HWND)param1,config_dialogProc);
  523. return 1;
  524. }
  525. return 0;
  526. }
  527. extern "C" __declspec(dllexport) PMPDevicePlugin *winampGetPMPDevicePlugin()
  528. {
  529. return &plugin;
  530. }