00001 /*************************************************************************** 00002 * Copyright (C) 2005 by yunfan * 00003 * yunfan_zg@163.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00021 #ifndef LIBCUSTOMPIC_EVATRANSFER_H 00022 #define LIBCUSTOMPIC_EVATRANSFER_H 00023 00024 #include "evapicpacket.h" 00025 #include <string> 00026 00027 class EvaPicTransferPacket : public EvaPicOutPacket{ 00028 public: 00029 EvaPicTransferPacket(); 00030 EvaPicTransferPacket(const bool isDataPacket, const bool isLastPacket); 00031 EvaPicTransferPacket(const EvaPicTransferPacket &rhs); 00032 virtual ~EvaPicTransferPacket(); 00033 00034 EvaPicTransferPacket &operator=(const EvaPicTransferPacket &rhs); 00035 00036 const unsigned int getSessionID() const {return sessionID; } 00037 const unsigned char *getMD5() const { return md5;} 00038 const std::string &getFileName() const { return fileName; } 00039 const unsigned int getImageLength() const { return imageLength; } 00040 00041 const unsigned char *getFragment() const { return fragment; } 00042 const unsigned short getFragmentLength() const { return fragLength; } 00043 00044 const bool isDataPacket() const { return isData; } 00045 const bool isLastPacket() const { return isLast; } 00046 00047 const bool isRequestSend() const { return requestSend; } 00048 const bool isDataReply() const { return dataReply; } 00049 00050 void setSessionID(const unsigned int id) { sessionID=id;} 00051 00052 void setMd5(const unsigned char *value); 00053 void setImageLength(const unsigned short len) { imageLength = len; } 00054 void setFileName( const std::string &name) { fileName = name ;} 00055 00056 void setFragment(const unsigned char *data, const unsigned int len); 00057 void setDataPacket(const bool ok) { isData = ok; } 00058 void setLastPacket(const bool ok) { isLast = ok; } 00059 00060 void setRequestSend(const bool ok) { requestSend= ok; } 00061 void setDataReply( const bool ok) { dataReply = ok; } 00062 00063 protected: 00064 int putBody(unsigned char *buf); 00065 private: 00066 unsigned int sessionID; 00067 00068 // for send file info 00069 unsigned char md5[16]; // always 16 bytes long 00070 unsigned int imageLength; 00071 std::string fileName; 00072 00073 // for user sending image 00074 unsigned char *fragment; 00075 unsigned short fragLength; 00076 bool isData; 00077 bool isLast; 00078 00079 bool requestSend; 00080 bool dataReply; 00081 }; 00082 00083 class EvaPicTransferReplyPacket : public EvaPicInPacket{ 00084 public: 00085 EvaPicTransferReplyPacket() {} 00086 EvaPicTransferReplyPacket(unsigned char *buf, int len); 00087 EvaPicTransferReplyPacket(const EvaPicTransferReplyPacket &rhs); 00088 virtual ~EvaPicTransferReplyPacket(); 00089 00090 EvaPicTransferReplyPacket &operator=(const EvaPicTransferReplyPacket &rhs); 00091 00092 const unsigned int getSessionID() const { return sessionID; } 00093 const unsigned char *getMd5() const { return md5; } 00094 const unsigned char *getFileNameMd5() const { return fileNameMd5; } 00095 const std::string &getFileName() const { return fileName; } 00096 const unsigned int getImageLength() const { return imageLength; } 00097 00098 const unsigned char *getData() const { return data; } 00099 const unsigned int getDataLength() const { return dataLength; } 00100 protected: 00101 void parseBody(); 00102 private: 00103 unsigned int sessionID; 00104 // server send to me file info packet 00105 unsigned char md5[16]; 00106 unsigned char fileNameMd5[16]; 00107 std::string fileName; 00108 unsigned int imageLength; 00109 00110 // data packet 00111 unsigned char *data; 00112 unsigned int dataLength; 00113 }; 00114 00115 #endif
1.4.4