00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00037
00038 const unsigned short V6_TCP_START = 0x07ee;
00039 const unsigned short V6_TCP_ACK = 0x07da;
00040
00041
00042
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
00063
00064
00065
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
00188 string m_source, m_sender, m_senders_network, m_time;
00189
00190
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
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
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