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 #ifndef LIBEVAFRIEND_H 00021 #define LIBEVAFRIEND_H 00022 00023 #include "evapacket.h" 00024 #include "evadefines.h" 00025 #include <list> 00026 #include <string> 00027 00028 class FriendItem{ 00029 public: 00030 FriendItem(); 00031 FriendItem(const unsigned char *buf, int *len); 00032 FriendItem(const FriendItem &rhs); 00033 ~FriendItem() {} 00034 00035 const int getQQ() const { return qqNum; } 00036 const short getFace() const { return face; } 00037 const char getAge() const { return age; } 00038 const char getGender() const { return gender; } 00039 const std::string &getNick() const { return nick; } // note: nick is encoded by "GB18030" 00040 const char getExtFlag() const { return extFlag; } 00041 const char getCommonFlag() const { return commonFlag; } 00042 const long getLoginTime() const { return loginTime; } 00043 const long getIdleTime() const { return idleTime; } 00044 const long getLastRefreshTime() const { return lastRefreshTime; } 00045 00046 void setQQ(const int id) { qqNum = id; } 00047 void setFace(const short f) { face = f; } 00048 void setAge(const char a) { age = a; } 00049 void setGender(const char g) { gender = g; } 00050 void setNick(const std::string &n) { nick = n; } 00051 void setExtFlag(const char ef) { extFlag = ef; } 00052 void setCommonFlag(const char cf) { commonFlag = cf; } 00053 00054 void setOnline(const bool online) { mIsOnline = online; } 00055 const bool isOnline() const { return mIsOnline; } 00056 00057 const unsigned short getQunGroupIndex() const { return qunGroupIndex; } 00058 const unsigned short getQunAdminValue() const { return qunAdminValue; } 00059 00060 void setQunGroupIndex(const unsigned char index) { qunGroupIndex = index;} 00061 void setQunAdminValue(const unsigned char value) { qunAdminValue = value;} 00062 const bool isAdmin() const { return qunAdminValue & QUN_TYPE_ADMIN; } 00063 const bool isShareHolder() const { return qunAdminValue & QUN_TYEP_SHAREHOLDER; } 00064 00065 // the following 2 methods implemented by henry first, I change the names a bit :) 00066 void setQunRealName(const std::string name) { m_QunRealName = name; } 00067 void setQunRealNameVersion( const int version) { m_QunRealNameVersion = version; } 00068 const std::string &getQunRealName() const { return m_QunRealName; } 00069 const int getQunRealNameVersion() const { return m_QunRealNameVersion; } 00070 00071 bool isMember() { return (commonFlag & 0x2) != 0; } 00072 bool isBoy() { return gender == QQ_FRIEND_GENDER_GG;} 00073 FriendItem *copy() { return new FriendItem(*this);} 00074 FriendItem &operator=(const FriendItem &rhs); 00075 private: 00076 void parseData(const unsigned char *buf, int *len); 00077 00078 int qqNum; 00079 short face; 00080 char age; 00081 char gender; 00082 std::string nick; 00083 char extFlag; // bit1: if has qqshow, the rest are unknown 00084 char commonFlag; // bit1: memeber, bit4: TCP mode, bit5 : mobile QQ, 00085 // bit6: mobile binding, bit7: webcam 00086 long loginTime; 00087 long idleTime; 00088 long lastRefreshTime; 00089 00090 unsigned char qunGroupIndex; // for qun use only, default is 0 00091 unsigned char qunAdminValue; // for qun use only, default is 0 00092 int m_QunRealNameVersion; 00093 std::string m_QunRealName; // henry: for qun use only 00094 00095 bool mIsOnline; 00096 }; 00097 00098 typedef std::list<FriendItem> friendItemList; 00099 00100 class GetFriendListPacket : public OutPacket { 00101 public: 00102 GetFriendListPacket(); 00103 GetFriendListPacket(const short startPosition); 00104 GetFriendListPacket(const GetFriendListPacket &rhs); 00105 virtual ~GetFriendListPacket() {}; 00106 00107 OutPacket * copy() { return new GetFriendListPacket(*this);} 00108 GetFriendListPacket &operator=( const GetFriendListPacket &rhs); 00109 00110 const short getStartPosition() const { return startPosition; } 00111 void setStartPosition(const short startPosition) { this->startPosition = startPosition; } 00112 00113 protected: 00114 virtual int putBody(unsigned char *buf) ; 00115 00116 private: 00117 short startPosition; 00118 }; 00119 00120 class GetFriendListReplyPacket : public InPacket { 00121 public: 00122 GetFriendListReplyPacket() {} 00123 GetFriendListReplyPacket(unsigned char *buf, int len); 00124 GetFriendListReplyPacket(const GetFriendListReplyPacket &rhs); 00125 virtual ~GetFriendListReplyPacket() {} 00126 00127 const short getPosition() const { return position; } 00128 const friendItemList &getFriendList() const { return friends; } 00129 GetFriendListReplyPacket &operator=( const GetFriendListReplyPacket &rhs); 00130 protected: 00131 void parseBody(); 00132 private: 00133 short position; 00134 friendItemList friends; 00135 }; 00136 00137 #endif 00138
1.4.4