+ /* If it was already asked, it must have been wrong, so ask again */
+ if (already_asked || !pwd || strlen(pwd) == 0) {
+ /* As per the UI spec, if no password was set in the account settings,
+ * ask for it now. But if the password is wrong in the account settings,
+ * then show a banner and the account settings dialog so it can be corrected:
+ */
+ const gboolean settings_have_password =
+ modest_account_mgr_get_server_account_has_password (priv->account_mgr, server_account_name);
+ MODEST_DEBUG_BLOCK(
+ printf ("DEBUG: modest: %s: settings_have_password=%d\n",
+ __FUNCTION__, settings_have_password);
+ );
+ if (settings_have_password) {
+ /* The password must be wrong, so show the account settings dialog so it can be corrected: */
+#ifdef MODEST_PLATFORM_MAEMO
+ show_wrong_password_dialog (account);
+#endif
+
+ if (cancel)
+ *cancel = TRUE;
+
+ return NULL;
+ }
+
+ /* we don't have it yet. Get the password from the user */
+ const gchar* account_id = tny_account_get_id (account);
+ gboolean remember = FALSE;
+ pwd = NULL;
+
+ if (already_asked) {
+ /* Show an info banner, before we show the protected password dialog: */
+ show_password_warning_only();
+ }
+
+ /* Request password */
+ g_signal_emit (G_OBJECT(account_store), signals[PASSWORD_REQUESTED_SIGNAL], 0,
+ account_id, /* server_account_name */
+ &username, &pwd, cancel, &remember);
+
+
+ if (!*cancel) {
+ /* The password will be returned as the result,
+ * but we need to tell tinymail about the username too: */
+ tny_account_set_user (account, username);
+
+ /* Do not save the password in gconf, because
+ * the UI spec says "The password will never
+ * be saved in the account": */
+
+ /* We need to dup the string even knowing that
+ it's already a dup of the contents of an
+ entry, because it if it's wrong, then camel
+ will free it */
+ g_hash_table_insert (priv->password_hash, g_strdup (server_account_name), g_strdup(pwd));
+ } else {
+ g_hash_table_remove (priv->password_hash, server_account_name);
+
+ g_free (pwd);
+ pwd = NULL;
+ }
+
+ g_free (username);
+ username = NULL;
+ } else
+ if (cancel)
+ *cancel = FALSE;
+ return pwd;
+}
+
+void
+modest_tny_account_store_forget_already_asked (ModestTnyAccountStore *self, TnyAccount *account)
+{
+ g_return_if_fail (account);
+
+ ModestTnyAccountStorePrivate *priv;
+ gchar *pwd = NULL;
+ gpointer pwd_ptr = NULL;
+ gboolean already_asked = FALSE;
+
+ const gchar *server_account_name = tny_account_get_id (account);