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;
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,
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);
}
{
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));
/* 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);
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
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;
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 */);
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;
/* 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);
/* 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));
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,
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) {
ModestEasysetupWizardDialog *self)
{
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_protocol_registry_protocol_type_has_tag
+ (registry,
+ modest_protocol_get_type_id (proto),
+ MODEST_PROTOCOL_REGISTRY_SINGLETON_PROVIDER_PROTOCOLS)) {
+ /* Check if there's already an account configured with this account type */
+ if (modest_account_mgr_singleton_protocol_exists (modest_runtime_get_account_mgr (),
+ modest_protocol_get_type_id (proto)))
+ continue;
+ }
+
+ if (MODEST_ACCOUNT_PROTOCOL (proto)) {
+ modest_account_protocol_cancel_check_support (MODEST_ACCOUNT_PROTOCOL (proto));
+ }
+ }
+ g_slist_free (provider_protos);
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);
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 {