dcop Library API Documentation

dcopserver.h

00001 /*
00002 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
00003 Copyright (c) 1999 Matthias Ettrich <ettrich@kde.org>
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy
00006 of this software and associated documentation files (the "Software"), to deal
00007 in the Software without restriction, including without limitation the rights
00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 copies of the Software, and to permit persons to whom the Software is
00010 furnished to do so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00018 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00019 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00020 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021 */
00022 #ifndef DCOPSERVER_H
00023 #define DCOPSERVER_H "$Id: dcopserver.h,v 1.36 2004/05/02 07:28:20 zrusin Exp $"
00024 
00025 #include <qobject.h>
00026 #include <qstring.h>
00027 #include <qsocketnotifier.h>
00028 #include <qptrlist.h>
00029 #include <qvaluelist.h>
00030 #include <qcstring.h>
00031 #include <qdict.h>
00032 #include <qptrdict.h>
00033 #include <qintdict.h>
00034 #include <qapplication.h>
00035 
00036 #define INT32 QINT32
00037 #ifdef Q_WS_X11
00038 #include <X11/Xlib.h>
00039 #include <X11/Xmd.h>
00040 #endif
00041 #include <KDE-ICE/ICElib.h>
00042 extern "C" {
00043 #include <KDE-ICE/ICEutil.h>
00044 #include <KDE-ICE/ICEmsg.h>
00045 #include <KDE-ICE/ICEproto.h>
00046 }
00047 
00048 class DCOPConnection;
00049 class DCOPListener;
00050 class DCOPSignalConnectionList;
00051 class DCOPSignals;
00052 class QTimer;
00053 
00054 // If you enable the following define DCOP will create
00055 // $HOME/.dcop.log file which will list all signals passing
00056 // through it.
00057 //#define DCOP_LOG
00058 #ifdef DCOP_LOG
00059 class QTextStream;
00060 class QFile;
00061 #endif
00062 
00063 typedef QValueList<QCString> QCStringList;
00064 
00068 class DCOPConnection : public QSocketNotifier
00069 {
00070 public:
00071     DCOPConnection( IceConn conn );
00072     ~DCOPConnection();
00073 
00074     DCOPSignalConnectionList *signalConnectionList();
00075 
00076     // Add the data from offset @p start in @p _data to the output
00077     // buffer and schedule it for later transmission.
00078     void waitForOutputReady(const QByteArray &_data, int start);
00079 
00080     // Called from DCOPServer::slotOutputReady()
00081     // Flush the output buffer.
00082     void slotOutputReady();
00083 
00084     QCString appId;
00085     QCString plainAppId;
00086     IceConn iceConn;
00087     int notifyRegister;
00099     QPtrList <_IceConn> waitingOnReply;
00100     QPtrList <_IceConn> waitingForReply;
00101     QPtrList <_IceConn> waitingForDelayedReply;
00102     DCOPSignalConnectionList *_signalConnectionList;
00103     bool daemon;
00104     bool outputBlocked;
00105     QValueList <QByteArray> outputBuffer;
00106     unsigned long outputBufferStart;
00107     QSocketNotifier *outputBufferNotifier;
00108 };
00109 
00110 
00114 class DCOPServer : public QObject
00115 {
00116     Q_OBJECT
00117 public:
00118     DCOPServer(bool _suicide);
00119     ~DCOPServer();
00120 
00121     void* watchConnection( IceConn iceConn );
00122     void removeConnection( void* data );
00123     void processMessage( IceConn iceConn, int opcode, unsigned long length, Bool swap);
00124     void ioError( IceConn iceConn );
00125 
00126     bool receive(const QCString &app, const QCString &obj,
00127                  const QCString &fun, const QByteArray& data,
00128                  QCString& replyType, QByteArray &replyData, IceConn iceConn);
00129 
00130     DCOPConnection *findApp(const QCString &appId);
00131     DCOPConnection *findConn(IceConn iceConn)
00132        { return clients.find(iceConn); }
00133 
00134     void sendMessage(DCOPConnection *conn, const QCString &sApp,
00135                      const QCString &rApp, const QCString &rObj,
00136                      const QCString &rFun, const QByteArray &data);
00137 
00138 private slots:
00139     void newClient( int socket );
00140     void processData( int socket );
00141     void slotTerminate();
00142     void slotSuicide();
00143     void slotCleanDeadConnections();
00144     void slotOutputReady(int socket );
00145 
00146 private:
00147     void broadcastApplicationRegistration( DCOPConnection* conn, const QCString type,
00148         const QString& data );
00149     bool suicide;
00150     int majorOpcode;
00151     int currentClientNumber;
00152     CARD32 serverKey;
00153     DCOPSignals *dcopSignals;
00154     QTimer *m_timer;
00155     QTimer *m_deadConnectionTimer;
00156     QPtrList<DCOPListener> listener;
00157     QAsciiDict<DCOPConnection> appIds; // index on app id
00158     QPtrDict<DCOPConnection> clients; // index on iceConn
00159     QIntDict<DCOPConnection> fd_clients; // index on fd
00160     QPtrList<_IceConn> deadConnections;
00161 
00162 #ifdef DCOP_LOG
00163     QTextStream *m_stream;
00164     QFile *m_logger;
00165 #endif
00166 };
00167 
00168 extern DCOPServer* the_server;
00169 #endif
KDE Logo
This file is part of the documentation for dcop Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 23 17:11:24 2004 by doxygen 1.3.8-20040913 written by Dimitri van Heesch, © 1997-2003