1
0

prefs.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. #include "../gracenote/gracenote.h"
  2. #include "api__ml_plg.h"
  3. #include <windows.h>
  4. #include "resource.h"
  5. #include "../../General/gen_ml/ml.h"
  6. #include "../winamp/wa_ipc.h"
  7. #include "../Agave/Language/api_language.h"
  8. #include "../nu/MediaLibraryInterface.h"
  9. #include "../nu/ComboBox.h"
  10. #include "main.h"
  11. #include <shlwapi.h>
  12. #include <assert.h>
  13. #include "playlist.h"
  14. #include <atlbase.h>
  15. #include "IDScanner.h"
  16. #include <strsafe.h>
  17. extern bool pluginEnabled;
  18. extern int scanMode;
  19. extern int plLengthType;
  20. volatile bool is_scan_running=false;
  21. static bool IsScanRunning()
  22. {
  23. return is_scan_running;
  24. }
  25. void ShowErrorDlg(HWND parent)
  26. {
  27. wchar_t title[32] = {0};
  28. WASABI_API_LNGSTRINGW_BUF(IDS_ERROR_INITIALIZING,title,32);
  29. MessageBox(parent, WASABI_API_LNGSTRINGW(IDS_INITFAILMSG),title,0);
  30. }
  31. IDScanner scanner;
  32. int ShutdownScanner(HANDLE handle, void *user_data, intptr_t id)
  33. {
  34. HANDLE event = (HANDLE)user_data;
  35. scanner.Shutdown();
  36. ShutdownPlaylistSDK();
  37. SetEvent(event);
  38. return 0;
  39. }
  40. static int ScanThread(HANDLE handle, void *user_data, intptr_t id)
  41. {
  42. is_scan_running=true;
  43. scanner.ScanDatabase();
  44. is_scan_running=false;
  45. return 0;
  46. }
  47. static void doProgressBar(HWND h, int x, int t=-1) {
  48. h = GetDlgItem(h,IDC_PROGRESS1);
  49. if(t!=-1 && SendMessage(h,PBM_GETRANGE,0,0) != t)
  50. SendMessage(h,PBM_SETRANGE32,0,t);
  51. SendMessage(h,PBM_SETPOS,x,0);
  52. }
  53. static void FillStatus(HWND hwndDlg)
  54. {
  55. long state, track, tracks;
  56. if (scanner.GetStatus(&state, &track, &tracks))
  57. {
  58. static int x=0;
  59. wchar_t *ticker;
  60. switch (x++)
  61. {
  62. case 0: ticker=L""; break;
  63. case 1: ticker=L"."; break;
  64. case 2: ticker=L".."; break;
  65. default: ticker=L"...";
  66. }
  67. x%=4;
  68. wchar_t status[1024]=L"";
  69. switch (state)
  70. {
  71. case IDScanner::STATE_ERROR:
  72. WASABI_API_LNGSTRINGW_BUF(IDS_ERROR_INITIALIZING,status,1024);
  73. KillTimer(hwndDlg, 1);
  74. doProgressBar(hwndDlg,0,1);
  75. ShowErrorDlg(hwndDlg);
  76. break;
  77. case IDScanner::STATE_IDLE:
  78. WASABI_API_LNGSTRINGW_BUF(IDS_IDLE,status,1024);
  79. doProgressBar(hwndDlg,0);
  80. break;
  81. case IDScanner::STATE_INITIALIZING:
  82. StringCchPrintfW(status, 1024, WASABI_API_LNGSTRINGW(IDS_INITIALIZING), ticker);
  83. doProgressBar(hwndDlg,0);
  84. break;
  85. case IDScanner::STATE_SYNC:
  86. StringCchPrintfW(status, 1024, WASABI_API_LNGSTRINGW(IDS_SYNC), track, tracks, ticker);
  87. doProgressBar(hwndDlg,track,tracks);
  88. break;
  89. case IDScanner::STATE_METADATA:
  90. StringCchPrintfW(status, 1024, WASABI_API_LNGSTRINGW(IDS_METADATA), track, tracks, ticker);
  91. doProgressBar(hwndDlg,track,tracks);
  92. break;
  93. case IDScanner::STATE_MUSICID:
  94. StringCchPrintfW(status, 1024, WASABI_API_LNGSTRINGW(IDS_MUSICID), track, tracks, ticker);
  95. doProgressBar(hwndDlg,track,tracks);
  96. break;
  97. case IDScanner::STATE_DONE:
  98. WASABI_API_LNGSTRINGW_BUF(IDS_DONE,status,1024);
  99. doProgressBar(hwndDlg,100,100);
  100. KillTimer(hwndDlg, 1);
  101. SetDlgItemText(hwndDlg,IDC_TEST,WASABI_API_LNGSTRINGW(IDS_SCAN));
  102. break;
  103. }
  104. SetDlgItemTextW(hwndDlg, IDC_STATUS, status);
  105. }
  106. }
  107. #if 0 // TODO: reimplement contract requirement
  108. LRESULT CALLBACK DeviceMsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  109. {
  110. if (uMsg == WM_TIMER)
  111. {
  112. if (wParam == 0)
  113. {
  114. KillTimer(hwnd, 0);
  115. if (CheckThread())
  116. {
  117. PostMessage(plugin.hwndLibraryParent, WM_USER+641, 0, 0);
  118. SetTimer(hwnd, 1, 3000, 0);
  119. }
  120. else
  121. DestroyWindow(hwnd);
  122. }
  123. else if (wParam == 1)
  124. {
  125. KillTimer(hwnd, 1);
  126. PostMessage(plugin.hwndLibraryParent, WM_USER+641, 1, 0);
  127. SetTimer(hwnd, 0, 27000, 0);
  128. }
  129. }
  130. else if (uMsg == WM_DESTROY)
  131. {
  132. PostMessage(plugin.hwndLibraryParent, WM_USER+641, 1, 0);
  133. }
  134. return DefWindowProcW(hwnd, uMsg, wParam, lParam);
  135. }
  136. static bool classRegistered=0;
  137. HWND CreateDummyWindow()
  138. {
  139. if (!classRegistered)
  140. {
  141. WNDCLASSW wc = {0, };
  142. wc.style = 0;
  143. wc.lpfnWndProc = DeviceMsgProc;
  144. wc.hInstance = plugin.hDllInstance;
  145. wc.hIcon = 0;
  146. wc.hCursor = NULL;
  147. wc.lpszClassName = L"ml_plg_window";
  148. if (!RegisterClassW(&wc))
  149. return 0;
  150. classRegistered = true;
  151. }
  152. HWND dummy = CreateWindowW(L"ml_plg_window", L"ml_plg_window", 0, 0, 0, 0, 0, NULL, NULL, plugin.hDllInstance, NULL);
  153. return dummy;
  154. }
  155. #endif
  156. bool StartScan()
  157. {
  158. if (IsScanRunning())
  159. {
  160. //run_full_scan_flag = true; // Not really necessary since we are already running the scan
  161. return false;
  162. }
  163. if (reset_db_flag) // See if we have the flag set to reset the DB.
  164. {
  165. SetDlgItemTextW(hwndDlgCurrent, IDC_STATIC_PROGRESS_STATE, WASABI_API_LNGSTRINGW(IDS_RESETDB));
  166. NukeDB();
  167. //ResetDBOnThread(true);
  168. reset_db_flag = false;
  169. }
  170. if (run_full_scan_flag) // See if we have the flag set for running the whole scan
  171. {
  172. // Call the scan procedure on the reserved gracenote specific thread
  173. if (WASABI_API_THREADPOOL->RunFunction(plg_thread, ScanThread, 0, 0, api_threadpool::FLAG_REQUIRE_COM_STA) == 0)
  174. {
  175. run_full_scan_flag = false; // Reset the flag to false since we (will) complete the run
  176. return true;
  177. }
  178. }
  179. else if (run_pass2_flag) // If we have the pass2 scan flag set then run the second pass only
  180. {
  181. if (WASABI_API_THREADPOOL->RunFunction(plg_thread, IDScanner::Pass2OnThread, 0, (intptr_t)&scanner, api_threadpool::FLAG_REQUIRE_COM_STA) == 0)
  182. {
  183. run_pass2_flag = false; // Set the flag back to false so we know that we wont have to run it again
  184. return true;
  185. }
  186. }
  187. return false;
  188. }
  189. void StopScan()
  190. {
  191. if (IsScanRunning())
  192. {
  193. scanner.Kill();
  194. while (IsScanRunning())
  195. Sleep(500);
  196. run_full_scan_flag = true; // Set the flag so that we rerun everything on a rescan
  197. }
  198. }
  199. void SetPlLengthTypeComboToItems(HWND hwndDlg, int value)
  200. {
  201. ComboBox combo(hwndDlg, IDC_COMBO_LENGTH);
  202. combo.Clear();
  203. combo.SetItemData(combo.AddString("10"),10);
  204. combo.SetItemData(combo.AddString("20"),20);
  205. combo.SetItemData(combo.AddString("50"),50);
  206. combo.SetItemData(combo.AddString("100"),100);
  207. combo.SetItemData(combo.AddString("200"),200);
  208. wchar_t buf[32] = {0};
  209. _itow(value,buf,10);
  210. combo.SetEditText(buf);
  211. }
  212. void SetPlLengthTypeComboToMinutes(HWND hwndDlg, int value)
  213. {
  214. ComboBox combo(hwndDlg, IDC_COMBO_LENGTH);
  215. combo.Clear();
  216. combo.SetItemData(combo.AddString("10"),10);
  217. combo.SetItemData(combo.AddString("20"),20);
  218. combo.SetItemData(combo.AddString("30"),30);
  219. combo.SetItemData(combo.AddString("60"),60);
  220. combo.SetItemData(combo.AddString("74"),60);
  221. combo.SetItemData(combo.AddString("80"),60);
  222. combo.SetItemData(combo.AddString("90"),60);
  223. combo.SetItemData(combo.AddString("120"),120);
  224. wchar_t buf[32] = {0};
  225. _itow(value,buf,10);
  226. combo.SetEditText(buf);
  227. }
  228. void SetPlLengthTypeComboToMegabytes(HWND hwndDlg, int value)
  229. {
  230. ComboBox combo(hwndDlg, IDC_COMBO_LENGTH);
  231. combo.Clear();
  232. combo.SetItemData(combo.AddString("100"),10);
  233. combo.SetItemData(combo.AddString("650"),20);
  234. combo.SetItemData(combo.AddString("703"),30);
  235. combo.SetItemData(combo.AddString("4489"),60);
  236. combo.SetItemData(combo.AddString("8147"),120);
  237. wchar_t buf[32] = {0};
  238. _itow(value,buf,10);
  239. combo.SetEditText(buf);
  240. }
  241. // Set a control to bold text and a more bold font
  242. void BoldStatusText(HWND hwndControl)
  243. {
  244. HFONT hFont ;
  245. LOGFONT lfFont;
  246. memset(&lfFont, 0x00, sizeof(lfFont));
  247. memcpy(lfFont.lfFaceName, TEXT("Microsoft Sans Serif"), 24);
  248. lfFont.lfHeight = 14;
  249. lfFont.lfWeight = FW_BOLD;
  250. lfFont.lfCharSet = ANSI_CHARSET;
  251. lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
  252. lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  253. lfFont.lfQuality = DEFAULT_QUALITY;
  254. // Create the font from the LOGFONT structure passed.
  255. hFont = CreateFontIndirect (&lfFont);
  256. //SendMessageW(GetDlgItem(hwndDlg,IDC_STATUS), WM_SETFONT, (LPARAM)hFont, MAKELONG(TRUE, 0 ) );
  257. SendMessageW(hwndControl, WM_SETFONT, (LPARAM)hFont, MAKELONG(TRUE, 0 ) );
  258. }
  259. void getViewport(RECT *r, HWND wnd, int full, RECT *sr)
  260. {
  261. POINT *p = NULL;
  262. if (p || sr || wnd)
  263. {
  264. HMONITOR hm = NULL;
  265. if (sr)
  266. hm = MonitorFromRect(sr, MONITOR_DEFAULTTONEAREST);
  267. else if (wnd)
  268. hm = MonitorFromWindow(wnd, MONITOR_DEFAULTTONEAREST);
  269. else if (p)
  270. hm = MonitorFromPoint(*p, MONITOR_DEFAULTTONEAREST);
  271. if (hm)
  272. {
  273. MONITORINFOEXW mi;
  274. memset(&mi, 0, sizeof(mi));
  275. mi.cbSize = sizeof(mi);
  276. if (GetMonitorInfoW(hm, &mi))
  277. {
  278. if (!full)
  279. *r = mi.rcWork;
  280. else
  281. *r = mi.rcMonitor;
  282. return ;
  283. }
  284. }
  285. }
  286. if (full)
  287. { // this might be borked =)
  288. r->top = r->left = 0;
  289. r->right = GetSystemMetrics(SM_CXSCREEN);
  290. r->bottom = GetSystemMetrics(SM_CYSCREEN);
  291. }
  292. else
  293. {
  294. SystemParametersInfoW(SPI_GETWORKAREA, 0, r, 0);
  295. }
  296. }
  297. BOOL windowOffScreen(HWND hwnd, POINT pt)
  298. {
  299. RECT r = {0}, wnd = {0}, sr = {0};
  300. GetWindowRect(hwnd, &wnd);
  301. sr.left = pt.x;
  302. sr.top = pt.y;
  303. sr.right = sr.left + (wnd.right - wnd.left);
  304. sr.bottom = sr.top + (wnd.bottom - wnd.top);
  305. getViewport(&r, hwnd, 0, &sr);
  306. return !PtInRect(&r, pt);
  307. }
  308. #define STATUS_MS 500
  309. INT_PTR CALLBACK PrefsProcedure(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  310. {
  311. switch (msg)
  312. {
  313. case WM_INITDIALOG:
  314. {
  315. // this will make sure that we've got thr aacplus logo shown even when using a localised version
  316. SendDlgItemMessage(hwndDlg,IDC_LOGO,STM_SETIMAGE,IMAGE_BITMAP,
  317. (LPARAM)LoadImage(plugin.hDllInstance,MAKEINTRESOURCE(IDB_GN_LOGO),IMAGE_BITMAP,0,0,LR_SHARED));
  318. SetDlgItemText(hwndDlg,IDC_BLURB,WASABI_API_LNGSTRINGW(IDS_SCANNER_BLURB));
  319. if (IsScanRunning())
  320. {
  321. //EnableWindow(GetDlgItem(hwndDlg, IDC_TEST), FALSE);
  322. SetDlgItemText(hwndDlg,IDC_TEST,WASABI_API_LNGSTRINGW(IDS_PAUSE));
  323. SetTimer(hwndDlg, 1, STATUS_MS, 0);
  324. }
  325. BoldStatusText(GetDlgItem(hwndDlg, IDC_STATUS) );
  326. FillStatus(hwndDlg);
  327. /*if(!pluginEnabled)
  328. CheckDlgButton(hwndDlg,IDC_SCANDISABLE,TRUE);
  329. else */
  330. if(scanMode == 1)
  331. CheckDlgButton(hwndDlg,IDC_SCANLAUNCH,TRUE);
  332. else
  333. CheckDlgButton(hwndDlg,IDC_SCANONUSE,TRUE);
  334. SetRadioControlsState(hwndDlg); // Set the playlist length radio buttons state
  335. if(scanMode == 0 || pluginEnabled == false)
  336. {
  337. pluginEnabled = true;
  338. scanMode = 2;
  339. }
  340. if(multipleArtists)
  341. CheckDlgButton(hwndDlg,IDC_CHECK_MULTIPLE_ARTISTS,TRUE);
  342. if(multipleAlbums)
  343. CheckDlgButton(hwndDlg,IDC_CHECK_MULTIPLE_ALBUMS,TRUE);
  344. if(useSeed)
  345. CheckDlgButton(hwndDlg,IDC_CHECK_USE_SEED,TRUE);
  346. // show config window and restore last position as applicable
  347. POINT pt = {(LONG)GetPrivateProfileInt(L"ml_plg", L"prefs_x", -1, mediaLibrary.GetWinampIniW()),
  348. (LONG)GetPrivateProfileInt(L"ml_plg", L"prefs_y", -1, mediaLibrary.GetWinampIniW())};
  349. if (!windowOffScreen(hwndDlg, pt))
  350. SetWindowPos(hwndDlg, HWND_TOP, pt.x, pt.y, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOSENDCHANGING);
  351. }
  352. break;
  353. case WM_TIMER:
  354. FillStatus(hwndDlg);
  355. break;
  356. case WM_COMMAND:
  357. switch (LOWORD(wParam))
  358. {
  359. case IDC_TEST:
  360. {
  361. if(StartScan()) // Start the scanning
  362. {
  363. SetDlgItemText(hwndDlg,IDC_TEST,WASABI_API_LNGSTRINGW(IDS_PAUSE));
  364. //EnableWindow(GetDlgItem(hwndDlg, IDC_TEST), FALSE);
  365. SetTimer(hwndDlg, 1, STATUS_MS, 0); // Start the timer ?
  366. }
  367. else // Stop the scanning
  368. {
  369. StopScan();
  370. SetDlgItemText(hwndDlg,IDC_TEST,WASABI_API_LNGSTRINGW(IDS_SCAN));
  371. SetDlgItemText(hwndDlg,IDC_STATUS,WASABI_API_LNGSTRINGW(IDS_PAUSE));
  372. }
  373. }
  374. break;
  375. case IDOK:
  376. case IDCANCEL:
  377. {
  378. RECT rect = {0};
  379. GetWindowRect(hwndDlg, &rect);
  380. char buf[16] = {0};
  381. StringCchPrintfA(buf, 16, "%d", rect.left);
  382. WritePrivateProfileStringA("ml_plg", "prefs_x", buf, mediaLibrary.GetWinampIni());
  383. StringCchPrintfA(buf, 16, "%d", rect.top);
  384. WritePrivateProfileStringA("ml_plg", "prefs_y", buf, mediaLibrary.GetWinampIni());
  385. EndDialog(hwndDlg, 0);
  386. StringCchPrintfA(buf, 10, "%d", scanMode);
  387. WritePrivateProfileStringA("ml_plg", "scanmode", buf, mediaLibrary.GetWinampIni());
  388. WritePrivateProfileStringA("ml_plg", "enable", pluginEnabled ? "1" : "0", mediaLibrary.GetWinampIni());
  389. }
  390. break;
  391. case IDC_SCANDISABLE:
  392. pluginEnabled = false;
  393. scanMode = 2;
  394. break;
  395. case IDC_SCANONUSE:
  396. pluginEnabled = true;
  397. scanMode = 2;
  398. break;
  399. case IDC_SCANLAUNCH:
  400. pluginEnabled = true;
  401. scanMode = 1;
  402. break;
  403. case IDC_RESETDB:
  404. {
  405. wchar_t title[32] = {0};
  406. WASABI_API_LNGSTRINGW_BUF(IDS_RESETDB,title,32);
  407. if(MessageBox(hwndDlg,WASABI_API_LNGSTRINGW(IDS_RESETDB_TEXT),title,MB_YESNO) == IDNO)
  408. break;
  409. StopScan();
  410. SetDlgItemText(hwndDlg,IDC_TEST,WASABI_API_LNGSTRINGW(IDS_SCAN));
  411. ResetDBOnThread(false);
  412. //NukeDB();
  413. }
  414. break;
  415. }
  416. break;
  417. }
  418. return 0;
  419. }
  420. int DeleteGracenoteMLDBOnThread(HANDLE handle, void *user_data, intptr_t id)
  421. {
  422. HANDLE event = (HANDLE)user_data;
  423. SetupPlaylistSDK(); // Need to set up the playlist SDK so that we have the MLDB manager ready to go, which is linked to the playlist manager
  424. DeleteGracenoteMLDB(!!id); // This will Shutdown the playlist manager in order to allow for a delete, id is recreating the silent boolean double NOT is creating int -> bool
  425. ShutdownPlaylistSDK(); // Hence we need to do a complete and proper shutdown afterwards
  426. SetEvent(event);
  427. return 0;
  428. }
  429. // silent - pass in true if the user should not be prompted on errors
  430. int ResetDBOnThread(bool silent)
  431. {
  432. int silentInt = (silent) ? 1 : 0; // Convert silent to int to pass it to wasabi thread runner
  433. /*HANDLE wait_event = CreateEvent(NULL, FALSE, FALSE, 0);
  434. WASABI_API_THREADPOOL->RunFunction(plg_thread, ShutdownScanner, (void *)wait_event, 0, api_threadpool::FLAG_REQUIRE_COM_STA);
  435. WaitForSingleObject(wait_event, INFINITE);*/
  436. HANDLE wait_event = CreateEvent(NULL, FALSE, FALSE, 0);
  437. WASABI_API_THREADPOOL->RunFunction(plg_thread, DeleteGracenoteMLDBOnThread, (void *)wait_event, silentInt, api_threadpool::FLAG_REQUIRE_COM_STA);
  438. WaitForSingleObject(wait_event, INFINITE);
  439. run_full_scan_flag = true; // Set the flag so that we rerun everything on a rescan
  440. return 0;
  441. }
  442. int ResetDB(bool silent)
  443. {
  444. int silentInt = silent;
  445. HANDLE wait_event = CreateEvent(NULL, FALSE, FALSE, 0);
  446. DeleteGracenoteMLDBOnThread (0, (void *)wait_event, silentInt);
  447. run_full_scan_flag = true; // Set the flag so that we rerun everything on a rescan
  448. return 0;
  449. }
  450. BOOL DeleteGracenoteFile(char *filename)
  451. {
  452. BOOL result;
  453. char path[MAX_PATH] = {0};
  454. PathCombineA(path,mediaLibrary.GetIniDirectory(),"Plugins\\Gracenote");
  455. PathAppendA(path, filename);
  456. result = DeleteFileA(path);
  457. return result;
  458. }
  459. int NukeDB(void)
  460. {
  461. ShutdownPlaylistSDK();
  462. DeleteGracenoteFile("cddb.db");
  463. DeleteGracenoteFile("cddbplm.chk");
  464. DeleteGracenoteFile("cddbplm.gcf");
  465. DeleteGracenoteFile("cddbplm.idx");
  466. DeleteGracenoteFile("cddbplm.pdb");
  467. DeleteGracenoteFile("elists.db");
  468. run_full_scan_flag = true; // Set the flag so that we rerun everything on a rescan
  469. return 0;
  470. }
  471. INT_PTR CALLBACK BGScanProcedure(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  472. {
  473. switch (msg)
  474. {
  475. case WM_INITDIALOG:
  476. SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam);
  477. if(!StartScan())
  478. {
  479. EndDialog(hwndDlg,0);
  480. return 0;
  481. }
  482. SetTimer(hwndDlg,1,STATUS_MS,NULL);
  483. ShowWindow(hwndDlg,SW_HIDE);
  484. break;
  485. case WM_TIMER:
  486. switch(wParam)
  487. {
  488. case 1:
  489. {
  490. long state, track, tracks;
  491. if (scanner.GetStatus(&state, &track, &tracks))
  492. {
  493. if(state == IDScanner::STATE_MUSICID && tracks != 0 && track != 0)
  494. {
  495. KillTimer(hwndDlg,1);
  496. ShowWindow(hwndDlg,SW_SHOWNA);
  497. SetTimer(hwndDlg,2,3000,NULL);
  498. }
  499. else if(state == IDScanner::STATE_DONE)
  500. EndDialog(hwndDlg,0);
  501. else if(state == IDScanner::STATE_ERROR)
  502. {
  503. EndDialog(hwndDlg,0);
  504. if(!GetWindowLongPtr(hwndDlg,GWLP_USERDATA)){
  505. KillTimer(hwndDlg,1);
  506. ShowErrorDlg(hwndDlg);
  507. }
  508. }
  509. }
  510. }
  511. break;
  512. case 2:
  513. EndDialog(hwndDlg,0);
  514. break;
  515. }
  516. break;
  517. case WM_COMMAND:
  518. switch(LOWORD(wParam))
  519. {
  520. case IDC_BUTTON1:
  521. EndDialog(hwndDlg,0);
  522. WASABI_API_DIALOGBOXW(IDD_PREFS, plugin.hwndLibraryParent, PrefsProcedure);
  523. break;
  524. case IDCANCEL:
  525. EndDialog(hwndDlg,0);
  526. break;
  527. }
  528. break;
  529. }
  530. return 0;
  531. }