Fixes NB#77038
authorFelipe Erias Morandeira <femorandeira@igalia.com>
Wed, 28 Nov 2007 10:34:49 +0000 (10:34 +0000)
committerFelipe Erias Morandeira <femorandeira@igalia.com>
Wed, 28 Nov 2007 10:34:49 +0000 (10:34 +0000)
* modest/src/modest-mail-operation.c: the "last_updated" field off an account is updated also when there aren't new headers to get
* modest/src/modest-account-mgr.[ch]: added a new signal, "account_updated"
* modest/src/widgets/modest-account-view.c: connected to the former signal to refresh the "last updated" column
* modest/src/maemo/modest-main-window.c: connected to the former signal to refresh the details widget

pmo-trunk-r3833

src/maemo/modest-main-window.c
src/modest-account-mgr.c
src/modest-account-mgr.h
src/modest-mail-operation.c
src/widgets/modest-account-view.c

index 65b175d..cb5196c 100644 (file)
@@ -145,6 +145,9 @@ static void on_show_account_action_toggled      (GtkToggleAction *action,
 static void on_refresh_account_action_activated   (GtkAction *action,
                                                   gpointer user_data);
 
+static void on_account_updated (ModestAccountMgr* mgr, gchar* account_name,
+                    gpointer user_data);
+
 static void on_send_receive_csm_activated         (GtkMenuItem *item,
                                                   gpointer user_data);
 
@@ -967,6 +970,12 @@ connect_signals (ModestMainWindow *self)
                                           G_CALLBACK (on_default_account_changed),
                                           self);
 
+       priv->sighandlers = 
+                       modest_signal_mgr_connect (priv->sighandlers,
+                                                  G_OBJECT (modest_runtime_get_account_mgr ()),
+                                                  "account_updated", 
+                                                  G_CALLBACK (on_account_updated),
+                                                  self);
        /* Account store */
        priv->sighandlers = 
                modest_signal_mgr_connect (priv->sighandlers,
@@ -1478,6 +1487,18 @@ on_account_removed (TnyAccountStore *accoust_store,
        update_menus (MODEST_MAIN_WINDOW (user_data));
 }
 
+static void
+on_account_updated (ModestAccountMgr* mgr,
+                    gchar* account_name,
+                    gpointer user_data)
+{
+       ModestMainWindow *win = MODEST_MAIN_WINDOW (user_data);
+       
+       if (modest_main_window_get_contents_style(win) == MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS) {
+               modest_main_window_set_contents_style (win, MODEST_MAIN_WINDOW_CONTENTS_STYLE_DETAILS);
+       }
+}
+
 /* 
  * This function manages the key events used to navigate between
  * header and folder views (when the window is in split view)
index 4a89001..9b622de 100644 (file)
@@ -56,6 +56,7 @@ enum {
        ACCOUNT_BUSY_SIGNAL,
        DEFAULT_ACCOUNT_CHANGED_SIGNAL,
        DISPLAY_NAME_CHANGED_SIGNAL,
+       ACCOUNT_UPDATED_SIGNAL,
        LAST_SIGNAL
 };
 
@@ -149,6 +150,16 @@ modest_account_mgr_base_init (gpointer g_class)
                                      NULL, NULL,
                                      g_cclosure_marshal_VOID__STRING,
                                      G_TYPE_NONE, 1, G_TYPE_STRING);
+               
+               signals[ACCOUNT_UPDATED_SIGNAL] =
+                       g_signal_new ("account_updated",
+                                     MODEST_TYPE_ACCOUNT_MGR,
+                                     G_SIGNAL_RUN_FIRST,
+                                     G_STRUCT_OFFSET(ModestAccountMgrClass, account_updated),
+                                     NULL, NULL,
+                                     g_cclosure_marshal_VOID__STRING,
+                                     G_TYPE_NONE, 1, G_TYPE_STRING);
+
 
                modest_account_mgr_initialized = TRUE;
        }
@@ -894,7 +905,6 @@ modest_account_mgr_set_int (ModestAccountMgr * self, const gchar * name,
                            const gchar * key, int val, gboolean server_account)
 {
        ModestAccountMgrPrivate *priv;
-
        const gchar *keyname;
        gboolean retval;
        GError *err = NULL;
@@ -912,6 +922,13 @@ modest_account_mgr_set_int (ModestAccountMgr * self, const gchar * name,
                g_printerr ("modest: error setting int '%s': %s\n", keyname, err->message);
                g_error_free (err);
                retval = FALSE;
+       } else {
+               /* check whether this field is one of those interesting for the 
+                * "account-updated" signal */
+               if (strcmp(key, MODEST_ACCOUNT_LAST_UPDATED) == 0) {
+                       g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATED_SIGNAL], 
+                                       0, name);
+               }
        }
        return retval;
 }
index 930be49..3400c76 100644 (file)
@@ -79,6 +79,10 @@ struct _ModestAccountMgrClass {
        void (* display_name_changed)   (ModestAccountMgr *obj, 
                                         const gchar *account,
                                         gpointer user_data);
+       
+       void (* account_updated)   (ModestAccountMgr *obj, 
+                        const gchar *account,
+                        gpointer user_data);
 };
 
 /**
index 1011f09..81afa1a 100644 (file)
@@ -1291,6 +1291,9 @@ inbox_refreshed_cb (TnyFolder *inbox,
        g_object_unref (info->inbox_observer);
        info->inbox_observer = NULL;
 
+       /* Update the last updated key, even if we don't have to get new headers */
+       modest_account_mgr_set_last_updated (mgr, tny_account_get_id (priv->account), time (NULL));
+       
        if (new_headers_array->len == 0)
                goto send_mail;
 
@@ -1350,9 +1353,6 @@ inbox_refreshed_cb (TnyFolder *inbox,
        g_ptr_array_foreach (new_headers_array, (GFunc) g_object_unref, NULL);
        g_ptr_array_free (new_headers_array, FALSE);
 
-       /* Update the last updated key */
-       modest_account_mgr_set_last_updated (mgr, tny_account_get_id (priv->account), time (NULL));
-
  send_mail:
        /* Send mails */
        priv->done = 0;
@@ -1550,9 +1550,9 @@ modest_mail_operation_update_account (ModestMailOperation *self,
 
        /* Get all folders and continue in the callback */    
        folders = tny_simple_list_new ();
-       tny_folder_store_get_folders_async (TNY_FOLDER_STORE (store_account),
-                                           folders, recurse_folders_async_cb, 
-                                           NULL, NULL, info);
+       tny_folder_store_get_folders_async (TNY_FOLDER_STORE (store_account),
+                               folders, recurse_folders_async_cb, 
+                               NULL, NULL, info);
 }
 
 /*
index a5ebda0..04efa36 100644 (file)
@@ -60,6 +60,9 @@ static void on_display_name_changed            (ModestAccountMgr *self,
 
 static void modest_account_view_select_first_account (ModestAccountView *account_view);
 
+static void on_account_updated (ModestAccountMgr* mgr, gchar* account_name,
+                    gpointer user_data);
+
 typedef enum {
        MODEST_ACCOUNT_VIEW_NAME_COLUMN,
        MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN,
@@ -382,6 +385,14 @@ on_account_default_toggled (GtkCellRendererToggle *cell_renderer,
        g_free (account_name);
 }
 
+static void
+on_account_updated (ModestAccountMgr* mgr,
+                    gchar* account_name,
+                    gpointer user_data)
+{
+       update_account_view (mgr, MODEST_ACCOUNT_VIEW (user_data));
+}
+
 void
 bold_if_default_cell_data  (GtkTreeViewColumn *column,  GtkCellRenderer *renderer,
                            GtkTreeModel *tree_model,  GtkTreeIter *iter,  gpointer user_data)
@@ -505,6 +516,12 @@ init_view (ModestAccountView *self)
                                           "display_name_changed",
                                           G_CALLBACK(on_display_name_changed), 
                                           self);
+       priv->sig_handlers = 
+                       modest_signal_mgr_connect (priv->sig_handlers,
+                                                  G_OBJECT (priv->account_mgr),
+                                                  "account_updated", 
+                                                  G_CALLBACK (on_account_updated),
+                                                  self);
 }