Mercurial > pidgin.yaz
changeset 9762:3f97624e7753
[gaim-migrate @ 10630]
nosnilmot writes:
This patch auto-linkifies the topic in chats in IRC,
Jabber & SILC, so you can now do /topic and get
clickable links. Much more fun than copy & paste.
This looks a little ugly to me. Too much code seems duplicated.
But it was already duplicated, stu just made it do a little more.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Mon, 16 Aug 2004 01:14:58 +0000 |
parents | 391e4e186708 |
children | b85df3f44350 |
files | ChangeLog src/protocols/irc/cmds.c src/protocols/irc/msgs.c src/protocols/jabber/chat.c src/protocols/jabber/message.c src/protocols/silc/ops.c src/protocols/silc/silc.c |
diffstat | 7 files changed, 83 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Aug 15 23:28:09 2004 +0000 +++ b/ChangeLog Mon Aug 16 01:14:58 2004 +0000 @@ -1,6 +1,9 @@ Gaim: The Pimpin' Penguin IM Client that's good for the soul! version 0.82: + New Features: + * Topics in the conversation window (not the topic field at the + top) with urls will now have those urls linkified (Stu Tomlinson) Bug Fixes: * Joining a Jabber chat no longer causes a crash (Stu Tomlinson) * Selecting a buddy icon for a brand new account no longer
--- a/src/protocols/irc/cmds.c Sun Aug 15 23:28:09 2004 +0000 +++ b/src/protocols/irc/cmds.c Mon Aug 16 01:14:58 2004 +0000 @@ -444,9 +444,12 @@ topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(convo)); if (topic) { - char *tmp = gaim_escape_html(topic); - buf = g_strdup_printf(_("current topic is: %s"), tmp); + char *tmp, *tmp2; + tmp = gaim_escape_html(topic); + tmp2 = gaim_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")); gaim_conv_chat_write(GAIM_CONV_CHAT(convo), target, buf, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
--- a/src/protocols/irc/msgs.c Sun Aug 15 23:28:09 2004 +0000 +++ b/src/protocols/irc/msgs.c Mon Aug 16 01:14:58 2004 +0000 @@ -260,7 +260,7 @@ void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) { - char *chan, *topic, *msg, *nick, *tmp; + char *chan, *topic, *msg, *nick, *tmp, *tmp2; GaimConversation *convo; if (!strcmp(name, "topic")) { @@ -278,20 +278,22 @@ /* If this is an interactive update, print it out */ tmp = gaim_escape_html(topic); + tmp2 = gaim_markup_linkify(tmp); + g_free(tmp); if (!strcmp(name, "topic")) { nick = irc_mask_nick(from); gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), nick, topic); - msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick, tmp); + msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick, tmp2); g_free(nick); gaim_conv_chat_write(GAIM_CONV_CHAT(convo), from, msg, GAIM_MESSAGE_SYSTEM, time(NULL)); g_free(msg); } else { - msg = g_strdup_printf(_("The topic for %s is: %s"), chan, tmp); + msg = g_strdup_printf(_("The topic for %s is: %s"), chan, tmp2); gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, topic); gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM, time(NULL)); g_free(msg); } - g_free(tmp); + g_free(tmp2); g_free(topic); }
--- a/src/protocols/jabber/chat.c Sun Aug 15 23:28:09 2004 +0000 +++ b/src/protocols/jabber/chat.c Mon Aug 16 01:14:58 2004 +0000 @@ -549,11 +549,15 @@ jabber_message_free(jm); } else { const char *cur = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(chat->conv)); - char *buf; + char *buf, *tmp, *tmp2; - if(cur) - buf = g_strdup_printf(_("current topic is: %s"), cur); - else + if(cur) { + tmp = gaim_escape_html(cur); + tmp2 = gaim_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")); gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "", buf, GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG, time(NULL));
--- a/src/protocols/jabber/message.c Sun Aug 15 23:28:09 2004 +0000 +++ b/src/protocols/jabber/message.c Mon Aug 16 01:14:58 2004 +0000 @@ -168,12 +168,16 @@ gaim_conv_chat_set_topic(GAIM_CONV_CHAT(chat->conv), jid->resource, jm->subject); if(!jm->xhtml && !jm->body) { - char *msg; + char *msg, *tmp, *tmp2; + tmp = gaim_escape_html(jm->subject); + tmp2 = gaim_markup_linkify(tmp); if(jid->resource) - msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, jm->subject); + msg = g_strdup_printf(_("%s has set the topic to: %s"), jid->resource, tmp2); else - msg = g_strdup_printf(_("The topic is: %s"), jm->subject); + msg = g_strdup_printf(_("The topic is: %s"), tmp2); gaim_conv_chat_write(GAIM_CONV_CHAT(chat->conv), "", msg, GAIM_MESSAGE_SYSTEM, jm->sent); + g_free(tmp); + g_free(tmp2); g_free(msg); } }
--- a/src/protocols/silc/ops.c Sun Aug 15 23:28:09 2004 +0000 +++ b/src/protocols/silc/ops.c Mon Aug 16 01:14:58 2004 +0000 @@ -314,52 +314,61 @@ break; case SILC_NOTIFY_TYPE_TOPIC_SET: - idtype = va_arg(va, int); - entry = va_arg(va, void *); - tmp = va_arg(va, char *); - channel = va_arg(va, SilcChannelEntry); + { + char *esc, *tmp2; + idtype = va_arg(va, int); + entry = va_arg(va, void *); + tmp = va_arg(va, char *); + channel = va_arg(va, SilcChannelEntry); + + convo = gaim_find_conversation_with_account(channel->channel_name, + sg->account); + if (!convo) + break; + + if (!tmp) + break; + + esc = gaim_escape_html(tmp); + tmp2 = gaim_markup_linkify(esc); + g_free(esc); - convo = gaim_find_conversation_with_account(channel->channel_name, - sg->account); - if (!convo) - break; + if (idtype == SILC_ID_CLIENT) { + client_entry = (SilcClientEntry)entry; + g_snprintf(buf, sizeof(buf), + _("%s has changed the topic of <I>%s</I> to: %s"), + client_entry->nickname, channel->channel_name, tmp2); + gaim_conv_chat_write(GAIM_CONV_CHAT(convo), client_entry->nickname, + buf, GAIM_MESSAGE_SYSTEM, time(NULL)); + gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), + client_entry->nickname, tmp); + } else if (idtype == SILC_ID_SERVER) { + server_entry = (SilcServerEntry)entry; + g_snprintf(buf, sizeof(buf), + _("%s has changed the topic of <I>%s</I> to: %s"), + server_entry->server_name, channel->channel_name, tmp2); + gaim_conv_chat_write(GAIM_CONV_CHAT(convo), server_entry->server_name, + buf, GAIM_MESSAGE_SYSTEM, time(NULL)); + gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), + server_entry->server_name, tmp); + } else if (idtype == SILC_ID_CHANNEL) { + channel = (SilcChannelEntry)entry; + g_snprintf(buf, sizeof(buf), + _("%s has changed the topic of <I>%s</I> to: %s"), + channel->channel_name, channel->channel_name, tmp2); + gaim_conv_chat_write(GAIM_CONV_CHAT(convo), channel->channel_name, + buf, GAIM_MESSAGE_SYSTEM, time(NULL)); + gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), + channel->channel_name, tmp); + } else { + gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, tmp); + } - if (!tmp) + g_free(tmp2); + break; - if (idtype == SILC_ID_CLIENT) { - client_entry = (SilcClientEntry)entry; - g_snprintf(buf, sizeof(buf), - _("%s has changed the topic of <I>%s</I> to: %s"), - client_entry->nickname, channel->channel_name, tmp); - gaim_conv_chat_write(GAIM_CONV_CHAT(convo), client_entry->nickname, - buf, GAIM_MESSAGE_SYSTEM, time(NULL)); - gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), - client_entry->nickname, tmp); - } else if (idtype == SILC_ID_SERVER) { - server_entry = (SilcServerEntry)entry; - g_snprintf(buf, sizeof(buf), - _("%s has changed the topic of <I>%s</I> to: %s"), - server_entry->server_name, channel->channel_name, tmp); - gaim_conv_chat_write(GAIM_CONV_CHAT(convo), server_entry->server_name, - buf, GAIM_MESSAGE_SYSTEM, time(NULL)); - gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), - server_entry->server_name, tmp); - } else if (idtype == SILC_ID_CHANNEL) { - channel = (SilcChannelEntry)entry; - g_snprintf(buf, sizeof(buf), - _("%s has changed the topic of <I>%s</I> to: %s"), - channel->channel_name, channel->channel_name, tmp); - gaim_conv_chat_write(GAIM_CONV_CHAT(convo), channel->channel_name, - buf, GAIM_MESSAGE_SYSTEM, time(NULL)); - gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), - channel->channel_name, tmp); - } else { - gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, tmp); } - - break; - case SILC_NOTIFY_TYPE_NICK_CHANGE: client_entry = va_arg(va, SilcClientEntry); client_entry2 = va_arg(va, SilcClientEntry);
--- a/src/protocols/silc/silc.c Sun Aug 15 23:28:09 2004 +0000 +++ b/src/protocols/silc/silc.c Mon Aug 16 01:14:58 2004 +0000 @@ -985,7 +985,7 @@ { GaimConnection *gc; int id = 0; - char *buf, *tmp; + char *buf, *tmp, *tmp2; const char *topic; gc = gaim_conversation_get_gc(conv); @@ -998,8 +998,10 @@ topic = gaim_conv_chat_get_topic (GAIM_CONV_CHAT(conv)); if (topic) { tmp = gaim_escape_html(topic); - buf = g_strdup_printf(_("current topic is: %s"), tmp); + tmp2 = gaim_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")); gaim_conv_chat_write(GAIM_CONV_CHAT(conv), gc->account->username, buf,