diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-01-18 00:07:19 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-01-19 12:48:47 +0800 |
commit | 61ae36351b24cc676f60483d576706bf827f2987 (patch) | |
tree | c55d9e000efd47fa14865fad2defa79b5ed61ffd | |
parent | 37644b9d257369c5c158121ca4807cafbe844595 (diff) | |
download | gsoc2013-evolution-61ae36351b24cc676f60483d576706bf827f2987.tar.gz gsoc2013-evolution-61ae36351b24cc676f60483d576706bf827f2987.tar.zst gsoc2013-evolution-61ae36351b24cc676f60483d576706bf827f2987.zip |
Introduce libemail-engine and libemail-utils.
These libraries are bound for E-D-S so they live at the lowest layer of
Evolution for now -- even libeutil can link to them (but please don't).
This is the first step toward moving mail handing to a D-Bus service.
169 files changed, 3419 insertions, 2325 deletions
diff --git a/Makefile.am b/Makefile.am index a5e0d9f767..d1f0d19a46 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,8 @@ SUBDIRS = \ data \ smclient \ libgnomecanvas \ + libemail-utils \ + libemail-engine \ e-util \ a11y \ filter \ diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index c8c208e1b3..a5c0ac6355 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -34,31 +34,35 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> + +#include <libecal/e-cal-time-util.h> #include <libedataserverui/e-category-completion.h> #include <libedataserverui/e-client-utils.h> #include <libedataserverui/e-source-combo-box.h> -#include "misc/e-dateedit.h" -#include "misc/e-send-options.h" -#include "misc/e-buffer-tagger.h" -#include <libecal/e-cal-time-util.h> -#include "../e-timezone-entry.h" -#include "e-util/e-util.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-categories-config.h" -#include "e-util/e-dialog-utils.h" -#include "e-util/e-dialog-widgets.h" -#include "e-util/e-util-private.h" +#include <e-util/e-util.h> +#include <e-util/e-categories-config.h> +#include <e-util/e-dialog-utils.h> +#include <e-util/e-dialog-widgets.h> +#include <e-util/e-util-private.h> + +#include <libemail-utils/e-account-utils.h> +#include <misc/e-dateedit.h> +#include <misc/e-send-options.h> +#include <misc/e-buffer-tagger.h> + +#include "../e-alarm-list.h" #include "../e-meeting-attendee.h" -#include "../e-meeting-store.h" #include "../e-meeting-list-view.h" -#include "comp-editor.h" -#include "comp-editor-util.h" -#include "../e-alarm-list.h" +#include "../e-meeting-store.h" +#include "../e-timezone-entry.h" + #include "alarm-list-dialog.h" -#include "event-page.h" +#include "comp-editor-util.h" +#include "comp-editor.h" #include "e-send-options-utils.h" +#include "event-page.h" #define EVENT_PAGE_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ diff --git a/calendar/gui/dialogs/memo-page.c b/calendar/gui/dialogs/memo-page.c index 9bee45c062..bf60445001 100644 --- a/calendar/gui/dialogs/memo-page.c +++ b/calendar/gui/dialogs/memo-page.c @@ -33,20 +33,23 @@ #include <string.h> #include <gtk/gtk.h> #include <glib/gi18n.h> + #include <libedataserverui/e-category-completion.h> #include <libedataserverui/e-client-utils.h> #include <libedataserverui/e-source-combo-box.h> #include <libedataserverui/e-name-selector.h> #include <libedataserverui/e-name-selector-entry.h> #include <libedataserverui/e-name-selector-list.h> -#include <widgets/misc/e-dateedit.h> -#include "misc/e-buffer-tagger.h" - -#include "e-util/e-util.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-categories-config.h" -#include "e-util/e-dialog-utils.h" -#include "e-util/e-util-private.h" + +#include <e-util/e-util.h> +#include <e-util/e-categories-config.h> +#include <e-util/e-dialog-utils.h> +#include <e-util/e-util-private.h> + +#include <misc/e-dateedit.h> +#include <misc/e-buffer-tagger.h> + +#include <libemail-utils/e-account-utils.h> #include "../calendar-config.h" #include "comp-editor.h" diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index 08cb6f45ea..2033a46ff2 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -33,27 +33,31 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> #include <gdk/gdkkeysyms.h> + #include <libedataserverui/e-category-completion.h> #include <libedataserverui/e-client-utils.h> #include <libedataserverui/e-source-combo-box.h> + #include <misc/e-dateedit.h> -#include "misc/e-buffer-tagger.h" +#include <misc/e-buffer-tagger.h> + +#include <e-util/e-categories-config.h> #include <e-util/e-dialog-utils.h> +#include <e-util/e-util-private.h> +#include <e-util/e-util.h> + +#include <libemail-utils/e-account-utils.h> + +#include "../e-meeting-attendee.h" +#include "../e-meeting-list-view.h" +#include "../e-meeting-store.h" #include "../e-timezone-entry.h" + #include "comp-editor.h" #include "comp-editor-util.h" #include "e-send-options-utils.h" #include "task-page.h" -#include "e-util/e-util.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-categories-config.h" -#include "e-util/e-util-private.h" - -#include "../e-meeting-attendee.h" -#include "../e-meeting-store.h" -#include "../e-meeting-list-view.h" - #define TASK_PAGE_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), TYPE_TASK_PAGE, TaskPagePrivate)) diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index c1ff096208..7344e87916 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -28,18 +28,22 @@ #include <string.h> #include <glib/gi18n.h> + #include <libebackend/e-extensible.h> #include <libedataserver/e-flag.h> #include <libedataserver/e-time-utils.h> #include <libecal/e-cal-client-view.h> #include <libecal/e-cal-time-util.h> + +#include <e-util/e-util.h> +#include <e-util/e-util-enumtypes.h> + +#include <libemail-utils/e-account-utils.h> + #include "comp-util.h" #include "e-cal-model.h" #include "itip-utils.h" #include "misc.h" -#include "e-util/e-util.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-util-enumtypes.h" struct _ECalModelComponentPrivate { GString *categories_str; diff --git a/calendar/gui/e-meeting-store.c b/calendar/gui/e-meeting-store.c index 833c6a821e..e11d90e7bb 100644 --- a/calendar/gui/e-meeting-store.c +++ b/calendar/gui/e-meeting-store.c @@ -28,6 +28,7 @@ #include <gio/gio.h> #include <glib/gi18n.h> #include <libsoup/soup.h> + #include <libecal/e-cal-component.h> #include <libecal/e-cal-util.h> #include <libecal/e-cal-time-util.h> @@ -35,8 +36,11 @@ #include <libedataserver/e-data-server-util.h> #include <libedataserver/e-proxy.h> #include <libedataserverui/e-passwords.h> -#include <e-util/e-account-utils.h> + #include <e-util/e-util-enumtypes.h> + +#include <libemail-utils/e-account-utils.h> + #include "itip-utils.h" #include "e-meeting-utils.h" #include "e-meeting-attendee.h" diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 4b2a8d262d..e58f2f9c7e 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -24,21 +24,24 @@ #include <config.h> #endif +#include <time.h> #include <glib/gi18n.h> -#include <libedataserver/e-time-utils.h> -#include <gtk/gtk.h> #include <libical/ical.h> -#include <e-util/e-account-utils.h> -#include <e-util/e-dialog-utils.h> +#include <libsoup/soup.h> + #include <libecal/e-cal-time-util.h> #include <libecal/e-cal-util.h> -#include <libsoup/soup.h> -#include "itip-utils.h" -#include <time.h> -#include "dialogs/comp-editor-util.h" +#include <libedataserver/e-time-utils.h> + +#include <e-util/e-dialog-utils.h> + +#include <libemail-utils/e-account-utils.h> #include <composer/e-msg-composer.h> +#include "itip-utils.h" +#include "dialogs/comp-editor-util.h" + #define d(x) static const gchar *itip_methods[] = { diff --git a/capplet/anjal-settings-main.c b/capplet/anjal-settings-main.c index 7efddcffbf..c04722e42f 100644 --- a/capplet/anjal-settings-main.c +++ b/capplet/anjal-settings-main.c @@ -36,7 +36,7 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> #include <libedataserverui/e-passwords.h> -#include <mail/mail-mt.h> +#include <libemail-utils/mail-mt.h> #include "settings/mail-capplet-shell.h" #include <libedataserver/e-categories.h> diff --git a/capplet/settings/Makefile.am b/capplet/settings/Makefile.am index 1367fd5a75..db899e0f6c 100644 --- a/capplet/settings/Makefile.am +++ b/capplet/settings/Makefile.am @@ -59,6 +59,8 @@ libevolution_mail_settings_la_LIBADD = \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/shell/libeshell.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ $(top_builddir)/e-util/libeutil.la libevolution_mail_settings_la_LDFLAGS = $(NO_UNDEFINED) diff --git a/capplet/settings/anjal-mail-view.c b/capplet/settings/anjal-mail-view.c index c0926536cb..232b8ff118 100644 --- a/capplet/settings/anjal-mail-view.c +++ b/capplet/settings/anjal-mail-view.c @@ -28,7 +28,7 @@ #include <glib/gi18n.h> #include "mail/em-utils.h" #include "mail/mail-send-recv.h" -#include "mail/mail-ops.h" +#include "libemail-engine/mail-ops.h" #include "mail/em-folder-tree.h" struct _AnjalMailViewPrivate { diff --git a/capplet/settings/mail-capplet-shell.c b/capplet/settings/mail-capplet-shell.c index 707efe3f35..3d3e015e94 100644 --- a/capplet/settings/mail-capplet-shell.c +++ b/capplet/settings/mail-capplet-shell.c @@ -38,8 +38,8 @@ #include <mail/em-utils.h> #include <mail/em-composer-utils.h> -#include <mail/mail-config.h> -#include <mail/mail-mt.h> +#include <libemail-engine/mail-config.h> +#include <libemail-utils/mail-mt.h> #include <shell/e-shell.h> diff --git a/capplet/settings/mail-settings-view.c b/capplet/settings/mail-settings-view.c index a699dca9ea..992f705826 100644 --- a/capplet/settings/mail-settings-view.c +++ b/capplet/settings/mail-settings-view.c @@ -25,10 +25,12 @@ #endif #include <glib/gi18n.h> -#include "mail-settings-view.h" #include <libedataserver/e-account-list.h> + +#include <libemail-utils/e-account-utils.h> + +#include "mail-settings-view.h" #include "mail-view.h" -#include <e-util/e-account-utils.h> struct _MailSettingsViewPrivate { GtkWidget *tab_str; diff --git a/capplet/settings/mail-view.c b/capplet/settings/mail-view.c index 53daf3fd08..4477be517a 100644 --- a/capplet/settings/mail-view.c +++ b/capplet/settings/mail-view.c @@ -27,7 +27,7 @@ #include <glib/gi18n.h> #include "mail/em-utils.h" #include "mail/mail-send-recv.h" -#include "mail/mail-ops.h" +#include "libemail-engine/mail-ops.h" #include "mail-view.h" #ifndef ANJAL_SETTINGS #include "mail-folder-view.h" diff --git a/composer/Makefile.am b/composer/Makefile.am index 013d04c8bd..cee00a002b 100644 --- a/composer/Makefile.am +++ b/composer/Makefile.am @@ -63,6 +63,7 @@ libcomposer_la_LIBADD = \ $(top_builddir)/em-format/libemformat.la \ $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.la \ $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(GTKHTML_LIBS) diff --git a/composer/e-composer-header-table.h b/composer/e-composer-header-table.h index f7edec0b14..9d6a83fb9a 100644 --- a/composer/e-composer-header-table.h +++ b/composer/e-composer-header-table.h @@ -23,9 +23,9 @@ #include <libebook/e-destination.h> #include <shell/e-shell.h> -#include <e-util/e-signature.h> -#include <e-util/e-signature-list.h> #include <composer/e-composer-header.h> +#include <libemail-utils/e-signature.h> +#include <libemail-utils/e-signature-list.h> /* Standard GObject macros */ #define E_TYPE_COMPOSER_HEADER_TABLE \ diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index a7250a7d7d..6a48950912 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -37,13 +37,13 @@ #include <ctype.h> #include <fcntl.h> -#include "e-util/e-account-utils.h" -#include "e-util/e-alert-dialog.h" -#include "e-util/e-dialog-utils.h" -#include "e-util/e-signature-utils.h" -#include "e-util/e-util-private.h" -#include "em-format/em-format.h" -#include "em-format/em-format-quote.h" +#include <e-util/e-alert-dialog.h> +#include <e-util/e-dialog-utils.h> +#include <e-util/e-util-private.h> +#include <em-format/em-format.h> +#include <em-format/em-format-quote.h> +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/e-signature-utils.h> #include "e-composer-private.h" diff --git a/configure.ac b/configure.ac index 8d5fbb4417..102244810a 100644 --- a/configure.ac +++ b/configure.ac @@ -1618,6 +1618,10 @@ help/quickref/pl/Makefile help/quickref/pt/Makefile help/quickref/sv/Makefile help/quickref/sq/Makefile +libemail-utils/Makefile +libemail-utils/libemail-utils.pc +libemail-engine/Makefile +libemail-engine/libemail-engine.pc libgnomecanvas/Makefile shell/Makefile shell/evolution-nognome diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 8ef95f1841..41a99316ef 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -18,7 +18,6 @@ endif privsolib_LTLIBRARIES = libeutil.la eutilinclude_HEADERS = \ - e-account-utils.h \ e-activity.h \ e-alert.h \ e-alert-dialog.h \ @@ -43,9 +42,6 @@ eutilinclude_HEADERS = \ e-plugin-ui.h \ e-plugin-util.h \ e-selection.h \ - e-signature.h \ - e-signature-list.h \ - e-signature-utils.h \ e-sorter.h \ e-sorter-array.h \ e-text-event-processor-emacs-like.h \ @@ -89,7 +85,6 @@ libeutil_la_CPPFLAGS = \ libeutil_la_SOURCES = \ $(eutilinclude_HEADERS) \ - e-account-utils.c \ e-activity.c \ e-alert.c \ e-alert-dialog.c \ @@ -114,9 +109,6 @@ libeutil_la_SOURCES = \ e-plugin-util.c \ e-print.c \ e-selection.c \ - e-signature.c \ - e-signature-list.c \ - e-signature-utils.c \ e-sorter.c \ e-sorter-array.c \ e-text-event-processor-emacs-like.c \ diff --git a/e-util/e-marshal.list b/e-util/e-marshal.list index 6d3c1fcdb0..bf15633ab8 100644 --- a/e-util/e-marshal.list +++ b/e-util/e-marshal.list @@ -42,9 +42,6 @@ NONE:OBJECT,BOOLEAN NONE:OBJECT,DOUBLE,DOUBLE,BOOLEAN NONE:OBJECT,OBJECT NONE:OBJECT,STRING -NONE:OBJECT,STRING,INT -NONE:OBJECT,STRING,INT,STRING,STRING,STRING -NONE:OBJECT,STRING,STRING NONE:OBJECT,STRING,UINT NONE:POINTER,INT NONE:POINTER,INT,INT,INT,INT diff --git a/evolution-mail.pc.in b/evolution-mail.pc.in index 782177052f..e2bdf78139 100644 --- a/evolution-mail.pc.in +++ b/evolution-mail.pc.in @@ -12,6 +12,6 @@ privincludedir=@privincludedir@ Name: Evolution Mail Description: Mail utilities for Evolution Version: @VERSION@ -Requires: evolution-shell-3.0 camel-1.2 +Requires: evolution-shell-3.0 camel-1.2 libemail-engine Libs: -L${privlibdir} -levolution-mail -lcomposer Cflags: -I${privincludedir} diff --git a/libemail-engine/Makefile.am b/libemail-engine/Makefile.am new file mode 100644 index 0000000000..88a0227aab --- /dev/null +++ b/libemail-engine/Makefile.am @@ -0,0 +1,71 @@ +NULL = + +lib_LTLIBRARIES = libemail-engine.la + +include $(top_srcdir)/glib-gen.mak +glib_enum_headers=e-mail-enums.h +glib_enum_output=e-mail-enumtypes +glib_enum_define=E_MAIL +glib_enum_prefix=e_mail + +ENUM_GENERATED = e-mail-enumtypes.h e-mail-enumtypes.c + +libemail_engine_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + $(EVOLUTION_DATA_SERVER_CFLAGS) \ + $(GNOME_PLATFORM_CFLAGS) \ + $(NULL) + +libmailengineincludedir = $(privincludedir)/libemail-engine +libmailengineinclude_HEADERS = \ + e-mail-enums.h \ + e-mail-enumtypes.h \ + e-mail-folder-utils.h \ + e-mail-junk-filter.h \ + e-mail-session-utils.h \ + e-mail-session.h \ + e-mail-store-utils.h \ + e-mail-utils.h \ + mail-config.h \ + mail-folder-cache.h \ + mail-ops.h \ + mail-tools.h \ + $(NULL) + +libemail_engine_la_SOURCES = \ + $(libmailengineinclude_HEADERS) \ + e-mail-enumtypes.c \ + e-mail-folder-utils.c \ + e-mail-junk-filter.c \ + e-mail-session-utils.c \ + e-mail-session.c \ + e-mail-store-utils.c \ + e-mail-utils.c \ + mail-config.c \ + mail-folder-cache.c \ + mail-ops.c \ + mail-tools.c \ + $(NULL) + +libemail_engine_la_LIBADD = \ + $(top_builddir)/libemail-utils/libemail-utils.la \ + $(EVOLUTION_DATA_SERVER_LIBS) \ + $(GNOME_PLATFORM_LIBS) \ + $(NULL) + +libemail_engine_la_LDFLAGS = $(NO_UNDEFINED) + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libemail-engine.pc + +BUILT_SOURCES = $(ENUM_GENERATED) + +CLEANFILES = $(BUILT_SOURCES) +DISTCLEANFILES = $(pkgconfig_DATA) + +dist-hook: + cd $(distdir); rm -f $(BUILT_SOURCES) + +-include $(top_srcdir)/git.mk diff --git a/mail/e-mail-enums.h b/libemail-engine/e-mail-enums.h index e0ad3ad86f..e0ad3ad86f 100644 --- a/mail/e-mail-enums.h +++ b/libemail-engine/e-mail-enums.h diff --git a/mail/e-mail-folder-utils.c b/libemail-engine/e-mail-folder-utils.c index fe093adb21..25754f4f96 100644 --- a/mail/e-mail-folder-utils.c +++ b/libemail-engine/e-mail-folder-utils.c @@ -24,7 +24,7 @@ #include <glib/gi18n-lib.h> -#include "mail/mail-tools.h" +#include <libemail-engine/mail-tools.h> /* X-Mailer header value */ #define X_MAILER ("Evolution " VERSION SUB_VERSION " " VERSION_COMMENT) diff --git a/mail/e-mail-folder-utils.h b/libemail-engine/e-mail-folder-utils.h index 9e8dd0f050..9e8dd0f050 100644 --- a/mail/e-mail-folder-utils.h +++ b/libemail-engine/e-mail-folder-utils.h diff --git a/mail/e-mail-junk-filter.c b/libemail-engine/e-mail-junk-filter.c index 71128013ad..fda8efb163 100644 --- a/mail/e-mail-junk-filter.c +++ b/libemail-engine/e-mail-junk-filter.c @@ -18,7 +18,7 @@ #include "e-mail-junk-filter.h" -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> G_DEFINE_ABSTRACT_TYPE ( EMailJunkFilter, diff --git a/mail/e-mail-junk-filter.h b/libemail-engine/e-mail-junk-filter.h index 74a7840c2d..74a7840c2d 100644 --- a/mail/e-mail-junk-filter.h +++ b/libemail-engine/e-mail-junk-filter.h diff --git a/mail/e-mail-session-utils.c b/libemail-engine/e-mail-session-utils.c index f1c27a3425..979d15388e 100644 --- a/mail/e-mail-session-utils.c +++ b/libemail-engine/e-mail-session-utils.c @@ -22,18 +22,19 @@ #include "e-mail-session-utils.h" -#include "em-utils.h" - #include <glib/gi18n-lib.h> -#include <mail/mail-tools.h> -#include <mail/e-mail-folder-utils.h> -#include <e-util/e-account-utils.h> -#include <filter/e-filter-rule.h> +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-utils.h> +#include <libemail-engine/mail-tools.h> +#include <libemail-utils/e-account-utils.h> /* X-Mailer header value */ #define X_MAILER ("Evolution " VERSION SUB_VERSION " " VERSION_COMMENT) +/* FIXME: Temporary - remove this after we move filter/ to eds */ +#define E_FILTER_SOURCE_OUTGOING "outgoing" + typedef struct _AsyncContext AsyncContext; struct _AsyncContext { diff --git a/mail/e-mail-session-utils.h b/libemail-engine/e-mail-session-utils.h index b398be5f84..2c92216533 100644 --- a/mail/e-mail-session-utils.h +++ b/libemail-engine/e-mail-session-utils.h @@ -21,7 +21,7 @@ /* High-level operations with Evolution-specific policies. */ -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> #define E_MAIL_ERROR (e_mail_error_quark ()) diff --git a/mail/e-mail-session.c b/libemail-engine/e-mail-session.c index 57c800cb91..012ad9ba7d 100644 --- a/mail/e-mail-session.c +++ b/libemail-engine/e-mail-session.c @@ -46,29 +46,17 @@ #include <libedataserver/e-proxy.h> #include <libebackend/e-extensible.h> #include <libedataserverui/e-passwords.h> +#include <libedataserver/e-data-server-util.h> -#include "e-util/e-util.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-alert-dialog.h" -#include "e-util/e-util-private.h" +#include "libemail-utils/e-account-utils.h" +#include "libemail-utils/mail-mt.h" -#include "shell/e-shell.h" -#include "shell/e-shell-view.h" -#include "shell/e-shell-content.h" -#include "shell/e-shell-window.h" - -#include "e-mail-account-store.h" -#include "e-mail-folder-utils.h" #include "e-mail-junk-filter.h" #include "e-mail-session.h" -#include "em-composer-utils.h" -#include "em-filter-context.h" -#include "em-filter-rule.h" -#include "em-utils.h" +#include "e-mail-folder-utils.h" +#include "e-mail-utils.h" #include "mail-config.h" -#include "mail-mt.h" #include "mail-ops.h" -#include "mail-send-recv.h" #include "mail-tools.h" #define E_MAIL_SESSION_GET_PRIVATE(obj) \ @@ -76,19 +64,14 @@ ((obj), E_TYPE_MAIL_SESSION, EMailSessionPrivate)) typedef struct _AsyncContext AsyncContext; -typedef struct _SourceContext SourceContext; struct _EMailSessionPrivate { - EMailAccountStore *account_store; MailFolderCache *folder_cache; - EMailLabelListStore *label_store; EAccountList *account_list; gulong account_added_handler_id; - gulong account_changed_handler_id; CamelStore *local_store; - CamelStore *vfolder_store; FILE *filter_logfile; GHashTable *junk_filters; @@ -109,28 +92,13 @@ struct _AsyncContext { CamelFolder *folder; }; -struct _SourceContext { - EMailSession *session; - CamelService *service; -}; - enum { PROP_0, - PROP_ACCOUNT_STORE, PROP_FOLDER_CACHE, PROP_JUNK_FILTER_NAME, - PROP_LABEL_STORE, - PROP_LOCAL_STORE, - PROP_VFOLDER_STORE + PROP_LOCAL_STORE }; -enum { - ACTIVITY_ADDED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - static const gchar *local_folder_names[E_MAIL_NUM_LOCAL_FOLDERS] = { N_("Inbox"), /* E_MAIL_LOCAL_FOLDER_INBOX */ N_("Drafts"), /* E_MAIL_LOCAL_FOLDER_DRAFTS */ @@ -140,14 +108,19 @@ static const gchar *local_folder_names[E_MAIL_NUM_LOCAL_FOLDERS] = { "Inbox" /* E_MAIL_LOCAL_FOLDER_LOCAL_INBOX */ }; +enum { + FLUSH_OUTBOX, + STORE_ADDED, + STORE_REMOVED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; + static gchar *mail_data_dir; static gchar *mail_cache_dir; static gchar *mail_config_dir; -#if 0 -static MailMsgInfo ms_thread_info_dummy = { sizeof (MailMsg) }; -#endif - G_DEFINE_TYPE_WITH_CODE ( EMailSession, e_mail_session, @@ -156,7 +129,6 @@ G_DEFINE_TYPE_WITH_CODE ( /* Support for CamelSession.alert_user() *************************************/ -static gpointer user_message_dialog; static GQueue user_message_queue = { NULL, NULL, 0 }; struct _user_message_msg { @@ -176,21 +148,15 @@ static void user_message_exec (struct _user_message_msg *m, GError **error); static void -user_message_response_free (GtkDialog *dialog, - gint button) +user_message_response_free (struct _user_message_msg *m) { - struct _user_message_msg *m = NULL; - - gtk_widget_destroy ((GtkWidget *) dialog); - - user_message_dialog = NULL; /* check for pendings */ if (!g_queue_is_empty (&user_message_queue)) { GCancellable *cancellable; m = g_queue_pop_head (&user_message_queue); - cancellable = e_activity_get_cancellable (m->base.activity); + cancellable = m->base.cancellable; user_message_exec (m, cancellable, &m->base.error); mail_msg_unref (m); } @@ -198,17 +164,15 @@ user_message_response_free (GtkDialog *dialog, /* clicked, send back the reply */ static void -user_message_response (GtkDialog *dialog, - gint button, - struct _user_message_msg *m) +user_message_response (struct _user_message_msg *m) { - /* if !m or !button_captions, then we've already replied */ - if (m && m->button_captions) { - m->result = button; + /* if !allow_cancel, then we've already replied */ + if (m->button_captions) { + m->result = TRUE; //If Accepted e_flag_set (m->done); } - user_message_response_free (dialog, button); + user_message_response_free (m); } static void @@ -216,127 +180,14 @@ user_message_exec (struct _user_message_msg *m, GCancellable *cancellable, GError **error) { - gboolean info_only; - GtkWindow *parent; - EShell *shell; - const gchar *error_type; - gint index; - GSList *iter; - - info_only = g_slist_length (m->button_captions) <= 1; - - if (!m->ismain && user_message_dialog != NULL && !info_only) { - g_queue_push_tail (&user_message_queue, mail_msg_ref (m)); - return; - } - - switch (m->type) { - case CAMEL_SESSION_ALERT_INFO: - error_type = "mail:session-message-info"; - break; - case CAMEL_SESSION_ALERT_WARNING: - error_type = "mail:session-message-warning"; - break; - case CAMEL_SESSION_ALERT_ERROR: - error_type = "mail:session-message-error"; - break; - default: - error_type = NULL; - g_return_if_reached (); - } - - shell = e_shell_get_default (); - - /* try to find "mail" view to place the informational alert to */ - if (info_only) { - GtkWindow *active_window; - EShellWindow *shell_window; - EShellView *shell_view; - EShellContent *shell_content = NULL; - - /* check currently active window first, ... */ - active_window = e_shell_get_active_window (shell); - if (active_window && E_IS_SHELL_WINDOW (active_window)) { - if (E_IS_SHELL_WINDOW (active_window)) { - shell_window = E_SHELL_WINDOW (active_window); - shell_view = e_shell_window_peek_shell_view (shell_window, "mail"); - if (shell_view) - shell_content = e_shell_view_get_shell_content (shell_view); - } - } - - if (!shell_content) { - GList *list, *iter; - - list = gtk_application_get_windows (GTK_APPLICATION (shell)); - - /* ...then iterate through all opened windows and pick one which has it */ - for (iter = list; iter != NULL && !shell_content; iter = g_list_next (iter)) { - if (E_IS_SHELL_WINDOW (iter->data)) { - shell_window = iter->data; - shell_view = e_shell_window_peek_shell_view (shell_window, "mail"); - if (shell_view) - shell_content = e_shell_view_get_shell_content (shell_view); - } - } - } - - /* when no shell-content found, which might not happen, but just in case, - process the information alert like usual, through an EAlertDialog machinery - */ - if (shell_content) { - e_alert_submit (E_ALERT_SINK (shell_content), error_type, m->prompt, NULL); - return; - } else if (!m->ismain && user_message_dialog != NULL) { - g_queue_push_tail (&user_message_queue, mail_msg_ref (m)); - return; - } - } - - /* Pull in the active window from the shell to get a parent window */ - parent = e_shell_get_active_window (shell); - user_message_dialog = e_alert_dialog_new_for_args ( - parent, error_type, m->prompt, NULL); - g_object_set (user_message_dialog, "resizable", TRUE, NULL); - - if (m->button_captions) { - GtkWidget *action_area; - GList *children, *child; - - /* remove all default buttons and keep only those requested */ - action_area = gtk_dialog_get_action_area (GTK_DIALOG (user_message_dialog)); - - children = gtk_container_get_children (GTK_CONTAINER (action_area)); - for (child = children; child != NULL; child = child->next) { - gtk_container_remove (GTK_CONTAINER (action_area), child->data); - } - - g_list_free (children); - } - - for (index = 0, iter = m->button_captions; iter; index++, iter = iter->next) { - gtk_dialog_add_button (GTK_DIALOG (user_message_dialog), iter->data, index); - } - /* XXX This is a case where we need to be able to construct * custom EAlerts without a predefined XML definition. */ if (m->ismain) { - gint response; - - response = gtk_dialog_run (user_message_dialog); - user_message_response ( - user_message_dialog, response, m); - } else { - gpointer user_data = m; - - if (g_slist_length (m->button_captions) <= 1) - user_data = NULL; - - g_signal_connect ( - user_message_dialog, "response", - G_CALLBACK (user_message_response), user_data); - gtk_widget_show (user_message_dialog); - } + /* Use DBUS to raise dialogs in clients and reply back. + * For now say accept all. */ + user_message_response (m); + } else + g_queue_push_tail (&user_message_queue, mail_msg_ref (m)); } static void @@ -371,63 +222,17 @@ get_folder (CamelFilterDriver *d, session, uri, 0, NULL, error); } -static gboolean -session_play_sound_cb (const gchar *filename) -{ -#ifdef HAVE_CANBERRA - if (filename != NULL && *filename != '\0') - ca_context_play ( - ca_gtk_context_get (), 0, - CA_PROP_MEDIA_FILENAME, filename, - NULL); - else -#endif - gdk_beep (); - - return FALSE; -} - -static void -session_play_sound (CamelFilterDriver *driver, - const gchar *filename, - gpointer user_data) -{ - g_idle_add_full ( - G_PRIORITY_DEFAULT_IDLE, - (GSourceFunc) session_play_sound_cb, - g_strdup (filename), (GDestroyNotify) g_free); -} - -static void -session_system_beep (CamelFilterDriver *driver, - gpointer user_data) -{ - g_idle_add ((GSourceFunc) session_play_sound_cb, NULL); -} - static CamelFilterDriver * main_get_filter_driver (CamelSession *session, const gchar *type, GError **error) { - EMailSession *ms = E_MAIL_SESSION (session); CamelFilterDriver *driver; - EFilterRule *rule = NULL; - const gchar *config_dir; - gchar *user, *system; + EMailSession *ms = (EMailSession *)session; GSettings *settings; - ERuleContext *fc; settings = g_settings_new ("org.gnome.evolution.mail"); - config_dir = mail_session_get_config_dir (); - user = g_build_filename (config_dir, "filters.xml", NULL); - system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL); - fc = (ERuleContext *) em_filter_context_new (ms); - e_rule_context_load (fc, system, user); - g_free (system); - g_free (user); - driver = camel_filter_driver_new (session); camel_filter_driver_set_folder_func (driver, get_folder, session); @@ -446,52 +251,6 @@ main_get_filter_driver (CamelSession *session, camel_filter_driver_set_logfile (driver, ms->priv->filter_logfile); } - camel_filter_driver_set_shell_func (driver, mail_execute_shell_command, NULL); - camel_filter_driver_set_play_sound_func (driver, session_play_sound, NULL); - camel_filter_driver_set_system_beep_func (driver, session_system_beep, NULL); - - if ((!strcmp (type, E_FILTER_SOURCE_INCOMING) || - !strcmp (type, E_FILTER_SOURCE_JUNKTEST)) - && camel_session_get_check_junk (session)) { - - /* implicit junk check as 1st rule */ - camel_filter_driver_add_rule ( - driver, "Junk check", "(junk-test)", - "(begin (set-system-flag \"junk\"))"); - } - - if (strcmp (type, E_FILTER_SOURCE_JUNKTEST) != 0) { - GString *fsearch, *faction; - - fsearch = g_string_new (""); - faction = g_string_new (""); - - if (!strcmp (type, E_FILTER_SOURCE_DEMAND)) - type = E_FILTER_SOURCE_INCOMING; - - /* add the user-defined rules next */ - while ((rule = e_rule_context_next_rule (fc, rule, type))) { - g_string_truncate (fsearch, 0); - g_string_truncate (faction, 0); - - /* skip disabled rules */ - if (!rule->enabled) - continue; - - e_filter_rule_build_code (rule, fsearch); - em_filter_rule_build_action ( - EM_FILTER_RULE (rule), faction); - camel_filter_driver_add_rule ( - driver, rule->name, - fsearch->str, faction->str); - } - - g_string_free (fsearch, TRUE); - g_string_free (faction, TRUE); - } - - g_object_unref (fc); - g_object_unref (settings); return driver; @@ -504,10 +263,11 @@ static guint preparing_flush = 0; static gboolean forward_to_flush_outbox_cb (EMailSession *session) { - g_return_val_if_fail (preparing_flush != 0, FALSE); preparing_flush = 0; - mail_send (session); + + /* Connect to this and call mail_send in the main email client.*/ + g_signal_emit (session, signals[FLUSH_OUTBOX], 0); return FALSE; } @@ -551,18 +311,6 @@ async_context_free (AsyncContext *context) g_slice_free (AsyncContext, context); } -static void -source_context_free (SourceContext *context) -{ - if (context->session != NULL) - g_object_unref (context->session); - - if (context->service != NULL) - g_object_unref (context->service); - - g_slice_free (SourceContext, context); -} - static gchar * mail_session_make_key (CamelService *service, const gchar *item) @@ -755,60 +503,6 @@ mail_session_account_added_cb (EAccountList *account_list, } static void -mail_session_account_changed_cb (EAccountList *account_list, - EAccount *account, - EMailSession *session) -{ - EMFolderTreeModel *folder_tree_model; - CamelService *service; - - service = camel_session_get_service ( - CAMEL_SESSION (session), account->uid); - - if (!CAMEL_IS_STORE (service)) - return; - - /* Update the display name of the corresponding CamelStore. - * EMailAccountStore listens for "notify" signals from each - * service so it will detect this and update the model. - * - * XXX If EAccount defined GObject properties we could just - * bind EAccount:name to CamelService:display-name and - * be done with it. Oh well. - */ - - camel_service_set_display_name (service, account->name); - - /* Remove the store from the folder tree model and, if the - * account is still enabled, re-add it. Easier than trying - * to update the model with the store in place. - * - * em_folder_tree_model_add_store() already knows which types - * of stores to disregard, so we don't have to deal with that - * here. */ - - folder_tree_model = em_folder_tree_model_get_default (); - - em_folder_tree_model_remove_store ( - folder_tree_model, CAMEL_STORE (service)); - - if (account->enabled) - em_folder_tree_model_add_store ( - folder_tree_model, CAMEL_STORE (service)); -} - -static gboolean -mail_session_add_service_cb (SourceContext *context) -{ - EMailAccountStore *store; - - store = e_mail_session_get_account_store (context->session); - e_mail_account_store_add_service (store, context->service); - - return FALSE; -} - -static void mail_session_add_local_store (EMailSession *session) { CamelLocalSettings *local_settings; @@ -885,38 +579,6 @@ mail_session_add_local_store (EMailSession *session) } static void -mail_session_add_vfolder_store (EMailSession *session) -{ - CamelSession *camel_session; - CamelService *service; - GError *error = NULL; - - camel_session = CAMEL_SESSION (session); - - service = camel_session_add_service ( - camel_session, E_MAIL_SESSION_VFOLDER_UID, - "vfolder", CAMEL_PROVIDER_STORE, &error); - - if (error != NULL) { - g_critical ("%s: %s", G_STRFUNC, error->message); - g_error_free (error); - return; - } - - g_return_if_fail (CAMEL_IS_SERVICE (service)); - - camel_service_set_display_name (service, _("Search Folders")); - em_utils_connect_service_sync (service, NULL, NULL); - - /* XXX There's more configuration to do in vfolder_load_storage() - * but it requires an EMailBackend, which we don't have access - * to from here, so it has to be called from elsewhere. Kinda - * thinking about reworking that... */ - - session->priv->vfolder_store = g_object_ref (service); -} - -static void mail_session_set_property (GObject *object, guint property_id, const GValue *value, @@ -940,13 +602,6 @@ mail_session_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { - case PROP_ACCOUNT_STORE: - g_value_set_object ( - value, - e_mail_session_get_account_store ( - E_MAIL_SESSION (object))); - return; - case PROP_FOLDER_CACHE: g_value_set_object ( value, @@ -961,26 +616,12 @@ mail_session_get_property (GObject *object, E_MAIL_SESSION (object))); return; - case PROP_LABEL_STORE: - g_value_set_object ( - value, - e_mail_session_get_label_store ( - E_MAIL_SESSION (object))); - return; - case PROP_LOCAL_STORE: g_value_set_object ( value, e_mail_session_get_local_store ( E_MAIL_SESSION (object))); return; - - case PROP_VFOLDER_STORE: - g_value_set_object ( - value, - e_mail_session_get_vfolder_store ( - E_MAIL_SESSION (object))); - return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -993,29 +634,15 @@ mail_session_dispose (GObject *object) priv = E_MAIL_SESSION_GET_PRIVATE (object); - if (priv->account_store != NULL) { - e_mail_account_store_clear (priv->account_store); - g_object_unref (priv->account_store); - priv->account_store = NULL; - } - if (priv->folder_cache != NULL) { g_object_unref (priv->folder_cache); priv->folder_cache = NULL; } - if (priv->label_store != NULL) { - g_object_unref (priv->label_store); - priv->label_store = NULL; - } - if (priv->account_list != NULL) { g_signal_handler_disconnect ( priv->account_list, priv->account_added_handler_id); - g_signal_handler_disconnect ( - priv->account_list, - priv->account_changed_handler_id); g_object_unref (priv->account_list); priv->account_list = NULL; } @@ -1025,11 +652,6 @@ mail_session_dispose (GObject *object) priv->local_store = NULL; } - if (priv->vfolder_store != NULL) { - g_object_unref (priv->vfolder_store); - priv->vfolder_store = NULL; - } - g_ptr_array_set_size (priv->local_folders, 0); g_ptr_array_set_size (priv->local_folder_uris, 0); @@ -1079,8 +701,7 @@ mail_session_initialize_stores_idle (gpointer user_data) g_return_val_if_fail (session != NULL, FALSE); - /* Load user-defined mail accounts. */ - account_list = session->priv->account_list; + account_list = e_get_account_list (); iter = e_list_get_iterator (E_LIST (account_list)); while (e_iterator_is_valid (iter)) { @@ -1094,25 +715,12 @@ mail_session_initialize_stores_idle (gpointer user_data) g_object_unref (iter); - /* Initialize which account is default. */ - - account = e_get_default_account (); - if (account != NULL) { - CamelService *service; - - service = camel_session_get_service ( - CAMEL_SESSION (session), account->uid); - e_mail_account_store_set_default_service ( - session->priv->account_store, service); - } - return FALSE; } static void mail_session_constructed (GObject *object) { - EMFolderTreeModel *folder_tree_model; EMailSession *session; EExtensible *extensible; GType extension_type; @@ -1129,27 +737,11 @@ mail_session_constructed (GObject *object) account_list = e_get_account_list (); session->priv->account_list = g_object_ref (account_list); - session->priv->account_store = e_mail_account_store_new (session); - /* This must be created after the account store. */ session->priv->folder_cache = mail_folder_cache_new (session); - /* XXX Make sure the folder tree model is created before we - * add built-in CamelStores so it gets signals from the - * EMailAccountStore. - * - * XXX This is creating a circular reference. Perhaps the - * model should only hold a weak pointer to EMailSession? - * - * FIXME EMailSession should just own the default instance. - */ - folder_tree_model = em_folder_tree_model_get_default (); - em_folder_tree_model_set_session (folder_tree_model, session); - /* Add built-in CamelStores. */ - mail_session_add_local_store (session); - mail_session_add_vfolder_store (session); /* Give it a chance to load user settings, they are not loaded yet. * @@ -1166,11 +758,6 @@ mail_session_constructed (GObject *object) G_CALLBACK (mail_session_account_added_cb), session); session->priv->account_added_handler_id = handler_id; - handler_id = g_signal_connect ( - account_list, "account-changed", - G_CALLBACK (mail_session_account_changed_cb), session); - session->priv->account_changed_handler_id = handler_id; - extensible = E_EXTENSIBLE (object); e_extensible_load_extensions (extensible); @@ -1289,22 +876,6 @@ mail_session_add_service (CamelSession *session, } } - /* Inform the EMailAccountStore of the new CamelService - * from an idle callback so the service has a chance to - * fully initialize first. */ - if (CAMEL_IS_STORE (service)) { - SourceContext *context; - - context = g_slice_new0 (SourceContext); - context->session = g_object_ref (session); - context->service = g_object_ref (service); - - g_idle_add_full ( - G_PRIORITY_DEFAULT_IDLE, - (GSourceFunc) mail_session_add_service_cb, - context, (GDestroyNotify) source_context_free); - } - return service; } @@ -1467,7 +1038,7 @@ mail_session_alert_user (CamelSession *session, if (g_slist_length (button_captions) > 1) mail_msg_ref (m); - cancellable = e_activity_get_cancellable (m->base.activity); + cancellable = m->base.cancellable; if (m->ismain) user_message_exec (m, cancellable, &m->base.error); @@ -1848,17 +1419,6 @@ e_mail_session_class_init (EMailSessionClass *class) g_object_class_install_property ( object_class, - PROP_LABEL_STORE, - g_param_spec_object ( - "label-store", - "Label Store", - "Mail label store", - E_TYPE_MAIL_LABEL_LIST_STORE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_class_install_property ( - object_class, PROP_LOCAL_STORE, g_param_spec_object ( "local-store", @@ -1868,26 +1428,57 @@ e_mail_session_class_init (EMailSessionClass *class) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property ( - object_class, - PROP_VFOLDER_STORE, - g_param_spec_object ( - "vfolder-store", - "Search Folder Store", - "Built-in search folder store", - CAMEL_TYPE_STORE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + /** + * EMailSession::flush-outbox + * @session: the email session + * + * Emitted if the send folder should be flushed. + **/ + signals[FLUSH_OUTBOX] = g_signal_new ( + "flush-outbox", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, /* struct offset */ + NULL, NULL, /* accumulator */ + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + /** + * EMailSession::store-added + * @session: the email session + * @store: the CamelStore + * + * Emitted when a store is added + **/ + signals[STORE_ADDED] = g_signal_new ( + "store-added", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, /* struct offset */ + NULL, NULL, /* accumulator */ + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + CAMEL_TYPE_STORE); + - signals[ACTIVITY_ADDED] = g_signal_new ( - "activity-added", - G_OBJECT_CLASS_TYPE (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMailSessionClass, activity_added), - NULL, NULL, + /** + * EMailSession::store-removed + * @session: the email session + * @store: the CamelStore + * + * Emitted when a store is removed + **/ + signals[STORE_REMOVED] = g_signal_new ( + "store-removed", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST, + 0, /* struct offset */ + NULL, NULL, /* accumulator */ g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - E_TYPE_ACTIVITY); + CAMEL_TYPE_STORE); + + } static void @@ -1901,7 +1492,6 @@ e_mail_session_init (EMailSession *session) (GEqualFunc) g_str_equal); session->priv = E_MAIL_SESSION_GET_PRIVATE (session); - session->priv->label_store = e_mail_label_list_store_new (); session->priv->junk_filters = junk_filters; session->priv->proxy = e_proxy_new (); @@ -1947,24 +1537,6 @@ e_mail_session_new (void) NULL); } -void -e_mail_session_add_activity (EMailSession *session, - EActivity *activity) -{ - g_return_if_fail (E_IS_MAIL_SESSION (session)); - g_return_if_fail (E_IS_ACTIVITY (activity)); - - g_signal_emit (session, signals[ACTIVITY_ADDED], 0, activity); -} - -EMailAccountStore * -e_mail_session_get_account_store (EMailSession *session) -{ - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - - return session->priv->account_store; -} - MailFolderCache * e_mail_session_get_folder_cache (EMailSession *session) { @@ -1973,14 +1545,6 @@ e_mail_session_get_folder_cache (EMailSession *session) return session->priv->folder_cache; } -EMailLabelListStore * -e_mail_session_get_label_store (EMailSession *session) -{ - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - - return session->priv->label_store; -} - CamelStore * e_mail_session_get_local_store (EMailSession *session) { @@ -1989,14 +1553,6 @@ e_mail_session_get_local_store (EMailSession *session) return session->priv->local_store; } -CamelStore * -e_mail_session_get_vfolder_store (EMailSession *session) -{ - g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); - - return session->priv->vfolder_store; -} - CamelFolder * e_mail_session_get_local_folder (EMailSession *session, EMailLocalFolder type) diff --git a/mail/e-mail-session.h b/libemail-engine/e-mail-session.h index 7f5f22de27..af7892dc22 100644 --- a/mail/e-mail-session.h +++ b/libemail-engine/e-mail-session.h @@ -26,11 +26,8 @@ #define E_MAIL_SESSION_H #include <camel/camel.h> -#include <e-util/e-activity.h> -#include <mail/e-mail-enums.h> -#include <mail/e-mail-account-store.h> -#include <mail/e-mail-label-list-store.h> -#include <mail/mail-folder-cache.h> +#include <libemail-engine/e-mail-enums.h> +#include <libemail-engine/mail-folder-cache.h> /* Standard GObject macros */ #define E_TYPE_MAIL_SESSION \ @@ -68,25 +65,13 @@ struct _EMailSession { struct _EMailSessionClass { CamelSessionClass parent_class; - - void (*activity_added) (EMailSession *session, - EActivity *activity); }; GType e_mail_session_get_type (void); EMailSession * e_mail_session_new (void); -void e_mail_session_add_activity (EMailSession *session, - EActivity *activity); -EMailAccountStore * - e_mail_session_get_account_store - (EMailSession *session); MailFolderCache * e_mail_session_get_folder_cache (EMailSession *session); -EMailLabelListStore * - e_mail_session_get_label_store (EMailSession *session); CamelStore * e_mail_session_get_local_store (EMailSession *session); -CamelStore * e_mail_session_get_vfolder_store - (EMailSession *session); CamelFolder * e_mail_session_get_local_folder (EMailSession *session, EMailLocalFolder type); const gchar * e_mail_session_get_local_folder_uri diff --git a/mail/e-mail-store-utils.c b/libemail-engine/e-mail-store-utils.c index 7f978c8b7f..757f86dfd5 100644 --- a/mail/e-mail-store-utils.c +++ b/libemail-engine/e-mail-store-utils.c @@ -20,7 +20,7 @@ #include <config.h> #endif -#include "em-utils.h" +#include "e-mail-utils.h" #include "e-mail-store-utils.h" diff --git a/mail/e-mail-store-utils.h b/libemail-engine/e-mail-store-utils.h index de4484c020..de4484c020 100644 --- a/mail/e-mail-store-utils.h +++ b/libemail-engine/e-mail-store-utils.h diff --git a/libemail-engine/e-mail-utils.c b/libemail-engine/e-mail-utils.c new file mode 100644 index 0000000000..05f5381147 --- /dev/null +++ b/libemail-engine/e-mail-utils.c @@ -0,0 +1,1062 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Authors: + * Srinivasa Ragavan <sragavan@gnome.org> + * + * + */ + +#include <stdio.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> +#include <time.h> + +#include <glib/gstdio.h> + +#ifdef G_OS_WIN32 +/* Work around namespace clobbage in <windows.h> */ +#define DATADIR windows_DATADIR +#include <windows.h> +#undef DATADIR +#undef interface +#endif + +#include <libebook/e-book-client.h> +#include <libebook/e-book-query.h> + + +#include <glib/gi18n.h> + +#include <gio/gio.h> + +#include <libedataserver/e-data-server-util.h> +#include <libedataserver/e-flag.h> +#include <libedataserver/e-proxy.h> + +#include "libemail-utils/e-account-utils.h" +#include "libemail-utils/mail-mt.h" + +#include "e-mail-folder-utils.h" +#include "e-mail-session.h" +#include "e-mail-utils.h" +#include "mail-tools.h" + +#define d(x) + +/** + * em_utils_folder_is_templates: + * @folder: a #CamelFolder + * + * Decides if @folder is a Templates folder. + * + * Returns %TRUE if this is a Templates folder or %FALSE otherwise. + **/ + +gboolean +em_utils_folder_is_templates (CamelFolder *folder) +{ + CamelFolder *local_templates_folder; + CamelSession *session; + CamelStore *store; + EAccountList *account_list; + EIterator *iterator; + gchar *folder_uri; + gboolean is_templates = FALSE; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); + + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); + + local_templates_folder = + e_mail_session_get_local_folder ( + E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_TEMPLATES); + + if (folder == local_templates_folder) + return TRUE; + + folder_uri = e_mail_folder_uri_from_folder (folder); + + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (!is_templates && e_iterator_is_valid (iterator)) { + EAccount *account; + + /* XXX EIterator misuses const. */ + account = (EAccount *) e_iterator_get (iterator); + + if (account->templates_folder_uri != NULL) + is_templates = e_mail_folder_uri_equal ( + session, folder_uri, + account->templates_folder_uri); + + e_iterator_next (iterator); + } + + g_object_unref (iterator); + g_free (folder_uri); + + return is_templates; +} + +/** + * em_utils_folder_is_drafts: + * @folder: a #CamelFolder + * + * Decides if @folder is a Drafts folder. + * + * Returns %TRUE if this is a Drafts folder or %FALSE otherwise. + **/ +gboolean +em_utils_folder_is_drafts (CamelFolder *folder) +{ + CamelFolder *local_drafts_folder; + CamelSession *session; + CamelStore *store; + EAccountList *account_list; + EIterator *iterator; + gchar *folder_uri; + gboolean is_drafts = FALSE; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); + + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); + + local_drafts_folder = + e_mail_session_get_local_folder ( + E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_DRAFTS); + + if (folder == local_drafts_folder) + return TRUE; + + folder_uri = e_mail_folder_uri_from_folder (folder); + + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (!is_drafts && e_iterator_is_valid (iterator)) { + EAccount *account; + + /* XXX EIterator misuses const. */ + account = (EAccount *) e_iterator_get (iterator); + + if (account->drafts_folder_uri != NULL) + is_drafts = e_mail_folder_uri_equal ( + session, folder_uri, + account->drafts_folder_uri); + + e_iterator_next (iterator); + } + + g_object_unref (iterator); + g_free (folder_uri); + + return is_drafts; +} + +/** + * em_utils_folder_is_sent: + * @folder: a #CamelFolder + * + * Decides if @folder is a Sent folder. + * + * Returns %TRUE if this is a Sent folder or %FALSE otherwise. + **/ +gboolean +em_utils_folder_is_sent (CamelFolder *folder) +{ + CamelFolder *local_sent_folder; + CamelSession *session; + CamelStore *store; + EAccountList *account_list; + EIterator *iterator; + gchar *folder_uri; + gboolean is_sent = FALSE; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); + + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); + + local_sent_folder = + e_mail_session_get_local_folder ( + E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_SENT); + + if (folder == local_sent_folder) + return TRUE; + + folder_uri = e_mail_folder_uri_from_folder (folder); + + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (!is_sent && e_iterator_is_valid (iterator)) { + EAccount *account; + + /* XXX EIterator misuses const. */ + account = (EAccount *) e_iterator_get (iterator); + + if (account->sent_folder_uri != NULL) + is_sent = e_mail_folder_uri_equal ( + session, folder_uri, + account->sent_folder_uri); + + e_iterator_next (iterator); + } + + g_object_unref (iterator); + g_free (folder_uri); + + return is_sent; +} + +/** + * em_utils_folder_is_outbox: + * @folder: a #CamelFolder + * + * Decides if @folder is an Outbox folder. + * + * Returns %TRUE if this is an Outbox folder or %FALSE otherwise. + **/ +gboolean +em_utils_folder_is_outbox (CamelFolder *folder) +{ + CamelStore *store; + CamelSession *session; + CamelFolder *local_outbox_folder; + + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); + + store = camel_folder_get_parent_store (folder); + session = camel_service_get_session (CAMEL_SERVICE (store)); + + local_outbox_folder = + e_mail_session_get_local_folder ( + E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_OUTBOX); + + return (folder == local_outbox_folder); +} + +/* ********************************************************************** */ + + +/* runs sync, in main thread */ +static gpointer +emu_addr_setup (gpointer user_data) +{ + GError *err = NULL; + ESourceList **psource_list = user_data; + + if (!e_book_client_get_sources (psource_list, &err)) + g_error_free (err); + + return NULL; +} + +static void +emu_addr_cancel_stop (gpointer data) +{ + gboolean *stop = data; + + g_return_if_fail (stop != NULL); + + *stop = TRUE; +} + +static void +emu_addr_cancel_cancellable (gpointer data) +{ + GCancellable *cancellable = data; + + g_return_if_fail (cancellable != NULL); + + g_cancellable_cancel (cancellable); +} + +struct TryOpenEBookStruct { + GError **error; + EFlag *flag; + gboolean result; +}; + +static void +try_open_book_client_cb (GObject *source_object, + GAsyncResult *result, + gpointer closure) +{ + EBookClient *book_client = E_BOOK_CLIENT (source_object); + struct TryOpenEBookStruct *data = (struct TryOpenEBookStruct *) closure; + GError *error = NULL; + + if (!data) + return; + + e_client_open_finish (E_CLIENT (book_client), result, &error); + + data->result = error == NULL; + + if (!data->result) { + g_clear_error (data->error); + g_propagate_error (data->error, error); + } + + e_flag_set (data->flag); +} + +/* + * try_open_book_client: + * Tries to open address book asynchronously, but acts as synchronous. + * The advantage is it checks periodically whether the camel_operation + * has been canceled or not, and if so, then stops immediately, with + * result FALSE. Otherwise returns same as e_client_open() + */ +static gboolean +try_open_book_client (EBookClient *book_client, + gboolean only_if_exists, + GCancellable *cancellable, + GError **error) +{ + struct TryOpenEBookStruct data; + gboolean canceled = FALSE; + EFlag *flag = e_flag_new (); + + data.error = error; + data.flag = flag; + data.result = FALSE; + + e_client_open ( + E_CLIENT (book_client), only_if_exists, + cancellable, try_open_book_client_cb, &data); + + while (canceled = g_cancellable_is_cancelled (cancellable), + !canceled && !e_flag_is_set (flag)) { + GTimeVal wait; + + g_get_current_time (&wait); + g_time_val_add (&wait, 250000); /* waits 250ms */ + + e_flag_timed_wait (flag, &wait); + } + + if (canceled) { + g_cancellable_cancel (cancellable); + + g_clear_error (error); + g_propagate_error ( + error, e_client_error_create ( + E_CLIENT_ERROR_CANCELLED, NULL)); + } + + e_flag_wait (flag); + e_flag_free (flag); + + return data.result && (!error || !*error); +} + + +#define NOT_FOUND_BOOK (GINT_TO_POINTER (1)) + +G_LOCK_DEFINE_STATIC (contact_cache); + +/* key is lowercased contact email; value is EBook pointer + * (just for comparison) where it comes from */ +static GHashTable *contact_cache = NULL; + +/* key is source ID; value is pointer to EBook */ +static GHashTable *emu_books_hash = NULL; + +/* key is source ID; value is same pointer as key; this is hash of + * broken books, which failed to open for some reason */ +static GHashTable *emu_broken_books_hash = NULL; + +static ESourceList *emu_books_source_list = NULL; + +static gboolean +search_address_in_addressbooks (const gchar *address, + gboolean local_only, + gboolean (*check_contact) (EContact *contact, + gpointer user_data), + gpointer user_data) +{ + gboolean found = FALSE, stop = FALSE, found_any = FALSE; + gchar *lowercase_addr; + gpointer ptr; + EBookQuery *book_query; + gchar *query; + GSList *s, *g, *addr_sources = NULL; + GHook *hook_cancellable; + GCancellable *cancellable; + + if (!address || !*address) + return FALSE; + + G_LOCK (contact_cache); + + if (!emu_books_source_list) { + mail_call_main ( + MAIL_CALL_p_p, (MailMainFunc) + emu_addr_setup, &emu_books_source_list); + emu_books_hash = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, g_object_unref); + emu_broken_books_hash = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, NULL); + contact_cache = g_hash_table_new_full ( + g_str_hash, g_str_equal, g_free, NULL); + } + + if (!emu_books_source_list) { + G_UNLOCK (contact_cache); + return FALSE; + } + + lowercase_addr = g_utf8_strdown (address, -1); + ptr = g_hash_table_lookup (contact_cache, lowercase_addr); + if (ptr != NULL && (check_contact == NULL || ptr == NOT_FOUND_BOOK)) { + g_free (lowercase_addr); + G_UNLOCK (contact_cache); + return ptr != NOT_FOUND_BOOK; + } + + book_query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address); + query = e_book_query_to_string (book_query); + e_book_query_unref (book_query); + + for (g = e_source_list_peek_groups (emu_books_source_list); + g; g = g_slist_next (g)) { + ESourceGroup *group = g->data; + + if (!group) + continue; + + if (local_only && !(e_source_group_peek_base_uri (group) && + g_str_has_prefix ( + e_source_group_peek_base_uri (group), "local:"))) + continue; + + for (s = e_source_group_peek_sources (group); s; s = g_slist_next (s)) { + ESource *source = s->data; + const gchar *completion = e_source_get_property (source, "completion"); + + if (completion && g_ascii_strcasecmp (completion, "true") == 0) { + addr_sources = g_slist_prepend (addr_sources, g_object_ref (source)); + } + } + } + + cancellable = g_cancellable_new (); + hook_cancellable = mail_cancel_hook_add (emu_addr_cancel_cancellable, cancellable); + + for (s = addr_sources; !stop && !found && s; s = g_slist_next (s)) { + ESource *source = s->data; + GSList *contacts; + EBookClient *book_client = NULL; + GHook *hook_stop; + gboolean cached_book = FALSE; + const gchar *display_name; + const gchar *uid; + GError *err = NULL; + + uid = e_source_peek_uid (source); + display_name = e_source_peek_name (source); + + /* failed to load this book last time, skip it now */ + if (g_hash_table_lookup (emu_broken_books_hash, uid) != NULL) { + d(printf ("%s: skipping broken book '%s'\n", + G_STRFUNC, display_name)); + continue; + } + + d(printf(" checking '%s'\n", e_source_get_uri(source))); + + hook_stop = mail_cancel_hook_add (emu_addr_cancel_stop, &stop); + + book_client = g_hash_table_lookup (emu_books_hash, uid); + if (!book_client) { + book_client = e_book_client_new (source, &err); + + if (book_client == NULL) { + if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))) { + stop = TRUE; + } else if (err) { + gchar *source_uid; + + source_uid = g_strdup (uid); + + g_hash_table_insert ( + emu_broken_books_hash, + source_uid, source_uid); + + g_warning ( + "%s: Unable to create addressbook '%s': %s", + G_STRFUNC, + display_name, + err->message); + } + g_clear_error (&err); + } else if (!stop && !try_open_book_client (book_client, TRUE, cancellable, &err)) { + g_object_unref (book_client); + book_client = NULL; + + if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))) { + stop = TRUE; + } else if (err) { + gchar *source_uid; + + source_uid = g_strdup (uid); + + g_hash_table_insert ( + emu_broken_books_hash, + source_uid, source_uid); + + g_warning ( + "%s: Unable to open addressbook '%s': %s", + G_STRFUNC, + display_name, + err->message); + } + g_clear_error (&err); + } + } else { + cached_book = TRUE; + } + + if (book_client && !stop && e_book_client_get_contacts_sync (book_client, query, &contacts, cancellable, &err)) { + if (contacts != NULL) { + if (!found_any) { + g_hash_table_insert (contact_cache, g_strdup (lowercase_addr), book_client); + } + found_any = TRUE; + + if (check_contact) { + GSList *l; + + for (l = contacts; l && !found; l = l->next) { + EContact *contact = l->data; + + found = check_contact (contact, user_data); + } + } else { + found = TRUE; + } + + g_slist_foreach (contacts, (GFunc) g_object_unref, NULL); + g_slist_free (contacts); + } + } else if (book_client) { + stop = stop || (err && + (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || + g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))); + if (err && !stop) { + gchar *source_uid = g_strdup (uid); + + g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid); + + g_warning ( + "%s: Can't get contacts from '%s': %s", + G_STRFUNC, + display_name, + err->message); + } + g_clear_error (&err); + } + + mail_cancel_hook_remove (hook_stop); + + if (stop && !cached_book && book_client) { + g_object_unref (book_client); + } else if (!stop && book_client && !cached_book) { + g_hash_table_insert ( + emu_books_hash, g_strdup (uid), book_client); + } + } + + mail_cancel_hook_remove (hook_cancellable); + g_object_unref (cancellable); + + g_slist_free_full (addr_sources, (GDestroyNotify) g_object_unref); + + g_free (query); + + if (!found_any) { + g_hash_table_insert (contact_cache, lowercase_addr, NOT_FOUND_BOOK); + lowercase_addr = NULL; + } + + G_UNLOCK (contact_cache); + + g_free (lowercase_addr); + + return found_any; +} + +gboolean +em_utils_in_addressbook (CamelInternetAddress *iaddr, + gboolean local_only) +{ + const gchar *addr; + + /* TODO: check all addresses? */ + if (iaddr == NULL || !camel_internet_address_get (iaddr, 0, NULL, &addr)) + return FALSE; + + return search_address_in_addressbooks (addr, local_only, NULL, NULL); +} + +static gboolean +extract_photo_data (EContact *contact, + gpointer user_data) +{ + EContactPhoto **photo = user_data; + + g_return_val_if_fail (contact != NULL, FALSE); + g_return_val_if_fail (user_data != NULL, FALSE); + + *photo = e_contact_get (contact, E_CONTACT_PHOTO); + if (!*photo) + *photo = e_contact_get (contact, E_CONTACT_LOGO); + + return *photo != NULL; +} + +typedef struct _PhotoInfo { + gchar *address; + EContactPhoto *photo; +} PhotoInfo; + +static void +emu_free_photo_info (PhotoInfo *pi) +{ + if (!pi) + return; + + if (pi->address) + g_free (pi->address); + if (pi->photo) + e_contact_photo_free (pi->photo); + g_free (pi); +} + +G_LOCK_DEFINE_STATIC (photos_cache); +static GSList *photos_cache = NULL; /* list of PhotoInfo-s */ + +CamelMimePart * +em_utils_contact_photo (CamelInternetAddress *cia, + gboolean local_only) +{ + const gchar *addr = NULL; + CamelMimePart *part = NULL; + EContactPhoto *photo = NULL; + GSList *p, *first_not_null = NULL; + gint count_not_null = 0; + + if (cia == NULL || !camel_internet_address_get (cia, 0, NULL, &addr) || !addr) { + return NULL; + } + + G_LOCK (photos_cache); + + /* search a cache first */ + for (p = photos_cache; p; p = p->next) { + PhotoInfo *pi = p->data; + + if (!pi) + continue; + + if (pi->photo) { + if (!first_not_null) + first_not_null = p; + count_not_null++; + } + + if (g_ascii_strcasecmp (addr, pi->address) == 0) { + photo = pi->photo; + break; + } + } + + /* !p means the address had not been found in the cache */ + if (!p && search_address_in_addressbooks ( + addr, local_only, extract_photo_data, &photo)) { + PhotoInfo *pi; + + if (photo && photo->type != E_CONTACT_PHOTO_TYPE_INLINED) { + e_contact_photo_free (photo); + photo = NULL; + } + + /* keep only up to 10 photos in memory */ + if (photo && count_not_null >= 10 && first_not_null) { + pi = first_not_null->data; + + photos_cache = g_slist_remove (photos_cache, pi); + + emu_free_photo_info (pi); + } + + pi = g_new0 (PhotoInfo, 1); + pi->address = g_strdup (addr); + pi->photo = photo; + + photos_cache = g_slist_append (photos_cache, pi); + } + + /* some photo found, use it */ + if (photo) { + /* Form a mime part out of the photo */ + part = camel_mime_part_new (); + camel_mime_part_set_content (part, + (const gchar *) photo->data.inlined.data, + photo->data.inlined.length, "image/jpeg"); + } + + G_UNLOCK (photos_cache); + + return part; +} + +/* list of email addresses (strings) to remove from local cache of photos and + * contacts, but only if the photo doesn't exist or is an not-found contact */ +void +emu_remove_from_mail_cache (const GSList *addresses) +{ + const GSList *a; + GSList *p; + CamelInternetAddress *cia; + + cia = camel_internet_address_new (); + + for (a = addresses; a; a = a->next) { + const gchar *addr = NULL; + + if (!a->data) + continue; + + if (camel_address_decode ((CamelAddress *) cia, a->data) != -1 && + camel_internet_address_get (cia, 0, NULL, &addr) && addr) { + gchar *lowercase_addr = g_utf8_strdown (addr, -1); + + G_LOCK (contact_cache); + if (g_hash_table_lookup (contact_cache, lowercase_addr) == NOT_FOUND_BOOK) + g_hash_table_remove (contact_cache, lowercase_addr); + G_UNLOCK (contact_cache); + + g_free (lowercase_addr); + + G_LOCK (photos_cache); + for (p = photos_cache; p; p = p->next) { + PhotoInfo *pi = p->data; + + if (pi && !pi->photo && g_ascii_strcasecmp (pi->address, addr) == 0) { + photos_cache = g_slist_remove (photos_cache, pi); + emu_free_photo_info (pi); + break; + } + } + G_UNLOCK (photos_cache); + } + } + + g_object_unref (cia); +} + + +void +emu_remove_from_mail_cache_1 (const gchar *address) +{ + GSList *l; + + g_return_if_fail (address != NULL); + + l = g_slist_append (NULL, (gpointer) address); + + emu_remove_from_mail_cache (l); + + g_slist_free (l); +} + +/* frees all data created by call of em_utils_in_addressbook() or + * em_utils_contact_photo() */ +void +emu_free_mail_cache (void) +{ + G_LOCK (contact_cache); + + if (emu_books_hash) { + g_hash_table_destroy (emu_books_hash); + emu_books_hash = NULL; + } + + if (emu_broken_books_hash) { + g_hash_table_destroy (emu_broken_books_hash); + emu_broken_books_hash = NULL; + } + + if (emu_books_source_list) { + g_object_unref (emu_books_source_list); + emu_books_source_list = NULL; + } + + if (contact_cache) { + g_hash_table_destroy (contact_cache); + contact_cache = NULL; + } + + G_UNLOCK (contact_cache); + + G_LOCK (photos_cache); + + g_slist_foreach (photos_cache, (GFunc) emu_free_photo_info, NULL); + g_slist_free (photos_cache); + photos_cache = NULL; + + G_UNLOCK (photos_cache); +} + +static EAccount * +guess_account_from_folder (CamelFolder *folder) +{ + CamelStore *store; + const gchar *uid; + + store = camel_folder_get_parent_store (folder); + uid = camel_service_get_uid (CAMEL_SERVICE (store)); + + return e_get_account_by_uid (uid); +} + +static EAccount * +guess_account_from_message (CamelMimeMessage *message) +{ + const gchar *uid; + + uid = camel_mime_message_get_source (message); + + return (uid != NULL) ? e_get_account_by_uid (uid) : NULL; +} + +EAccount * +em_utils_guess_account (CamelMimeMessage *message, + CamelFolder *folder) +{ + EAccount *account = NULL; + + g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); + + if (folder != NULL) + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); + + /* check for newsgroup header */ + if (folder != NULL + && camel_medium_get_header (CAMEL_MEDIUM (message), "Newsgroups")) + account = guess_account_from_folder (folder); + + /* check for source folder */ + if (account == NULL && folder != NULL) + account = guess_account_from_folder (folder); + + /* then message source */ + if (account == NULL) + account = guess_account_from_message (message); + + return account; +} + +EAccount * +em_utils_guess_account_with_recipients (CamelMimeMessage *message, + CamelFolder *folder) +{ + EAccount *account = NULL; + EAccountList *account_list; + GHashTable *recipients; + EIterator *iterator; + CamelInternetAddress *addr; + const gchar *type; + const gchar *key; + + /* This policy is subject to debate and tweaking, + * but please also document the rational here. */ + + g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); + + /* Build a set of email addresses in which to test for membership. + * Only the keys matter here; the values just need to be non-NULL. */ + recipients = g_hash_table_new (g_str_hash, g_str_equal); + + type = CAMEL_RECIPIENT_TYPE_TO; + addr = camel_mime_message_get_recipients (message, type); + if (addr != NULL) { + gint index = 0; + + while (camel_internet_address_get (addr, index++, NULL, &key)) + g_hash_table_insert ( + recipients, (gpointer) key, + GINT_TO_POINTER (1)); + } + + type = CAMEL_RECIPIENT_TYPE_CC; + addr = camel_mime_message_get_recipients (message, type); + if (addr != NULL) { + gint index = 0; + + while (camel_internet_address_get (addr, index++, NULL, &key)) + g_hash_table_insert ( + recipients, (gpointer) key, + GINT_TO_POINTER (1)); + } + + /* First Preference: We were given a folder that maps to an + * enabled account, and that account's email address appears + * in the list of To: or Cc: recipients. */ + + if (folder != NULL) + account = guess_account_from_folder (folder); + + if (account == NULL || !account->enabled) + goto second_preference; + + if ((key = account->id->address) == NULL) + goto second_preference; + + if (g_hash_table_lookup (recipients, key) != NULL) + goto exit; + +second_preference: + + /* Second Preference: Choose any enabled account whose email + * address appears in the list to To: or Cc: recipients. */ + + account_list = e_get_account_list (); + iterator = e_list_get_iterator (E_LIST (account_list)); + + while (e_iterator_is_valid (iterator)) { + account = (EAccount *) e_iterator_get (iterator); + e_iterator_next (iterator); + + if (account == NULL || !account->enabled) + continue; + + if ((key = account->id->address) == NULL) + continue; + + if (g_hash_table_lookup (recipients, key) != NULL) { + g_object_unref (iterator); + goto exit; + } + } + g_object_unref (iterator); + + /* Last Preference: Defer to em_utils_guess_account(). */ + account = em_utils_guess_account (message, folder); + +exit: + g_hash_table_destroy (recipients); + + return account; +} + +static void +cancel_service_connect_cb (GCancellable *cancellable, + CamelService *service) +{ + g_return_if_fail (CAMEL_IS_SERVICE (service)); + + camel_service_cancel_connect (service); +} + +gboolean +em_utils_connect_service_sync (CamelService *service, + GCancellable *cancellable, + GError **error) +{ + gboolean res; + gulong handler_id = 0; + + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + + if (cancellable != NULL) + handler_id = g_cancellable_connect ( + cancellable, + G_CALLBACK (cancel_service_connect_cb), + service, NULL); + + res = camel_service_connect_sync (service, error); + + if (handler_id) + g_cancellable_disconnect (cancellable, handler_id); + + return res; +} + +gboolean +em_utils_disconnect_service_sync (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error) +{ + gboolean res; + gulong handler_id = 0; + + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + + if (cancellable != NULL) + handler_id = g_cancellable_connect ( + cancellable, + G_CALLBACK (cancel_service_connect_cb), + service, NULL); + + res = camel_service_disconnect_sync (service, clean, error); + + if (handler_id) + g_cancellable_disconnect (cancellable, handler_id); + + return res; +} + +/** + * em_utils_uids_free: + * @uids: array of uids + * + * Frees the array of uids pointed to by @uids back to the system. + **/ +void +em_utils_uids_free (GPtrArray *uids) +{ + gint i; + + for (i = 0; i < uids->len; i++) + g_free (uids->pdata[i]); + + g_ptr_array_free (uids, TRUE); +} + +/* Returns TRUE if CamelURL points to a local mbox file. */ +gboolean +em_utils_is_local_delivery_mbox_file (CamelURL *url) +{ + g_return_val_if_fail (url != NULL, FALSE); + + return g_str_equal (url->protocol, "mbox") && + (url->path != NULL) && + g_file_test (url->path, G_FILE_TEST_EXISTS) && + !g_file_test (url->path, G_FILE_TEST_IS_DIR); +} + diff --git a/libemail-engine/e-mail-utils.h b/libemail-engine/e-mail-utils.h new file mode 100644 index 0000000000..144f13dfdd --- /dev/null +++ b/libemail-engine/e-mail-utils.h @@ -0,0 +1,56 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Authors: + * Srinivasa Ragavan <sragavan@gnome.org> + * + * + */ + +#ifndef E_MAIL_UTILS_H +#define E_MAIL_UTILS_H + +#include <camel/camel.h> +#include <libedataserver/e-account.h> + +gboolean em_utils_folder_is_drafts (CamelFolder *folder); +gboolean em_utils_folder_is_templates (CamelFolder *folder); +gboolean em_utils_folder_is_sent (CamelFolder *folder); +gboolean em_utils_folder_is_outbox (CamelFolder *folder); +gboolean em_utils_in_addressbook (CamelInternetAddress *addr, + gboolean local_only); +CamelMimePart * em_utils_contact_photo (CamelInternetAddress *addr, + gboolean local); +EAccount * em_utils_guess_account (CamelMimeMessage *message, + CamelFolder *folder); +EAccount * em_utils_guess_account_with_recipients + (CamelMimeMessage *message, + CamelFolder *folder); +void emu_remove_from_mail_cache (const GSList *addresses); +void emu_remove_from_mail_cache_1 (const gchar *address); +void emu_free_mail_cache (void); +gboolean em_utils_connect_service_sync (CamelService *service, + GCancellable *cancellable, + GError **error); +gboolean em_utils_disconnect_service_sync + (CamelService *service, + gboolean clean, + GCancellable *cancellable, + GError **error); +void em_utils_uids_free (GPtrArray *uids); +gboolean em_utils_is_local_delivery_mbox_file + (CamelURL *url); + +#endif /* E_MAIL_UTILS_H */ diff --git a/libemail-engine/libemail-engine.pc.in b/libemail-engine/libemail-engine.pc.in new file mode 100644 index 0000000000..1d915bcf33 --- /dev/null +++ b/libemail-engine/libemail-engine.pc.in @@ -0,0 +1,15 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +datadir=@datadir@ + +privincludedir=@privincludedir@ + +Name: libemail-engine +Description: Client library for evolution mail +Version: @VERSION@ +Requires: libemail-utils +Libs: -L${libdir} -lemail-engine +Cflags: -I${privincludedir} diff --git a/mail/mail-config.c b/libemail-engine/mail-config.c index fc003acbde..51d34a0714 100644 --- a/mail/mail-config.c +++ b/libemail-engine/mail-config.c @@ -31,9 +31,8 @@ #include <libedataserver/e-data-server-util.h> -#include <e-util/e-util.h> -#include "e-util/e-account-utils.h" -#include "e-util/e-signature-utils.h" +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/e-signature-utils.h> #include "e-mail-folder-utils.h" #include "mail-config.h" diff --git a/mail/mail-config.h b/libemail-engine/mail-config.h index 29038093cb..0a1c618f35 100644 --- a/mail/mail-config.h +++ b/libemail-engine/mail-config.h @@ -23,7 +23,7 @@ #ifndef MAIL_CONFIG_H #define MAIL_CONFIG_H -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> G_BEGIN_DECLS diff --git a/mail/mail-folder-cache.c b/libemail-engine/mail-folder-cache.c index 4092ee6861..954c14d379 100644 --- a/mail/mail-folder-cache.c +++ b/libemail-engine/mail-folder-cache.c @@ -39,18 +39,17 @@ #include <glib/gstdio.h> #include <libedataserver/e-data-server-util.h> -#include <e-util/e-marshal.h> -#include <e-util/e-util.h> -#include "mail-mt.h" +#include <libemail-utils/mail-mt.h> + #include "mail-folder-cache.h" #include "mail-ops.h" #include "mail-tools.h" - -#include "em-utils.h" +#include "e-mail-utils.h" #include "e-mail-folder-utils.h" #include "e-mail-session.h" #include "e-mail-store-utils.h" +#include "mail-config.h" #define w(x) #define d(x) @@ -65,7 +64,6 @@ typedef struct _StoreInfo StoreInfo; struct _MailFolderCachePrivate { gpointer session; /* weak pointer */ - EMailAccountStore *account_store; /* source id for the ping timeout callback */ guint ping_id; @@ -273,7 +271,7 @@ flush_updates_idle_cb (MailFolderCache *cache) if (CAMEL_IS_VEE_STORE (up->store) && !up->remove) { /* Normally the vfolder store takes care of the - * folder_opened event itcache, but we add folder to + * folder_opened event itself, but we add folder to * the noting system later, thus we do not know about * search folders to update them in a tree, thus * ensure their changes will be tracked correctly. */ @@ -1046,56 +1044,6 @@ storeinfo_find_folder_info (CamelStore *store, } static void -mail_folder_cache_service_removed (EMailAccountStore *account_store, - CamelService *service, - MailFolderCache *cache) -{ - StoreInfo *si; - - if (cache->priv->stores == NULL) - return; - - g_mutex_lock (cache->priv->stores_mutex); - - si = g_hash_table_lookup (cache->priv->stores, service); - if (si != NULL) { - g_hash_table_remove (cache->priv->stores, service); - - g_signal_handlers_disconnect_matched ( - service, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, cache); - - g_hash_table_foreach ( - si->folders, (GHFunc) - unset_folder_info_hash, cache); - - store_info_free (si); - } - - g_mutex_unlock (cache->priv->stores_mutex); -} - -static void -mail_folder_cache_service_enabled (EMailAccountStore *account_store, - CamelService *service, - MailFolderCache *cache) -{ - mail_folder_cache_note_store ( - cache, CAMEL_STORE (service), NULL, NULL, NULL); -} - -static void -mail_folder_cache_service_disabled (EMailAccountStore *account_store, - CamelService *service, - MailFolderCache *cache) -{ - /* To the folder cache, disabling a service is the same as - * removing it. We keep a separate callback function only - * to use as a breakpoint target in a debugger. */ - mail_folder_cache_service_removed (account_store, service, cache); -} - -static void mail_folder_cache_set_session (MailFolderCache *cache, EMailSession *session) { @@ -1157,14 +1105,6 @@ mail_folder_cache_dispose (GObject *object) priv->session = NULL; } - if (priv->account_store != NULL) { - g_signal_handlers_disconnect_matched ( - priv->account_store, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, object); - g_object_unref (priv->account_store); - priv->account_store = NULL; - } - /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (mail_folder_cache_parent_class)->dispose (object); } @@ -1200,41 +1140,6 @@ mail_folder_cache_finalize (GObject *object) } static void -mail_folder_cache_constructed (GObject *object) -{ - MailFolderCache *cache; - EMailSession *session; - EMailAccountStore *account_store; - - cache = MAIL_FOLDER_CACHE (object); - - /* Chain up to parent's constructed() method. */ - G_OBJECT_CLASS (mail_folder_cache_parent_class)->constructed (object); - - session = mail_folder_cache_get_session (cache); - account_store = e_mail_session_get_account_store (session); - - cache->priv->account_store = g_object_ref (account_store); - - /* No need to connect to "service-added" emissions since it's - * always immediately followed by either "service-enabled" or - * "service-disabled". */ - - g_signal_connect ( - account_store, "service-removed", - G_CALLBACK (mail_folder_cache_service_removed), cache); - - g_signal_connect ( - account_store, "service-enabled", - G_CALLBACK (mail_folder_cache_service_enabled), cache); - - g_signal_connect ( - account_store, "service-disabled", - G_CALLBACK (mail_folder_cache_service_disabled), cache); - -} - -static void mail_folder_cache_folder_available (MailFolderCache *cache, CamelStore *store, const gchar *folder_name) @@ -1396,7 +1301,6 @@ mail_folder_cache_class_init (MailFolderCacheClass *class) object_class->get_property = mail_folder_cache_get_property; object_class->dispose = mail_folder_cache_dispose; object_class->finalize = mail_folder_cache_finalize; - object_class->constructed = mail_folder_cache_constructed; class->folder_available = mail_folder_cache_folder_available; class->folder_unavailable = mail_folder_cache_folder_unavailable; @@ -1426,8 +1330,7 @@ mail_folder_cache_class_init (MailFolderCacheClass *class) G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (MailFolderCacheClass, folder_available), - NULL, NULL, /* accumulator */ - e_marshal_VOID__OBJECT_STRING, + NULL, NULL, NULL, G_TYPE_NONE, 2, CAMEL_TYPE_STORE, G_TYPE_STRING); @@ -1446,8 +1349,7 @@ mail_folder_cache_class_init (MailFolderCacheClass *class) G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (MailFolderCacheClass, folder_unavailable), - NULL, NULL, /* accumulator */ - e_marshal_VOID__OBJECT_STRING, + NULL, NULL, NULL, G_TYPE_NONE, 2, CAMEL_TYPE_STORE, G_TYPE_STRING); @@ -1465,7 +1367,7 @@ mail_folder_cache_class_init (MailFolderCacheClass *class) G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (MailFolderCacheClass, folder_deleted), NULL, NULL, /* accumulator */ - e_marshal_VOID__OBJECT_STRING, + NULL, G_TYPE_NONE, 2, CAMEL_TYPE_STORE, G_TYPE_STRING); @@ -1483,8 +1385,7 @@ mail_folder_cache_class_init (MailFolderCacheClass *class) G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (MailFolderCacheClass, folder_renamed), - NULL, NULL, /* accumulator */ - e_marshal_VOID__OBJECT_STRING_STRING, + NULL, NULL, NULL, G_TYPE_NONE, 3, CAMEL_TYPE_STORE, G_TYPE_STRING, @@ -1503,8 +1404,7 @@ mail_folder_cache_class_init (MailFolderCacheClass *class) G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (MailFolderCacheClass, folder_unread_updated), - NULL, NULL, /* accumulator */ - e_marshal_VOID__OBJECT_STRING_INT, + NULL, NULL, NULL, G_TYPE_NONE, 3, CAMEL_TYPE_STORE, G_TYPE_STRING, @@ -1527,8 +1427,7 @@ mail_folder_cache_class_init (MailFolderCacheClass *class) G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (MailFolderCacheClass, folder_changed), - NULL, NULL, /* accumulator */ - e_marshal_VOID__OBJECT_STRING_INT_STRING_STRING_STRING, + NULL, NULL, NULL, G_TYPE_NONE, 6, CAMEL_TYPE_STORE, G_TYPE_STRING, @@ -1812,8 +1711,8 @@ mail_folder_cache_get_folder_has_children (MailFolderCache *cache, struct _find_info fi = { NULL, NULL }; gchar *folder_uri; - g_return_val_if_fail (cache != NULL, FALSE); - g_return_val_if_fail (folder != NULL, FALSE); + g_return_val_if_fail (MAIL_IS_FOLDER_CACHE (cache), FALSE); + g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); if (cache->priv->stores == NULL) return FALSE; @@ -1825,7 +1724,7 @@ mail_folder_cache_get_folder_has_children (MailFolderCache *cache, g_hash_table_foreach ( cache->priv->stores, (GHFunc) storeinfo_find_folder_info, &fi); - if (found) + if (found != NULL) *found = fi.fi != NULL; g_mutex_unlock (cache->priv->stores_mutex); @@ -1873,3 +1772,70 @@ mail_folder_cache_get_remote_folder_uris (MailFolderCache *self, g_mutex_unlock (self->priv->stores_mutex); } + +void +mail_folder_cache_service_added (MailFolderCache *cache, + CamelService *service) +{ + g_return_if_fail (MAIL_IS_FOLDER_CACHE (cache)); + g_return_if_fail (CAMEL_IS_SERVICE (service)); + + mail_folder_cache_note_store ( + cache, CAMEL_STORE (service), NULL, NULL, NULL); +} + +void +mail_folder_cache_service_removed (MailFolderCache *cache, + CamelService *service) +{ + StoreInfo *si; + + g_return_if_fail (MAIL_IS_FOLDER_CACHE (cache)); + g_return_if_fail (CAMEL_IS_SERVICE (service)); + + if (cache->priv->stores == NULL) + return; + + g_mutex_lock (cache->priv->stores_mutex); + + si = g_hash_table_lookup (cache->priv->stores, service); + if (si != NULL) { + g_hash_table_remove (cache->priv->stores, service); + + g_signal_handlers_disconnect_matched ( + service, G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, cache); + + g_hash_table_foreach ( + si->folders, (GHFunc) + unset_folder_info_hash, cache); + + store_info_free (si); + } + + g_mutex_unlock (cache->priv->stores_mutex); +} + +void +mail_folder_cache_service_enabled (MailFolderCache *cache, + CamelService *service) +{ + g_return_if_fail (MAIL_IS_FOLDER_CACHE (cache)); + g_return_if_fail (CAMEL_IS_SERVICE (service)); + + mail_folder_cache_note_store ( + cache, CAMEL_STORE (service), NULL, NULL, NULL); +} + +void +mail_folder_cache_service_disabled (MailFolderCache *cache, + CamelService *service) +{ + g_return_if_fail (MAIL_IS_FOLDER_CACHE (cache)); + g_return_if_fail (CAMEL_IS_SERVICE (service)); + + /* To the folder cache, disabling a service is the same as + * removing it. We keep a separate callback function only + * to use as a breakpoint target in a debugger. */ + mail_folder_cache_service_removed (cache, service); +} diff --git a/mail/mail-folder-cache.h b/libemail-engine/mail-folder-cache.h index 8e9fa34fe5..b0d1d1bc49 100644 --- a/mail/mail-folder-cache.h +++ b/libemail-engine/mail-folder-cache.h @@ -138,6 +138,18 @@ void mail_folder_cache_get_local_folder_uris void mail_folder_cache_get_remote_folder_uris (MailFolderCache *cache, GQueue *out_queue); +void mail_folder_cache_service_added (MailFolderCache *cache, + CamelService *service); +void mail_folder_cache_service_removed + (MailFolderCache *cache, + CamelService *service); +void mail_folder_cache_service_enabled + (MailFolderCache *cache, + CamelService *service); +void mail_folder_cache_service_disabled + (MailFolderCache *cache, + CamelService *service); + G_END_DECLS diff --git a/mail/mail-ops.c b/libemail-engine/mail-ops.c index 27b48c2aa8..7063179e55 100644 --- a/mail/mail-ops.c +++ b/libemail-engine/mail-ops.c @@ -35,11 +35,11 @@ #include <glib/gi18n.h> #include <libedataserver/e-data-server-util.h> -#include "e-util/e-account-utils.h" -#include "em-filter-rule.h" -#include "em-utils.h" -#include "mail-mt.h" +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/mail-mt.h> + +#include "e-mail-utils.h" #include "mail-ops.h" #include "mail-tools.h" @@ -950,7 +950,7 @@ mail_send_queue (EMailSession *session, m->queue = g_object_ref (queue); m->transport = g_object_ref (transport); if (G_IS_CANCELLABLE (cancellable)) - e_activity_set_cancellable (m->base.activity, cancellable); + m->base.cancellable = cancellable; m->status = status; m->status_data = status_data; m->done = done; @@ -1383,10 +1383,11 @@ expunge_pop3_stores (CamelFolder *expunging, CamelFolder *folder; CamelService *service; CamelSettings *settings; - gboolean any_found = FALSE, delete_expunged = FALSE, keep_on_server = FALSE; + gboolean any_found = FALSE; + gboolean delete_expunged = FALSE; + gboolean keep_on_server = FALSE; - service = camel_session_get_service ( - session, account->uid); + service = camel_session_get_service (session, account->uid); if (!CAMEL_IS_STORE (service)) continue; diff --git a/mail/mail-ops.h b/libemail-engine/mail-ops.h index b8eb184c7e..236dd2325f 100644 --- a/mail/mail-ops.h +++ b/libemail-engine/mail-ops.h @@ -27,9 +27,8 @@ G_BEGIN_DECLS #include <camel/camel.h> - -#include <mail/mail-mt.h> -#include <mail/e-mail-backend.h> +#include <libemail-utils/mail-mt.h> +#include <libemail-engine/e-mail-session.h> void mail_transfer_messages (EMailSession *session, CamelFolder *source, diff --git a/mail/mail-tools.c b/libemail-engine/mail-tools.c index 30ac175a18..82b2146b92 100644 --- a/mail/mail-tools.c +++ b/libemail-engine/mail-tools.c @@ -38,7 +38,6 @@ #include <glib/gi18n.h> #include "e-mail-session.h" -#include "em-utils.h" #include "mail-folder-cache.h" #include "mail-tools.h" diff --git a/mail/mail-tools.h b/libemail-engine/mail-tools.h index 94b19c0d12..94b19c0d12 100644 --- a/mail/mail-tools.h +++ b/libemail-engine/mail-tools.h diff --git a/libemail-utils/Makefile.am b/libemail-utils/Makefile.am new file mode 100644 index 0000000000..a2aea9aa93 --- /dev/null +++ b/libemail-utils/Makefile.am @@ -0,0 +1,44 @@ +NULL = + +lib_LTLIBRARIES = libemail-utils.la + +libemail_utils_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \ + $(EVOLUTION_DATA_SERVER_CFLAGS) \ + $(GNOME_PLATFORM_CFLAGS) \ + $(NULL) + +libmailutilsincludedir = $(privincludedir)/libemail-utils +libmailutilsinclude_HEADERS = \ + e-account-utils.h \ + e-signature-list.h \ + e-signature-utils.h \ + e-signature.h \ + mail-mt.h \ + $(NULL) + +libemail_utils_la_SOURCES = \ + $(libmailutilsinclude_HEADERS) \ + e-account-utils.c \ + e-signature-list.c \ + e-signature-utils.c \ + e-signature.c \ + mail-mt.c \ + $(NULL) + +libemail_utils_la_LDFLAGS = $(NO_UNDEFINED) + +libemail_utils_la_LIBADD = \ + $(EVOLUTION_DATA_SERVER_LIBS) \ + $(GNOME_PLATFORM_LIBS) \ + $(NULL) + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libemail-utils.pc + +DISTCLEANFILES = $(pkgconfig_DATA) + +-include $(top_srcdir)/git.mk diff --git a/e-util/e-account-utils.c b/libemail-utils/e-account-utils.c index 6e64d45747..6e64d45747 100644 --- a/e-util/e-account-utils.c +++ b/libemail-utils/e-account-utils.c diff --git a/e-util/e-account-utils.h b/libemail-utils/e-account-utils.h index d7dbd283fd..d7dbd283fd 100644 --- a/e-util/e-account-utils.h +++ b/libemail-utils/e-account-utils.h diff --git a/e-util/e-signature-list.c b/libemail-utils/e-signature-list.c index afc1d9eefd..afc1d9eefd 100644 --- a/e-util/e-signature-list.c +++ b/libemail-utils/e-signature-list.c diff --git a/e-util/e-signature-list.h b/libemail-utils/e-signature-list.h index 866bc73b65..ebcb4b28e2 100644 --- a/e-util/e-signature-list.h +++ b/libemail-utils/e-signature-list.h @@ -26,7 +26,7 @@ #include <gconf/gconf-client.h> #include <libedataserver/e-list.h> -#include <e-util/e-signature.h> +#include <libemail-utils/e-signature.h> /* Standard GObject macros */ #define E_TYPE_SIGNATURE_LIST \ diff --git a/e-util/e-signature-utils.c b/libemail-utils/e-signature-utils.c index 7a5a7829ac..ca46f053db 100644 --- a/e-util/e-signature-utils.c +++ b/libemail-utils/e-signature-utils.c @@ -31,7 +31,7 @@ #include <sys/wait.h> #endif -#include "e-util/e-util.h" +#include <libedataserver/e-data-server-util.h> static ESignatureList *global_signature_list; diff --git a/e-util/e-signature-utils.h b/libemail-utils/e-signature-utils.h index 56f8564131..a642a136f1 100644 --- a/e-util/e-signature-utils.h +++ b/libemail-utils/e-signature-utils.h @@ -21,8 +21,8 @@ #define E_SIGNATURE_UTILS_H #include <gtk/gtk.h> -#include <e-util/e-signature.h> -#include <e-util/e-signature-list.h> +#include <libemail-utils/e-signature.h> +#include <libemail-utils/e-signature-list.h> G_BEGIN_DECLS diff --git a/e-util/e-signature.c b/libemail-utils/e-signature.c index 1b49389a82..1b49389a82 100644 --- a/e-util/e-signature.c +++ b/libemail-utils/e-signature.c diff --git a/e-util/e-signature.h b/libemail-utils/e-signature.h index fad1faffa3..fad1faffa3 100644 --- a/e-util/e-signature.h +++ b/libemail-utils/e-signature.h diff --git a/libemail-utils/libemail-utils.pc.in b/libemail-utils/libemail-utils.pc.in new file mode 100644 index 0000000000..384147b793 --- /dev/null +++ b/libemail-utils/libemail-utils.pc.in @@ -0,0 +1,15 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ +datarootdir=@datarootdir@ +datadir=@datadir@ + +privincludedir=@privincludedir@ + +Name: libemail-utils +Description: Client library for evolution mail +Version: @VERSION@ +Requires: camel-1.2 libedataserver-1.2 gio-2.0 +Libs: -L${libdir} -lemail-utils +Cflags: -I${privincludedir} diff --git a/mail/mail-mt.c b/libemail-utils/mail-mt.c index 526571f61f..e932bd6e93 100644 --- a/mail/mail-mt.c +++ b/libemail-utils/mail-mt.c @@ -28,9 +28,6 @@ #include <libedataserver/e-flag.h> -#include <e-util/e-alert-sink.h> -#include <shell/e-shell-view.h> - #include "mail-mt.h" /*#define MALLOC_CHECK*/ @@ -47,6 +44,29 @@ static GHashTable *mail_msg_active_table; static GMutex *mail_msg_lock; static GCond *mail_msg_cond; +static MailMsgCreateActivityFunc create_activity = NULL; +static MailMsgSubmitActivityFunc submit_acitivity = NULL; +static MailMsgFreeActivityFunc free_activity = NULL; +static MailMsgCompleteActivityFunc complete_activity = NULL; +static MailMsgAlertErrorFunc alert_error = NULL; +static MailMsgCancelActivityFunc cancel_activity = NULL; + +void mail_msg_register_activities (MailMsgCreateActivityFunc acreate, + MailMsgSubmitActivityFunc asubmit, + MailMsgFreeActivityFunc freeact, + MailMsgCompleteActivityFunc comp_act, + MailMsgCancelActivityFunc cancel_act, + MailMsgAlertErrorFunc ealert) +{ + /* This is a utter hack to keep EActivity out of EDS and still let Evolution do EActivity */ + create_activity = acreate; + submit_acitivity = asubmit; + free_activity = freeact; + complete_activity = comp_act; + cancel_activity = cancel_act; + alert_error = ealert; +} + static void mail_msg_cancelled (CamelOperation *operation, gpointer user_data) @@ -54,18 +74,13 @@ mail_msg_cancelled (CamelOperation *operation, mail_msg_cancel (GPOINTER_TO_UINT (user_data)); } + static gboolean -mail_msg_submit (EActivity *activity) +mail_msg_submit (CamelOperation *cancellable) { - EShell *shell; - EShellBackend *shell_backend; - - shell = e_shell_get_default (); - shell_backend = e_shell_get_backend_by_name ( - shell, shell_builtin_backend); - - e_shell_backend_add_activity (shell_backend, activity); + if (submit_acitivity) + submit_acitivity ((GCancellable *)cancellable); return FALSE; } @@ -73,7 +88,6 @@ gpointer mail_msg_new (MailMsgInfo *info) { MailMsg *msg; - GCancellable *cancellable; g_mutex_lock (mail_msg_lock); @@ -81,20 +95,17 @@ mail_msg_new (MailMsgInfo *info) msg->info = info; msg->ref_count = 1; msg->seq = mail_msg_seq++; - msg->activity = e_activity_new (); - cancellable = camel_operation_new (); - - e_activity_set_percent (msg->activity, 0.0); - e_activity_set_cancellable (msg->activity, cancellable); + msg->cancellable = camel_operation_new (); + + if (create_activity) + create_activity (msg->cancellable); g_signal_connect ( - cancellable, "cancelled", + msg->cancellable, "cancelled", G_CALLBACK (mail_msg_cancelled), GINT_TO_POINTER (msg->seq)); - g_object_unref (cancellable); - g_hash_table_insert ( mail_msg_active_table, GINT_TO_POINTER (msg->seq), msg); @@ -134,8 +145,11 @@ mail_msg_free (MailMsg *mail_msg) { /* This is an idle callback. */ - if (mail_msg->activity != NULL) - g_object_unref (mail_msg->activity); + if (free_activity) + free_activity (mail_msg->cancellable); + + if (mail_msg->cancellable != NULL) + g_object_unref (mail_msg->cancellable); if (mail_msg->error != NULL) g_error_free (mail_msg->error); @@ -196,14 +210,7 @@ mail_msg_unref (gpointer msg) void mail_msg_check_error (gpointer msg) { - EShell *shell; - EShellView *shell_view; - EShellWindow *shell_window = NULL; - EShellContent *shell_content; - GtkApplication *application; MailMsg *m = msg; - gchar *what; - GList *list, *iter; #ifdef MALLOC_CHECK checkmem (m); @@ -211,13 +218,17 @@ mail_msg_check_error (gpointer msg) checkmem (m->priv); #endif - if (e_activity_handle_cancellation (m->activity, m->error)) + if (m->error == NULL) return; - e_activity_set_state (m->activity, E_ACTIVITY_COMPLETED); + if (complete_activity) + complete_activity (m->cancellable); - if (m->error == NULL) + if (g_error_matches (m->error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + if (cancel_activity) + cancel_activity (m->cancellable); return; + } /* XXX Hmm, no explanation of why this is needed. It looks like * a lame hack and will be removed at some point, if only to @@ -226,38 +237,17 @@ mail_msg_check_error (gpointer msg) if (g_error_matches (m->error, CAMEL_FOLDER_ERROR, CAMEL_FOLDER_ERROR_INVALID_UID)) return; - shell = e_shell_get_default (); - application = GTK_APPLICATION (shell); - list = gtk_application_get_windows (application); + /* FIXME: Submit an error on the dbus */ + if (alert_error) { + char *what; - /* Find the most recently used EShellWindow. */ - for (iter = list; iter != NULL; iter = g_list_next (iter)) { - if (E_IS_SHELL_WINDOW (iter->data)) { - shell_window = E_SHELL_WINDOW (iter->data); - break; - } + if (m->info->desc && (what = m->info->desc (m))) { + alert_error (m->cancellable, what, m->error->message); + g_free (what); + } else + alert_error (m->cancellable, NULL, m->error->message); } - - /* If we can't find an EShellWindow then... well, screw it. */ - if (shell_window == NULL) - return; - - shell_view = e_shell_window_get_shell_view ( - shell_window, shell_builtin_backend); - shell_content = e_shell_view_get_shell_content (shell_view); - - if (m->info->desc && (what = m->info->desc (m))) { - e_alert_submit ( - E_ALERT_SINK (shell_content), - "mail:async-error", what, - m->error->message, NULL); - g_free (what); - } else - e_alert_submit ( - E_ALERT_SINK (shell_content), - "mail:async-error-nodescribe", - m->error->message, NULL); -} +} void mail_msg_cancel (guint msgid) @@ -273,7 +263,7 @@ mail_msg_cancel (guint msgid) /* Hold a reference to the GCancellable so it doesn't finalize * itself on us between unlocking the mutex and cancelling. */ if (msg != NULL) { - cancellable = e_activity_get_cancellable (msg->activity); + cancellable = msg->cancellable; if (g_cancellable_is_cancelled (cancellable)) cancellable = NULL; else @@ -371,12 +361,12 @@ mail_msg_idle_cb (void) while ((msg = g_async_queue_try_pop (main_loop_queue)) != NULL) { GCancellable *cancellable; - cancellable = e_activity_get_cancellable (msg->activity); + cancellable = msg->cancellable; g_idle_add_full ( G_PRIORITY_DEFAULT, (GSourceFunc) mail_msg_submit, - g_object_ref (msg->activity), + g_object_ref (msg->cancellable), (GDestroyNotify) g_object_unref); if (msg->info->exec != NULL) msg->info->exec (msg, cancellable, &msg->error); @@ -400,7 +390,7 @@ mail_msg_proxy (MailMsg *msg) { GCancellable *cancellable; - cancellable = e_activity_get_cancellable (msg->activity); + cancellable = msg->cancellable; if (msg->info->desc != NULL) { gchar *text = msg->info->desc (msg); @@ -411,7 +401,7 @@ mail_msg_proxy (MailMsg *msg) g_idle_add_full ( G_PRIORITY_DEFAULT, (GSourceFunc) mail_msg_submit, - g_object_ref (msg->activity), + g_object_ref (msg->cancellable), (GDestroyNotify) g_object_unref); if (msg->info->exec != NULL) @@ -584,10 +574,13 @@ do_call (struct _call_msg *m, break; } - e_activity_set_state ( - m->base.activity, - g_cancellable_is_cancelled (cancellable) ? - E_ACTIVITY_CANCELLED : E_ACTIVITY_COMPLETED); + if (g_cancellable_is_cancelled (cancellable)) { + if (cancel_activity) + cancel_activity (cancellable); + } else { + if (complete_activity) + complete_activity (cancellable); + } if (m->done != NULL) e_flag_set (m->done); @@ -618,7 +611,7 @@ mail_call_main (mail_call_t type, m->func = func; G_VA_COPY (m->ap, ap); - cancellable = e_activity_get_cancellable (m->base.activity); + cancellable = m->base.cancellable; if (mail_in_main_thread ()) do_call (m, cancellable, &m->base.error); diff --git a/mail/mail-mt.h b/libemail-utils/mail-mt.h index 0b595072b6..52da408f70 100644 --- a/mail/mail-mt.h +++ b/libemail-utils/mail-mt.h @@ -24,7 +24,6 @@ #define _MAIL_MT #include <camel/camel.h> -#include <e-util/e-activity.h> typedef struct _MailMsg MailMsg; typedef struct _MailMsgInfo MailMsgInfo; @@ -37,12 +36,20 @@ typedef void (*MailMsgDoneFunc) (MailMsg *msg); typedef void (*MailMsgFreeFunc) (MailMsg *msg); typedef void (*MailMsgDispatchFunc) (gpointer msg); + +typedef void (*MailMsgCreateActivityFunc) (GCancellable *cancellable); +typedef void (*MailMsgSubmitActivityFunc) (GCancellable *cancellable); +typedef void (*MailMsgFreeActivityFunc) (GCancellable *cancellable); +typedef void (*MailMsgCompleteActivityFunc) (GCancellable *cancellable); +typedef void (*MailMsgCancelActivityFunc) (GCancellable *cancellable); +typedef void (*MailMsgAlertErrorFunc) (GCancellable *cancellable, const char *what, const char *message); + struct _MailMsg { MailMsgInfo *info; volatile gint ref_count; guint seq; /* seq number for synchronisation */ gint priority; /* priority (default = 0) */ - EActivity *activity; + GCancellable *cancellable; GError *error; /* up to the caller to use this */ }; @@ -56,6 +63,12 @@ struct _MailMsgInfo { /* setup ports */ void mail_msg_init (void); +void mail_msg_register_activities (MailMsgCreateActivityFunc, + MailMsgSubmitActivityFunc, + MailMsgFreeActivityFunc, + MailMsgCompleteActivityFunc, + MailMsgCancelActivityFunc, + MailMsgAlertErrorFunc); gboolean mail_in_main_thread (void); diff --git a/mail/Makefile.am b/mail/Makefile.am index 8310cff129..b80d56cb8e 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -4,14 +4,6 @@ privsolib_LTLIBRARIES = libevolution-mail.la mailincludedir = $(privincludedir)/mail -include $(top_srcdir)/glib-gen.mak -glib_enum_headers=e-mail-enums.h -glib_enum_output=e-mail-enumtypes -glib_enum_define=E_MAIL -glib_enum_prefix=e_mail - -ENUM_GENERATED = e-mail-enumtypes.h e-mail-enumtypes.c - libevolution_mail_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ -I$(top_srcdir)/widgets \ @@ -53,11 +45,7 @@ mailinclude_HEADERS = \ e-mail-backend.h \ e-mail-browser.h \ e-mail-display.h \ - e-mail-enums.h \ - e-mail-enumtypes.h \ e-mail-folder-pane.h \ - e-mail-folder-utils.h \ - e-mail-junk-filter.h \ e-mail-junk-options.h \ e-mail-label-action.h \ e-mail-label-dialog.h \ @@ -70,10 +58,8 @@ mailinclude_HEADERS = \ e-mail-paned-view.h \ e-mail-reader-utils.h \ e-mail-reader.h \ - e-mail-session-utils.h \ - e-mail-session.h \ + e-mail-ui-session.h \ e-mail-sidebar.h \ - e-mail-store-utils.h \ e-mail-tag-editor.h \ e-mail-view.h \ em-account-editor.h \ @@ -104,13 +90,8 @@ mailinclude_HEADERS = \ em-vfolder-editor.h \ em-vfolder-rule.h \ mail-autofilter.h \ - mail-config.h \ - mail-folder-cache.h \ mail-guess-servers.h \ - mail-mt.h \ - mail-ops.h \ mail-send-recv.h \ - mail-tools.h \ mail-vfolder.h \ message-list.h @@ -129,10 +110,7 @@ libevolution_mail_la_SOURCES = \ e-mail-backend.c \ e-mail-browser.c \ e-mail-display.c \ - e-mail-enumtypes.c \ e-mail-folder-pane.c \ - e-mail-folder-utils.c \ - e-mail-junk-filter.c \ e-mail-junk-options.c \ e-mail-label-action.c \ e-mail-label-dialog.c \ @@ -145,10 +123,8 @@ libevolution_mail_la_SOURCES = \ e-mail-paned-view.c \ e-mail-reader-utils.c \ e-mail-reader.c \ - e-mail-session-utils.c \ - e-mail-session.c \ + e-mail-ui-session.c \ e-mail-sidebar.c \ - e-mail-store-utils.c \ e-mail-tag-editor.c \ e-mail-view.c \ em-account-editor.c \ @@ -179,13 +155,8 @@ libevolution_mail_la_SOURCES = \ em-vfolder-editor.c \ em-vfolder-rule.c \ mail-autofilter.c \ - mail-config.c \ - mail-folder-cache.c \ mail-guess-servers.c \ - mail-mt.c \ - mail-ops.c \ mail-send-recv.c \ - mail-tools.c \ mail-vfolder.c \ message-list.c @@ -202,6 +173,8 @@ SMIME_LIBS = \ endif libevolution_mail_la_LIBADD = \ + $(top_builddir)/libemail-utils/libemail-utils.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/shell/libeshell.la \ $(top_builddir)/composer/libcomposer.la \ @@ -307,7 +280,7 @@ endif dist-hook: cd $(distdir); rm -f $(BUILT_SOURCES) -BUILT_SOURCES = $(error_DATA) $(ENUM_GENERATED) +BUILT_SOURCES = $(error_DATA) CLEANFILES = $(BUILT_SOURCES) diff --git a/mail/e-mail-account-manager.c b/mail/e-mail-account-manager.c index 522e26e94c..86a0bf5e4b 100644 --- a/mail/e-mail-account-manager.c +++ b/mail/e-mail-account-manager.c @@ -22,7 +22,7 @@ #include <glib/gi18n-lib.h> #include <gdk/gdkkeysyms.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> #include <mail/e-mail-account-tree-view.h> #define E_MAIL_ACCOUNT_MANAGER_GET_PRIVATE(obj) \ diff --git a/mail/e-mail-account-manager.h b/mail/e-mail-account-manager.h index 23f7890500..63e52b463c 100644 --- a/mail/e-mail-account-manager.h +++ b/mail/e-mail-account-manager.h @@ -20,8 +20,8 @@ #define E_MAIL_ACCOUNT_MANAGER_H #include <gtk/gtk.h> -#include <e-util/e-account-utils.h> #include <mail/e-mail-account-store.h> +#include <libemail-utils/e-account-utils.h> /* Standard GObject macros */ #define E_TYPE_MAIL_ACCOUNT_MANAGER \ diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c index e5a630850c..c14f75e4e5 100644 --- a/mail/e-mail-account-store.c +++ b/mail/e-mail-account-store.c @@ -25,9 +25,11 @@ #include <libebackend/e-extensible.h> #include <e-util/e-marshal.h> -#include <e-util/e-account-utils.h> #include <e-util/e-alert-dialog.h> -#include <mail/mail-ops.h> + +#include <libemail-utils/e-account-utils.h> +#include <libemail-engine/mail-ops.h> + #include <mail/mail-vfolder.h> #define E_MAIL_ACCOUNT_STORE_GET_PRIVATE(obj) \ @@ -462,9 +464,16 @@ mail_account_store_service_removed (EMailAccountStore *store, EAccountList *account_list; EAccount *account; + EMailSession *session; + MailFolderCache *cache; CamelProvider *provider; const gchar *uid; + session = e_mail_account_store_get_session (store); + cache = e_mail_session_get_folder_cache (session); + + mail_folder_cache_service_removed (cache, service); + account_list = e_get_account_list (); uid = camel_service_get_uid (service); account = e_get_account_by_uid (uid); @@ -497,9 +506,16 @@ mail_account_store_service_enabled (EMailAccountStore *store, * The 'busy_count' is bumped until changes are written back * to the D-Bus service. For now I guess we'll just block. */ + EMailSession *session; + MailFolderCache *cache; GSettings *settings; const gchar *uid; + session = e_mail_account_store_get_session (store); + cache = e_mail_session_get_folder_cache (session); + + mail_folder_cache_service_enabled (cache, service); + uid = camel_service_get_uid (service); /* Handle built-in services that don't have an EAccount. */ @@ -541,9 +557,16 @@ mail_account_store_service_disabled (EMailAccountStore *store, * The 'busy_count' is bumped until changes are written back * to the D-Bus service. For now I guess we'll just block. */ + EMailSession *session; + MailFolderCache *cache; GSettings *settings; const gchar *uid; + session = e_mail_account_store_get_session (store); + cache = e_mail_session_get_folder_cache (session); + + mail_folder_cache_service_disabled (cache, service); + uid = camel_service_get_uid (service); /* Handle built-in services that don't have an EAccount. */ @@ -1096,6 +1119,10 @@ e_mail_account_store_add_service (EMailAccountStore *store, /* This populates the rest of the columns. */ mail_account_store_update_row (store, service, &iter); + /* No need to connect to "service-added" emissions since it's + * always immediately followed by either "service-enabled" or + * "service-disabled" in MailFolderCache */ + g_signal_emit (store, signals[SERVICE_ADDED], 0, service); if (enabled) @@ -1115,7 +1142,7 @@ e_mail_account_store_remove_service (EMailAccountStore *store, CamelService *service) { GtkTreeIter iter; - gboolean proceed = TRUE; + gboolean proceed; g_return_if_fail (E_IS_MAIL_ACCOUNT_STORE (store)); g_return_if_fail (CAMEL_IS_SERVICE (service)); @@ -1148,7 +1175,7 @@ e_mail_account_store_enable_service (EMailAccountStore *store, CamelService *service) { GtkTreeIter iter; - gboolean proceed = TRUE; + gboolean proceed; g_return_if_fail (E_IS_MAIL_ACCOUNT_STORE (store)); g_return_if_fail (CAMEL_IS_SERVICE (service)); @@ -1166,7 +1193,6 @@ e_mail_account_store_enable_service (EMailAccountStore *store, gtk_list_store_set ( GTK_LIST_STORE (store), &iter, E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED, TRUE, -1); - g_signal_emit (store, signals[SERVICE_ENABLED], 0, service); } } @@ -1177,7 +1203,7 @@ e_mail_account_store_disable_service (EMailAccountStore *store, CamelService *service) { GtkTreeIter iter; - gboolean proceed = TRUE; + gboolean proceed; g_return_if_fail (E_IS_MAIL_ACCOUNT_STORE (store)); g_return_if_fail (CAMEL_IS_SERVICE (service)); @@ -1195,7 +1221,6 @@ e_mail_account_store_disable_service (EMailAccountStore *store, gtk_list_store_set ( GTK_LIST_STORE (store), &iter, E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED, FALSE, -1); - g_signal_emit (store, signals[SERVICE_DISABLED], 0, service); } } diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index 2f769e9c42..921b2d0efc 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -32,26 +32,29 @@ #include <glib/gstdio.h> #include <libedataserver/e-data-server-util.h> -#include "e-util/e-account-utils.h" -#include "e-util/e-alert-dialog.h" -#include "e-util/e-alert-sink.h" - -#include "misc/e-account-combo-box.h" - -#include "shell/e-shell.h" - -#include "mail/e-mail-folder-utils.h" -#include "mail/e-mail-migrate.h" -#include "mail/e-mail-session.h" -#include "mail/e-mail-store-utils.h" -#include "mail/em-event.h" -#include "mail/em-folder-tree-model.h" -#include "mail/em-utils.h" -#include "mail/mail-autofilter.h" -#include "mail/mail-config.h" -#include "mail/mail-folder-cache.h" -#include "mail/mail-ops.h" -#include "mail/mail-vfolder.h" +#include <shell/e-shell.h> + +#include <e-util/e-alert-dialog.h> +#include <e-util/e-alert-sink.h> + +#include <misc/e-account-combo-box.h> + +#include <libemail-utils/e-account-utils.h> +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/e-mail-store-utils.h> +#include <libemail-engine/mail-config.h> +#include <libemail-engine/mail-folder-cache.h> +#include <libemail-engine/mail-ops.h> + +#include <mail/e-mail-migrate.h> +#include <mail/e-mail-ui-session.h> +#include <mail/em-event.h> +#include <mail/em-folder-tree-model.h> +#include <mail/em-utils.h> +#include <mail/mail-autofilter.h> +#include <mail/mail-send-recv.h> +#include <mail/mail-vfolder.h> #define E_MAIL_BACKEND_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -760,6 +763,132 @@ mail_backend_finalize (GObject *object) } static void +mail_backend_add_store (EMailSession *session, + CamelStore *store, + EMailBackend *backend) +{ + EMFolderTreeModel *model; + + model = em_folder_tree_model_get_default (); + em_folder_tree_model_add_store (model, store); +} + +static void +mail_backend_remove_store (EMailSession *session, + CamelStore *store, + EMailBackend *backend) +{ + EMFolderTreeModel *model; + + model = em_folder_tree_model_get_default (); + em_folder_tree_model_remove_store (model, store); +} + +#define SET_ACITIVITY(cancellable, activity) \ + g_object_set_data (G_OBJECT (cancellable), "e-activity", activity) +#define GET_ACITIVITY(cancellable) \ + g_object_get_data (G_OBJECT (cancellable), "e-activity") + +static void +mail_mt_create_activity (GCancellable *cancellable) +{ + EActivity *activity; + + activity = e_activity_new (); + e_activity_set_percent (activity, 0.0); + e_activity_set_cancellable (activity, cancellable); + SET_ACITIVITY (cancellable, activity); +} + +static void +mail_mt_submit_activity (GCancellable *cancellable) +{ + EShell *shell; + EShellBackend *shell_backend; + EActivity *activity; + + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name ( + shell, "mail"); + + activity = GET_ACITIVITY (cancellable); + if (activity) + e_shell_backend_add_activity (shell_backend, activity); + +} + +static void +mail_mt_free_activity (GCancellable *cancellable) +{ + EActivity *activity = GET_ACITIVITY (cancellable); + + if (activity) + g_object_unref (activity); +} + +static void +mail_mt_complete_acitivity (GCancellable *cancellable) +{ + EActivity *activity = GET_ACITIVITY (cancellable); + + if (activity) + e_activity_set_state (activity, E_ACTIVITY_COMPLETED); +} + +static void +mail_mt_cancel_activity (GCancellable *cancellable) +{ + EActivity *activity = GET_ACITIVITY (cancellable); + + if (activity) + e_activity_set_state (activity, E_ACTIVITY_CANCELLED); +} + +static void +mail_mt_alert_error (GCancellable *cancellable, + const char *what, + const char *message) +{ + EShell *shell; + EShellView *shell_view; + EShellWindow *shell_window = NULL; + EShellContent *shell_content; + GList *list, *iter; + GtkApplication *application; + + shell = e_shell_get_default (); + application = GTK_APPLICATION (shell); + list = gtk_application_get_windows (application); + + /* Find the most recently used EShellWindow. */ + for (iter = list; iter != NULL; iter = g_list_next (iter)) { + if (E_IS_SHELL_WINDOW (iter->data)) { + shell_window = E_SHELL_WINDOW (iter->data); + break; + } + } + + /* If we can't find an EShellWindow then... well, screw it. */ + if (shell_window == NULL) + return; + + shell_view = e_shell_window_get_shell_view ( + shell_window, "mail"); + shell_content = e_shell_view_get_shell_content (shell_view); + + if (what) { + e_alert_submit ( + E_ALERT_SINK (shell_content), + "mail:async-error", what, + message, NULL); + } else + e_alert_submit ( + E_ALERT_SINK (shell_content), + "mail:async-error-nodescribe", + message, NULL); +} + +static void mail_backend_constructed (GObject *object) { EMailBackendPrivate *priv; @@ -777,7 +906,11 @@ mail_backend_constructed (GObject *object) camel_provider_init (); - priv->session = e_mail_session_new (); + priv->session = e_mail_ui_session_new (); + + g_signal_connect ( + priv->session, "flush-outbox", + G_CALLBACK (mail_send), priv->session); g_object_bind_property ( shell, "online", @@ -806,6 +939,16 @@ mail_backend_constructed (GObject *object) e_account_combo_box_set_session (CAMEL_SESSION (priv->session)); g_signal_connect ( + priv->session, "store-added", + G_CALLBACK (mail_backend_add_store), + shell_backend); + + g_signal_connect ( + priv->session, "store-removed", + G_CALLBACK (mail_backend_remove_store), + shell_backend); + + g_signal_connect ( shell, "prepare-for-offline", G_CALLBACK (mail_backend_prepare_for_offline_cb), shell_backend); @@ -844,6 +987,14 @@ mail_backend_constructed (GObject *object) mail_config_init (priv->session); mail_msg_init (); + mail_msg_register_activities ( + mail_mt_create_activity, + mail_mt_submit_activity, + mail_mt_free_activity, + mail_mt_complete_acitivity, + mail_mt_cancel_activity, + mail_mt_alert_error); + /* Chain up to parent's constructed() method. */ G_OBJECT_CLASS (e_mail_backend_parent_class)->constructed (object); } diff --git a/mail/e-mail-backend.h b/mail/e-mail-backend.h index 6279d3fb5e..b44b330a9f 100644 --- a/mail/e-mail-backend.h +++ b/mail/e-mail-backend.h @@ -26,8 +26,8 @@ #ifndef E_MAIL_BACKEND_H #define E_MAIL_BACKEND_H -#include <mail/e-mail-session.h> #include <shell/e-shell-backend.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define E_TYPE_MAIL_BACKEND \ diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c index 277228071e..7e0457e3bd 100644 --- a/mail/e-mail-folder-pane.c +++ b/mail/e-mail-folder-pane.c @@ -30,18 +30,22 @@ #include "e-util/e-util.h" #include "e-util/e-plugin-ui.h" + #include "shell/e-shell.h" #include "shell/e-shell-utils.h" + #include "widgets/misc/e-popup-action.h" #include "widgets/misc/e-preview-pane.h" +#include "libemail-engine/e-mail-utils.h" +#include "libemail-engine/mail-tools.h" + #include "mail/e-mail-reader.h" #include "mail/e-mail-reader-utils.h" #include "mail/em-folder-tree-model.h" #include "mail/em-format-html-display.h" #include "mail/em-composer-utils.h" #include "mail/em-utils.h" -#include "mail/mail-tools.h" #include "mail/message-list.h" #define E_MAIL_FOLDER_PANE_GET_PRIVATE(obj) \ diff --git a/mail/e-mail-junk-options.c b/mail/e-mail-junk-options.c index d57e1d6dc6..e2c670c688 100644 --- a/mail/e-mail-junk-options.c +++ b/mail/e-mail-junk-options.c @@ -21,7 +21,7 @@ #include <config.h> #include <glib/gi18n-lib.h> -#include <mail/e-mail-junk-filter.h> +#include <libemail-engine/e-mail-junk-filter.h> #define E_MAIL_JUNK_OPTIONS_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ diff --git a/mail/e-mail-junk-options.h b/mail/e-mail-junk-options.h index 5e2c99faf7..7e9108e7b7 100644 --- a/mail/e-mail-junk-options.h +++ b/mail/e-mail-junk-options.h @@ -20,7 +20,7 @@ #define E_MAIL_JUNK_OPTIONS_H #include <gtk/gtk.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define E_TYPE_MAIL_JUNK_OPTIONS \ diff --git a/mail/e-mail-migrate.c b/mail/e-mail-migrate.c index fdf5684e0a..3b7de4c387 100644 --- a/mail/e-mail-migrate.c +++ b/mail/e-mail-migrate.c @@ -48,22 +48,25 @@ #include <libxml/parser.h> #include <libxml/xmlmemory.h> -#include <e-util/e-util.h> #include <libedataserver/e-xml-utils.h> #include <libedataserver/e-data-server-util.h> + +#include <shell/e-shell.h> +#include <shell/e-shell-migrate.h> + +#include <e-util/e-util.h> #include <e-util/e-xml-utils.h> -#include "e-util/e-account-utils.h" -#include "e-util/e-alert-dialog.h" -#include "e-util/e-util-private.h" -#include "e-util/e-plugin.h" -#include "e-util/e-signature-utils.h" +#include <e-util/e-alert-dialog.h> +#include <e-util/e-util-private.h> +#include <e-util/e-plugin.h> + +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/e-signature-utils.h> -#include "shell/e-shell.h" -#include "shell/e-shell-migrate.h" +#include <libemail-engine/e-mail-folder-utils.h> #include "e-mail-backend.h" -#include "e-mail-folder-utils.h" #include "em-utils.h" #define d(x) x diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c index 0232b92423..5d100cfc21 100644 --- a/mail/e-mail-notebook-view.c +++ b/mail/e-mail-notebook-view.c @@ -31,7 +31,7 @@ #include "mail/em-folder-tree.h" #include "e-mail-notebook-view.h" #include "e-mail-folder-pane.h" -#include "e-mail-folder-utils.h" +#include "libemail-engine/e-mail-folder-utils.h" #include "e-mail-message-pane.h" #include <shell/e-shell-window-actions.h> diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c index 0098462de1..7a510e3ebd 100644 --- a/mail/e-mail-paned-view.c +++ b/mail/e-mail-paned-view.c @@ -38,11 +38,13 @@ #include <shell/e-shell-window-actions.h> +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-utils.h> +#include <libemail-engine/mail-config.h> +#include <libemail-engine/mail-ops.h> + #include "em-utils.h" -#include "mail-config.h" -#include "mail-ops.h" #include "message-list.h" -#include "e-mail-folder-utils.h" #include "e-mail-reader-utils.h" #define E_MAIL_PANED_VIEW_GET_PRIVATE(obj) \ diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index bd51c97e1f..c814435119 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -37,15 +37,17 @@ #include "misc/e-web-view.h" #include "shell/e-shell-utils.h" +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-utils.h> +#include <libemail-engine/mail-ops.h> +#include <libemail-engine/mail-tools.h> + #include "mail/e-mail-backend.h" #include "mail/e-mail-browser.h" -#include "mail/e-mail-folder-utils.h" #include "mail/em-composer-utils.h" #include "mail/em-format-html-print.h" #include "mail/em-utils.h" #include "mail/mail-autofilter.h" -#include "mail/mail-ops.h" -#include "mail/mail-tools.h" #include "mail/mail-vfolder.h" #include "mail/message-list.h" diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 5c67c62d02..37c92fbf78 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -32,7 +32,6 @@ #include <X11/XF86keysym.h> #endif -#include "e-util/e-account-utils.h" #include "e-util/e-charset.h" #include "e-util/e-util.h" #include "e-util/e-alert-dialog.h" @@ -40,10 +39,16 @@ #include "widgets/misc/e-popup-action.h" #include "widgets/misc/e-menu-tool-action.h" +#include "libemail-utils/e-account-utils.h" +#include "libemail-utils/mail-mt.h" + +#include "libemail-engine/mail-ops.h" +#include "libemail-engine/e-mail-utils.h" +#include "libemail-engine/e-mail-enumtypes.h" + #include "mail/e-mail-backend.h" #include "mail/e-mail-browser.h" #include "mail/e-mail-display.h" -#include "mail/e-mail-enumtypes.h" #include "mail/e-mail-reader-utils.h" #include "mail/e-mail-view.h" #include "mail/em-composer-utils.h" @@ -52,8 +57,6 @@ #include "mail/em-folder-tree.h" #include "mail/em-utils.h" #include "mail/mail-autofilter.h" -#include "mail/mail-ops.h" -#include "mail/mail-mt.h" #include "mail/mail-vfolder.h" #include "mail/message-list.h" diff --git a/mail/e-mail-sidebar.h b/mail/e-mail-sidebar.h index a88c3ccc15..bdde4c1090 100644 --- a/mail/e-mail-sidebar.h +++ b/mail/e-mail-sidebar.h @@ -22,8 +22,8 @@ #ifndef E_MAIL_SIDEBAR_H #define E_MAIL_SIDEBAR_H -#include <mail/e-mail-session.h> #include <mail/em-folder-tree.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define E_TYPE_MAIL_SIDEBAR \ diff --git a/mail/e-mail-ui-session.c b/mail/e-mail-ui-session.c new file mode 100644 index 0000000000..dcb2e25573 --- /dev/null +++ b/mail/e-mail-ui-session.c @@ -0,0 +1,904 @@ +/* + * e-mail-ui-session.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Authors: + * Jonathon Jongsma <jonathon.jongsma@collabora.co.uk> + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * Copyright (C) 2009 Intel Corporation + * + */ + +/* mail-session.c: handles the session information and resource manipulation */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +#include <glib/gi18n.h> +#include <glib/gstdio.h> + +#include <gtk/gtk.h> + + +#ifdef HAVE_CANBERRA +#include <canberra-gtk.h> +#endif + +#include <libedataserver/e-flag.h> +#include <libedataserver/e-proxy.h> +#include <libebackend/e-extensible.h> +#include <libedataserverui/e-passwords.h> + +#include "e-mail-account-store.h" + +#include "e-util/e-util.h" +#include "libemail-utils/e-account-utils.h" +#include "e-util/e-alert-dialog.h" +#include "e-util/e-util-private.h" + +#include "shell/e-shell.h" +#include "shell/e-shell-view.h" +#include "shell/e-shell-content.h" +#include "shell/e-shell-window.h" + +#include "libemail-engine/e-mail-folder-utils.h" +#include "libemail-engine/e-mail-junk-filter.h" +#include "libemail-engine/e-mail-session.h" +#include "e-mail-ui-session.h" +#include "em-composer-utils.h" +#include "em-filter-context.h" +#include "em-filter-rule.h" +#include "em-utils.h" +#include "libemail-engine/mail-config.h" +#include "libemail-utils/mail-mt.h" +#include "libemail-engine/mail-ops.h" +#include "mail-send-recv.h" +#include "libemail-engine/mail-tools.h" + +#define E_MAIL_UI_SESSION_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE \ + ((obj), E_TYPE_MAIL_UI_SESSION, EMailUISessionPrivate)) + +typedef struct _SourceContext SourceContext; + +struct _EMailUISessionPrivate { + FILE *filter_logfile; + CamelStore *vfolder_store; + EMailAccountStore *account_store; + EMailLabelListStore *label_store; + + EAccountList *account_list; + gulong account_changed_handler_id; +}; + +enum { + PROP_0, + PROP_ACCOUNT_STORE, + PROP_LABEL_STORE, + PROP_VFOLDER_STORE +}; + +enum { + ACTIVITY_ADDED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; + +G_DEFINE_TYPE_WITH_CODE ( + EMailUISession, + e_mail_ui_session, + E_TYPE_MAIL_SESSION, + G_IMPLEMENT_INTERFACE (E_TYPE_EXTENSIBLE, NULL)) + +struct _SourceContext { + EMailUISession *session; + CamelService *service; +}; + +/* Support for CamelSession.alert_user() *************************************/ + +static gpointer user_message_dialog; +static GQueue user_message_queue = { NULL, NULL, 0 }; + +struct _user_message_msg { + MailMsg base; + + CamelSessionAlertType type; + gchar *prompt; + GSList *button_captions; + EFlag *done; + + gint result; + guint ismain : 1; +}; + +static void user_message_exec (struct _user_message_msg *m, + GCancellable *cancellable, + GError **error); + +static void +user_message_response_free (GtkDialog *dialog, + gint button) +{ + struct _user_message_msg *m = NULL; + + gtk_widget_destroy ((GtkWidget *) dialog); + + user_message_dialog = NULL; + + /* check for pendings */ + if (!g_queue_is_empty (&user_message_queue)) { + GCancellable *cancellable; + + m = g_queue_pop_head (&user_message_queue); + cancellable = m->base.cancellable; + user_message_exec (m, cancellable, &m->base.error); + mail_msg_unref (m); + } +} + +/* clicked, send back the reply */ +static void +user_message_response (GtkDialog *dialog, + gint button, + struct _user_message_msg *m) +{ + /* if !m or !button_captions, then we've already replied */ + if (m && m->button_captions) { + m->result = button; + e_flag_set (m->done); + } + + user_message_response_free (dialog, button); +} + +static void +user_message_exec (struct _user_message_msg *m, + GCancellable *cancellable, + GError **error) +{ + gboolean info_only; + GtkWindow *parent; + EShell *shell; + const gchar *error_type; + gint index; + GSList *iter; + + info_only = g_slist_length (m->button_captions) <= 1; + + if (!m->ismain && user_message_dialog != NULL && !info_only) { + g_queue_push_tail (&user_message_queue, mail_msg_ref (m)); + return; + } + + switch (m->type) { + case CAMEL_SESSION_ALERT_INFO: + error_type = "mail:session-message-info"; + break; + case CAMEL_SESSION_ALERT_WARNING: + error_type = "mail:session-message-warning"; + break; + case CAMEL_SESSION_ALERT_ERROR: + error_type = "mail:session-message-error"; + break; + default: + error_type = NULL; + g_return_if_reached (); + } + + shell = e_shell_get_default (); + + /* try to find "mail" view to place the informational alert to */ + if (info_only) { + GtkWindow *active_window; + EShellWindow *shell_window; + EShellView *shell_view; + EShellContent *shell_content = NULL; + + /* check currently active window first, ... */ + active_window = e_shell_get_active_window (shell); + if (active_window && E_IS_SHELL_WINDOW (active_window)) { + if (E_IS_SHELL_WINDOW (active_window)) { + shell_window = E_SHELL_WINDOW (active_window); + shell_view = e_shell_window_peek_shell_view (shell_window, "mail"); + if (shell_view) + shell_content = e_shell_view_get_shell_content (shell_view); + } + } + + if (!shell_content) { + GList *list, *iter; + + list = gtk_application_get_windows (GTK_APPLICATION (shell)); + + /* ...then iterate through all opened windows and pick one which has it */ + for (iter = list; iter != NULL && !shell_content; iter = g_list_next (iter)) { + if (E_IS_SHELL_WINDOW (iter->data)) { + shell_window = iter->data; + shell_view = e_shell_window_peek_shell_view (shell_window, "mail"); + if (shell_view) + shell_content = e_shell_view_get_shell_content (shell_view); + } + } + } + + /* when no shell-content found, which might not happen, but just in case, + process the information alert like usual, through an EAlertDialog machinery + */ + if (shell_content) { + e_alert_submit (E_ALERT_SINK (shell_content), error_type, m->prompt, NULL); + return; + } else if (!m->ismain && user_message_dialog != NULL) { + g_queue_push_tail (&user_message_queue, mail_msg_ref (m)); + return; + } + } + + /* Pull in the active window from the shell to get a parent window */ + parent = e_shell_get_active_window (shell); + user_message_dialog = e_alert_dialog_new_for_args ( + parent, error_type, m->prompt, NULL); + g_object_set (user_message_dialog, "resizable", TRUE, NULL); + + if (m->button_captions) { + GtkWidget *action_area; + GList *children, *child; + + /* remove all default buttons and keep only those requested */ + action_area = gtk_dialog_get_action_area (GTK_DIALOG (user_message_dialog)); + + children = gtk_container_get_children (GTK_CONTAINER (action_area)); + for (child = children; child != NULL; child = child->next) { + gtk_container_remove (GTK_CONTAINER (action_area), child->data); + } + + g_list_free (children); + } + + for (index = 0, iter = m->button_captions; iter; index++, iter = iter->next) { + gtk_dialog_add_button (GTK_DIALOG (user_message_dialog), iter->data, index); + } + + + /* XXX This is a case where we need to be able to construct + * custom EAlerts without a predefined XML definition. */ + if (m->ismain) { + gint response; + + response = gtk_dialog_run (user_message_dialog); + user_message_response ( + user_message_dialog, response, m); + } else { + gpointer user_data = m; + + if (g_slist_length (m->button_captions) <= 1) + user_data = NULL; + + g_signal_connect ( + user_message_dialog, "response", + G_CALLBACK (user_message_response), user_data); + gtk_widget_show (user_message_dialog); + } +} + +static void +user_message_free (struct _user_message_msg *m) +{ + g_free (m->prompt); + g_slist_free_full (m->button_captions, g_free); + e_flag_free (m->done); +} + +static MailMsgInfo user_message_info = { + sizeof (struct _user_message_msg), + (MailMsgDescFunc) NULL, + (MailMsgExecFunc) user_message_exec, + (MailMsgDoneFunc) NULL, + (MailMsgFreeFunc) user_message_free +}; + +/* Support for CamelSession.get_filter_driver () *****************************/ + +static CamelFolder * +get_folder (CamelFilterDriver *d, + const gchar *uri, + gpointer user_data, + GError **error) +{ + EMailSession *session = E_MAIL_SESSION (user_data); + + /* FIXME Not passing a GCancellable here. */ + /* FIXME Need a camel_filter_driver_get_session(). */ + return e_mail_session_uri_to_folder_sync ( + session, uri, 0, NULL, error); +} + +static gboolean +session_play_sound_cb (const gchar *filename) +{ +#ifdef HAVE_CANBERRA + if (filename != NULL && *filename != '\0') + ca_context_play ( + ca_gtk_context_get (), 0, + CA_PROP_MEDIA_FILENAME, filename, + NULL); + else +#endif + gdk_beep (); + + return FALSE; +} + +static void +session_play_sound (CamelFilterDriver *driver, + const gchar *filename, + gpointer user_data) +{ + g_idle_add_full ( + G_PRIORITY_DEFAULT_IDLE, + (GSourceFunc) session_play_sound_cb, + g_strdup (filename), (GDestroyNotify) g_free); +} + +static void +session_system_beep (CamelFilterDriver *driver, + gpointer user_data) +{ + g_idle_add ((GSourceFunc) session_play_sound_cb, NULL); +} + +static CamelFilterDriver * +main_get_filter_driver (CamelSession *session, + const gchar *type, + GError **error) +{ + EMailSession *ms = E_MAIL_SESSION (session); + CamelFilterDriver *driver; + EFilterRule *rule = NULL; + const gchar *config_dir; + gchar *user, *system; + GSettings *settings; + ERuleContext *fc; + EMailUISessionPrivate *priv; + + priv = E_MAIL_UI_SESSION_GET_PRIVATE (session); + + settings = g_settings_new ("org.gnome.evolution.mail"); + + config_dir = mail_session_get_config_dir (); + user = g_build_filename (config_dir, "filters.xml", NULL); + system = g_build_filename (EVOLUTION_PRIVDATADIR, "filtertypes.xml", NULL); + fc = (ERuleContext *) em_filter_context_new (ms); + e_rule_context_load (fc, system, user); + g_free (system); + g_free (user); + + driver = camel_filter_driver_new (session); + camel_filter_driver_set_folder_func (driver, get_folder, session); + + if (g_settings_get_boolean (settings, "filters-log-actions")) { + if (priv->filter_logfile == NULL) { + gchar *filename; + + filename = g_settings_get_string (settings, "filters-log-file"); + if (filename) { + priv->filter_logfile = g_fopen (filename, "a+"); + g_free (filename); + } + } + + if (priv->filter_logfile) + camel_filter_driver_set_logfile (driver, priv->filter_logfile); + } + + camel_filter_driver_set_shell_func (driver, mail_execute_shell_command, NULL); + camel_filter_driver_set_play_sound_func (driver, session_play_sound, NULL); + camel_filter_driver_set_system_beep_func (driver, session_system_beep, NULL); + + if ((!strcmp (type, E_FILTER_SOURCE_INCOMING) || + !strcmp (type, E_FILTER_SOURCE_JUNKTEST)) + && camel_session_get_check_junk (session)) { + + /* implicit junk check as 1st rule */ + camel_filter_driver_add_rule ( + driver, "Junk check", "(junk-test)", + "(begin (set-system-flag \"junk\"))"); + } + + if (strcmp (type, E_FILTER_SOURCE_JUNKTEST) != 0) { + GString *fsearch, *faction; + + fsearch = g_string_new (""); + faction = g_string_new (""); + + if (!strcmp (type, E_FILTER_SOURCE_DEMAND)) + type = E_FILTER_SOURCE_INCOMING; + + /* add the user-defined rules next */ + while ((rule = e_rule_context_next_rule (fc, rule, type))) { + g_string_truncate (fsearch, 0); + g_string_truncate (faction, 0); + + /* skip disabled rules */ + if (!rule->enabled) + continue; + + e_filter_rule_build_code (rule, fsearch); + em_filter_rule_build_action ( + EM_FILTER_RULE (rule), faction); + camel_filter_driver_add_rule ( + driver, rule->name, + fsearch->str, faction->str); + } + + g_string_free (fsearch, TRUE); + g_string_free (faction, TRUE); + } + + g_object_unref (fc); + + g_object_unref (settings); + + return driver; +} + +static void +source_context_free (SourceContext *context) +{ + if (context->session != NULL) + g_object_unref (context->session); + + if (context->service != NULL) + g_object_unref (context->service); + + g_slice_free (SourceContext, context); +} + +static void +mail_ui_session_dispose (GObject *object) +{ + EMailUISessionPrivate *priv; + + priv = E_MAIL_UI_SESSION_GET_PRIVATE (object); + + if (priv->account_store != NULL) { + e_mail_account_store_clear (priv->account_store); + g_object_unref (priv->account_store); + priv->account_store = NULL; + } + + if (priv->label_store != NULL) { + g_object_unref (priv->label_store); + priv->label_store = NULL; + } + + + if (priv->vfolder_store != NULL) { + g_object_unref (priv->vfolder_store); + priv->vfolder_store = NULL; + } + + if (priv->account_list != NULL) { + g_signal_handler_disconnect ( + priv->account_list, + priv->account_changed_handler_id); + g_object_unref (priv->account_list); + priv->account_list = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (e_mail_ui_session_parent_class)->dispose (object); +} + +static void +mail_ui_session_add_vfolder_store (EMailUISession *uisession) +{ + CamelSession *camel_session; + CamelService *service; + GError *error = NULL; + + camel_session = CAMEL_SESSION (uisession); + + service = camel_session_add_service ( + camel_session, E_MAIL_SESSION_VFOLDER_UID, + "vfolder", CAMEL_PROVIDER_STORE, &error); + + if (error != NULL) { + g_critical ("%s: %s", G_STRFUNC, error->message); + g_error_free (error); + return; + } + + g_return_if_fail (CAMEL_IS_SERVICE (service)); + + camel_service_set_display_name (service, _("Search Folders")); + em_utils_connect_service_sync (service, NULL, NULL); + + /* XXX There's more configuration to do in vfolder_load_storage() + * but it requires an EMailBackend, which we don't have access + * to from here, so it has to be called from elsewhere. Kinda + * thinking about reworking that... */ + + uisession->priv->vfolder_store = g_object_ref (service); +} + +static void +mail_ui_session_account_changed_cb (EAccountList *account_list, + EAccount *account, + EMailSession *session) +{ + EMFolderTreeModel *folder_tree_model; + CamelService *service; + + service = camel_session_get_service ( + CAMEL_SESSION (session), account->uid); + + if (!CAMEL_IS_STORE (service)) + return; + + /* Update the display name of the corresponding CamelStore. + * EMailAccountStore listens for "notify" signals from each + * service so it will detect this and update the model. + * + * XXX If EAccount defined GObject properties we could just + * bind EAccount:name to CamelService:display-name and + * be done with it. Oh well. + */ + + camel_service_set_display_name (service, account->name); + + /* Remove the store from the folder tree model and, if the + * account is still enabled, re-add it. Easier than trying + * to update the model with the store in place. + * + * em_folder_tree_model_add_store() already knows which types + * of stores to disregard, so we don't have to deal with that + * here. */ + + folder_tree_model = em_folder_tree_model_get_default (); + + em_folder_tree_model_remove_store ( + folder_tree_model, CAMEL_STORE (service)); + + if (account->enabled) + em_folder_tree_model_add_store ( + folder_tree_model, CAMEL_STORE (service)); +} + +static gboolean +mail_ui_session_initialize_stores_idle (gpointer user_data) +{ + EMailUISession *session = user_data; + EMailAccountStore *account_store; + EAccount *account; + + g_return_val_if_fail (session != NULL, FALSE); + + account_store = e_mail_ui_session_get_account_store (session); + + /* Initialize which account is default. */ + account = e_get_default_account (); + if (account != NULL) { + CamelService *service; + + service = camel_session_get_service ( + CAMEL_SESSION (session), account->uid); + e_mail_account_store_set_default_service ( + account_store, service); + } + + return FALSE; +} + +static void +mail_ui_session_constructed (GObject *object) +{ + EMailUISessionPrivate *priv; + EMFolderTreeModel *folder_tree_model; + EMailSession *session; + EMailUISession *uisession; + EAccountList *account_list; + gulong handler_id; + + session = E_MAIL_SESSION (object); + uisession = E_MAIL_UI_SESSION(object); + uisession->priv = priv = E_MAIL_UI_SESSION_GET_PRIVATE (object); + + priv->account_store = e_mail_account_store_new (session); + + account_list = e_get_account_list (); + uisession->priv->account_list = g_object_ref (account_list); + + /* XXX Make sure the folder tree model is created before we + * add built-in CamelStores so it gets signals from the + * EMailAccountStore. + * + * XXX This is creating a circular reference. Perhaps the + * model should only hold a weak pointer to EMailSession? + * + * FIXME EMailSession should just own the default instance. + */ + folder_tree_model = em_folder_tree_model_get_default (); + + /* Chain up to parent's constructed() method. */ + G_OBJECT_CLASS (e_mail_ui_session_parent_class)->constructed (object); + + em_folder_tree_model_set_session (folder_tree_model, session); + + mail_ui_session_add_vfolder_store (uisession); + + g_idle_add (mail_ui_session_initialize_stores_idle, object); + + handler_id = g_signal_connect ( + account_list, "account-changed", + G_CALLBACK (mail_ui_session_account_changed_cb), session); + priv->account_changed_handler_id = handler_id; + +} + +static gint +mail_ui_session_alert_user (CamelSession *session, + CamelSessionAlertType type, + const gchar *prompt, + GSList *button_captions) +{ + struct _user_message_msg *m; + GCancellable *cancellable; + gint result = -1; + GSList *iter; + + m = mail_msg_new (&user_message_info); + m->ismain = mail_in_main_thread (); + m->type = type; + m->prompt = g_strdup (prompt); + m->done = e_flag_new (); + m->button_captions = g_slist_copy (button_captions); + + for (iter = m->button_captions; iter; iter = iter->next) + iter->data = g_strdup (iter->data); + + if (g_slist_length (button_captions) > 1) + mail_msg_ref (m); + + cancellable = m->base.cancellable; + + if (m->ismain) + user_message_exec (m, cancellable, &m->base.error); + else + mail_msg_main_loop_push (m); + + if (g_slist_length (button_captions) > 1) { + e_flag_wait (m->done); + result = m->result; + mail_msg_unref (m); + } else if (m->ismain) + mail_msg_unref (m); + + return result; +} + +static CamelFilterDriver * +mail_ui_session_get_filter_driver (CamelSession *session, + const gchar *type, + GError **error) +{ + return (CamelFilterDriver *) mail_call_main ( + MAIL_CALL_p_ppp, (MailMainFunc) main_get_filter_driver, + session, type, error); +} + +static void +mail_ui_session_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_ui_session_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_ACCOUNT_STORE: + g_value_set_object ( + value, + e_mail_ui_session_get_account_store ( + E_MAIL_UI_SESSION (object))); + return; + + case PROP_LABEL_STORE: + g_value_set_object ( + value, + e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (object))); + return; + + + case PROP_VFOLDER_STORE: + g_value_set_object ( + value, + e_mail_ui_session_get_vfolder_store ( + E_MAIL_UI_SESSION (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static gboolean +mail_ui_session_add_service_cb (SourceContext *context) +{ + EMailAccountStore *store; + + store = e_mail_ui_session_get_account_store (context->session); + e_mail_account_store_add_service (store, context->service); + + return FALSE; +} + +static CamelService * +mail_ui_session_add_service (CamelSession *session, + const gchar *uid, + const gchar *protocol, + CamelProviderType type, + GError **error) +{ + CamelService *service; + + /* Chain up to parent's constructed() method. */ + service = CAMEL_SESSION_CLASS (e_mail_ui_session_parent_class)-> + add_service (session, uid, protocol, type, error); + + /* Inform the EMailAccountStore of the new CamelService + * from an idle callback so the service has a chance to + * fully initialize first. */ + if (CAMEL_IS_STORE (service)) { + SourceContext *context; + + context = g_slice_new0 (SourceContext); + context->session = g_object_ref (session); + context->service = g_object_ref (service); + + g_idle_add_full ( + G_PRIORITY_DEFAULT_IDLE, + (GSourceFunc) mail_ui_session_add_service_cb, + context, (GDestroyNotify) source_context_free); + } + + return service; +} + +static void +e_mail_ui_session_class_init (EMailUISessionClass *class) +{ + GObjectClass *object_class; + CamelSessionClass *session_class; + + g_type_class_add_private (class, sizeof (EMailUISessionPrivate)); + + object_class = G_OBJECT_CLASS (class); + object_class->set_property = mail_ui_session_set_property; + object_class->get_property = mail_ui_session_get_property; + object_class->dispose = mail_ui_session_dispose; + object_class->constructed = mail_ui_session_constructed; + + session_class = CAMEL_SESSION_CLASS (class); + session_class->alert_user = mail_ui_session_alert_user; + session_class->get_filter_driver = mail_ui_session_get_filter_driver; + session_class->add_service = mail_ui_session_add_service; + + g_object_class_install_property ( + object_class, + PROP_VFOLDER_STORE, + g_param_spec_object ( + "vfolder-store", + "Search Folder Store", + "Built-in search folder store", + CAMEL_TYPE_STORE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, + PROP_LABEL_STORE, + g_param_spec_object ( + "label-store", + "Label Store", + "Mail label store", + E_TYPE_MAIL_LABEL_LIST_STORE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + signals[ACTIVITY_ADDED] = g_signal_new ( + "activity-added", + G_OBJECT_CLASS_TYPE (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EMailUISessionClass, activity_added), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + E_TYPE_ACTIVITY); +} + +static void +e_mail_ui_session_init (EMailUISession *session) +{ + session->priv = E_MAIL_UI_SESSION_GET_PRIVATE (session); + session->priv->label_store = e_mail_label_list_store_new (); +} + +EMailSession * +e_mail_ui_session_new (void) +{ + const gchar *user_data_dir; + const gchar *user_cache_dir; + + user_data_dir = mail_session_get_data_dir (); + user_cache_dir = mail_session_get_cache_dir (); + + return g_object_new ( + E_TYPE_MAIL_UI_SESSION, + "user-data-dir", user_data_dir, + "user-cache-dir", user_cache_dir, + NULL); +} + + +EMailAccountStore * +e_mail_ui_session_get_account_store (EMailUISession *session) +{ + g_return_val_if_fail (E_IS_MAIL_UI_SESSION (session), NULL); + + return session->priv->account_store; +} + +CamelStore * +e_mail_ui_session_get_vfolder_store (EMailUISession *session) +{ + g_return_val_if_fail (E_IS_MAIL_UI_SESSION (session), NULL); + + return session->priv->vfolder_store; +} + +void +e_mail_ui_session_add_activity (EMailUISession *session, + EActivity *activity) +{ + g_return_if_fail (E_IS_MAIL_UI_SESSION (session)); + g_return_if_fail (E_IS_ACTIVITY (activity)); + + g_signal_emit (session, signals[ACTIVITY_ADDED], 0, activity); +} + +EMailLabelListStore * +e_mail_ui_session_get_label_store (EMailUISession *session) +{ + g_return_val_if_fail (E_IS_MAIL_UI_SESSION (session), NULL); + + return session->priv->label_store; +} + diff --git a/mail/e-mail-ui-session.h b/mail/e-mail-ui-session.h new file mode 100644 index 0000000000..1a36487757 --- /dev/null +++ b/mail/e-mail-ui-session.h @@ -0,0 +1,93 @@ +/* + * e-mail-session.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see <http://www.gnu.org/licenses/> + * + * + * Authors: + * Jeffrey Stedfast <fejj@ximian.com> + * Srinivasa Ragavan <sragavan@gnome.org> + * + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef E_MAIL_UI_SESSION_H +#define E_MAIL_UI_SESSION_H + +#include <camel/camel.h> +#include <libemail-engine/e-mail-enums.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/mail-folder-cache.h> +#include <mail/e-mail-account-store.h> +#include <e-util/e-activity.h> + +#include <mail/e-mail-account-store.h> +#include <mail/e-mail-label-list-store.h> + +/* Standard GObject macros */ +#define E_TYPE_MAIL_UI_SESSION \ + (e_mail_ui_session_get_type ()) +#define E_MAIL_UI_SESSION(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), E_TYPE_MAIL_UI_SESSION, EMailUISession)) +#define E_MAIL_UI_SESSION_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), E_TYPE_MAIL_UI_SESSION, EMailUISessionClass)) +#define E_IS_MAIL_UI_SESSION(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), E_TYPE_MAIL_UI_SESSION)) +#define E_IS_MAIL_UI_SESSION_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), E_TYPE_MAIL_UI_SESSION)) +#define E_MAIL_UI_SESSION_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), E_TYPE_MAIL_UI_SESSION, EMailUISessionClass)) + +G_BEGIN_DECLS + +typedef struct _EMailUISession EMailUISession; +typedef struct _EMailUISessionClass EMailUISessionClass; +typedef struct _EMailUISessionPrivate EMailUISessionPrivate; + +struct _EMailUISession { + EMailSession parent; + EMailUISessionPrivate *priv; +}; + +struct _EMailUISessionClass { + EMailSessionClass parent_class; + + void (*activity_added) (EMailUISession *session, + EActivity *activity); + +}; + +GType e_mail_ui_session_get_type (void); +EMailSession * e_mail_ui_session_new (void); +CamelStore * e_mail_ui_session_get_vfolder_store + (EMailUISession *session); +EMailAccountStore * + e_mail_ui_session_get_account_store + (EMailUISession *session); +void e_mail_ui_session_add_activity (EMailUISession *session, + EActivity *activity); +EMailLabelListStore * + e_mail_ui_session_get_label_store + (EMailUISession *session); + +G_END_DECLS + +#endif /* E_MAIL_UI_SESSION_H */ diff --git a/mail/e-mail.h b/mail/e-mail.h index 02c169cd10..3b34765784 100644 --- a/mail/e-mail.h +++ b/mail/e-mail.h @@ -26,7 +26,6 @@ #include <mail/e-mail-enums.h> #include <mail/e-mail-enumtypes.h> #include <mail/e-mail-folder-pane.h> -#include <mail/e-mail-folder-utils.h> #include <mail/e-mail-label-action.h> #include <mail/e-mail-label-dialog.h> #include <mail/e-mail-label-list-store.h> @@ -38,10 +37,7 @@ #include <mail/e-mail-paned-view.h> #include <mail/e-mail-reader.h> #include <mail/e-mail-reader-utils.h> -#include <mail/e-mail-session.h> -#include <mail/e-mail-session-utils.h> #include <mail/e-mail-sidebar.h> -#include <mail/e-mail-store-utils.h> #include <mail/e-mail-tag-editor.h> #include <mail/e-mail-view.h> diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c index 1fc17abc5e..8b7f1600d6 100644 --- a/mail/em-account-editor.c +++ b/mail/em-account-editor.c @@ -45,32 +45,38 @@ #include <libedataserverui/e-passwords.h> -#include "shell/e-shell.h" -#include "e-util/e-util.h" -#include "e-util/e-alert-dialog.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-dialog-utils.h" -#include "e-util/e-signature-list.h" -#include "e-util/e-signature-utils.h" -#include "e-util/e-util-private.h" -#include "widgets/misc/e-auth-combo-box.h" -#include "widgets/misc/e-signature-editor.h" -#include "widgets/misc/e-port-entry.h" +#include <shell/e-shell.h> +#include <e-util/e-util.h> +#include <e-util/e-alert-dialog.h> +#include <e-util/e-dialog-utils.h> +#include <e-util/e-util-private.h> + +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/e-signature-list.h> +#include <libemail-utils/e-signature-utils.h> +#include <libemail-utils/mail-mt.h> + +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/mail-ops.h> + +#include <widgets/misc/e-auth-combo-box.h> +#include <widgets/misc/e-signature-editor.h> +#include <widgets/misc/e-port-entry.h> + +#include "e-mail-account-store.h" #include "e-mail-backend.h" -#include "e-mail-folder-utils.h" #include "e-mail-junk-options.h" +#include "e-mail-ui-session.h" +#include "em-account-editor.h" #include "em-config.h" #include "em-folder-selection-button.h" -#include "em-account-editor.h" -#include "mail-send-recv.h" #include "em-utils.h" -#include "mail-ops.h" -#include "mail-mt.h" #include "mail-guess-servers.h" +#include "mail-send-recv.h" #if defined (HAVE_NSS) && defined (ENABLE_SMIME) -#include "smime/gui/e-cert-selector.h" +#include <smime/gui/e-cert-selector.h> #endif #define EM_ACCOUNT_EDITOR_GET_PRIVATE(obj) \ @@ -5501,7 +5507,7 @@ emae_commit (EConfig *ec, service = camel_session_get_service ( CAMEL_SESSION (session), account->uid); - store = e_mail_session_get_account_store (session); + store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION(session)); e_mail_account_store_set_default_service (store, service); } diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index dc8d89725a..4d8e37d9a4 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -32,32 +32,35 @@ #include <libedataserver/e-data-server-util.h> -#include "mail-mt.h" -#include "mail-ops.h" -#include "mail-tools.h" -#include "mail-send-recv.h" +#include <e-util/e-alert-dialog.h> +#include <e-util/e-alert-sink.h> +#include <e-util/e-util.h> + +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/mail-mt.h> + +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/e-mail-session-utils.h> +#include <libemail-engine/mail-ops.h> +#include <libemail-engine/mail-tools.h> -#include "e-util/e-account-utils.h" -#include "e-util/e-alert-dialog.h" -#include "e-util/e-alert-sink.h" -#include "e-util/e-util.h" +#include <shell/e-shell.h> -#include "shell/e-shell.h" +#include <composer/e-msg-composer.h> +#include <composer/e-composer-actions.h> +#include <composer/e-composer-post-header.h> -#include "e-mail-folder-utils.h" -#include "e-mail-session.h" -#include "e-mail-session-utils.h" #include "em-utils.h" #include "em-composer-utils.h" -#include "composer/e-msg-composer.h" -#include "composer/e-composer-actions.h" -#include "composer/e-composer-post-header.h" #include "em-folder-selector.h" #include "em-folder-tree.h" #include "em-format-html.h" #include "em-format-html-print.h" #include "em-format-quote.h" #include "em-event.h" +#include "mail-send-recv.h" + #ifdef G_OS_WIN32 #ifdef gmtime_r diff --git a/mail/em-composer-utils.h b/mail/em-composer-utils.h index 093001dfd0..5b3d3a469a 100644 --- a/mail/em-composer-utils.h +++ b/mail/em-composer-utils.h @@ -26,9 +26,9 @@ #include <em-format/em-format.h> #include <mail/e-mail-backend.h> -#include <mail/e-mail-enums.h> #include <mail/e-mail-reader.h> #include <composer/e-msg-composer.h> +#include <libemail-engine/e-mail-enums.h> G_BEGIN_DECLS diff --git a/mail/em-filter-context.h b/mail/em-filter-context.h index 3545bf16eb..1f8889d94c 100644 --- a/mail/em-filter-context.h +++ b/mail/em-filter-context.h @@ -25,8 +25,8 @@ #ifndef EM_FILTER_CONTEXT_H #define EM_FILTER_CONTEXT_H -#include <mail/e-mail-session.h> #include <filter/e-rule-context.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_FILTER_CONTEXT \ diff --git a/mail/em-filter-folder-element.h b/mail/em-filter-folder-element.h index f71b4c128b..f5a1741795 100644 --- a/mail/em-filter-folder-element.h +++ b/mail/em-filter-folder-element.h @@ -25,8 +25,8 @@ #ifndef EM_FILTER_FOLDER_ELEMENT_H #define EM_FILTER_FOLDER_ELEMENT_H -#include <mail/e-mail-session.h> #include <filter/e-filter-element.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_FILTER_FOLDER_ELEMENT \ diff --git a/mail/em-filter-source-element.c b/mail/em-filter-source-element.c index a8e51e2827..5848f938db 100644 --- a/mail/em-filter-source-element.c +++ b/mail/em-filter-source-element.c @@ -32,8 +32,8 @@ #include <gtk/gtk.h> #include <camel/camel.h> -#include <e-util/e-account-utils.h> #include <filter/e-filter-part.h> +#include <libemail-utils/e-account-utils.h> #define EM_FILTER_SOURCE_ELEMENT_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ diff --git a/mail/em-filter-source-element.h b/mail/em-filter-source-element.h index 41c3f3f8fc..061a487fc8 100644 --- a/mail/em-filter-source-element.h +++ b/mail/em-filter-source-element.h @@ -24,8 +24,8 @@ #ifndef EM_FILTER_SOURCE_ELEMENT_H #define EM_FILTER_SOURCE_ELEMENT_H -#include <mail/e-mail-session.h> #include <filter/e-filter-element.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_FILTER_SOURCE_ELEMENT \ diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c index 75ccf5304b..2abb1f366d 100644 --- a/mail/em-folder-properties.c +++ b/mail/em-folder-properties.c @@ -24,18 +24,20 @@ #include <config.h> #endif +#include "em-folder-properties.h" + #include <string.h> #include <gtk/gtk.h> #include <glib/gi18n.h> -#include "em-folder-properties.h" -#include "em-config.h" +#include <libemail-utils/mail-mt.h> +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/mail-ops.h> #include "e-mail-backend.h" -#include "e-mail-folder-utils.h" -#include "mail-ops.h" -#include "mail-mt.h" +#include "e-mail-ui-session.h" +#include "em-config.h" #include "mail-vfolder.h" typedef struct _AsyncContext AsyncContext; @@ -498,8 +500,8 @@ em_folder_properties_show (CamelStore *store, cancellable = camel_operation_new (); e_activity_set_cancellable (context->activity, cancellable); - e_mail_session_add_activity ( - E_MAIL_SESSION (session), context->activity); + e_mail_ui_session_add_activity ( + E_MAIL_UI_SESSION (session), context->activity); camel_store_get_folder ( store, folder_name, 0, G_PRIORITY_DEFAULT, cancellable, diff --git a/mail/em-folder-properties.h b/mail/em-folder-properties.h index 704e43b6d3..2d829af17f 100644 --- a/mail/em-folder-properties.h +++ b/mail/em-folder-properties.h @@ -25,7 +25,8 @@ #define __EM_FOLDER_PROPERTIES_H__ #include <camel/camel.h> -#include <mail/e-mail-session.h> +#include <e-util/e-alert-sink.h> +#include <libemail-engine/e-mail-session.h> G_BEGIN_DECLS diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c index 6e40234444..fb4e27d83b 100644 --- a/mail/em-folder-selection-button.c +++ b/mail/em-folder-selection-button.c @@ -28,7 +28,8 @@ #include <glib/gi18n.h> #include <e-util/e-util.h> -#include "e-mail-folder-utils.h" +#include <libemail-engine/e-mail-folder-utils.h> + #include "em-folder-tree.h" #include "em-folder-selector.h" #include "em-utils.h" diff --git a/mail/em-folder-selection-button.h b/mail/em-folder-selection-button.h index 6e646e3af0..945f1dab0b 100644 --- a/mail/em-folder-selection-button.h +++ b/mail/em-folder-selection-button.h @@ -25,7 +25,7 @@ #define EM_FOLDER_SELECTION_BUTTON_H #include <gtk/gtk.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_FOLDER_SELECTION_BUTTON \ diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c index 2f5b58274f..18172cb7a5 100644 --- a/mail/em-folder-selector.c +++ b/mail/em-folder-selector.c @@ -29,7 +29,8 @@ #include <glib/gi18n.h> #include <e-util/e-util.h> -#include "e-mail-session.h" +#include <libemail-engine/e-mail-session.h> + #include "em-folder-tree.h" #include "em-folder-selector.h" #include "em-folder-utils.h" diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index c346435f80..7ee385c892 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -36,22 +36,22 @@ #include <glib/gi18n.h> -#include "e-util/e-util.h" -#include "e-util/e-account-utils.h" +#include <e-util/e-util.h> +#include <shell/e-shell.h> -#include "mail-tools.h" -#include "mail-mt.h" -#include "mail-ops.h" +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/mail-mt.h> -/* sigh, these 2 only needed for outbox total count checking - a mess */ -#include "mail-folder-cache.h" +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/mail-folder-cache.h> +#include <libemail-engine/mail-tools.h> +#include <libemail-engine/mail-ops.h> -#include "em-utils.h" -#include "em-folder-utils.h" -#include "em-event.h" - -#include "e-mail-folder-utils.h" -#include "shell/e-shell.h" +#include <e-mail-account-store.h> +#include <e-mail-ui-session.h> +#include <em-utils.h> +#include <em-folder-utils.h> +#include <em-event.h> #define EM_FOLDER_TREE_MODEL_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -573,7 +573,7 @@ em_folder_tree_model_set_session (EMFolderTreeModel *model, MailFolderCache *folder_cache; folder_cache = e_mail_session_get_folder_cache (session); - account_store = e_mail_session_get_account_store (session); + account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session)); /* Keep our own reference since we connect to its signals. */ g_warn_if_fail (model->priv->account_store == NULL); diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h index 1bf5483367..b4acb3dce6 100644 --- a/mail/em-folder-tree-model.h +++ b/mail/em-folder-tree-model.h @@ -26,7 +26,7 @@ #include <gtk/gtk.h> #include <camel/camel.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_FOLDER_TREE_MODEL \ diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index a1e4142cf6..46a8c108e8 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -48,11 +48,11 @@ #include "em-vfolder-rule.h" -#include "mail-mt.h" -#include "mail-ops.h" -#include "mail-tools.h" -#include "mail-send-recv.h" -#include "mail-vfolder.h" +#include "libemail-utils/mail-mt.h" +#include "libemail-engine/e-mail-folder-utils.h" +#include "libemail-engine/e-mail-session.h" +#include "libemail-engine/mail-ops.h" +#include "libemail-engine/mail-tools.h" #include "em-utils.h" #include "em-folder-tree.h" @@ -60,9 +60,10 @@ #include "em-folder-selector.h" #include "em-folder-properties.h" #include "em-event.h" +#include "mail-send-recv.h" +#include "mail-vfolder.h" -#include "e-mail-folder-utils.h" -#include "e-mail-session.h" +#include "e-mail-ui-session.h" #define d(x) @@ -1822,7 +1823,8 @@ em_folder_tree_new_activity (EMFolderTree *folder_tree) g_object_unref (cancellable); session = em_folder_tree_get_session (folder_tree); - e_mail_session_add_activity (session, activity); + e_mail_ui_session_add_activity ( + E_MAIL_UI_SESSION (session), activity); return activity; } @@ -2036,7 +2038,7 @@ folder_tree_drop_folder (struct _DragDataReceivedAsync *m) d(printf(" * Drop folder '%s' onto '%s'\n", data, m->full_name)); - cancellable = e_activity_get_cancellable (m->base.activity); + cancellable = m->base.cancellable; folder = e_mail_session_uri_to_folder_sync ( m->session, (gchar *) data, 0, diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h index 6a60f2bc31..1e39ebab18 100644 --- a/mail/em-folder-tree.h +++ b/mail/em-folder-tree.h @@ -25,9 +25,10 @@ #define EM_FOLDER_TREE_H #include <gtk/gtk.h> +#include <e-util/e-activity.h> #include <e-util/e-alert-sink.h> -#include <mail/e-mail-session.h> #include <mail/em-folder-tree-model.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_FOLDER_TREE \ diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index 825e6af7ca..1350df7c7b 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -45,22 +45,23 @@ #include "em-vfolder-rule.h" -#include "mail-mt.h" -#include "mail-ops.h" -#include "mail-tools.h" -#include "mail-vfolder.h" -#include "mail-folder-cache.h" - +#include "libemail-utils/mail-mt.h" +#include "libemail-engine/e-mail-folder-utils.h" +#include "libemail-engine/e-mail-session.h" +#include "libemail-engine/e-mail-store-utils.h" +#include "libemail-engine/e-mail-utils.h" +#include "libemail-engine/mail-ops.h" +#include "libemail-engine/mail-tools.h" +#include "libemail-engine/mail-folder-cache.h" + +#include "e-mail-ui-session.h" #include "em-utils.h" #include "em-folder-tree.h" #include "em-folder-tree-model.h" #include "em-folder-utils.h" #include "em-folder-selector.h" #include "em-folder-properties.h" - -#include "e-mail-folder-utils.h" -#include "e-mail-session.h" -#include "e-mail-store-utils.h" +#include "mail-vfolder.h" #define d(x) @@ -567,7 +568,7 @@ em_folder_utils_create_folder (GtkWindow *parent, model = em_folder_tree_model_new (); em_folder_tree_model_set_session (model, session); - account_store = e_mail_session_get_account_store (session); + account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session)); e_mail_account_store_queue_enabled_services (account_store, &queue); while (!g_queue_is_empty (&queue)) { diff --git a/mail/em-folder-utils.h b/mail/em-folder-utils.h index 9211cacd90..db3853042c 100644 --- a/mail/em-folder-utils.h +++ b/mail/em-folder-utils.h @@ -26,7 +26,7 @@ #include <gtk/gtk.h> #include <camel/camel.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> #include <mail/em-folder-tree.h> G_BEGIN_DECLS diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c index a600c5a48a..04216900bc 100644 --- a/mail/em-format-html-print.c +++ b/mail/em-format-html-print.c @@ -30,11 +30,13 @@ #include <gtk/gtk.h> #include <gtkhtml/gtkhtml.h> -#include "mail-ops.h" -#include "mail-mt.h" -#include "em-format-html-print.h" #include <e-util/e-print.h> +#include <libemail-utils/mail-mt.h> +#include <libemail-engine/mail-ops.h> + +#include "em-format-html-print.h" + G_DEFINE_TYPE ( EMFormatHTMLPrint, em_format_html_print, diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 706de09248..a720d2cc9f 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -57,12 +57,15 @@ #include <glib/gi18n.h> -#include "e-mail-enumtypes.h" +#include <libemail-utils/mail-mt.h> + +#include <libemail-engine/e-mail-enumtypes.h> +#include <libemail-engine/e-mail-utils.h> +#include <libemail-engine/mail-config.h> + #include "em-format-html.h" #include "em-html-stream.h" #include "em-utils.h" -#include "mail-config.h" -#include "mail-mt.h" #define EM_FORMAT_HTML_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ diff --git a/mail/em-format-html.h b/mail/em-format-html.h index 7ded2e82f9..954a54ea0c 100644 --- a/mail/em-format-html.h +++ b/mail/em-format-html.h @@ -29,9 +29,9 @@ #define EM_FORMAT_HTML_H #include <em-format/em-format.h> -#include <mail/e-mail-enums.h> #include <misc/e-web-view.h> #include <gtkhtml/gtkhtml-embedded.h> +#include <libemail-engine/e-mail-enums.h> /* Standard GObject macros */ #define EM_TYPE_FORMAT_HTML \ diff --git a/mail/em-subscription-editor.c b/mail/em-subscription-editor.c index 15f7a3be32..ceefe7ca49 100644 --- a/mail/em-subscription-editor.c +++ b/mail/em-subscription-editor.c @@ -25,12 +25,12 @@ #include <string.h> #include <glib/gi18n-lib.h> -#include "mail-tools.h" -#include "mail-ops.h" -#include "mail-mt.h" +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/mail-mt.h> +#include <libemail-engine/mail-tools.h> +#include <libemail-engine/mail-ops.h> #include <e-util/e-util.h> -#include <e-util/e-account-utils.h> #include <e-util/e-util-private.h> #include "em-folder-utils.h" diff --git a/mail/em-subscription-editor.h b/mail/em-subscription-editor.h index c6f6c258f0..b9abedb166 100644 --- a/mail/em-subscription-editor.h +++ b/mail/em-subscription-editor.h @@ -21,7 +21,7 @@ #include <gtk/gtk.h> #include <camel/camel.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_SUBSCRIPTION_EDITOR \ diff --git a/mail/em-sync-stream.c b/mail/em-sync-stream.c index 06f96ecd83..841d890e41 100644 --- a/mail/em-sync-stream.c +++ b/mail/em-sync-stream.c @@ -32,7 +32,7 @@ #include <glib/gi18n-lib.h> #include <libedataserver/e-flag.h> -#include "mail-mt.h" +#include <libemail-utils/mail-mt.h> enum _write_msg_t { EMSS_WRITE, diff --git a/mail/em-utils.c b/mail/em-utils.c index 416588cfbb..247b47d967 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -41,38 +41,40 @@ #undef interface #endif -#include <libebook/e-book-client.h> -#include <libebook/e-book-query.h> - #include "em-filter-editor.h" #include <glib/gi18n.h> #include <gio/gio.h> -#include "mail-mt.h" -#include "mail-ops.h" -#include "mail-tools.h" -#include "e-mail-tag-editor.h" - +#include <libebook/e-book-client.h> +#include <libebook/e-book-query.h> #include <libedataserver/e-data-server-util.h> #include <libedataserver/e-flag.h> #include <libedataserver/e-proxy.h> -#include "e-util/e-util.h" -#include "e-util/e-util-private.h" -#include "e-util/e-mktemp.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-dialog-utils.h" -#include "e-util/e-alert-dialog.h" -#include "shell/e-shell.h" -#include "widgets/misc/e-attachment.h" -#include "em-utils.h" +#include <e-util/e-util.h> +#include <e-util/e-util-private.h> +#include <e-util/e-mktemp.h> +#include <e-util/e-dialog-utils.h> +#include <e-util/e-alert-dialog.h> + +#include <shell/e-shell.h> +#include <widgets/misc/e-attachment.h> + +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/mail-mt.h> + +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/mail-ops.h> +#include <libemail-engine/mail-tools.h> + +#include "e-mail-tag-editor.h" #include "em-composer-utils.h" #include "em-format-quote.h" #include "em-format-html-print.h" -#include "e-mail-folder-utils.h" -#include "e-mail-session.h" +#include "em-utils.h" /* XXX This is a dirty hack on a dirty hack. We really need * to rework or get rid of the functions that use this. */ @@ -1107,202 +1109,6 @@ em_utils_selection_get_urilist (GtkSelectionData *selection_data, g_strfreev (uris); } -/** - * em_utils_folder_is_templates: - * @folder: a #CamelFolder - * - * Decides if @folder is a Templates folder. - * - * Returns %TRUE if this is a Templates folder or %FALSE otherwise. - **/ - -gboolean -em_utils_folder_is_templates (CamelFolder *folder) -{ - CamelFolder *local_templates_folder; - CamelSession *session; - CamelStore *store; - EAccountList *account_list; - EIterator *iterator; - gchar *folder_uri; - gboolean is_templates = FALSE; - - g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); - - store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); - - local_templates_folder = - e_mail_session_get_local_folder ( - E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_TEMPLATES); - - if (folder == local_templates_folder) - return TRUE; - - folder_uri = e_mail_folder_uri_from_folder (folder); - - account_list = e_get_account_list (); - iterator = e_list_get_iterator (E_LIST (account_list)); - - while (!is_templates && e_iterator_is_valid (iterator)) { - EAccount *account; - - /* XXX EIterator misuses const. */ - account = (EAccount *) e_iterator_get (iterator); - - if (account->templates_folder_uri != NULL) - is_templates = e_mail_folder_uri_equal ( - session, folder_uri, - account->templates_folder_uri); - - e_iterator_next (iterator); - } - - g_object_unref (iterator); - g_free (folder_uri); - - return is_templates; -} - -/** - * em_utils_folder_is_drafts: - * @folder: a #CamelFolder - * - * Decides if @folder is a Drafts folder. - * - * Returns %TRUE if this is a Drafts folder or %FALSE otherwise. - **/ -gboolean -em_utils_folder_is_drafts (CamelFolder *folder) -{ - CamelFolder *local_drafts_folder; - CamelSession *session; - CamelStore *store; - EAccountList *account_list; - EIterator *iterator; - gchar *folder_uri; - gboolean is_drafts = FALSE; - - g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); - - store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); - - local_drafts_folder = - e_mail_session_get_local_folder ( - E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_DRAFTS); - - if (folder == local_drafts_folder) - return TRUE; - - folder_uri = e_mail_folder_uri_from_folder (folder); - - account_list = e_get_account_list (); - iterator = e_list_get_iterator (E_LIST (account_list)); - - while (!is_drafts && e_iterator_is_valid (iterator)) { - EAccount *account; - - /* XXX EIterator misuses const. */ - account = (EAccount *) e_iterator_get (iterator); - - if (account->drafts_folder_uri != NULL) - is_drafts = e_mail_folder_uri_equal ( - session, folder_uri, - account->drafts_folder_uri); - - e_iterator_next (iterator); - } - - g_object_unref (iterator); - g_free (folder_uri); - - return is_drafts; -} - -/** - * em_utils_folder_is_sent: - * @folder: a #CamelFolder - * - * Decides if @folder is a Sent folder. - * - * Returns %TRUE if this is a Sent folder or %FALSE otherwise. - **/ -gboolean -em_utils_folder_is_sent (CamelFolder *folder) -{ - CamelFolder *local_sent_folder; - CamelSession *session; - CamelStore *store; - EAccountList *account_list; - EIterator *iterator; - gchar *folder_uri; - gboolean is_sent = FALSE; - - g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); - - store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); - - local_sent_folder = - e_mail_session_get_local_folder ( - E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_SENT); - - if (folder == local_sent_folder) - return TRUE; - - folder_uri = e_mail_folder_uri_from_folder (folder); - - account_list = e_get_account_list (); - iterator = e_list_get_iterator (E_LIST (account_list)); - - while (!is_sent && e_iterator_is_valid (iterator)) { - EAccount *account; - - /* XXX EIterator misuses const. */ - account = (EAccount *) e_iterator_get (iterator); - - if (account->sent_folder_uri != NULL) - is_sent = e_mail_folder_uri_equal ( - session, folder_uri, - account->sent_folder_uri); - - e_iterator_next (iterator); - } - - g_object_unref (iterator); - g_free (folder_uri); - - return is_sent; -} - -/** - * em_utils_folder_is_outbox: - * @folder: a #CamelFolder - * - * Decides if @folder is an Outbox folder. - * - * Returns %TRUE if this is an Outbox folder or %FALSE otherwise. - **/ -gboolean -em_utils_folder_is_outbox (CamelFolder *folder) -{ - CamelStore *store; - CamelSession *session; - CamelFolder *local_outbox_folder; - - g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE); - - store = camel_folder_get_parent_store (folder); - session = camel_service_get_session (CAMEL_SERVICE (store)); - - local_outbox_folder = - e_mail_session_get_local_folder ( - E_MAIL_SESSION (session), E_MAIL_LOCAL_FOLDER_OUTBOX); - - return (folder == local_outbox_folder); -} - /* ********************************************************************** */ static EProxy *emu_proxy = NULL; static GStaticMutex emu_proxy_lock = G_STATIC_MUTEX_INIT; @@ -1454,578 +1260,6 @@ em_utils_empty_trash (GtkWidget *parent, /* ********************************************************************** */ -/* runs sync, in main thread */ -static gpointer -emu_addr_setup (gpointer user_data) -{ - GError *err = NULL; - ESourceList **psource_list = user_data; - - if (!e_book_client_get_sources (psource_list, &err)) - g_error_free (err); - - return NULL; -} - -static void -emu_addr_cancel_stop (gpointer data) -{ - gboolean *stop = data; - - g_return_if_fail (stop != NULL); - - *stop = TRUE; -} - -static void -emu_addr_cancel_cancellable (gpointer data) -{ - GCancellable *cancellable = data; - - g_return_if_fail (cancellable != NULL); - - g_cancellable_cancel (cancellable); -} - -struct TryOpenEBookStruct { - GError **error; - EFlag *flag; - gboolean result; -}; - -static void -try_open_book_client_cb (GObject *source_object, - GAsyncResult *result, - gpointer closure) -{ - EBookClient *book_client = E_BOOK_CLIENT (source_object); - struct TryOpenEBookStruct *data = (struct TryOpenEBookStruct *) closure; - GError *error = NULL; - - if (!data) - return; - - e_client_open_finish (E_CLIENT (book_client), result, &error); - - data->result = error == NULL; - - if (!data->result) { - g_clear_error (data->error); - g_propagate_error (data->error, error); - } - - e_flag_set (data->flag); -} - -/* - * try_open_book_client: - * Tries to open address book asynchronously, but acts as synchronous. - * The advantage is it checks periodically whether the camel_operation - * has been canceled or not, and if so, then stops immediately, with - * result FALSE. Otherwise returns same as e_client_open() - */ -static gboolean -try_open_book_client (EBookClient *book_client, - gboolean only_if_exists, - GCancellable *cancellable, - GError **error) -{ - struct TryOpenEBookStruct data; - gboolean canceled = FALSE; - EFlag *flag = e_flag_new (); - - data.error = error; - data.flag = flag; - data.result = FALSE; - - e_client_open ( - E_CLIENT (book_client), only_if_exists, - cancellable, try_open_book_client_cb, &data); - - while (canceled = g_cancellable_is_cancelled (cancellable), - !canceled && !e_flag_is_set (flag)) { - GTimeVal wait; - - g_get_current_time (&wait); - g_time_val_add (&wait, 250000); /* waits 250ms */ - - e_flag_timed_wait (flag, &wait); - } - - if (canceled) { - g_cancellable_cancel (cancellable); - - g_clear_error (error); - g_propagate_error ( - error, e_client_error_create ( - E_CLIENT_ERROR_CANCELLED, NULL)); - } - - e_flag_wait (flag); - e_flag_free (flag); - - return data.result && (!error || !*error); -} - -#define NOT_FOUND_BOOK (GINT_TO_POINTER (1)) - -G_LOCK_DEFINE_STATIC (contact_cache); - -/* key is lowercased contact email; value is EBook pointer - * (just for comparison) where it comes from */ -static GHashTable *contact_cache = NULL; - -/* key is source ID; value is pointer to EBook */ -static GHashTable *emu_books_hash = NULL; - -/* key is source ID; value is same pointer as key; this is hash of - * broken books, which failed to open for some reason */ -static GHashTable *emu_broken_books_hash = NULL; - -static ESourceList *emu_books_source_list = NULL; - -static gboolean -search_address_in_addressbooks (const gchar *address, - gboolean local_only, - gboolean (*check_contact) (EContact *contact, - gpointer user_data), - gpointer user_data) -{ - gboolean found = FALSE, stop = FALSE, found_any = FALSE; - gchar *lowercase_addr; - gpointer ptr; - EBookQuery *book_query; - gchar *query; - GSList *s, *g, *addr_sources = NULL; - GHook *hook_cancellable; - GCancellable *cancellable; - - if (!address || !*address) - return FALSE; - - G_LOCK (contact_cache); - - if (!emu_books_source_list) { - mail_call_main ( - MAIL_CALL_p_p, (MailMainFunc) - emu_addr_setup, &emu_books_source_list); - emu_books_hash = g_hash_table_new_full ( - g_str_hash, g_str_equal, g_free, g_object_unref); - emu_broken_books_hash = g_hash_table_new_full ( - g_str_hash, g_str_equal, g_free, NULL); - contact_cache = g_hash_table_new_full ( - g_str_hash, g_str_equal, g_free, NULL); - } - - if (!emu_books_source_list) { - G_UNLOCK (contact_cache); - return FALSE; - } - - lowercase_addr = g_utf8_strdown (address, -1); - ptr = g_hash_table_lookup (contact_cache, lowercase_addr); - if (ptr != NULL && (check_contact == NULL || ptr == NOT_FOUND_BOOK)) { - g_free (lowercase_addr); - G_UNLOCK (contact_cache); - return ptr != NOT_FOUND_BOOK; - } - - book_query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address); - query = e_book_query_to_string (book_query); - e_book_query_unref (book_query); - - for (g = e_source_list_peek_groups (emu_books_source_list); - g; g = g_slist_next (g)) { - ESourceGroup *group = g->data; - - if (!group) - continue; - - if (local_only && !(e_source_group_peek_base_uri (group) && - g_str_has_prefix ( - e_source_group_peek_base_uri (group), "local:"))) - continue; - - for (s = e_source_group_peek_sources (group); s; s = g_slist_next (s)) { - ESource *source = s->data; - const gchar *completion = e_source_get_property (source, "completion"); - - if (completion && g_ascii_strcasecmp (completion, "true") == 0) { - addr_sources = g_slist_prepend (addr_sources, g_object_ref (source)); - } - } - } - - cancellable = g_cancellable_new (); - hook_cancellable = mail_cancel_hook_add (emu_addr_cancel_cancellable, cancellable); - - for (s = addr_sources; !stop && !found && s; s = g_slist_next (s)) { - ESource *source = s->data; - GSList *contacts; - EBookClient *book_client = NULL; - GHook *hook_stop; - gboolean cached_book = FALSE; - const gchar *display_name; - const gchar *uid; - GError *err = NULL; - - uid = e_source_peek_uid (source); - display_name = e_source_peek_name (source); - - /* failed to load this book last time, skip it now */ - if (g_hash_table_lookup (emu_broken_books_hash, uid) != NULL) { - d(printf ("%s: skipping broken book '%s'\n", - G_STRFUNC, display_name)); - continue; - } - - d(printf(" checking '%s'\n", e_source_get_uri(source))); - - hook_stop = mail_cancel_hook_add (emu_addr_cancel_stop, &stop); - - book_client = g_hash_table_lookup (emu_books_hash, uid); - if (!book_client) { - book_client = e_book_client_new (source, &err); - - if (book_client == NULL) { - if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))) { - stop = TRUE; - } else if (err) { - gchar *source_uid; - - source_uid = g_strdup (uid); - - g_hash_table_insert ( - emu_broken_books_hash, - source_uid, source_uid); - - g_warning ( - "%s: Unable to create addressbook '%s': %s", - G_STRFUNC, - display_name, - err->message); - } - g_clear_error (&err); - } else if (!stop && !try_open_book_client (book_client, TRUE, cancellable, &err)) { - g_object_unref (book_client); - book_client = NULL; - - if (err && (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))) { - stop = TRUE; - } else if (err) { - gchar *source_uid; - - source_uid = g_strdup (uid); - - g_hash_table_insert ( - emu_broken_books_hash, - source_uid, source_uid); - - g_warning ( - "%s: Unable to open addressbook '%s': %s", - G_STRFUNC, - display_name, - err->message); - } - g_clear_error (&err); - } - } else { - cached_book = TRUE; - } - - if (book_client && !stop && e_book_client_get_contacts_sync (book_client, query, &contacts, cancellable, &err)) { - if (contacts != NULL) { - if (!found_any) { - g_hash_table_insert (contact_cache, g_strdup (lowercase_addr), book_client); - } - found_any = TRUE; - - if (check_contact) { - GSList *l; - - for (l = contacts; l && !found; l = l->next) { - EContact *contact = l->data; - - found = check_contact (contact, user_data); - } - } else { - found = TRUE; - } - - g_slist_foreach (contacts, (GFunc) g_object_unref, NULL); - g_slist_free (contacts); - } - } else if (book_client) { - stop = stop || (err && - (g_error_matches (err, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) || - g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))); - if (err && !stop) { - gchar *source_uid = g_strdup (uid); - - g_hash_table_insert (emu_broken_books_hash, source_uid, source_uid); - - g_warning ( - "%s: Can't get contacts from '%s': %s", - G_STRFUNC, - display_name, - err->message); - } - g_clear_error (&err); - } - - mail_cancel_hook_remove (hook_stop); - - if (stop && !cached_book && book_client) { - g_object_unref (book_client); - } else if (!stop && book_client && !cached_book) { - g_hash_table_insert ( - emu_books_hash, g_strdup (uid), book_client); - } - } - - mail_cancel_hook_remove (hook_cancellable); - g_object_unref (cancellable); - - g_slist_free_full (addr_sources, (GDestroyNotify) g_object_unref); - - g_free (query); - - if (!found_any) { - g_hash_table_insert (contact_cache, lowercase_addr, NOT_FOUND_BOOK); - lowercase_addr = NULL; - } - - G_UNLOCK (contact_cache); - - g_free (lowercase_addr); - - return found_any; -} - -gboolean -em_utils_in_addressbook (CamelInternetAddress *iaddr, - gboolean local_only) -{ - const gchar *addr; - - /* TODO: check all addresses? */ - if (iaddr == NULL || !camel_internet_address_get (iaddr, 0, NULL, &addr)) - return FALSE; - - return search_address_in_addressbooks (addr, local_only, NULL, NULL); -} - -static gboolean -extract_photo_data (EContact *contact, - gpointer user_data) -{ - EContactPhoto **photo = user_data; - - g_return_val_if_fail (contact != NULL, FALSE); - g_return_val_if_fail (user_data != NULL, FALSE); - - *photo = e_contact_get (contact, E_CONTACT_PHOTO); - if (!*photo) - *photo = e_contact_get (contact, E_CONTACT_LOGO); - - return *photo != NULL; -} - -typedef struct _PhotoInfo { - gchar *address; - EContactPhoto *photo; -} PhotoInfo; - -static void -emu_free_photo_info (PhotoInfo *pi) -{ - if (!pi) - return; - - if (pi->address) - g_free (pi->address); - if (pi->photo) - e_contact_photo_free (pi->photo); - g_free (pi); -} - -G_LOCK_DEFINE_STATIC (photos_cache); -static GSList *photos_cache = NULL; /* list of PhotoInfo-s */ - -CamelMimePart * -em_utils_contact_photo (CamelInternetAddress *cia, - gboolean local_only) -{ - const gchar *addr = NULL; - CamelMimePart *part = NULL; - EContactPhoto *photo = NULL; - GSList *p, *first_not_null = NULL; - gint count_not_null = 0; - - if (cia == NULL || !camel_internet_address_get (cia, 0, NULL, &addr) || !addr) { - return NULL; - } - - G_LOCK (photos_cache); - - /* search a cache first */ - for (p = photos_cache; p; p = p->next) { - PhotoInfo *pi = p->data; - - if (!pi) - continue; - - if (pi->photo) { - if (!first_not_null) - first_not_null = p; - count_not_null++; - } - - if (g_ascii_strcasecmp (addr, pi->address) == 0) { - photo = pi->photo; - break; - } - } - - /* !p means the address had not been found in the cache */ - if (!p && search_address_in_addressbooks ( - addr, local_only, extract_photo_data, &photo)) { - PhotoInfo *pi; - - if (photo && photo->type != E_CONTACT_PHOTO_TYPE_INLINED) { - e_contact_photo_free (photo); - photo = NULL; - } - - /* keep only up to 10 photos in memory */ - if (photo && count_not_null >= 10 && first_not_null) { - pi = first_not_null->data; - - photos_cache = g_slist_remove (photos_cache, pi); - - emu_free_photo_info (pi); - } - - pi = g_new0 (PhotoInfo, 1); - pi->address = g_strdup (addr); - pi->photo = photo; - - photos_cache = g_slist_append (photos_cache, pi); - } - - /* some photo found, use it */ - if (photo) { - /* Form a mime part out of the photo */ - part = camel_mime_part_new (); - camel_mime_part_set_content (part, - (const gchar *) photo->data.inlined.data, - photo->data.inlined.length, "image/jpeg"); - } - - G_UNLOCK (photos_cache); - - return part; -} - -/* list of email addresses (strings) to remove from local cache of photos and - * contacts, but only if the photo doesn't exist or is an not-found contact */ -void -emu_remove_from_mail_cache (const GSList *addresses) -{ - const GSList *a; - GSList *p; - CamelInternetAddress *cia; - - cia = camel_internet_address_new (); - - for (a = addresses; a; a = a->next) { - const gchar *addr = NULL; - - if (!a->data) - continue; - - if (camel_address_decode ((CamelAddress *) cia, a->data) != -1 && - camel_internet_address_get (cia, 0, NULL, &addr) && addr) { - gchar *lowercase_addr = g_utf8_strdown (addr, -1); - - G_LOCK (contact_cache); - if (g_hash_table_lookup (contact_cache, lowercase_addr) == NOT_FOUND_BOOK) - g_hash_table_remove (contact_cache, lowercase_addr); - G_UNLOCK (contact_cache); - - g_free (lowercase_addr); - - G_LOCK (photos_cache); - for (p = photos_cache; p; p = p->next) { - PhotoInfo *pi = p->data; - - if (pi && !pi->photo && g_ascii_strcasecmp (pi->address, addr) == 0) { - photos_cache = g_slist_remove (photos_cache, pi); - emu_free_photo_info (pi); - break; - } - } - G_UNLOCK (photos_cache); - } - } - - g_object_unref (cia); -} - -void -emu_remove_from_mail_cache_1 (const gchar *address) -{ - GSList *l; - - g_return_if_fail (address != NULL); - - l = g_slist_append (NULL, (gpointer) address); - - emu_remove_from_mail_cache (l); - - g_slist_free (l); -} - -/* frees all data created by call of em_utils_in_addressbook() or - * em_utils_contact_photo() */ -void -emu_free_mail_cache (void) -{ - G_LOCK (contact_cache); - - if (emu_books_hash) { - g_hash_table_destroy (emu_books_hash); - emu_books_hash = NULL; - } - - if (emu_broken_books_hash) { - g_hash_table_destroy (emu_broken_books_hash); - emu_broken_books_hash = NULL; - } - - if (emu_books_source_list) { - g_object_unref (emu_books_source_list); - emu_books_source_list = NULL; - } - - if (contact_cache) { - g_hash_table_destroy (contact_cache); - contact_cache = NULL; - } - - G_UNLOCK (contact_cache); - - G_LOCK (photos_cache); - - g_slist_foreach (photos_cache, (GFunc) emu_free_photo_info, NULL); - g_slist_free (photos_cache); - photos_cache = NULL; - - G_UNLOCK (photos_cache); -} - void em_utils_clear_get_password_canceled_accounts_flag (void) { @@ -2080,148 +1314,6 @@ em_utils_url_unescape_amp (const gchar *url) return buff; } -static EAccount * -guess_account_from_folder (CamelFolder *folder) -{ - CamelStore *store; - const gchar *uid; - - store = camel_folder_get_parent_store (folder); - uid = camel_service_get_uid (CAMEL_SERVICE (store)); - - return e_get_account_by_uid (uid); -} - -static EAccount * -guess_account_from_message (CamelMimeMessage *message) -{ - const gchar *uid; - - uid = camel_mime_message_get_source (message); - - return (uid != NULL) ? e_get_account_by_uid (uid) : NULL; -} - -EAccount * -em_utils_guess_account (CamelMimeMessage *message, - CamelFolder *folder) -{ - EAccount *account = NULL; - - g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); - - if (folder != NULL) - g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL); - - /* check for newsgroup header */ - if (folder != NULL - && camel_medium_get_header (CAMEL_MEDIUM (message), "Newsgroups")) - account = guess_account_from_folder (folder); - - /* check for source folder */ - if (account == NULL && folder != NULL) - account = guess_account_from_folder (folder); - - /* then message source */ - if (account == NULL) - account = guess_account_from_message (message); - - return account; -} - -EAccount * -em_utils_guess_account_with_recipients (CamelMimeMessage *message, - CamelFolder *folder) -{ - EAccount *account = NULL; - EAccountList *account_list; - GHashTable *recipients; - EIterator *iterator; - CamelInternetAddress *addr; - const gchar *type; - const gchar *key; - - /* This policy is subject to debate and tweaking, - * but please also document the rational here. */ - - g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL); - - /* Build a set of email addresses in which to test for membership. - * Only the keys matter here; the values just need to be non-NULL. */ - recipients = g_hash_table_new (g_str_hash, g_str_equal); - - type = CAMEL_RECIPIENT_TYPE_TO; - addr = camel_mime_message_get_recipients (message, type); - if (addr != NULL) { - gint index = 0; - - while (camel_internet_address_get (addr, index++, NULL, &key)) - g_hash_table_insert ( - recipients, (gpointer) key, - GINT_TO_POINTER (1)); - } - - type = CAMEL_RECIPIENT_TYPE_CC; - addr = camel_mime_message_get_recipients (message, type); - if (addr != NULL) { - gint index = 0; - - while (camel_internet_address_get (addr, index++, NULL, &key)) - g_hash_table_insert ( - recipients, (gpointer) key, - GINT_TO_POINTER (1)); - } - - /* First Preference: We were given a folder that maps to an - * enabled account, and that account's email address appears - * in the list of To: or Cc: recipients. */ - - if (folder != NULL) - account = guess_account_from_folder (folder); - - if (account == NULL || !account->enabled) - goto second_preference; - - if ((key = account->id->address) == NULL) - goto second_preference; - - if (g_hash_table_lookup (recipients, key) != NULL) - goto exit; - -second_preference: - - /* Second Preference: Choose any enabled account whose email - * address appears in the list to To: or Cc: recipients. */ - - account_list = e_get_account_list (); - iterator = e_list_get_iterator (E_LIST (account_list)); - - while (e_iterator_is_valid (iterator)) { - account = (EAccount *) e_iterator_get (iterator); - e_iterator_next (iterator); - - if (account == NULL || !account->enabled) - continue; - - if ((key = account->id->address) == NULL) - continue; - - if (g_hash_table_lookup (recipients, key) != NULL) { - g_object_unref (iterator); - goto exit; - } - } - g_object_unref (iterator); - - /* Last Preference: Defer to em_utils_guess_account(). */ - account = em_utils_guess_account (message, folder); - -exit: - g_hash_table_destroy (recipients); - - return account; -} - void emu_restore_folder_tree_state (EMFolderTree *folder_tree) { @@ -2252,76 +1344,6 @@ emu_restore_folder_tree_state (EMFolderTree *folder_tree) g_key_file_free (key_file); } -/* Returns TRUE if CamelURL points to a local mbox file. */ -gboolean -em_utils_is_local_delivery_mbox_file (CamelURL *url) -{ - g_return_val_if_fail (url != NULL, FALSE); - - return g_str_equal (url->protocol, "mbox") && - (url->path != NULL) && - g_file_test (url->path, G_FILE_TEST_EXISTS) && - !g_file_test (url->path, G_FILE_TEST_IS_DIR); -} - -static void -cancel_service_connect_cb (GCancellable *cancellable, - CamelService *service) -{ - g_return_if_fail (CAMEL_IS_SERVICE (service)); - - camel_service_cancel_connect (service); -} - -gboolean -em_utils_connect_service_sync (CamelService *service, - GCancellable *cancellable, - GError **error) -{ - gboolean res; - gulong handler_id = 0; - - g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); - - if (cancellable != NULL) - handler_id = g_cancellable_connect ( - cancellable, - G_CALLBACK (cancel_service_connect_cb), - service, NULL); - - res = camel_service_connect_sync (service, error); - - if (handler_id) - g_cancellable_disconnect (cancellable, handler_id); - - return res; -} - -gboolean -em_utils_disconnect_service_sync (CamelService *service, - gboolean clean, - GCancellable *cancellable, - GError **error) -{ - gboolean res; - gulong handler_id = 0; - - g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); - - if (cancellable != NULL) - handler_id = g_cancellable_connect ( - cancellable, - G_CALLBACK (cancel_service_connect_cb), - service, NULL); - - res = camel_service_disconnect_sync (service, clean, error); - - if (handler_id) - g_cancellable_disconnect (cancellable, handler_id); - - return res; -} - static gboolean check_prefix (const gchar *subject, const gchar *prefix, diff --git a/mail/em-utils.h b/mail/em-utils.h index bf02419526..09ae4a56eb 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -29,8 +29,10 @@ #include <libedataserver/e-proxy.h> #include <libedataserver/e-account.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/e-mail-utils.h> + #include <mail/e-mail-reader.h> -#include <mail/e-mail-session.h> #include <mail/em-folder-tree.h> G_BEGIN_DECLS @@ -42,7 +44,6 @@ gboolean em_utils_ask_open_many (GtkWindow *parent, gint how_many); gboolean em_utils_prompt_user (GtkWindow *parent, const gchar *promptkey, const gchar *tag, ...); GPtrArray *em_utils_uids_copy (GPtrArray *uids); -void em_utils_uids_free (GPtrArray *uids); void em_utils_edit_filters (EMailSession *session, EAlertSink *alert_sink, @@ -64,11 +65,6 @@ void em_utils_selection_get_uidlist (GtkSelectionData *data, EMailSession *sessi void em_utils_selection_set_urilist (GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids); void em_utils_selection_get_urilist (GtkSelectionData *data, CamelFolder *folder); -gboolean em_utils_folder_is_drafts (CamelFolder *folder); -gboolean em_utils_folder_is_templates (CamelFolder *folder); -gboolean em_utils_folder_is_sent (CamelFolder *folder); -gboolean em_utils_folder_is_outbox (CamelFolder *folder); - EProxy * em_utils_get_proxy (void); /* FIXME: should this have an override charset? */ @@ -77,33 +73,16 @@ gchar *em_utils_message_to_html (CamelMimeMessage *msg, const gchar *credits, gu void em_utils_empty_trash (GtkWidget *parent, EMailSession *session); -/* is this address in the addressbook? caches results */ -gboolean em_utils_in_addressbook (CamelInternetAddress *addr, gboolean local_only); -CamelMimePart *em_utils_contact_photo (CamelInternetAddress *addr, gboolean local); - /* clears flag 'get_password_canceled' at every known accounts, so if needed, get_password will show dialog */ void em_utils_clear_get_password_canceled_accounts_flag (void); /* Unescapes & back to a real & in URIs */ gchar *em_utils_url_unescape_amp (const gchar *url); -EAccount * em_utils_guess_account (CamelMimeMessage *message, - CamelFolder *folder); -EAccount * em_utils_guess_account_with_recipients - (CamelMimeMessage *message, - CamelFolder *folder); - -void emu_remove_from_mail_cache (const GSList *addresses); -void emu_remove_from_mail_cache_1 (const gchar *address); -void emu_free_mail_cache (void); +void emu_free_mail_account_sort_order_cache (void); void emu_restore_folder_tree_state (EMFolderTree *folder_tree); -gboolean em_utils_is_local_delivery_mbox_file (CamelURL *url); - -gboolean em_utils_connect_service_sync (CamelService *service, GCancellable *cancellable, GError **error); -gboolean em_utils_disconnect_service_sync (CamelService *service, gboolean clean, GCancellable *cancellable, GError **error); - gboolean em_utils_is_re_in_subject (struct _EShell *shell, const gchar *subject, gint *skip_len); diff --git a/mail/em-vfolder-context.h b/mail/em-vfolder-context.h index c0fd041abc..2d1c6ef0fc 100644 --- a/mail/em-vfolder-context.h +++ b/mail/em-vfolder-context.h @@ -25,8 +25,8 @@ #ifndef EM_VFOLDER_CONTEXT_H #define EM_VFOLDER_CONTEXT_H -#include <mail/e-mail-session.h> #include <filter/e-rule-context.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_VFOLDER_CONTEXT \ diff --git a/mail/em-vfolder-rule.c b/mail/em-vfolder-rule.c index a22816070a..91bf46128e 100644 --- a/mail/em-vfolder-rule.c +++ b/mail/em-vfolder-rule.c @@ -30,17 +30,19 @@ #include <gtk/gtk.h> #include <glib/gi18n.h> +#include <shell/e-shell.h> + +#include <e-util/e-util.h> +#include <e-util/e-alert.h> +#include <e-util/e-util-private.h> + +#include <libemail-engine/e-mail-folder-utils.h> + +#include "em-folder-selector.h" +#include "em-folder-tree.h" +#include "em-utils.h" #include "em-vfolder-context.h" #include "em-vfolder-rule.h" -#include "mail/e-mail-folder-utils.h" -#include "mail/em-utils.h" -#include "mail/em-folder-tree.h" -#include "mail/em-folder-selector.h" -#include "shell/e-shell.h" - -#include "e-util/e-util.h" -#include "e-util/e-alert.h" -#include "e-util/e-util-private.h" #define EM_VFOLDER_RULE_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ diff --git a/mail/em-vfolder-rule.h b/mail/em-vfolder-rule.h index 7fc8daaee9..1b3a4432ca 100644 --- a/mail/em-vfolder-rule.h +++ b/mail/em-vfolder-rule.h @@ -24,8 +24,8 @@ #ifndef EM_VFOLDER_RULE_H #define EM_VFOLDER_RULE_H -#include <mail/e-mail-session.h> #include <filter/e-filter-rule.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define EM_TYPE_VFOLDER_RULE \ diff --git a/mail/importers/Makefile.am b/mail/importers/Makefile.am index fa1a400f03..6a7e9a8b6e 100644 --- a/mail/importers/Makefile.am +++ b/mail/importers/Makefile.am @@ -28,6 +28,8 @@ libevolution_mail_importers_la_LIBADD = \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/shell/libeshell.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(GTKHTML_LIBS) diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c index 832bf749ea..288d9fb736 100644 --- a/mail/importers/elm-importer.c +++ b/mail/importers/elm-importer.c @@ -40,7 +40,7 @@ #include "mail-importer.h" -#include "mail/mail-mt.h" +#include "libemail-utils/mail-mt.h" #include "mail/e-mail-backend.h" #include "e-util/e-import.h" #include "shell/e-shell.h" diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c index c3d5f2f1b7..f6e5c63613 100644 --- a/mail/importers/evolution-mbox-importer.c +++ b/mail/importers/evolution-mbox-importer.c @@ -48,7 +48,7 @@ #include "mail/em-folder-selection-button.h" #include "mail/em-folder-tree-model.h" #include "mail/em-folder-tree.h" -#include "mail/mail-mt.h" +#include "libemail-utils/mail-mt.h" #include "mail-importer.h" diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c index 558359c636..716d99c991 100644 --- a/mail/importers/mail-importer.c +++ b/mail/importers/mail-importer.c @@ -39,9 +39,9 @@ #include "e-util/e-util-private.h" #include "shell/e-shell-backend.h" -#include "mail-mt.h" -#include "mail-tools.h" -#include "e-mail-session.h" +#include "libemail-utils/mail-mt.h" +#include "libemail-engine/mail-tools.h" +#include "libemail-engine/e-mail-session.h" #include "mail-importer.h" @@ -277,9 +277,9 @@ mail_importer_import_mbox_sync (EMailSession *session, m->path = g_strdup (path); m->uri = g_strdup (folderuri); if (cancellable) - e_activity_set_cancellable (m->base.activity, cancellable); + m->base.cancellable = cancellable; - cancellable = e_activity_get_cancellable (m->base.activity); + cancellable = m->base.cancellable; import_mbox_exec (m, cancellable, &m->base.error); import_mbox_done (m); diff --git a/mail/importers/mail-importer.h b/mail/importers/mail-importer.h index d66ed464ec..bd0335c299 100644 --- a/mail/importers/mail-importer.h +++ b/mail/importers/mail-importer.h @@ -26,7 +26,7 @@ #include <e-util/e-import.h> #include <camel/camel.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> EImportImporter *mbox_importer_peek (void); diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c index 1ba44583ab..3ecfbbc5df 100644 --- a/mail/importers/pine-importer.c +++ b/mail/importers/pine-importer.c @@ -43,7 +43,7 @@ #include "mail-importer.h" -#include "mail/mail-mt.h" +#include "libemail-utils/mail-mt.h" #include "mail/e-mail-backend.h" #include "e-util/e-import.h" #include "shell/e-shell.h" diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c index 6d08c78a40..08e3a3d937 100644 --- a/mail/mail-autofilter.c +++ b/mail/mail-autofilter.c @@ -29,8 +29,9 @@ #include <glib/gi18n.h> -#include "e-mail-folder-utils.h" -#include "e-mail-session.h" +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-session.h> + #include "mail-vfolder.h" #include "mail-autofilter.h" #include "em-utils.h" diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h index 47f68c3be5..34593b0f95 100644 --- a/mail/mail-autofilter.h +++ b/mail/mail-autofilter.h @@ -27,9 +27,9 @@ #include <camel/camel.h> #include <filter/e-filter-rule.h> -#include <mail/e-mail-session.h> #include <mail/em-filter-context.h> #include <mail/em-vfolder-context.h> +#include <libemail-engine/e-mail-session.h> enum { AUTO_SUBJECT = 1, diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index 4e206ea221..05a48c47ce 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -29,22 +29,26 @@ #include <glib/gi18n.h> -#include "libedataserver/e-account-list.h" +#include <libedataserver/e-account-list.h> -#include "shell/e-shell.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-util.h" +#include <shell/e-shell.h> +#include <e-util/e-util.h> -#include "e-mail-folder-utils.h" -#include "e-mail-session.h" +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/mail-mt.h> + +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/mail-folder-cache.h> +#include <libemail-engine/mail-ops.h> +#include <libemail-engine/mail-tools.h> + +#include "e-mail-account-store.h" +#include "e-mail-ui-session.h" #include "em-event.h" #include "em-filter-rule.h" #include "em-utils.h" -#include "mail-folder-cache.h" -#include "mail-mt.h" -#include "mail-ops.h" #include "mail-send-recv.h" -#include "mail-tools.h" #define d(x) @@ -501,7 +505,7 @@ build_dialog (GtkWindow *parent, EMEventTargetSendReceive *target; GQueue queue = G_QUEUE_INIT; - account_store = e_mail_session_get_account_store (session); + account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session)); /* Convert the outgoing account to a CamelTransport. */ if (outgoing_account != NULL) { diff --git a/mail/mail-send-recv.h b/mail/mail-send-recv.h index cd11a4a9bb..fb49493060 100644 --- a/mail/mail-send-recv.h +++ b/mail/mail-send-recv.h @@ -24,7 +24,7 @@ #define MAIL_SEND_RECV_H #include <gtk/gtk.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> G_BEGIN_DECLS diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index f5039d98ff..4b10e829de 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -31,20 +31,23 @@ #include "e-util/e-alert-dialog.h" #include "e-util/e-util-private.h" +#include "libemail-utils/mail-mt.h" +#include "libemail-engine/mail-folder-cache.h" +#include "libemail-engine/e-mail-folder-utils.h" +#include "libemail-engine/e-mail-session.h" +#include "libemail-engine/e-mail-utils.h" +#include "libemail-engine/mail-ops.h" +#include "libemail-engine/mail-tools.h" + #include "e-mail-backend.h" -#include "e-mail-session.h" -#include "e-mail-folder-utils.h" #include "em-folder-tree-model.h" #include "em-utils.h" #include "em-vfolder-context.h" #include "em-vfolder-editor.h" #include "em-vfolder-rule.h" #include "mail-autofilter.h" -#include "mail-folder-cache.h" -#include "mail-mt.h" -#include "mail-ops.h" -#include "mail-tools.h" #include "mail-vfolder.h" +#include "e-mail-ui-session.h" #define d(x) /* (printf("%s:%s: ", G_STRLOC, G_STRFUNC), (x))*/ @@ -1020,7 +1023,7 @@ vfolder_load_storage (EMailBackend *backend) config_dir = mail_session_get_config_dir (); session = e_mail_backend_get_session (backend); - vfolder_store = e_mail_session_get_vfolder_store (session); + vfolder_store = e_mail_ui_session_get_vfolder_store (E_MAIL_UI_SESSION(session)); g_signal_connect ( vfolder_store, "folder-deleted", diff --git a/mail/message-list.c b/mail/message-list.c index 98fd90babb..405e9d08cd 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -58,13 +58,16 @@ #include "table/e-tree-memory-callbacks.h" #include "table/e-tree-memory.h" -#include "e-mail-label-list-store.h" -#include "em-utils.h" -#include "mail-config.h" -#include "mail-mt.h" -#include "mail-ops.h" -#include "mail-tools.h" -#include "message-list.h" +#include "libemail-utils/mail-mt.h" +#include "libemail-engine/e-mail-utils.h" +#include "libemail-engine/mail-config.h" +#include "libemail-engine/mail-ops.h" +#include "libemail-engine/mail-tools.h" + +#include "mail/e-mail-label-list-store.h" +#include "mail/e-mail-ui-session.h" +#include "mail/em-utils.h" +#include "mail/message-list.h" #if HAVE_CLUTTER #include <clutter/clutter.h> @@ -1709,7 +1712,8 @@ ml_tree_value_at_ex (ETreeModel *etm, /* Get all applicable labels. */ struct LabelsData ld; - ld.store = e_mail_session_get_label_store (session); + ld.store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); ld.labels_tag2iter = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) gtk_tree_iter_free); for_node_and_subtree_if_collapsed (message_list, path, msg_info, add_all_labels_foreach, &ld); @@ -1791,7 +1795,8 @@ ml_tree_value_at_ex (ETreeModel *etm, struct LabelsData ld; GString *result = g_string_new (""); - ld.store = e_mail_session_get_label_store (session); + ld.store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); ld.labels_tag2iter = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) gtk_tree_iter_free); for_node_and_subtree_if_collapsed (message_list, path, msg_info, add_all_labels_foreach, &ld); @@ -4764,7 +4769,7 @@ regen_list_done (struct _regen_list_msg *m) GCancellable *cancellable; gboolean searching; - cancellable = e_activity_get_cancellable (m->base.activity); + cancellable = m->base.cancellable; if (m->ml->priv->destroyed) return; @@ -4956,7 +4961,7 @@ mail_regen_cancel (MessageList *ml) MailMsg *mm = link->data; GCancellable *cancellable; - cancellable = e_activity_get_cancellable (mm->activity); + cancellable = mm->cancellable; g_cancellable_cancel (cancellable); } diff --git a/mail/message-list.h b/mail/message-list.h index bd2e97b6f8..44a312e667 100644 --- a/mail/message-list.h +++ b/mail/message-list.h @@ -27,7 +27,7 @@ #include <camel/camel.h> #include <table/e-tree.h> -#include <mail/e-mail-session.h> +#include <libemail-engine/e-mail-session.h> /* Standard GObject macros */ #define MESSAGE_LIST_TYPE \ diff --git a/modules/bogofilter/Makefile.am b/modules/bogofilter/Makefile.am index 5fbf45e5b4..2d8f5c9fd2 100644 --- a/modules/bogofilter/Makefile.am +++ b/modules/bogofilter/Makefile.am @@ -14,6 +14,8 @@ libevolution_module_bogofilter_la_SOURCES = \ libevolution_module_bogofilter_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/mail/libevolution-mail.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) diff --git a/modules/bogofilter/evolution-bogofilter.c b/modules/bogofilter/evolution-bogofilter.c index 74c1d362ca..0467c0f654 100644 --- a/modules/bogofilter/evolution-bogofilter.c +++ b/modules/bogofilter/evolution-bogofilter.c @@ -23,7 +23,7 @@ #include <camel/camel.h> -#include <mail/e-mail-junk-filter.h> +#include <libemail-engine/e-mail-junk-filter.h> /* Standard GObject macros */ #define E_TYPE_BOGOFILTER \ diff --git a/modules/calendar/Makefile.am b/modules/calendar/Makefile.am index 4f09f92692..57b697b0df 100644 --- a/modules/calendar/Makefile.am +++ b/modules/calendar/Makefile.am @@ -89,6 +89,7 @@ libevolution_module_calendar_la_LIBADD = \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.la \ $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/widgets/menus/libmenus.la \ diff --git a/modules/calendar/e-cal-shell-view-private.h b/modules/calendar/e-cal-shell-view-private.h index 27aaca6e9e..ad4984a4ef 100644 --- a/modules/calendar/e-cal-shell-view-private.h +++ b/modules/calendar/e-cal-shell-view-private.h @@ -26,6 +26,7 @@ #include <string.h> #include <glib/gi18n.h> + #include <libecal/e-cal-time-util.h> #include <libecal/e-cal-system-timezone.h> #include <libedataserver/e-categories.h> @@ -33,31 +34,34 @@ #include <libedataserver/e-sexp.h> #include <libedataserverui/e-client-utils.h> -#include "e-util/e-account-utils.h" -#include "e-util/e-selection.h" -#include "e-util/e-dialog-utils.h" -#include "e-util/e-file-utils.h" -#include "e-util/e-util.h" -#include "shell/e-shell-utils.h" -#include "misc/e-popup-action.h" -#include "misc/e-selectable.h" - -#include "calendar/gui/calendar-config.h" -#include "calendar/gui/comp-util.h" -#include "calendar/gui/e-cal-list-view.h" -#include "calendar/gui/e-cal-model-tasks.h" -#include "calendar/gui/e-calendar-view.h" -#include "calendar/gui/e-day-view.h" -#include "calendar/gui/e-week-view.h" -#include "calendar/gui/gnome-cal.h" -#include "calendar/gui/print.h" -#include "calendar/gui/dialogs/calendar-setup.h" -#include "calendar/gui/dialogs/copy-source-dialog.h" -#include "calendar/gui/dialogs/event-editor.h" -#include "calendar/gui/dialogs/goto-dialog.h" -#include "calendar/gui/dialogs/memo-editor.h" -#include "calendar/gui/dialogs/select-source-dialog.h" -#include "calendar/gui/dialogs/task-editor.h" +#include <e-util/e-selection.h> +#include <e-util/e-dialog-utils.h> +#include <e-util/e-file-utils.h> +#include <e-util/e-util.h> + +#include <libemail-utils/e-account-utils.h> + +#include <shell/e-shell-utils.h> + +#include <misc/e-popup-action.h> +#include <misc/e-selectable.h> + +#include <calendar/gui/calendar-config.h> +#include <calendar/gui/comp-util.h> +#include <calendar/gui/e-cal-list-view.h> +#include <calendar/gui/e-cal-model-tasks.h> +#include <calendar/gui/e-calendar-view.h> +#include <calendar/gui/e-day-view.h> +#include <calendar/gui/e-week-view.h> +#include <calendar/gui/gnome-cal.h> +#include <calendar/gui/print.h> +#include <calendar/gui/dialogs/calendar-setup.h> +#include <calendar/gui/dialogs/copy-source-dialog.h> +#include <calendar/gui/dialogs/event-editor.h> +#include <calendar/gui/dialogs/goto-dialog.h> +#include <calendar/gui/dialogs/memo-editor.h> +#include <calendar/gui/dialogs/select-source-dialog.h> +#include <calendar/gui/dialogs/task-editor.h> #include "e-cal-shell-backend.h" #include "e-cal-shell-content.h" diff --git a/modules/calendar/e-memo-shell-migrate.c b/modules/calendar/e-memo-shell-migrate.c index 6402cf1e0a..171428f408 100644 --- a/modules/calendar/e-memo-shell-migrate.c +++ b/modules/calendar/e-memo-shell-migrate.c @@ -28,13 +28,14 @@ #include <string.h> #include <glib/gi18n.h> #include <camel/camel.h> + #include <libedataserver/e-source.h> #include <libedataserver/e-source-group.h> #include <libedataserver/e-source-list.h> -#include "e-util/e-account-utils.h" -#include "calendar/gui/calendar-config-keys.h" -#include "shell/e-shell.h" +#include <shell/e-shell.h> +#include <calendar/gui/calendar-config-keys.h> +#include <libemail-utils/e-account-utils.h> #include "e-memo-shell-backend.h" diff --git a/modules/mail/Makefile.am b/modules/mail/Makefile.am index 90cf1aa54f..7fbb354b26 100644 --- a/modules/mail/Makefile.am +++ b/modules/mail/Makefile.am @@ -3,7 +3,6 @@ module_LTLIBRARIES = libevolution-module-mail.la libevolution_module_mail_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ -I$(top_srcdir) \ - -I$(top_srcdir)/mail \ -I$(top_srcdir)/widgets \ -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ -DEVOLUTION_UIDIR=\""$(uidir)"\" \ @@ -51,6 +50,8 @@ libevolution_module_mail_la_SOURCES = \ em-network-prefs.h libevolution_module_mail_la_LIBADD = \ + $(top_builddir)/libemail-utils/libemail-utils.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/em-format/libemformat.la \ $(top_builddir)/filter/libfilter.la \ diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index d15ca1ebe8..4e28d8c629 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -27,37 +27,42 @@ #include <glib/gi18n.h> -#include "e-util/e-import.h" -#include "e-util/e-util.h" -#include "shell/e-shell.h" -#include "shell/e-shell-window.h" -#include "composer/e-msg-composer.h" -#include "widgets/misc/e-preferences-window.h" -#include "widgets/misc/e-web-view.h" +#include <e-util/e-import.h> +#include <e-util/e-util.h> + +#include <shell/e-shell.h> +#include <shell/e-shell-window.h> + +#include <composer/e-msg-composer.h> + +#include <widgets/misc/e-preferences-window.h> +#include <widgets/misc/e-web-view.h> + +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/mail-config.h> +#include <libemail-engine/mail-ops.h> + +#include <mail/e-mail-browser.h> +#include <mail/e-mail-reader.h> +#include <mail/em-account-editor.h> +#include <mail/em-composer-utils.h> +#include <mail/em-folder-utils.h> +#include <mail/em-format-hook.h> +#include <mail/em-format-html-display.h> +#include <mail/em-utils.h> +#include <mail/mail-send-recv.h> +#include <mail/mail-vfolder.h> +#include <mail/importers/mail-importer.h> +#include <mail/e-mail-ui-session.h> #include "e-mail-shell-settings.h" #include "e-mail-shell-sidebar.h" #include "e-mail-shell-view.h" - -#include "e-mail-browser.h" -#include "e-mail-folder-utils.h" -#include "e-mail-reader.h" -#include "e-mail-session.h" -#include "em-account-editor.h" #include "em-account-prefs.h" #include "em-composer-prefs.h" -#include "em-composer-utils.h" -#include "em-folder-utils.h" -#include "em-format-hook.h" -#include "em-format-html-display.h" #include "em-mailer-prefs.h" #include "em-network-prefs.h" -#include "em-utils.h" -#include "mail-config.h" -#include "mail-ops.h" -#include "mail-send-recv.h" -#include "mail-vfolder.h" -#include "importers/mail-importer.h" #define E_MAIL_SHELL_BACKEND_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -471,7 +476,7 @@ mail_shell_backend_start (EShellBackend *shell_backend) backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - account_store = e_mail_session_get_account_store (session); + account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session)); enable_search_folders = e_shell_settings_get_boolean ( shell_settings, "mail-enable-search-folders"); @@ -646,7 +651,8 @@ e_mail_labels_get_filter_options (void) backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - label_store = e_mail_session_get_label_store (session); + label_store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); model = GTK_TREE_MODEL (label_store); valid = gtk_tree_model_get_iter_first (model, &iter); diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c index 56a0c52de6..5bb60e3784 100644 --- a/modules/mail/e-mail-shell-content.c +++ b/modules/mail/e-mail-shell-content.c @@ -28,21 +28,23 @@ #include <glib/gi18n.h> #include <libedataserver/e-data-server-util.h> -#include "e-util/e-util-private.h" -#include "widgets/menus/gal-view-etable.h" -#include "widgets/menus/gal-view-instance.h" -#include "widgets/misc/e-paned.h" -#include "widgets/misc/e-preview-pane.h" -#include "widgets/misc/e-search-bar.h" - -#include "em-utils.h" -#include "mail-ops.h" -#include "message-list.h" - -#include "e-mail-paned-view.h" -#include "e-mail-notebook-view.h" -#include "e-mail-reader.h" -#include "e-mail-reader-utils.h" +#include <e-util/e-util-private.h> + +#include <widgets/menus/gal-view-etable.h> +#include <widgets/menus/gal-view-instance.h> +#include <widgets/misc/e-paned.h> +#include <widgets/misc/e-preview-pane.h> +#include <widgets/misc/e-search-bar.h> + +#include <libemail-engine/mail-ops.h> + +#include <mail/e-mail-paned-view.h> +#include <mail/e-mail-notebook-view.h> +#include <mail/e-mail-reader.h> +#include <mail/e-mail-reader-utils.h> +#include <mail/em-utils.h> +#include <mail/message-list.h> + #include "e-mail-shell-backend.h" #include "e-mail-shell-view-actions.h" diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index 26bcfc4bb8..407f17ef78 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -99,7 +99,7 @@ action_mail_account_disable_cb (GtkAction *action, backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - account_store = e_mail_session_get_account_store (session); + account_store = e_mail_ui_session_get_account_store (E_MAIL_UI_SESSION (session)); folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); store = em_folder_tree_get_selected_store (folder_tree); @@ -709,7 +709,8 @@ action_mail_label_new_cb (GtkAction *action, backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - label_store = e_mail_session_get_label_store (session); + label_store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); label_dialog = E_MAIL_LABEL_DIALOG (dialog); label_name = e_mail_label_dialog_get_label_name (label_dialog); @@ -770,7 +771,8 @@ action_mail_label_none_cb (GtkAction *action, backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - label_store = e_mail_session_get_label_store (session); + label_store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); @@ -1919,7 +1921,8 @@ e_mail_shell_view_update_popup_labels (EMailShellView *mail_shell_view) backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - label_store = e_mail_session_get_label_store (session); + label_store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); action_group = ACTION_GROUP (MAIL_LABEL); merge_id = mail_shell_view->priv->label_merge_id; @@ -2021,7 +2024,8 @@ e_mail_shell_view_update_search_filter (EMailShellView *mail_shell_view) backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - label_store = e_mail_session_get_label_store (session); + label_store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); action_group = ACTION_GROUP (MAIL_FILTER); e_action_group_remove_all_actions (action_group); diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index b7e7f9575b..f43734f175 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -665,7 +665,8 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view) backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - label_store = e_mail_session_get_label_store (session); + label_store = e_mail_ui_session_get_label_store ( + E_MAIL_UI_SESSION (session)); e_shell_window_add_action_group (shell_window, "mail"); e_shell_window_add_action_group (shell_window, "mail-filter"); diff --git a/modules/mail/e-mail-shell-view-private.h b/modules/mail/e-mail-shell-view-private.h index 24b5e531bf..c60d5c699e 100644 --- a/modules/mail/e-mail-shell-view-private.h +++ b/modules/mail/e-mail-shell-view-private.h @@ -28,38 +28,43 @@ #include <gtkhtml/gtkhtml.h> #include <camel/camel-search-private.h> /* for camel_search_word */ -#include "e-util/e-util.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-ui-manager.h" -#include "filter/e-filter-part.h" -#include "widgets/misc/e-web-view.h" -#include "widgets/misc/e-popup-action.h" -#include "widgets/menus/gal-view-instance.h" - -#include "e-mail-folder-utils.h" -#include "e-mail-label-action.h" -#include "e-mail-label-dialog.h" -#include "e-mail-label-list-store.h" -#include "e-mail-reader.h" -#include "e-mail-reader-utils.h" -#include "e-mail-session.h" -#include "e-mail-session-utils.h" -#include "e-mail-sidebar.h" -#include "e-mail-store-utils.h" -#include "em-composer-utils.h" -#include "em-folder-properties.h" -#include "em-folder-selector.h" -#include "em-folder-utils.h" -#include "em-search-context.h" -#include "em-subscription-editor.h" -#include "em-utils.h" -#include "mail-autofilter.h" -#include "mail-folder-cache.h" -#include "mail-ops.h" -#include "mail-send-recv.h" -#include "mail-tools.h" -#include "mail-vfolder.h" -#include "message-list.h" +#include <e-util/e-util.h> +#include <e-util/e-ui-manager.h> + +#include <filter/e-filter-part.h> + +#include <libemail-utils/e-account-utils.h> + +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/e-mail-session-utils.h> +#include <libemail-engine/e-mail-store-utils.h> +#include <libemail-engine/mail-folder-cache.h> +#include <libemail-engine/mail-ops.h> +#include <libemail-engine/mail-tools.h> + +#include <misc/e-web-view.h> +#include <misc/e-popup-action.h> +#include <menus/gal-view-instance.h> + +#include <mail/e-mail-label-action.h> +#include <mail/e-mail-label-dialog.h> +#include <mail/e-mail-label-list-store.h> +#include <mail/e-mail-reader.h> +#include <mail/e-mail-reader-utils.h> +#include <mail/e-mail-sidebar.h> +#include <mail/e-mail-ui-session.h> +#include <mail/em-composer-utils.h> +#include <mail/em-folder-properties.h> +#include <mail/em-folder-selector.h> +#include <mail/em-folder-utils.h> +#include <mail/em-search-context.h> +#include <mail/em-subscription-editor.h> +#include <mail/em-utils.h> +#include <mail/mail-autofilter.h> +#include <mail/mail-send-recv.h> +#include <mail/mail-vfolder.h> +#include <mail/message-list.h> #include "e-mail-shell-backend.h" #include "e-mail-shell-content.h" diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c index 07fec7e45f..afd7501d92 100644 --- a/modules/mail/e-mail-shell-view.c +++ b/modules/mail/e-mail-shell-view.c @@ -269,7 +269,7 @@ mail_shell_view_execute_search (EShellView *shell_view) folder = e_mail_reader_get_folder (reader); message_list = e_mail_reader_get_message_list (reader); - label_store = e_mail_session_get_label_store (session); + label_store = e_mail_ui_session_get_label_store (E_MAIL_UI_SESSION (session)); action = ACTION (MAIL_SEARCH_SUBJECT_OR_ADDRESSES_CONTAIN); value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); diff --git a/modules/mail/em-account-prefs.c b/modules/mail/em-account-prefs.c index 24651d1131..c6b132ebbb 100644 --- a/modules/mail/em-account-prefs.c +++ b/modules/mail/em-account-prefs.c @@ -33,16 +33,20 @@ #include <glib/gi18n.h> -#include "e-util/e-alert-dialog.h" -#include "e-util/e-account-utils.h" +#include <e-util/e-alert-dialog.h> -#include "e-mail-backend.h" -#include "em-config.h" -#include "em-account-editor.h" -#include "em-utils.h" -#include "mail-vfolder.h" -#include "shell/e-shell.h" -#include "capplet/settings/mail-capplet-shell.h" +#include <shell/e-shell.h> + +#include <libemail-utils/e-account-utils.h> + +#include <capplet/settings/mail-capplet-shell.h> + +#include <mail/e-mail-backend.h> +#include <mail/e-mail-ui-session.h> +#include <mail/em-config.h> +#include <mail/em-account-editor.h> +#include <mail/em-utils.h> +#include <mail/mail-vfolder.h> #define EM_ACCOUNT_PREFS_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -321,7 +325,8 @@ em_account_prefs_new (EPreferencesWindow *window) backend = E_MAIL_BACKEND (shell_backend); session = e_mail_backend_get_session (backend); - account_store = e_mail_session_get_account_store (session); + account_store = e_mail_ui_session_get_account_store ( + E_MAIL_UI_SESSION (session)); return g_object_new ( EM_TYPE_ACCOUNT_PREFS, diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c index 0dcd1116bb..e678152097 100644 --- a/modules/mail/em-composer-prefs.c +++ b/modules/mail/em-composer-prefs.c @@ -24,18 +24,14 @@ #include <config.h> #endif +#include "em-composer-prefs.h" + #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> -#include "e-util/e-signature-utils.h" - -#include "em-composer-prefs.h" -#include "composer/e-msg-composer.h" -#include "shell/e-shell-utils.h" - #include <glib/gi18n.h> #include <glib/gstdio.h> @@ -44,14 +40,21 @@ #include <e-util/e-util.h> #include <e-util/e-util-private.h> + +#include <libemail-utils/e-signature-utils.h> + +#include <composer/e-msg-composer.h> + +#include <shell/e-shell-utils.h> + #include <misc/e-charset-combo-box.h> #include <misc/e-signature-editor.h> #include <misc/e-signature-manager.h> #include <misc/e-signature-preview.h> -#include "em-config.h" -#include "em-folder-selection-button.h" -#include "e-mail-junk-options.h" +#include <mail/em-config.h> +#include <mail/em-folder-selection-button.h> +#include <mail/e-mail-junk-options.h> G_DEFINE_TYPE ( EMComposerPrefs, diff --git a/modules/mail/em-network-prefs.c b/modules/mail/em-network-prefs.c index 793925055a..93a12d202a 100644 --- a/modules/mail/em-network-prefs.c +++ b/modules/mail/em-network-prefs.c @@ -24,25 +24,24 @@ #include <config.h> #endif +#include "em-network-prefs.h" + #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> -#include "em-network-prefs.h" - +#include <glib/gstdio.h> #include <gdk/gdkkeysyms.h> #include <gconf/gconf-client.h> -#include <glib/gstdio.h> - -#include "e-util/e-util.h" -#include "e-util/e-util-private.h" -#include "mail/e-mail-junk-options.h" +#include <e-util/e-util.h> +#include <e-util/e-util-private.h> -#include "em-config.h" -#include "em-folder-selection-button.h" +#include <mail/em-config.h> +#include <mail/em-folder-selection-button.h> +#include <mail/e-mail-junk-options.h> #define d(x) diff --git a/modules/mdn/evolution-mdn.c b/modules/mdn/evolution-mdn.c index fa3fd8171c..d0a1e6d6ee 100644 --- a/modules/mdn/evolution-mdn.c +++ b/modules/mdn/evolution-mdn.c @@ -23,13 +23,15 @@ #include <libebackend/e-extension.h> #include <e-util/e-alert-dialog.h> -#include <e-util/e-account-utils.h> + +#include <libemail-utils/e-account-utils.h> + +#include <libemail-engine/e-mail-folder-utils.h> #include <mail/em-utils.h> #include <mail/e-mail-reader.h> #include <mail/mail-send-recv.h> #include <mail/em-composer-utils.h> -#include <mail/e-mail-folder-utils.h> #define MDN_USER_FLAG "receipt-handled" diff --git a/modules/online-accounts/Makefile.am b/modules/online-accounts/Makefile.am index ccb7ada29a..f449247ec9 100644 --- a/modules/online-accounts/Makefile.am +++ b/modules/online-accounts/Makefile.am @@ -18,6 +18,7 @@ libevolution_module_online_accounts_la_SOURCES = \ libevolution_module_online_accounts_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/shell/libeshell.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(GOA_LIBS) diff --git a/modules/online-accounts/camel-sasl-xoauth.c b/modules/online-accounts/camel-sasl-xoauth.c index edf5c6eec3..7b1a59aa24 100644 --- a/modules/online-accounts/camel-sasl-xoauth.c +++ b/modules/online-accounts/camel-sasl-xoauth.c @@ -20,11 +20,11 @@ #include <config.h> #endif -#include <e-util/e-account-utils.h> +#include <glib/gi18n-lib.h> -#include "camel-sasl-xoauth.h" +#include <libemail-utils/e-account-utils.h> -#include <glib/gi18n-lib.h> +#include "camel-sasl-xoauth.h" #define GOA_API_IS_SUBJECT_TO_CHANGE #include <goa/goa.h> diff --git a/modules/online-accounts/e-online-accounts-google.c b/modules/online-accounts/e-online-accounts-google.c index e71b8d16cb..709eb3bb8e 100644 --- a/modules/online-accounts/e-online-accounts-google.c +++ b/modules/online-accounts/e-online-accounts-google.c @@ -29,7 +29,7 @@ #include <libecal/e-cal.h> #include <libebook/e-book.h> -#include <e-util/e-account-utils.h> +#include <libemail-utils/e-account-utils.h> /* This is the property name or URL parameter under which we * embed the GoaAccount ID into an EAccount or ESource object. */ diff --git a/modules/online-accounts/evolution-online-accounts.c b/modules/online-accounts/evolution-online-accounts.c index d127f4d096..6efeaba33e 100644 --- a/modules/online-accounts/evolution-online-accounts.c +++ b/modules/online-accounts/evolution-online-accounts.c @@ -30,7 +30,8 @@ #include <libedataserver/e-account-list.h> #include <shell/e-shell.h> -#include <e-util/e-account-utils.h> + +#include <libemail-utils/e-account-utils.h> #include "camel-sasl-xoauth.h" #include "e-online-accounts-google.h" diff --git a/modules/spamassassin/Makefile.am b/modules/spamassassin/Makefile.am index 8ea91303b4..fce8989566 100644 --- a/modules/spamassassin/Makefile.am +++ b/modules/spamassassin/Makefile.am @@ -14,6 +14,8 @@ libevolution_module_spamassassin_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/shell/libeshell.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) diff --git a/modules/spamassassin/evolution-spamassassin.c b/modules/spamassassin/evolution-spamassassin.c index 1b88d0f558..7f595caf32 100644 --- a/modules/spamassassin/evolution-spamassassin.c +++ b/modules/spamassassin/evolution-spamassassin.c @@ -25,7 +25,7 @@ #include <shell/e-shell.h> #include <e-util/e-mktemp.h> -#include <mail/e-mail-junk-filter.h> +#include <libemail-engine/e-mail-junk-filter.h> /* Standard GObject macros */ #define E_TYPE_SPAM_ASSASSIN \ diff --git a/modules/startup-wizard/Makefile.am b/modules/startup-wizard/Makefile.am index 2643387010..ebaec22531 100644 --- a/modules/startup-wizard/Makefile.am +++ b/modules/startup-wizard/Makefile.am @@ -19,6 +19,8 @@ libevolution_module_startup_wizard_la_LIBADD = \ $(top_builddir)/calendar/gui/libevolution-calendar.la \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/capplet/settings/libevolution-mail-settings.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) diff --git a/modules/startup-wizard/evolution-startup-wizard.c b/modules/startup-wizard/evolution-startup-wizard.c index de15b72609..2edeb1cc78 100644 --- a/modules/startup-wizard/evolution-startup-wizard.c +++ b/modules/startup-wizard/evolution-startup-wizard.c @@ -24,13 +24,17 @@ #include <libebackend/e-extension.h> #include <shell/e-shell.h> -#include <e-util/e-account-utils.h> + #include <e-util/e-alert-dialog.h> #include <e-util/e-import.h> +#include <libemail-utils/e-account-utils.h> + #include <mail/e-mail-backend.h> #include <mail/em-account-editor.h> + #include <capplet/settings/mail-capplet-shell.h> + #include <calendar/gui/calendar-config.h> /* Standard GObject macros */ diff --git a/plugins/caldav/Makefile.am b/plugins/caldav/Makefile.am index 6d89204eff..432cafd08e 100644 --- a/plugins/caldav/Makefile.am +++ b/plugins/caldav/Makefile.am @@ -19,6 +19,7 @@ liborg_gnome_evolution_caldav_la_SOURCES = \ liborg_gnome_evolution_caldav_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) diff --git a/plugins/caldav/caldav-browse-server.c b/plugins/caldav/caldav-browse-server.c index e1384ce062..c9d09cea20 100644 --- a/plugins/caldav/caldav-browse-server.c +++ b/plugins/caldav/caldav-browse-server.c @@ -38,7 +38,8 @@ #include <libedataserverui/e-passwords.h> #include <e-util/e-dialog-utils.h> -#include <e-util/e-account-utils.h> + +#include <libemail-utils/e-account-utils.h> #include "caldav-browse-server.h" diff --git a/plugins/dbx-import/Makefile.am b/plugins/dbx-import/Makefile.am index 67d5e0d5d3..eeaf69ff3f 100644 --- a/plugins/dbx-import/Makefile.am +++ b/plugins/dbx-import/Makefile.am @@ -27,6 +27,8 @@ liborg_gnome_dbx_import_la_LIBADD = \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/shell/libeshell.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(GTKHTML_LIBS) diff --git a/plugins/dbx-import/dbx-importer.c b/plugins/dbx-import/dbx-importer.c index 5415f4867c..f6b666516a 100644 --- a/plugins/dbx-import/dbx-importer.c +++ b/plugins/dbx-import/dbx-importer.c @@ -64,10 +64,11 @@ #include <libedataserver/e-data-server-util.h> #include <libedataserverui/e-source-selector-dialog.h> +#include <libemail-utils/mail-mt.h> +#include <libemail-engine/mail-tools.h> + #include <mail/e-mail-backend.h> #include <mail/em-folder-selection-button.h> -#include <mail/mail-mt.h> -#include <mail/mail-tools.h> #include <mail/em-utils.h> #define d(x) @@ -603,7 +604,7 @@ dbx_import_file (DbxImporter *m) /* Destination folder, was set in our widget */ m->parent_uri = g_strdup (((EImportTargetURI *) m->target)->uri_dest); - cancellable = e_activity_get_cancellable (m->base.activity); + cancellable = m->base.cancellable; /* XXX Dig up the EMailSession from the default EShell. * Since the EImport framework doesn't allow for user diff --git a/plugins/imap-features/imap-headers.c b/plugins/imap-features/imap-headers.c index f09f880b36..60f50d7dd6 100644 --- a/plugins/imap-features/imap-headers.c +++ b/plugins/imap-features/imap-headers.c @@ -25,15 +25,14 @@ #endif #include <string.h> - -#include <mail/em-config.h> - #include <gtk/gtk.h> +#include <glib/gi18n.h> #include <e-util/e-util.h> -#include <e-util/e-account-utils.h> -#include <glib/gi18n.h> +#include <libemail-utils/e-account-utils.h> + +#include <mail/em-config.h> typedef struct _epif_data EPImapFeaturesData; struct _epif_data { diff --git a/plugins/itip-formatter/Makefile.am b/plugins/itip-formatter/Makefile.am index 793908ecad..71fced63f0 100644 --- a/plugins/itip-formatter/Makefile.am +++ b/plugins/itip-formatter/Makefile.am @@ -22,6 +22,8 @@ liborg_gnome_itip_formatter_la_LIBADD = \ $(top_builddir)/shell/libeshell.la \ $(top_builddir)/em-format/libemformat.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(GTKHTML_LIBS) diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c index 687dc26a53..d450dcfb80 100644 --- a/plugins/itip-formatter/itip-formatter.c +++ b/plugins/itip-formatter/itip-formatter.c @@ -27,27 +27,36 @@ #include <string.h> #include <gtk/gtk.h> #include <glib/gi18n.h> + #include <libecal/e-cal-client.h> #include <libecal/e-cal-time-util.h> +#include <libedataserver/e-account-list.h> #include <libedataserverui/e-source-selector.h> #include <libedataserverui/e-client-utils.h> #include <gtkhtml/gtkhtml-embedded.h> + +#include <e-util/e-alert-dialog.h> +#include <e-util/e-mktemp.h> + +#include <shell/e-shell.h> +#include <shell/e-shell-utils.h> + +#include <libemail-utils/e-account-utils.h> +#include <libemail-utils/mail-mt.h> + +#include <libemail-engine/mail-folder-cache.h> +#include <libemail-engine/mail-tools.h> + #include <mail/em-format-hook.h> #include <mail/em-config.h> #include <mail/em-format-html.h> #include <mail/em-utils.h> -#include <mail/mail-folder-cache.h> -#include <mail/mail-tools.h> -#include <mail/mail-mt.h> -#include <libedataserver/e-account-list.h> -#include <e-util/e-account-utils.h> -#include <e-util/e-alert-dialog.h> -#include <e-util/e-mktemp.h> + +#include <misc/e-attachment.h> + #include <calendar/gui/itip-utils.h> -#include <shell/e-shell.h> -#include <shell/e-shell-utils.h> + #include "itip-view.h" -#include <misc/e-attachment.h> #define CLASSID "itip://" #define CONF_KEY_DELETE "delete-processed" diff --git a/plugins/mail-notification/Makefile.am b/plugins/mail-notification/Makefile.am index bcac34a81c..07cb42ed32 100644 --- a/plugins/mail-notification/Makefile.am +++ b/plugins/mail-notification/Makefile.am @@ -29,6 +29,7 @@ liborg_gnome_mail_notification_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/shell/libeshell.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(LIBNOTIFY_LIBS) \ diff --git a/plugins/mail-notification/mail-notification.c b/plugins/mail-notification/mail-notification.c index 481cf24c97..0c6714d856 100644 --- a/plugins/mail-notification/mail-notification.c +++ b/plugins/mail-notification/mail-notification.c @@ -36,7 +36,7 @@ #include <time.h> #include <e-util/e-config.h> -#include <mail/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-folder-utils.h> #include <mail/em-utils.h> #include <mail/em-event.h> #include <mail/em-folder-tree.h> diff --git a/plugins/mail-to-task/Makefile.am b/plugins/mail-to-task/Makefile.am index 845a82c7a3..48f0724b6f 100644 --- a/plugins/mail-to-task/Makefile.am +++ b/plugins/mail-to-task/Makefile.am @@ -23,6 +23,7 @@ liborg_gnome_mail_to_task_la_LIBADD = \ $(top_builddir)/calendar/gui/libevolution-calendar.la \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(GTKHTML_LIBS) diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c index a4713c5447..e338393a76 100644 --- a/plugins/mail-to-task/mail-to-task.c +++ b/plugins/mail-to-task/mail-to-task.c @@ -28,9 +28,9 @@ #include <config.h> #endif -#include <glib/gi18n-lib.h> -#include <string.h> #include <stdio.h> +#include <string.h> +#include <glib/gi18n-lib.h> #include <gtkhtml/gtkhtml.h> #include <libecal/e-cal-client.h> @@ -41,20 +41,25 @@ #include <libedataserverui/e-source-selector-dialog.h> #include <libedataserverui/e-client-utils.h> -#include <mail/e-mail-browser.h> -#include <mail/em-utils.h> -#include <mail/em-format-html.h> -#include <mail/message-list.h> -#include <e-util/e-account-utils.h> #include <e-util/e-dialog-utils.h> + +#include <libemail-utils/e-account-utils.h> + #include <misc/e-popup-action.h> +#include <misc/e-attachment-store.h> + #include <shell/e-shell-view.h> #include <shell/e-shell-window-actions.h> + +#include <mail/e-mail-browser.h> +#include <mail/em-utils.h> +#include <mail/em-format-html.h> +#include <mail/message-list.h> + #include <calendar/gui/dialogs/comp-editor.h> #include <calendar/gui/dialogs/event-editor.h> -#include <calendar/gui/dialogs/task-editor.h> #include <calendar/gui/dialogs/memo-editor.h> -#include <misc/e-attachment-store.h> +#include <calendar/gui/dialogs/task-editor.h> #define E_SHELL_WINDOW_ACTION_CONVERT_TO_EVENT(window) \ E_SHELL_WINDOW_ACTION ((window), "mail-convert-to-event") diff --git a/plugins/mailing-list-actions/Makefile.am b/plugins/mailing-list-actions/Makefile.am index 77f6fdce6e..a3c46efab2 100644 --- a/plugins/mailing-list-actions/Makefile.am +++ b/plugins/mailing-list-actions/Makefile.am @@ -21,6 +21,8 @@ liborg_gnome_mailing_list_actions_la_LIBADD = \ $(top_builddir)/composer/libcomposer.la \ $(top_builddir)/mail/libevolution-mail.la \ $(top_builddir)/shell/libeshell.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(GTKHTML_LIBS) diff --git a/plugins/mailing-list-actions/mailing-list-actions.c b/plugins/mailing-list-actions/mailing-list-actions.c index 8e849be972..a9bc811c1d 100644 --- a/plugins/mailing-list-actions/mailing-list-actions.c +++ b/plugins/mailing-list-actions/mailing-list-actions.c @@ -24,27 +24,32 @@ #include <config.h> #endif -#include <glib/gi18n-lib.h> #include <stdio.h> #include <string.h> #include <gtk/gtk.h> +#include <glib/gi18n-lib.h> + +#include <e-util/e-util.h> +#include <e-util/e-alert-dialog.h> + +#include <libemail-utils/e-account-utils.h> + +#include <shell/e-shell-view.h> +#include <shell/e-shell-window.h> +#include <shell/e-shell-window-actions.h> + +#include <composer/e-msg-composer.h> + +#include <libemail-utils/mail-mt.h> +#include <libemail-engine/mail-ops.h> -#include "composer/e-msg-composer.h" -#include "mail/e-mail-browser.h" -#include "mail/e-mail-reader.h" -#include "mail/em-composer-utils.h" -#include "mail/em-format-hook.h" -#include "mail/em-config.h" -#include "mail/em-utils.h" -#include "mail/mail-ops.h" -#include "mail/mail-mt.h" -#include "mail/message-list.h" -#include "e-util/e-util.h" -#include "e-util/e-account-utils.h" -#include "e-util/e-alert-dialog.h" -#include "shell/e-shell-view.h" -#include "shell/e-shell-window.h" -#include "shell/e-shell-window-actions.h" +#include <mail/e-mail-browser.h> +#include <mail/e-mail-reader.h> +#include <mail/em-composer-utils.h> +#include <mail/em-config.h> +#include <mail/em-format-hook.h> +#include <mail/em-utils.h> +#include <mail/message-list.h> /* EAlert Message IDs */ #define MESSAGE_PREFIX "org.gnome.mailing-list-actions:" diff --git a/plugins/mark-all-read/mark-all-read.c b/plugins/mark-all-read/mark-all-read.c index 476172d43e..beac49ae47 100644 --- a/plugins/mark-all-read/mark-all-read.c +++ b/plugins/mark-all-read/mark-all-read.c @@ -30,7 +30,8 @@ #include <glib/gi18n.h> #include <e-util/e-plugin-ui.h> -#include <mail/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-folder-utils.h> + #include <mail/em-folder-tree.h> #include <mail/em-utils.h> diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c index 4305827ed1..f1e61dd07c 100644 --- a/plugins/pst-import/pst-importer.c +++ b/plugins/pst-import/pst-importer.c @@ -53,10 +53,11 @@ #include <libedataserverui/e-source-combo-box.h> #include <libedataserverui/e-client-utils.h> +#include <libemail-utils/mail-mt.h> +#include <libemail-engine/mail-tools.h> + #include <mail/e-mail-backend.h> #include <mail/em-folder-selection-button.h> -#include <mail/mail-mt.h> -#include <mail/mail-tools.h> #include <mail/em-utils.h> #include <shell/e-shell.h> #include <shell/e-shell-window.h> diff --git a/plugins/templates/Makefile.am b/plugins/templates/Makefile.am index a64a10e1dd..948dfea677 100644 --- a/plugins/templates/Makefile.am +++ b/plugins/templates/Makefile.am @@ -23,6 +23,7 @@ liborg_gnome_templates_la_LIBADD = \ $(top_builddir)/composer/libcomposer.la \ $(top_builddir)/shell/libeshell.la \ $(top_builddir)/mail/libevolution-mail.la \ + $(top_builddir)/libemail-engine/libemail-engine.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(GTKHTML_LIBS) diff --git a/plugins/templates/templates.c b/plugins/templates/templates.c index 714a6f0e0b..2b62dc922d 100644 --- a/plugins/templates/templates.c +++ b/plugins/templates/templates.c @@ -30,19 +30,21 @@ #include <glib/gi18n.h> #include <string.h> +#include <e-util/e-alert-dialog.h> #include <e-util/e-config.h> +#include <e-util/e-plugin.h> +#include <e-util/e-util.h> + +#include <shell/e-shell-view.h> + +#include <libemail-engine/e-mail-folder-utils.h> +#include <libemail-engine/e-mail-session.h> +#include <libemail-engine/mail-ops.h> -#include <mail/e-mail-folder-utils.h> #include <mail/e-mail-reader.h> -#include <mail/e-mail-session.h> #include <mail/em-composer-utils.h> #include <mail/em-utils.h> -#include <mail/mail-ops.h> #include <mail/message-list.h> -#include <e-util/e-alert-dialog.h> -#include <e-util/e-plugin.h> -#include <e-util/e-util.h> -#include <shell/e-shell-view.h> #include <composer/e-msg-composer.h> diff --git a/po/POTFILES.in b/po/POTFILES.in index 4ffe4684c9..5814851518 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -166,7 +166,6 @@ e-util/e-file-utils.c e-util/e-plugin.c e-util/e-plugin-util.c e-util/e-print.c -e-util/e-signature.c e-util/e-system.error.xml e-util/e-util.c filter/e-filter-datespec.c @@ -179,12 +178,21 @@ filter/e-rule-context.c filter/e-rule-editor.c filter/filter.error.xml [type: gettext/glade]filter/filter.ui +libemail-engine/e-mail-folder-utils.c +libemail-engine/e-mail-session.c +libemail-engine/e-mail-session-utils.c +libemail-engine/e-mail-store-utils.c +libemail-engine/mail-config.c +libemail-engine/mail-folder-cache.c +libemail-engine/mail-ops.c +libemail-engine/mail-tools.c +libemail-utils/e-signature.c +libemail-utils/mail-mt.c mail/e-mail-account-manager.c mail/e-mail-account-tree-view.c mail/e-mail-attachment-bar.c mail/e-mail-browser.c mail/e-mail-display.c -mail/e-mail-folder-utils.c mail/e-mail-junk-options.c mail/e-mail-label-dialog.c mail/e-mail-label-list-store.c @@ -194,10 +202,8 @@ mail/e-mail-migrate.c mail/e-mail-notebook-view.c mail/e-mail-reader.c mail/e-mail-reader-utils.c -mail/e-mail-session.c -mail/e-mail-session-utils.c -mail/e-mail-store-utils.c mail/e-mail-tag-editor.c +mail/e-mail-ui-session.c mail/em-account-editor.c mail/em-composer-utils.c mail/em-filter-editor.c @@ -225,15 +231,10 @@ mail/importers/evolution-mbox-importer.c mail/importers/mail-importer.c mail/importers/pine-importer.c mail/mail-autofilter.c -mail/mail-config.c [type: gettext/glade]mail/mail-config.ui [type: gettext/glade]mail/mail-dialogs.ui mail/mail.error.xml -mail/mail-folder-cache.c -mail/mail-mt.c -mail/mail-ops.c mail/mail-send-recv.c -mail/mail-tools.c mail/mail-vfolder.c mail/message-list.c mail/message-list.etspec diff --git a/shell/Makefile.am b/shell/Makefile.am index ad9a0bb308..57b9b0c75d 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -90,6 +90,7 @@ libeshell_la_SOURCES = \ libeshell_la_LDFLAGS = $(NO_UNDEFINED) libeshell_la_LIBADD = \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/smclient/libeggsmclient.la \ @@ -142,6 +143,7 @@ evolution_LDADD = \ $(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \ $(top_builddir)/widgets/menus/libmenus.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/filter/libfilter.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ diff --git a/smime/lib/Makefile.am b/smime/lib/Makefile.am index df2fb96208..9ed6067c0e 100644 --- a/smime/lib/Makefile.am +++ b/smime/lib/Makefile.am @@ -29,6 +29,7 @@ libessmime_la_SOURCES = \ e-pkcs12.h libessmime_la_LIBADD = \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(top_builddir)/e-util/libeutil.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am index 24495ed2cb..d0bef3fa28 100644 --- a/widgets/misc/Makefile.am +++ b/widgets/misc/Makefile.am @@ -157,6 +157,7 @@ libemiscwidgets_la_LIBADD = \ $(top_builddir)/filter/libfilter.la \ $(top_builddir)/a11y/libevolution-a11y.la \ $(top_builddir)/libgnomecanvas/libgnomecanvas.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(MATH_LIB) \ diff --git a/widgets/misc/e-signature-combo-box.h b/widgets/misc/e-signature-combo-box.h index dd81eb55c3..5a571499df 100644 --- a/widgets/misc/e-signature-combo-box.h +++ b/widgets/misc/e-signature-combo-box.h @@ -23,8 +23,8 @@ #define E_SIGNATURE_COMBO_BOX_H #include <gtk/gtk.h> -#include <e-util/e-signature.h> -#include <e-util/e-signature-list.h> +#include <libemail-utils/e-signature.h> +#include <libemail-utils/e-signature-list.h> /* Standard GObject macros */ #define E_TYPE_SIGNATURE_COMBO_BOX \ diff --git a/widgets/misc/e-signature-editor.c b/widgets/misc/e-signature-editor.c index 16efaa6d34..d968debe8f 100644 --- a/widgets/misc/e-signature-editor.c +++ b/widgets/misc/e-signature-editor.c @@ -30,7 +30,7 @@ #include <e-util/e-alert-dialog.h> #include <e-util/e-alert-sink.h> -#include <e-util/e-signature-utils.h> +#include <libemail-utils/e-signature-utils.h> #include <misc/e-web-view.h> enum { diff --git a/widgets/misc/e-signature-editor.h b/widgets/misc/e-signature-editor.h index 6d9f4a9b61..0d07cb840e 100644 --- a/widgets/misc/e-signature-editor.h +++ b/widgets/misc/e-signature-editor.h @@ -23,8 +23,8 @@ #define E_SIGNATURE_EDITOR_H #include <gtkhtml-editor.h> -#include <e-util/e-signature.h> #include <misc/e-focus-tracker.h> +#include <libemail-utils/e-signature.h> /* Standard GObject macros */ #define E_TYPE_SIGNATURE_EDITOR \ diff --git a/widgets/misc/e-signature-manager.h b/widgets/misc/e-signature-manager.h index 88ee391564..a5516214a2 100644 --- a/widgets/misc/e-signature-manager.h +++ b/widgets/misc/e-signature-manager.h @@ -23,9 +23,9 @@ #define E_SIGNATURE_MANAGER_H #include <gtk/gtk.h> -#include <e-util/e-signature-list.h> #include <misc/e-signature-editor.h> #include <misc/e-signature-tree-view.h> +#include <libemail-utils/e-signature-list.h> /* Standard GObject macros */ #define E_TYPE_SIGNATURE_MANAGER \ diff --git a/widgets/misc/e-signature-preview.c b/widgets/misc/e-signature-preview.c index a2c2352efb..6de03c0881 100644 --- a/widgets/misc/e-signature-preview.c +++ b/widgets/misc/e-signature-preview.c @@ -29,7 +29,8 @@ #include <string.h> #include <unistd.h> #include <glib/gstdio.h> -#include "e-util/e-signature-utils.h" + +#include <libemail-utils/e-signature-utils.h> enum { PROP_0, diff --git a/widgets/misc/e-signature-preview.h b/widgets/misc/e-signature-preview.h index 1a884b8563..f13ecf8ec4 100644 --- a/widgets/misc/e-signature-preview.h +++ b/widgets/misc/e-signature-preview.h @@ -22,8 +22,8 @@ #ifndef E_SIGNATURE_PREVIEW_H #define E_SIGNATURE_PREVIEW_H -#include <e-util/e-signature.h> #include <misc/e-web-view.h> +#include <libemail-utils/e-signature.h> /* Standard GObject macros */ #define E_TYPE_SIGNATURE_PREVIEW \ diff --git a/widgets/misc/e-signature-tree-view.h b/widgets/misc/e-signature-tree-view.h index 50d1e11905..6842340d8a 100644 --- a/widgets/misc/e-signature-tree-view.h +++ b/widgets/misc/e-signature-tree-view.h @@ -23,8 +23,8 @@ #define E_SIGNATURE_TREE_VIEW_H #include <gtk/gtk.h> -#include <e-util/e-signature.h> -#include <e-util/e-signature-list.h> +#include <libemail-utils/e-signature.h> +#include <libemail-utils/e-signature-list.h> /* Standard GObject macros */ #define E_TYPE_SIGNATURE_TREE_VIEW \ diff --git a/widgets/table/Makefile.am b/widgets/table/Makefile.am index 36af5ec2bf..001a2fd1e7 100644 --- a/widgets/table/Makefile.am +++ b/widgets/table/Makefile.am @@ -172,6 +172,7 @@ libetable_la_LIBADD = \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ $(top_builddir)/widgets/text/libetext.la \ $(top_builddir)/libgnomecanvas/libgnomecanvas.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(MATH_LIB) diff --git a/widgets/text/Makefile.am b/widgets/text/Makefile.am index d7c62af74e..0928da099f 100644 --- a/widgets/text/Makefile.am +++ b/widgets/text/Makefile.am @@ -35,6 +35,7 @@ libetext_la_LIBADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ $(top_builddir)/libgnomecanvas/libgnomecanvas.la \ + $(top_builddir)/libemail-utils/libemail-utils.la \ $(EVOLUTION_DATA_SERVER_LIBS) \ $(GNOME_PLATFORM_LIBS) \ $(REGEX_LIBS) \ |