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,v 1.38 2005/02/21 23:52:16 waba Exp $"
00024
00025
#include <qobject.h>
00026
00027
#ifdef Q_OS_UNIX //not available yet for win32
00028
00029
#include <qstring.h>
00030
#include <qsocketnotifier.h>
00031
#include <qptrlist.h>
00032
#include <qvaluelist.h>
00033
#include <qcstring.h>
00034
#include <qdict.h>
00035
#include <qptrdict.h>
00036
#include <qintdict.h>
00037
#include <qapplication.h>
00038
00039
#define INT32 QINT32
00040
#ifdef Q_WS_X11
00041
#include <X11/Xlib.h>
00042
#include <X11/Xmd.h>
00043
#endif
00044
#include <KDE-ICE/ICElib.h>
00045
extern "C" {
00046
#include <KDE-ICE/ICEutil.h>
00047
#include <KDE-ICE/ICEmsg.h>
00048
#include <KDE-ICE/ICEproto.h>
00049 }
00050
00051
class DCOPConnection;
00052
class DCOPListener;
00053
class DCOPSignalConnectionList;
00054
class DCOPSignals;
00055
class QTimer;
00056
00057
00058
00059
00060
00061
#ifdef DCOP_LOG
00062
class QTextStream;
00063
class QFile;
00064
#endif
00065
00066
typedef QValueList<QCString> QCStringList;
00067
00071
class DCOPConnection :
public QSocketNotifier
00072 {
00073
public:
00074 DCOPConnection( IceConn conn );
00075 ~DCOPConnection();
00076
00077 DCOPSignalConnectionList *signalConnectionList();
00078
00079
00080
00081
void waitForOutputReady(
const QByteArray &_data,
int start);
00082
00083
00084
00085
void slotOutputReady();
00086
00087
QCString appId;
00088
QCString plainAppId;
00089 IceConn iceConn;
00090
int notifyRegister;
00102 QPtrList <_IceConn> waitingOnReply;
00103 QPtrList <_IceConn> waitingForReply;
00104 QPtrList <_IceConn> waitingForDelayedReply;
00105 DCOPSignalConnectionList *_signalConnectionList;
00106
bool daemon;
00107
bool outputBlocked;
00108 QValueList <QByteArray> outputBuffer;
00109
unsigned long outputBufferStart;
00110
QSocketNotifier *outputBufferNotifier;
00111 };
00112
00113
00117
class DCOPServer :
public QObject
00118 {
00119 Q_OBJECT
00120
public:
00121 DCOPServer(
bool _suicide);
00122 ~DCOPServer();
00123
00124
void* watchConnection( IceConn iceConn );
00125
void removeConnection(
void* data );
00126
void processMessage( IceConn iceConn,
int opcode,
unsigned long length, Bool swap);
00127
void ioError( IceConn iceConn );
00128
00129
bool receive(
const QCString &app,
const QCString &obj,
00130
const QCString &fun,
const QByteArray& data,
00131
QCString& replyType,
QByteArray &replyData, IceConn iceConn);
00132
00133 DCOPConnection *findApp(
const QCString &appId);
00134 DCOPConnection *findConn(IceConn iceConn)
00135 {
return clients.find(iceConn); }
00136
00137
void sendMessage(DCOPConnection *conn,
const QCString &sApp,
00138
const QCString &rApp,
const QCString &rObj,
00139
const QCString &rFun,
const QByteArray &data);
00140
00141
private slots:
00142
void newClient(
int socket );
00143
void processData(
int socket );
00144
void slotTerminate();
00145
void slotSuicide();
00146
void slotShutdown();
00147
void slotExit();
00148
void slotCleanDeadConnections();
00149
void slotOutputReady(
int socket );
00150
00151
private:
00152
void broadcastApplicationRegistration( DCOPConnection* conn,
const QCString type,
00153
const QString& data );
00154
bool suicide;
00155
bool shutdown;
00156
int majorOpcode;
00157
int currentClientNumber;
00158 CARD32 serverKey;
00159 DCOPSignals *dcopSignals;
00160
QTimer *m_timer;
00161
QTimer *m_deadConnectionTimer;
00162
QPtrList<DCOPListener> listener;
00163
QAsciiDict<DCOPConnection> appIds;
00164
QPtrDict<DCOPConnection> clients;
00165
QIntDict<DCOPConnection> fd_clients;
00166
QPtrList<_IceConn> deadConnections;
00167
00168
#ifdef DCOP_LOG
00169
QTextStream *m_stream;
00170
QFile *m_logger;
00171
#endif
00172
};
00173
00174
extern DCOPServer* the_server;
00175
00176
#endif //Q_OS_UNIX
00177
00178
#endif