From bc4764aefd072a865de16679da71aa5520c79234 Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Sat, 6 Mar 2010 19:22:59 -0500 Subject: [PATCH] Looks like irc_dictionary things cannot support more than one key with the same value. Therefore, a rework of +J and OACCEPT's metadata are required to make them work properly with multiple users. --- extensions/m_oaccept.c | 12 +++++++++--- extensions/m_okick.c | 7 +++++-- modules/core/m_kick.c | 5 ++++- modules/core/m_message.c | 4 +++- src/channel.c | 7 +++++-- src/chmode.c | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/extensions/m_oaccept.c b/extensions/m_oaccept.c index 036f1c5..459cd16 100644 --- a/extensions/m_oaccept.c +++ b/extensions/m_oaccept.c @@ -21,7 +21,9 @@ void mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Metadata *md; + struct DictionaryIter iter; struct Client *target_p; + char *text = rb_strdup(""); if(!(target_p = find_client(parv[1]))) { @@ -29,16 +31,20 @@ mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const cha return; } + rb_sprintf(text, "O%s", source_p->id); + /* Don't allow someone to pointlessly fill up someone's metadata * with identical OACCEPT entries. */ - if((md = user_metadata_find(target_p, "OACCEPT"))) - if(!strcmp(source_p->id, md->value)) + DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) + { + if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text)) { sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name); return; } + } - user_metadata_add(target_p, "OACCEPT", source_p->id, 1); + user_metadata_add(target_p, text, "OACCEPT", 1); sendto_wallops_flags(UMODE_WALLOP, &me, "OACCEPT called for %s by %s!%s@%s", diff --git a/extensions/m_okick.c b/extensions/m_okick.c index 16ddcdd..c09c42a 100644 --- a/extensions/m_okick.c +++ b/extensions/m_okick.c @@ -68,6 +68,7 @@ mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char char *name; char *p = NULL; char *user; + char *text = rb_strdup(""); static char buf[BUFSIZE]; if(*parv[2] == '\0') @@ -137,8 +138,10 @@ mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char ":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment); remove_user_from_channel(msptr); + rb_sprintf(text, "K%s", who->id); + /* we don't need to track NOREJOIN stuff unless it's our client being kicked */ - if(MyClient(target_p) && chptr->mode.mode & MODE_NOREJOIN) - channel_metadata_time_add(chptr, "KICKNOREJOIN", rb_current_time(), target_p->id); + if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN) + channel_metadata_time_add(chptr, text, rb_current_time(), "KICKNOREJOIN"); return 0; } diff --git a/modules/core/m_kick.c b/modules/core/m_kick.c index a85b7a7..4d903d1 100644 --- a/modules/core/m_kick.c +++ b/modules/core/m_kick.c @@ -68,6 +68,7 @@ m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *p char *comment; const char *name; char *p = NULL; + char *text = rb_strdup(""); const char *user; static char buf[BUFSIZE]; int is_override = 0; @@ -229,9 +230,11 @@ m_kick(struct Client *client_p, struct Client *source_p, int parc, const char *p use_id(source_p), chptr->chname, use_id(who), comment); remove_user_from_channel(msptr); + rb_sprintf(text, "K%s", who->id); + /* we don't need to track NOREJOIN stuff unless it's our client being kicked */ if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN) - channel_metadata_time_add(chptr, "KICKNOREJOIN", rb_current_time(), who->id); + channel_metadata_time_add(chptr, text, rb_current_time(), "KICKNOREJOIN"); } else if (MyClient(source_p)) sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 0a78302..0101500 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -736,6 +736,7 @@ msg_client(int p_or_n, const char *command, struct Metadata *md; struct DictionaryIter iter; int oaccept = 0; + char *text3 = rb_strdup(""); if(MyClient(source_p)) { @@ -798,9 +799,10 @@ msg_client(int p_or_n, const char *command, { if (IsOper(source_p)) { + rb_sprintf(text3, "O%s", source_p->id); DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) { - if(!strcmp(md->value, source_p->id)) + if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text3)) { oaccept = 1; break; diff --git a/src/channel.c b/src/channel.c index f18c94f..7ff1684 100644 --- a/src/channel.c +++ b/src/channel.c @@ -826,6 +826,7 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key) char src_host[NICKLEN + USERLEN + HOSTLEN + 6]; char src_iphost[NICKLEN + USERLEN + HOSTLEN + 6]; char src_althost[NICKLEN + USERLEN + HOSTLEN + 6]; + char *text = rb_strdup(""); int use_althost = 0; int i = 0; hook_data_channel moduledata; @@ -864,12 +865,14 @@ can_join(struct Client *source_p, struct Channel *chptr, char *key) if((is_banned(chptr, source_p, NULL, src_host, src_iphost)) == CHFL_BAN) return (ERR_BANNEDFROMCHAN); + rb_sprintf(text, "K%s", source_p->id); + DICTIONARY_FOREACH(md, &iter, chptr->metadata) { - if(!strcmp(md->name, "KICKNOREJOIN") && !strcmp(md->value, source_p->id) && (md->timevalue + ConfigChannel.kick_no_rejoin_time > rb_current_time())) + if(!strcmp(md->value, "KICKNOREJOIN") && !strcmp(md->name, text) && (md->timevalue + ConfigChannel.kick_no_rejoin_time > rb_current_time())) return ERR_KICKNOREJOIN; /* cleanup any stale KICKNOREJOIN metadata we find while we're at it */ - if(!strcmp(md->name, "KICKNOREJOIN") && !(md->timevalue + ConfigChannel.kick_no_rejoin_time > rb_current_time())) + if(!strcmp(md->value, "KICKNOREJOIN") && !(md->timevalue + ConfigChannel.kick_no_rejoin_time > rb_current_time())) channel_metadata_delete(chptr, md->name, 0); } diff --git a/src/chmode.c b/src/chmode.c index ecff7d9..792016a 100644 --- a/src/chmode.c +++ b/src/chmode.c @@ -548,7 +548,7 @@ chm_simple(struct Client *source_p, struct Channel *chptr, { DICTIONARY_FOREACH(md, &iter, chptr->metadata) { - if(!strcmp(md->name, "KICKNOREJOIN")) + if(!strcmp(md->value, "KICKNOREJOIN")) channel_metadata_delete(chptr, md->name, 0); } }