summaryrefslogtreecommitdiff
path: root/x11/ipc/server/ocopserver.h
Unidiff
Diffstat (limited to 'x11/ipc/server/ocopserver.h') (more/less context) (ignore whitespace changes)
-rw-r--r--x11/ipc/server/ocopserver.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/x11/ipc/server/ocopserver.h b/x11/ipc/server/ocopserver.h
new file mode 100644
index 0000000..3e08d5b
--- a/dev/null
+++ b/x11/ipc/server/ocopserver.h
@@ -0,0 +1,95 @@
1
2#ifndef OPIE_OCOP_SERVER_H
3#define OPIE_OCOP_SERVER_H
4
5#include <sys/un.h>
6
7#include <qvaluelist.h>
8#include <qobject.h>
9#include <qmap.h>
10#include <qstring.h>
11#include <qsocketnotifier.h>
12
13#include "../common/ocoppacket.h"
14#include "ocopclient.h"
15/**
16 * This is the main server
17 * It starts the socket
18 * takes care of the receiving and sending
19 */
20class OCopServer : public QObject {
21 Q_OBJECT
22public:
23 OCopServer();
24 ~OCopServer();
25
26 QStringList channels();
27 bool isChannelRegistered(const QCString& )const;
28
29private slots:
30 void errorOnServer();// error on Server
31 void newOnServer();// accept to be taken
32 void newOnClient(int fd ); // new package received
33
34private:
35 /* replace fd with a special class in future
36 * to even work on Windoze aye aye
37 */
38 /**
39 * add a channel with a fd
40 * if the channel is not present
41 * then it'll be created
42 * if it's present we will ad the fd
43 */
44 void addChannel( const QCString& channel,
45 int fd );
46 void delChannel( const QCString& channel,
47 int fd );
48
49 /**
50 * fd was closed
51 */
52 void deregisterClient( int fd );
53
54 /**
55 * fd popped up
56 */
57 void registerClient( int fd );
58
59private:
60 void init();
61private slots:
62 void initSocket();
63private:
64 int accept();
65 void isRegistered( const QCString& channel, int );
66 void dispatch( const OCOPPacket&, int sourceFD );
67 void call( const OCOPPacket&, int sourceFD );
68 QValueList<int> clients(const QCString& channel );
69 /*
70 * All clients
71 * They include a fd and a QSocketNotifier
72 */
73 QMap<int, OCOPClient> m_clients;
74
75 /*
76 * The channels avilable
77 */
78 QMap<QCString, QValueList<int> > m_channels;
79
80 /*
81 * a notifier for our server
82 * if new stuff is arriving
83 */
84 QSocketNotifier* m_server;
85
86 /*
87 * error
88 */
89 QSocketNotifier* m_serverError;
90 int m_serverfd;
91 struct sockaddr_un m_address;
92 unsigned int m_adrlaenge;
93};
94
95#endif