[evolution-data-server] ESourceMailAccount: Add 'builtin' property



commit 58c988ccb7c2fdba36ca15681d676ee0f44a60f4
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jul 5 20:11:51 2022 +0200

    ESourceMailAccount: Add 'builtin' property
    
    It can be used by the mail clients to limit operations the users
    can do on the account.

 src/camel/camel-enums.h                    |  3 +-
 src/libedataserver/e-source-mail-account.c | 74 +++++++++++++++++++++++++++++-
 src/libedataserver/e-source-mail-account.h |  5 ++
 3 files changed, 80 insertions(+), 2 deletions(-)
---
diff --git a/src/camel/camel-enums.h b/src/camel/camel-enums.h
index 44e4eeaff..6a585705f 100644
--- a/src/camel/camel-enums.h
+++ b/src/camel/camel-enums.h
@@ -497,7 +497,8 @@ typedef enum { /*< flags >*/
        CAMEL_STORE_CAN_EDIT_FOLDERS = 1 << 5,
        CAMEL_STORE_USE_CACHE_DIR = 1 << 6,
        CAMEL_STORE_CAN_DELETE_FOLDERS_AT_ONCE = 1 << 7,
-       CAMEL_STORE_SUPPORTS_INITIAL_SETUP = 1 << 8
+       CAMEL_STORE_SUPPORTS_INITIAL_SETUP = 1 << 8,
+       CAMEL_STORE_IS_BUILTIN = 1 << 9
 } CamelStoreFlags;
 
 /**
diff --git a/src/libedataserver/e-source-mail-account.c b/src/libedataserver/e-source-mail-account.c
index f45199839..284234b01 100644
--- a/src/libedataserver/e-source-mail-account.c
+++ b/src/libedataserver/e-source-mail-account.c
@@ -46,6 +46,7 @@ struct _ESourceMailAccountPrivate {
        gboolean needs_initial_setup;
        EThreeState mark_seen;
        gint mark_seen_timeout;
+       gboolean builtin;
 };
 
 enum {
@@ -54,7 +55,8 @@ enum {
        PROP_ARCHIVE_FOLDER,
        PROP_NEEDS_INITIAL_SETUP,
        PROP_MARK_SEEN,
-       PROP_MARK_SEEN_TIMEOUT
+       PROP_MARK_SEEN_TIMEOUT,
+       PROP_BUILTIN
 };
 
 G_DEFINE_TYPE_WITH_PRIVATE (
@@ -98,6 +100,12 @@ source_mail_account_set_property (GObject *object,
                                E_SOURCE_MAIL_ACCOUNT (object),
                                g_value_get_int (value));
                        return;
+
+               case PROP_BUILTIN:
+                       e_source_mail_account_set_builtin (
+                               E_SOURCE_MAIL_ACCOUNT (object),
+                               g_value_get_boolean (value));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -144,6 +152,13 @@ source_mail_account_get_property (GObject *object,
                                e_source_mail_account_get_mark_seen_timeout (
                                E_SOURCE_MAIL_ACCOUNT (object)));
                        return;
+
+               case PROP_BUILTIN:
+                       g_value_set_boolean (
+                               value,
+                               e_source_mail_account_get_builtin (
+                               E_SOURCE_MAIL_ACCOUNT (object)));
+                       return;
        }
 
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -248,6 +263,20 @@ e_source_mail_account_class_init (ESourceMailAccountClass *class)
                        G_PARAM_EXPLICIT_NOTIFY |
                        G_PARAM_STATIC_STRINGS |
                        E_SOURCE_PARAM_SETTING));
+
+       g_object_class_install_property (
+               object_class,
+               PROP_BUILTIN,
+               g_param_spec_boolean (
+                       "builtin",
+                       "Builtin",
+                       "Whether the account is builtin",
+                       FALSE,
+                       G_PARAM_READWRITE |
+                       G_PARAM_CONSTRUCT |
+                       G_PARAM_EXPLICIT_NOTIFY |
+                       G_PARAM_STATIC_STRINGS |
+                       E_SOURCE_PARAM_SETTING));
 }
 
 static void
@@ -546,3 +575,46 @@ e_source_mail_account_set_mark_seen_timeout (ESourceMailAccount *extension,
 
        g_object_notify (G_OBJECT (extension), "mark-seen-timeout");
 }
+
+/**
+ * e_source_mail_account_get_builtin:
+ * @extension: an #ESourceMailAccount
+ *
+ * Returns whether the mail account is a builtin account. The builtin
+ * account cannot be created by a user. The default value is %FALSE.
+ *
+ * Returns: %TRUE, when the account is a builtin account
+ *
+ * Since: 3.46
+ **/
+gboolean
+e_source_mail_account_get_builtin (ESourceMailAccount *extension)
+{
+       g_return_val_if_fail (E_IS_SOURCE_MAIL_ACCOUNT (extension), FALSE);
+
+       return extension->priv->builtin;
+}
+
+/**
+ * e_source_mail_account_set_builtin:
+ * @extension: an #ESourceMailAccount
+ * @builtin: value to set
+ *
+ * Sets whether the account is a builtin account. See e_source_mail_account_get_builtin()
+ * for more information about what it means.
+ *
+ * Since: 3.46
+ **/
+void
+e_source_mail_account_set_builtin (ESourceMailAccount *extension,
+                                  gboolean builtin)
+{
+       g_return_if_fail (E_IS_SOURCE_MAIL_ACCOUNT (extension));
+
+       if ((extension->priv->builtin ? 1 : 0) == (builtin ? 1 : 0))
+               return;
+
+       extension->priv->builtin = builtin;
+
+       g_object_notify (G_OBJECT (extension), "builtin");
+}
diff --git a/src/libedataserver/e-source-mail-account.h b/src/libedataserver/e-source-mail-account.h
index 4039b9edb..60ee1875a 100644
--- a/src/libedataserver/e-source-mail-account.h
+++ b/src/libedataserver/e-source-mail-account.h
@@ -109,6 +109,11 @@ gint               e_source_mail_account_get_mark_seen_timeout
 void           e_source_mail_account_set_mark_seen_timeout
                                        (ESourceMailAccount *extension,
                                         gint timeout);
+gboolean       e_source_mail_account_get_builtin
+                                       (ESourceMailAccount *extension);
+void           e_source_mail_account_set_builtin
+                                       (ESourceMailAccount *extension,
+                                        gint builtin);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]