1 /*
2 	Kopete Oscar Protocol
3 	icquserinfo.h - ICQ User Info Data Types
4 
5 	Copyright (c) 2004 Matt Rogers <mattr@kde.org>
6 	Copyright (c) 2006 Roman Jarosz <kedgedev@centrum.cz>
7 
8 	Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
9 
10 	*************************************************************************
11 	*                                                                       *
12 	* This library is free software; you can redistribute it and/or         *
13 	* modify it under the terms of the GNU Lesser General Public            *
14 	* License as published by the Free Software Foundation; either          *
15 	* version 2 of the License, or (at your option) any later version.      *
16 	*                                                                       *
17 	*************************************************************************
18 */
19 
20 #ifndef _ICQUSERINFO_H_
21 #define _ICQUSERINFO_H_
22 
23 #include <QByteArray>
24 #include <QList>
25 
26 #include "liboscar_export.h"
27 #include "oscartypes.h"
28 #include "icqinfovalue.h"
29 
30 class Buffer;
31 
32 /**
33  * @file icquserinfo.h
34  * Classes encapsulating user data retrieved from the server
35  */
36 
37 class LIBOSCAR_EXPORT ICQInfoBase
38 {
39 public:
40 
ICQInfoBase()41 	ICQInfoBase() : m_sequence( 0 ) {}
~ICQInfoBase()42 	virtual ~ICQInfoBase() {}
43 	virtual void fill( Buffer* buffer ) = 0;
store(Buffer *)44 	virtual void store( Buffer* ) {}
45 
setSequenceNumber(Oscar::DWORD number)46 	void setSequenceNumber( Oscar::DWORD number ) { m_sequence = number; }
sequenceNumber()47 	Oscar::DWORD sequenceNumber() { return m_sequence; }
48 
49 private:
50 	Oscar::DWORD m_sequence;
51 };
52 
53 class LIBOSCAR_EXPORT ICQShortInfo : public ICQInfoBase
54 {
55 public:
56 	ICQShortInfo();
~ICQShortInfo()57 	~ICQShortInfo() {}
58 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
59 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
60 
61 public:
62 	unsigned long uin;
63 	QByteArray nickname;
64 	QByteArray firstName;
65 	QByteArray lastName;
66 	QByteArray email;
67 	ICQInfoValue<bool> needsAuth;
68 	ICQInfoValue<bool> webAware; // 0=offline, 1=online, 2=not webaware
69 // 	unsigned int gender;
70 };
71 
72 class LIBOSCAR_EXPORT ICQGeneralUserInfo : public ICQInfoBase
73 {
74 public:
75 	ICQGeneralUserInfo();
~ICQGeneralUserInfo()76 	~ICQGeneralUserInfo() {}
77 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
78 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
79 
80 public:
81 	ICQInfoValue<unsigned long> uin;
82 	ICQInfoValue<QByteArray> nickName;
83 	ICQInfoValue<QByteArray> firstName;
84 	ICQInfoValue<QByteArray> lastName;
85 	ICQInfoValue<QByteArray> email;
86 	ICQInfoValue<QByteArray> city;
87 	ICQInfoValue<QByteArray> state;
88 	ICQInfoValue<QByteArray> phoneNumber;
89 	ICQInfoValue<QByteArray> faxNumber;
90 	ICQInfoValue<QByteArray> address;
91 	ICQInfoValue<QByteArray> cellNumber;
92 	ICQInfoValue<QByteArray> zip;
93 	ICQInfoValue<int> country;
94 	ICQInfoValue<char> timezone;
95 	ICQInfoValue<bool> publishEmail;
96 	ICQInfoValue<bool> allowsDC;
97 	ICQInfoValue<bool> webAware;
98 	ICQInfoValue<bool> needsAuth;
99 };
100 
101 class LIBOSCAR_EXPORT ICQWorkUserInfo : public ICQInfoBase
102 {
103 public:
104 	ICQWorkUserInfo();
~ICQWorkUserInfo()105 	~ICQWorkUserInfo() {}
106 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
107 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
108 
109 public:
110 	ICQInfoValue<QByteArray> city;
111 	ICQInfoValue<QByteArray> state;
112 	ICQInfoValue<QByteArray> phone;
113 	ICQInfoValue<QByteArray> fax;
114 	ICQInfoValue<QByteArray> address;
115 	ICQInfoValue<QByteArray> zip;
116 	ICQInfoValue<int> country;
117 	ICQInfoValue<QByteArray> company;
118 	ICQInfoValue<QByteArray> department;
119 	ICQInfoValue<QByteArray> position;
120 	ICQInfoValue<int> occupation;
121 	ICQInfoValue<QByteArray> homepage;
122 };
123 
124 class LIBOSCAR_EXPORT ICQMoreUserInfo : public ICQInfoBase
125 {
126 public:
127 	ICQMoreUserInfo();
~ICQMoreUserInfo()128 	~ICQMoreUserInfo() {}
129 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
130 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
131 
132 public:
133 	ICQInfoValue<int> age;
134 	ICQInfoValue<unsigned int> gender;
135 	ICQInfoValue<QByteArray> homepage;
136 	ICQInfoValue<int> birthdayDay;
137 	ICQInfoValue<int> birthdayMonth;
138 	ICQInfoValue<int> birthdayYear;
139 	ICQInfoValue<unsigned int> lang1;
140 	ICQInfoValue<unsigned int> lang2;
141 	ICQInfoValue<unsigned int> lang3;
142 	ICQInfoValue<QByteArray> ocity;
143 	ICQInfoValue<QByteArray> ostate;
144 	ICQInfoValue<int> ocountry;
145 	ICQInfoValue<int> marital;
146 	ICQInfoValue<bool> sendInfo;
147 };
148 
149 class LIBOSCAR_EXPORT ICQEmailInfo : public ICQInfoBase
150 {
151 public:
152 	ICQEmailInfo();
~ICQEmailInfo()153 	~ICQEmailInfo() {}
154 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
155 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
156 
157 public:
158 	class EmailItem
159 	{
160 	public:
161 		bool publish;
162 		QByteArray email;
163 		bool operator==( const EmailItem& item ) const
164 		{
165 			return ( publish == item.publish && email == item.email );
166 		}
167 	};
168 
169 	ICQInfoValue< QList<EmailItem> > emailList;
170 };
171 
172 class LIBOSCAR_EXPORT ICQNotesInfo : public ICQInfoBase
173 {
174 public:
175 	ICQNotesInfo();
~ICQNotesInfo()176 	~ICQNotesInfo() {}
177 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
178 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
179 
180 public:
181 	ICQInfoValue<QByteArray> notes;
182 };
183 
184 class LIBOSCAR_EXPORT ICQInterestInfo : public ICQInfoBase
185 {
186 public:
187 	ICQInterestInfo();
~ICQInterestInfo()188 	~ICQInterestInfo() {}
189 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
190 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
191 
192 public:
193 	ICQInfoValue<int> topics[4];
194 	ICQInfoValue<QByteArray> descriptions[4];
195 };
196 
197 class LIBOSCAR_EXPORT ICQOrgAffInfo : public ICQInfoBase
198 {
199 public:
200 	ICQOrgAffInfo();
~ICQOrgAffInfo()201 	~ICQOrgAffInfo() {}
202 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
203 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
204 
205 public:
206 	ICQInfoValue<int> org1Category;
207 	ICQInfoValue<int> org2Category;
208 	ICQInfoValue<int> org3Category;
209 	ICQInfoValue<QByteArray> org1Keyword;
210 	ICQInfoValue<QByteArray> org2Keyword;
211 	ICQInfoValue<QByteArray> org3Keyword;
212 	ICQInfoValue<int> pastAff1Category;
213 	ICQInfoValue<int> pastAff2Category;
214 	ICQInfoValue<int> pastAff3Category;
215 	ICQInfoValue<QByteArray> pastAff1Keyword;
216 	ICQInfoValue<QByteArray> pastAff2Keyword;
217 	ICQInfoValue<QByteArray> pastAff3Keyword;
218 };
219 
220 class LIBOSCAR_EXPORT ICQSearchResult
221 {
222 public:
223 	ICQSearchResult();
224 	void fill( Buffer* buffer );
225 	quint32 uin;
226 	QByteArray firstName;
227 	QByteArray lastName;
228 	QByteArray nickName;
229 	QByteArray email;
230 	bool auth;
231 	bool online;
232 	char gender;
233 	quint16 age;
234 };
235 
236 class LIBOSCAR_EXPORT ICQWPSearchInfo
237 {
238 public:
239 	ICQWPSearchInfo();
240 
241 	QByteArray firstName;
242 	QByteArray lastName;
243 	QByteArray nickName;
244 	QByteArray email;
245 	int age;
246 	int gender;
247 	int language;
248 	QByteArray city;
249 	QByteArray state;
250 	int country;
251 	QByteArray company;
252 	QByteArray department;
253 	QByteArray position;
254 	int occupation;
255 	bool onlineOnly;
256 };
257 
258 class LIBOSCAR_EXPORT ICQFullInfo : public ICQInfoBase
259 {
260 public:
261 	/**
262 	 * ICQFullInfo constructor
263 	 * @param assumeDirty if false only values that where explicitly set with set method will be stored.
264 	 */
265 	ICQFullInfo( bool assumeDirty = true );
~ICQFullInfo()266 	~ICQFullInfo() {}
267 
268 	void fill( Buffer* buffer ) Q_DECL_OVERRIDE;
269 	void store( Buffer* buffer ) Q_DECL_OVERRIDE;
270 
271 public:
272 	class AddressItem
273 	{
274 	public:
AddressItem()275 		AddressItem() : country(0) {}
276 
277 		QByteArray	address;
278 		QByteArray	city;
279 		QByteArray	state;
280 		QByteArray	zip;
281 		quint32		country;
282 	};
283 	typedef QList<AddressItem> AddressItemList;
284 
285 	class WorkItem
286 	{
287 	public:
WorkItem()288 		WorkItem() : country(0) {}
289 
290 		QByteArray position;
291 		QByteArray companyName;
292 		QByteArray department;
293 		QByteArray homepage;
294 		QByteArray address;
295 		QByteArray city;
296 		QByteArray state;
297 		QByteArray zip;
298 		quint32 country;
299 	};
300 	typedef QList<WorkItem> WorkItemList;
301 
302 	class InfoItem {
303 	public:
InfoItem()304 		InfoItem() : category(0) {}
305 
306 		quint16 category;
307 		QByteArray description;
308 	};
309 	typedef QList<InfoItem> InfoItemList;
310 
311 	ICQInfoValue<QByteArray>		uin;
312 	ICQInfoValue<QByteArray>		firstName;
313 	ICQInfoValue<QByteArray>		lastName;
314 	ICQInfoValue<QByteArray>		nickName;
315 	ICQInfoValue<QByteArray>		homepage;
316 	ICQInfoValue<char>				gender;				//0x00 - None, 0x01 - Female, 0x02 - Male
317 	ICQInfoValue<bool>				webAware;
318 	ICQInfoValue<quint16>			privacyProfile;		//0x00 - Low, 0x01 - Medium, 0x02 - High
319 
320 	ICQInfoValue<quint16>			language1;
321 	ICQInfoValue<quint16>			language2;
322 	ICQInfoValue<quint16>			language3;
323 
324 	ICQInfoValue<QByteArray>		statusDescription;
325 
326 	ICQInfoValue<quint16>			timezone;
327 	ICQInfoValue<QByteArray>		notes;
328 
329 	ICQInfoValue<AddressItemList>	homeList;
330 	ICQInfoValue<AddressItemList>	originList;
331 	ICQInfoValue<WorkItemList>		workList;
332 
333 	ICQInfoValue<InfoItemList>		interestList;
334 	ICQInfoValue<InfoItemList>		organizationList;
335 	ICQInfoValue<InfoItemList>		pastAffliationList;
336 	ICQInfoValue<InfoItemList>		phoneList;
337 
338 private:
339 	AddressItemList parseAddressItemList( const QByteArray& data ) const;
340 	QByteArray storeAddressItemList( const AddressItemList& infoList ) const;
341 	WorkItemList parseWorkItemList( const QByteArray& data ) const;
342 	QByteArray storeWorkItemList( const WorkItemList& infoList ) const;
343 	InfoItemList parseInfoItemList( const QByteArray& data ) const;
344 	QByteArray storeInfoItemList( const InfoItemList& infoList ) const;
345 };
346 
347 #endif
348