summaryrefslogtreecommitdiff
path: root/plugins/New_GPG/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-10 08:04:30 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-10 08:04:30 +0000
commitddba4ede6b451d0cfcd0d32b5180fbd0689966bf (patch)
tree5d74f37a7013d13b92c182628d6b68a58e148ae4 /plugins/New_GPG/src
parentc39340bf493a1745a41317bbf937fc7eb6cbb26a (diff)
- HANDLE hContact => HCONTACT
- GCF_* prefix was added to chat constants to avoid name conflicts git-svn-id: http://svn.miranda-ng.org/main/trunk@8078 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG/src')
-rw-r--r--plugins/New_GPG/src/clist.cpp3
-rw-r--r--plugins/New_GPG/src/globals.h8
-rw-r--r--plugins/New_GPG/src/icons.cpp12
-rwxr-xr-xplugins/New_GPG/src/main.cpp270
-rwxr-xr-xplugins/New_GPG/src/messages.cpp157
-rw-r--r--plugins/New_GPG/src/metacontacts.cpp60
-rw-r--r--plugins/New_GPG/src/metacontacts.h16
-rwxr-xr-xplugins/New_GPG/src/options.cpp158
-rw-r--r--plugins/New_GPG/src/srmm.cpp16
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp68
-rw-r--r--plugins/New_GPG/src/utilities.h15
11 files changed, 341 insertions, 442 deletions
diff --git a/plugins/New_GPG/src/clist.cpp b/plugins/New_GPG/src/clist.cpp
index 4533a464c2..9a2322023d 100644
--- a/plugins/New_GPG/src/clist.cpp
+++ b/plugins/New_GPG/src/clist.cpp
@@ -17,7 +17,6 @@
#include "commonheaders.h"
void RefreshContactListIcons(void);
-void setClistIcon(HANDLE);
int onExtraImageListRebuilding(WPARAM, LPARAM)
{
@@ -27,6 +26,6 @@ int onExtraImageListRebuilding(WPARAM, LPARAM)
int onExtraImageApplying(WPARAM wParam, LPARAM)
{
- setClistIcon((HANDLE)wParam);
+ setClistIcon((HCONTACT)wParam);
return 0;
}
diff --git a/plugins/New_GPG/src/globals.h b/plugins/New_GPG/src/globals.h
index 9942e16e96..744bcad389 100644
--- a/plugins/New_GPG/src/globals.h
+++ b/plugins/New_GPG/src/globals.h
@@ -19,4 +19,12 @@
extern bool bAppendTags, bPresenceSigning, bStripTags, gpg_valid, gpg_keyexist, tabsrmm_used, bSameAction, bFileTransfers, bDebugLog;
extern TCHAR *inopentag, *inclosetag, *outopentag, *outclosetag;
extern logtofile debuglog;
+
+extern map<int, HCONTACT> user_data;
+extern int item_num;
+
+extern bool _terminate;
+extern wstring new_key;
+extern HCONTACT new_key_hcnt;
+extern boost::mutex new_key_hcnt_mutex;
#endif
diff --git a/plugins/New_GPG/src/icons.cpp b/plugins/New_GPG/src/icons.cpp
index 4c7b100023..65ddc26b0a 100644
--- a/plugins/New_GPG/src/icons.cpp
+++ b/plugins/New_GPG/src/icons.cpp
@@ -44,11 +44,11 @@ HANDLE IconLibHookIconsChanged(MIRANDAHOOK hook)
return HookEvent(ME_SKIN2_ICONSCHANGED, hook);
}
-void setClistIcon(HANDLE hContact)
+void setClistIcon(HCONTACT hContact)
{
bool enabled = isContactSecured(hContact);
extern HANDLE g_hCLIcon;
- HANDLE hMC = hContact;
+ HCONTACT hMC = hContact;
if(metaIsSubcontact(hContact))
hMC = metaGetContact(hContact);
else if(metaIsProtoMetaContacts(hContact))
@@ -59,11 +59,11 @@ void setClistIcon(HANDLE hContact)
ExtraIcon_SetIcon(g_hCLIcon, hMC, szIconId);
}
-void setSrmmIcon(HANDLE h)
+void setSrmmIcon(HCONTACT h)
{
- HANDLE hContact = metaIsProtoMetaContacts(h)?metaGetMostOnline(h):h;
+ HCONTACT hContact = metaIsProtoMetaContacts(h) ? metaGetMostOnline(h) : h;
bool enabled = isContactSecured(hContact);
- HANDLE hMC = NULL;
+ HCONTACT hMC = NULL;
if(metaIsSubcontact(hContact))
hMC = metaGetContact(hContact);
else if(metaIsProtoMetaContacts(hContact))
@@ -91,7 +91,7 @@ void RefreshContactListIcons()
{
CallService(MS_CLUI_LISTBEGINREBUILD,0,0);
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (HCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
setClistIcon(hContact);
CallService(MS_CLUI_LISTENDREBUILD,0,0);
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index 5f1b61f782..2230a26ebd 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -362,7 +362,7 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR
}
delete [] name;
}
- bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange");
+ bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange") != 0;
gpg_valid = isGPGValid();
gpg_keyexist = isGPGKeyExist();
DestroyWindow(hwndDlg);
@@ -370,8 +370,6 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR
case IDC_OTHER:
{
void ShowLoadPublicKeyDialog();
- extern map<int, HANDLE> user_data;
- extern int item_num;
item_num = 0; //black magic here
user_data[1] = 0;
ShowLoadPublicKeyDialog();
@@ -1247,7 +1245,7 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
SetWindowText(hwndCurKey_p, path.c_str());
}
}
- bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange");
+ bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange") != 0;
gpg_valid = true;
db_set_b(NULL, szGPGModuleName, "FirstRun", 0);
DestroyWindow(hwndDlg);
@@ -1283,84 +1281,68 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
static INT_PTR CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- extern HANDLE new_key_hcnt;
- extern boost::mutex new_key_hcnt_mutex;
- static HANDLE hContact = INVALID_HANDLE_VALUE;
+ static HCONTACT hContact = (HCONTACT)INVALID_HANDLE_VALUE;
void ImportKey();
TCHAR *tmp = NULL;
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- hContact = new_key_hcnt;
- //new_key_hcnt_mutex.unlock();
- SetWindowPos(hwndDlg, 0, new_key_rect.left, new_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
- TranslateDialogDefault(hwndDlg);
- TCHAR *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T(""));
- SetDlgItemText(hwndDlg, IDC_MESSAGE, tmp[0]?TranslateT("There is existing key for contact, would you like to replace it with new key?"):TranslateT("New public key was received, do you want to import it?"));
- EnableWindow(GetDlgItem(hwndDlg, IDC_IMPORT_AND_USE), db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0)?0:1);
- SetDlgItemText(hwndDlg, ID_IMPORT, tmp[0]?TranslateT("Replace"):TranslateT("Accept"));
- mir_free(tmp);
- tmp = new TCHAR [256];
- _tcscpy(tmp, TranslateT("Received key from "));
- _tcscat(tmp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, (LPARAM)GCDNF_TCHAR));
- SetDlgItemText(hwndDlg, IDC_KEY_FROM, tmp);
- delete [] tmp;
- return TRUE;
- }
-
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case ID_IMPORT:
- ImportKey();
- DestroyWindow(hwndDlg);
- break;
- case IDC_IMPORT_AND_USE:
- ImportKey();
- db_set_b(hContact, szGPGModuleName, "GPGEncryption", 1);
- void setSrmmIcon(HANDLE hContact);
- void setClistIcon(HANDLE hContact);
- setSrmmIcon(hContact);
- setClistIcon(hContact);
- DestroyWindow(hwndDlg);
- break;
- case IDC_IGNORE_KEY:
- DestroyWindow(hwndDlg);
- break;
- default:
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ hContact = new_key_hcnt;
+ //new_key_hcnt_mutex.unlock();
+ SetWindowPos(hwndDlg, 0, new_key_rect.left, new_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
+ TranslateDialogDefault(hwndDlg);
+ TCHAR *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T(""));
+ SetDlgItemText(hwndDlg, IDC_MESSAGE, tmp[0]?TranslateT("There is existing key for contact, would you like to replace it with new key?"):TranslateT("New public key was received, do you want to import it?"));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_IMPORT_AND_USE), db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0)?0:1);
+ SetDlgItemText(hwndDlg, ID_IMPORT, tmp[0]?TranslateT("Replace"):TranslateT("Accept"));
+ mir_free(tmp);
+ tmp = new TCHAR [256];
+ _tcscpy(tmp, TranslateT("Received key from "));
+ _tcscat(tmp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, (LPARAM)GCDNF_TCHAR));
+ SetDlgItemText(hwndDlg, IDC_KEY_FROM, tmp);
+ delete [] tmp;
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case ID_IMPORT:
+ ImportKey();
+ DestroyWindow(hwndDlg);
+ break;
+ case IDC_IMPORT_AND_USE:
+ ImportKey();
+ db_set_b(hContact, szGPGModuleName, "GPGEncryption", 1);
+ void setSrmmIcon(HCONTACT hContact);
+ void setClistIcon(HCONTACT hContact);
+ setSrmmIcon(hContact);
+ setClistIcon(hContact);
+ DestroyWindow(hwndDlg);
+ break;
+ case IDC_IGNORE_KEY:
+ DestroyWindow(hwndDlg);
+ break;
+ }
break;
- }
-
- break;
- }
-
- case WM_NOTIFY:
- {
-/* switch (((LPNMHDR)lParam)->code)
- {
- default:
- break;
- }*/
- }
- break;
- case WM_CLOSE:
- DestroyWindow(hwndDlg);
- break;
- case WM_DESTROY:
- {
- GetWindowRect(hwndDlg, &new_key_rect);
- db_set_dw(NULL, szGPGModuleName, "NewKeyWindowX", new_key_rect.left);
- db_set_dw(NULL, szGPGModuleName, "NewKeyWindowY", new_key_rect.top);
- }
- hwndNewKey = NULL;
- break;
- }
- return FALSE;
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ {
+ GetWindowRect(hwndDlg, &new_key_rect);
+ db_set_dw(NULL, szGPGModuleName, "NewKeyWindowX", new_key_rect.left);
+ db_set_dw(NULL, szGPGModuleName, "NewKeyWindowY", new_key_rect.top);
+ }
+ hwndNewKey = NULL;
+ break;
+
+ }
+ return FALSE;
}
+
static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
@@ -1914,84 +1896,61 @@ static INT_PTR CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wPar
return FALSE;
}
+
static INT_PTR CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- extern HANDLE new_key_hcnt;
- extern boost::mutex new_key_hcnt_mutex;
- HANDLE hContact = INVALID_HANDLE_VALUE;
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- hContact = new_key_hcnt;
- new_key_hcnt_mutex.unlock();
- SetWindowPos(hwndDlg, 0 , import_key_rect.left, import_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
- TranslateDialogDefault(hwndDlg);
- ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), _T("subkeys.pgp.net"), 0);
- ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), _T("keys.gnupg.net"), 0);
- return TRUE;
- }
-
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_IMPORT:
- {
- string out;
- DWORD code;
- std::vector<wstring> cmd;
- cmd.push_back(L"--keyserver");
- TCHAR *server= new TCHAR [128];
- GetDlgItemText(hwndDlg, IDC_KEYSERVER, server, 128);
- cmd.push_back(server);
- delete [] server;
- cmd.push_back(L"--recv-keys");
-// char *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID_Prescense", "");
-// TCHAR *tmp2 = mir_a2t(tmp);
-// mir_free(tmp);
- cmd.push_back(toUTF16(hcontact_data[hContact].key_in_prescense));
-// mir_free(tmp2);
- gpg_execution_params params(cmd);
- pxResult result;
- params.out = &out;
- params.code = &code;
- params.result = &result;
- gpg_launcher(params);
- MessageBoxA(0, out.c_str(), "GPG output", MB_OK);
- }
- break;
- default:
+ HCONTACT hContact = (HCONTACT)INVALID_HANDLE_VALUE;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ {
+ hContact = new_key_hcnt;
+ new_key_hcnt_mutex.unlock();
+ SetWindowPos(hwndDlg, 0 , import_key_rect.left, import_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
+ TranslateDialogDefault(hwndDlg);
+ ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), _T("subkeys.pgp.net"), 0);
+ ComboBoxAddStringUtf(GetDlgItem(hwndDlg, IDC_KEYSERVER), _T("keys.gnupg.net"), 0);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_IMPORT:
+ {
+ string out;
+ DWORD code;
+ std::vector<wstring> cmd;
+ cmd.push_back(L"--keyserver");
+ TCHAR *server= new TCHAR [128];
+ GetDlgItemText(hwndDlg, IDC_KEYSERVER, server, 128);
+ cmd.push_back(server);
+ delete [] server;
+ cmd.push_back(L"--recv-keys");
+ cmd.push_back(toUTF16(hcontact_data[hContact].key_in_prescense));
+ gpg_execution_params params(cmd);
+ pxResult result;
+ params.out = &out;
+ params.code = &code;
+ params.result = &result;
+ gpg_launcher(params);
+ MessageBoxA(0, out.c_str(), "GPG output", MB_OK);
+ }
+ break;
+ }
break;
- }
- break;
- }
-
- case WM_NOTIFY:
- {
-/* switch (((LPNMHDR)lParam)->code)
- {
- default:
- break;
- } */
- }
- break;
- case WM_CLOSE:
- DestroyWindow(hwndDlg);
- break;
- case WM_DESTROY:
- {
- GetWindowRect(hwndDlg, &import_key_rect);
- db_set_dw(NULL, szGPGModuleName, "ImportKeyWindowX", import_key_rect.left);
- db_set_dw(NULL, szGPGModuleName, "ImportKeyWindowY", import_key_rect.top);
- }
- break;
- }
- return FALSE;
-}
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+ case WM_DESTROY:
+ GetWindowRect(hwndDlg, &import_key_rect);
+ db_set_dw(NULL, szGPGModuleName, "ImportKeyWindowX", import_key_rect.left);
+ db_set_dw(NULL, szGPGModuleName, "ImportKeyWindowY", import_key_rect.top);
+ break;
+ }
+ return FALSE;
+}
extern HINSTANCE hInst;
@@ -2315,10 +2274,7 @@ void InitCheck()
void ImportKey()
{
- extern wstring new_key;
- extern HANDLE new_key_hcnt;
- extern boost::mutex new_key_hcnt_mutex;
- HANDLE hContact = new_key_hcnt;
+ HCONTACT hContact = new_key_hcnt;
new_key_hcnt_mutex.unlock();
bool for_all_sub = false;
if(metaIsProtoMetaContacts(hContact))
@@ -2326,13 +2282,12 @@ void ImportKey()
for_all_sub = true;
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(for_all_sub)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_set_ts(hcnt, szGPGModuleName, "GPGPubKey", new_key.c_str());
}
@@ -2381,13 +2336,12 @@ void ImportKey()
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(for_all_sub)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
{
char *tmp = NULL;
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index cff898dae5..b9deb63655 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -18,14 +18,14 @@
wstring new_key;
-HANDLE new_key_hcnt = NULL;
+HCONTACT new_key_hcnt = NULL;
boost::mutex new_key_hcnt_mutex;
bool _terminate = false;
-int returnNoError(HANDLE hContact);
+int returnNoError(HCONTACT hContact);
std::list<HANDLE> sent_msgs;
-void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp)
+void RecvMsgSvc_func(HCONTACT hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp)
{
DWORD dbflags = DBEF_UTF;
{ //check for gpg related data
@@ -35,9 +35,6 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags,
s2 = str.find(_T("-----END PGP MESSAGE-----"));
if((s2 != wstring::npos) && (s1 != wstring::npos))
{ //this is generic encrypted data block
- void setSrmmIcon(HANDLE);
- void setClistIcon(HANDLE);
- bool isContactHaveKey(HANDLE hContact);
if(!isContactSecured(hContact))
{
if(bDebugLog)
@@ -47,8 +44,6 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags,
if(!isContactHaveKey(hContact))
{
void ShowLoadPublicKeyDialog();
- extern map<int, HANDLE> user_data;
- extern int item_num;
item_num = 0; //black magic here
user_data[1] = hContact;
ShowLoadPublicKeyDialog();
@@ -601,11 +596,11 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
}
if(!strstr(msg, "-----BEGIN PGP MESSAGE-----"))
return CallService(MS_PROTO_CHAINRECV, w, l);
- boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, str, msg, ccs->wParam, pre->timestamp));
+ boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, str, msg, (DWORD)ccs->wParam, pre->timestamp));
return 0;
}
-void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags)
+void SendMsgSvc_func(HCONTACT hContact, char *msg, DWORD flags)
{
bool isansi = false;
DWORD dbflags = 0;
@@ -845,7 +840,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
DBEVENTINFO * dbei = (DBEVENTINFO*)l;
if(dbei->eventType != EVENTTYPE_MESSAGE)
return 0;
- HANDLE hContact = (HANDLE)w;
+ HCONTACT hContact = (HCONTACT)w;
if(dbei->flags & DBEF_SENT)
{
if(isContactSecured(hContact) && strstr((char*)dbei->pBlob, "-----BEGIN PGP MESSAGE-----")) //our service data, can be double added by metacontacts e.t.c.
@@ -872,7 +867,6 @@ int HookSendMsg(WPARAM w, LPARAM l)
{
if(bDebugLog)
debuglog<<std::string(time_str()+": info: checking for autoexchange possibility, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)));
- void send_encrypted_msgs_thread(HANDLE hContact);
LPSTR proto = GetContactProto(hContact);
DWORD uin = db_get_dw(hContact, proto, "UIN", 0);
if(uin)
@@ -994,7 +988,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
debuglog<<std::string(time_str()+": event message: \""+(char*)dbei->pBlob+"\" passed event filter, contact "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" is unsecured");
return 0;
}
- if(!(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((HANDLE)w))
+ if(!(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((HCONTACT)w))
{
char tmp[29];
strncpy(tmp, (char*)dbei->pBlob, 27);
@@ -1013,94 +1007,77 @@ int HookSendMsg(WPARAM w, LPARAM l)
static INT_PTR CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
char *inkeyid = NULL;
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- inkeyid = UniGetContactSettingUtf(new_key_hcnt, szGPGModuleName, "InKeyID", "");
- new_key_hcnt_mutex.unlock();
- TCHAR *tmp = NULL;
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ inkeyid = UniGetContactSettingUtf(new_key_hcnt, szGPGModuleName, "InKeyID", "");
+ new_key_hcnt_mutex.unlock();
+ TCHAR *tmp = NULL;
- SetWindowPos(hwndDlg, 0, key_password_rect.left, key_password_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
- TranslateDialogDefault(hwndDlg);
- string questionstr = "Please enter password for key with ID: ";
- questionstr += inkeyid;
- mir_free(inkeyid);
- SetDlgItemTextA(hwndDlg, IDC_KEYID, questionstr.c_str());
- EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_PASSWORD), 0);
- return TRUE;
- }
-
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDOK:
- {
- TCHAR tmp[64];
- GetDlgItemText(hwndDlg, IDC_KEY_PASSWORD, tmp, 64);
- if(tmp[0])
+ SetWindowPos(hwndDlg, 0, key_password_rect.left, key_password_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
+ TranslateDialogDefault(hwndDlg);
+ string questionstr = "Please enter password for key with ID: ";
+ questionstr += inkeyid;
+ mir_free(inkeyid);
+ SetDlgItemTextA(hwndDlg, IDC_KEYID, questionstr.c_str());
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_PASSWORD), 0);
+ return TRUE;
+ }
+
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDOK:
{
- extern TCHAR *password;
- if(IsDlgButtonChecked(hwndDlg, IDC_SAVE_PASSWORD))
+ TCHAR tmp[64];
+ GetDlgItemText(hwndDlg, IDC_KEY_PASSWORD, tmp, 64);
+ if(tmp[0])
{
- if(inkeyid && inkeyid[0] && !IsDlgButtonChecked(hwndDlg, IDC_DEFAULT_PASSWORD))
+ extern TCHAR *password;
+ if(IsDlgButtonChecked(hwndDlg, IDC_SAVE_PASSWORD))
{
- string dbsetting = "szKey_";
- dbsetting += inkeyid;
- dbsetting += "_Password";
- db_set_ts(NULL, szGPGModuleName, dbsetting.c_str(), tmp);
+ if(inkeyid && inkeyid[0] && !IsDlgButtonChecked(hwndDlg, IDC_DEFAULT_PASSWORD))
+ {
+ string dbsetting = "szKey_";
+ dbsetting += inkeyid;
+ dbsetting += "_Password";
+ db_set_ts(NULL, szGPGModuleName, dbsetting.c_str(), tmp);
+ }
+ else
+ db_set_ts(NULL, szGPGModuleName, "szKeyPassword", tmp);
}
- else
- db_set_ts(NULL, szGPGModuleName, "szKeyPassword", tmp);
+ if(password)
+ mir_free(password);
+ password = (TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(tmp)+1));
+ _tcscpy(password, tmp);
}
- if(password)
- mir_free(password);
- password = (TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(tmp)+1));
- _tcscpy(password, tmp);
+ mir_free(tmp);
+ mir_free(inkeyid);
+ DestroyWindow(hwndDlg);
}
- mir_free(tmp);
+ break;
+
+ case IDCANCEL:
mir_free(inkeyid);
+ _terminate = true;
DestroyWindow(hwndDlg);
- break;
- }
- case IDCANCEL:
- mir_free(inkeyid);
- _terminate = true;
- DestroyWindow(hwndDlg);
- break;
- default:
+ break;
+ }
break;
- }
-
- break;
- }
-
- case WM_NOTIFY:
- {
-/* switch (((LPNMHDR)lParam)->code)
- {
- default:
- EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT_PASSWORD), IsDlgButtonChecked(hwndDlg, IDC_SAVE_PASSWORD)?1:0);
- break;
- }*/
- }
- break;
- case WM_CLOSE:
- mir_free(inkeyid);
- DestroyWindow(hwndDlg);
- break;
- case WM_DESTROY:
- {
- GetWindowRect(hwndDlg, &key_password_rect);
- db_set_dw(NULL, szGPGModuleName, "PasswordWindowX", key_password_rect.left);
- db_set_dw(NULL, szGPGModuleName, "PasswordWindowY", key_password_rect.top);
- }
- break;
- }
- return FALSE;
+ case WM_CLOSE:
+ mir_free(inkeyid);
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ GetWindowRect(hwndDlg, &key_password_rect);
+ db_set_dw(NULL, szGPGModuleName, "PasswordWindowX", key_password_rect.left);
+ db_set_dw(NULL, szGPGModuleName, "PasswordWindowY", key_password_rect.top);
+ break;
+ }
+ return FALSE;
}
void ShowLoadKeyPasswordWindow()
diff --git a/plugins/New_GPG/src/metacontacts.cpp b/plugins/New_GPG/src/metacontacts.cpp
index b466cc65f0..dcf7667f4f 100644
--- a/plugins/New_GPG/src/metacontacts.cpp
+++ b/plugins/New_GPG/src/metacontacts.cpp
@@ -18,69 +18,65 @@
extern bool bMetaContacts;
-bool metaIsProtoMetaContacts(HANDLE hContact)
+bool metaIsProtoMetaContacts(HCONTACT hContact)
{
- if(bMetaContacts) {
- LPSTR proto = GetContactProto(hContact);
- if( proto && strcmp(proto,"MetaContacts")==0 ) {
- return true;
- }
- }
- return false;
+ if(bMetaContacts) {
+ LPSTR proto = GetContactProto(hContact);
+ if( proto && strcmp(proto,"MetaContacts")==0 ) {
+ return true;
+ }
+ }
+ return false;
}
-bool metaIsDefaultSubContact(HANDLE hContact)
+bool metaIsDefaultSubContact(HCONTACT hContact)
{
- if(bMetaContacts)
+ if(bMetaContacts)
return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0),0)==hContact;
- return false;
+ return false;
}
-HANDLE metaGetContact(HANDLE hContact)
+HCONTACT metaGetContact(HCONTACT hContact)
{
- if(bMetaContacts)
+ if(bMetaContacts)
if(metaIsSubcontact(hContact))
- return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0);
- return NULL;
+ return (HCONTACT)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0);
+ return NULL;
}
-bool metaIsSubcontact(HANDLE hContact)
+bool metaIsSubcontact(HCONTACT hContact)
{
if(bMetaContacts)
return CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0) != 0;
- return false;
+ return false;
}
-HANDLE metaGetMostOnline(HANDLE hContact)
+HCONTACT metaGetMostOnline(HCONTACT hContact)
{
-
- if(bMetaContacts)
+ if(bMetaContacts)
if(metaIsProtoMetaContacts(hContact))
- return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0);
- return NULL;
+ return (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0);
+ return NULL;
}
-HANDLE metaGetDefault(HANDLE hContact)
+HCONTACT metaGetDefault(HCONTACT hContact)
{
-
- if(bMetaContacts)
+ if(bMetaContacts)
if(metaIsProtoMetaContacts(hContact))
- return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)hContact,0);
- return NULL;
+ return (HCONTACT)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)hContact,0);
+ return NULL;
}
-DWORD metaGetContactsNum(HANDLE hContact)
+DWORD metaGetContactsNum(HCONTACT hContact)
{
if(bMetaContacts)
return CallService(MS_MC_GETNUMCONTACTS, (WPARAM)hContact, 0);
return 0;
}
-HANDLE metaGetSubcontact(HANDLE hContact, int num)
+HCONTACT metaGetSubcontact(HCONTACT hContact, int num)
{
if(bMetaContacts)
- return (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, (LPARAM)num);
+ return (HCONTACT)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hContact, (LPARAM)num);
return 0;
}
-
-
diff --git a/plugins/New_GPG/src/metacontacts.h b/plugins/New_GPG/src/metacontacts.h
index 8b8873edcc..9dba2943c0 100644
--- a/plugins/New_GPG/src/metacontacts.h
+++ b/plugins/New_GPG/src/metacontacts.h
@@ -14,11 +14,11 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-bool metaIsProtoMetaContacts(HANDLE hContact);
-bool metaIsDefaultSubContact(HANDLE hContact) ;
-HANDLE metaGetContact(HANDLE hContact);
-bool metaIsSubcontact(HANDLE hContact);
-HANDLE metaGetMostOnline(HANDLE hContact);
-HANDLE metaGetDefault(HANDLE hContact);
-DWORD metaGetContactsNum(HANDLE hContact);
-HANDLE metaGetSubcontact(HANDLE hContact, int num); \ No newline at end of file
+bool metaIsProtoMetaContacts(HCONTACT hContact);
+bool metaIsDefaultSubContact(HCONTACT hContact) ;
+HCONTACT metaGetContact(HCONTACT hContact);
+bool metaIsSubcontact(HCONTACT hContact);
+HCONTACT metaGetMostOnline(HCONTACT hContact);
+HCONTACT metaGetDefault(HCONTACT hContact);
+DWORD metaGetContactsNum(HCONTACT hContact);
+HCONTACT metaGetSubcontact(HCONTACT hContact, int num);
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index 8418e49bf9..75279c7e96 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -66,7 +66,7 @@ int GpgOptInit(WPARAM wParam,LPARAM lParam)
return 0;
}
-map<int, HANDLE> user_data;
+map<int, HCONTACT> user_data;
int item_num = 0;
HWND hwndList_p = NULL;
@@ -120,8 +120,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
ListView_InsertColumn(hwndList, 4, &col);
ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
int i = 1, iRow = 0;
- bool isContactHaveKey(HANDLE);
- for(HANDLE hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) {
+ for(HCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) {
if(isContactHaveKey(hContact)) {
TCHAR *name = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
item.mask = LVIF_TEXT;
@@ -193,16 +192,16 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
switch (LOWORD(wParam))
{
case IDC_DELETE_KEY_BUTTON:
- void setClistIcon(HANDLE hContact);
- void setSrmmIcon(HANDLE hContact);
+ void setClistIcon(HCONTACT hContact);
+ void setSrmmIcon(HCONTACT hContact);
{ //gpg execute block
TCHAR tmp2[MAX_PATH] = {0};
TCHAR *ptmp;
char *tmp;
bool keep = false;
bool ismetacontact = false;
- HANDLE meta = NULL;
- HANDLE hContact = user_data[item_num+1];
+ HCONTACT meta = NULL;
+ HCONTACT hContact = user_data[item_num+1];
if(metaIsProtoMetaContacts(hContact))
{
meta = hContact;
@@ -215,7 +214,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
ismetacontact = true;
}
tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", "");
- for(HANDLE hcnttmp = db_find_first(); hcnttmp != NULL; hcnttmp = db_find_next(hcnttmp)) {
+ for(HCONTACT hcnttmp = db_find_first(); hcnttmp != NULL; hcnttmp = db_find_next(hcnttmp)) {
if(hcnttmp != hContact) {
char *tmp2 = UniGetContactSettingUtf(hcnttmp, szGPGModuleName, "KeyID", "");
if(!strcmp(tmp, tmp2)) {
@@ -263,7 +262,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
if(MessageBox(0, TranslateT("Do you want to remove key from entire metacontact (all subcontacts)?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
{
- HANDLE hcnt = NULL;
+ HCONTACT hcnt = NULL;
int count = metaGetContactsNum(meta);
for(int i = 0; i < count; i++)
{
@@ -408,8 +407,8 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
else if(hdr->hdr.code == LVN_ITEMCHANGED)
{
- void setClistIcon(HANDLE hContact);
- void setSrmmIcon(HANDLE hContact);
+ void setClistIcon(HCONTACT hContact);
+ void setSrmmIcon(HCONTACT hContact);
if(ListView_GetCheckState(hwndList, item_num))
db_set_b(user_data[item_num+1], szGPGModuleName, "GPGEncryption", 1);
else
@@ -424,18 +423,18 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
case PSN_APPLY:
{
extern bool bJabberAPI, bFileTransfers;
- bDebugLog = CheckStateStoreDB(hwndDlg, IDC_DEBUG_LOG, "bDebugLog");
+ bDebugLog = CheckStateStoreDB(hwndDlg, IDC_DEBUG_LOG, "bDebugLog") != 0;
if(bDebugLog)
debuglog.init();
- bJabberAPI = CheckStateStoreDB(hwndDlg, IDC_JABBER_API, "bJabberAPI");
- bool old_bFileTransfers = db_get_b(NULL, szGPGModuleName, "bFileTransfers", 0);
- bFileTransfers = CheckStateStoreDB(hwndDlg, IDC_FILE_TRANSFERS, "bFileTransfers");
+ bJabberAPI = CheckStateStoreDB(hwndDlg, IDC_JABBER_API, "bJabberAPI") != 0;
+ bool old_bFileTransfers = db_get_b(NULL, szGPGModuleName, "bFileTransfers", 0) != 0;
+ bFileTransfers = CheckStateStoreDB(hwndDlg, IDC_FILE_TRANSFERS, "bFileTransfers") != 0;
if(bFileTransfers != old_bFileTransfers)
{
db_set_b(NULL, szGPGModuleName, "bSameAction", 0);
bSameAction = false;
}
- bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange");
+ bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange") != 0;
{
TCHAR tmp[512];
GetDlgItemText(hwndDlg, IDC_LOG_FILE_EDIT, tmp, 512);
@@ -630,8 +629,8 @@ static INT_PTR CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
case PSN_APPLY:
{
- bAppendTags = CheckStateStoreDB(hwndDlg, IDC_APPEND_TAGS, "bAppendTags");
- bStripTags = CheckStateStoreDB(hwndDlg, IDC_STRIP_TAGS, "bStripTags");
+ bAppendTags = CheckStateStoreDB(hwndDlg, IDC_APPEND_TAGS, "bAppendTags") != 0;
+ bStripTags = CheckStateStoreDB(hwndDlg, IDC_STRIP_TAGS, "bStripTags") != 0;
{
TCHAR tmp[128];
GetDlgItemText(hwndDlg, IDC_IN_OPEN_TAG, tmp, 128);
@@ -666,58 +665,43 @@ static INT_PTR CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
static INT_PTR CALLBACK DlgProcGpgAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
- {
+ switch (msg) {
+ case WM_INITDIALOG:
extern bool bJabberAPI;
TranslateDialogDefault(hwndDlg);
CheckStateLoadDB(hwndDlg, IDC_PRESCENSE_SUBSCRIPTION, "bPresenceSigning", 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_PRESCENSE_SUBSCRIPTION), bJabberAPI);
- return TRUE;
- }
-
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_EXPORT:
- {
- INT_PTR ExportGpGKeys(WPARAM w, LPARAM l);
- ExportGpGKeys(NULL, NULL);
- }
- break;
- case IDC_IMPORT:
- {
- INT_PTR ImportGpGKeys(WPARAM w, LPARAM l);
- ImportGpGKeys(NULL, NULL);
- }
- break;
- default:
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_EXPORT:
+ {
+ INT_PTR ExportGpGKeys(WPARAM w, LPARAM l);
+ ExportGpGKeys(NULL, NULL);
+ }
+ break;
+ case IDC_IMPORT:
+ {
+ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l);
+ ImportGpGKeys(NULL, NULL);
+ }
+ break;
+ }
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
-
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->code)
- {
-
- case PSN_APPLY:
- {
- bPresenceSigning = CheckStateStoreDB(hwndDlg, IDC_PRESCENSE_SUBSCRIPTION, "bPresenceSigning");
- return TRUE;
- }
- }
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ bPresenceSigning = CheckStateStoreDB(hwndDlg, IDC_PRESCENSE_SUBSCRIPTION, "bPresenceSigning") != 0;
+ return TRUE;
+ }
+ break;
}
- break;
- }
- return FALSE;
+ return FALSE;
}
HWND hPubKeyEdit = NULL;
@@ -735,7 +719,7 @@ static LRESULT CALLBACK editctrl_ctrl_a(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR
static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
- static HANDLE hContact;
+ static HCONTACT hContact;
TCHAR *tmp = NULL;
wstring key_buf;
wstring::size_type ws1 = 0, ws2 = 0;
@@ -745,7 +729,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
hContact = user_data[1];
SetWindowPos(hwndDlg, 0, load_key_rect.left, load_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PUBLIC_KEY_EDIT), editctrl_ctrl_a);
- HANDLE hcnt = hContact;
+ HCONTACT hcnt = hContact;
if(metaIsProtoMetaContacts(hcnt))
hcnt = metaGetMostOnline(hcnt);
TranslateDialogDefault(hwndDlg);
@@ -894,14 +878,13 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(MessageBox(0, TranslateT("Do you want to load key for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
{
allsubcontacts = true;
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_set_ts(hcnt, szGPGModuleName, "GPGPubKey", key_buf.substr(ws1,ws2-ws1).c_str());
}
@@ -921,7 +904,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
string output;
DWORD exitcode;
{
- HANDLE hcnt = hContact;
+ HCONTACT hcnt = hContact;
if(metaIsProtoMetaContacts(hcnt))
hcnt = metaGetMostOnline(hcnt);
ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
@@ -960,22 +943,19 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(allsubcontacts)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_unset(hcnt, szGPGModuleName, "bAlwatsTrust");
}
}
- else
- db_unset(metaGetMostOnline(hContact), szGPGModuleName, "bAlwatsTrust");
+ else db_unset(metaGetMostOnline(hContact), szGPGModuleName, "bAlwatsTrust");
}
- else
- db_unset(hContact, szGPGModuleName, "bAlwatsTrust");
+ else db_unset(hContact, szGPGModuleName, "bAlwatsTrust");
}
{
TCHAR *tmp;
@@ -994,13 +974,12 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(allsubcontacts)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyID", tmp2);
}
@@ -1044,13 +1023,12 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(allsubcontacts)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str());
}
@@ -1082,13 +1060,12 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(allsubcontacts)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str());
}
@@ -1109,22 +1086,19 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(allsubcontacts)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str());
}
}
- else
- db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str());
+ else db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str());
}
- else
- db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str());
+ else db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str());
}
mir_free(tmp2);
tmp = mir_wstrdup(toUTF16(output.substr(s,s2-s)).c_str());
@@ -1141,22 +1115,19 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(allsubcontacts)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_set_s(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
}
}
- else
- db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
+ else db_set_s(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
}
- else
- db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
+ else db_set_s(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
}
mir_free(tmp2);
tmp = mir_wstrdup(toUTF16(output.substr(s2,s-s2)).c_str());
@@ -1217,13 +1188,12 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
{
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(allsubcontacts)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
{
if(!isContactSecured(hcnt))
@@ -1299,8 +1269,6 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam
}
break;
case IDC_IMPORT:
- extern HANDLE new_key_hcnt;
- extern boost::mutex new_key_hcnt_mutex;
new_key_hcnt_mutex.lock();
new_key_hcnt = hContact;
void ShowImportKeyDialog();
diff --git a/plugins/New_GPG/src/srmm.cpp b/plugins/New_GPG/src/srmm.cpp
index 85e149214e..542312213d 100644
--- a/plugins/New_GPG/src/srmm.cpp
+++ b/plugins/New_GPG/src/srmm.cpp
@@ -18,8 +18,8 @@
#include "commonheaders.h"
-void ShowStatusIcon(HANDLE hContact);
-void setSrmmIcon(HANDLE hContact);
+void ShowStatusIcon(HCONTACT hContact);
+void setSrmmIcon(HCONTACT hContact);
int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) {
@@ -32,9 +32,10 @@ int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) {
}
-int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) {
- HANDLE hContact = (HANDLE)wParam;
- HANDLE hMeta = NULL;
+int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
+{
+ HCONTACT hContact = (HCONTACT)wParam;
+ HCONTACT hMeta = NULL;
if(metaIsProtoMetaContacts(hContact))
{
hMeta = hContact;
@@ -46,9 +47,6 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) {
if(strcmp(sicd->szModule, szGPGModuleName))
return 0; // not our event
- void setSrmmIcon(HANDLE);
- void setClistIcon(HANDLE);
- bool isContactHaveKey(HANDLE hContact);
BYTE enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
if(enc)
{
@@ -62,8 +60,6 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) {
if(!isContactHaveKey(hContact))
{
void ShowLoadPublicKeyDialog();
- extern map<int, HANDLE> user_data;
- extern int item_num;
item_num = 0; //black magic here
user_data[1] = hContact;
ShowLoadPublicKeyDialog();
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index bd2e4ec45e..d1122dca94 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -18,7 +18,7 @@
#include "commonheaders.h"
-TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, TCHAR* szDef)
+TCHAR* __stdcall UniGetContactSettingUtf(HCONTACT hContact, const char *szModule,const char* szSetting, TCHAR* szDef)
{
DBVARIANT dbv = {DBVT_DELETED};
TCHAR* szRes = NULL;
@@ -33,7 +33,7 @@ TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,c
return szRes;
}
-char* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, char* szDef)
+char* __stdcall UniGetContactSettingUtf(HCONTACT hContact, const char *szModule,const char* szSetting, char* szDef)
{
DBVARIANT dbv = {DBVT_DELETED};
char* szRes = NULL;
@@ -138,15 +138,14 @@ void GetFolderPath(TCHAR *WindowTittle, char *szSetting)
INT_PTR LoadKey(WPARAM w, LPARAM l)
{
void ShowLoadPublicKeyDialog();
- extern map<int, HANDLE> user_data;
- user_data[1] = (HANDLE)w;
+ user_data[1] = (HCONTACT)w;
ShowLoadPublicKeyDialog();
return 0;
}
INT_PTR SendKey(WPARAM w, LPARAM l)
{
- HANDLE hContact = (HANDLE)w;
+ HCONTACT hContact = (HCONTACT)w;
if(metaIsProtoMetaContacts(hContact))
hContact = metaGetMostOnline(hContact);
char *szMessage;
@@ -202,7 +201,7 @@ extern HGENMENU hToggleEncryption, hSendKey;
INT_PTR ToggleEncryption(WPARAM w, LPARAM l)
{
- HANDLE hContact = (HANDLE)w;
+ HCONTACT hContact = (HCONTACT)w;
BYTE enc = 0;
if(metaIsProtoMetaContacts(hContact))
enc = db_get_b(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0);
@@ -210,13 +209,12 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM l)
enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
if(metaIsProtoMetaContacts(hContact))
{
- HANDLE hcnt = NULL;
if(MessageBox(0, TranslateT("Do you want to toggle encryption for all subcontacts?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES)
{
int count = metaGetContactsNum(hContact);
for(int i = 0; i < count; i++)
{
- hcnt = metaGetSubcontact(hContact, i);
+ HCONTACT hcnt = metaGetSubcontact(hContact, i);
if(hcnt)
db_set_b(hcnt, szGPGModuleName, "GPGEncryption", enc?0:1);
}
@@ -225,8 +223,8 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM l)
}
else
db_set_b(hContact, szGPGModuleName, "GPGEncryption", enc?0:1);
- void setSrmmIcon(HANDLE hContact);
- void setClistIcon(HANDLE hContact);
+ void setSrmmIcon(HCONTACT hContact);
+ void setClistIcon(HCONTACT hContact);
setSrmmIcon(hContact);
setClistIcon(hContact);
enc = enc?0:1;
@@ -239,7 +237,7 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM l)
int OnPreBuildContactMenu(WPARAM w, LPARAM l)
{
- HANDLE hContact = (HANDLE)w;
+ HCONTACT hContact = (HCONTACT)w;
if(metaIsProtoMetaContacts(hContact))
hContact = metaGetMostOnline(hContact);
@@ -396,9 +394,6 @@ int onProtoAck(WPARAM w, LPARAM l)
return 0;
while(out.find("public key decryption failed: bad passphrase") != string::npos)
{
- extern bool _terminate;
- extern HANDLE new_key_hcnt;
- extern boost::mutex new_key_hcnt_mutex;
if(bDebugLog)
debuglog<<std::string(time_str()+": info: failed to decrypt messaage from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR))+" password needed, trying to get one");
if(_terminate)
@@ -478,12 +473,12 @@ int onProtoAck(WPARAM w, LPARAM l)
return 0;
}
-std::wstring encrypt_file(HANDLE hContact, TCHAR *filename)
+std::wstring encrypt_file(HCONTACT hContact, TCHAR *filename)
{
string out;
DWORD code;
pxResult result;
- HANDLE hcnt = metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact;
+ HCONTACT hcnt = metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact;
std::vector<wstring> cmd;
cmd.push_back(L"--batch");
cmd.push_back(L"--tes");
@@ -643,7 +638,7 @@ INT_PTR onSendFile(WPARAM w, LPARAM l)
}
-void HistoryLog(HANDLE hContact, db_event evt)
+void HistoryLog(HCONTACT hContact, db_event evt)
{
DBEVENTINFO Event = { sizeof(Event) };
Event.szModule = szGPGModuleName;
@@ -724,7 +719,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU
LPCTSTR attr = xi.getAttrValue(local_node, _T("to"));
if(attr)
{
- HANDLE hContact = ji->ContactFromJID(attr);
+ HCONTACT hContact = ji->ContactFromJID(attr);
if(hContact)
if(!isContactSecured(hContact))
return FALSE;
@@ -1014,7 +1009,7 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi
string::size_type p2 = out.find("\n", p1);
if(p1 != string::npos && p2 != string::npos)
{
- HANDLE hContact = NULL;
+ HCONTACT hContact = NULL;
{
extern list <JabberAccount*> Accounts;
list <JabberAccount*>::iterator p = Accounts.begin();
@@ -1075,7 +1070,7 @@ void AddHandlers()
}
}
-bool isContactSecured(HANDLE hContact)
+bool isContactSecured(HCONTACT hContact)
{
BYTE gpg_enc = db_get_b(hContact, szGPGModuleName, "GPGEncryption", 0);
if(!gpg_enc)
@@ -1101,7 +1096,7 @@ bool isContactSecured(HANDLE hContact)
return true;
}
-bool isContactHaveKey(HANDLE hContact)
+bool isContactHaveKey(HCONTACT hContact)
{
TCHAR *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T(""));
if(_tcslen(key) > 0)
@@ -1220,7 +1215,7 @@ const bool StriStr(const char *str, const char *substr)
return i;
}
-bool IsOnline(HANDLE hContact)
+bool IsOnline(HCONTACT hContact)
{
if(db_get_b(hContact, szGPGModuleName, "Status", 0) == ID_STATUS_OFFLINE)
return false;
@@ -1231,34 +1226,34 @@ bool IsOnline(HANDLE hContact)
#include <process.h>
struct TFakeAckParams {
- inline TFakeAckParams( HANDLE p1, HANDLE p2, LONG p3, LPCSTR p4 ) :
+ inline TFakeAckParams( HANDLE p1, HCONTACT p2, LONG p3, LPCSTR p4 ) :
hEvent( p1 ),
hContact( p2 ),
id( p3 ),
msg( p4 )
{}
- HANDLE hEvent;
- HANDLE hContact;
- LONG id;
- LPCSTR msg;
+ HANDLE hEvent;
+ HCONTACT hContact;
+ LONG id;
+ LPCSTR msg;
};
-__forceinline int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
+__forceinline int SendBroadcast(HCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
return ProtoBroadcastAck( GetContactProto(hContact), hContact, type, result, hProcess, lParam);
}
-unsigned __stdcall sttFakeAck( LPVOID param ) {
-
+unsigned __stdcall sttFakeAck( LPVOID param )
+{
TFakeAckParams* tParam = ( TFakeAckParams* )param;
WaitForSingleObject( tParam->hEvent, INFINITE );
Sleep( 100 );
if ( tParam->msg == NULL )
- SendBroadcast( tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, ( HANDLE )tParam->id, 0 );
+ SendBroadcast(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)tParam->id, 0 );
else
- SendBroadcast( tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, ( HANDLE )tParam->id, LPARAM( tParam->msg ));
+ SendBroadcast(tParam->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)tParam->id, LPARAM(tParam->msg));
CloseHandle( tParam->hEvent );
delete tParam;
@@ -1267,7 +1262,7 @@ unsigned __stdcall sttFakeAck( LPVOID param ) {
}
-int returnNoError(HANDLE hContact) {
+int returnNoError(HCONTACT hContact) {
HANDLE hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
unsigned int tID;
CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttFakeAck, new TFakeAckParams(hEvent,hContact,777,0), 0, &tID) );
@@ -1323,8 +1318,9 @@ string get_random(int length)
return data;
}
-void send_encrypted_msgs_thread(HANDLE hContact)
+void send_encrypted_msgs_thread(void *param)
{
+ HCONTACT hContact = (HCONTACT)param;
while(true)
{
//char *key = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", "");
@@ -1398,7 +1394,7 @@ void ExportGpGKeysFunc(int type)
if(!file.is_open())
return; //TODO: handle error
if(!type || type == 2) {
- for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for(HCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *k = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", "");
std::string key;
if(!k[0])
@@ -1685,7 +1681,7 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l)
if(acc.length())
{
const char * uid = (const char*)CallProtoService(acc.c_str(), PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0);
- for(HANDLE hContact = db_find_first(acc.c_str()); hContact; hContact = db_find_next(hContact, acc.c_str())) {
+ for(HCONTACT hContact = db_find_first(acc.c_str()); hContact; hContact = db_find_next(hContact, acc.c_str())) {
DBVARIANT dbv = {0};
db_get(hContact, acc.c_str(), uid, &dbv);
std::string id;
diff --git a/plugins/New_GPG/src/utilities.h b/plugins/New_GPG/src/utilities.h
index ef3fbced23..3b884a3846 100644
--- a/plugins/New_GPG/src/utilities.h
+++ b/plugins/New_GPG/src/utilities.h
@@ -16,17 +16,22 @@
#ifndef UTILITIES_H
#define UTILITIES_H
-TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, TCHAR* szDef);
-char* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, char* szDef);
+TCHAR* __stdcall UniGetContactSettingUtf(HCONTACT hContact, const char *szModule,const char* szSetting, TCHAR* szDef);
+char* __stdcall UniGetContactSettingUtf(HCONTACT hContact, const char *szModule,const char* szSetting, char* szDef);
void GetFilePath(TCHAR *WindowTittle, char *szSetting, TCHAR *szExt, TCHAR *szExtDesc);
TCHAR *GetFilePath(TCHAR *WindowTittle, TCHAR *szExt, TCHAR *szExtDesc, bool save_file = false);
void GetFolderPath(TCHAR *WindowTittle, char *szSetting);
void storeOutput(HANDLE ahandle, string *output);
+void setSrmmIcon(HCONTACT);
+void setClistIcon(HCONTACT);
+
+void send_encrypted_msgs_thread(void*);
+
int ComboBoxAddStringUtf(HWND hCombo, const TCHAR *szString, DWORD data);
-bool isContactSecured(HANDLE hContact);
-bool isContactHaveKey(HANDLE hContact);
+bool isContactSecured(HCONTACT hContact);
+bool isContactHaveKey(HCONTACT hContact);
bool isTabsrmmUsed();
bool isGPGKeyExist();
bool isGPGValid();
@@ -99,7 +104,7 @@ public:
cbSize = 0;
}
};
-void HistoryLog(HANDLE, db_event);
+void HistoryLog(HCONTACT, db_event);
void fix_line_term(std::string &s);
void fix_line_term(std::wstring &s);
void strip_line_term(std::wstring &s);