summaryrefslogtreecommitdiff
path: root/protocols/CloudFile/src/menus.cpp
blob: aaf767a3229b4ed11e13f87630469bd3abb26705 (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
59
60
#include "stdafx.h"

static HGENMENU hContactMenu;

void InitializeMenus()
{
	if (hContactMenu)
		Menu_RemoveItem(hContactMenu);

	// no money, no honey
	if (g_arServices.getCount() == 0)
		return;

	CMenuItem mi(&g_plugin);
	SET_UID(mi, 0x93d4495b, 0x259b, 0x4fba, 0xbc, 0x14, 0xf9, 0x46, 0x2c, 0xda, 0xfc, 0x6d);
	mi.position = -2000019999;

	CMStringA szService;
	if (g_arServices.getCount() == 1) {
		auto *S = g_arServices[0];

		szService.Format("%s%s", S->m_szModuleName, PS_UPLOAD);
		CMStringW wszTitle(FORMAT, L"%s %s", TranslateT("Upload to"), S->m_tszUserName);
		mi.flags |= CMIF_UNICODE;
		mi.pszService = szService;
		mi.name.w = wszTitle.GetBuffer();
		mi.hIcolibItem = g_plugin.getIconHandle(S->GetIconId());
		hContactMenu = Menu_AddContactMenuItem(&mi);
	}
	else {
		mi.hIcolibItem = g_plugin.getIconHandle(IDI_UPLOAD);
		mi.name.a = LPGEN("Upload to...");
		hContactMenu = Menu_AddContactMenuItem(&mi);

		int i = 1000;
		for (auto &S : g_arServices) {
			szService.Format("%s%s", S->m_szModuleName, PS_UPLOAD);

			CMenuItem mi2(S->GetId());
			mi2.root = hContactMenu;
			mi2.flags = CMIF_SYSTEM | CMIF_UNICODE;
			mi2.name.w = S->m_tszUserName;
			mi2.position = i++;
			mi2.pszService = szService;
			mi2.hIcolibItem = g_plugin.getIconHandle(S->GetIconId());
			Menu_AddContactMenuItem(&mi2);
		}
	}
}

void CCloudService::OnModulesLoaded()
{
	InitializeMenus();
}

int OnPrebuildContactMenu(WPARAM hContact, LPARAM)
{
	Menu_ShowItem(hContactMenu, CanSendToContact(hContact));
	return 0;
}