diff options
Diffstat (limited to 'plugins/MessageState/src/clist_extra.cpp')
-rw-r--r-- | plugins/MessageState/src/clist_extra.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/plugins/MessageState/src/clist_extra.cpp b/plugins/MessageState/src/clist_extra.cpp new file mode 100644 index 0000000000..40fcc0d9f0 --- /dev/null +++ b/plugins/MessageState/src/clist_extra.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h"
+
+HANDLE hExtraIcon = NULL;
+
+bool HasUnread(MCONTACT hContact)
+{
+ const char *szProto = GetContactProto(hContact);
+ if (CheckProtoSupport(szProto))
+ {
+ return ((GetLastSentMessageTime(hContact) > db_get_dw(hContact, MODULENAME, DBKEY_MESSAGE_READ_TIME, 0)) && db_get_dw(hContact, MODULENAME, DBKEY_MESSAGE_READ_TIME, 0) != 0);
+ }
+
+ return false;
+}
+
+int ExtraIconsApply(WPARAM hContact, LPARAM)
+{
+ if (hContact == NULL) return 0;
+
+ if (HasUnread(hContact))
+ ExtraIcon_SetIconByName(hExtraIcon, hContact, "clist_unread_icon");
+ else
+ ExtraIcon_Clear(hExtraIcon, hContact);
+
+ return 0;
+}
+
+void InitClistExtraIcon()
+{
+ hExtraIcon = ExtraIcon_RegisterIcolib("messagestate_unread", LPGEN("MessageState unread extra icon"), "clist_unread_icon");
+ HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, ExtraIconsApply);
+
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ ExtraIconsApply(hContact, 0);
+}
\ No newline at end of file |