return FALSE;
}
+
+static gint
+on_dbus_method_dump (DBusConnection *con, DBusMessage *message)
+{
+ gchar *str;
+ gchar *op_queue_str;
+ DBusMessage *reply;
+ dbus_uint32_t serial = 0;
+
+ op_queue_str = modest_mail_operation_queue_to_string
+ (modest_runtime_get_mail_operation_queue ());
+
+ str = g_strdup_printf ("\nmodest debug dump\n=================\n%s\n",
+ op_queue_str);
+ g_free (op_queue_str);
+
+ 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);
+ return OSSO_OK;
+}
+
+
static gint
on_send_receive(GArray *arguments, gpointer data, osso_rpc_t * retval)
{
} else if (g_ascii_strcasecmp (method, MODEST_DBUS_METHOD_TOP_APPLICATION) == 0) {
if (arguments->len != 0)
goto param_error;
- return on_top_application (arguments, data, retval);
+ return on_top_application (arguments, data, retval);
} else {
/* We need to return INVALID here so
* libosso will return DBUS_HANDLER_RESULT_NOT_YET_HANDLED,
on_dbus_method_search (con, message);
handled = TRUE;
} else if (dbus_message_is_method_call (message,
- MODEST_DBUS_IFACE,
- MODEST_DBUS_METHOD_GET_FOLDERS)) {
+ MODEST_DBUS_IFACE,
+ MODEST_DBUS_METHOD_GET_FOLDERS)) {
on_dbus_method_get_folders (con, message);
handled = TRUE;
- }
- else {
+ } else if (dbus_message_is_method_call (message,
+ MODEST_DBUS_IFACE,
+ MODEST_DBUS_METHOD_DUMP)) {
+ on_dbus_method_dump (con, message);
+ handled = TRUE;
+ } else {
/* Note that this mentions methods that were already handled in modest_dbus_req_handler(). */
/*
g_debug (" debug: %s: Unexpected (maybe already handled) D-Bus method:\n Interface=%s, Member=%s\n",
return found_operations;
}
+
+static void
+accumulate_mail_op_strings (ModestMailOperation *op, gchar **str)
+{
+ *str = g_strdup_printf ("%s\n%s", *str, modest_mail_operation_to_string (op));
+}
+
+
+gchar*
+modest_mail_operation_queue_to_string (ModestMailOperationQueue *self)
+{
+ gchar *str;
+ guint len;
+ ModestMailOperationQueuePrivate *priv;
+
+ g_return_val_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self), NULL);
+
+ priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
+
+ len = g_queue_get_length (priv->op_queue);
+ str = g_strdup_printf ("mail operation queue (%02d)\n-------------------------", len);
+ if (len == 0)
+ str = g_strdup_printf ("%s\n%s", str, "<empty>");
+ else {
+ g_mutex_lock (priv->queue_lock);
+ g_queue_foreach (priv->op_queue, (GFunc)accumulate_mail_op_strings, &str);
+ g_mutex_unlock (priv->queue_lock);
+ }
+
+ return str;
+}
*
* Returns a list with the #ModestMailOperation that have the given source
**/
-GSList*
-modest_mail_operation_queue_get_by_source (ModestMailOperationQueue *op_queue, GObject *source);
+GSList* modest_mail_operation_queue_get_by_source (ModestMailOperationQueue *op_queue, GObject *source);
+
+
+/**
+ * modest_mail_operation_queue_get_by_source:
+ * @op_queue: a #ModestMailOperationQueue
+ *
+ * Returns a string representation of the operation queue (for debugging)
+ *
+ * Returns: a newly allocated string, or NULL in case of error
+ **/
+gchar* modest_mail_operation_queue_to_string (ModestMailOperationQueue *self);
G_END_DECLS