aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_online/Setup/setup.cpp
blob: e849730686065d7abf895072366db1c3c12be4d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#define GUID_DEFINE
#include "../../winamp/setup/svc_setup.h"
#undef GUID_DEFINE

#include "./setupPage.h"

#include "../api__ml_online.h"


static HRESULT Setup_RegisterPage()
{	
	HRESULT hr;
	svc_setup *setupSvc;
	SetupPage *page;


	if (FAILED(WasabiApi_LoadDefaults()) ||
		NULL == OMBROWSERMNGR ||
		NULL == OMSERVICEMNGR ||
		NULL == OMUTILITY) 
	{
		return E_UNEXPECTED;
	}
	
	setupSvc = QueryWasabiInterface(svc_setup, UID_SVC_SETUP);
	if (NULL == setupSvc) 
		return E_POINTER;

	page = SetupPage::CreateInstance();
	if (NULL == page) 
		hr = E_OUTOFMEMORY;
	else
	{
		// try to insert before 'feedback' (if present)
		// otherwise dump at the end of the pages list.
		int index = 0xFFFFF;
		if (FAILED(setupSvc->GetPageCount(&index)))
			index = 0xFFFFF;
		else if (index > 0 && index == 3) 
			index--;

		hr = setupSvc->InsertPage(page, &index);
		if (SUCCEEDED(hr))
			setupSvc->AddJob((ifc_setupjob*)page);
		
		page->Release();
	}
	
	ReleaseWasabiInterface(UID_SVC_SETUP, setupSvc);
	
	return hr;
}

EXTERN_C _declspec(dllexport) BOOL RegisterSetup(HINSTANCE hInstance, api_service *waServices)
{
	// check the current date and if past November 30th 2013
	// then we will prevent the online page from being shown
	time_t now = time(0);
	struct tm *tn = localtime(&now);
	tn->tm_sec = tn->tm_min = tn->tm_hour = 0;

	if (mktime(tn) >= 1387497600)
		return FALSE;

	if (FAILED(WasabiApi_Initialize(hInstance, waServices)))
		return FALSE;

	BOOL result = SUCCEEDED(Setup_RegisterPage());
	WasabiApi_Release();
	return result;
}