pidgin.2.x.y: 22d544ff: Print unknown IRC numerics to channels i...
elb at pidgin.im
elb at pidgin.im
Sun May 6 10:51:02 EDT 2012
----------------------------------------------------------------------
Revision: 22d544ffc6215f22b81d1dc34931bad4c82775c2
Parent: 2c7bb15f7d34b42e9f35162018618a1c6094d290
Author: elb at pidgin.im
Date: 05/06/12 10:45:01
Branch: im.pidgin.pidgin.2.x.y
URL: http://d.pidgin.im/viewmtn/revision/info/22d544ffc6215f22b81d1dc34931bad4c82775c2
Changelog:
Print unknown IRC numerics to channels if we can associate them.
Basically, if they are of the form:
<routing> <numeric> <...> <channel> <more>
... then we print <numeric>: <more> to <channel>. Thanks to marienz
from Freenode for suggesting this.
Fixes #15090
Changes against parent 2c7bb15f7d34b42e9f35162018618a1c6094d290
patched ChangeLog
patched libpurple/protocols/irc/msgs.c
-------------- next part --------------
============================================================
--- ChangeLog d5a35afc538d75ad049329bd2c993ee0232c0a7a
+++ ChangeLog 321d3de1982cc753a839ee62aa9c1633f5eda3ba
@@ -5,6 +5,8 @@ version 2.10.4:
* Disable periodic WHO timer. IRC channel user lists will no
longer automatically display away status, but libpurple will be
much kinder to the network.
+ * Print unknown numerics to channel windows if we can associate
+ them. Thanks to Marien Zwart. (#15090)
version 2.10.3 (03/26/2012):
MSN:
============================================================
--- libpurple/protocols/irc/msgs.c 1a8b5b3acaa301d0e3fefb1fbd8e9abe5dc81253
+++ libpurple/protocols/irc/msgs.c 86d6f49c05e2c4bd6982af4372b484b167f49ee8
@@ -112,9 +112,78 @@ static void irc_connected(struct irc_con
irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc);
}
+/* This function is ugly, but it's really an error handler. */
void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args)
{
- char *clean;
+ int i;
+ const char *end, *cur, *numeric = NULL;
+ char *clean, *tmp, *convname;
+ PurpleConversation *convo;
+
+ for (cur = args[0], i = 0; i < 4; i++) {
+ end = strchr(cur, ' ');
+ if (end == NULL) {
+ goto undirected;
+ }
+ /* Check for 3-digit numeric in second position */
+ if (i == 1) {
+ if (end - cur != 3
+ || !isdigit(cur[0]) || !isdigit(cur[1])
+ || !isdigit(cur[2])) {
+ goto undirected;
+ }
+ /* Save the numeric for printing to the channel */
+ numeric = cur;
+ }
+ /* Don't advance cur if we're on the final iteration. */
+ if (i != 3) {
+ cur = end + 1;
+ }
+ }
+
+ /* At this point, cur is the beginning of the fourth position,
+ * end is the following space, and there are remaining
+ * arguments. We'll check to see if this argument is a
+ * currently active conversation (private message or channel,
+ * either one), and print the numeric to that conversation if it
+ * is. */
+
+ tmp = g_strndup(cur, end - cur);
+ convname = purple_utf8_salvage(tmp);
+ g_free(tmp);
+
+ /* Check for an existing conversation */
+ convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY,
+ convname,
+ irc->account);
+ g_free(convname);
+
+ if (convo == NULL) {
+ goto undirected;
+ }
+
+ /* end + 1 is the first argument past the target. The initial
+ * arguments we've skipped are routing info, numeric, recipient
+ * (this account's nick, most likely), and target (this
+ * channel). If end + 1 is an ASCII :, skip it, because it's
+ * meaningless in this context. This won't catch all
+ * :-arguments, but it'll catch the easy case. */
+ if (*++end == ':') {
+ end++;
+ }
+
+ /* We then print "numeric: remainder". */
+ clean = purple_utf8_salvage(end);
+ tmp = g_strdup_printf("%.3s: %s", numeric, clean);
+ g_free(clean);
+ purple_conversation_write(convo, "", tmp,
+ PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG
+ |PURPLE_MESSAGE_RAW|PURPLE_MESSAGE_NO_LINKIFY,
+ time(NULL));
+ g_free(tmp);
+ return;
+
+ undirected:
/* This, too, should be escaped somehow (smarter) */
clean = purple_utf8_salvage(args[0]);
purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", clean);
More information about the Commits
mailing list