[evolution-data-server] Bug 223621 - Add per-account mail Archive Folder option
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 223621 - Add per-account mail Archive Folder option
- Date: Mon, 20 Oct 2014 13:09:42 +0000 (UTC)
commit 0914aa0b546168212062074267da76d3a46f3b53
Author: Milan Crha <mcrha redhat com>
Date: Mon Oct 20 15:07:42 2014 +0200
Bug 223621 - Add per-account mail Archive Folder option
libedataserver/e-source-mail-account.c | 115 +++++++++++++++++++++++++++++++-
libedataserver/e-source-mail-account.h | 7 ++
2 files changed, 121 insertions(+), 1 deletions(-)
---
diff --git a/libedataserver/e-source-mail-account.c b/libedataserver/e-source-mail-account.c
index 7bc1987..f544be3 100644
--- a/libedataserver/e-source-mail-account.c
+++ b/libedataserver/e-source-mail-account.c
@@ -47,11 +47,13 @@
struct _ESourceMailAccountPrivate {
GMutex property_lock;
gchar *identity_uid;
+ gchar *archive_folder;
};
enum {
PROP_0,
- PROP_IDENTITY_UID
+ PROP_IDENTITY_UID,
+ PROP_ARCHIVE_FOLDER
};
G_DEFINE_TYPE (
@@ -71,6 +73,12 @@ source_mail_account_set_property (GObject *object,
E_SOURCE_MAIL_ACCOUNT (object),
g_value_get_string (value));
return;
+
+ case PROP_ARCHIVE_FOLDER:
+ e_source_mail_account_set_archive_folder (
+ E_SOURCE_MAIL_ACCOUNT (object),
+ g_value_get_string (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -89,6 +97,13 @@ source_mail_account_get_property (GObject *object,
e_source_mail_account_dup_identity_uid (
E_SOURCE_MAIL_ACCOUNT (object)));
return;
+
+ case PROP_ARCHIVE_FOLDER:
+ g_value_take_string (
+ value,
+ e_source_mail_account_dup_archive_folder (
+ E_SOURCE_MAIL_ACCOUNT (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -104,6 +119,7 @@ source_mail_account_finalize (GObject *object)
g_mutex_clear (&priv->property_lock);
g_free (priv->identity_uid);
+ g_free (priv->archive_folder);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (e_source_mail_account_parent_class)->finalize (object);
@@ -137,6 +153,19 @@ e_source_mail_account_class_init (ESourceMailAccountClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS |
E_SOURCE_PARAM_SETTING));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_ARCHIVE_FOLDER,
+ g_param_spec_string (
+ "archive-folder",
+ "Archive Folder",
+ "Folder to Archive messages in",
+ "",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS |
+ E_SOURCE_PARAM_SETTING));
}
static void
@@ -227,3 +256,87 @@ e_source_mail_account_set_identity_uid (ESourceMailAccount *extension,
g_object_notify (G_OBJECT (extension), "identity-uid");
}
+/**
+ * e_source_mail_account_get_archive_folder:
+ * @extension: an #ESourceMailAccount
+ *
+ * Returns a string identifying the archive folder.
+ * The format of the identifier string is defined by the client application.
+ *
+ * Returns: an identifier of the archive folder
+ *
+ * Since: 3.14
+ **/
+const gchar *
+e_source_mail_account_get_archive_folder (ESourceMailAccount *extension)
+{
+ g_return_val_if_fail (E_IS_SOURCE_MAIL_ACCOUNT (extension), NULL);
+
+ return extension->priv->archive_folder;
+}
+
+/**
+ * e_source_mail_account_dup_archive_folder:
+ * @extension: an #ESourceMailAccount
+ *
+ * Thread-safe variation of e_source_mail_account_get_archive_folder().
+ * Use this function when accessing @extension from multiple threads.
+ *
+ * The returned string should be freed with g_free() when no longer needed.
+ *
+ * Returns: a newly-allocated copy of #ESourceMailAccount:archive-folder
+ *
+ * Since: 3.14
+ **/
+gchar *
+e_source_mail_account_dup_archive_folder (ESourceMailAccount *extension)
+{
+ const gchar *protected;
+ gchar *duplicate;
+
+ g_return_val_if_fail (E_IS_SOURCE_MAIL_ACCOUNT (extension), NULL);
+
+ g_mutex_lock (&extension->priv->property_lock);
+
+ protected = e_source_mail_account_get_archive_folder (extension);
+ duplicate = g_strdup (protected);
+
+ g_mutex_unlock (&extension->priv->property_lock);
+
+ return duplicate;
+}
+
+/**
+ * e_source_mail_account_set_archive_folder:
+ * @extension: an #ESourceMailAccount
+ * @archive_folder: (allow-none): an identifier for the archive folder, or %NULL
+ *
+ * Sets the folder for sent messages by an identifier string.
+ * The format of the identifier string is defined by the client application.
+ *
+ * The internal copy of @archive_folder is automatically stripped of leading
+ * and trailing whitespace. If the resulting string is empty, %NULL is set
+ * instead.
+ *
+ * Since: 3.14
+ **/
+void
+e_source_mail_account_set_archive_folder (ESourceMailAccount *extension,
+ const gchar *archive_folder)
+{
+ g_return_if_fail (E_IS_SOURCE_MAIL_ACCOUNT (extension));
+
+ g_mutex_lock (&extension->priv->property_lock);
+
+ if (g_strcmp0 (extension->priv->archive_folder, archive_folder) == 0) {
+ g_mutex_unlock (&extension->priv->property_lock);
+ return;
+ }
+
+ g_free (extension->priv->archive_folder);
+ extension->priv->archive_folder = g_strdup (archive_folder);
+
+ g_mutex_unlock (&extension->priv->property_lock);
+
+ g_object_notify (G_OBJECT (extension), "archive-folder");
+}
diff --git a/libedataserver/e-source-mail-account.h b/libedataserver/e-source-mail-account.h
index eec7756..4095b28 100644
--- a/libedataserver/e-source-mail-account.h
+++ b/libedataserver/e-source-mail-account.h
@@ -85,6 +85,13 @@ gchar * e_source_mail_account_dup_identity_uid
void e_source_mail_account_set_identity_uid
(ESourceMailAccount *extension,
const gchar *identity_uid);
+const gchar * e_source_mail_account_get_archive_folder
+ (ESourceMailAccount *extension);
+gchar * e_source_mail_account_dup_archive_folder
+ (ESourceMailAccount *extension);
+void e_source_mail_account_set_archive_folder
+ (ESourceMailAccount *extension,
+ const gchar *archive_folder);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]