summaryrefslogtreecommitdiff
path: root/plugins/AutoShutdown/utils.c
blob: b9bbddbc01eecefada7eee64e972dea9976f6e8d (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
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
/*

'AutoShutdown'-Plugin for Miranda IM

Copyright 2004-2007 H. Herkenrath

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 (Shutdown-License.txt); if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include "common.h"

/************************* String *********************************/

// mir_free() the return value
#if !defined(_UNICODE)
WCHAR* a2u(const char *pszAnsi)
{
	int codepage,cch;
	WCHAR *psz;
	
	if(pszAnsi==NULL) return NULL;
	codepage=CallService(MS_LANGPACK_GETCODEPAGE,0,0);
	cch=MultiByteToWideChar(codepage,0,pszAnsi,-1,NULL,0);
	if(!cch) return NULL;

	psz=(WCHAR*)mir_alloc(cch*sizeof(WCHAR));
	if(psz!=NULL && !MultiByteToWideChar(codepage,0,pszAnsi,-1,psz,cch)) {
		mir_free(psz);
		return NULL;
	}
	return psz;
}
#endif

// mir_free() the return value
#if defined(_UNICODE)
char* u2a(const WCHAR *pszUnicode)
{
	int codepage,cch;
	char *psz;
	DWORD flags;

	if(pszUnicode==NULL) return NULL;
	codepage=CallService(MS_LANGPACK_GETCODEPAGE,0,0);
	/* without WC_COMPOSITECHECK some characters might get out strange (see MS blog) */
	cch=WideCharToMultiByte(codepage,flags=WC_COMPOSITECHECK,pszUnicode,-1,NULL,0,NULL,NULL);
	if(!cch) cch=WideCharToMultiByte(codepage,flags=0,pszUnicode,-1,NULL,0,NULL,NULL);
	if(!cch) return NULL;

	psz=(char*)mir_alloc(cch);
	if(psz!=NULL && !WideCharToMultiByte(codepage,flags,pszUnicode,-1,psz,cch,NULL,NULL)){
		mir_free(psz);
		return NULL;
	}
	return psz;
}
#endif

void TrimString(TCHAR *pszStr)
{
	int i;
	TCHAR *psz,szChars[]=_T(" \r\n\t");
	for(i=0;i<SIZEOF(szChars);++i) {
		/* trim end */
		psz=&pszStr[lstrlen(pszStr)-1];
		while(pszStr[0] && *psz==szChars[i]) {
			*psz=0;
			psz=CharPrev(pszStr,psz);
		}
		/* trim beginning */
		for(psz=pszStr;(*psz && *psz==szChars[i]);psz=CharNext(psz));
		MoveMemory(pszStr,psz,(lstrlen(psz)+1)*sizeof(TCHAR));
	}
}

/************************* Error Output ***************************/

static void MessageBoxIndirectFree(MSGBOXPARAMSA *mbp)
{
	MessageBoxIndirectA(mbp);
	mir_free((char*)mbp->lpszCaption); /* does NULL check */
	mir_free((char*)mbp->lpszText);    /* does NULL check */
	mir_free(mbp);
}

void ShowInfoMessage(BYTE flags,const char *pszTitle,const char *pszTextFmt,...)
{
	char szText[256]; /* max for systray */
	MSGBOXPARAMSA *mbp;

	va_list va;
	va_start(va,pszTextFmt);
	mir_vsnprintf(szText,SIZEOF(szText),pszTextFmt,va);
	va_end(va);

	if(ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) {
		MIRANDASYSTRAYNOTIFY msn;
		msn.cbSize=sizeof(msn);
		msn.szProto=NULL;
		msn.szInfoTitle=(char*)pszTitle;
		msn.szInfo=(char*)szText;
		msn.uTimeout=30000; /* max timeout */
		msn.dwInfoFlags=flags;
		if(!CallServiceSync(MS_CLIST_SYSTRAY_NOTIFY,0,(LPARAM)&msn))
			return; /* success */
	}

	mbp=(MSGBOXPARAMSA*)mir_calloc(sizeof(*mbp));
	if(mbp==NULL) return;
	mbp->cbSize=sizeof(*mbp);
	mbp->lpszCaption=mir_strdup(pszTitle);
	mbp->lpszText=mir_strdup(szText);
	mbp->dwStyle=MB_OK|MB_SETFOREGROUND|MB_TASKMODAL;
	mbp->dwLanguageId=LANGIDFROMLCID((LCID)CallService(MS_LANGPACK_GETLOCALE,0,0));
	switch(flags&NIIF_ICON_MASK) {
		case NIIF_INFO:    mbp->dwStyle|=MB_ICONINFORMATION; break;
		case NIIF_WARNING: mbp->dwStyle|=MB_ICONWARNING; break;
		case NIIF_ERROR:   mbp->dwStyle|=MB_ICONERROR;
	}
	mir_forkthread(MessageBoxIndirectFree,mbp);
}

// LocalFree() the return value
char* GetWinErrorDescription(DWORD dwLastError)
{
	char *buf=NULL;
	DWORD flags=FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM;
	if(!FormatMessageA(flags,NULL,dwLastError,LANGIDFROMLCID((LCID)CallService(MS_LANGPACK_GETLOCALE,0,0)),(char*)&buf,0,NULL))
		if(GetLastError()==ERROR_RESOURCE_LANG_NOT_FOUND) 
			FormatMessageA(flags,NULL,dwLastError,0,(char*)&buf,0,NULL);
	return buf;
}

/************************* Time ***********************************/

BOOL SystemTimeToTimeStamp(SYSTEMTIME *st,time_t *timestamp)
{
	struct tm ts;
	ts.tm_isdst=-1;             /* daylight saving time (-1=compute) */
	ts.tm_sec=st->wSecond;      /* 0-59 */
	ts.tm_min=st->wMinute;      /* 0-59 */
	ts.tm_hour=st->wHour;       /* 0-23 */
	ts.tm_mday=st->wDay;        /* 1-31 */
	ts.tm_wday=st->wDayOfWeek;  /* 0-6 (Sun-Sat) */
	ts.tm_mon=st->wMonth-1;     /* 0-11 (Jan-Dec) */
	ts.tm_year=st->wYear-1900;  /* current year minus 1900 */
	ts.tm_yday=0;               /* 0-365 (Jan1=0) */
	*timestamp=mktime(&ts);
	return (*timestamp!=-1);
}

BOOL TimeStampToSystemTime(time_t timestamp,SYSTEMTIME *st)
{
	struct tm *ts;
	ts=localtime(&timestamp);  /* statically alloced, local time correction */
	if(ts==NULL) return FALSE;
	st->wMilliseconds=0;                 /* 0-999 (not given in tm) */
	st->wSecond=(WORD)ts->tm_sec;       /* 0-59 */
	st->wMinute=(WORD)ts->tm_min;       /* 0-59 */
	st->wHour=(WORD)ts->tm_hour;        /* 0-23 */
	st->wDay=(WORD)ts->tm_mday;         /* 1-31 */
	st->wDayOfWeek=(WORD)ts->tm_wday;   /* 0-6 (Sun-Sat) */
	st->wMonth=(WORD)(ts->tm_mon+1);    /* 1-12 (Jan-Dec) */
	st->wYear=(WORD)(ts->tm_year+1900); /* 1601-30827 */
	return TRUE;
}

BOOL GetFormatedCountdown(TCHAR *pszOut,int nSize,time_t countdown) 
{
	static BOOL fInited=FALSE;
	static int (WINAPI *pfnStrFromTimeInterval)(TCHAR*,UINT,DWORD,int);
	#if defined(_UNICODE)
	static int (WINAPI *pfnGetDurationFormat)(LCID,DWORD,const SYSTEMTIME*,double,WCHAR*,WCHAR*,int); 
	#endif
	/* Init */
	if(!fInited) {
		#if defined(_UNICODE)
		*(PROC*)&pfnGetDurationFormat=GetProcAddress(GetModuleHandleA("KERNEL32"),"GetDurationFormat");
		if(pfnGetDurationFormat==NULL) {
		#endif
			HMODULE hShlwDLL=LoadLibraryA("SHLWAPI"); /* all ascii */
			#if defined(_UNICODE)
				*(PROC*)&pfnStrFromTimeInterval=GetProcAddress(hShlwDLL,"StrFromTimeIntervalW");
			#else
				*(PROC*)&pfnStrFromTimeInterval=GetProcAddress(hShlwDLL,"StrFromTimeIntervalA");
			#endif
		#if defined(_UNICODE)
		}
		#endif
		fInited=TRUE;
	}
	/* WinVista */
	#if defined(_UNICODE)
	if(pfnGetDurationFormat!=NULL) {
		SYSTEMTIME st;
		LCID locale;
		locale=(LCID)CallService(MS_LANGPACK_GETLOCALE,0,0);
		if(TimeStampToSystemTime(countdown,&st))
			if(pfnGetDurationFormat(locale,0,&st,0,NULL,pszOut,nSize))
				return TRUE;
		return FALSE;
	}
	#endif
	/* Win9x/NT/XP */
	if(pfnStrFromTimeInterval!=NULL)
		return pfnStrFromTimeInterval(pszOut,nSize,(countdown>(MAXDWORD/1000))?MAXDWORD:(countdown*1000),10)!=0;
	return FALSE;
}

BOOL GetFormatedDateTime(TCHAR *pszOut,int nSize,time_t timestamp,BOOL fShowDateEvenToday) 
{
	SYSTEMTIME st,stNow;
	LCID locale;
	locale=(LCID)CallService(MS_LANGPACK_GETLOCALE,0,0);
	GetLocalTime(&stNow);
	TimeStampToSystemTime(timestamp,&st);
	/* today: no need to show the date */
	if(!fShowDateEvenToday && st.wDay==stNow.wDay && st.wMonth==stNow.wMonth && st.wYear==stNow.wYear)
		return GetTimeFormat(locale,((st.wSecond==0)?TIME_NOSECONDS:0)|TIME_FORCE24HOURFORMAT,&st,NULL,pszOut,nSize)!=0;
	/* show both date and time */
	{	TCHAR szDate[128],szTime[128];
		if(!GetTimeFormat(locale,((st.wSecond==0)?TIME_NOSECONDS:0)|TIME_FORCE24HOURFORMAT,&st,NULL,szTime,SIZEOF(szTime)))
			return FALSE;
		if(!GetDateFormat(locale,DATE_SHORTDATE,&st,NULL,szDate,SIZEOF(szDate)))
			return FALSE;
		mir_sntprintf(pszOut,nSize,_T("%s %s"),szTime,szDate);
		return TRUE;
	}
}

/************************* Fonts & Colors *************************/

int FontService_RegisterFont(const char *pszDbModule,const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDescription,int position,BOOL bAllowEffects,LOGFONT *plfDefault,COLORREF clrDefault)
{
	FontIDT fid;
	ZeroMemory(&fid,sizeof(fid));
	fid.cbSize=sizeof(fid);
	lstrcpynA(fid.dbSettingsGroup,pszDbModule,sizeof(fid.dbSettingsGroup)); /* buffer safe */
	lstrcpynA(fid.prefix,pszDbName,sizeof(fid.prefix)); /* buffer safe */
	lstrcpyn(fid.group,pszSection,SIZEOF(fid.group)); /* buffer safe */
	lstrcpyn(fid.name,pszDescription,SIZEOF(fid.name)); /* buffer safe */
	fid.flags=FIDF_ALLOWREREGISTER;
	if(bAllowEffects) fid.flags|=FIDF_ALLOWEFFECTS;
	fid.order=position;
	if(plfDefault!=NULL) {
		fid.flags|=FIDF_DEFAULTVALID;
		fid.deffontsettings.colour=clrDefault;
		fid.deffontsettings.size=(char)plfDefault->lfHeight;
		if(plfDefault->lfItalic) fid.deffontsettings.style|=DBFONTF_ITALIC;
		if(plfDefault->lfWeight!=FW_NORMAL) fid.deffontsettings.style|=DBFONTF_BOLD;
		if(plfDefault->lfUnderline) fid.deffontsettings.style|=DBFONTF_UNDERLINE;
		if(plfDefault->lfStrikeOut) fid.deffontsettings.style|=DBFONTF_STRIKEOUT;
		fid.deffontsettings.charset=plfDefault->lfCharSet;
		lstrcpyn(fid.deffontsettings.szFace,plfDefault->lfFaceName,SIZEOF(fid.deffontsettings.szFace)); /* buffer safe */
	}
	return CallService(MS_FONT_REGISTERT,(WPARAM)&fid,(LPARAM)&fid);
}

int FontService_GetFont(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr,LOGFONT *plf)
{
	FontIDT fid;
	fid.cbSize=sizeof(fid);
	lstrcpyn(fid.group,pszSection,SIZEOF(fid.group)); /* buffer sfae */
	lstrcpyn(fid.name,pszDescription,SIZEOF(fid.name)); /* buffer safe */
	*pclr=(COLORREF)CallService(MS_FONT_GETT,(WPARAM)&fid,(LPARAM)plf); /* uses fallback font on error */
	return (int)*pclr==-1;
}

int FontService_RegisterColor(const char *pszDbModule,const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF clrDefault)
{
	ColourIDT cid;
	ZeroMemory(&cid,sizeof(cid));
	cid.cbSize=sizeof(cid);
	cid.defcolour=clrDefault; 
	lstrcpynA(cid.dbSettingsGroup,pszDbModule,sizeof(cid.dbSettingsGroup)); /* buffer safe */
	lstrcpynA(cid.setting,pszDbName,sizeof(cid.setting)); /* buffer safe */
	lstrcpyn(cid.group,pszSection,SIZEOF(cid.group)); /* buffer safe */
	lstrcpyn(cid.name,pszDescription,SIZEOF(cid.name)); /* buffer safe */
	return CallService(MS_COLOUR_REGISTERT,(WPARAM)&cid,0);
}

int FontService_GetColor(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr)
{
	ColourIDT cid;
	ZeroMemory(&cid,sizeof(cid));
	cid.cbSize=sizeof(cid);
	lstrcpyn(cid.group,pszSection,sizeof(cid.group)); /* buffer safe */
	lstrcpyn(cid.name,pszDescription,sizeof(cid.name)); /* buffer safe */
	*pclr=(COLORREF)CallService(MS_COLOUR_GETT,(WPARAM)&cid,0);
	return (int)*pclr==-1;
}

/************************* Skin ***********************************/

HANDLE IcoLib_AddIconRes(const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDesc,HINSTANCE hInst,WORD idRes,BOOL fLarge)
{
	SKINICONDESC sid;
	TCHAR szFileName[MAX_PATH];
	sid.cbSize=sizeof(SKINICONDESC);
	sid.pszName=(char*)pszDbName;
	sid.ptszSection=(TCHAR*)pszSection;
	sid.ptszDescription=(TCHAR*)pszDesc;
	sid.ptszDefaultFile=szFileName;
	sid.iDefaultIndex=-idRes;
	sid.cx=GetSystemMetrics(fLarge?SM_CXICON:SM_CXSMICON);
	sid.cy=GetSystemMetrics(fLarge?SM_CYICON:SM_CYSMICON);
	sid.hDefaultIcon=NULL;
	sid.flags=SIDF_SORTED|SIDF_ALL_TCHAR;
	if(!GetModuleFileName(hInst,szFileName,SIZEOF(szFileName)))
		return NULL;
	return (HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
}

HICON IcoLib_GetIcon(const char *pszDbName)
{
	return (HICON)CallService(MS_SKIN2_GETICON,0,(LPARAM)pszDbName);
}

int IcoLib_ReleaseIcon(HICON hIcon)
{
	return CallService(MS_SKIN2_RELEASEICON,(WPARAM)hIcon,0);
}

int SkinAddNewSoundBundled(const char *pszDbName,const char *pszSection,const char *pszDesc,const char *pszSubDir,const char *pszDefaultFile)
{
	SKINSOUNDDESCEX ssd;
	char szFile[MAX_PATH],*p;
	HANDLE hFile;

	ssd.cbSize=sizeof(ssd);
	ssd.pszName=pszDbName;
	ssd.pszSection=pszSection;
	ssd.pszDescription=pszDesc;
	ssd.pszDefaultFile=NULL;
	if(GetModuleFileNameA(NULL,szFile,SIZEOF(szFile)-lstrlenA(pszSubDir)-lstrlenA(pszDefaultFile))) {
		p=strrchr(szFile,'\\');
		if(p!=NULL) *(++p)=0;
		lstrcatA(lstrcatA(szFile,pszSubDir),pszDefaultFile); /* buffer safe */
		/* check if sound file exist */
		hFile=CreateFileA(szFile,0,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
		if(hFile!=INVALID_HANDLE_VALUE) {
			ssd.pszDefaultFile=szFile; /* MS_UTILS_PATHTORELATIVET called automatically */
			CloseHandle(hFile);
		}
	}
	return CallService(MS_SKIN_ADDNEWSOUND,0,(LPARAM)&ssd);
}

/* workaround for 'Hotkey Service' plugin because it has needs an event catcher */
static char szHotkeyService[MAXMODULELABELLENGTH];
static int moduleId,itemId;
static int HotkeysServiceHotkeyPressed(WPARAM wParam,LPARAM lParam)
{
	UNREFERENCED_PARAMETER(lParam);
	if(((THKSEvent*)wParam)->moduleId==moduleId && ((THKSEvent*)wParam)->itemId==LOWORD(itemId))
		CallService(szHotkeyService,0,0);
	return 0;
}

/* defines for 'Hotkey Manager' */
#define HK_ACT_OVERWRITE  0
#define HKF_GLOBAL        0x00000001
#define HKF_WPARNUM       0x00000008
#define HKF_HEX           0x00000200
#define HKF_LCURRENT      0x00001000
#define HKT_SERVICE       2
typedef struct {
	void *reserved1;
	void *reserved2;
	int hotkey;
	WCHAR* descr;
	DWORD flags;
	ATOM reserved3;
	DWORD _type;
	char* service;
	WPARAM wparam;
	LPARAM lparam;
} HOTKEYREC;
#define MS_HK_ADDHOTKEY  "HotKey/AddHotkey"

int SkinAddNewHotkey(const char *pszDbName,const char *pszSection,const char *pszDescription,UINT vk,UINT hotkeyfModifiers,const char *pszServiceName)
{
	if(ServiceExists(MS_SKIN_ADDHOTKEY)) { /* clist_mw, clist_modern */
		SKINHOTKEYDESCEX shd;
		ZeroMemory(&shd,sizeof(shd));
		shd.cbSize=sizeof(shd);
		shd.pszName=(char*)pszDbName;
		shd.pszDescription=(char*)pszDescription;
		shd.pszSection=(char*)pszSection;
		shd.pszService=(char*)pszServiceName;
		shd.DefHotKey=MAKEWORD(vk,hotkeyfModifiers);
		CallService(MS_SKIN_ADDHOTKEY,0,(LPARAM)&shd);
		/* no return */
	}
	if(ServiceExists(MS_HOTKEYSPLUS_ADDKEY)) /* 'Hotkeys Plus' */
		return CallService(MS_HOTKEYSPLUS_ADDKEY,(WPARAM)pszServiceName,(LPARAM)pszDescription);
	if(ServiceExists(HKS_REGISTERFUNCTION)) { /* mHotKey */
		KEYHASH kh;
		kh.isShift=(hotkeyfModifiers&HOTKEYF_SHIFT)!=0;
		kh.isCtrl=(hotkeyfModifiers&HOTKEYF_CONTROL)!=0;
		kh.isAlt=(hotkeyfModifiers&HOTKEYF_ALT)!=0;
		kh.vkCode=vk;
		return !CallService(HKS_REGISTERFUNCTION,(WPARAM)&kh,(LPARAM)pszServiceName);
	}
	if(ServiceExists(MS_HK_ADDHOTKEY)) { /* 'Hotkey Manager' */
		HOTKEYREC hkr;
		ZeroMemory(&hkr,sizeof(hkr));
		hkr.hotkey=(int)MAKEWORD(vk,hotkeyfModifiers);
		#if defined(_UNICODE)
			hkr.descr=(WCHAR*)pszDescription;
		#else
			hkr.descr=(WCHAR*)a2u(pszDescription);
		#endif
		hkr.flags=HKF_GLOBAL|HKF_WPARNUM|HKF_LCURRENT|HKF_HEX;
		hkr._type=HKT_SERVICE;
		hkr.service=(char*)pszServiceName;
		CallService(MS_HK_ADDHOTKEY,(WPARAM)&hkr,HK_ACT_OVERWRITE);
		#if !defined(_UNICODE)
			mir_free(hkr.descr);
		#endif
		return 0;
	}
	if(ServiceExists(MS_HKS_REGISTER_ITEM)) { /* 'Hotkeys Service' */
		THKSItem item;
		ZeroMemory(&item,sizeof(item));
		item.name=(char*)pszSection;
		item.itemType=HKS_ITEM_MODULE;
		item.owner=LOWORD(CallService(MS_HKS_REGISTER_ITEM,(WPARAM)&item,0));
		item.name=(char*)pszDescription;
		item.itemType=HKS_ITEM_ACTION;
		item.hotkey.key=(WORD)vk;
		item.hotkey.modifiers=MOD_GLOBAL;
		if(hotkeyfModifiers&HOTKEYF_ALT) item.hotkey.modifiers|=MOD_ALT;
		if(hotkeyfModifiers&HOTKEYF_CONTROL) item.hotkey.modifiers|=MOD_CONTROL;
		if(hotkeyfModifiers&HOTKEYF_SHIFT) item.hotkey.modifiers|=MOD_SHIFT;
		if(hotkeyfModifiers&HOTKEYF_EXT) item.hotkey.modifiers|=MOD_WIN;
		/* no possibility to specify a service to call,
		 * all processing needs to be done in the plugins */
		moduleId=item.owner;
		mir_snprintf(szHotkeyService,sizeof(szHotkeyService),"%s",pszServiceName); // only allows for one hotkey as a whole
		HookEvent(ME_HKS_KEY_PRESSED,HotkeysServiceHotkeyPressed);
		itemId=CallService(MS_HKS_REGISTER_ITEM,(WPARAM)&item,0);
		return HIWORD(itemId);
	}
	return 1;
}