+2007-06-17 Johannes Schmid <johannes.schmid@openismus.com>
+
+ * configure.ac:
+ Fixed build with hildon < 0.99
+
+ * src/maemo/modest-account-view-window.c: (on_edit_button_clicked):
+ Check if the selected account is busy instead of checking all accounts
+
+ * src/modest-account-mgr-priv.h:
+ * src/modest-account-mgr.c: (modest_account_mgr_class_init),
+ (modest_account_mgr_init), (compare_account_name),
+ (modest_account_mgr_set_account_busy),
+ (modest_account_mgr_account_is_busy):
+ * src/modest-account-mgr.h:
+ Added busy information to the account manager. It possible to
+ set an account to busy or not busy now.
+
+ * src/modest-mail-operation.c: (modest_mail_operation_finalize),
+ (modest_mail_operation_update_account),
+ (modest_mail_operation_notify_end):
+ Set the account to busy/not busy depending on the operation state.
+
+ * src/widgets/modest-account-view.c:
+ (modest_account_view_finalize), (get_last_updated_string),
+ (update_account_view), (on_account_busy_changed), (init_view):
+ Show string "Refreshing..." if the account is currently busy.
+
+ All this fixes projects.maemo.org bug NB#59711
+
2007-06-14 Armin Burgmeier <armin@openismus.com>
* src/widgets/modest-attachments-view.h:
Show an comfirmation dialog for the smpt-edit-window if there are
unsaved changes and the user hits cancel.
- (projects.maemo.org but NB#60479
+ (projects.maemo.org bug NB#60479)
2007-06-14 Armin Burgmeier <armin@openismus.com>
PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-1 libosso libhildonmime osso-addressbook-1.0 wpeditor hildon-help libebook-1.2 libalarm hildon-notify libnotify)
else # the old hildon
- PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-libs >= 0.12.0 libosso libossomime libossohelp osso-addressbook-1.0 libwpeditor-plus libebook-1.2 libalarm gnome-vfs-module-2.0)
- AC_DEFINE_UNQUOTED(MODEST_HILDON_VERSION_0, 1, ["The Hildon version we support."])
+ PKG_CHECK_MODULES(MODEST_LIBTINYMAIL_MAEMO, conic libtinymail-maemo-1.0 hildon-libs >= 0.12.0 libosso libossomime libossohelp osso-addressbook-1.0 libwpeditor-plus libebook-1.2 libalarm gnome-vfs-module-2.0 hildon-notify libnotify) AC_DEFINE_UNQUOTED(MODEST_HILDON_VERSION_0, 1, ["The Hildon version we support."])
fi
AC_SUBST(MODEST_LIBTINYMAIL_MAEMO_CFLAGS)
/* Check whether any connections are active, and cancel them if
* the user wishes.
- * TODO: Check only for connections with this account, instead of all.
- * Maybe we need a queue per account.
*/
- ModestMailOperationQueue* queue = modest_runtime_get_mail_operation_queue ();
- if (modest_mail_operation_queue_num_elements(queue)) {
+ ModestAccountMgr* mgr = modest_runtime_get_account_mgr ();
+ ModestMailOperationQueue* queue = modest_runtime_get_mail_operation_queue();
+ if (modest_account_mgr_account_is_busy(mgr, account_name)) {
GtkWidget *note = hildon_note_new_confirmation (GTK_WINDOW (self),
_("emev_nc_disconnect_account"));
const int response = gtk_dialog_run (GTK_DIALOG(note));
gtk_widget_destroy (note);
if (response == GTK_RESPONSE_OK) {
+ /* FIXME: We should only cancel those of this account */
modest_mail_operation_queue_cancel_all(queue);
}
else
GSList *changed_conf_keys;
guint timeout;
gulong key_changed_handler_uid;
+ GSList* busy_accounts;
};
#define MODEST_ACCOUNT_MGR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
enum {
ACCOUNT_CHANGED_SIGNAL,
ACCOUNT_REMOVED_SIGNAL,
+ ACCOUNT_BUSY_SIGNAL,
LAST_SIGNAL
};
NULL, NULL,
modest_marshal_VOID__STRING_POINTER_BOOLEAN,
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
+ signals[ACCOUNT_BUSY_SIGNAL] =
+ g_signal_new ("account_busy_changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(ModestAccountMgrClass,account_busy_changed),
+ NULL, NULL,
+ modest_marshal_VOID__STRING_BOOLEAN,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
}
MODEST_ACCOUNT_MGR_GET_PRIVATE (obj);
priv->modest_conf = NULL;
+ priv->busy_accounts = NULL;
priv->timeout = g_timeout_add (1000 /* milliseconds */, on_timeout_notify_changes, obj);
}
return accounts_exist;
}
+
+static int
+compare_account_name(gconstpointer a, gconstpointer b)
+{
+ const gchar* account_name = (const gchar*) a;
+ const gchar* account_name2 = (const gchar*) b;
+ return strcmp(account_name, account_name2);
+}
+
+void
+modest_account_mgr_set_account_busy(ModestAccountMgr* self, const gchar* account_name,
+ gboolean busy)
+{
+ ModestAccountMgrPrivate* priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ if (busy)
+ {
+ GSList *account_names = modest_account_mgr_account_names (self,
+ TRUE);
+ GSList* account =
+ g_slist_find_custom(account_names, account_name, (GCompareFunc) compare_account_name);
+ if (account && !modest_account_mgr_account_is_busy(self, account_name))
+ {
+ priv->busy_accounts = g_slist_append(priv->busy_accounts, g_strdup(account_name));
+ g_signal_emit_by_name(G_OBJECT(self), "account-busy-changed", account_name, TRUE);
+ }
+ g_slist_free(account_names);
+ }
+ else
+ {
+ GSList* account =
+ g_slist_find_custom(priv->busy_accounts, account_name, (GCompareFunc) compare_account_name);
+ if (account)
+ {
+ g_free(account->data);
+ priv->busy_accounts = g_slist_delete_link(priv->busy_accounts, account);
+ g_signal_emit_by_name(G_OBJECT(self), "account-busy-changed", account_name, FALSE);
+ }
+ }
+}
+
+gboolean
+modest_account_mgr_account_is_busy(ModestAccountMgr* self, const gchar* account_name)
+{
+ ModestAccountMgrPrivate* priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ return (g_slist_find_custom(priv->busy_accounts, account_name, (GCompareFunc) compare_account_name)
+ != NULL);
+}
+
const GSList* key,
gboolean server_account,
gpointer user_data);
+ void (* account_busy_changed) (ModestAccountMgr *obj,
+ const gchar* account,
+ gboolean busy,
+ gpointer user_data);
+
};
/**
gboolean modest_account_mgr_has_accounts (ModestAccountMgr* self, gboolean enabled);
+/**
+ * modest_account_mgr_set_account_busy
+ * @self: a ModestAccountMgr instance
+ * @account_name: name of the account
+ * @busy: whether to set busy or not busy
+ *
+ * Changes the busy flag of an account
+ *
+ */
+
+void modest_account_mgr_set_account_busy(ModestAccountMgr* self, const gchar* account_name,
+ gboolean busy);
+
+/**
+ * modest_account_mgr_account_is_busy
+ * @self: a ModestAccountMgr instance
+ * @account_name: name of the account
+ *
+ * Returns: If the account is currently busy or not
+ *
+ */
+gboolean
+modest_account_mgr_account_is_busy(ModestAccountMgr* self, const gchar* account_name);
+
+
G_END_DECLS
#endif /* __MODEST_ACCOUNT_MGR_H__ */
typedef struct _ModestMailOperationPrivate ModestMailOperationPrivate;
struct _ModestMailOperationPrivate {
TnyAccount *account;
+ gchar *account_name;
guint done;
guint total;
GObject *source;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(obj);
+
+
if (priv->error) {
g_error_free (priv->error);
priv->error = NULL;
gint max_size;
gint retrieve_limit;
gchar *retrieve_type;
+ gchar *account_name;
} UpdateAccountInfo;
/***** I N T E R N A L F O L D E R O B S E R V E R *****/
state = modest_mail_operation_clone_state (mail_op);
g_signal_emit (G_OBJECT (mail_op), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
g_slice_free (ModestMailOperationState, state);
-
+
return TRUE;
}
ModestMailOperationPrivate *priv = NULL;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(mail_op);
-
+
modest_mail_operation_notify_end (mail_op);
g_object_unref (mail_op);
freed before this idle happens, but the mail operation will
be still alive */
g_idle_add (notify_update_account_queue, g_object_ref (info->mail_op));
-
+
/* Frees */
g_object_unref (query);
g_object_unref (all_folders);
/* printf ("DEBUG: %s: info->retrieve_limit = %d\n", __FUNCTION__, info->retrieve_limit); */
+ /* Set account busy */
+ modest_account_mgr_set_account_busy(mgr, account_name, TRUE);
+ priv->account_name = g_strdup(account_name);
+
thread = g_thread_create (update_account_thread, info, FALSE, NULL);
return TRUE;
modest_mail_operation_notify_end (ModestMailOperation *self)
{
ModestMailOperationState *state;
+ ModestMailOperationPrivate *priv = NULL;
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+
+ /* Set the account back to not busy */
+ if (priv->account_name)
+ {
+ modest_account_mgr_set_account_busy(modest_runtime_get_account_mgr(), priv->account_name,
+ FALSE);
+ g_free(priv->account_name);
+ priv->account_name = NULL;
+ }
+
/* Notify the observers about the mail opertation end */
state = modest_mail_operation_clone_state (self);
g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, state, NULL);
typedef struct _ModestAccountViewPrivate ModestAccountViewPrivate;
struct _ModestAccountViewPrivate {
ModestAccountMgr *account_mgr;
- gulong sig1, sig2;
+ gulong sig1, sig2, sig3;
/* When this is TRUE, we ignore configuration key changes.
* This is useful when making many changes. */
if (priv->sig2)
g_signal_handler_disconnect (priv->account_mgr, priv->sig2);
+ if (priv->sig3)
+ g_signal_handler_disconnect (priv->account_mgr, priv->sig3);
+
g_object_unref (G_OBJECT(priv->account_mgr));
priv->account_mgr = NULL;
}
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
-
+/* Get the string for the last updated time. Result must be g_freed */
+static gchar*
+get_last_updated_string(ModestAccountMgr* account_mgr, ModestAccountData *account_data)
+{
+ /* FIXME: let's assume that 'last update' applies to the store account... */
+ gchar* last_updated_string;
+ time_t last_updated = account_data->store_account->last_updated;
+ if (!modest_account_mgr_account_is_busy(account_mgr, account_data->account_name))
+ {
+ if (last_updated > 0)
+ last_updated_string = modest_text_utils_get_display_date(last_updated);
+ else
+ last_updated_string = g_strdup (_("mcen_va_never"));
+ }
+ else
+ {
+ /* FIXME: There should be a logical name in the UI specs */
+ last_updated_string = g_strdup(_("Refreshing..."));
+ }
+ return last_updated_string;
+}
static void
update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view)
if (account_data->store_account) {
GtkTreeIter iter;
- time_t last_updated;
- gchar *last_updated_string;
- /* FIXME: let's assume that 'last update' applies to the store account... */
- last_updated = account_data->store_account->last_updated;
- if (last_updated > 0)
- last_updated_string = modest_text_utils_get_display_date(last_updated);
- else
- last_updated_string = g_strdup (_("mcen_va_never"));
+ gchar *last_updated_string = get_last_updated_string(account_mgr, account_data);
if (account_data->is_enabled) {
gtk_list_store_insert_with_values (
MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, account_data->display_name,
MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN, account_data->is_enabled,
MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, account_data->is_default,
-
+
MODEST_ACCOUNT_VIEW_PROTO_COLUMN,
modest_protocol_info_get_transport_store_protocol_name (account_data->store_account->proto),
MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string,
-1);
- g_free (last_updated_string);
}
+ g_free (last_updated_string);
}
modest_account_mgr_free_account_data (account_mgr, account_data);
update_account_view (account_mgr, self);
}
+static void
+on_account_busy_changed(ModestAccountMgr *account_mgr, const gchar *account_name,
+ gboolean busy, ModestAccountView *self)
+{
+ GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(self)));
+ GtkTreeIter iter;
+ if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
+ return;
+ do
+ {
+ gchar* cur_name;
+ gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, MODEST_ACCOUNT_VIEW_NAME_COLUMN,
+ &cur_name, -1);
+ if (g_str_equal(cur_name, account_name))
+ {
+ ModestAccountData* account_data =
+ modest_account_mgr_get_account_data (account_mgr, account_name);
+ if (!account_data)
+ return;
+ gchar* last_updated_string = get_last_updated_string(account_mgr, account_data);
+ gtk_list_store_set(model, &iter,
+ MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string,
+ -1);
+ g_free (last_updated_string);
+ modest_account_mgr_free_account_data (account_mgr, account_data);
+ return;
+ }
+ }
+ while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter));
+}
static void
on_account_removed (ModestAccountMgr *account_mgr,
G_CALLBACK(on_account_removed), self);
priv->sig2 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_changed",
G_CALLBACK(on_account_changed), self);
+ priv->sig3 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_busy_changed",
+ G_CALLBACK(on_account_busy_changed), self);
}