+static void
+cancel_window_operations (ModestWindow *window)
+{
+ GSList* pending_ops = NULL;
+
+ /* cancel open and receive operations */
+ pending_ops = modest_mail_operation_queue_get_by_source (modest_runtime_get_mail_operation_queue (),
+ G_OBJECT (window));
+ while (pending_ops != NULL) {
+ ModestMailOperationTypeOperation type;
+ GSList* tmp_list = NULL;
+
+ type = modest_mail_operation_get_type_operation (MODEST_MAIL_OPERATION (pending_ops->data));
+ if (type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || type == MODEST_MAIL_OPERATION_TYPE_OPEN) {
+ modest_mail_operation_cancel (pending_ops->data);
+ }
+ g_object_unref (G_OBJECT (pending_ops->data));
+ tmp_list = pending_ops;
+ pending_ops = g_slist_next (pending_ops);
+ g_slist_free_1 (tmp_list);
+ }
+}
+
+
+