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

evakeyrequest.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 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 "evakeyrequest.h"
00022 #include <string.h>
00023 
00024 EvaRequestKeyPacket::EvaRequestKeyPacket()
00025       : OutPacket(QQ_CMD_REQUEST_KEY, true)
00026 {
00027 }
00028 
00029 EvaRequestKeyPacket::EvaRequestKeyPacket(const unsigned char requestType)
00030       : OutPacket(QQ_CMD_REQUEST_KEY, true)
00031 {
00032         request = requestType;
00033 }
00034 
00035 EvaRequestKeyPacket::EvaRequestKeyPacket( const EvaRequestKeyPacket &rhs )
00036         : OutPacket(rhs)
00037 {
00038         *this = rhs;
00039 }
00040 
00041 EvaRequestKeyPacket::~EvaRequestKeyPacket()
00042 {
00043 }
00044 
00045 EvaRequestKeyPacket &EvaRequestKeyPacket::operator=(const EvaRequestKeyPacket &rhs)
00046 {
00047         *( (OutPacket *)this) = (OutPacket)rhs;
00048         request = rhs.getRequest();
00049         return *this;
00050 }
00051 
00052 int EvaRequestKeyPacket::putBody(unsigned char* buf)
00053 {
00054         buf[0]=request;
00055         return 1;
00056 }
00057 
00058 
00059 
00060 /**********************************************************************************************************************/
00061 
00062 EvaRequestKeyReplyPacket::EvaRequestKeyReplyPacket(unsigned char* buf, int len)
00063         : InPacket(buf, len)
00064 {
00065 }
00066 
00067 EvaRequestKeyReplyPacket::EvaRequestKeyReplyPacket(const EvaRequestKeyReplyPacket &rhs)
00068         : InPacket(rhs)
00069 {
00070         *this = rhs;
00071 }
00072 
00073 EvaRequestKeyReplyPacket &EvaRequestKeyReplyPacket::operator=(const EvaRequestKeyReplyPacket &rhs)
00074 {
00075         *( (InPacket *)this) = (InPacket)rhs;
00076         keyType = rhs.getKeyType();
00077         replyCode = rhs.getReplyCode();
00078         memcpy(key, rhs.getKey(), 16);
00079         tokenLength = rhs.getTokenLength();
00080         memcpy(token, rhs.getToken(), tokenLength);
00081         return *this;
00082 }
00083 
00084 void EvaRequestKeyReplyPacket::parseBody()
00085 {
00086         keyType = decryptedBuf[0];
00087         replyCode = decryptedBuf[1];
00088         if(replyCode == QQ_REQUEST_KEY_REPLY_OK) {            
00089                 memcpy(key, decryptedBuf+2, QQ_KEY_LENGTH);
00090                 
00091                 if(keyType == QQ_REQUEST_FILE_AGENT_KEY) 
00092                         setFileAgentKey(key);                   // now we set file agent key
00093                 
00094                 tokenLength = (int)(decryptedBuf[2+QQ_KEY_LENGTH+12]) & 0xFF;            
00095                 memcpy(token, decryptedBuf+2+QQ_KEY_LENGTH+12+1, tokenLength);
00096                 
00097                 if(keyType == QQ_REQUEST_FILE_AGENT_KEY) 
00098                         setFileAgentToken(token, tokenLength);          // now we can set file agent token
00099         }
00100 }

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