Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

evarequestface.cpp

Go to the documentation of this file.
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 #include "evarequestface.h"
00022 #include <string.h>
00023 #ifdef _WIN32
00024 #include <winsock.h>
00025 #else
00026 #include <arpa/inet.h>
00027 #endif
00028 
00029 EvaRequestFacePacket::EvaRequestFacePacket()
00030         : EvaPicOutPacket(QQ_05_CMD_REQUEST_FACE, true), fileAgentToken(NULL)
00031 {
00032         cryptPosition = 12;
00033 }
00034 
00035 EvaRequestFacePacket::EvaRequestFacePacket(const EvaRequestFacePacket &rhs)
00036         : EvaPicOutPacket(rhs), fileAgentToken(NULL)
00037 {
00038         *this = rhs;
00039 }
00040 
00041 EvaRequestFacePacket::~EvaRequestFacePacket()
00042 {
00043         if(fileAgentToken)
00044                 delete fileAgentToken;
00045 }
00046 
00047 EvaRequestFacePacket &EvaRequestFacePacket::operator=(const EvaRequestFacePacket &rhs)
00048 {
00049         *((EvaPicOutPacket*)this) = (EvaPicOutPacket)rhs;
00050         qunID = rhs.getQunID();
00051         sessionID = rhs.getSessionID();
00052         
00053         tokenLength = rhs.getTokenLength();
00054         setFileAgentToken(rhs.getFileAgentToken(), tokenLength);
00055         return *this;
00056 }
00057 
00058 void EvaRequestFacePacket::setFileAgentToken(const unsigned char *token, const int len)
00059 {
00060         if(!fileAgentToken)
00061                 fileAgentToken = new unsigned char[len];
00062         tokenLength = len;
00063         memcpy(fileAgentToken, token, tokenLength);
00064 }
00065 
00066 int EvaRequestFacePacket::putBody(unsigned char *buf)
00067 {
00068         int pos = 0;
00069         int tmp4_1, tmp4_2;
00070         memcpy(buf, &tmp4_1, 4);
00071         pos+=4;
00072         memcpy(buf+pos, &tmp4_2, 4); // unknown 8 bytes
00073         pos+=4;
00074         
00075         tmp4_1 = htonl(sessionID);
00076         memcpy(buf+pos, &tmp4_1, 4);
00077         pos+=4;
00078         
00079         unsigned short tmp2;
00080         tmp2 = htons(tokenLength) & 0xffff;
00081         memcpy(buf+pos, &tmp2, 2);
00082         pos+=2;
00083         
00084         memcpy(buf+pos, fileAgentToken, tokenLength);
00085         pos+=tokenLength;
00086         
00087         tmp4_1 = htonl(qunID);
00088         memcpy(buf+pos, &tmp4_1, 4);
00089         pos+=4;
00090         
00091         return pos;
00092 }
00093 
00094 
00095 /***********************************************************************************************************************/
00096 
00097 
00098 EvaRequestFaceReplyPacket::EvaRequestFaceReplyPacket(unsigned char *buf, int len)
00099         : EvaPicInPacket(buf, len, 12)
00100 {
00101 }
00102 
00103 EvaRequestFaceReplyPacket::EvaRequestFaceReplyPacket(const EvaRequestFaceReplyPacket &rhs)
00104         : EvaPicInPacket(rhs)
00105 {
00106         *this = rhs;
00107 }
00108 
00109 EvaRequestFaceReplyPacket &EvaRequestFaceReplyPacket::operator=(const EvaRequestFaceReplyPacket &rhs)
00110 {
00111         *((EvaPicInPacket*)this) = (EvaPicInPacket)rhs;
00112         sessionID = rhs.getSessionID();
00113         return *this;
00114 }
00115 
00116 void EvaRequestFaceReplyPacket::parseBody()
00117 {
00118         int pos = 0;
00119         pos+=8;  // we ignore the first 8 bytes of body
00120         int tmp4;
00121         memcpy(&tmp4, decryptedBuf+pos, 4);
00122         sessionID = ntohl(tmp4);
00123 }
00124 
00125 
00126 
00127 
00128 

Generated on Mon May 15 20:48:42 2006 for libeva by  doxygen 1.4.4