3 * D-Bus++ - C++ bindings for D-Bus
5 * Copyright (C) 2005-2009 Paolo Durante <shackan@gmail.com>
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.
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.
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
25 #ifndef __DBUSXX_MESSAGE_H
26 #define __DBUSXX_MESSAGE_H
43 class DBUSXXAPI MessageIter
55 MessageIter
&operator ++();
57 MessageIter
operator ++(int);
59 bool append_byte(unsigned char byte
);
61 unsigned char get_byte();
63 bool append_bool(bool b
);
67 bool append_int16(signed short i
);
69 signed short get_int16();
71 bool append_uint16(unsigned short u
);
73 unsigned short get_uint16();
75 bool append_int32(signed int i
);
77 signed int get_int32();
79 bool append_uint32(unsigned int u
);
81 unsigned int get_uint32();
83 bool append_int64(signed long long i
);
85 signed long long get_int64();
87 bool append_uint64(unsigned long long i
);
89 unsigned long long get_uint64();
91 bool append_double(double d
);
95 bool append_string(const char *chars
);
97 const char *get_string();
99 bool append_path(const char *chars
);
101 const char *get_path();
103 bool append_signature(const char *chars
);
105 const char *get_signature();
107 char *signature() const; //returned string must be manually free()'d
109 MessageIter
recurse();
111 bool append_array(char type
, const void *ptr
, size_t length
);
115 int get_array(void *ptr
);
121 MessageIter
new_array(const char *sig
);
123 MessageIter
new_variant(const char *sig
);
125 MessageIter
new_struct();
127 MessageIter
new_dict_entry();
129 void close_container(MessageIter
&container
);
131 void copy_data(MessageIter
&to
);
140 DBUSXXAPILOCAL
MessageIter(Message
&msg
) : _msg(&msg
) {}
142 DBUSXXAPILOCAL
bool append_basic(int type_id
, void *value
);
144 DBUSXXAPILOCAL
void get_basic(int type_id
, void *ptr
);
148 /* I'm sorry, but don't want to include dbus.h in the public api
150 unsigned char _iter
[sizeof(void *)*3+sizeof(int)*11];
154 friend class Message
;
157 class DBUSXXAPI Message
165 Message(Private
*, bool incref
= true);
167 Message(const Message
&m
);
171 Message
&operator = (const Message
&m
);
177 int reply_serial() const;
179 bool reply_serial(int);
181 const char *sender() const;
183 bool sender(const char *s
);
185 const char *destination() const;
187 bool destination(const char *s
);
189 bool is_error() const;
191 bool is_error(const char *error
) const;
193 bool is_signal() const;
195 bool is_signal(const char *interface
, const char *signal
) const;
197 bool is_call() const;
199 bool is_call(const char *interface
, const char *method
) const;
201 bool is_return() const;
203 MessageIter
reader() const;
205 MessageIter
writer();
207 bool append(int first_type
, ...);
213 RefPtrI
<Private
> _pvt
;
215 /* classes who need to read `_pvt` directly
217 friend class ErrorMessage
;
218 friend class ReturnMessage
;
219 friend class MessageIter
;
221 friend class Connection
;
227 class DBUSXXAPI ErrorMessage
: public Message
233 ErrorMessage(const Message
&, const char *name
, const char *message
);
235 const char *name() const;
237 bool name(const char *n
);
239 bool operator == (const ErrorMessage
&) const;
245 class DBUSXXAPI SignalMessage
: public Message
249 SignalMessage(const char *name
);
251 SignalMessage(const char *path
, const char *interface
, const char *name
);
253 const char *interface() const;
255 bool interface(const char *i
);
257 const char *member() const;
259 bool member(const char *m
);
261 const char *path() const;
263 char **path_split() const;
265 bool path(const char *p
);
267 bool operator == (const SignalMessage
&) const;
273 class DBUSXXAPI CallMessage
: public Message
279 CallMessage(const char *dest
, const char *path
, const char *iface
, const char *method
);
281 const char *interface() const;
283 bool interface(const char *i
);
285 const char *member() const;
287 bool member(const char *m
);
289 const char *path() const;
291 char **path_split() const;
293 bool path(const char *p
);
295 const char *signature() const;
297 bool operator == (const CallMessage
&) const;
303 class DBUSXXAPI ReturnMessage
: public Message
307 ReturnMessage(const CallMessage
&callee
);
309 const char *signature() const;
312 } /* namespace DBus */
314 #endif//__DBUSXX_MESSAGE_H