+ g_return_val_if_fail (error, FALSE);
+
+ if ((error->domain != TNY_ACCOUNT_ERROR)
+ && (error->domain != TNY_ACCOUNT_STORE_ERROR)) {
+ g_warning("modest: %s: Unexpected error domain: != TNY_ACCOUNT_ERROR: %d, message=%s",
+ __FUNCTION__, error->domain, error->message);
+
+ return FALSE;
+ }
+
+ printf("DEBUG: %s: GError code: %d, message=%s\n",
+ __FUNCTION__, error->code, error->message);
+
+ /* Get the server name: */
+ const gchar* server_name = NULL;
+ if (account && TNY_IS_ACCOUNT (account)) {
+ server_name = tny_account_get_hostname (account);
+ printf ("modest: %s: account name = %s, server_name=%s\n", __FUNCTION__,
+ tny_account_get_id (account), server_name);
+ }
+
+ if (!server_name)
+ server_name = _("Unknown Server");
+
+ ModestTransportStoreProtocol proto = MODEST_PROTOCOL_STORE_POP; /* Arbitrary default. */
+ if (account) {
+ const gchar *proto_name = tny_account_get_proto (account);
+ if (proto_name)
+ proto = modest_protocol_info_get_transport_store_protocol (proto_name);
+ else {
+ g_warning("modest: %s: account with id=%s has no proto.\n", __FUNCTION__,
+ tny_account_get_id (account));
+ }
+ }
+
+ /* const gchar *prompt = NULL; */
+ gchar *prompt = NULL;
+ switch (error->code) {
+ case TNY_ACCOUNT_STORE_ERROR_CANCEL_ALERT:
+ case TNY_ACCOUNT_ERROR_TRY_CONNECT_USER_CANCEL:
+ /* Don't show waste the user's time by showing him a dialog telling
+ * him that he has just cancelled something: */
+ g_debug ("%s: Handling GError domain=%d, code=%d (cancelled) without showing a dialog, message=%s",
+ __FUNCTION__, error->domain, error->code, error->message);
+ prompt = NULL;
+ break;
+
+ case TNY_ACCOUNT_ERROR_TRY_CONNECT_HOST_LOOKUP_FAILED:
+ /* TODO: Show the appropriate message, depending on whether it's POP or IMAP: */
+ g_debug ("%s: Handling GError domain=%d, code=%d (lookup failed), message=%s",
+ __FUNCTION__, error->domain, error->code, error->message);
+
+ switch (proto) {
+ case MODEST_PROTOCOL_STORE_POP:
+ prompt = g_strdup_printf (_("emev_ni_ui_pop3_msg_connect_error"), server_name);
+ break;
+ case MODEST_PROTOCOL_STORE_IMAP:
+ prompt = g_strdup_printf (_("emev_ni_ui_imap_connect_server_error"), server_name);
+ break;
+ case MODEST_PROTOCOL_TRANSPORT_SMTP:
+ default: /* Arbitrary default. */
+ prompt = g_strdup_printf (_("emev_ib_ui_smtp_server_invalid"), server_name);
+ break;
+ }
+
+ /*
+ prompt = g_strdup_printf(
+ _("Incorrect Account Settings:\n Host lookup failed.%s"),
+ error->message);
+ */
+ break;
+
+ case TNY_ACCOUNT_ERROR_TRY_CONNECT_AUTHENTICATION_NOT_SUPPORTED:
+ g_debug ("%s: Handling GError domain=%d, code=%d (authentication not supported), message=%s",
+ __FUNCTION__, error->domain, error->code, error->message);
+ /* TODO: This needs a logical ID for the string: */
+ prompt = g_strdup_printf(
+ _("Incorrect Account Settings:\nThe secure authentication method is not supported.\n%s"),
+ error->message);
+ break;
+
+ case TNY_ACCOUNT_ERROR_TRY_CONNECT_CERTIFICATE:
+ g_debug ("%s: Handling GError domain=%d, code=%d (certificatae), message=%s",
+ __FUNCTION__, error->domain, error->code, error->message);
+ prompt = g_strdup_printf(
+ _("Certificate Problem:\n%s"),
+ error->message);
+ break;
+
+ case TNY_ACCOUNT_ERROR_TRY_CONNECT:
+ /* The tinymail camel implementation just sends us this for almost
+ * everything, so we have to guess at the cause.
+ * It could be a wrong password, or inability to resolve a hostname,
+ * or lack of network, or incorrect authentication method, or something entirely different: */
+ /* TODO: Fix camel to provide specific error codes, and then use the
+ * specific dialog messages from Chapter 12 of the UI spec.
+ */
+ case TNY_ACCOUNT_STORE_ERROR_UNKNOWN_ALERT:
+ /* This debug output is useful. Please keep it uncommented until
+ * we have fixed the problems in this function: */
+ g_debug ("%s: Handling GError domain=%d, code=%d, message=%s",
+ __FUNCTION__, error->domain, error->code, error->message);
+
+ /* TODO: Remove the internal error message for the real release.
+ * This is just so the testers can give us more information: */
+ /* prompt = _("Modest account not yet fully configured."); */
+ prompt = g_strdup_printf(
+ "%s\n (Internal error message, often very misleading):\n%s",
+ _("Incorrect Account Settings"),
+ error->message);
+
+ /* Note: If the password was wrong then get_password() would be called again,
+ * instead of this vfunc being called. */
+
+ break;
+