dcop
dcopserver.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef DCOPSERVER_H
00023 #define DCOPSERVER_H "$Id: dcopserver.h 423060 2005-06-07 10:49:14Z staniek $"
00024
00025 #include <qobject.h>
00026
00027 #include <qstring.h>
00028 #include <qsocketnotifier.h>
00029 #include <qptrlist.h>
00030 #include <qvaluelist.h>
00031 #include <qcstring.h>
00032 #include <qdict.h>
00033 #include <qptrdict.h>
00034 #include <qintdict.h>
00035 #include <qapplication.h>
00036
00037 #define INT32 QINT32
00038 #ifdef Q_WS_X11
00039 #include <X11/Xlib.h>
00040 #include <X11/Xmd.h>
00041 #endif
00042 #include <KDE-ICE/ICElib.h>
00043 extern "C" {
00044 #include <KDE-ICE/ICEutil.h>
00045 #include <KDE-ICE/ICEmsg.h>
00046 #include <KDE-ICE/ICEproto.h>
00047 }
00048
00049 class DCOPConnection;
00050 class DCOPListener;
00051 class DCOPSignalConnectionList;
00052 class DCOPSignals;
00053 class QTimer;
00054
00055
00056
00057
00058
00059 #ifdef DCOP_LOG
00060 class QTextStream;
00061 class QFile;
00062 #endif
00063
00064 typedef QValueList<QCString> QCStringList;
00065
00069 class DCOPConnection : public QSocketNotifier
00070 {
00071 public:
00072 DCOPConnection( IceConn conn );
00073 ~DCOPConnection();
00074
00075 DCOPSignalConnectionList *signalConnectionList();
00076
00077
00078
00079 void waitForOutputReady(const QByteArray &_data, int start);
00080
00081
00082
00083 void slotOutputReady();
00084
00085 QCString appId;
00086 QCString plainAppId;
00087 IceConn iceConn;
00088 int notifyRegister;
00100 QPtrList <_IceConn> waitingOnReply;
00101 QPtrList <_IceConn> waitingForReply;
00102 QPtrList <_IceConn> waitingForDelayedReply;
00103 DCOPSignalConnectionList *_signalConnectionList;
00104 bool daemon;
00105 bool outputBlocked;
00106 QValueList <QByteArray> outputBuffer;
00107 unsigned long outputBufferStart;
00108 QSocketNotifier *outputBufferNotifier;
00109 };
00110
00111
00115 class DCOPServer : public QObject
00116 {
00117 Q_OBJECT
00118 public:
00119 DCOPServer(bool _suicide);
00120 ~DCOPServer();
00121
00122 void* watchConnection( IceConn iceConn );
00123 void removeConnection( void* data );
00124 void processMessage( IceConn iceConn, int opcode, unsigned long length, Bool swap);
00125 void ioError( IceConn iceConn );
00126
00127 bool receive(const QCString &app, const QCString &obj,
00128 const QCString &fun, const QByteArray& data,
00129 QCString& replyType, QByteArray &replyData, IceConn iceConn);
00130
00131 DCOPConnection *findApp(const QCString &appId);
00132 DCOPConnection *findConn(IceConn iceConn)
00133 { return clients.find(iceConn); }
00134
00135 void sendMessage(DCOPConnection *conn, const QCString &sApp,
00136 const QCString &rApp, const QCString &rObj,
00137 const QCString &rFun, const QByteArray &data);
00138
00139 private slots:
00140 void newClient( int socket );
00141 void processData( int socket );
00142 void slotTerminate();
00143 void slotSuicide();
00144 void slotShutdown();
00145 void slotExit();
00146 void slotCleanDeadConnections();
00147 void slotOutputReady(int socket );
00148
00149 #ifdef Q_OS_WIN
00150 public:
00151 static BOOL WINAPI dcopServerConsoleProc(DWORD dwCtrlType);
00152 private:
00153 static DWORD WINAPI TerminatorThread(void * pParam);
00154 #endif
00155 private:
00156 void broadcastApplicationRegistration( DCOPConnection* conn, const QCString type,
00157 const QCString& data );
00158 bool suicide;
00159 bool shutdown;
00160 int majorOpcode;
00161 int currentClientNumber;
00162 CARD32 serverKey;
00163 DCOPSignals *dcopSignals;
00164 QTimer *m_timer;
00165 QTimer *m_deadConnectionTimer;
00166 QPtrList<DCOPListener> listener;
00167 QAsciiDict<DCOPConnection> appIds;
00168 QPtrDict<DCOPConnection> clients;
00169 QIntDict<DCOPConnection> fd_clients;
00170 QPtrList<_IceConn> deadConnections;
00171
00172 #ifdef Q_OS_WIN
00173 HANDLE m_evTerminate;
00174 HANDLE m_hTerminateThread;
00175 DWORD m_dwTerminateThreadId;
00176 #endif
00177
00178 #ifdef DCOP_LOG
00179 QTextStream *m_stream;
00180 QFile *m_logger;
00181 #endif
00182 };
00183
00184 extern DCOPServer* the_server;
00185
00186 #endif