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

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

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

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

		BBButton bbd = {};
		bbd.pszModuleName = MODULENAME;
		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)
{
	InitializeMenus();

	HookEvent(ME_PROTO_ACK, OnProtoAck);

	// srfile
	HookEvent(ME_FILEDLG_CANCELED, OnFileDialogCanceled);

	HookTemporaryEvent(ME_MSG_TOOLBARLOADED, OnSrmmToolbarLoaded);
	return 0;
}