summaryrefslogtreecommitdiff
path: root/plugins/MyDetails/src/data.h
blob: 23fee6839b3e7953b5ce3f9ae041947d3a1fcec1 (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
/*
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(wchar_t *dest, wchar_t *src, size_t maxlen);

public:
	// Name of protocol
	char name[256];
	wchar_t description[256];
	wchar_t nickname[256];
	wchar_t status_name[256];
	wchar_t status_message[1024];
	wchar_t listening_to[1024];
	AVATARCACHEENTRY *ace;
	wchar_t 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 wchar_t *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 wchar_t *file_name);
	//void SetAvatar(const char *file_name, HBITMAP hBmp);

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

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

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



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

public:
	wchar_t default_nick[256];
	wchar_t default_avatar_file[256];
	wchar_t 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 wchar_t *file);

	void SetNicks(const wchar_t *nick);

	void SetStatus(int aStatus);

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

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

	bool CanSetStatusMsgPerProtocol();

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

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

extern ProtocolArray *protocols;



void InitProtocolData();
void DeInitProtocolData();






#endif // __DATA_H__