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 #ifndef LIBEVAONLINESTATUS_H 00022 #define LIBEVAONLINESTATUS_H 00023 00024 #include "evapacket.h" 00025 #include <list> 00026 00027 class FriendStatus; // this class is for private use only 00028 00029 class FriendOnlineEntry { 00030 public: 00031 FriendOnlineEntry(); 00032 FriendOnlineEntry(const FriendOnlineEntry &rhs); 00033 ~FriendOnlineEntry(); 00034 00035 FriendOnlineEntry *copy() { return new FriendOnlineEntry(*this);} 00036 00037 const int getQQ() const; 00038 const int getIP() const; 00039 const short getPort() const; 00040 const char getStatus() const; 00041 const char getUnknown1_4() const; // bit 4 00042 const char getUnknown2_11() const; // bit 11 00043 const short getUnknown3_13_14() const; // bit 13-14 00044 const unsigned char * getUnknownKey() const; 00045 00046 00047 const short getUnknown4_31_32() const { return unknown31_32; } 00048 const char getExtFlag() const { return extFlag; } 00049 const char getCommFlag() const { return commFlag; } 00050 const short getUnknown5_35_36() const { return unknown35_36; } 00051 const char getEnd() const { return ending; } 00052 00053 int numOfBytes; 00054 int readData(unsigned char * buf); 00055 FriendOnlineEntry &operator=(const FriendOnlineEntry &rhs); 00056 private: 00057 FriendStatus *status; 00058 short unknown31_32; 00059 char extFlag; 00060 char commFlag; 00061 short unknown35_36; 00062 char ending; // always be 0 00063 }; 00064 00065 typedef std::list<FriendOnlineEntry> onlineList; 00066 00067 class GetOnlineFriendsPacket : public OutPacket 00068 { 00069 public: 00070 GetOnlineFriendsPacket(); 00071 GetOnlineFriendsPacket(const char position); 00072 GetOnlineFriendsPacket(const GetOnlineFriendsPacket &rhs); 00073 virtual ~GetOnlineFriendsPacket() {}; 00074 00075 OutPacket * copy() { return new GetOnlineFriendsPacket(*this);} 00076 GetOnlineFriendsPacket &operator=(const GetOnlineFriendsPacket &rhs); 00077 00078 const char getStartPosition() const { return startPosition; }; 00079 00080 void setStartPosition(const char position) { startPosition = position; }; 00081 00082 protected: 00083 int putBody(unsigned char *buf); 00084 private: 00085 char startPosition; 00086 }; 00087 00088 class GetOnlineFriendReplyPacket : public InPacket 00089 { 00090 public: 00091 GetOnlineFriendReplyPacket() {} 00092 GetOnlineFriendReplyPacket(unsigned char *buf, int len); 00093 GetOnlineFriendReplyPacket(const GetOnlineFriendReplyPacket &rhs); 00094 virtual ~GetOnlineFriendReplyPacket() {} 00095 00096 const char getPosition() const { return position; } 00097 const onlineList &getOnlineFriendList() const { return onlineFriends; } 00098 GetOnlineFriendReplyPacket &operator=(const GetOnlineFriendReplyPacket &rhs); 00099 protected: 00100 void parseBody(); 00101 private: 00102 char position; 00103 onlineList onlineFriends; 00104 }; 00105 00106 class FriendChangeStatusPacket : public InPacket 00107 { 00108 public: 00109 FriendChangeStatusPacket() {} 00110 FriendChangeStatusPacket(unsigned char* buf, int len); 00111 FriendChangeStatusPacket(const FriendChangeStatusPacket &rhs); 00112 virtual ~FriendChangeStatusPacket(); 00113 00114 const int getQQ() const; 00115 const int getIP() const; 00116 const short getPort() const; 00117 const char getStatus() const; 00118 const char getUnknown1_4() const; // bit 4 00119 const char getUnknown2_11() const; // bit 11 00120 const short getUnknown3_13_14() const; // bit 13-14 00121 const unsigned char *getUnknownKey() const; 00122 00123 // this is not that useful, just means the message's receiver should hold this account 00124 const int getMyQQ() const { return myQQNum;} 00125 FriendChangeStatusPacket &operator=(const FriendChangeStatusPacket &rhs); 00126 protected: 00127 void parseBody(); 00128 private: 00129 FriendStatus *status; 00130 int myQQNum; 00131 00132 }; 00133 00134 class ChangeStatusPacket : public OutPacket 00135 { 00136 public: 00137 ChangeStatusPacket(); 00138 ChangeStatusPacket(char status); 00139 ChangeStatusPacket(const ChangeStatusPacket &rhs); 00140 virtual ~ChangeStatusPacket() {}; 00141 OutPacket * copy() { return new ChangeStatusPacket(*this);} 00142 ChangeStatusPacket &operator=(const ChangeStatusPacket &rhs); 00143 00144 const char getOnlineStatus() const { return myStatus; } 00145 void setOnlineStatus( const char status) { myStatus = status; } 00146 void setMiscStatus( const unsigned int status ) { miscStatus = status; } 00147 protected: 00148 virtual int putBody(unsigned char *buf); 00149 private: 00150 char myStatus; 00151 unsigned int miscStatus; 00152 }; 00153 00154 class ChangeStatusReplyPacket : public InPacket 00155 { 00156 public: 00157 ChangeStatusReplyPacket() {} 00158 ChangeStatusReplyPacket(unsigned char *buf, int len); 00159 ChangeStatusReplyPacket(const ChangeStatusReplyPacket &rhs); 00160 virtual ~ChangeStatusReplyPacket() {} 00161 00162 const char getReplyCode() const { return replyCode; }; 00163 const bool isAccepted() const; 00164 ChangeStatusReplyPacket &operator=(const ChangeStatusReplyPacket &rhs); 00165 protected: 00166 void parseBody(); 00167 private: 00168 char replyCode; 00169 }; 00170 00171 #endif 00172
1.4.4