From 94d1e755f4034c94a324904b81e132144ef00d6f Mon Sep 17 00:00:00 2001 From: Alexander Gluzsky Date: Thu, 13 Sep 2012 14:17:18 +0000 Subject: fix double messages in metacontacts (untested) better handling for uncommon keys (untested) improoved translations support (untested, should work) git-svn-id: http://svn.miranda-ng.org/main/trunk@1570 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/New_GPG/src/messages.cpp | 15 ++- plugins/New_GPG/src/options.cpp | 242 ++++++++++++++++++++------------------ plugins/New_GPG/src/utilities.cpp | 2 - 3 files changed, 133 insertions(+), 126 deletions(-) (limited to 'plugins/New_GPG') diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 07aad1f722..4fe4268ea6 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -41,7 +41,7 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, if(!isContactSecured(hContact)) { debuglog< output.find("<", s)) - s2 = output.find("<", s); - if(s2 != string::npos) - { - tmp2 = (char*)mir_alloc(output.substr(s,s2-s-1).length()+1); - strcpy(tmp2, output.substr(s,s2-s-1).c_str()); - mir_utf8decode(tmp2, 0); - if(hContact) - { - if(metaIsProtoMetaContacts(hContact)) - { - HANDLE hcnt = NULL; - if(allsubcontacts) - { - int count = metaGetContactsNum(hContact); - for(int i = 0; i < count; i++) - { - hcnt = metaGetSubcontact(hContact, i); - if(hcnt) - DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str()); - } - } - else - DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str()); + { + if((s2 = output.find("<", s)) == string::npos) + { + s2 = output.find("”", s); + uncommon = true; } - else - DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str()); } - mir_free(tmp2); - tmp = mir_wstrdup(toUTF16(output.substr(s,s2-s-1)).c_str()); - if(hContact && hwndList_p) - ListView_SetItemText(hwndList_p, item_num, 2, tmp); - mir_free(tmp); - if((s = output.find(")", s2)) == string::npos) - s = output.find(">", s2); - else if(s > output.find(">", s2)) - s = output.find(">", s2); - s2++; - if(output[s] == ')') + else if(s2 > output.find("<", s)) + s2 = output.find("<", s); + if(s2 != string::npos && s != string::npos) { - tmp2 = new char [output.substr(s2,s-s2).length()+1]; - strcpy(tmp2, output.substr(s2,s-s2).c_str()); + tmp2 = (char*)mir_alloc(sizeof(char)*(output.substr(s,s2-s-(uncommon?1:0)).length()+1)); + strcpy(tmp2, output.substr(s,s2-s-(uncommon?1:0)).c_str()); mir_utf8decode(tmp2, 0); if(hContact) { @@ -1122,80 +1093,119 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam { hcnt = metaGetSubcontact(hContact, i); if(hcnt) - DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str()); + DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str()); } } else - DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str()); + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str()); } else - DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str()); + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str()); } mir_free(tmp2); - s+=3; - s2 = output.find(">", s); - tmp2 = new char [output.substr(s,s2-s).length()+1]; - strcpy(tmp2, output.substr(s,s2-s).c_str()); - mir_utf8decode(tmp2, 0); - if(hContact) + tmp = mir_wstrdup(toUTF16(output.substr(s,s2-s-1)).c_str()); + if(hContact && hwndList_p) + ListView_SetItemText(hwndList_p, item_num, 2, tmp); + mir_free(tmp); + if((s = output.find(")", s2)) == string::npos) + s = output.find(">", s2); + else if(s > output.find(">", s2)) + s = output.find(">", s2); + s2++; + if(s != string::npos && s2 != string::npos) { - if(metaIsProtoMetaContacts(hContact)) + if(output[s] == ')') { - HANDLE hcnt = NULL; - if(allsubcontacts) + tmp2 = (char*)mir_alloc((output.substr(s2,s-s2).length()+1)*sizeof(char)); + strcpy(tmp2, output.substr(s2,s-s2).c_str()); + mir_utf8decode(tmp2, 0); + if(hContact) { - int count = metaGetContactsNum(hContact); - for(int i = 0; i < count; i++) + if(metaIsProtoMetaContacts(hContact)) { - hcnt = metaGetSubcontact(hContact, i); - if(hcnt) - DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str()); + HANDLE hcnt = NULL; + if(allsubcontacts) + { + int count = metaGetContactsNum(hContact); + for(int i = 0; i < count; i++) + { + hcnt = metaGetSubcontact(hContact, i); + if(hcnt) + DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str()); + } + } + else + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str()); } + else + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str()); } - else - DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str()); + mir_free(tmp2); + s+=3; + s2 = output.find(">", s); + tmp2 = new char [output.substr(s,s2-s).length()+1]; + strcpy(tmp2, output.substr(s,s2-s).c_str()); + mir_utf8decode(tmp2, 0); + if(hContact) + { + if(metaIsProtoMetaContacts(hContact)) + { + HANDLE hcnt = NULL; + if(allsubcontacts) + { + int count = metaGetContactsNum(hContact); + for(int i = 0; i < count; i++) + { + hcnt = metaGetSubcontact(hContact, i); + if(hcnt) + DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str()); + } + } + else + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str()); + } + else + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str()); + } + mir_free(tmp2); + tmp = mir_wstrdup(toUTF16(output.substr(s,s2-s)).c_str()); + if(hContact && hwndList_p) + ListView_SetItemText(hwndList_p, item_num, 3, tmp); + mir_free(tmp); } else - DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str()); - } - mir_free(tmp2); - tmp = mir_wstrdup(toUTF16(output.substr(s,s2-s)).c_str()); - if(hContact && hwndList_p) - ListView_SetItemText(hwndList_p, item_num, 3, tmp); - mir_free(tmp); - } - else - { - tmp2 = (char*)mir_alloc(output.substr(s2,s-s2).length()+1); - strcpy(tmp2, output.substr(s2,s-s2).c_str()); - mir_utf8decode(tmp2, 0); - if(hContact) - { - if(metaIsProtoMetaContacts(hContact)) { - HANDLE hcnt = NULL; - if(allsubcontacts) + tmp2 = (char*)mir_alloc(output.substr(s2,s-s2).length()+1); + strcpy(tmp2, output.substr(s2,s-s2).c_str()); + mir_utf8decode(tmp2, 0); + if(hContact) { - int count = metaGetContactsNum(hContact); - for(int i = 0; i < count; i++) + if(metaIsProtoMetaContacts(hContact)) { - hcnt = metaGetSubcontact(hContact, i); - if(hcnt) - DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); + HANDLE hcnt = NULL; + if(allsubcontacts) + { + int count = metaGetContactsNum(hContact); + for(int i = 0; i < count; i++) + { + hcnt = metaGetSubcontact(hContact, i); + if(hcnt) + DBWriteContactSettingString(hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); + } + } + else + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); } + else + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); } - else - DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); + mir_free(tmp2); + tmp = mir_wstrdup(toUTF16(output.substr(s2,s-s2)).c_str()); + if(hContact && hwndList_p) + ListView_SetItemText(hwndList_p, item_num, 3, tmp); + mir_free(tmp); } - else - DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); } - mir_free(tmp2); - tmp = mir_wstrdup(toUTF16(output.substr(s2,s-s2)).c_str()); - if(hContact && hwndList_p) - ListView_SetItemText(hwndList_p, item_num, 3, tmp); - mir_free(tmp); - } } if(hContact && hwndList_p) { @@ -1288,7 +1298,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam break; case ID_LOAD_FROM_FILE: { - tmp = GetFilePath(_T("Set file containing GPG public key"), _T("*"), _T("GPG public key file")); + tmp = GetFilePath(TranslateT("Set file containing GPG public key"), _T("*"), TranslateT("GPG public key file")); if(!tmp) { break; @@ -1297,7 +1307,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam delete [] tmp; if(!f.is_open()) { - MessageBox(0, _T("Failed to open file"), _T("Error"), MB_OK); + MessageBox(0, TranslateT("Failed to open file"), TranslateT("Error"), MB_OK); break; } if(f.is_open()) @@ -1326,7 +1336,7 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam } if(ws2 == wstring::npos || ws1 == wstring::npos) { - MessageBox(0, _T("Where is no public or private key."), _T("Info"), MB_OK); + MessageBox(0, TranslateT("Where is no public or private key."), TranslateT("Info"), MB_OK); break; } ws2 += _tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----")); diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 4a51e364c5..8175917d05 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -134,8 +134,6 @@ INT_PTR LoadKey(WPARAM w, LPARAM l) { void ShowLoadPublicKeyDialog(); extern map user_data; - extern int item_num; - item_num = 0; //black magic here user_data[1] = (HANDLE)w; ShowLoadPublicKeyDialog(); return 0; -- cgit v1.2.3