[evolution-data-server] Calendar: Make it possible to assign email address to On This Computer sources
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Calendar: Make it possible to assign email address to On This Computer sources
- Date: Fri, 30 Oct 2020 08:04:11 +0000 (UTC)
commit 613104b9d5b39db12a95457ff36415c24db41cdf
Author: Milan Crha <mcrha redhat com>
Date: Fri Oct 30 09:02:39 2020 +0100
Calendar: Make it possible to assign email address to On This Computer sources
This email address can be used as a default organizer or an email reminder
address.
src/calendar/backends/file/e-cal-backend-file.c | 9 +-
src/libedataserver/e-source-local.c | 109 ++++++++++++++++++++++++
src/libedataserver/e-source-local.h | 4 +
3 files changed, 118 insertions(+), 4 deletions(-)
---
diff --git a/src/calendar/backends/file/e-cal-backend-file.c b/src/calendar/backends/file/e-cal-backend-file.c
index af10cb478..8134f360e 100644
--- a/src/calendar/backends/file/e-cal-backend-file.c
+++ b/src/calendar/backends/file/e-cal-backend-file.c
@@ -471,10 +471,11 @@ e_cal_backend_file_get_backend_property (ECalBackend *backend,
} else if (g_str_equal (prop_name, E_CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS) ||
g_str_equal (prop_name, E_CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS)) {
- /* A file backend has no particular email address associated
- * with it (although that would be a useful feature some day).
- */
- return NULL;
+ ESourceLocal *local_extension;
+
+ local_extension = e_source_get_extension (e_backend_get_source (E_BACKEND (backend)),
E_SOURCE_EXTENSION_LOCAL_BACKEND);
+
+ return e_source_local_dup_email_address (local_extension);
} else if (g_str_equal (prop_name, E_CAL_BACKEND_PROPERTY_DEFAULT_OBJECT)) {
ECalComponent *comp;
diff --git a/src/libedataserver/e-source-local.c b/src/libedataserver/e-source-local.c
index 67e50bb62..90fa2accb 100644
--- a/src/libedataserver/e-source-local.c
+++ b/src/libedataserver/e-source-local.c
@@ -22,11 +22,13 @@
struct _ESourceLocalPrivate {
GFile *custom_file;
gboolean writable;
+ gchar *email_address;
};
enum {
PROP_0,
PROP_CUSTOM_FILE,
+ PROP_EMAIL_ADDRESS,
PROP_WRITABLE
};
@@ -48,6 +50,12 @@ source_local_set_property (GObject *object,
g_value_get_object (value));
return;
+ case PROP_EMAIL_ADDRESS:
+ e_source_local_set_email_address (
+ E_SOURCE_LOCAL (object),
+ g_value_get_string (value));
+ return;
+
case PROP_WRITABLE:
e_source_local_set_writable (
E_SOURCE_LOCAL (object),
@@ -72,6 +80,13 @@ source_local_get_property (GObject *object,
E_SOURCE_LOCAL (object)));
return;
+ case PROP_EMAIL_ADDRESS:
+ g_value_take_string (
+ value,
+ e_source_local_dup_email_address (
+ E_SOURCE_LOCAL (object)));
+ return;
+
case PROP_WRITABLE:
g_value_set_boolean (
value,
@@ -126,6 +141,19 @@ e_source_local_class_init (ESourceLocalClass *class)
G_PARAM_EXPLICIT_NOTIFY |
E_SOURCE_PARAM_SETTING));
+ g_object_class_install_property (
+ object_class,
+ PROP_EMAIL_ADDRESS,
+ g_param_spec_string (
+ "email-address",
+ "Email Address",
+ "Email address associated with the calendar",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_EXPLICIT_NOTIFY |
+ E_SOURCE_PARAM_SETTING));
+
g_object_class_install_property (
object_class,
PROP_WRITABLE,
@@ -275,3 +303,84 @@ e_source_local_set_writable (ESourceLocal *extension,
if (changed)
g_object_notify (G_OBJECT (extension), "writable");
}
+
+/**
+ * e_source_local_get_email_address:
+ * @extension: an #ESourceLocal
+ *
+ * Returns: (nullable): the email address for @extension
+ *
+ * Since: 3.40
+ **/
+const gchar *
+e_source_local_get_email_address (ESourceLocal *extension)
+{
+ g_return_val_if_fail (E_IS_SOURCE_LOCAL (extension), NULL);
+
+ return extension->priv->email_address;
+}
+
+/**
+ * e_source_local_dup_email_address:
+ * @extension: an #ESourceLocal
+ *
+ * Thread-safe variation of e_source_lcoal_get_email_address().
+ * Use this function when accessing @extension from multiple threads.
+ *
+ * The returned string should be freed with g_free() when no longer needed.
+ *
+ * Returns: (transfer full): a newly-allocated copy of #ESourceLocal:email-address
+ *
+ * Since: 3.40
+ **/
+gchar *
+e_source_local_dup_email_address (ESourceLocal *extension)
+{
+ const gchar *protected;
+ gchar *duplicate;
+
+ g_return_val_if_fail (E_IS_SOURCE_LOCAL (extension), NULL);
+
+ e_source_extension_property_lock (E_SOURCE_EXTENSION (extension));
+
+ protected = e_source_local_get_email_address (extension);
+ duplicate = g_strdup (protected);
+
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
+
+ return duplicate;
+}
+
+/**
+ * e_source_local_set_email_address:
+ * @extension: an #ESourceLocal
+ * @email_address: (nullable): an email address, or %NULL
+ *
+ * Sets the email address for @extension.
+ *
+ * The internal copy of @email_address is automatically stripped of leading
+ * and trailing whitespace. If the resulting string is empty, %NULL is set
+ * instead.
+ *
+ * Since: 3.40
+ **/
+void
+e_source_local_set_email_address (ESourceLocal *extension,
+ const gchar *email_address)
+{
+ g_return_if_fail (E_IS_SOURCE_LOCAL (extension));
+
+ e_source_extension_property_lock (E_SOURCE_EXTENSION (extension));
+
+ if (e_util_strcmp0 (extension->priv->email_address, email_address) == 0) {
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
+ return;
+ }
+
+ g_free (extension->priv->email_address);
+ extension->priv->email_address = e_util_strdup_strip (email_address);
+
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
+
+ g_object_notify (G_OBJECT (extension), "email-address");
+}
diff --git a/src/libedataserver/e-source-local.h b/src/libedataserver/e-source-local.h
index 65847ef61..4697701fb 100644
--- a/src/libedataserver/e-source-local.h
+++ b/src/libedataserver/e-source-local.h
@@ -77,6 +77,10 @@ void e_source_local_set_custom_file (ESourceLocal *extension,
gboolean e_source_local_get_writable (ESourceLocal *extension);
void e_source_local_set_writable (ESourceLocal *extension,
gboolean writable);
+const gchar * e_source_local_get_email_address(ESourceLocal *extension);
+gchar * e_source_local_dup_email_address(ESourceLocal *extension);
+void e_source_local_set_email_address(ESourceLocal *extension,
+ const gchar *email_address);
G_END_DECLS
#endif /* E_SOURCE_LOCAL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]