* qt/: Update to Subversion r548032.
[platform/upstream/dbus.git] / qt / src / qdbusmessage.h
1 /* qdbusmessage.h QDBusMessage object
2  *
3  * Copyright (C) 2005 Harald Fernengel <harry@kdevelop.org>
4  * Copyright (C) 2006 Trolltech AS. All rights reserved.
5  *    Author: Thiago Macieira <thiago.macieira@trolltech.com>
6  *
7  * Licensed under the Academic Free License version 2.1
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  *
23  */
24
25 #ifndef QDBUSMESSAGE_H
26 #define QDBUSMESSAGE_H
27
28 #include "qdbusmacros.h"
29 #include "qdbuserror.h"
30 #include <QtCore/qlist.h>
31 #include <QtCore/qvariant.h>
32
33 #include <limits.h>
34
35 class QDBusMessagePrivate;
36 class QDBusConnection;
37 class QDBusConnectionPrivate;
38 struct DBusMessage;
39
40 class QDBUS_EXPORT QDBusMessage: public QList<QVariant>
41 {
42     //friend class QDBusConnection;
43     friend class QDBusConnectionPrivate;
44 public:
45     enum { DefaultTimeout = -1, NoTimeout = INT_MAX};
46     enum MessageType { InvalidMessage, MethodCallMessage, ReplyMessage,
47                        ErrorMessage, SignalMessage };
48
49     QDBusMessage();
50     QDBusMessage(const QDBusMessage &other);
51     ~QDBusMessage();
52
53     QDBusMessage &operator=(const QDBusMessage &other);
54
55     static QDBusMessage signal(const QString &path, const QString &interface,
56                                const QString &name);
57     static QDBusMessage methodCall(const QString &destination, const QString &path,
58                                    const QString &interface, const QString &method);
59     static QDBusMessage methodReply(const QDBusMessage &other);
60     static QDBusMessage error(const QDBusMessage &other, const QString &name,
61                               const QString &message = QString());
62     static QDBusMessage error(const QDBusMessage &other, const QDBusError &error);
63
64     QString path() const;
65     QString interface() const;
66     QString name() const;
67     inline QString member() const { return name(); }
68     inline QString method() const { return name(); }
69     QString service() const;
70     inline QString sender() const { return service(); }
71     MessageType type() const;
72
73     int timeout() const;
74     void setTimeout(int ms);
75
76     bool noReply() const;
77
78     QString signature() const;
79     void setSignature(const QString &signature);
80
81     QDBusConnection connection() const;
82
83     int serialNumber() const;
84     int replySerialNumber() const;
85     bool wasRepliedTo() const;
86
87 private:
88     DBusMessage *toDBusMessage() const;
89     static QDBusMessage fromDBusMessage(DBusMessage *dmsg, const QDBusConnection &connection);
90     static QDBusMessage fromError(const QDBusError& error);
91     QDBusMessagePrivate *d_ptr;
92 };
93
94 #ifndef QT_NO_DEBUG
95 QDebug operator<<(QDebug, const QDBusMessage &);
96 #endif
97
98 #endif
99