2007-05-08 Murray Cumming <murrayc@murrayc.com>
+ * src/modest-defs.h:
+ * src/modest-account-mgr-helpers.h:
+ * src/modest-account-mgr-helpers.c:
+ Added modest_server_account_get_username_has_succeeded(),
+ modest_server_account_set_username_has_succeeded().
+ (modest_server_account_set_username),
+ Reset the has-succeeded flag if the username changes.
+
+ * src/maemo/modest-account-settings-dialog.c: (save_configuration):
+ * src/maemo/modest-connection-specific-smtp-window.c:
+ (modest_connection_specific_smtp_window_save_server_accounts):
+ Use modest_server_account_set_username() instead of using
+ modest_conf_set_string() directly, so that the has-succeeded flag is always
+ reset.
+
+ * src/modest-ui-actions.c:
+ (modest_ui_actions_on_password_requested): Dim the username entry if
+ the username has ever worked, as per the UI spec.
+
+2007-05-08 Murray Cumming <murrayc@murrayc.com>
+
* src/modest-tny-account-store.c: (get_password):
* src/modest-ui-actions.c:
(modest_ui_actions_on_password_requested):
return FALSE;
const gchar* username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_username));
- test = modest_account_mgr_set_string (dialog->account_manager, incoming_account_name,
- MODEST_ACCOUNT_USERNAME, username, TRUE /* server account */);
- if (!test)
- return FALSE;
-
+ modest_server_account_set_username (dialog->account_manager, incoming_account_name, username);
+
const gchar* password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_user_password));
- test = modest_account_mgr_set_string (dialog->account_manager, incoming_account_name,
- MODEST_ACCOUNT_PASSWORD, password, TRUE /* server account */);
- if (!test)
- return FALSE;
+ modest_server_account_set_password (dialog->account_manager, incoming_account_name, password);
const ModestProtocol protocol_authentication_incoming = gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth))
return FALSE;
username = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_username));
- test = modest_account_mgr_set_string (dialog->account_manager, outgoing_account_name,
- MODEST_ACCOUNT_USERNAME, username, TRUE /* server account */);
- if (!test)
- return FALSE;
+ modest_server_account_set_username (dialog->account_manager, outgoing_account_name,
+ username);
password = gtk_entry_get_text (GTK_ENTRY (dialog->entry_outgoing_password));
- test = modest_account_mgr_set_string (dialog->account_manager, outgoing_account_name,
- MODEST_ACCOUNT_PASSWORD, password, TRUE /* server account */);
- if (!test)
- return FALSE;
+ modest_server_account_set_password (dialog->account_manager, outgoing_account_name,
+ password);
const ModestProtocol protocol_security_outgoing = modest_serversecurity_combo_box_get_active_serversecurity (
MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_outgoing_security));
/* Change an existing server account: */
success = modest_account_mgr_set_string (priv->account_manager, server_account_name,
MODEST_ACCOUNT_HOSTNAME, data->hostname, TRUE /* server account */);
+
+ modest_server_account_set_username (priv->account_manager, server_account_name,
+ data->username);
- success = success && modest_account_mgr_set_string (priv->account_manager, server_account_name,
- MODEST_ACCOUNT_USERNAME, data->username, TRUE /* server account */);
-
- success = success && modest_account_mgr_set_string (priv->account_manager, server_account_name,
- MODEST_ACCOUNT_PASSWORD, data->password, TRUE /* server account */);
+ modest_server_account_set_password (priv->account_manager, server_account_name,
+ data->password);
modest_server_account_set_secure_auth (priv->account_manager, server_account_name,
data->secure_auth);
modest_server_account_set_username (ModestAccountMgr *self, const gchar* account_name,
const gchar* username)
{
+ /* Note that this won't work properly as long as the gconf cache is broken
+ * in Maemo Bora: */
+ gchar *existing_username = modest_server_account_get_username(self,
+ account_name);
+
modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_USERNAME,
username, TRUE /* server account */);
+
+ /* We don't know anything about new usernames: */
+ if (strcmp (existing_username, username) != 0)
+ modest_server_account_set_username_has_succeeded (self,
+ account_name, FALSE);
+
+ g_free (existing_username);
+}
+
+gboolean
+modest_server_account_get_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name)
+{
+ return modest_account_mgr_get_bool (self, account_name, MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED,
+ TRUE /* server account */);
+}
+
+void
+modest_server_account_set_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name,
+ gboolean succeeded)
+{
+ modest_account_mgr_set_bool (self, account_name, MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED,
+ succeeded, TRUE /* server account */);
}
void
const gchar* username);
/**
+ * modest_server_account_get_username_has_succeeded:
+ * @self: a ModestAccountMgr instance
+ * @account_name: The name of a server account.
+ *
+ * Whether a connection has ever been successfully made to this account with
+ * the current username. This can be used to avoid asking again for the username
+ * when asking a second time for a non-stored password.
+ *
+ * Returns: TRUE if the username is known to be correct.
+ */
+gboolean
+modest_server_account_get_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name);
+
+/**
+ * modest_server_account_set_username_has_succeeded:
+ * @self: a ModestAccountMgr instance
+ * @account_name: The name of a server account.
+ * @succeeded: Whether the username has succeeded
+ *
+ * Sets whether the username is known to be correct.
+ */
+void
+modest_server_account_set_username_has_succeeded (ModestAccountMgr *self, const gchar* account_name,
+ gboolean succeeded);
+
+/**
* modest_server_account_set_password:
* @self: a ModestAccountMgr instance
* @account_name: The name of a server account.
#define MODEST_ACCOUNT_REMEMBER_PWD "remember_pwd" /* boolean */
#define MODEST_ACCOUNT_HOSTNAME "hostname" /* string */
#define MODEST_ACCOUNT_USERNAME "username" /* string */
+#define MODEST_ACCOUNT_USERNAME_HAS_SUCCEEDED "username_succeeded" /* string */
#define MODEST_ACCOUNT_USE_SIGNATURE "use_signature" /* boolean */
#define MODEST_ACCOUNT_SIGNATURE "signature" /* string */
#define MODEST_ACCOUNT_URI "uri" /* string */
g_return_val_if_fail (error, FALSE);
g_return_val_if_fail (error->domain == TNY_ACCOUNT_ERROR, FALSE);
- printf("DEBUG: %s: error->message=%s\n", __FUNCTION__, error->message);
+ /* printf("DEBUG: %s: error->message=%s\n", __FUNCTION__, error->message); */
GtkMessageType gtktype;
gboolean retval = FALSE;
GtkWidget *entry_username = gtk_entry_new ();
if (initial_username)
gtk_entry_set_text (GTK_ENTRY (entry_username), initial_username);
- /* TODO: Dim this if a connection has ever succeeded with this username,
+ /* Dim this if a connection has ever succeeded with this username,
* as per the UI spec: */
- /* gtk_widget_set_sensitive (entry_username, FALSE); */
+ const gboolean username_known =
+ modest_server_account_get_username_has_succeeded(
+ modest_runtime_get_account_mgr(), server_account_name);
+ gtk_widget_set_sensitive (entry_username, !username_known);
#ifdef MODEST_PLATFORM_MAEMO
/* Auto-capitalization is the default, so let's turn it off: */