Commit d797e8e1 authored by Raul Gutierrez Segales's avatar Raul Gutierrez Segales
Browse files

core: add Folks.PersonaStore.user-set-default property

With this property we can tell if a Store (i.e.: an e-d-s address
book) has been marked by the user as his default store (either from
Evo or from GOA, etc).

Helps: https://bugzilla.gnome.org/show_bug.cgi?id=657141
parent 32c95ea8
......@@ -26,6 +26,7 @@ API changes:
* Add Folks.IndividualAggregatorError.NO_PRIMARY_STORE
* In IndividualAggregator.ensure_individual_property_writeable we now throw
NO_PRIMARY_STORE instead of NO_WRITEABLE_STORE
* Add Folks.PersonaStore.user_set_default
Overview of changes from libfolks 0.6.2 to libfolks 0.6.2.1
===========================================================
......
......@@ -644,6 +644,7 @@ public class Folks.IndividualAggregator : Object
{
var store_id = this._get_store_full_id (store.type_id, store.id);
this._maybe_configure_as_primary (store);
this._set_primary_store (store);
this._stores.set (store_id, store);
......@@ -652,6 +653,8 @@ public class Folks.IndividualAggregator : Object
this._is_primary_store_changed_cb);
store.notify["is-quiescent"].connect (
this._persona_store_is_quiescent_changed_cb);
store.notify["is-user-set-default"].connect (
this._persona_store_is_user_set_default_changed_cb);
/* Increase the number of non-quiescent persona stores we're waiting for.
* If we've already reached a quiescent state, this is ignored. If we
......@@ -687,6 +690,8 @@ public class Folks.IndividualAggregator : Object
this._persona_store_is_quiescent_changed_cb);
store.notify["is-primary-store"].disconnect (
this._is_primary_store_changed_cb);
store.notify["is-user-set-default"].disconnect (
this._persona_store_is_user_set_default_changed_cb);
/* If we were still waiting on this persona store to reach a quiescent
* state, stop waiting. */
......@@ -1332,6 +1337,29 @@ public class Folks.IndividualAggregator : Object
}
}
private void _persona_store_is_user_set_default_changed_cb (Object obj,
ParamSpec pspec)
{
var store = (PersonaStore) obj;
if (this._maybe_configure_as_primary (store))
this._set_primary_store (store);
}
private bool _maybe_configure_as_primary (PersonaStore store)
{
var configured = false;
if (!this._user_configured_primary_store &&
store.is_user_set_default)
{
this._configured_primary_store_type_id = store.type_id;
this._configured_primary_store_id = store.id;
configured = true;
}
return configured;
}
private void _individual_removed_cb (Individual i, Individual? replacement)
{
if (this.user == i)
......
......@@ -645,4 +645,13 @@ public abstract class Folks.PersonaStore : Object
* @since UNRELEASED
*/
public bool is_primary_store { get; internal set; default = false; }
/**
* Whether this {@link PersonaStore} has been marked as the default
* store (in its backend) by the user. I.e.: a PersonaStore for the e-d-s
* backend would set this to true if it represents the default address book.
*
* @since UNRELEASED
*/
public bool is_user_set_default { get; internal set; default = false; }
}
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