X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-easysetup-wizard-dialog.c;h=81322550567cad7063d4d5083a6843ca0ff20e63;hb=28d019df4f60f67426a816fc4da9f8df51784a8d;hp=8c9731ce2f3d85c5414316612edef97b14c9a1b0;hpb=366e77fcfcd44e42ad443802a10ac403056fbe89;p=modest diff --git a/src/hildon2/modest-easysetup-wizard-dialog.c b/src/hildon2/modest-easysetup-wizard-dialog.c index 8c9731c..8132255 100644 --- a/src/hildon2/modest-easysetup-wizard-dialog.c +++ b/src/hildon2/modest-easysetup-wizard-dialog.c @@ -106,7 +106,9 @@ struct _ModestEasysetupWizardDialogPrivate GtkWidget *page_welcome; gboolean check_support_done; guint check_support_show_progress_id; + guint check_support_progress_pulse_id; GtkWidget *check_support_cancel_note; + GtkWidget *check_support_progress; gint pending_check_support; gboolean destroyed; @@ -155,6 +157,7 @@ static void check_support_callback (ModestAccountProtocol *protocol, gpointer userdata); static void check_support_of_protocols (ModestEasysetupWizardDialog *self); static gboolean check_support_show_progress (gpointer userdata); +static gboolean check_support_progress_pulse (gpointer userdata); static gboolean on_delete_event (GtkWidget *widget, @@ -184,6 +187,11 @@ modest_easysetup_wizard_dialog_dispose (GObject *object) priv->check_support_show_progress_id = 0; } + if (priv->check_support_progress_pulse_id > 0) { + g_source_remove (priv->check_support_progress_pulse_id); + priv->check_support_progress_pulse_id = 0; + } + if (G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose) G_OBJECT_CLASS (modest_easysetup_wizard_dialog_parent_class)->dispose (object); } @@ -193,6 +201,26 @@ modest_easysetup_wizard_dialog_finalize (GObject *object) { ModestEasysetupWizardDialog *self = MODEST_EASYSETUP_WIZARD_DIALOG (object); ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self); + ModestProtocolRegistry *registry; + GSList *provider_protos, *node; + + registry = modest_runtime_get_protocol_registry (); + provider_protos = modest_protocol_registry_get_by_tag (registry, + MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS); + + for (node = provider_protos; node != NULL; node = g_slist_next (node)) { + ModestProtocol *proto = MODEST_PROTOCOL (node->data); + + if (!modest_protocol_registry_protocol_type_has_tag (registry, + modest_protocol_get_type_id (proto), + MODEST_PROTOCOL_REGISTRY_STORE_PROTOCOLS)) + continue; + + if (MODEST_ACCOUNT_PROTOCOL (proto)) { + modest_account_protocol_wizard_finished (MODEST_ACCOUNT_PROTOCOL (proto)); + } + } + g_slist_free (provider_protos); if (priv->account_manager) g_object_unref (G_OBJECT (priv->account_manager)); @@ -1439,7 +1467,9 @@ modest_easysetup_wizard_dialog_init (ModestEasysetupWizardDialog *self) /* Initialize fields */ priv->check_support_done = FALSE; priv->check_support_show_progress_id = 0; + priv->check_support_progress_pulse_id = 0; priv->check_support_cancel_note = NULL; + priv->check_support_progress = NULL; priv->pending_check_support = 0; priv->destroyed = FALSE; priv->page_welcome = create_page_welcome (self); @@ -2112,6 +2142,35 @@ modest_easysetup_wizard_dialog_class_init (ModestEasysetupWizardDialogClass *kla base_klass->save = on_save; } +static void +check_username_for_provider (const gchar *provider_id, + const gchar *domain, + gchar **username) +{ + gchar *providers_to_check[] = { "ovi.com", "yahoomailplus.com" }; + gint i; + gboolean found = FALSE; + gchar *old; + + /* Check if the username contains the @hostname, if not then add it */ + if (strchr (*username, '@')) + return; + + /* Check if it's one of the providers to check */ + for (i = 0; i < G_N_ELEMENTS (providers_to_check) && !found; i++) { + if (!g_ascii_strncasecmp (providers_to_check[i], provider_id, strlen (providers_to_check[i]))) + found = TRUE; + } + + if (!found) + return; + + /* Replace the username */ + old = *username; + *username = g_strconcat (*username, "@", domain, NULL); + g_free (old); +} + /** * save_to_settings: * @self: a #ModestEasysetupWizardDialog @@ -2124,7 +2183,8 @@ save_to_settings (ModestEasysetupWizardDialog *self) ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self); guint special_port; gchar *provider_id = NULL; - gchar* display_name; + gchar *alternate_username = NULL; + gchar *display_name; const gchar *username, *password; gchar *store_hostname, *transport_hostname; guint store_port, transport_port; @@ -2198,6 +2258,8 @@ save_to_settings (ModestEasysetupWizardDialog *self) if (provider_id) { ModestProtocolType store_provider_server_type; gboolean store_provider_use_alternate_port; + gchar *domain = NULL; + /* Use presets: */ store_hostname = modest_presets_get_server (priv->presets, provider_id, TRUE /* store */); @@ -2215,6 +2277,17 @@ save_to_settings (ModestEasysetupWizardDialog *self) provider_id, TRUE /* store */); + + /* This is HORRIBLE, but it seems that somehow it helps users + that do not like to read the user instructions for their + email accounts */ + domain = modest_presets_get_domain (priv->presets, provider_id); + if (domain) { + alternate_username = g_strdup (username); + check_username_for_provider (provider_id, domain, &alternate_username); + g_free (domain); + } + /* We don't check for SMTP here as that is impossible for an incoming server. */ if (store_provider_server_type == MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) store_protocol = MODEST_PROTOCOLS_STORE_POP; @@ -2252,7 +2325,7 @@ save_to_settings (ModestEasysetupWizardDialog *self) /* now we store the common store account settings */ modest_server_account_settings_set_hostname (store_settings, store_hostname); - modest_server_account_settings_set_username (store_settings, username); + modest_server_account_settings_set_username (store_settings, (alternate_username) ? alternate_username : username); modest_server_account_settings_set_password (store_settings, password); modest_server_account_settings_set_protocol (store_settings, store_protocol); @@ -2338,12 +2411,14 @@ save_to_settings (ModestEasysetupWizardDialog *self) /* now we store the common transport account settings */ modest_server_account_settings_set_hostname (transport_settings, transport_hostname); - modest_server_account_settings_set_username (transport_settings, username); + modest_server_account_settings_set_username (transport_settings, (alternate_username) ? alternate_username : username); modest_server_account_settings_set_password (transport_settings, password); modest_server_account_settings_set_protocol (transport_settings, transport_protocol); g_object_unref (transport_settings); g_free (transport_hostname); + if (alternate_username) + g_free (alternate_username); fullname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_name)); email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email)); @@ -2482,6 +2557,22 @@ check_support_show_progress (gpointer userdata) return FALSE; } +static gboolean +check_support_progress_pulse (gpointer userdata) +{ + ModestEasysetupWizardDialog *self = (ModestEasysetupWizardDialog *) userdata; + ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self); + + if (priv->destroyed || priv->check_support_progress == NULL) { + priv->check_support_progress_pulse_id = 0; + return FALSE; + } + + gtk_progress_bar_pulse (GTK_PROGRESS_BAR (priv->check_support_progress)); + + return TRUE; +} + static void check_support_callback (ModestAccountProtocol *protocol, gboolean supported, @@ -2503,6 +2594,7 @@ check_support_callback (ModestAccountProtocol *protocol, if (priv->check_support_cancel_note) { gtk_widget_destroy (priv->check_support_cancel_note); priv->check_support_cancel_note = NULL; + priv->check_support_progress = NULL; } if (!priv->destroyed) { @@ -2555,19 +2647,21 @@ on_check_support_cancel (GtkDialog *cancel_note, gtk_widget_destroy (GTK_WIDGET (cancel_note)); priv->check_support_cancel_note = NULL; + priv->check_support_progress = NULL; } static void check_support_of_protocols (ModestEasysetupWizardDialog *self) { ModestProtocolRegistry *registry; - GSList *provider_protos, *node; + GSList *provider_protos, *node, *check_support_providers; ModestEasysetupWizardDialogPrivate *priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self); registry = modest_runtime_get_protocol_registry (); provider_protos = modest_protocol_registry_get_by_tag (registry, MODEST_PROTOCOL_REGISTRY_PROVIDER_PROTOCOLS); + check_support_providers = NULL; for (node = provider_protos; node != NULL; node = g_slist_next (node)) { ModestProtocol *proto = MODEST_PROTOCOL (node->data); @@ -2588,20 +2682,31 @@ check_support_of_protocols (ModestEasysetupWizardDialog *self) if (MODEST_ACCOUNT_PROTOCOL (proto)) { priv->pending_check_support ++; - modest_account_protocol_check_support (MODEST_ACCOUNT_PROTOCOL (proto), - check_support_callback, - g_object_ref (self)); + check_support_providers = g_slist_prepend (check_support_providers, proto); } } g_slist_free (provider_protos); + + for (node = check_support_providers; node != NULL; node = g_slist_next (node)) { + ModestProtocol *proto = MODEST_PROTOCOL (node->data); + + modest_account_protocol_check_support (MODEST_ACCOUNT_PROTOCOL (proto), + check_support_callback, + g_object_ref (self)); + } + g_slist_free (check_support_providers); if (priv->pending_check_support > 0) { priv->check_support_show_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 1000, check_support_show_progress, g_object_ref (self), g_object_unref); + priv->check_support_progress_pulse_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 200, + check_support_progress_pulse, + g_object_ref (self), g_object_unref); + priv->check_support_progress = gtk_progress_bar_new (); priv->check_support_cancel_note = hildon_note_new_cancel_with_progress_bar (GTK_WINDOW (self), _("mcen_cn_availability_check"), - NULL); + GTK_PROGRESS_BAR (priv->check_support_progress)); gtk_widget_show (priv->check_support_cancel_note); g_signal_connect (priv->check_support_cancel_note, "response", G_CALLBACK (on_check_support_cancel), self); } else {