summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2011-06-14 15:21:29 +0100
committerPhilip Withnall <philip@tecnocode.co.uk>2011-06-22 11:59:15 +0100
commitfb8474d72d9afae514522c243503e6d928642131 (patch)
tree899a2518b9581b6ba109ed8dd781c8a4efdefecb
parent3c5ebf360d0dd934928683f6d1ee41c6ba106e91 (diff)
Bug 648071 — Add support for presence status from Telepathy
Add a presence_status property to PresenceDetails to expose the detailed presence status string that Telepathy exposes. Closes: bgo#648071
-rw-r--r--NEWS2
-rw-r--r--backends/telepathy/lib/tpf-persona.vala19
-rw-r--r--folks/individual.vala14
-rw-r--r--folks/presence-details.vala12
-rw-r--r--tests/telepathy/individual-properties.vala1
5 files changed, 48 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index fd1b071..3224224 100644
--- a/NEWS
+++ b/NEWS
@@ -6,9 +6,11 @@ Bugs fixed:
* Bug 646244 — Incomplete logic to handle attribute updates in Folks.Individual
* Bug 652463 — Tidy up CLEANFILES
* Bug 652434 — Add ability to run any tests through gdb
+* Bug 648071 — Add support for presence status from Telepathy
API changes:
* Swf.Persona retains and exposes its libsocialweb Contact
+* Add a PresenceDetails.presence_status property
Overview of changes from libfolks 0.5.1 to libfolks 0.5.2
=========================================================
diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala
index 255463d..4e6ef9c 100644
--- a/backends/telepathy/lib/tpf-persona.vala
+++ b/backends/telepathy/lib/tpf-persona.vala
@@ -75,6 +75,15 @@ public class Tpf.Persona : Folks.Persona,
public Folks.PresenceType presence_type { get; private set; }
/**
+ * The Persona's presence status.
+ *
+ * See {@link Folks.PresenceDetails.presence_status}.
+ *
+ * @since 0.5.UNRELEASED
+ */
+ public string presence_status { get; private set; }
+
+ /**
* The Persona's presence message.
*
* See {@link Folks.PresenceDetails.presence_message}.
@@ -285,8 +294,13 @@ public class Tpf.Persona : Folks.Persona,
{
this._contact_notify_presence_type ();
});
+ contact.notify["presence-status"].connect ((s, p) =>
+ {
+ this._contact_notify_presence_status ();
+ });
this._contact_notify_presence_message ();
this._contact_notify_presence_type ();
+ this._contact_notify_presence_status ();
((Tpf.PersonaStore) this.store).group_members_changed.connect (
(s, group, added, removed) =>
@@ -350,6 +364,11 @@ public class Tpf.Persona : Folks.Persona,
this.contact.get_presence_type ());
}
+ private void _contact_notify_presence_status ()
+ {
+ this.presence_status = this.contact.get_presence_status ();
+ }
+
private static PresenceType _folks_presence_type_from_tp (
TelepathyGLib.ConnectionPresenceType type)
{
diff --git a/folks/individual.vala b/folks/individual.vala
index f4a1bcf..e6f998d 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -123,6 +123,13 @@ public class Folks.Individual : Object,
/**
* {@inheritDoc}
+ *
+ * @since 0.5.UNRELEASED
+ */
+ public string presence_status { get; private set; }
+
+ /**
+ * {@inheritDoc}
*/
public string presence_message { get; private set; }
@@ -794,6 +801,7 @@ public class Folks.Individual : Object,
private void _update_presence ()
{
var presence_message = "";
+ var presence_status = "";
var presence_type = Folks.PresenceType.UNSET;
/* Choose the most available presence from our personas */
@@ -808,12 +816,15 @@ public class Folks.Individual : Object,
{
presence_type = presence.presence_type;
presence_message = presence.presence_message;
+ presence_status = presence.presence_status;
}
}
}
if (presence_message == null)
presence_message = "";
+ if (presence_status == null)
+ presence_status = "";
/* only notify if the value has changed */
if (this.presence_message != presence_message)
@@ -821,6 +832,9 @@ public class Folks.Individual : Object,
if (this.presence_type != presence_type)
this.presence_type = presence_type;
+
+ if (this.presence_status != presence_status)
+ this.presence_status = presence_status;
}
private void _update_is_favourite ()
diff --git a/folks/presence-details.vala b/folks/presence-details.vala
index acd4ac1..a23ecc7 100644
--- a/folks/presence-details.vala
+++ b/folks/presence-details.vala
@@ -99,6 +99,18 @@ public interface Folks.PresenceDetails : Object
*/
public abstract string presence_message { get; set; default = ""; }
+ /**
+ * The contact's detailed presence status.
+ *
+ * This is a more detailed representation of the contact's presence than
+ * {@link PresenceDetails.presence_type}. It may be empty, or one of a
+ * well-known set of strings, as defined in the Telepathy specification:
+ * {@link http://telepathy.freedesktop.org/spec/Connection_Interface_Simple_Presence.html#description}
+ *
+ * @since 0.5.UNRELEASED
+ */
+ public abstract string presence_status { get; set; default = ""; }
+
/* Rank the presence types for comparison purposes, with higher numbers
* meaning more available */
private static int _type_availability (PresenceType type)
diff --git a/tests/telepathy/individual-properties.vala b/tests/telepathy/individual-properties.vala
index d7cfa94..ccb6fa2 100644
--- a/tests/telepathy/individual-properties.vala
+++ b/tests/telepathy/individual-properties.vala
@@ -62,6 +62,7 @@ public class IndividualPropertiesTests : Folks.TestCase
/* Check properties */
assert (i.alias == "Olivier");
assert (i.presence_message == "");
+ assert (i.presence_status == "away");
assert (i.presence_type == PresenceType.AWAY);
assert (((PresenceDetails) i).is_online () == true);