aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-02-04 18:45:20 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-02-04 18:45:20 +0800
commitef8a0762ac9e07a36e8d39d2948c8acd065aa350 (patch)
tree344be4bd475744a8e86a98b4952a215facfe6ce8 /mail
parent0650e002ea411371bef49056da8f1dfd3fca00f0 (diff)
downloadgsoc2013-evolution-ef8a0762ac9e07a36e8d39d2948c8acd065aa350.tar.gz
gsoc2013-evolution-ef8a0762ac9e07a36e8d39d2948c8acd065aa350.tar.zst
gsoc2013-evolution-ef8a0762ac9e07a36e8d39d2948c8acd065aa350.zip
** See bug #53683.
2004-02-04 Not Zed <NotZed@Ximian.com> ** See bug #53683. * mail-ops.c (mail_sync_store): new async op to call CamelStore::sync. * mail-component.c (impl_requestQuit): implement, check to see if we can quit, or have open or unsent messages (and are in online mode). (impl_quit): implement. Trigger off a sync of all open stores, and return FALSE until its done. (impl_upgradeFromVersion): fixed the signature to match the idl, killed that warning at last. ** See bug #53832. * em-folder-browser.c (emfb_folder_properties): only show this if we have a uri set. Strictly, the menu item shouldn't be activated. ** See bug #53131. * em-folder-browser.c (em_folder_browser_show_preview): copy the message list's cursor_uid before calling set_message, since it can get freed during setting the message. svn path=/trunk/; revision=24608
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog27
-rw-r--r--mail/mail-component.c81
-rw-r--r--mail/mail-ops.c70
-rw-r--r--mail/mail-ops.h6
-rw-r--r--mail/mail-vfolder.c3
5 files changed, 180 insertions, 7 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index fdbf85a0c4..9bb1fe429f 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,30 @@
+2004-02-04 Not Zed <NotZed@Ximian.com>
+
+ ** See bug #53683.
+
+ * mail-ops.c (mail_sync_store): new async op to call
+ CamelStore::sync.
+
+ * mail-component.c (impl_requestQuit): implement, check to see if
+ we can quit, or have open or unsent messages (and are in online
+ mode).
+ (impl_quit): implement. Trigger off a sync of all open stores,
+ and return FALSE until its done.
+ (impl_upgradeFromVersion): fixed the signature to match the idl,
+ killed that warning at last.
+
+ ** See bug #53832.
+
+ * em-folder-browser.c (emfb_folder_properties): only show this if
+ we have a uri set. Strictly, the menu item shouldn't be
+ activated.
+
+ ** See bug #53131.
+
+ * em-folder-browser.c (em_folder_browser_show_preview): copy the
+ message list's cursor_uid before calling set_message, since it can
+ get freed during setting the message.
+
2004-02-03 Jeffrey Stedfast <fejj@ximian.com>
* em-folder-tree.c (tree_drag_data_received): Modified
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 400a493008..9a4a556bf3 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -55,6 +55,8 @@
#include "mail-session.h"
#include "mail-offline-handler.h"
+#include "composer/e-msg-composer.h"
+
#include "e-task-bar.h"
#include <gtk/gtklabel.h>
@@ -81,6 +83,10 @@ static BonoboObjectClass *parent_class = NULL;
struct _MailComponentPrivate {
GMutex *lock;
+ /* states/data used during shutdown */
+ enum { MC_QUIT_START, MC_QUIT_SYNC } quit_state;
+ int quit_count;
+
char *base_directory;
EMFolderTreeModel *model;
@@ -325,6 +331,8 @@ impl_dispose (GObject *object)
{
MailComponentPrivate *priv = MAIL_COMPONENT (object)->priv;
+ printf("mail dispose?\n");
+
if (priv->activity_handler != NULL) {
g_object_unref (priv->activity_handler);
priv->activity_handler = NULL;
@@ -357,7 +365,7 @@ static void
impl_finalize (GObject *object)
{
MailComponentPrivate *priv = MAIL_COMPONENT (object)->priv;
-
+
g_free (priv->base_directory);
mail_async_event_destroy (priv->async_event);
@@ -434,6 +442,71 @@ impl_createControls (PortableServer_Servant servant,
g_signal_connect (tree_widget, "folder-selected", G_CALLBACK (folder_selected_cb), view_widget);
}
+static CORBA_boolean
+impl_requestQuit(PortableServer_Servant servant, CORBA_Environment *ev)
+{
+ /*MailComponent *mc = MAIL_COMPONENT(bonobo_object_from_servant(servant));*/
+ CamelFolder *folder;
+
+ if (!e_msg_composer_request_close_all())
+ return FALSE;
+
+ folder = mc_default_folders[MAIL_COMPONENT_FOLDER_OUTBOX].folder;
+ if (folder != NULL
+ && camel_folder_get_message_count(folder) != 0
+ && camel_session_is_online(session)) {
+ GtkWidget *dialog;
+ guint resp;
+
+ /* FIXME: HIG? */
+ dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_INFO, GTK_BUTTONS_YES_NO,
+ _("You have unsent messages, do you wish to quit anyway?"));
+ gtk_dialog_set_default_response((GtkDialog *)dialog, GTK_RESPONSE_NO);
+ resp = gtk_dialog_run((GtkDialog *)dialog);
+ gtk_widget_destroy(dialog);
+
+ if (resp != GTK_RESPONSE_YES)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+mc_quit_sync_done(CamelStore *store, void *data)
+{
+ MailComponent *mc = data;
+
+ mc->priv->quit_count--;
+}
+
+static void
+mc_quit_sync(CamelStore *store, char *name, MailComponent *mc)
+{
+ int expunge = gconf_client_get_bool(mail_config_get_gconf_client(), "/apps/evolution/mail/trash/empty_on_exit", NULL);
+
+ mc->priv->quit_count++;
+ mail_sync_store(store, expunge, mc_quit_sync_done, mc);
+}
+
+static CORBA_boolean
+impl_quit(PortableServer_Servant servant, CORBA_Environment *ev)
+{
+ MailComponent *mc = MAIL_COMPONENT(bonobo_object_from_servant(servant));
+
+ switch (mc->priv->quit_state) {
+ case MC_QUIT_START:
+ g_hash_table_foreach(mc->priv->store_hash, (GHFunc)mc_quit_sync, mc);
+ mc->priv->quit_state = MC_QUIT_SYNC;
+ /* Falls through */
+ case MC_QUIT_SYNC:
+ return mc->priv->quit_count == 0;
+ /* What else do we need to do at quit time? */
+ }
+
+ return TRUE;
+}
+
static GNOME_Evolution_CreatableItemTypeList *
impl__get_userCreatableItems (PortableServer_Servant servant, CORBA_Environment *ev)
{
@@ -489,8 +562,8 @@ impl_sendAndReceive (PortableServer_Servant servant, CORBA_Environment *ev)
mail_send_receive ();
}
-static gboolean
-impl_upgradeFromVersion (PortableServer_Servant servant, short major, short minor, short revision, CORBA_Environment *ev)
+static CORBA_boolean
+impl_upgradeFromVersion (PortableServer_Servant servant, const short major, const short minor, const short revision, CORBA_Environment *ev)
{
MailComponent *component;
CamelException ex;
@@ -521,6 +594,8 @@ mail_component_class_init (MailComponentClass *class)
object_class->finalize = impl_finalize;
epv->createControls = impl_createControls;
+ epv->requestQuit = impl_requestQuit;
+ epv->quit = impl_quit;
epv->_get_userCreatableItems = impl__get_userCreatableItems;
epv->requestCreateItem = impl_requestCreateItem;
epv->handleURI = impl_handleURI;
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 10e40eafc5..26dde00460 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1571,6 +1571,76 @@ mail_sync_folder(CamelFolder *folder, void (*done) (CamelFolder *folder, void *d
e_thread_put(mail_thread_queued_slow, (EMsg *)m);
}
+/* ** SYNC STORE ********************************************************* */
+
+struct _sync_store_msg {
+ struct _mail_msg msg;
+
+ CamelStore *store;
+ int expunge;
+ void (*done) (CamelStore *store, void *data);
+ void *data;
+};
+
+static char *sync_store_desc(struct _mail_msg *mm, int done)
+{
+ struct _sync_store_msg *m = (struct _sync_store_msg *)mm;
+ char *uri, *res;
+
+ uri = camel_url_to_string(((CamelService *)m->store)->url, CAMEL_URL_HIDE_ALL);
+ res = g_strdup_printf(m->expunge
+ ?_("Expunging and storing account '%s'")
+ :_("Storing account '%s'"),
+ uri);
+ g_free(uri);
+
+ return res;
+}
+
+static void sync_store_sync(struct _mail_msg *mm)
+{
+ struct _sync_store_msg *m = (struct _sync_store_msg *)mm;
+
+ camel_store_sync(m->store, m->expunge, &mm->ex);
+}
+
+static void sync_store_synced(struct _mail_msg *mm)
+{
+ struct _sync_store_msg *m = (struct _sync_store_msg *)mm;
+
+ if (m->done)
+ m->done(m->store, m->data);
+}
+
+static void sync_store_free(struct _mail_msg *mm)
+{
+ struct _sync_store_msg *m = (struct _sync_store_msg *)mm;
+
+ camel_object_unref(m->store);
+}
+
+static struct _mail_msg_op sync_store_op = {
+ sync_store_desc,
+ sync_store_sync,
+ sync_store_synced,
+ sync_store_free,
+};
+
+void
+mail_sync_store(CamelStore *store, int expunge, void (*done) (CamelStore *store, void *data), void *data)
+{
+ struct _sync_store_msg *m;
+
+ m = mail_msg_new(&sync_store_op, NULL, sizeof(*m));
+ m->store = store;
+ m->expunge = expunge;
+ camel_object_ref(store);
+ m->data = data;
+ m->done = done;
+
+ e_thread_put(mail_thread_queued_slow, (EMsg *)m);
+}
+
/* ******************************************************************************** */
static char *refresh_folder_desc(struct _mail_msg *mm, int done)
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index 142052277d..a2863df424 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -80,8 +80,10 @@ void mail_build_attachment (CamelFolder *folder, GPtrArray *uids,
void *data);
void mail_sync_folder (CamelFolder *folder,
- void (*done) (CamelFolder *folder, void *data),
- void *data);
+ void (*done) (CamelFolder *folder, void *data), void *data);
+
+void mail_sync_store(CamelStore *store, int expunge,
+ void (*done) (CamelStore *store, void *data), void *data);
void mail_refresh_folder (CamelFolder *folder,
void (*done) (CamelFolder *folder, void *data),
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 65954efbe4..80331e70e4 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -28,8 +28,6 @@
#include <string.h>
#include <libgnome/gnome-i18n.h>
-#include "Evolution.h"
-
#include "mail-component.h"
#include "mail-vfolder.h"
#include "mail-tools.h"
@@ -38,6 +36,7 @@
#include "mail.h"
#include "mail-ops.h"
#include "mail-mt.h"
+#include "em-utils.h"
#include "e-util/e-dialog-utils.h"