00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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