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

int OnModulesLoaded(WPARAM, LPARAM)
{
	
	//InitializeMenus();

	// options
	HookEvent(ME_OPT_INITIALISE, OnOptionsInitialized);

	// srfile
	for (auto &service : Services)
		HookEventObj(ME_FILEDLG_CANCELED, OnFileDialogCanceled, service);

	HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildContactMenu);

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

	HookTemporaryEvent(ME_MSG_TOOLBARLOADED, OnSrmmToolbarLoaded);

	return 0;
}

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

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

	for (MCONTACT hContact = db_find_first(ack->szModule); hContact; hContact = db_find_next(hContact, 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;
}

int OnFileDialogCanceled(void* obj, WPARAM hContact, LPARAM)
{
	CCloudService *service = (CCloudService*)obj;

	auto it = service->InterceptedContacts.find(hContact);
	if (it != service->InterceptedContacts.end())
		service->InterceptedContacts.erase(it);

	return 0;
}