CONFIG.Cpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. #include "main.h"
  2. #ifndef IGNORE_API_GRACENOTE
  3. #include "cddb.h"
  4. #else
  5. extern char config_use_cddb;
  6. //char config_use_cddb = 0;
  7. #endif
  8. #include "api__in_cdda.h"
  9. #include "../winamp/wa_ipc.h"
  10. //int config_sample=1;
  11. //int config_use_veritas=1;
  12. //int config_rip_veritas=1;
  13. //int config_maxextractspeed=4;
  14. //int config_offset=0;
  15. //int config_read_leadin=0;
  16. //int config_rip_buffersize=24;
  17. //int config_rip_buffers=256;
  18. //int config_play_buffersize=1;
  19. //int config_play_buffers=256;
  20. char *INI_FILE = 0;
  21. char app_name[] = "CDDA/Line Input Driver";
  22. static int _r_i(char *name, int def)
  23. {
  24. name += 7;
  25. return GetPrivateProfileIntA(app_name, name, def, INI_FILE);
  26. }
  27. #define RI(x) (( x ) = _r_i(#x,( x )))
  28. static void _w_i(char *name, int d)
  29. {
  30. char str[120] = {0};
  31. wsprintfA(str, "%d", d);
  32. name += 7;
  33. WritePrivateProfileStringA(app_name, name, str, INI_FILE);
  34. }
  35. #define WI(x) _w_i(#x,( x ))
  36. void config_read()
  37. {
  38. INI_FILE = (char*)SendMessage(line.hMainWindow, WM_WA_IPC, 0, IPC_GETINIFILE);
  39. //RI(config_sample);
  40. RI(config_use_cddb);
  41. /*RI(config_use_veritas);
  42. config_rip_veritas=config_use_veritas;
  43. RI(config_rip_veritas);*/
  44. //RI(config_maxextractspeed);
  45. //RI(config_offset);
  46. //RI(config_rip_buffersize);
  47. //RI(config_rip_buffers);
  48. //RI(config_play_buffersize);
  49. //RI(config_play_buffers);
  50. //RI(config_read_leadin);
  51. }
  52. void config_write()
  53. {
  54. //WI(config_sample);
  55. WI(config_use_cddb);
  56. //WI(config_use_veritas);
  57. //WI(config_rip_veritas);
  58. //WI(config_maxextractspeed);
  59. }
  60. // TODO need to review all of this!!!
  61. #if 0
  62. BOOL CALLBACK ripConfigProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  63. {
  64. switch (uMsg)
  65. {
  66. case WM_INITDIALOG:
  67. //if (config_rip_veritas) CheckDlgButton(hwndDlg,IDC_VERITAS,BST_CHECKED);
  68. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)L"0.5x");
  69. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)L"1x");
  70. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)L"2x");
  71. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)L"4x");
  72. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)L"8x");
  73. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)L"16x");
  74. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)WASABI_API_LNGSTRINGW(IDS_UNLIMITED));
  75. if (config_maxextractspeed<0)config_maxextractspeed=0;
  76. if (config_maxextractspeed>6)config_maxextractspeed=6;
  77. //if (config_maxextractspeed > 4 && getRegVer() < 1) config_maxextractspeed=4;
  78. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_SETCURSEL,config_maxextractspeed,0);
  79. return 0;
  80. case WM_COMMAND:
  81. switch (LOWORD(wParam))
  82. {
  83. /*case IDC_VERITAS:
  84. config_rip_veritas = IsDlgButtonChecked(hwndDlg,IDC_VERITAS)?1:0;
  85. break;*/
  86. case IDC_COMBO1:
  87. {
  88. int x=(INT)SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_GETCURSEL,0,0);
  89. if (x != CB_ERR)
  90. {
  91. if (x<0)x=0;
  92. if (x>6)x=6;
  93. /*if (x > 4 && getRegVer() < 1)
  94. {
  95. SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_SETCURSEL,4,0);
  96. x=4;
  97. config_maxextractspeed=x;
  98. wchar_t title[64] = {0};
  99. if (MessageBoxW(hwndDlg,WASABI_API_LNGSTRINGW(IDS_PURCHASE_WINAMP_PRO_PROMPT),
  100. WASABI_API_LNGSTRINGW_BUF(IDS_WINAMP_PRO_FEATURE,title,64),MB_YESNO) == IDYES)
  101. {
  102. SendMessage(line.hMainWindow,WM_WA_IPC,0,IPC_GETREGISTEREDVERSION);
  103. }
  104. }
  105. else*/ config_maxextractspeed=x;
  106. }
  107. }
  108. break;
  109. }
  110. return FALSE;
  111. case WM_DESTROY:
  112. config_write();
  113. return FALSE;
  114. }
  115. return 0;
  116. }
  117. #endif
  118. static long cddbResourceID=202;
  119. static long cddbMaxFrames=46;
  120. static long cddbHeight=80, cddbWidth=80;
  121. static HMODULE cddbUI = 0;
  122. static bool GetUI()
  123. {
  124. #ifndef IGNORE_API_GRACENOTE
  125. ICddbUIOptions *pUIOptions;
  126. if (SUCCEEDED(Cddb_GetIUIOptions((void**)&pUIOptions)))
  127. {
  128. if (SUCCEEDED(pUIOptions->GetCurrent(UI_DISP_PROGRESS))) // not sure what this does, but it seems to be required
  129. {
  130. pUIOptions->get_ProgressResourceID(&cddbResourceID);
  131. pUIOptions->get_Frames(&cddbMaxFrames);
  132. pUIOptions->get_Bottom(&cddbHeight);
  133. pUIOptions->get_Right(&cddbWidth);
  134. pUIOptions->get_ResourceHINSTANCE((long *)&cddbUI);
  135. }
  136. pUIOptions->Release();
  137. return true;
  138. }
  139. #endif
  140. return false;
  141. }
  142. static HANDLE cddbImage =0;
  143. static int cddbFrame = 0;
  144. BOOL CALLBACK ConfigProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  145. {
  146. switch (uMsg)
  147. {
  148. case WM_DRAWITEM:
  149. if (wParam == IDC_CDDBICON)
  150. {
  151. DRAWITEMSTRUCT *drawItem = (DRAWITEMSTRUCT *) lParam;
  152. if (cddbImage)
  153. {
  154. HDC hdcbm = CreateCompatibleDC(drawItem->hDC);
  155. HGDIOBJ old = SelectObject(hdcbm, cddbImage);
  156. BitBlt(drawItem->hDC, 0, 0, cddbWidth, cddbHeight, hdcbm, (cddbFrame * cddbWidth), 0, SRCCOPY);
  157. SelectObject(hdcbm, old);
  158. DeleteDC(hdcbm);
  159. }
  160. else
  161. {
  162. RECT r={0,0,cddbWidth,cddbHeight};
  163. FillRect(drawItem->hDC, &r, (HBRUSH)GetStockObject(GRAY_BRUSH));
  164. }
  165. return TRUE;
  166. }
  167. break;
  168. case WM_DESTROY:
  169. cddbImage=0;
  170. break;
  171. case WM_INITDIALOG:
  172. cddbFrame=0;
  173. cddbImage=0;
  174. {
  175. IUnknown *pUnknown = NULL;
  176. #ifndef IGNORE_API_GRACENOTE
  177. Cddb_GetIControl((void**)&pUnknown);
  178. #endif
  179. if (!pUnknown)
  180. {
  181. ShowWindow(GetDlgItem(hwndDlg,IDC_CDDBNOTE),SW_SHOWNA);
  182. ShowWindow(GetDlgItem(hwndDlg,IDC_CDDB),SW_HIDE);
  183. ShowWindow(GetDlgItem(hwndDlg,IDC_CDDBICON),SW_HIDE);
  184. }
  185. else pUnknown->Release();
  186. }
  187. //if (config_sample) CheckDlgButton(hwndDlg,IDC_SAMPLE,BST_CHECKED);
  188. if (config_use_cddb&1) CheckDlgButton(hwndDlg,IDC_CDDB,BST_CHECKED);
  189. //if (config_use_veritas) CheckDlgButton(hwndDlg,IDC_VERITAS,BST_CHECKED);
  190. if ((config_use_cddb&1) && GetUI())
  191. {
  192. cddbImage = LoadImage(cddbUI, MAKEINTRESOURCE(cddbResourceID), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
  193. SetTimer(hwndDlg, 2, 65, NULL);
  194. }
  195. SetWindowPos(GetDlgItem(hwndDlg, IDC_CDDBICON), 0, 0, 0, cddbWidth, cddbHeight, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
  196. return TRUE;
  197. case WM_TIMER:
  198. switch (wParam)
  199. {
  200. case 2:
  201. if (cddbFrame < cddbMaxFrames-1)
  202. {
  203. cddbFrame++;
  204. InvalidateRect(GetDlgItem(hwndDlg, IDC_CDDBICON), 0, TRUE);
  205. }
  206. else
  207. KillTimer(hwndDlg, 2);
  208. break;
  209. }
  210. return 0;
  211. case WM_COMMAND:
  212. switch (LOWORD(wParam))
  213. {
  214. case IDC_CDDBICON:
  215. if (HIWORD(wParam) == STN_CLICKED) SendMessage(line.hMainWindow, WM_WA_IPC, (WPARAM)L"http://www.cddb.com/", IPC_OPEN_URL);
  216. return 0;
  217. case IDOK:
  218. //config_sample = IsDlgButtonChecked(hwndDlg,IDC_SAMPLE)?1:0;
  219. config_use_cddb = IsDlgButtonChecked(hwndDlg,IDC_CDDB)?1:0;
  220. //config_use_veritas = IsDlgButtonChecked(hwndDlg,IDC_VERITAS)?1:0;
  221. config_write();
  222. case IDCANCEL:
  223. EndDialog(hwndDlg,1);
  224. return FALSE;
  225. }
  226. return FALSE;
  227. }
  228. return 0;
  229. }
  230. void config(HWND hwndParent)
  231. {
  232. WASABI_API_DIALOGBOXW(IDD_DIALOG1,hwndParent,ConfigProc);
  233. }