[folks] Configure the writeable store by type_id and store id
- From: Raul Gutierrez Segales <raulgs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Configure the writeable store by type_id and store id
- Date: Tue, 2 Aug 2011 18:27:28 +0000 (UTC)
commit 5c062183b8475bc46d7acb7c225e749e992fd3fa
Author: Raul Gutierrez Segales <rgs collabora co uk>
Date: Thu Jul 21 01:33:50 2011 +0100
Configure the writeable store by type_id and store id
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=654907
NEWS | 1 +
folks/individual-aggregator.vala | 44 +++++++++++++++++++++++++++++++-------
folks/persona-store.vala | 8 ++++++-
3 files changed, 44 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index 9b7d656..6ca3444 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,7 @@ Bugs fixed:
* Bug 650414 â Need better APIs to handle image data
* Bug 652643 â Add PersonaStore cache
* Bug 655510 â Make truly-writeable *Details property setters public
+* Bug 654907 â The writable store shouldn't be set by type_id
API changes:
* Swf.Persona retains and exposes its libsocialweb Contact
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 049e722..39151dc 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -65,6 +65,7 @@ public class Folks.IndividualAggregator : Object
private bool _is_prepared = false;
private Debug _debug;
private string _configured_writeable_store_type_id;
+ private string _configured_writeable_store_id;
private static const string _FOLKS_CONFIG_KEY =
"/system/folks/backends/primary_store";
@@ -181,20 +182,22 @@ public class Folks.IndividualAggregator : Object
this._debug.print_status.connect (this._debug_print_status);
/* Check out the configured writeable store */
- var store_type_id = Environment.get_variable ("FOLKS_WRITEABLE_STORE");
- if (store_type_id != null)
+ var store_config_ids = Environment.get_variable ("FOLKS_WRITEABLE_STORE");
+ if (store_config_ids != null)
{
- this._configured_writeable_store_type_id = store_type_id;
+ this._set_writeable_store (store_config_ids);
}
else
{
this._configured_writeable_store_type_id = "key-file";
+ this._configured_writeable_store_id = "";
+
try
{
unowned GConf.Client client = GConf.Client.get_default ();
GConf.Value? val = client.get (this._FOLKS_CONFIG_KEY);
if (val != null)
- this._configured_writeable_store_type_id = val.get_string ();
+ this._set_writeable_store (val.get_string ());
}
catch (GLib.Error e)
{
@@ -222,6 +225,21 @@ public class Folks.IndividualAggregator : Object
this._debug.print_status.disconnect (this._debug_print_status);
}
+ private void _set_writeable_store (string store_config_ids)
+ {
+ if (store_config_ids.str (":") != null)
+ {
+ var ids = store_config_ids.split (":", 2);
+ this._configured_writeable_store_type_id = ids[0];
+ this._configured_writeable_store_id = ids[1];
+ }
+ else
+ {
+ this._configured_writeable_store_type_id = store_config_ids;
+ this._configured_writeable_store_id = "";
+ }
+ }
+
private void _debug_print_status (Debug debug)
{
const string domain = Debug.STATUS_LOG_DOMAIN;
@@ -449,12 +467,22 @@ public class Folks.IndividualAggregator : Object
var store_id = this._get_store_full_id (store.type_id, store.id);
/* We use the configured PersonaStore as the only trusted and writeable
- * PersonaStore. */
+ * PersonaStore.
+ *
+ * If the type_id is `eds` we *must* know the actual store
+ * (address book) we are talking about or we might end up using
+ * a random store on every run.
+ */
if (store.type_id == this._configured_writeable_store_type_id)
{
- store.is_writeable = true;
- store.trust_level = PersonaStoreTrust.FULL;
- this._writeable_store = store;
+ if ((store.type_id != "eds" &&
+ this._configured_writeable_store_id == "") ||
+ this._configured_writeable_store_id == store.id)
+ {
+ store.is_writeable = true;
+ store.trust_level = PersonaStoreTrust.FULL;
+ this._writeable_store = store;
+ }
}
this._stores.set (store_id, store);
diff --git a/folks/persona-store.vala b/folks/persona-store.vala
index e70e88a..cdf3a69 100644
--- a/folks/persona-store.vala
+++ b/folks/persona-store.vala
@@ -374,7 +374,13 @@ public abstract class Folks.PersonaStore : Object
* This is guaranteed to always be available; even before
* { link PersonaStore.prepare} is called.
*/
- public abstract string type_id { get; }
+ public abstract string type_id
+ {
+ /* Note: the type_id must not contain colons because the primary writeable
+ * store is configured, either via GConf or the FOLKS_WRITEABLE_STORE
+ * env variable, with a string of the form 'type_id:store_id'. */
+ get;
+ }
/**
* The human-readable, service-specific name used to represent the
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]