summaryrefslogtreecommitdiff
path: root/plugins/UserInfoEx/src/init.cpp
blob: 628b9c0f995f0794d0fe29cc2849fbc89ccf9a1b (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
UserinfoEx plugin for Miranda IM

Copyright:
� 2006-2010 DeathAxe, Yasnovidyashii, Merlin, K. Romanov, Kreol

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "stdafx.h"

CMPlugin g_plugin;
HMODULE hDwmApi;

MGLOBAL myGlobals;
pfnDwmIsCompositionEnabled	dwmIsCompositionEnabled;

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

static PLUGININFOEX pluginInfoEx =
{
	sizeof(PLUGININFOEX),
	__PLUGIN_NAME,
	PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
	__DESCRIPTION,
	__AUTHOR,
	__COPYRIGHT,
	__AUTHORWEB,
	UNICODE_AWARE,
	// {9C23A24B-E6AA-43C6-B0B8-D6C36D2F7B57}
	{0x9c23a24b, 0xe6aa, 0x43c6, {0xb0, 0xb8, 0xd6, 0xc3, 0x6d, 0x2f, 0x7b, 0x57}}
};

CMPlugin::CMPlugin() :
	PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),

	// Common options
	bUseUnknownFlag(MODULENAME, "UseUnknownFlag", true),
	bShowStatusIconFlag(MODULENAME, "ShowStatusIconFlag", true),

	// Advanced options
	bCheckVersion(MODULENAME, "CheckIconPackVersion", true),
	bMetaScan(MODULENAME, "MetaScan", true),
	bButtonIcons(MODULENAME, "ButtonIcons", true),
	bEmailService(MODULENAME, "emailEx", true),

	// Propsheet options
	bAero(MODULENAME, "AeroAdaption", true),
	bReadOnly(MODULENAME, "PBCIReadOnly", false),
	bSortTree(MODULENAME, "TreeSortItems", false),
	bTreeGroups(MODULENAME, "TreeGroups", true),
	bShowColours(MODULENAME, "ShowColours", true),
	
	clrBoth(MODULENAME, "colourBoth", RGB(0, 160, 10)),
	clrMeta(MODULENAME, "colourMeta", RGB(120, 40, 130)),
	clrCustom(MODULENAME, "colourUser", RGB(0, 10, 130)),
	clrNormal(MODULENAME, "colourNormal", RGB(90, 90, 90)),
	clrChanged(MODULENAME, "colourChanged", RGB(190, 0, 0)),

	// Reminder options
	bRemindExtraIcon(MODULENAME, "RemindExtraIcon", true),
	bRemindFlashIcon(MODULENAME, "RemindFlashIcon", false),
	bRemindMenuEnabled(MODULENAME, "RemindMenuEnabled", true),
	bRemindStartupCheck(MODULENAME, "RemindStartupCheck", false),
	bRemindCheckVisible(MODULENAME, "RemindCheckVisible", false),

	iRemindState(MODULENAME, "RemindEnabled", REMIND_ALL),
	wRemindOffset(MODULENAME, "RemindOffset", 9),
	wRemindSoundOffset(MODULENAME, "RemindSoundOffset", 3),
	wRemindNotifyInterval(MODULENAME, "RemindNotifyInterval", 12),

	// Popup options
	bPopupEnabled(MODULENAME, "PopupEnabled", true),
	bPopupMsgbox(MODULENAME, "PopupMsgBox", false),
	bPopupProgress(MODULENAME, "PopupProgress", false),

	iPopupDelay(MODULENAME, "PopupDelay", 0),
	iAnnivClrType(MODULENAME, "PopupAnnivClrType", POPUP_COLOR_CUSTOM),
	iBirthClrType(MODULENAME, "PopupBirthClrType", POPUP_COLOR_CUSTOM),

	clrAback(MODULENAME, "PopupAnnivClrBack", RGB(90, 190, 130)),
	clrAtext(MODULENAME, "PopupAnnivClrText", RGB(0, 0, 0)),
	clrBback(MODULENAME, "PopupBirthClrBirthBack", RGB(192, 180, 30)),
	clrBtext(MODULENAME, "PopupBirthClrBirthText", RGB(0, 0, 0))
{}

/*
============================================================================================
	event hooks
============================================================================================
*/

/**
 * This function is called by the ME_TTB_MODULELOADED event.
 * It adds a set of buttons to the TopToolbar plugin.
 *
 * @param	wParam	- not used
 * @param	lParam	- not used
 *
 * @return	always 0
 **/
static int OnTopToolBarLoaded(WPARAM, LPARAM)
{
	TTBButton ttb = {};
	ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
	ttb.pszService = MS_USERINFO_SHOWDIALOG;
	ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_MAIN);
	ttb.name = ttb.pszTooltipUp = LPGEN("User &details");
	g_plugin.addTTB(&ttb);

	ttb.dwFlags = TTBBF_SHOWTOOLTIP;
	ttb.pszService = MS_USERINFO_REMINDER_LIST;
	ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_ANNIVERSARY);
	ttb.name = ttb.pszTooltipUp = LPGEN("Anniversary list");
	g_plugin.addTTB(&ttb);

	ttb.pszService = MS_USERINFO_REMINDER_CHECK;
	ttb.hIconHandleUp = g_plugin.getIconHandle(IDI_BIRTHDAY);
	ttb.name = ttb.pszTooltipUp = LPGEN("Check anniversaries");
	g_plugin.addTTB(&ttb);
	return 0;
}

/**
 * This function is called by Miranda just after loading all system modules.
 *
 * @param	wParam	- not used
 * @param	lParam	- not used
 *
 * @return	always 0
 **/
static int OnModulesLoaded(WPARAM, LPARAM)
{
	// create services to receive string lists of languages and timezones
	SvcConstantsLoadModule();

	// load module to remind user about birthday and a anniversary
	SvcReminderOnModulesLoaded();

	// load extended intagration services
	SvcFlagsOnModulesLoaded();

	// build contact's menuitems
	RebuildMenu();
	HookEvent(ME_CLIST_PREBUILDGROUPMENU, OnBuildGroupMenu);
	HookEvent(ME_CLIST_PREBUILDSTATUSMENU, OnBuildStatusMenu);
	return 0;
}

static int OnShutdown(WPARAM, LPARAM)
{
	DlgContactInfoUnLoadModule();
	SvcReminderUnloadModule();

	// uninitialize classes
	CtrlContactUnLoadModule();
	CtrlButtonUnloadModule();

	SvcConstantsUnloadModule();
	SvcFlagsUnloadModule();

	mir_free(hMenuItemAccount);
	return 0;
}

//============================================================================================
//	plugin interface
//============================================================================================


/**
 * This function returns the provided interfaces.
 *
 * @return	array of interfaces
 **/
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {
	MIID_UIUSERINFO,		// replace the default userinfo module
	MIID_SREMAIL,			// Send/Receive E-Mail service is provided
	MIID_LAST
};

/**
 * This function is called by Miranda just to make it possible to unload some memory, ...
 *
 * @return	0
 **/
int CMPlugin::Unload()
{
	FreeLibrary(hDwmApi);
	return 0;
}

/**
 * This function is called by Miranda to initialize the plugin.
 *
 * @return	0
 **/
int CMPlugin::Load()
{
	// init common controls
	INITCOMMONCONTROLSEX ccEx;
	ccEx.dwSize = sizeof(ccEx);
	ccEx.dwICC = ICC_WIN95_CLASSES | ICC_DATE_CLASSES;
	InitCommonControlsEx(&ccEx);

	memset(&myGlobals, 0, sizeof(MGLOBAL));

	if (IsWinVerVistaPlus()) {
		hDwmApi = LoadLibraryA("dwmapi.dll");
		if (hDwmApi)
			dwmIsCompositionEnabled = (pfnDwmIsCompositionEnabled)GetProcAddress(hDwmApi, "DwmIsCompositionEnabled");
	}

	// load icon library
	IcoLib_LoadModule();

	SvcFlagsLoadModule();
	SvcTimezoneLoadModule();
	SvcRefreshContactInfoLoadModule();

	CtrlContactLoadModule();
	// load my button class
	CtrlButtonLoadModule();
	// initializes the Ex/Import Services
	SvcExImport_LoadModule();
	// load the UserInfoPropertySheet module
	DlgContactInfoLoadModule();

	// Anniversary stuff
	DlgAnniversaryListLoadModule();
	SvcReminderLoadModule();

	// Now the module is loaded! Start initializing certain things
	HookEvent(ME_OPT_INITIALISE, OnInitOptions);
	HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
	HookEvent(ME_TTB_MODULELOADED, OnTopToolBarLoaded);
	HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
	return 0;
}