+ uri = (char *) user_data;
+
+ g_thread_create (thread_prepare_delete_message, g_strdup (uri), FALSE, NULL);
+
+ return FALSE;
+
+}
+
+
+
+
+static gint
+on_delete_message (GArray *arguments, gpointer data, osso_rpc_t *retval)
+{
+ /* Get the arguments: */
+ osso_rpc_t val = g_array_index (arguments,
+ osso_rpc_t,
+ MODEST_DBUS_DELETE_MESSAGE_ARG_URI);
+ gchar *uri = g_strdup (val.value.s);
+
+ /* Use g_idle to context-switch into the application's thread: */
+ g_idle_add(on_idle_delete_message, (gpointer)uri);
+
+ return OSSO_OK;
+}
+
+static gboolean
+on_idle_send_receive(gpointer user_data)
+{
+ gboolean auto_update;
+ ModestWindow *top_win = NULL;
+
+ top_win = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ());
+
+ gdk_threads_enter (); /* CHECKED */
+
+ /* Check if the autoupdate feature is on */
+ auto_update = modest_conf_get_bool (modest_runtime_get_conf (),
+ MODEST_CONF_AUTO_UPDATE, NULL);
+
+ if (auto_update)
+ /* Do send receive */
+ modest_ui_actions_do_send_receive_all (top_win, FALSE, FALSE, FALSE);
+ else
+ /* Disable auto update */
+ modest_platform_set_update_interval (0);
+
+ gdk_threads_leave (); /* CHECKED */
+
+ return FALSE;
+}
+
+
+
+static gint
+on_dbus_method_dump_send_queues (DBusConnection *con, DBusMessage *message)
+{
+ gchar *str;
+
+ DBusMessage *reply;
+ dbus_uint32_t serial = 0;
+
+ GSList *account_names, *cursor;
+
+ str = g_strdup("\nsend queues\n"
+ "===========\n");
+
+ cursor = account_names = modest_account_mgr_account_names
+ (modest_runtime_get_account_mgr(), TRUE); /* only enabled accounts */
+
+ while (cursor) {
+ TnyAccount *acc;
+ gchar *tmp, *accname = (gchar*)cursor->data;
+
+ tmp = g_strdup_printf ("%s", str);
+ g_free (str);
+ str = tmp;
+
+ /* transport */
+ acc = modest_tny_account_store_get_server_account (
+ modest_runtime_get_account_store(), accname,
+ TNY_ACCOUNT_TYPE_TRANSPORT);
+ if (TNY_IS_ACCOUNT(acc)) {
+ gchar *tmp = NULL, *url = tny_account_get_url_string (acc);
+ ModestTnySendQueue *sendqueue =
+ modest_runtime_get_send_queue (TNY_TRANSPORT_ACCOUNT(acc), TRUE);
+
+ if (TNY_IS_SEND_QUEUE (sendqueue)) {
+ gchar *queue_str = modest_tny_send_queue_to_string (sendqueue);
+
+ tmp = g_strdup_printf ("%s[%s]: '%s': %s\n%s",
+ str, accname, tny_account_get_id (acc), url,
+ queue_str);
+ g_free(queue_str);
+ g_free (str);
+ str = tmp;
+ }
+ g_free (url);
+
+ g_object_unref (acc);
+ }
+
+ cursor = g_slist_next (cursor);
+ }
+ modest_account_mgr_free_account_names (account_names);
+
+ g_printerr (str);
+
+ reply = dbus_message_new_method_return (message);
+ if (reply) {
+ dbus_message_append_args (reply,
+ DBUS_TYPE_STRING, &str,
+ DBUS_TYPE_INVALID);
+ dbus_connection_send (con, reply, &serial);
+ dbus_connection_flush (con);
+ dbus_message_unref (reply);
+ }
+ g_free (str);
+
+ /* Let modest die */
+ g_idle_add (notify_error_in_dbus_callback, NULL);
+
+ return OSSO_OK;