summaryrefslogtreecommitdiff
path: root/plugins/SecureIM/src/crypt_popups.cpp
blob: 1d368b22ca8c3886d5bd8669d6039ae25e031efb (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "commonheaders.h"

void showPopup(LPCSTR lpzText,MCONTACT hContact,HICON hIcon, UINT type)
{
	//type=0 key colors
	//type=1 session colors
	//type=2 SR colors

	if (!bPopupExists) return;

	COLORREF colorBack, colorText;
	int timeout=0;

	DBVARIANT dbv;

	if (type == 0) {
		colorBack = db_get_dw(0, MODULENAME, "colorKeyb", RGB(230,230,255));
		colorText = db_get_dw(0, MODULENAME, "colorKeyt", RGB(0,0,0));
		if (!db_get_s(0, MODULENAME, "timeoutKey", &dbv)) {
			timeout = atoi(dbv.pszVal);
			db_free(&dbv);
		}
	}
	else if (type == 1) {
		colorBack = db_get_dw(0, MODULENAME, "colorSecb", RGB(255,255,200));
		colorText = db_get_dw(0, MODULENAME, "colorSect", RGB(0,0,0));
		if (!db_get_s(0, MODULENAME, "timeoutSec" ,&dbv)) {
			timeout = atoi(dbv.pszVal);
			db_free(&dbv);
		}
	}
	else if (type >= 2) {
		colorBack = db_get_dw(0, MODULENAME, "colorSRb", RGB(200,255,200));
		colorText = db_get_dw(0, MODULENAME, "colorSRt", RGB(0,0,0));
		if (!db_get_s(0, MODULENAME, "timeoutSR", &dbv)) {
			timeout = atoi(dbv.pszVal);
			db_free(&dbv);
		}
	}

	POPUPDATAW ppd = {0};
	ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked.
	ppd.lchIcon = hIcon;
	LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,hContact,GSMDF_UNICODE);
	wcscpy(ppd.lpwzContactName, lpwzContactName);
	LPWSTR lpwzText = mir_a2u(lpzText);
	wcscpy(ppd.lpwzText, TranslateW(lpwzText));
	mir_free(lpwzText);
	ppd.colorBack = colorBack;
	ppd.colorText = colorText;
	ppd.iSeconds = timeout;
	PUAddPopupW(&ppd);
}

void showPopupDCmsg(MCONTACT hContact,LPCSTR msg)
{
	if (db_get_b(0, MODULENAME, "dc", 1))
		showPopup(msg, hContact, g_hPOP[POP_PU_DIS], 1);
}

void showPopupDC(MCONTACT hContact)
{
	if (db_get_b(0, MODULENAME, "dc", 1))
		showPopup(sim006, hContact, g_hPOP[POP_PU_DIS], 1);
}

void showPopupEC(MCONTACT hContact)
{
	if (db_get_b(0, MODULENAME, "ec", 1))
		showPopup(sim001, hContact, g_hPOP[POP_PU_EST], 1);
}

void showPopupKS(MCONTACT hContact)
{
	if (db_get_b(0, MODULENAME, "ks",1))
		showPopup(sim007, hContact, g_hPOP[POP_PU_PRC], 0);
}

void showPopupKRmsg(MCONTACT hContact,LPCSTR msg)
{
	if (db_get_b(0, MODULENAME, "kr", 1))
		showPopup(msg, hContact, g_hPOP[POP_PU_PRC], 0);
}

void showPopupKR(MCONTACT hContact)
{
	if (db_get_b(0, MODULENAME, "kr", 1))
		showPopup(sim008, hContact, g_hPOP[POP_PU_PRC], 0);
}

void showPopupSM(MCONTACT hContact)
{
	if (db_get_b(0, MODULENAME, "ss", 0))
		showPopup(sim009, hContact, g_hPOP[POP_PU_MSS], 2);
	SkinPlaySound("OutgoingSecureMessage");
}

void showPopupRM(MCONTACT hContact)
{
	if (db_get_b(0, MODULENAME, "sr", 0))
		showPopup(sim010, hContact, g_hPOP[POP_PU_MSR], 2);
	SkinPlaySound("IncomingSecureMessage");
}

// EOF