Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

ICQ.h

00001 /*
00002  * ICQ Subtypes
00003  *
00004  * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef ICQ_H
00023 #define ICQ_H
00024 
00025 #include <string>
00026 
00027 #include <libicq2000/Xml.h>
00028 #include <libicq2000/buffer.h>
00029 #include <libicq2000/exceptions.h>
00030 #include <libicq2000/constants.h>
00031 
00032 using std::string;
00033 
00034 namespace ICQ2000 {
00035 
00036   // ------------- TCP Command Types ------------------
00037 
00038   const unsigned short V6_TCP_START     = 0x07ee;
00039   const unsigned short V6_TCP_ACK       = 0x07da;
00040   
00041 
00042   // ------------- Message Types ----------------------
00043 
00044   const unsigned char MSG_Type_Normal  = 0x01;
00045   const unsigned char MSG_Type_URL     = 0x04;
00046   const unsigned char MSG_Type_AuthReq = 0x06;
00047   const unsigned char MSG_Type_AuthRej = 0x07;
00048   const unsigned char MSG_Type_AuthAcc = 0x08;
00049   const unsigned char MSG_Type_UserAdd = 0x0c;
00050   const unsigned char MSG_Type_EmailEx = 0x0e;
00051   const unsigned char MSG_Type_SMS     = 0x1a;
00052 
00053   const unsigned char MSG_Type_AutoReq_Away = 0xe8;
00054   const unsigned char MSG_Type_AutoReq_Occ  = 0xe9;
00055   const unsigned char MSG_Type_AutoReq_NA   = 0xea;
00056   const unsigned char MSG_Type_AutoReq_DND  = 0xeb;
00057   const unsigned char MSG_Type_AutoReq_FFC  = 0xec;
00058 
00059   const unsigned char MSG_Flag_AutoReq = 0x03;
00060   const unsigned char MSG_Flag_Multi   = 0x80;
00061 
00062   /* ICQSubtype classes
00063    * An attempt at clearing up the complete
00064    * mess ICQ have made of bundling everything
00065    * into one TLV
00066    */
00067 
00068   class ICQSubType {
00069    protected:
00070     unsigned short m_seqnum;
00071 
00072     unsigned char m_flags;
00073     
00074    public:
00075     ICQSubType();
00076     virtual ~ICQSubType() { }
00077 
00078     static ICQSubType* ParseICQSubType(Buffer& b, bool adv);
00079     void Output(Buffer& b) const;
00080 
00081     virtual void Parse(Buffer& b) = 0;
00082     virtual void OutputBody(Buffer& b) const = 0;
00083     virtual unsigned short Length() const = 0;
00084 
00085     virtual unsigned char getType() const = 0;
00086     virtual unsigned char getFlags() const { return m_flags; }
00087     virtual void setFlags(unsigned char f) { m_flags = f; }
00088 
00089     unsigned short getSeqNum() const { return m_seqnum; }
00090     void setSeqNum(unsigned short s)  { m_seqnum = s; }
00091   };
00092 
00093   class UINICQSubType : public ICQSubType {
00094    protected:
00095     unsigned int m_source, m_destination;
00096     bool m_advanced, m_ack;
00097 
00098    public:
00099     UINICQSubType();
00100     UINICQSubType(unsigned int s, unsigned int d);
00101 
00102     void setDestination(unsigned int uin);
00103     void setSource(unsigned int uin);
00104     unsigned int getSource() const;
00105     unsigned int getDestination() const;
00106 
00107     bool isAdvanced() const;
00108     void setAdvanced(bool b);
00109     void setACK(bool b);
00110     bool isACK() const;
00111   };
00112 
00113   class NormalICQSubType : public UINICQSubType {
00114    private:
00115     string m_message;
00116     bool m_multi;
00117     unsigned int m_foreground, m_background;
00118     
00119    public:
00120     NormalICQSubType(bool multi);
00121     NormalICQSubType(const string& msg, unsigned int destination);
00122 
00123     string getMessage() const;
00124     bool isMultiParty() const;
00125     void setMessage(const string& message);
00126     
00127     void setForeground(unsigned int f);
00128     void setBackground(unsigned int f);
00129     unsigned int getForeground() const;
00130     unsigned int getBackground() const;
00131 
00132     void Parse(Buffer& b);
00133     void OutputBody(Buffer& b) const;
00134     unsigned short Length() const;
00135     unsigned char getType() const;
00136   };
00137 
00138   class URLICQSubType : public UINICQSubType {
00139    private:
00140     string m_message;
00141     string m_url;
00142     bool m_advanced;
00143     
00144    public:
00145     URLICQSubType();
00146     URLICQSubType(const string& msg, const string& url, unsigned int source, unsigned int destination);
00147 
00148     string getMessage() const;
00149     void setMessage(const string& msg);
00150     string getURL() const;
00151     void setURL(const string& url);
00152     
00153     void Parse(Buffer& b);
00154     void OutputBody(Buffer& b) const;
00155     unsigned short Length() const;
00156     unsigned char getType() const;
00157   };
00158 
00159   class AwayMsgSubType : public UINICQSubType {
00160    private:
00161     unsigned char m_type;
00162     string m_message;
00163 
00164    public:
00165     AwayMsgSubType(Status s, unsigned int destination);
00166     AwayMsgSubType(unsigned char m_type);
00167 
00168     void Parse(Buffer& b);
00169     void OutputBody(Buffer& b) const;
00170 
00171     string getMessage() const;
00172     void setMessage(const string& msg);
00173 
00174     unsigned short Length() const;
00175     unsigned char getType() const;
00176     unsigned char getFlags() const;
00177   };
00178 
00179   class SMSICQSubType : public ICQSubType {
00180    public:
00181     enum Type {
00182       SMS,
00183       SMS_Receipt
00184     };
00185 
00186    private:
00187     // SMS fields
00188     string m_source, m_sender, m_senders_network, m_time;
00189 
00190     // SMS Receipt fields
00191     string m_message_id, m_destination, m_submission_time, m_delivery_time;
00192     bool m_delivered;
00193 
00194     string m_message;
00195     Type m_type;
00196 
00197    public:
00198     SMSICQSubType();
00199 
00200     string getMessage() const;
00201     Type getSMSType() const;
00202 
00203     void Parse(Buffer& b);
00204     void OutputBody(Buffer& b) const;
00205     unsigned short Length() const;
00206     unsigned char getType() const;
00207 
00208     // -- SMS fields --
00209     string getSource() const { return m_source; }
00210     string getSender() const { return m_sender; }
00211     string getSenders_network() const { return m_senders_network; }
00212     string getTime() const { return m_time; }
00213 
00214     // -- SMS Receipt fields --
00215     string getMessageId() const { return m_message_id; }
00216     string getDestination() const { return m_destination; }
00217     string getSubmissionTime() const { return m_submission_time; }
00218     string getDeliveryTime() const { return m_delivery_time; }
00219     bool delivered() const { return m_delivered; }
00220 
00221   };
00222 
00223   class AuthReqICQSubType : public UINICQSubType {
00224    private:
00225     string m_nick;
00226     string m_firstname;
00227     string m_lastname;
00228     string m_email;
00229     string m_message;
00230 
00231    public:
00232     AuthReqICQSubType();
00233     AuthReqICQSubType(const string& msg, unsigned int source, 
00234                       unsigned int destination);
00235 
00236     string getMessage() const;
00237     string getNick() const;
00238     string getFirstName() const;
00239     string getLastName() const;
00240     string getEmail() const;
00241 
00242     void Parse(Buffer& b);
00243     void OutputBody(Buffer& b) const;
00244     unsigned short Length() const;
00245     unsigned char getType() const;
00246 
00247   };
00248   
00249   class AuthAccICQSubType : public UINICQSubType {
00250    public:
00251     AuthAccICQSubType();
00252     AuthAccICQSubType(unsigned int source, unsigned int destination);
00253 
00254     void Parse(Buffer& b);
00255     void OutputBody(Buffer& b) const;
00256     unsigned short Length() const;
00257     unsigned char getType() const;
00258 
00259   };
00260   
00261   class AuthRejICQSubType : public UINICQSubType {
00262    private:
00263     string m_message;
00264 
00265    public:
00266     AuthRejICQSubType();
00267     AuthRejICQSubType(const string& msg, unsigned int source, 
00268                       unsigned int destination);
00269 
00270     string getMessage() const;
00271     void setMessage(const string& msg);
00272 
00273     void Parse(Buffer& b);
00274     void OutputBody(Buffer& b) const;
00275     unsigned short Length() const;
00276     unsigned char getType() const;
00277 
00278   };
00279 }
00280 
00281 #endif

Generated on Tue Jan 15 12:24:35 2002 for libicq2000 by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001