1
0

setup.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #define GUID_DEFINE
  2. #include "../../winamp/setup/svc_setup.h"
  3. #undef GUID_DEFINE
  4. #include "./setupPage.h"
  5. #include "../api__ml_online.h"
  6. static HRESULT Setup_RegisterPage()
  7. {
  8. HRESULT hr;
  9. svc_setup *setupSvc;
  10. SetupPage *page;
  11. if (FAILED(WasabiApi_LoadDefaults()) ||
  12. NULL == OMBROWSERMNGR ||
  13. NULL == OMSERVICEMNGR ||
  14. NULL == OMUTILITY)
  15. {
  16. return E_UNEXPECTED;
  17. }
  18. setupSvc = QueryWasabiInterface(svc_setup, UID_SVC_SETUP);
  19. if (NULL == setupSvc)
  20. return E_POINTER;
  21. page = SetupPage::CreateInstance();
  22. if (NULL == page)
  23. hr = E_OUTOFMEMORY;
  24. else
  25. {
  26. // try to insert before 'feedback' (if present)
  27. // otherwise dump at the end of the pages list.
  28. int index = 0xFFFFF;
  29. if (FAILED(setupSvc->GetPageCount(&index)))
  30. index = 0xFFFFF;
  31. else if (index > 0 && index == 3)
  32. index--;
  33. hr = setupSvc->InsertPage(page, &index);
  34. if (SUCCEEDED(hr))
  35. setupSvc->AddJob((ifc_setupjob*)page);
  36. page->Release();
  37. }
  38. ReleaseWasabiInterface(UID_SVC_SETUP, setupSvc);
  39. return hr;
  40. }
  41. EXTERN_C _declspec(dllexport) BOOL RegisterSetup(HINSTANCE hInstance, api_service *waServices)
  42. {
  43. // check the current date and if past November 30th 2013
  44. // then we will prevent the online page from being shown
  45. time_t now = time(0);
  46. struct tm *tn = localtime(&now);
  47. tn->tm_sec = tn->tm_min = tn->tm_hour = 0;
  48. if (mktime(tn) >= 1387497600)
  49. return FALSE;
  50. if (FAILED(WasabiApi_Initialize(hInstance, waServices)))
  51. return FALSE;
  52. BOOL result = SUCCEEDED(Setup_RegisterPage());
  53. WasabiApi_Release();
  54. return result;
  55. }