[folks] telepathy: Correctly advertise the writeability of alias and group properties
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] telepathy: Correctly advertise the writeability of alias and group properties
- Date: Tue, 17 Apr 2012 11:17:38 +0000 (UTC)
commit 834cb05e09c75d1ed0100af3a495217b04a20670
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Mar 26 16:58:50 2012 +0100
telepathy: Correctly advertise the writeability of alias and group properties
Previously, Tpf.Personas were always advertising aliases and groups as
being writeable properties, when they're actually not writeable for
Facebook XMPP connections.
Aliases were previously not writeable in the Telepathy fake CM (so the test
was previously in error), but theyâre now writeable, so everythingâs fine.
Closes: https://bugzilla.gnome.org/show_bug.cgi?id=671662
NEWS | 1 +
backends/telepathy/lib/tpf-persona-store.vala | 70 ++++++++++++++-----------
backends/telepathy/lib/tpf-persona.vala | 62 +++++++++++-----------
3 files changed, 70 insertions(+), 63 deletions(-)
---
diff --git a/NEWS b/NEWS
index febb240..a0031ec 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Overview of changes from libfolks 0.6.9 to libfolks 0.7.0
Bugs fixed:
â Bug 658576 â Need API to get a FolksIndividual from his ID
+â Bug 671662 â Renamed alias of Facebook contact is not saved
API changes:
â Add IndividualAggregator.look_up_individual()
diff --git a/backends/telepathy/lib/tpf-persona-store.vala b/backends/telepathy/lib/tpf-persona-store.vala
index 2263e07..80880f0 100644
--- a/backends/telepathy/lib/tpf-persona-store.vala
+++ b/backends/telepathy/lib/tpf-persona-store.vala
@@ -40,10 +40,7 @@ extern const string BACKEND_NAME;
*/
public class Tpf.PersonaStore : Folks.PersonaStore
{
- private const string[] _always_writeable_properties =
- {
- "is-favourite"
- };
+ private string[] _always_writeable_properties = { "is-favourite" };
/* Sets of Personas exposed by this store.
* This is the roster + self_contact */
@@ -692,6 +689,9 @@ public class Tpf.PersonaStore : Folks.PersonaStore
if (this._conn.get_group_storage () != ContactMetadataStorageType.NONE)
{
this._can_group_personas = MaybeBool.TRUE;
+
+ this._always_writeable_properties += "groups";
+ this.notify_property ("always-writeable-properties");
}
else
{
@@ -711,40 +711,45 @@ public class Tpf.PersonaStore : Folks.PersonaStore
}
this.notify_property ("can-add-personas");
this.notify_property ("can-remove-personas");
- this.thaw_notify ();
-
- /* Add the local user */
- this._conn.notify["self-contact"].connect (this._self_contact_changed_cb);
- this._self_contact_changed_cb (this._conn, null);
/* FIXME: TpConnection still does not have high-level API for this.
* See fd.o#14540 */
- FolksTpLowlevel.connection_get_alias_flags_async.begin (this._conn, (s2, res) =>
+ /* We have to do this before emitting the self persona so that code which
+ * checks the self persona's writeable fields gets correct values. */
+ var new_can_alias = MaybeBool.FALSE;
+
+ try
{
- var new_can_alias = MaybeBool.FALSE;
- try
- {
- var flags =
- FolksTpLowlevel.connection_get_alias_flags_async.end (res);
- if ((flags &
- ConnectionAliasFlags.CONNECTION_ALIAS_FLAG_USER_SET) > 0)
- {
- new_can_alias = MaybeBool.TRUE;
- }
- }
- catch (GLib.Error e)
+ var flags = yield FolksTpLowlevel.connection_get_alias_flags_async (
+ this._conn);
+
+ if ((flags &
+ ConnectionAliasFlags.CONNECTION_ALIAS_FLAG_USER_SET) > 0)
{
- GLib.warning (
- /* Translators: the first parameter is the display name for
- * the Telepathy account, and the second is an error
- * message. */
- _("Failed to determine whether we can set aliases on Telepathy account '%s': %s"),
- this.display_name, e.message);
+ new_can_alias = MaybeBool.TRUE;
+
+ this._always_writeable_properties += "alias";
+ this.notify_property ("always-writeable-properties");
}
+ }
+ catch (GLib.Error e)
+ {
+ GLib.warning (
+ /* Translators: the first parameter is the display name for
+ * the Telepathy account, and the second is an error
+ * message. */
+ _("Failed to determine whether we can set aliases on Telepathy account '%s': %s"),
+ this.display_name, e.message);
+ }
- this._can_alias_personas = new_can_alias;
- this.notify_property ("can-alias-personas");
- });
+ this._can_alias_personas = new_can_alias;
+ this.notify_property ("can-alias-personas");
+
+ this.thaw_notify ();
+
+ /* Add the local user */
+ this._conn.notify["self-contact"].connect (this._self_contact_changed_cb);
+ this._self_contact_changed_cb (this._conn, null);
this._conn.notify["contact-list-state"].connect (this._contact_list_state_changed_cb);
this._contact_list_state_changed_cb (this._conn, null);
@@ -838,6 +843,9 @@ public class Tpf.PersonaStore : Folks.PersonaStore
this._can_alias_personas = MaybeBool.FALSE;
this._can_group_personas = MaybeBool.FALSE;
this._can_remove_personas = MaybeBool.FALSE;
+
+ this._always_writeable_properties = { "is-favourite" };
+ this.notify_property ("always-writeable-properties");
}
/**
diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala
index b8543af..5401504 100644
--- a/backends/telepathy/lib/tpf-persona.vala
+++ b/backends/telepathy/lib/tpf-persona.vala
@@ -41,12 +41,6 @@ public class Tpf.Persona : Folks.Persona,
UrlDetails
{
private const string[] _linkable_properties = { "im-addresses" };
- private const string[] _always_writeable_properties =
- {
- "alias",
- "is-favourite",
- "groups"
- };
private string[] _writeable_properties = null;
/* Whether we've finished being constructed; this is used to prevent
@@ -263,13 +257,7 @@ public class Tpf.Persona : Folks.Persona,
*/
public override string[] writeable_properties
{
- get
- {
- if (this.is_user)
- return this._writeable_properties;
-
- return this._always_writeable_properties;
- }
+ get { return this._writeable_properties; }
}
private string _alias = ""; /* must never be null */
@@ -761,15 +749,22 @@ public class Tpf.Persona : Folks.Persona,
});
this._contact_groups_changed (this.contact.get_contact_groups (), {});
+ var tpf_store = this.store as Tpf.PersonaStore;
+
if (this.is_user)
{
- ((Tpf.PersonaStore) this.store).notify["supported-fields"].connect (
- (s, p) =>
- {
- this._store_notify_supported_fields ();
- });
- this._store_notify_supported_fields ();
+ tpf_store.notify["supported-fields"].connect ((s, p) =>
+ {
+ this._update_writeable_properties ();
+ });
}
+
+ tpf_store.notify["always-writeable-properties"].connect ((s, p) =>
+ {
+ this._update_writeable_properties ();
+ });
+
+ this._update_writeable_properties ();
}
/* Called after all construction-time properties have been set. */
@@ -778,21 +773,24 @@ public class Tpf.Persona : Folks.Persona,
this._is_constructed = true;
}
- private void _store_notify_supported_fields ()
+ private void _update_writeable_properties ()
{
var tpf_store = this.store as Tpf.PersonaStore;
- this._writeable_properties = this._always_writeable_properties;
-
- if ("bday" in tpf_store.supported_fields)
- this._writeable_properties += "birthday";
- if ("email" in tpf_store.supported_fields)
- this._writeable_properties += "email-addresses";
- if ("fn" in tpf_store.supported_fields)
- this._writeable_properties += "full-name";
- if ("tel" in tpf_store.supported_fields)
- this._writeable_properties += "phone-numbers";
- if ("url" in tpf_store.supported_fields)
- this._writeable_properties += "urls";
+ this._writeable_properties = this.store.always_writeable_properties;
+
+ if (this.is_user)
+ {
+ if ("bday" in tpf_store.supported_fields)
+ this._writeable_properties += "birthday";
+ if ("email" in tpf_store.supported_fields)
+ this._writeable_properties += "email-addresses";
+ if ("fn" in tpf_store.supported_fields)
+ this._writeable_properties += "full-name";
+ if ("tel" in tpf_store.supported_fields)
+ this._writeable_properties += "phone-numbers";
+ if ("url" in tpf_store.supported_fields)
+ this._writeable_properties += "urls";
+ }
}
private void _contact_notify_contact_info ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]