edelib 2.1.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List

EdbusConnection.h
1 /*
2 * $Id: EdbusConnection.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_EDBUSCONNECTION_H__
22 #define __EDELIB_EDBUSCONNECTION_H__
23
24 #include "EdbusMessage.h"
25 #include "EdbusError.h"
26
27 EDELIB_NS_BEGIN
28
39 #define EDBUS_INTROSPECTION_DTD \
40 "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \n" \
41 "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n\n"
42
48 enum EdbusConnectionType {
49 EDBUS_SYSTEM,
50 EDBUS_SESSION
51 };
52
58 enum EdbusNameMode {
59 EDBUS_NAME_NO_REPLACE = 0,
60 EDBUS_NAME_ALLOW_REPLACE = 1,
61 EDBUS_NAME_REPLACE_EXISTING = 2
62 };
63
68 typedef int (*EdbusCallback)(const EdbusMessage*, void*);
69
70 #ifndef SKIP_DOCS
71 struct EdbusConnImpl;
72 #endif
73
154 class EDELIB_API EdbusConnection {
155 private:
156 EdbusConnImpl* dc;
157 void setup_filter(void);
158
159 E_DISABLE_CLASS_COPY(EdbusConnection)
160 public:
165 EdbusConnection();
166
170 ~EdbusConnection();
171
178 bool connect(EdbusConnectionType ctype);
179
183 void disconnect(void);
184
191 bool connected(void);
192
201 bool send(const EdbusMessage& content);
202
212 bool send_with_reply_and_block(const EdbusMessage& content, int timeout_ms, EdbusMessage& ret);
213
239 bool request_name(const char* name, int mode = EDBUS_NAME_NO_REPLACE);
240
244 const char* unique_name(void);
245
253 void signal_callback(EdbusCallback cb, void* data);
254
262 void method_callback(EdbusCallback cb, void* data);
263
270 void add_signal_match(const char* path, const char* interface, const char* name);
271
281 void add_method_match(const char* path, const char* interface, const char* name);
282
294 void register_object(const char* path);
295
299 void unregister_object(const char* path);
300
307 void setup_listener(void);
308
313 void setup_listener_with_fltk(void);
314
330 int wait(int timeout_ms);
331
336 EdbusError* error(void);
337 };
338
339 EDELIB_NS_END
340 #endif
edelib::EdbusConnection
D-Bus connection and data sender.
Definition: EdbusConnection.h:154
edelib::EDBUS_NAME_REPLACE_EXISTING
Force replacement.
Definition: EdbusConnection.h:61
edelib::EdbusCallback
int(* EdbusCallback)(const EdbusMessage *, void *)
Definition: EdbusConnection.h:68
edelib::EdbusNameMode
EdbusNameMode
What to do when known name is acquired.
Definition: EdbusConnection.h:58
edelib::EDBUS_SYSTEM
System bus.
Definition: EdbusConnection.h:49
edelib::EDBUS_NAME_ALLOW_REPLACE
Existing name can be replaced.
Definition: EdbusConnection.h:60
edelib::EDBUS_SESSION
Session bus.
Definition: EdbusConnection.h:50
edelib::EdbusMessage
Data transporter for D-Bus.
Definition: EdbusMessage.h:104
E_DISABLE_CLASS_COPY
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
edelib::EDBUS_NAME_NO_REPLACE
Do not replace existing name.
Definition: EdbusConnection.h:59
edelib::EdbusConnectionType
EdbusConnectionType
Represents connection either to system or session bus.
Definition: EdbusConnection.h:48
edelib::EdbusError
A class representing D-Bus error.
Definition: EdbusError.h:70