summaryrefslogtreecommitdiff
path: root/plugins/FavContacts/src/contact_cache.h
blob: db50bbc15b5179f9e1003440cb22221550408b7f (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
38
39
40
41
42
43
44
45
#ifndef __contact_cache__
#define __contact_cache__

class CContactCache
{
public:
	enum { INFOSIZE = 1024 };

	struct TContactInfo
	{
		MCONTACT hContact;
		float rate;
		bool infoLoaded;
		wchar_t info[INFOSIZE];
	
		TContactInfo()
		{
			info[0] = info[1] = 0;
			infoLoaded = false;
		}

		void LoadInfo();
	};

private:
	LIST<TContactInfo> m_cache;
	unsigned long m_lastUpdate;
	mir_cs m_cs;

	int __cdecl OnDbEventAdded(WPARAM wParam, LPARAM lParam);
	float GetEventWeight(unsigned long age);
	float GetTimeWeight(unsigned long age);

public:
	CContactCache();
	~CContactCache();

	void Rebuild();

	MCONTACT get(int rate);
	float getWeight(int rate);
	bool filter(int rate, wchar_t *str);
};

#endif // __contact_cache__