summaryrefslogtreecommitdiff
path: root/plugins/MyDetails/src/data.h
blob: f2ab3e555a1ec0c98a37ab5b934f9a2e8e9c31c9 (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
/* 
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 : public MZeroedObject
{
	// Attributes ////////////
protected:
	bool valid;
	bool can_set_nick;
	bool can_have_avatar;
	bool can_have_listening_to;
	int PF3;

	void lcopystr(TCHAR *dest, TCHAR *src, size_t maxlen);

public:
	// Name of protocol
	char name[256];
	TCHAR description[256];
	TCHAR nickname[256];
	TCHAR status_name[256];
	TCHAR status_message[1024];
	TCHAR listening_to[1024];
	AVATARCACHEENTRY *ace;
	TCHAR avatar_file[1024];
	HBITMAP avatar_bmp;
	int status;
	int custom_status;

	int avatar_max_width;
	int avatar_max_height;

	bool data_changed;

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

	Protocol(const char *name, const TCHAR *descr);
	~Protocol();

	bool IsValid();

	int GetStatus();		// Copy to cache and return a copy
	void SetStatus(int aStatus);

	bool HasAvatar();
	bool CanGetAvatar();
	void GetAvatar();		// Copy to cache

	bool CanSetAvatar();
	void SetAvatar(const TCHAR *file_name);
	//void SetAvatar(const char *file_name, HBITMAP hBmp);

	bool CanGetNick();
	TCHAR * GetNick();			// Copy to cache and return a copy
	int GetNickMaxLength();
	bool CanSetNick();
	void SetNick(const TCHAR *nick);

	bool CanGetListeningTo();
	bool CanSetListeningTo();
	bool ListeningToEnabled();
	TCHAR * GetListeningTo();	// Copy to cache and return a copy

	bool CanGetStatusMsg();
	bool CanGetStatusMsg(int aStatus);
	TCHAR * GetStatusMsg();	// Copy to cache and return a copy
	void GetStatusMsg(int aStatus, TCHAR *msg, size_t msg_size);
	bool CanSetStatusMsg();
	bool CanSetStatusMsg(int aStatus);
	void SetStatusMsg(const TCHAR *message);
	void SetStatusMsg(int aStatus, const TCHAR *message);
};



class ProtocolArray
{
protected:
	// Attributes ////////////
	Protocol **buffer;
	int buffer_len;

public:
	TCHAR default_nick[256];
	TCHAR default_avatar_file[256];
	TCHAR default_status_message[256];

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

	ProtocolArray(int max_size);
	virtual ~ProtocolArray();

	int GetSize();

	void Add(Protocol *p);
	Protocol* Get(int i);
	Protocol* Get(const char *name);

	void GetAvatars();
	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);

	void GetStatusMsgs();
	void GetStatuses();
	int  GetGlobalStatus();

	bool CanSetStatusMsgPerProtocol();

	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 InitProtocolData();
void DeInitProtocolData();






#endif // __DATA_H__