summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-12-09 17:13:48 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-12-09 17:13:48 +0000
commit15e815e8d3ff84683c2429f59738f6625d3e4f9b (patch)
treed09ad892780db823466c9a36b102fe2de3882154
parenta8419ed5b93af2c063ca90a4f34ffe36d88458a2 (diff)
downloadirssi-15e815e8d3ff84683c2429f59738f6625d3e4f9b.zip
Better support for halfops, patch by yathen@web.de
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2228 dbcabf3a-b0e7-0310-adc4-f8d773084564
-rw-r--r--src/core/nicklist.c38
-rw-r--r--src/fe-common/core/fe-channels.c18
-rw-r--r--src/fe-common/core/module-formats.c2
-rw-r--r--src/irc/core/irc-nicklist.c8
-rw-r--r--src/irc/core/irc-nicklist.h2
-rw-r--r--src/irc/core/irc-session.c6
-rw-r--r--src/irc/core/massjoin.c2
-rw-r--r--src/perl/irc/Channel.xs5
8 files changed, 57 insertions, 24 deletions
diff --git a/src/core/nicklist.c b/src/core/nicklist.c
index 24ad0d1a..66b58ffb 100644
--- a/src/core/nicklist.c
+++ b/src/core/nicklist.c
@@ -356,17 +356,39 @@ GSList *nicklist_get_same_unique(SERVER_REC *server, void *id)
/* nick record comparision for sort functions */
int nicklist_compare(NICK_REC *p1, NICK_REC *p2)
{
+ int status1, status2;
+
if (p1 == NULL) return -1;
if (p2 == NULL) return 1;
- if (p1->op && !p2->op) return -1;
- if (!p1->op && p2->op) return 1;
-
- if (!p1->op) {
- if (p1->voice && !p2->voice) return -1;
- if (!p1->voice && p2->voice) return 1;
- }
-
+ /* we assign each status (op, halfop, voice, normal) a number
+ * and compare them. this is easier than 100,000 if's and
+ * returns :-)
+ * -- yath */
+
+ if (p1->op)
+ status1 = 4;
+ else if (p1->halfop)
+ status1 = 3;
+ else if (p1->voice)
+ status1 = 2;
+ else
+ status1 = 1;
+
+ if (p2->op)
+ status2 = 4;
+ else if (p2->halfop)
+ status2 = 3;
+ else if (p2->voice)
+ status2 = 2;
+ else
+ status2 = 1;
+
+ if (status1 < status2)
+ return 1;
+ else if (status1 > status2)
+ return -1;
+
return g_strcasecmp(p1->nick, p2->nick);
}
diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c
index 3813534b..0b82df64 100644
--- a/src/fe-common/core/fe-channels.c
+++ b/src/fe-common/core/fe-channels.c
@@ -390,8 +390,15 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist)
for (tmp = nicklist; tmp != NULL; tmp = tmp->next) {
NICK_REC *rec = tmp->data;
- nickmode[0] = rec->op ? '@' : rec->voice ? '+' : ' ';
-
+ if (rec->op)
+ nickmode[0] = '@';
+ else if (rec->halfop)
+ nickmode[0] = '%';
+ else if (rec->voice)
+ nickmode[0] = '+';
+ else
+ nickmode[0] = ' ';
+
if (linebuf_size < columns[col]-item_extra+1) {
linebuf_size = (columns[col]-item_extra+1)*2;
linebuf = g_realloc(linebuf, linebuf_size);
@@ -439,9 +446,9 @@ void fe_channels_nicklist(CHANNEL_REC *channel, int flags)
{
NICK_REC *nick;
GSList *tmp, *nicklist, *sorted;
- int nicks, normal, voices, ops;
+ int nicks, normal, voices, halfops, ops;
- nicks = normal = voices = ops = 0;
+ nicks = normal = voices = halfops = ops = 0;
nicklist = nicklist_getnicks(channel);
sorted = NULL;
@@ -455,6 +462,7 @@ void fe_channels_nicklist(CHANNEL_REC *channel, int flags)
if ((flags & CHANNEL_NICKLIST_FLAG_OPS) == 0)
continue;
} else if (nick->halfop) {
+ halfops++;
if ((flags & CHANNEL_NICKLIST_FLAG_HALFOPS) == 0)
continue;
} else if (nick->voice) {
@@ -482,7 +490,7 @@ void fe_channels_nicklist(CHANNEL_REC *channel, int flags)
printformat(channel->server, channel->name,
MSGLEVEL_CRAP, TXT_ENDOFNAMES,
- channel->name, nicks, ops, voices, normal);
+ channel->name, nicks, ops, halfops, voices, normal);
}
/* SYNTAX: NAMES [-count | -ops -halfops -voices -normal] [<channels> | **] */
diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c
index 2f6a1d30..79fd7bdc 100644
--- a/src/fe-common/core/module-formats.c
+++ b/src/fe-common/core/module-formats.c
@@ -108,7 +108,7 @@ FORMAT_REC fecommon_core_formats[] = {
{ "names_nick_halfop", "{names_nick_halfop $0 $1}", 2, { 0, 0 } },
{ "names_nick_voice", "{names_nick_voice $0 $1}", 2, { 0, 0 } },
{ "names_nick", "{names_nick $0 $1}", 2, { 0, 0 } },
- { "endofnames", "{channel $0}: Total of {hilight $1} nicks {comment {hilight $2} ops, {hilight $3} voices, {hilight $4} normal}", 5, { 0, 1, 1, 1, 1 } },
+ { "endofnames", "{channel $0}: Total of {hilight $1} nicks {comment {hilight $2} ops, {hilight $3} halfops, {hilight $4} voices, {hilight $5} normal}", 6, { 0, 1, 1, 1, 1, 1 } },
{ "chanlist_header", "You are on the following channels:", 0 },
{ "chanlist_line", "{channel $[-10]0} %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } },
{ "chansetup_not_found", "Channel {channel $0} not found", 2, { 0, 0 } },
diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c
index 5614c7d0..9de3febc 100644
--- a/src/irc/core/irc-nicklist.c
+++ b/src/irc/core/irc-nicklist.c
@@ -31,7 +31,7 @@
/* Add new nick to list */
NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
- int op, int voice, int send_massjoin)
+ int op, int halfop, int voice, int send_massjoin)
{
NICK_REC *rec;
@@ -42,6 +42,7 @@ NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
rec->nick = g_strdup(nick);
if (op) rec->op = TRUE;
+ if (halfop) rec->halfop = TRUE;
if (voice) rec->voice = TRUE;
rec->send_massjoin = send_massjoin;
@@ -112,7 +113,8 @@ static void event_names_list(IRC_SERVER_REC *server, const char *data)
if (*names != '\0') *names++ = '\0';
irc_nicklist_insert(chanrec, ptr+isnickflag(*ptr),
- *ptr == '@', *ptr == '+', FALSE);
+ *ptr == '@', *ptr == '%', *ptr == '+',
+ FALSE);
}
g_free(params);
@@ -138,7 +140,7 @@ static void event_end_of_names(IRC_SERVER_REC *server, const char *data)
nicks = g_hash_table_size(chanrec->nicks);
ownnick = irc_nicklist_insert(chanrec, server->nick,
nicks == 0, FALSE,
- FALSE);
+ FALSE, FALSE);
}
nicklist_set_own(CHANNEL(chanrec), ownnick);
chanrec->chanop = chanrec->ownnick->op;
diff --git a/src/irc/core/irc-nicklist.h b/src/irc/core/irc-nicklist.h
index 7d0ae2f4..0b392c77 100644
--- a/src/irc/core/irc-nicklist.h
+++ b/src/irc/core/irc-nicklist.h
@@ -5,7 +5,7 @@
/* Add new nick to list */
NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick,
- int op, int voice, int send_massjoin);
+ int op, int halfop, int voice, int send_massjoin);
/* Remove all "extra" characters from `nick'. Like _nick_ -> nick */
char *irc_nick_strip(const char *nick);
diff --git a/src/irc/core/irc-session.c b/src/irc/core/irc-session.c
index 01fa6fba..c72a6165 100644
--- a/src/irc/core/irc-session.c
+++ b/src/irc/core/irc-session.c
@@ -77,7 +77,7 @@ static void sig_session_restore_nick(IRC_CHANNEL_REC *channel,
CONFIG_NODE *node)
{
const char *nick;
- int op, voice;
+ int op, halfop, voice;
NICK_REC *nickrec;
if (!IS_IRC_CHANNEL(channel))
@@ -89,8 +89,8 @@ static void sig_session_restore_nick(IRC_CHANNEL_REC *channel,
op = config_node_get_bool(node, "op", FALSE);
voice = config_node_get_bool(node, "voice", FALSE);
- nickrec = irc_nicklist_insert(channel, nick, op, voice, FALSE);
- nickrec->halfop = config_node_get_bool(node, "halfop", FALSE);
+ halfop = config_node_get_bool(node, "halfop", FALSE);
+ nickrec = irc_nicklist_insert(channel, nick, op, halfop, voice, FALSE);
}
static void session_restore_channel(IRC_CHANNEL_REC *channel)
diff --git a/src/irc/core/massjoin.c b/src/irc/core/massjoin.c
index 07ea8fbd..71a46edc 100644
--- a/src/irc/core/massjoin.c
+++ b/src/irc/core/massjoin.c
@@ -57,7 +57,7 @@ static void event_join(IRC_SERVER_REC *server, const char *data,
if (chanrec == NULL) return;
/* add user to nicklist */
- nickrec = irc_nicklist_insert(chanrec, nick, FALSE, FALSE, TRUE);
+ nickrec = irc_nicklist_insert(chanrec, nick, FALSE, FALSE, FALSE, TRUE);
nicklist_set_host(CHANNEL(chanrec), nickrec, address);
if (chanrec->massjoins == 0) {
diff --git a/src/perl/irc/Channel.xs b/src/perl/irc/Channel.xs
index 53cbb2f6..0bf94753 100644
--- a/src/perl/irc/Channel.xs
+++ b/src/perl/irc/Channel.xs
@@ -50,14 +50,15 @@ PPCODE:
}
Irssi::Irc::Nick
-irc_nick_insert(channel, nick, op, voice, send_massjoin)
+irc_nick_insert(channel, nick, op, halfop, voice, send_massjoin)
Irssi::Irc::Channel channel
char *nick
int op
+ int halfop
int voice
int send_massjoin
CODE:
- RETVAL = irc_nicklist_insert(channel, nick, op, voice, send_massjoin);
+ RETVAL = irc_nicklist_insert(channel, nick, op, halfop, voice, send_massjoin);
OUTPUT:
RETVAL