aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_wire/UpdateTime.cpp
blob: 008a6118b3f0361e5ab406e7eba5fe478f9c1c29 (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
#include "main.h"
#include "api__ml_wire.h"
#include "UpdateTime.h"

__time64_t Update::times[] = {0,                                                 // TIME_MANUALLY
60 /* 1 minute */ * 60 /* 1 hour */ * 24 /* 1 day */ * 7 /* 1 week */,           // TIME_WEEKLY
60 /* 1 minute */ * 60 /* 1 hour */ * 24 /* 1 day */,                            // TIME_DAILY
60 /* 1 minute */ * 60 /* 1 hour */,                                             // TIME_HOURLY
};

const wchar_t *Update::GetTitle( int position, wchar_t *buffer, int bufferMax )
{
	if ( NULL == buffer )
		return NULL;

	INT stringId = IDS_ERROR_FYEO;
	switch ( position )
	{
		case TIME_MANUALLY:
			stringId = IDS_UPD_MANUALLY;
			break;
		case TIME_WEEKLY:
			stringId = IDS_UPD_WEEK;
			break;
		case TIME_DAILY:
			stringId = IDS_UPD_DAY;
			break;
		case TIME_HOURLY:
			stringId = IDS_UPD_HOUR;
			break;
	}
	return WASABI_API_LNGSTRINGW_BUF( stringId, buffer, bufferMax );
}

bool Update::GetAutoUpdate(int selection)
{
	if (selection == TIME_MANUALLY)
		return false;
	else
		return true;
}

__time64_t Update::GetTime(int selection)
{
	if (selection >= 0 && selection < TIME_NUMENTRIES)
		return times[selection];
	else
		return 0;
}

int Update::GetSelection(__time64_t selTime, bool autoUpdate)
{
	if (!autoUpdate)
		return TIME_MANUALLY;

	for (int i = TIME_WEEKLY;i < TIME_NUMENTRIES;i++)
		if (selTime >= times[i])
			return i;

	return TIME_DAILY;

}