1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2000-2012 Licq developers <licq-dev@googlegroups.com>
4  *
5  * Licq is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Licq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Licq; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef LICQICQ_PACKET_SRV_H
21 #define LICQICQ_PACKET_SRV_H
22 
23 #include <cstring>
24 #include <list>
25 #include <map>
26 #include <pthread.h>
27 #include <stdint.h>
28 #include <string>
29 
30 #include <licq/userid.h>
31 #include <licq/packet.h>
32 
33 #include "buffer.h"
34 #include "defines.h"
35 
36 namespace Licq
37 {
38 typedef std::list<std::string> StringList;
39 typedef std::map<unsigned int, std::string> UserCategoryMap;
40 class Buffer;
41 class INetSocket;
42 class User;
43 }
44 
45 namespace LicqIcq
46 {
47 class User;
48 
49 typedef Licq::Buffer CBuffer;
50 typedef Licq::Packet CPacket;
51 
52 typedef std::map<int, std::string> GroupNameMap;
53 
54 // values of extra info to identify plugin request
55 const unsigned short ServerInfoPluginRequest     = 3;
56 const unsigned short ServerStatusPluginRequest   = 4;
57 
58 
59 //=====ServerTCP===============================================================
60 
61 //-----SrvPacketTcp------------------------------------------------------------
62 
63 class CSrvPacketTcp : public CPacket
64 {
65 public:
66   virtual ~CSrvPacketTcp();
67 
getBuffer()68   virtual Licq::Buffer* getBuffer() { return buffer; }
69 
70   // Packet details
icqChannel()71   unsigned char icqChannel() const { return myIcqChannel; }
Sequence()72   virtual unsigned short Sequence()    { return m_nSequence; }
SubSequence()73   virtual unsigned short SubSequence() { return m_nSubSequence; }
SNAC()74   virtual unsigned long  SNAC() { return ((m_nFamily << 16) | (m_nSubType)); }
SubCommand()75   virtual unsigned short SubCommand()  { return m_nSubCommand; }
76 
77   // Misc.
ExtraInfo()78   virtual unsigned short ExtraInfo() { return m_nExtraInfo; }
79   virtual CBuffer *Finalize(Licq::INetSocket*);
SetExtraInfo(unsigned short e)80   void SetExtraInfo(unsigned short e)  { m_nExtraInfo = e; }
81 
82 protected:
83   CSrvPacketTcp(unsigned char);
84   void InitBuffer();
85   static void initSequence(int service);
86 
87   static bool s_bRegistered;
88   static unsigned short s_nSequence[32];
89   static unsigned short s_nSubSequence;
90   static pthread_mutex_t s_xMutex;
91 
92   unsigned char myIcqChannel;
93   unsigned short m_nSequence;
94   unsigned short m_nSubSequence;
95   unsigned short m_nFamily;
96   unsigned short m_nSubType;
97   unsigned short m_nSubCommand;
98   unsigned short m_nExtraInfo;
99   unsigned short m_nService;
100 
101   char *m_szSequenceOffset;
102 
103   Buffer* buffer;
104 };
105 
106 //=====UDP======================================================================
107 
108 //-----PacketUdp----------------------------------------------------------------
109 class CPacketUdp : public CPacket
110 {
111 public:
112    virtual ~CPacketUdp();
113 
getBuffer()114   virtual Licq::Buffer* getBuffer() { return buffer; }
115 
116    virtual CBuffer *Finalize(Licq::INetSocket*);
Sequence()117    virtual unsigned short Sequence() { return m_nSequence; }
SubSequence()118    virtual unsigned short SubSequence() { return m_nSubSequence; }
SubCommand()119    virtual unsigned short SubCommand()  { return 0; }
120 protected:
121    CPacketUdp(unsigned short _nCommand);
122    void InitBuffer();
123 
124    static bool s_bRegistered;
125 
126 #if ICQ_VERSION == 2
127    unsigned short m_nVersion;
128    unsigned short m_nCommand;
129    unsigned short m_nSequence;
130    unsigned short m_nSubSequence;
131 #elif ICQ_VERSION == 4
132    unsigned short m_nVersion;
133    unsigned short m_nRandom;
134    unsigned short m_nZero;
135    unsigned short m_nCommand;
136    unsigned short m_nSequence;
137    unsigned short m_nSubSequence;
138    unsigned long  m_nCheckSum;
139 #else
140    unsigned short m_nVersion;
141    unsigned long  m_nZero;
142    unsigned long  m_nSessionId;
143    unsigned short m_nCommand;
144    unsigned short m_nSequence;
145    unsigned short m_nSubSequence;
146    unsigned long  m_nCheckSum;
147 #endif
148 
149    static unsigned short s_nSequence;
150    static unsigned short s_nSubSequence;
151    static unsigned long  s_nSessionId;
152 
153   Licq::Buffer* buffer;
154 };
155 
156 class CPU_ConnectStart : public CSrvPacketTcp
157 {
158 public:
159   CPU_ConnectStart();
160 };
161 
162 //-----Logon--------------------------------------------------------------------
163 class CPU_Logon : public CSrvPacketTcp
164 {
165 public:
166   CPU_Logon(const std::string& password, const std::string& accountId, unsigned short _nLogonStatus);
167   virtual ~CPU_Logon();
168 protected:
169   unsigned long  m_nLogonStatus;
170   unsigned long  m_nTcpVersion;
171 };
172 
173 //-----Logoff-------------------------------------------------------------------
174 class CPU_Logoff : public CSrvPacketTcp
175 {
176 public:
177    CPU_Logoff();
178    virtual ~CPU_Logoff();
179 };
180 
181 //-----SendCookie---------------------------------------------------------------
182 class CPU_SendCookie : public CSrvPacketTcp
183 {
184 public:
185   CPU_SendCookie(const std::string& cookie, unsigned short nService = 0);
186   virtual ~CPU_SendCookie();
187 };
188 
189 //-----CommonFamily----------------------------------------------------------
190 class CPU_CommonFamily : public CSrvPacketTcp
191 {
192 public:
193   CPU_CommonFamily(unsigned short Family, unsigned short SubType);
194   virtual ~CPU_CommonFamily();
195 
196 protected:
197   void InitBuffer();
198 };
199 
200 class CPU_GenericFamily : public CPU_CommonFamily
201 {
202 public:
203   CPU_GenericFamily(unsigned short Family, unsigned short SubType,
204                     unsigned short nService = 0);
205   virtual ~CPU_GenericFamily();
206 };
207 
208 class CPU_RequestLogonSalt : public CPU_CommonFamily
209 {
210 public:
211   CPU_RequestLogonSalt(const std::string &);
212 };
213 
214 class CPU_NewLogon : public CPU_CommonFamily
215 {
216 public:
217   CPU_NewLogon(const std::string& password, const std::string& accountId, const std::string& md5Salt);
218 };
219 
220 #if ICQ_VERSION == 2 || ICQ_VERSION == 6
221 //-----Register----------------------------------------------------------------
222 // Doesn't actually descend from CPacketUdp in version 2 but we keep the
223 // name the same for simplicity
224 class CPU_Register : public CPacketUdp
225 {
226 public:
227   CPU_Register(const std::string& password);
228   virtual ~CPU_Register();
229 
Sequence()230   virtual unsigned short Sequence() { return m_nSequence; }
SubSequence()231   virtual unsigned short SubSequence() { return 0; }
SubCommand()232   virtual unsigned short SubCommand() { return 0; }
233 protected:
getSize()234   virtual unsigned long getSize()       { return 1; }
235 
236   /* 02 00 FC 03 01 00 02 00 04 00 65 66 67 00 72 00 00 00 00 00 00 00 */
237   unsigned short m_nVersion;
238   unsigned short m_nCommand;
239   unsigned short m_nSequence;
240   unsigned short m_nUnknown1;
241   unsigned short m_nPasswdLen;
242   std::string myPassword;
243   unsigned long  m_nUnknown2;
244   unsigned long  m_nUnknown3;
245 };
246 #elif ICQ_VERSION == 4 || ICQ_VERSION == 5
247 //-----Register----------------------------------------------------------------
248 class CPU_Register : public CPacketUdp
249 {
250 public:
251   CPU_Register(const std::string& password);
252   virtual ~CPU_Register();
253 };
254 #elif ICQ_VERSION > 6
255 class CPU_RegisterFirst : public CSrvPacketTcp
256 {
257 public:
258   CPU_RegisterFirst();
259   virtual ~CPU_RegisterFirst();
260 };
261 
262 class CPU_Register : public CPU_CommonFamily
263 {
264 public:
265   CPU_Register(const std::string& password);
266   virtual ~CPU_Register();
267 };
268 #endif
269 
270 //-----VerifyRegistration------------------------------------------------------
271 class CPU_VerifyRegistration : public CPU_CommonFamily
272 {
273 public:
274   CPU_VerifyRegistration();
275   virtual ~CPU_VerifyRegistration();
276 };
277 
278 //-----SendVerification--------------------------------------------------------
279 class CPU_SendVerification : public CPU_CommonFamily
280 {
281 public:
282   CPU_SendVerification(const std::string& password, const std::string& verification);
283   virtual ~CPU_SendVerification();
284 };
285 
286 //-----ListRequestRights-----------------------------------------------------
287 class CPU_ListRequestRights : public CPU_CommonFamily
288 {
289 public:
290   CPU_ListRequestRights();
291 };
292 
293 //-----ImICQ------------------------------------------------------------------
294 class CPU_ImICQ : public CPU_CommonFamily
295 {
296 public:
297   CPU_ImICQ();
298   CPU_ImICQ(unsigned short VerArray[][2], unsigned short NumVer,
299             unsigned short nService);
300 };
301 
302 //-----ICQMode------------------------------------------------------------------
303 class CPU_ICQMode : public CPU_CommonFamily
304 {
305 public:
306     CPU_ICQMode(unsigned short nChannel, unsigned long nFlags);
307 };
308 
309 //-----CapabilitySettings-------------------------------------------------------------
310 class CPU_CapabilitySettings : public CPU_CommonFamily
311 {
312 public:
313   CPU_CapabilitySettings();
314 };
315 
316 //-----RateAck-----------------------------------------------------------------
317 class CPU_RateAck : public CPU_CommonFamily
318 {
319 public:
320   CPU_RateAck(unsigned short nService = 0);
321 };
322 
323 //-----GenericUinList------------------------------------------------------------
324 class CPU_GenericUinList : public CPU_CommonFamily
325 {
326 public:
327    CPU_GenericUinList(const std::string& accountId, unsigned short Family, unsigned short Subtype);
328    CPU_GenericUinList(const Licq::StringList& users, unsigned short, unsigned short);
329    CPU_GenericUinList(unsigned long _nUin, unsigned short Family, unsigned short Subtype);
330 };
331 
332 //-----RequestList--------------------------------------------------------------
333 class CPU_RequestList : public CPU_CommonFamily
334 {
335 public:
336   CPU_RequestList();
337 
338 protected:
339   time_t         m_nSavedTime;
340   unsigned short m_nRecords;
341 };
342 
343 //-----ExportContactStart-------------------------------------------------------
344 class CPU_ExportContactStart : public CPU_CommonFamily
345 {
346 public:
347   CPU_ExportContactStart();
348 };
349 
350 //-----ExportToServerList-------------------------------------------------------
351 class CPU_ExportToServerList : public CPU_CommonFamily
352 {
353 public:
354   CPU_ExportToServerList(const std::list<Licq::UserId>& users, unsigned short type);
355 };
356 
357 //-----ExportGroupsToServerList-------------------------------------------------
358 class CPU_ExportGroupsToServerList : public CPU_CommonFamily
359 {
360 public:
361   CPU_ExportGroupsToServerList(const GroupNameMap& groups);
362 };
363 
364 //-----AddPrivacyInfo-----------------------------------------------------------
365 class CPU_AddPDINFOToServerList : public CPU_CommonFamily
366 {
367 public:
368   CPU_AddPDINFOToServerList();
369 
GetSID()370   unsigned short GetSID()   { return m_nSID; }
GetGSID()371   unsigned short GetGSID()  { return m_nGSID; }
372 
373 protected:
374   unsigned short m_nSID,
375                  m_nGSID;
376 };
377 
378 //-----AddToServerList----------------------------------------------------------
379 class CPU_AddToServerList : public CPU_CommonFamily
380 {
381 public:
382   CPU_AddToServerList(const Licq::UserId& userId, unsigned short _nType,
383       unsigned short _nGroup = 0, bool _bAuthReq = false);
384 
385   CPU_AddToServerList(const std::string& groupName,
386                       bool _bAuthReq = false, bool _bTopLevel = false);
387 
GetSID()388   unsigned short GetSID()   { return m_nSID; }
GetGSID()389   unsigned short GetGSID()  { return m_nGSID; }
390 
391 protected:
392   void init(const std::string& name, unsigned short _nType, bool _bAuthReq, bool _bTopLevel);
393 
394   unsigned short m_nSID,
395                  m_nGSID;
396   Buffer tlvBuffer;
397 };
398 
399 //-----RemoveFromServerList-----------------------------------------------------
400 class CPU_RemoveFromServerList : public CPU_CommonFamily
401 {
402 public:
403   CPU_RemoveFromServerList(const Licq::UserId& userId, unsigned short _nGSID,
404       unsigned short _nSID, unsigned short _nType);
405   CPU_RemoveFromServerList(const std::string& name, unsigned short _nGSID);
406 
407 protected:
408   void init(const std::string& name, unsigned short _nGSID,
409       unsigned short _nSID, unsigned short _nType);
410 
411   Buffer tlvBuffer;
412 };
413 
414 //-----ClearServerList----------------------------------------------------------
415 class CPU_ClearServerList : public CPU_CommonFamily
416 {
417 public:
418   CPU_ClearServerList(const std::list<Licq::UserId>& userIds, unsigned short type);
419 };
420 
421 //-----UpdateToServerList-------------------------------------------------------
422 class CPU_UpdateToServerList : public CPU_CommonFamily
423 {
424 public:
425   CPU_UpdateToServerList(const Licq::UserId& userId, unsigned short _nType, bool _bAuthReq = false);
426   CPU_UpdateToServerList(const std::string& name, unsigned short _nSID = 0);
427 protected:
428   void init(const std::string& name, unsigned short _nType, bool _bAuthReq,
429       unsigned short nGSID, unsigned short nSID, unsigned short nExtraLen);
430 
431   Buffer tlvBuffer;
432   std::list<unsigned long> groupIds;
433 };
434 
435 //-----SetPrivacy---------------------------------------------------------------
436 class CPU_SetPrivacy : public CPU_CommonFamily
437 {
438 public:
439   CPU_SetPrivacy(unsigned char _nPrivacy);
440 };
441 
442 //-----SetStatus----------------------------------------------------------------
443 class CPU_SetStatus : public CPU_CommonFamily
444 {
445 public:
446   CPU_SetStatus(unsigned long _nNewStatus);
447 
448 private:
449   unsigned long m_nNewStatus;
450 };
451 
452 class CPU_SetStatusFamily : public CPU_CommonFamily
453 {
454 public:
455   CPU_SetStatusFamily();
456 
457 protected:
458   void InitBuffer();
459   unsigned long m_nNewStatus;
460 };
461 
462 class CPU_SetLogonStatus : public CPU_SetStatusFamily
463 {
464 public:
465   CPU_SetLogonStatus(unsigned long _nNewStatus);
466 };
467 
468 class CPU_UpdateInfoTimestamp : public CPU_SetStatusFamily
469 {
470 public:
471   CPU_UpdateInfoTimestamp(const uint8_t* GUID);
472 };
473 
474 class CPU_UpdateStatusTimestamp : public CPU_SetStatusFamily
475 {
476 public:
477   CPU_UpdateStatusTimestamp(const uint8_t* GUID, unsigned long nState,
478     unsigned long nStatus = ICQ_STATUS_OFFLINE);
479 };
480 
481 class CPU_UpdateTimestamp : public CPU_SetStatusFamily
482 {
483 public:
484   CPU_UpdateTimestamp();
485 };
486 
487 //-----ClientReady--------------------------------------------------------------
488 class CPU_ClientReady : public CPU_CommonFamily
489 {
490 public:
491    CPU_ClientReady();
492    CPU_ClientReady(unsigned short VerArray[][4], unsigned short NumVer,
493                    unsigned short nService);
494 };
495 
496 //-----ClientAckNameInfo--------------------------------------------------------
497 class CPU_AckNameInfo : public CPU_CommonFamily
498 {
499 public:
500    CPU_AckNameInfo();
501 };
502 
503 //-----RequestSysMsg------------------------------------------------------------
504 class CPU_RequestSysMsg : public CPU_CommonFamily
505 {
506 public:
507    CPU_RequestSysMsg();
SubCommand()508    virtual unsigned short SubCommand()   { return m_nMetaCommand; }
509 
510 protected:
511    unsigned short m_nMetaCommand;
512 };
513 
514 //-----SysMsgDoneAck------------------------------------------------------------
515 class CPU_SysMsgDoneAck : public CPU_CommonFamily
516 {
517 public:
518   CPU_SysMsgDoneAck(unsigned short nId);
SubCommand()519   virtual unsigned short SubCommand()   { return m_nMetaCommand; }
520 
521 protected:
522   unsigned short m_nMetaCommand;
523 };
524 
525 //-----TypingNotification------------------------------------------------------
526 class CPU_TypingNotification : public CPU_CommonFamily
527 {
528 public:
529   CPU_TypingNotification(const std::string& accountId, bool bActive);
530 };
531 
532 //-----CheckInvisible----------------------------------------------------------
533 class CPU_CheckInvisible : public CPU_CommonFamily
534 {
535 public:
536   CPU_CheckInvisible(const std::string& accountId);
537 };
538 
539 //-----Ack---------------------------------------------------------------------
540 class CPU_Ack : public CPacketUdp
541 {
542 public:
543 #if ICQ_VERSION == 2
544    CPU_Ack(unsigned short _nSequence);
545 #else
546    CPU_Ack(unsigned short _nSequence, unsigned short _nSubSequence);
547 #endif
548 };
549 
550 
551 //-----AddUser------------------------------------------------------------------
552 class CPU_AddUser : public CPacketUdp
553 {
554 public:
555    CPU_AddUser(unsigned long _nAddedUin);
556 protected:
557    /* 02 00 3C 05 06 00 50 A5 82 00 8F 76 20 00 */
558    unsigned long  m_nAddedUin;
559 };
560 
561 
562 //-----SearchWhitePages---------------------------------------------------------
563 class CPU_SearchWhitePages : public CPU_CommonFamily
564 {
565 public:
566   CPU_SearchWhitePages(const std::string& firstName, const std::string& lastName,
567       const std::string& alias, const std::string& email, unsigned short nMinAge,
568       unsigned short nMaxAge, char nGender, char nLanguage, const std::string& city,
569       const std::string& state, unsigned short nCountryCode, const std::string& coName,
570       const std::string& coDept, const std::string& coPos, const std::string& keyword,
571       bool bOnlineOnly);
SubCommand()572    virtual unsigned short SubCommand()   { return m_nMetaCommand; }
Uin()573    unsigned long Uin()  { return 0; }
574   void packSearch(unsigned short nCmd, const std::string& field);
575 
576 protected:
577    unsigned long m_nMetaCommand;
578 };
579 
580 
581 //-----SearchByUin--------------------------------------------------------------
582 class CPU_SearchByUin : public CPU_CommonFamily
583 {
584 public:
585    CPU_SearchByUin(unsigned long nUin);
SubCommand()586    virtual unsigned short SubCommand()   { return m_nMetaCommand; }
587 protected:
588    unsigned long m_nMetaCommand;
589 };
590 
591 
592 //-----UpdatePersonalBasicInfo--------------------------------------------------
593 class CPU_UpdatePersonalBasicInfo : public CPacketUdp
594 {
595 public:
596   CPU_UpdatePersonalBasicInfo(const std::string& alias, const std::string& firstName,
597       const std::string& lastName, const std::string& email, bool _bAuthorization);
598 
alias()599   const std::string& alias() const { return myAlias; }
firstName()600   const std::string& firstName() const { return myFirstName; }
lastName()601   const std::string& lastName() const { return myLastName; }
email()602   const std::string& email() const { return myEmail; }
Authorization()603    bool Authorization()  { return m_nAuthorization == 0; }
604 protected:
605   std::string myAlias;
606   std::string myFirstName;
607   std::string myLastName;
608   std::string myEmail;
609   char m_nAuthorization;
610 };
611 
612 
613 //-----UpdatePersonalExtInfo-------------------------------------------------------
614 class CPU_UpdatePersonalExtInfo : public CPacketUdp
615 {
616 public:
617   CPU_UpdatePersonalExtInfo(const std::string& city, unsigned short _nCountry,
618       const std::string& state, unsigned short _nAge, char _cSex, const std::string& phone,
619       const std::string& homepage, const std::string& about, unsigned long _nZipcode);
620 
city()621   const std::string& city() const { return myCity; }
Country()622    unsigned short Country()  { return m_nCountry; }
state()623   const std::string& state() const { return myState; }
Age()624    unsigned short Age()  { return m_nAge; }
Sex()625    char Sex()  { return m_cSex; }
phoneNumber()626   const std::string& phoneNumber() const { return myPhone; }
homepage()627   const std::string& homepage() const { return myHomepage; }
about()628   const std::string& about() const { return myAbout; }
Zipcode()629    unsigned long Zipcode() { return m_nZipcode; }
630 protected:
631   std::string myCity;
632    unsigned short m_nCountry;
633    char           m_cTimezone;
634   std::string myState;
635    unsigned short m_nAge;
636    char           m_cSex;
637   std::string myPhone;
638   std::string myHomepage;
639   std::string myAbout;
640    unsigned long  m_nZipcode;
641 };
642 
643 
644 //-----Ping---------------------------------------------------------------------
645 class CPU_Ping : public CSrvPacketTcp
646 {
647 public:
648    CPU_Ping();
649 };
650 
651 
652 //-----ThroughServer-----------------------------------------------------------
653 class CPU_ThroughServer : public CPU_CommonFamily
654 {
655 public:
656   CPU_ThroughServer(const std::string& accountId, unsigned char format, const std::string& message,
657       unsigned short _nCharset = 0, bool bOffline = true);
658 protected:
659   unsigned char  m_nMsgType;
660 };
661 
662 //-----Type2Message-------------------------------------------------------------
663 class CPU_Type2Message : public CPU_CommonFamily
664 {
665 public:
666   CPU_Type2Message(const User* u, bool _bAck, bool _bDirectInfo, const uint8_t* cap,
667                    unsigned long nMsgID1 = 0,
668                    unsigned long nMsgID2 = 0);
669 protected:
670   void InitBuffer();
671 
672   const User* m_pUser;
673   bool m_bAck;
674   bool m_bDirectInfo;
675   unsigned long m_nMsgID[2];
676   uint8_t m_cap[CAP_LENGTH];
677   unsigned long m_nExtraLen; // length of data following 0x2711 tlv
678 };
679 
680 //-----ReverseConnect-----------------------------------------------------------
681 class CPU_ReverseConnect : public CPU_Type2Message
682 {
683 public:
684   CPU_ReverseConnect(const User* u, unsigned long nLocalIP,
685                      unsigned short nLocalPort, unsigned short nRemotePort);
686 };
687 
688 //-----ReverseConnectFailed-----------------------------------------------------
689 class CPU_ReverseConnectFailed : public CPU_CommonFamily
690 {
691 public:
692   CPU_ReverseConnectFailed(const std::string& accountId, unsigned long nMsgID1,
693                            unsigned long nMsgID2, unsigned short nFailedPort,
694                            unsigned short nOurPort, unsigned long nConnectID);
695 };
696 
697 //-----PluginMessage-----------------------------------------------------------
698 class CPU_PluginMessage : public CPU_Type2Message
699 {
700 public:
701   CPU_PluginMessage(const User* u, bool bAck, const uint8_t* PluginGUID,
702                     unsigned long nMsgID1 = 0, unsigned long nMsgID2 = 0);
703 
704 protected:
705   void InitBuffer();
706 
707   uint8_t m_PluginGUID[GUID_LENGTH];
708 };
709 
710 //-----InfoPluginRequest-------------------------------------------------------
711 class CPU_InfoPluginReq : public CPU_PluginMessage
712 {
713 public:
714   CPU_InfoPluginReq(const User* u, const uint8_t* GUID, unsigned long nTime);
RequestGUID()715   virtual const char *RequestGUID() { return m_ReqGUID; }
ExtraInfo()716   virtual unsigned short ExtraInfo() { return ServerInfoPluginRequest; }
717 
718 protected:
719   char m_ReqGUID[GUID_LENGTH];
720 };
721 
722 //-----StatusPluginRequest-----------------------------------------------------
723 class CPU_StatusPluginReq : public CPU_PluginMessage
724 {
725 public:
726   CPU_StatusPluginReq(const User* u, const uint8_t* GUID, unsigned long nTime);
ExtraInfo()727   virtual unsigned short ExtraInfo() { return ServerStatusPluginRequest; }
RequestGUID()728   virtual const char *RequestGUID() { return m_ReqGUID; }
729 
730 protected:
731   char m_ReqGUID[GUID_LENGTH];
732 };
733 
734 //-----AdvancedMessage---------------------------------------------------------
735 class CPU_AdvancedMessage : public CPU_Type2Message
736 {
737 public:
738   CPU_AdvancedMessage(const User* u, unsigned short _nMsgType,
739                       unsigned short _nMsgFlags, bool _bAck,
740                       unsigned short _nSequence,
741                       unsigned long nID1 = 0,
742                       unsigned long nID2 = 0);
743 protected:
744   void InitBuffer();
745 
746   unsigned short m_nMsgType;
747   unsigned short m_nMsgFlags;
748   unsigned short m_nSequence;
749 };
750 
751 //-----ChatRequest-------------------------------------------------------------
752 class CPU_ChatRequest : public CPU_AdvancedMessage
753 {
754 public:
755   CPU_ChatRequest(const std::string& message, const std::string& chatUsers, unsigned short nPort,
756       unsigned short nLevel, const User* pUser, bool bICBM);
757 };
758 
759 //-----FileTransfer------------------------------------------------------------
760 class CPU_FileTransfer : public CPU_AdvancedMessage
761 {
762 public:
763   CPU_FileTransfer(const User* u, const std::list<std::string>& lFileList,
764       const std::string& file, const std::string& desc, unsigned short nLevel, bool bICBM);
765 
IsValid()766   bool IsValid()                { return m_bValid; }
GetFileList()767   const std::list<std::string>& GetFileList() const { return m_lFileList; }
filename()768   const std::string& filename() const { return myFilename; }
description()769   const std::string& description() const { return myDesc; }
GetFileSize()770   unsigned long GetFileSize()   { return m_nFileSize; }
771 
772 private:
773   bool          m_bValid;
774   std::string myDesc;
775   std::string myFilename;
776   std::list<std::string> m_lFileList;
777   unsigned long m_nFileSize;
778 };
779 
780 //-----NoManager--------------------------------------------------------
781 class CPU_NoManager : public CPU_CommonFamily
782 {
783 public:
784   CPU_NoManager(const Licq::User* u, unsigned long nMsgID1, unsigned long nMsgID2);
785 };
786 
787 //-----AckThroughServer--------------------------------------------------------
788 class CPU_AckThroughServer : public CPU_CommonFamily
789 {
790 public:
791   CPU_AckThroughServer(const Licq::User* u, unsigned long msgid1,
792                          unsigned long msgid2, unsigned short sequence,
793                          unsigned short msgType, bool bAccept,
794                          unsigned short nLevel, const uint8_t* GUID);
795 protected:
796   void InitBuffer();
797 
798   unsigned long m_nMsgID[2];
799   unsigned short m_nSequence, m_nMsgType, m_nStatus, m_nLevel;
800   std::string myAccountId;
801   std::string myMessage;
802   uint8_t m_GUID[GUID_LENGTH];
803 };
804 
805 //-----AckGeneral--------------------------------------------------------------
806 class CPU_AckGeneral : public CPU_AckThroughServer
807 {
808 public:
809   CPU_AckGeneral(const Licq::User* u, unsigned long nMsgID1,
810                  unsigned long nMsgID2, unsigned short nSequence,
811                  unsigned short nMsgType, bool bAccept, unsigned short nLevel);
812 };
813 
814 //-----AckFileAccept-----------------------------------------------------------
815 class CPU_AckFileAccept : public CPU_AdvancedMessage
816 {
817 public:
818   CPU_AckFileAccept(const User* u, const unsigned long nMsgID[],
819       unsigned short nSequence, unsigned short nPort, const std::string& desc,
820       const std::string& file, unsigned long nFileSize);
821 };
822 
823 //-----AckFileRefuse-----------------------------------------------------------
824 class CPU_AckFileRefuse : public CPU_AckThroughServer
825 {
826 public:
827   CPU_AckFileRefuse(const User* u, const unsigned long nMsgID[],
828       unsigned short nSequence, const std::string& message);
829 };
830 
831 //-----AckChatAccept-----------------------------------------------------------
832 class CPU_AckChatAccept : public CPU_AdvancedMessage
833 {
834 public:
835   CPU_AckChatAccept(const User* u, const std::string& clients,
836       const unsigned long nMsgID[], unsigned short nSequence, unsigned short nPort);
837 };
838 
839 //-----AckChatRefuse-----------------------------------------------------------
840 class CPU_AckChatRefuse : public CPU_AckThroughServer
841 {
842 public:
843   CPU_AckChatRefuse(const User* u, const unsigned long nMsgID[],
844       unsigned short nSequence, const std::string& message);
845 };
846 
847 //-----PluginError-------------------------------------------------------------
848 class CPU_PluginError : public CPU_AckThroughServer
849 {
850 public:
851   CPU_PluginError(const Licq::User* u, unsigned long nMsgID1, unsigned long nMsgID2,
852                   unsigned short nSequence, const uint8_t* GUID);
853 };
854 
855 //-----InfoPluginListResp------------------------------------------------------
856 class CPU_InfoPluginListResp : public CPU_AckThroughServer
857 {
858 public:
859   CPU_InfoPluginListResp(const Licq::User* u, unsigned long nMsgID1,
860                          unsigned long nMsgID2, unsigned short nSequence);
861 };
862 
863 //-----InfoPhoneBookResp-------------------------------------------------------
864 class CPU_InfoPhoneBookResp : public CPU_AckThroughServer
865 {
866 public:
867   CPU_InfoPhoneBookResp(const Licq::User* u, unsigned long nMsgID1,
868                         unsigned long nMsgID2, unsigned short nSequence);
869 };
870 
871 //-----InfoPictureResp---------------------------------------------------------
872 class CPU_InfoPictureResp : public CPU_AckThroughServer
873 {
874 public:
875   CPU_InfoPictureResp(const Licq::User* u, unsigned long nMsgID1,
876                       unsigned long nMsgID2, unsigned short nSequence);
877 };
878 
879 //-----StatusPluginListResp----------------------------------------------------
880 class CPU_StatusPluginListResp : public CPU_AckThroughServer
881 {
882 public:
883   CPU_StatusPluginListResp(const Licq::User* u, unsigned long nMsgID1,
884                            unsigned long nMsgID2, unsigned short nSequence);
885 };
886 
887 //-----StatusPluginResp-----------------------------------------------------
888 class CPU_StatusPluginResp : public CPU_AckThroughServer
889 {
890 public:
891   CPU_StatusPluginResp(const Licq::User* u, unsigned long nMsgID1,
892                        unsigned long nMsgID2, unsigned short nSequence,
893                        unsigned long nStatus);
894 };
895 
896 //-----SendSms-----------------------------------------------------------
897 class CPU_SendSms : public CPU_CommonFamily
898 {
899 public:
900   CPU_SendSms(const std::string& number, const std::string& message);
SubCommand()901    virtual unsigned short SubCommand() { return m_nMetaCommand; }
902 protected:
903    unsigned long m_nMetaCommand;
904 };
905 
906 //-----ReverseTCPRequest--------------------------------------------------------
907 
908 class CPU_ReverseTCPRequest : public CPacketUdp
909 {
910 public:
911    CPU_ReverseTCPRequest(unsigned long _nDestinationUin, unsigned long _nIP,
912                          unsigned short _nPort, unsigned short _nPort2);
913 protected:
914    unsigned long  m_nDestinationUin;
915 };
916 
917 //-----RequestAuth--------------------------------------------------------------
918 class CPU_RequestAuth : public CPU_CommonFamily
919 {
920 public:
921   CPU_RequestAuth(const std::string& accountId, const std::string& message);
922 };
923 
924 //-----Authorize----------------------------------------------------------------
925 class CPU_Authorize : public CPU_CommonFamily
926 {
927 public:
928    CPU_Authorize(const std::string& accountId);
929 };
930 
931 
932 
933 
934 //-----SetRandomChatGroup----------------------------------------------------
935 class CPU_SetRandomChatGroup : public CPU_CommonFamily
936 {
937 public:
938   CPU_SetRandomChatGroup(unsigned long nGroup);
Group()939   unsigned long Group() { return m_nGroup; }
SubCommand()940   virtual unsigned short SubCommand() { return m_nMetaCommand; }
941 protected:
942   unsigned long m_nGroup;
943   unsigned long m_nMetaCommand;
944 };
945 
946 
947 
948 //-----RandomChatSearch----------------------------------------------------
949 class CPU_RandomChatSearch : public CPU_CommonFamily
950 {
951 public:
952   CPU_RandomChatSearch(unsigned long nGroup);
SubCommand()953   virtual unsigned short SubCommand() { return m_nMetaCommand; }
954 protected:
955   unsigned long m_nMetaCommand;
956 };
957 
958 
959 
960 //-----Meta_SetGeneralInfo-----------------------------------------------------
961 class CPU_Meta_SetGeneralInfo : public CPU_CommonFamily
962 {
963 public:
964   CPU_Meta_SetGeneralInfo(const std::string& alias, const std::string& firstName,
965       const std::string& lastName, const std::string& emailPrimary,
966       const std::string& city, const std::string& state, const std::string& phoneNumber,
967       const std::string& faxNumber, const std::string& address,
968       const std::string& cellularNumber, const std::string& zipCode,
969       unsigned short nCountryCode, bool bHideEmail);
SubCommand()970   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
971 protected:
972   unsigned short m_nMetaCommand;
973 
974   std::string myAlias;
975   std::string myFirstName;
976   std::string myLastName;
977   std::string myEmailPrimary;
978   std::string myCity;
979   std::string myState;
980   std::string myPhoneNumber;
981   std::string myFaxNumber;
982   std::string myAddress;
983   std::string myCellularNumber;
984   std::string myZipCode;
985   unsigned short m_nCountryCode;
986   char m_nTimezone;
987   char m_nHideEmail;
988 
989   friend class IcqProtocol;
990 };
991 
992 
993 //-----Meta_SetMoreEmailInfo---------------------------------------------------
994 class CPU_Meta_SetEmailInfo : public CPU_CommonFamily
995 {
996 public:
997   CPU_Meta_SetEmailInfo(const std::string& emailSecondary, const std::string& emailOld);
SubCommand()998   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
999 protected:
1000   unsigned short m_nMetaCommand;
1001 
1002   std::string myEmailSecondary;
1003   std::string myEmailOld;
1004 
1005   friend class IcqProtocol;
1006 };
1007 
1008 
1009 //-----Meta_SetMoreInfo------------------------------------------------------
1010 class CPU_Meta_SetMoreInfo : public CPU_CommonFamily
1011 {
1012 public:
1013   CPU_Meta_SetMoreInfo(unsigned short nAge, char nGender, const std::string& homepage,
1014       unsigned short nBirthYear, char nBirthMonth, char nBirthDay, char nLanguage1,
1015       char nLanguage2, char nLanguage3);
SubCommand()1016   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
1017 protected:
1018   unsigned short m_nMetaCommand;
1019 
1020   unsigned short m_nAge;
1021   char m_nGender;
1022   std::string myHomepage;
1023   unsigned short m_nBirthYear;
1024   char m_nBirthMonth;
1025   char m_nBirthDay;
1026   char m_nLanguage1;
1027   char m_nLanguage2;
1028   char m_nLanguage3;
1029 
1030   friend class IcqProtocol;
1031 };
1032 
1033 //-----Meta_SetInterestsInfo----------------------------------------------------
1034 class CPU_Meta_SetInterestsInfo : public CPU_CommonFamily
1035 {
1036 public:
1037   CPU_Meta_SetInterestsInfo(const Licq::UserCategoryMap& interests);
SubCommand()1038   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
1039 protected:
1040   unsigned short m_nMetaCommand;
1041 
1042   Licq::UserCategoryMap myInterests;
1043 
1044   friend class IcqProtocol;
1045 };
1046 
1047 
1048 //-----Meta_SetOrgBackInfo------------------------------------------------------
1049 class CPU_Meta_SetOrgBackInfo : public CPU_CommonFamily
1050 {
1051 public:
1052   CPU_Meta_SetOrgBackInfo(const Licq::UserCategoryMap& orgs,
1053       const Licq::UserCategoryMap& background);
SubCommand()1054   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
1055 protected:
1056   unsigned short m_nMetaCommand;
1057 
1058   Licq::UserCategoryMap myOrganizations;
1059   Licq::UserCategoryMap myBackgrounds;
1060 
1061   friend class IcqProtocol;
1062 };
1063 
1064 //-----Meta_SetWorkInfo------------------------------------------------------
1065 class CPU_Meta_SetWorkInfo : public CPU_CommonFamily
1066 {
1067 public:
1068   CPU_Meta_SetWorkInfo(const std::string& city, const std::string& state,
1069       const std::string& phoneNumber, const std::string& faxNumber,
1070       const std::string& address, const std::string& zip,
1071       unsigned short nCompanyCountry, const std::string& name,
1072       const std::string& department, const std::string& position,
1073       unsigned short nCompanyOccupation, const std::string& homepage);
SubCommand()1074   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
1075 protected:
1076   unsigned short m_nMetaCommand;
1077 
1078   std::string myCity;
1079   std::string myState;
1080   std::string myPhoneNumber;
1081   std::string myFaxNumber;
1082   std::string myAddress;
1083   std::string myZip;
1084   unsigned short m_nCompanyCountry;
1085   std::string myName;
1086   std::string myDepartment;
1087   std::string myPosition;
1088   unsigned short m_nCompanyOccupation;
1089   std::string myHomepage;
1090 
1091   friend class IcqProtocol;
1092 };
1093 
1094 
1095 //-----Meta_SetAbout---------------------------------------------------------
1096 class CPU_Meta_SetAbout : public CPU_CommonFamily
1097 {
1098 public:
1099   CPU_Meta_SetAbout(const std::string& about);
SubCommand()1100   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
1101 protected:
1102   unsigned short m_nMetaCommand;
1103 
1104   std::string myAbout;
1105 
1106   friend class IcqProtocol;
1107 };
1108 
1109 //-----RequestInfo-----------------------------------------------------------
1110 class CPU_RequestInfo : public CPU_CommonFamily
1111 {
1112 public:
1113   CPU_RequestInfo(const std::string& accountId);
1114 };
1115 
1116 //-----RequestBuddyIcon------------------------------------------------------
1117 class CPU_RequestBuddyIcon : public CPU_CommonFamily
1118 {
1119 public:
1120   CPU_RequestBuddyIcon(const std::string& accountId, unsigned short _nBuddyIconType,
1121       char _nBuddyIconHashType, const std::string& buddyIconHash, unsigned short nService);
1122 };
1123 
1124 class CPU_RequestService : public CPU_CommonFamily
1125 {
1126 public:
1127   CPU_RequestService(unsigned short nFam);
1128 };
1129 
1130 //-----AIMFetchAwayMessage--------------------------------------------------
1131 class CPU_AIMFetchAwayMessage : public CPU_CommonFamily
1132 {
1133 public:
1134   CPU_AIMFetchAwayMessage(const std::string& accountId);
1135 };
1136 
1137 //-----SetPassword---------------------------------------------------------
1138 class CPU_SetPassword : public CPU_CommonFamily
1139 {
1140 public:
1141   CPU_SetPassword(const std::string& password);
SubCommand()1142   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
Uin()1143   unsigned long Uin()           { return 0; }
1144 protected:
1145   unsigned short m_nMetaCommand;
1146   std::string myPassword;
1147 
1148   friend class IcqProtocol;
1149 };
1150 
1151 
1152 //-----Meta_SetSecurityInfo--------------------------------------------------
1153 class CPU_Meta_SetSecurityInfo : public CPU_CommonFamily
1154 {
1155 public:
1156   CPU_Meta_SetSecurityInfo(bool bAuthorization,
1157                            bool bWebAware);
SubCommand()1158   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
1159 
Authorization()1160   bool Authorization()  { return m_nAuthorization == 0; }
WebAware()1161   bool WebAware()       { return m_nWebAware == 1; }
1162 protected:
1163   unsigned short m_nMetaCommand;
1164   char m_nAuthorization;
1165   char m_nWebAware;
1166 };
1167 
1168 
1169 //-----Meta_RequestAllInfo------------------------------------------------------
1170 class CPU_Meta_RequestAllInfo : public CPU_CommonFamily
1171 {
1172 public:
1173   CPU_Meta_RequestAllInfo(const Licq::UserId& userId);
SubCommand()1174   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
1175 protected:
1176   unsigned short m_nMetaCommand;
1177 };
1178 
1179 
1180 //-----Meta_RequestBasicInfo------------------------------------------------------
1181 class CPU_Meta_RequestBasicInfo : public CPU_CommonFamily
1182 {
1183 public:
1184   CPU_Meta_RequestBasicInfo(const std::string& accountId);
SubCommand()1185   virtual unsigned short SubCommand()  { return m_nMetaCommand; }
accountId()1186   const std::string& accountId() const {  return myAccountId; }
1187 protected:
1188   unsigned short m_nMetaCommand;
1189   std::string myAccountId;
1190 };
1191 
1192 } // namespace LicqIcq
1193 
1194 #endif
1195