2003-06-22 Havoc Pennington <hp@pobox.com>
[platform/upstream/dbus.git] / qt / message.h
1 /* -*- mode: C++; c-file-style: "gnu" -*- */
2 /* message.h: Qt wrapper for DBusMessage
3  *
4  * Copyright (C) 2003  Zack Rusin <zack@kde.org>
5  *
6  * Licensed under the Academic Free License version 1.2
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #include <qvariant.h>
25 #include <qstring.h>
26 #include <dbus.h>
27
28 namespace DBus {
29
30   class Message
31   {
32   public:
33     class iterator {
34     public:
35       iterator();
36       iterator( const iterator & );
37       iterator( DBusMessage* msg );
38       ~iterator();
39
40       iterator& operator=( const iterator& );
41       const QVariant& operator*() const;
42       QVariant& operator*();
43       iterator& operator++();
44       iterator operator++(int);
45       bool operator==( const iterator& it );
46       bool operator!=( const iterator& it );
47
48       QVariant var() const;
49     private:
50       void fillVar();
51       struct IteratorData;
52       IteratorData *d;
53     };
54
55     Message( const QString& service, const QString& name );
56     Message( const QString& name,
57              const Message& replayingTo );
58     Message( const Message& other );
59
60     virtual ~Message();
61
62     bool    setSender( const QString& sender );
63     void    setError( bool error );
64
65     QString name() const;
66     QString service() const;
67     QString sender() const;
68     bool    isError() const;
69
70     virtual void append( const QVariant& var );
71
72     operator DBusMessage*() const;
73
74     iterator begin() const;
75     iterator end() const;
76
77     QVariant at( int i );
78
79   protected:
80     DBusMessage* message() const;
81
82   private:
83     struct MessagePrivate;
84     MessagePrivate *d;
85   };
86
87 }