From 629aa199668b32ff33452d9d22985e21193c6e4f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Sun, 3 Jul 2011 20:38:29 +0100 Subject: [PATCH] =?utf8?q?Bug=20645549=20=E2=80=94=20Add=20a=20way=20to=20?= =?utf8?q?get=20the=20individual=20from=20a=20persona?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a Persona.individual property which is updated by Individual._connect_to_persona() and ._disconnect_from_persona() as appropriate, so should remain in lock-step with the Individual whose persona set the Persona instance is currently in. Closes: bgo#645549 --- NEWS | 2 ++ folks/individual.vala | 9 +++++++-- folks/persona.vala | 29 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index e2853fb..fc737c8 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ Bugs fixed: * Bug 654509 — Folks master not building * Bug 652048 — Make nickname writable * Bug 652425 — Failure codes for removing personas needed in PersonaStoreError +* Bug 645549 — Add a way to get the individual from a persona API changes: * Swf.Persona retains and exposes its libsocialweb Contact @@ -27,6 +28,7 @@ API changes: * Add PersonaStoreError.PERMISSION_DENIED and PersonaStoreError.REMOVE_FAILED * Change the error domain of PersonaStore.remove_persona() from GLib.Error to Folks.PersonaStoreError +* Add a Persona.individual property Overview of changes from libfolks 0.5.1 to libfolks 0.5.2 ========================================================= diff --git a/folks/individual.vala b/folks/individual.vala index 79630e3..8cdb9dd 100644 --- a/folks/individual.vala +++ b/folks/individual.vala @@ -1101,6 +1101,8 @@ public class Folks.Individual : Object, private void _connect_to_persona (Persona persona) { + persona.individual = this; + persona.notify["alias"].connect (this._notify_alias_cb); persona.notify["avatar"].connect (this._notify_avatar_cb); persona.notify["presence-message"].connect (this._notify_presence_cb); @@ -1208,7 +1210,8 @@ public class Folks.Individual : Object, } } - private void _disconnect_from_persona (Persona persona) + private void _disconnect_from_persona (Persona persona, + Individual? replacement_individual) { persona.notify["alias"].disconnect (this._notify_alias_cb); persona.notify["avatar"].disconnect (this._notify_avatar_cb); @@ -1244,6 +1247,8 @@ public class Folks.Individual : Object, ((GroupDetails) persona).group_changed.disconnect ( this._persona_group_changed_cb); } + + persona.individual = replacement_individual; } private void _update_gender () @@ -1558,7 +1563,7 @@ public class Folks.Individual : Object, this._stores.unset (store); } - this._disconnect_from_persona (p); + this._disconnect_from_persona (p, replacement_individual); iter.remove (); } } diff --git a/folks/persona.vala b/folks/persona.vala index 8f36b81..a49805b 100644 --- a/folks/persona.vala +++ b/folks/persona.vala @@ -30,6 +30,8 @@ using GLib; */ public abstract class Folks.Persona : Object { + private weak Individual _individual; + /** * The internal ID used to represent the Persona for linking. * @@ -105,6 +107,33 @@ public abstract class Folks.Persona : Object public weak PersonaStore store { get; construct; } /** + * The {@link Individual} which contains this Persona. + * + * This may be `null`, but should only ever be so when the Persona has just + * been created, when its {@link PersonaStore} is being destroyed, or when + * it's moving between {@link Individual}s. + * + * @since UNRELEASED + */ + public weak Individual? individual + { + get + { + assert (this._individual == null || + this._individual.personas.contains (this)); + + return this._individual; + } + + internal set + { + assert (value == null || value.personas.contains (this)); + + this._individual = value; + } + } + + /** * The names of the properties of this Persona which are linkable. * * If a property name is in this list, and the Persona is from a -- 2.7.4