+2007-05-22 Murray Cumming <murrayc@murrayc.com>
+
+ * src/gnome/modest-main-window.c:
+ (on_account_store_connecting_finished), (connect_signals):
+ * src/maemo/modest-main-window.c:
+ (on_account_store_connecting_finished), (connect_signals),
+ (modest_main_window_new):
+ Handle TnyAccountStore::connecting-finished instead of
+ TnyDevice::connection-changed, because we cannot actually perform
+ operations on accounts until TnyAccountStore has itself responded to
+ the TnyDevice::connection-changed signal. This prevents a GError from
+ tinymail.
+ Do not try to update at startup, because we (at least on scratchbox)
+ already do an update at startup when the device goes online.
+ This prevents a GError from tinymail.
+ * src/modest-ui-actions.c: (modest_ui_actions_do_send_receive):
+ Added TODO about stopping simultaneous operations.
+
2007-05-21 Murray Cumming <murrayc@murrayc.com>
* src/modest-account-mgr.c: (modest_account_mgr_add_account):
static void
-on_connection_changed (TnyDevice *device, gboolean online, ModestMainWindow *self)
+on_account_store_connecting_finished (TnyAccountStore *store, ModestMainWindow *self)
{
+ const gboolean online = TRUE;
+
GtkWidget *icon;
const gchar *icon_name;
ModestMainWindowPrivate *priv;
/* If Modest has became online and the header view has a
header selected then show it */
- /* FIXME: there is a race condition if some account needs to
+ /* TODO: FIXME: there is a race condition if some account needs to
ask the user for a password */
/* if (online) { */
G_CALLBACK (modest_ui_actions_on_password_requested), self);
/* Device */
- g_signal_connect (G_OBJECT(modest_runtime_get_device()), "connection_changed",
- G_CALLBACK(on_connection_changed), self);
+ g_signal_connect (G_OBJECT(modest_runtime_get_account_store()), "connecting-finished",
+ G_CALLBACK(on_account_store_connecting_finished), self);
g_signal_connect (G_OBJECT(priv->online_toggle), "toggled",
G_CALLBACK(on_online_toggle_toggled), self);
static void
-on_connection_changed (TnyDevice *device, gboolean online, ModestMainWindow *self)
+on_account_store_connecting_finished (TnyAccountStore *store, ModestMainWindow *self)
{
/* When going online, do the equivalent of pressing the send/receive button,
* as per the specification:
* (without the check for >0 accounts, though that is not specified): */
- if (online) {
- modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (self));
- }
+ modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (self));
}
G_CALLBACK (modest_ui_actions_on_password_requested), self);
/* Device */
- g_signal_connect (G_OBJECT(modest_runtime_get_device()), "connection_changed",
- G_CALLBACK(on_connection_changed), self);
+ g_signal_connect (G_OBJECT(modest_runtime_get_account_store()), "connecting-finished",
+ G_CALLBACK(on_account_store_connecting_finished), self);
}
+#if 0
/** Idle handler, to send/receive at startup .*/
gboolean
sync_accounts_cb (ModestMainWindow *win)
modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (win));
return FALSE; /* Do not call this idle handler again. */
}
+#endif
static void on_hildon_program_is_topmost_notify(GObject *self,
GParamSpec *propert_param, gpointer user_data)
tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
- /* do send & receive when we are idle */
- g_idle_add ((GSourceFunc)sync_accounts_cb, self);
+ /* Do send & receive when we are idle */
+ /* TODO: Enable this again. I have commented it out because,
+ * at least in scratchbox, this can cause us to start a second
+ * update (in response to a connection change) when we are already
+ * doing an update (started here, at startup). Tinymail doesn't like that.
+ * murrayc.
+ */
+ /* g_idle_add ((GSourceFunc)sync_accounts_cb, self); */
HildonProgram *app = hildon_program_get_instance ();
hildon_program_add_window (app, HILDON_WINDOW (self));
acc_name = g_strdup (account_name);
}
- /* Send & receive. Do not continue if no suitable connection
+ /* Send & receive. */
+
+ /* Do not continue if no suitable connection
is open */
- if (check_for_connection (acc_name)) {
- /* As per the UI spec,
- * for POP accounts, we should receive,
- * for IMAP we should synchronize everything, including receiving,
- * for SMTP we should send,
- * first receiving, then sending:
- */
- /* Create the mail operation */
- /* TODO: The spec wants us to first do any pending deletions, before receiving. */
- ModestMailOperation *mail_op;
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE, G_OBJECT(win));
- modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
- modest_mail_operation_update_account (mail_op, acc_name);
- g_object_unref (G_OBJECT (mail_op));
+ if (!check_for_connection (acc_name)) {
+ g_free (acc_name);
+ return;
}
+
+ /* TODO: Do not continue if an operation is already in progress:
+ * Maybe there are some operations that tinymail allows to
+ * happen simulatenously.
+ * TODO: Maybe a simple global gboolean is_updating is enough?
+ * murrayc.
+ */
+
+ /* As per the UI spec,
+ * for POP accounts, we should receive,
+ * for IMAP we should synchronize everything, including receiving,
+ * for SMTP we should send,
+ * first receiving, then sending:
+ */
+ /* Create the mail operation */
+ /* TODO: The spec wants us to first do any pending deletions, before receiving. */
+ ModestMailOperation *mail_op;
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE, G_OBJECT(win));
+ modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
+ modest_mail_operation_update_account (mail_op, acc_name);
+ g_object_unref (G_OBJECT (mail_op));
+
/* Free */
g_free (acc_name);
}
void modest_ui_actions_on_move_folder_to_trash_folder (GtkAction *action,
ModestMainWindow *main_window);
+/*
void modest_ui_actions_on_connection_changed (TnyDevice *device, gboolean online,
ModestMainWindow *main_window);
+*/
void modest_ui_actions_on_password_requested (TnyAccountStore *account_store,
const gchar* server_account_name,