diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
@@ -464,6 +464,9 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP static BOOL CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { extern HANDLE new_key_hcnt; + extern HANDLE new_key_hcnt_mutex; + HANDLE hContact = new_key_hcnt; + CloseHandle(new_key_hcnt_mutex); void ImportKey(); TCHAR *tmp = NULL; switch (msg) @@ -471,14 +474,14 @@ static BOOL CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); - TCHAR *tmp = UniGetContactSettingUtf(new_key_hcnt, szGPGModuleName, "GPGPubKey", _T("")); + TCHAR *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T("")); SetDlgItemText(hwndDlg, IDC_MESSAGE, (_tcslen(tmp) > 0)?_T("There is existing key for contact, would you like to replace with new key ?"):_T("New public key was received, do you want to import it?")); - EnableWindow(GetDlgItem(hwndDlg, IDC_IMPORT_AND_USE), DBGetContactSettingByte(new_key_hcnt, szGPGModuleName, "GPGEncryption", 0)?0:1); + EnableWindow(GetDlgItem(hwndDlg, IDC_IMPORT_AND_USE), DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0)?0:1); SetDlgItemText(hwndDlg, ID_IMPORT, (_tcslen(tmp) > 0)?_T("Replace"):_T("Accept")); mir_free(tmp); tmp = new TCHAR [256]; _tcscpy(tmp, _T("Received key from ")); - _tcscat(tmp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)new_key_hcnt, (LPARAM)GCDNF_TCHAR)); + _tcscat(tmp, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, (LPARAM)GCDNF_TCHAR)); SetDlgItemText(hwndDlg, IDC_KEY_FROM, tmp); delete [] tmp; return TRUE; @@ -495,11 +498,11 @@ static BOOL CALLBACK DlgProcNewKeyDialog(HWND hwndDlg, UINT msg, WPARAM wParam, break; case IDC_IMPORT_AND_USE: ImportKey(); - DBWriteContactSettingByte(new_key_hcnt, szGPGModuleName, "GPGEncryption", 1); + DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 1); void setSrmmIcon(HANDLE hContact); void setClistIcon(HANDLE hContact); - setSrmmIcon(new_key_hcnt); - setClistIcon(new_key_hcnt); + setSrmmIcon(hContact); + setClistIcon(hContact); DestroyWindow(hwndDlg); break; case IDC_IGNORE_KEY: @@ -1094,7 +1097,10 @@ void ImportKey() { extern wstring new_key; extern HANDLE new_key_hcnt; - DBWriteContactSettingTString(new_key_hcnt, szGPGModuleName, "GPGPubKey", new_key.c_str()); + extern HANDLE new_key_hcnt_mutex; + HANDLE hContact = new_key_hcnt; + CloseHandle(new_key_hcnt_mutex); + DBWriteContactSettingTString(hContact, szGPGModuleName, "GPGPubKey", new_key.c_str()); { //gpg execute block wstring cmd; TCHAR tmp2[MAX_PATH] = {0}; @@ -1108,7 +1114,7 @@ void ImportKey() _tcscat(tmp2, _T("\\")); _tcscat(tmp2, _T("temporary_exported.asc")); wfstream f(tmp2, std::ios::out); - ptmp = UniGetContactSettingUtf(new_key_hcnt, szGPGModuleName, "GPGPubKey", _T("")); + ptmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T("")); wstring new_key = ptmp; mir_free(ptmp); f<<new_key.c_str(); @@ -1136,23 +1142,23 @@ void ImportKey() MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); return; } - DBDeleteContactSetting(new_key_hcnt, szGPGModuleName, "bAlwatsTrust"); + DBDeleteContactSetting(hContact, szGPGModuleName, "bAlwatsTrust"); { char *tmp = NULL; string::size_type s = output.find("gpg: key ") + strlen("gpg: key "); string::size_type s2 = output.find(":", s); - DBWriteContactSettingString(new_key_hcnt, szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str()); + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str()); s2+=2; s = output.find("\"", s2)-1; if(s != s2-1) - DBWriteContactSettingString(new_key_hcnt, szGPGModuleName, "KeyType", output.substr(s2,s-s2).c_str()); + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyType", output.substr(s2,s-s2).c_str()); s+=2; if((s2 = output.find("(", s)) == string::npos) s2 = output.find("<", s); tmp = new char [output.substr(s,s2-s-1).length()+1]; strcpy(tmp, output.substr(s,s2-s-1).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(new_key_hcnt, szGPGModuleName, "KeyMainName", tmp); + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", tmp); mir_free(tmp); if((s = output.find(")", s2)) == string::npos) s = output.find(">", s2); @@ -1162,14 +1168,14 @@ void ImportKey() tmp = new char [output.substr(s2,s-s2).length()+1]; strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(new_key_hcnt, szGPGModuleName, "KeyComment", tmp); + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", tmp); mir_free(tmp); s+=3; s2 = output.find(">", s); tmp = new char [output.substr(s,s2-s).length()+1]; strcpy(tmp, output.substr(s,s2-s).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(new_key_hcnt, szGPGModuleName, "KeyMainEmail", tmp); + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", tmp); mir_free(tmp); } else @@ -1177,7 +1183,7 @@ void ImportKey() tmp = new char [output.substr(s2,s-s2).length()+1]; strcpy(tmp, output.substr(s2,s-s2).c_str()); mir_utf8decode(tmp, 0); - DBWriteContactSettingString(new_key_hcnt, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); mir_free(tmp); } } |