2007-06-26 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Tue, 26 Jun 2007 12:31:38 +0000 (12:31 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Tue, 26 Jun 2007 12:31:38 +0000 (12:31 +0000)
* src/dbus_api/modest-dbus-callbacks.c: (on_idle_mail_to),
(on_idle_compose_mail), (on_compose_mail), (on_idle_open_message),
(on_idle_send_receive), (on_idle_open_default_inbox):
* src/maemo/modest-msg-edit-window.c:
(modest_msg_edit_window_attach_file_noninteractive):
Use gdk_threads_enter() and gdk_threads_leave() in all the idle handlers,
to prevent a hang. I don't quite understand why these are necessary,
beause we should already be in the main loop. I guess something outside
of the main loop is taking the lock.

* tests/dbus_api/test_compose_mail.c: (main): Use file:// prefixes so
we are really using URIs, and use files that are more likely to exist.

pmo-trunk-r2427

ChangeLog2
src/dbus_api/modest-dbus-callbacks.c
src/maemo/modest-msg-edit-window.c
tests/dbus_api/test_compose_mail.c

index d361f87..e024e2f 100644 (file)
@@ -1,5 +1,20 @@
 2007-06-26  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/dbus_api/modest-dbus-callbacks.c: (on_idle_mail_to),
+       (on_idle_compose_mail), (on_compose_mail), (on_idle_open_message),
+       (on_idle_send_receive), (on_idle_open_default_inbox):
+       * src/maemo/modest-msg-edit-window.c:
+       (modest_msg_edit_window_attach_file_noninteractive):
+       Use gdk_threads_enter() and gdk_threads_leave() in all the idle handlers, 
+       to prevent a hang. I don't quite understand why these are necessary, 
+       beause we should already be in the main loop. I guess something outside 
+       of the main loop is taking the lock.
+       
+       * tests/dbus_api/test_compose_mail.c: (main): Use file:// prefixes so 
+       we are really using URIs, and use files that are more likely to exist.
+
+2007-06-26  Murray Cumming  <murrayc@murrayc.com>
+
        * tests/dbus_api/Makefile.am: Fix the build of the tests. This was 
        necessary because configure.ac now defines different variables.
 
index d783567..2032a2e 100644 (file)
@@ -185,6 +185,8 @@ static gchar* uri_parse_mailto (const gchar* mailto, GSList** list_items_and_val
 static gboolean
 on_idle_mail_to(gpointer user_data)
 {
+       gdk_threads_enter();
+       
        /* This is based on the implemenation of main.c:start_uil(): */
        
        gchar *uri = (gchar*)user_data;
@@ -283,6 +285,8 @@ on_idle_mail_to(gpointer user_data)
                
        g_free(uri);
 
+       gdk_threads_leave();
+       
        return FALSE; /* Do not call this callback again. */
 }
 
@@ -312,6 +316,8 @@ static gint on_mail_to(GArray * arguments, gpointer data, osso_rpc_t * retval)
 static gboolean
 on_idle_compose_mail(gpointer user_data)
 {
+       gdk_threads_enter();
+       
        ComposeMailIdleData *idle_data = (ComposeMailIdleData*)user_data;
        gchar **list = NULL;
        gint i = 0;
@@ -387,13 +393,14 @@ on_idle_compose_mail(gpointer user_data)
        g_free (idle_data);
        
        g_free (account_name);
+       
+       gdk_threads_leave();
+       
        return FALSE; /* Do not call this callback again. */
 }
 
 static gint on_compose_mail(GArray * arguments, gpointer data, osso_rpc_t * retval)
 {
-
-       
        if (arguments->len != MODEST_DEBUS_COMPOSE_MAIL_ARGS_COUNT)
        return OSSO_ERROR;
        
@@ -501,6 +508,8 @@ out:
 static gboolean
 on_idle_open_message (gpointer user_data)
 {
+       gdk_threads_enter();
+       
        ModestWindow *msg_view;
        TnyMsg       *msg;
        TnyAccount   *account;
@@ -517,6 +526,7 @@ on_idle_open_message (gpointer user_data)
 
        if (msg == NULL) {
                g_debug ("  %s: message not found.", __FUNCTION__);
+               gdk_threads_leave();
                return FALSE;
        }
        g_debug ("  %s: Found message.", __FUNCTION__);
@@ -535,6 +545,8 @@ on_idle_open_message (gpointer user_data)
        g_object_unref (header);
        g_object_unref (account);
        
+       gdk_threads_leave();
+       
        return FALSE; /* Do not call this callback again. */
 }
 
@@ -659,6 +671,7 @@ on_delete_message (GArray *arguments, gpointer data, osso_rpc_t *retval)
 static gboolean
 on_idle_send_receive(gpointer user_data)
 {
+       gdk_threads_enter();
        ModestWindow *win;
 
        /* Pick the main window if it exists */
@@ -668,6 +681,8 @@ on_idle_send_receive(gpointer user_data)
        /* TODO: check the auto-update parameter in the configuration */
        modest_ui_actions_do_send_receive_all (win);
        
+       gdk_threads_leave();
+       
        return FALSE; /* Do not call this callback again. */
 }
 
@@ -688,6 +703,8 @@ static gint on_send_receive(GArray * arguments, gpointer data, osso_rpc_t * retv
 static gboolean
 on_idle_open_default_inbox(gpointer user_data)
 {
+       gdk_threads_enter();
+       
        ModestWindow *win = 
                modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
 
@@ -697,6 +714,8 @@ on_idle_open_default_inbox(gpointer user_data)
        modest_folder_view_select_first_inbox_or_local (
                MODEST_FOLDER_VIEW (folder_view));
        
+       gdk_threads_leave();
+       
        return FALSE; /* Do not call this callback again. */
 }
 
index 1365ded..bc18a13 100644 (file)
@@ -1611,7 +1611,7 @@ modest_msg_edit_window_attach_file_noninteractive (
        
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
 
-       if (file_uri) {
+       if (file_uri && strlen(file_uri)) {
                gint file_id = 0;
                
                /* TODO: We should probably try to use only the URI,
@@ -1619,7 +1619,7 @@ modest_msg_edit_window_attach_file_noninteractive (
                 */
                gchar* filename = g_filename_from_uri (file_uri, NULL, NULL);
                if (!filename) {
-                       g_warning("%s: g_filename_from_uri(%s) failed.\n", __FUNCTION__, file_uri);
+                       g_warning("%s: g_filename_from_uri('%s') failed.\n", __FUNCTION__, file_uri);
                }
 
                file_id = g_open (filename, O_RDONLY, 0);
index 6751aa1..9d3d88c 100644 (file)
@@ -18,7 +18,7 @@ int main(int argc, char *argv[])
        
        /* Call the function in libmodest-dbus-client: */
        
-       attachments = g_slist_append(attachments, "/usr/include/math.h,/usr/include/malloc.h");
+       attachments = g_slist_append(attachments, "file:///usr/include/math.h,file:///usr/include/glib-2.0/glib.h");
        
        const gboolean ret = libmodest_dbus_client_compose_mail (
                osso_context,