diff options
author | George Hazan <ghazan@miranda.im> | 2020-06-23 18:14:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-06-23 18:14:06 +0300 |
commit | c7f6afe4b2f0dd41d7a97ea26075398bf7bd1843 (patch) | |
tree | 5f2509e6f2a6d010353375024a170e1d8b904a35 /plugins/New_GPG | |
parent | 7e120902cd5b5fe17bf9cbdd799802a20eee5c6e (diff) |
New_GPG: fix for extra icon's behavior
Diffstat (limited to 'plugins/New_GPG')
-rwxr-xr-x | plugins/New_GPG/src/globals.h | 1 | ||||
-rwxr-xr-x | plugins/New_GPG/src/icons.cpp | 6 | ||||
-rwxr-xr-x | plugins/New_GPG/src/init.cpp | 7 | ||||
-rwxr-xr-x | plugins/New_GPG/src/options.cpp | 7 | ||||
-rwxr-xr-x | plugins/New_GPG/src/srmm.cpp | 44 | ||||
-rwxr-xr-x | plugins/New_GPG/src/stdafx.h | 1 | ||||
-rwxr-xr-x | plugins/New_GPG/src/ui.cpp | 5 |
7 files changed, 38 insertions, 33 deletions
diff --git a/plugins/New_GPG/src/globals.h b/plugins/New_GPG/src/globals.h index b7001de220..96d6a81c1d 100755 --- a/plugins/New_GPG/src/globals.h +++ b/plugins/New_GPG/src/globals.h @@ -30,7 +30,6 @@ struct globals_s wchar_t key_id_global[17] = { 0 }; list <JabberAccount*> Accounts; HFONT bold_font = nullptr; - HANDLE g_hCLIcon = nullptr; HGENMENU hSendKey = nullptr, hToggleEncryption = nullptr; logtofile debuglog; bool gpg_valid = false, gpg_keyexist = false; diff --git a/plugins/New_GPG/src/icons.cpp b/plugins/New_GPG/src/icons.cpp index 70271a654f..c9f640c498 100755 --- a/plugins/New_GPG/src/icons.cpp +++ b/plugins/New_GPG/src/icons.cpp @@ -48,8 +48,8 @@ void setSrmmIcon(MCONTACT h) if (hMC != hContact) Srmm_SetIconFlags(hMC, MODULENAME, 2, flags); - const char *szIconId = (enabled) ? "secured" : nullptr; - ExtraIcon_SetIconByName(globals.g_hCLIcon, hContact, szIconId); + const char *szIconId = (enabled) ? "secured" : "unsecured"; + ExtraIcon_SetIconByName(g_plugin.hCLIcon, hContact, szIconId); if (hMC != hContact) - ExtraIcon_SetIconByName(globals.g_hCLIcon, hMC, szIconId); + ExtraIcon_SetIconByName(g_plugin.hCLIcon, hMC, szIconId); } diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index 46b405bad0..1473f85550 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -28,6 +28,7 @@ int GetJabberInterface(WPARAM, LPARAM); int onProtoAck(WPARAM, LPARAM); int onWindowEvent(WPARAM, LPARAM); int onIconPressed(WPARAM, LPARAM); +int onExtraIconPressed(WPARAM, LPARAM, LPARAM); void InitCheck(); void FirstRun(); @@ -217,7 +218,11 @@ int CMPlugin::Load() //////////////////////////////////////////////////////////////////////////////////////// // Extra icon - globals.g_hCLIcon = ExtraIcon_RegisterIcolib(MODULENAME, Translate("GPG encryption status"), "secured"); + hCLIcon = ExtraIcon_RegisterIcolib(MODULENAME, Translate("GPG encryption status"), "secured", &onExtraIconPressed); + for (auto &cc : Contacts()) + if (isContactHaveKey(cc)) + ExtraIcon_SetIconByName(hCLIcon, cc, "unsecured"); + return 0; } diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index 485c7b431c..c658775a8d 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -298,12 +298,7 @@ public: check_JABBER_API.Enable(); check_AUTO_EXCHANGE.Enable(g_plugin.bJabberAPI); - CMStringW keyinfo = TranslateT("Default private key ID"); - keyinfo += L": "; - - ptrW keyid(g_plugin.getWStringA("KeyID")); - keyinfo += (mir_wstrlen(keyid) > 0) ? keyid : TranslateT("not set"); - lbl_CURRENT_KEY.SetText(keyinfo); + lbl_CURRENT_KEY.SetText(CMStringW(FORMAT, L"%s: %s", TranslateT("Default private key ID"), ptrW(g_plugin.getWStringA("KeyID", TranslateT("not set"))).get())); check_JABBER_API.SetState(g_plugin.getByte("bJabberAPI", 1)); check_FILE_TRANSFERS.SetState(g_plugin.getByte("bFileTransfers", 0)); diff --git a/plugins/New_GPG/src/srmm.cpp b/plugins/New_GPG/src/srmm.cpp index 3a0e99da26..61219a3617 100755 --- a/plugins/New_GPG/src/srmm.cpp +++ b/plugins/New_GPG/src/srmm.cpp @@ -16,19 +16,8 @@ #include "stdafx.h" -void setSrmmIcon(MCONTACT hContact); - -int __cdecl onWindowEvent(WPARAM, LPARAM lParam) +static void ToggleIcon(MCONTACT hContact) { - MessageWindowEventData *mwd = (MessageWindowEventData *)lParam; - if (mwd->uType == MSG_WINDOW_EVT_OPEN || mwd->uType == MSG_WINDOW_EVT_OPENING) - setSrmmIcon(mwd->hContact); - return 0; -} - -int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) -{ - MCONTACT hContact = wParam; MCONTACT hMeta = NULL; if (db_mc_isMeta(hContact)) { hMeta = hContact; @@ -37,11 +26,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) else if (db_mc_isSub(hContact)) hMeta = db_mc_getMeta(hContact); - StatusIconClickData *sicd = (StatusIconClickData *)lParam; - if (mir_strcmp(sicd->szModule, MODULENAME)) - return 0; // not our event - - int enc = g_plugin.getByte(hContact, "GPGEncryption", 0); + int enc = g_plugin.getByte(hContact, "GPGEncryption"); if (enc) { g_plugin.setByte(hContact, "GPGEncryption", 0); if (hMeta) @@ -56,7 +41,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) if (hMeta) g_plugin.setByte(hMeta, "GPGEncryption", 1); setSrmmIcon(hContact); - return 0; + return; } if (isContactHaveKey(hContact)) { @@ -66,5 +51,28 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) setSrmmIcon(hContact); } } +} + +int __cdecl onWindowEvent(WPARAM, LPARAM lParam) +{ + MessageWindowEventData *mwd = (MessageWindowEventData *)lParam; + if (mwd->uType == MSG_WINDOW_EVT_OPEN || mwd->uType == MSG_WINDOW_EVT_OPENING) + if (isContactHaveKey(mwd->hContact)) + setSrmmIcon(mwd->hContact); + return 0; +} + +int __cdecl onIconPressed(WPARAM hContact, LPARAM lParam) +{ + StatusIconClickData *sicd = (StatusIconClickData *)lParam; + if (!mir_strcmp(sicd->szModule, MODULENAME)) + ToggleIcon(hContact); + + return 0; +} + +int __cdecl onExtraIconPressed(WPARAM hContact, LPARAM, LPARAM) +{ + ToggleIcon(hContact); return 0; } diff --git a/plugins/New_GPG/src/stdafx.h b/plugins/New_GPG/src/stdafx.h index 79c0a01826..1df8b1518e 100755 --- a/plugins/New_GPG/src/stdafx.h +++ b/plugins/New_GPG/src/stdafx.h @@ -74,6 +74,7 @@ using std::fstream; struct CMPlugin : public PLUGIN<CMPlugin> { CMOption<bool> bJabberAPI, bPresenceSigning, bFileTransfers, bAutoExchange, bSameAction, bAppendTags, bStripTags, bDebugLog, bSendErrorMessages; + HANDLE hCLIcon = nullptr; CMPlugin(); diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp index 8f0d9e8950..35b4b5217a 100755 --- a/plugins/New_GPG/src/ui.cpp +++ b/plugins/New_GPG/src/ui.cpp @@ -523,10 +523,7 @@ public: } combo_ACCOUNT.SetCurSel(0); - CMStringW keyinfo = TranslateT("key ID"); - keyinfo += L": "; - keyinfo += g_plugin.getMStringW("KeyID", TranslateT("not set")); - lbl_KEY_ID.SetText(keyinfo); + lbl_KEY_ID.SetText(CMStringW(FORMAT, L"%s: %s", TranslateT("key ID"), ptrW(g_plugin.getWStringA("KeyID", TranslateT("not set"))).get())); return true; } |