summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-17 21:57:18 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-17 21:57:18 +0300
commite3aa8e1f1e5312252f700902bab5d8575fc06a85 (patch)
tree10fdaca42d4898e234d5b2b993b86916242361d3 /plugins
parent1c2df22138f73779aaef56cc5019dc58913700b1 (diff)
New_GPG:
- fix for key deletion; - fix for checkboxes inside User list; - nasty perversion aka globals.user_data removed, instead a parameter is passed into ShowLoadPublicKeyDialog(); - UI code cleaning; - version bump
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/New_GPG/src/globals.h1
-rwxr-xr-xplugins/New_GPG/src/messages.cpp9
-rwxr-xr-xplugins/New_GPG/src/options.cpp319
-rwxr-xr-xplugins/New_GPG/src/srmm.cpp9
-rwxr-xr-xplugins/New_GPG/src/ui.cpp38
-rwxr-xr-xplugins/New_GPG/src/ui.h2
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp5
-rwxr-xr-xplugins/New_GPG/src/version.h2
8 files changed, 184 insertions, 201 deletions
diff --git a/plugins/New_GPG/src/globals.h b/plugins/New_GPG/src/globals.h
index 1b8687c4d0..113fbcd76a 100755
--- a/plugins/New_GPG/src/globals.h
+++ b/plugins/New_GPG/src/globals.h
@@ -30,7 +30,6 @@ struct globals_s
logtofile debuglog;
bool gpg_valid = false, gpg_keyexist = false;
std::map<MCONTACT, contact_data> hcontact_data;
- map<int, MCONTACT> user_data;
bool _terminate;
int item_num; //TODO: get rid of this
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index 055ce67fa7..0dd3b471ae 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -48,17 +48,14 @@ static void RecvMsgSvc_func(RecvParams *param)
if (globals.bDebugLog)
globals.debuglog << std::string(time_str() + ": info: received encrypted message from: " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with turned off encryption");
if (MessageBox(nullptr, TranslateT("We received encrypted message from contact with encryption turned off.\nDo you want to turn on encryption for this contact?"), TranslateT("Warning"), MB_YESNO) == IDYES) {
- if (!isContactHaveKey(hContact)) {
- void ShowLoadPublicKeyDialog(bool = false);
- globals.item_num = 0; //black magic here
- globals.user_data[1] = hContact;
- ShowLoadPublicKeyDialog(true);
- }
+ if (!isContactHaveKey(hContact))
+ ShowLoadPublicKeyDialog(hContact, true);
else {
g_plugin.setByte(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, "GPGEncryption", 1);
setSrmmIcon(hContact);
setClistIcon(hContact);
}
+
if (isContactHaveKey(hContact)) {
g_plugin.setByte(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, "GPGEncryption", 1);
setSrmmIcon(hContact);
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index 4323da0347..347c7ecbbc 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -18,12 +18,12 @@
globals_s globals;
-
-int item_num = 0;
-HWND hwndList_p = nullptr;
HWND hwndCurKey_p = nullptr;
-void ShowLoadPublicKeyDialog(bool = false);
+/////////////////////////////////////////////////////////////////////////////////////////
+// COptGpgMainDlg class
+
+static class COptGpgMainDlg *g_pMainDlg;
class COptGpgMainDlg : public CDlgBase
{
@@ -46,17 +46,21 @@ public:
btn_LOG_FILE_SET.OnClick = Callback(this, &COptGpgMainDlg::onClick_LOG_FILE_SET);
check_JABBER_API.OnChange = Callback(this, &COptGpgMainDlg::onChange_JABBER_API);
+
+ list_USERLIST.OnItemChanged = Callback(this, &COptGpgMainDlg::onItemChanged_USERLIST);
}
bool OnInitDialog() override
{
+ g_pMainDlg = this;
+
list_USERLIST.AddColumn(0, TranslateT("Contact"), 60);
list_USERLIST.AddColumn(1, TranslateT("Key ID"), 50);
list_USERLIST.AddColumn(2, TranslateT("Name"), 50);
list_USERLIST.AddColumn(3, TranslateT("Email"), 50);
list_USERLIST.AddColumn(4, TranslateT("Account"), 60);
list_USERLIST.SetExtendedListViewStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_SINGLEROW);
- int i = 1;
+
for (auto &hContact : Contacts()) {
if (!isContactHaveKey(hContact))
continue;
@@ -67,7 +71,7 @@ public:
wchar_t *name = Clist_GetContactDisplayName(hContact);
- int row = list_USERLIST.AddItem(L"", 0);
+ int row = list_USERLIST.AddItem(L"", 0, hContact);
list_USERLIST.SetItemText(row, 0, name);
list_USERLIST.SetItemText(row, 4, pa->tszAccountName);
@@ -83,15 +87,9 @@ public:
if (g_plugin.getByte(hContact, "GPGEncryption", 0))
list_USERLIST.SetCheckState(row, 1);
- globals.user_data[(int)i] = hContact;
- i++;
}
- list_USERLIST.SetColumnWidth(0, LVSCW_AUTOSIZE);
- list_USERLIST.SetColumnWidth(1, LVSCW_AUTOSIZE);
- list_USERLIST.SetColumnWidth(2, LVSCW_AUTOSIZE);
- list_USERLIST.SetColumnWidth(3, LVSCW_AUTOSIZE);
- list_USERLIST.SetColumnWidth(4, LVSCW_AUTOSIZE);
+ SetListAutoSize();
edit_LOG_FILE_EDIT.SetText(ptrW(g_plugin.getWStringA("szLogFilePath", L"")));
@@ -112,11 +110,8 @@ public:
//TODO: get rid of following s..t
////////////////
- hwndList_p = list_USERLIST.GetHwnd();
hwndCurKey_p = lbl_CURRENT_KEY.GetHwnd();
////////////////
-
- list_USERLIST.OnItemChanged = Callback(this, &COptGpgMainDlg::onItemChanged_USERLIST);
return true;
}
@@ -138,101 +133,105 @@ public:
return true;
}
+ void OnDestroy() override
+ {
+ hwndCurKey_p = nullptr;
+ g_pMainDlg = nullptr;
+ }
+
void onClick_DELETE_KEY_BUTTON(CCtrlButton*)
{
- void setClistIcon(MCONTACT hContact);
- void setSrmmIcon(MCONTACT hContact);
- { //gpg execute block
- wchar_t *ptmp;
- bool keep = false;
- bool ismetacontact = false;
- MCONTACT meta = NULL;
- MCONTACT hContact = globals.user_data[item_num + 1];
- if (db_mc_isMeta(hContact)) {
- meta = hContact;
- hContact = metaGetMostOnline(hContact);
- ismetacontact = true;
- }
- else if ((meta = db_mc_getMeta(globals.user_data[item_num + 1])) != NULL) {
- hContact = metaGetMostOnline(meta);
- ismetacontact = true;
- }
+ int idx = list_USERLIST.GetSelectionMark();
+ if (idx == -1)
+ return;
- CMStringA tmp(g_plugin.getMStringA(hContact, "KeyID"));
- for (auto &hcnttmp : Contacts()) {
- if (hcnttmp != hContact) {
- ptrA tmp2(g_plugin.getStringA(hcnttmp, "KeyID"));
- if (!mir_strcmp(tmp, tmp2)) {
- keep = true;
- break;
- }
+ bool keep = false;
+ bool ismetacontact = false;
+ MCONTACT meta = NULL;
+ MCONTACT hContact = list_USERLIST.GetItemData(idx);
+ if (db_mc_isMeta(hContact)) {
+ meta = hContact;
+ hContact = metaGetMostOnline(hContact);
+ ismetacontact = true;
+ }
+ else if ((meta = db_mc_getMeta(hContact)) != NULL) {
+ hContact = metaGetMostOnline(meta);
+ ismetacontact = true;
+ }
+
+ CMStringA tmp(g_plugin.getMStringA(hContact, "KeyID"));
+ for (auto &hcnttmp : Contacts()) {
+ if (hcnttmp != hContact) {
+ ptrA tmp2(g_plugin.getStringA(hcnttmp, "KeyID"));
+ if (!mir_strcmp(tmp, tmp2)) {
+ keep = true;
+ break;
}
}
+ }
- if (!keep)
- if (MessageBox(nullptr, TranslateT("This key is not used by any contact. Do you want to remove it from public keyring?"), TranslateT("Key info"), MB_YESNO) == IDYES) {
- gpg_execution_params params;
- params.addParam(L"--batch");
- params.addParam(L"--yes");
- params.addParam(L"--delete-key");
- ptmp = mir_a2u(tmp);
- params.addParam(ptmp);
- mir_free(ptmp);
- if (!gpg_launcher(params))
- return;
-
- if (params.result == pxNotFound)
- return;
-
- if (params.out.Find("--delete-secret-keys") != -1)
- MessageBox(nullptr, TranslateT("we have secret key for this public key, do not removing from GPG keyring"), TranslateT("info"), MB_OK);
- else
- MessageBox(nullptr, TranslateT("Key removed from GPG keyring"), TranslateT("info"), MB_OK);
- }
+ if (!keep)
+ if (MessageBox(nullptr, TranslateT("This key is not used by any contact. Do you want to remove it from public keyring?"), TranslateT("Key info"), MB_YESNO) == IDYES) {
+ gpg_execution_params params;
+ params.addParam(L"--batch");
+ params.addParam(L"--yes");
+ params.addParam(L"--delete-key");
+ params.addParam(_A2T(tmp).get());
+ if (!gpg_launcher(params))
+ return;
- if (ismetacontact) {
- if (MessageBox(nullptr, TranslateT("Do you want to remove key from entire metacontact (all subcontacts)?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) {
- MCONTACT hcnt = NULL;
- int count = db_mc_getSubCount(meta);
- for (int i = 0; i < count; i++) {
- hcnt = db_mc_getSub(meta, i);
- if (hcnt) {
- g_plugin.delSetting(hcnt, "KeyID");
- g_plugin.delSetting(hcnt, "GPGPubKey");
- g_plugin.delSetting(hcnt, "KeyMainName");
- g_plugin.delSetting(hcnt, "KeyType");
- g_plugin.delSetting(hcnt, "KeyMainEmail");
- g_plugin.delSetting(hcnt, "KeyComment");
- setClistIcon(hcnt);
- setSrmmIcon(hcnt);
- }
+ if (params.result == pxNotFound)
+ return;
+
+ if (params.out.Find("--delete-secret-keys") != -1)
+ MessageBox(nullptr, TranslateT("we have secret key for this public key, do not removing from GPG keyring"), TranslateT("info"), MB_OK);
+ else
+ MessageBox(nullptr, TranslateT("Key removed from GPG keyring"), TranslateT("info"), MB_OK);
+ }
+
+ if (ismetacontact) {
+ if (MessageBox(nullptr, TranslateT("Do you want to remove key from entire metacontact (all subcontacts)?"), TranslateT("Metacontact detected"), MB_YESNO) == IDYES) {
+ MCONTACT hcnt = NULL;
+ int count = db_mc_getSubCount(meta);
+ for (int i = 0; i < count; i++) {
+ hcnt = db_mc_getSub(meta, i);
+ if (hcnt) {
+ g_plugin.delSetting(hcnt, "KeyID");
+ g_plugin.delSetting(hcnt, "GPGPubKey");
+ g_plugin.delSetting(hcnt, "KeyMainName");
+ g_plugin.delSetting(hcnt, "KeyType");
+ g_plugin.delSetting(hcnt, "KeyMainEmail");
+ g_plugin.delSetting(hcnt, "KeyComment");
+ setClistIcon(hcnt);
+ setSrmmIcon(hcnt);
}
}
- else {
- g_plugin.delSetting(hContact, "KeyID");
- g_plugin.delSetting(hContact, "GPGPubKey");
- g_plugin.delSetting(hContact, "KeyMainName");
- g_plugin.delSetting(hContact, "KeyType");
- g_plugin.delSetting(hContact, "KeyMainEmail");
- g_plugin.delSetting(hContact, "KeyComment");
- setClistIcon(hContact);
- setSrmmIcon(hContact);
- }
}
else {
- g_plugin.delSetting(globals.user_data[item_num + 1], "KeyID");
- g_plugin.delSetting(globals.user_data[item_num + 1], "GPGPubKey");
- g_plugin.delSetting(globals.user_data[item_num + 1], "KeyMainName");
- g_plugin.delSetting(globals.user_data[item_num + 1], "KeyType");
- g_plugin.delSetting(globals.user_data[item_num + 1], "KeyMainEmail");
- g_plugin.delSetting(globals.user_data[item_num + 1], "KeyComment");
- setClistIcon(globals.user_data[item_num + 1]);
- setSrmmIcon(globals.user_data[item_num + 1]);
+ g_plugin.delSetting(hContact, "KeyID");
+ g_plugin.delSetting(hContact, "GPGPubKey");
+ g_plugin.delSetting(hContact, "KeyMainName");
+ g_plugin.delSetting(hContact, "KeyType");
+ g_plugin.delSetting(hContact, "KeyMainEmail");
+ g_plugin.delSetting(hContact, "KeyComment");
+ setClistIcon(hContact);
+ setSrmmIcon(hContact);
}
}
- list_USERLIST.SetItemText(item_num, 3, TranslateT("not set"));
- list_USERLIST.SetItemText(item_num, 2, TranslateT("not set"));
- list_USERLIST.SetItemText(item_num, 1, TranslateT("not set"));
+ else {
+ g_plugin.delSetting(hContact, "KeyID");
+ g_plugin.delSetting(hContact, "GPGPubKey");
+ g_plugin.delSetting(hContact, "KeyMainName");
+ g_plugin.delSetting(hContact, "KeyType");
+ g_plugin.delSetting(hContact, "KeyMainEmail");
+ g_plugin.delSetting(hContact, "KeyComment");
+ setClistIcon(hContact);
+ setSrmmIcon(hContact);
+ }
+
+ list_USERLIST.SetItemText(idx, 3, TranslateT("not set"));
+ list_USERLIST.SetItemText(idx, 2, TranslateT("not set"));
+ list_USERLIST.SetItemText(idx, 1, TranslateT("not set"));
}
void onClick_SELECT_KEY(CCtrlButton*)
@@ -243,9 +242,14 @@ public:
void onClick_SAVE_KEY_BUTTON(CCtrlButton*)
{
+ int idx = list_USERLIST.GetSelectionMark();
+ if (idx == -1)
+ return;
+
+ MCONTACT hContact = list_USERLIST.GetItemData(idx);
ptrW tmp(GetFilePath(TranslateT("Export public key"), L"*", TranslateT(".asc pubkey file"), true));
if (tmp) {
- CMStringW str(g_plugin.getMStringW(globals.user_data[item_num + 1], "GPGPubKey"));
+ CMStringW str(g_plugin.getMStringW(hContact, "GPGPubKey"));
str.Replace(L"\r", L"");
wfstream f(tmp, std::ios::out);
@@ -307,40 +311,41 @@ public:
void onItemChanged_USERLIST(CCtrlListView::TEventInfo *ev)
{
- //TODO: get rid of "item_num"
- if (ev->nmlv)
- {
- NMLISTVIEW *hdr = ev->nmlv;
-
- if (hdr->iItem == -1)
- return;
- void setClistIcon(MCONTACT hContact);
- void setSrmmIcon(MCONTACT hContact);
- item_num = hdr->iItem;
- if (list_USERLIST.GetCheckState(hdr->iItem))
- g_plugin.setByte(globals.user_data[item_num + 1], "GPGEncryption", 1);
- else
- g_plugin.setByte(globals.user_data[item_num + 1], "GPGEncryption", 0);
- setClistIcon(globals.user_data[item_num + 1]);
- setSrmmIcon(globals.user_data[item_num + 1]);
- }
+ NMLISTVIEW *hdr = ev->nmlv;
+ if (hdr->iItem == -1)
+ return;
+
+ void setClistIcon(MCONTACT hContact);
+ void setSrmmIcon(MCONTACT hContact);
+
+ MCONTACT hContact = list_USERLIST.GetItemData(hdr->iItem);
+ if (list_USERLIST.GetCheckState(hdr->iItem))
+ g_plugin.setByte(hContact, "GPGEncryption", 1);
+ else
+ g_plugin.setByte(hContact, "GPGEncryption", 0);
+ setClistIcon(hContact);
+ setSrmmIcon(hContact);
}
- void onClick_USERLIST(CCtrlListView::TEventInfo *ev)
+ void SetLineText(int i, const wchar_t *pwszText)
{
- //TODO: get rid of "item_num"
- if (ev->nmlv)
- {
- NMLISTVIEW *hdr = ev->nmlv;
-
- if (hdr->iItem == -1)
- return;
+ int idx = list_USERLIST.GetSelectionMark();
+ if (idx != -1)
+ list_USERLIST.SetItemText(idx, i, pwszText);
+ }
- item_num = hdr->iItem;
- }
+ void SetListAutoSize()
+ {
+ list_USERLIST.SetColumnWidth(0, LVSCW_AUTOSIZE);
+ list_USERLIST.SetColumnWidth(1, LVSCW_AUTOSIZE);
+ list_USERLIST.SetColumnWidth(2, LVSCW_AUTOSIZE);
+ list_USERLIST.SetColumnWidth(3, LVSCW_AUTOSIZE);
+ list_USERLIST.SetColumnWidth(4, LVSCW_AUTOSIZE);
}
};
+/////////////////////////////////////////////////////////////////////////////////////////
+// COptGpgBinDlg class
class COptGpgBinDlg : public CDlgBase
{
@@ -366,12 +371,12 @@ public:
bool OnApply() override
{
- wchar_t tmp[8192];
- g_plugin.setWString("szGpgBinPath", edit_BIN_PATH.GetText());
- mir_wstrncpy(tmp, edit_HOME_DIR.GetText(), 8191);
- while (tmp[mir_wstrlen(tmp) - 1] == '\\')
- tmp[mir_wstrlen(tmp) - 1] = '\0';
- g_plugin.setWString("szHomePath", tmp);
+ g_plugin.setWString("szGpgBinPath", ptrW(edit_BIN_PATH.GetText()));
+
+ ptrW wszHomeDir(edit_HOME_DIR.GetText());
+ while (wszHomeDir[mir_wstrlen(wszHomeDir) - 1] == '\\')
+ wszHomeDir[mir_wstrlen(wszHomeDir) - 1] = '\0';
+ g_plugin.setWString("szHomePath", wszHomeDir);
return true;
}
@@ -543,7 +548,9 @@ class CDlgLoadPubKeyDlg : public CDlgBase
CCtrlEdit edit_PUBLIC_KEY_EDIT;
public:
- CDlgLoadPubKeyDlg() : CDlgBase(g_plugin, IDD_LOAD_PUBLIC_KEY),
+ CDlgLoadPubKeyDlg(MCONTACT _p1) :
+ CDlgBase(g_plugin, IDD_LOAD_PUBLIC_KEY),
+ hContact(_p1),
chk_ENABLE_ENCRYPTION(this, IDC_ENABLE_ENCRYPTION),
btn_SELECT_EXISTING(this, IDC_SELECT_EXISTING), btn_OK(this, ID_OK), btn_LOAD_FROM_FILE(this, ID_LOAD_FROM_FILE), btn_IMPORT(this, IDC_IMPORT),
edit_PUBLIC_KEY_EDIT(this, IDC_PUBLIC_KEY_EDIT)
@@ -556,7 +563,6 @@ public:
bool OnInitDialog() override
{
- hContact = globals.user_data[1];
SetWindowPos(m_hwnd, nullptr, globals.load_key_rect.left, globals.load_key_rect.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
mir_subclassWindow(GetDlgItem(m_hwnd, IDC_PUBLIC_KEY_EDIT), editctrl_ctrl_a);
MCONTACT hcnt = db_mc_tryMeta(hContact);
@@ -759,10 +765,10 @@ public:
}
mir_free(tmp3);
}
- tmp = mir_wstrdup(toUTF16(output.substr(s, s2 - s)).c_str());
- if (hContact && hwndList_p)
- ListView_SetItemText(hwndList_p, item_num, 1, tmp);
- mir_free(tmp);
+
+ if (hContact && g_pMainDlg)
+ g_pMainDlg->SetLineText(1, toUTF16(output.substr(s, s2 - s)).c_str());
+
s = output.find("“", s2);
if (s == string::npos) {
s = output.find("\"", s2);
@@ -800,10 +806,10 @@ public:
}
mir_free(tmp3);
}
- tmp = mir_wstrdup(toUTF16(output.substr(s, s2 - s - 1)).c_str());
- if (hContact && hwndList_p)
- ListView_SetItemText(hwndList_p, item_num, 2, tmp); //TODO: do something with this
- mir_free(tmp);
+
+ if (hContact && g_pMainDlg)
+ g_pMainDlg->SetLineText(2, toUTF16(output.substr(s, s2 - s - 1)).c_str());
+
if ((s = output.find(")", s2)) == string::npos)
s = output.find(">", s2);
else if (s > output.find(">", s2))
@@ -849,10 +855,9 @@ public:
else g_plugin.setString(hContact, "KeyMainEmail", output.substr(s, s2 - s).c_str());
}
mir_free(tmp3);
- 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);
+
+ if (hContact && g_pMainDlg)
+ g_pMainDlg->SetLineText(3, toUTF16(output.substr(s, s2 - s)).c_str());
}
else {
char *tmp3 = (char*)mir_alloc(output.substr(s2, s - s2).length() + 1);
@@ -873,20 +878,14 @@ public:
else g_plugin.setString(hContact, "KeyMainEmail", output.substr(s2, s - s2).c_str());
}
mir_free(tmp3);
- tmp = mir_wstrdup(toUTF16(output.substr(s2, s - s2)).c_str());
- if (hContact && hwndList_p)
- ListView_SetItemText(hwndList_p, item_num, 3, tmp); //TODO: do something with this
- mir_free(tmp);
+
+ if (hContact && g_pMainDlg)
+ g_pMainDlg->SetLineText(3, toUTF16(output.substr(s2, s - s2)).c_str());
}
}
}
- if (hContact && hwndList_p) //TODO: do something with this
- {
- ListView_SetColumnWidth(hwndList_p, 0, LVSCW_AUTOSIZE);
- ListView_SetColumnWidth(hwndList_p, 1, LVSCW_AUTOSIZE);
- ListView_SetColumnWidth(hwndList_p, 2, LVSCW_AUTOSIZE);
- ListView_SetColumnWidth(hwndList_p, 3, LVSCW_AUTOSIZE);
- }
+ if (hContact && g_pMainDlg)
+ g_pMainDlg->SetListAutoSize();
}
if (!hContact) {
gpg_execution_params params2;
@@ -978,10 +977,10 @@ public:
};
-void ShowLoadPublicKeyDialog(bool modal)
+void ShowLoadPublicKeyDialog(MCONTACT hContact, bool bModal)
{
- CDlgLoadPubKeyDlg *d = new CDlgLoadPubKeyDlg();
- if (modal)
+ CDlgLoadPubKeyDlg *d = new CDlgLoadPubKeyDlg(hContact);
+ if (bModal)
d->DoModal();
else
d->Show();
diff --git a/plugins/New_GPG/src/srmm.cpp b/plugins/New_GPG/src/srmm.cpp
index e44c69ec31..89993664b1 100755
--- a/plugins/New_GPG/src/srmm.cpp
+++ b/plugins/New_GPG/src/srmm.cpp
@@ -50,12 +50,8 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
setClistIcon(hContact);
}
else if (!enc) {
- if (!isContactHaveKey(hContact)) {
- void ShowLoadPublicKeyDialog(bool = false);
- globals.item_num = 0; //black magic here
- globals.user_data[1] = hContact;
- ShowLoadPublicKeyDialog();
- }
+ if (!isContactHaveKey(hContact))
+ ShowLoadPublicKeyDialog(hContact, false);
else {
g_plugin.setByte(hContact, "GPGEncryption", 1);
if (hMeta)
@@ -64,6 +60,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
setClistIcon(hContact);
return 0;
}
+
if (isContactHaveKey(hContact)) {
g_plugin.setByte(hContact, "GPGEncryption", 1);
if (hMeta)
diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp
index 4f575e9678..05f1675744 100755
--- a/plugins/New_GPG/src/ui.cpp
+++ b/plugins/New_GPG/src/ui.cpp
@@ -342,10 +342,7 @@ void CDlgFirstRun::onClick_GENERATE_KEY(CCtrlButton*)
void CDlgFirstRun::onClick_OTHER(CCtrlButton*)
{
- void ShowLoadPublicKeyDialog(bool = false);
- globals.item_num = 0; //black magic here
- globals.user_data[1] = 0;
- ShowLoadPublicKeyDialog(true);
+ ShowLoadPublicKeyDialog(0, true);
refresh_key_list();
}
@@ -354,6 +351,7 @@ void CDlgFirstRun::onClick_DELETE_KEY(CCtrlButton*)
int i = list_KEY_LIST.GetSelectionMark();
if (i == -1)
return;
+
list_KEY_LIST.GetItemText(i, 0, fp, _countof(fp));
{
gpg_execution_params params;
@@ -365,28 +363,22 @@ void CDlgFirstRun::onClick_DELETE_KEY(CCtrlButton*)
if (params.result == pxNotFound)
return;
- string out(params.out);
- string::size_type s = out.find("Key fingerprint = ");
+ int s = params.out.Find("Key fingerprint = ");
s += mir_strlen("Key fingerprint = ");
- string::size_type s2 = out.find("\n", s);
- wchar_t *str = nullptr;
- {
- string tmp = out.substr(s, s2 - s - 1).c_str();
- string::size_type p = 0;
- while ((p = tmp.find(" ", p)) != string::npos)
- tmp.erase(p, 1);
-
- str = mir_a2u(tmp.c_str());
- }
+ int s2 = params.out.Find("\n", s);
- params.addParam(L"--batch");
- params.addParam(L"--delete-secret-and-public-key");
- params.addParam(L"--fingerprint");
- params.addParam(str);
- mir_free(str);
- if (!gpg_launcher(params))
+ CMStringW tmp = params.out.Mid(s, s2 - s - 1);
+ tmp.Remove(' ');
+
+ gpg_execution_params params2;
+ params2.addParam(L"--batch");
+ params2.addParam(L"--delete-secret-and-public-key");
+ params2.addParam(L"--fingerprint");
+ params2.addParam(tmp.c_str());
+
+ if (!gpg_launcher(params2))
return;
- if (params.result == pxNotFound)
+ if (params2.result == pxNotFound)
return;
}
diff --git a/plugins/New_GPG/src/ui.h b/plugins/New_GPG/src/ui.h
index 02e3fcb579..6ab8c7111c 100755
--- a/plugins/New_GPG/src/ui.h
+++ b/plugins/New_GPG/src/ui.h
@@ -17,6 +17,8 @@
#ifndef UI_H
#define UI_H
+void ShowLoadPublicKeyDialog(MCONTACT hContact, bool bModal);
+
class CDlgEncryptedFileMsgBox : public CDlgBase
{
CCtrlCheck chk_REMEMBER;
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index 3ba1b02578..d72e49b27c 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -18,8 +18,6 @@
#include "utf8.h"
-void ShowLoadPublicKeyDialog(bool = false);
-
void GetFilePath(wchar_t *WindowTittle, char *szSetting, wchar_t *szExt, wchar_t *szExtDesc)
{
wchar_t str[MAX_PATH + 2] = {};
@@ -96,8 +94,7 @@ void GetFolderPath(wchar_t *WindowTittle)
INT_PTR LoadKey(WPARAM w, LPARAM)
{
- globals.user_data[(int)1] = (MCONTACT)w;
- ShowLoadPublicKeyDialog();
+ ShowLoadPublicKeyDialog((MCONTACT)w, false);
return 0;
}
diff --git a/plugins/New_GPG/src/version.h b/plugins/New_GPG/src/version.h
index 23bef7f8e7..946c4645c3 100755
--- a/plugins/New_GPG/src/version.h
+++ b/plugins/New_GPG/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>