summaryrefslogtreecommitdiff
path: root/src/conn-aliasing.c
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2011-06-28 10:59:20 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2011-06-28 11:01:04 +0100
commit0acb80d4c7669d26fe543e515473ad3f7dfbe11d (patch)
treedcd7ec72230af64ad8c4c239f4bfc97d7d4431be /src/conn-aliasing.c
parent0f30bcdcaab39a2ebcaafb42272056d79f126c11 (diff)
downloadtelepathy-gabble-0acb80d4c7669d26fe543e515473ad3f7dfbe11d.tar.gz
Correctly clear our own alias when asked to.
Previously, Gabble would include an empty <NICKNAME/> node in your vCard, which kind of offends my inner purist: it should just leave it out. En passant, this should also fix clearing the name='' attribute on the roster for yourself (if you're on your own roster) but this is untested.
Diffstat (limited to 'src/conn-aliasing.c')
-rw-r--r--src/conn-aliasing.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/conn-aliasing.c b/src/conn-aliasing.c
index 545039183..8b77a8fd2 100644
--- a/src/conn-aliasing.c
+++ b/src/conn-aliasing.c
@@ -521,6 +521,9 @@ set_one_alias (
g_assert (base->status == TP_CONNECTION_STATUS_CONNECTED);
+ if (tp_str_empty (alias))
+ alias = NULL;
+
if (!tp_handle_is_valid (contact_handles, handle, error))
{
ret = FALSE;
@@ -542,7 +545,7 @@ set_one_alias (
gchar *remote_alias = NULL;
GabbleConnectionAliasSource source = GABBLE_CONNECTION_ALIAS_FROM_ROSTER;
- if (tp_str_empty (alias))
+ if (alias == NULL)
{
source = _gabble_connection_get_cached_remote_alias (conn, handle,
&remote_alias);
@@ -561,7 +564,8 @@ set_one_alias (
if (base->self_handle == handle)
{
- GList *edits = NULL;
+ GabbleVCardManagerEditInfo *edit;
+ GQueue edits = G_QUEUE_INIT;
/* User has called SetAliases on themselves - patch their vCard.
* FIXME: because SetAliases is currently synchronous, we ignore errors
@@ -575,8 +579,8 @@ set_one_alias (
WockyNode *item;
msg = wocky_pep_service_make_publish_stanza (conn->pep_nick, &item);
- wocky_node_add_child_with_content_ns (item, "nick",
- alias, NS_NICK);
+ /* Does the right thing if alias == NULL. */
+ wocky_node_add_child_with_content_ns (item, "nick", alias, NS_NICK);
_gabble_connection_send_with_reply (conn, msg,
nick_publish_msg_reply_cb, NULL, NULL, NULL);
@@ -584,10 +588,20 @@ set_one_alias (
lm_message_unref (msg);
}
- edits = g_list_append (edits, gabble_vcard_manager_edit_info_new (
- NULL, alias, GABBLE_VCARD_EDIT_SET_ALIAS, NULL));
+ if (alias == NULL)
+ /* Deliberately not doing the fall-back-to-FN-on-GTalk dance because
+ * clearing your FN is more serious.
+ */
+ edit = gabble_vcard_manager_edit_info_new ("NICKNAME", NULL,
+ GABBLE_VCARD_EDIT_DELETE, NULL);
+ else
+ edit = gabble_vcard_manager_edit_info_new (NULL, alias,
+ GABBLE_VCARD_EDIT_SET_ALIAS, NULL);
+
+ g_queue_push_head (&edits, edit);
+ /* Yes, gabble_vcard_manager_edit steals the list you pass it. */
gabble_vcard_manager_edit (conn->vcard_manager, 0, NULL,
- NULL, G_OBJECT (conn), edits);
+ NULL, G_OBJECT (conn), edits.head);
}
return ret;