Commit 44f9a831 authored by Raul Gutierrez Segales's avatar Raul Gutierrez Segales
Browse files

Let each PersonaStore manage its trust-level

Previously, the IndividualAggregator was in charge of
downgrading and upgrading the trust-level of each
PersonaStore. From now on, we let each Store manage its
trust-level since it's the natural way to do it.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=659075
parent 7d4d0100
......@@ -61,6 +61,7 @@ public class Edsf.PersonaStore : Folks.PersonaStore
private void _address_book_notify_read_only_cb (Object address_book,
ParamSpec pspec)
{
this._update_trust_level ();
this.notify_property ("can-add-personas");
this.notify_property ("can-remove-personas");
}
......@@ -208,7 +209,6 @@ public class Edsf.PersonaStore : Folks.PersonaStore
this._personas = new HashMap<string, Persona> ();
this._personas_ro = this._personas.read_only_view;
this._query_str = "(contains \"x-evolution-any-field\" \"\")";
this.trust_level = PersonaStoreTrust.PARTIAL;
}
~PersonaStore ()
......@@ -546,6 +546,8 @@ public class Edsf.PersonaStore : Folks.PersonaStore
this._address_book_notify_read_only_cb);
yield this._addressbook.open (false, null);
this._update_trust_level ();
}
catch (GLib.Error e1)
{
......@@ -1821,4 +1823,32 @@ public class Edsf.PersonaStore : Folks.PersonaStore
this.removed ();
}
}
/* This isn't perfect, since we want to base our trust of the address book on
* whether *other people* can write to it (and potentially maliciously affect
* the linking our aggregator does). However, since we can't know that, we
* assume that if we can write to the address book we're probably in full
* control of it. If we can't, either nobody/a sysadmin is (e.g. LDAP) or
* or somebody else (who we can't trust) is (e.g. a read-only view of someone
* else's WebDAV address book).
*/
private void _update_trust_level ()
{
unowned SourceGroup? group = (SourceGroup?) this._source.peek_group ();
if (group != null)
{
var base_uri = group.peek_base_uri ();
/* base_uri should be ldap:// for LDAP based address books */
if (base_uri != null && base_uri.has_prefix("ldap"))
{
this.trust_level = PersonaStoreTrust.PARTIAL;
return;
}
}
if (this._addressbook.readonly)
this.trust_level = PersonaStoreTrust.PARTIAL;
else
this.trust_level = PersonaStoreTrust.FULL;
}
}
......@@ -417,6 +417,7 @@ public class Trf.PersonaStore : Folks.PersonaStore
this._personas = new HashMap<string, Persona> ();
this._personas_ro = this._personas.read_only_view;
debug ("Initial query : \n%s\n", this._INITIAL_QUERY);
this.trust_level = PersonaStoreTrust.FULL;
}
/**
......
......@@ -614,7 +614,6 @@ public class Folks.IndividualAggregator : Object
this._configured_primary_store_id == store.id)
{
store.is_primary_store = true;
store.trust_level = PersonaStoreTrust.FULL;
this._primary_store = store;
this.notify_property ("primary-store");
}
......@@ -624,7 +623,6 @@ public class Folks.IndividualAggregator : Object
store.personas_changed.connect (this._personas_changed_cb);
store.notify["is-primary-store"].connect (
this._is_primary_store_changed_cb);
store.notify["trust-level"].connect (this._trust_level_changed_cb);
store.notify["is-quiescent"].connect (
this._persona_store_is_quiescent_changed_cb);
......@@ -660,7 +658,6 @@ public class Folks.IndividualAggregator : Object
store.personas_changed.disconnect (this._personas_changed_cb);
store.notify["is-quiescent"].disconnect (
this._persona_store_is_quiescent_changed_cb);
store.notify["trust-level"].disconnect (this._trust_level_changed_cb);
store.notify["is-primary-store"].disconnect (
this._is_primary_store_changed_cb);
......@@ -1277,17 +1274,6 @@ public class Folks.IndividualAggregator : Object
store != this._primary_store));
}
private void _trust_level_changed_cb (Object object, ParamSpec pspec)
{
/* Only our primary_store can be fully trusted. */
var store = (PersonaStore) object;
if (this._primary_store != null &&
store == this._primary_store)
assert (store.trust_level == PersonaStoreTrust.FULL);
else
assert (store.trust_level != PersonaStoreTrust.FULL);
}
private void _persona_store_is_quiescent_changed_cb (Object obj,
ParamSpec pspec)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment