private Cancellable? _load_cache_cancellable = null;
private bool _cached = false;
+ /* marshalled from ContactInfo.SupportedFields */
+ internal HashSet<string> _supported_fields;
+ internal Set<string> _supported_fields_ro;
internal signal void group_members_changed (string group,
GLib.List<Persona>? added, GLib.List<Persona>? removed);
internal signal void group_removed (string group, GLib.Error? error);
get { return this._personas_ro; }
}
+ internal Set<string> supported_fields
+ {
+ get { return this._supported_fields_ro; }
+ }
+
/**
* Create a new PersonaStore.
*
}
}
+ this._supported_fields = new HashSet<string> ();
+ this._supported_fields_ro = this._supported_fields.read_only_view;
this._groups = new HashMap<string, Channel> ();
this._favourite_handles = new HashSet<uint> ();
this._self_contact = null;
/* account disconnected */
if (account.connection == null)
{
+ this._supported_fields.clear ();
+ this.notify_property ("supported-fields");
+
/* When disconnecting, we want the PersonaStore to remain alive, but
* all its Personas to be removed. We do *not* want the PersonaStore
* to be destroyed, as that makes coming back online hard.
FolksTpLowlevel.connection_connect_to_new_group_channels (c,
this._new_group_channels_cb);
+ this._marshall_supported_fields ();
+ this.notify_property ("supported-fields");
+
FolksTpLowlevel.connection_get_alias_flags_async.begin (c, (s2, res) =>
{
var new_can_alias = MaybeBool.FALSE;
this._initialise_favourite_contacts.begin ();
}
+ private void _marshall_supported_fields ()
+ {
+ var connection = this.account.connection;
+ if (connection != null)
+ {
+ this._supported_fields.clear ();
+
+ var ci_flags = connection.get_contact_info_flags ();
+ if ((ci_flags & ContactInfoFlags.CAN_SET) != 0)
+ {
+ var field_specs =
+ connection.get_contact_info_supported_fields ();
+ foreach (var field_spec in field_specs)
+ {
+ /* XXX: we ignore the maximum count for each type of
+ * field since the common-sense count for each
+ * corresponding field (eg, full-name max = 1) in
+ * Folks is already reflected in our API and we have
+ * no other way to express it; but this seems a very
+ * minor problem */
+ this._supported_fields.add (field_spec.name);
+ }
+ }
+ }
+ }
+
/**
* If our account is disconnected, we want to continue to export a static
* view of personas from the cache.
get
{
if (this.is_user)
- {
- var connection =
- ((Tpf.PersonaStore) this.store).account.connection;
- if (connection != null)
- {
- var ci_flags = connection.get_contact_info_flags ();
- if ((ci_flags & ContactInfoFlags.CAN_SET) != 0)
- {
- var field_specs =
- connection.get_contact_info_supported_fields ();
- var supported_fields = new HashSet<string> ();
- foreach (var field_spec in field_specs)
- {
- /* XXX: we ignore the maximum count for each type of
- * field since the common-sense count for each
- * corresponding field (eg, full-name max = 1) in
- * Folks is already reflected in our API and we have
- * no other way to express it; but this seems a very
- * minor problem */
- supported_fields.add (field_spec.name);
- }
-
- this._writeable_properties =
- this._always_writeable_properties;
-
- if ("fn" in supported_fields)
- this._writeable_properties += "full-name";
- if ("tel" in supported_fields)
- this._writeable_properties += "phone-numbers";
-
- return this._writeable_properties;
- }
- }
- }
+ return this._writeable_properties;
return this._always_writeable_properties;
}
store: store,
is_user: contact.handle == connection.self_handle);
+
this._full_name = "";
contact.notify["alias"].connect ((s, p) =>
this._change_group (group, false);
}
});
+
+ if (this.is_user)
+ {
+ ((Tpf.PersonaStore) this.store).notify["supported-fields"].connect (
+ (s, p) =>
+ {
+ this._store_notify_supported_fields ();
+ });
+ this._store_notify_supported_fields ();
+ }
+ }
+
+ private void _store_notify_supported_fields ()
+ {
+ var tpf_store = this.store as Tpf.PersonaStore;
+ this._writeable_properties = this._always_writeable_properties;
+
+ if ("fn" in tpf_store.supported_fields)
+ this._writeable_properties += "full-name";
+ if ("tel" in tpf_store.supported_fields)
+ this._writeable_properties += "phone-numbers";
}
private void _contact_notify_contact_info ()