summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_message.h15
-rw-r--r--libs/win32/mir_app.libbin189220 -> 189458 bytes
-rw-r--r--libs/win64/mir_app.libbin185116 -> 185326 bytes
-rw-r--r--plugins/CountryFlags/src/extraimg.cpp49
-rw-r--r--plugins/FavContacts/src/services.cpp10
-rw-r--r--plugins/FingerprintNG/src/fingerprint.cpp12
-rw-r--r--plugins/HistorySweeperLight/src/historysweeperlight.cpp10
-rw-r--r--plugins/HistorySweeperLight/src/main.cpp32
-rw-r--r--plugins/HistorySweeperLight/src/options.cpp78
-rw-r--r--plugins/HistorySweeperLight/src/stdafx.h4
-rw-r--r--plugins/MessageState/src/messagestate.cpp20
-rw-r--r--plugins/MirOTR/src/svcs_srmm.cpp22
-rwxr-xr-xplugins/New_GPG/src/icons.cpp18
-rw-r--r--plugins/NoHistory/src/dllmain.cpp19
-rw-r--r--plugins/Popup/src/srmm_menu.cpp10
-rw-r--r--plugins/Scriver/src/chat_window.cpp4
-rw-r--r--plugins/Scriver/src/msgdialog.cpp23
-rw-r--r--plugins/Scriver/src/msgoptions.cpp1
-rw-r--r--plugins/Scriver/src/msgs.cpp11
-rw-r--r--plugins/Scriver/src/stdafx.h1
-rw-r--r--plugins/SecureIM/src/crypt_icons.cpp11
-rw-r--r--plugins/SpellChecker/src/spellchecker.cpp25
-rw-r--r--plugins/SpellChecker/src/utils.cpp11
-rw-r--r--plugins/UserInfoEx/src/Flags/svc_flags.cpp21
-rw-r--r--protocols/JabberG/src/jabber_menu.cpp9
-rw-r--r--src/mir_app/src/meta_services.cpp2
-rw-r--r--src/mir_app/src/meta_utils.cpp10
-rw-r--r--src/mir_app/src/metacontacts.h1
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/srmm_statusicon.cpp136
31 files changed, 219 insertions, 348 deletions
diff --git a/include/m_message.h b/include/m_message.h
index b4c2f3ca3d..d348b39ffa 100644
--- a/include/m_message.h
+++ b/include/m_message.h
@@ -165,15 +165,16 @@ EXTERN_C MIR_APP_DLL(int) Srmm_AddIcon(StatusIconData *sid, HPLUGIN pPlugin);
EXTERN_C MIR_APP_DLL(void) Srmm_RemoveIcon(const char *szProto, DWORD iconId);
// if hContact is null, icon is modified for all contacts
-// otherwise, only the flags field is valid
-// if either hIcon, hIconDisabled or szTooltip is null, they will not be modified
-EXTERN_C MIR_APP_DLL(int) Srmm_ModifyIcon(MCONTACT hContact, StatusIconData *sid);
+// if either hIcon or pwszTooltip is null, they will not be modified
+EXTERN_C MIR_APP_DLL(void) Srmm_ModifyIcon(MCONTACT hContact, const char *szModule, DWORD iconId, HICON hIcon, const wchar_t *pwszToolTip);
-// wParam = (HANDLE)hContact
-// lParam = (int)zero-based index of a visible icon
-// returns (StatusIconData*)icon description filled for the required contact
+// if hContact is null, flags are modified for all contacts
+EXTERN_C MIR_APP_DLL(void) Srmm_SetIconFlags(MCONTACT hContact, const char *szModule, DWORD iconId, int flags);
+
+// idx is zero-based index of a visible icon
+// returns (StatusIconData*)icon description filled for the required contact or NULL if there're no more icons
// don't free this memory.
-EXTERN_C MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index);
+EXTERN_C MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int idx);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// status icons click notification
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 44731ab588..a8eeec60e4 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 e91ada7d49..a6bc69ad41 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/CountryFlags/src/extraimg.cpp b/plugins/CountryFlags/src/extraimg.cpp
index 90f48993e6..cf52d9ecb2 100644
--- a/plugins/CountryFlags/src/extraimg.cpp
+++ b/plugins/CountryFlags/src/extraimg.cpp
@@ -49,7 +49,7 @@ static void CALLBACK SetExtraImage(MCONTACT hContact)
{
if (!bShowExtraIcon)
return;
-
+
int countryNumber = ServiceDetectContactOriginCountry(hContact, 0);
if (countryNumber == 0xFFFF && !bUseUnknown)
ExtraIcon_Clear(hExtraIcon, hContact);
@@ -87,48 +87,31 @@ void UpdateExtraImages()
#define STATUSICON_REFRESHDELAY 100 /* time for which setting changes are buffered */
// always call in context of main thread
-static void __fastcall SetStatusIcon(MCONTACT hContact,int countryNumber)
+static void __fastcall SetStatusIcon(MCONTACT hContact, int countryNumber)
{
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
-
- if (countryNumber != 0xFFFF || bUseUnknown) {
+ if (countryNumber != 0xFFFF || bUseUnknown)
/* copy icon as status icon API will call DestroyIcon() on it */
- sid.hIcon = LoadFlagIcon(countryNumber);
- sid.szTooltip.a = (char*) CallService(MS_UTILS_GETCOUNTRYBYNUMBER,countryNumber,0);
- }
- else sid.flags = MBF_HIDDEN;
-
- Srmm_ModifyIcon(hContact, &sid);
-
- if (sid.hIcon)
- IcoLib_ReleaseIcon(sid.hIcon);
-}
-
-// always call in context of main thread
-static void __fastcall UnsetStatusIcon(MCONTACT hContact)
-{
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.flags = MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
+ Srmm_ModifyIcon(hContact, MODULENAME, 0, LoadFlagIcon(countryNumber), _A2T((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, countryNumber, 0)));
+ else
+ Srmm_SetIconFlags(hContact, MODULENAME, 0, MBF_HIDDEN);
}
static int MsgWndEvent(WPARAM, LPARAM lParam)
{
- MessageWindowEventData *msgwe=(MessageWindowEventData*)lParam;
- switch(msgwe->uType) {
+ MessageWindowEventData *msgwe = (MessageWindowEventData*)lParam;
+ switch (msgwe->uType) {
case MSG_WINDOW_EVT_OPENING:
case MSG_WINDOW_EVT_CLOSE:
if (bShowStatusIcon) {
int countryNumber = ServiceDetectContactOriginCountry((WPARAM)msgwe->hContact, 0);
if (msgwe->uType == MSG_WINDOW_EVT_OPENING && countryNumber != 0xFFFF)
- SetStatusIcon(msgwe->hContact,countryNumber);
+ SetStatusIcon(msgwe->hContact, countryNumber);
else
- UnsetStatusIcon(msgwe->hContact);
+ Srmm_SetIconFlags(msgwe->hContact, MODULENAME, 0, MBF_HIDDEN);
}
- /* ensure it is hidden, RemoveStatusIcons() only enums currently opened ones */
- else UnsetStatusIcon(msgwe->hContact);
+ // ensure it is hidden, RemoveStatusIcons() only enums currently opened ones
+ else
+ Srmm_SetIconFlags(msgwe->hContact, MODULENAME, 0, MBF_HIDDEN);
}
return 0;
}
@@ -143,7 +126,7 @@ void CALLBACK UpdateStatusIcons(LPARAM)
int countryNumber = ServiceDetectContactOriginCountry(hContact, 0);
SetStatusIcon(hContact, countryNumber);
}
- else UnsetStatusIcon(hContact);
+ else Srmm_SetIconFlags(hContact, MODULENAME, 0, MBF_HIDDEN);
}
}
}
@@ -160,11 +143,11 @@ static int ExtraImgSettingChanged(WPARAM hContact, LPARAM lParam)
DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam;
if (hContact) {
/* user details update */
- if (!strcmp(dbcws->szSetting,"RealIP") || !strcmp(dbcws->szSetting,"Country") || !strcmp(dbcws->szSetting,"CompanyCountry")) {
+ if (!strcmp(dbcws->szSetting, "RealIP") || !strcmp(dbcws->szSetting, "Country") || !strcmp(dbcws->szSetting, "CompanyCountry")) {
/* Extra Image */
SetExtraImage(hContact);
/* Status Icon */
- CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY);
+ CallFunctionBuffered(UpdateStatusIcons, 0, FALSE, STATUSICON_REFRESHDELAY);
}
}
return 0;
diff --git a/plugins/FavContacts/src/services.cpp b/plugins/FavContacts/src/services.cpp
index b6f1f8d52b..82e448aa63 100644
--- a/plugins/FavContacts/src/services.cpp
+++ b/plugins/FavContacts/src/services.cpp
@@ -52,10 +52,7 @@ int ProcessSrmmEvent(WPARAM, LPARAM lParam)
WindowList_Add(hDialogsList, event->hwndWindow, event->hContact);
BYTE fav = g_plugin.getByte(event->hContact, "IsFavourite");
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.flags = fav ? 0 : MBF_DISABLED;
- Srmm_ModifyIcon(event->hContact, &sid);
+ Srmm_SetIconFlags(event->hContact, MODULENAME, 0, fav ? 0 : MBF_DISABLED);
if (event->hContact == hContactToActivate) {
HWND hwndRoot = event->hwndWindow;
@@ -94,10 +91,7 @@ int ProcessSrmmIconClick(WPARAM hContact, LPARAM lParam)
if (fav)
CallService(MS_AV_GETAVATARBITMAP, hContact, 0);
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.flags = fav ? 0 : MBF_DISABLED;
- Srmm_ModifyIcon(hContact, &sid);
+ Srmm_SetIconFlags(hContact, MODULENAME, 0, fav ? 0 : MBF_DISABLED);
}
else ShowMenu(false);
diff --git a/plugins/FingerprintNG/src/fingerprint.cpp b/plugins/FingerprintNG/src/fingerprint.cpp
index cc5d58d3f2..8ab34436fe 100644
--- a/plugins/FingerprintNG/src/fingerprint.cpp
+++ b/plugins/FingerprintNG/src/fingerprint.cpp
@@ -147,18 +147,10 @@ void RegisterIcons()
static void SetSrmmIcon(MCONTACT hContact, LPTSTR ptszMirver)
{
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.dwId = 1;
- sid.flags = MBF_UNICODE;
- sid.szTooltip.w = ptszMirver;
-
if (mir_wstrlen(ptszMirver))
- sid.hIcon = (HICON)ServiceGetClientIconW((WPARAM)ptszMirver, TRUE);
+ Srmm_ModifyIcon(hContact, MODULENAME, 1, (HICON)ServiceGetClientIconW((WPARAM)ptszMirver, TRUE), ptszMirver);
else
- sid.flags |= MBF_HIDDEN;
-
- Srmm_ModifyIcon(hContact, &sid);
+ Srmm_SetIconFlags(hContact, MODULENAME, 1, MBF_HIDDEN);
}
int __fastcall ApplyFingerprintImage(MCONTACT hContact, LPTSTR szMirVer)
diff --git a/plugins/HistorySweeperLight/src/historysweeperlight.cpp b/plugins/HistorySweeperLight/src/historysweeperlight.cpp
index 57a7e649b6..91c3478011 100644
--- a/plugins/HistorySweeperLight/src/historysweeperlight.cpp
+++ b/plugins/HistorySweeperLight/src/historysweeperlight.cpp
@@ -239,12 +239,6 @@ void SetSrmmIcon(MCONTACT hContact)
{
int sweep = g_plugin.getByte(hContact, "SweepHistory");
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
-
- for (int i = 0; i < 4; i++) {
- sid.dwId = i;
- sid.flags = (sweep == i) ? 0 : MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
- }
+ for (int i = 0; i < 4; i++)
+ Srmm_SetIconFlags(hContact, MODULENAME, i, (sweep == i) ? 0 : MBF_HIDDEN);
}
diff --git a/plugins/HistorySweeperLight/src/main.cpp b/plugins/HistorySweeperLight/src/main.cpp
index b33612d569..7d4ecd5311 100644
--- a/plugins/HistorySweeperLight/src/main.cpp
+++ b/plugins/HistorySweeperLight/src/main.cpp
@@ -53,19 +53,12 @@ static int OnIconPressed(WPARAM hContact, LPARAM lParam)
if (!(sicd->flags & MBCF_RIGHTBUTTON) && !mir_strcmp(sicd->szModule, MODULENAME) && g_plugin.getByte("ChangeInMW", 0)) {
int nh = sicd->dwId;
-
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.dwId = nh;
- sid.flags = MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
+ Srmm_SetIconFlags(hContact, MODULENAME, nh, MBF_HIDDEN);
nh = (nh + 1) % 4;
- g_plugin.setByte(hContact, "SweepHistory", (BYTE)nh);
- sid.dwId = nh;
- sid.flags = 0;
- Srmm_ModifyIcon(hContact, &sid);
+ g_plugin.setByte(hContact, "SweepHistory", (BYTE)nh);
+ Srmm_SetIconFlags(hContact, MODULENAME, nh, 0);
}
return 0;
}
@@ -79,33 +72,30 @@ static int OnModulesLoaded(WPARAM, LPARAM)
sid.hIcon = LoadIconEx("actG");
if (sweep == 0)
- sid.szTooltip.a = LPGEN("Keep all events");
+ sid.szTooltip.w = LPGENW("Keep all events");
else if (sweep == 1)
- sid.szTooltip.a = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)];
+ sid.szTooltip.w = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)];
else if (sweep == 2)
- sid.szTooltip.a = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)];
+ sid.szTooltip.w = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)];
else if (sweep == 3)
- sid.szTooltip.a = LPGEN("Delete all events");
+ sid.szTooltip.w = LPGENW("Delete all events");
- sid.flags = MBF_HIDDEN;
+ sid.flags = MBF_HIDDEN | MBF_UNICODE;
Srmm_AddIcon(&sid, &g_plugin);
sid.dwId = 1;
sid.hIcon = LoadIconEx("act1");
- sid.szTooltip.a = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)];
- sid.flags = MBF_HIDDEN;
+ sid.szTooltip.w = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)];
Srmm_AddIcon(&sid, &g_plugin);
sid.dwId = 2;
sid.hIcon = LoadIconEx("act2");
- sid.szTooltip.a = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)];
- sid.flags = MBF_HIDDEN;
+ sid.szTooltip.w = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)];
Srmm_AddIcon(&sid, &g_plugin);
sid.dwId = 3;
sid.hIcon = LoadIconEx("actDel");
- sid.szTooltip.a = LPGEN("Delete all events");
- sid.flags = MBF_HIDDEN;
+ sid.szTooltip.w = LPGENW("Delete all events");
Srmm_AddIcon(&sid, &g_plugin);
HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp
index 314cfb43d1..4dc71814f8 100644
--- a/plugins/HistorySweeperLight/src/options.cpp
+++ b/plugins/HistorySweeperLight/src/options.cpp
@@ -22,26 +22,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
// Time Stamps strings
-char* time_stamp_strings[] =
+wchar_t* time_stamp_strings[] =
{
- LPGEN("Delete older than 1 day"),
- LPGEN("Delete older than 3 days"),
- LPGEN("Delete older than 7 days"),
- LPGEN("Delete older than 2 weeks (14 days)"),
- LPGEN("Delete older than 1 month (30 days)"),
- LPGEN("Delete older than 3 months (90 days)"),
- LPGEN("Delete older than 6 months (180 days)"),
- LPGEN("Delete older than 1 year (365 days)")
+ LPGENW("Delete older than 1 day"),
+ LPGENW("Delete older than 3 days"),
+ LPGENW("Delete older than 7 days"),
+ LPGENW("Delete older than 2 weeks (14 days)"),
+ LPGENW("Delete older than 1 month (30 days)"),
+ LPGENW("Delete older than 3 months (90 days)"),
+ LPGENW("Delete older than 6 months (180 days)"),
+ LPGENW("Delete older than 1 year (365 days)")
};
-char* keep_strings[] =
+wchar_t* keep_strings[] =
{
- LPGEN("Keep 1 last event"),
- LPGEN("Keep 2 last events"),
- LPGEN("Keep 5 last events"),
- LPGEN("Keep 10 last events"),
- LPGEN("Keep 20 last events"),
- LPGEN("Keep 50 last events")
+ LPGENW("Keep 1 last event"),
+ LPGENW("Keep 2 last events"),
+ LPGENW("Keep 5 last events"),
+ LPGENW("Keep 10 last events"),
+ LPGENW("Keep 20 last events"),
+ LPGENW("Keep 50 last events")
};
static IconItem iconList[] =
@@ -75,7 +75,7 @@ HANDLE GetIconHandle(const char* name)
return nullptr;
}
-void ReleaseIconEx(const char* name)
+void ReleaseIconEx(const char* name)
{
char szSettingName[100];
mir_snprintf(szSettingName, "%s_%s", MODULENAME, name);
@@ -117,15 +117,11 @@ void LoadSettings(HWND hwndDlg)
SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_RESETCONTENT, 0, 0);
- for (auto &it : time_stamp_strings) {
- ptrW ptszTimeStr(Langpack_PcharToTchar(it));
- SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr);
- }
+ for (auto &it : time_stamp_strings)
+ SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
- for (auto &it : keep_strings) {
- ptrW ptszTimeStr(Langpack_PcharToTchar(it));
- SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr);
- }
+ for (auto &it : keep_strings)
+ SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_SETCURSEL, g_plugin.getByte("StartupShutdownOlder", 0), 0);
SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_SETCURSEL, g_plugin.getByte("StartupShutdownKeep", 0), 0);
@@ -164,25 +160,19 @@ void SaveSettings(HWND hwndDlg)
// set tooltips
int st = g_plugin.getByte("SweepHistory", 0);
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.dwId = 0;
- sid.hIcon = LoadIconEx("actG");
- if (st == 0) sid.szTooltip.a = LPGEN("Keep all events");
- else if (st == 1) sid.szTooltip.a = LPGEN(time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]);
- else if (st == 2) sid.szTooltip.a = LPGEN(keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]);
- else if (st == 3) sid.szTooltip.a = LPGEN("Delete all events");
- Srmm_ModifyIcon(NULL, &sid);
-
- sid.dwId = 1;
- sid.hIcon = LoadIconEx("act1");
- sid.szTooltip.a = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)];
- Srmm_ModifyIcon(NULL, &sid);
-
- sid.dwId = 2;
- sid.hIcon = LoadIconEx("act2");
- sid.szTooltip.a = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)];
- Srmm_ModifyIcon(NULL, &sid);
+ const wchar_t *pwszToolTip = nullptr;
+ if (st == 0)
+ pwszToolTip = LPGENW("Keep all events");
+ else if (st == 1)
+ pwszToolTip = time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)];
+ else if (st == 2)
+ pwszToolTip = keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)];
+ else if (st == 3)
+ pwszToolTip = LPGENW("Delete all events");
+ Srmm_ModifyIcon(NULL, MODULENAME, 0, nullptr, pwszToolTip);
+
+ Srmm_ModifyIcon(NULL, MODULENAME, 1, nullptr, time_stamp_strings[g_plugin.getByte("StartupShutdownOlder", 0)]);
+ Srmm_ModifyIcon(NULL, MODULENAME, 2, nullptr, keep_strings[g_plugin.getByte("StartupShutdownKeep", 0)]);
}
INT_PTR CALLBACK DlgProcHSOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
diff --git a/plugins/HistorySweeperLight/src/stdafx.h b/plugins/HistorySweeperLight/src/stdafx.h
index 5172588f6b..5d68a9c2bb 100644
--- a/plugins/HistorySweeperLight/src/stdafx.h
+++ b/plugins/HistorySweeperLight/src/stdafx.h
@@ -56,8 +56,8 @@ struct CMPlugin : public PLUGIN<CMPlugin>
extern LIST<void> g_hWindows;
// options.c
-extern char* time_stamp_strings[];
-extern char* keep_strings[];
+extern wchar_t* time_stamp_strings[];
+extern wchar_t* keep_strings[];
int HSOptInitialise(WPARAM wParam, LPARAM lParam);
void InitIcons(void);
void ReleaseIconEx(const char* name);
diff --git a/plugins/MessageState/src/messagestate.cpp b/plugins/MessageState/src/messagestate.cpp
index 0e52b1d5ad..10735e977c 100644
--- a/plugins/MessageState/src/messagestate.cpp
+++ b/plugins/MessageState/src/messagestate.cpp
@@ -19,11 +19,6 @@ const wchar_t* Tooltips[] =
void SetSRMMIcon(MCONTACT hContact, SRMM_ICON_TYPE type, time_t time)
{
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.dwId = 1;
- sid.flags = MBF_UNICODE;
-
MCONTACT hActualContact;
if (db_mc_isMeta(hContact))
hActualContact = db_mc_getSrmmSub(hContact);
@@ -31,21 +26,20 @@ void SetSRMMIcon(MCONTACT hContact, SRMM_ICON_TYPE type, time_t time)
hActualContact = hContact;
if (type != ICON_HIDDEN) {
- sid.hIcon = IcoLib_GetIconByHandle(Icons[type].hIcolib);
-
+ const wchar_t *pwszToolTip;
if (type == ICON_READ) {
if (g_plugin.getDword(hActualContact, DBKEY_MESSAGE_READ_TIME_TYPE, -1) == MRD_TYPE_READTIME) {
wchar_t buf[100];
wcsftime(buf, _countof(buf), TranslateT("Last message read at %X %x"), localtime(&time));
- sid.szTooltip.w = buf;
+ pwszToolTip = buf;
}
- else sid.szTooltip.w = TranslateT("Last message read (unknown time)");
+ else pwszToolTip = TranslateT("Last message read (unknown time)");
}
- else sid.szTooltip.w = TranslateW(Tooltips[type]);
+ else pwszToolTip = TranslateW(Tooltips[type]);
+
+ Srmm_ModifyIcon(hContact, MODULENAME, 1, IcoLib_GetIconByHandle(Icons[type].hIcolib), pwszToolTip);
}
- else sid.flags |= MBF_HIDDEN;
-
- Srmm_ModifyIcon(hContact, &sid);
+ else Srmm_SetIconFlags(hContact, MODULENAME, 1, MBF_HIDDEN);
}
int IconsUpdate(MCONTACT hContact)
diff --git a/plugins/MirOTR/src/svcs_srmm.cpp b/plugins/MirOTR/src/svcs_srmm.cpp
index 5e006e7841..1a4da8b146 100644
--- a/plugins/MirOTR/src/svcs_srmm.cpp
+++ b/plugins/MirOTR/src/svcs_srmm.cpp
@@ -24,35 +24,27 @@ void SetEncryptionStatus(MCONTACT hContact, TrustLevel level)
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0));
BBButton button = OTRButton;
-
- StatusIconData sid = {}, sid2 = {};
- sid.szModule = MODULENAME;
- sid.dwId = 0;
- sid.flags = MBF_HIDDEN;
-
- sid2.szModule = MODULENAME;
- sid2.dwId = 1;
- sid2.flags = MBF_HIDDEN;
+ int flags1 = MBF_HIDDEN, flags2 = MBF_HIDDEN;
if (!chat_room) {
switch (level) {
case TRUST_FINISHED:
- sid.flags = 0;
+ flags1 = 0;
button.pwszTooltip = TranslateW(LANG_STATUS_FINISHED);
button.hIcon = iconList[ICON_FINISHED].hIcolib;
break;
case TRUST_UNVERIFIED:
- sid2.flags = MBF_DISABLED;
+ flags2 = MBF_DISABLED;
button.pwszTooltip = TranslateW(LANG_STATUS_UNVERIFIED);
button.hIcon = iconList[ICON_UNVERIFIED].hIcolib;
break;
case TRUST_PRIVATE:
- sid2.flags = 0;
+ flags2 = 0;
button.pwszTooltip = TranslateW(LANG_STATUS_PRIVATE);
button.hIcon = iconList[ICON_PRIVATE].hIcolib;
break;
default:
- sid.flags = MBF_DISABLED;
+ flags1 = MBF_DISABLED;
button.pwszTooltip = TranslateW(LANG_STATUS_DISABLED);
button.hIcon = iconList[ICON_NOT_PRIVATE].hIcolib;
break;
@@ -61,8 +53,8 @@ void SetEncryptionStatus(MCONTACT hContact, TrustLevel level)
}
else button.bbbFlags = BBSF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
- Srmm_ModifyIcon(hContact, &sid2);
+ Srmm_SetIconFlags(hContact, MODULENAME, 0, flags1);
+ Srmm_SetIconFlags(hContact, MODULENAME, 1, flags2);
Srmm_SetButtonState(hContact, &button);
g_plugin.setDword(hContact, "TrustLevel", level);
diff --git a/plugins/New_GPG/src/icons.cpp b/plugins/New_GPG/src/icons.cpp
index 31cd5ff2fa..6b3268e732 100755
--- a/plugins/New_GPG/src/icons.cpp
+++ b/plugins/New_GPG/src/icons.cpp
@@ -48,21 +48,15 @@ void setSrmmIcon(MCONTACT h)
bool enabled = isContactSecured(hContact);
MCONTACT hMC = db_mc_tryMeta(hContact);
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.hIcon = IcoLib_GetIcon("secured");
- sid.dwId = 1;
- sid.flags = enabled ? 0 : MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
+ int flags = enabled ? 0 : MBF_HIDDEN;
+ Srmm_SetIconFlags(hContact, MODULENAME, 1, flags);
if (hMC != hContact)
- Srmm_ModifyIcon(hMC, &sid);
+ Srmm_SetIconFlags(hMC, MODULENAME, 1, flags);
- sid.hIcon = IcoLib_GetIcon("unsecured");
- sid.dwId = 2;
- sid.flags = enabled ? MBF_HIDDEN : 0;
- Srmm_ModifyIcon(hContact, &sid);
+ flags = enabled ? MBF_HIDDEN : 0;
+ Srmm_SetIconFlags(hContact, MODULENAME, 2, flags);
if (hMC != hContact)
- Srmm_ModifyIcon(hMC, &sid);
+ Srmm_SetIconFlags(hMC, MODULENAME, 2, flags);
}
void RefreshContactListIcons()
diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp
index 4197106333..08412fae4f 100644
--- a/plugins/NoHistory/src/dllmain.cpp
+++ b/plugins/NoHistory/src/dllmain.cpp
@@ -157,14 +157,8 @@ INT_PTR ServiceToggle(WPARAM hContact, LPARAM)
remove = !remove;
g_plugin.setByte(hContact, DBSETTING_REMOVE, remove != 0);
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
-
- for (int i = 0; i < 2; ++i) {
- sid.dwId = i;
- sid.flags = (i == remove) ? 0 : MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
- }
+ for (int i = 0; i < 2; ++i)
+ Srmm_SetIconFlags(hContact, MODULENAME, i, (i == remove) ? 0 : MBF_HIDDEN);
return 0;
}
@@ -183,13 +177,8 @@ int WindowEvent(WPARAM, LPARAM lParam)
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
int remove = g_plugin.getByte(hContact, DBSETTING_REMOVE) != 0;
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- for (int i=0; i < 2; ++i) {
- sid.dwId = i;
- sid.flags = (chat_room ? MBF_HIDDEN : (i == remove) ? 0 : MBF_HIDDEN);
- Srmm_ModifyIcon(hContact, &sid);
- }
+ for (int i = 0; i < 2; ++i)
+ Srmm_SetIconFlags(hContact, MODULENAME, i, chat_room ? MBF_HIDDEN : (i == remove) ? 0 : MBF_HIDDEN);
}
return 0;
diff --git a/plugins/Popup/src/srmm_menu.cpp b/plugins/Popup/src/srmm_menu.cpp
index a506c82e1c..885bb4fa38 100644
--- a/plugins/Popup/src/srmm_menu.cpp
+++ b/plugins/Popup/src/srmm_menu.cpp
@@ -38,14 +38,8 @@ static void SrmmMenu_UpdateIcon(MCONTACT hContact)
int mode = g_plugin.getByte(hContact, "ShowMode", PU_SHOWMODE_AUTO);
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
-
- for (int i = 0; i < 4; i++) {
- sid.dwId = i;
- sid.flags = (i == mode) ? 0 : MBF_HIDDEN;
- Srmm_ModifyIcon(hContact, &sid);
- }
+ for (int i = 0; i < 4; i++)
+ Srmm_SetIconFlags(hContact, MODULENAME, i, (i == mode) ? 0 : MBF_HIDDEN);
}
static int SrmmMenu_ProcessEvent(WPARAM, LPARAM lParam)
diff --git a/plugins/Scriver/src/chat_window.cpp b/plugins/Scriver/src/chat_window.cpp
index 9b2384c485..d3b8863594 100644
--- a/plugins/Scriver/src/chat_window.cpp
+++ b/plugins/Scriver/src/chat_window.cpp
@@ -515,9 +515,7 @@ void CChatRoomDlg::UpdateStatusBar()
sbd.pszText = L"";
SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
- StatusIconData sid = {};
- sid.szModule = SRMM_MODULE;
- Srmm_ModifyIcon(m_hContact, &sid);
+ Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 0, 0);
}
void CChatRoomDlg::UpdateTitle()
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 2abee8259e..91db9a165a 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -769,17 +769,13 @@ void CSrmmWindow::UpdateStatusBar()
SendMessage(m_hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)m_hwnd);
UpdateReadChars();
- StatusIconData sid = {};
- sid.szModule = SRMM_MODULE;
- sid.flags = MBF_DISABLED;
- Srmm_ModifyIcon(m_hContact, &sid);
- sid.dwId = 1;
- if (IsTypingNotificationSupported() && g_dat.flags2 & SMF2_SHOWTYPINGSWITCH)
- sid.flags = (g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.getByte(SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW))) ? 0 : MBF_DISABLED;
- else
- sid.flags = MBF_HIDDEN;
+ Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 0, MBF_DISABLED);
- Srmm_ModifyIcon(m_hContact, &sid);
+ if (IsTypingNotificationSupported() && g_dat.flags2 & SMF2_SHOWTYPINGSWITCH) {
+ int mode = g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.getByte(SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW));
+ Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 1, mode ? 0 : MBF_DISABLED);
+ }
+ else Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 1, MBF_HIDDEN);
}
}
@@ -1273,14 +1269,9 @@ INT_PTR CSrmmWindow::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case DM_SWITCHTYPING:
if (IsTypingNotificationSupported()) {
- StatusIconData sid = {};
- sid.szModule = SRMM_MODULE;
- sid.dwId = 1;
-
BYTE typingNotify = (g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.getByte(SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW)));
g_plugin.setByte(m_hContact, SRMSGSET_TYPING, (BYTE)!typingNotify);
- sid.flags = typingNotify ? MBF_DISABLED : 0;
- Srmm_ModifyIcon(m_hContact, &sid);
+ Srmm_SetIconFlags(m_hContact, SRMM_MODULE, 1, typingNotify ? MBF_DISABLED : 0);
}
break;
diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp
index 6f2ec42c36..393ecddc0c 100644
--- a/plugins/Scriver/src/msgoptions.cpp
+++ b/plugins/Scriver/src/msgoptions.cpp
@@ -130,7 +130,6 @@ int IconsChanged(WPARAM, LPARAM)
LoadGlobalIcons();
FreeMsgLogIcons();
LoadMsgLogIcons();
- ChangeStatusIcons();
Srmm_Broadcast(DM_REMAKELOG, 0, 0);
Srmm_Broadcast(DM_CHANGEICONS, 0, 1);
return 0;
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp
index 9913193237..8355dc8868 100644
--- a/plugins/Scriver/src/msgs.cpp
+++ b/plugins/Scriver/src/msgs.cpp
@@ -408,17 +408,6 @@ static void RegisterStatusIcons()
Srmm_AddIcon(&sid, &g_plugin);
}
-void ChangeStatusIcons()
-{
- StatusIconData sid = {};
- sid.szModule = SRMM_MODULE;
- sid.dwId = 1;
- sid.hIcon = GetCachedIcon("scriver_TYPING");
- sid.hIconDisabled = GetCachedIcon("scriver_TYPINGOFF");
- sid.flags = MBF_HIDDEN;
- Srmm_ModifyIcon(0, &sid);
-}
-
int StatusIconPressed(WPARAM wParam, LPARAM lParam)
{
StatusIconClickData *sicd = (StatusIconClickData *) lParam;
diff --git a/plugins/Scriver/src/stdafx.h b/plugins/Scriver/src/stdafx.h
index e1ae6b4b96..ad8cc20feb 100644
--- a/plugins/Scriver/src/stdafx.h
+++ b/plugins/Scriver/src/stdafx.h
@@ -98,7 +98,6 @@ struct CMPlugin : public PLUGIN<CMPlugin>
extern HCURSOR hDragCursor;
extern ITaskbarList3 *pTaskbarInterface;
-void ChangeStatusIcons();
void LoadInfobarFonts();
#define SPLITTER_HEIGHT 4
diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp
index 2d08e017e7..bed0d48ad4 100644
--- a/plugins/SecureIM/src/crypt_icons.cpp
+++ b/plugins/SecureIM/src/crypt_icons.cpp
@@ -79,16 +79,13 @@ void ShowStatusIcon(MCONTACT hContact, int mode)
ExtraIcon_Clear(g_hCLIcon, hMC);
}
- StatusIconData sid = {};
- sid.szModule = (char*)MODULENAME;
for (int i = MODE_NATIVE; i < MODE_CNT; i++) {
- sid.dwId = i;
- sid.flags = (mode & SECURED) ? 0 : MBF_DISABLED;
+ int flags = (mode & SECURED) ? 0 : MBF_DISABLED;
if (mode == -1 || (mode & 0x0f) != i || isChatRoom(hContact))
- sid.flags |= MBF_HIDDEN; // отключаем все ненужные иконки
- Srmm_ModifyIcon(hContact, &sid);
+ flags |= MBF_HIDDEN; // отключаем все ненужные иконки
+ Srmm_SetIconFlags(hContact, MODULENAME, i, flags);
if (hMC)
- Srmm_ModifyIcon(hMC, &sid);
+ Srmm_SetIconFlags(hMC, MODULENAME, i, flags);
}
}
diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp
index 0d99fb96b6..3a1c9eaea1 100644
--- a/plugins/SpellChecker/src/spellchecker.cpp
+++ b/plugins/SpellChecker/src/spellchecker.cpp
@@ -62,30 +62,6 @@ CMPlugin::CMPlugin() :
// Functions ////////////////////////////////////////////////////////////////////////////
-static int IconsChanged(WPARAM, LPARAM)
-{
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
- sid.hIconDisabled = IcoLib_GetIcon("spellchecker_disabled");
- sid.flags = MBF_HIDDEN | MBF_UNICODE;
-
- for (int i = 0; i < languages.getCount(); i++) {
- sid.dwId = i;
-
- wchar_t tmp[128];
- mir_snwprintf(tmp, L"%s - %s", TranslateT("Spell Checker"), languages[i]->full_name);
- sid.szTooltip.w = tmp;
-
- HICON hIcon = (opts.use_flags) ? IcoLib_GetIconByHandle(languages[i]->hIcolib) : IcoLib_GetIcon("spellchecker_enabled");
- sid.hIcon = CopyIcon(hIcon);
- IcoLib_ReleaseIcon(hIcon);
-
- Srmm_ModifyIcon(NULL, &sid);
- }
-
- return 0;
-}
-
static int PreShutdown(WPARAM, LPARAM)
{
mir_free(dictionariesFolder);
@@ -179,7 +155,6 @@ static int ModulesLoaded(WPARAM, LPARAM)
dict->load();
}
- HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
HookEvent(ME_MSG_WINDOWEVENT, MsgWindowEvent);
HookEvent(ME_MSG_WINDOWPOPUP, MsgWindowPopup);
HookEvent(ME_MSG_ICONPRESSED, IconPressed);
diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp
index fc8a83365e..017dcb09c2 100644
--- a/plugins/SpellChecker/src/utils.cpp
+++ b/plugins/SpellChecker/src/utils.cpp
@@ -814,18 +814,11 @@ void GetContactLanguage(Dialog *dlg)
void ModifyIcon(Dialog *dlg)
{
- StatusIconData sid = {};
- sid.szModule = MODULENAME;
-
for (int i = 0; i < languages.getCount(); i++) {
- sid.dwId = i;
-
if (languages[i] == dlg->lang)
- sid.flags = (dlg->enabled ? 0 : MBF_DISABLED);
+ Srmm_SetIconFlags(dlg->hContact, MODULENAME, i, dlg->enabled ? 0 : MBF_DISABLED);
else
- sid.flags = MBF_HIDDEN;
-
- Srmm_ModifyIcon(dlg->hContact, &sid);
+ Srmm_SetIconFlags(dlg->hContact, MODULENAME, i, MBF_HIDDEN);
}
}
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp
index b17f9faa0b..82b90cc0da 100644
--- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp
+++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp
@@ -97,26 +97,17 @@ MsgWndData::~MsgWndData()
void MsgWndData::FlagsIconSet()
{
- StatusIconData sid = {};
- sid.szModule = MODNAMEFLAGS;
- if (!g_bShowStatusIconFlag)
- sid.flags = MBF_HIDDEN;
- if (m_countryID != 0xFFFF || g_bUseUnknownFlag) {
- sid.hIcon = LoadFlagIcon(m_countryID);
- sid.szTooltip.a = Translate((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, m_countryID, 0));
+ if (!g_bShowStatusIconFlag || (m_countryID == 0xFFFF && !g_bUseUnknownFlag))
+ Srmm_SetIconFlags(m_hContact, MODNAMEFLAGS, 0, MBF_HIDDEN);
+ else {
+ char *szTooltip = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, m_countryID, 0);
+ Srmm_ModifyIcon(m_hContact, MODNAMEFLAGS, 0, LoadFlagIcon(m_countryID), TranslateW(_A2T(szTooltip)));
}
- else sid.flags = MBF_HIDDEN;
-
- Srmm_ModifyIcon(m_hContact, &sid);
}
void UpdateStatusIcons()
{
- StatusIconData sid = {};
- sid.szModule = MODNAMEFLAGS;
- if (!g_bShowStatusIconFlag)
- sid.flags = MBF_HIDDEN;
- Srmm_ModifyIcon(NULL, &sid);
+ Srmm_SetIconFlags(NULL, MODNAMEFLAGS, 0, MBF_HIDDEN);
/* enum all opened message windows */
for (auto &it : gMsgWndList)
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp
index 067fadf6a0..22dd87b721 100644
--- a/protocols/JabberG/src/jabber_menu.cpp
+++ b/protocols/JabberG/src/jabber_menu.cpp
@@ -878,13 +878,8 @@ void CJabberProto::MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item)
return;
MCONTACT hContact = HContactFromJID(item->jid);
- if (!hContact)
- return;
-
- StatusIconData sid = {};
- sid.szModule = m_szModuleName;
- sid.flags = item->arResources.getCount() ? 0 : MBF_DISABLED;
- Srmm_ModifyIcon(hContact, &sid);
+ if (hContact)
+ Srmm_SetIconFlags(hContact, m_szModuleName, 0, item->arResources.getCount() ? 0 : MBF_DISABLED);
}
int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
diff --git a/src/mir_app/src/meta_services.cpp b/src/mir_app/src/meta_services.cpp
index b54e652c56..49547f73f1 100644
--- a/src/mir_app/src/meta_services.cpp
+++ b/src/mir_app/src/meta_services.cpp
@@ -534,7 +534,7 @@ static int Meta_MessageWindowEvent(WPARAM, LPARAM lParam)
if (mwed->uType == MSG_WINDOW_EVT_OPEN) {
DBCachedContact *cc = currDb->getCache()->GetCachedContact(mwed->hContact);
if (cc != nullptr) {
- Meta_UpdateSrmmIcon(cc, db_get_w(cc->contactID, META_PROTO, "Status", ID_STATUS_OFFLINE));
+ Srmm_SetIconFlags(cc->contactID, META_PROTO, 0, cc->IsMeta() ? 0 : MBF_HIDDEN);
if (cc->IsMeta()) {
MetaSrmmData *p = new MetaSrmmData;
p->m_hMeta = cc->contactID;
diff --git a/src/mir_app/src/meta_utils.cpp b/src/mir_app/src/meta_utils.cpp
index 935a1e0fee..8b2d5af91e 100644
--- a/src/mir_app/src/meta_utils.cpp
+++ b/src/mir_app/src/meta_utils.cpp
@@ -548,13 +548,5 @@ void Meta_FixStatus(DBCachedContact *ccMeta)
}
db_set_w(ccMeta->contactID, META_PROTO, "Status", status);
- Meta_UpdateSrmmIcon(ccMeta, status);
-}
-
-void Meta_UpdateSrmmIcon(DBCachedContact *ccMeta, int)
-{
- StatusIconData sid = {};
- sid.szModule = META_PROTO;
- sid.flags = (ccMeta->IsMeta()) ? 0 : MBF_HIDDEN;
- Srmm_ModifyIcon(ccMeta->contactID, &sid);
+ Srmm_SetIconFlags(ccMeta->contactID, META_PROTO, 0, ccMeta->IsMeta() ? 0 : MBF_HIDDEN);
}
diff --git a/src/mir_app/src/metacontacts.h b/src/mir_app/src/metacontacts.h
index 590c886a84..ae12ec51b7 100644
--- a/src/mir_app/src/metacontacts.h
+++ b/src/mir_app/src/metacontacts.h
@@ -66,7 +66,6 @@ DBCachedContact* CheckMeta(MCONTACT hMeta);
// function to copy history from one contact to another - courtesy JdGordon with mods (thx)
void Meta_FixStatus(DBCachedContact *ccMeta);
-void Meta_UpdateSrmmIcon(DBCachedContact *ccMeta, int iStatus);
INT_PTR Meta_GetCaps(WPARAM wParam,LPARAM lParam);
INT_PTR Meta_GetName(WPARAM wParam,LPARAM lParam);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index a1730123f0..b99133764f 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -674,3 +674,4 @@ Popup_AddClass @763
Popup_Add @764
Popup_Change @765
Skin_GetProtoIcon @766
+Srmm_SetIconFlags @767
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 1cda05d3e1..9b8928ccae 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -674,3 +674,4 @@ Popup_AddClass @763
Popup_Add @764
Popup_Change @765
Skin_GetProtoIcon @766
+Srmm_SetIconFlags @767
diff --git a/src/mir_app/src/srmm_statusicon.cpp b/src/mir_app/src/srmm_statusicon.cpp
index 2b737edb19..fbced9eb8a 100644
--- a/src/mir_app/src/srmm_statusicon.cpp
+++ b/src/mir_app/src/srmm_statusicon.cpp
@@ -62,11 +62,15 @@ struct StatusIconMain : public MZeroedObject
~StatusIconMain()
{
- mir_free((void*)sid.szModule);
- mir_free((void*)sid.szTooltip.w);
+ mir_free(szModule);
+ mir_free(pwszTooltip);
}
- StatusIconData sid;
+ char* szModule;
+ DWORD dwId;
+ HICON hIcon, hIconDisabled;
+ int flags;
+ wchar_t* pwszTooltip;
HANDLE hIcolibOn, hIcolibOff;
HPLUGIN pPlugin;
@@ -75,11 +79,11 @@ struct StatusIconMain : public MZeroedObject
static int CompareIcons(const StatusIconMain *p1, const StatusIconMain *p2)
{
- int res = mir_strcmp(p1->sid.szModule, p2->sid.szModule);
+ int res = mir_strcmp(p1->szModule, p2->szModule);
if (res)
return res;
- return p1->sid.dwId - p2->sid.dwId;
+ return p1->dwId - p2->dwId;
}
static OBJLIST<StatusIconMain> arIcons(10, CompareIcons);
@@ -93,18 +97,23 @@ MIR_APP_DLL(int) Srmm_AddIcon(StatusIconData *sid, HPLUGIN pPlugin)
StatusIconMain *p = arIcons.find((StatusIconMain*)sid);
if (p != nullptr)
- return Srmm_ModifyIcon(0, sid);
+ return 2;
p = new StatusIconMain;
- memcpy(&p->sid, sid, sizeof(p->sid));
+ p->szModule = mir_strdup(sid->szModule);
+ p->dwId = sid->dwId;
+ p->flags = sid->flags;
p->pPlugin = pPlugin;
- p->sid.szModule = mir_strdup(sid->szModule);
- p->hIcolibOn = IcoLib_IsManaged(sid->hIcon);
- p->hIcolibOff = IcoLib_IsManaged(sid->hIconDisabled);
+
+ if ((p->hIcolibOn = IcoLib_IsManaged(sid->hIcon)) == nullptr)
+ p->hIcon = sid->hIcon;
+ if ((p->hIcolibOff = IcoLib_IsManaged(sid->hIconDisabled)) == nullptr)
+ p->hIconDisabled = sid->hIconDisabled;
+
if (sid->flags & MBF_UNICODE)
- p->sid.szTooltip.w = mir_wstrdup(sid->szTooltip.w);
+ p->pwszTooltip = mir_wstrdup(sid->szTooltip.w);
else
- p->sid.szTooltip.w = mir_a2u(sid->szTooltip.a);
+ p->pwszTooltip = mir_a2u(sid->szTooltip.a);
arIcons.insert(p);
NotifyEventHooks(hHookIconsChanged, 0, (LPARAM)p);
@@ -113,44 +122,65 @@ MIR_APP_DLL(int) Srmm_AddIcon(StatusIconData *sid, HPLUGIN pPlugin)
/////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(int) Srmm_ModifyIcon(MCONTACT hContact, StatusIconData *sid)
+MIR_APP_DLL(void) Srmm_ModifyIcon(MCONTACT hContact, const char *szModule, DWORD iconId, HICON hIcon, const wchar_t *pwszToolTip)
{
- if (sid == nullptr)
- return 1;
+ StatusIconData sid;
+ sid.szModule = szModule;
+ sid.dwId = iconId;
- StatusIconMain *p = arIcons.find((StatusIconMain*)sid);
+ StatusIconMain *p = arIcons.find((StatusIconMain*)&sid);
if (p == nullptr)
- return 1;
+ return;
if (hContact == 0) {
- mir_free((void*)p->sid.szModule);
- mir_free((void*)p->sid.szTooltip.w);
- memcpy(&p->sid, sid, sizeof(p->sid));
- p->hIcolibOn = IcoLib_IsManaged(sid->hIcon);
- p->hIcolibOff = IcoLib_IsManaged(sid->hIconDisabled);
- p->sid.szModule = mir_strdup(sid->szModule);
- p->sid.szTooltip.w = (sid->flags & MBF_UNICODE) ? mir_wstrdup(sid->szTooltip.w) : mir_a2u(sid->szTooltip.a);
-
- NotifyEventHooks(hHookIconsChanged, 0, (LPARAM)p);
- return 0;
+ if (hIcon)
+ if ((p->hIcolibOn = IcoLib_IsManaged(hIcon)) == nullptr)
+ p->hIcon = hIcon;
+
+ replaceStrW(p->pwszTooltip, pwszToolTip);
}
+ else {
+ StatusIconChild *pc = p->arChildren.find((StatusIconChild*)&hContact);
+ if (pc == nullptr) {
+ pc = new StatusIconChild();
+ pc->hContact = hContact;
+ p->arChildren.insert(pc);
+ }
- StatusIconChild *pc = p->arChildren.find((StatusIconChild*)&hContact);
- if (pc == nullptr) {
- pc = new StatusIconChild();
- pc->hContact = hContact;
- p->arChildren.insert(pc);
+ if (hIcon)
+ if ((pc->hIcolibOn = IcoLib_IsManaged(hIcon)) == nullptr)
+ pc->hIcon = hIcon;
+
+ replaceStrW(pc->pwszTooltip, pwszToolTip);
}
- pc->flags = sid->flags;
- pc->hIcon = sid->hIcon;
- pc->hIconDisabled = sid->hIconDisabled;
- pc->hIcolibOn = IcoLib_IsManaged(sid->hIcon);
- pc->hIcolibOff = IcoLib_IsManaged(sid->hIconDisabled);
- replaceStrW(pc->pwszTooltip, (sid->flags & MBF_UNICODE) ? mir_wstrdup(sid->szTooltip.w) : mir_a2u(sid->szTooltip.a));
+ NotifyEventHooks(hHookIconsChanged, hContact, (LPARAM)p);
+}
+
+MIR_APP_DLL(void) Srmm_SetIconFlags(MCONTACT hContact, const char *szModule, DWORD iconId, int flags)
+{
+ StatusIconData sid;
+ sid.szModule = szModule;
+ sid.dwId = iconId;
+
+ StatusIconMain *p = arIcons.find((StatusIconMain*)&sid);
+ if (p == nullptr)
+ return;
+
+ if (hContact == 0)
+ p->flags = flags;
+ else {
+ StatusIconChild *pc = p->arChildren.find((StatusIconChild*)&hContact);
+ if (pc == nullptr) {
+ pc = new StatusIconChild();
+ pc->hContact = hContact;
+ p->arChildren.insert(pc);
+ }
+
+ pc->flags = flags;
+ }
NotifyEventHooks(hHookIconsChanged, hContact, (LPARAM)p);
- return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -165,6 +195,16 @@ MIR_APP_DLL(void) Srmm_RemoveIcon(const char *szProto, DWORD iconId)
/////////////////////////////////////////////////////////////////////////////////////////
+static void tryIcolib(HANDLE hIcolib, HICON hIcon, HICON &dest)
+{
+ if (hIcolib != nullptr)
+ hIcon = IcoLib_GetIconByHandle(hIcolib);
+ if (hIcon != nullptr)
+ dest = hIcon;
+ if (hIcolib != nullptr)
+ IcoLib_ReleaseIcon(hIcon);
+}
+
MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index)
{
static StatusIconData res;
@@ -176,22 +216,26 @@ MIR_APP_DLL(StatusIconData*) Srmm_GetNthIcon(MCONTACT hContact, int index)
if (pc->flags & MBF_HIDDEN)
continue;
}
- else if (it->sid.flags & MBF_HIDDEN)
+ else if (it->flags & MBF_HIDDEN)
continue;
if (nVis == index) {
memcpy(&res, it, sizeof(res));
if (pc) {
- if (pc->hIcon)
- res.hIcon = pc->hIcon;
- if (pc->hIconDisabled)
- res.hIconDisabled = pc->hIconDisabled;
- else if (pc->hIcon)
- res.hIconDisabled = pc->hIcon;
+ tryIcolib(pc->hIcolibOn, pc->hIcon, res.hIcon);
+ tryIcolib(pc->hIcolibOff, pc->hIconDisabled, res.hIconDisabled);
if (pc->pwszTooltip)
res.szTooltip.w = pc->pwszTooltip;
res.flags = pc->flags;
}
+
+ if (res.hIcon == nullptr)
+ tryIcolib(it->hIcolibOn, it->hIcon, res.hIcon);
+ if (res.hIconDisabled == nullptr)
+ tryIcolib(it->hIcolibOff, it->hIconDisabled, res.hIconDisabled);
+
+ if (res.hIconDisabled == nullptr)
+ res.hIconDisabled = res.hIcon;
res.szTooltip.w = TranslateW_LP(res.szTooltip.w, it->pPlugin);
return &res;
}