X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-account-settings-dialog.c;h=e50123319a12cfd4be5847e4c407548f1fbaad1e;hb=4094c9fb325b6a9e1bf5d4a91caf0373f7d0831a;hp=444b1348ec0a35fcdf20a318a33f98e77a2f9695;hpb=69014ca6c2411ed39ea44796fc13dfbe891f5ff0;p=modest diff --git a/src/maemo/modest-account-settings-dialog.c b/src/maemo/modest-account-settings-dialog.c index 444b134..e501233 100644 --- a/src/maemo/modest-account-settings-dialog.c +++ b/src/maemo/modest-account-settings-dialog.c @@ -523,6 +523,9 @@ create_page_user_details (ModestAccountSettingsDialog *self) * as required by our UI specification: */ modest_validating_entry_set_unallowed_characters_whitespace ( MODEST_VALIDATING_ENTRY (self->entry_user_username)); + modest_validating_entry_set_func (MODEST_VALIDATING_ENTRY (self->entry_user_username), + modest_maemo_utils_on_entry_invalid_character, + self); /* Set max length as in the UI spec: * The UI spec seems to want us to show a dialog if we hit the maximum. */ @@ -763,8 +766,10 @@ static void on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data) { ModestAccountSettingsDialog *self = MODEST_ACCOUNT_SETTINGS_DIALOG (user_data); + ModestConnectionProtocol protocol_security_incoming; + gint port_number; - const gint port_number = + port_number = modest_serversecurity_combo_box_get_active_serversecurity_port ( MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security)); @@ -772,6 +777,12 @@ on_combo_incoming_security_changed (GtkComboBox *widget, gpointer user_data) hildon_number_editor_set_value ( HILDON_NUMBER_EDITOR (self->entry_incoming_port), port_number); } + + protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity ( + MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security)); + gtk_widget_set_sensitive (self->checkbox_incoming_auth, !modest_protocol_info_is_secure (protocol_security_incoming)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth), modest_protocol_info_is_secure (protocol_security_incoming)); + } @@ -1002,14 +1013,9 @@ check_data (ModestAccountSettingsDialog *self) HILDON_NUMBER_EDITOR (self->entry_incoming_port)); const gchar* username = gtk_entry_get_text (GTK_ENTRY (self->entry_user_username)); - /* const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity ( MODEST_SERVERSECURITY_COMBO_BOX (self->combo_incoming_security)); - */ - /* If we use an encrypted protocol then there is no need to encrypt the password */ - /* I don't think this is a good assumption. It overrides the user's request. murrayc: - * if (!modest_protocol_info_is_secure(protocol_security_incoming)) */ - if (TRUE) + if (!modest_protocol_info_is_secure(protocol_security_incoming)) { if (gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (self->checkbox_incoming_auth))) { @@ -1041,7 +1047,7 @@ check_data (ModestAccountSettingsDialog *self) if(error == NULL || error->domain != modest_utils_get_supported_secure_authentication_error_quark() || error->code != MODEST_UTILS_GET_SUPPORTED_SECURE_AUTHENTICATION_ERROR_CANCELED) hildon_banner_show_information(GTK_WIDGET (self), NULL, - _("Could not discover supported secure authentication methods.")); + _("mcen_ib_unableto_discover_auth_methods")); if(error != NULL) g_error_free(error); @@ -1110,7 +1116,7 @@ on_response (GtkDialog *wizard_dialog, store_settings = modest_account_settings_get_store_settings (self->settings); - transport_settings = modest_account_settings_get_store_settings (self->settings); + transport_settings = modest_account_settings_get_transport_settings (self->settings); store_account_name = modest_server_account_settings_get_account_name (store_settings); transport_account_name = modest_server_account_settings_get_account_name (transport_settings); @@ -1125,7 +1131,8 @@ on_response (GtkDialog *wizard_dialog, g_object_unref (store_settings); g_object_unref (transport_settings); - hildon_banner_show_information(NULL, NULL, _("mcen_ib_advsetup_settings_saved")); + if (!self->save_password) + hildon_banner_show_information(NULL, NULL, _("mcen_ib_advsetup_settings_saved")); } } else { hildon_banner_show_information (NULL, NULL, _("mail_ib_setting_failed")); @@ -1186,6 +1193,7 @@ modest_account_settings_dialog_init (ModestAccountSettingsDialog *self) G_CALLBACK (on_response), self); self->modified = FALSE; + self->save_password = FALSE; /* When this window is shown, hibernation should not be possible, * because there is no sensible way to save the state: */ @@ -1242,8 +1250,7 @@ void modest_account_settings_dialog_set_account (ModestAccountSettingsDialog *di null_means_empty (modest_account_settings_get_fullname (settings))); gtk_entry_set_text( GTK_ENTRY (dialog->entry_user_email), null_means_empty (modest_account_settings_get_email_address (settings))); - modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), - modest_server_account_settings_get_protocol (incoming_account)); + modest_retrieve_combo_box_fill (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), modest_server_account_settings_get_protocol (incoming_account)); modest_retrieve_combo_box_set_active_retrieve_conf (MODEST_RETRIEVE_COMBO_BOX (dialog->combo_retrieve), modest_account_settings_get_retrieve_type (settings)); modest_limit_retrieve_combo_box_set_active_limit_retrieve ( @@ -1298,7 +1305,8 @@ void modest_account_settings_dialog_set_account (ModestAccountSettingsDialog *di const ModestAuthProtocol secure_auth = modest_server_account_settings_get_auth_protocol (incoming_account); dialog->protocol_authentication_incoming = (secure_auth != MODEST_PROTOCOL_AUTH_NONE)? secure_auth:MODEST_PROTOCOL_AUTH_PASSWORD; - if (modest_protocol_info_auth_is_secure(secure_auth)) + ModestConnectionProtocol secure_protocol = modest_server_account_settings_get_security (incoming_account); + if (modest_protocol_info_is_secure (secure_protocol) || modest_protocol_info_auth_is_secure(secure_auth)) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth), TRUE); @@ -1308,6 +1316,8 @@ void modest_account_settings_dialog_set_account (ModestAccountSettingsDialog *di gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (dialog->checkbox_incoming_auth), FALSE); }; + + gtk_widget_set_sensitive (dialog->checkbox_incoming_auth, !modest_protocol_info_is_secure (secure_protocol)); update_incoming_server_title (dialog, dialog->incoming_protocol); @@ -1480,8 +1490,13 @@ save_configuration (ModestAccountSettingsDialog *dialog) const ModestConnectionProtocol protocol_security_incoming = modest_serversecurity_combo_box_get_active_serversecurity ( MODEST_SERVERSECURITY_COMBO_BOX (dialog->combo_incoming_security)); - modest_server_account_settings_set_security (store_settings, protocol_security_incoming); - modest_server_account_settings_set_auth_protocol (store_settings, dialog->protocol_authentication_incoming); + modest_server_account_settings_set_security (store_settings, protocol_security_incoming); + if (modest_protocol_info_is_secure (protocol_security_incoming)) { + modest_server_account_settings_set_auth_protocol (store_settings, FALSE); + } else { + modest_server_account_settings_set_auth_protocol (store_settings, + dialog->protocol_authentication_incoming); + } g_object_unref (store_settings); @@ -1572,10 +1587,10 @@ enable_buttons (ModestAccountSettingsDialog *self) /* The account details title is mandatory: */ if (entry_is_empty(self->entry_account_title)) - enable_ok = FALSE; + enable_ok = FALSE; /* The user details username is mandatory: */ - if (entry_is_empty(self->entry_user_username)) + if (enable_ok && entry_is_empty(self->entry_user_username)) enable_ok = FALSE; /* The user details email address is mandatory: */ @@ -1583,7 +1598,11 @@ enable_buttons (ModestAccountSettingsDialog *self) enable_ok = FALSE; /* The custom incoming server is mandatory: */ - if (entry_is_empty(self->entry_incomingserver)) + if (enable_ok && entry_is_empty(self->entry_incomingserver)) + enable_ok = FALSE; + + /* The custom incoming server is mandatory: */ + if (enable_ok && entry_is_empty(self->entry_outgoingserver)) enable_ok = FALSE; /* Outgoing username is mandatory if outgoing auth is secure */ @@ -1605,6 +1624,52 @@ enable_buttons (ModestAccountSettingsDialog *self) enable_ok); } +void +modest_account_settings_dialog_check_allow_changes (ModestAccountSettingsDialog *self) +{ + ModestServerAccountSettings *incoming_settings; + const gchar *server_account_name; + gboolean username_known; + + if (!G_IS_OBJECT (self->settings)) + return; + + incoming_settings = modest_account_settings_get_store_settings (self->settings); + server_account_name = modest_server_account_settings_get_account_name (incoming_settings); + + username_known = modest_account_mgr_get_server_account_username_has_succeeded (self->account_manager, + server_account_name); + + /* Enable or disable widgets */ + gtk_widget_set_sensitive (self->entry_user_username, !username_known); + gtk_widget_set_sensitive (self->entry_incomingserver, !username_known); + gtk_widget_set_sensitive (self->entry_outgoingserver, !username_known); + gtk_widget_set_sensitive (self->entry_outgoing_username, !username_known); + gtk_widget_set_sensitive (self->entry_incoming_port, !username_known); + gtk_widget_set_sensitive (self->entry_outgoing_port, !username_known); + gtk_widget_set_sensitive (self->combo_incoming_security, !username_known); + gtk_widget_set_sensitive (self->combo_outgoing_security, !username_known); +} + +void +modest_account_settings_dialog_set_modified (ModestAccountSettingsDialog *dialog, gboolean modified) +{ + g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog)); + + dialog->modified = modified; + +} + +void +modest_account_settings_dialog_save_password (ModestAccountSettingsDialog *dialog) +{ + g_return_if_fail (MODEST_IS_ACCOUNT_SETTINGS_DIALOG (dialog)); + + dialog->save_password = TRUE; + dialog->modified = TRUE; +} + + static void modest_account_settings_dialog_class_init (ModestAccountSettingsDialogClass *klass) {