summaryrefslogtreecommitdiff
path: root/plugins/MessageState/src/utils.cpp
blob: bd21cc208b431c3081d9290a31e8dcdee6e6d6c3 (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
#include "stdafx.h"

static mir_cs csContacts;
OBJLIST<ContactData> g_arContacts(50, NumericKeySortT);

// always returns an object, creates an empty one if missing
ContactData* FindContact(MCONTACT hContact)
{
	mir_cslock lck(csContacts);

	auto *p = g_arContacts.find((ContactData *)&hContact);
	if (p == nullptr)
		g_arContacts.insert(p = new ContactData(hContact));

	return p;
}

bool HasUnread(MCONTACT hContact)
{
	if (!CheckProtoSupport(Proto_GetBaseAccountName(hContact)))
		return false;
	
	auto *p = FindContact(hContact);
	if (p->dwLastSentTime <= p->dwLastReadTime)
		return false;
	
	return p->dwLastReadTime != 0;
}