1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Changing roster handle with no argument clears handle

This commit is contained in:
James Booth 2013-05-19 03:27:59 +01:00
parent d9cb8c100f
commit 1c41a46dce
3 changed files with 14 additions and 6 deletions

View File

@ -275,14 +275,16 @@ static struct cmd_t main_commands[] =
NULL } } }, NULL } } },
{ "/roster", { "/roster",
_cmd_roster, parse_args_with_freetext, 3, 3, _cmd_roster, parse_args_with_freetext, 2, 3,
{ "/roster nick jid handle", "Add or change a contacts handle.", { "/roster nick jid [handle]", "Add or change a contacts handle.",
{ "/roster nick jid handle", { "/roster nick jid [handle]",
"-----------------------", "-------------------------",
"Change the nickname (handle) associated with a contact in your roster." "Change the nickname (handle) associated with a contact in your roster."
"If no handle is supplied, any existing handle will be removed.",
"", "",
"Example : /roster nick bob.smith@server.com bobby", "Example : /roster nick bob.smith@server.com bobby",
"Example : /roster nick myfriend@chat.org My Friend", "Example : /roster nick myfriend@chat.org My Friend",
"Example : /roster nick kai@server.com (clears handle)",
NULL } } }, NULL } } },
{ "/info", { "/info",

View File

@ -80,7 +80,9 @@ p_contact_set_name(const PContact contact, const char * const name)
FREE_SET_NULL(contact->name); FREE_SET_NULL(contact->name);
} }
contact->name = strdup(name); if (name != NULL) {
contact->name = strdup(name);
}
} }
gboolean gboolean

View File

@ -104,7 +104,11 @@ stanza_create_roster_set(xmpp_ctx_t *ctx, const char * const jid,
xmpp_stanza_t *item = xmpp_stanza_new(ctx); xmpp_stanza_t *item = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(item, STANZA_NAME_ITEM); xmpp_stanza_set_name(item, STANZA_NAME_ITEM);
xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid); xmpp_stanza_set_attribute(item, STANZA_ATTR_JID, jid);
xmpp_stanza_set_attribute(item, STANZA_ATTR_NAME, handle); if (handle != NULL) {
xmpp_stanza_set_attribute(item, STANZA_ATTR_NAME, handle);
} else {
xmpp_stanza_set_attribute(item, STANZA_ATTR_NAME, "");
}
xmpp_stanza_add_child(query, item); xmpp_stanza_add_child(query, item);
xmpp_stanza_add_child(iq, query); xmpp_stanza_add_child(iq, query);