pidgin: 941a367b: Fix XMPP prpl->set_chat_topic with an em...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sat Apr 25 21:50:43 EDT 2009
-----------------------------------------------------------------
Revision: 941a367b55f4c8881ae4cfc3f70c346d574d9af5
Ancestor: 04dd344955066d1eac3d66204389e3816956bf63
Author: darkrain42 at pidgin.im
Date: 2009-04-26T00:06:30
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/941a367b55f4c8881ae4cfc3f70c346d574d9af5
Modified files:
libpurple/protocols/jabber/chat.c
libpurple/protocols/jabber/jabber.c
libpurple/protocols/jabber/message.c
ChangeLog:
Fix XMPP prpl->set_chat_topic with an empty string (or NULL)
The slash-command /topic displays the message with no arguments, but the
set_chat_topic should not.
Closes #8810.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/chat.c c61f9b2656b26a97349feeca261782ccb7457ae8
+++ libpurple/protocols/jabber/chat.c b3a7e0a6655f61e1756f0b1addec638d166b1cf4
@@ -597,37 +597,25 @@ void jabber_chat_change_topic(JabberChat
/* merge this with the function below when we get everyone on the same page wrt /commands */
void jabber_chat_change_topic(JabberChat *chat, const char *topic)
{
- if(topic && *topic) {
- JabberMessage *jm;
- jm = g_new0(JabberMessage, 1);
- jm->js = chat->js;
- jm->type = JABBER_MESSAGE_GROUPCHAT;
- jm->subject = purple_markup_strip_html(topic);
- jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
- jabber_message_send(jm);
- jabber_message_free(jm);
- } else {
- const char *cur = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(chat->conv));
- char *buf, *tmp, *tmp2;
+ JabberMessage *jm;
- if(cur) {
- tmp = g_markup_escape_text(cur, -1);
- tmp2 = purple_markup_linkify(tmp);
- buf = g_strdup_printf(_("current topic is: %s"), tmp2);
- g_free(tmp);
- g_free(tmp2);
- } else
- buf = g_strdup(_("No topic is set"));
- purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", buf,
- PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
- g_free(buf);
- }
+ jm = g_new0(JabberMessage, 1);
+ jm->js = chat->js;
+ jm->type = JABBER_MESSAGE_GROUPCHAT;
+ jm->to = g_strdup_printf("%s@%s", chat->room, chat->server);
+ if (topic && *topic)
+ jm->subject = purple_markup_strip_html(topic);
+ else
+ jm->subject = g_strdup("");
+
+ jabber_message_send(jm);
+ jabber_message_free(jm);
}
void jabber_chat_set_topic(PurpleConnection *gc, int id, const char *topic)
{
- JabberStream *js = gc->proto_data;
+ JabberStream *js = purple_connection_get_protocol_data(gc);
JabberChat *chat = jabber_chat_find_by_id(js, id);
if(!chat)
============================================================
--- libpurple/protocols/jabber/jabber.c 8a2ea03b1b52a051312222af7691be2e0ab5acb1
+++ libpurple/protocols/jabber/jabber.c 02f9cfa39d6aaa884135867205634260064cc546
@@ -2305,7 +2305,25 @@ static PurpleCmdRet jabber_cmd_chat_topi
if (!chat)
return PURPLE_CMD_RET_FAILED;
- jabber_chat_change_topic(chat, args ? args[0] : NULL);
+ if (args && args[0] && *args[0])
+ jabber_chat_change_topic(chat, args[0]);
+ else {
+ const char *cur = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv));
+ char *buf, *tmp, *tmp2;
+
+ if (cur) {
+ tmp = g_markup_escape_text(cur, -1);
+ tmp2 = purple_markup_linkify(tmp);
+ buf = g_strdup_printf(_("current topic is: %s"), tmp2);
+ g_free(tmp);
+ g_free(tmp2);
+ } else
+ buf = g_strdup(_("No topic is set"));
+ purple_conv_chat_write(PURPLE_CONV_CHAT(conv), "", buf,
+ PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL));
+ g_free(buf);
+ }
+
return PURPLE_CMD_RET_OK;
}
============================================================
--- libpurple/protocols/jabber/message.c fb024f59b1640c23a575f1f234ed89940c010cc1
+++ libpurple/protocols/jabber/message.c ae7d630f1cd9cc0d6f35b07f318d4a3946498001
@@ -597,8 +597,11 @@ void jabber_message_parse(JabberStream *
/* The following tests expect xmlns != NULL */
continue;
} else if(!strcmp(child->name, "subject") && !strcmp(xmlns,"jabber:client")) {
- if(!jm->subject)
+ if(!jm->subject) {
jm->subject = xmlnode_get_data(child);
+ if(!jm->subject)
+ jm->subject = g_strdup("");
+ }
} else if(!strcmp(child->name, "thread") && !strcmp(xmlns,"jabber:client")) {
if(!jm->thread_id)
jm->thread_id = xmlnode_get_data(child);
More information about the Commits
mailing list