* Fixes NB#65999 note that the translation is still not available
authorSergio Villar Senin <svillar@igalia.com>
Wed, 3 Oct 2007 15:31:19 +0000 (15:31 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 3 Oct 2007 15:31:19 +0000 (15:31 +0000)
* Fixes the problem present when creating a new account, the account view was showing the account id of the account instead of the display account
* Now, every account that is added is automatically refreshed

pmo-trunk-r3462

src/maemo/easysetup/modest-easysetup-wizard.c
src/maemo/modest-account-settings-dialog.c
src/maemo/modest-main-window.c
src/modest-account-mgr-helpers.c
src/modest-account-mgr-helpers.h
src/modest-account-mgr.c
src/modest-account-mgr.h
src/modest-mail-operation.c
src/modest-tny-account-store.c
src/modest-ui-actions.c
src/widgets/modest-folder-view.c

index b86f40d..f2d77bc 100644 (file)
@@ -1832,11 +1832,19 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
                return FALSE;   
        }
        
+       const gchar* user_fullname = gtk_entry_get_text (GTK_ENTRY (self->entry_user_name));
+       const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
+       const gchar *retrieve = MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
        
        /* Create the account, which will contain the two "server accounts": */
-       created = modest_account_mgr_add_account (self->account_manager, account_name, 
-                                                 store_name, /* The name of our POP/IMAP server account. */
-                                                 transport_name, /* The name of our SMTP server account. */
+       created = modest_account_mgr_add_account (self->account_manager, 
+                                                 account_name, 
+                                                 display_name,
+                                                 user_fullname,
+                                                 emailaddress,
+                                                 retrieve,
+                                                 store_name,
+                                                 transport_name,
                                                  enabled);
        g_free (store_name);
        g_free (transport_name);
@@ -1855,20 +1863,6 @@ create_account (ModestEasysetupWizardDialog *self, gboolean enabled)
        if(!modest_account_mgr_has_accounts (self->account_manager, FALSE))
                g_warning ("modest_account_mgr_account_names() returned NULL after adding an account.");
                
-       /* The user name and email address must be set additionally: */
-       const gchar* user_name = gtk_entry_get_text (GTK_ENTRY (self->entry_user_name));
-       modest_account_mgr_set_server_account_user_fullname (self->account_manager, account_name, user_name);
-
-       const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (self->entry_user_email));
-       modest_account_mgr_set_server_account_user_email (self->account_manager, account_name, emailaddress); 
-
-       /* Set the display name: */
-       modest_account_mgr_set_display_name (self->account_manager, account_name, display_name);
-
-       /* Set retrieve type */ 
-       const gchar *retrieve = MODEST_ACCOUNT_RETRIEVE_VALUE_HEADERS_ONLY;
-       modest_account_mgr_set_retrieve_type (self->account_manager, account_name, retrieve);
-
        /* Save the connection-specific SMTP server accounts. */
         modest_account_mgr_set_use_connection_specific_smtp(self->account_manager, account_name, 
                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self->checkbox_outgoing_smtp_specific)));
index 64097e8..b5f25c4 100644 (file)
@@ -1458,13 +1458,13 @@ save_configuration (ModestAccountSettingsDialog *dialog)
                
        /* Set the account data from the widgets: */
        const gchar* user_fullname = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_name));
-       modest_account_mgr_set_server_account_user_fullname (dialog->account_manager, 
-                                                            account_name,
-                                                            user_fullname);
+       modest_account_mgr_set_user_fullname (dialog->account_manager, 
+                                             account_name,
+                                             user_fullname);
        
        const gchar* emailaddress = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_email));
-       modest_account_mgr_set_server_account_user_email (dialog->account_manager, account_name,
-                                                         emailaddress);
+       modest_account_mgr_set_user_email (dialog->account_manager, account_name,
+                                          emailaddress);
                
        /* Signature: */
        if (dialog->signature_dialog) {
index 2c20d16..2183f14 100644 (file)
@@ -96,8 +96,7 @@ static void restore_settings (ModestMainWindow *self,
 
 static void save_state (ModestWindow *self);
 
-static void
-update_menus (ModestMainWindow* self);
+static void update_menus (ModestMainWindow* self);
 
 static void modest_main_window_show_toolbar   (ModestWindow *window,
                                               gboolean show_toolbar);
@@ -515,7 +514,7 @@ update_menus (ModestMainWindow* self)
                        }
                        /* We need to call this in order to ensure
                           that the new actions are added in the right
-                          order (alphabetical */
+                          order (alphabetical) */
                        gtk_ui_manager_ensure_update (parent_priv->ui_manager);
                } else 
                        groups = g_list_next (groups);
@@ -545,13 +544,9 @@ update_menus (ModestMainWindow* self)
        priv->view_additions_group = gtk_action_group_new (MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS);
        radio_group = NULL;
        for (i = 0; i < num_accounts; i++) {
-               gchar *display_name = NULL;
-               
+               gchar *display_name = NULL;     
                ModestAccountData *account_data = (ModestAccountData *) g_slist_nth_data (accounts, i);
 
-               /* Create display name. The UI specification specifies a different format string 
-                * to use for the default account, though both seem to be "%s", so 
-                * I don't see what the point is. murrayc. */
                if (default_account && account_data->account_name && 
                        !(strcmp (default_account, account_data->account_name) == 0)) {
                        display_name = g_strdup_printf (_("mcen_me_toolbar_sendreceive_default"), 
index 48c39a1..6cc1282 100644 (file)
@@ -511,8 +511,9 @@ modest_account_mgr_free_server_account_data (ModestAccountMgr *self,
 
 /** You must use modest_account_mgr_free_account_data() on the result.
  */
-ModestAccountData*
-modest_account_mgr_get_account_data     (ModestAccountMgr *self, const gchar* name)
+ModestAccountData *
+modest_account_mgr_get_account_data (ModestAccountMgr *self, 
+                                    const gchar* name)
 {
        ModestAccountData *data;
        gchar *server_account;
@@ -883,9 +884,9 @@ modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
 
 
 void
-modest_account_mgr_set_server_account_user_fullname (ModestAccountMgr *self, 
-                                                    const gchar *account_name,
-                                                    const gchar *fullname)
+modest_account_mgr_set_user_fullname (ModestAccountMgr *self, 
+                                     const gchar *account_name,
+                                     const gchar *fullname)
 {
        modest_account_mgr_set_string (self, 
                                       account_name,
@@ -895,9 +896,9 @@ modest_account_mgr_set_server_account_user_fullname (ModestAccountMgr *self,
 }
 
 void
-modest_account_mgr_set_server_account_user_email (ModestAccountMgr *self, 
-                                                 const gchar *account_name,
-                                                 const gchar *email)
+modest_account_mgr_set_user_email (ModestAccountMgr *self, 
+                                  const gchar *account_name,
+                                  const gchar *email)
 {
        modest_account_mgr_set_string (self, 
                                       account_name,
index c8da096..a7f120c 100644 (file)
@@ -469,13 +469,13 @@ void  modest_account_mgr_set_retrieve_type (ModestAccountMgr *self,
                                            const gchar *account_name,
                                            const gchar *retrieve_type);
 
-void  modest_account_mgr_set_server_account_user_fullname (ModestAccountMgr *self, 
-                                                          const gchar *account_name,
-                                                          const gchar *fullname);
+void  modest_account_mgr_set_user_fullname (ModestAccountMgr *self, 
+                                           const gchar *account_name,
+                                           const gchar *fullname);
 
-void  modest_account_mgr_set_server_account_user_email (ModestAccountMgr *self, 
-                                                       const gchar *account_name,
-                                                       const gchar *email);
+void  modest_account_mgr_set_user_email (ModestAccountMgr *self, 
+                                        const gchar *account_name,
+                                        const gchar *email);
 
 G_END_DECLS
 
index e3de899..d8866b3 100644 (file)
@@ -258,6 +258,10 @@ null_means_empty (const gchar * str)
 gboolean
 modest_account_mgr_add_account (ModestAccountMgr *self,
                                const gchar *name,
+                               const gchar *display_name,
+                               const gchar *user_fullname,
+                               const gchar *user_email,
+                               const gchar *retrieve_type,
                                const gchar *store_account,
                                const gchar *transport_account,
                                gboolean enabled)
@@ -332,6 +336,20 @@ modest_account_mgr_add_account (ModestAccountMgr *self,
        modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_LEAVE_ON_SERVER, TRUE, FALSE);
        modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_ENABLED, enabled,FALSE);
 
+       /* Fill other data */
+       modest_account_mgr_set_string (self, name,
+                                      MODEST_ACCOUNT_DISPLAY_NAME, 
+                                      display_name, FALSE);
+       modest_account_mgr_set_string (self, name,
+                                      MODEST_ACCOUNT_FULLNAME, 
+                                      user_fullname, FALSE);
+       modest_account_mgr_set_string (self, name,
+                                      MODEST_ACCOUNT_EMAIL, 
+                                      user_email, FALSE);
+       modest_account_mgr_set_string (self, name,
+                                      MODEST_ACCOUNT_RETRIEVE, 
+                                      retrieve_type, FALSE);
+
        /* Notify the observers */
        g_signal_emit (self, signals[ACCOUNT_INSERTED_SIGNAL], 0, name);
 
index 1381081..930be49 100644 (file)
@@ -115,7 +115,11 @@ ModestAccountMgr*        modest_account_mgr_new            (ModestConf *modest_c
  * Returns: TRUE if the creation succeeded, FALSE otherwise,
  */
 gboolean        modest_account_mgr_add_account    (ModestAccountMgr *self,
-                                                  const gchar* name,
+                                                  const gchar *name,
+                                                  const gchar *display_name,
+                                                  const gchar *user_fullname,
+                                                  const gchar *user_email,
+                                                  const gchar *retrieve_type,
                                                   const gchar* store_name,
                                                   const gchar* transport_name,
                                                   gboolean enabled);
index 89e369c..95e216d 100644 (file)
@@ -95,7 +95,6 @@ enum _ModestMailOperationSignals
 typedef struct _ModestMailOperationPrivate ModestMailOperationPrivate;
 struct _ModestMailOperationPrivate {
        TnyAccount                *account;
-       gchar                     *account_name;
        guint                      done;
        guint                      total;
        GObject                   *source;
@@ -1410,17 +1409,20 @@ update_account_thread (gpointer thr_user_data)
        priv->total = 0;
        if (priv->account != NULL) 
                g_object_unref (priv->account);
-       priv->account = g_object_ref (info->transport_account);
+
+       if (info->transport_account) {
+               priv->account = g_object_ref (info->transport_account);
        
-       send_queue = modest_runtime_get_send_queue (info->transport_account);
-       if (send_queue) {
-               modest_tny_send_queue_try_to_send (send_queue);
-       } else {
-               g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
-                            MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED,
-                            "cannot create a send queue for %s\n", 
-                            tny_account_get_name (TNY_ACCOUNT (info->transport_account)));
-               priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+               send_queue = modest_runtime_get_send_queue (info->transport_account);
+               if (send_queue) {
+                       modest_tny_send_queue_try_to_send (send_queue);
+               } else {
+                       g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
+                                    MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED,
+                                    "cannot create a send queue for %s\n", 
+                                    tny_account_get_name (TNY_ACCOUNT (info->transport_account)));
+                       priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+               }
        }
        
        /* Check if the operation was a success */
@@ -1435,7 +1437,10 @@ update_account_thread (gpointer thr_user_data)
        }
 
  out:
-
+       /* Set the account back to not busy */
+       modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr(), 
+                                            info->account_name, FALSE);
+       
        if (info->callback) {
                UpdateAccountInfo *idle_info;
 
@@ -1459,7 +1464,9 @@ update_account_thread (gpointer thr_user_data)
        if (all_folders)
                g_object_unref (all_folders);
        g_object_unref (info->account);
-       g_object_unref (info->transport_account);
+       if (info->transport_account)
+               g_object_unref (info->transport_account);
+       g_free (info->account_name);
        g_free (info->retrieve_type);
        g_slice_free (UpdateAccountInfo, info);
 
@@ -1525,6 +1532,7 @@ modest_mail_operation_update_account (ModestMailOperation *self,
        info->account = store_account;
        info->transport_account = transport_account;
        info->callback = callback;
+       info->account_name = g_strdup (account_name);
        info->user_data = user_data;
 
        /* Get the message size limit */
@@ -1548,7 +1556,6 @@ modest_mail_operation_update_account (ModestMailOperation *self,
 
        /* Set account busy */
        modest_account_mgr_set_account_busy(mgr, account_name, TRUE);
-       priv->account_name = g_strdup(account_name);
        
        modest_mail_operation_notify_start (self);
        thread = g_thread_create (update_account_thread, info, FALSE, NULL);
@@ -2858,14 +2865,6 @@ modest_mail_operation_notify_end (ModestMailOperation *self)
 
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
 
-       /* Set the account back to not busy */
-       if (priv->account_name) {
-               modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr(), 
-                                                    priv->account_name, FALSE);
-               g_free(priv->account_name);
-               priv->account_name = NULL;
-       }
-       
        /* Notify the observers about the mail operation end. We do
           not wrapp this emission because we assume that this
           function is always called from within the main lock */
index 9f117c5..41a924b 100644 (file)
@@ -1536,7 +1536,6 @@ add_outbox_from_transport_account_to_global_outbox (ModestTnyAccountStore *self,
        g_object_unref (per_account_outbox);
 }
 
-
 /*
  * This function will be used for both adding new accounts and for the
  * initialization. In the initialization we do not want to emit
@@ -1557,39 +1556,36 @@ insert_account (ModestTnyAccountStore *self,
        store_account = create_tny_account (self, account, TNY_ACCOUNT_TYPE_STORE);
        transport_account = create_tny_account (self, account, TNY_ACCOUNT_TYPE_TRANSPORT);
 
-       /* Add to the list, and notify the observers */
-       if (store_account) {
-               tny_list_append (priv->store_accounts, G_OBJECT (store_account));
-               if (notify)
-                       g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, store_account);
-               g_object_unref (store_account);
-       }
+       g_assert (store_account);
+       g_assert (transport_account);
 
-       /* Add to the list, and notify the observers */
-       if (transport_account) {
-               /* Add account to the list */
-               tny_list_append (priv->transport_accounts, G_OBJECT (transport_account));
-               g_assert (TNY_IS_ACCOUNT (transport_account));
-
-               /* Create a new pseudo-account with an outbox for this
-                  transport account and add it to the global outbox
-                  in the local account */
-               add_outbox_from_transport_account_to_global_outbox (self, account, transport_account);
-
-               if (notify) {
-                       TnyAccount *local_account = NULL;
-
-                       /* Notify that the local account changed */
-                       local_account = modest_tny_account_store_get_local_folders_account (self);
-                       g_signal_emit (G_OBJECT (self), signals [ACCOUNT_CHANGED_SIGNAL], 0, local_account);
-                       g_object_unref (local_account);
-                       
-                       /* Notify the observers about the new account */
-                       g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, transport_account);
-               }
+       /* Add accounts to the lists */
+       tny_list_append (priv->store_accounts, G_OBJECT (store_account));
+       tny_list_append (priv->transport_accounts, G_OBJECT (transport_account));
 
-               g_object_unref (transport_account);
+       /* Create a new pseudo-account with an outbox for this
+          transport account and add it to the global outbox
+          in the local account */
+       add_outbox_from_transport_account_to_global_outbox (self, account, transport_account);
+       
+       /* Notify the observers. We do it after everything is
+          created */
+       if (notify) {
+               TnyAccount *local_account = NULL;
+               
+               /* Notify the observers about the new server & transport accounts */
+               g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, store_account);   
+               g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, transport_account);
+
+               /* Notify that the local account changed */
+               local_account = modest_tny_account_store_get_local_folders_account (self);
+               g_signal_emit (G_OBJECT (self), signals [ACCOUNT_CHANGED_SIGNAL], 0, local_account);
+               g_object_unref (local_account);
        }
+
+       /* Frees */
+       g_object_unref (store_account);
+       g_object_unref (transport_account);
 }
 
 static void
index 08d9e0a..771cc85 100644 (file)
@@ -140,9 +140,8 @@ static void     folder_refreshed_cb    (ModestMailOperation *mail_op,
                                        TnyFolder *folder, 
                                        gpointer user_data);
 
-static void     _on_send_receive_progress_changed (ModestMailOperation  *mail_op, 
-                                                  ModestMailOperationState *state,
-                                                  gpointer user_data);
+static void     on_send_receive_finished (ModestMailOperation  *mail_op, 
+                                         gpointer user_data);
 
 static gint header_list_count_uncached_msgs (TnyList *header_list);
 static gboolean connect_to_get_msg (
@@ -1613,8 +1612,8 @@ modest_ui_actions_do_send_receive (const gchar *account_name, ModestWindow *win)
                                                                 modest_ui_actions_send_receive_error_handler,
                                                                 NULL);
 
-       g_signal_connect (G_OBJECT(mail_op), "progress-changed", 
-                         G_CALLBACK (_on_send_receive_progress_changed), 
+       g_signal_connect (G_OBJECT(mail_op), "operation-finished", 
+                         G_CALLBACK (on_send_receive_finished), 
                          win);
 
        /* Send & receive. */
@@ -4671,16 +4670,11 @@ modest_ui_actions_on_toggle_find_in_page (GtkToggleAction *action,
 }
 
 static void 
-_on_send_receive_progress_changed (ModestMailOperation  *mail_op, 
-                                  ModestMailOperationState *state,
-                                  gpointer user_data)
+on_send_receive_finished (ModestMailOperation  *mail_op, 
+                          gpointer user_data)
 {
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW(user_data));
-
        /* Set send/receive operation finished */       
-       if (state->status != MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS)
-               modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW(user_data));
-       
+       modest_main_window_notify_send_receive_completed (MODEST_MAIN_WINDOW (user_data));      
 }
 
 
index 14657b9..9ae1997 100644 (file)
@@ -56,6 +56,7 @@
 #include <modest-widget-memory.h>
 #include <modest-ui-actions.h>
 #include "modest-dnd.h"
+#include "widgets/modest-window.h"
 
 /* Folder view drag types */
 const GtkTargetEntry folder_view_drag_types[] =
@@ -814,6 +815,22 @@ modest_folder_view_set_account_store (TnyAccountStoreView *self, TnyAccountStore
 }
 
 static void
+on_connection_status_changed (TnyAccount *self, 
+                             TnyConnectionStatus status, 
+                             gpointer user_data)
+{
+       /* If the account becomes online then refresh it */
+       if (status == TNY_CONNECTION_STATUS_CONNECTED) {
+               const gchar *acc_name;
+               GtkWidget *my_window;
+
+               my_window = gtk_widget_get_ancestor (GTK_WIDGET (user_data), MODEST_TYPE_WINDOW);
+               acc_name = modest_tny_account_get_parent_modest_account_name_for_server_account (self);
+               modest_ui_actions_do_send_receive (acc_name, MODEST_WINDOW (my_window));
+       }
+}
+
+static void
 on_account_inserted (TnyAccountStore *account_store, 
                     TnyAccount *account,
                     gpointer user_data)
@@ -844,6 +861,11 @@ on_account_inserted (TnyAccountStore *account_store,
        tny_list_append (TNY_LIST (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model))),
                         G_OBJECT (account));
 
+
+       /* When the store account gets online refresh it */
+       g_signal_connect (account, "connection_status_changed", 
+                         G_CALLBACK (on_connection_status_changed), 
+                         MODEST_FOLDER_VIEW (user_data));
 }