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
|
#include "common.h"
#include "srmm_icon.h"
#include "resource.h"
#include "notifications.h"
#include "server_con.h"
#include <ctime>
int WindowEvent(WPARAM wParam, LPARAM lParam) {
MessageWindowEventData *wd = (MessageWindowEventData *)lParam;
if(wd->uType != MSG_WINDOW_EVT_OPEN) return 0;
HANDLE hContact = wd->hContact, hTemp;
if(ServiceExists(MS_MC_GETMOSTONLINECONTACT) && (hTemp = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
hContact = hTemp;
bool hide = false;
if(!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULE))
hide = true;
StatusIconData sid = {0};
sid.cbSize = sizeof(sid);
sid.szModule = MODULE;
sid.flags = (hide ? MBF_HIDDEN : 0);
CallService(MS_MSG_MODIFYICON, (WPARAM)wd->hContact, (LPARAM)&sid);
return 0;
}
int IconPressed(WPARAM wParam, LPARAM lParam) {
StatusIconClickData *cd = (StatusIconClickData *)lParam;
if(strcmp(cd->szModule, MODULE) != 0) return 0;
HANDLE hContact = (HANDLE)wParam, hTemp;
if(ServiceExists(MS_MC_GETMOSTONLINECONTACT) && (hTemp = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
hContact = hTemp;
if(!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULE))
return 0;
HMENU hMenu = CreatePopupMenu();
for(int i = 0; zap_array[i]; i++) {
AppendMenuA(hMenu,MF_STRING,i+1, Translate(zap_array[i]));
}
BOOL cmd = TrackPopupMenu(hMenu, TPM_NONOTIFY | TPM_RETURNCMD, cd->clickLocation.x, cd->clickLocation.y, 0, (HWND)CallService(MS_CLUI_GETHWND, 0, 0), 0);
DestroyMenu(hMenu);
if(cmd) {
int zap_num = cmd - 1;
NotifyZapSend(hContact, zap_num);
}
return 0;
}
HICON hZapIcon = 0;
HANDLE hEventIconPressed = 0, hEventWindow = 0;
void InitSRMMIcon() {
// add icon to srmm status icons
if(ServiceExists(MS_MSG_ADDICON)) {
hZapIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ZAPS));
StatusIconData sid = {0};
sid.cbSize = sizeof(sid);
sid.szModule = MODULE;
sid.hIcon = hZapIcon;
sid.szTooltip = Translate("Send ZAP");
CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
// hook the window events so that we can can change the status of the icon
hEventWindow = HookEvent(ME_MSG_WINDOWEVENT, WindowEvent);
hEventIconPressed = HookEvent(ME_MSG_ICONPRESSED, IconPressed);
}
}
void DeinitSRMMIcon() {
if(hZapIcon) DestroyIcon(hZapIcon);
if(hEventIconPressed) UnhookEvent(hEventIconPressed);
if(hEventWindow) UnhookEvent(hEventWindow);
}
|