edelib
2.0.0
|
00001 /* 00002 * $Id: EdbusMessage.h 2839 2009-09-28 11:36:20Z karijes $ 00003 * 00004 * D-BUS stuff 00005 * Copyright (c) 2008 edelib authors 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public License 00018 * along with this library. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef __EDELIB_EDBUSMESSAGE_H__ 00022 #define __EDELIB_EDBUSMESSAGE_H__ 00023 00024 #include "List.h" 00025 #include "EdbusData.h" 00026 00027 struct DBusMessage; 00028 00029 EDELIB_NS_BEGIN 00030 00031 class EdbusConnection; 00032 struct EdbusMessageImpl; 00033 00104 class EDELIB_API EdbusMessage { 00105 private: 00106 friend class EdbusConnection; 00107 00108 EdbusMessageImpl* dm; 00109 list<EdbusData> msg_content; 00110 00111 void from_dbus_message(DBusMessage* m); 00112 DBusMessage* to_dbus_message(void) const; 00113 00114 E_DISABLE_CLASS_COPY(EdbusMessage) 00115 public: 00119 typedef list<EdbusData>::iterator iterator; 00120 00124 typedef list<EdbusData>::const_iterator const_iterator; 00125 00131 EdbusMessage(); 00132 00137 EdbusMessage(DBusMessage* msg); 00138 00142 ~EdbusMessage(); 00143 00151 void create_signal(const char* path, const char* interface, const char* name); 00152 00161 void create_method_call(const char* service, const char* path, const char* interface, const char* method); 00162 00168 void create_reply(const EdbusMessage& replying_to); 00169 00176 void create_error_reply(const EdbusMessage& replying_to, const char* errmsg); 00177 00186 void clear_all(void); 00187 00191 bool is_signal(void); 00192 00196 bool is_method_call(void); 00197 00201 bool is_error_reply(const char* errmsg); 00202 00207 void path(const char* np); 00208 00213 const char* path(void) const; 00214 00219 void interface(const char* ni); 00220 00225 const char* interface(void) const; 00226 00236 void destination(const char* nd); 00237 00242 const char* destination(void) const; 00243 00250 void member(const char* nm); 00251 00256 const char* member(void) const; 00257 00266 void sender(const char* ns); 00267 00276 const char* sender(void) const; 00277 00287 const char* signature(void) const; 00288 00292 void append(const EdbusData& data) { msg_content.push_back(data); } 00293 00297 iterator begin(void) { return msg_content.begin(); } 00298 00302 const_iterator begin(void) const { return msg_content.begin(); } 00303 00308 iterator end(void) { return msg_content.end(); } 00309 00314 const_iterator end(void) const { return msg_content.end(); } 00315 00319 unsigned int size(void) const { return msg_content.size(); } 00320 }; 00321 00331 inline EdbusMessage& operator<<(EdbusMessage& m, const EdbusData& val) { 00332 m.append(val); 00333 return m; 00334 } 00335 00336 EDELIB_NS_END 00337 #endif