summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Crequy <alban.crequy@collabora.co.uk>2011-05-11 14:19:46 +0100
committerTravis Reitter <travis.reitter@collabora.co.uk>2011-06-01 18:33:20 -0700
commitd016a8345dff6b20e319b2427e1132836f5e7928 (patch)
tree3bbe0d54b02f62e6814ae9f475d31d7cadbc5a4d
parent20128af512e75b117b82ae46998e4287ca03a36b (diff)
libsocialweb: Swf.Persona stores SocialWebClient.Contact
Closes: bgo#649925 - expose SocialWebClient.Contact in Swf.Persona
-rw-r--r--NEWS6
-rw-r--r--backends/libsocialweb/lib/swf-persona.vala21
-rw-r--r--tests/libsocialweb/dummy-lsw.vala34
3 files changed, 59 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index a835563..d434b39 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
Overview of changes from libfolks 0.5.2 to libfolks 0.5.3
=========================================================
+Bugs fixed:
+* Bug 649925 — expose SocialWebClient.Contact in Swf.Persona
+
+API changes:
+* Swf.Persona retains and exposes its libsocialweb Contact
+
Overview of changes from libfolks 0.5.1 to libfolks 0.5.2
=========================================================
diff --git a/backends/libsocialweb/lib/swf-persona.vala b/backends/libsocialweb/lib/swf-persona.vala
index b2d1bda..c65897b 100644
--- a/backends/libsocialweb/lib/swf-persona.vala
+++ b/backends/libsocialweb/lib/swf-persona.vala
@@ -121,6 +121,24 @@ public class Swf.Persona : Folks.Persona,
private set {}
}
+ private Contact _lsw_contact;
+
+ /**
+ * The Contact from libsocialweb
+ */
+ public Contact lsw_contact
+ {
+ get { return this._lsw_contact; }
+ private set
+ {
+ if (_lsw_contact != null && _lsw_contact != value)
+ {
+ _lsw_contact.unref ();
+ }
+ this._lsw_contact = value.ref ();
+ }
+ }
+
/**
* Build the Facebook JID.
*
@@ -188,6 +206,7 @@ public class Swf.Persona : Folks.Persona,
iid: iid,
store: store,
is_user: false);
+ this.lsw_contact = contact;
debug ("Creating new Sw.Persona '%s' for %s UID '%s': %p",
uid, store.display_name, id, this);
@@ -218,6 +237,8 @@ public class Swf.Persona : Folks.Persona,
~Persona ()
{
debug ("Destroying Sw.Persona '%s': %p", this.uid, this);
+ this._lsw_contact.unref ();
+ this._lsw_contact = null;
}
public static string? get_contact_id (Contact contact)
diff --git a/tests/libsocialweb/dummy-lsw.vala b/tests/libsocialweb/dummy-lsw.vala
index 2269543..7db9831 100644
--- a/tests/libsocialweb/dummy-lsw.vala
+++ b/tests/libsocialweb/dummy-lsw.vala
@@ -22,6 +22,7 @@ using LibsocialwebTest;
using Folks;
using Gee;
using GLib;
+using SocialWebClient;
public class DummyLswTests : Folks.TestCase
{
@@ -110,7 +111,8 @@ public class DummyLswTests : Folks.TestCase
Idle.add (() =>
{
string text = "([('mysocialnetwork', 'id01', %x, "
- + "{'id': ['id01'], 'name': ['Gargantua']}), "
+ + "{'id': ['id01'], 'name': ['Gargantua'], "
+ + "'X-foo': ['secret']}), "
+ "('mysocialnetwork', 'id02', %x, "
+ "{'id': ['id02'], 'name': ['Pantagruel']})],)";
Variant v = new Variant.parsed (text, 1300792578, 1300792579);
@@ -164,12 +166,37 @@ public class DummyLswTests : Folks.TestCase
aggregator.disconnect (handler_id);
assert (i1 != null);
assert (i2 != null);
+ Folks.Persona persona1 = null;
+ Folks.Persona persona2 = null;
+ foreach (var p1 in i1.personas)
+ {
+ persona1 = p1;
+ break;
+ }
+ foreach (var p2 in i2.personas)
+ {
+ persona2 = p2;
+ break;
+ }
+ assert (persona1 is Swf.Persona);
+ assert (persona2 is Swf.Persona);
+ Contact contact1 = ((Swf.Persona) persona1).lsw_contact;
+ Contact contact2 = ((Swf.Persona) persona2).lsw_contact;
+ assert (contact1 != null);
+ assert (contact2 != null);
+ assert (contact1.get_value ("id") == "id01");
+ assert (contact1.get_value ("X-foo") == "secret");
+ assert (contact1.get_value ("X-bar") == null);
+ assert (contact2.get_value ("id") == "id02");
+ assert (contact2.get_value ("X-foo") == null);
+
/* Test changing a contact */
Idle.add (() =>
{
string text = "([('mysocialnetwork', 'id01', %x, "
- + "{'id': ['id01'], 'name': ['Rabelais']})],)";
+ + "{'id': ['id01'], 'name': ['Rabelais'], "
+ + "'X-foo': ['secret'], 'X-bar': ['bar']})],)";
Variant v = new Variant.parsed (text, 1300792581);
try
{
@@ -194,6 +221,9 @@ public class DummyLswTests : Folks.TestCase
debug ("Aggregator changed some data!");
string nickname = ((Folks.NameDetails) i1).nickname;
assert (nickname == "Rabelais");
+ assert (contact1.get_value ("id") == "id01");
+ assert (contact1.get_value ("X-foo") == "secret");
+ assert (contact1.get_value ("X-bar") == "bar");
main_loop.quit ();
});