aboutsummaryrefslogtreecommitdiffstats
path: root/libemail-engine
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2012-07-16 05:17:11 +0800
committerMatthew Barnes <mbarnes@redhat.com>2012-07-16 06:19:39 +0800
commitd88c38abebb672977729735513135da8b47409d4 (patch)
treeb3fc09637ee26727fa8c85a4a8b1da582ae64795 /libemail-engine
parentfcca366ecce1ffddaf6a280e248456127def1b4d (diff)
downloadgsoc2013-evolution-d88c38abebb672977729735513135da8b47409d4.tar
gsoc2013-evolution-d88c38abebb672977729735513135da8b47409d4.tar.gz
gsoc2013-evolution-d88c38abebb672977729735513135da8b47409d4.tar.bz2
gsoc2013-evolution-d88c38abebb672977729735513135da8b47409d4.tar.lz
gsoc2013-evolution-d88c38abebb672977729735513135da8b47409d4.tar.xz
gsoc2013-evolution-d88c38abebb672977729735513135da8b47409d4.tar.zst
gsoc2013-evolution-d88c38abebb672977729735513135da8b47409d4.zip
Rework handling of GOA mail.
Disabling the mail part of an online account through the Control Center panel will now remove the CamelService from the EMailSession in addition to disabling the account/identity/transport ESources, causing it to be delisted from the account list in Preferences. Furthermore, hide the Enabled check box for accounts linked to GOA in Preferences. The collection ESource for these accounts can no longer be disabled through Evolution; all such account manipulation must be done through the Control Center panel. Lastly, display an icon next to accounts linked to GOA in Preferences. * Might be nice to show the actual provider icon instead of the generic Online Accounts icon from the Control Center, but need to think about how best to do that. Don't want a GOA dependency in core Evolution. Maybe ESourceCollection should grow a GIcon property for the online- accounts module in the registry service to set?
Diffstat (limited to 'libemail-engine')
-rw-r--r--libemail-engine/e-mail-session.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/libemail-engine/e-mail-session.c b/libemail-engine/e-mail-session.c
index 0b4ab58818..84ac60a736 100644
--- a/libemail-engine/e-mail-session.c
+++ b/libemail-engine/e-mail-session.c
@@ -74,6 +74,8 @@ struct _EMailSessionPrivate {
gulong source_added_handler_id;
gulong source_removed_handler_id;
+ gulong source_enabled_handler_id;
+ gulong source_disabled_handler_id;
gulong default_mail_account_handler_id;
CamelStore *local_store;
@@ -474,6 +476,27 @@ mail_session_refresh_cb (ESource *source,
g_signal_emit (session, signals[REFRESH_SERVICE], 0, service);
}
+static gboolean
+mail_session_check_goa_mail_disabled (EMailSession *session,
+ ESource *source)
+{
+ ESource *goa_source;
+ ESourceRegistry *registry;
+ gboolean goa_mail_disabled = FALSE;
+
+ registry = e_mail_session_get_registry (session);
+
+ goa_source = e_source_registry_find_extension (
+ registry, source, E_SOURCE_EXTENSION_GOA);
+
+ if (goa_source != NULL) {
+ goa_mail_disabled = !e_source_get_enabled (source);
+ g_object_unref (goa_source);
+ }
+
+ return goa_mail_disabled;
+}
+
static void
mail_session_add_from_source (EMailSession *session,
CamelProviderType type,
@@ -507,6 +530,13 @@ mail_session_add_from_source (EMailSession *session,
g_return_if_fail (uid != NULL);
g_return_if_fail (backend_name != NULL);
+ /* Collection sources with a [GNOME Online Accounts] extension
+ * require special handling. If the collection's mail-enabled
+ * flag is FALSE, do not add a CamelService. The account must
+ * not appear anywhere, not even in the Mail Accounts list. */
+ if (mail_session_check_goa_mail_disabled (session, source))
+ return;
+
/* Our own CamelSession.add_service() method will handle the
* resulting CamelService, so we don't need the return value. */
camel_session_add_service (
@@ -580,6 +610,44 @@ mail_session_source_removed_cb (ESourceRegistry *registry,
}
static void
+mail_session_source_enabled_cb (ESourceRegistry *registry,
+ ESource *source,
+ EMailSession *session)
+{
+ ESource *goa_source;
+
+ /* If the source is linked to a GNOME Online Account,
+ * enabling the source is equivalent to adding it. */
+
+ goa_source = e_source_registry_find_extension (
+ registry, source, E_SOURCE_EXTENSION_GOA);
+
+ if (goa_source != NULL) {
+ mail_session_source_added_cb (registry, source, session);
+ g_object_unref (goa_source);
+ }
+}
+
+static void
+mail_session_source_disabled_cb (ESourceRegistry *registry,
+ ESource *source,
+ EMailSession *session)
+{
+ ESource *goa_source;
+
+ /* If the source is linked to a GNOME Online Account,
+ * disabling the source is equivalent to removing it. */
+
+ goa_source = e_source_registry_find_extension (
+ registry, source, E_SOURCE_EXTENSION_GOA);
+
+ if (goa_source != NULL) {
+ mail_session_source_removed_cb (registry, source, session);
+ g_object_unref (goa_source);
+ }
+}
+
+static void
mail_session_default_mail_account_cb (ESourceRegistry *registry,
GParamSpec *pspec,
EMailSession *session)
@@ -881,6 +949,12 @@ mail_session_dispose (GObject *object)
priv->source_removed_handler_id);
g_signal_handler_disconnect (
priv->registry,
+ priv->source_enabled_handler_id);
+ g_signal_handler_disconnect (
+ priv->registry,
+ priv->source_disabled_handler_id);
+ g_signal_handler_disconnect (
+ priv->registry,
priv->default_mail_account_handler_id);
/* This requires the registry. */
@@ -1029,6 +1103,16 @@ mail_session_constructed (GObject *object)
session->priv->source_removed_handler_id = handler_id;
handler_id = g_signal_connect (
+ registry, "source-enabled",
+ G_CALLBACK (mail_session_source_enabled_cb), session);
+ session->priv->source_enabled_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
+ registry, "source-disabled",
+ G_CALLBACK (mail_session_source_disabled_cb), session);
+ session->priv->source_disabled_handler_id = handler_id;
+
+ handler_id = g_signal_connect (
registry, "notify::default-mail-account",
G_CALLBACK (mail_session_default_mail_account_cb), session);
session->priv->default_mail_account_handler_id = handler_id;