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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
#include "stdafx.h"
#include "mu_common.h"
#include <map>
#include <set>
namespace mu
{
/*
* clist
*/
namespace clist
{
HANDLE addMainMenuItem(const TCHAR* pszName, DWORD flags, int position, HICON hIcon, const char* pszService, const TCHAR* pszPopupName /* = NULL */, int popupPosition /* = 0 */, DWORD hotKey /* = 0 */)
{
// TODO: support for unicode-core with unicode-aware CList
CLISTMENUITEM mi = { 0 };
mi.ptszName = (TCHAR*)pszName;
mi.flags = flags | CMIF_TCHAR;
mi.position = position;
mi.hIcon = hIcon;
mi.pszService = const_cast<char*>(pszService);
mi.ptszPopupName = (TCHAR*)pszPopupName;
mi.popupPosition = popupPosition;
mi.hotKey = hotKey;
return Menu_AddMainMenuItem(&mi);
}
HANDLE addContactMenuItem(const TCHAR* pszName, DWORD flags, int position, HICON hIcon, const char* pszService, DWORD hotKey /* = 0 */, const char* pszContactOwner /* = NULL */)
{
// TODO: support for unicode-core with unicode-aware CList
CLISTMENUITEM mi = { 0 };
mi.ptszName = (TCHAR*)pszName;
mi.flags = flags | CMIF_TCHAR;
mi.position = position;
mi.hIcon = hIcon;
mi.pszService = const_cast<char*>(pszService);
mi.hotKey = hotKey;
mi.pszContactOwner = const_cast<char*>(pszContactOwner);
return Menu_AddContactMenuItem(&mi);
}
int modifyMenuItem(HANDLE hMenuItem, DWORD toModify, const TCHAR* pszName /* = NULL */, DWORD flags /* = 0 */, HICON hIcon /* = NULL */, DWORD hotKey /* = 0 */)
{
// TODO: support for unicode-core with unicode-aware CList
CLISTMENUITEM mi = { 0 };
mi.ptszName = (TCHAR*)pszName;
mi.flags = toModify | flags | CMIF_TCHAR;
mi.hIcon = hIcon;
mi.hotKey = hotKey;
return CallService(MS_CLIST_MODIFYMENUITEM, reinterpret_cast<WPARAM>(hMenuItem), reinterpret_cast<LPARAM>(&mi));
}
const TCHAR* getContactDisplayName(MCONTACT hContact)
{
return reinterpret_cast<const TCHAR*>(CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_UNICODE));
}
const TCHAR* getStatusModeDescription(int nStatusMode)
{
return reinterpret_cast<const TCHAR*>(CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, static_cast<WPARAM>(nStatusMode), GSMDF_UNICODE));
}
}
/*
* db
*/
namespace db
{
int getProfilePath(int cbName, TCHAR* pszName)
{
return CallService(MS_DB_GETPROFILEPATHT, cbName, reinterpret_cast<LPARAM>(pszName));
}
int getProfileName(int cbName, TCHAR* pszName)
{
return CallService(MS_DB_GETPROFILENAMET, cbName, reinterpret_cast<LPARAM>(pszName));
}
void setSafetyMode(bool safetyMode)
{
CallService(MS_DB_SETSAFETYMODE, BOOL_(safetyMode), 0);
}
}
/*
* db_time
*/
namespace db_contact
{
int enumSettings(MCONTACT hContact, const char* szModule, DBSETTINGENUMPROC pEnumProc, LPARAM lProcParam)
{
DBCONTACTENUMSETTINGS dbces;
dbces.pfnEnumProc = pEnumProc;
dbces.lParam = lProcParam;
dbces.szModule = szModule;
dbces.ofsSettings = 0;
return CallService(MS_DB_CONTACT_ENUMSETTINGS, hContact, reinterpret_cast<LPARAM>(&dbces));
}
}
/*
* icolib
*/
namespace icolib
{
bool _available()
{
return true;
}
void addIcon(const TCHAR* szSection, const TCHAR* szDescription, const char* szIconName, const char* szDefaultFile, int iDefaultIndex, int cx /* = 16 */, int cy /* = 16 */)
{
SKINICONDESC sid = { 0 };
sid.section.t = const_cast<TCHAR*>(szSection);
sid.description.t = const_cast<TCHAR*>(szDescription);
sid.pszName = const_cast<char*>(szIconName);
sid.defaultFile.a = const_cast<char*>(szDefaultFile);
sid.iDefaultIndex = iDefaultIndex;
sid.cx = cx;
sid.cy = cy;
sid.flags = SIDF_TCHAR;
IcoLib_AddIcon(&sid);
}
void addIcon(const TCHAR* szSection, const TCHAR* szDescription, const char* szIconName, HICON hDefaultIcon, int cx /* = 16 */, int cy /* = 16 */)
{
SKINICONDESC sid = { 0 };
sid.section.t = const_cast<TCHAR*>(szSection);
sid.description.t = const_cast<TCHAR*>(szDescription);
sid.pszName = const_cast<char*>(szIconName);
sid.defaultFile.a = NULL;
sid.iDefaultIndex = 0;
sid.hDefaultIcon = hDefaultIcon;
sid.cx = cx;
sid.cy = cy;
sid.flags = SIDF_TCHAR;
IcoLib_AddIcon(&sid);
}
HICON getIcon(const char* szIconName)
{
return IcoLib_GetIcon(szIconName);
}
}
/*
* opt
*/
namespace opt
{
void addPage(WPARAM addInfo, const TCHAR* pszGroup, const TCHAR* pszTitle, const TCHAR* pszTab, DLGPROC pfnDlgProc, const char* pszTemplate, HINSTANCE hInstance, DWORD flags /* = ODPF_BOLDGROUPS */)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.ptszTitle = const_cast<TCHAR*>(pszTitle);
odp.pfnDlgProc = pfnDlgProc;
odp.pszTemplate = const_cast<char*>(pszTemplate);
odp.hInstance = hInstance;
odp.ptszGroup = const_cast<TCHAR*>(pszGroup);
odp.flags = flags | ODPF_TCHAR;
odp.ptszTab = const_cast<TCHAR*>(pszTab);
Options_AddPage(addInfo, &odp);
}
}
/*
* protosvc
*/
namespace protosvc
{
DWORD getCaps(const char* szProto, int flagNum)
{
return (DWORD)CallProtoService(szProto, PS_GETCAPS, static_cast<WPARAM>(flagNum), 0);
}
HICON loadIcon(const char* szProto, int whichIcon)
{
return reinterpret_cast<HICON>(CallProtoService(szProto, PS_LOADICON, static_cast<WPARAM>(whichIcon), 0));
}
}
/*
* system
*/
namespace system
{
DWORD getVersion()
{
return static_cast<DWORD>(CallService(MS_SYSTEM_GETVERSION, 0, 0));
}
int getVersionText(int cchVersion, char* szVersion)
{
return CallService(MS_SYSTEM_GETVERSIONTEXT, cchVersion, reinterpret_cast<LPARAM>(szVersion));
}
int terminated()
{
return CallService(MS_SYSTEM_TERMINATED, 0, 0);
}
}
/*
* core interface functions
*/
bool load()
{
// check for version
if (!isMirandaVersionOk(system::getVersion()))
return false;
return true;
}
void unload()
{}
DWORD getMinimalMirandaVersion()
{
// MEMO: version dependency check
return PLUGIN_MAKE_VERSION(0, 6, 7, 0);
}
bool isMirandaVersionOk(DWORD version)
{
return (version >= getMinimalMirandaVersion());
}
bool isMirandaUnicode()
{
if (system::getVersion() < PLUGIN_MAKE_VERSION(0, 4, 3, 33))
return false;
char szVersion[256] = { 0 };
if (system::getVersionText(256, szVersion) != 0)
return false;
if (!strstr(szVersion, "Unicode"))
return false;
return true;
}
/*
* string handling
*/
char* wideToAnsiDup(const WCHAR* pszWide, UINT uCP /* = CP_ACP */)
{
if (!pszWide)
return NULL;
int len = WideCharToMultiByte(uCP, 0, pszWide, -1, NULL, 0, NULL, NULL);
char* result = reinterpret_cast<char*>(malloc(sizeof(char)* len));
if (!result)
return NULL;
WideCharToMultiByte(uCP, 0, pszWide, -1, result, len, NULL, NULL);
result[len - 1] = 0;
return result;
}
WCHAR* ansiToWideDup(const char* pszAnsi, UINT uCP /* = CP_ACP */)
{
if (!pszAnsi)
return NULL;
int len = MultiByteToWideChar(uCP, 0, pszAnsi, -1, NULL, 0);
WCHAR* result = reinterpret_cast<WCHAR*>(malloc(sizeof(WCHAR)* len));
if (!result)
return NULL;
MultiByteToWideChar(uCP, 0, pszAnsi, -1, result, len);
result[len - 1] = 0;
return result;
}
char* wideToAnsi(const WCHAR* pszWide, char* pszRes, int maxLen, UINT uCP /* = CP_ACP */)
{
if (!pszWide)
return NULL;
WideCharToMultiByte(uCP, 0, pszWide, -1, pszRes, maxLen, NULL, NULL);
return pszRes;
}
WCHAR* ansiToWide(const char* pszAnsi, WCHAR* pszRes, int maxLen, UINT uCP /* = CP_ACP */)
{
if (!pszAnsi)
return NULL;
MultiByteToWideChar(uCP, 0, pszAnsi, -1, pszRes, maxLen);
return pszRes;
}
}
|