From 4d6e2ff42009b847a88b53fe8d1c397d5460077e Mon Sep 17 00:00:00 2001 From: Travis Reitter Date: Mon, 12 Jul 2010 15:45:18 -0700 Subject: [PATCH] Combine the PersonaStore:personas-added and personas-removed signals. Also include a backend-supplied message, persona who caused the change, and reason for the change. This will allow us to pass on the more-detailed notification bits for Telepathy (eg, "You got kicked from room XYZ by Foo Bar: 'I just felt like booting someone.'"). --- backends/telepathy/tpf-persona-store.vala | 6 +-- folks/groups.vala | 62 +++++++++++++++++++++++++++++++ folks/persona-store.vala | 23 ++++++------ 3 files changed, 77 insertions(+), 14 deletions(-) diff --git a/backends/telepathy/tpf-persona-store.vala b/backends/telepathy/tpf-persona-store.vala index 535c517..ff0461f 100644 --- a/backends/telepathy/tpf-persona-store.vala +++ b/backends/telepathy/tpf-persona-store.vala @@ -566,7 +566,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore var personas = new GLib.List (); personas.append (persona); - this.personas_removed (personas); + this.personas_changed (null, personas, null, null, 0); this._personas.remove (persona.iid); } @@ -867,7 +867,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore } if (personas != null) - this.personas_added (personas); + this.personas_changed (personas, null, null, null, 0); return personas; } @@ -920,7 +920,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore this.channel_groups_add_new_personas (); if (personas != null) - this.personas_added (personas); + this.personas_changed (personas, null, null, null, 0); } private void channel_groups_add_new_personas () diff --git a/folks/groups.vala b/folks/groups.vala index fb6f8d8..82fc6e7 100644 --- a/folks/groups.vala +++ b/folks/groups.vala @@ -27,6 +27,68 @@ using GLib; public interface Folks.Groups : Object { /** + * The reason a group member has changed its membership in the group. + * + * These closely follow the + * [[http://telepathy.freedesktop.org/spec/Channel_Interface_Group.html#Channel_Group_Change_Reason|Channel_Group_Change_Reason]] + * interface in the Telepathy specification. + */ + public static enum ChangeReason + { + /* No reason was provided for this change. + * + * This is used when a member joins or leaves a group normally. */ + NONE = 0, + /* The change is due to a member going offline. + * + * Also used when member is already offline, but this wasn't known + * previously. */ + OFFLINE = 1, + /* The change is due to a kick operation. */ + KICKED = 2, + /* The change is due to a busy indication. */ + BUSY = 3, + /* The change is due to an invitation. */ + INVITED = 4, + /* The change is due to a kick+ban operation. */ + BANNED = 5, + /* The change is due to an error occurring. */ + ERROR = 6, + /* The change is because the requested member does not exist. + * + * For instance, if the user invites a nonexistent contact to a chatroom + * or attempts to call a nonexistent contact */ + INVALID_MEMBER = 7, + /* The change is because the requested contact did not respond. */ + NO_ANSWER = 8, + /* The change is because a member's unique identifier changed. + * + * There must be exactly one member in the removed set and exactly one + * member in one of the added sets. */ + RENAMED = 9, + /* The change is because there was no permission to contact the requested + * member. */ + PERMISSION_DENIED = 10, + /* If members are removed with this reason code, the change is because the + * group has split into unconnected parts which can only communicate + * within themselves (e.g. netsplits on IRC use this reason code). + * + * If members are added with this reason code, the change is because + * unconnected parts of the group have rejoined. If this channel carries + * messages (e.g. Text or Tubes channels) applications must assume that + * the contacts being added are likely to have missed some messages as a + * result of the separation, and that the contacts in the group are likely + * to have missed some messages from the contacts being added. + * + * Note that from the added contacts' perspective, they have been in the + * group all along, and the contacts we indicate to be in the group + * (including the local user) have just rejoined the group with reason + * Separated. Application protocols in Tubes should be prepared to cope + * with this situation. */ + SEPARATED = 11 + } + + /** * A mapping of group ID to whether the contact is a member. * * Freeform group IDs are mapped to a boolean which is `true` if the diff --git a/folks/persona-store.vala b/folks/persona-store.vala index e2ff024..b96a3ea 100644 --- a/folks/persona-store.vala +++ b/folks/persona-store.vala @@ -43,19 +43,20 @@ public errordomain Folks.PersonaStoreError public abstract class Folks.PersonaStore : Object { /** - * Emitted when one or more {@link Persona}s are added to the PersonaStore. + * Emitted when one or more {@link Persona}s are added to or removed from + * the store. * - * @param personas a list of {@link Persona}s added to the PersonaStore + * @param added a list of {@link Persona}s which have been removed + * @param removed a list of {@link Persona}s which have been removed + * @param message a string message from the backend, if any + * @param actor the {@link Persona} who made the change, if known + * @param reason the reason for the change */ - public abstract signal void personas_added (GLib.List personas); - - /** - * Emitted when one or more {@link Persona}s are removed from the - * PersonaStore. - * - * @param personas a list of {@link Persona}s removed from the PersonaStore - */ - public abstract signal void personas_removed (GLib.List personas); + public signal void personas_changed (GLib.List? added, + GLib.List? removed, + string? message, + Persona? actor, + Groups.ChangeReason reason); /** * Emitted when the backing store for this PersonaStore has been removed. -- 2.7.4