[evolution-data-server] Add e_source_dup_secret_label().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add e_source_dup_secret_label().
- Date: Thu, 13 Feb 2014 22:04:02 +0000 (UTC)
commit 8a37f1b14c202fddfc8e8ec7baf93fa1f0d7df69
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Feb 13 15:39:53 2014 -0500
Add e_source_dup_secret_label().
Creates a label string based on the ESource's display name for use with
SecretItem.
docs/reference/eds/eds-sections.txt | 1 +
libedataserver/e-source.c | 37 +++++++++++++++++++++++++++++++++-
libedataserver/e-source.h | 1 +
3 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/eds/eds-sections.txt b/docs/reference/eds/eds-sections.txt
index 4d07c72..d89f0d3 100644
--- a/docs/reference/eds/eds-sections.txt
+++ b/docs/reference/eds/eds-sections.txt
@@ -2863,6 +2863,7 @@ e_source_ref_main_context
e_source_get_display_name
e_source_dup_display_name
e_source_set_display_name
+e_source_dup_secret_label
e_source_compare_by_display_name
e_source_to_string
e_source_parameter_to_key
diff --git a/libedataserver/e-source.c b/libedataserver/e-source.c
index 824dc72..5de2aa0 100644
--- a/libedataserver/e-source.c
+++ b/libedataserver/e-source.c
@@ -115,7 +115,6 @@
#define PRIMARY_GROUP_NAME "Data Source"
#define KEYRING_ITEM_ATTRIBUTE_NAME "e-source-uid"
-#define KEYRING_ITEM_DISPLAY_FORMAT "Evolution Data Source '%s'"
typedef struct _AsyncContext AsyncContext;
typedef struct _RemoveContext RemoveContext;
@@ -2835,6 +2834,40 @@ e_source_set_display_name (ESource *source,
}
/**
+ * e_source_dup_secret_label:
+ * @source: an #ESource
+ *
+ * Creates a label string based on @source's #ESource:display-name for use
+ * with #SecretItem.
+ *
+ * Returns: a newly-allocated secret label
+ *
+ * Since: 3.12
+ **/
+gchar *
+e_source_dup_secret_label (ESource *source)
+{
+ gchar *display_name;
+ gchar *secret_label;
+
+ g_return_val_if_fail (E_IS_SOURCE (source), NULL);
+
+ display_name = e_source_dup_display_name (source);
+
+ if (display_name == NULL || *display_name == '\0') {
+ g_free (display_name);
+ display_name = e_source_dup_uid (source);
+ }
+
+ secret_label = g_strdup_printf (
+ "Evolution Data Source \"%s\"", display_name);
+
+ g_free (display_name);
+
+ return secret_label;
+}
+
+/**
* e_source_compare_by_display_name:
* @source1: the first #ESource
* @source2: the second #ESource
@@ -3480,7 +3513,7 @@ e_source_store_password_sync (ESource *source,
collection = SECRET_COLLECTION_SESSION;
uid = e_source_get_uid (source);
- label = g_strdup_printf (KEYRING_ITEM_DISPLAY_FORMAT, uid);
+ label = e_source_dup_secret_label (source);
success = secret_password_store_sync (
&password_schema,
diff --git a/libedataserver/e-source.h b/libedataserver/e-source.h
index 821e600..690232e 100644
--- a/libedataserver/e-source.h
+++ b/libedataserver/e-source.h
@@ -178,6 +178,7 @@ const gchar * e_source_get_display_name (ESource *source);
gchar * e_source_dup_display_name (ESource *source);
void e_source_set_display_name (ESource *source,
const gchar *display_name);
+gchar * e_source_dup_secret_label (ESource *source);
gint e_source_compare_by_display_name
(ESource *source1,
ESource *source2);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]