1 /*
2     Kopete Oscar Protocol
3     oscartypes.h - Oscar Type Definitions
4 
5     Copyright (c) 2004 Matt Rogers <mattr@kde.org>
6 
7     Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
8 
9     *************************************************************************
10     *                                                                       *
11     * This library is free software; you can redistribute it and/or         *
12     * modify it under the terms of the GNU Lesser General Public            *
13     * License as published by the Free Software Foundation; either          *
14     * version 2 of the License, or (at your option) any later version.      *
15     *                                                                       *
16     *************************************************************************
17 */
18 
19 #ifndef _OSCARTYPES_H_
20 #define _OSCARTYPES_H_
21 
22 #include "oscartypeclasses.h"
23 #include "oscarguid.h"
24 #include <qglobal.h>
25 #include <qdatetime.h>
26 #include <qstring.h>
27 #include <qstringlist.h>
28 #ifdef Q_OS_WIN
29   // BYTE, WORD, DWORD
30   #include <windows.h>
31 #endif
32 
33 //! Debug Areas
34 const int OSCAR_RAW_DEBUG = 14151;
35 const int OSCAR_GEN_DEBUG = 14150;
36 const int OSCAR_AIM_DEBUG = 14152;
37 const int OSCAR_ICQ_DEBUG = 14153;
38 
39 namespace Oscar
40 {
41 //! Capabilities
42 enum Capability
43 {
44 	CAP_CHAT = 0, CAP_VOICE, CAP_SENDFILE, CAP_DIRECT_ICQ_COMMUNICATION, CAP_IMIMAGE, CAP_BUDDYICON, CAP_SAVESTOCKS,
45 	CAP_GETFILE, CAP_ICQSERVERRELAY, CAP_GAMES, CAP_GAMES2, CAP_SENDBUDDYLIST, CAP_RTFMSGS, CAP_IS_2001,
46 	CAP_TRILLIAN, CAP_TRILLIANCRYPT, CAP_APINFO, CAP_UTF8, CAP_TYPING, CAP_INTEROPERATE,
47 	CAP_KOPETE, CAP_MIRANDA, CAP_QIP, CAP_QIPINFIUM, CAP_QIPPDA, CAP_QIPSYMBIAN, CAP_QIPMOBILE,
48 	CAP_JIMM, CAP_MICQ, CAP_MACICQ, CAP_SIMOLD, CAP_SIMNEW,
49 	CAP_VMICQ, CAP_LICQ, CAP_ANDRQ, CAP_RANDQ, CAP_MCHAT,
50 	CAP_XTRAZ, CAP_TZERS, CAP_HTMLMSGS,
51 	CAP_ICQ_RAMBLER, CAP_ICQ_ABV, CAP_ICQ_NETVIGATOR, CAP_STR_2001, CAP_STR_2002, CAP_XTRAZ_MULTIUSER_CHAT,
52 	CAP_DEVILS, CAP_NEWCAPS, CAP_UNKNOWN2, CAP_PUSH2TALK, CAP_VIDEO, CAP_LAST
53 };
54 
55 Q_DECLARE_FLAGS( Capabilities, Capability )
56 
57 const Guid oscar_caps[] =
58 {
59 	//CAP_CHAT,
60 	Guid( QLatin1String( "748f2420628711d18222444553540000" ) ),
61 
62 	//CAP_VOICE,
63 	Guid( QLatin1String( "094613414c7f11d18222444553540000" ) ),
64 
65 	// CAP_SENDFILE,
66 	Guid( QLatin1String( "094613434c7f11d18222444553540000" ) ),
67 
68 	// CAP_DIRECT_ICQ_COMMUNICATION,
69 	Guid( QLatin1String( "094613444c7f11d18222444553540000" ) ),
70 
71 	// CAP_IMIMAGE,
72 	Guid( QLatin1String( "094613454c7f11d18222444553540000" ) ),
73 
74 	// CAP_BUDDYICON,
75 	Guid( QLatin1String( "094613464c7f11d18222444553540000" ) ),
76 
77 	// CAP_SAVESTOCKS,
78 	Guid( QLatin1String( "094613474c7f11d18222444553540000" ) ),
79 
80 	// CAP_GETFILE,
81 	Guid( QLatin1String( "094613484c7f11d18222444553540000" ) ),
82 
83 	// CAP_ICQSERVERRELAY,
84 	Guid( QLatin1String( "094613494c7f11d18222444553540000" ) ),
85 
86 	// CAP_GAMES,
87 	Guid( QLatin1String( "0946134a4c7f11d18222444553540000" ) ),
88 
89 	// CAP_GAMES2,
90 	Guid( QLatin1String( "0946134a4c7f11d12282444553540000" ) ),
91 
92 	// CAP_SENDBUDDYLIST,
93 	Guid( QLatin1String( "0946134b4c7f11d18222444553540000" ) ),
94 
95 	// CAP_RTFMSGS,
96 	Guid( QLatin1String( "97b12751243c4334ad22d6abf73f1492" ) ),
97 
98 	// CAP_IS_2001,
99 	Guid( QLatin1String( "2e7a6475fadf4dc8886fea3595fdb6df" ) ),
100 
101 	// CAP_TRILLIAN
102 	Guid( QLatin1String( "97b12751243c4334ad22d6abf73f1409" ) ),
103 
104 	// CAP_TRILLIANCRYPT
105 	Guid( QLatin1String( "f2e7c7f4fead4dfbb23536798bdf0000" ) ),
106 
107 	// CAP_APINFO,
108 	Guid( QLatin1String( "AA4A32B5F88448c6A3D78C509719FD5B" ) ),
109 
110 	// CAP_UTF8,
111 	Guid( QLatin1String( "0946134E4C7F11D18222444553540000" ) ),
112 
113 	// CAP_TYPING - client supports mini typing notifications
114 	Guid( QLatin1String( "563FC8090B6f41BD9F79422609DFA2F3" ) ),
115 
116 	// CAP_INTEROPERATE,
117 	Guid( QLatin1String( "0946134D4C7F11D18222444553540000" ) ),
118 
119 	// CAP_KOPETE,
120 	Guid( QByteArray::fromRawData( "Kopete ICQ      ", 16 ) ),
121 
122 	// CAP_MARANDA
123 	Guid( QLatin1String( "4d6972616e64614d0000000000000000" ) ),
124 
125 	// CAP_QIP
126 	Guid( QLatin1String( "563fc8090b6f41514950203230303561" ) ),
127 
128 	// CAP_QIPINFIUM
129 	Guid( QLatin1String( "7C737502C3BE4F3EA69F015313431E1A" ) ),
130 
131 	// CAP_QIPPDA
132 	Guid( QLatin1String( "563FC8090B6F41514950202020202021" ) ),
133 
134 	// CAP_QIPSYMBIAN
135 	Guid( QLatin1String( "51ADD1907204473DA1A149F4A397A41F" ) ),
136 
137 	// CAP_QIPMOBILE
138 	Guid( QLatin1String( "B08262F67F7C4561ADC11C6D75705EC5" ) ),
139 
140 	// CAP_JIMM
141 	Guid( QByteArray::fromRawData( "Jimm ", 16 ) ),
142 
143 	// CAP_MICQ
144 	// last 4 bytes determine version
145 	Guid( QLatin1String( "6d49435120a920522e4b2e2000000000" ) ),
146 
147 	// CAP_MACICQ
148 	Guid( QLatin1String( "DD16F20284E611D490DB00104B9B4B7D" ) ),
149 
150 	// CAP_SIMOLD
151 	// last byte determines version
152 	// (major + 1) << 6 + minor
153 	Guid( QLatin1String( "97B12751243C4334AD22D6ABF73F1400" ) ),
154 
155 	// CAP_SIMNEW
156 	// last 4 bytes determine version (US-ASCII encoded)
157 	Guid( QByteArray::fromRawData( "SIM client  \0\0\0\0", 16 ) ),
158 
159 	// CAP_VMICQ
160 	Guid( QLatin1String( "566d4943512000000000000000000000" ) ),
161 
162 	// CAP_LICQ
163 	Guid( QLatin1String( "4c69637120636c69656e742000000000" ) ),
164 
165 	// CAP_ANDRQ
166 	Guid( QLatin1String( "265251696e7369646500000000000000" ) ),
167 
168 	// CAP_RANDQ
169 	Guid( QLatin1String( "522651696e7369646500000000000000" ) ),
170 
171 	// CAP_MCHAT
172 	Guid( QLatin1String( "6D436861742069637120000000000000" ) ),
173 
174 	// CAP_XTRAZ
175 	Guid( QLatin1String( "1A093C6CD7FD4EC59D51A6474E34F5A0" ) ),
176 
177 	// CAP_TZERS
178 	Guid( QLatin1String( "B2EC8F167C6F451BBD79DC58497888B9" ) ),
179 
180 	// CAP_HTMLMSGS
181 	Guid( QLatin1String( "0138CA7B769A491588F213FC00979EA8" ) ),
182 
183 	// CAP_ICQ_RAMBLER
184 	Guid( QLatin1String( "7e11b778a3534926a80244735208c42a" ) ),
185 
186 	// CAP_ICQ_ABV
187 	Guid( QLatin1String( "00E7E0DFA9D04fe19162c8909A132A1B" ) ),
188 
189 	// CAP_ICQ_NETVIGATOR
190 	Guid( QLatin1String( "4C6B90A33D2D480E89D62E4B2C10D99F" ) ),
191 
192 	// CAP_STR_2001
193 	Guid( QLatin1String( "A0E93F374C7F11D18222444553540000" ) ),
194 
195 	// CAP_STR_2002
196 	Guid( QLatin1String( "10CF40D14C7F11D18222444553540000" ) ),
197 
198 	// CAP_XTRAZ_MULTIUSER_CHAT
199 	Guid( QLatin1String( "67361515612D4C078F3DBDE6408EA041" ) ),
200 
201 	// CAP_DEVILS
202 	Guid( QLatin1String( "0946134C4C7F11D18222444553540000" ) ),
203 
204 	// CAP_NEWCAPS
205 	Guid( QLatin1String( "094600004C7F11D18222444553540000" ) ),
206 
207 	// CAP_UNKNOWN2
208 	Guid( QLatin1String( "B99708B53A924202B069F1E757BB2E17" ) ),
209 
210 	// CAP_PUSH2TALK
211 	Guid( QLatin1String( "E362C1E9121A4B94A6267A74DE24270D" ) ),
212 
213 	// CAP_VIDEO
214 	Guid( QLatin1String( "B6074378F50C4AC790925938502D0591" ) ),
215 
216 	// CAP_LAST,
217 	Guid( QLatin1String( "00000000000000000000000000000000" ) )
218 };
219 
220 enum XStatus
221 {
222 	XSTAT_ANGRY = 0, XSTAT_DUCK, XSTAT_TIRED, XSTAT_PARTY, XSTAT_BEER, XSTAT_THINKING, XSTAT_EATING, XSTAT_TV,
223 	XSTAT_FRIENDS, XSTAT_COFFEE, XSTAT_MUSIC, XSTAT_BUSINESS, XSTAT_CAMERA, XSTAT_FUNNY, XSTAT_PHONE, XSTAT_GAMES,
224 	XSTAT_STUDYING, XSTAT_SHOPPING, XSTAT_SICK, XSTAT_SLEEPING, XSTAT_SURFING, XSTAT_BROWSING, XSTAT_WORKING,
225 	XSTAT_TYPING, XSTAT_PICNIC, XSTAT_COOKING, XSTAT_SMOKING, XSTAT_I_AM_HIGH, XSTAT_WC, XSTAT_TO_BE_OR_NOT_TO_BE,
226 	XSTAT_WATCHING_PRO7, XSTAT_LOVE, XSTAT_LAST
227 
228 };
229 
230 const Guid oscar_xStatus[] =
231 {
232 	// XSTAT_ANGRY
233 	Guid( QLatin1String( "01D8D7EEAC3B492AA58DD3D877E66B92" ) ),
234 
235 	// XSTAT_DUCK
236 	Guid( QLatin1String( "5A581EA1E580430CA06F612298B7E4C7" ) ),
237 
238 	// XSTAT_TIRED
239 	Guid( QLatin1String( "83C9B78E77E74378B2C5FB6CFCC35BEC" ) ),
240 
241 	// XSTAT_PARTY
242 	Guid( QLatin1String( "E601E41C33734BD1BC06811D6C323D81" ) ),
243 
244 	// XSTAT_BEER
245 	Guid( QLatin1String( "8C50DBAE81ED4786ACCA16CC3213C7B7" ) ),
246 
247 	// XSTAT_THINKING
248 	Guid( QLatin1String( "3FB0BD36AF3B4A609EEFCF190F6A5A7F" ) ),
249 
250 	// XSTAT_EATING
251 	Guid( QLatin1String( "F8E8D7B282C4414290F810C6CE0A89A6" ) ),
252 
253 	// XSTAT_TV
254 	Guid( QLatin1String( "80537DE2A4674A76B3546DFD075F5EC6" ) ),
255 
256 	// XSTAT_FRIENDS
257 	Guid( QLatin1String( "F18AB52EDC57491D99DC6444502457AF" ) ),
258 
259 	// XSTAT_COFFEE
260 	Guid( QLatin1String( "1B78AE31FA0B4D3893D1997EEEAFB218" ) ),
261 
262 	// XSTAT_MUSIC
263 	Guid( QLatin1String( "61BEE0DD8BDD475D8DEE5F4BAACF19A7" ) ),
264 
265 	// XSTAT_BUSINESS
266 	Guid( QLatin1String( "488E14898ACA4A0882AA77CE7A165208" ) ),
267 
268 	// XSTAT_CAMERA
269 	Guid( QLatin1String( "107A9A1812324DA4B6CD0879DB780F09" ) ),
270 
271 	// XSTAT_FUNNY
272 	Guid( QLatin1String( "6F4930984F7C4AFFA27634A03BCEAEA7" ) ),
273 
274 	// XSTAT_PHONE
275 	Guid( QLatin1String( "1292E5501B644F66B206B29AF378E48D" ) ),
276 
277 	// XSTAT_GAMES
278 	Guid( QLatin1String( "D4A611D08F014EC09223C5B6BEC6CCF0" ) ),
279 
280 	// XSTAT_STUDYING
281 	Guid( QLatin1String( "609D52F8A29A49A6B2A02524C5E9D260" ) ),
282 
283 	// XSTAT_SHOPPING
284 	Guid( QLatin1String( "63627337A03F49FF80E5F709CDE0A4EE" ) ),
285 
286 	// XSTAT_SICK
287 	Guid( QLatin1String( "1F7A4071BF3B4E60BC324C5787B04CF1" ) ),
288 
289 	// XSTAT_SLEEPING
290 	Guid( QLatin1String( "785E8C4840D34C65886F04CF3F3F43DF" ) ),
291 
292 	// XSTAT_SURFING
293 	Guid( QLatin1String( "A6ED557E6BF744D4A5D4D2E7D95CE81F" ) ),
294 
295 	// XSTAT_BROWSING
296 	Guid( QLatin1String( "12D07E3EF885489E8E97A72A6551E58D" ) ),
297 
298 	// XSTAT_WORKING
299 	Guid( QLatin1String( "BA74DB3E9E24434B87B62F6B8DFEE50F" ) ),
300 
301 	// XSTAT_TYPING
302 	Guid( QLatin1String( "634F6BD8ADD24AA1AAB9115BC26D05A1" ) ),
303 
304 	// XSTAT_PICNIC
305 	Guid( QLatin1String( "2CE0E4E57C6443709C3A7A1CE878A7DC" ) ),
306 
307 	// XSTAT_COOKING
308 	Guid( QLatin1String( "101117C9A3B040F981AC49E159FBD5D4" ) ),
309 
310 	// XSTAT_SMOKING
311 	Guid( QLatin1String( "160C60BBDD4443F39140050F00E6C009" ) ),
312 
313 	// XSTAT_I_AM_HIGH
314 	Guid( QLatin1String( "6443C6AF22604517B58CD7DF8E290352" ) ),
315 
316 	// XSTAT_WC
317 	Guid( QLatin1String( "16F5B76FA9D240358CC5C084703C98FA" ) ),
318 
319 	// XSTAT_TO_BE_OR_NOT_TO_BE
320 	Guid( QLatin1String( "631436FF3F8A40D0A5CB7B66E051B364" ) ),
321 
322 	// XSTAT_WATCHING_PRO7
323 	Guid( QLatin1String( "B70867F538254327A1FFCF4CC1939797" ) ),
324 
325 	// XSTAT_LOVE
326 	Guid( QLatin1String( "DDCF0EA971954048A9C6413206D6F280" ) ),
327 
328 	// XSTAT_LAST
329 	Guid( QLatin1String( "00000000000000000000000000000000" ) )
330 };
331 
332 //! Oscar Data Types
333 typedef quint8 BYTE;
334 typedef quint16 WORD;
335 typedef quint32 DWORD;
336 
337 struct FLAP
338 {
339 	BYTE channel;
340 	WORD sequence;
341 	WORD length;
342 };
343 
344 struct SNAC
345 {
346 	WORD family;
347 	WORD subtype;
348 	WORD flags;
349 	DWORD id;
350 };
351 
352 struct RateInfo
353 {
354 	WORD classId;
355 	DWORD windowSize;
356 	DWORD initialLevel;
357 	DWORD clearLevel;
358 	DWORD alertLevel;
359 	DWORD limitLevel;
360 	DWORD disconnectLevel;
361 	DWORD currentLevel;
362 	DWORD maxLevel;
363 	DWORD lastTime;
364 	BYTE currentState;
365 };
366 
367 struct ChatExchangeInfo
368 {
369 	WORD number;
370     WORD maxRooms;
371     WORD maxRoomNameLength;
372 	WORD maxMsgLength;
373 	BYTE flags;
374 	QString description;
375 	BYTE canCreate;
376 	QString charset1;
377 	QString charset2;
378 	QString lang1;
379 	QString lang2;
380 };
381 
382 struct ChatRoomInfo
383 {
384 	WORD exchange;
385 	QByteArray cookie;
386 	WORD instance;
387 	QString description;
388 	WORD maxMsgLength;
389 	QString name;
390 };
391 
392 struct OFT
393 {
394 	WORD type;
395 	QByteArray cookie;
396 	DWORD fileSize;
397 	DWORD modTime;
398 	DWORD checksum;
399 	DWORD bytesSent;
400 	DWORD sentChecksum;
401 	BYTE flags;
402 	QString fileName;
403 	WORD fileCount;
404 	WORD filesLeft;
405 	WORD partCount;
406 	WORD partsLeft;
407 	DWORD totalSize;
408 };
409 
410 struct OFTRendezvous
411 {
412 	QByteArray cookie;
413 	WORD fileCount;
414 	DWORD totalSize;
415 	QString fileName;
416 
417 	QStringList files;
418 	QString dir;
419 };
420 
421 struct ClientVersion
422 {
423 	QString clientString;
424 	WORD clientId;
425 	WORD major;
426 	WORD minor;
427 	WORD point;
428 	WORD build;
429 	DWORD other;
430 	QString country;
431 	QString lang;
432 };
433 
434 	/* ICQ Version Characteristics */
435 	const unsigned char ICQ_TCP_VERSION 	= 0x0009; // 9 for rtf support
436 
437 	/* AIM Version Characteristics */
438 	const char AIM_MD5_STRING[]     = "AOL Instant Messenger (SM)";
439 
440 	/* SSI types */
441 	const WORD ROSTER_CONTACT       = 0x0000; // a normal contact
442 	const WORD ROSTER_GROUP         = 0x0001; // a group of contacts
443 	const WORD ROSTER_VISIBLE       = 0x0002; // a contact on the visible list
444 	const WORD ROSTER_INVISIBLE     = 0x0003; // a contact on the invisible list
445 	const WORD ROSTER_VISIBILITY    = 0x0004; // this entry contains visibility setting TLV(0xca)=TLV(202)
446 	const WORD ROSTER_PRESENCE      = 0x0005; // Presence info (if others can see your idle status, etc)
447 	const WORD ROSTER_ICQSHORTCUT   = 0x0009; // Unknown or ICQ2k shortcut bar items
448 	const WORD ROSTER_IGNORE        = 0x000e; // a contact on the ignore list
449 	const WORD ROSTER_LASTUPDATE    = 0x000F; // Last update date (name: "LastUpdateDate")
450 	const WORD ROSTER_NONICQ        = 0x0010; // a non-icq contact, no UIN, used to send SMS
451 	const WORD ROSTER_IMPORTTIME    = 0x0013; // roster import time (name: "Import time")
452 	const WORD ROSTER_BUDDYICONS    = 0x0014; // Buddy icon info. (names: from "0" and incrementing by one)
453 
454     /* User classes/statuses */
455     const WORD CLASS_UNCONFIRMED    = 0x0001; // AOL Unconfirmed user
456     const WORD CLASS_ADMINISTRATOR  = 0x0002; // AOL Administrator
457     const WORD CLASS_AOL            = 0x0004; // AOL Staff
458     const WORD CLASS_COMMERCIAL     = 0x0008; // AOL commercial account
459     const WORD CLASS_FREE           = 0x0010; // ICQ non-commercial account
460     const WORD CLASS_AWAY           = 0x0020; // Away status
461     const WORD CLASS_ICQ            = 0x0040; // ICQ user
462     const WORD CLASS_WIRELESS       = 0x0080; // AOL wireless user
463     const WORD CLASS_UNKNOWN100     = 0x0100; // Unknown
464     const WORD CLASS_UNKNOWN400     = 0x0400; // Unknown
465     const WORD CLASS_UNKNOWN800     = 0x0800; // Unknown
466 
467     const WORD STATUS_ONLINE        = 0x0000; // Online
468     const WORD STATUS_AWAY          = 0x0001; // Away
469     const WORD STATUS_DND           = 0x0002; // Do not Disturb
470     const WORD STATUS_NA            = 0x0004; // Not Available
471     const WORD STATUS_OCCUPIED      = 0x0010; // Occupied (BUSY/BISY)
472     const WORD STATUS_FREE4CHAT     = 0x0020; // Free for chat
473     const WORD STATUS_INVISIBLE     = 0x0100; // Invisible
474 }
475 
476 Q_DECLARE_OPERATORS_FOR_FLAGS(Oscar::Capabilities)
477 
478 #endif
479 
480