00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef EVA_RECEIVE_IM_PACKET_H
00021 #define EVA_RECEIVE_IM_PACKET_H
00022
00023 #include "evapacket.h"
00024 #include <string>
00025
00026
00027 #define REPLY_KEY_LENGTH 16
00028 class ReceiveIMPacket :public InPacket
00029 {
00030 public:
00031 ReceiveIMPacket() {}
00032 ReceiveIMPacket(unsigned char *buf, const int len);
00033 ReceiveIMPacket(const ReceiveIMPacket &rhs);
00034 ~ReceiveIMPacket() {};
00035
00036 const int getSender() const { return sender; }
00037 const int getReceiver() const { return receiver; }
00038 const int getIntSequence() const { return intSequence; }
00039 const int getSenderIP() const { return senderIP; }
00040 const short getSenderPort() const { return senderPort; }
00041 const short getIMType() const { return type; }
00042
00043 const char *getReplyKey() const { return replyKey; }
00044 const int getBodyLength() const { return (bodyLength - bodyOffset); }
00045 const unsigned char *getBodyData() const { return (decryptedBuf + bodyOffset); }
00046
00047 static std::string convertToShow(const std::string &src, const unsigned char type = QQ_IM_NORMAL_REPLY);
00048 ReceiveIMPacket &operator=(const ReceiveIMPacket &rhs);
00049 protected:
00050 virtual void parseBody();
00051
00052 private:
00053 char replyKey[REPLY_KEY_LENGTH];
00054
00055 int sender;
00056 int receiver;
00057 int intSequence;
00058 int senderIP;
00059 short senderPort;
00060 short type;
00061
00062 int bodyOffset;
00063 int readHeader(const unsigned char * buf);
00064 };
00065
00066 class ReceivedSystemIM{
00067 public:
00068 ReceivedSystemIM(const unsigned char *buf, const int len);
00069 ReceivedSystemIM( const ReceivedSystemIM &rhs);
00070 ~ReceivedSystemIM() {};
00071
00072 const unsigned char getSystemIMType() const { return systemIMType; }
00073 const std::string &getMessage() const { return message; }
00074 ReceivedSystemIM &operator=(const ReceivedSystemIM &rhs);
00075 private:
00076 unsigned char systemIMType;
00077 std::string message;
00078 void parseData(const unsigned char *buf, const int len);
00079 };
00080
00081 class NormalIMBase{
00082 public:
00083 NormalIMBase() {}
00084 NormalIMBase(const unsigned char *buf, const int len);
00085 NormalIMBase(const NormalIMBase &rhs);
00086 virtual ~NormalIMBase();
00087
00088 void setNormalIMBase(const NormalIMBase *base);
00089 const unsigned char *getBodyData() const { return bodyBuf; }
00090 const int getBodyLength() const { return bodyLength; }
00091
00092 const short getSenderVersion() const { return senderVersion; }
00093 const int getSender() const { return sender; }
00094 const int getReceiver() const { return receiver; }
00095 const unsigned char *getBuddyFileSessionKey() const { return fileSessionKey; }
00096 const short getNormalIMType() const { return type; }
00097 const short getSequence() const { return sequence; }
00098 const int getSendTime() const { return sendTime; }
00099 const char getUnknown1() const { return unknown1; }
00100 const short getSenderFace() const { return senderFace; }
00101
00102 void parseData();
00103
00104 NormalIMBase &operator=(const NormalIMBase &rhs);
00105 protected:
00106 virtual void parseContents(const unsigned char *buf, const int len);
00107 unsigned char *bodyBuf;
00108 int bodyLength;
00109 private:
00110 short senderVersion;
00111 int sender;
00112 int receiver;
00113 unsigned char fileSessionKey[16];
00114 short type;
00115 short sequence;
00116 int sendTime;
00117 char unknown1;
00118 short senderFace;
00119 int readHeader(const unsigned char * buf);
00120 };
00121
00122 class ReceivedNormalIM : public NormalIMBase {
00123 public:
00124 ReceivedNormalIM() {}
00125 ReceivedNormalIM(const unsigned char *buf, const int len);
00126 ReceivedNormalIM(const ReceivedNormalIM &rhs);
00127 virtual ~ReceivedNormalIM() {};
00128
00129 const char *getUnknown2() const { return unknown2; }
00130 const char *getUnknown3() const { return unknown3; }
00131 const char getReplyType() const { return replyType; }
00132 const std::string getMessage() const { return message; }
00133 const bool hasFontAttribute() const { return mHasFontAttribute; }
00134 const short getEncoding() const { return encoding; }
00135 const char getRed() const { return red; }
00136 const char getGreen() const { return green; }
00137 const char getBlue() const { return blue; }
00138 const char getFontSize() const { return fontSize; }
00139 const std::string &getFontName() const { return fontName; }
00140 const bool isBold() const { return bold; }
00141 const bool isItalic() const { return italic; }
00142 const bool isUnderline() const { return underline; }
00143
00144 const bool isNormalReply() const;
00145 ReceivedNormalIM &operator=(const ReceivedNormalIM &rhs);
00146 protected:
00147 virtual void parseContents(const unsigned char *buf, const int len);
00148 private:
00149 char unknown2[3];
00150 char unknown3[4];
00151 char replyType;
00152 std::string message;
00153
00154 bool mHasFontAttribute;
00155 short encoding;
00156 char red, green, blue;
00157 char fontSize;
00158 std::string fontName;
00159 bool bold, italic, underline;
00160 };
00161
00162 class ReceiveIMReplyPacket : public OutPacket
00163 {
00164 public:
00165 ReceiveIMReplyPacket() {}
00166 ReceiveIMReplyPacket(const char * key);
00167 ReceiveIMReplyPacket(const ReceiveIMReplyPacket &rhs);
00168 virtual ~ReceiveIMReplyPacket() {};
00169
00170 virtual OutPacket *copy(){ return new ReceiveIMReplyPacket(*this);}
00171 ReceiveIMReplyPacket &operator=(const ReceiveIMReplyPacket &rhs);
00172
00173 const char *getReplyKey() const { return replyKey; }
00174
00175 protected:
00176 virtual int putBody(unsigned char *buf);
00177 private:
00178 char replyKey[REPLY_KEY_LENGTH];
00179 };
00180
00181 class ReceivedQunIM{
00182 public:
00183 ReceivedQunIM(const short src, const unsigned char *buf, const int len);
00184 ReceivedQunIM( const ReceivedQunIM &rhs);
00185 ReceivedQunIM() {};
00186
00187 const short getUnknown1() const { return unknown1; }
00188
00189 const short getSource() const { return source; }
00190 const int getExtID() const { return externalID; }
00191 const int getQunID() const { return qunID; }
00192 const char getType() const { return type; }
00193 const int getSenderQQ() const { return sender; }
00194 const short getSequence() const { return sequence; }
00195 const int getSentTime() const { return sentTime; }
00196 const short getVersionID() const { return versionID; }
00197 const std::string getMessage() const { return message; }
00198
00199 const bool hasFontAttribute() const { return mHasFontAttribute; }
00200 const short getEncoding() const { return encoding; }
00201 const char getRed() const { return red; }
00202 const char getGreen() const { return green; }
00203 const char getBlue() const { return blue; }
00204 const char getFontSize() const { return fontSize; }
00205 const std::string &getFontName() const { return fontName; }
00206 const bool isBold() const { return bold; }
00207 const bool isItalic() const { return italic; }
00208 const bool isUnderline() const { return underline; }
00209
00210 ReceivedQunIM &operator=(const ReceivedQunIM &rhs);
00211 private:
00212 short source;
00213 int externalID;
00214 int qunID;
00215 char type;
00216 int sender;
00217 short unknown1;
00218 short sequence;
00219 uint sentTime;
00220 int versionID;
00221 std::string message;
00222
00223 bool mHasFontAttribute;
00224 short encoding;
00225 char red, green, blue;
00226 char fontSize;
00227 std::string fontName;
00228 bool bold, italic, underline;
00229
00230 void parseData(const unsigned char *buf, const int len);
00231 };
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250 class ReceivedQunIMJoinRequest{
00251 public:
00252 ReceivedQunIMJoinRequest(const unsigned char *buf, const int len);
00253 ReceivedQunIMJoinRequest( const ReceivedQunIMJoinRequest &rhs);
00254 ReceivedQunIMJoinRequest() {};
00255
00256 const int getExtID() const { return externalID; }
00257 const int getSender() const { return sender; }
00258 const std::string &getMessage() const { return message; }
00259 const char getType() const { return type; }
00260
00261 ReceivedQunIMJoinRequest &operator=(const ReceivedQunIMJoinRequest &rhs);
00262 private:
00263 int externalID;
00264 int sender;
00265 unsigned char type;
00266 std::string message;
00267 };
00268
00269 class SignatureChangedPacket{
00270 public:
00271 SignatureChangedPacket(const unsigned char *buf, const int len);
00272 SignatureChangedPacket( const SignatureChangedPacket &rhs);
00273 ~SignatureChangedPacket() {};
00274
00275 const int getQQ() const { return qq; }
00276 const int getTime() const { return time; }
00277 const std::string &getSignature() const { return signature; }
00278 SignatureChangedPacket &operator=(const SignatureChangedPacket &rhs);
00279 private:
00280 int qq;
00281 int time;
00282 std::string signature;
00283 void parseData(const unsigned char *buf, const int len);
00284 };
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297 class ReceivedFileIM : public NormalIMBase{
00298 public:
00299 ReceivedFileIM() {}
00300 ReceivedFileIM(const unsigned char *buf, const int len);
00301 ReceivedFileIM(const ReceivedFileIM &rhs);
00302 virtual ~ReceivedFileIM() {};
00303
00304 const unsigned char getTransferType() const { return m_TransferType; }
00305 const unsigned char getConnectMode() const { return m_ConnectMode; }
00306
00307 const unsigned int getSessionId() const { return m_SessionId; }
00308 const unsigned int getWanIp() const { return m_WanIp; }
00309 const unsigned short getWanPort() const { return m_WanPort; }
00310
00311
00312
00313 const unsigned char *getAgentServerKey() const { return m_AgentServerKey; }
00314
00315 const std::string &getFileName() const { return m_FileName; }
00316 const unsigned int getFileSize() const { return m_FileSize; }
00317
00318 ReceivedFileIM &operator=(const ReceivedFileIM &rhs);
00319 protected:
00320 virtual void parseContents(const unsigned char *buf, const int len);
00321 private:
00322 unsigned char m_TransferType;
00323 unsigned char m_ConnectMode;
00324
00325 unsigned int m_SessionId;
00326 unsigned int m_WanIp;
00327 unsigned short m_WanPort;
00328
00329 unsigned char m_AgentServerKey[16];
00330
00331
00332
00333
00334
00335
00336 std::string m_FileName;
00337 unsigned int m_FileSize;
00338 };
00339
00340
00341
00342
00343 class ReceivedFileExIpIM : public NormalIMBase{
00344 public:
00345 ReceivedFileExIpIM() {}
00346 ReceivedFileExIpIM(const unsigned char *buf, const int len);
00347 ReceivedFileExIpIM(const ReceivedFileExIpIM &rhs);
00348 virtual ~ReceivedFileExIpIM() {};
00349
00350 const unsigned char getTransferType() const { return m_TransferType; }
00351 const unsigned char getConnectMode() const { return m_ConnectMode; }
00352 const unsigned int getSessionId() const { return m_SessionId; }
00353 const unsigned int getWanIp1() const { return m_WanIp1; }
00354 const unsigned int getWanPort1() const { return m_WanPort1; }
00355 const unsigned int getWanIp2() const { return m_WanIp2; }
00356 const unsigned int getWanPort2() const { return m_WanPort2; }
00357 const unsigned int getWanIp3() const { return m_WanIp3; }
00358 const unsigned int getWanPort3() const { return m_WanPort3; }
00359
00360 const unsigned int getLanIp1() const { return m_LanIp1; }
00361 const unsigned int getLanPort1() const { return m_LanPort1; }
00362 const unsigned int getLanIp2() const { return m_LanIp2; }
00363 const unsigned int getLanPort2() const { return m_LanPort2; }
00364 const unsigned int getLanIp3() const { return m_LanIp3; }
00365 const unsigned int getLanPort3() const { return m_LanPort3; }
00366
00367 const unsigned int getSyncIp() const { return m_SyncIp; }
00368 const unsigned int getSyncPort() const { return m_SyncPort; }
00369 const unsigned int getSyncSession() const { return m_SyncSession; }
00370
00371 const bool isSender() const { return m_IsSender; }
00372
00373
00374 ReceivedFileExIpIM &operator=(const ReceivedFileExIpIM &rhs);
00375
00376 protected:
00377 virtual void parseContents(const unsigned char *buf, const int len);
00378 private:
00379 unsigned char m_TransferType;
00380 unsigned char m_ConnectMode;
00381 unsigned int m_SessionId;
00382
00383 bool m_IsSender;
00384
00385 unsigned int m_WanIp1;
00386 unsigned int m_WanPort1;
00387 unsigned int m_WanIp2;
00388 unsigned int m_WanPort2;
00389 unsigned int m_WanIp3;
00390 unsigned int m_WanPort3;
00391
00392 unsigned int m_LanIp1;
00393 unsigned int m_LanPort1;
00394 unsigned int m_LanIp2;
00395 unsigned int m_LanPort2;
00396 unsigned int m_LanIp3;
00397 unsigned int m_LanPort3;
00398
00399 unsigned int m_SyncIp;
00400 unsigned int m_SyncPort;
00401 unsigned int m_SyncSession;
00402 };
00403 #endif
00404