diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-10-17 21:40:36 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-10-19 00:32:37 +0800 |
commit | 35e55a8d6e3455efa92abd669680d191e3e4cbac (patch) | |
tree | 303d479aaaf12538d73f611f52db1157da64549b | |
parent | b674a37a381d0328a7273bafa62d80203c8cdf70 (diff) | |
download | gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.tar.gz gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.tar.zst gsoc2013-evolution-35e55a8d6e3455efa92abd669680d191e3e4cbac.zip |
Send errors to an EAlertSink instead of the task bar.
This marks the end of unintrusive error dialogs, which were too
unintrusive. We now show errors directly in the main window using
the EAlert / EAlertSink framework.
51 files changed, 570 insertions, 1754 deletions
diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 9d455a8395..1b3759eb2d 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -227,10 +227,6 @@ void e_calendar_view_modify_and_send (ECalComponent *comp, CalObjModType mod, GtkWindow *toplevel, gboolean new); -void e_calendar_utils_show_error_silent - (GtkWidget *widget); -void e_calendar_utils_show_info_silent - (GtkWidget *widget); gboolean e_calendar_view_get_tooltips (const ECalendarViewEventData *data); diff --git a/capplet/settings/mail-capplet-shell.c b/capplet/settings/mail-capplet-shell.c index 9153edb7ab..889325bb13 100644 --- a/capplet/settings/mail-capplet-shell.c +++ b/capplet/settings/mail-capplet-shell.c @@ -250,7 +250,7 @@ mail_capplet_shell_construct (MailCappletShell *shell, gint socket_id, gboolean tmp = gtk_vbox_new (FALSE, 0); gtk_box_pack_end ((GtkBox *)priv->box, (GtkWidget *)shell->view, TRUE, TRUE, 2); - mail_config_init (CAMEL_SESSION (shell->priv->session)); + mail_config_init (shell->priv->session); mail_msg_init (); custom_dir = g_build_filename (e_get_user_data_dir (), "mail", NULL); e_mail_store_init (shell->priv->session, custom_dir); diff --git a/doc/reference/shell/eshell-docs.sgml b/doc/reference/shell/eshell-docs.sgml index eff7d8d278..5451736723 100644 --- a/doc/reference/shell/eshell-docs.sgml +++ b/doc/reference/shell/eshell-docs.sgml @@ -35,7 +35,6 @@ <xi:include href="xml/e-dialog-utils.xml"/> <xi:include href="xml/e-html-utils.xml"/> <xi:include href="xml/e-icon-factory.xml"/> - <xi:include href="xml/e-logger.xml"/> <xi:include href="xml/e-poolv.xml"/> <xi:include href="xml/e-print.xml"/> <xi:include href="xml/e-selection.xml"/> diff --git a/doc/reference/shell/eshell-sections.txt b/doc/reference/shell/eshell-sections.txt index 2c0e82de89..577a98d481 100644 --- a/doc/reference/shell/eshell-sections.txt +++ b/doc/reference/shell/eshell-sections.txt @@ -523,7 +523,6 @@ EAlert e_alert_new e_alert_run_dialog e_alert_run_dialog_for_args -e_alert_dialog_count_buttons </SECTION> <SECTION> @@ -916,29 +915,6 @@ e_icon_factory_create_thumbnail </SECTION> <SECTION> -<FILE>e-logger</FILE> -<TITLE>Error Logging</TITLE> -ELogger -ELogFunction -ELogLevel -e_logger_new -e_logger_get_name -e_logger_log -e_logger_get_logs -<SUBSECTION Standard> -E_LOGGER -E_IS_LOGGER -E_TYPE_LOGGER -E_LOGGER_CLASS -E_IS_LOGGER_CLASS -E_LOGGER_GET_CLASS -ELoggerClass -e_logger_get_type -<SUBSECTION Private> -ELoggerPrivate -</SECTION> - -<SECTION> <FILE>e-module</FILE> <TITLE>EModule</TITLE> EModule diff --git a/doc/reference/shell/eshell.types b/doc/reference/shell/eshell.types index b5c41aecf6..51b7c7693e 100644 --- a/doc/reference/shell/eshell.types +++ b/doc/reference/shell/eshell.types @@ -1,7 +1,6 @@ e_bit_array_get_type e_extensible_get_type e_extension_get_type -e_logger_get_type e_module_get_type e_signature_get_type e_signature_list_get_type diff --git a/doc/reference/shell/tmpl/e-alert.sgml b/doc/reference/shell/tmpl/e-alert.sgml index 46df813c66..2c460a32ba 100644 --- a/doc/reference/shell/tmpl/e-alert.sgml +++ b/doc/reference/shell/tmpl/e-alert.sgml @@ -80,12 +80,3 @@ User Alert Handling @Returns: -<!-- ##### FUNCTION e_alert_dialog_count_buttons ##### --> -<para> - -</para> - -@dialog: -@Returns: - - diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml index 3c0d257832..1428d63fc2 100644 --- a/doc/reference/shell/tmpl/eshell-unused.sgml +++ b/doc/reference/shell/tmpl/eshell-unused.sgml @@ -26,6 +26,34 @@ GObject Property Bindings +<!-- ##### SECTION ./tmpl/e-logger.sgml:Image ##### --> + + + +<!-- ##### SECTION ./tmpl/e-logger.sgml:Long_Description ##### --> +<para> + +</para> + + +<!-- ##### SECTION ./tmpl/e-logger.sgml:See_Also ##### --> +<para> + +</para> + + +<!-- ##### SECTION ./tmpl/e-logger.sgml:Short_Description ##### --> + + + +<!-- ##### SECTION ./tmpl/e-logger.sgml:Stability_Level ##### --> + + + +<!-- ##### SECTION ./tmpl/e-logger.sgml:Title ##### --> +Error Logging + + <!-- ##### SECTION ./tmpl/e-shell-window.sgml.sgml.sgml.sgml:Image ##### --> @@ -126,6 +154,35 @@ e-shell-window.sgml @user_data: @Returns: +<!-- ##### USER_FUNCTION ELogFunction ##### --> +<para> + +</para> + +@line: +@data: + +<!-- ##### ENUM ELogLevel ##### --> +<para> + +</para> + +@E_LOG_ERROR: +@E_LOG_WARNING: +@E_LOG_DEBUG: + +<!-- ##### STRUCT ELogger ##### --> +<para> + +</para> + + +<!-- ##### ARG ELogger:name ##### --> +<para> + +</para> + + <!-- ##### STRUCT EMutualBinding ##### --> <para> @@ -212,6 +269,14 @@ e-shell-window.sgml @activity: @allow_cancel: +<!-- ##### FUNCTION e_alert_dialog_count_buttons ##### --> +<para> + +</para> + +@dialog: +@Returns: + <!-- ##### FUNCTION e_binding_new ##### --> <para> @@ -263,6 +328,41 @@ e-shell-window.sgml @void: @Returns: +<!-- ##### FUNCTION e_logger_get_logs ##### --> +<para> + +</para> + +@logger: +@func: +@user_data: + +<!-- ##### FUNCTION e_logger_get_name ##### --> +<para> + +</para> + +@logger: +@Returns: + +<!-- ##### FUNCTION e_logger_log ##### --> +<para> + +</para> + +@logger: +@level: +@primary: +@secondary: + +<!-- ##### FUNCTION e_logger_new ##### --> +<para> + +</para> + +@name: +@Returns: + <!-- ##### FUNCTION e_mutual_binding_new ##### --> <para> diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 619f88c27a..d96b2b0bc3 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -12,7 +12,6 @@ eutilinclude_HEADERS = \ e-account-utils.h \ e-activity.h \ e-alert.h \ - e-alert-activity.h \ e-alert-dialog.h \ e-alert-sink.h \ e-bit-array.h \ @@ -30,11 +29,9 @@ eutilinclude_HEADERS = \ e-icon-factory.h \ e-import.h \ e-io-activity.h \ - e-logger.h \ e-marshal.h \ e-mktemp.h \ e-module.h \ - e-non-intrusive-error-dialog.h \ e-poolv.h \ e-print.h \ e-plugin.h \ @@ -50,7 +47,6 @@ eutilinclude_HEADERS = \ e-text-event-processor-emacs-like.h \ e-text-event-processor-types.h \ e-text-event-processor.h \ - e-timeout-activity.h \ e-ui-manager.h \ e-util.h \ e-unicode.h \ @@ -91,7 +87,6 @@ libeutil_la_SOURCES = \ e-account-utils.c \ e-activity.c \ e-alert.c \ - e-alert-activity.c \ e-alert-dialog.c \ e-alert-sink.c \ e-bit-array.c \ @@ -109,11 +104,9 @@ libeutil_la_SOURCES = \ e-icon-factory.c \ e-import.c \ e-io-activity.c \ - e-logger.c \ e-marshal.c \ e-mktemp.c \ e-module.c \ - e-non-intrusive-error-dialog.c \ e-poolv.c \ e-plugin.c \ e-plugin-ui.c \ @@ -128,7 +121,6 @@ libeutil_la_SOURCES = \ e-sorter-array.c \ e-text-event-processor-emacs-like.c \ e-text-event-processor.c \ - e-timeout-activity.c \ e-ui-manager.c \ e-util.c \ e-unicode.c \ diff --git a/e-util/e-alert-activity.c b/e-util/e-alert-activity.c deleted file mode 100644 index 7d7e5a7999..0000000000 --- a/e-util/e-alert-activity.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * e-alert-activity.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 - * - */ - -#include "e-alert-activity.h" -#include "e-alert-dialog.h" - -#define E_ALERT_ACTIVITY_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_ALERT_ACTIVITY, EAlertActivityPrivate)) - -struct _EAlertActivityPrivate { - GtkWidget *message_dialog; -}; - -enum { - PROP_0, - PROP_MESSAGE_DIALOG -}; - -G_DEFINE_TYPE ( - EAlertActivity, - e_alert_activity, - E_TYPE_TIMEOUT_ACTIVITY) - -static void -alert_activity_set_message_dialog (EAlertActivity *alert_activity, - GtkWidget *message_dialog) -{ - g_return_if_fail (alert_activity->priv->message_dialog == NULL); - - alert_activity->priv->message_dialog = g_object_ref (message_dialog); -} - -static void -alert_activity_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_MESSAGE_DIALOG: - alert_activity_set_message_dialog ( - E_ALERT_ACTIVITY (object), - g_value_get_object (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -alert_activity_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_MESSAGE_DIALOG: - g_value_set_object ( - value, e_alert_activity_get_message_dialog ( - E_ALERT_ACTIVITY (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -alert_activity_dispose (GObject *object) -{ - EAlertActivityPrivate *priv; - - priv = E_ALERT_ACTIVITY_GET_PRIVATE (object); - - if (priv->message_dialog != NULL) { - g_object_unref (priv->message_dialog); - priv->message_dialog = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (e_alert_activity_parent_class)->dispose (object); -} - -static void -alert_activity_constructed (GObject *object) -{ - EActivity *activity; - EAlertActivity *alert_activity; - EAlert *alert; - GtkWidget *message_dialog; - const gchar *primary_text; - const gchar *secondary_text; - - activity = E_ACTIVITY (object); - alert_activity = E_ALERT_ACTIVITY (object); - - message_dialog = e_alert_activity_get_message_dialog (alert_activity); - alert = e_alert_dialog_get_alert (E_ALERT_DIALOG (message_dialog)); - - primary_text = e_alert_get_primary_text (alert); - e_activity_set_primary_text (activity, primary_text); - - secondary_text = e_alert_get_secondary_text (alert); - e_activity_set_secondary_text (activity, secondary_text); - - /* This is a constructor property, so can't do it in init(). - * XXX What we really want to do is override the property's - * default value, but GObject does not support that. */ - e_activity_set_clickable (E_ACTIVITY (alert_activity), TRUE); -} - -static void -alert_activity_clicked (EActivity *activity) -{ - EAlertActivity *alert_activity; - GtkWidget *message_dialog; - - e_activity_complete (activity); - - alert_activity = E_ALERT_ACTIVITY (activity); - message_dialog = e_alert_activity_get_message_dialog (alert_activity); - gtk_dialog_run (GTK_DIALOG (message_dialog)); - gtk_widget_hide (message_dialog); - - /* Chain up to parent's clicked() method. */ - E_ACTIVITY_CLASS (e_alert_activity_parent_class)->clicked (activity); -} - -static void -alert_activity_timeout (ETimeoutActivity *activity) -{ - e_activity_complete (E_ACTIVITY (activity)); - - /* Chain up to parent's timeout() method. */ - E_TIMEOUT_ACTIVITY_CLASS (e_alert_activity_parent_class)->timeout (activity); -} - -static void -e_alert_activity_class_init (EAlertActivityClass *class) -{ - GObjectClass *object_class; - EActivityClass *activity_class; - ETimeoutActivityClass *timeout_activity_class; - - g_type_class_add_private (class, sizeof (EAlertActivityPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = alert_activity_set_property; - object_class->get_property = alert_activity_get_property; - object_class->dispose = alert_activity_dispose; - object_class->constructed = alert_activity_constructed; - - activity_class = E_ACTIVITY_CLASS (class); - activity_class->clicked = alert_activity_clicked; - - timeout_activity_class = E_TIMEOUT_ACTIVITY_CLASS (class); - timeout_activity_class->timeout = alert_activity_timeout; - - g_object_class_install_property ( - object_class, - PROP_MESSAGE_DIALOG, - g_param_spec_object ( - "message-dialog", - NULL, - NULL, - GTK_TYPE_DIALOG, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); -} - -static void -e_alert_activity_init (EAlertActivity *alert_activity) -{ - alert_activity->priv = E_ALERT_ACTIVITY_GET_PRIVATE (alert_activity); - - e_timeout_activity_set_timeout (E_TIMEOUT_ACTIVITY (alert_activity), 60); -} - -EActivity * -e_alert_activity_new_info (GtkWidget *message_dialog) -{ - g_return_val_if_fail (GTK_IS_DIALOG (message_dialog), NULL); - - return g_object_new ( - E_TYPE_ALERT_ACTIVITY, - "icon-name", "dialog-information", - "message-dialog", message_dialog, NULL); -} - -EActivity * -e_alert_activity_new_error (GtkWidget *message_dialog) -{ - g_return_val_if_fail (GTK_IS_DIALOG (message_dialog), NULL); - - return g_object_new ( - E_TYPE_ALERT_ACTIVITY, - "icon-name", "dialog-error", - "message-dialog", message_dialog, NULL); -} - -EActivity * -e_alert_activity_new_warning (GtkWidget *message_dialog) -{ - g_return_val_if_fail (GTK_IS_DIALOG (message_dialog), NULL); - - return g_object_new ( - E_TYPE_ALERT_ACTIVITY, - "icon-name", "dialog-warning", - "message-dialog", message_dialog, NULL); -} - -GtkWidget * -e_alert_activity_get_message_dialog (EAlertActivity *alert_activity) -{ - g_return_val_if_fail (E_IS_ALERT_ACTIVITY (alert_activity), NULL); - - return alert_activity->priv->message_dialog; -} diff --git a/e-util/e-alert-activity.h b/e-util/e-alert-activity.h deleted file mode 100644 index b19d7600e3..0000000000 --- a/e-util/e-alert-activity.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * e-alert-activity.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/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef E_ALERT_ACTIVITY_H -#define E_ALERT_ACTIVITY_H - -#include <e-util/e-timeout-activity.h> - -/* Standard GObject macros */ -#define E_TYPE_ALERT_ACTIVITY \ - (e_alert_activity_get_type ()) -#define E_ALERT_ACTIVITY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_ALERT_ACTIVITY, EAlertActivity)) -#define E_ALERT_ACTIVITY_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_ALERT_ACTIVITY, EAlertActivityClass)) -#define E_IS_ALERT_ACTIVITY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_ALERT_ACTIVITY)) -#define E_IS_ALERT_ACTIVITY_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_ALERT_ACTIVITY)) -#define E_ALERT_ACTIVITY_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_ALERT_ACTIVITY, EAlertActivityClass)) - -G_BEGIN_DECLS - -typedef struct _EAlertActivity EAlertActivity; -typedef struct _EAlertActivityClass EAlertActivityClass; -typedef struct _EAlertActivityPrivate EAlertActivityPrivate; - -struct _EAlertActivity { - ETimeoutActivity parent; - EAlertActivityPrivate *priv; -}; - -struct _EAlertActivityClass { - ETimeoutActivityClass parent_class; -}; - -GType e_alert_activity_get_type (void); -EActivity * e_alert_activity_new_info (GtkWidget *message_dialog); -EActivity * e_alert_activity_new_error (GtkWidget *message_dialog); -EActivity * e_alert_activity_new_warning (GtkWidget *message_dialog); -GtkWidget * e_alert_activity_get_message_dialog - (EAlertActivity *alert_activity); - -G_END_DECLS - -#endif /* E_ALERT_ACTIVITY_H */ diff --git a/e-util/e-alert-dialog.c b/e-util/e-alert-dialog.c index 888c9121f9..2639196ca7 100644 --- a/e-util/e-alert-dialog.c +++ b/e-util/e-alert-dialog.c @@ -24,7 +24,6 @@ #include "e-alert-dialog.h" #include "e-util.h" -#include "e-alert-action.h" #define E_ALERT_DIALOG_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -325,36 +324,6 @@ e_alert_run_dialog_for_args (GtkWindow *parent, } /** - * e_alert_dialog_count_buttons: - * @dialog: a #EAlertDialog - * - * Counts the number of buttons in @dialog's action area. - * - * Returns: number of action area buttons - **/ -guint -e_alert_dialog_count_buttons (EAlertDialog *dialog) -{ - GtkWidget *container; - GList *children, *iter; - guint n_buttons = 0; - - g_return_val_if_fail (E_IS_ALERT_DIALOG (dialog), 0); - - container = gtk_dialog_get_action_area (GTK_DIALOG (dialog)); - children = gtk_container_get_children (GTK_CONTAINER (container)); - - /* Iterate over the children looking for buttons. */ - for (iter = children; iter != NULL; iter = iter->next) - if (GTK_IS_BUTTON (iter->data)) - n_buttons++; - - g_list_free (children); - - return n_buttons; -} - -/** * e_alert_dialog_get_alert: * @dialog: a #EAlertDialog * diff --git a/e-util/e-alert-dialog.h b/e-util/e-alert-dialog.h index 96253a582e..5a23d72c4f 100644 --- a/e-util/e-alert-dialog.h +++ b/e-util/e-alert-dialog.h @@ -72,7 +72,6 @@ gint e_alert_run_dialog (GtkWindow *parent, gint e_alert_run_dialog_for_args (GtkWindow *parent, const gchar *tag, ...) G_GNUC_NULL_TERMINATED; -guint e_alert_dialog_count_buttons (EAlertDialog *dialog); EAlert * e_alert_dialog_get_alert (EAlertDialog *dialog); G_END_DECLS diff --git a/e-util/e-alert.c b/e-util/e-alert.c index 96e9078402..12bee6d78c 100644 --- a/e-util/e-alert.c +++ b/e-util/e-alert.c @@ -38,7 +38,6 @@ #include "e-util.h" #include "e-util-private.h" #include "e-alert.h" -#include "e-alert-action.h" #include "e-alert-sink.h" #define d(x) diff --git a/e-util/e-logger.c b/e-util/e-logger.c deleted file mode 100644 index b29595a70f..0000000000 --- a/e-util/e-logger.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * - * 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> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <glib.h> -#include <glib/gi18n.h> -#include <glib/gstdio.h> -#include "e-logger.h" -#include "e-mktemp.h" - -/* 5 Minutes */ -#define TIMEOUT_INTERVAL 300 - -#define E_LOGGER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_LOGGER, ELoggerPrivate)) - -struct _ELoggerPrivate { - gchar *name; - gchar *logfile; - FILE *fp; - - guint timer; -}; - -enum { - PROP_0, - PROP_NAME -}; - -G_DEFINE_TYPE ( - ELogger, - e_logger, - G_TYPE_OBJECT) - -static gboolean -logger_flush (ELogger *logger) -{ - if (logger->priv->fp) - fflush (logger->priv->fp); - logger->priv->timer = 0; - - return FALSE; -} - -static void -logger_set_dirty (ELogger *logger) -{ - if (logger->priv->timer) - return; - - logger->priv->timer = g_timeout_add ( - TIMEOUT_INTERVAL, (GSourceFunc) logger_flush, logger); -} - -static void -logger_set_name (ELogger *logger, - const gchar *name) -{ - gchar *temp; - - g_return_if_fail (logger->priv->name == NULL); - - temp = g_strdup_printf ("%s.log.XXXXXX", name); - - logger->priv->name = g_strdup (name); - logger->priv->logfile = e_mktemp (temp); - logger->priv->fp = g_fopen (logger->priv->logfile, "w"); - logger->priv->timer = 0; - - if (!logger->priv->fp) - g_warning ( - "%s: Failed to open log file '%s' for writing.", - G_STRFUNC, logger->priv->logfile ? - logger->priv->logfile : "[null]"); - - g_free (temp); -} - -static void -logger_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_NAME: - logger_set_name ( - E_LOGGER (object), - g_value_get_string (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -logger_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_NAME: - g_value_set_string ( - value, e_logger_get_name ( - E_LOGGER (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -logger_finalize (GObject *object) -{ - ELogger *logger = E_LOGGER (object); - - if (logger->priv->timer) - g_source_remove (logger->priv->timer); - logger_flush (logger); - if (logger->priv->fp) - fclose (logger->priv->fp); - - g_free (logger->priv->name); - g_free (logger->priv->logfile); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (e_logger_parent_class)->finalize (object); -} - -static void -e_logger_class_init (ELoggerClass *class) -{ - GObjectClass *object_class; - - g_type_class_add_private (class, sizeof (ELoggerPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->set_property = logger_set_property; - object_class->get_property = logger_get_property; - object_class->finalize = logger_finalize; - - g_object_class_install_property ( - object_class, - PROP_NAME, - g_param_spec_string ( - "name", - "Name", - "Name of the logger", - "anonymous", - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); -} - -static void -e_logger_init (ELogger *logger) -{ - logger->priv = E_LOGGER_GET_PRIVATE (logger); -} - -ELogger * -e_logger_new (const gchar *name) -{ - g_return_val_if_fail (name != NULL, NULL); - - return g_object_new (E_TYPE_LOGGER, "name", name, NULL); -} - -const gchar * -e_logger_get_name (ELogger *logger) -{ - g_return_val_if_fail (E_IS_LOGGER (logger), NULL); - - return logger->priv->name; -} - -void -e_logger_log (ELogger *logger, - ELogLevel level, - gchar *primary, - gchar *secondary) -{ - time_t t = time (NULL); - - g_return_if_fail (E_LOGGER (logger)); - g_return_if_fail (primary != NULL); - g_return_if_fail (secondary != NULL); - - if (!logger->priv->fp) - return; - - fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, primary); - fprintf (logger->priv->fp, "%d:%ld:%s\n", level, t, secondary); - logger_set_dirty (logger); -} - -void -e_logger_get_logs (ELogger *logger, - ELogFunction func, - gpointer user_data) -{ - FILE *fp; - gchar buf[250]; - - g_return_if_fail (E_LOGGER (logger)); - g_return_if_fail (func != NULL); - - /* Flush everything before we get the logs */ - if (logger->priv->fp) - fflush (logger->priv->fp); - fp = g_fopen (logger->priv->logfile, "r"); - - if (!fp) { - g_warning ( - "%s: Cannot open log file '%s' for reading! " - "No flush yet?\n", G_STRFUNC, logger->priv->logfile ? - logger->priv->logfile : "[null]"); - return; - } - - while (!feof (fp)) { - gchar *tmp; - gsize len; - - tmp = fgets (buf, sizeof (buf), fp); - if (!tmp) - break; - - len = strlen (tmp); - if (len > 0 && tmp[len - 1] != '\n' && !feof (fp)) { - /* there are more characters on a row than 249, so read them all */ - GString *str = g_string_sized_new (1024); - - g_string_append (str, tmp); - - while (!feof (fp) && len > 0 && tmp[len - 1] != '\n') { - tmp = fgets (buf, sizeof (buf), fp); - if (!tmp) - break; - - len = strlen (tmp); - g_string_append (str, tmp); - } - - func (str->str, user_data); - - g_string_free (str, TRUE); - } else - func (tmp, user_data); - } - - fclose (fp); -} diff --git a/e-util/e-logger.h b/e-util/e-logger.h deleted file mode 100644 index efb5cd47f1..0000000000 --- a/e-util/e-logger.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef E_LOGGER_H -#define E_LOGGER_H - -#include <glib-object.h> - -/* Standard GObject macros */ -#define E_TYPE_LOGGER \ - (e_logger_get_type ()) -#define E_LOGGER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_LOGGER, ELogger)) -#define E_LOGGER_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_LOGGER, ELoggerClass)) -#define E_IS_LOGGER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_LOGGER)) -#define E_IS_LOGGER_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_LOGGER)) -#define E_LOGGER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_LOGGER, ELoggerClass)) - -G_BEGIN_DECLS - -typedef struct _ELogger ELogger; -typedef struct _ELoggerClass ELoggerClass; -typedef struct _ELoggerPrivate ELoggerPrivate; - -typedef void (*ELogFunction) (gchar *line, gpointer data); - -typedef enum { - E_LOG_ERROR, - E_LOG_WARNING, - E_LOG_DEBUG -} ELogLevel; - -struct _ELogger { - GObject parent; - ELoggerPrivate *priv; -}; - -struct _ELoggerClass { - GObjectClass parent_class; -}; - -GType e_logger_get_type (void); -ELogger * e_logger_new (const gchar *name); -const gchar * e_logger_get_name (ELogger *logger); -void e_logger_log (ELogger *logger, - ELogLevel level, - gchar *primary, - gchar *secondary); -void e_logger_get_logs (ELogger *logger, - ELogFunction func, - gpointer user_data); - -G_END_DECLS - -#endif /* E_LOGGER_H */ diff --git a/e-util/e-non-intrusive-error-dialog.c b/e-util/e-non-intrusive-error-dialog.c deleted file mode 100644 index fb7f1f3afc..0000000000 --- a/e-util/e-non-intrusive-error-dialog.c +++ /dev/null @@ -1,313 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Ashish Shrivastava <shashish@novell.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -#include <glib.h> -#include <glib/gi18n.h> -#include <glib/gstdio.h> -#include <glib/gstdio.h> -#include <gconf/gconf-client.h> -#include "e-non-intrusive-error-dialog.h" - -/* eni - non intrusive error */ - -static gboolean -eni_query_tooltip_cb (GtkTreeView *view, - gint x, - gint y, - gboolean keyboard_mode, - GtkTooltip *tooltip) -{ - GtkTreeViewColumn *column; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - gint level; - - if (!gtk_tree_view_get_tooltip_context ( - view, &x, &y, keyboard_mode, NULL, &path, &iter)) - return FALSE; - - /* Figure out which column we're pointing at. */ - if (keyboard_mode) - gtk_tree_view_get_cursor (view, NULL, &column); - else - gtk_tree_view_get_path_at_pos ( - view, x, y, NULL, &column, NULL, NULL); - - /* Restrict the tip area to a single cell. */ - gtk_tree_view_set_tooltip_cell (view, tooltip, path, column, NULL); - - /* This only works if the tree view is NOT reorderable. */ - if (column != gtk_tree_view_get_column (view, 0)) - return FALSE; - - model = gtk_tree_view_get_model (view); - gtk_tree_model_get (model, &iter, COL_LEVEL, &level, -1); - gtk_tooltip_set_text (tooltip, ldata[level].key); - - return TRUE; -} - -static void -eni_render_pixbuf (GtkTreeViewColumn *column, GtkCellRenderer *renderer, - GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) -{ - gint level; - - gtk_tree_model_get (model, iter, COL_LEVEL, &level, -1); - g_object_set ( - renderer, "stock-id", ldata[level].stock_id, - "stock-size", GTK_ICON_SIZE_MENU, NULL); -} - -static void -eni_render_date (GtkTreeViewColumn *column, GtkCellRenderer *renderer, - GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) -{ - time_t t; - gchar sdt[100]; /* Should be sufficient? */ - - gtk_tree_model_get (model, iter, COL_TIME, &t, -1); - strftime (sdt, 100, "%x %X", localtime (&t)); - g_object_set (renderer, "text", sdt, NULL); -} - -static void -eni_append_logs (const gchar *txt, GtkListStore *store) -{ - gchar **str; - - str = g_strsplit (txt, ":", 3); - if (str[0] && str[1] && str[2]) { - GtkTreeIter iter; - - gtk_list_store_append (store, &iter); - gtk_list_store_set ( - store, &iter, - COL_LEVEL, atoi (str[0]), - COL_TIME, atol (str[1]), - COL_DATA, g_strstrip (str[2]), - -1); - } else - g_printerr ("Unable to decode error log: %s\n", txt); - - g_strfreev (str); -} - -static guint -eni_config_get_error_level (const gchar *path) -{ - GConfClient *gconf_client; - guint error_level; - - gconf_client = gconf_client_get_default (); - error_level = gconf_client_get_int (gconf_client, path, NULL); - - g_object_unref (gconf_client); - return error_level; -} - -guint -eni_config_get_error_timeout (const gchar *path) -{ - GConfClient *gconf_client; - guint error_time; - - gconf_client = gconf_client_get_default (); - error_time = gconf_client_get_int (gconf_client, path, NULL); - - g_object_unref (gconf_client); - return error_time; -} - -static void -eni_error_timeout_changed (GtkSpinButton *b, gpointer data) -{ - GConfClient *gconf_client; - gint value = gtk_spin_button_get_value_as_int (b); - - gconf_client = gconf_client_get_default (); - - gconf_client_set_int (gconf_client, (gchar *) data, value, NULL); - g_object_unref (gconf_client); -} - -static void -eni_error_level_value_changed (GtkComboBox *w, gpointer *data) -{ - GConfClient *gconf_client; - gint value = gtk_combo_box_get_active (w); - - gconf_client = gconf_client_get_default (); - - gconf_client_set_int (gconf_client, (gchar *) data, value, NULL); - - g_object_unref (gconf_client); -} - -void -eni_show_logger (ELogger *logger, - GtkWidget *top, - const gchar *error_timeout_path, - const gchar *error_level_path) -{ - GtkWidget *container; - GtkWidget *label; - GtkWidget *toplevel; - GtkWidget *vbox; - GtkWidget *widget; - GtkWidget *window; - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - gint i; - - toplevel = gtk_widget_get_toplevel (top); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size (GTK_WINDOW (window), 500, 400); - gtk_window_set_title (GTK_WINDOW (window), _("Debug Logs")); - gtk_window_set_transient_for ( - GTK_WINDOW (window), GTK_WINDOW (toplevel)); - gtk_container_set_border_width (GTK_CONTAINER (window), 12); - - vbox = gtk_vbox_new (FALSE, 12); - gtk_container_add (GTK_CONTAINER (window), vbox); - - container = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0); - - /* Translators: This is the first part of the sentence - * "Show _errors in the status bar for" - XXX - "second(s)." */ - widget = gtk_label_new_with_mnemonic ( - _("Show _errors in the status bar for")); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - label = widget; - - widget = gtk_spin_button_new_with_range (1.0, 60.0, 1.0); - gtk_spin_button_set_value ( - GTK_SPIN_BUTTON (widget), - (gdouble) eni_config_get_error_timeout (error_timeout_path)); - g_signal_connect ( - widget, "value-changed", - G_CALLBACK (eni_error_timeout_changed), - (gpointer) error_timeout_path); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - - /* Translators: This is the second part of the sentence - * "Show _errors in the status bar for" - XXX - "second(s)." */ - widget = gtk_label_new_with_mnemonic (_("second(s).")); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - - container = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0); - - widget = gtk_label_new_with_mnemonic (_("Log Messages:")); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - label = widget; - - widget = gtk_combo_box_new_text (); - for (i = E_LOG_ERROR; i <= E_LOG_DEBUG; i++) - gtk_combo_box_append_text ( - GTK_COMBO_BOX (widget), ldata[i].text); - gtk_combo_box_set_active ( - GTK_COMBO_BOX (widget), - eni_config_get_error_level (error_level_path)); - - g_signal_connect ( - widget, "changed", - G_CALLBACK (eni_error_level_value_changed), - (gpointer) error_level_path); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - - store = gtk_list_store_new (3, G_TYPE_INT, G_TYPE_LONG, G_TYPE_STRING); - e_logger_get_logs (logger, (ELogFunction) eni_append_logs, store); - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (store), COL_TIME, GTK_SORT_DESCENDING); - - container = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy ( - GTK_SCROLLED_WINDOW (container), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type ( - GTK_SCROLLED_WINDOW (container), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (vbox), container, TRUE, TRUE, 0); - - widget = gtk_tree_view_new (); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (widget), TRUE); - gtk_tree_view_set_reorderable (GTK_TREE_VIEW (widget), FALSE); - gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (store)); - gtk_tree_view_set_search_column (GTK_TREE_VIEW (widget), COL_DATA); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), TRUE); - gtk_widget_set_has_tooltip (widget, TRUE); - gtk_container_add (GTK_CONTAINER (container), widget); - - g_signal_connect ( - widget, "query-tooltip", - G_CALLBACK (eni_query_tooltip_cb), NULL); - - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Log Level")); - gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); - renderer = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (column, renderer, TRUE); - gtk_tree_view_column_set_cell_data_func ( - column, renderer, eni_render_pixbuf, NULL, NULL); - - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Time")); - gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); - - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (column, renderer, FALSE); - gtk_tree_view_column_set_cell_data_func ( - column, renderer, eni_render_date, NULL, NULL); - - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (widget), -1, _("Messages"), - renderer, "markup", COL_DATA, NULL); - - container = gtk_hbutton_box_new (); - gtk_button_box_set_layout ( - GTK_BUTTON_BOX (container), GTK_BUTTONBOX_END); - gtk_box_pack_start (GTK_BOX (vbox), container, FALSE, FALSE, 0); - - widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - gtk_widget_set_tooltip_text (widget, _("Close this window")); - g_signal_connect_swapped ( - widget, "clicked", - G_CALLBACK (gtk_widget_destroy), window); - gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); - - gtk_widget_show_all (window); -} diff --git a/e-util/e-non-intrusive-error-dialog.h b/e-util/e-non-intrusive-error-dialog.h deleted file mode 100644 index 58456a13af..0000000000 --- a/e-util/e-non-intrusive-error-dialog.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Ashish Shrivastava <shashish@novell.com> - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef __E_ERROR_DIALOG_H__ -#define __E_ERROR_DIALOG_H__ - -#include <glib-object.h> -#include "e-icon-factory.h" -#include "e-logger.h" - -G_BEGIN_DECLS - -struct _log_data { - gint level; - const gchar *key; - const gchar *text; - const gchar *stock_id; - GdkPixbuf *pbuf; -} ldata[] = { - { E_LOG_ERROR, N_("Error"), N_("Errors"), GTK_STOCK_DIALOG_ERROR }, - { E_LOG_WARNING, N_("Warning"), N_("Warnings and Errors"), GTK_STOCK_DIALOG_WARNING }, - { E_LOG_DEBUG, N_("Debug"), N_("Error, Warnings and Debug messages"), GTK_STOCK_DIALOG_INFO } -}; - -enum -{ - COL_LEVEL = 0, - COL_TIME, - COL_DATA -}; - -/* eni - error non intrusive*/ -guint eni_config_get_error_timeout (const gchar *path); -void eni_show_logger (ELogger *logger, - GtkWidget *widget, - const gchar *error_timeout_path, - const gchar *error_level_path); - -G_END_DECLS - -#endif /* __E_ERROR_DIALOG_H__ */ diff --git a/e-util/e-timeout-activity.c b/e-util/e-timeout-activity.c deleted file mode 100644 index b5a48f0520..0000000000 --- a/e-util/e-timeout-activity.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * e-timeout-activity.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/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "e-timeout-activity.h" - -#include <stdarg.h> - -#define E_TIMEOUT_ACTIVITY_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_TIMEOUT_ACTIVITY, ETimeoutActivityPrivate)) - -struct _ETimeoutActivityPrivate { - guint timeout_id; -}; - -enum { - TIMEOUT, - LAST_SIGNAL -}; - -static gulong signals[LAST_SIGNAL]; - -G_DEFINE_TYPE ( - ETimeoutActivity, - e_timeout_activity, - E_TYPE_ACTIVITY) - -static gboolean -timeout_activity_cb (ETimeoutActivity *timeout_activity) -{ - g_signal_emit (timeout_activity, signals[TIMEOUT], 0); - - return FALSE; -} - -static void -timeout_activity_finalize (GObject *object) -{ - ETimeoutActivityPrivate *priv; - - priv = E_TIMEOUT_ACTIVITY_GET_PRIVATE (object); - - if (priv->timeout_id > 0) - g_source_remove (priv->timeout_id); - - /* Chain up to parent's finalize() method. */ - G_OBJECT_CLASS (e_timeout_activity_parent_class)->finalize (object); -} - -static void -timeout_activity_cancelled (EActivity *activity) -{ - ETimeoutActivityPrivate *priv; - - priv = E_TIMEOUT_ACTIVITY_GET_PRIVATE (activity); - - if (priv->timeout_id > 0) { - g_source_remove (priv->timeout_id); - priv->timeout_id = 0; - } - - /* Chain up to parent's cancelled() method. */ - E_ACTIVITY_CLASS (e_timeout_activity_parent_class)->cancelled (activity); -} - -static void -timeout_activity_completed (EActivity *activity) -{ - ETimeoutActivityPrivate *priv; - - priv = E_TIMEOUT_ACTIVITY_GET_PRIVATE (activity); - - if (priv->timeout_id > 0) { - g_source_remove (priv->timeout_id); - priv->timeout_id = 0; - } - - /* Chain up to parent's completed() method. */ - E_ACTIVITY_CLASS (e_timeout_activity_parent_class)->completed (activity); -} - -static void -timeout_activity_timeout (ETimeoutActivity *timeout_activity) -{ - /* Allow subclasses to safely chain up. */ -} - -static void -e_timeout_activity_class_init (ETimeoutActivityClass *class) -{ - GObjectClass *object_class; - EActivityClass *activity_class; - - g_type_class_add_private (class, sizeof (ETimeoutActivityPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->finalize = timeout_activity_finalize; - - activity_class = E_ACTIVITY_CLASS (class); - activity_class->cancelled = timeout_activity_cancelled; - activity_class->completed = timeout_activity_completed; - - class->timeout = timeout_activity_timeout; - - signals[TIMEOUT] = g_signal_new ( - "timeout", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (ETimeoutActivityClass, timeout), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -e_timeout_activity_init (ETimeoutActivity *timeout_activity) -{ - timeout_activity->priv = - E_TIMEOUT_ACTIVITY_GET_PRIVATE (timeout_activity); -} - -EActivity * -e_timeout_activity_new (const gchar *primary_text) -{ - return g_object_new ( - E_TYPE_TIMEOUT_ACTIVITY, - "primary-text", primary_text, NULL); -} - -EActivity * -e_timeout_activity_newv (const gchar *format, ...) -{ - EActivity *activity; - gchar *primary_text; - va_list args; - - va_start (args, format); - primary_text = g_strdup_vprintf (format, args); - activity = e_timeout_activity_new (primary_text); - g_free (primary_text); - va_end (args); - - return activity; -} - -void -e_timeout_activity_set_timeout (ETimeoutActivity *timeout_activity, - guint seconds) -{ - g_return_if_fail (E_IS_TIMEOUT_ACTIVITY (timeout_activity)); - - if (timeout_activity->priv->timeout_id > 0) - g_source_remove (timeout_activity->priv->timeout_id); - - timeout_activity->priv->timeout_id = g_timeout_add_seconds ( - seconds, (GSourceFunc) timeout_activity_cb, timeout_activity); -} diff --git a/e-util/e-timeout-activity.h b/e-util/e-timeout-activity.h deleted file mode 100644 index 7545568e13..0000000000 --- a/e-util/e-timeout-activity.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * e-timeout-activity.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/> - * - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef E_TIMEOUT_ACTIVITY_H -#define E_TIMEOUT_ACTIVITY_H - -#include <e-util/e-activity.h> - -/* Standard GObject macros */ -#define E_TYPE_TIMEOUT_ACTIVITY \ - (e_timeout_activity_get_type ()) -#define E_TIMEOUT_ACTIVITY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_TIMEOUT_ACTIVITY, ETimeoutActivity)) -#define E_TIMEOUT_ACTIVITY_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_TIMEOUT_ACTIVITY, ETimeoutActivityClass)) -#define E_IS_TIMEOUT_ACTIVITY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_TIMEOUT_ACTIVITY)) -#define E_IS_TIMEOUT_ACTIVITY_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_TIMEOUT_ACTIVITY)) -#define E_TIMEOUT_ACTIVITY_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_TIMEOUT_ACTIVITY, ETimeoutActivityClass)) - -G_BEGIN_DECLS - -typedef struct _ETimeoutActivity ETimeoutActivity; -typedef struct _ETimeoutActivityClass ETimeoutActivityClass; -typedef struct _ETimeoutActivityPrivate ETimeoutActivityPrivate; - -struct _ETimeoutActivity { - EActivity parent; - ETimeoutActivityPrivate *priv; -}; - -struct _ETimeoutActivityClass { - EActivityClass parent_class; - - /* Signals */ - void (*timeout) (ETimeoutActivity *timeout_activity); -}; - -GType e_timeout_activity_get_type (void); -EActivity * e_timeout_activity_new (const gchar *primary_text); -EActivity * e_timeout_activity_newv (const gchar *format, - ...) G_GNUC_PRINTF (1, 2); -void e_timeout_activity_set_timeout (ETimeoutActivity *timeout_activity, - guint seconds); - -G_END_DECLS - -#endif /* E_TIMEOUT_ACTIVITY_H */ diff --git a/mail/e-mail-backend.c b/mail/e-mail-backend.c index dd34737272..0ecae4856c 100644 --- a/mail/e-mail-backend.c +++ b/mail/e-mail-backend.c @@ -322,10 +322,7 @@ mail_backend_folder_deleted_cb (MailFolderCache *folder_cache, const gchar *uri, EMailBackend *backend) { - EMailSession *session; - - session = e_mail_backend_get_session (backend); - mail_filter_delete_uri (session, store, uri); + mail_filter_delete_uri (backend, store, uri); } static void @@ -335,10 +332,7 @@ mail_backend_folder_renamed_cb (MailFolderCache *folder_cache, const gchar *new_uri, EMailBackend *backend) { - EMailSession *session; - - session = e_mail_backend_get_session (backend); - mail_filter_rename_uri (session, store, old_uri, new_uri); + mail_filter_rename_uri (backend, store, old_uri, new_uri); } static void @@ -406,6 +400,8 @@ mail_backend_idle_cb (EMailBackend *backend) e_mail_store_init (session, data_dir); + vfolder_load_storage (backend); + return FALSE; } @@ -449,8 +445,8 @@ mail_backend_constructed (GObject *object) EMailBackendPrivate *priv; EShell *shell; EShellBackend *shell_backend; - MailFolderCache *folder_cache; EMFolderTreeModel *folder_tree_model; + MailFolderCache *folder_cache; priv = E_MAIL_BACKEND_GET_PRIVATE (object); @@ -463,6 +459,7 @@ mail_backend_constructed (GObject *object) camel_provider_init (); priv->session = e_mail_session_new (); + folder_cache = e_mail_session_get_folder_cache (priv->session); g_object_bind_property ( shell, "online", @@ -477,8 +474,6 @@ mail_backend_constructed (GObject *object) folder_tree_model = em_folder_tree_model_get_default (); em_folder_tree_model_set_session (folder_tree_model, priv->session); - folder_cache = mail_folder_cache_get_default (); - g_signal_connect ( shell, "prepare-for-offline", G_CALLBACK (mail_backend_prepare_for_offline_cb), @@ -513,7 +508,7 @@ mail_backend_constructed (GObject *object) folder_cache, "folder-changed", G_CALLBACK (mail_backend_folder_changed_cb), shell); - mail_config_init (CAMEL_SESSION (priv->session)); + mail_config_init (priv->session); mail_msg_init (); /* Defer initializing CamelStores until after the main loop @@ -591,3 +586,50 @@ e_mail_backend_empty_trash_policy_decision (EMailBackend *backend) return class->empty_trash_policy_decision (backend); } + +void +e_mail_backend_submit_alert (EMailBackend *backend, + const gchar *tag, + ...) +{ + EShell *shell; + EShellView *shell_view; + EShellBackend *shell_backend; + EShellContent *shell_content; + EShellWindow *shell_window = NULL; + EShellBackendClass *class; + GList *list, *iter; + va_list va; + + /* XXX This is meant to be a convenient but temporary hack. + * Instead, pass alerts directly to an EShellContent. + * Perhaps even take an EAlert** instead of a GError** + * in some low-level functions. */ + + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (tag != NULL); + + shell_backend = E_SHELL_BACKEND (backend); + shell = e_shell_backend_get_shell (shell_backend); + + /* Find the most recently used EShellWindow. */ + list = e_shell_get_watched_windows (shell); + 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; + + class = E_SHELL_BACKEND_GET_CLASS (shell_backend); + shell_view = e_shell_window_get_shell_view (shell_window, class->name); + shell_content = e_shell_view_get_shell_content (shell_view); + + va_start (va, tag); + e_alert_submit_valist (GTK_WIDGET (shell_content), tag, va); + va_end (va); +} diff --git a/mail/e-mail-backend.h b/mail/e-mail-backend.h index 18fdf885ca..6d425197f3 100644 --- a/mail/e-mail-backend.h +++ b/mail/e-mail-backend.h @@ -75,6 +75,9 @@ gboolean e_mail_backend_delete_junk_policy_decision (EMailBackend *backend); gboolean e_mail_backend_empty_trash_policy_decision (EMailBackend *backend); +void e_mail_backend_submit_alert (EMailBackend *backend, + const gchar *tag, + ...) G_GNUC_NULL_TERMINATED; G_END_DECLS diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 83dc3f569a..2b9c832315 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -1556,9 +1556,6 @@ action_search_folder_recipient_cb (GtkAction *action, if (curl->path != NULL && *curl->path != '\0') { CamelInternetAddress *inet_addr; - /* Ensure vfolder is running. */ - vfolder_load_storage (session); - inet_addr = camel_internet_address_new (); camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path); vfolder_gui_add_from_address ( @@ -1600,9 +1597,6 @@ action_search_folder_sender_cb (GtkAction *action, if (curl->path != NULL && *curl->path != '\0') { CamelInternetAddress *inet_addr; - /* Ensure vfolder is running. */ - vfolder_load_storage (session); - inet_addr = camel_internet_address_new (); camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path); vfolder_gui_add_from_address ( diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c index 14213bf6e4..1d9b44f02a 100644 --- a/mail/e-mail-session.c +++ b/mail/e-mail-session.c @@ -57,7 +57,6 @@ #include "em-filter-rule.h" #include "em-utils.h" #include "mail-config.h" -#include "mail-folder-cache.h" #include "mail-mt.h" #include "mail-ops.h" #include "mail-send-recv.h" @@ -73,6 +72,8 @@ static guint session_gconf_proxy_id; typedef struct _AsyncContext AsyncContext; struct _EMailSessionPrivate { + MailFolderCache *folder_cache; + FILE *filter_logfile; GList *junk_plugins; }; @@ -86,6 +87,11 @@ struct _AsyncContext { CamelFolder *folder; }; +enum { + PROP_0, + PROP_FOLDER_CACHE +}; + static gchar *mail_data_dir; static gchar *mail_config_dir; @@ -187,31 +193,19 @@ user_message_exec (struct _user_message_msg *m) user_message_dialog, "allow_shrink", TRUE, "allow_grow", TRUE, NULL); - /* Use the number of dialog buttons as a heuristic for whether to - * emit a status bar message or present the dialog immediately, the - * thought being if there's more than one button then something is - * probably blocked until the user responds. */ - if (e_alert_dialog_count_buttons (user_message_dialog) > 1) { - if (m->ismain) { - gint response; - - response = gtk_dialog_run (user_message_dialog); - user_message_response ( - user_message_dialog, response, m); - } else { - g_signal_connect ( - user_message_dialog, "response", - G_CALLBACK (user_message_response), m); - gtk_widget_show (user_message_dialog); - } + /* 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 { g_signal_connect ( user_message_dialog, "response", - G_CALLBACK (user_message_response_free), m); - g_object_set_data ( - user_message_dialog, "response-handled", - GINT_TO_POINTER (TRUE)); - em_utils_show_error_silent (user_message_dialog); + G_CALLBACK (user_message_response), m); + gtk_widget_show (user_message_dialog); } } @@ -520,6 +514,40 @@ mail_session_check_junk_notify (GConfClient *gconf, } static void +mail_session_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_FOLDER_CACHE: + g_value_set_object ( + value, + e_mail_session_get_folder_cache ( + E_MAIL_SESSION (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +mail_session_dispose (GObject *object) +{ + EMailSessionPrivate *priv; + + priv = E_MAIL_SESSION_GET_PRIVATE (object); + + if (priv->folder_cache != NULL) { + g_object_unref (priv->folder_cache); + priv->folder_cache = NULL; + } + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (e_mail_session_parent_class)->dispose (object); +} + +static void mail_session_finalize (GObject *object) { GConfClient *client; @@ -885,6 +913,8 @@ e_mail_session_class_init (EMailSessionClass *class) g_type_class_add_private (class, sizeof (EMailSessionPrivate)); object_class = G_OBJECT_CLASS (class); + object_class->get_property = mail_session_get_property; + object_class->dispose = mail_session_dispose; object_class->finalize = mail_session_finalize; session_class = CAMEL_SESSION_CLASS (class); @@ -897,6 +927,16 @@ e_mail_session_class_init (EMailSessionClass *class) session_class->thread_msg_free = mail_session_thread_msg_free; session_class->thread_status = mail_session_thread_status; session_class->forward_to = mail_session_forward_to; + + g_object_class_install_property ( + object_class, + PROP_FOLDER_CACHE, + g_param_spec_object ( + "folder-cache", + NULL, + NULL, + MAIL_TYPE_FOLDER_CACHE, + G_PARAM_READABLE)); } static void @@ -905,6 +945,7 @@ e_mail_session_init (EMailSession *session) GConfClient *client; session->priv = E_MAIL_SESSION_GET_PRIVATE (session); + session->priv->folder_cache = mail_folder_cache_new (); /* Initialize the EAccount setup. */ e_account_writable (NULL, E_ACCOUNT_SOURCE_SAVE_PASSWD); @@ -927,7 +968,7 @@ e_mail_session_init (EMailSession *session) session, NULL, NULL); CAMEL_SESSION (session)->junk_plugin = NULL; - mail_config_reload_junk_headers (CAMEL_SESSION (session)); + mail_config_reload_junk_headers (session); init_socks_proxy (CAMEL_SESSION (session)); @@ -940,6 +981,14 @@ e_mail_session_new (void) return g_object_new (E_TYPE_MAIL_SESSION, NULL); } +MailFolderCache * +e_mail_session_get_folder_cache (EMailSession *session) +{ + g_return_val_if_fail (E_IS_MAIL_SESSION (session), NULL); + + return session->priv->folder_cache; +} + static void mail_session_get_inbox_thread (GSimpleAsyncResult *simple, EMailSession *session, @@ -1236,10 +1285,10 @@ e_mail_session_uri_to_folder_sync (EMailSession *session, } if (folder != NULL) { - MailFolderCache *cache; + MailFolderCache *folder_cache; - cache = mail_folder_cache_get_default (); - mail_folder_cache_note_folder (cache, folder); + folder_cache = e_mail_session_get_folder_cache (session); + mail_folder_cache_note_folder (folder_cache, folder); } camel_url_free (url); diff --git a/mail/e-mail-session.h b/mail/e-mail-session.h index 71a5d73eb4..f9cab970cc 100644 --- a/mail/e-mail-session.h +++ b/mail/e-mail-session.h @@ -26,6 +26,7 @@ #define E_MAIL_SESSION_H #include <camel/camel.h> +#include <mail/mail-folder-cache.h> /* Standard GObject macros */ #define E_TYPE_MAIL_SESSION \ @@ -63,6 +64,8 @@ struct _EMailSessionClass { GType e_mail_session_get_type (void); EMailSession * e_mail_session_new (void); +MailFolderCache * + e_mail_session_get_folder_cache (EMailSession *session); CamelFolder * e_mail_session_get_inbox_sync (EMailSession *session, const gchar *service_uri, GCancellable *cancellable, diff --git a/mail/e-mail-store.c b/mail/e-mail-store.c index ef997d2fe2..b23e6f2121 100644 --- a/mail/e-mail-store.c +++ b/mail/e-mail-store.c @@ -35,7 +35,8 @@ typedef struct _StoreInfo StoreInfo; -typedef void (*AddStoreCallback) (CamelStore *store, +typedef void (*AddStoreCallback) (MailFolderCache *folder_cache, + CamelStore *store, CamelFolderInfo *info, StoreInfo *store_info); @@ -132,25 +133,25 @@ store_table_free (StoreInfo *store_info) } static gboolean -mail_store_note_store_cb (CamelStore *store, +mail_store_note_store_cb (MailFolderCache *folder_cache, + CamelStore *store, CamelFolderInfo *info, gpointer user_data) { StoreInfo *store_info = user_data; if (store_info->callback != NULL) - store_info->callback (store, info, store_info); + store_info->callback ( + folder_cache, store, info, store_info); if (!store_info->removed) { /* This keeps message counters up-to-date. */ if (store_info->vtrash != NULL) mail_folder_cache_note_folder ( - mail_folder_cache_get_default (), - store_info->vtrash); + folder_cache, store_info->vtrash); if (store_info->vjunk != NULL) mail_folder_cache_note_folder ( - mail_folder_cache_get_default (), - store_info->vjunk); + folder_cache, store_info->vjunk); } store_info_unref (store_info); @@ -165,11 +166,13 @@ mail_store_add (EMailSession *session, AddStoreCallback callback) { EMFolderTreeModel *default_model; + MailFolderCache *folder_cache; StoreInfo *store_info; g_return_if_fail (store_table != NULL); default_model = em_folder_tree_model_get_default (); + folder_cache = e_mail_session_get_folder_cache (session); store_info = store_info_new (store, display_name); store_info->callback = callback; @@ -180,14 +183,13 @@ mail_store_add (EMailSession *session, default_model, store, store_info->display_name); mail_folder_cache_note_store ( - mail_folder_cache_get_default (), - CAMEL_SESSION (session), store, NULL, - mail_store_note_store_cb, - store_info_ref (store_info)); + folder_cache, CAMEL_SESSION (session), store, NULL, + mail_store_note_store_cb, store_info_ref (store_info)); } static void -mail_store_add_local_done_cb (CamelStore *store, +mail_store_add_local_done_cb (MailFolderCache *folder_cache, + CamelStore *store, CamelFolderInfo *info, StoreInfo *store_info) { @@ -196,9 +198,9 @@ mail_store_add_local_done_cb (CamelStore *store, for (ii = 0; ii < E_MAIL_NUM_LOCAL_FOLDERS; ii++) { folder = e_mail_local_get_folder (ii); - if (folder != NULL) - mail_folder_cache_note_folder ( - mail_folder_cache_get_default (), folder); + if (folder == NULL) + continue; + mail_folder_cache_note_folder (folder_cache, folder); } } @@ -337,10 +339,13 @@ fail: } void -e_mail_store_remove (CamelStore *store) +e_mail_store_remove (EMailSession *session, + CamelStore *store) { + MailFolderCache *folder_cache; EMFolderTreeModel *default_model; + g_return_if_fail (E_IS_MAIL_SESSION (session)); g_return_if_fail (CAMEL_IS_STORE (store)); g_return_if_fail (store_table != NULL); @@ -355,8 +360,9 @@ e_mail_store_remove (CamelStore *store) g_object_ref (store); g_hash_table_remove (store_table, store); - mail_folder_cache_note_store_remove ( - mail_folder_cache_get_default (), store); + + folder_cache = e_mail_session_get_folder_cache (session); + mail_folder_cache_note_store_remove (folder_cache, store); default_model = em_folder_tree_model_get_default (); em_folder_tree_model_remove_store (default_model, store); @@ -389,7 +395,7 @@ e_mail_store_remove_by_uri (EMailSession *session, if (service == NULL) return; - e_mail_store_remove (CAMEL_STORE (service)); + e_mail_store_remove (session, CAMEL_STORE (service)); g_object_unref (service); } diff --git a/mail/e-mail-store.h b/mail/e-mail-store.h index 8def4b8e73..b120d14aef 100644 --- a/mail/e-mail-store.h +++ b/mail/e-mail-store.h @@ -36,7 +36,8 @@ void e_mail_store_add (EMailSession *session, CamelStore * e_mail_store_add_by_uri (EMailSession *session, const gchar *uri, const gchar *display_name); -void e_mail_store_remove (CamelStore *store); +void e_mail_store_remove (EMailSession *session, + CamelStore *store); void e_mail_store_remove_by_uri (EMailSession *session, const gchar *uri); void e_mail_store_foreach (GHFunc func, diff --git a/mail/em-folder-properties.c b/mail/em-folder-properties.c index 525a7ffefa..d802aeb885 100644 --- a/mail/em-folder-properties.c +++ b/mail/em-folder-properties.c @@ -349,13 +349,16 @@ em_folder_properties_show (EShellView *shell_view, const gchar *uri) { EShellBackend *shell_backend; + EMailBackend *backend; EMailSession *session; g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); g_return_if_fail (uri != NULL); shell_backend = e_shell_view_get_shell_backend (shell_view); - session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend)); + + backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); /* HACK: its the old behaviour, not very 'neat' but it works */ if (!strncmp (uri, "vfolder:", 8)) { @@ -367,7 +370,7 @@ em_folder_properties_show (EShellView *shell_view, || strcmp (url->fragment, CAMEL_UNMATCHED_NAME) != 0) { if (url) camel_url_free (url); - vfolder_edit_rule (uri); + vfolder_edit_rule (backend, uri); return; } if (url != NULL) diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c index 5b22bd0f9d..9da5711cf0 100644 --- a/mail/em-folder-tree-model.c +++ b/mail/em-folder-tree-model.c @@ -556,11 +556,6 @@ folder_tree_model_init (EMFolderTreeModel *model) model->priv->account_added_id = g_signal_connect ( model->priv->accounts, "account-added", G_CALLBACK (account_added_cb), model); - - g_signal_connect_swapped ( - mail_folder_cache_get_default (), - "folder-unread-updated", - G_CALLBACK (folder_tree_model_set_unread_count), model); } GType @@ -665,6 +660,20 @@ em_folder_tree_model_set_session (EMFolderTreeModel *model, model->priv->session = session; + /* FIXME Technically we should be disconnecting this signal + * when replacing an old session with a new session, + * but at present this function is only called once. */ + if (session != NULL) { + MailFolderCache *folder_cache; + + folder_cache = e_mail_session_get_folder_cache (session); + + g_signal_connect_swapped ( + folder_cache, "folder-unread-updated", + G_CALLBACK (folder_tree_model_set_unread_count), + model); + } + g_object_notify (G_OBJECT (model), "session"); } @@ -677,6 +686,8 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, { GtkTreeRowReference *uri_row, *path_row; GtkTreeStore *tree_store; + MailFolderCache *folder_cache; + EMailSession *session; guint unread; GtkTreePath *path; GtkTreeIter sub; @@ -696,6 +707,9 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, tree_store = GTK_TREE_STORE (model); + session = em_folder_tree_model_get_session (model); + folder_cache = e_mail_session_get_folder_cache (session); + if (!fully_loaded) load = (fi->child == NULL) && !(fi->flags & (CAMEL_FOLDER_NOCHILDREN | CAMEL_FOLDER_NOINFERIORS)); @@ -717,7 +731,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, * be functionised. */ unread = fi->unread; if (mail_folder_cache_get_folder_from_uri ( - mail_folder_cache_get_default (), fi->uri, &folder) && folder) { + folder_cache, fi->uri, &folder) && folder) { is_drafts = em_utils_folder_is_drafts (folder, fi->uri); if (is_drafts || em_utils_folder_is_outbox (folder, fi->uri)) { diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index e966f2b0cc..cae91af14f 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -281,10 +281,11 @@ struct _copy_folder_data { }; static void -emfu_copy_folder_selected (EMailSession *session, +emfu_copy_folder_selected (EMailBackend *backend, const gchar *uri, gpointer data) { + EMailSession *session; struct _copy_folder_data *cfd = data; CamelStore *fromstore = NULL, *tostore = NULL; CamelStore *local_store; @@ -298,36 +299,34 @@ emfu_copy_folder_selected (EMailSession *session, } local_store = e_mail_local_get_store (); + session = e_mail_backend_get_session (backend); fromstore = camel_session_get_store ( CAMEL_SESSION (session), cfd->fi->uri, &local_error); if (fromstore == NULL) { - e_alert_run_dialog_for_args ( - e_shell_get_active_window (NULL), - cfd->delete ? "mail:no-move-folder-notexist" : - "mail:no-copy-folder-notexist", + e_mail_backend_submit_alert ( + backend, cfd->delete ? + "mail:no-move-folder-notexist" : + "mail:no-copy-folder-notexist", cfd->fi->full_name, uri, local_error->message, NULL); goto fail; } if (cfd->delete && fromstore == local_store && emfu_is_special_local_folder (cfd->fi->full_name)) { - GtkWidget *w; - - w = e_alert_dialog_new_for_args ( - e_shell_get_active_window (NULL), "mail:no-rename-special-folder", + e_mail_backend_submit_alert ( + backend, "mail:no-rename-special-folder", cfd->fi->full_name, NULL); - em_utils_show_error_silent (w); goto fail; } tostore = camel_session_get_store ( CAMEL_SESSION (session), uri, &local_error); if (tostore == NULL) { - e_alert_run_dialog_for_args ( - e_shell_get_active_window (NULL), - cfd->delete ? "mail:no-move-folder-to-notexist" : - "mail:no-copy-folder-to-notexist", + e_mail_backend_submit_alert ( + backend, cfd->delete ? + "mail:no-move-folder-to-notexist" : + "mail:no-copy-folder-to-notexist", cfd->fi->full_name, uri, local_error->message, NULL); goto fail; @@ -341,7 +340,8 @@ emfu_copy_folder_selected (EMailSession *session, if (tobase == NULL) tobase = ""; - em_folder_utils_copy_folders (fromstore, cfd->fi->full_name, tostore, tobase, cfd->delete); + em_folder_utils_copy_folders ( + fromstore, cfd->fi->full_name, tostore, tobase, cfd->delete); camel_url_free (url); fail: @@ -389,18 +389,22 @@ emfu_copy_folder_exclude (EMFolderTree *tree, GtkTreeModel *model, GtkTreeIter * /* FIXME: these functions must be documented */ void em_folder_utils_copy_folder (GtkWindow *parent, - EMailSession *session, + EMailBackend *backend, CamelFolderInfo *folderinfo, gint delete) { GtkWidget *dialog; EMFolderTree *emft; + EMailSession *session; const gchar *label; const gchar *title; struct _copy_folder_data *cfd; + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); g_return_if_fail (folderinfo != NULL); + session = e_mail_backend_get_session (backend); + cfd = g_malloc (sizeof (*cfd)); cfd->fi = folderinfo; cfd->delete = delete; @@ -425,94 +429,113 @@ em_folder_utils_copy_folder (GtkWindow *parent, uri = em_folder_selector_get_selected_uri ( EM_FOLDER_SELECTOR (dialog)); - emfu_copy_folder_selected (session, uri, cfd); + emfu_copy_folder_selected (backend, uri, cfd); } gtk_widget_destroy (dialog); } +typedef struct { + EMailBackend *backend; + GtkWidget *dialog; +} DeleteFolderData; + static void -emfu_delete_done (CamelFolder *folder, gboolean removed, GError **error, gpointer data) +emfu_delete_done (CamelFolder *folder, + gboolean removed, + GError **error, + gpointer user_data) { - GtkWidget *dialog = data; + DeleteFolderData *data = user_data; if (error != NULL && *error != NULL) { - GtkWidget *w; - - w = e_alert_dialog_new_for_args ( - e_shell_get_active_window (NULL), + e_mail_backend_submit_alert ( + data->backend, "mail:no-delete-folder", camel_folder_get_full_name (folder), (*error)->message, NULL); - em_utils_show_error_silent (w); g_clear_error (error); } - if (dialog) - gtk_widget_destroy (dialog); -} - -static void -emfu_delete_response (GtkWidget *dialog, gint response, gpointer data) -{ - if (response == GTK_RESPONSE_OK) { - /* disable dialog until operation finishes */ - gtk_widget_set_sensitive (dialog, FALSE); - - mail_remove_folder (g_object_get_data ((GObject *) dialog, "folder"), emfu_delete_done, dialog); - } else { - gtk_widget_destroy (dialog); - } + g_object_unref (data->backend); + gtk_widget_destroy (data->dialog); + g_slice_free (DeleteFolderData, data); } /* FIXME: these functions must be documented */ void -em_folder_utils_delete_folder (CamelFolder *folder) +em_folder_utils_delete_folder (EMailBackend *backend, + CamelFolder *folder) { CamelStore *local_store; CamelStore *parent_store; + EMailSession *session; + MailFolderCache *folder_cache; GtkWindow *parent = e_shell_get_active_window (NULL); GtkWidget *dialog; const gchar *full_name; gint flags = 0; + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (CAMEL_IS_FOLDER (folder)); + full_name = camel_folder_get_full_name (folder); parent_store = camel_folder_get_parent_store (folder); local_store = e_mail_local_get_store (); + session = e_mail_backend_get_session (backend); + folder_cache = e_mail_session_get_folder_cache (session); if (parent_store == local_store && emfu_is_special_local_folder (full_name)) { - dialog = e_alert_dialog_new_for_args ( - parent, "mail:no-delete-special-folder", + e_mail_backend_submit_alert ( + backend, "mail:no-delete-special-folder", full_name, NULL); - em_utils_show_error_silent (dialog); return; } - if (mail_folder_cache_get_folder_info_flags (mail_folder_cache_get_default (), folder, &flags) && (flags & CAMEL_FOLDER_SYSTEM)) - { - e_alert_run_dialog_for_args ( - parent,"mail:no-delete-special-folder", + if (mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags) && (flags & CAMEL_FOLDER_SYSTEM)) { + e_mail_backend_submit_alert ( + backend, "mail:no-delete-special-folder", camel_folder_get_name (folder), NULL); return; } g_object_ref (folder); - if (mail_folder_cache_get_folder_info_flags (mail_folder_cache_get_default (), folder, &flags) && (flags & CAMEL_FOLDER_CHILDREN)) { - dialog = e_alert_dialog_new_for_args (parent, - (parent_store && CAMEL_IS_VEE_STORE(parent_store))?"mail:ask-delete-vfolder":"mail:ask-delete-folder", - full_name, NULL); + if (mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags) && (flags & CAMEL_FOLDER_CHILDREN)) { + if (parent_store && CAMEL_IS_VEE_STORE (parent_store)) + dialog = e_alert_dialog_new_for_args ( + parent, "mail:ask-delete-vfolder", + full_name, NULL); + else + dialog = e_alert_dialog_new_for_args ( + parent, "mail:ask-delete-folder", + full_name, NULL); } else { - dialog = e_alert_dialog_new_for_args (parent, - (parent_store && CAMEL_IS_VEE_STORE(parent_store))?"mail:ask-delete-vfolder-nochild":"mail:ask-delete-folder-nochild", - full_name, NULL); + if (parent_store && CAMEL_IS_VEE_STORE (parent_store)) + dialog = e_alert_dialog_new_for_args ( + parent, "mail:ask-delete-vfolder-nochild", + full_name, NULL); + else + dialog = e_alert_dialog_new_for_args ( + parent, "mail:ask-delete-folder-nochild", + full_name, NULL); } - g_object_set_data_full ((GObject *) dialog, "folder", folder, g_object_unref); - g_signal_connect (dialog, "response", G_CALLBACK (emfu_delete_response), NULL); - gtk_widget_show (dialog); + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { + DeleteFolderData *data; + + /* disable dialog until operation finishes */ + gtk_widget_set_sensitive (dialog, FALSE); + + data = g_slice_new0 (DeleteFolderData); + data->backend = g_object_ref (backend); + data->dialog = dialog; + + mail_remove_folder (folder, emfu_delete_done, data); + } else + gtk_widget_destroy (dialog); } struct _EMCreateFolder { @@ -681,9 +704,6 @@ emfu_popup_new_folder_response (EMFolderSelector *emfs, if (CAMEL_IS_VEE_STORE (store)) { EFilterRule *rule; - /* ensures vfolder is running */ - vfolder_load_storage (session); - rule = em_vfolder_rule_new (session); e_filter_rule_set_name (rule, path); vfolder_gui_add_rule (EM_VFOLDER_RULE (rule)); diff --git a/mail/em-folder-utils.h b/mail/em-folder-utils.h index a6a2a21da0..f67ef50531 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 <mail/e-mail-backend.h> #include <mail/em-folder-tree.h> G_BEGIN_DECLS @@ -41,10 +41,11 @@ gint em_folder_utils_copy_folders (CamelStore *fromstore, * most rely on the wrong data. */ void em_folder_utils_copy_folder (GtkWindow *parent, - EMailSession *session, + EMailBackend *backend, CamelFolderInfo *folderinfo, gboolean delete); -void em_folder_utils_delete_folder (CamelFolder *folder); +void em_folder_utils_delete_folder (EMailBackend *backend, + CamelFolder *folder); void em_folder_utils_create_folder (CamelFolderInfo *folderinfo, EMFolderTree *emft, GtkWindow *parent); diff --git a/mail/em-utils.c b/mail/em-utils.c index 9f1f82ec50..dab327a20e 100644 --- a/mail/em-utils.c +++ b/mail/em-utils.c @@ -64,7 +64,6 @@ #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-activity.h" #include "e-util/e-alert-dialog.h" #include "shell/e-shell.h" #include "widgets/misc/e-attachment.h" @@ -265,7 +264,7 @@ static EMFilterSource em_filter_source_element_names[] = { /** * em_utils_edit_filters: * @parent: parent window - * @session: an #EMailSession + * @backend: an #EMailBAckend * * Opens or raises the filters editor dialog so that the user may edit * his/her filters. If @parent is non-NULL, then the dialog will be @@ -273,13 +272,14 @@ static EMFilterSource em_filter_source_element_names[] = { **/ void em_utils_edit_filters (GtkWidget *parent, - EMailSession *session) + EMailBackend *backend) { const gchar *config_dir; gchar *user, *system; EMFilterContext *fc; + EMailSession *session; - g_return_if_fail (E_IS_MAIL_SESSION (session)); + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); if (filter_editor) { gtk_window_present (GTK_WINDOW (filter_editor)); @@ -287,6 +287,7 @@ em_utils_edit_filters (GtkWidget *parent, } config_dir = mail_session_get_config_dir (); + session = e_mail_backend_get_session (backend); fc = em_filter_context_new (session); user = g_build_filename (config_dir, "filters.xml", NULL); @@ -296,8 +297,9 @@ em_utils_edit_filters (GtkWidget *parent, g_free (system); if (((ERuleContext *) fc)->error) { - GtkWidget *w = e_alert_dialog_new_for_args ((GtkWindow *)parent, "mail:filter-load-error", ((ERuleContext *)fc)->error, NULL); - em_utils_show_error_silent (w); + e_mail_backend_submit_alert ( + backend, "mail:filter-load-error", + ((ERuleContext *)fc)->error, NULL); return; } @@ -2025,48 +2027,6 @@ em_utils_clear_get_password_canceled_accounts_flag (void) } } -void -em_utils_show_error_silent (GtkWidget *widget) -{ - EShell *shell; - EShellBackend *shell_backend; - EActivity *activity; - - shell = e_shell_get_default (); - shell_backend = e_shell_get_backend_by_name ( - shell, shell_builtin_backend); - - activity = e_alert_activity_new_warning (widget); - e_shell_backend_add_activity (shell_backend, activity); - g_object_unref (activity); - - if (g_object_get_data (G_OBJECT (widget), "response-handled") == NULL) - g_signal_connect ( - widget, "response", - G_CALLBACK (gtk_widget_destroy), NULL); -} - -void -em_utils_show_info_silent (GtkWidget *widget) -{ - EShell *shell; - EShellBackend *shell_backend; - EActivity *activity; - - shell = e_shell_get_default (); - shell_backend = e_shell_get_backend_by_name ( - shell, shell_builtin_backend); - - activity = e_alert_activity_new_info (widget); - e_shell_backend_add_activity (shell_backend, activity); - g_object_unref (activity); - - if (g_object_get_data (G_OBJECT (widget), "response-handled") == NULL) - g_signal_connect ( - widget, "response", - G_CALLBACK (gtk_widget_destroy), NULL); -} - gchar * em_utils_url_unescape_amp (const gchar *url) { diff --git a/mail/em-utils.h b/mail/em-utils.h index 684d43c0e1..2229d26653 100644 --- a/mail/em-utils.h +++ b/mail/em-utils.h @@ -43,7 +43,7 @@ void em_utils_uids_free (GPtrArray *uids); gboolean em_utils_check_user_can_send_mail (void); -void em_utils_edit_filters (GtkWidget *parent, EMailSession *session); +void em_utils_edit_filters (GtkWidget *parent, EMailBackend *backend); void em_filename_make_safe (gchar *string); void em_utils_edit_vfolders (GtkWidget *parent); @@ -82,10 +82,6 @@ gchar *em_utils_folder_name_from_uri (const gchar *uri); gchar *em_uri_from_camel (const gchar *curi); gchar *em_uri_to_camel (const gchar *euri); -/* Run errors silently on the status bar */ -void em_utils_show_error_silent (GtkWidget *widget); -void em_utils_show_info_silent (GtkWidget *widget); - /* 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); diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c index 566369a3b5..aac7deb49a 100644 --- a/mail/mail-autofilter.c +++ b/mail/mail-autofilter.c @@ -385,12 +385,13 @@ filter_gui_add_from_message (EMailSession *session, } void -mail_filter_rename_uri (EMailSession *session, +mail_filter_rename_uri (EMailBackend *backend, CamelStore *store, const gchar *olduri, const gchar *newuri) { EMFilterContext *fc; + EMailSession *session; const gchar *config_dir; gchar *user, *system; GList *changed; @@ -399,6 +400,8 @@ mail_filter_rename_uri (EMailSession *session, eolduri = em_uri_from_camel (olduri); enewuri = em_uri_from_camel (newuri); + session = e_mail_backend_get_session (backend); + fc = em_filter_context_new (session); config_dir = mail_session_get_config_dir (); user = g_build_filename (config_dir, "filters.xml", NULL); @@ -422,11 +425,12 @@ mail_filter_rename_uri (EMailSession *session, } void -mail_filter_delete_uri (EMailSession *session, +mail_filter_delete_uri (EMailBackend *backend, CamelStore *store, const gchar *uri) { EMFilterContext *fc; + EMailSession *session; const gchar *config_dir; gchar *user, *system; GList *deleted; @@ -434,6 +438,8 @@ mail_filter_delete_uri (EMailSession *session, euri = em_uri_from_camel (uri); + session = e_mail_backend_get_session (backend); + fc = em_filter_context_new (session); config_dir = mail_session_get_config_dir (); user = g_build_filename (config_dir, "filters.xml", NULL); @@ -443,7 +449,6 @@ mail_filter_delete_uri (EMailSession *session, deleted = e_rule_context_delete_uri ((ERuleContext *) fc, euri, g_str_equal); if (deleted) { - GtkWidget *dialog; GString *s; guint s_count; gchar *info; @@ -477,8 +482,8 @@ mail_filter_delete_uri (EMailSession *session, "The following filter rules\n%s have been modified " "to account for the deleted folder\n\"%s\".", s_count), s->str, euri); - dialog = e_alert_dialog_new_for_args (e_shell_get_active_window (NULL), "mail:filter-updated", info, NULL); - em_utils_show_info_silent (dialog); + e_mail_backend_submit_alert ( + backend, "mail:filter-updated", info, NULL); g_string_free (s, TRUE); g_free (info); diff --git a/mail/mail-autofilter.h b/mail/mail-autofilter.h index 35e5c3aac1..7967023b20 100644 --- a/mail/mail-autofilter.h +++ b/mail/mail-autofilter.h @@ -27,6 +27,7 @@ #include <camel/camel.h> #include <filter/e-filter-rule.h> +#include <mail/e-mail-backend.h> #include <mail/em-filter-context.h> #include <mail/em-vfolder-context.h> @@ -57,11 +58,11 @@ void filter_gui_add_from_message (EMailSession *session, /* Also easiest place for these, we should really * share a global rule context for this stuff ... */ -void mail_filter_rename_uri (EMailSession *session, +void mail_filter_rename_uri (EMailBackend *backend, CamelStore *store, const gchar *olduri, const gchar *newuri); -void mail_filter_delete_uri (EMailSession *session, +void mail_filter_delete_uri (EMailBackend *backend, CamelStore *store, const gchar *uri); diff --git a/mail/mail-config.c b/mail/mail-config.c index fae6bda204..5bd85ac23d 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -38,7 +38,6 @@ #include <gconf/gconf-client.h> #include "e-mail-local.h" -#include "e-mail-session.h" #include "mail-config.h" #include "mail-folder-cache.h" #include "mail-tools.h" @@ -150,7 +149,7 @@ static void gconf_jh_headers_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, - CamelSession *session) + EMailSession *session) { GSList *node; GPtrArray *name, *value; @@ -171,7 +170,8 @@ gconf_jh_headers_changed (GConfClient *client, g_strfreev (tok); } camel_session_set_junk_headers ( - session, (const gchar **) name->pdata, + CAMEL_SESSION (session), + (const gchar **) name->pdata, (const gchar **) value->pdata, name->len); g_ptr_array_foreach (name, (GFunc) g_free, NULL); @@ -184,12 +184,13 @@ static void gconf_jh_check_changed (GConfClient *client, guint cnxn_id, GConfEntry *entry, - CamelSession *session) + EMailSession *session) { config->jh_check = gconf_client_get_bool ( config->gconf, "/apps/evolution/mail/junk/check_custom_header", NULL); if (!config->jh_check) { - camel_session_set_junk_headers (session, NULL, NULL, 0); + camel_session_set_junk_headers ( + CAMEL_SESSION (session), NULL, NULL, 0); } else { gconf_jh_headers_changed (NULL, 0, NULL, session); } @@ -539,9 +540,9 @@ mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix) } void -mail_config_reload_junk_headers (CamelSession *session) +mail_config_reload_junk_headers (EMailSession *session) { - g_return_if_fail (CAMEL_IS_SESSION (session)); + g_return_if_fail (E_IS_MAIL_SESSION (session)); /* It automatically sets in the session */ if (config == NULL) @@ -582,12 +583,13 @@ folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *oldur /* Config struct routines */ void -mail_config_init (CamelSession *session) +mail_config_init (EMailSession *session) { GConfClientNotifyFunc func; + MailFolderCache *folder_cache; const gchar *key; - g_return_if_fail (CAMEL_IS_SESSION (session)); + g_return_if_fail (E_IS_MAIL_SESSION (session)); if (config) return; @@ -708,8 +710,12 @@ mail_config_init (CamelSession *session) gconf_jh_check_changed (config->gconf, 0, NULL, session); - g_signal_connect (mail_folder_cache_get_default (), "folder-deleted", - (GCallback) folder_deleted_cb, NULL); - g_signal_connect (mail_folder_cache_get_default (), "folder-renamed", - (GCallback) folder_renamed_cb, NULL); + folder_cache = e_mail_session_get_folder_cache (session); + + g_signal_connect ( + folder_cache, "folder-deleted", + (GCallback) folder_deleted_cb, NULL); + g_signal_connect ( + folder_cache, "folder-renamed", + (GCallback) folder_renamed_cb, NULL); } diff --git a/mail/mail-config.h b/mail/mail-config.h index 7fbdaeeda9..8bd87c56b4 100644 --- a/mail/mail-config.h +++ b/mail/mail-config.h @@ -24,13 +24,14 @@ #define MAIL_CONFIG_H #include <gtk/gtk.h> -#include <camel/camel.h> #include <libedataserver/e-account.h> #include <libedataserver/e-account-list.h> #include <e-util/e-signature.h> #include <e-util/e-signature-list.h> +#include <mail/e-mail-session.h> + G_BEGIN_DECLS typedef enum { @@ -62,7 +63,7 @@ typedef enum { GType evolution_mail_config_get_type (void); /* Configuration */ -void mail_config_init (CamelSession *session); +void mail_config_init (EMailSession *session); void mail_config_write (void); GConfClient * mail_config_get_gconf_client (void); @@ -89,7 +90,7 @@ gchar * mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix); gint mail_config_get_sync_timeout (void); -void mail_config_reload_junk_headers (CamelSession *session); +void mail_config_reload_junk_headers (EMailSession *session); gboolean mail_config_get_lookup_book (void); gboolean mail_config_get_lookup_book_local_only (void); diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index 7ff29c3414..0cbcea511a 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -730,7 +730,7 @@ struct _update_data { gint id; /* id for cancellation */ guint cancel:1; /* also tells us we're cancelled */ - gboolean (*done)(CamelStore *store, CamelFolderInfo *info, gpointer data); + NoteDoneFunc done; gpointer data; MailFolderCache *cache; }; @@ -770,7 +770,7 @@ update_folders (CamelStore *store, CamelFolderInfo *fi, gpointer data) g_mutex_unlock (ud->cache->priv->stores_mutex); if (ud->done) - res = ud->done (store, fi, ud->data); + res = ud->done (ud->cache, store, fi, ud->data); g_free (ud); return res; @@ -1065,23 +1065,10 @@ mail_folder_cache_init (MailFolderCache *self) timeout, (GSourceFunc) ping_cb, self); } -static MailFolderCache *default_cache = NULL; -G_LOCK_DEFINE_STATIC (default_cache); - -/** - * mail_folder_cache_get_default: - * - * Get the default folder cache object - */ MailFolderCache * -mail_folder_cache_get_default (void) +mail_folder_cache_new (void) { - G_LOCK (default_cache); - if (!default_cache) - default_cache = g_object_new (MAIL_TYPE_FOLDER_CACHE, NULL); - G_UNLOCK (default_cache); - - return default_cache; + return g_object_new (MAIL_TYPE_FOLDER_CACHE, NULL); } /** diff --git a/mail/mail-folder-cache.h b/mail/mail-folder-cache.h index 170592390d..f89d2d9aed 100644 --- a/mail/mail-folder-cache.h +++ b/mail/mail-folder-cache.h @@ -59,7 +59,8 @@ typedef struct _MailFolderCachePrivate MailFolderCachePrivate; * The signature of a function to be registered as a callback for * mail_folder_cache_note_store() */ -typedef gboolean (*NoteDoneFunc) (CamelStore *store, +typedef gboolean (*NoteDoneFunc) (MailFolderCache *cache, + CamelStore *store, CamelFolderInfo *info, gpointer data); @@ -80,7 +81,7 @@ struct _MailFolderCacheClass { GType mail_folder_cache_get_type (void) G_GNUC_CONST; MailFolderCache * - mail_folder_cache_get_default (void); + mail_folder_cache_new (void); void mail_folder_cache_note_store (MailFolderCache *self, CamelSession *session, CamelStore *store, diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 9cac82841d..907d57938a 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -27,9 +27,7 @@ #include <libedataserver/e-flag.h> -#include "shell/e-shell.h" -#include "e-util/e-alert-activity.h" -#include "e-util/e-alert-dialog.h" +#include <shell/e-shell-view.h> #include "mail-mt.h" @@ -43,8 +41,6 @@ const gchar *shell_builtin_backend = "mail"; /* background operation status stuff */ struct _MailMsgPrivate { EActivity *activity; - GtkWidget *error; - gboolean cancelable; }; static guint mail_msg_seq; /* sequence number of each message */ @@ -91,7 +87,6 @@ mail_msg_new (MailMsgInfo *info) msg->priv = g_slice_new0 (MailMsgPrivate); msg->priv->activity = e_activity_new (); - msg->priv->cancelable = TRUE; e_activity_set_percent (msg->priv->activity, 0.0); @@ -161,16 +156,6 @@ mail_msg_free (MailMsg *mail_msg) if (mail_msg->error != NULL) g_error_free (mail_msg->error); - if (mail_msg->priv->error != NULL) { - EActivity *activity; - GtkWidget *widget; - - widget = mail_msg->priv->error; - activity = e_alert_activity_new_warning (widget); - e_shell_backend_add_activity (shell_backend, activity); - g_object_unref (activity); - } - g_slice_free (MailMsgPrivate, mail_msg->priv); g_slice_free1 (mail_msg->info->size, mail_msg); @@ -224,28 +209,16 @@ mail_msg_unref (gpointer msg) g_idle_add ((GSourceFunc) mail_msg_free, mail_msg); } -/* hash table of ops->dialogue of active errors */ -static GHashTable *active_errors = NULL; - -static void -error_finalized (gpointer data, GObject *gone_gd) -{ - g_hash_table_remove (active_errors, data); -} - -static void -error_response (GtkWidget *dialog, gint button, gpointer data) -{ - gtk_widget_destroy (dialog); -} - void mail_msg_check_error (gpointer msg) { - GtkWindow *parent; + EShell *shell; + EShellView *shell_view; + EShellWindow *shell_window = NULL; + EShellContent *shell_content; MailMsg *m = msg; gchar *what; - GtkDialog *gd; + GList *list, *iter; #ifdef MALLOC_CHECK checkmem (m); @@ -258,40 +231,37 @@ mail_msg_check_error (gpointer msg) || g_error_matches (m->error, CAMEL_FOLDER_ERROR, CAMEL_FOLDER_ERROR_INVALID_UID)) return; - if (active_errors == NULL) - active_errors = g_hash_table_new (NULL, NULL); + shell = e_shell_get_default (); - /* check to see if we have dialogue already running for this operation */ - /* we key on the operation pointer, which is at least accurate enough - for the operation type, although it could be on a different object. */ - if (g_hash_table_lookup (active_errors, m->info)) { - g_message ( - "Error occurred while existing dialogue active:\n%s", - m->error->message); - return; + /* Find the most recently used EShellWindow. */ + list = e_shell_get_watched_windows (shell); + 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; + } } - parent = e_shell_get_active_window (NULL); + /* 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))) { - gd = (GtkDialog *) e_alert_dialog_new_for_args ( - parent, "mail:async-error", what, + e_alert_submit ( + GTK_WIDGET (shell_content), + "mail:async-error", what, m->error->message, NULL); g_free (what); } else - gd = (GtkDialog *) e_alert_dialog_new_for_args ( - parent, "mail:async-error-nodescribe", + e_alert_submit ( + GTK_WIDGET (shell_content), + "mail:async-error-nodescribe", m->error->message, NULL); - - g_hash_table_insert (active_errors, m->info, gd); - g_signal_connect(gd, "response", G_CALLBACK(error_response), m->info); - g_object_weak_ref (G_OBJECT (gd), error_finalized, m->info); - if (m->priv->cancelable) - m->priv->error = (GtkWidget *) gd; - else - gtk_widget_show ((GtkWidget *)gd); - } void @@ -379,14 +349,6 @@ mail_cancel_all (void) g_mutex_unlock (mail_msg_lock); } -void -mail_msg_set_cancelable (gpointer msg, gboolean status) -{ - MailMsg *mail_msg = msg; - - mail_msg->priv->cancelable = status; -} - static guint idle_source_id = 0; G_LOCK_DEFINE_STATIC (idle_source_id); static GAsyncQueue *main_loop_queue = NULL; diff --git a/mail/mail-mt.h b/mail/mail-mt.h index e925946f0a..122519162b 100644 --- a/mail/mail-mt.h +++ b/mail/mail-mt.h @@ -76,7 +76,6 @@ void mail_msg_slow_ordered_push (gpointer msg); GHook * mail_cancel_hook_add (GHookFunc func, gpointer data); void mail_cancel_hook_remove (GHook *hook); void mail_cancel_all (void); -void mail_msg_set_cancelable (gpointer msg, gboolean status); /* request a string/password */ gchar *mail_get_password (CamelService *service, const gchar *prompt, diff --git a/mail/mail-ops.c b/mail/mail-ops.c index d0db1c8ba8..97a72aade0 100644 --- a/mail/mail-ops.c +++ b/mail/mail-ops.c @@ -906,7 +906,6 @@ mail_send_queue (EMailSession *session, if (G_IS_CANCELLABLE (cancellable)) { m->cancellable = g_object_ref (cancellable); g_object_unref (m->base.cancellable); - mail_msg_set_cancelable (m, FALSE); m->base.cancellable = NULL; } m->status = status; diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index c2584cf53a..e2c70861b6 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -961,7 +961,10 @@ static MailMsgInfo refresh_folders_info = { }; static gboolean -receive_update_got_folderinfo (CamelStore *store, CamelFolderInfo *info, gpointer data) +receive_update_got_folderinfo (MailFolderCache *folder_cache, + CamelStore *store, + CamelFolderInfo *info, + gpointer data) { if (info) { GPtrArray *folders = g_ptr_array_new (); @@ -989,11 +992,14 @@ receive_update_got_folderinfo (CamelStore *store, CamelFolderInfo *info, gpointe static void receive_update_got_store (gchar *uri, CamelStore *store, gpointer data) { + MailFolderCache *folder_cache; struct _send_info *info = data; + folder_cache = e_mail_session_get_folder_cache (info->session); + if (store) { mail_folder_cache_note_store ( - mail_folder_cache_get_default (), + folder_cache, CAMEL_SESSION (info->session), store, info->cancellable, receive_update_got_folderinfo, info); diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c index 0d8f127b2b..dbca145c0d 100644 --- a/mail/mail-vfolder.c +++ b/mail/mail-vfolder.c @@ -248,17 +248,19 @@ vfolder_adduri_exec (struct _adduri_msg *m) { GList *l; CamelFolder *folder = NULL; + MailFolderCache *folder_cache; if (vfolder_shutdown) return; d(printf("%s uri to vfolder: %s\n", m->remove?"Removing":"Adding", m->uri)); + folder_cache = e_mail_session_get_folder_cache (m->session); + /* we dont try lookup the cache if we are removing it, its no longer there */ if (!m->remove && - !mail_folder_cache_get_folder_from_uri (mail_folder_cache_get_default (), - m->uri, &folder)) { + !mail_folder_cache_get_folder_from_uri (folder_cache, m->uri, &folder)) { g_warning("Folder '%s' disappeared while I was adding/remove it to/from my vfolder", m->uri); return; } @@ -591,7 +593,7 @@ mail_vfolder_notify_uri_unavailable (EMailSession *session, /** * mail_vfolder_delete_uri: - * + * @backend: an #EMailBackend * @store: a #CamelStore containing the uri * @curi: an email uri that has been deleted * @@ -607,7 +609,9 @@ mail_vfolder_notify_uri_unavailable (EMailSession *session, * NOTE: This function must be called from the main thread. */ static void -mail_vfolder_delete_uri (CamelStore *store, const gchar *curi) +mail_vfolder_delete_uri (EMailBackend *backend, + CamelStore *store, + const gchar *curi) { EFilterRule *rule; const gchar *source; @@ -617,6 +621,10 @@ mail_vfolder_delete_uri (CamelStore *store, const gchar *curi) gchar *uri; GList *link; + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (CAMEL_IS_STORE (store)); + g_return_if_fail (curi != NULL); + if (uri_is_spethal (store, curi)) return; @@ -689,7 +697,6 @@ done: G_UNLOCK (vfolder); if (changed_count > 0) { - GtkWidget *dialog; const gchar *config_dir; gchar *user, *info; @@ -704,8 +711,8 @@ done: "The following Search Folders\n%s have been modified " "to account for the deleted folder\n\"%s\".", changed_count), changed->str, uri); - dialog = e_alert_dialog_new_for_args (e_shell_get_active_window (NULL), "mail:vfolder-updated", info, NULL); - em_utils_show_info_silent (dialog); + e_mail_backend_submit_alert ( + backend, "mail:vfolder-updated", info, NULL); g_free (info); config_dir = mail_session_get_config_dir (); @@ -803,17 +810,23 @@ mail_vfolder_get_sources_remote (void) static void context_rule_added (ERuleContext *ctx, EFilterRule *rule); static void -rule_add_sources (GList *l, GList **sources_folderp, GList **sources_urip) +rule_add_sources (EMailSession *session, + GList *l, + GList **sources_folderp, + GList **sources_urip) { GList *sources_folder = *sources_folderp; GList *sources_uri = *sources_urip; + MailFolderCache *folder_cache; CamelFolder *newfolder; + folder_cache = e_mail_session_get_folder_cache (session); + while (l) { gchar *curi = em_uri_to_camel (l->data); - if (mail_folder_cache_get_folder_from_uri - (mail_folder_cache_get_default (), curi, &newfolder)) { + if (mail_folder_cache_get_folder_from_uri ( + folder_cache, curi, &newfolder)) { if (newfolder) sources_folder = g_list_append (sources_folder, newfolder); else @@ -836,6 +849,7 @@ rule_changed (EFilterRule *rule, CamelFolder *folder) const gchar *full_name; full_name = camel_folder_get_full_name (folder); + session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule)); /* if the folder has changed name, then add it, then remove the old manually */ if (strcmp (full_name, rule->name) != 0) { @@ -866,19 +880,24 @@ rule_changed (EFilterRule *rule, CamelFolder *folder) d(printf("Filter rule changed? for folder '%s'!!\n", folder->name)); /* find any (currently available) folders, and add them to the ones to open */ - rule_add_sources (((EMVFolderRule *)rule)->sources, &sources_folder, &sources_uri); + rule_add_sources ( + session, ((EMVFolderRule *)rule)->sources, + &sources_folder, &sources_uri); G_LOCK (vfolder); if (((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_LOCAL || ((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE) - rule_add_sources (source_folders_local, &sources_folder, &sources_uri); + rule_add_sources ( + session, source_folders_local, + &sources_folder, &sources_uri); if (((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_REMOTE_ACTIVE || ((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE) - rule_add_sources (source_folders_remote, &sources_folder, &sources_uri); + rule_add_sources ( + session, source_folders_remote, + &sources_folder, &sources_uri); G_UNLOCK (vfolder); query = g_string_new(""); e_filter_rule_build_code (rule, query); - session = em_vfolder_rule_get_session (EM_VFOLDER_RULE (rule)); vfolder_setup (session, folder, query->str, sources_uri, sources_folder); g_string_free (query, TRUE); @@ -1036,9 +1055,12 @@ folder_unavailable_cb (MailFolderCache *cache, } static void -folder_deleted_cb (MailFolderCache *cache, CamelStore *store, const gchar *uri, gpointer user_data) +folder_deleted_cb (MailFolderCache *cache, + CamelStore *store, + const gchar *uri, + EMailBackend *backend) { - mail_vfolder_delete_uri (store, uri); + mail_vfolder_delete_uri (backend, store, uri); } static void @@ -1048,7 +1070,7 @@ folder_renamed_cb (MailFolderCache *cache, CamelStore *store, const gchar *oldur } void -vfolder_load_storage (EMailSession *session) +vfolder_load_storage (EMailBackend *backend) { /* lock for loading storage, it is safe to call it more than once */ G_LOCK_DEFINE_STATIC (vfolder_hash); @@ -1057,9 +1079,13 @@ vfolder_load_storage (EMailSession *session) const gchar *config_dir; gchar *user, *storeuri; EFilterRule *rule; + MailFolderCache *folder_cache; + EMailSession *session; gchar *xmlfile; GConfClient *gconf; + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + G_LOCK (vfolder_hash); if (vfolder_hash) { @@ -1074,6 +1100,7 @@ vfolder_load_storage (EMailSession *session) data_dir = mail_session_get_data_dir (); config_dir = mail_session_get_config_dir (); + session = e_mail_backend_get_session (backend); /* first, create the vfolder store, and set it up */ storeuri = g_strdup_printf("vfolder:%s/vfolder", data_dir); @@ -1086,7 +1113,7 @@ vfolder_load_storage (EMailSession *session) g_signal_connect ( vfolder_store, "folder-deleted", - G_CALLBACK (store_folder_deleted_cb), NULL); + G_CALLBACK (store_folder_deleted_cb), backend); g_signal_connect ( vfolder_store, "folder-renamed", @@ -1130,17 +1157,19 @@ vfolder_load_storage (EMailSession *session) if (!gconf_client_get_bool (gconf, "/apps/evolution/mail/display/enable_vfolders", NULL)) gconf_client_set_bool (gconf, "/apps/evolution/mail/display/enable_vfolders", TRUE, NULL); + folder_cache = e_mail_session_get_folder_cache (session); + g_signal_connect ( - mail_folder_cache_get_default (), "folder-available", + folder_cache, "folder-available", G_CALLBACK (folder_available_cb), session); g_signal_connect ( - mail_folder_cache_get_default (), "folder-unavailable", + folder_cache, "folder-unavailable", G_CALLBACK (folder_unavailable_cb), session); g_signal_connect ( - mail_folder_cache_get_default (), "folder-deleted", + folder_cache, "folder-deleted", G_CALLBACK (folder_deleted_cb), NULL); g_signal_connect ( - mail_folder_cache_get_default (), "folder-renamed", + folder_cache, "folder-renamed", G_CALLBACK (folder_renamed_cb), NULL); } @@ -1162,6 +1191,7 @@ vfolder_edit (EShellView *shell_view) { EShellBackend *shell_backend; EShellWindow *shell_window; + EMailBackend *backend; EMailSession *session; GtkWidget *dialog; const gchar *config_dir; @@ -1175,10 +1205,8 @@ vfolder_edit (EShellView *shell_view) config_dir = e_shell_backend_get_config_dir (shell_backend); filename = g_build_filename (config_dir, "vfolders.xml", NULL); - session = e_mail_backend_get_session (E_MAIL_BACKEND (shell_backend)); - - /* ensures vfolder is running */ - vfolder_load_storage (session); + backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); dialog = em_vfolder_editor_new (context); gtk_window_set_title ( @@ -1218,7 +1246,8 @@ edit_rule_response (GtkWidget *w, gint button, gpointer data) } void -vfolder_edit_rule (const gchar *uri) +vfolder_edit_rule (EMailBackend *backend, + const gchar *uri) { GtkWidget *w; GtkDialog *gd; @@ -1226,6 +1255,9 @@ vfolder_edit_rule (const gchar *uri) EFilterRule *rule, *newrule; CamelURL *url; + g_return_if_fail (E_IS_MAIL_BACKEND (backend)); + g_return_if_fail (uri != NULL); + url = camel_url_new (uri, NULL); if (url && url->fragment && (rule = e_rule_context_find_rule ((ERuleContext *)context, url->fragment, NULL))) { @@ -1255,11 +1287,9 @@ vfolder_edit_rule (const gchar *uri) g_signal_connect(gd, "response", G_CALLBACK(edit_rule_response), NULL); gtk_widget_show ((GtkWidget *)gd); } else { - GtkWidget *w; - /* TODO: we should probably just create it ... */ - w = e_alert_dialog_new_for_args (e_shell_get_active_window (NULL), "mail:vfolder-notexist", uri, NULL); - em_utils_show_error_silent (w); + e_mail_backend_submit_alert ( + backend, "mail:vfolder-notexist", uri, NULL); } if (url) @@ -1341,9 +1371,6 @@ vfolder_gui_add_rule (EMVFolderRule *rule) session = em_vfolder_rule_get_session (rule); - /* this should be done before we call this function */ - vfolder_load_storage (session); - w = e_filter_rule_get_widget ((EFilterRule *)rule, (ERuleContext *)context); gd = (GtkDialog *)gtk_dialog_new_with_buttons ( @@ -1380,9 +1407,6 @@ vfolder_gui_add_from_message (EMailSession *session, g_return_if_fail (msg != NULL); - /* ensures vfolder is running */ - vfolder_load_storage (session); - rule = (EMVFolderRule*)em_vfolder_rule_from_message (context, msg, flags, source); vfolder_gui_add_rule (rule); } @@ -1397,9 +1421,6 @@ vfolder_gui_add_from_address (EMailSession *session, g_return_if_fail (addr != NULL); - /* ensures vfolder is running */ - vfolder_load_storage (session); - rule = (EMVFolderRule*)em_vfolder_rule_from_address (context, addr, flags, source); vfolder_gui_add_rule (rule); } diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h index 187a68d294..19c4d524b4 100644 --- a/mail/mail-vfolder.h +++ b/mail/mail-vfolder.h @@ -26,13 +26,15 @@ #include <filter/e-filter-part.h> #include <filter/e-filter-rule.h> +#include <mail/e-mail-backend.h> #include <mail/em-vfolder-rule.h> #include <shell/e-shell-view.h> -void vfolder_load_storage (EMailSession *session); +void vfolder_load_storage (EMailBackend *backend); void vfolder_revert (void); void vfolder_edit (EShellView *shell_view); -void vfolder_edit_rule (const gchar *name); +void vfolder_edit_rule (EMailBackend *backend, + const gchar *name); EFilterPart * vfolder_create_part (const gchar *name); EFilterRule * vfolder_clone_rule (EFilterRule *in); void vfolder_gui_add_rule (EMVFolderRule *rule); diff --git a/modules/mail/e-mail-junk-hook.c b/modules/mail/e-mail-junk-hook.c index ac88f1ea4c..24c1ac77fc 100644 --- a/modules/mail/e-mail-junk-hook.c +++ b/modules/mail/e-mail-junk-hook.c @@ -28,6 +28,7 @@ #include "mail/em-junk.h" #include "mail/em-utils.h" +#include "mail/e-mail-backend.h" #include "mail/e-mail-session.h" #define E_MAIL_JUNK_HOOK_GET_PRIVATE(obj) \ @@ -49,11 +50,15 @@ static GType mail_junk_hook_type; static gboolean mail_junk_hook_idle_cb (struct ErrorData *data) { - GtkWidget *widget; + EShell *shell; + EShellBackend *shell_backend; + + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); - widget = e_alert_dialog_new_for_args (e_shell_get_active_window (NULL), + e_mail_backend_submit_alert ( + E_MAIL_BACKEND (shell_backend), data->error_message, data->error->message, NULL); - em_utils_show_error_silent (widget); g_error_free (data->error); g_slice_free (struct ErrorData, data); diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c index 36e4cbdfb3..73386911ec 100644 --- a/modules/mail/e-mail-shell-backend.c +++ b/modules/mail/e-mail-shell-backend.c @@ -526,7 +526,6 @@ mail_shell_backend_start (EShellBackend *shell_backend) EShell *shell; EShellSettings *shell_settings; EMailBackend *backend; - EMailSession *session; gboolean enable_search_folders; priv = E_MAIL_SHELL_BACKEND_GET_PRIVATE (shell_backend); @@ -535,12 +534,11 @@ mail_shell_backend_start (EShellBackend *shell_backend) shell_settings = e_shell_get_shell_settings (shell); backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); enable_search_folders = e_shell_settings_get_boolean ( shell_settings, "mail-enable-search-folders"); if (enable_search_folders) - vfolder_load_storage (session); + vfolder_load_storage (backend); mail_autoreceive_init (backend); diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c index fa083bf6f2..7548b5e54a 100644 --- a/modules/mail/e-mail-shell-view-actions.c +++ b/modules/mail/e-mail-shell-view-actions.c @@ -118,8 +118,6 @@ action_mail_create_search_folder_cb (GtkAction *action, mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); searchbar = e_mail_shell_content_get_searchbar (mail_shell_content); - vfolder_load_storage (session); - search_rule = e_shell_view_get_search_rule (shell_view); g_return_if_fail (search_rule != NULL); @@ -181,8 +179,6 @@ action_mail_folder_copy_cb (GtkAction *action, EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; - EMailBackend *backend; - EMailSession *session; CamelFolderInfo *folder_info; EMFolderTree *folder_tree; @@ -190,9 +186,6 @@ action_mail_folder_copy_cb (GtkAction *action, shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); folder_info = em_folder_tree_get_selected_folder_info (folder_tree); @@ -200,7 +193,9 @@ action_mail_folder_copy_cb (GtkAction *action, /* XXX Leaking folder_info? */ em_folder_utils_copy_folder ( - GTK_WINDOW (shell_window), session, folder_info, FALSE); + GTK_WINDOW (shell_window), + E_MAIL_BACKEND (shell_backend), + folder_info, FALSE); } static void @@ -208,15 +203,21 @@ action_mail_folder_delete_cb (GtkAction *action, EMailShellView *mail_shell_view) { EMailShellSidebar *mail_shell_sidebar; + EShellBackend *shell_backend; + EShellView *shell_view; EMFolderTree *folder_tree; CamelFolder *folder; + shell_view = E_SHELL_VIEW (mail_shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); + mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); folder = em_folder_tree_get_selected_folder (folder_tree); g_return_if_fail (folder != NULL); - em_folder_utils_delete_folder (folder); + em_folder_utils_delete_folder ( + E_MAIL_BACKEND (shell_backend), folder); } static void @@ -255,11 +256,14 @@ action_mail_folder_mark_all_as_read_cb (GtkAction *action, { EShellView *shell_view; EShellWindow *shell_window; + EShellBackend *shell_backend; EMailShellContent *mail_shell_content; EMailReader *reader; EMailView *mail_view; CamelFolder *folder; GtkWindow *parent; + EMailBackend *backend; + EMailSession *session; MailFolderCache *cache; GtkWidget *message_list; GPtrArray *uids; @@ -269,6 +273,7 @@ action_mail_folder_mark_all_as_read_cb (GtkAction *action, shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); + shell_backend = e_shell_view_get_shell_backend (shell_view); parent = GTK_WINDOW (shell_window); mail_shell_content = mail_shell_view->priv->mail_shell_content; @@ -279,8 +284,11 @@ action_mail_folder_mark_all_as_read_cb (GtkAction *action, folder = e_mail_reader_get_folder (reader); g_return_if_fail (folder != NULL); - cache = mail_folder_cache_get_default (); + backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); + cache = e_mail_session_get_folder_cache (session); key = "/apps/evolution/mail/prompts/mark_all_read"; + if (mail_folder_cache_get_folder_has_children (cache, folder, NULL)) prompt = "mail:ask-mark-all-read-sub"; else @@ -312,8 +320,6 @@ action_mail_folder_move_cb (GtkAction *action, EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; - EMailBackend *backend; - EMailSession *session; CamelFolderInfo *folder_info; EMFolderTree *folder_tree; @@ -321,9 +327,6 @@ action_mail_folder_move_cb (GtkAction *action, shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); folder_info = em_folder_tree_get_selected_folder_info (folder_tree); @@ -331,7 +334,9 @@ action_mail_folder_move_cb (GtkAction *action, /* XXX Leaking folder_info? */ em_folder_utils_copy_folder ( - GTK_WINDOW (shell_window), session, folder_info, TRUE); + GTK_WINDOW (shell_window), + E_MAIL_BACKEND (shell_backend), + folder_info, TRUE); } static void @@ -1017,17 +1022,14 @@ action_mail_tools_filters_cb (GtkAction *action, EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; - EMailBackend *backend; - EMailSession *session; shell_view = E_SHELL_VIEW (mail_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); - backend = E_MAIL_BACKEND (shell_backend); - session = e_mail_backend_get_session (backend); - - em_utils_edit_filters (GTK_WIDGET (shell_window), session); + em_utils_edit_filters ( + GTK_WIDGET (shell_window), + E_MAIL_BACKEND (shell_backend)); } static void diff --git a/plugins/groupwise-features/share-folder-common.c b/plugins/groupwise-features/share-folder-common.c index adb373d6c6..10b0c4c622 100644 --- a/plugins/groupwise-features/share-folder-common.c +++ b/plugins/groupwise-features/share-folder-common.c @@ -273,9 +273,6 @@ users_dialog_response (GtkWidget *dialog, gint response, struct ShareInfo *ssi) if (CAMEL_IS_VEE_STORE (store)) { EFilterRule *rule; - /* ensures vfolder is running */ - vfolder_load_storage (session); - rule = em_vfolder_rule_new (session); e_filter_rule_set_name (rule, path); vfolder_gui_add_rule (EM_VFOLDER_RULE (rule)); diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c index 2c52241c54..d8ff9b95f6 100644 --- a/plugins/itip-formatter/itip-formatter.c +++ b/plugins/itip-formatter/itip-formatter.c @@ -2236,6 +2236,11 @@ check_is_instance (icalcomponent *icalcomp) static gboolean in_proper_folder (CamelFolder *folder) { + EShell *shell; + EShellBackend *shell_backend; + EMailBackend *backend; + EMailSession *session; + MailFolderCache *folder_cache; const gchar *folder_uri; gboolean res = TRUE; gint flags = 0; @@ -2243,10 +2248,15 @@ in_proper_folder (CamelFolder *folder) if (!folder) return FALSE; + shell = e_shell_get_default (); + shell_backend = e_shell_get_backend_by_name (shell, "mail"); + backend = E_MAIL_BACKEND (shell_backend); + session = e_mail_backend_get_session (backend); + folder_cache = e_mail_session_get_folder_cache (session); + folder_uri = camel_folder_get_uri (folder); - if (mail_folder_cache_get_folder_info_flags (mail_folder_cache_get_default (), - folder, &flags)) { + if (mail_folder_cache_get_folder_info_flags (folder_cache, folder, &flags)) { /* it should be neither trash nor junk folder, */ res = ((flags & CAMEL_FOLDER_TYPE_TRASH) != CAMEL_FOLDER_TYPE_TRASH && (flags & CAMEL_FOLDER_TYPE_JUNK) != CAMEL_FOLDER_TYPE_JUNK && diff --git a/po/POTFILES.in b/po/POTFILES.in index 852a27961f..7c937946d5 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -153,10 +153,7 @@ e-util/e-charset.c e-util/e-datetime-format.c e-util/e-dialog-utils.c e-util/e-file-utils.c -e-util/e-logger.c e-util/e-module.c -e-util/e-non-intrusive-error-dialog.c -e-util/e-non-intrusive-error-dialog.h e-util/e-plugin.c e-util/e-plugin-util.c e-util/e-print.c diff --git a/widgets/misc/e-alert-bar.c b/widgets/misc/e-alert-bar.c index 6e81bece1f..cae1bc0172 100644 --- a/widgets/misc/e-alert-bar.c +++ b/widgets/misc/e-alert-bar.c @@ -21,8 +21,6 @@ #include <config.h> #include <glib/gi18n-lib.h> -#include "e-util/e-alert-action.h" - #define E_ALERT_BAR_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_ALERT_BAR, EAlertBarPrivate)) |