diff options
25 files changed, 243 insertions, 468 deletions
diff --git a/include/m_message.h b/include/m_message.h index c12b0150f4..3779eafe0b 100644 --- a/include/m_message.h +++ b/include/m_message.h @@ -24,6 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_MESSAGE_H__
#define M_MESSAGE_H__ 1
+#include <m_core.h>
+
+extern int hLangpack;
+
//brings up the send message dialog for a contact
//wParam = (WPARAM)(HANDLE)hContact
//lParam = (LPARAM)(char*)szText
@@ -151,15 +155,23 @@ typedef struct { int flags; // bitwize OR of MBCF_* flags above
} StatusIconClickData;
-// wParam = 0 (unused)
+// wParam = (int)hLangpack
// lParam = (StatusIconData *)&StatusIconData
-#define MS_MSG_ADDICON "MessageAPI/AddIcon"
+// #define MS_MSG_ADDICON "MessageAPI/AddIcon"
+
+__forceinline INT_PTR Srmm_AddIcon(StatusIconData *sid)
+{ return CallService("MessageAPI/AddIcon", hLangpack, (LPARAM)&sid);
+}
// wParam = 0 (unused)
// lParam = (StatusIconData *)&StatusIconData
// only szModule and szId are used
#define MS_MSG_REMOVEICON "MessageAPI/RemoveIcon"
+__forceinline void Srmm_RemoveIcon(StatusIconData *sid)
+{ CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
+}
+
// wParam = (HANDLE)hContact
// lParam = (StatusIconData *)&StatusIconData
// if hContact is null, icon is modified for all contacts
diff --git a/plugins/CountryFlags/src/extraimg.cpp b/plugins/CountryFlags/src/extraimg.cpp index 7da037909a..4300276f53 100644 --- a/plugins/CountryFlags/src/extraimg.cpp +++ b/plugins/CountryFlags/src/extraimg.cpp @@ -165,7 +165,7 @@ static void CALLBACK UpdateStatusIcons(LPARAM lParam) static int StatusIconsChanged(WPARAM wParam,LPARAM lParam)
{
- if (ServiceExists(MS_MSG_ADDICON))
+ if (ServiceExists(MS_MSG_MODIFYICON))
if ( db_get_b(NULL, MODULENAME, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT))
CallFunctionBuffered(UpdateStatusIcons, 0, FALSE, STATUSICON_REFRESHDELAY);
return 0;
@@ -184,7 +184,7 @@ static INT_PTR CALLBACK ExtraImgOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,L {
BOOL val;
/* Status Icon */
- if (ServiceExists(MS_MSG_ADDICON))
+ if (ServiceExists(MS_MSG_REMOVEICON))
val = db_get_b(NULL, MODULENAME, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT) != 0;
else
EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_SHOWSTATUSICONFLAG),val=FALSE);
@@ -266,7 +266,7 @@ static int ExtraImgSettingChanged(WPARAM wParam,LPARAM lParam) if (!lstrcmpA(dbcws->szSetting,"ShowStatusIconFlag") ||
!lstrcmpA(dbcws->szSetting,"UseUnknownFlag") ||
!lstrcmpA(dbcws->szSetting,"UseIpToCountry"))
- if (ServiceExists(MS_MSG_ADDICON))
+ if (ServiceExists(MS_MSG_REMOVEICON))
CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY);
}
}
@@ -277,7 +277,7 @@ static int ExtraImgSettingChanged(WPARAM wParam,LPARAM lParam) /* Extra Image */
SetExtraImage((HANDLE)wParam);
/* Status Icon */
- if (ServiceExists(MS_MSG_ADDICON))
+ if (ServiceExists(MS_MSG_REMOVEICON))
CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY);
}
return 0;
@@ -298,29 +298,19 @@ static int ExtraImgModulesLoaded(WPARAM wParam,LPARAM lParam) StatusIconData sid = { sizeof(sid) };
sid.szModule = MODULENAME; // dwID = 0
sid.flags = MBF_HIDDEN;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
/* Status Icon */
HookEvent(ME_MSG_WINDOWEVENT, MsgWndEvent);
return 0;
}
-static int ExtraImgShutdown(WPARAM, LPARAM)
-{
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = MODULENAME; // dwID = 0
- sid.flags = MBF_HIDDEN;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
- return 0;
-}
-
void InitExtraImg(void)
{
/* Services */
hServiceDetectContactOrigin = CreateServiceFunction(MS_FLAGS_DETECTCONTACTORIGINCOUNTRY,ServiceDetectContactOriginCountry);
/* Misc */
HookEvent(ME_SYSTEM_MODULESLOADED, ExtraImgModulesLoaded);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, ExtraImgShutdown);
/* Status icon */
HookEvent(ME_SKIN2_ICONSCHANGED,StatusIconsChanged);
/* Options */
diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp index 3abcf07a58..6f8d797111 100644 --- a/plugins/FavContacts/src/main.cpp +++ b/plugins/FavContacts/src/main.cpp @@ -144,18 +144,15 @@ int ProcessModulesLoaded(WPARAM wParam, LPARAM lParam) {
HookEvent(ME_TTB_MODULELOADED, ProcessTBLoaded);
- if (ServiceExists(MS_MSG_ADDICON)) {
- StatusIconData sid = {0};
- sid.cbSize = sizeof(sid);
- sid.szModule = "FavContacts";
- sid.szTooltip = "Favourite Contacts";
- sid.hIcon = Skin_GetIconByHandle(iconList[0].hIcolib);
- sid.hIconDisabled = Skin_GetIconByHandle(iconList[1].hIcolib);
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
-
- HookEvent(ME_MSG_ICONPRESSED, ProcessSrmmIconClick);
- HookEvent(ME_MSG_WINDOWEVENT, ProcessSrmmEvent);
- }
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = "FavContacts";
+ sid.szTooltip = "Favourite Contacts";
+ sid.hIcon = Skin_GetIconByHandle(iconList[0].hIcolib);
+ sid.hIconDisabled = Skin_GetIconByHandle(iconList[1].hIcolib);
+ Srmm_AddIcon(&sid);
+
+ HookEvent(ME_MSG_ICONPRESSED, ProcessSrmmIconClick);
+ HookEvent(ME_MSG_WINDOWEVENT, ProcessSrmmEvent);
/////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/FingerprintNG/src/fingerprint.cpp b/plugins/FingerprintNG/src/fingerprint.cpp index df1a7aca71..036c1eb7a2 100644 --- a/plugins/FingerprintNG/src/fingerprint.cpp +++ b/plugins/FingerprintNG/src/fingerprint.cpp @@ -1159,38 +1159,20 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) hExtraIcon = ExtraIcon_Register("Client", LPGEN("Fingerprint"), "client_Miranda_Unknown",
OnExtraIconListRebuild,OnExtraImageApply,OnExtraIconClick);
- if (db_get_b(NULL, MODULENAME, "StatusBarIcon", 1) && ServiceExists(MS_MSG_ADDICON)) {
+ if (db_get_b(NULL, MODULENAME, "StatusBarIcon", 1)) {
StatusIconData sid = { sizeof(sid) };
sid.szModule = MODULENAME;
sid.flags = MBF_HIDDEN;
sid.dwId = 1;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
}
return 0;
}
-/****************************************************************************************
-* OnPreShutdown
-* Drops all unused graphic stuff
-*/
-
-static int OnPreShutdown(WPARAM wParam, LPARAM lParam)
-{
- if (ServiceExists(MS_MSG_REMOVEICON)) {
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = MODULENAME;
- sid.dwId = 1;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
- }
-
- return 0;
-}
-
void InitFingerModule()
{
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown);
CreateServiceFunction(MS_FP_SAMECLIENTS, ServiceSameClientsA);
CreateServiceFunction(MS_FP_GETCLIENTICON, ServiceGetClientIconA);
diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp index 0e96e3ad6f..43518e17b2 100644 --- a/plugins/HistorySweeperLight/src/main.cpp +++ b/plugins/HistorySweeperLight/src/main.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. HINSTANCE hInst;
-static HANDLE hHooks[5];
int hLangpack;
static PLUGININFOEX pluginInfoEx =
@@ -85,37 +84,32 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) if (sweep == 0)
sid.szTooltip = Translate("Keep all events");
else if (sweep == 1)
- {
sid.szTooltip = Translate(time_stamp_strings[db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0)]);
- }
else if (sweep == 2)
- {
sid.szTooltip = Translate(keep_strings[db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0)]);
- }
else if (sweep == 3)
- {
sid.szTooltip = Translate("Delete all events");
- }
+
sid.flags = MBF_HIDDEN;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
sid.dwId = 1;
sid.hIcon = LoadIconEx("act1");
sid.szTooltip = Translate(time_stamp_strings[db_get_b(NULL, ModuleName, "StartupShutdownOlder", 0)]);
sid.flags = MBF_HIDDEN;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
sid.dwId = 2;
sid.hIcon = LoadIconEx("act2");
sid.szTooltip = Translate(keep_strings[db_get_b(NULL, ModuleName, "StartupShutdownKeep", 0)]);
sid.flags = MBF_HIDDEN;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
sid.dwId = 3;
sid.hIcon = LoadIconEx("actDel");
sid.szTooltip = Translate("Delete all events");
sid.flags = MBF_HIDDEN;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
// for new contacts
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
@@ -133,8 +127,8 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) }
}
- hHooks[2] = HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
- hHooks[3] = HookEvent(ME_MSG_ICONPRESSED, OnIconPressed);
+ HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
+ HookEvent(ME_MSG_ICONPRESSED, OnIconPressed);
return 0;
}
@@ -146,11 +140,10 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) int Load(void)
{
-
mir_getLP(&pluginInfoEx);
- hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
- hHooks[1] = HookEvent(ME_OPT_INITIALISE, HSOptInitialise);
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ HookEvent(ME_OPT_INITIALISE, HSOptInitialise);
InitIcons();
@@ -159,15 +152,6 @@ extern "C" __declspec(dllexport) int Load(void) extern "C" __declspec(dllexport) int Unload(void)
{
- int i;
-
ShutdownAction();
-
- for (i = 0; i < SIZEOF(hHooks); i++)
- {
- if (hHooks[i])
- UnhookEvent(hHooks[i]);
- }
-
return 0;
}
\ No newline at end of file diff --git a/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp b/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp index 030a534b28..cb73e3a448 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp @@ -251,12 +251,12 @@ void InitSRMM() { sid.hIconDisabled = hIconNotSecure;
sid.flags = MBF_DISABLED | MBF_HIDDEN;
sid.szTooltip = Translate(LANG_OTR_TOOLTIP);
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
sid.dwId = 1;
sid.hIcon = hIconPrivate;
sid.hIconDisabled = hIconUnverified;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
// hook the window events so that we can can change the status of the icon
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index 46a0aaa475..01bf91848c 100755 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -124,26 +124,21 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) if(!db_get_b(NULL, szGPGModuleName, "FirstRun", 1))
InitCheck();
InitIconLib();
- if(ServiceExists(MS_MSG_ADDICON))
- {
- HICON IconLibGetIcon(const char* ident);
- StatusIconData sid = {0};
- sid.cbSize = sizeof(sid);
- sid.szModule = szGPGModuleName;
- sid.flags = MBF_HIDDEN;
- sid.dwId = 0x00000001;
- sid.hIcon = IconLibGetIcon("secured");
- sid.szTooltip = Translate("GPG Turn off encryption");
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
- ZeroMemory(&sid, sizeof(sid));
- sid.cbSize = sizeof(sid);
- sid.szModule = szGPGModuleName;
- sid.flags = MBF_HIDDEN;
- sid.dwId = 0x00000002;
- sid.hIcon = IconLibGetIcon("unsecured");
- sid.szTooltip = Translate("GPG Turn on encryption");
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
- }
+
+ HICON IconLibGetIcon(const char* ident);
+
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = szGPGModuleName;
+ sid.flags = MBF_HIDDEN;
+ sid.dwId = 0x00000001;
+ sid.hIcon = IconLibGetIcon("secured");
+ sid.szTooltip = Translate("GPG Turn off encryption");
+ Srmm_AddIcon(&sid);
+
+ sid.dwId = 0x00000002;
+ sid.hIcon = IconLibGetIcon("unsecured");
+ sid.szTooltip = Translate("GPG Turn on encryption");
+ Srmm_AddIcon(&sid);
bMetaContacts = ServiceExists(MS_MC_GETMETACONTACT) != 0;
diff --git a/plugins/NoHistory/src/common.h b/plugins/NoHistory/src/common.h index d00d444593..549eaaddb0 100644 --- a/plugins/NoHistory/src/common.h +++ b/plugins/NoHistory/src/common.h @@ -31,8 +31,6 @@ extern HINSTANCE hInst; #endif
-
void SrmmMenu_Load();
-void SrmmMenu_Unload();
diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp index 1d8caa5cd8..0e7193c9b3 100644 --- a/plugins/NoHistory/src/dllmain.cpp +++ b/plugins/NoHistory/src/dllmain.cpp @@ -239,27 +239,22 @@ int IconPressed(WPARAM wParam, LPARAM lParam) // add icon to srmm status icons
void SrmmMenu_Load()
{
- if ( ServiceExists(MS_MSG_ADDICON)) {
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = MODULE;
- sid.flags = 0;
- sid.dwId = 0;
-
- sid.szTooltip = Translate("History Enabled");
- sid.hIcon = sid.hIconDisabled = hIconKeep;
-
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = MODULE;
- sid.dwId = 1;
- sid.szTooltip = Translate("History Disabled");
- sid.hIcon = sid.hIconDisabled = hIconRemove;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ sid.dwId = 0;
+ sid.szTooltip = Translate("History Enabled");
+ sid.hIcon = sid.hIconDisabled = hIconKeep;
+ Srmm_AddIcon(&sid);
+ sid.dwId = 1;
+ sid.szTooltip = Translate("History Disabled");
+ sid.hIcon = sid.hIconDisabled = hIconRemove;
+ Srmm_AddIcon(&sid);
- // hook the window events so that we can can change the status of the icon
- HookEvent(ME_MSG_WINDOWEVENT, WindowEvent);
- HookEvent(ME_MSG_ICONPRESSED, IconPressed);
- }
+ // hook the window events so that we can can change the status of the icon
+ HookEvent(ME_MSG_WINDOWEVENT, WindowEvent);
+ HookEvent(ME_MSG_ICONPRESSED, IconPressed);
}
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp index e7199dae36..8ec040ab6c 100644 --- a/plugins/Popup/src/main.cpp +++ b/plugins/Popup/src/main.cpp @@ -326,7 +326,6 @@ MIRAPI PLUGININFOEX* MirandaPluginInfoEx(DWORD) //called before the app goes into shutdown routine to make sure everyone is happy to exit
static int OkToExit(WPARAM, LPARAM)
{
- SrmmMenu_Unload();
closing = TRUE;
StopPopupThread();
return 0;
diff --git a/plugins/Popup/src/srmm_menu.cpp b/plugins/Popup/src/srmm_menu.cpp index 32f207e8c4..06456618cc 100644 --- a/plugins/Popup/src/srmm_menu.cpp +++ b/plugins/Popup/src/srmm_menu.cpp @@ -37,62 +37,37 @@ static int SrmmMenu_ProcessIconClick(WPARAM wParam, LPARAM lParam); void SrmmMenu_Load()
{
- if (ServiceExists(MS_MSG_ADDICON))
- {
- StatusIconData sid = {0};
- sid.cbSize = sizeof(sid);
- sid.szModule = MODULNAME;
- sid.flags = 0;
-
- sid.dwId = 0;
- sid.szTooltip = Translate("Popup Mode: Auto");
- sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_POPUP_ON,0);
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
-
- sid.dwId = 1;
- sid.szTooltip = Translate("Popup Mode: Favourite");
- sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_FAV,0);
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
-
- sid.dwId = 2;
- sid.szTooltip = Translate("Popup Mode: Ignore fullscreen");
- sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_FULLSCREEN,0);
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
-
- sid.dwId = 3;
- sid.szTooltip = Translate("Popup Mode: Block contact");
- sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_POPUP_OFF,0);
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
-
- HookEvent(ME_MSG_ICONPRESSED, SrmmMenu_ProcessIconClick);
- HookEvent(ME_MSG_WINDOWEVENT, SrmmMenu_ProcessEvent);
- }
-}
-
-void SrmmMenu_Unload()
-{
- if (ServiceExists(MS_MSG_REMOVEICON))
- {
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = MODULNAME;
-
- sid.dwId = 0;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
-
- sid.dwId = 1;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
-
- sid.dwId = 2;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = MODULNAME;
- sid.dwId = 3;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
- }
+ sid.dwId = 0;
+ sid.szTooltip = Translate("Popup Mode: Auto");
+ sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_POPUP_ON,0);
+ Srmm_AddIcon(&sid);
+
+ sid.dwId = 1;
+ sid.szTooltip = Translate("Popup Mode: Favourite");
+ sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_FAV,0);
+ Srmm_AddIcon(&sid);
+
+ sid.dwId = 2;
+ sid.szTooltip = Translate("Popup Mode: Ignore fullscreen");
+ sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_FULLSCREEN,0);
+ Srmm_AddIcon(&sid);
+
+ sid.dwId = 3;
+ sid.szTooltip = Translate("Popup Mode: Block contact");
+ sid.hIcon = sid.hIconDisabled = IcoLib_GetIcon(ICO_POPUP_OFF,0);
+ Srmm_AddIcon(&sid);
+
+ HookEvent(ME_MSG_ICONPRESSED, SrmmMenu_ProcessIconClick);
+ HookEvent(ME_MSG_WINDOWEVENT, SrmmMenu_ProcessEvent);
}
static void SrmmMenu_UpdateIcon(HANDLE hContact)
{
- if (!hContact) return;
+ if (!hContact)
+ return;
int mode = db_get_b(hContact, MODULNAME, "ShowMode", PU_SHOWMODE_AUTO);
@@ -100,8 +75,7 @@ static void SrmmMenu_UpdateIcon(HANDLE hContact) sid.cbSize = sizeof(sid);
sid.szModule = MODULNAME;
- for (int i=0; i < 4; ++i)
- {
+ for (int i=0; i < 4; ++i) {
sid.dwId = i;
sid.flags = (i == mode) ? 0 : MBF_HIDDEN;
CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
@@ -112,15 +86,14 @@ static int SrmmMenu_ProcessEvent(WPARAM, LPARAM lParam) {
MessageWindowEventData *mwevent = (MessageWindowEventData *)lParam;
- if ( mwevent->uType == MSG_WINDOW_EVT_OPEN )
- {
+ if (mwevent->uType == MSG_WINDOW_EVT_OPEN) {
if (!hDialogsList)
hDialogsList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
WindowList_Add(hDialogsList, mwevent->hwndWindow, mwevent->hContact);
SrmmMenu_UpdateIcon(mwevent->hContact);
}
- else if ( mwevent->uType == MSG_WINDOW_EVT_CLOSING )
+ else if (mwevent->uType == MSG_WINDOW_EVT_CLOSING)
{
if (hDialogsList)
WindowList_Remove(hDialogsList, mwevent->hwndWindow);
@@ -139,8 +112,7 @@ static int SrmmMenu_ProcessIconClick(WPARAM wParam, LPARAM lParam) int mode = db_get_b(hContact, MODULNAME, "ShowMode", PU_SHOWMODE_AUTO);
- if (sicd->flags&MBCF_RIGHTBUTTON)
- {
+ if (sicd->flags & MBCF_RIGHTBUTTON) {
HMENU hMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING, 1+PU_SHOWMODE_AUTO, TranslateT("Auto"));
@@ -157,8 +129,8 @@ static int SrmmMenu_ProcessIconClick(WPARAM wParam, LPARAM lParam) db_set_b(hContact, MODULNAME, "ShowMode", mode-1);
SrmmMenu_UpdateIcon(hContact);
}
- } else
- {
+ }
+ else {
db_set_b(hContact, MODULNAME, "ShowMode", (mode == PU_SHOWMODE_AUTO) ? PU_SHOWMODE_BLOCK : PU_SHOWMODE_AUTO);
SrmmMenu_UpdateIcon(hContact);
}
diff --git a/plugins/Popup/src/srmm_menu.h b/plugins/Popup/src/srmm_menu.h index c64d3b303c..67ea73cc12 100644 --- a/plugins/Popup/src/srmm_menu.h +++ b/plugins/Popup/src/srmm_menu.h @@ -25,6 +25,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __srmm_menu_h__
void SrmmMenu_Load();
-void SrmmMenu_Unload();
#endif // __srmm_menu_h__
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 26600238b0..7b58fba856 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -376,8 +376,7 @@ static void RegisterStatusIcons() sid.hIcon = CopyIcon(GetCachedIcon("scriver_TYPING"));
sid.hIconDisabled = CopyIcon(GetCachedIcon("scriver_TYPINGOFF"));
sid.flags = MBF_HIDDEN;
- sid.szTooltip = NULL;
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+ Srmm_AddIcon(&sid);
}
void ChangeStatusIcons()
diff --git a/plugins/Scriver/src/statusicon.cpp b/plugins/Scriver/src/statusicon.cpp index b530c3ebe3..a51cdd22d5 100644 --- a/plugins/Scriver/src/statusicon.cpp +++ b/plugins/Scriver/src/statusicon.cpp @@ -91,9 +91,8 @@ int DeinitStatusIcons() int GetStatusIconsCount(HANDLE hContact)
{
- StatusIconData *si;
int nIcon = 0;
- while ((si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon)) != NULL)
+ while ( CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon) != NULL)
nIcon++;
return nIcon;
}
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 00eb331a93..81c66f45fd 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -379,7 +379,6 @@ int onSystemOKToExit(WPARAM, LPARAM) free_rtfconv();
DeinitNetlib();
- DeinitSRMMIcons();
return 0;
}
diff --git a/plugins/SecureIM/src/svcs_srmm.cpp b/plugins/SecureIM/src/svcs_srmm.cpp index fd330367db..405206621a 100644 --- a/plugins/SecureIM/src/svcs_srmm.cpp +++ b/plugins/SecureIM/src/svcs_srmm.cpp @@ -32,62 +32,39 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) void InitSRMMIcons()
{
// add icon to srmm status icons
- if (ServiceExists(MS_MSG_ADDICON)) {
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = MODULENAME;
- sid.flags = MBF_DISABLED|MBF_HIDDEN;
- // Native
- sid.dwId = MODE_NATIVE;
- sid.hIcon = mode2icon(MODE_NATIVE|SECURED,3);
- sid.hIconDisabled = mode2icon(MODE_NATIVE,3);
- sid.szTooltip = Translate("SecureIM [Native]");
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
- // PGP
- sid.dwId = MODE_PGP;
- sid.hIcon = mode2icon(MODE_PGP|SECURED,3);
- sid.hIconDisabled = mode2icon(MODE_PGP,3);
- sid.szTooltip = Translate("SecureIM [PGP]");
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
- // GPG
- sid.dwId = MODE_GPG;
- sid.hIcon = mode2icon(MODE_GPG|SECURED,3);
- sid.hIconDisabled = mode2icon(MODE_GPG,3);
- sid.szTooltip = Translate("SecureIM [GPG]");
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
- // RSAAES
- sid.dwId = MODE_RSAAES;
- sid.hIcon = mode2icon(MODE_RSAAES|SECURED,3);
- sid.hIconDisabled = mode2icon(MODE_RSAAES,3);
- sid.szTooltip = Translate("SecureIM [RSA/AES]");
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
-
- // hook the window events so that we can can change the status of the icon
- HookEvent(ME_MSG_WINDOWEVENT, onWindowEvent);
- HookEvent(ME_MSG_ICONPRESSED, onIconPressed);
- }
-}
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = MODULENAME;
+ sid.flags = MBF_DISABLED|MBF_HIDDEN;
+ // Native
+ sid.dwId = MODE_NATIVE;
+ sid.hIcon = mode2icon(MODE_NATIVE|SECURED,3);
+ sid.hIconDisabled = mode2icon(MODE_NATIVE,3);
+ sid.szTooltip = Translate("SecureIM [Native]");
+ Srmm_AddIcon(&sid);
+ // PGP
+ sid.dwId = MODE_PGP;
+ sid.hIcon = mode2icon(MODE_PGP|SECURED,3);
+ sid.hIconDisabled = mode2icon(MODE_PGP,3);
+ sid.szTooltip = Translate("SecureIM [PGP]");
+ Srmm_AddIcon(&sid);
+ // GPG
+ sid.dwId = MODE_GPG;
+ sid.hIcon = mode2icon(MODE_GPG|SECURED,3);
+ sid.hIconDisabled = mode2icon(MODE_GPG,3);
+ sid.szTooltip = Translate("SecureIM [GPG]");
+ Srmm_AddIcon(&sid);
+ // RSAAES
+ sid.dwId = MODE_RSAAES;
+ sid.hIcon = mode2icon(MODE_RSAAES|SECURED,3);
+ sid.hIconDisabled = mode2icon(MODE_RSAAES,3);
+ sid.szTooltip = Translate("SecureIM [RSA/AES]");
+ Srmm_AddIcon(&sid);
-void DeinitSRMMIcons()
-{
- // remove srmm status icons
- if (ServiceExists(MS_MSG_REMOVEICON)) {
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = MODULENAME;
- // Native
- sid.dwId = MODE_NATIVE;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
- // PGP
- sid.dwId = MODE_PGP;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
- // GPG
- sid.dwId = MODE_GPG;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
- // RSAAES
- sid.dwId = MODE_RSAAES;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
- }
+ // hook the window events so that we can can change the status of the icon
+ HookEvent(ME_MSG_WINDOWEVENT, onWindowEvent);
+ HookEvent(ME_MSG_ICONPRESSED, onIconPressed);
}
// EOF
diff --git a/plugins/SecureIM/src/svcs_srmm.h b/plugins/SecureIM/src/svcs_srmm.h index 8334a4dd7d..8de1d07b98 100644 --- a/plugins/SecureIM/src/svcs_srmm.h +++ b/plugins/SecureIM/src/svcs_srmm.h @@ -2,6 +2,5 @@ #define __SVCS_SRMM_H__
void InitSRMMIcons();
-void DeinitSRMMIcons();
#endif
diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp index ef633af616..4e4782d740 100644 --- a/plugins/SpellChecker/src/spellchecker.cpp +++ b/plugins/SpellChecker/src/spellchecker.cpp @@ -98,12 +98,6 @@ static int IconsChanged(WPARAM wParam, LPARAM lParam) static int PreShutdown(WPARAM wParam, LPARAM lParam) { - if (ServiceExists(MS_MSG_REMOVEICON)) { - StatusIconData sid = { sizeof(sid) }; - sid.szModule = MODULE_NAME; - CallService(MS_MSG_REMOVEICON, 0, (LPARAM) &sid); - } - mir_free(dictionariesFolder); mir_free(customDictionariesFolder); mir_free(flagsDllFolder); @@ -211,30 +205,27 @@ static int ModulesLoaded(WPARAM wParam, LPARAM lParam) CreateServiceFunction(MS_SPELLCHECKER_REMOVE_RICHEDIT, RemoveContactTextBoxService); CreateServiceFunction(MS_SPELLCHECKER_SHOW_POPUP_MENU, ShowPopupMenuService); - if (ServiceExists(MS_MSG_ADDICON)) { - StatusIconData sid = { sizeof(sid) }; - sid.szModule = MODULE_NAME; - sid.hIconDisabled = Skin_GetIcon("spellchecker_disabled"); - sid.flags = MBF_HIDDEN; + StatusIconData sid = { sizeof(sid) }; + sid.szModule = MODULE_NAME; + sid.hIconDisabled = Skin_GetIcon("spellchecker_disabled"); + sid.flags = MBF_HIDDEN; - for (int i = 0; i < languages.getCount(); i++) { - sid.dwId = i; + for (int i = 0; i < languages.getCount(); i++) { + sid.dwId = i; - char tmp[128]; - mir_snprintf(tmp, SIZEOF(tmp), "%s - %S", - Translate("Spell Checker"), languages[i]->full_name); - sid.szTooltip = tmp; + char tmp[128]; + mir_snprintf(tmp, SIZEOF(tmp), "%s - %S", + Translate("Spell Checker"), languages[i]->full_name); + sid.szTooltip = tmp; - HICON hIcon = (opts.use_flags) ? Skin_GetIconByHandle(languages[i]->hIcolib) : Skin_GetIcon("spellchecker_enabled"); - sid.hIcon = CopyIcon(hIcon); - Skin_ReleaseIcon(hIcon); + HICON hIcon = (opts.use_flags) ? Skin_GetIconByHandle(languages[i]->hIcolib) : Skin_GetIcon("spellchecker_enabled"); + sid.hIcon = CopyIcon(hIcon); + Skin_ReleaseIcon(hIcon); - CallService(MS_MSG_ADDICON, 0, (LPARAM) &sid); - } + Srmm_AddIcon(&sid); } - HOTKEYDESC hkd = {0}; - hkd.cbSize = sizeof(hkd); + HOTKEYDESC hkd = { sizeof(hkd) }; hkd.pszName = "Spell Checker/Toggle"; hkd.pszSection = LPGEN("Spell Checker"); hkd.pszDescription = LPGEN("Enable/disable spell checker"); diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index 75cdf0f5cf..19375c7fb7 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -329,6 +329,12 @@ MsgWndData::MsgWndData(HWND hwnd, HANDLE hContact) { m_hwnd = hwnd;
m_hContact = hContact;
m_countryID = (int)ServiceDetectContactOriginCountry((WPARAM)m_hContact,0);
+
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = MODNAMEFLAGS;
+ sid.flags = MBF_HIDDEN;
+ Srmm_AddIcon(&sid);
+
FlagsIconUpdate();
}
@@ -344,8 +350,7 @@ void MsgWndData::FlagsIconSet() sid.szModule = MODNAMEFLAGS;
sid.hIconDisabled = sid.hIcon = LoadFlagIcon(m_countryID);
sid.szTooltip = Translate((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER,m_countryID,0));
- if(CallService(MS_MSG_MODIFYICON,(WPARAM)m_hContact,(LPARAM)&sid) !=0) /* not yet registered? */
- CallService(MS_MSG_ADDICON,0,(LPARAM)&sid);
+ CallService(MS_MSG_MODIFYICON, (WPARAM)m_hContact, (LPARAM)&sid);
}
}
@@ -369,7 +374,8 @@ static int CompareIconListData(const IconList* p1, const IconList* p2) }
static OBJLIST<IconList> gIListMW(10, CompareIconListData);
-IconList::IconList(StatusIconData *sid) {
+IconList::IconList(StatusIconData *sid)
+{
m_StatusIconData.cbSize = sid->cbSize;
m_StatusIconData.szModule = mir_strdup(sid->szModule);
m_StatusIconData.dwId = sid->dwId;
@@ -379,13 +385,15 @@ IconList::IconList(StatusIconData *sid) { m_StatusIconData.szTooltip = mir_strdup(sid->szTooltip);
m_ID = sid->dwId;
- CallService(MS_MSG_ADDICON,0,(LPARAM)sid);
+ Srmm_AddIcon(sid);
}
-IconList::~IconList() {
+IconList::~IconList()
+{
mir_free(m_StatusIconData.szModule);
mir_free(m_StatusIconData.szTooltip);
}
+
// const char *pszName; // [Optional] Name of an icon registered with icolib to be used in GUI.
static __inline int MessageAPI_AddIcon(const char* pszName, const char* szModul/*StatusIconData *sid*/,int ID, int flags, const char* szTooltip)
{
diff --git a/plugins/UserInfoEx/src/init.cpp b/plugins/UserInfoEx/src/init.cpp index cc4e12f945..d353c585a8 100644 --- a/plugins/UserInfoEx/src/init.cpp +++ b/plugins/UserInfoEx/src/init.cpp @@ -70,7 +70,7 @@ static int OnTopToolBarLoaded(WPARAM wParam, LPARAM lParam) static int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
myGlobals.PopUpActionsExist = ServiceExists(MS_POPUP_REGISTERACTIONS);
- myGlobals.MsgAddIconExist = ServiceExists(MS_MSG_ADDICON);
+ myGlobals.MsgAddIconExist = ServiceExists(MS_MSG_MODIFYICON);
// init meta contacts
INT_PTR ptr = CallService(MS_MC_GETPROTOCOLNAME, 0, 0);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 8f68e215aa..967176d71a 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -294,31 +294,24 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) JHookEvent(ME_GC_BUILDMENU, &CJabberProto::JabberGcMenuHook);
}
- if (ServiceExists(MS_MSG_ADDICON)) {
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = m_szModuleName;
- sid.hIcon = sid.hIconDisabled = LoadIconEx("main");
- sid.flags = MBF_HIDDEN;
- sid.szTooltip = Translate("Jabber Resource");
- CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
- Skin_ReleaseIcon(sid.hIcon);
-
- JHookEvent(ME_MSG_ICONPRESSED, &CJabberProto::OnProcessSrmmIconClick);
- JHookEvent(ME_MSG_WINDOWEVENT, &CJabberProto::OnProcessSrmmEvent);
-
- for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- MenuHideSrmmIcon(hContact);
- }
-
- DBEVENTTYPEDESCR dbEventType = {0};
- dbEventType.cbSize = sizeof(DBEVENTTYPEDESCR);
- dbEventType.eventType = JABBER_DB_EVENT_TYPE_CHATSTATES;
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = m_szModuleName;
+ sid.hIcon = sid.hIconDisabled = LoadIconEx("main");
+ sid.flags = MBF_HIDDEN;
+ sid.szTooltip = Translate("Jabber Resource");
+ Srmm_AddIcon(&sid);
+ Skin_ReleaseIcon(sid.hIcon);
+
+ JHookEvent(ME_MSG_ICONPRESSED, &CJabberProto::OnProcessSrmmIconClick);
+ JHookEvent(ME_MSG_WINDOWEVENT, &CJabberProto::OnProcessSrmmEvent);
+
+ DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) };
dbEventType.module = m_szModuleName;
+ dbEventType.eventType = JABBER_DB_EVENT_TYPE_CHATSTATES;
dbEventType.descr = "Chat state notifications";
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
dbEventType.eventType = JABBER_DB_EVENT_TYPE_PRESENCE;
- dbEventType.module = m_szModuleName;
dbEventType.descr = "Presence notifications";
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
@@ -378,11 +371,9 @@ int __cdecl CJabberProto::OnPreShutdown(WPARAM, LPARAM) m_sendManager.Shutdown();
ConsoleUninit();
- if (ServiceExists(MS_MSG_REMOVEICON)) {
- StatusIconData sid = { sizeof(sid) };
- sid.szModule = m_szModuleName;
- CallService(MS_MSG_REMOVEICON, 0, (LPARAM)&sid);
- }
+ StatusIconData sid = { sizeof(sid) };
+ sid.szModule = m_szModuleName;
+ Srmm_RemoveIcon(&sid);
return 0;
}
diff --git a/src/core/miranda.h b/src/core/miranda.h index fcb308dbc8..c34ea56ad1 100644 --- a/src/core/miranda.h +++ b/src/core/miranda.h @@ -140,6 +140,10 @@ extern HANDLE hOkToExitEvent, hModulesLoadedEvent, hevLoadModule, hevUnloadModul char* GetPluginNameByInstance(HINSTANCE hInstance);
int GetPluginFakeId(const MUUID &uuid, int hLangpack);
+/**** srmm.cpp *************************************************************************/
+
+void KillModuleSrmmIcons(int hLangpack);
+
/**** utf.cpp **************************************************************************/
__forceinline char* Utf8DecodeA(const char* src)
diff --git a/src/core/stdmsg/src/statusicon.cpp b/src/core/stdmsg/src/statusicon.cpp index 6dc1017b8f..68ad9d25d5 100644 --- a/src/core/stdmsg/src/statusicon.cpp +++ b/src/core/stdmsg/src/statusicon.cpp @@ -22,202 +22,74 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h"
#include "statusicon.h"
-struct StatusIconListNode {
- StatusIconData sid;
- struct StatusIconListNode *next;
-};
-
HANDLE hHookIconPressedEvt;
-struct StatusIconListNode *status_icon_list = 0;
-int status_icon_list_size = 0;
-
-INT_PTR AddStatusIcon(WPARAM wParam, LPARAM lParam) {
- StatusIconData *sid = (StatusIconData *)lParam;
- struct StatusIconListNode *siln = (struct StatusIconListNode *)mir_calloc(sizeof(struct StatusIconListNode));
-
- siln->sid.cbSize = sid->cbSize;
- siln->sid.szModule = mir_strdup(sid->szModule);
- siln->sid.dwId = sid->dwId;
- siln->sid.hIcon = sid->hIcon;
- siln->sid.hIconDisabled = sid->hIconDisabled;
- siln->sid.flags = sid->flags;
- if(sid->szTooltip) siln->sid.szTooltip = mir_strdup(sid->szTooltip);
- else siln->sid.szTooltip = 0;
-
- siln->next = status_icon_list;
- status_icon_list = siln;
- status_icon_list_size++;
-
- WindowList_Broadcast(g_dat.hMessageWindowList, DM_STATUSICONCHANGE, 0, 0);
- return 0;
-}
-
-INT_PTR RemoveStatusIcon(WPARAM wParam, LPARAM lParam) {
- StatusIconData *sid = (StatusIconData *)lParam;
- struct StatusIconListNode *current = status_icon_list, *prev = 0;
-
- while(current) {
- if(strcmp(current->sid.szModule, sid->szModule) == 0 && current->sid.dwId == sid->dwId) {
- if(prev) prev->next = current->next;
- else status_icon_list = current->next;
-
- status_icon_list_size--;
-
- mir_free(current->sid.szModule);
- DestroyIcon(current->sid.hIcon);
- if(current->sid.hIconDisabled) DestroyIcon(current->sid.hIconDisabled);
- mir_free(current->sid.szTooltip);
- mir_free(current);
- WindowList_Broadcast(g_dat.hMessageWindowList, DM_STATUSICONCHANGE, 0, 0);
- return 0;
- }
-
- prev = current;
- current = current->next;
- }
-
- return 1;
-}
-
-void RemoveAllStatusIcons(void) {
- struct StatusIconListNode *current;
-
- while(status_icon_list) {
- current = status_icon_list;
- status_icon_list = status_icon_list->next;
- status_icon_list_size--;
-
- mir_free(current->sid.szModule);
- DestroyIcon(current->sid.hIcon);
- if(current->sid.hIconDisabled) DestroyIcon(current->sid.hIconDisabled);
- if(current->sid.szTooltip) mir_free(current->sid.szTooltip);
- mir_free(current);
- }
- WindowList_Broadcast(g_dat.hMessageWindowList, DM_STATUSICONCHANGE, 0, 0);
-}
-
-INT_PTR ModifyStatusIcon(WPARAM wParam, LPARAM lParam) {
+static int OnSrmmIconChanged(WPARAM wParam, LPARAM)
+{
HANDLE hContact = (HANDLE)wParam;
-
- StatusIconData *sid = (StatusIconData *)lParam;
- struct StatusIconListNode *current = status_icon_list, *prev = 0;
-
- while(current) {
- if(strcmp(current->sid.szModule, sid->szModule) == 0 && current->sid.dwId == sid->dwId) {
- if (!hContact) {
- current->sid.flags = sid->flags;
- if(sid->hIcon) {
- DestroyIcon(current->sid.hIcon);
- current->sid.hIcon = sid->hIcon;
- }
- if(sid->hIconDisabled) {
- DestroyIcon(current->sid.hIconDisabled);
- current->sid.hIconDisabled = sid->hIconDisabled;
- }
- if(sid->szTooltip) {
- mir_free(current->sid.szTooltip);
- current->sid.szTooltip = mir_strdup(sid->szTooltip);
- }
-
- WindowList_Broadcast(g_dat.hMessageWindowList, DM_STATUSICONCHANGE, 0, 0);
- } else {
- char buff[256];
- HWND hwnd;
- sprintf(buff, "SRMMStatusIconFlags%d", sid->dwId);
- db_set_b(hContact, sid->szModule, buff, (BYTE)sid->flags);
- if (hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact)) {
- PostMessage(hwnd, DM_STATUSICONCHANGE, 0, 0);
- }
- }
- return 0;
- }
-
- current = current->next;
+ if (hContact == NULL)
+ WindowList_Broadcast(g_dat.hMessageWindowList, DM_STATUSICONCHANGE, 0, 0);
+ else {
+ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact);
+ if (hwnd != NULL)
+ PostMessage(GetParent(hwnd), DM_STATUSICONCHANGE, 0, 0);
}
-
- return 1;
+ return 0;
}
-void DrawStatusIcons(HANDLE hContact, HDC hDC, RECT r, int gap) {
- struct StatusIconListNode *current = status_icon_list;
+void DrawStatusIcons(HANDLE hContact, HDC hDC, RECT r, int gap)
+{
HICON hIcon;
- char buff[256];
- int flags;
int x = r.left;
- while(current && x < r.right) {
- sprintf(buff, "SRMMStatusIconFlags%d", current->sid.dwId);
- flags = db_get_b(hContact, current->sid.szModule, buff, current->sid.flags);
- if (!(flags & MBF_HIDDEN)) {
- if ((flags & MBF_DISABLED) && current->sid.hIconDisabled) hIcon = current->sid.hIconDisabled;
- else hIcon = current->sid.hIcon;
-
- SetBkMode(hDC, TRANSPARENT);
- DrawIconEx(hDC, x, (r.top + r.bottom - GetSystemMetrics(SM_CYSMICON)) >> 1, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
-
- x += GetSystemMetrics(SM_CYSMICON) + gap;
- }
- current = current->next;
- }
-}
-void CheckIconClick(HANDLE hContact, HWND hwndFrom, POINT pt, RECT r, int gap, int click_flags) {
- StatusIconClickData sicd;
- struct StatusIconListNode *current = status_icon_list;
- int iconNum = (pt.x - r.left) / (GetSystemMetrics(SM_CXSMICON) + gap);
- char buff[256];
- int flags;
-
- while(current && iconNum >= 0) {
- sprintf(buff, "SRMMStatusIconFlags%d", current->sid.dwId);
- flags = db_get_b(hContact, current->sid.szModule, buff, current->sid.flags);
- if (!(flags & MBF_HIDDEN)) iconNum--;
- if(iconNum >= 0)
- current = current->next;
- }
+ StatusIconData *sid;
+ int nIcon = 0;
+ while ((sid = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon++)) != NULL && x < r.right) {
+ if ((sid->flags & MBF_DISABLED) && sid->hIconDisabled) hIcon = sid->hIconDisabled;
+ else hIcon = sid->hIcon;
- if(current) {
- sicd.cbSize = sizeof(StatusIconClickData);
- ClientToScreen(hwndFrom, &pt);
- sicd.clickLocation = pt;
- sicd.dwId = current->sid.dwId;
- sicd.szModule = current->sid.szModule;
- sicd.flags = click_flags;
+ SetBkMode(hDC, TRANSPARENT);
+ DrawIconEx(hDC, x, (r.top + r.bottom - GetSystemMetrics(SM_CYSMICON)) >> 1, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
- NotifyEventHooks(hHookIconPressedEvt, (WPARAM)hContact, (LPARAM)&sicd);
+ x += GetSystemMetrics(SM_CYSMICON) + gap;
}
}
+void CheckIconClick(HANDLE hContact, HWND hwndFrom, POINT pt, RECT r, int gap, int click_flags)
+{
+ int iconNum = (pt.x - r.left) / (GetSystemMetrics(SM_CXSMICON) + gap);
+ StatusIconData *sid = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, iconNum);
+ if (sid == NULL)
+ return;
+
+ StatusIconClickData sicd = { sizeof(sicd) };
+ ClientToScreen(hwndFrom, &pt);
+ sicd.clickLocation = pt;
+ sicd.dwId = sid->dwId;
+ sicd.szModule = sid->szModule;
+ sicd.flags = click_flags;
+
+ NotifyEventHooks(hHookIconPressedEvt, (WPARAM)hContact, (LPARAM)&sicd);
+}
+
HANDLE hServiceIcon[3];
-int InitStatusIcons() {
- hServiceIcon[0] = CreateServiceFunction(MS_MSG_ADDICON, AddStatusIcon);
- hServiceIcon[1] = CreateServiceFunction(MS_MSG_REMOVEICON, RemoveStatusIcon);
- hServiceIcon[2] = CreateServiceFunction(MS_MSG_MODIFYICON, ModifyStatusIcon);
- hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED);
+int InitStatusIcons()
+{
+ hHookIconPressedEvt = CreateHookableEvent(ME_MSG_ICONPRESSED);
return 0;
}
-int DeinitStatusIcons() {
- int i;
+int DeinitStatusIcons()
+{
DestroyHookableEvent(hHookIconPressedEvt);
- for(i = 0; i < 3; i++) DestroyServiceFunction(hServiceIcon[i]);
- RemoveAllStatusIcons();
return 0;
}
-int GetStatusIconsCount(HANDLE hContact) {
- char buff[256];
- int count = 0;
- int flags;
- struct StatusIconListNode *current = status_icon_list;
- while(current) {
- sprintf(buff, "SRMMStatusIconFlags%d", (int)current->sid.dwId);
- flags = db_get_b(hContact, current->sid.szModule, buff, current->sid.flags);
- if (!(flags & MBF_HIDDEN)) {
- count ++;
- }
- current = current->next;
- }
- return count;
+int GetStatusIconsCount(HANDLE hContact)
+{
+ int nIcon = 0;
+ while ( CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon) != NULL)
+ nIcon++;
+ return nIcon;
}
diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 90ea348e59..dccf3fe780 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -366,6 +366,7 @@ int Plugin_UnloadDyn(pluginEntry *p) KillModuleHotkeys(hLangpack);
KillModuleSounds(hLangpack);
KillModuleExtraIcons(hLangpack);
+ KillModuleSrmmIcons(hLangpack);
}
NotifyEventHooks(hevUnloadModule, (WPARAM)p->bpi.pluginInfo, (LPARAM)p->bpi.hInst);
diff --git a/src/modules/srmm/statusicon.cpp b/src/modules/srmm/statusicon.cpp index dcf055a88f..ca5f526fac 100644 --- a/src/modules/srmm/statusicon.cpp +++ b/src/modules/srmm/statusicon.cpp @@ -49,6 +49,8 @@ struct StatusIconMain : public MZeroedObject }
StatusIconData sid;
+
+ int hPangpack;
OBJLIST<StatusIconChild> arChildren;
};
@@ -111,6 +113,7 @@ static INT_PTR AddStatusIcon(WPARAM wParam, LPARAM lParam) p = new StatusIconMain;
memcpy(&p->sid, sid, sizeof(p->sid));
+ p->hPangpack = (int)wParam;
p->sid.szModule = mir_strdup(sid->szModule);
p->sid.szTooltip = mir_strdup(sid->szTooltip);
arIcons.insert(p);
@@ -185,9 +188,18 @@ static int OnModulesLoaded(WPARAM, LPARAM) return 0;
}
+void KillModuleSrmmIcons(int hLangpack)
+{
+ for (int i=arIcons.getCount()-1; i >= 0; i--) {
+ StatusIconMain &p = arIcons[i];
+ if (p.hPangpack == hLangpack)
+ arIcons.remove(i);
+ }
+}
+
int LoadSrmmModule()
{
- CreateServiceFunction(MS_MSG_ADDICON, AddStatusIcon);
+ CreateServiceFunction("MessageAPI/AddIcon", AddStatusIcon);
CreateServiceFunction(MS_MSG_REMOVEICON, RemoveStatusIcon);
CreateServiceFunction(MS_MSG_MODIFYICON, ModifyStatusIcon);
CreateServiceFunction(MS_MSG_GETNTHICON, GetNthIcon);
|