2007-05-22 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Tue, 22 May 2007 08:21:20 +0000 (08:21 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Tue, 22 May 2007 08:21:20 +0000 (08:21 +0000)
* src/gnome/modest-main-window.c:
        (on_account_store_connecting_finished), (connect_signals):
        * src/maemo/modest-main-window.c:
        (on_account_store_connecting_finished), (connect_signals),
        (modest_main_window_new):
        Handle TnyAccountStore::connecting-finished instead of
        TnyDevice::connection-changed, because we cannot actually perform
        operations on accounts until TnyAccountStore has itself responded to
        the TnyDevice::connection-changed signal. This prevents a GError from
        tinymail.
        Do not try to update at startup, because we (at least on scratchbox)
        already do an update at startup when the device goes online.
        This prevents a GError from tinymail.
        * src/modest-ui-actions.c: (modest_ui_actions_do_send_receive):
        Added TODO about stopping simultaneous operations.

pmo-trunk-r1945

ChangeLog2
src/gnome/modest-main-window.c
src/maemo/modest-main-window.c
src/modest-ui-actions.c
src/modest-ui-actions.h

index 02382d4..37c5b08 100644 (file)
@@ -1,3 +1,21 @@
+2007-05-22 Murray Cumming  <murrayc@murrayc.com>
+
+       * src/gnome/modest-main-window.c:
+       (on_account_store_connecting_finished), (connect_signals):
+       * src/maemo/modest-main-window.c:
+       (on_account_store_connecting_finished), (connect_signals),
+       (modest_main_window_new):
+       Handle TnyAccountStore::connecting-finished instead of 
+       TnyDevice::connection-changed, because we cannot actually perform 
+       operations on accounts until TnyAccountStore has itself responded to 
+       the TnyDevice::connection-changed signal. This prevents a GError from 
+       tinymail.
+       Do not try to update at startup, because we (at least on scratchbox) 
+       already do an update at startup when the device goes online. 
+       This prevents a GError from tinymail.
+       * src/modest-ui-actions.c: (modest_ui_actions_do_send_receive): 
+       Added TODO about stopping simultaneous operations.
+
 2007-05-21  Murray Cumming  <murrayc@murrayc.com>
 
        * src/modest-account-mgr.c: (modest_account_mgr_add_account):
 2007-05-21  Murray Cumming  <murrayc@murrayc.com>
 
        * src/modest-account-mgr.c: (modest_account_mgr_add_account):
index c15c39c..00aa551 100644 (file)
@@ -308,8 +308,10 @@ save_sizes (ModestMainWindow *self)
 
 
 static void
 
 
 static void
-on_connection_changed (TnyDevice *device, gboolean online, ModestMainWindow *self)
+on_account_store_connecting_finished (TnyAccountStore *store, ModestMainWindow *self)
 {
 {
+       const gboolean online = TRUE;
+
        GtkWidget *icon;
        const gchar *icon_name;
        ModestMainWindowPrivate *priv;
        GtkWidget *icon;
        const gchar *icon_name;
        ModestMainWindowPrivate *priv;
@@ -332,7 +334,7 @@ on_connection_changed (TnyDevice *device, gboolean online, ModestMainWindow *sel
        
        /* If Modest has became online and the header view has a
           header selected then show it */
        
        /* If Modest has became online and the header view has a
           header selected then show it */
-       /* FIXME: there is a race condition if some account needs to
+       /* TODO: FIXME: there is a race condition if some account needs to
           ask the user for a password */
 
 /*     if (online) { */
           ask the user for a password */
 
 /*     if (online) { */
@@ -421,8 +423,8 @@ connect_signals (ModestMainWindow *self)
                          G_CALLBACK (modest_ui_actions_on_password_requested), self);
        
        /* Device */
                          G_CALLBACK (modest_ui_actions_on_password_requested), self);
        
        /* Device */
-       g_signal_connect (G_OBJECT(modest_runtime_get_device()), "connection_changed",
-                         G_CALLBACK(on_connection_changed), self);
+       g_signal_connect (G_OBJECT(modest_runtime_get_account_store()), "connecting-finished",
+                         G_CALLBACK(on_account_store_connecting_finished), self);
        g_signal_connect (G_OBJECT(priv->online_toggle), "toggled",
                          G_CALLBACK(on_online_toggle_toggled), self);
 
        g_signal_connect (G_OBJECT(priv->online_toggle), "toggled",
                          G_CALLBACK(on_online_toggle_toggled), self);
 
index 5983d5e..f0fe227 100644 (file)
@@ -367,14 +367,12 @@ on_delete_event (GtkWidget *widget, GdkEvent  *event, ModestMainWindow *self)
 
 
 static void
 
 
 static void
-on_connection_changed (TnyDevice *device, gboolean online, ModestMainWindow *self)
+on_account_store_connecting_finished (TnyAccountStore *store, ModestMainWindow *self)
 {
        /* When going online, do the equivalent of pressing the send/receive button, 
         * as per the specification:
         * (without the check for >0 accounts, though that is not specified): */
 {
        /* When going online, do the equivalent of pressing the send/receive button, 
         * as per the specification:
         * (without the check for >0 accounts, though that is not specified): */
-       if (online) {
-               modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (self));
-       }
+       modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (self));
 }
 
 
 }
 
 
@@ -442,10 +440,11 @@ connect_signals (ModestMainWindow *self)
                          G_CALLBACK (modest_ui_actions_on_password_requested), self);
                          
        /* Device */
                          G_CALLBACK (modest_ui_actions_on_password_requested), self);
                          
        /* Device */
-       g_signal_connect (G_OBJECT(modest_runtime_get_device()), "connection_changed",
-                         G_CALLBACK(on_connection_changed), self);
+       g_signal_connect (G_OBJECT(modest_runtime_get_account_store()), "connecting-finished",
+                         G_CALLBACK(on_account_store_connecting_finished), self);
 }
 
 }
 
+#if 0
 /** Idle handler, to send/receive at startup .*/
 gboolean
 sync_accounts_cb (ModestMainWindow *win)
 /** Idle handler, to send/receive at startup .*/
 gboolean
 sync_accounts_cb (ModestMainWindow *win)
@@ -453,6 +452,7 @@ sync_accounts_cb (ModestMainWindow *win)
        modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (win));
        return FALSE; /* Do not call this idle handler again. */
 }
        modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (win));
        return FALSE; /* Do not call this idle handler again. */
 }
+#endif
 
 static void on_hildon_program_is_topmost_notify(GObject *self,
        GParamSpec *propert_param, gpointer user_data)
 
 static void on_hildon_program_is_topmost_notify(GObject *self,
        GParamSpec *propert_param, gpointer user_data)
@@ -625,8 +625,14 @@ modest_main_window_new (void)
        tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
                                                  TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
 
        tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
                                                  TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
 
-       /* do send & receive when we are idle */
-       g_idle_add ((GSourceFunc)sync_accounts_cb, self);
+       /* Do send & receive when we are idle */
+       /* TODO: Enable this again. I have commented it out because, 
+        * at least in scratchbox, this can cause us to start a second 
+        * update (in response to a connection change) when we are already 
+        * doing an update (started here, at startup). Tinymail doesn't like that.
+        * murrayc.
+        */
+       /* g_idle_add ((GSourceFunc)sync_accounts_cb, self); */
        
        HildonProgram *app = hildon_program_get_instance ();
        hildon_program_add_window (app, HILDON_WINDOW (self));
        
        HildonProgram *app = hildon_program_get_instance ();
        hildon_program_add_window (app, HILDON_WINDOW (self));
index 602e512..e61f593 100644 (file)
@@ -865,23 +865,36 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win)
                acc_name = g_strdup (account_name);
        }
 
                acc_name = g_strdup (account_name);
        }
 
-       /* Send & receive. Do not continue if no suitable connection
+       /* Send & receive. */
+       
+       /* Do not continue if no suitable connection
           is open */
           is open */
-       if (check_for_connection (acc_name)) {
-               /* As per the UI spec,
-                * for POP accounts, we should receive,
-                * for IMAP we should synchronize everything, including receiving,
-                * for SMTP we should send,
-                * first receiving, then sending:
-                */
-               /* Create the mail operation */
-               /* TODO: The spec wants us to first do any pending deletions, before receiving. */
-               ModestMailOperation *mail_op;
-               mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE, G_OBJECT(win));
-               modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
-               modest_mail_operation_update_account (mail_op, acc_name);
-               g_object_unref (G_OBJECT (mail_op));
+       if (!check_for_connection (acc_name)) {
+               g_free (acc_name);
+               return;
        }
        }
+       
+       /* TODO: Do not continue if an operation is already in progress:
+        * Maybe there are some operations that tinymail allows to 
+        * happen simulatenously.
+        * TODO: Maybe a simple global gboolean is_updating is enough?
+        * murrayc.
+        */
+       
+       /* As per the UI spec,
+        * for POP accounts, we should receive,
+        * for IMAP we should synchronize everything, including receiving,
+        * for SMTP we should send,
+        * first receiving, then sending:
+        */
+       /* Create the mail operation */
+       /* TODO: The spec wants us to first do any pending deletions, before receiving. */
+       ModestMailOperation *mail_op;
+       mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE, G_OBJECT(win));
+       modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
+       modest_mail_operation_update_account (mail_op, acc_name);
+       g_object_unref (G_OBJECT (mail_op));
+       
        /* Free */
        g_free (acc_name);
 }
        /* Free */
        g_free (acc_name);
 }
index aca1757..0eff091 100644 (file)
@@ -221,8 +221,10 @@ void     modest_ui_actions_on_delete_folder            (GtkAction *action,
 void     modest_ui_actions_on_move_folder_to_trash_folder     (GtkAction *action,
                                                               ModestMainWindow *main_window);
 
 void     modest_ui_actions_on_move_folder_to_trash_folder     (GtkAction *action,
                                                               ModestMainWindow *main_window);
 
+/*
 void     modest_ui_actions_on_connection_changed    (TnyDevice *device, gboolean online,
                                                     ModestMainWindow *main_window);
 void     modest_ui_actions_on_connection_changed    (TnyDevice *device, gboolean online,
                                                     ModestMainWindow *main_window);
+*/
 
 void     modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                                  const gchar* server_account_name,
 
 void     modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
                                                  const gchar* server_account_name,