evolution r36155 - branches/mail-dbus-remoting/mail
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution r36155 - branches/mail-dbus-remoting/mail
- Date: Thu, 28 Aug 2008 11:30:07 +0000 (UTC)
Author: sragavan
Date: Thu Aug 28 11:30:06 2008
New Revision: 36155
URL: http://svn.gnome.org/viewvc/evolution?rev=36155&view=rev
Log:
Lots of cleanups. Make a generic signal handler for session/store/folder.
Modified:
branches/mail-dbus-remoting/mail/camel-object-remote-impl.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 Thu Aug 28 11:30:06 2008
@@ -20,7 +20,7 @@
/* Session */
static void
-session_signal_cb (CamelObject *sess, gpointer ev_data, gpointer data)
+object_signal_cb (CamelObject *sess, gpointer ev_data, gpointer data)
{
DBusError err;
dbus_bool_t ret;
@@ -31,8 +31,8 @@
CAMEL_DBUS_NAME,
CAMEL_SESSION_OBJECT_PATH,
CAMEL_SESSION_INTERFACE,
- "session_signal",
- &err, "ii", ev_data, data);
+ "signal",
+ &err, "is", ev_data, data);
access ("after dbind context emit signal", 0);
if (!ret)
@@ -40,13 +40,15 @@
}
DBusHandlerResult
-camel_object_session_signal_handler (DBusConnection *connection,
+camel_object_signal_handler (DBusConnection *connection,
DBusMessage *message,
- void *user_data)
+ void *user_data,
+ CamelObjectRemoteImplType type)
{
const char *method = dbus_message_get_member (message);
DBusMessage *return_val;
gboolean added = FALSE;
+ CamelObject *object;
printf("Handling session/co functions : %s\n", dbus_message_get_sender(message));
return_val = dbus_message_new_method_return (message);
@@ -61,80 +63,15 @@
DBUS_TYPE_STRING, &signal,
DBUS_TYPE_INT32, &ptr,
DBUS_TYPE_INVALID);
- data = GINT_TO_POINTER (ptr);
- printf("got: %s %s %p\n", object_hash, signal, data);
- ret_id = camel_object_hook_event (session, signal, (CamelObjectEventHookFunc)session_signal_cb, data);
- dbus_message_append_args (return_val, DBUS_TYPE_UINT32, &ret_id, DBUS_TYPE_INVALID);
- added = TRUE;
- } else /* FIXME: Free memory and return */
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
- if (!added)
- dbus_message_append_args (return_val, DBUS_TYPE_INVALID);
-
- dbus_connection_send (connection, return_val, NULL);
- dbus_message_unref (return_val);
- dbus_connection_flush(connection);
+ data = g_strdup_printf ("%s:%s:%d", object_hash, signal, ptr);
+ if (type == CAMEL_ROT_STORE)
+ object = g_hash_table_lookup (store_hash, object_hash);
+ else if (type == CAMEL_ROT_FOLDER)
+ object = g_hash_table_lookup (folder_hash, object_hash);
+ else
+ object = session;
- return DBUS_HANDLER_RESULT_HANDLED;
-
-}
-
-/* Store */
-static char *
-hash_store (CamelObject *store)
-{
- return e_dbus_get_store_hash (camel_service_get_url((CamelService *)store));
-}
-
-static void
-store_signal_cb (CamelObject *store, gpointer ev_data, gpointer data)
-{
- /* Signal back to the caller */
- DBusMessage *signal;
- DBusConnection *dbus = e_dbus_connection_get();
- char *hash = hash_store (store);
-
- signal = dbus_message_new_signal (CAMEL_STORE_OBJECT_PATH,
- CAMEL_STORE_INTERFACE,
- "store_signal");
- /* It sucks here to pass the pointer across the object */
- dbus_message_append_args (signal, DBUS_TYPE_STRING, &hash, DBUS_TYPE_INT32, &ev_data, DBUS_TYPE_STRING, &data, DBUS_TYPE_INVALID);
- dbus_connection_send (dbus, signal, NULL);
- dbus_message_unref (signal);
- dbus_connection_flush(dbus);
-}
-
-DBusHandlerResult
-camel_object_store_signal_handler (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- const char *method = dbus_message_get_member (message);
- DBusMessage *return_val;
- gboolean added = FALSE;
-
- printf ("D-Bus message: obj_path = '%s' interface = '%s' method = '%s' destination = '%s'\n",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message),
- dbus_message_get_destination (message));
-
-
- return_val = dbus_message_new_method_return (message);
-
- if (strcmp(method, "camel_object_hook_event") == 0) {
- char *signal, *data, *object_hash;
- unsigned int ret_id;
- CamelObject *obj;
-
- dbus_message_get_args(message, NULL,
- DBUS_TYPE_STRING, &object_hash,
- DBUS_TYPE_STRING, &signal,
- DBUS_TYPE_STRING, &data,
- DBUS_TYPE_INVALID);
- obj = g_hash_table_lookup (store_hash, object_hash);
- ret_id = camel_object_hook_event (obj, signal, (CamelObjectEventHookFunc)store_signal_cb, data);
+ ret_id = camel_object_hook_event (object, signal, (CamelObjectEventHookFunc)object_signal_cb, data);
dbus_message_append_args (return_val, DBUS_TYPE_UINT32, &ret_id, DBUS_TYPE_INVALID);
added = TRUE;
} else /* FIXME: Free memory and return */
@@ -151,79 +88,6 @@
}
-
-/* Folder */
-static char *
-hash_folder (CamelObject *obj)
-{
- CamelFolder *folder = (CamelFolder *)obj;
- return e_dbus_get_folder_hash (camel_service_get_url((CamelService *)folder->parent_store), folder->full_name);
-}
-
-static void
-folder_signal_cb (CamelObject *folder, gpointer ev_data, gpointer data)
-{
- /* Signal back to the caller */
- DBusMessage *signal;
- DBusConnection *dbus = e_dbus_connection_get();
- char *hash = hash_folder(folder);
- signal = dbus_message_new_signal (CAMEL_FOLDER_OBJECT_PATH,
- CAMEL_FOLDER_INTERFACE,
- "folder_signal");
- /* It sucks here to pass the pointer across the object */
- dbus_message_append_args (signal, DBUS_TYPE_STRING, &hash, DBUS_TYPE_INT32, &ev_data, DBUS_TYPE_STRING, &data, DBUS_TYPE_INVALID);
- dbus_connection_send (dbus, signal, NULL);
- dbus_message_unref (signal);
- dbus_connection_flush(dbus);
-}
-
-DBusHandlerResult
-camel_object_folder_signal_handler (DBusConnection *connection,
- DBusMessage *message,
- void *user_data)
-{
- const char *method = dbus_message_get_member (message);
- DBusMessage *return_val;
- gboolean added = FALSE;
-
- printf ("D-Bus message: obj_path = '%s' interface = '%s' method = '%s' destination = '%s'\n",
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message),
- dbus_message_get_destination (message));
-
-
- return_val = dbus_message_new_method_return (message);
-
- if (strcmp(method, "camel_object_hook_event") == 0) {
- char *signal, *data, *object_hash;
- unsigned int ret_id;
- CamelObject *obj;
-
- dbus_message_get_args(message, NULL,
- DBUS_TYPE_STRING, &object_hash,
- DBUS_TYPE_STRING, &signal,
- DBUS_TYPE_STRING, &data,
- DBUS_TYPE_INVALID);
- obj = g_hash_table_lookup (folder_hash, object_hash);
- ret_id = camel_object_hook_event (obj, signal, (CamelObjectEventHookFunc)folder_signal_cb, data);
- dbus_message_append_args (return_val, DBUS_TYPE_UINT32, &ret_id, DBUS_TYPE_INVALID);
- added = TRUE;
- } else /* FIXME: Free memory and return */
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
- if (!added)
- dbus_message_append_args (return_val, DBUS_TYPE_INVALID);
-
- dbus_connection_send (connection, return_val, NULL);
- dbus_message_unref (return_val);
- dbus_connection_flush(connection);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-
-}
-
-
void
camel_object_remote_impl_init ()
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]