dcopclient.h
00001 /* 00002 Copyright (c) 1999 Preston Brown <pbrown@kde.org> 00003 Copyright (c) 1999, 2000 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 00023 #ifndef _DCOPCLIENT_H 00024 #define _DCOPCLIENT_H 00025 00026 #include <tqobject.h> 00027 #include <tqcstring.h> 00028 #include <tqvaluelist.h> 00029 #include <tqstring.h> 00030 #include <kdatastream.h> // needed for proper bool marshalling 00031 #include <tdelibs_export.h> 00032 00033 class DCOPObjectProxy; 00034 class DCOPClientPrivate; 00035 class DCOPClientTransaction; 00036 00037 typedef TQValueList<TQCString> QCStringList; 00038 00068 class DCOP_EXPORT DCOPClient : public TQObject 00069 { 00070 Q_OBJECT 00071 00072 00073 public: 00076 DCOPClient(); 00077 00081 virtual ~DCOPClient(); 00082 00090 static void setServerAddress(const TQCString &addr); 00091 00110 bool attach(); 00111 00118 void bindToApp(); 00119 00124 bool detach(); 00125 00130 bool isAttached() const; 00131 00137 bool isAttachedToForeignServer() const; 00138 00143 bool acceptCalls() const; 00144 00151 void setAcceptCalls(bool b); 00152 00159 bool qtBridgeEnabled(); // ### KDE 4.0: make const 00160 00168 void setQtBridgeEnabled(bool b); 00169 00195 TQCString registerAs( const TQCString &appId, bool addPID = true ); 00196 00201 bool isRegistered() const; 00202 00208 TQCString appId() const; 00209 00214 int socket() const; 00215 00228 void suspend(); 00229 00235 void resume(); 00236 00243 bool isSuspended() const; 00244 00255 bool send(const TQCString &remApp, const TQCString &remObj, 00256 const TQCString &remFun, const TQByteArray &data); 00257 00269 bool send(const TQCString &remApp, const TQCString &remObj, 00270 const TQCString &remFun, const TQString &data); 00271 00304 bool call(const TQCString &remApp, const TQCString &remObj, 00305 const TQCString &remFun, const TQByteArray &data, 00306 TQCString& replyType, TQByteArray &replyData, 00307 bool useEventLoop/*=false*/, int timeout/*=-1*/, 00308 bool forceRemote/*=false*/); 00309 00313 // KDE4 merge with above 00314 bool call(const TQCString &remApp, const TQCString &remObj, 00315 const TQCString &remFun, const TQByteArray &data, 00316 TQCString& replyType, TQByteArray &replyData, 00317 bool useEventLoop/*=false*/, int timeout/*=-1*/); 00321 // KDE4 merge with above 00322 bool call(const TQCString &remApp, const TQCString &remObj, 00323 const TQCString &remFun, const TQByteArray &data, 00324 TQCString& replyType, TQByteArray &replyData, 00325 bool useEventLoop=false); 00326 00355 int callAsync(const TQCString &remApp, const TQCString &remObj, 00356 const TQCString &remFun, const TQByteArray &data, 00357 TQObject *callBackObj, const char *callBackSlot); 00358 00395 bool findObject(const TQCString &remApp, const TQCString &remObj, 00396 const TQCString &remFun, const TQByteArray &data, 00397 TQCString &foundApp, TQCString &foundObj, 00398 bool useEventLoop/*=false*/, int timeout/*=-1*/); 00399 00403 // KDE4 merge with above 00404 bool findObject(const TQCString &remApp, const TQCString &remObj, 00405 const TQCString &remFun, const TQByteArray &data, 00406 TQCString &foundApp, TQCString &foundObj, 00407 bool useEventLoop=false); 00408 00409 00414 void emitDCOPSignal( const TQCString &object, const TQCString &signal, 00415 const TQByteArray &data); 00416 00417 /* For backwards compatibility */ 00418 void emitDCOPSignal( const TQCString &signal, const TQByteArray &data); 00419 00440 bool connectDCOPSignal( const TQCString &sender, const TQCString &senderObj, 00441 const TQCString &signal, 00442 const TQCString &receiverObj, const TQCString &slot, 00443 bool Volatile); 00444 00449 bool connectDCOPSignal( const TQCString &sender, const TQCString &signal, 00450 const TQCString &receiverObj, const TQCString &slot, 00451 bool Volatile) KDE_DEPRECATED; 00452 00470 bool disconnectDCOPSignal( const TQCString &sender, const TQCString &senderObj, 00471 const TQCString &signal, 00472 const TQCString &receiverObj, const TQCString &slot); 00473 00478 bool disconnectDCOPSignal( const TQCString &sender, const TQCString &signal, 00479 const TQCString &receiverObj, const TQCString &slot) KDE_DEPRECATED; 00480 00496 virtual bool process(const TQCString &fun, const TQByteArray &data, 00497 TQCString& replyType, TQByteArray &replyData); 00498 00508 DCOPClientTransaction *beginTransaction( ); 00509 00517 void endTransaction( DCOPClientTransaction *t, TQCString& replyType, TQByteArray &replyData); 00518 00528 TQ_INT32 transactionId() const; 00529 00535 bool isApplicationRegistered( const TQCString& remApp); 00536 00542 QCStringList registeredApplications(); 00543 00551 QCStringList remoteObjects( const TQCString& remApp, bool *ok = 0 ); 00552 00562 QCStringList remoteInterfaces( const TQCString& remApp, const TQCString& remObj , bool *ok = 0 ); 00563 00573 QCStringList remoteFunctions( const TQCString& remApp, const TQCString& remObj , bool *ok = 0 ); 00574 00589 bool receive(const TQCString &app, const TQCString &obj, 00590 const TQCString &fun, const TQByteArray& data, 00591 TQCString& replyType, TQByteArray &replyData); 00592 00606 bool find(const TQCString &app, const TQCString &obj, 00607 const TQCString &fun, const TQByteArray& data, 00608 TQCString& replyType, TQByteArray &replyData); 00609 00627 static TQCString normalizeFunctionSignature( const TQCString& fun ); 00628 00629 00635 TQCString senderId() const; 00636 00637 00645 void setDefaultObject( const TQCString& objId ); 00646 00655 TQCString defaultObject() const; 00656 00668 void setNotifications( bool enabled ); 00669 00678 void setDaemonMode( bool daemonMode ); 00679 00685 void setPriorityCall(bool); 00686 00694 static DCOPClient* mainClient(); 00695 00703 static void setMainClient( DCOPClient* mainClient); 00704 00710 static DCOPClient* findLocalClient( const TQCString &_appId ); 00711 00715 static void emergencyClose(); 00716 00722 static const char *postMortemSender(); 00724 static const char *postMortemObject(); 00726 static const char *postMortemFunction(); 00727 00735 static TQCString dcopServerFile(const TQCString &hostname=0); 00736 00742 static TQCString dcopServerFileOld(const TQCString &hostname=0) KDE_DEPRECATED; 00743 00747 static TQCString iceauthPath(); 00748 00749 signals: 00758 void applicationRegistered( const TQCString& appId ); 00767 void applicationRemoved( const TQCString& appId ); 00768 00777 void attachFailed(const TQString &msg); 00778 00796 void blockUserInput( bool block ); 00797 00807 void callBack(int, const TQCString&, const TQByteArray &); 00808 00809 public slots: 00814 void processSocketData(int socknum); 00815 00816 protected slots: 00817 00818 private slots: 00819 void processPostedMessagesInternal(); 00820 void asyncReplyReady(); 00821 void eventLoopTimeout(); 00822 00823 public: 00824 class ReplyStruct; 00825 00829 void handleAsyncReply(ReplyStruct *replyStruct); 00830 00831 private: 00832 00833 bool isLocalTransactionFinished(TQ_INT32 id, TQCString &replyType, TQByteArray &replyData); 00834 00835 bool attachInternal( bool registerAsAnonymous = true ); 00836 00837 bool callInternal(const TQCString &remApp, const TQCString &remObj, 00838 const TQCString &remFun, const TQByteArray &data, 00839 TQCString& replyType, TQByteArray &replyData, 00840 bool useEventLoop, int timeout, int minor_opcode); 00841 00842 00843 bool callInternal(const TQCString &remApp, const TQCString &remObjId, 00844 const TQCString &remFun, const TQByteArray &data, 00845 ReplyStruct *replyStruct, 00846 bool useEventLoop, int timeout, int minor_opcode); 00847 00848 protected: 00849 virtual void virtual_hook( int id, void* data ); 00850 private: 00851 DCOPClientPrivate *d; 00852 }; 00853 00854 #endif