}
static void
+set_contact_alias_cb (TpConnection *conn,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ if (error != NULL)
+ {
+ g_warning ("failed to change contact's alias: %s", error->message);
+ return;
+ }
+}
+
+void
+folks_tp_lowlevel_connection_set_contact_alias (
+ FolksTpLowlevel *tp_lowlevel,
+ TpConnection *conn,
+ TpHandle handle,
+ const gchar *alias)
+{
+ GHashTable *ht = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
+ g_free);
+ g_hash_table_insert (ht, GUINT_TO_POINTER (handle), g_strdup (alias));
+
+ tp_cli_connection_interface_aliasing_call_set_aliases (conn, -1,
+ ht, set_contact_alias_cb, NULL, NULL, NULL);
+
+ g_hash_table_destroy (ht);
+}
+
+static void
iterate_on_channels (TpConnection *conn,
const GPtrArray *channels,
gpointer user_data,
const char *name);
void
+folks_tp_lowlevel_connection_set_contact_alias (
+ FolksTpLowlevel *tp_lowlevel,
+ TpConnection *conn,
+ TpHandle handle,
+ const gchar *alias);
+
+void
folks_tp_lowlevel_connection_open_contact_list_channel_async (
FolksTpLowlevel *lowlevel,
TpConnection *conn,
warning ("failed to change a persona's favourite status");
}
}
+
+ internal async void change_alias (Tpf.Persona persona, string alias)
+ {
+ debug ("Changing alias of persona %u to '%s'.", persona.contact.handle,
+ alias);
+ this.ll.connection_set_contact_alias (this.conn,
+ (Handle) persona.contact.handle, alias);
+ }
}
{
private HashTable<string, bool> _groups;
private bool _is_favourite;
+ private string _alias;
- /* interface Alias */
- public string alias { get; set; }
+ /* Whether we've finished being constructed; this is used to prevent
+ * unnecessary trips to the Telepathy service to tell it about properties
+ * being set which are actually just being set from data it's just given us.
+ */
+ private bool is_constructed = false;
/* interface Avatar */
public File avatar { get; set; }
public Folks.PresenceType presence_type { get; private set; }
public string presence_message { get; private set; }
+ /* interface Alias */
+ public string alias
+ {
+ get { return this._alias; }
+
+ set
+ {
+ if (this._alias == value)
+ return;
+
+ if (this.is_constructed)
+ ((Tpf.PersonaStore) this.store).change_alias (this, value);
+ this._alias = value;
+ }
+ }
+
/* interface Favourite */
public bool is_favourite
{
if (this._is_favourite == value)
return;
- ((Tpf.PersonaStore) this.store).change_is_favourite (this, value);
+ if (this.is_constructed)
+ ((Tpf.PersonaStore) this.store).change_is_favourite (this, value);
this._is_favourite = value;
}
}
uid: uid,
store: store);
+ this.is_constructed = true;
+
this._groups = new HashTable<string, bool> (str_hash, str_equal);
contact.notify["avatar-file"].connect ((s, p) =>
private GLib.List<Persona> _personas;
private HashTable<PersonaStore, HashSet<Persona>> stores;
private bool _is_favourite;
-
- /* XXX: should setting this push it down into the Persona (to foward along to
- * the actual store if possible?) */
- /**
- * {@inheritDoc}
- */
- public string alias { get; set; }
+ private string _alias;
/**
* {@inheritDoc}
public signal void removed ();
/**
+ * {@inheritDoc}
+ */
+ public string alias
+ {
+ get { return this._alias; }
+
+ set
+ {
+ if (this._alias == value)
+ return;
+
+ this._alias = value;
+ this._personas.foreach ((p) =>
+ {
+ if (p is Alias)
+ ((Alias) p).alias = value;
+ });
+ }
+ }
+
+ /**
* Whether this Individual is a user-defined favourite.
*
* This property is `true` if any of this Individual's {@link Persona}s are