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
|
#ifndef __debug_h__
#define __debug_h__
#define PlugName "SplashScreen"
extern TCHAR szLogFile[MAX_PATH];
/*
* output a notification message.
* may accept a hContact to include the contacts nickname in the notification message...
* the actual message is using printf() rules for formatting and passing the arguments...
*
*/
int inline _DebugPopup(HANDLE hContact, TCHAR *fmt, ...)
{
POPUPDATAT ppd;
va_list va;
TCHAR debug[1024];
va_start(va, fmt);
mir_sntprintf(debug, SIZEOF(debug), fmt, va);
if(CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0) == 1)
{
ZeroMemory((void *)&ppd, sizeof(ppd));
ppd.lchContact = hContact;
ppd.lchIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
if(hContact != 0)
_tcsncpy_s(ppd.lptzContactName, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR), MAX_CONTACTNAME);
else
_tcsncpy_s(ppd.lptzContactName, _T(PlugName), MAX_CONTACTNAME);
_tcsncpy_s(ppd.lptzText, debug, MAX_SECONDLINE - 20);
ppd.colorText = RGB(255,255,255);
ppd.colorBack = RGB(255,0,0);
CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0);
}
return 0;
}
/*
* initialize logfile
*/
int inline initLog()
{
fclose(_tfopen(szLogFile, L"w"));
return 0;
}
/*
* logging func
*/
void inline logMessage(TCHAR *func, TCHAR *msg)
{
FILE *f = _tfopen(szLogFile, L"a");
_ftprintf(f, L"%s:\t\t%s\n", func, msg);
fclose(f);
}
#endif // __debug_h__
|