# DBus-C++

## Desktop Communication Bus System

libdbus-c-- Documentation 0.9.0

- Files
- Data Structures
- Globals
- Main Page

message.h
Go to the documentation of this file.
1/*
2 *
3 * D-Bus++ - C++ bindings for D-Bus
4 *
5 * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com>
6 *
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library 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 GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24
25#ifndef __DBUSXX_MESSAGE_H
26#define __DBUSXX_MESSAGE_H
27
28#include <string>
29#include <map>
30
31#include "api.h"
32#include "util.h"
33
34 namespace DBus
35{
36
37 class Message;
38 class ErrorMessage;
39 class SignalMessage;
40 class ReturnMessage;
41 class Error;
42 class Connection;
43
44 class DXXAPI MessageIter
45{
46 public:
47
48 MessageIter() {}
49
50 int type();
51
52 bool at_end();
53
54 bool has_next();
55
56 MessageIter &operator ++();
57
58 MessageIter operator ++(int);
59
60 bool append_byte(unsigned char byte);
61
62 unsigned char get_byte();
63
64 bool append_bool(bool b);
65
66 bool get_bool();
67
68 bool append_int16(signed short i);
69
70 signed short get_int16();
71
72 bool append_uint16(unsigned short u);
73
74 unsigned short get_uint16();
75
76 bool append_int32(signed int i);
77
78 signed int get_int32();
79
80 bool append_uint32(unsigned int u);
81
82 unsigned int get_uint32();
83
84 bool append_int64(signed long long i);
85
86 signed long long get_int64();
87
88 bool append_uint64(unsigned long long i);
89
90 unsigned long long get_uint64();
91
92 bool append_double(double d);
93
94 double get_double();
95
96 bool append_string(const char *chars);
97
98 const char *get_string();
99
100 bool append_path(const char *chars);
101
102 const char *get_path();
103
104 bool append_signature(const char *chars);
105
106 const char *get_signature();
107
108 char *signature() const; //returned string must be manually free()'d
109
110 MessageIter recurse();
111
112 bool append_array(char type, const void *ptr, size_t length);
113
114 int array_type();
115
116 int get_array(void *ptr);
117
118 bool is_array();
119
120 bool is_dict();
121
122 MessageIter new_array(const char *sig);
123
124 MessageIter new_variant(const char *sig);
125
126 MessageIter new_struct();
127
128 MessageIter new_dict_entry();
129
130 void close_container(MessageIter &container);
131
132 void copy_data(MessageIter &to);
133
134 Message &msg() const
135 {
136 return *_msg;
137 }
138
139 private:
140
141 DXXAPILOCAL MessageIter(Message &msg) : _msg(&msg) {}
142
143 DXXAPILOCAL bool append_basic(int type_id, void *value);
144
145 DXXAPILOCAL void get_basic(int type_id, void *ptr);
146
147 private:
148
149 /* I'm sorry, but don't want to include dbus.h in the public api
150 */
151 unsigned char _iter[sizeof(void *) * 3 + sizeof(int) * 11];
152
153 Message *_msg;
154
155 friend class Message;
156};
157
158 class DXXAPI Message
159{
160 public:
161
162 struct Private;
163
164 Message(Private *, bool incref = true);
165
166 Message(const Message &m);
167
168 ~Message();
169
170 Message &operator = (const Message &m);
171
172 Message copy();
173
174 int type() const;
175
176 int serial() const;
177
178 int reply_serial() const;
179
180 bool reply_serial(int);
181
182 const char *sender() const;
183
184 bool sender(const char *s);
185
186 const char *destination() const;
187
188 bool destination(const char *s);
189
190 bool is_error() const;
191
192 bool is_signal(const char *interface, const char *member) const;
193
194 MessageIter reader() const;
195
196 MessageIter writer();
197
198 bool append(int first_type, ...);
199
200 void terminate();
201
202 protected:
203
204 Message();
205
206 protected:
207
208 RefPtrI<Private> _pvt;
209
210 /* classes who need to read `_pvt` directly
211 */
212 friend class ErrorMessage;
213 friend class ReturnMessage;
214 friend class MessageIter;
215 friend class Error;
216 friend class Connection;
217};
218
219/*
220*/
221
222 class DXXAPI ErrorMessage : public Message
223{
224 public:
225
226 ErrorMessage();
227
228 ErrorMessage(const Message &, const char *name, const char *message);
229
230 const char *name() const;
231
232 bool name(const char *n);
233
234 bool operator == (const ErrorMessage &) const;
235};
236
237/*
238*/
239
240 class DXXAPI SignalMessage : public Message
241{
242 public:
243
244 SignalMessage(const char *name);
245
246 SignalMessage(const char *path, const char *interface, const char *name);
247
248 const char *interface() const;
249
250 bool interface(const char *i);
251
252 const char *member() const;
253
254 bool member(const char *m);
255
256 const char *path() const;
257
258 char **path_split() const;
259
260 bool path(const char *p);
261
262 bool operator == (const SignalMessage &) const;
263};
264
265/*
266*/
267
268 class DXXAPI CallMessage : public Message
269{
270 public:
271
272 CallMessage();
273
274 CallMessage(const char *dest, const char *path, const char *iface, const char *method);
275
276 const char *interface() const;
277
278 bool interface(const char *i);
279
280 const char *member() const;
281
282 bool member(const char *m);
283
284 const char *path() const;
285
286 char **path_split() const;
287
288 bool path(const char *p);
289
290 const char *signature() const;
291
292 bool operator == (const CallMessage &) const;
293};
294
295/*
296*/
297
298 class DXXAPI ReturnMessage : public Message
299{
300 public:
301
302 ReturnMessage(const CallMessage &callee);
303
304 const char *signature() const;
305};
306
307} /* namespace DBus */
308
309#endif//__DBUSXX_MESSAGE_H
api.h
DXXAPILOCAL
#define DXXAPILOCAL
Definition api.h:32
DXXAPI
#define DXXAPI
Definition api.h:36
DBus::CallMessage
Definition message.h:269
DBus::CallMessage::CallMessage
CallMessage()
Definition message.cpp:574
DBus::CallMessage::path_split
char ** path_split() const
Definition message.cpp:614
DBus::CallMessage::member
const char * member() const
Definition message.cpp:599
DBus::CallMessage::signature
const char * signature() const
Definition message.cpp:626
DBus::CallMessage::path
const char * path() const
Definition message.cpp:609
DBus::CallMessage::interface
const char * interface() const
Definition message.cpp:589
DBus::Connection
Definition connection.h:49
DBus::ErrorMessage
Definition message.h:223
DBus::ErrorMessage::ErrorMessage
ErrorMessage()
Definition message.cpp:490
DBus::ErrorMessage::name
const char * name() const
Definition message.cpp:505
DBus::Error
Definition error.h:40
DBus::MessageIter
Definition message.h:45
DBus::MessageIter::MessageIter
MessageIter()
Definition message.h:48
DBus::MessageIter::msg
Message & msg() const
Definition message.h:134
DBus::MessageIter::_msg
Message * _msg
Definition message.h:153
DBus::MessageIter::Message
friend class Message
Definition message.h:155
DBus::MessageIter::_iter
unsigned char _iter[sizeof(void *) *3+sizeof(int) *11]
Definition message.h:151
DBus::MessageIter::MessageIter
DXXAPILOCAL MessageIter(Message &msg)
Definition message.h:141
DBus::Message
Definition message.h:159
DBus::Message::Message
Message(Private *, bool incref=true)
Definition message.cpp:373
DBus::Message::_pvt
RefPtrI< Private > _pvt
Definition message.h:208
DBus::Message::copy
Message copy()
Definition message.cpp:401
DBus::Message::Error
friend class Error
Definition message.h:215
DBus::Message::ReturnMessage
friend class ReturnMessage
Definition message.h:213
DBus::Message::writer
MessageIter writer()
Definition message.cpp:473
DBus::Message::is_signal
bool is_signal(const char *interface, const char *member) const
Definition message.cpp:468
DBus::Message::terminate
void terminate()
Definition message.cpp:418
DBus::Message::reply_serial
int reply_serial() const
Definition message.cpp:433
DBus::Message::append
bool append(int first_type,...)
Definition message.cpp:407
DBus::Message::is_error
bool is_error() const
Definition message.cpp:463
DBus::Message::Connection
friend class Connection
Definition message.h:216
DBus::Message::destination
const char * destination() const
Definition message.cpp:453
DBus::Message::sender
const char * sender() const
Definition message.cpp:443
DBus::Message::ErrorMessage
friend class ErrorMessage
Definition message.h:212
DBus::Message::reader
MessageIter reader() const
Definition message.cpp:480
DBus::Message::MessageIter
friend class MessageIter
Definition message.h:214
DBus::Message::type
int type() const
Definition message.cpp:423
DBus::Message::serial
int serial() const
Definition message.cpp:428
DBus::RefPtrI
Definition util.h:114
DBus::ReturnMessage
Definition message.h:299
DBus::ReturnMessage::signature
const char * signature() const
Definition message.cpp:639
DBus::ReturnMessage::ReturnMessage
ReturnMessage(const CallMessage &callee)
Definition message.cpp:634
DBus::SignalMessage
Definition message.h:241
DBus::SignalMessage::member
const char * member() const
Definition message.cpp:544
DBus::SignalMessage::interface
const char * interface() const
Definition message.cpp:534
DBus::SignalMessage::path
const char * path() const
Definition message.cpp:554
DBus::SignalMessage::SignalMessage
SignalMessage(const char *name)
Definition message.cpp:518
DBus::SignalMessage::path_split
char ** path_split() const
Definition message.cpp:559
DBus
Definition connection_p.h:42
DBus::Message::Private
Definition message_p.h:41
DBus::type
Definition types.h:145
util.h