edelib  2.1.0
EdbusMessage.h
1 /*
2  * $Id: EdbusMessage.h 3401 2012-08-29 07:57:30Z karijes $
3  *
4  * D-BUS stuff
5  * Copyright (c) 2008 edelib authors
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library 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 GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __EDELIB_EDBUSMESSAGE_H__
22 #define __EDELIB_EDBUSMESSAGE_H__
23 
24 #include "List.h"
25 #include "EdbusData.h"
26 
27 struct DBusMessage;
28 
29 EDELIB_NS_BEGIN
30 
31 class EdbusConnection;
32 struct EdbusMessageImpl;
33 
104 class EDELIB_API EdbusMessage {
105 private:
106  friend class EdbusConnection;
107 
108  EdbusMessageImpl* dm;
109  list<EdbusData> msg_content;
110 
111  void from_dbus_message(DBusMessage* m);
112  DBusMessage* to_dbus_message(void) const;
113 
115 public:
120 
125 
131  EdbusMessage() : dm(NULL) { }
132 
137  EdbusMessage(DBusMessage* msg);
138 
142  ~EdbusMessage();
143 
151  void create_signal(const char* path, const char* interface, const char* name);
152 
161  void create_method_call(const char* service, const char* path, const char* interface, const char* method);
162 
168  void create_reply(const EdbusMessage& replying_to);
169 
176  void create_error_reply(const EdbusMessage& replying_to, const char* errmsg);
177 
186  void clear_all(void);
187 
191  bool is_signal(void);
192 
196  bool is_method_call(void);
197 
201  bool is_error_reply(const char* errmsg);
202 
207  void path(const char* np);
208 
213  const char* path(void) const;
214 
219  void interface(const char* ni);
220 
225  const char* interface(void) const;
226 
236  void destination(const char* nd);
237 
242  const char* destination(void) const;
243 
250  void member(const char* nm);
251 
256  const char* member(void) const;
257 
266  void sender(const char* ns);
267 
276  const char* sender(void) const;
277 
287  const char* signature(void) const;
288 
292  void append(const EdbusData& data) { msg_content.push_back(data); }
293 
297  iterator begin(void) { return msg_content.begin(); }
298 
302  const_iterator begin(void) const { return msg_content.begin(); }
303 
308  iterator end(void) { return msg_content.end(); }
309 
314  const_iterator end(void) const { return msg_content.end(); }
315 
319  unsigned int size(void) const { return msg_content.size(); }
320 };
321 
332  m.append(val);
333  return m;
334 }
335 
336 EDELIB_NS_END
337 #endif
D-Bus connection and data sender.
Definition: EdbusConnection.h:154
iterator end(void)
Definition: EdbusMessage.h:308
unsigned int size(void) const
Definition: EdbusMessage.h:319
Class for representing D-Bus data types.
Definition: EdbusData.h:110
Linked list class.
Definition: List.h:160
EdbusMessage()
Definition: EdbusMessage.h:131
iterator begin(void)
Definition: EdbusMessage.h:297
const_iterator begin(void) const
Definition: EdbusMessage.h:302
list< EdbusData >::const_iterator const_iterator
Definition: EdbusMessage.h:124
Data transporter for D-Bus.
Definition: EdbusMessage.h:104
void append(const EdbusData &data)
Definition: EdbusMessage.h:292
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
const_iterator end(void) const
Definition: EdbusMessage.h:314
EdbusList & operator<<(EdbusList &lst, const EdbusData &val)
Definition: EdbusList.h:219
list< EdbusData >::iterator iterator
Definition: EdbusMessage.h:119