00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _DCOPCLIENT_H
00024 #define _DCOPCLIENT_H
00025
00026 #include <qobject.h>
00027 #include <qcstring.h>
00028 #include <qvaluelist.h>
00029 #include <qstring.h>
00030 #include <kdatastream.h>
00031
00032 class DCOPObjectProxy;
00033 class DCOPClientPrivate;
00034 class DCOPClientTransaction;
00035
00036 typedef QValueList<QCString> QCStringList;
00037
00067 class DCOPClient : public QObject
00068 {
00069 Q_OBJECT
00070
00071 public:
00074 DCOPClient();
00075
00079 virtual ~DCOPClient();
00080
00088 static void setServerAddress(const QCString &addr);
00089
00108 bool attach();
00109
00116 void bindToApp();
00117
00122 bool detach();
00123
00128 bool isAttached() const;
00129
00135 bool isAttachedToForeignServer() const;
00136
00141 bool acceptCalls() const;
00142
00149 void setAcceptCalls(bool b);
00150
00157 bool qtBridgeEnabled();
00158
00166 void setQtBridgeEnabled(bool b);
00167
00193 QCString registerAs( const QCString &appId, bool addPID = true );
00194
00199 bool isRegistered() const;
00200
00206 QCString appId() const;
00207
00212 int socket() const;
00213
00226 void suspend();
00227
00233 void resume();
00234
00241 bool isSuspended() const;
00242
00253 bool send(const QCString &remApp, const QCString &remObj,
00254 const QCString &remFun, const QByteArray &data);
00255
00267 bool send(const QCString &remApp, const QCString &remObj,
00268 const QCString &remFun, const QString &data);
00269
00295 bool call(const QCString &remApp, const QCString &remObj,
00296 const QCString &remFun, const QByteArray &data,
00297 QCString& replyType, QByteArray &replyData,
00298 bool useEventLoop=false);
00299
00332 bool findObject(const QCString &remApp, const QCString &remObj,
00333 const QCString &remFun, const QByteArray &data,
00334 QCString &foundApp, QCString &foundObj,
00335 bool useEventLoop=false);
00336
00337
00342 void emitDCOPSignal( const QCString &object, const QCString &signal,
00343 const QByteArray &data);
00344
00345
00346 void emitDCOPSignal( const QCString &signal, const QByteArray &data);
00347
00368 bool connectDCOPSignal( const QCString &sender, const QCString &senderObj,
00369 const QCString &signal,
00370 const QCString &receiverObj, const QCString &slot,
00371 bool Volatile);
00372
00377 bool connectDCOPSignal( const QCString &sender, const QCString &signal,
00378 const QCString &receiverObj, const QCString &slot,
00379 bool Volatile);
00380
00398 bool disconnectDCOPSignal( const QCString &sender, const QCString &senderObj,
00399 const QCString &signal,
00400 const QCString &receiverObj, const QCString &slot);
00401
00406 bool disconnectDCOPSignal( const QCString &sender, const QCString &signal,
00407 const QCString &receiverObj, const QCString &slot);
00408
00424 virtual bool process(const QCString &fun, const QByteArray &data,
00425 QCString& replyType, QByteArray &replyData);
00426
00436 DCOPClientTransaction *beginTransaction( );
00437
00445 void endTransaction( DCOPClientTransaction *t, QCString& replyType, QByteArray &replyData);
00446
00456 Q_INT32 transactionId() const;
00457
00463 bool isApplicationRegistered( const QCString& remApp);
00464
00470 QCStringList registeredApplications();
00471
00479 QCStringList remoteObjects( const QCString& remApp, bool *ok = 0 );
00480
00490 QCStringList remoteInterfaces( const QCString& remApp, const QCString& remObj , bool *ok = 0 );
00491
00501 QCStringList remoteFunctions( const QCString& remApp, const QCString& remObj , bool *ok = 0 );
00502
00515 bool receive(const QCString &app, const QCString &obj,
00516 const QCString &fun, const QByteArray& data,
00517 QCString& replyType, QByteArray &replyData);
00518
00530 bool find(const QCString &app, const QCString &obj,
00531 const QCString &fun, const QByteArray& data,
00532 QCString& replyType, QByteArray &replyData);
00533
00551 static QCString normalizeFunctionSignature( const QCString& fun );
00552
00553
00559 QCString senderId() const;
00560
00561
00569 void setDefaultObject( const QCString& objId );
00570
00579 QCString defaultObject() const;
00580
00592 void setNotifications( bool enabled );
00593
00602 void setDaemonMode( bool daemonMode );
00603
00611 static DCOPClient* mainClient();
00612
00620 static void setMainClient( DCOPClient* mainClient);
00621
00625 static void emergencyClose();
00626
00632 static const char *postMortemSender();
00634 static const char *postMortemObject();
00636 static const char *postMortemFunction();
00637
00645 static QCString dcopServerFile(const QCString &hostname=0);
00646
00651 static QCString dcopServerFileOld(const QCString &hostname=0);
00652
00653 signals:
00662 void applicationRegistered( const QCString& appId );
00671 void applicationRemoved( const QCString& appId );
00672
00681 void attachFailed(const QString &msg);
00682
00700 void blockUserInput( bool block );
00701
00702 public slots:
00703
00704 protected slots:
00709 void processSocketData(int socknum);
00710
00711 private slots:
00712 void processPostedMessagesInternal();
00713
00714 protected:
00715
00716 private:
00717
00718 bool attachInternal( bool registerAsAnonymous = TRUE );
00719
00720 bool callInternal(const QCString &remApp, const QCString &remObj,
00721 const QCString &remFun, const QByteArray &data,
00722 QCString& replyType, QByteArray &replyData,
00723 bool useEventLoop, int minor_opcode);
00724 protected:
00725 virtual void virtual_hook( int id, void* data );
00726 private:
00727 DCOPClientPrivate *d;
00728 };
00729
00730 #endif