summaryrefslogtreecommitdiff
path: root/plugins/MirandaG15/src/CContactList.h
blob: ed556ce872f71a38db4893f2bb0e6df6e9f424b6 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef _CCONTACTLIST_H_
#define _CCONTACTLIST_H_

#include "LCDFramework/CLCDList.h"

class CContactListEntry
{
public:
	int iMessages;
	tstring strMessages;
	MCONTACT hHandle;
	tstring strName;
	tstring strProto;
	tstring strStatus;
	int iStatus;
};

class CContactListGroup
{
public:
	tstring strName;
	tstring strPath;
	int iMembers;
	int iGroups;
	int iOnline;
	int iEvents;

	MCONTACT hMetaContact;
	CContactListEntry *pContactListEntry;
};

class CContactList : public CLCDList<CContactListEntry*,CContactListGroup*>
{
public:
	// constructor
	CContactList();
	// destructor
	~CContactList();
	
	// initializes the list
	bool Initialize();
	// deinitializes the list
	bool Shutdown();
	
	// called when a contact has been added
	void OnContactAdded(MCONTACT hContact);
	// called when a contact has been deleted
	void OnContactDeleted(MCONTACT hContact);
	// called when the configuration has changed
	void OnConfigChanged();
	// called when a contacts group has changed
	void OnContactGroupChanged(MCONTACT hContact,tstring strGroup);
	// called when a contacts hidden flag has changed
	void OnContactHiddenChanged(MCONTACT hContact, bool bVisibility);	
	// called when a contacts nickname has changed
	void OnContactNickChanged(MCONTACT hContact, tstring strNick);
	// called when a contacts status has changed
	void OnStatusChange(MCONTACT hContact,int iStatus);
	// called when the contacts message count has changed
	void OnMessageCountChanged(MCONTACT hContact);
	// returns the contact's status
	int GetContactStatus(MCONTACT hContact);

	// Called to compare two entrys
	static bool CompareEntries(CListEntry<CContactListEntry*,CContactListGroup*> *pLeft,CListEntry<CContactListEntry*,CContactListGroup*> *pRight);

	void SetPosition(CListEntry<CContactListEntry*,CContactListGroup*> *pEntry);
	bool ScrollUp();
	bool ScrollDown();
	void ShowSelection();

	bool SetFont(LOGFONT &lf);
protected:	
	// returns the contacts group path
	tstring GetContactGroupPath(MCONTACT hContact);

	// adds a contact to the list
	void AddContact(MCONTACT hContact);
	// removes a contact from the list
	void RemoveContact(MCONTACT hContact);
	
	// uninitializes the group objects
	void UninitializeGroupObjects();

	// initializes the group objects
	void InitializeGroupObjects();
	// get group object by string
	CContactListGroup *GetGroupObjectByPath(tstring strPath);
	// creates a group object by string
	CContactListGroup *CreateGroupObjectByPath(tstring strPath);
	// deletes a group object by string
	void DeleteGroupObjectByPath(tstring strPath);

	// changes the groups membercount
	void ChangeGroupObjectCounters(tstring strGroup,int iMembers,int iOnline=0,int iEvents=0);

	// returns wether a contact should be listed or not
	bool IsVisible(CContactListEntry *pEntry);

	// sorts all entries of a group
	void SortGroup(CListContainer<CContactListEntry*,CContactListGroup*> *pGroup);

	// tries to find a contact in the specified group
	CListEntry<CContactListEntry*,CContactListGroup*> *FindContactInGroup(MCONTACT hContact,CListContainer<CContactListEntry*,CContactListGroup*> *pGroup);
	
	// tries to find a group in the specified group
	CListContainer<CContactListEntry*,CContactListGroup*> *FindGroupInGroup(tstring strGroup,CListContainer<CContactListEntry*,CContactListGroup*> *pGroup);

	// Adds a group
	CListContainer<CContactListEntry*,CContactListGroup*> *AddGroupByString(tstring strGroup);
	// get group by string
	CListContainer<CContactListEntry*,CContactListGroup*> *GetGroupByString(tstring strGroup);

	// updates the message counter for the specified entry
	void UpdateMessageCounter(CListEntry<CContactListEntry*,CContactListGroup*> *pContactEntry);
	// refreshes the list
	void RefreshList();

	// returns the entry for the specified handle
	CListEntry<CContactListEntry*,CContactListGroup*> *FindContact(MCONTACT hContact);
	
	// returns the entry for the specified group name
	CListContainer<CContactListEntry*,CContactListGroup*> *FindGroup(tstring strGroup);

	// returns the contacts ccontactlistentry class
	static CContactListEntry *GetContactData(CListEntry<CContactListEntry*,CContactListGroup*> *pEntry);

	// Called to delete the specified item
	void DeleteItem(CContactListEntry *pEntry);
	// Called to delete the specified group
	void DeleteGroup(CContactListGroup* pGroup);
	// Called to draw the specified group
	void DrawGroup(CLCDGfx *pGfx,CContactListGroup* pGroup,bool bOpen,bool bSelected);
	// Called to draw the specified entry
	void DrawEntry(CLCDGfx *pGfx,CContactListEntry *pEntry,bool bSelected);
	
	bool m_bUseGroups;
	bool m_bUseMetaContacts;
	vector<CContactListGroup*> m_Groups;
	DWORD m_dwLastScroll;

	HBITMAP m_ahBitmaps[8];
};

#endif