Closed irssibot closed 14 years ago
irssi-fix-nicklist-prefixes.diff
Add prefixes to irc_nicklist_insert() so that nickrec.prefixes is accurate in the
"nicklist new" signal.
NOTE: This changes the API subtly. We may want to do this another way, but it fixes
the nicklist sorting on xirssi.
Index: src/perl/irc/Channel.xs
===================================================================
--- src/perl/irc/Channel.xs (revision 5174)
+++ src/perl/irc/Channel.xs (working copy)
@@ -58,6 +58,6 @@
int voice
int send_massjoin
CODE:
- RETVAL = irc_nicklist_insert(channel, nick, op, halfop, voice, send_massjoin);
+ RETVAL = irc_nicklist_insert(channel, nick, op, halfop, voice, send_massjoin, NULL);
OUTPUT:
RETVAL
Index: src/irc/core/irc-session.c
===================================================================
--- src/irc/core/irc-session.c (revision 5174)
+++ src/irc/core/irc-session.c (working copy)
@@ -129,7 +129,6 @@
op = config_node_get_bool(node, "op", FALSE);
voice = config_node_get_bool(node, "voice", FALSE);
halfop = config_node_get_bool(node, "halfop", FALSE);
- nickrec = irc_nicklist_insert(channel, nick, op, halfop, voice, FALSE);
prefixes = config_node_get_str(node, "prefixes", NULL);
if (prefixes == NULL || *prefixes == '\0') {
/* upgrading from old irssi or from an in-between
@@ -146,9 +145,7 @@
newprefixes[i] = '\0';
prefixes = newprefixes;
}
- strocpy(nickrec->prefixes,
- prefixes,
- sizeof(nickrec->prefixes));
+ nickrec = irc_nicklist_insert(channel, nick, op, halfop, voice, FALSE, prefixes);
}
static void session_restore_channel(IRC_CHANNEL_REC *channel)
Index: src/irc/core/massjoin.c
===================================================================
--- src/irc/core/massjoin.c (revision 5174)
+++ src/irc/core/massjoin.c (working copy)
@@ -65,7 +65,7 @@
}
/* add user to nicklist */
- nickrec = irc_nicklist_insert(chanrec, nick, FALSE, FALSE, FALSE, TRUE);
+ nickrec = irc_nicklist_insert(chanrec, nick, FALSE, FALSE, FALSE, TRUE, NULL);
nicklist_set_host(CHANNEL(chanrec), nickrec, address);
if (chanrec->massjoins == 0) {
Index: src/irc/core/irc-nicklist.c
===================================================================
--- src/irc/core/irc-nicklist.c (revision 5174)
+++ src/irc/core/irc-nicklist.c (working copy)
@@ -31,7 +31,8 @@
/* Add new nick to list */
NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
- int op, int halfop, int voice, int send_massjoin)
+ int op, int halfop, int voice, int send_massjoin,
+ char *prefixes)
{
NICK_REC *rec;
@@ -46,6 +47,10 @@
if (voice) rec->voice = TRUE;
rec->send_massjoin = send_massjoin;
+ if (prefixes != NULL) {
+ strocpy(rec->prefixes, prefixes, sizeof(rec->prefixes));
+ }
+
nicklist_insert(CHANNEL(channel), rec);
return rec;
}
@@ -159,8 +164,7 @@
if (nicklist_find((CHANNEL_REC *) chanrec, ptr) == NULL) {
rec = irc_nicklist_insert(chanrec, ptr, op, halfop,
- voice, FALSE);
- memcpy(rec->prefixes, prefixes, sizeof(rec->prefixes));
+ voice, FALSE, prefixes);
}
}
@@ -187,7 +191,7 @@
nicks = g_hash_table_size(chanrec->nicks);
ownnick = irc_nicklist_insert(chanrec, server->nick,
nicks == 0, FALSE,
- FALSE, FALSE);
+ FALSE, FALSE, NULL);
}
nicklist_set_own(CHANNEL(chanrec), ownnick);
chanrec->chanop = chanrec->ownnick->op;
Index: src/irc/core/irc-nicklist.h
===================================================================
--- src/irc/core/irc-nicklist.h (revision 5174)
+++ src/irc/core/irc-nicklist.h (working copy)
@@ -5,7 +5,8 @@
/* Add new nick to list */
NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
- int op, int halfop, int voice, int send_massjoin);
+ int op, int halfop, int voice, int send_massjoin,
+ char *prefixes);
/* Remove all "extra" characters from `nick'. Like _nick_ -> nick */
char *irc_nick_strip(const char *nick);
You're right. I also tested your patch (by watching the signal in a Perl script) and it seems to work. It's applied. Thanks.
In xirssi, the nicklist is updated using the "nicklist new" signal. Unfortunately, when the "nicklist new" signal is called, the NICK_REC is incomplete which results in incorrect sorting of the nicklist.
The attached patch adds a prefixes field to the irc_nicklist_insert() procedure to ensure that NICK_RECs are properly constructed with the correct flags before the signal is fired. At the moment, the Perl API is left alone e.g. Irssi::IRC::irc_nicklist_insert() always passes NULL as prefixes.