1 /* qdbusconnection_p.h QDBusConnection private object
3 * Copyright (C) 2005 Harald Fernengel <harry@kdevelop.org>
5 * Licensed under the Academic Free License version 2.1
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 // This file is not part of the public API. This header file may
28 // change from version to version without notice, or even be
35 #ifndef QDBUSCONNECTION_P_H
36 #define QDBUSCONNECTION_P_H
38 #include "qdbuserror.h"
40 #include <QtCore/qatomic.h>
41 #include <QtCore/qhash.h>
42 #include <QtCore/qobject.h>
43 #include <QtCore/qpointer.h>
44 #include <QtCore/qvarlengtharray.h>
46 #include <dbus/dbus.h>
49 class QSocketNotifier;
52 typedef struct DBusConnection;
53 typedef struct DBusServer;
55 class QDBusConnectionPrivate: public QObject
59 QDBusConnectionPrivate(QObject *parent = 0);
60 ~QDBusConnectionPrivate();
62 void bindToApplication();
64 void setConnection(DBusConnection *connection);
65 void setServer(DBusServer *server);
66 void closeConnection();
67 void timerEvent(QTimerEvent *e);
69 bool handleSignal(DBusMessage *msg) const;
70 bool handleObjectCall(DBusMessage *message) const;
75 void socketWrite(int);
76 void objectDestroyed(QObject *o);
82 enum ConnectionMode { InvalidMode, ServerMode, ClientMode };
86 DBusConnection *connection;
89 static int messageMetaType;
90 static int registerMessageMetaType();
91 bool handleSignal(const QString &path, const QDBusMessage &msg) const;
92 int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver,
93 const char *method) const;
97 Watcher(): watch(0), read(0), write(0) {}
99 QSocketNotifier *read;
100 QSocketNotifier *write;
102 typedef QMultiHash<int, Watcher> WatcherHash;
103 WatcherHash watchers;
105 typedef QHash<int, DBusTimeout *> TimeoutHash;
106 TimeoutHash timeouts;
110 QString interface, name;
111 QPointer<QObject> obj;
113 QVarLengthArray<int, 10> params;
115 bool setSlot(const char *slotName);
118 typedef QMultiHash<QString, SignalHook> SignalHookHash;
119 SignalHookHash signalHooks;
124 QPointer<QObject> obj;
126 typedef QMultiHash<QString, ObjectHook> ObjectHookHash;
127 ObjectHookHash objectHooks;
128 QList<DBusTimeout *> pendingTimeouts;