00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SOCKETCLIENT_H
00023 #define SOCKETCLIENT_H
00024
00025 #include <string>
00026
00027 #include <sigc++/signal_system.h>
00028
00029 #include <libicq2000/socket.h>
00030 #include <libicq2000/events.h>
00031
00032 namespace ICQ2000 {
00033
00034 class SocketClient : public SigC::Object {
00035 protected:
00036 void SignalAddSocket(int fd, SocketEvent::Mode m);
00037 void SignalRemoveSocket(int fd);
00038
00039 TCPSocket *m_socket;
00040
00041 public:
00042 virtual void Connect() = 0;
00043 virtual void FinishNonBlockingConnect() = 0;
00044 virtual void Recv() = 0;
00045
00046
00047 void SignalLog(LogEvent::LogType type, const std::string& msg);
00048
00049
00050 SigC::Signal1<void,LogEvent*> logger;
00051 SigC::Signal1<void,MessageEvent*> messageack;
00052 SigC::Signal1<void,SocketEvent*> socket;
00053 SigC::Signal0<void> connected;
00054
00055 int getfd() const;
00056 TCPSocket* getSocket() const;
00057 virtual void clearoutMessagesPoll() = 0;
00058
00059 virtual void SendEvent(MessageEvent* ev) = 0;
00060 };
00061
00062 class SocketClientException : public exception {
00063 private:
00064 string m_errortext;
00065
00066 public:
00067 SocketClientException();
00068 SocketClientException(const string& text);
00069 ~SocketClientException() throw() { }
00070
00071 const char* what() const throw();
00072 };
00073
00074 class DisconnectedException : public SocketClientException {
00075 public:
00076 DisconnectedException(const string& text);
00077 };
00078
00079 }
00080
00081 #endif