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 <kdelibs_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 TQ_OBJECT 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 00301 bool call(const TQCString &remApp, const TQCString &remObj, 00302 const TQCString &remFun, const TQByteArray &data, 00303 TQCString& replyType, TQByteArray &replyData, 00304 bool useEventLoop/*=false*/, int timeout/*=-1*/); 00308 // KDE4 merge with above 00309 bool call(const TQCString &remApp, const TQCString &remObj, 00310 const TQCString &remFun, const TQByteArray &data, 00311 TQCString& replyType, TQByteArray &replyData, 00312 bool useEventLoop=false); 00313 00342 int callAsync(const TQCString &remApp, const TQCString &remObj, 00343 const TQCString &remFun, const TQByteArray &data, 00344 TQObject *callBackObj, const char *callBackSlot); 00345 00382 bool findObject(const TQCString &remApp, const TQCString &remObj, 00383 const TQCString &remFun, const TQByteArray &data, 00384 TQCString &foundApp, TQCString &foundObj, 00385 bool useEventLoop/*=false*/, int timeout/*=-1*/); 00386 00390 // KDE4 merge with above 00391 bool findObject(const TQCString &remApp, const TQCString &remObj, 00392 const TQCString &remFun, const TQByteArray &data, 00393 TQCString &foundApp, TQCString &foundObj, 00394 bool useEventLoop=false); 00395 00396 00401 void emitDCOPSignal( const TQCString &object, const TQCString &signal, 00402 const TQByteArray &data); 00403 00404 /* For backwards compatibility */ 00405 void emitDCOPSignal( const TQCString &signal, const TQByteArray &data); 00406 00427 bool connectDCOPSignal( const TQCString &sender, const TQCString &senderObj, 00428 const TQCString &signal, 00429 const TQCString &receiverObj, const TQCString &slot, 00430 bool Volatile); 00431 00436 bool connectDCOPSignal( const TQCString &sender, const TQCString &signal, 00437 const TQCString &receiverObj, const TQCString &slot, 00438 bool Volatile) KDE_DEPRECATED; 00439 00457 bool disconnectDCOPSignal( const TQCString &sender, const TQCString &senderObj, 00458 const TQCString &signal, 00459 const TQCString &receiverObj, const TQCString &slot); 00460 00465 bool disconnectDCOPSignal( const TQCString &sender, const TQCString &signal, 00466 const TQCString &receiverObj, const TQCString &slot) KDE_DEPRECATED; 00467 00483 virtual bool process(const TQCString &fun, const TQByteArray &data, 00484 TQCString& replyType, TQByteArray &replyData); 00485 00495 DCOPClientTransaction *beginTransaction( ); 00496 00504 void endTransaction( DCOPClientTransaction *t, TQCString& replyType, TQByteArray &replyData); 00505 00515 TQ_INT32 transactionId() const; 00516 00522 bool isApplicationRegistered( const TQCString& remApp); 00523 00529 QCStringList registeredApplications(); 00530 00538 QCStringList remoteObjects( const TQCString& remApp, bool *ok = 0 ); 00539 00549 QCStringList remoteInterfaces( const TQCString& remApp, const TQCString& remObj , bool *ok = 0 ); 00550 00560 QCStringList remoteFunctions( const TQCString& remApp, const TQCString& remObj , bool *ok = 0 ); 00561 00576 bool receive(const TQCString &app, const TQCString &obj, 00577 const TQCString &fun, const TQByteArray& data, 00578 TQCString& replyType, TQByteArray &replyData); 00579 00593 bool find(const TQCString &app, const TQCString &obj, 00594 const TQCString &fun, const TQByteArray& data, 00595 TQCString& replyType, TQByteArray &replyData); 00596 00614 static TQCString normalizeFunctionSignature( const TQCString& fun ); 00615 00616 00622 TQCString senderId() const; 00623 00624 00632 void setDefaultObject( const TQCString& objId ); 00633 00642 TQCString defaultObject() const; 00643 00655 void setNotifications( bool enabled ); 00656 00665 void setDaemonMode( bool daemonMode ); 00666 00672 void setPriorityCall(bool); 00673 00681 static DCOPClient* mainClient(); 00682 00690 static void setMainClient( DCOPClient* mainClient); 00691 00697 static DCOPClient* findLocalClient( const TQCString &_appId ); 00698 00702 static void emergencyClose(); 00703 00709 static const char *postMortemSender(); 00711 static const char *postMortemObject(); 00713 static const char *postMortemFunction(); 00714 00722 static TQCString dcopServerFile(const TQCString &hostname=0); 00723 00729 static TQCString dcopServerFileOld(const TQCString &hostname=0) KDE_DEPRECATED; 00730 00734 static TQCString iceauthPath(); 00735 00736 signals: 00745 void applicationRegistered( const TQCString& appId ); 00754 void applicationRemoved( const TQCString& appId ); 00755 00764 void attachFailed(const TQString &msg); 00765 00783 void blockUserInput( bool block ); 00784 00794 void callBack(int, const TQCString&, const TQByteArray &); 00795 00796 public slots: 00801 void processSocketData(int socknum); 00802 00803 protected slots: 00804 00805 private slots: 00806 void processPostedMessagesInternal(); 00807 void asyncReplyReady(); 00808 void eventLoopTimeout(); 00809 00810 public: 00811 class ReplyStruct; 00812 00816 void handleAsyncReply(ReplyStruct *replyStruct); 00817 00818 private: 00819 00820 bool isLocalTransactionFinished(TQ_INT32 id, TQCString &replyType, TQByteArray &replyData); 00821 00822 bool attachInternal( bool registerAsAnonymous = true ); 00823 00824 bool callInternal(const TQCString &remApp, const TQCString &remObj, 00825 const TQCString &remFun, const TQByteArray &data, 00826 TQCString& replyType, TQByteArray &replyData, 00827 bool useEventLoop, int timeout, int minor_opcode); 00828 00829 00830 bool callInternal(const TQCString &remApp, const TQCString &remObjId, 00831 const TQCString &remFun, const TQByteArray &data, 00832 ReplyStruct *replyStruct, 00833 bool useEventLoop, int timeout, int minor_opcode); 00834 00835 protected: 00836 virtual void virtual_hook( int id, void* data ); 00837 private: 00838 DCOPClientPrivate *d; 00839 }; 00840 00841 #endif