diff options
author | George Hazan <ghazan@miranda.im> | 2021-05-20 21:56:55 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-05-20 21:56:55 +0300 |
commit | 850dd08c679f8265491aad2cf04e5cb67db0a39a (patch) | |
tree | b66059b3f4a9e23a408dd6b5b882f72e4f8923bb /protocols/JabberG/src | |
parent | 497a8a92a3f4a9ab0c3c0a5a554d2af9ade87343 (diff) |
Jabber: fix for drawing mood icons in the contact list (as advanced status icons)
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r-- | protocols/JabberG/src/jabber_icolib.cpp | 32 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.cpp | 2 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.h | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_xstatus.cpp | 26 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_xstatus.h | 3 |
5 files changed, 49 insertions, 17 deletions
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index 43e55a43c4..d50c2e541f 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -317,6 +317,7 @@ int CJabberProto::OnReloadIcons(WPARAM, LPARAM) if (m_transportProtoTableStartIndex[i] != -1)
LoadAdvancedIcons(i);
+ ClearMoodIcons();
return 0;
}
@@ -329,24 +330,31 @@ int CJabberProto::OnReloadIcons(WPARAM, LPARAM) // if imagelist require advanced painting status overlay(like xStatus)
// index should be shifted to HIWORD, LOWORD should be 0
-INT_PTR __cdecl CJabberProto::JGetAdvancedStatusIcon(WPARAM hContact, LPARAM)
+INT_PTR __cdecl CJabberProto::OnGetAdvancedStatusIcon(WPARAM hContact, LPARAM)
{
if (!hContact)
return -1;
- if (!getByte(hContact, "IsTransported", 0))
- return -1;
+ if (getByte(hContact, "IsTransported", 0)) {
+ int iID = GetTransportProtoID(ptrA(getUStringA(hContact, "Transport")));
+ if (iID < 0)
+ return -1;
+
+ WORD Status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
+ if (Status < ID_STATUS_OFFLINE)
+ Status = ID_STATUS_OFFLINE;
+ else if (Status > ID_STATUS_INVISIBLE)
+ Status = ID_STATUS_ONLINE;
+ return GetTransportStatusIconIndex(iID, Status);
+ }
- int iID = GetTransportProtoID(ptrA(getUStringA(hContact, "Transport")));
- if (iID < 0)
- return -1;
+ if (int xStatus = getByte(hContact, DBSETTING_XSTATUSID)) {
+ int idx = GetMoodIconIdx(xStatus);
+ if (idx != -1)
+ return MAKELONG(0, idx); // shift icon id to the upper word
+ }
- WORD Status = getWord(hContact, "Status", ID_STATUS_OFFLINE);
- if (Status < ID_STATUS_OFFLINE)
- Status = ID_STATUS_OFFLINE;
- else if (Status > ID_STATUS_INVISIBLE)
- Status = ID_STATUS_ONLINE;
- return GetTransportStatusIconIndex(iID, Status);
+ return -1;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 0811404422..1ab7f3588a 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -157,7 +157,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : CreateProtoService(PS_GETCUSTOMSTATUSEX, &CJabberProto::OnGetXStatusEx);
CreateProtoService(PS_SETCUSTOMSTATUSEX, &CJabberProto::OnSetXStatusEx);
CreateProtoService(PS_GETCUSTOMSTATUSICON, &CJabberProto::OnGetXStatusIcon);
- CreateProtoService(PS_GETADVANCEDSTATUSICON, &CJabberProto::JGetAdvancedStatusIcon);
+ CreateProtoService(PS_GETADVANCEDSTATUSICON, &CJabberProto::OnGetAdvancedStatusIcon);
CreateProtoService(JS_HTTP_AUTH, &CJabberProto::OnHttpAuthRequest);
CreateProtoService(JS_INCOMING_NOTE_EVENT, &CJabberProto::OnIncomingNoteEvent);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index ab0ab5e8a0..430f8b0eed 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -523,7 +523,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface int GetTransportStatusIconIndex(int iID, int Status);
bool DBCheckIsTransportedContact(const char *jid, MCONTACT hContact);
void CheckAllContactsAreTransported(void);
- INT_PTR __cdecl JGetAdvancedStatusIcon(WPARAM wParam, LPARAM lParam);
+
+ INT_PTR __cdecl OnGetAdvancedStatusIcon(WPARAM wParam, LPARAM lParam);
//---- jabber_iq.c -------------------------------------------------------------------
diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index 466ee76dcc..41902de81d 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -459,12 +459,13 @@ int CPepGuiService::OnMenuItemClick(WPARAM, LPARAM) struct
{
- wchar_t *szName;
- char* szTag;
+ wchar_t *szName;
+ char *szTag;
+ int clistIconId;
}
static g_arrMoods[] =
{
- { LPGENW("None"), nullptr },
+ { LPGENW("None"), nullptr },
{ LPGENW("Afraid"), "afraid" },
{ LPGENW("Amazed"), "amazed" },
{ LPGENW("Amorous"), "amorous" },
@@ -710,6 +711,24 @@ void CPepMood::UpdateMenuView() m_proto->m_pInfoFrame->UpdateInfoItem("$/PEP/mood", hIcon, title);
}
+void ClearMoodIcons()
+{
+ for (auto &it : g_arrMoods)
+ it.clistIconId = 0;
+}
+
+int GetMoodIconIdx(int xStatusId)
+{
+ if (xStatusId <= 0 || xStatusId >= _countof(g_arrMoods))
+ return -1;
+
+ auto &pIcon = g_arrMoods[xStatusId];
+ if (pIcon.clistIconId == 0)
+ pIcon.clistIconId = ImageList_AddIcon(Clist_GetImageList(), g_MoodIcons.GetIcon(pIcon.szTag));
+
+ return pIcon.clistIconId;
+}
+
///////////////////////////////////////////////////////////////////////////////
// CPepActivity
@@ -1449,6 +1468,7 @@ void g_XstatusIconsInit() wchar_t szSection[100];
mir_wstrcpy(szSection, L"Protocols/Jabber/" LPGENW("Moods"));
+ ClearMoodIcons();
for (int i = 1; i < _countof(g_arrMoods); i++)
g_MoodIcons.RegisterIcon(g_arrMoods[i].szTag, szFile, -(1200 + i), szSection, TranslateW(g_arrMoods[i].szName));
diff --git a/protocols/JabberG/src/jabber_xstatus.h b/protocols/JabberG/src/jabber_xstatus.h index 25f72f40e9..a4deb72ba0 100644 --- a/protocols/JabberG/src/jabber_xstatus.h +++ b/protocols/JabberG/src/jabber_xstatus.h @@ -29,6 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. struct CJabberProto;
+void ClearMoodIcons();
+int GetMoodIconIdx(int xStstusId);
+
class CPepService
{
public:
|