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
|
#include "common.h"
int CToxProto::OnModulesLoaded(WPARAM, LPARAM)
{
CToxProto::InitIcons();
CToxProto::InitMenus();
CToxProto::InitCustomDbEvents();
hProfileFolderPath = FoldersRegisterCustomPathT("Tox", Translate("Profiles folder"), MIRANDA_USERDATAT);
return 0;
}
void CToxProto::InitCustomDbEvents()
{
DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) };
dbEventType.module = MODULE;
dbEventType.flags = DETF_HISTORY | DETF_MSGWINDOW;
dbEventType.eventType = DB_EVENT_ACTION;
dbEventType.descr = Translate("Action");
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
dbEventType.eventType = DB_EVENT_AUDIO_CALL;
dbEventType.descr = Translate("Audio call");
dbEventType.eventIcon = GetIconHandle("audio_call");
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
}
int CToxProto::OnDbEventAdded(WPARAM hContact, LPARAM hEvent)
{
DWORD dwSignature;
DBEVENTINFO dbei = { sizeof(dbei) };
dbei.cbBlob = sizeof(DWORD);
dbei.pBlob = (PBYTE)&dwSignature;
db_event_get(hEvent, &dbei);
if (dbei.flags & (DBEF_SENT | DBEF_READ) || dbei.eventType <= DB_EVENT_ACTION || dwSignature == 0)
return 0;
DBEVENTTYPEDESCR *dbEventType = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)MODULE, dbei.eventType);
if (dbEventType == NULL)
return 0;
CLISTEVENT cle = { sizeof(cle) };
cle.flags |= CLEF_TCHAR;
cle.hContact = hContact;
cle.hDbEvent = hEvent;
cle.hIcon = Skin_GetIconByHandle(dbEventType->eventIcon);
TCHAR szTooltip[256];
mir_sntprintf(szTooltip, SIZEOF(szTooltip), _T("%s %s %s"), _A2T(dbEventType->descr), TranslateT("from"), pcli->pfnGetContactDisplayName(hContact, 0));
cle.ptszTooltip = szTooltip;
char szService[256];
switch (dbei.eventType)
{
case DB_EVENT_AUDIO_CALL:
mir_snprintf(szService, SIZEOF(szService), "%s/AudioCall", GetContactProto(hContact));
break;
default:
return 0;
}
cle.pszService = szService;
CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
return 0;
}
|