summaryrefslogtreecommitdiff
path: root/plugins/MessageState/src/services.cpp
blob: 12474e6685a9fb6b64ca755b31978d69d6fdfcfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "stdafx.h"

static IconItem Icons[] =
{
	{ LPGEN("Unread message icon"), "unread_icon", IDI_UNREAD },
	{ LPGEN("Read message icon"), "read_icon", IDI_READ },
	{ LPGEN("Failed sending icon"), "fail_icon", IDI_FAIL },
	{ LPGEN("Sending message icon"), "nosent_icon", IDI_NOSENT },
	{ LPGEN("Unread contact list extra icon"), "clist_unread_icon", IDI_EXTRA },
};

static INT_PTR UpdateService(WPARAM hContact, LPARAM lParam)
{
	auto *p = FindContact(hContact);
	
	time_t currTime = time(0);
	if (currTime >= p->dwLastReadTime) {
		p->dwLastReadTime = currTime;
		p->type = lParam;

		if (db_mc_isSub(hContact)) {
			p = FindContact(db_mc_getMeta(hContact));
			p->dwLastReadTime = currTime;
			p->type = lParam;
		}
		
		IconsUpdate(hContact);
	}
	return 0;
}

void InitServices()
{
	g_plugin.registerIcon(MODULENAME, Icons);

	CreateServiceFunction(MS_MESSAGESTATE_UPDATE, UpdateService);
}