summaryrefslogtreecommitdiff
path: root/plugins/StatusManager/src/options.cpp
blob: dcb67397415a5944ddfcc35d67207bbcc20e5d48 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "stdafx.h"

bool IsSubPluginEnabled(const char *name)
{
	// Check if this plugin was disabled as separate dll
	CMStringA dllName(FORMAT, "%s.dll", name);
	dllName.MakeLower();
	int dllEnabled = !db_get_b(0, "PluginDisable", dllName);

	char setting[128];
	mir_snprintf(setting, "%s_enabled", name);
	return db_get_b(0, MODULENAME, setting, dllEnabled) != 0;
}

/////////////////////////////////////////////////////////////////////////////////////////

CSubPluginsOptionsDlg::CSubPluginsOptionsDlg() :
	CPluginDlgBase(hInst, IDD_OPT_SUBPLUGINS, MODULENAME),
	m_enableKeepStatus(this, IDC_ENABLE_KEEPSTATUS),
	m_enableStartupStatus(this, IDC_ENABLE_STARTUPSTATUS),
	m_enableAdvancedAutoAway(this, IDC_ENABLE_ADVANCEDAUTOAWAY)
{
}

void CSubPluginsOptionsDlg::OnInitDialog()
{
	CDlgBase::OnInitDialog();

	m_enableKeepStatus.SetState(IsSubPluginEnabled(KSMODULENAME));
	m_enableStartupStatus.SetState(IsSubPluginEnabled(SSMODULENAME));
	m_enableAdvancedAutoAway.SetState(IsSubPluginEnabled(AAAMODULENAME));
}

void CSubPluginsOptionsDlg::OnApply()
{
	char setting[128];
	mir_snprintf(setting, "%s_enabled", KSMODULENAME);
	int bEnabled = m_enableKeepStatus.GetState();
	if (bEnabled != db_get_b(0, MODULENAME, setting)) {
		db_set_b(0, MODULENAME, setting, m_enableKeepStatus.GetState());

		if (bEnabled)
			KeepStatusLoad();
		else
			KeepStatusUnload();
	}

	mir_snprintf(setting, "%s_enabled", SSMODULENAME);
	bEnabled = m_enableStartupStatus.GetState();
	if (bEnabled != db_get_b(0, MODULENAME, setting)) {
		db_set_b(0, MODULENAME, setting, m_enableStartupStatus.GetState());

		if (bEnabled)
			StartupStatusLoad();
		else
			StartupStatusUnload();
	}
	
	mir_snprintf(setting, "%s_enabled", AAAMODULENAME);
	bEnabled = m_enableAdvancedAutoAway.GetState();
	if (bEnabled != db_get_b(0, MODULENAME, setting)) {
		db_set_b(0, MODULENAME, setting, m_enableAdvancedAutoAway.GetState());

		if (bEnabled)
			AdvancedAutoAwayLoad();
		else
			AdvancedAutoAwayUnload();
	}
}

/////////////////////////////////////////////////////////////////////////////////////////

int CSubPluginsOptionsDlg::OnOptionsInit(WPARAM wParam, LPARAM)
{
	OPTIONSDIALOGPAGE odp = { 0 };
	odp.hInstance = hInst;
	odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
	odp.szGroup.w = LPGENW("Status");
	odp.szTitle.w = LPGENW("Status manager");
	odp.pDialog = CSubPluginsOptionsDlg::CreateOptionsPage();
	Options_AddPage(wParam, &odp);

	return 0;
}