Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

SocketClient.h

00001 /*
00002  * SocketClient
00003  *
00004  * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
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     // ------------------ Signal dispatchers -----------------
00047     void SignalLog(LogEvent::LogType type, const std::string& msg);
00048 
00049     // ------------------  Signals ---------------------------
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 std::exception {
00063    private:
00064     std::string m_errortext;
00065     
00066    public:
00067     SocketClientException();
00068     SocketClientException(const std::string& text);
00069     ~SocketClientException() throw() { }
00070 
00071     const char* what() const throw();
00072   };
00073   
00074   class DisconnectedException : public SocketClientException {
00075    public:
00076     DisconnectedException(const std::string& text);
00077   };
00078 
00079 }
00080 
00081 #endif

Generated on Sun Jul 21 10:57:32 2002 for libicq2000 by doxygen1.2.16