Helps bgo#626179.
}
/**
+ * Whether this PersonaStore can set the alias of {@link Folks.Persona}s.
+ *
+ * See {@link Folks.PersonaStore.can_alias_personas}.
+ *
+ * @since 0.3.1
+ */
+ public override MaybeBool can_alias_personas
+ {
+ get { return MaybeBool.TRUE; }
+ }
+
+ /**
* Whether this PersonaStore can remove {@link Folks.Persona}s.
*
* See {@link Folks.PersonaStore.can_remove_personas}.
}
static void
+connection_get_alias_flags_cb (TpConnection *conn,
+ guint flags,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data);
+
+ if (error != NULL)
+ {
+ g_simple_async_result_set_from_error (simple, error);
+ }
+ else
+ {
+ g_simple_async_result_set_op_res_gpointer (simple,
+ GUINT_TO_POINTER (flags), NULL);
+ }
+
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+}
+
+void
+folks_tp_lowlevel_connection_get_alias_flags_async (
+ FolksTpLowlevel *tp_lowlevel,
+ TpConnection *conn,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (G_OBJECT (conn), callback, user_data,
+ folks_tp_lowlevel_connection_get_alias_flags_finish);
+
+ tp_cli_connection_interface_aliasing_call_get_alias_flags (conn, -1,
+ connection_get_alias_flags_cb, result, NULL, G_OBJECT (conn));
+}
+
+/**
+ * folks_tp_lowlevel_connection_get_alias_flags_finish:
+ * @lowlevel: a #FolksTpLowlevel
+ * @result: a #GAsyncResult
+ * @error: return location for a #GError, or %NULL
+ *
+ * Determine the alias-related capabilities of the #TpConnection.
+ *
+ * Returns: the #TpConnectionAliasFlags
+ */
+TpConnectionAliasFlags
+folks_tp_lowlevel_connection_get_alias_flags_finish (
+ FolksTpLowlevel *lowlevel,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ TpConnection *conn;
+
+ g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (simple), FALSE);
+
+ conn = TP_CONNECTION (g_async_result_get_source_object (result));
+ g_return_val_if_fail (TP_IS_CONNECTION (conn), FALSE);
+
+ if (g_simple_async_result_propagate_error (simple, error))
+ return 0;
+
+ g_return_val_if_fail (g_simple_async_result_is_valid (result,
+ G_OBJECT (conn), folks_tp_lowlevel_connection_get_alias_flags_finish),
+ 0);
+
+ return (TpConnectionAliasFlags) (g_simple_async_result_get_op_res_gpointer (
+ G_SIMPLE_ASYNC_RESULT (result)));
+}
+
+static void
get_contacts_by_handle_cb (TpConnection *conn,
guint n_contacts,
TpContact * const *contacts,
GError **error);
void
+folks_tp_lowlevel_connection_get_alias_flags_async (
+ FolksTpLowlevel *tp_lowlevel,
+ TpConnection *conn,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+
+TpConnectionAliasFlags
+folks_tp_lowlevel_connection_get_alias_flags_finish (
+ FolksTpLowlevel *lowlevel,
+ GAsyncResult *result,
+ GError **error);
+
+void
folks_tp_lowlevel_connection_get_contacts_by_handle_async (
FolksTpLowlevel *tp_lowlevel,
TpConnection *conn,
private Logger logger;
private Contact self_contact;
private MaybeBool _can_add_personas = MaybeBool.UNSET;
+ private MaybeBool _can_alias_personas = MaybeBool.UNSET;
private MaybeBool _can_remove_personas = MaybeBool.UNSET;
private bool _is_prepared = false;
}
/**
+ * Whether this PersonaStore can set the alias of {@link Folks.Persona}s.
+ *
+ * See {@link Folks.PersonaStore.can_alias_personas}.
+ *
+ * @since 0.3.1
+ */
+ public override MaybeBool can_alias_personas
+ {
+ get { return this._can_alias_personas; }
+ }
+
+ /**
* Whether this PersonaStore can remove {@link Folks.Persona}s.
*
* See {@link Folks.PersonaStore.can_remove_personas}.
this.ll.connection_connect_to_new_group_channels (c,
this.new_group_channels_cb);
+ this.ll.connection_get_alias_flags_async.begin (c, (s2, res) =>
+ {
+ var new_can_alias = MaybeBool.FALSE;
+ try
+ {
+ var flags = this.ll.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)
+ {
+ GLib.warning ("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.add_standard_channel (c, "publish");
this.add_standard_channel (c, "stored");
this.add_standard_channel (c, "subscribe");
public abstract MaybeBool can_add_personas { get; default = MaybeBool.UNSET; }
/**
+ * Whether this {@link PersonaStore} can set the alias of {@link Persona}s.
+ *
+ * @since 0.3.1
+ */
+ public abstract MaybeBool can_alias_personas
+ {
+ get;
+ default = MaybeBool.UNSET;
+ }
+
+ /**
* Whether this {@link PersonaStore} can remove {@link Persona}s.
*
* @since 0.3.1
else
store.notify["can-remove-personas"].connect (
this.can_remove_personas_cb);
+
+ if (store.can_alias_personas != MaybeBool.UNSET)
+ can_alias_personas_cb (store, null);
+ else
+ store.notify["can-alias-personas"].connect (
+ this.can_alias_personas_cb);
}
catch (GLib.Error e)
{
this.can_remove_personas_cb);
}
}
+
+ private void can_alias_personas_cb (GLib.Object s, ParamSpec? p)
+ {
+ assert (s is Tpf.PersonaStore);
+ var store = (Tpf.PersonaStore) s;
+
+ if (store.can_alias_personas != MaybeBool.UNSET)
+ {
+ assert (store.can_alias_personas == MaybeBool.TRUE);
+
+ this.group_flags_received.add ("can-alias-personas");
+
+ store.notify["can-alias-personas"].disconnect (
+ this.can_alias_personas_cb);
+ }
+ }
}
public int main (string[] args)