number of pending operations to be observed.
* Fix bug in replay/forward when mulitple headers are
selected.
* Reply/Forward functions are observed now by MainWindow
progress objects, to get all messages to reply/forward.
* Replay/Forward status_callback implemented.
pmo-trunk-r1744
+static gboolean
+observers_empty (ModestMainWindow *self)
+{
+ GSList *tmp = NULL;
+ ModestMainWindowPrivate *priv;
+ gboolean is_empty = FALSE;
+ guint pending_ops = 0;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+ tmp = priv->progress_widgets;
+ if (tmp == NULL) return TRUE;
+
+ /* Check all observers */
+ while (tmp && !is_empty) {
+ pending_ops = modest_progress_object_num_pending_operations (MODEST_PROGRESS_OBJECT(tmp->data));
+ is_empty = pending_ops == 0;
+
+ tmp = g_slist_next(tmp);
+ }
+
+ return is_empty;
+}
+
static void
on_queue_changed (ModestMailOperationQueue *queue,
ModestMailOperation *mail_op,
static void
on_queue_changed (ModestMailOperationQueue *queue,
ModestMailOperation *mail_op,
}
break;
case MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED:
}
break;
case MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED:
- if (modest_mail_operation_queue_num_elements (queue) == 0)
- set_toolbar_mode (MODEST_MAIN_WINDOW(self), TOOLBAR_MODE_NORMAL);
if (mode == TOOLBAR_MODE_TRANSFER) {
while (tmp) {
modest_progress_object_remove_operation (MODEST_PROGRESS_OBJECT (tmp->data),
mail_op);
tmp = g_slist_next (tmp);
}
if (mode == TOOLBAR_MODE_TRANSFER) {
while (tmp) {
modest_progress_object_remove_operation (MODEST_PROGRESS_OBJECT (tmp->data),
mail_op);
tmp = g_slist_next (tmp);
}
+
+ /* If no more operations are being observed, NORMAL mode is enabled again */
+ if (observers_empty (MODEST_MAIN_WINDOW(self)))
+ set_toolbar_mode (MODEST_MAIN_WINDOW(self), TOOLBAR_MODE_NORMAL);
static void
modest_progress_bar_cancel_current_operation (ModestProgressObject *self);
static void
modest_progress_bar_cancel_current_operation (ModestProgressObject *self);
+static guint
+modest_progress_bar_num_pending_operations (ModestProgressObject *self);
+
static void on_progress_changed (ModestMailOperation *mail_op,
ModestProgressBarWidget *self);
static void on_progress_changed (ModestMailOperation *mail_op,
ModestProgressBarWidget *self);
klass->add_operation_func = modest_progress_bar_add_operation;
klass->remove_operation_func = modest_progress_bar_remove_operation;
klass->cancel_current_operation_func = modest_progress_bar_cancel_current_operation;
klass->add_operation_func = modest_progress_bar_add_operation;
klass->remove_operation_func = modest_progress_bar_remove_operation;
klass->cancel_current_operation_func = modest_progress_bar_cancel_current_operation;
+ klass->num_pending_operations_func = modest_progress_bar_num_pending_operations;
+static guint
+modest_progress_bar_num_pending_operations (ModestProgressObject *self)
+{
+ ModestProgressBarWidget *me;
+ ModestProgressBarWidgetPrivate *priv;
+
+ me = MODEST_PROGRESS_BAR_WIDGET (self);
+ priv = MODEST_PROGRESS_BAR_WIDGET_GET_PRIVATE (me);
+
+ return g_slist_length(priv->observables);
+}
+
static void
modest_progress_bar_cancel_current_operation (ModestProgressObject *self)
{
static void
modest_progress_bar_cancel_current_operation (ModestProgressObject *self)
{
TnyStatus *status,
gpointer user_data);
TnyStatus *status,
gpointer user_data);
+static void update_process_msg_status_cb (GObject *obj,
+ TnyStatus *status,
+ gpointer user_data);
enum _ModestMailOperationSignals
{
enum _ModestMailOperationSignals
{
TnyStatus *status,
gpointer user_data)
{
TnyStatus *status,
gpointer user_data)
{
+ ModestMailOperation *self;
+ ModestMailOperationPrivate *priv;
+
+ g_return_if_fail (status != NULL);
+ g_return_if_fail (status->code == TNY_FOLDER_STATUS_CODE_REFRESH);
+
+ self = MODEST_MAIL_OPERATION (user_data);
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+
+ priv->done = status->position;
+ priv->total = status->of_total;
+
+ if (priv->done == 1 && priv->total == 100)
+ return;
+
+ g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, NULL);
void modest_mail_operation_process_msg (ModestMailOperation *self,
TnyHeader *header,
void modest_mail_operation_process_msg (ModestMailOperation *self,
TnyHeader *header,
TnyGetMsgCallback user_callback,
gpointer user_data)
{
TnyGetMsgCallback user_callback,
gpointer user_data)
{
folder = tny_header_get_folder (header);
priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
folder = tny_header_get_folder (header);
priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
/* Get message from folder */
if (folder) {
/* The callback will call it per each header */
/* Get message from folder */
if (folder) {
/* The callback will call it per each header */
- tny_folder_get_msg_async (folder, header, user_callback, NULL, user_data);
+ tny_folder_get_msg_async (folder, header, user_callback, update_process_msg_status_cb, user_data);
g_object_unref (G_OBJECT (folder));
} else {
/* Set status failed and set an error */
g_object_unref (G_OBJECT (folder));
} else {
/* Set status failed and set an error */
+static void
+update_process_msg_status_cb (GObject *obj,
+ TnyStatus *status,
+ gpointer user_data)
+{
+ ModestMailOperation *self;
+ ModestMailOperationPrivate *priv;
+
+ g_return_if_fail (status != NULL);
+ g_return_if_fail (status->code == TNY_FOLDER_STATUS_CODE_REFRESH);
+
+ self = MODEST_MAIL_OPERATION (user_data);
+ priv = MODEST_MAIL_OPERATION_GET_PRIVATE(self);
+
+ priv->done += status->position;
+
+ if (priv->done == 1 && priv->total == 100)
+ return;
+
+ g_signal_emit (G_OBJECT (self), signals[PROGRESS_CHANGED_SIGNAL], 0, NULL);
+}
+
* modest_mail_operation_process_msg:
* @self: a #ModestMailOperation
* @header: the #TnyHeader of the message to get
* modest_mail_operation_process_msg:
* @self: a #ModestMailOperation
* @header: the #TnyHeader of the message to get
+ * @num_ops: number of times to repeat operation with next header.
+ * @user_callback: a #TnyGetMsgCallback function to call after tinymail operation execution.
+ * @user_data: user data passed to both, user_callback and update_status_callback.
*
* Gets a message and process it using @callback function
* pased as argument. This operation is assynchronous, so the
*
* Gets a message and process it using @callback function
* pased as argument. This operation is assynchronous, so the
**/
void modest_mail_operation_process_msg (ModestMailOperation *self,
TnyHeader *header,
**/
void modest_mail_operation_process_msg (ModestMailOperation *self,
TnyHeader *header,
TnyGetMsgCallback user_callback,
gpointer user_data);
TnyGetMsgCallback user_callback,
gpointer user_data);
return MODEST_PROGRESS_OBJECT_GET_IFACE (self)->cancel_current_operation_func (self);
}
return MODEST_PROGRESS_OBJECT_GET_IFACE (self)->cancel_current_operation_func (self);
}
+guint
+modest_progress_object_num_pending_operations (ModestProgressObject *self)
+{
+ return MODEST_PROGRESS_OBJECT_GET_IFACE (self)->num_pending_operations_func (self);
+}
+
+
static void
modest_progress_object_base_init (gpointer g_class)
{
static void
modest_progress_object_base_init (gpointer g_class)
{
void (*add_operation_func) (ModestProgressObject *self, ModestMailOperation *mail_op);
void (*remove_operation_func) (ModestProgressObject *self, ModestMailOperation *mail_op);
void (*cancel_current_operation_func) (ModestProgressObject *self);
void (*add_operation_func) (ModestProgressObject *self, ModestMailOperation *mail_op);
void (*remove_operation_func) (ModestProgressObject *self, ModestMailOperation *mail_op);
void (*cancel_current_operation_func) (ModestProgressObject *self);
+ guint (*num_pending_operations_func) (ModestProgressObject *self);
};
GType modest_progress_object_get_type (void) G_GNUC_CONST;
};
GType modest_progress_object_get_type (void) G_GNUC_CONST;
ModestMailOperation *mail_op);
void modest_progress_object_cancel_current_operation (ModestProgressObject *self);
ModestMailOperation *mail_op);
void modest_progress_object_cancel_current_operation (ModestProgressObject *self);
+guint modest_progress_object_num_pending_operations (ModestProgressObject *self);
+
G_END_DECLS
#endif /* __MODEST_PROGRESS_OBJECT_H__ */
G_END_DECLS
#endif /* __MODEST_PROGRESS_OBJECT_H__ */
ModestWindow *window;
ModestMailOperation *mail_op;
TnyIterator *iter;
ModestWindow *window;
ModestMailOperation *mail_op;
TnyIterator *iter;
GFunc func;
gpointer user_data;
} GetMsgAsyncHelper;
GFunc func;
gpointer user_data;
} GetMsgAsyncHelper;
if (account)
g_object_unref (G_OBJECT (account));
if (account)
g_object_unref (G_OBJECT (account));
- g_free (rf_helper->account_name);
- g_slice_free (ReplyForwardHelper, rf_helper);
+/* g_free (rf_helper->account_name); */
+/* g_slice_free (ReplyForwardHelper, rf_helper); */
}
/*
* Common code for the reply and forward actions
}
/*
* Common code for the reply and forward actions
helper->func = reply_forward_func;
helper->iter = tny_list_create_iterator (header_list);
helper->user_data = rf_helper;
helper->func = reply_forward_func;
helper->iter = tny_list_create_iterator (header_list);
helper->user_data = rf_helper;
+ helper->num_ops = tny_list_get_length (header_list);
if (MODEST_IS_MSG_VIEW_WINDOW(win)) {
TnyMsg *msg;
if (MODEST_IS_MSG_VIEW_WINDOW(win)) {
TnyMsg *msg;
helper->mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), helper->mail_op);
helper->mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), helper->mail_op);
- modest_mail_operation_process_msg (helper->mail_op, header, get_msg_cb, helper);
+ modest_mail_operation_process_msg (helper->mail_op, header, helper->num_ops, get_msg_cb, helper);
/* Clean */
g_object_unref (G_OBJECT (header));
/* Clean */
g_object_unref (G_OBJECT (header));
- /* Notify the queue (if neccesary) */
- if (helper->mail_op != NULL)
- modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), helper->mail_op);
-
/* Call user function */
if (helper->func)
helper->func (msg, user_data);
/* Call user function */
if (helper->func)
helper->func (msg, user_data);
/* Process next element (if exists) */
tny_iterator_next (helper->iter);
if (tny_iterator_is_done (helper->iter)) {
/* Process next element (if exists) */
tny_iterator_next (helper->iter);
if (tny_iterator_is_done (helper->iter)) {
+ /* Notify the queue */
+ if (helper->mail_op != NULL)
+ modest_mail_operation_queue_remove (modest_runtime_get_mail_operation_queue (), helper->mail_op);
+
+ /* Free resources */
+ ReplyForwardHelper *rf_helper = (ReplyForwardHelper *) helper->user_data;
headers = tny_iterator_get_list (helper->iter);
headers = tny_iterator_get_list (helper->iter);
g_object_unref (G_OBJECT (headers));
g_object_unref (G_OBJECT (helper->iter));
g_object_unref (G_OBJECT (headers));
g_object_unref (G_OBJECT (helper->iter));
+ if (rf_helper != NULL) {
+ g_free (rf_helper->account_name);
+ g_slice_free (ReplyForwardHelper, rf_helper);
+ }
g_slice_free (GetMsgAsyncHelper, helper);
} else {
TnyHeader *header;
header = TNY_HEADER (tny_iterator_get_current (helper->iter));
/* tny_folder_get_msg_async (folder, header, */
/* get_msg_cb, NULL, helper); */
g_slice_free (GetMsgAsyncHelper, helper);
} else {
TnyHeader *header;
header = TNY_HEADER (tny_iterator_get_current (helper->iter));
/* tny_folder_get_msg_async (folder, header, */
/* get_msg_cb, NULL, helper); */
- helper->mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE);
- modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), helper->mail_op);
- modest_mail_operation_process_msg (helper->mail_op, header, get_msg_cb, helper);
+ modest_mail_operation_process_msg (helper->mail_op, header, helper->num_ops, get_msg_cb, helper);
g_object_unref (G_OBJECT(header));
}
g_object_unref (G_OBJECT(header));
}
helper->window = MODEST_WINDOW (main_window);
helper->iter = tny_list_create_iterator (list);
helper->func = read_msg_func;
helper->window = MODEST_WINDOW (main_window);
helper->iter = tny_list_create_iterator (list);
helper->func = read_msg_func;
+ helper->num_ops = tny_list_get_length (list);
/* folder = tny_header_get_folder (TNY_HEADER(header)); */
/* folder = tny_header_get_folder (TNY_HEADER(header)); */
helper->mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), helper->mail_op);
helper->mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), helper->mail_op);
- modest_mail_operation_process_msg (helper->mail_op, header, get_msg_cb, helper);
+ modest_mail_operation_process_msg (helper->mail_op, header, helper->num_ops, get_msg_cb, helper);
/* Frees */
/* g_object_unref (G_OBJECT (folder)); */
/* Frees */
/* g_object_unref (G_OBJECT (folder)); */
from = modest_account_mgr_get_from_string (account_mgr, account_name);
/* Create the mail operation */
from = modest_account_mgr_get_from_string (account_mgr, account_name);
/* Create the mail operation */
- mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE);
+ mail_operation = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_INFO);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
modest_mail_operation_save_to_drafts (mail_operation,
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_operation);
modest_mail_operation_save_to_drafts (mail_operation,
if (result == GTK_RESPONSE_REJECT) {
finished = TRUE;
} else {
if (result == GTK_RESPONSE_REJECT) {
finished = TRUE;
} else {
- ModestMailOperation *mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE);
+ ModestMailOperation *mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_INFO);
TnyFolder *new_folder = NULL;
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
TnyFolder *new_folder = NULL;
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
if (folder_name != NULL && strlen (folder_name) > 0) {
ModestMailOperation *mail_op;
if (folder_name != NULL && strlen (folder_name) > 0) {
ModestMailOperation *mail_op;
- mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_RECEIVE);
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_ID_INFO);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);