00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef EVAFTPROTOCOLS_H
00022 #define EVAFTPROTOCOLS_H
00023
00024 #include "evaftpacket.h"
00025 #include <string>
00026
00027 #define QQ_FILE_AGENT_CREATE_OK 0x0000
00028 #define QQ_FILE_AGENT_CREATE_REDIRECT 0x0001
00029 #define QQ_FILE_AGENT_CREATE_ERROR 0x0002
00030 #define QQ_FILE_AGENT_OPERATION_OK 0x00000000
00031
00032 #define QQ_FILE_AGENT_TRANSFER_INFO 1
00033 #define QQ_FILE_AGENT_TRANSFER_DATA 2
00034 #define QQ_FILE_AGENT_TRANSFER_REPLY 3
00035 #define QQ_FILE_AGENT_TRANSFER_START 4
00036
00037 class EvaFTAgentCreate : public EvaFTAgentPacket
00038 {
00039 public:
00040 EvaFTAgentCreate();
00041 virtual ~EvaFTAgentCreate();
00042 void setFileAgentToken(const unsigned char *token, const int len);
00043 inline void setBuddyQQ(const int id) { m_Id = id; }
00044 inline void setIp(const unsigned int ip) { m_Ip = ip; }
00045 protected:
00046 const int fillBody(unsigned char *buf);
00047 private:
00048 unsigned char *m_Token;
00049 int m_TokenLength;
00050 int m_Id;
00051 unsigned int m_Ip;
00052 };
00053
00054
00055 class EvaFTAgentCreateReply : public EvaFTAgentPacket
00056 {
00057 public:
00058 EvaFTAgentCreateReply(const unsigned char *buf, const int len);
00059
00060 inline const bool isConnected() const { return m_ReplyCode==QQ_FILE_AGENT_CREATE_OK; }
00061 const unsigned short getReplyCode() const { return m_ReplyCode; }
00062
00063
00064
00065
00066 inline const unsigned int getIp() const { return m_Ip; }
00067 inline const unsigned short getPort() const { return m_Port; }
00068
00069 const std::string &getMessage() const { return m_ErrMessage; }
00070 protected:
00071 const bool parseBody(unsigned char *buf, const int len);
00072 private:
00073 unsigned short m_ReplyCode;
00074 unsigned int m_Ip;
00075 unsigned short m_Port;
00076 std::string m_ErrMessage;
00077 };
00078
00079
00080 class EvaFTAgentLogin : public EvaFTAgentPacket
00081 {
00082 public:
00083 EvaFTAgentLogin();
00084 ~EvaFTAgentLogin();
00085 void setFileAgentToken(const unsigned char *token, const int len);
00086 protected:
00087 const int fillBody(unsigned char *buf);
00088 private:
00089 unsigned char *m_Token;
00090 int m_TokenLength;
00091 };
00092
00093
00094 class EvaFTAgentLoginReply : public EvaFTAgentPacket
00095 {
00096 public:
00097 EvaFTAgentLoginReply(const unsigned char *buf, const int len);
00098 ~EvaFTAgentLoginReply() {};
00099 inline const bool isConnected() const { return m_ReplyCode==QQ_FILE_AGENT_OPERATION_OK ;}
00100 protected:
00101 const bool parseBody(unsigned char *buf, const int len);
00102 private:
00103 unsigned int m_ReplyCode;
00104 };
00105
00106
00107
00108 class EvaFTAgentTransfer : public EvaFTAgentPacket
00109 {
00110 public:
00111 EvaFTAgentTransfer(const int type);
00112 ~EvaFTAgentTransfer();
00113
00114
00115 void setInfo(const std::string &file, const unsigned char *fileMd5,
00116 const unsigned int size);
00117
00118
00119 void setData(const unsigned char *data, const unsigned int len);
00120
00121
00122 inline void setOffset(const unsigned int offset) { m_StartOffset = offset; }
00123 protected:
00124 const int fillBody(unsigned char *buf);
00125 private:
00126 int m_Type;
00127
00128
00129 std::string m_FileName;
00130 unsigned char *m_FMd5;
00131 unsigned int m_FileSize;
00132
00133
00134 unsigned char *m_Data;
00135 unsigned int m_DataLength;
00136
00137 unsigned int m_StartOffset;
00138 };
00139
00140
00141
00142 class EvaFTAgentTransferReply : public EvaFTAgentPacket
00143 {
00144 public:
00145 EvaFTAgentTransferReply(const int type, const unsigned char *buf, const int len);
00146 ~EvaFTAgentTransferReply();
00147
00148
00149 inline unsigned int getStartPosition() const { return m_ReplyCode;}
00150
00151
00152
00153 inline const bool isReceivedOk() const { return m_NextReplyCode == 0x02; }
00154
00155
00156 const unsigned char * getFileMd5();
00157 const unsigned char * getFileNameMd5();
00158 inline const std::string &getFileName() const { return m_FileName; }
00159 inline const unsigned int getFileSize() const { return m_FileSize; }
00160
00161
00162
00163
00164 inline const unsigned int getDataLength() const { return m_DataLength; }
00165
00166 inline const unsigned char *getData() const { return m_Data; }
00167
00168 protected:
00169 const bool parseBody(unsigned char *buf, const int len);
00170 private:
00171 int m_Type;
00172
00173
00174 unsigned int m_ReplyCode;
00175
00176
00177 unsigned char m_NextReplyCode;
00178
00179
00180 unsigned char *m_FileMd5;
00181 unsigned char *m_FileNameMd5;
00182 std::string m_FileName;
00183 unsigned int m_FileSize;
00184
00185
00186 unsigned char *m_Data;
00187 unsigned int m_DataLength;
00188 };
00189
00190
00191 class EvaFTAgentAckReady : public EvaFTAgentPacket
00192 {
00193 public:
00194 EvaFTAgentAckReady();
00195 ~EvaFTAgentAckReady();
00196 protected:
00197 const int fillBody(unsigned char *buf);
00198 };
00199
00200
00201 class EvaFTAgentAskReady : public EvaFTAgentPacket
00202 {
00203 public:
00204 EvaFTAgentAskReady(const unsigned char *buf, const int len);
00205 ~EvaFTAgentAskReady() {};
00206 inline const bool isAskReady() const { return m_ReplyCode==QQ_FILE_AGENT_OPERATION_OK ;}
00207 protected:
00208 const bool parseBody(unsigned char *buf, const int len);
00209 private:
00210 unsigned int m_ReplyCode;
00211 };
00212
00213
00214 class EvaFTAgentStart : public EvaFTAgentPacket
00215 {
00216 public:
00217 EvaFTAgentStart();
00218 ~EvaFTAgentStart();
00219 protected:
00220 const int fillBody(unsigned char *buf);
00221 };
00222
00223
00224 class EvaFTAgentStartReply : public EvaFTAgentPacket
00225 {
00226 public:
00227 EvaFTAgentStartReply(const unsigned char *buf, const int len);
00228 ~EvaFTAgentStartReply() {};
00229 protected:
00230 const bool parseBody(unsigned char *buf, const int len);
00231 };
00232
00233
00237 class EvaFTSynCreate : public EvaFTSynPacket
00238 {
00239 public:
00240 EvaFTSynCreate();
00241 ~EvaFTSynCreate();
00242 void setFileAgentToken(const unsigned char *token, const int len);
00243 inline void setBuddyQQ(const int id) { m_BuddyId = id; }
00244 protected:
00245 const int fillBody(unsigned char *buf);
00246 private:
00247 unsigned char *m_Token;
00248 int m_TokenLength;
00249 int m_BuddyId;
00250 };
00251
00252 class EvaFTSynCreateReply : public EvaFTSynPacket
00253 {
00254 public:
00255 EvaFTSynCreateReply(const unsigned char *buf, const int len);
00256
00257 inline const bool isSuccessful() const { return m_ReplyCode==QQ_FILE_AGENT_CREATE_OK; }
00258 const unsigned short getReplyCode() const { return m_ReplyCode; }
00259
00260 inline const unsigned int getIp() const { return m_Ip; }
00261 inline const unsigned short getPort() const { return m_Port; }
00262 protected:
00263 const bool parseBody(unsigned char *buf, const int len);
00264 private:
00265 unsigned short m_ReplyCode;
00266 unsigned int m_Ip;
00267 unsigned short m_Port;
00268 };
00269
00270
00271 #endif //#ifndef EVAFTPROTOCOL_H