00001 00002 #ifndef OPIE_OCOP_SERVER_H 00003 #define OPIE_OCOP_SERVER_H 00004 00005 #include <sys/un.h> 00006 00007 #include <qvaluelist.h> 00008 #include <qobject.h> 00009 #include <qmap.h> 00010 #include <qstring.h> 00011 #include <qsocketnotifier.h> 00012 00013 #include "../common/ocoppacket.h" 00014 #include "ocopclient.h" 00020 class OCopServer : public QObject { 00021 Q_OBJECT 00022 public: 00023 OCopServer(); 00024 ~OCopServer(); 00025 00026 QStringList channels(); 00027 bool isChannelRegistered(const QCString& )const; 00028 00029 private slots: 00030 void errorOnServer();// error on Server 00031 void newOnServer();// accept to be taken 00032 void newOnClient(int fd ); // new package received 00033 00034 private: 00035 /* replace fd with a special class in future 00036 * to even work on Windoze aye aye 00037 */ 00044 void addChannel( const QCString& channel, 00045 int fd ); 00046 void delChannel( const QCString& channel, 00047 int fd ); 00048 00052 void deregisterClient( int fd ); 00053 00057 void registerClient( int fd ); 00058 00059 private: 00060 void init(); 00061 private slots: 00062 void initSocket(); 00063 private: 00064 int accept(); 00065 void isRegistered( const QCString& channel, int ); 00066 void dispatch( const OCOPPacket&, int sourceFD ); 00067 void call( const OCOPPacket&, int sourceFD ); 00068 QValueList<int> clients(const QCString& channel ); 00069 /* 00070 * All clients 00071 * They include a fd and a QSocketNotifier 00072 */ 00073 QMap<int, OCOPClient> m_clients; 00074 00075 /* 00076 * The channels avilable 00077 */ 00078 QMap<QCString, QValueList<int> > m_channels; 00079 00080 /* 00081 * a notifier for our server 00082 * if new stuff is arriving 00083 */ 00084 QSocketNotifier* m_server; 00085 00086 /* 00087 * error 00088 */ 00089 QSocketNotifier* m_serverError; 00090 int m_serverfd; 00091 struct sockaddr_un m_address; 00092 unsigned int m_adrlaenge; 00093 }; 00094 00095 #endif
1.4.2