edelib
2.0.0
|
00001 /* 00002 * $Id: EdbusConnection.h 2911 2009-10-13 10:37:34Z 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_EDBUSCONNECTION_H__ 00022 #define __EDELIB_EDBUSCONNECTION_H__ 00023 00024 #include "EdbusMessage.h" 00025 #include "EdbusError.h" 00026 00027 EDELIB_NS_BEGIN 00028 00038 enum EdbusConnectionType { 00039 EDBUS_SYSTEM, 00040 EDBUS_SESSION 00041 }; 00042 00048 enum EdbusNameMode { 00049 EDBUS_NAME_NO_REPLACE = 0, 00050 EDBUS_NAME_ALLOW_REPLACE = 1, 00051 EDBUS_NAME_REPLACE_EXISTING = 2 00052 }; 00053 00058 typedef int (*EdbusCallback)(const EdbusMessage*, void*); 00059 00060 #ifndef SKIP_DOCS 00061 struct EdbusConnImpl; 00062 #endif 00063 00144 class EDELIB_API EdbusConnection { 00145 private: 00146 EdbusConnImpl* dc; 00147 void setup_filter(void); 00148 00149 E_DISABLE_CLASS_COPY(EdbusConnection) 00150 public: 00155 EdbusConnection(); 00156 00160 ~EdbusConnection(); 00161 00168 bool connect(EdbusConnectionType ctype); 00169 00173 void disconnect(void); 00174 00183 bool send(const EdbusMessage& content); 00184 00194 bool send_with_reply_and_block(const EdbusMessage& content, int timeout_ms, EdbusMessage& ret); 00195 00221 bool request_name(const char* name, int mode = EDBUS_NAME_NO_REPLACE); 00222 00226 const char* unique_name(void); 00227 00235 void signal_callback(EdbusCallback cb, void* data); 00236 00244 void method_callback(EdbusCallback cb, void* data); 00245 00252 void add_signal_match(const char* path, const char* interface, const char* name); 00253 00263 void add_method_match(const char* path, const char* interface, const char* name); 00264 00277 void register_object(const char* path); 00278 00283 void unregister_object(const char* path); 00284 00291 void setup_listener(void); 00292 00297 void setup_listener_with_fltk(void); 00298 00314 int wait(int timeout_ms); 00315 00320 EdbusError* error(void); 00321 }; 00322 00323 EDELIB_NS_END 00324 #endif