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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
#include "commonheaders.h"
INT_PTR __cdecl Service_IsContactSecured(WPARAM wParam, LPARAM)
{
return (isContactSecured(wParam)&SECURED) || isContactPGP(wParam) || isContactGPG(wParam);
}
INT_PTR __cdecl Service_CreateIM(WPARAM wParam, LPARAM)
{
ProtoChainSend(wParam, PSS_MESSAGE, PREF_METANODB, (LPARAM)SIG_INIT);
return 1;
}
INT_PTR __cdecl Service_DisableIM(WPARAM wParam, LPARAM)
{
ProtoChainSend(wParam, PSS_MESSAGE, PREF_METANODB, (LPARAM)SIG_DEIN);
return 1;
}
INT_PTR __cdecl Service_Status(WPARAM wParam, LPARAM lParam)
{
switch (--lParam) {
case STATUS_DISABLED:
case STATUS_ENABLED:
case STATUS_ALWAYSTRY:
pUinKey ptr = getUinKey(wParam);
if (ptr) {
ptr->status = ptr->tstatus = (BYTE)lParam;
if (ptr->status == STATUS_ENABLED)
db_unset(ptr->hContact, MODULENAME, "StatusID");
else
db_set_b(ptr->hContact, MODULENAME, "StatusID", ptr->status);
}
break;
}
return 1;
}
INT_PTR __cdecl Service_StatusDis(WPARAM wParam, LPARAM)
{
return Service_Status(wParam, STATUS_DISABLED + 1);
}
INT_PTR __cdecl Service_StatusEna(WPARAM wParam, LPARAM)
{
return Service_Status(wParam, STATUS_ENABLED + 1);
}
INT_PTR __cdecl Service_StatusTry(WPARAM wParam, LPARAM)
{
return Service_Status(wParam, STATUS_ALWAYSTRY + 1);
}
INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM)
{
if (bPGPloaded) {
db_unset(wParam, MODULENAME, "pgp");
db_unset(wParam, MODULENAME, "pgp_mode");
db_unset(wParam, MODULENAME, "pgp_abbr");
}
{
pUinKey ptr = getUinKey(wParam);
cpp_delete_context(ptr->cntx); ptr->cntx = nullptr;
}
ShowStatusIconNotify(wParam);
return 1;
}
INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam)
{
BOOL del = true;
if (bPGPloaded) {
if (bPGPkeyrings) {
char szKeyID[128]; szKeyID[0] = '\0';
PVOID KeyID = pgp_select_keyid(GetForegroundWindow(), szKeyID);
if (szKeyID[0]) {
db_unset(wParam, MODULENAME, "pgp");
db_set_blob(wParam, MODULENAME, "pgp", KeyID, pgp_size_keyid());
db_set_b(wParam, MODULENAME, "pgp_mode", 0);
db_set_s(wParam, MODULENAME, "pgp_abbr", szKeyID);
del = false;
}
}
else if (bPGPprivkey) {
char KeyPath[MAX_PATH]; KeyPath[0] = '\0';
if (ShowSelectKeyDlg(nullptr, KeyPath)) {
char *publ = LoadKeys(KeyPath, false);
if (publ) {
db_unset(wParam, MODULENAME, "pgp");
db_set_s(wParam, MODULENAME, "pgp", publ);
db_set_b(wParam, MODULENAME, "pgp_mode", 1);
db_set_s(wParam, MODULENAME, "pgp_abbr", "(binary)");
mir_free(publ);
del = false;
}
}
}
}
if (del)
Service_PGPdelKey(wParam, lParam);
else {
pUinKey ptr = getUinKey(wParam);
cpp_delete_context(ptr->cntx); ptr->cntx = nullptr;
}
ShowStatusIconNotify(wParam);
return 1;
}
INT_PTR __cdecl Service_GPGdelKey(WPARAM wParam, LPARAM)
{
if (bGPGloaded)
db_unset(wParam, MODULENAME, "gpg");
{
pUinKey ptr = getUinKey(wParam);
cpp_delete_context(ptr->cntx); ptr->cntx = nullptr;
}
ShowStatusIconNotify(wParam);
return 1;
}
INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam)
{
bool del = true;
if (bGPGloaded && bGPGkeyrings) {
char szKeyID[128]; szKeyID[0] = '\0';
gpg_select_keyid(GetForegroundWindow(), szKeyID);
if (szKeyID[0]) {
db_set_s(wParam, MODULENAME, "gpg", szKeyID);
del = false;
}
}
if (del)
Service_GPGdelKey(wParam, lParam);
else {
pUinKey ptr = getUinKey(wParam);
cpp_delete_context(ptr->cntx); ptr->cntx = nullptr;
}
ShowStatusIconNotify(wParam);
return 1;
}
INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam)
{
pUinKey ptr = getUinKey(wParam);
switch (--lParam) {
case MODE_NATIVE:
case MODE_RSAAES:
if (isContactSecured(wParam)&SECURED) {
msgbox(nullptr, sim111, MODULENAME, MB_OK);
return 0;
}
if (lParam != MODE_NATIVE && ptr->status > STATUS_ENABLED)
Service_Status(wParam, STATUS_ENABLED + 1);
case MODE_PGP:
case MODE_GPG:
// íóæíî ìíîãî ïðîâåðîê è îòêëþ÷åíèå àêòèâíîãî êîíòåêñòà åñëè íåîáõîäèìî
if (ptr) {
if (ptr->cntx) {
cpp_delete_context(ptr->cntx);
ptr->cntx = nullptr;
ptr->keyLoaded = 0;
}
ptr->mode = (BYTE)lParam;
db_set_b(wParam, MODULENAME, "mode", (BYTE)lParam);
}
ShowStatusIcon(wParam);
break;
}
return 1;
}
INT_PTR __cdecl Service_ModeNative(WPARAM wParam, LPARAM)
{
return Service_Mode(wParam, MODE_NATIVE + 1);
}
INT_PTR __cdecl Service_ModePGP(WPARAM wParam, LPARAM)
{
return Service_Mode(wParam, MODE_PGP + 1);
}
INT_PTR __cdecl Service_ModeGPG(WPARAM wParam, LPARAM)
{
return Service_Mode(wParam, MODE_GPG + 1);
}
INT_PTR __cdecl Service_ModeRSAAES(WPARAM wParam, LPARAM)
{
return Service_Mode(wParam, MODE_RSAAES + 1);
}
|