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

evalevel.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 "evalevel.h"
00022 #ifdef _WIN32
00023 #include <winsock.h>
00024 #else
00025 #include <arpa/inet.h>
00026 #endif
00027 
00028 EvaGetLevelPacket::EvaGetLevelPacket(const std::list<int> &l)
00029         : OutPacket(QQ_CMD_GET_LEVEL, true), 
00030         friends(l)
00031 {
00032 }
00033 
00034 EvaGetLevelPacket::EvaGetLevelPacket(const EvaGetLevelPacket &rhs)
00035         : OutPacket(rhs)
00036 {
00037         friends = rhs.getList();
00038 }
00039 
00040 EvaGetLevelPacket &EvaGetLevelPacket::operator=(const EvaGetLevelPacket &rhs)
00041 {
00042         *((OutPacket *)this) = (OutPacket)rhs;
00043         friends = rhs.getList();
00044         return *this;
00045 }
00046 
00047 int EvaGetLevelPacket::putBody(unsigned char *buf)
00048 {
00049         int pos = 0;
00050         buf[pos++] = 0x00;
00051         
00052         int tmp4;
00053         std::list<int>::iterator iter;
00054         for(iter = friends.begin(); iter!=friends.end(); ++iter){
00055                 tmp4 = htonl(*iter);
00056                 memcpy(buf+pos, &tmp4, 4);
00057                 pos+=4;
00058         }
00059         return pos;
00060 }
00061 
00062 
00063 /*** ============================================================== */
00064 
00065 EvaGetLevelReplyPacket::EvaGetLevelReplyPacket(unsigned char *buf, int len)
00066         : InPacket(buf, len)
00067 { 
00068 } 
00069 
00070 EvaGetLevelReplyPacket::EvaGetLevelReplyPacket(const EvaGetLevelReplyPacket &rhs)
00071         : InPacket(rhs)
00072 {
00073         replyCode = rhs.getReplyCode();
00074         friends = rhs.getLevelList();
00075 }
00076 
00077 EvaGetLevelReplyPacket &EvaGetLevelReplyPacket::operator=(const EvaGetLevelReplyPacket &rhs)
00078 {
00079         *((InPacket *)this) = (InPacket)rhs;
00080         replyCode = rhs.getReplyCode();
00081         friends = rhs.getLevelList();
00082         return *this;
00083 }
00084 
00085 void EvaGetLevelReplyPacket::parseBody()
00086 {
00087         replyCode = decryptedBuf[0];
00088         
00089         int pos = 1;
00090         int tmp4;
00091         short tmp2;
00092         
00093         friends.clear();
00094         LevelUserItem item;
00095         while( pos < bodyLength ){
00096                 memcpy(&tmp4, decryptedBuf + pos, 4);
00097                 item.qqNum = ntohl(tmp4);
00098                 pos+=4;
00099                 
00100                 memcpy(&tmp4, decryptedBuf + pos, 4);
00101                 item.onlineTime = ntohl(tmp4);
00102                 pos+=4;
00103                 
00104                 memcpy(&tmp2, decryptedBuf + pos, 2);
00105                 item.level = ntohs(tmp2);
00106                 pos+=2;
00107                 
00108                 memcpy(&tmp2, decryptedBuf + pos, 2);
00109                 item.timeRemainder = ntohs(tmp2);
00110                 pos+=2;
00111                 
00112                 friends.push_back(item);
00113         }
00114 }
00115 

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