* Fixes NB#82632, show the proper error note when the username is dimmed in the...
authorSergio Villar Senin <svillar@igalia.com>
Wed, 2 Apr 2008 17:50:24 +0000 (17:50 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 2 Apr 2008 17:50:24 +0000 (17:50 +0000)
* Set the username as dimmed properly using the connection policy and do not do it in the send&receive method

pmo-trunk-r4364

src/modest-default-connection-policy.c
src/modest-mail-operation.c
src/modest-tny-account-store.c

index 214a3e2..e72d478 100644 (file)
 
 #include <config.h>
 #include <glib.h>
 
 #include <config.h>
 #include <glib.h>
-#include <glib/gi18n-lib.h>
 
 
-#include <modest-default-connection-policy.h>
+#include "modest-default-connection-policy.h"
+#include "modest-account-mgr-helpers.h"
+#include "modest-runtime.h"
 #include <tny-account.h>
 #include <tny-account.h>
+#include <tny-store-account.h>
 
 static GObjectClass *parent_class = NULL;
 
 
 static GObjectClass *parent_class = NULL;
 
@@ -45,6 +47,12 @@ modest_default_connection_policy_set_current (TnyConnectionPolicy *self, TnyAcco
 static void
 modest_default_connection_policy_on_connect (TnyConnectionPolicy *self, TnyAccount *account)
 {
 static void
 modest_default_connection_policy_on_connect (TnyConnectionPolicy *self, TnyAccount *account)
 {
+       /* Set the username as succedded */
+       if (TNY_IS_STORE_ACCOUNT (account))
+               modest_account_mgr_set_server_account_username_has_succeeded (modest_runtime_get_account_mgr (), 
+                                                                             tny_account_get_id (account), 
+                                                                             TRUE);
+
        return;
 }
 
        return;
 }
 
index 4839f04..ff0b2e3 100644 (file)
@@ -1251,7 +1251,7 @@ inbox_refreshed_cb (TnyFolder *inbox,
        ModestAccountMgr *mgr;
        ModestAccountRetrieveType retrieve_type;
        TnyList *new_headers = NULL;
        ModestAccountMgr *mgr;
        ModestAccountRetrieveType retrieve_type;
        TnyList *new_headers = NULL;
-       gboolean headers_only, ignore_limit, succeeded;
+       gboolean headers_only, ignore_limit;
        TnyTransportAccount *transport_account = NULL;
 
        info = (UpdateAccountInfo *) user_data;
        TnyTransportAccount *transport_account = NULL;
 
        info = (UpdateAccountInfo *) user_data;
@@ -1306,8 +1306,6 @@ inbox_refreshed_cb (TnyFolder *inbox,
 
        /* 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));
 
        /* 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 (!canceled && !err) 
-               modest_account_mgr_set_server_account_username_has_succeeded (mgr, tny_account_get_id (priv->account), TRUE);
        
        if (new_headers_array->len == 0)
                goto send_mail;
        
        if (new_headers_array->len == 0)
                goto send_mail;
@@ -1377,13 +1375,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);
 
        g_ptr_array_foreach (new_headers_array, (GFunc) g_object_unref, NULL);
        g_ptr_array_free (new_headers_array, FALSE);
 
-       if (priv->error)
-               succeeded = FALSE;
-       else
-               succeeded = TRUE;
-       modest_account_mgr_set_server_account_username_has_succeeded (modest_runtime_get_account_mgr (), 
-                                                                     tny_account_get_name (priv->account), 
-                                                                     succeeded);
  send_mail:
        /* Get the transport account */
        transport_account = (TnyTransportAccount *)
  send_mail:
        /* Get the transport account */
        transport_account = (TnyTransportAccount *)
index 7a925af..da8e2c4 100644 (file)
@@ -501,17 +501,14 @@ on_account_settings_hide (GtkWidget *widget, gpointer user_data)
 }
 
 static void 
 }
 
 static void 
-show_password_warning_only ()
+show_password_warning_only (const gchar *msg)
 {
        ModestWindow *main_window = 
                modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE); /* don't create */
        
        /* Show an explanatory temporary banner: */
        if (main_window) 
 {
        ModestWindow *main_window = 
                modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE); /* don't create */
        
        /* Show an explanatory temporary banner: */
        if (main_window) 
-               modest_platform_information_banner (NULL, NULL, 
-                                                   _("mcen_ib_username_pw_incorrect"));
-       else
-               g_warning ("%s: %s", __FUNCTION__, _("mcen_ib_username_pw_incorrect"));
+               modest_platform_information_banner (NULL, NULL, msg);
 }
 
 static void 
 }
 
 static void 
@@ -662,8 +659,16 @@ get_password (TnyAccount *account, const gchar * prompt_not_used, gboolean *canc
                pwd = NULL;
                
                if (already_asked) {
                pwd = NULL;
                
                if (already_asked) {
-                       /* Show an info banner, before we show the protected password dialog: */
-                       show_password_warning_only();
+                       const gchar *msg;
+                       gboolean username_known = 
+                               modest_account_mgr_get_server_account_username_has_succeeded(priv->account_mgr, 
+                                                                                            server_account_name);
+                       /* If the login has ever succeeded then show a specific message */
+                       if (username_known)
+                               msg = _("ecdg_ib_set_password_incorrect");
+                       else
+                               msg = _("mcen_ib_username_pw_incorrect");
+                       show_password_warning_only (msg);
                }
 
                /* Request password */
                }
 
                /* Request password */
@@ -1507,6 +1512,10 @@ connection_status_changed (TnyAccount *account,
                           TnyConnectionStatus status, 
                           gpointer data)
 {
                           TnyConnectionStatus status, 
                           gpointer data)
 {
+       /* We do this here and not in the connection policy because we
+          don't want to do it for every account, just for the
+          accounts that are interactively added when modest is
+          runnning */
        if (status == TNY_CONNECTION_STATUS_CONNECTED) {
                const gchar *account_name;
                ModestWindow *main_window;
        if (status == TNY_CONNECTION_STATUS_CONNECTED) {
                const gchar *account_name;
                ModestWindow *main_window;
@@ -1519,11 +1528,6 @@ connection_status_changed (TnyAccount *account,
                                                                  G_OBJECT (account),
                                                                  "connection_status_changed");
 
                                                                  G_OBJECT (account),
                                                                  "connection_status_changed");
 
-               /* Set the username as succedded */
-               modest_account_mgr_set_server_account_username_has_succeeded (modest_runtime_get_account_mgr (), 
-                                                                             tny_account_get_id (account), 
-                                                                             TRUE);
-
                /* Perform a send receive */
                account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
                main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE);
                /* Perform a send receive */
                account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
                main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE);