#include <tny-camel-transport-account.h>
#include <tny-camel-imap-store-account.h>
#include <tny-camel-pop-store-account.h>
-
+#include "modest-text-utils.h"
#include <modest-runtime.h>
#include <modest-marshal.h>
#include <modest-protocol-registry.h>
TnyConnectionStatus status,
gpointer data);
-static gboolean only_local_accounts (ModestTnyAccountStore *self);
+static inline gboolean only_local_accounts (ModestTnyAccountStore *self);
/* list my signals */
enum {
server_account_name);
/* If the login has ever succeeded then show a specific message */
if (username_known)
- msg = dgettext ("hildon-common-strings", "ecdg_ib_set_password_incorrect");
+ msg = _CS ("ecdg_ib_set_password_incorrect");
else
msg = _("mcen_ib_username_pw_incorrect");
show_password_warning_only (msg);
if (error->code == TNY_SERVICE_ERROR_CERTIFICATE)
retval = modest_platform_run_certificate_confirmation_dialog (server_name,
error->message);
- else if (error->code == TNY_SERVICE_ERROR_AUTHENTICATE) {
+ else if (error->code == TNY_SERVICE_ERROR_AUTHENTICATE ||
+ error->code == TNY_SERVICE_ERROR_CONNECT) {
+
modest_platform_run_information_dialog (NULL, prompt, TRUE);
/* Show the account dialog if it was wrong */
- if (error->code == TNY_SERVICE_ERROR_CONNECT ||
- error->code == TNY_SERVICE_ERROR_AUTHENTICATE)
+ if (error->code == TNY_SERVICE_ERROR_AUTHENTICATE)
show_wrong_password_dialog (account);
retval = TRUE;
runnning */
if (status == TNY_CONNECTION_STATUS_CONNECTED) {
const gchar *account_name;
- ModestWindow *main_window;
+ ModestWindow *top_window;
ModestTnyAccountStorePrivate *priv = NULL;
-
+
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (data);
/* Remove this handler */
/* Perform a send receive */
account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
- main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE);
- modest_ui_actions_do_send_receive (account_name, FALSE, FALSE, TRUE, main_window);
+ top_window = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ());
+ modest_ui_actions_do_send_receive (account_name, FALSE, FALSE, TRUE, top_window);
}
}
g_object_unref (transport_account);
}
-static gboolean
+static inline gboolean
only_local_accounts (ModestTnyAccountStore *self)
{
- ModestTnyAccountStorePrivate *priv = NULL;
- gboolean only_local = TRUE;
- TnyIterator *iter;
-
- /* Check if this is the first remote account we add */
- priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
- iter = tny_list_create_iterator (priv->store_accounts);
-
- while (!tny_iterator_is_done (iter) && only_local) {
- TnyAccount *account = (TnyAccount *) tny_iterator_get_current (iter);
- if (modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account)))
- only_local = FALSE;
- g_object_unref (account);
- tny_iterator_next (iter);
- }
- g_object_unref (iter);
-
- return only_local;
+ return (modest_tny_account_store_get_num_remote_accounts (self) > 0) ? FALSE : TRUE;
}
static void
priv->send_mail_blocked = blocked;
}
+
+static void
+count_remote_accounts (gpointer data, gpointer user_data)
+{
+ TnyFolderStore *account = TNY_FOLDER_STORE (data);
+ gint *count = (gint *) user_data;
+
+ if (modest_tny_folder_store_is_remote (account))
+ (*count)++;
+}
+
+guint
+modest_tny_account_store_get_num_remote_accounts (ModestTnyAccountStore *self)
+{
+ ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
+ gint count = 0;
+
+ /* Count remote accounts */
+ tny_list_foreach (priv->store_accounts, (GFunc) count_remote_accounts, &count);
+
+ return count;
+}