[evolution] Mail: Handle built-in accounts similar to 'On This Computer' and 'Search Folders'
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Mail: Handle built-in accounts similar to 'On This Computer' and 'Search Folders'
- Date: Tue, 5 Jul 2022 18:30:17 +0000 (UTC)
commit 15e74029b138ec0336caf39c3e866498117a21f5
Author: Milan Crha <mcrha redhat com>
Date: Tue Jul 5 20:21:45 2022 +0200
Mail: Handle built-in accounts similar to 'On This Computer' and 'Search Folders'
The built-in accounts have limited functions the users can do with them.
src/e-util/e-accounts-window.c | 14 ++++++--
src/mail/e-mail-account-manager.c | 4 +--
src/mail/e-mail-account-store.c | 7 ++--
src/mail/e-mail-sidebar.c | 9 +++--
src/mail/em-filter-rule.c | 4 +++
.../startup-wizard/evolution-startup-wizard.c | 38 ++++++----------------
6 files changed, 40 insertions(+), 36 deletions(-)
---
diff --git a/src/e-util/e-accounts-window.c b/src/e-util/e-accounts-window.c
index 002bebcc17..077a1396d5 100644
--- a/src/e-util/e-accounts-window.c
+++ b/src/e-util/e-accounts-window.c
@@ -676,9 +676,16 @@ accounts_window_fill_tree_view (EAccountsWindow *accounts_window)
for (slink = top_mail_accounts; slink; slink = g_slist_next (slink)) {
ESource *source = slink->data;
GtkTreeIter iter;
+ gboolean is_builtin = FALSE;
+
+ if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT)) {
+ ESourceMailAccount *mail_account = e_source_get_extension (source,
E_SOURCE_EXTENSION_MAIL_ACCOUNT);
+ is_builtin = e_source_mail_account_get_builtin (mail_account);
+ }
/* Skip 'On This Computer' and 'Search Folders' mail accounts */
- if (g_strcmp0 (e_source_get_uid (source), "local") == 0 ||
+ if (is_builtin ||
+ g_strcmp0 (e_source_get_uid (source), "local") == 0 ||
g_strcmp0 (e_source_get_uid (source), "vfolder") == 0)
continue;
@@ -883,9 +890,12 @@ accounts_window_source_added_cb (ESourceRegistry *registry,
accounts_window_fill_children (accounts_window, tree_store, &iter, is_managed_collection,
TRUE, children_and_siblings);
} else if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT) && (
!e_source_get_parent (source) || g_strcmp0 (e_source_get_parent (source), "") == 0)) {
+ ESourceMailAccount *mail_account = e_source_get_extension (source,
E_SOURCE_EXTENSION_MAIL_ACCOUNT);
+ gboolean is_builtin = e_source_mail_account_get_builtin (mail_account);
/* Skip 'On This Computer' and 'Search Folders' mail accounts */
- if (g_strcmp0 (e_source_get_uid (source), "local") != 0 &&
+ if (!is_builtin &&
+ g_strcmp0 (e_source_get_uid (source), "local") != 0 &&
g_strcmp0 (e_source_get_uid (source), "vfolder") != 0) {
if (!accounts_window_find_child_with_sort_hint (accounts_window, tree_store, NULL,
MAIL_ACCOUNTS_SORT_HINT, &root)) {
gtk_tree_store_append (tree_store, &root, NULL);
diff --git a/src/mail/e-mail-account-manager.c b/src/mail/e-mail-account-manager.c
index 9de737d017..eea620e0f0 100644
--- a/src/mail/e-mail-account-manager.c
+++ b/src/mail/e-mail-account-manager.c
@@ -471,7 +471,7 @@ mail_account_manager_selection_changed_cb (EMailAccountManager *manager,
source = collection;
}
- removable = e_source_get_removable (source);
+ removable = !builtin && e_source_get_removable (source);
extension_name = E_SOURCE_EXTENSION_GOA;
if (e_source_has_extension (source, extension_name)) {
@@ -500,7 +500,7 @@ mail_account_manager_selection_changed_cb (EMailAccountManager *manager,
sensitive = (service != NULL && !builtin);
gtk_widget_set_sensitive (edit_button, sensitive);
- sensitive = (service != NULL && removable);
+ sensitive = (service != NULL && !builtin && removable);
gtk_widget_set_sensitive (delete_button, sensitive);
sensitive = (service != NULL && !builtin && not_default);
diff --git a/src/mail/e-mail-account-store.c b/src/mail/e-mail-account-store.c
index 6c9dbf9995..78d2d310ec 100644
--- a/src/mail/e-mail-account-store.c
+++ b/src/mail/e-mail-account-store.c
@@ -1204,7 +1204,7 @@ e_mail_account_store_add_service (EMailAccountStore *store,
const gchar *icon_name = NULL;
const gchar *uid;
gint intended_position;
- gboolean builtin;
+ gboolean builtin = FALSE;
gboolean enabled;
gboolean online_account = FALSE;
gboolean enabled_visible = TRUE;
@@ -1218,7 +1218,10 @@ e_mail_account_store_add_service (EMailAccountStore *store,
uid = camel_service_get_uid (service);
- builtin =
+ if (CAMEL_IS_STORE (service))
+ builtin = (camel_store_get_flags (CAMEL_STORE (service)) & CAMEL_STORE_IS_BUILTIN) != 0;
+
+ builtin = builtin ||
(g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0) ||
(g_strcmp0 (uid, E_MAIL_SESSION_VFOLDER_UID) == 0);
diff --git a/src/mail/e-mail-sidebar.c b/src/mail/e-mail-sidebar.c
index ad0aafe26a..9b055b7973 100644
--- a/src/mail/e-mail-sidebar.c
+++ b/src/mail/e-mail-sidebar.c
@@ -433,6 +433,7 @@ mail_sidebar_check_state (EMailSidebar *sidebar)
CamelStore *store;
gchar *full_name;
const gchar *uid;
+ gboolean store_is_builtin;
gboolean store_is_local;
gboolean store_is_vfolder;
gboolean allows_children = TRUE;
@@ -460,6 +461,7 @@ mail_sidebar_check_state (EMailSidebar *sidebar)
COL_UINT_FLAGS, &folder_flags, -1);
uid = camel_service_get_uid (CAMEL_SERVICE (store));
+ store_is_builtin = (camel_store_get_flags (store) & CAMEL_STORE_IS_BUILTIN) != 0;
store_is_local = (g_strcmp0 (uid, E_MAIL_SESSION_LOCAL_UID) == 0);
store_is_vfolder = (g_strcmp0 (uid, E_MAIL_SESSION_VFOLDER_UID) == 0);
@@ -501,7 +503,7 @@ mail_sidebar_check_state (EMailSidebar *sidebar)
}
/* GOA and UOA-based accounts cannot be disabled from Evolution. */
- if (is_store && !store_is_local && !store_is_vfolder) {
+ if (is_store && !store_is_local && !store_is_vfolder && !store_is_builtin) {
EMFolderTree *folder_tree;
EMailSession *session;
ESourceRegistry *registry;
@@ -530,6 +532,9 @@ mail_sidebar_check_state (EMailSidebar *sidebar)
g_object_unref (source);
}
+ if (store_is_builtin)
+ can_disable = FALSE;
+
if (allows_children)
state |= E_MAIL_SIDEBAR_FOLDER_ALLOWS_CHILDREN;
if (can_delete)
@@ -544,7 +549,7 @@ mail_sidebar_check_state (EMailSidebar *sidebar)
state |= E_MAIL_SIDEBAR_FOLDER_IS_TRASH;
if (is_virtual)
state |= E_MAIL_SIDEBAR_FOLDER_IS_VIRTUAL;
- if (store_is_local || store_is_vfolder)
+ if (store_is_local || store_is_vfolder || store_is_builtin)
state |= E_MAIL_SIDEBAR_STORE_IS_BUILTIN;
if (CAMEL_IS_SUBSCRIBABLE (store))
state |= E_MAIL_SIDEBAR_STORE_IS_SUBSCRIBABLE;
diff --git a/src/mail/em-filter-rule.c b/src/mail/em-filter-rule.c
index e3e7ad920e..8a91226bfd 100644
--- a/src/mail/em-filter-rule.c
+++ b/src/mail/em-filter-rule.c
@@ -889,6 +889,10 @@ filter_rule_fill_account_combo (GtkComboBox *source_combo,
g_strcmp0 (uid, E_MAIL_SESSION_VFOLDER_UID) == 0)
continue;
+ if (is_incoming && CAMEL_IS_STORE (service) &&
+ (camel_store_get_flags (CAMEL_STORE (service)) & CAMEL_STORE_IS_BUILTIN) != 0)
+ continue;
+
if ((is_incoming && CAMEL_IS_STORE (service)) ||
(!is_incoming && CAMEL_IS_TRANSPORT (service))) {
ESource *source = e_source_registry_ref_source (registry, uid);
diff --git a/src/modules/startup-wizard/evolution-startup-wizard.c
b/src/modules/startup-wizard/evolution-startup-wizard.c
index 820211207f..5370e3b1b8 100644
--- a/src/modules/startup-wizard/evolution-startup-wizard.c
+++ b/src/modules/startup-wizard/evolution-startup-wizard.c
@@ -95,11 +95,10 @@ static gboolean
startup_wizard_have_mail_account (EStartupWizard *extension)
{
EShell *shell;
- ESource *source;
ESourceRegistry *registry;
GList *list, *link;
+ guint skip_sources = 0;
const gchar *extension_name;
- const gchar *uid;
gboolean have_account;
shell = startup_wizard_get_shell (extension);
@@ -109,35 +108,18 @@ startup_wizard_have_mail_account (EStartupWizard *extension)
list = e_source_registry_list_sources (registry, extension_name);
- /* Exclude the built-in 'On This Computer' source. */
- uid = E_MAIL_SESSION_LOCAL_UID;
- source = e_source_registry_ref_source (registry, uid);
- link = g_list_find (list, source);
- if (link != NULL) {
- /* We have two references to the ESource,
- * one from e_source_registry_list_sources()
- * and one from e_source_registry_ref_source().
- * Drop them both. */
- g_object_unref (source);
- g_object_unref (source);
- list = g_list_delete_link (list, link);
- }
+ for (link = list; link; link = g_list_next (link)) {
+ ESource *source = list->data;
+ ESourceMailAccount *mail_account = e_source_get_extension (source, extension_name);
- /* Exclude the built-in 'Search Folders' source. */
- uid = E_MAIL_SESSION_VFOLDER_UID;
- source = e_source_registry_ref_source (registry, uid);
- link = g_list_find (list, source);
- if (link != NULL) {
- /* We have two references to the ESource,
- * one from e_source_registry_list_sources()
- * and one from e_source_registry_ref_source().
- * Drop them both. */
- g_object_unref (source);
- g_object_unref (source);
- list = g_list_delete_link (list, link);
+ /* Exclude the built-in, 'On This Computer' and 'Search Folders' sources. */
+ if (e_source_mail_account_get_builtin (mail_account) ||
+ g_strcmp0 (e_source_get_uid (source), E_MAIL_SESSION_LOCAL_UID) == 0 ||
+ g_strcmp0 (e_source_get_uid (source), E_MAIL_SESSION_VFOLDER_UID) == 0)
+ skip_sources++;
}
- have_account = (list != NULL);
+ have_account = g_list_length (list) > skip_sources;
g_list_free_full (list, (GDestroyNotify) g_object_unref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]