-
-
-/* interval before retrying to close the application */
-#define CLOSING_RETRY_INTERVAL 3000
-/* interval before cancel whatever is left in the queue, and closing anyway */
-#define MAX_WAIT_FOR_CLOSING 30 * 1000
-
-static gboolean
-on_quit_maybe (ModestWindowMgr *self)
-{
- ModestWindowMgrPrivate *priv;
- guint queue_num;
-
- priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
-
- /* it seems, in the meantime some windows were
- * created. in that case, stop 'on_quit_maybe' */
- if (priv->window_list) {
- priv->closing_time = 0;
- return FALSE;
- }
-
- if (priv->closing_time >= MAX_WAIT_FOR_CLOSING) {
- /* we waited long enough: cancel all remaining operations */
- g_debug ("%s: we waited long enough (%ds), cancelling queue and quiting",
- __FUNCTION__, priv->closing_time/1000);
- /* FIXME: below gives me a lot of:
- * GLIB CRITICAL ** default - modest_mail_operation_cancel:
- * assertion `priv->account' failed
- * which means there is no account for the given operation
- * so, we're not trying to be nice, we're just quiting.
- */
- //modest_mail_operation_queue_cancel_all
- // (modest_runtime_get_mail_operation_queue());
- } else {
-
- /* if there is anything left in our operation queue,
- * wait another round
- */
- queue_num = modest_mail_operation_queue_num_elements
- (modest_runtime_get_mail_operation_queue());
- if (queue_num > 0) {
- g_debug ("%s: waiting, there are still %d operation(s) queued",
- __FUNCTION__, queue_num);
- priv->closing_time += CLOSING_RETRY_INTERVAL;
- return TRUE;
- }
- }
-
- /* so: no windows left, nothing in the queue: quit */
- priv->closing_time = 0;
- gtk_main_quit ();
- return FALSE;
-}
-
-