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]) { DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp"); DBCONTACTWRITESETTING cws; memset(&cws,0,sizeof(cws)); cws.szModule = szModuleName; cws.szSetting = "pgp"; cws.value.type = DBVT_BLOB; cws.value.pbVal = (LPBYTE)KeyID; cws.value.cpbVal = pgp_size_keyid(); CallService(MS_DB_CONTACT_WRITESETTING,wParam,(LPARAM)&cws); DBWriteContactSettingByte((HANDLE)wParam,szModuleName,"pgp_mode",0); DBWriteContactSettingString((HANDLE)wParam,szModuleName,"pgp_abbr",szKeyID); del = false; } } else if(bPGPprivkey) { char KeyPath[MAX_PATH]; KeyPath[0]='\0'; if(ShowSelectKeyDlg(0,KeyPath)) { char *publ = LoadKeys(KeyPath,false); if(publ) { DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp"); myDBWriteStringEncode((HANDLE)wParam,szModuleName,"pgp",publ); DBWriteContactSettingByte((HANDLE)wParam,szModuleName,"pgp_mode",1); DBWriteContactSettingString((HANDLE)wParam,szModuleName,"pgp_abbr","(binary)"); mir_free(publ); del = false; } } } } if(del) Service_PGPdelKey(wParam,lParam); else { pUinKey ptr = getUinKey((HANDLE)wParam); cpp_delete_context(ptr->cntx); ptr->cntx=0; } ShowStatusIconNotify((HANDLE)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(0, 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 = 0; } ShowStatusIconNotify(wParam); return 1; }