[folks] Add the PersonaStore:can-remove-personas property.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Add the PersonaStore:can-remove-personas property.
- Date: Wed, 13 Oct 2010 18:37:54 +0000 (UTC)
commit 074a341f2b84096195ae525b0d6da03480d7cacc
Author: Travis Reitter <travis reitter collabora co uk>
Date: Fri Oct 8 15:42:18 2010 -0700
Add the PersonaStore:can-remove-personas property.
Helps bgo#626179.
backends/key-file/kf-persona-store.vala | 12 +++++++++
backends/telepathy/lib/tpf-persona-store.vala | 17 ++++++++++++
folks/persona-store.vala | 11 ++++++++
tests/telepathy/persona-store-capabilities.vala | 31 ++++++++++++++++++++---
4 files changed, 67 insertions(+), 4 deletions(-)
---
diff --git a/backends/key-file/kf-persona-store.vala b/backends/key-file/kf-persona-store.vala
index fe52a6b..008e6ba 100644
--- a/backends/key-file/kf-persona-store.vala
+++ b/backends/key-file/kf-persona-store.vala
@@ -66,6 +66,18 @@ public class Folks.Backends.Kf.PersonaStore : Folks.PersonaStore
}
/**
+ * Whether this PersonaStore can remove { link Folks.Persona}s.
+ *
+ * See { link Folks.PersonaStore.can_remove_personas}.
+ *
+ * @since 0.3.1
+ */
+ public override MaybeBool can_remove_personas
+ {
+ get { return MaybeBool.TRUE; }
+ }
+
+ /**
* Whether this PersonaStore has been prepared.
*
* See { link Folks.PersonaStore.is_prepared}.
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 442120e..ef853d4 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -66,6 +66,7 @@ public class Tpf.PersonaStore : Folks.PersonaStore
private Logger logger;
private Contact self_contact;
private MaybeBool _can_add_personas = MaybeBool.UNSET;
+ private MaybeBool _can_remove_personas = MaybeBool.UNSET;
private bool _is_prepared = false;
internal signal void group_members_changed (string group,
@@ -115,6 +116,18 @@ public class Tpf.PersonaStore : Folks.PersonaStore
}
/**
+ * Whether this PersonaStore can remove { link Folks.Persona}s.
+ *
+ * See { link Folks.PersonaStore.can_remove_personas}.
+ *
+ * @since 0.3.1
+ */
+ public override MaybeBool can_remove_personas
+ {
+ get { return this._can_remove_personas; }
+ }
+
+ /**
* Whether this PersonaStore has been prepared.
*
* See { link Folks.PersonaStore.is_prepared}.
@@ -653,6 +666,10 @@ public class Tpf.PersonaStore : Folks.PersonaStore
this.update_capability ((ChannelGroupFlags) added,
(ChannelGroupFlags) removed, ChannelGroupFlags.CAN_ADD,
ref this._can_add_personas, "can-add-personas");
+
+ this.update_capability ((ChannelGroupFlags) added,
+ (ChannelGroupFlags) removed, ChannelGroupFlags.CAN_REMOVE,
+ ref this._can_remove_personas, "can-remove-personas");
}
private void update_capability (
diff --git a/folks/persona-store.vala b/folks/persona-store.vala
index 37507af..ad67c27 100644
--- a/folks/persona-store.vala
+++ b/folks/persona-store.vala
@@ -183,6 +183,17 @@ public abstract class Folks.PersonaStore : Object
public abstract MaybeBool can_add_personas { get; default = MaybeBool.UNSET; }
/**
+ * Whether this { link PersonaStore} can remove { link Persona}s.
+ *
+ * @since 0.3.1
+ */
+ public abstract MaybeBool can_remove_personas
+ {
+ get;
+ default = MaybeBool.UNSET;
+ }
+
+ /**
* Whether { link PersonaStore.prepare} has successfully completed for this
* store.
*
diff --git a/tests/telepathy/persona-store-capabilities.vala b/tests/telepathy/persona-store-capabilities.vala
index 46dd5e2..cd2a5f8 100644
--- a/tests/telepathy/persona-store-capabilities.vala
+++ b/tests/telepathy/persona-store-capabilities.vala
@@ -14,7 +14,7 @@ public class PersonaStoreCapabilitiesTests : Folks.TestCase
private MainLoop main_loop;
private string bus_name;
private string object_path;
- private bool got_group_flags;
+ private HashSet<string> group_flags_received;
public PersonaStoreCapabilitiesTests ()
{
@@ -26,7 +26,7 @@ public class PersonaStoreCapabilitiesTests : Folks.TestCase
public override void set_up ()
{
- this.got_group_flags = false;
+ this.group_flags_received = new HashSet<string> (str_hash, str_equal);
this.main_loop = new GLib.MainLoop (null, false);
@@ -170,7 +170,8 @@ public class PersonaStoreCapabilitiesTests : Folks.TestCase
main_loop.run ();
- assert (this.got_group_flags);
+ assert (this.group_flags_received.contains ("can-add-personas"));
+ assert (this.group_flags_received.contains ("can-remove-personas"));
}
private void set_up_persona_store (Folks.PersonaStore store)
@@ -186,6 +187,12 @@ public class PersonaStoreCapabilitiesTests : Folks.TestCase
else
store.notify["can-add-personas"].connect (
this.can_add_personas_cb);
+
+ if (store.can_remove_personas != MaybeBool.UNSET)
+ can_remove_personas_cb (store, null);
+ else
+ store.notify["can-remove-personas"].connect (
+ this.can_remove_personas_cb);
}
catch (GLib.Error e)
{
@@ -204,12 +211,28 @@ public class PersonaStoreCapabilitiesTests : Folks.TestCase
{
assert (store.can_add_personas == MaybeBool.TRUE);
- this.got_group_flags = true;
+ this.group_flags_received.add ("can-add-personas");
store.notify["can-add-personas"].disconnect (
this.can_add_personas_cb);
}
}
+
+ private void can_remove_personas_cb (GLib.Object s, ParamSpec? p)
+ {
+ assert (s is Tpf.PersonaStore);
+ var store = (Tpf.PersonaStore) s;
+
+ if (store.can_remove_personas != MaybeBool.UNSET)
+ {
+ assert (store.can_remove_personas == MaybeBool.TRUE);
+
+ this.group_flags_received.add ("can-remove-personas");
+
+ store.notify["can-remove-personas"].disconnect (
+ this.can_remove_personas_cb);
+ }
+ }
}
public int main (string[] args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]