summaryrefslogtreecommitdiff
path: root/plugins/MirOTR
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-03-07 15:53:20 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-03-07 15:53:20 +0300
commita714fa356e4d6dd8c6169ef4123fea167371a1f9 (patch)
tree8c71762fdd2285a83f30a033b6ee2190e98ae69b /plugins/MirOTR
parente43e5e9e3ff94b20953c840a819952e4221654fa (diff)
OTR:
- icolib icons support rewritten more transparently; - fix for the wrong icon in menu
Diffstat (limited to 'plugins/MirOTR')
-rw-r--r--plugins/MirOTR/src/icons.cpp17
-rw-r--r--plugins/MirOTR/src/icons.h19
-rw-r--r--plugins/MirOTR/src/language.h7
-rw-r--r--plugins/MirOTR/src/mirotrmenu.cpp16
-rw-r--r--plugins/MirOTR/src/otr.cpp3
-rw-r--r--plugins/MirOTR/src/svcs_menu.cpp4
-rw-r--r--plugins/MirOTR/src/svcs_srmm.cpp26
7 files changed, 46 insertions, 46 deletions
diff --git a/plugins/MirOTR/src/icons.cpp b/plugins/MirOTR/src/icons.cpp
index c58cab94a7..4091a9cb43 100644
--- a/plugins/MirOTR/src/icons.cpp
+++ b/plugins/MirOTR/src/icons.cpp
@@ -1,15 +1,16 @@
#include "stdafx.h"
-static IconItem iconList[] = {
- { LPGEN(LANG_ICON_OTR), ICON_OTR, IDI_OTR },
- { LPGEN(LANG_ICON_PRIVATE), ICON_PRIVATE, IDI_PRIVATE },
- { LPGEN(LANG_ICON_UNVERIFIED), ICON_UNVERIFIED, IDI_UNVERIFIED },
- { LPGEN(LANG_ICON_FINISHED), ICON_FINISHED, IDI_FINISHED },
- { LPGEN(LANG_ICON_NOT_PRIVATE), ICON_NOT_PRIVATE, IDI_INSECURE },
- { LPGEN(LANG_ICON_REFRESH), ICON_REFRESH, IDI_REFRESH }
+IconItem iconList[ICON_MAXID] =
+{
+ { LPGEN("OTR"), "otr", IDI_OTR },
+ { LPGEN("OTR private"), "private", IDI_PRIVATE },
+ { LPGEN("OTR unverified"), "unverified", IDI_UNVERIFIED },
+ { LPGEN("OTR finished"), "finished", IDI_FINISHED },
+ { LPGEN("OTR not secure"), "not_private", IDI_INSECURE },
+ { LPGEN("Refresh"), "refresh", IDI_REFRESH }
};
void InitIcons()
{
- g_plugin.registerIcon("OTR", iconList);
+ g_plugin.registerIcon("OTR", iconList, MODULENAME);
}
diff --git a/plugins/MirOTR/src/icons.h b/plugins/MirOTR/src/icons.h
index a366517bdc..b094df5f58 100644
--- a/plugins/MirOTR/src/icons.h
+++ b/plugins/MirOTR/src/icons.h
@@ -1,9 +1,16 @@
#pragma once
-#define ICON_FINISHED (MODULENAME"_finished")
-#define ICON_UNVERIFIED (MODULENAME"_unverified")
-#define ICON_PRIVATE (MODULENAME"_private")
-#define ICON_NOT_PRIVATE (MODULENAME"_not_private")
-#define ICON_OTR (MODULENAME"_otr")
-#define ICON_REFRESH (MODULENAME"_refresh")
+
+enum
+{
+ ICON_OTR,
+ ICON_PRIVATE,
+ ICON_UNVERIFIED,
+ ICON_FINISHED,
+ ICON_NOT_PRIVATE,
+ ICON_REFRESH,
+ ICON_MAXID
+};
+
+extern IconItem iconList[ICON_MAXID];
void InitIcons();
diff --git a/plugins/MirOTR/src/language.h b/plugins/MirOTR/src/language.h
index b191f1ab30..e6b4da1bfe 100644
--- a/plugins/MirOTR/src/language.h
+++ b/plugins/MirOTR/src/language.h
@@ -39,13 +39,6 @@
#define LANG_FINGERPRINT_VERIFIED LPGENW("OTR encrypted session with '%s' is now using a VERIFIED fingerprint")
#define LANG_FINGERPRINT_NOT_VERIFIED LPGENW("OTR encrypted session with '%s' is now using a NOT VERIFIED fingerprint")
-#define LANG_ICON_UNVERIFIED LPGEN("OTR unverified")
-#define LANG_ICON_FINISHED LPGEN("OTR finished")
-#define LANG_ICON_PRIVATE LPGEN("OTR private")
-#define LANG_ICON_NOT_PRIVATE LPGEN("OTR not secure")
-#define LANG_ICON_OTR LPGEN("OTR")
-#define LANG_ICON_REFRESH LPGEN("Refresh")
-
#define LANG_GENERATE_KEY LPGENW("Generating new private key for protocol '%s'.\nPlease Wait...")
#define LANG_OPT_GENERAL LPGENW("General")
diff --git a/plugins/MirOTR/src/mirotrmenu.cpp b/plugins/MirOTR/src/mirotrmenu.cpp
index bffb67d743..8aaae58e2f 100644
--- a/plugins/MirOTR/src/mirotrmenu.cpp
+++ b/plugins/MirOTR/src/mirotrmenu.cpp
@@ -69,20 +69,20 @@ INT_PTR MirOTRMenuCheckService(WPARAM wParam, LPARAM)
switch (level) {
case TRUST_PRIVATE:
mir_snwprintf(text, L"%s [v%i]", TranslateW(LANG_STATUS_PRIVATE), context->protocol_version);
- Menu_ModifyItem(hStatusInfoItem, text, IcoLib_GetIconHandle(ICON_PRIVATE));
+ Menu_ModifyItem(hStatusInfoItem, text, iconList[ICON_PRIVATE].hIcolib);
break;
case TRUST_UNVERIFIED:
mir_snwprintf(text, L"%s [v%i]", TranslateW(LANG_STATUS_UNVERIFIED), context->protocol_version);
- Menu_ModifyItem(hStatusInfoItem, text, IcoLib_GetIconHandle(ICON_UNVERIFIED));
+ Menu_ModifyItem(hStatusInfoItem, text, iconList[ICON_UNVERIFIED].hIcolib);
break;
case TRUST_FINISHED:
- Menu_ModifyItem(hStatusInfoItem, TranslateW(LANG_STATUS_FINISHED), IcoLib_GetIconHandle(ICON_UNVERIFIED));
+ Menu_ModifyItem(hStatusInfoItem, TranslateW(LANG_STATUS_FINISHED), iconList[ICON_UNVERIFIED].hIcolib);
break;
default:
- Menu_ModifyItem(hStatusInfoItem, TranslateW(LANG_STATUS_DISABLED), IcoLib_GetIconHandle(ICON_NOT_PRIVATE));
+ Menu_ModifyItem(hStatusInfoItem, TranslateW(LANG_STATUS_DISABLED), iconList[ICON_NOT_PRIVATE].hIcolib);
}
}
else if (pcpp->MenuItemHandle == hHTMLConvMenuItem)
@@ -175,25 +175,25 @@ void InitMirOTRMenu(void)
mi.flags = CMIF_UNICODE | CMIF_NOTPRIVATE | CMIF_NOTUNVERIFIED;
mi.name.w = LANG_MENU_START;
mi.position = 100001;
- mi.hIcolibItem = IcoLib_GetIconHandle(ICON_UNVERIFIED);
+ mi.hIcolibItem = iconList[ICON_UNVERIFIED].hIcolib;
AddMirOTRMenuItem(&mi, MS_OTR_MENUSTART);
mi.flags = CMIF_UNICODE | CMIF_NOTNOTPRIVATE | CMIF_NOTFINISHED;
mi.name.w = LANG_MENU_REFRESH;
mi.position = 100002;
- mi.hIcolibItem = IcoLib_GetIconHandle(ICON_FINISHED);
+ mi.hIcolibItem = iconList[ICON_REFRESH].hIcolib;
AddMirOTRMenuItem(&mi, MS_OTR_MENUREFRESH);
mi.flags = CMIF_UNICODE | CMIF_NOTNOTPRIVATE;
mi.name.w = LANG_MENU_STOP;
mi.position = 100003;
- mi.hIcolibItem = IcoLib_GetIconHandle(ICON_NOT_PRIVATE);
+ mi.hIcolibItem = iconList[ICON_NOT_PRIVATE].hIcolib;
AddMirOTRMenuItem(&mi, MS_OTR_MENUSTOP);
mi.flags = CMIF_UNICODE | CMIF_NOTNOTPRIVATE | CMIF_NOTFINISHED;
mi.name.w = LANG_MENU_VERIFY;
mi.position = 200001;
- mi.hIcolibItem = IcoLib_GetIconHandle(ICON_PRIVATE);
+ mi.hIcolibItem = iconList[ICON_PRIVATE].hIcolib;
AddMirOTRMenuItem(&mi, MS_OTR_MENUVERIFY);
mi.flags = CMIF_UNICODE | CMIF_CHECKED;
diff --git a/plugins/MirOTR/src/otr.cpp b/plugins/MirOTR/src/otr.cpp
index bd0b7839be..edace0275d 100644
--- a/plugins/MirOTR/src/otr.cpp
+++ b/plugins/MirOTR/src/otr.cpp
@@ -55,7 +55,7 @@ INT_PTR CALLBACK GenKeyDlgBoxProc(HWND hWndDlg, UINT msg, WPARAM, LPARAM lParam)
return 0;
}
TranslateDialogDefault(hWndDlg);
- SetClassLongPtr(hWndDlg, GCLP_HICON, (LONG_PTR)IcoLib_GetIcon(ICON_OTR, 1));
+ SetClassLongPtr(hWndDlg, GCLP_HICON, (LONG_PTR)IcoLib_GetIconByHandle(iconList[ICON_OTR].hIcolib, 1));
wchar_t buff[256];
wchar_t *proto = mir_a2u((char*)lParam);
mir_snwprintf(buff, TranslateW(LANG_GENERATE_KEY), proto);
@@ -71,7 +71,6 @@ INT_PTR CALLBACK GenKeyDlgBoxProc(HWND hWndDlg, UINT msg, WPARAM, LPARAM lParam)
return TRUE;
case WM_DESTROY:
SetClassLongPtr(hWndDlg, GCLP_HICON, 0);
- IcoLib_Release(ICON_OTR, 1);
}
return FALSE;
}
diff --git a/plugins/MirOTR/src/svcs_menu.cpp b/plugins/MirOTR/src/svcs_menu.cpp
index c05fb30cdc..474d3d9dfe 100644
--- a/plugins/MirOTR/src/svcs_menu.cpp
+++ b/plugins/MirOTR/src/svcs_menu.cpp
@@ -163,13 +163,13 @@ void InitMenu()
SET_UID(mi, 0xAB574FAD, 0x15D8, 0x49FF, 0xB7, 0x03, 0xDA, 0x2B, 0x45, 0x46, 0xC3, 0x56);
mi.name.w = _A2W(LANG_STOP_OTR);
mi.pszService = MS_OTR_MENUSTOP;
- mi.hIcolibItem = IcoLib_GetIconHandle(ICON_PRIVATE);
+ mi.hIcolibItem = iconList[ICON_PRIVATE].hIcolib;
hStopItem = Menu_AddContactMenuItem(&mi);
mi.uid.d[7]++;
mi.name.w = _A2W(LANG_START_OTR);
mi.pszService = MS_OTR_MENUSTART;
- mi.hIcolibItem = IcoLib_GetIconHandle(ICON_NOT_PRIVATE);
+ mi.hIcolibItem = iconList[ICON_NOT_PRIVATE].hIcolib;
hStartItem = Menu_AddContactMenuItem(&mi);
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SVC_PrebuildContactMenu);
diff --git a/plugins/MirOTR/src/svcs_srmm.cpp b/plugins/MirOTR/src/svcs_srmm.cpp
index 34053374b2..c4855a842a 100644
--- a/plugins/MirOTR/src/svcs_srmm.cpp
+++ b/plugins/MirOTR/src/svcs_srmm.cpp
@@ -39,22 +39,22 @@ void SetEncryptionStatus(MCONTACT hContact, TrustLevel level)
case TRUST_FINISHED:
sid.flags = 0;
button.pwszTooltip = TranslateW(LANG_STATUS_FINISHED);
- button.hIcon = IcoLib_GetIconHandle(ICON_FINISHED);
+ button.hIcon = iconList[ICON_FINISHED].hIcolib;
break;
case TRUST_UNVERIFIED:
sid2.flags = MBF_DISABLED;
button.pwszTooltip = TranslateW(LANG_STATUS_UNVERIFIED);
- button.hIcon = IcoLib_GetIconHandle(ICON_UNVERIFIED);
+ button.hIcon = iconList[ICON_UNVERIFIED].hIcolib;
break;
case TRUST_PRIVATE:
sid2.flags = 0;
button.pwszTooltip = TranslateW(LANG_STATUS_PRIVATE);
- button.hIcon = IcoLib_GetIconHandle(ICON_PRIVATE);
+ button.hIcon = iconList[ICON_PRIVATE].hIcolib;
break;
default:
sid.flags = MBF_DISABLED;
button.pwszTooltip = TranslateW(LANG_STATUS_DISABLED);
- button.hIcon = IcoLib_GetIconHandle(ICON_NOT_PRIVATE);
+ button.hIcon = iconList[ICON_NOT_PRIVATE].hIcolib;
break;
}
button.bbbFlags = 0;
@@ -110,10 +110,10 @@ void InitSRMM()
// add icon to srmm status icons
InitMirOTRMenu();
- hIconNotSecure = IcoLib_GetIcon(ICON_NOT_PRIVATE, 0);
- hIconFinished = IcoLib_GetIcon(ICON_FINISHED, 0);
- hIconPrivate = IcoLib_GetIcon(ICON_PRIVATE, 0);
- hIconUnverified = IcoLib_GetIcon(ICON_UNVERIFIED, 0);
+ hIconNotSecure = IcoLib_GetIconByHandle(iconList[ICON_NOT_PRIVATE].hIcolib, 0);
+ hIconFinished = IcoLib_GetIconByHandle(iconList[ICON_FINISHED].hIcolib, 0);
+ hIconPrivate = IcoLib_GetIconByHandle(iconList[ICON_PRIVATE].hIcolib, 0);
+ hIconUnverified = IcoLib_GetIconByHandle(iconList[ICON_UNVERIFIED].hIcolib, 0);
StatusIconData sid = {};
sid.szModule = MODULENAME;
@@ -136,7 +136,7 @@ void InitSRMM()
OTRButton.dwDefPos = 200;
OTRButton.bbbFlags = BBBF_ISRSIDEBUTTON | BBBF_CANBEHIDDEN | BBBF_ISIMBUTTON;
OTRButton.pwszTooltip = TranslateT(LANG_OTR_TOOLTIP);
- OTRButton.hIcon = IcoLib_GetIconHandle(ICON_NOT_PRIVATE);
+ OTRButton.hIcon = iconList[ICON_NOT_PRIVATE].hIcolib;
HookEvent(ME_MSG_BUTTONPRESSED, SVC_ButtonsBarPressed);
@@ -145,10 +145,10 @@ void InitSRMM()
void DeinitSRMM()
{
- IcoLib_Release(ICON_NOT_PRIVATE, 0);
- IcoLib_Release(ICON_FINISHED, 0);
- IcoLib_Release(ICON_PRIVATE, 0);
- IcoLib_Release(ICON_UNVERIFIED, 0);
+ IcoLib_ReleaseIcon(hIconNotSecure);
+ IcoLib_ReleaseIcon(hIconFinished);
+ IcoLib_ReleaseIcon(hIconPrivate);
+ IcoLib_ReleaseIcon(hIconUnverified);
hIconNotSecure = hIconFinished = hIconPrivate = hIconUnverified =nullptr;
UninitMirOTRMenu();