summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_extraicons.h6
-rw-r--r--plugins/UserInfoEx/src/svc_email.cpp11
-rw-r--r--plugins/UserInfoEx/src/svc_gender.cpp10
-rw-r--r--plugins/UserInfoEx/src/svc_homepage.cpp10
-rw-r--r--plugins/UserInfoEx/src/svc_phone.cpp10
-rw-r--r--plugins/UserInfoEx/src/svc_reminder.cpp12
-rw-r--r--src/core/miranda.h4
-rw-r--r--src/modules/extraicons/BaseExtraIcon.h3
-rw-r--r--src/modules/extraicons/ExtraIcon.cpp2
-rw-r--r--src/modules/extraicons/ExtraIcon.h2
-rw-r--r--src/modules/extraicons/extraicons.cpp35
-rw-r--r--src/modules/extraicons/extraicons.h2
-rw-r--r--src/modules/extraicons/options_ei.cpp10
-rw-r--r--src/modules/plugins/newplugins.cpp1
14 files changed, 60 insertions, 58 deletions
diff --git a/include/m_extraicons.h b/include/m_extraicons.h
index 2d38fe7db4..add2858e02 100644
--- a/include/m_extraicons.h
+++ b/include/m_extraicons.h
@@ -139,6 +139,8 @@ typedef struct {
#ifndef _NO_WRAPPERS
#ifdef __cplusplus
+extern int hLangpack;
+
static HANDLE ExtraIcon_Register(
const char *name, const char *description, const char *descIcon,
MIRANDAHOOK RebuildIcons,
@@ -158,7 +160,7 @@ static HANDLE ExtraIcon_Register(
ei.OnClick = OnClick;
ei.onClickParam = onClickParam;
- return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, 0);
+ return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, hLangpack);
}
static HANDLE ExtraIcon_Register(
@@ -176,7 +178,7 @@ static HANDLE ExtraIcon_Register(
ei.OnClick = OnClick;
ei.onClickParam = onClickParam;
- return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, 0);
+ return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, hLangpack);
}
static int ExtraIcon_SetIcon(HANDLE hExtraIcon, HANDLE hContact, HANDLE hImage)
diff --git a/plugins/UserInfoEx/src/svc_email.cpp b/plugins/UserInfoEx/src/svc_email.cpp
index f0915e64fe..563d0dabf4 100644
--- a/plugins/UserInfoEx/src/svc_email.cpp
+++ b/plugins/UserInfoEx/src/svc_email.cpp
@@ -283,15 +283,8 @@ VOID SvcEMailEnableExtraIcons(BOOLEAN bEnable, BOOLEAN bUpdateDB)
if (hApplyIconHook == NULL)
hApplyIconHook = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, OnCListApplyIcons);
- if (ghExtraIconSvc == INVALID_HANDLE_VALUE) {
- EXTRAICON_INFO ico = { sizeof(ico) };
- ico.type = EXTRAICON_TYPE_ICOLIB;
- ico.name = "email"; //must be the same as the group name in extraicon
- ico.description= "E-mail (uinfoex)";
- ico.descIcon = ICO_BTN_EMAIL;
- ghExtraIconSvc = (HANDLE)CallService(MS_EXTRAICON_REGISTER, (WPARAM)&ico, 0);
- ZeroMemory(&ico,sizeof(ico));
- }
+ if (ghExtraIconSvc == INVALID_HANDLE_VALUE)
+ ghExtraIconSvc = ExtraIcon_Register("email", "E-mail (uinfoex)", ICO_BTN_EMAIL);
}
else { // E-mail uncheckt
if (hChangedHook) {
diff --git a/plugins/UserInfoEx/src/svc_gender.cpp b/plugins/UserInfoEx/src/svc_gender.cpp
index cf820a1ba4..7fe59908bd 100644
--- a/plugins/UserInfoEx/src/svc_gender.cpp
+++ b/plugins/UserInfoEx/src/svc_gender.cpp
@@ -141,14 +141,8 @@ VOID SvcGenderEnableExtraIcons(BYTE bColumn, BOOLEAN bUpdateDB)
DB::Setting::WriteByte(SET_CLIST_EXTRAICON_GENDER2, bColumn);
if (bEnable) { // Gender checkt or dropdown select
- if (ghExtraIconSvc == INVALID_HANDLE_VALUE) {
- EXTRAICON_INFO ico = { sizeof(ico) };
- ico.type = EXTRAICON_TYPE_ICOLIB;
- ico.name = "gender"; //must be the same as the group name in extraicon
- ico.description="Gender (uinfoex)";
- ico.descIcon = ICO_COMMON_MALE;
- ghExtraIconSvc = (HANDLE)CallService(MS_EXTRAICON_REGISTER, (WPARAM)&ico, 0);
- }
+ if (ghExtraIconSvc == INVALID_HANDLE_VALUE)
+ ghExtraIconSvc = ExtraIcon_Register("gender", "Gender (uinfoex)", ICO_COMMON_MALE);
// hook events
if (hChangedHook == NULL)
diff --git a/plugins/UserInfoEx/src/svc_homepage.cpp b/plugins/UserInfoEx/src/svc_homepage.cpp
index e5d31746f2..7364653d56 100644
--- a/plugins/UserInfoEx/src/svc_homepage.cpp
+++ b/plugins/UserInfoEx/src/svc_homepage.cpp
@@ -228,14 +228,8 @@ VOID SvcHomepageEnableExtraIcons(BOOLEAN bEnable, BOOLEAN bUpdateDB)
if (hApplyIconHook == NULL)
hApplyIconHook = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, (MIRANDAHOOK)OnCListApplyIcons);
- if (ghExtraIconSvc == INVALID_HANDLE_VALUE) {
- EXTRAICON_INFO ico = { sizeof(ico) };
- ico.type = EXTRAICON_TYPE_ICOLIB;
- ico.name = "homepage"; //must be the same as the group name in extraicon
- ico.description = "Homepage (uinfoex)";
- ico.descIcon = ICO_BTN_GOTO;
- ghExtraIconSvc = (HANDLE)CallService(MS_EXTRAICON_REGISTER, (WPARAM)&ico, 0);
- }
+ if (ghExtraIconSvc == INVALID_HANDLE_VALUE)
+ ghExtraIconSvc = ExtraIcon_Register("homepage", "Homepage (uinfoex)", ICO_BTN_GOTO);
}
else {
if (hChangedHook) {
diff --git a/plugins/UserInfoEx/src/svc_phone.cpp b/plugins/UserInfoEx/src/svc_phone.cpp
index 9490a563e9..303fb37bb6 100644
--- a/plugins/UserInfoEx/src/svc_phone.cpp
+++ b/plugins/UserInfoEx/src/svc_phone.cpp
@@ -173,14 +173,8 @@ VOID SvcPhoneEnableExtraIcons(BOOLEAN bEnable, BOOLEAN bUpdateDB)
if (hApplyIconHook == NULL)
hApplyIconHook = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, (MIRANDAHOOK)OnCListApplyIcons);
- if (ghExtraIconSvc == INVALID_HANDLE_VALUE) {
- EXTRAICON_INFO ico = { sizeof(ico) };
- ico.type = EXTRAICON_TYPE_ICOLIB;
- ico.name = "sms"; //must be the same as the group name in extraicon
- ico.description = "(uinfoex)";
- ico.descIcon = ICO_BTN_CELLULAR;
- ghExtraIconSvc = (HANDLE)CallService(MS_EXTRAICON_REGISTER, (WPARAM)&ico, 0);
- }
+ if (ghExtraIconSvc == INVALID_HANDLE_VALUE)
+ ghExtraIconSvc = ExtraIcon_Register("sms", "(uinfoex)", ICO_BTN_CELLULAR);
}
else {
if (hChangedHook) {
diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp
index 660d2de23e..a3cc8e63cd 100644
--- a/plugins/UserInfoEx/src/svc_reminder.cpp
+++ b/plugins/UserInfoEx/src/svc_reminder.cpp
@@ -968,15 +968,9 @@ VOID SvcReminderEnable(BOOLEAN bEnable)
{
if (bEnable) // Reminder is on
{
- if (ExtraIcon == INVALID_HANDLE_VALUE) {
- EXTRAICON_INFO ico = { sizeof(ico) };
- ico.type = EXTRAICON_TYPE_ICOLIB;
- ico.name = "Reminder";
- ico.description = "Reminder (uinfoex)";
- ico.descIcon = ICO_COMMON_ANNIVERSARY;
- ExtraIcon = (HANDLE)CallService(MS_EXTRAICON_REGISTER, (WPARAM)&ico, 0);
- ZeroMemory(&ico,sizeof(ico));
- }
+ if (ExtraIcon == INVALID_HANDLE_VALUE)
+ ExtraIcon = ExtraIcon_Register("Reminder", "Reminder (uinfoex)", ICO_COMMON_ANNIVERSARY);
+
// init hooks
if (!ghCListIA)
ghCListIA = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, (MIRANDAHOOK)OnCListApplyIcon);
diff --git a/src/core/miranda.h b/src/core/miranda.h
index 614c4aee98..49fbfa68ae 100644
--- a/src/core/miranda.h
+++ b/src/core/miranda.h
@@ -117,6 +117,10 @@ extern LIST<DATABASELINK> arDbPlugins;
int InitIni(void);
void UninitIni(void);
+/**** extraicons.cpp *******************************************************************/
+
+void KillModuleExtraIcons(int hLangpack);
+
/**** fontService.cpp ******************************************************************/
void KillModuleFonts(int hLangpack);
diff --git a/src/modules/extraicons/BaseExtraIcon.h b/src/modules/extraicons/BaseExtraIcon.h
index e382d0d3a9..3f5e15c986 100644
--- a/src/modules/extraicons/BaseExtraIcon.h
+++ b/src/modules/extraicons/BaseExtraIcon.h
@@ -25,8 +25,7 @@
class BaseExtraIcon : public ExtraIcon
{
public:
- BaseExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick,
- LPARAM param);
+ BaseExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param);
virtual ~BaseExtraIcon();
virtual int getID() const;
diff --git a/src/modules/extraicons/ExtraIcon.cpp b/src/modules/extraicons/ExtraIcon.cpp
index 50758a4056..3a2d7f4139 100644
--- a/src/modules/extraicons/ExtraIcon.cpp
+++ b/src/modules/extraicons/ExtraIcon.cpp
@@ -24,7 +24,7 @@
#include "extraicons.h"
ExtraIcon::ExtraIcon(const char *name) :
- name(name), slot(-1), position(1000)
+ name(name), slot(-1), position(1000), hLangpack(0)
{
}
diff --git a/src/modules/extraicons/ExtraIcon.h b/src/modules/extraicons/ExtraIcon.h
index 576b330dea..ae9e1ab797 100644
--- a/src/modules/extraicons/ExtraIcon.h
+++ b/src/modules/extraicons/ExtraIcon.h
@@ -64,6 +64,8 @@ public:
virtual int ClistSetExtraIcon(HANDLE hContact, HANDLE hImage) =0;
+ int hLangpack;
+
protected:
std::string name;
diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp
index 71565bb89a..c2d1cb1e1e 100644
--- a/src/modules/extraicons/extraicons.cpp
+++ b/src/modules/extraicons/extraicons.cpp
@@ -34,7 +34,9 @@
// Prototypes ///////////////////////////////////////////////////////////////////////////
-vector<BaseExtraIcon*> registeredExtraIcons;
+typedef vector<ExtraIcon*>::iterator IconIter;
+
+LIST<BaseExtraIcon> registeredExtraIcons(10);
vector<ExtraIcon*> extraIconsByHandle;
vector<ExtraIcon*> extraIconsBySlot;
@@ -59,6 +61,25 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
return 0;
}
+void KillModuleExtraIcons(int hLangpack)
+{
+ for (IconIter p1 = extraIconsByHandle.begin(); p1 != extraIconsByHandle.end(); p1++)
+ if ((*p1)->hLangpack == hLangpack)
+ extraIconsByHandle.erase(p1--);
+
+ for (IconIter p2 = extraIconsBySlot.begin(); p2 != extraIconsBySlot.end(); p2++)
+ if ((*p2)->hLangpack == hLangpack)
+ extraIconsBySlot.erase(p2--);
+
+ for (int i=registeredExtraIcons.getCount()-1; i >= 0; i--) {
+ BaseExtraIcon *p = registeredExtraIcons[i];
+ if (p->hLangpack == hLangpack) {
+ registeredExtraIcons.remove(i);
+ delete p;
+ }
+ }
+}
+
int PreShutdown(WPARAM wParam, LPARAM lParam)
{
DefaultExtraIcons_Unload();
@@ -122,7 +143,7 @@ ExtraIcon* GetExtraIconBySlot(int slot)
BaseExtraIcon* GetExtraIconByName(const char *name)
{
- for (unsigned int i = 0; i < registeredExtraIcons.size(); i++) {
+ for (int i=0; i < registeredExtraIcons.getCount(); i++) {
BaseExtraIcon *extra = registeredExtraIcons[i];
if (strcmp(name, extra->getName()) == 0)
return extra;
@@ -389,7 +410,7 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
return extra->getID();
}
- int id = (int)registeredExtraIcons.size() + 1;
+ int id = registeredExtraIcons.getCount() + 1;
switch (ei->type) {
case EXTRAICON_TYPE_CALLBACK:
@@ -414,7 +435,9 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
slot = -1;
extra->setSlot(slot);
- registeredExtraIcons.push_back(extra);
+ extra->hLangpack = (int)lParam;
+
+ registeredExtraIcons.insert(extra);
extraIconsByHandle.push_back(extra);
vector<ExtraIconGroup *> groups;
@@ -546,6 +569,8 @@ void LoadExtraIconsModule()
void UnloadExtraIconsModule(void)
{
- for (size_t i=0; i < registeredExtraIcons.size(); i++)
+ for (int i=0; i < registeredExtraIcons.getCount(); i++)
delete registeredExtraIcons[i];
+
+ registeredExtraIcons.destroy();
}
diff --git a/src/modules/extraicons/extraicons.h b/src/modules/extraicons/extraicons.h
index 2ee5982e9c..95807832e3 100644
--- a/src/modules/extraicons/extraicons.h
+++ b/src/modules/extraicons/extraicons.h
@@ -33,7 +33,7 @@ class ExtraIconGroup;
class ExtraIcon;
class BaseExtraIcon;
-extern vector<BaseExtraIcon*> registeredExtraIcons;
+extern LIST<BaseExtraIcon> registeredExtraIcons;
extern vector<ExtraIcon*> extraIconsByHandle;
extern vector<ExtraIcon*> extraIconsBySlot;
void RebuildListsBasedOnGroups(vector<ExtraIconGroup *> &groups);
diff --git a/src/modules/extraicons/options_ei.cpp b/src/modules/extraicons/options_ei.cpp
index 2d4e9fd7df..3a70169f98 100644
--- a/src/modules/extraicons/options_ei.cpp
+++ b/src/modules/extraicons/options_ei.cpp
@@ -419,7 +419,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
TranslateDialogDefault(hwndDlg);
{
int numSlots = GetNumberOfSlots();
- if (numSlots < (int)registeredExtraIcons.size()) {
+ if (numSlots < (int)registeredExtraIcons.getCount()) {
TCHAR txt[512];
mir_sntprintf(txt, SIZEOF(txt), TranslateT("* only the first %d icons will be shown"), numSlots);
@@ -439,7 +439,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
DestroyIcon(hDefaultIcon);
unsigned int i;
- for (i = 0; i < registeredExtraIcons.size(); i++) {
+ for (i = 0; i < registeredExtraIcons.getCount(); i++) {
ExtraIcon *extra = registeredExtraIcons[i];
HICON hIcon = Skin_GetIcon(extra->getDescIcon());
@@ -489,9 +489,9 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
HWND tree = GetDlgItem(hwndDlg, IDC_EXTRAORDER);
// Store old slots
- int *oldSlots = new int[registeredExtraIcons.size()];
+ int *oldSlots = new int[registeredExtraIcons.getCount()];
int lastUsedSlot = -1;
- for (i = 0; i < registeredExtraIcons.size(); i++) {
+ for (i = 0; i < registeredExtraIcons.getCount(); i++) {
if (extraIconsByHandle[i] == registeredExtraIcons[i])
oldSlots[i] = registeredExtraIcons[i]->getSlot();
else
@@ -549,7 +549,7 @@ static INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
}
// Store data
- for (i = 0; i < registeredExtraIcons.size(); i++) {
+ for (i = 0; i < registeredExtraIcons.getCount(); i++) {
BaseExtraIcon *extra = registeredExtraIcons[i];
char setting[512];
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp
index 753720efb1..c80db5c948 100644
--- a/src/modules/plugins/newplugins.cpp
+++ b/src/modules/plugins/newplugins.cpp
@@ -361,6 +361,7 @@ int Plugin_UnloadDyn(pluginEntry* p)
KillModuleIcons(hLangpack);
KillModuleHotkeys(hLangpack);
KillModuleSounds(hLangpack);
+ KillModuleExtraIcons(hLangpack);
}
Plugin_Uninit(p);