summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-04-12 12:44:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-04-12 12:44:14 +0300
commit8469e07dd899482905b638c248200db6a7c16191 (patch)
treea527a0e733716cd046bf877f592094c5026394f4
parent402a9893b490b7865ab8bdc63791019a04993a23 (diff)
standard icolib management code added to CMPluginBase
-rw-r--r--include/newpluginapi.h6
-rw-r--r--libs/win32/mir_app.libbin189458 -> 190696 bytes
-rw-r--r--libs/win64/mir_app.libbin185326 -> 186598 bytes
-rw-r--r--src/mir_app/src/CMPluginBase.cpp28
-rw-r--r--src/mir_app/src/icolib.cpp3
-rw-r--r--src/mir_app/src/menu_utils.cpp2
-rw-r--r--src/mir_app/src/mir_app.def4
-rw-r--r--src/mir_app/src/mir_app64.def4
8 files changed, 45 insertions, 2 deletions
diff --git a/include/newpluginapi.h b/include/newpluginapi.h
index 32ed951999..f479f5f9f4 100644
--- a/include/newpluginapi.h
+++ b/include/newpluginapi.h
@@ -160,6 +160,7 @@ protected:
const char *m_szModuleName;
const PLUGININFOEX &m_pInfo;
HANDLE m_hLogger = nullptr;
+ LIST<void> m_arIcons;
CMPluginBase(const char *moduleName, const PLUGININFOEX &pInfo);
~CMPluginBase();
@@ -172,6 +173,11 @@ public:
void debugLogA(LPCSTR szFormat, ...);
void debugLogW(LPCWSTR wszFormat, ...);
+ __forceinline void addIcolib(HANDLE hIcolib) { m_arIcons.insert(hIcolib); }
+ HICON getIcon(int iconId);
+ HANDLE getIconHandle(int iconId);
+ void releaseIcon(int iconId);
+
__forceinline const PLUGININFOEX& getInfo() const { return m_pInfo; }
__forceinline const char* getModule() const { return m_szModuleName; }
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index a8eeec60e4..20744cd2aa 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index a6bc69ad41..550c19b1b8 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/src/mir_app/src/CMPluginBase.cpp b/src/mir_app/src/CMPluginBase.cpp
index 062d89471e..2b5fe51b29 100644
--- a/src/mir_app/src/CMPluginBase.cpp
+++ b/src/mir_app/src/CMPluginBase.cpp
@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "plugins.h"
+#include "IcoLib.h"
static int sttFakeID = -100;
@@ -111,9 +112,15 @@ EXTERN_C MIR_APP_DLL(void) UnregisterPlugin(CMPluginBase *pPlugin)
/////////////////////////////////////////////////////////////////////////////////////////
+static int CompareIcons(const void *p1, const void *p2)
+{
+ return ((IcolibItem*)p1)->default_indx - ((IcolibItem*)p2)->default_indx;
+}
+
CMPluginBase::CMPluginBase(const char *moduleName, const PLUGININFOEX &pInfo) :
m_szModuleName(moduleName),
- m_pInfo(pInfo)
+ m_pInfo(pInfo),
+ m_arIcons(10, CompareIcons)
{
if (m_hInst != nullptr)
g_arPlugins.insert(this);
@@ -272,6 +279,25 @@ void CMPluginBase::debugLogW(LPCWSTR wszFormat, ...)
/////////////////////////////////////////////////////////////////////////////////////////
+HICON CMPluginBase::getIcon(int iconId)
+{
+ return IcoLib_GetIconByHandle(getIconHandle(iconId));
+}
+
+HANDLE CMPluginBase::getIconHandle(int iconId)
+{
+ IcolibItem *p = (IcolibItem*)alloca(sizeof(IcolibItem));
+ p->default_indx = iconId;
+ return m_arIcons.find(p);
+}
+
+void CMPluginBase::releaseIcon(int iconId)
+{
+ IcoLib_ReleaseIcon(getIcon(iconId));
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CMPluginBase::RegisterProtocol(int type, pfnInitProto fnInit, pfnUninitProto fnUninit)
{
if (isPluginBanned(m_pInfo.uuid))
diff --git a/src/mir_app/src/icolib.cpp b/src/mir_app/src/icolib.cpp
index e8605688c4..6069202925 100644
--- a/src/mir_app/src/icolib.cpp
+++ b/src/mir_app/src/icolib.cpp
@@ -522,6 +522,9 @@ MIR_APP_DLL(HANDLE) IcoLib_AddIcon(const SKINICONDESC *sid, HPLUGIN pPlugin)
if (item->section)
item->section->flags = sid->flags & SIDF_SORTED;
+ if (pPlugin && item->default_indx)
+ ((CMPluginBase*)pPlugin)->addIcolib(item);
+
return item;
}
diff --git a/src/mir_app/src/menu_utils.cpp b/src/mir_app/src/menu_utils.cpp
index b2328884d0..56681136af 100644
--- a/src/mir_app/src/menu_utils.cpp
+++ b/src/mir_app/src/menu_utils.cpp
@@ -1240,7 +1240,7 @@ static int MO_RegisterIcon(TMO_IntMenuItem *pmi, void*)
sid.pszName = iconame;
sid.description.w = descr;
sid.hDefaultIcon = hIcon;
- pmi->hIcolibItem = IcoLib_AddIcon(&sid, 0);
+ pmi->hIcolibItem = IcoLib_AddIcon(&sid, pmi->mi.pPlugin);
Safe_DestroyIcon(hIcon);
if (hIcon = IcoLib_GetIcon(iconame)) {
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index b99133764f..2754e8aa53 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -675,3 +675,7 @@ Popup_Add @764
Popup_Change @765
Skin_GetProtoIcon @766
Srmm_SetIconFlags @767
+?addIcolib@CMPluginBase@@QAEXPAX@Z @768 NONAME
+?getIcon@CMPluginBase@@QAEPAUHICON__@@H@Z @769 NONAME
+?getIconHandle@CMPluginBase@@QAEPAXH@Z @770 NONAME
+?releaseIcon@CMPluginBase@@QAEXH@Z @771 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 9b8928ccae..dbb8284250 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -675,3 +675,7 @@ Popup_Add @764
Popup_Change @765
Skin_GetProtoIcon @766
Srmm_SetIconFlags @767
+?addIcolib@CMPluginBase@@QEAAXPEAX@Z @768 NONAME
+?getIcon@CMPluginBase@@QEAAPEAUHICON__@@H@Z @769 NONAME
+?getIconHandle@CMPluginBase@@QEAAPEAXH@Z @770 NONAME
+?releaseIcon@CMPluginBase@@QEAAXH@Z @771 NONAME