if (auto_update)
/* Do send receive */
- modest_ui_actions_do_send_receive_all (main_win, FALSE);
+ modest_ui_actions_do_send_receive_all (main_win, FALSE, FALSE);
else
/* Disable auto update */
modest_platform_set_update_interval (0);
show_toolbar);
}
-/*
- * Counts the number of remote accounts in a list
- */
-static guint
-num_remote_accounts (TnyList *accounts)
-{
- TnyIterator *iter;
- guint num = 0;
-
- iter = tny_list_create_iterator (accounts);
- while (!tny_iterator_is_done (iter)) {
- TnyAccount *account = (TnyAccount *) tny_iterator_get_current (iter);
- if (modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account)))
- num++;
- tny_iterator_next (iter);
- }
- g_object_unref (iter);
- return num;
-}
-
-
static void
on_account_inserted (TnyAccountStore *accoust_store,
TnyAccount *account,
folders account do now cause menu changes */
if (TNY_IS_STORE_ACCOUNT (account) &&
modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account))) {
- TnyList *list = tny_simple_list_new ();
-
/* Update menus */
update_menus (MODEST_MAIN_WINDOW (user_data));
-
- /* Perform a send&receive if there are more than 1
- remote account , if this is the first remote
- account the folder view will automatically select
- and update it */
- tny_account_store_get_accounts (TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()),
- list, TNY_ACCOUNT_STORE_STORE_ACCOUNTS);
- if (num_remote_accounts (list) > 1) {
- const gchar *account_name =
- modest_tny_account_get_parent_modest_account_name_for_server_account (account);
- modest_ui_actions_do_send_receive (account_name, FALSE, MODEST_WINDOW (user_data));
- }
-
- g_object_unref (list);
}
}
/* If account_name == NULL, we must update all (option All) */
if (!account_name)
- modest_ui_actions_do_send_receive_all (win, TRUE);
+ modest_ui_actions_do_send_receive_all (win, TRUE, TRUE);
else
- modest_ui_actions_do_send_receive (account_name, TRUE, win);
+ modest_ui_actions_do_send_receive (account_name, TRUE, TRUE, win);
}
/* We don't know anything about new usernames: */
if (strcmp (existing_username, username) != 0)
- modest_account_mgr_set_server_account_username_has_succeeded (self, account_name,
- TRUE);
+ modest_account_mgr_set_server_account_username_has_succeeded (self, account_name, FALSE);
g_free (existing_username);
}
succeeded, TRUE /* server account */);
}
-void
-modest_account_mgr_set_server_account_password (ModestAccountMgr *self, const gchar* account_name,
- const gchar* password)
-{
- modest_account_mgr_set_string (self, account_name, MODEST_ACCOUNT_PASSWORD,
- password, TRUE /* server account */);
-}
-
-
gchar*
modest_account_mgr_get_server_account_password (ModestAccountMgr *self, const gchar* account_name)
{
ModestAccountMgr *mgr;
ModestAccountRetrieveType retrieve_type;
TnyList *new_headers = NULL;
- gboolean headers_only, ignore_limit;
+ gboolean headers_only, ignore_limit, succeeded;
TnyTransportAccount *transport_account = NULL;
info = (UpdateAccountInfo *) user_data;
g_ptr_array_foreach (new_headers_array, (GFunc) g_object_unref, NULL);
g_ptr_array_free (new_headers_array, FALSE);
+ if (priv->error)
+ succeeded = FALSE;
+ else
+ succeeded = TRUE;
+ modest_account_mgr_set_server_account_username_has_succeeded (modest_runtime_get_account_mgr (),
+ tny_account_get_name (priv->account),
+ succeeded);
send_mail:
/* Get the transport account */
transport_account = (TnyTransportAccount *)
if (err || canceled) {
/* Try to continue anyway */
- } else {
+ } else if (info->poke_all) {
+ /* We're not getting INBOX children if we don't want to poke all */
TnyIterator *iter = tny_list_create_iterator (list);
while (!tny_iterator_is_done (iter)) {
TnyFolderStore *folder = (TnyFolderStore*) tny_iterator_get_current (iter);
g_return_if_fail(priv!=NULL);
- /* If the folder is remote, set the "Last updated" value */
- if (modest_tny_folder_is_remote_folder (folder)) {
- TnyAccount *account = modest_tny_folder_get_account (folder);
- ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
- const gchar *name;
- name = modest_tny_account_get_parent_modest_account_name_for_server_account (account);
- modest_account_mgr_set_last_updated (mgr, tny_account_get_id (account), time (NULL));
- if (!cancelled && !error)
- modest_account_mgr_set_server_account_username_has_succeeded (mgr, tny_account_get_id (account), TRUE);
- modest_account_mgr_set_account_busy (mgr, name, FALSE);
- g_object_unref (account);
- }
-
if (error) {
priv->error = g_error_copy (error);
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
helper->user_callback = user_callback;
helper->user_data = user_data;
- /* Refresh the folder. TODO: tinymail could issue a status
- updates before the callback call then this could happen. We
- must review the design */
- if (modest_tny_folder_is_remote_folder (folder)) {
- /* If the folder is remote, mark its account as busy */
- const gchar *name;
- name = modest_tny_account_get_parent_modest_account_name_for_server_account (priv->account);
- modest_account_mgr_set_account_busy (modest_runtime_get_account_mgr (), name, TRUE);
- }
modest_mail_operation_notify_start (self);
/* notify that the operation was started */
#include <tny-gtk-lockable.h>
#include <camel/camel.h>
#include <modest-platform.h>
+#include "modest-ui-actions.h"
#ifdef MODEST_PLATFORM_MAEMO
#include <tny-maemo-conic-device.h>
static void add_connection_specific_transport_accounts (ModestTnyAccountStore *self);
+static void connection_status_changed (TnyAccount *account,
+ TnyConnectionStatus status,
+ gpointer data);
+
/* list my signals */
enum {
ACCOUNT_CHANGED_SIGNAL,
modest_account_mgr_free_account_names (account_names);
}
+static void
+connection_status_changed (TnyAccount *account,
+ TnyConnectionStatus status,
+ gpointer data)
+{
+ if (status == TNY_CONNECTION_STATUS_CONNECTED) {
+ const gchar *account_name;
+ ModestWindow *main_window;
+ ModestTnyAccountStorePrivate *priv = NULL;
+
+ priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (data);
+
+ /* Remove this handler */
+ priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
+ G_OBJECT (account),
+ "connection_status_changed");
+
+ /* Set the username as succedded */
+ modest_account_mgr_set_server_account_username_has_succeeded (modest_runtime_get_account_mgr (),
+ tny_account_get_id (account),
+ TRUE);
+
+ /* 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, main_window);
+ }
+}
+
static TnyAccount*
create_tny_account (ModestTnyAccountStore *self,
const gchar *name,
we use a new account if any */
modest_tny_account_store_forget_password_in_memory (self,
tny_account_get_id (account));
+
+ /* Install a signal handler that will refresh the
+ account the first time it becomes online */
+ priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+ G_OBJECT (account),
+ "connection_status_changed",
+ G_CALLBACK (connection_status_changed),
+ self);
+
/* Set the account store */
g_object_set_data (G_OBJECT(account), "account_store", self);
} else {
self = MODEST_TNY_ACCOUNT_STORE (user_data);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
+ /* Remove the connection-status-changed handler if it's still there */
+ if (modest_signal_mgr_is_connected (priv->sighandlers,
+ G_OBJECT (account),
+ "connection_status_changed")) {
+ priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
+ G_OBJECT (account),
+ "connection_status_changed");
+ }
+
/* Remove it from the list of accounts */
if (TNY_IS_STORE_ACCOUNT (account))
tny_list_remove (priv->store_accounts, (GObject *) account);
TnyGetPassFunc get_pass_func,
TnyForgetPassFunc forget_pass_func);
-#if 0
-/**
- * modest_tny_account_new_from_server_account_name:
- * @tny_account: a valid tny account
- * @account_mgr: a valid account mgr instance
- * @server_account_name: the name of a server account in the configuration system.
- *
- * update the given tny account; note that you cannot change the protocol type
- *
- * Returns: a new TnyAccount or NULL in case of error.
- */
-gboolean modest_tny_account_update_from_server_account_name (TnyAccount *tny_account,
- ModestAccountMgr *account_mgr,
- const gchar *server_account_name);
-#endif
-
/**
* modest_tny_account_get_special_folder:
* @self: a TnyAccount
TnyAccount *account;
ModestWindow *win;
gchar *account_name;
+ gboolean poke_status;
} SendReceiveInfo;
static void
/* Send & receive. */
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
- modest_mail_operation_update_account (mail_op, info->account_name, (info->win) ? FALSE : TRUE,
+ modest_mail_operation_update_account (mail_op, info->account_name, info->poke_status,
(info->win) ? retrieve_all_messages_cb : NULL,
new_messages_arrived, info->win);
g_object_unref (G_OBJECT (mail_op));
void
modest_ui_actions_do_send_receive (const gchar *account_name,
gboolean force_connection,
+ gboolean poke_status,
ModestWindow *win)
{
gchar *acc_name = NULL;
info = g_slice_new (SendReceiveInfo);
info->account_name = acc_name;
info->win = (win) ? g_object_ref (win) : NULL;
+ info->poke_status = poke_status;
info->account = modest_tny_account_store_get_server_account (acc_store, acc_name,
TNY_ACCOUNT_TYPE_STORE);
*/
void
modest_ui_actions_do_send_receive_all (ModestWindow *win,
- gboolean force_connection)
+ gboolean force_connection,
+ gboolean poke_status)
{
GSList *account_names, *iter;
iter = account_names;
while (iter) {
- modest_ui_actions_do_send_receive ((const char*) iter->data, force_connection, win);
+ modest_ui_actions_do_send_receive ((const char*) iter->data,
+ force_connection,
+ poke_status, win);
iter = g_slist_next (iter);
}
g_object_unref (folder_store);
}
- /* Refresh the active account. Force the connection if needed */
- modest_ui_actions_do_send_receive (NULL, TRUE, win);
+ /* Refresh the active account. Force the connection if needed
+ and poke the status of all folders */
+ modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, win);
}
/**
* modest_ui_actions_do_send_receive_all:
* @win: the window that will be used as source of the refresh mail operation
+ * @force_connection: whether or not the code should try to force a new connection if we're offline
+ * @poke_status: wheter ot not we want to poke the status of all mail folders
*
* Refreshes all the accounts
**/
void modest_ui_actions_do_send_receive_all (ModestWindow *win,
- gboolean force_connection);
+ gboolean force_connection,
+ gboolean poke_status);
/**
* modest_ui_actions_do_send_receive:
* @account_name: the name of the Modest account or NULL
+ * @force_connection: whether or not the code should try to force a new connection if we're offline
+ * @poke_status: wheter ot not we want to poke the status of all mail folders
* @win: the window that will be used as source of the refresh mail operation
*
* Refreshes the Modest account whose name is passed as argument. If
**/
void modest_ui_actions_do_send_receive (const gchar *account_name,
gboolean force_connection,
+ gboolean poke_status,
ModestWindow *win);
/**