aboutsummaryrefslogtreecommitdiffstats
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
parentfcca366ecce1ffddaf6a280e248456127def1b4d (diff)
downloadgsoc2013-evolution-d88c38abebb672977729735513135da8b47409d4.tar.gz
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?
-rw-r--r--libemail-engine/e-mail-session.c84
-rw-r--r--mail/e-mail-account-store.c16
-rw-r--r--mail/e-mail-account-store.h2
-rw-r--r--mail/e-mail-account-tree-view.c20
4 files changed, 121 insertions, 1 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;
diff --git a/mail/e-mail-account-store.c b/mail/e-mail-account-store.c
index 51ad51cd95..b7228e2c71 100644
--- a/mail/e-mail-account-store.c
+++ b/mail/e-mail-account-store.c
@@ -981,6 +981,8 @@ e_mail_account_store_init (EMailAccountStore *store)
types[ii++] = G_TYPE_BOOLEAN; /* COLUMN_DEFAULT */
types[ii++] = G_TYPE_STRING; /* COLUMN_BACKEND_NAME */
types[ii++] = G_TYPE_STRING; /* COLUMN_DISPLAY_NAME */
+ types[ii++] = G_TYPE_BOOLEAN; /* COLUMN_ONLINE_ACCOUNT */
+ types[ii++] = G_TYPE_BOOLEAN; /* COLUMN_ENABLED_VISIBLE */
g_assert (ii == E_MAIL_ACCOUNT_STORE_NUM_COLUMNS);
@@ -1114,6 +1116,8 @@ e_mail_account_store_add_service (EMailAccountStore *store,
const gchar *uid;
gboolean builtin;
gboolean enabled;
+ gboolean online_account = FALSE;
+ gboolean enabled_visible = TRUE;
g_return_if_fail (E_IS_MAIL_ACCOUNT_STORE (store));
g_return_if_fail (CAMEL_IS_SERVICE (service));
@@ -1141,7 +1145,17 @@ e_mail_account_store_add_service (EMailAccountStore *store,
collection = e_source_registry_find_extension (
registry, source, E_SOURCE_EXTENSION_COLLECTION);
if (collection != NULL) {
+ const gchar *extension_name;
+
enabled = e_source_get_enabled (collection);
+
+ /* Check for GNOME Online Accounts linkage. */
+ extension_name = E_SOURCE_EXTENSION_GOA;
+ if (e_source_has_extension (collection, extension_name)) {
+ online_account = TRUE;
+ enabled_visible = FALSE;
+ }
+
g_object_unref (collection);
} else {
enabled = e_source_get_enabled (source);
@@ -1168,6 +1182,8 @@ e_mail_account_store_add_service (EMailAccountStore *store,
E_MAIL_ACCOUNT_STORE_COLUMN_SERVICE, service,
E_MAIL_ACCOUNT_STORE_COLUMN_BUILTIN, builtin,
E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED, enabled,
+ E_MAIL_ACCOUNT_STORE_COLUMN_ONLINE_ACCOUNT, online_account,
+ E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED_VISIBLE, enabled_visible,
-1);
/* This populates the rest of the columns. */
diff --git a/mail/e-mail-account-store.h b/mail/e-mail-account-store.h
index 51d0afa088..063f6c07ad 100644
--- a/mail/e-mail-account-store.h
+++ b/mail/e-mail-account-store.h
@@ -53,6 +53,8 @@ typedef enum {
E_MAIL_ACCOUNT_STORE_COLUMN_DEFAULT,
E_MAIL_ACCOUNT_STORE_COLUMN_BACKEND_NAME,
E_MAIL_ACCOUNT_STORE_COLUMN_DISPLAY_NAME,
+ E_MAIL_ACCOUNT_STORE_COLUMN_ONLINE_ACCOUNT,
+ E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED_VISIBLE,
E_MAIL_ACCOUNT_STORE_NUM_COLUMNS
} EMailAccountStoreColumn;
diff --git a/mail/e-mail-account-tree-view.c b/mail/e-mail-account-tree-view.c
index 269a03d777..424294bf86 100644
--- a/mail/e-mail-account-tree-view.c
+++ b/mail/e-mail-account-tree-view.c
@@ -96,6 +96,10 @@ mail_account_tree_view_constructed (GObject *object)
column, cell_renderer, "active",
E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED);
+ gtk_tree_view_column_add_attribute (
+ column, cell_renderer, "visible",
+ E_MAIL_ACCOUNT_STORE_COLUMN_ENABLED_VISIBLE);
+
gtk_tree_view_append_column (tree_view, column);
/* Column: Account Name */
@@ -106,12 +110,26 @@ mail_account_tree_view_constructed (GObject *object)
cell_renderer = gtk_cell_renderer_text_new ();
g_object_set (cell_renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
+ gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
gtk_tree_view_column_add_attribute (
column, cell_renderer, "text",
E_MAIL_ACCOUNT_STORE_COLUMN_DISPLAY_NAME);
+ cell_renderer = gtk_cell_renderer_pixbuf_new ();
+ g_object_set (
+ cell_renderer, "icon-name", "goa-panel",
+ "stock-size", GTK_ICON_SIZE_MENU, NULL);
+ gtk_tree_view_column_pack_start (column, cell_renderer, FALSE);
+
+ gtk_tree_view_column_add_attribute (
+ column, cell_renderer, "visible",
+ E_MAIL_ACCOUNT_STORE_COLUMN_ONLINE_ACCOUNT);
+
+ /* This renderer is just an empty space filler. */
+ cell_renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_tree_view_column_pack_start (column, cell_renderer, TRUE);
+
cell_renderer = gtk_cell_renderer_text_new ();
g_object_set (cell_renderer, "text", _("Default"), NULL);
gtk_tree_view_column_pack_end (column, cell_renderer, FALSE);