dcop Library: dcopserver.h Source File (dcop Library)

| # dcop Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# 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 420160 2005-05-31 13:34:41Z lunakl $"
    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 // If you enable the following define DCOP will create
    00058 // $HOME/.dcop.log file which will list all signals passing
    00059 // through it.
    00060 //#define DCOP_LOG
    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     // Add the data from offset @p start in @p _data to the output
    00080     // buffer and schedule it for later transmission.
    00081     void waitForOutputReady(const QByteArray &_data, int start);
    00082
    00083     // Called from DCOPServer::slotOutputReady()
    00084     // Flush the output buffer.
    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 QCString& 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; // index on app id
    00164     QPtrDict<DCOPConnection> clients; // index on iceConn
    00165     QIntDict<DCOPConnection> fd_clients; // index on fd
    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

This file is part of the documentation for dcop Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:16:55 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003