evolution r36140 - branches/mail-dbus-remoting/mail
- From: michael svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution r36140 - branches/mail-dbus-remoting/mail
- Date: Wed, 27 Aug 2008 21:10:17 +0000 (UTC)
Author: michael
Date: Wed Aug 27 21:10:17 2008
New Revision: 36140
URL: http://svn.gnome.org/viewvc/evolution?rev=36140&view=rev
Log:
clean up dbind to allow signal emission
Modified:
branches/mail-dbus-remoting/mail/camel-object-remote-impl.c
branches/mail-dbus-remoting/mail/camel-object-remote.c
branches/mail-dbus-remoting/mail/camel-object-remote.h
branches/mail-dbus-remoting/mail/dbind.c
branches/mail-dbus-remoting/mail/dbind.h
branches/mail-dbus-remoting/mail/evo-dbus.c
Modified: branches/mail-dbus-remoting/mail/camel-object-remote-impl.c
==============================================================================
--- branches/mail-dbus-remoting/mail/camel-object-remote-impl.c (original)
+++ branches/mail-dbus-remoting/mail/camel-object-remote-impl.c Wed Aug 27 21:10:17 2008
@@ -26,8 +26,8 @@
dbus_bool_t ret;
dbus_error_init (&err);
- ret = dbind_context_method_call (e_dbus_peek_context(),
- CLIENT_DBUS_NAME,
+ ret = dbind_context_emit_signal (e_dbus_peek_context(),
+ CAMEL_DBUS_NAME,
CAMEL_SESSION_OBJECT_PATH,
CAMEL_SESSION_INTERFACE,
"session_signal",
Modified: branches/mail-dbus-remoting/mail/camel-object-remote.c
==============================================================================
--- branches/mail-dbus-remoting/mail/camel-object-remote.c (original)
+++ branches/mail-dbus-remoting/mail/camel-object-remote.c Wed Aug 27 21:10:17 2008
@@ -43,13 +43,18 @@
DBusObjectPathVTable *dbus_listener_vtable;
DBindContext *ctx = evolution_dbus_peek_context ();
DBusError err; int ret;
+ char *rule;
+
dbus_error_init (&err);
dbus_listener_vtable = g_new0 (DBusObjectPathVTable, 1);
dbus_listener_vtable->message_function = reg;
dbus_listener_vtable->unregister_function = unreg;
-
-// ret = dbus_bus_request_name (ctx->cnx, "org.gnome.evolution.mail", DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
-// printf("req bus :%d %s\n", ret, err.message);
+
+ rule = g_strconcat ("type='signal',path='", object_path, "'", NULL);
+ d(printf("EVODBUS: add match '%s'\n", rule));
+ dbus_bus_add_match (ctx->cnx, rule, NULL);
+ g_free (rule);
+
if (!dbus_connection_register_object_path (ctx->cnx,
object_path,
dbus_listener_vtable,
Modified: branches/mail-dbus-remoting/mail/camel-object-remote.h
==============================================================================
--- branches/mail-dbus-remoting/mail/camel-object-remote.h (original)
+++ branches/mail-dbus-remoting/mail/camel-object-remote.h Wed Aug 27 21:10:17 2008
@@ -12,8 +12,6 @@
/* the data server */
#define CAMEL_DBUS_NAME "org.gnome.evolution.server.camel"
-/* the hard-coded, single client [yuck] */
-#define CLIENT_DBUS_NAME "org.gnome.evolution.client"
#define CAMEL_SESSION_OBJECT_PATH "/org/gnome/evolution/camel/session"
#define MAIL_SESSION_OBJECT_PATH "/org/gnome/evolution/camel/session/mail"
Modified: branches/mail-dbus-remoting/mail/dbind.c
==============================================================================
--- branches/mail-dbus-remoting/mail/dbind.c (original)
+++ branches/mail-dbus-remoting/mail/dbind.c Wed Aug 27 21:10:17 2008
@@ -95,6 +95,52 @@
return success;
}
+dbus_bool_t
+dbind_context_emit_signal (DBindContext *ctx,
+ const char *bus_name,
+ const char *path,
+ const char *interface,
+ const char *method,
+ DBusError *opt_error,
+ const char *arg_types,
+ ...)
+{
+ dbus_bool_t success;
+ va_list args;
+
+ va_start (args, arg_types);
+
+ success = dbind_connection_emit_signal_va
+ (ctx->cnx, bus_name, path, interface, method, opt_error, arg_types, args);
+
+ va_end (args);
+
+ return success;
+}
+
+dbus_bool_t
+dbind_connection_emit_signal (DBusConnection *cnx,
+ const char *bus_name,
+ const char *path,
+ const char *interface,
+ const char *method,
+ DBusError *opt_error,
+ const char *arg_types,
+ ...)
+{
+ dbus_bool_t success;
+ va_list args;
+
+ va_start (args, arg_types);
+
+ success = dbind_connection_emit_signal_va
+ (cnx, bus_name, path, interface, method, opt_error, arg_types, args);
+
+ va_end (args);
+
+ return success;
+}
+
static void set_reply (DBusPendingCall *pending, void *user_data)
{
void **replyptr = (void **)user_data;
@@ -120,15 +166,16 @@
return reply;
}
-dbus_bool_t
-dbind_connection_method_call_va (DBusConnection *cnx,
- const char *bus_name,
- const char *path,
- const char *interface,
- const char *method,
- DBusError *opt_error,
- const char *arg_types,
- va_list args)
+static dbus_bool_t
+dbind_connection_exec_va (DBusConnection *cnx,
+ int message_type,
+ const char *bus_name,
+ const char *path,
+ const char *interface,
+ const char *method,
+ DBusError *opt_error,
+ const char *arg_types,
+ va_list args)
{
dbus_bool_t success = FALSE;
DBusMessage *msg = NULL, *reply = NULL;
@@ -144,7 +191,12 @@
err = &real_err;
}
- msg = dbus_message_new_method_call (bus_name, path, interface, method);
+// msg = dbus_message_new_method_call (bus_name, path, interface, method);
+ msg = dbus_message_new (message_type);
+ dbus_message_set_destination (msg, bus_name);
+ dbus_message_set_path (msg, path);
+ dbus_message_set_interface (msg, interface);
+ dbus_message_set_member (msg, method);
if (!msg)
goto out;
dbus_message_set_auto_start (msg, TRUE);
@@ -214,11 +266,11 @@
if (!dest)
goto out;
- /* We should clean evo.'s APIs up to not require re-enterancy later */
- if (*p == '\0') { /* one-way */
+ if (*p == '\0' || message_type == DBUS_MESSAGE_TYPE_SIGNAL) { /* one-way */
success = dbus_connection_send (cnx, msg, NULL);
goto out;
} else {
+ /* FIXME: We should clean evo.'s APIs up to not require re-enterancy later */
reply = send_and_allow_reentry (cnx, msg, -1, err);
}
if (!reply)
@@ -256,3 +308,33 @@
return success;
}
+/* urgh - axe this mess in favour of a single public message_type method */
+dbus_bool_t
+dbind_connection_method_call_va (DBusConnection *cnx,
+ const char *bus_name,
+ const char *path,
+ const char *interface,
+ const char *method,
+ DBusError *opt_error,
+ const char *arg_types,
+ va_list args)
+{
+ return dbind_connection_exec_va (cnx, DBUS_MESSAGE_TYPE_METHOD_CALL,
+ bus_name, path, interface, method,
+ opt_error, arg_types, args);
+}
+
+dbus_bool_t
+dbind_connection_emit_signal_va (DBusConnection *cnx,
+ const char *bus_name,
+ const char *path,
+ const char *interface,
+ const char *method,
+ DBusError *opt_error,
+ const char *arg_types,
+ va_list args)
+{
+ return dbind_connection_exec_va (cnx, DBUS_MESSAGE_TYPE_SIGNAL,
+ bus_name, path, interface, method,
+ opt_error, arg_types, args);
+}
Modified: branches/mail-dbus-remoting/mail/dbind.h
==============================================================================
--- branches/mail-dbus-remoting/mail/dbind.h (original)
+++ branches/mail-dbus-remoting/mail/dbind.h Wed Aug 27 21:10:17 2008
@@ -21,6 +21,14 @@
DBusError *opt_error,
const char *arg_types,
...);
+dbus_bool_t dbind_context_emit_signal (DBindContext *ctx,
+ const char *bus_name,
+ const char *path,
+ const char *interface,
+ const char *method,
+ DBusError *opt_error,
+ const char *arg_types,
+ ...);
/* dbus connection variants */
dbus_bool_t dbind_connection_method_call (DBusConnection *cnx,
@@ -39,5 +47,21 @@
DBusError *opt_error,
const char *arg_types,
va_list args);
+dbus_bool_t dbind_connection_emit_signal (DBusConnection *cnx,
+ const char *bus_name,
+ const char *path,
+ const char *interface,
+ const char *method,
+ DBusError *opt_error,
+ const char *arg_types,
+ ...);
+dbus_bool_t dbind_connection_emit_signal_va (DBusConnection *cnx,
+ const char *bus_name,
+ const char *path,
+ const char *interface,
+ const char *method,
+ DBusError *opt_error,
+ const char *arg_types,
+ va_list args);
#endif /* _DBIND_H_ */
Modified: branches/mail-dbus-remoting/mail/evo-dbus.c
==============================================================================
--- branches/mail-dbus-remoting/mail/evo-dbus.c (original)
+++ branches/mail-dbus-remoting/mail/evo-dbus.c Wed Aug 27 21:10:17 2008
@@ -31,16 +31,6 @@
return -1;
}
- d(printf("Client context setup: request name\n"));
- dbus_error_init (&error);
- dbus_bus_request_name (ctx->cnx, CLIENT_DBUS_NAME, 0, &error);
-
- if (dbus_error_is_set (&error)) {
- g_warning ("**** dbus_bus_request_name error: %s\n", error.message);
- dbus_error_free (&error);
- return -1;
- }
-
d(printf("DBind context setup: done\n"));
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]