summaryrefslogtreecommitdiff
path: root/plugins/MyDetails/data.h
blob: 9c458b50dd62b7a54515e452cdd7ef1a5d8ac435 (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/* 
Copyright (C) 2005 Ricardo Pescuma Domenecci

This is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.

This is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Library General Public
License along with this file; see the file license.txt.  If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  
*/


#ifndef __DATA_H__
# define __DATA_H__


//#include "protocol_config.h"

class Protocol
{
	// Attributes ////////////
	std::string name;
	
	std::string description;

	bool avatar_initialized;
	std::string avatar_file;
	HBITMAP avatar_bmp;

	bool status_message_initialized;
	std::string status_message;

	bool nickname_initialized;
	std::string nickname;

	bool locked_initialized;
	bool locked;

	bool emails_initialized;
	int emails;

	bool listening_to_initialized;
	std::string listening_to;

	bool status_initialized;
	std::string status_name;
	std::string custom_status_name_key;
	std::string custom_status_message_key;
	int status;
	int custom_status;

public:	
	Protocol(const char *name);
	~Protocol();

	bool IsValid();
	operator bool ();

	void UpdateAll();

	const char * GetName();
	const char * GetDescription();

	const char * GetStatusName();
	const char * GetCustomStatusNameKey();
	const char * GetCustomStatusMessageKey();
	int GetStatus();
	int GetCustomStatus();
	void SetStatus(int aStatus);

	bool HasAvatar();
	bool CanGetAvatar();
	const char * GetAvatarFile();
	HBITMAP GetAvatarImage();

	bool CanSetAvatar();
	void SetAvatar(const TCHAR *file_name);

	bool CanGetNick();
	const char * GetNick();
	int GetNickMaxLength();
	bool CanSetNick();
	void SetNick(const TCHAR *nick);

	bool CanGetListeningTo();
	bool CanSetListeningTo();
	bool ListeningToEnabled();
	const char * GetListeningTo();

	bool CanGetStatusMsg();
	bool CanGetStatusMsg(int aStatus);
	void GetStatusMsg(int aStatus, TCHAR *msg, size_t msg_size);
	const char * GetStatusMsg();

	bool CanSetStatusMsg();
	bool CanSetStatusMsg(int aStatus);
	void SetStatusMsg(const TCHAR *message);
	void SetStatusMsg(int aStatus, const TCHAR *message);

	bool IsLocked();

	bool CanGetEmailCount();
	int GetEmailCount();

	int Call(const char *service, WPARAM wParam = 0, LPARAM lParam = 0);
	bool CanCall(const char *service);

	std::string GetDBSettingString(const char *key, const char *def = "");

private:
	void UpdateStatus();
	void UpdateAvatar();
	void UpdateNick();
	void UpdateListeningTo();
	void UpdateStatusMsg();
	void UpdateLocked();
	void UpdateEmailCount();
};



class ProtocolArray
{
public:
	TCHAR default_nick[256];
	TCHAR default_avatar_file[256];
	TCHAR default_status_message[256];

	// Methods ///////////////

	ProtocolArray();

	bool CanSetAvatars();
	void SetAvatars(const TCHAR *file);

	void SetNicks(const TCHAR *nick);

	void SetStatus(int aStatus);

	void SetStatusMsgs(const TCHAR *message);
	void SetStatusMsgs(int status, const TCHAR *message);

	int GetGlobalStatus();

	void GetDefaultNick();	// Copy to cache
	void GetDefaultAvatar();	// Copy to cache
	TCHAR * GetDefaultStatusMsg();	// Copy to cache
	TCHAR * GetDefaultStatusMsg(int status);

	bool CanSetListeningTo();
	bool ListeningToEnabled();
};

extern ProtocolArray *protocols;


void SetCurrentProtocol(int index);
Protocol * GetCurrentProtocol(bool createIfDontExist = true);
int GetCurrentProtocolIndex();

void GetProtocols(std::vector<Protocol> *result);
int GetProtocolIndexByName(const char *moduleName);
int GetNumProtocols();
Protocol GetProtocolByIndex(int index);
Protocol GetProtocolByName(const char *proto);

void InitProtocolData();
void DeInitProtocolData();






#endif // __DATA_H__