summaryrefslogtreecommitdiff
path: root/plugins/MessageState/src/utils.cpp
blob: 40371be1a5831a4a6cf64f0f557a6a9a142cc343 (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
#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;
}

__int64 GetPreciousTime()
{
	LARGE_INTEGER li;
	QueryPerformanceCounter(&li);
	return li.QuadPart;
}