aboutsummaryrefslogtreecommitdiffstats
path: root/otr.c
diff options
context:
space:
mode:
authorSven Moritz Hallberg <sm@khjk.org>2008-02-10 14:36:43 +0100
committerSven Moritz Hallberg <sm@khjk.org>2008-02-10 14:36:43 +0100
commit52e6e17d3b3610afd6d6b997257b72e798d95c47 (patch)
tree7cc59aeb807156657597e66cf1731d86a7a8d5f4 /otr.c
parentf55cfe93aeae5c24fd067e28733826d7e3029085 (diff)
Support halfops for 'notaway' status etc.
Diffstat (limited to 'otr.c')
-rw-r--r--otr.c67
1 files changed, 46 insertions, 21 deletions
diff --git a/otr.c b/otr.c
index 60581ee6..ccb65887 100644
--- a/otr.c
+++ b/otr.c
@@ -981,31 +981,56 @@ const char *peernick(irc_t *irc, const char *handle, const char *protocol)
int otr_update_modeflags(irc_t *irc, user_t *u)
{
- char *vo = set_getstr(&irc->set, "voice_buddies");
- char *oo = set_getstr(&irc->set, "op_buddies");
- char eflag=0, tflag=0;
- int e = u->encrypted;
- int t = (u->encrypted > 1);
+ char *vb = set_getstr(&irc->set, "voice_buddies");
+ char *hb = set_getstr(&irc->set, "halfop_buddies");
+ char *ob = set_getstr(&irc->set, "op_buddies");
+ int encrypted = u->encrypted;
+ int trusted = u->encrypted > 1;
+ char flags[7];
+ int nflags;
+ char *p = flags;
+ int i;
- if(!strcmp(vo, "encrypted"))
- eflag='v';
- else if(!strcmp(oo, "encrypted"))
- eflag='o';
- if(!strcmp(vo, "trusted"))
- tflag='v';
- else if(!strcmp(oo, "trusted"))
- tflag='o';
+ if(!strcmp(vb, "encrypted")) {
+ *(p++) = encrypted ? '+' : '-';
+ *(p++) = 'v';
+ nflags++;
+ } else if(!strcmp(vb, "trusted")) {
+ *(p++) = trusted ? '+' : '-';
+ *(p++) = 'v';
+ nflags++;
+ }
+ if(!strcmp(hb, "encrypted")) {
+ *(p++) = encrypted ? '+' : '-';
+ *(p++) = 'h';
+ nflags++;
+ } else if(!strcmp(hb, "trusted")) {
+ *(p++) = trusted ? '+' : '-';
+ *(p++) = 'h';
+ nflags++;
+ }
+ if(!strcmp(ob, "encrypted")) {
+ *(p++) = encrypted ? '+' : '-';
+ *(p++) = 'o';
+ nflags++;
+ } else if(!strcmp(ob, "trusted")) {
+ *(p++) = trusted ? '+' : '-';
+ *(p++) = 'o';
+ nflags++;
+ }
+ *p = '\0';
- if(!eflag)
+ p = g_malloc(nflags * (strlen(u->nick)+1) + 1);
+ *p = '\0';
+ if(!p)
return 0;
-
- if(tflag) {
- irc_write( irc, ":%s!%s@%s MODE %s %c%c%c%c %s %s", irc->mynick, irc->mynick, irc->myhost,
- irc->channel, e?'+':'-', eflag, t?'+':'-', tflag, u->nick, u->nick );
- } else {
- irc_write( irc, ":%s!%s@%s MODE %s %c%c %s", irc->mynick, irc->mynick, irc->myhost,
- irc->channel, e?'+':'-', eflag, u->nick );
+ for(i=0; i<nflags; i++) {
+ strcat(p, " ");
+ strcat(p, u->nick);
}
+ irc_write( irc, ":%s!%s@%s MODE %s %s%s", irc->mynick, irc->mynick, irc->myhost,
+ irc->channel, flags, p );
+ g_free(p);
return 1;
}