1
0

install.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /** (c) Nullsoft, Inc. C O N F I D E N T I A L
  2. ** Filename:
  3. ** Project:
  4. ** Description:
  5. ** Author:
  6. ** Created:
  7. **/
  8. #include "main.h"
  9. #include "api.h"
  10. #include "../nu/AutoChar.h"
  11. #include "./setup/svc_setup.h"
  12. #include <api/service/waservicefactorybase.h>
  13. #include "./setup/postsetup.h"
  14. #define APSTUDIO_READONLY_SYMBOLS
  15. #include "./setup/setup_resource.h"
  16. #include "./setup/setupfactory.h"
  17. void DoInstall(int is_install)
  18. {
  19. //2=audiotype
  20. //4=videotype
  21. //8=cd
  22. //16=set needreg=1
  23. //32=dircontextmenus
  24. //64=playlisttype
  25. //128=run setup wizard
  26. if (is_install&128)
  27. {
  28. HRESULT hr(S_FALSE);
  29. HWND hwndStatus(NULL), hwndWA(NULL);
  30. waServiceFactory *psf = WASABI_API_SVC->service_getServiceByGuid(UID_SVC_SETUP);
  31. if (psf)
  32. {
  33. svc_setup *pSvc = (svc_setup*)psf->getInterface();
  34. if (pSvc)
  35. {
  36. Setup_RegisterDefault();
  37. Setup_RegisterPlugins();
  38. hr = pSvc->Start(hMainWindow);
  39. if (S_OK == hr)
  40. {
  41. pSvc->CreateStatusWnd(&hwndStatus);
  42. if (hwndStatus)
  43. {
  44. ShowWindow(hwndStatus, SW_SHOWNORMAL);
  45. UpdateWindow(hwndStatus);
  46. }
  47. pSvc->Save(hwndStatus);
  48. pSvc->ExecJobs(hwndStatus);
  49. }
  50. pSvc->Release();
  51. }
  52. WASABI_API_SVC->service_deregister(psf);
  53. }
  54. if (S_OK == hr && hwndStatus)
  55. {
  56. SetDlgItemTextW(hwndStatus, IDC_LBL_STATUS, getStringW(IDS_STATUS_RUNWA, NULL, 0));
  57. }
  58. out_deinit();
  59. in_deinit();
  60. w5s_deinit();
  61. if (S_OK == hr)
  62. {
  63. DWORD attr = GetFileAttributesW(INI_FILE);
  64. if(attr & FILE_ATTRIBUTE_READONLY)
  65. {
  66. SetFileAttributesW(INI_FILE,(attr - FILE_ATTRIBUTE_READONLY));
  67. }
  68. char szWAParam[MAX_PATH] = {0};
  69. WritePrivateProfileStringW(L"WinampReg", L"NeedReg", L"0", INI_FILE);
  70. GetPrivateProfileStringA("SETUP", "WAParam", "", szWAParam, sizeof(szWAParam)/sizeof(char), INI_FILEA);
  71. WritePrivateProfileStringW(L"SETUP", NULL, NULL, INI_FILE);
  72. PathQuoteSpacesA(szWAParam);
  73. StartWinamp((NULL != hwndStatus), &hwndWA, szWAParam);
  74. }
  75. Wasabi_Unload();
  76. if (hwndStatus) DestroyWindow(hwndStatus);
  77. if (hwndWA && IsWindow(hwndWA)) SetForegroundWindow(hwndWA);
  78. RemoveRegistrar();
  79. ExitProcess(0);
  80. return;
  81. }
  82. config_setup_filetypes(0);
  83. config_registermediaplayer(1);
  84. if (is_install&32) config_adddircontext(0);
  85. else config_removedircontext(0);
  86. if (is_install&16) WritePrivateProfileStringW(L"WinampReg", L"NeedReg", L"1", INI_FILE);
  87. if (is_install&8)
  88. {
  89. if (!config_iscdplayer()) config_regcdplayer(1, 0);
  90. }
  91. else
  92. {
  93. if (config_iscdplayer()) config_regcdplayer(0, 0);
  94. }
  95. if (is_install&(4 | 2 | 64)) // audio or video or both
  96. {
  97. extern void _w_sW(const char *name, const wchar_t *data);
  98. wchar_t ext_list[16384] = {0};
  99. if (is_install&(4 | 2))
  100. {
  101. wchar_t *ext = in_getextlistW();
  102. wchar_t *a = ext;
  103. if (ext)
  104. {
  105. while (a && *a)
  106. {
  107. wchar_t buf[1024] = {0}, buf2[64] = {0};
  108. StringCchPrintfW(buf, 1024, L"test.%s", a);
  109. buf2[0] = 0;
  110. in_get_extended_fileinfoW(buf, L"type", buf2, 32);
  111. int type = _wtoi(buf2);
  112. if (lstrlenW(ext_list) + lstrlenW(buf) > 16128) break;
  113. {
  114. int doreg = (!type && (is_install & 2)) || (type && (is_install & 4));
  115. if (doreg) config_register(a, doreg);
  116. if (doreg)
  117. {
  118. if (*ext_list) StringCchCatW(ext_list, 16384, L":");
  119. StringCchCatW(ext_list, 16384, a);
  120. }
  121. }
  122. a += lstrlenW(a) + 1;
  123. }
  124. GlobalFree((HGLOBAL)ext);
  125. SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST | SHCNF_FLUSHNOWAIT, NULL, NULL);
  126. }
  127. }
  128. if (is_install&64)
  129. {
  130. const wchar_t *p;
  131. size_t i=0;
  132. while (NULL != (p = playlistManager->EnumExtension(i++)))
  133. {
  134. int doreg = !!(is_install & 64);
  135. if (doreg)
  136. {
  137. config_register((wchar_t*)p, doreg);
  138. if (*ext_list) StringCchCatW(ext_list, 16384, L":");
  139. StringCchCatW(ext_list, 8192, p);
  140. }
  141. p += lstrlenW(p) + 1;
  142. }
  143. }
  144. _w_sW("config_extlist", ext_list);
  145. }
  146. //CreateEQPresets();
  147. config_register(L"wsz", 1);
  148. config_register(L"wal", 1);
  149. config_register(L"wlz", 1);
  150. config_write(0);
  151. out_deinit();
  152. in_deinit();
  153. w5s_deinit();
  154. Wasabi_Unload();
  155. RemoveRegistrar();
  156. ExitProcess(0);
  157. }