summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-09-18 15:07:11 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-09-18 15:07:11 +0200
commit43fe926f20bd427e96a22081deace10752bb4533 (patch)
tree64a3a9950ad659ad3ff193df2916d05e31fa085c /lib
parent73c3f5fba688d9359dbf79f70b8759aee2857e41 (diff)
downloadabrt-43fe926f20bd427e96a22081deace10752bb4533.tar.gz
abrt-43fe926f20bd427e96a22081deace10752bb4533.tar.xz
abrt-43fe926f20bd427e96a22081deace10752bb4533.zip
abrt-applet: remove dbus-c++ glue. -50k of code
text data bss dec hex filename 70529 2144 1528 74201 121d9 abrt.t0/UNPACKED/usr/bin/abrt-applet 22116 1688 376 24180 5e74 abrt.t1/UNPACKED/usr/bin/abrt-applet Also, we do not use dbus-c++ anymore, which is 200k of code Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Utils/abrt_dbus.cpp4
-rw-r--r--lib/Utils/abrt_dbus.h37
2 files changed, 40 insertions, 1 deletions
diff --git a/lib/Utils/abrt_dbus.cpp b/lib/Utils/abrt_dbus.cpp
index 37d6d3e6..ad23d56c 100644
--- a/lib/Utils/abrt_dbus.cpp
+++ b/lib/Utils/abrt_dbus.cpp
@@ -264,6 +264,10 @@ void attach_dbus_conn_to_glib_main_loop(DBusConnection* conn,
const char* object_path,
DBusHandlerResult (*message_received_func)(DBusConnection *conn, DBusMessage *msg, void* data)
) {
+ if (g_dbus_conn)
+ error_msg_and_die("Internal bug: can't connect to more than one dbus");
+ g_dbus_conn = conn;
+
//do we need this? why?
//log("dbus_connection_set_dispatch_status_function");
// dbus_connection_set_dispatch_status_function(conn,
diff --git a/lib/Utils/abrt_dbus.h b/lib/Utils/abrt_dbus.h
index 731f1c10..09063c5a 100644
--- a/lib/Utils/abrt_dbus.h
+++ b/lib/Utils/abrt_dbus.h
@@ -8,8 +8,43 @@ extern DBusConnection* g_dbus_conn;
/*
* Glib integration machinery
*/
+
+/* Hook up to DBus and to glib main loop.
+ * Usage cases:
+ *
+ * - server:
+ * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err);
+ * attach_dbus_conn_to_glib_main_loop(conn, "/some/path", handler_of_calls_to_some_path);
+ * rc = dbus_bus_request_name(conn, "server.name", DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
+ *
+ * - client which does not receive signals (only makes calls and emits signals):
+ * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err);
+ * // needed only if you need to use async dbus calls (not shown below):
+ * attach_dbus_conn_to_glib_main_loop(conn);
+ * // syncronous method call:
+ * msg = dbus_message_new_method_call("some.serv", "/path/on/serv", "optional.iface.on.serv", "method_name");
+ * reply = dbus_connection_send_with_reply_and_block(conn, msg, timeout, &err);
+ * // emitting signal:
+ * msg = dbus_message_new_signal("/path/sig/emitted/from", "iface.sig.emitted.from", "sig_name");
+ * // (note: "iface.sig.emitted.from" is not optional for signals!)
+ * dbus_message_set_destination(msg, "peer"); // optional
+ * dbus_connection_send(conn, msg, &serial); // &serial can be NULL
+ *
+ * - client which receives and processes signals:
+ * conn = dbus_bus_get(DBUS_BUS_SYSTEM/SESSION, &err);
+ * attach_dbus_conn_to_glib_main_loop(conn);
+ * dbus_connection_add_filter(conn, handle_message, NULL, NULL)
+ * dbus_bus_add_match(system_conn, "type='signal',...", &err);
+ * // signal is a dbus message which looks like this:
+ * // sender=XXX dest=YYY(or null) path=/path/sig/emitted/from interface=iface.sig.emitted.from member=sig_name
+ * // and handler_for_signals(conn,msg,opaque) will be called by glib
+ * // main loop to process received signals (and other messages
+ * // if you ask for them in dbus_bus_add_match[es], but this
+ * // would turn you into a server if you handle them too) ;]
+ */
void attach_dbus_conn_to_glib_main_loop(DBusConnection* conn,
- const char* object_path_to_register = NULL, /* NULL if you are just a client */
+ /* NULL if you are just a client */
+ const char* object_path_to_register = NULL,
/* makes sense only if you use object_path_to_register: */
DBusHandlerResult (*message_received_func)(DBusConnection *conn, DBusMessage *msg, void* data) = NULL
);