* test/qt/Makefile.am: build from srcdir
[platform/upstream/dbus.git] / qt / qdbusconnection.h
1 /* qdbusconnection.h QDBusConnection object
2  *
3  * Copyright (C) 2005 Harald Fernengel <harry@kdevelop.org>
4  *
5  * Licensed under the Academic Free License version 2.1
6  *
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.
11  *
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.
16  *
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
20  *
21  */
22
23 #ifndef QDBUSCONNECTION_H
24 #define QDBUSCONNECTION_H
25
26 #include "dbus/qdbus.h"
27 #include <QtCore/qstring.h>
28
29 class QDBusConnectionPrivate;
30 class QDBusError;
31 class QDBusMessage;
32 class QByteArray;
33 class QObject;
34
35 class QDBUS_EXPORT QDBusConnection
36 {
37 public:
38     enum BusType { SessionBus, SystemBus, ActivationBus };
39
40     QDBusConnection(const QString &name = QLatin1String(default_connection_name));
41     QDBusConnection(const QDBusConnection &other);
42     ~QDBusConnection();
43
44     QDBusConnection &operator=(const QDBusConnection &other);
45
46     bool isConnected() const;
47     QDBusError lastError() const;
48
49     enum NameRequestMode { NoReplace = 0, AllowReplace = 1, ReplaceExisting = 2 };
50     bool requestName(const QString &name, NameRequestMode mode = NoReplace);
51
52     QString baseService() const;
53
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;
58
59     bool connect(const QString &path, const QString &interface,
60                  const QString &name, QObject *receiver, const char *slot);
61
62     bool registerObject(const QString &path, const QString &interface,
63                         QObject *object);
64     void unregisterObject(const QString &path);
65
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));
71
72     QT_STATIC_CONST char *default_connection_name;
73
74 private:
75     QDBusConnectionPrivate *d;
76 };
77
78 #endif