diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-11 08:04:17 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-11 08:04:17 +0000 |
commit | ba430f779e1f3692d563c48b3517915429bd393d (patch) | |
tree | 9af1ee5dcb725e8b66c796b2c76795b4a00481d9 | |
parent | 5fe330d9ca85adf0df19f60839f5472d53e34f9c (diff) |
status icons almost recovered
git-svn-id: http://svn.miranda-ng.org/main/trunk@4420 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_message.h | 15 | ||||
-rw-r--r-- | plugins/Scriver/src/statusicon.cpp | 7 | ||||
-rw-r--r-- | plugins/TabSRMM/src/controls.cpp | 19 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 25 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_menu.cpp | 16 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/statusicon.cpp | 8 | ||||
-rw-r--r-- | src/modules/srmm/statusicon.cpp | 29 |
9 files changed, 45 insertions, 80 deletions
diff --git a/include/m_message.h b/include/m_message.h index 7559210dda..bb5495d813 100644 --- a/include/m_message.h +++ b/include/m_message.h @@ -157,7 +157,7 @@ typedef struct { // 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);
@@ -166,7 +166,7 @@ __forceinline INT_PTR Srmm_AddIcon(StatusIconData *sid) // wParam = 0 (unused)
// lParam = (StatusIconData *)&StatusIconData
// only szModule and szId are used
-#define MS_MSG_REMOVEICON "MessageAPI/RemoveIcon"
+#define MS_MSG_REMOVEICON "MessageAPI/RemoveIcon"
__forceinline void Srmm_RemoveIcon(StatusIconData *sid)
{ CallService(MS_MSG_REMOVEICON, 0, (LPARAM)sid);
@@ -177,13 +177,20 @@ __forceinline void Srmm_RemoveIcon(StatusIconData *sid) // 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
-#define MS_MSG_MODIFYICON "MessageAPI/ModifyIcon"
+#define MS_MSG_MODIFYICON "MessageAPI/ModifyIcon"
+
+__forceinline void Srmm_ModifyIcon(HANDLE hContact, StatusIconData *sid)
+{ CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)sid);
+}
// wParam = (HANDLE)hContact
// lParam = (int)zero-based index of a visible icon
// returns (StatusIconData*)icon description filled for the required contact
// don't free this memory.
-#define MS_MSG_GETNTHICON "MessageAPI/GetNthIcon"
+
+__forceinline StatusIconData* Srmm_GetNthIcon(HANDLE hContact, int index)
+{ return (StatusIconData*)CallService("MessageAPI/GetNthIcon", (WPARAM)hContact, index);
+}
// wParam = (HANDLE)hContact;
// lParam = (StatusIconClickData *)&StatusIconClickData;
diff --git a/plugins/Scriver/src/statusicon.cpp b/plugins/Scriver/src/statusicon.cpp index a51cdd22d5..b6879370f3 100644 --- a/plugins/Scriver/src/statusicon.cpp +++ b/plugins/Scriver/src/statusicon.cpp @@ -30,9 +30,8 @@ void DrawStatusIcons(HANDLE hContact, HDC hDC, RECT r, int gap) HICON hIcon;
int x = r.left;
- StatusIconData *si;
int nIcon = 0;
- while ((si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon++)) != NULL) {
+ while (StatusIconData *si = Srmm_GetNthIcon(hContact, nIcon++)) {
if ((si->flags & MBF_DISABLED) && si->hIconDisabled) hIcon = si->hIconDisabled;
else hIcon = si->hIcon;
@@ -46,7 +45,7 @@ void DrawStatusIcons(HANDLE hContact, HDC hDC, RECT r, int gap) void CheckStatusIconClick(HANDLE hContact, HWND hwndFrom, POINT pt, RECT r, int gap, int click_flags)
{
unsigned int iconNum = (pt.x - r.left) / (GetSystemMetrics(SM_CXSMICON) + gap) + 1;
- StatusIconData *si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, iconNum);
+ StatusIconData *si = Srmm_GetNthIcon(hContact, iconNum);
if (si == NULL)
return;
@@ -92,7 +91,7 @@ int DeinitStatusIcons() int GetStatusIconsCount(HANDLE hContact)
{
int nIcon = 0;
- while ( CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon) != NULL)
+ while ( Srmm_GetNthIcon(hContact, nIcon) != NULL)
nIcon++;
return nIcon;
}
diff --git a/plugins/TabSRMM/src/controls.cpp b/plugins/TabSRMM/src/controls.cpp index 5477979d29..6f0d9141a1 100644 --- a/plugins/TabSRMM/src/controls.cpp +++ b/plugins/TabSRMM/src/controls.cpp @@ -925,10 +925,9 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR {
int list_icons = 0;
struct TWindowData *dat = (struct TWindowData *)lParam;
- if (dat) {
- while ( CallService(MS_MSG_GETNTHICON, (WPARAM)dat->hContact, list_icons))
+ if (dat)
+ while ( Srmm_GetNthIcon(dat->hContact, list_icons))
list_icons++;
- }
SendMessage(hWnd, WM_SIZE, 0, 0);
@@ -1012,11 +1011,11 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR int gap = 2;
unsigned int iconNum = (pt.x - rc.left) / (PluginConfig.m_smcxicon + gap);
+ char *szModule = NULL, *szTooltip;
int list_icons = 0;
- StatusIconData *si, *clicked = NULL;
- while ((si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)dat->hContact, list_icons)) != NULL)
+ while (StatusIconData *sid = Srmm_GetNthIcon(dat->hContact, list_icons))
if (list_icons++ == iconNum)
- clicked = si;
+ szModule = sid->szModule, szTooltip = sid->szTooltip;
if ((int)iconNum == list_icons && pContainer) {
TCHAR wBuf[512];
@@ -1043,11 +1042,9 @@ LONG_PTR CALLBACK StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPAR CallService(szTTService, (WPARAM)wBuf, (LPARAM)&ti);
tooltip_active = TRUE;
}
- else {
- if (clicked) {
- CallService("mToolTip/ShowTip", (WPARAM)clicked->szTooltip, (LPARAM)&ti);
- tooltip_active = TRUE;
- }
+ else if (szModule) {
+ CallService("mToolTip/ShowTip", (WPARAM)szTooltip, (LPARAM)&ti);
+ tooltip_active = TRUE;
}
}
SendMessage(hWnd, SB_GETRECT, 1, (LPARAM)&rc);
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index ad5ae42a4b..67d47edc1b 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -2039,9 +2039,8 @@ void DrawStatusIcons(struct TWindowData *dat, HDC hDC, RECT r, int gap) SetBkMode(hDC, TRANSPARENT);
- StatusIconData *si;
int nIcon = 0;
- while ((si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)dat->hContact, nIcon++)) != NULL) {
+ while (StatusIconData *si = Srmm_GetNthIcon(dat->hContact, nIcon++)) {
if ((si->flags & MBF_DISABLED) && si->hIconDisabled)
hIcon = si->hIconDisabled;
else
@@ -2079,11 +2078,6 @@ void DrawStatusIcons(struct TWindowData *dat, HDC hDC, RECT r, int gap) void SI_CheckStatusIconClick(struct TWindowData *dat, HWND hwndFrom, POINT pt, RECT r, int gap, int code)
{
- StatusIconClickData sicd;
-
- UINT iconNum = (pt.x - (r.left + 0)) / (PluginConfig.m_smcxicon + gap);
- UINT list_icons = 0;
-
if (dat && (code == NM_CLICK || code == NM_RCLICK)) {
POINT ptScreen;
@@ -2092,11 +2086,13 @@ void SI_CheckStatusIconClick(struct TWindowData *dat, HWND hwndFrom, POINT pt, R return;
}
- StatusIconData *si, *clicked = NULL;
+ UINT iconNum = (pt.x - (r.left + 0)) / (PluginConfig.m_smcxicon + gap), list_icons = 0;
+ DWORD dwID;
+ char *szModule = NULL;
if (dat)
- while ((si = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)dat->hContact, list_icons)) != NULL) {
+ while (StatusIconData *si = Srmm_GetNthIcon(dat->hContact, list_icons)) {
if (list_icons == iconNum)
- clicked = si;
+ szModule = si->szModule, dwID = si->dwId;
list_icons++;
}
@@ -2121,11 +2117,12 @@ void SI_CheckStatusIconClick(struct TWindowData *dat, HWND hwndFrom, POINT pt, R PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_TRAYICONNOTIFY, 101, WM_LBUTTONUP);
else if (code == NM_RCLICK)
PostMessage(PluginConfig.g_hwndHotkeyHandler, DM_TRAYICONNOTIFY, 101, WM_RBUTTONUP);
- } else if (clicked) {
- sicd.cbSize = sizeof(StatusIconClickData);
+ }
+ else if (szModule) {
+ StatusIconClickData sicd = { sizeof(sicd) };
GetCursorPos(&sicd.clickLocation);
- sicd.dwId = clicked->dwId;
- sicd.szModule = clicked->szModule;
+ sicd.dwId = dwID;
+ sicd.szModule = szModule;
sicd.flags = (code == NM_RCLICK ? MBCF_RIGHTBUTTON : 0);
NotifyEventHooks(hHookIconPressedEvt, (WPARAM)dat->hContact, (LPARAM)&sicd);
InvalidateRect(dat->pContainer->hwndStatus, NULL, TRUE);
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index 2d7bbe11e9..7a47f5ef20 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -1015,28 +1015,18 @@ void CJabberProto::CheckMenuItems() static HANDLE hDialogsList = NULL;
-void CJabberProto::MenuHideSrmmIcon(HANDLE hContact)
-{
- StatusIconData sid = {0};
- sid.cbSize = sizeof(sid);
- sid.szModule = m_szModuleName;
- sid.flags = MBF_HIDDEN;
- CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
-}
-
void CJabberProto::MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item)
{
- if (item->list != LIST_ROSTER || !ServiceExists(MS_MSG_MODIFYICON))
+ if (item->list != LIST_ROSTER)
return;
HANDLE hContact = HContactFromJID(item->jid);
if ( !hContact)
return;
- StatusIconData sid = {0};
- sid.cbSize = sizeof(sid);
+ StatusIconData sid = { sizeof(sid) };
sid.szModule = m_szModuleName;
- sid.flags = item->resourceCount ? 0 : MBF_HIDDEN;
+ sid.flags = item->resourceCount ? 0 : MBF_DISABLED;
CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index ea534109d1..6810416685 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -695,8 +695,6 @@ struct CJabberProto : public PROTO_INTERFACE void GlobalMenuUninit(void);
void MenuInit(void);
-
- void MenuHideSrmmIcon(HANDLE hContact);
void MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item);
void AuthWorker(HANDLE hContact, char* authReqType);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index f1331af187..376dc3b7fc 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -595,10 +595,8 @@ recvRest: JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
// Set all contacts to offline
- for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
SetContactOfflineStatus(hContact);
- MenuHideSrmmIcon(hContact);
- }
mir_free(m_szJabberJID);
m_szJabberJID = NULL;
diff --git a/src/core/stdmsg/src/statusicon.cpp b/src/core/stdmsg/src/statusicon.cpp index 68ad9d25d5..25e7813615 100644 --- a/src/core/stdmsg/src/statusicon.cpp +++ b/src/core/stdmsg/src/statusicon.cpp @@ -42,9 +42,9 @@ void DrawStatusIcons(HANDLE hContact, HDC hDC, RECT r, int gap) HICON hIcon;
int x = r.left;
- StatusIconData *sid;
int nIcon = 0;
- while ((sid = (StatusIconData*)CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon++)) != NULL && x < r.right) {
+ StatusIconData *sid;
+ while ((sid = Srmm_GetNthIcon(hContact, nIcon++)) != 0 && x < r.right) {
if ((sid->flags & MBF_DISABLED) && sid->hIconDisabled) hIcon = sid->hIconDisabled;
else hIcon = sid->hIcon;
@@ -58,7 +58,7 @@ void DrawStatusIcons(HANDLE hContact, HDC hDC, RECT r, int 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);
+ StatusIconData *sid = Srmm_GetNthIcon(hContact, iconNum);
if (sid == NULL)
return;
@@ -89,7 +89,7 @@ int DeinitStatusIcons() int GetStatusIconsCount(HANDLE hContact)
{
int nIcon = 0;
- while ( CallService(MS_MSG_GETNTHICON, (WPARAM)hContact, nIcon) != NULL)
+ while ( Srmm_GetNthIcon(hContact, nIcon) != NULL)
nIcon++;
return nIcon;
}
diff --git a/src/modules/srmm/statusicon.cpp b/src/modules/srmm/statusicon.cpp index ca5f526fac..554df1565c 100644 --- a/src/modules/srmm/statusicon.cpp +++ b/src/modules/srmm/statusicon.cpp @@ -154,10 +154,10 @@ static INT_PTR GetNthIcon(WPARAM wParam, LPARAM lParam) if (nVis == (int)lParam) {
memcpy(&res, &p, sizeof(res));
if (pc) {
- res.hIcon = pc->hIcon;
- res.hIconDisabled = pc->hIconDisabled;
+ if (pc->hIcon) res.hIcon = pc->hIcon;
+ if (pc->hIconDisabled) res.hIconDisabled = pc->hIconDisabled;
+ if (pc->szTooltip) res.szTooltip = pc->szTooltip;
res.flags = pc->flags;
- res.szTooltip = pc->szTooltip;
}
return (INT_PTR)&res;
}
@@ -169,25 +169,6 @@ static INT_PTR GetNthIcon(WPARAM wParam, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
-static int OnWindowEvent(WPARAM, LPARAM lParam)
-{
- MessageWindowEventData *evt = (MessageWindowEventData*)lParam;
- if (evt->uType == MSG_WINDOW_EVT_CLOSE) {
- for (int i=0; i < arIcons.getCount(); i++) {
- StatusIconMain &p = arIcons[i];
- p.arChildren.remove((StatusIconChild*)&evt->hContact);
- }
- }
-
- return 0;
-}
-
-static int OnModulesLoaded(WPARAM, LPARAM)
-{
- HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
- return 0;
-}
-
void KillModuleSrmmIcons(int hLangpack)
{
for (int i=arIcons.getCount()-1; i >= 0; i--) {
@@ -202,9 +183,7 @@ int LoadSrmmModule() CreateServiceFunction("MessageAPI/AddIcon", AddStatusIcon);
CreateServiceFunction(MS_MSG_REMOVEICON, RemoveStatusIcon);
CreateServiceFunction(MS_MSG_MODIFYICON, ModifyStatusIcon);
- CreateServiceFunction(MS_MSG_GETNTHICON, GetNthIcon);
-
- HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ CreateServiceFunction("MessageAPI/GetNthIcon", GetNthIcon);
hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED);
return 0;
|