summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-01 14:31:21 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-01 14:31:21 +0300
commitcf24ded29a5769680068cc46b5e99fe576c0efaa (patch)
treec54bf62275e6776f9817c4a9e45fb60c1b6d46d3 /plugins
parentdf13b2870889a7cb8c319fd35d5ff4f1ae4c2fe0 (diff)
fixes #1780 (MessageState doesn't work in metacontacts)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/MessageState/src/messagestate.cpp56
-rw-r--r--plugins/MessageState/src/stdafx.h1
2 files changed, 37 insertions, 20 deletions
diff --git a/plugins/MessageState/src/messagestate.cpp b/plugins/MessageState/src/messagestate.cpp
index a2dfc9c7f0..e4af06acac 100644
--- a/plugins/MessageState/src/messagestate.cpp
+++ b/plugins/MessageState/src/messagestate.cpp
@@ -24,21 +24,24 @@ void SetSRMMIcon(MCONTACT hContact, SRMM_ICON_TYPE type, time_t time)
sid.dwId = 1;
sid.flags = MBF_UNICODE;
- CMStringW tszTooltip;
+ MCONTACT hActualContact;
+ if (db_mc_isMeta(hContact))
+ hActualContact = db_mc_getSrmmSub(hContact);
+ else
+ hActualContact = hContact;
if (type != ICON_HIDDEN) {
sid.hIcon = IcoLib_GetIconByHandle(Icons[type].hIcolib);
if (type == ICON_READ) {
- if (g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME_TYPE, -1) == MRD_TYPE_READTIME) {
- wcsftime(tszTooltip.GetBuffer(64), 64, TranslateT("Last message read at %X %x"), localtime(&time));
- tszTooltip.ReleaseBuffer();
+ 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.tszTooltip = buf;
}
- else tszTooltip = TranslateT("Last message read (unknown time)");
+ else sid.tszTooltip = TranslateT("Last message read (unknown time)");
}
- else tszTooltip = TranslateW(Tooltips[type]);
-
- sid.tszTooltip = tszTooltip.GetBuffer();
+ else sid.tszTooltip = TranslateW(Tooltips[type]);
}
else sid.flags |= MBF_HIDDEN;
@@ -47,33 +50,39 @@ void SetSRMMIcon(MCONTACT hContact, SRMM_ICON_TYPE type, time_t time)
int IconsUpdate(MCONTACT hContact)
{
- time_t readtime = g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME, 0);
- time_t lasttime = GetLastSentMessageTime(hContact);
- if (lasttime != -1 && readtime != 0) {
- SetSRMMIcon(hContact, HasUnread(hContact) ? ICON_UNREAD : ICON_READ, readtime);
- }
- else {
+ MCONTACT hActualContact;
+ if (db_mc_isMeta(hContact))
+ hActualContact = db_mc_getSrmmSub(hContact);
+ else
+ hActualContact = hContact;
+
+ time_t readtime = g_plugin.getDword(hActualContact, DBKEY_MESSAGE_READ_TIME, 0);
+ time_t lasttime = GetLastSentMessageTime(hActualContact);
+ if (lasttime != -1 && readtime != 0)
+ SetSRMMIcon(hContact, HasUnread(hActualContact) ? ICON_UNREAD : ICON_READ, readtime);
+ else
SetSRMMIcon(hContact, ICON_HIDDEN);
- }
ExtraIconsApply(hContact, 0);
return 0;
}
-int OnProtoAck(WPARAM, LPARAM lParam)
+static int OnProtoAck(WPARAM, LPARAM lParam)
{
ACKDATA *pAck = (ACKDATA *)lParam;
if (pAck && (pAck->type == ACKTYPE_MESSAGE || pAck->type == ACKTYPE_FILE) && CheckProtoSupport(pAck->szModule)) {
- if (pAck->result == ACKRESULT_SUCCESS) SetSRMMIcon(pAck->hContact, ICON_UNREAD);
- else if (pAck->result == ACKRESULT_FAILED) SetSRMMIcon(pAck->hContact, ICON_FAILED);
+ if (pAck->result == ACKRESULT_SUCCESS)
+ SetSRMMIcon(pAck->hContact, ICON_UNREAD);
+ else if (pAck->result == ACKRESULT_FAILED)
+ SetSRMMIcon(pAck->hContact, ICON_FAILED);
ExtraIconsApply(pAck->hContact, 0);
}
return 0;
}
-int OnEventFilterAdd(WPARAM hContact, LPARAM lParam)
+static int OnEventFilterAdd(WPARAM hContact, LPARAM lParam)
{
DBEVENTINFO *dbei = (DBEVENTINFO *)lParam;
if ((dbei->flags & DBEF_SENT) && CheckProtoSupport(dbei->szModule) && db_get_b(hContact, "Tab_SRMsg", "no_ack", 0))
@@ -81,10 +90,17 @@ int OnEventFilterAdd(WPARAM hContact, LPARAM lParam)
return 0;
}
+static int OnMetaChanged(WPARAM hContact, LPARAM)
+{
+ IconsUpdate(hContact);
+ return 0;
+}
+
int OnModulesLoaded(WPARAM, LPARAM)
{
HookEvent(ME_PROTO_ACK, OnProtoAck);
HookEvent(ME_DB_EVENT_FILTER_ADD, OnEventFilterAdd);
+ HookEvent(ME_MC_DEFAULTTCHANGED, OnMetaChanged);
g_plugin.registerIcon(MODULENAME, Icons);
@@ -100,4 +116,4 @@ int OnModulesLoaded(WPARAM, LPARAM)
IconsUpdate(hContact);
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/MessageState/src/stdafx.h b/plugins/MessageState/src/stdafx.h
index ac6e58326e..ce6df98224 100644
--- a/plugins/MessageState/src/stdafx.h
+++ b/plugins/MessageState/src/stdafx.h
@@ -9,6 +9,7 @@
#include <m_database.h>
#include <m_protocols.h>
#include <m_protosvc.h>
+#include <m_metacontacts.h>
#include <m_langpack.h>
#include <m_icolib.h>
#include <m_extraicons.h>