diff options
author | Thiago Macieira <thiago.macieira@trolltech.com> | 2006-02-15 16:25:11 +0000 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@trolltech.com> | 2006-02-15 16:25:11 +0000 |
commit | 174f04c441723d78faa3346944944ab15603ca8c (patch) | |
tree | 3c7941775bc9e847c5d65a7fb4abf11ed328bcef /qt/qdbusconnection_p.h | |
parent | a696be1a0d10478e91f0f72f7ce743a19461f68d (diff) |
Merge the changes to the bindings from the KDE Subversion server.
This is a major change: library is source- and binary-incompatible to
what it used to be.
All testcases are green, functionality is preserved.
It is not feature-complete. Development will continue in the branch in the
Subversion server for a while.
Diffstat (limited to 'qt/qdbusconnection_p.h')
-rw-r--r-- | qt/qdbusconnection_p.h | 144 |
1 files changed, 103 insertions, 41 deletions
diff --git a/qt/qdbusconnection_p.h b/qt/qdbusconnection_p.h index 3f78dad..fa0fdd8 100644 --- a/qt/qdbusconnection_p.h +++ b/qt/qdbusconnection_p.h @@ -1,6 +1,8 @@ /* qdbusconnection_p.h QDBusConnection private object * * Copyright (C) 2005 Harald Fernengel <harry@kdevelop.org> + * Copyright (C) 2006 Trolltech AS. All rights reserved. + * Author: Thiago Macieira <thiago.macieira@trolltech.com> * * Licensed under the Academic Free License version 2.1 * @@ -15,8 +17,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ @@ -38,16 +40,24 @@ #include "qdbuserror.h" #include <QtCore/qatomic.h> +#include <QtCore/qmutex.h> #include <QtCore/qhash.h> #include <QtCore/qobject.h> #include <QtCore/qpointer.h> #include <QtCore/qvarlengtharray.h> +#include <QtCore/qeventloop.h> +#include <QtCore/qmutex.h> #include <dbus/dbus.h> +#include "qdbusmessage.h" +#include "qdbusintrospection.h" + class QDBusMessage; class QSocketNotifier; class QTimerEvent; +class QDBusObjectPrivate; +class CallDeliveryEvent; typedef struct DBusConnection; typedef struct DBusServer; @@ -56,6 +66,43 @@ class QDBusConnectionPrivate: public QObject { Q_OBJECT public: + // structs and enums + enum ConnectionMode { InvalidMode, ServerMode, ClientMode }; + + struct Watcher + { + Watcher(): watch(0), read(0), write(0) {} + DBusWatch *watch; + QSocketNotifier *read; + QSocketNotifier *write; + }; + + struct SignalHook + { + QString interface, name, signature; + QPointer<QObject> obj; + int midx; + QList<int> params; + }; + + struct ObjectData + { + QPointer<QObject> obj; + int flags; + }; + +public: + // typedefs + typedef QMultiHash<int, Watcher> WatcherHash; + typedef QHash<int, DBusTimeout *> TimeoutHash; + typedef QMultiHash<QString, SignalHook> SignalHookHash; + typedef QHash<QString, ObjectData> ObjectDataHash; + typedef QHash<QString, ObjectDataHash> ObjectHookHash; + typedef QHash<QString, QSharedDataPointer<QDBusIntrospection::Interface> > KnownInterfacesHash; + typedef QHash<QString, QDBusIntrospection::Object* > KnownObjectsHash; + +public: + // public methods QDBusConnectionPrivate(QObject *parent = 0); ~QDBusConnectionPrivate(); @@ -66,66 +113,81 @@ public: void closeConnection(); void timerEvent(QTimerEvent *e); - bool handleSignal(DBusMessage *msg) const; - bool handleObjectCall(DBusMessage *message) const; + bool handleSignal(const QString &path, const QDBusMessage &msg); + bool send(const QDBusMessage &message) const; + int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver, + const char *method) const; + + bool handleSignal(const QDBusMessage &msg); + bool handleObjectCall(const QDBusMessage &message); bool handleError(); + void disposeOfLocked(QDBusIntrospection::Object* obj); + void disposeOf(QDBusObjectPrivate* obj); + QSharedDataPointer<QDBusIntrospection::Interface> findInterface(const QString& name); + QDBusIntrospection::Object* findObject(const QString& service, + const QString& path); + + bool activateReply(QObject *object, int idx, const QList<int>& metaTypes, + const QDBusMessage &msg); + bool activateSignal(const SignalHook& hook, const QDBusMessage &msg); + bool activateCall(QObject* object, int flags, const QDBusMessage &msg); + bool activateAdaptor(QObject *object, int flags, const QDBusMessage &msg); + bool activateObject(const ObjectData& data, const QDBusMessage &msg); + void deliverCall(const CallDeliveryEvent &data) const; + +protected: + virtual void customEvent(QEvent *event); + public slots: + // public slots void socketRead(int); void socketWrite(int); void objectDestroyed(QObject *o); public: + // public member variables DBusError error; QDBusError lastError; - enum ConnectionMode { InvalidMode, ServerMode, ClientMode }; - QAtomic ref; + QMutex mutex; ConnectionMode mode; DBusConnection *connection; DBusServer *server; - static int messageMetaType; - static int registerMessageMetaType(); - bool handleSignal(const QString &path, const QDBusMessage &msg) const; - int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver, - const char *method) const; - - struct Watcher - { - Watcher(): watch(0), read(0), write(0) {} - DBusWatch *watch; - QSocketNotifier *read; - QSocketNotifier *write; - }; - typedef QMultiHash<int, Watcher> WatcherHash; WatcherHash watchers; - - typedef QHash<int, DBusTimeout *> TimeoutHash; TimeoutHash timeouts; - - struct SignalHook - { - QString interface, name; - QPointer<QObject> obj; - int midx; - QVarLengthArray<int, 10> params; - - bool setSlot(const char *slotName); - }; - - typedef QMultiHash<QString, SignalHook> SignalHookHash; SignalHookHash signalHooks; - - struct ObjectHook - { - QString interface; - QPointer<QObject> obj; - }; - typedef QMultiHash<QString, ObjectHook> ObjectHookHash; ObjectHookHash objectHooks; QList<DBusTimeout *> pendingTimeouts; + +public: + // public mutable member variables + mutable KnownInterfacesHash knownInterfaces; + mutable KnownObjectsHash knownObjects; + +public: + // static methods + static int messageMetaType; + static int registerMessageMetaType(); + static int findSlot(QObject *obj, const char *slotName, QList<int>& params); }; +class QDBusReplyWaiter: public QEventLoop +{ + Q_OBJECT +public: + QDBusMessage replyMsg; + +#ifndef QT_NO_DEBUG + int level; + int exec(ProcessEventsFlags flags); + void exit(int = 0); +#endif + +public slots: + void reply(const QDBusMessage &msg); +}; + #endif |