summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/events.cpp
blob: 874ce16f72a704ebdc6a0576f27427485d0684b9 (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
#include "stdafx.h"

static int OnProtoAck(WPARAM, LPARAM lParam)
{
	ACKDATA *ack = (ACKDATA*)lParam;

	if (ack->type != ACKTYPE_STATUS)
		return 0;

	for (auto &hContact : contact_iter(ack->szModule)) {
		MessageWindowData msgw;
		if (Srmm_GetWindowData(hContact, msgw) || !(msgw.uState & MSG_WINDOW_STATE_EXISTS))
			continue;

		BBButton bbd = {};
		bbd.pszModuleName = MODULE;
		bbd.dwButtonID = BBB_ID_FILE_SEND;
		bbd.bbbFlags = CanSendToContact(hContact)
			? BBSF_RELEASED
			: BBSF_DISABLED;
		Srmm_SetButtonState(hContact, &bbd);
	}

	return 0;
}

static int OnFileDialogCanceled(WPARAM hContact, LPARAM)
{
	for (auto &service : Services) {
		auto it = service->InterceptedContacts.find(hContact);
		if (it != service->InterceptedContacts.end())
			service->InterceptedContacts.erase(it);
	}
	return 0;
}

int OnModulesLoaded(WPARAM, LPARAM)
{
	
	HookEvent(ME_PROTO_ACK, OnProtoAck);

	// options
	HookEvent(ME_OPT_INITIALISE, OnOptionsInitialized);

	// srfile
	HookEvent(ME_FILEDLG_CANCELED, OnFileDialogCanceled);

	HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildContactMenu);

	HookEvent(ME_MSG_WINDOWEVENT, OnSrmmWindowOpened);
	HookEvent(ME_MSG_BUTTONPRESSED, OnSrmmButtonPressed);

	HookTemporaryEvent(ME_MSG_TOOLBARLOADED, OnSrmmToolbarLoaded);

	return 0;
}