tocprotocol.h

00001 // -*- C++ -*- 00002 /* 00003 $Id: tocprotocol_8h-source.html,v 1.1 2004/10/05 21:12:03 mentat Exp $ 00004 00005 GNU Messenger - The secure instant messenger 00006 00007 Original TOC implementation: 00008 Copyright (C) 1999-2001 Henrik Abelsson <henrik@abelsson.com> 00009 00010 Re-written implementation in C++: 00011 Copyright (C) 2002-2004 Jesse Lovelace <jesse at aslogicsys dot com> 00012 00013 This program is free software; you can redistribute it and/or modify 00014 it under the terms of the GNU General Public License as published by 00015 the Free Software Foundation; either version 2 of the License, or 00016 (at your option) any later version. 00017 00018 This program is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with this program; if not, write to the Free Software 00025 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 */ 00027 00028 #ifndef GM_TOCPROTOCOL_H 00029 #define GM_TOCPROTOCOL_H 00030 00031 #include "gm/forward.h" 00032 #include "gm/protocol.h" 00033 #include "gm/buffer.h" 00034 00035 namespace GNUMessenger 00036 { 00037 using namespace std; 00038 00039 class Network; 00040 class XMLNode; 00041 00060 class TocProtocol : public Protocol 00061 { 00062 public: 00063 00064 TocProtocol(const XMLNode &, ProtocolManager *manager); 00065 virtual ~TocProtocol(); 00066 00067 const string getLoginName() { return m_screenName; }; 00068 00069 virtual void update(); 00070 00072 virtual void login(); 00073 00075 virtual void logout(); 00076 00078 virtual void shutdown(); 00079 00081 virtual bool sendMessage(const Contact &recipient, const string &message); 00082 00084 virtual void addContact(const Contact &c); 00085 00087 virtual void delContact(const Contact &c); 00088 00090 virtual void newUser(const string& userName, const VBuffer& password); 00091 00094 virtual void getPubkey(); 00095 00097 virtual void handleData(Network *net); 00098 virtual void handleData(Network *net, const VBuffer& data); 00099 virtual void handleData(Network *net, const string& data) 00100 { 00101 handleData(net, VBuffer(data)); 00102 } 00103 00105 virtual void connectionError(Network *net,int error); 00106 00108 virtual void connectedToServer(Network *net); 00109 00111 virtual void setAway(const string& msg = ""); 00112 00114 virtual void setInfo(const string& info = ""); 00115 00118 virtual void getInfo(const string& contact); 00119 00120 virtual void reset(); 00121 00123 static string getErrorText(int i, const string& name); 00124 00126 class FlapHeader; 00127 00129 static vector<string> splitStrLF(const string& str); 00130 00132 static vector<string> splitStr(const string& str); 00133 00134 private: 00135 00136 /*------- Client->TOC Commands -----------*/ 00138 void signup(); 00140 void forceContactUpdate(const Contact& c); 00142 void addBuddies(); 00144 void sendCap(); 00146 void sendMessageAuto(const Contact &c, const string &message); 00149 void tocSendKeepalive(); 00150 00151 void tocGetInfo(const Contact& c); 00152 00153 /*------- TOC->Client Commands -----------*/ 00154 00156 void processUpdateBuddy(const string& data); 00158 void processFlapSignon(const string& data); 00160 void processSignon(const string& data); 00162 void processGotConfig(const string& data); 00164 void processIM(const string& data); 00166 void processError(const string& data); 00168 void processNick(const string& data); 00169 00170 /*------ Untility Functions --------*/ 00171 00172 virtual string formatId(const string& id) { return aim_normalize(id); } 00174 string aim_encode(const string& s); 00175 00177 string aim_normalize(const string& s); 00178 00180 string roastPassword(const VBuffer& pass); 00182 void send_flap(int type, const VBuffer& data); 00184 VBuffer return_flap(int type, const VBuffer& data); 00185 00187 void tocParseConfig(const string& config); 00188 00189 private: 00190 00192 enum PacketType { 00193 TYPE_SIGNON=1, 00194 TYPE_DATA , 00195 TYPE_ERROR, 00196 TYPE_SIGNOFF, 00197 TYPE_KEEPALIVE}; 00198 00200 bool m_paused; 00201 00203 VBuffer m_buffer; 00204 00206 string m_screenName; 00207 00209 string m_awayMessage; 00210 00211 00212 unsigned long m_realLength; 00213 00215 map <string, string> m_buddiesFromServer; 00216 00218 bool m_away; 00219 00220 typedef void (TocProtocol:: * tocFun)(const string& data); 00221 typedef Sgi::hash_map<string, tocFun> FuncMap; 00223 FuncMap m_funcMap; 00224 00225 protected: 00226 00228 void handleRealData(Network *net, const string& data); 00229 00231 Network *m_net; 00232 00233 }; 00234 } // !GNUMessenger 00235 00236 #endif // ! GM_TOCPROTOCOL_H

Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by doxygen 1.3.8