00001 /*
00002 Copyright (c) 1999,2000 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 _DCOPOBJECT_H
00024 #define _DCOPOBJECT_H
00025
00026 #include <qobject.h>
00027 #include <qmap.h>
00028 #include <qstring.h>
00029 #include <qptrlist.h>
00030 #include <qvaluelist.h>
00031 #include <kdatastream.h> // needed for proper bool marshalling
00032 #include "kdelibs_export.h"
00033
00034 class DCOPClient;
00035 typedef QValueList<QCString> QCStringList;
00036
00037 // Makros for DCOP interfaces
00038
00039 #define K_DCOP \
00040 public: \
00041 virtual bool process(const QCString &fun, const QByteArray &data, QCString& replyType, QByteArray &replyData); \
00042 QCStringList functions(); \
00043 QCStringList interfaces(); \
00044 private:
00045
00046 #define k_dcop_signals public
00047 #define k_dcop_hidden public
00048 #define k_dcop public
00049 #define ASYNC void
00050
00067 class DCOP_EXPORT DCOPObject
00068 {
00069 public:
00074 DCOPObject();
00080 DCOPObject(QObject *obj);
00085 DCOPObject(const QCString &objId);
00090 virtual ~DCOPObject();
00091
00096 QCString objId() const;
00097
00104 bool setObjId(const QCString &objId);
00105
00137 virtual bool process(const QCString &fun, const QByteArray &data,
00138 QCString& replyType, QByteArray &replyData);
00139
00140
00163 virtual bool processDynamic(const QCString &fun, const QByteArray &data,
00164 QCString& replyType, QByteArray &replyData);
00165
00177 virtual QCStringList functionsDynamic();
00178
00190 virtual QCStringList interfacesDynamic();
00191
00201 virtual QCStringList interfaces();
00202
00221 virtual QCStringList functions();
00222
00229 void emitDCOPSignal( const QCString &signal, const QByteArray &data);
00230
00250 bool connectDCOPSignal( const QCString &sender, const QCString &senderObj,
00251 const QCString &signal,
00252 const QCString &slot,
00253 bool Volatile);
00254
00272 bool disconnectDCOPSignal( const QCString &sender, const QCString &senderObj,
00273 const QCString &signal,
00274 const QCString &slot);
00275
00284 DCOPClient *callingDcopClient();
00285
00290 void setCallingDcopClient(DCOPClient *);
00291
00299 static bool hasObject(const QCString &objId);
00300
00307 static DCOPObject *find(const QCString &objId);
00308
00309
00319 static QPtrList<DCOPObject> match(const QCString &partialId);
00320
00327 static QCString objectName( QObject* obj );
00328
00329 private:
00333 QCString ident;
00334
00335 protected:
00336 virtual void virtual_hook( int id, void* data );
00337 private:
00338 class DCOPObjectPrivate;
00339 DCOPObjectPrivate *d;
00340 };
00341
00342 class DCOPObjectProxyPrivate;
00352 class DCOP_EXPORT DCOPObjectProxy
00353 {
00354 public:
00358 DCOPObjectProxy();
00359
00366 DCOPObjectProxy( DCOPClient*);
00367
00371 virtual ~DCOPObjectProxy();
00372
00394 virtual bool process( const QCString& obj, const QCString& fun,
00395 const QByteArray& data,
00396 QCString& replyType, QByteArray &replyData );
00397 private:
00398 void* unused;
00399 void* unused_too;
00400 friend class DCOPClient;
00401 static QPtrList<DCOPObjectProxy>* proxies;
00402 protected:
00403 virtual void virtual_hook( int id, void* data );
00404 private:
00405 DCOPObjectProxyPrivate* d;
00406 };
00407
00408
00409
00410 #endif