1 /* qdbusconnection.h QDBusConnection 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
23 #ifndef QDBUSCONNECTION_H
24 #define QDBUSCONNECTION_H
26 #include "dbus/qdbus.h"
27 #include <QtCore/qstring.h>
29 class QDBusConnectionPrivate;
35 class QDBUS_EXPORT QDBusConnection
38 enum BusType { SessionBus, SystemBus, ActivationBus };
40 QDBusConnection(const QString &name = QLatin1String(default_connection_name));
41 QDBusConnection(const QDBusConnection &other);
44 QDBusConnection &operator=(const QDBusConnection &other);
46 bool isConnected() const;
47 QDBusError lastError() const;
49 enum NameRequestMode { NoReplace = 0, AllowReplace = 1, ReplaceExisting = 2 };
50 bool requestName(const QString &name, NameRequestMode mode = NoReplace);
52 QString baseService() const;
54 bool send(const QDBusMessage &message) const;
55 QDBusMessage sendWithReply(const QDBusMessage &message) const;
56 int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver,
57 const char *slot) const;
59 bool connect(const QString &path, const QString &interface,
60 const QString &name, QObject *receiver, const char *slot);
62 bool registerObject(const QString &path, const QString &interface,
64 void unregisterObject(const QString &path);
66 static QDBusConnection addConnection(BusType type,
67 const QString &name = QLatin1String(default_connection_name));
68 static QDBusConnection addConnection(const QString &address,
69 const QString &name = QLatin1String(default_connection_name));
70 static void closeConnection(const QString &name = QLatin1String(default_connection_name));
72 QT_STATIC_CONST char *default_connection_name;
75 QDBusConnectionPrivate *d;