1
0
mirror of https://github.com/anope/anope.git synced 2026-07-08 18:43:13 +02:00

Added BotInfo* sender arg to all of the User mode functions, changed IRcdProto::SendMode for channels to accept a Channel pointer and fixed unsetting users vhosts on Unreal

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2710 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
Adam-
2009-12-17 02:10:35 +00:00
parent 453963eeae
commit 861fe9e7b3
16 changed files with 104 additions and 85 deletions
+4 -4
View File
@@ -1320,8 +1320,8 @@ class CoreExport IRCDProto
{
private:
virtual void SendSVSKillInternal(BotInfo *, User *, const char *) = 0;
virtual void SendModeInternal(BotInfo *, const char *, const char *) = 0;
virtual void SendModeInternal(User *, const char *) = 0;
virtual void SendModeInternal(BotInfo *, Channel *, const char *) = 0;
virtual void SendModeInternal(BotInfo *, User *, const char *) = 0;
virtual void SendKickInternal(BotInfo *, Channel *, User *, const char *) = 0;
virtual void SendNoticeChanopsInternal(BotInfo *bi, Channel *, const char *) = 0;
virtual void SendMessageInternal(BotInfo *bi, const char *dest, const char *buf);
@@ -1343,8 +1343,8 @@ class CoreExport IRCDProto
virtual void SendAkillDel(Akill *) = 0;
virtual void SendSVSKill(BotInfo *source, User *user, const char *fmt, ...);
virtual void SendSVSMode(User *, int, const char **) = 0;
virtual void SendMode(BotInfo *bi, const char *dest, const char *fmt, ...);
virtual void SendMode(User *u, const char *fmt, ...);
virtual void SendMode(BotInfo *bi, Channel *dest, const char *fmt, ...);
virtual void SendMode(BotInfo *bi, User *u, const char *fmt, ...);
virtual void SendClientIntroduction(const char *, const char *, const char *, const char *, const char *, const char *uid) = 0;
virtual void SendKick(BotInfo *bi, Channel *chan, User *user, const char *fmt, ...);
virtual void SendNoticeChanops(BotInfo *bi, Channel *dest, const char *fmt, ...);
+14 -7
View File
@@ -174,41 +174,48 @@ class CoreExport User : public Extensible
void RemoveModeInternal(UserMode *um);
/** Set a mode on the user
* @param bi The client setting the mode
* @param um The user mode
* @param Param Optional param for the mode
*/
void SetMode(UserMode *um, const std::string &Param = "");
void SetMode(BotInfo *bi, UserMode *um, const std::string &Param = "");
/** Set a mode on the user
* @param bi The client setting the mode
* @param Name The mode name
* @param Param Optional param for the mode
*/
void SetMode(UserModeName Name, const std::string &Param = "");
void SetMode(BotInfo *bi, UserModeName Name, const std::string &Param = "");
/* Set a mode on the user
* @param bi The client setting the mode
* @param ModeChar The mode char
* @param param Optional param for the mode
*/
void SetMode(char ModeChar, const std::string &Param = "");
void SetMode(BotInfo *bi, char ModeChar, const std::string &Param = "");
/** Remove a mode on the user
* @param bi The client setting the mode
* @param um The user mode
*/
void RemoveMode(UserMode *um);
void RemoveMode(BotInfo *bi, UserMode *um);
/** Remove a mode from the user
* @param bi The client setting the mode
* @param Name The mode name
*/
void RemoveMode(UserModeName Name);
void RemoveMode(BotInfo *bi, UserModeName Name);
/** Remove a mode from the user
* @param bi The client setting the mode
* @param ModeChar The mode char
*/
void RemoveMode(char ModeChar);
void RemoveMode(BotInfo *bi, char ModeChar);
/** Set a string of modes on a user
* @param bi The client setting the mode
* @param modes The modes
*/
void SetModes(const std::string &modes, ...);
void SetModes(BotInfo *bi, const std::string &modes, ...);
};
+1 -1
View File
@@ -876,7 +876,7 @@ void chan_set_user_status(Channel * chan, User * user, int16 status)
user->nick, status, chan->name);
}
user->SetMode(um);
user->SetMode(NULL, um);
}
for (uc = user->chans; uc; uc = uc->next) {
+1 -1
View File
@@ -59,7 +59,7 @@ class CommandCSTopic : public Command
if (ircd->join2set && whosends(ci) == findbot(Config.s_ChanServ))
{
ircdproto->SendJoin(findbot(Config.s_ChanServ), c->name, c->creation_time);
ircdproto->SendMode(NULL, c->name, "+o %s", Config.s_ChanServ);
ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ);
}
ircdproto->SendTopic(whosends(ci), c, u->nick, topic ? topic : "");
if (ircd->join2set && whosends(ci) == findbot(Config.s_ChanServ))
+1 -1
View File
@@ -34,7 +34,7 @@ class CommandOSOLine : public Command
else if (u2 && flag[0] == '+')
{
ircdproto->SendSVSO(Config.s_OperServ, nick, flag);
u2->SetMode(UMODE_OPER);
u2->SetMode(findbot(Config.s_OperServ), UMODE_OPER);
notice_lang(Config.s_OperServ, u2, OPER_OLINE_IRCOP);
notice_lang(Config.s_OperServ, u, OPER_OLINE_SUCCESS, flag, nick);
ircdproto->SendGlobops(findbot(Config.s_OperServ), "\2%s\2 used OLINE for %s", u->nick, nick);
+1 -1
View File
@@ -42,7 +42,7 @@ class CommandOSUMode : public Command
notice_lang(Config.s_OperServ, u, NICK_X_NOT_IN_USE, nick);
else
{
u2->SetModes(modes);
u2->SetModes(findbot(Config.s_OperServ), modes);
notice_lang(Config.s_OperServ, u, OPER_UMODE_SUCCESS, nick);
notice_lang(Config.s_OperServ, u2, OPER_UMODE_CHANGED, u->nick);
+3 -3
View File
@@ -243,7 +243,7 @@ void ChannelModeBan::AddMask(Channel *chan, const char *mask)
if (entry_match(ban, bi->nick, bi->user, bi->host, 0))
{
ircdproto->SendMode(bi, chan->name, "-b %s", mask);
ircdproto->SendMode(bi, chan, "-b %s", mask);
entry_delete(chan->bans, ban);
return;
}
@@ -820,9 +820,9 @@ void ModeManager::ProcessModes()
for (std::list<std::string>::iterator lit = ModeStrings.begin(); lit != ModeStrings.end(); ++lit)
{
if (c)
ircdproto->SendMode(s->bi, c->name, lit->c_str());
ircdproto->SendMode(s->bi, c, lit->c_str());
else if (u)
ircdproto->SendMode(u, lit->c_str());
ircdproto->SendMode(s->bi, u, lit->c_str());
}
delete it->second;
}
+1 -1
View File
@@ -102,7 +102,7 @@ class CommandCSAppendTopic : public Command
if (whosends(ci) == findbot(Config.s_ChanServ))
{
ircdproto->SendJoin(findbot(Config.s_ChanServ), c->name, c->creation_time);
ircdproto->SendMode(NULL, c->name, "+o %s", Config.s_ChanServ);
ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ);
}
}
ircdproto->SendTopic(whosends(ci), c, u->nick, topic);
+3 -3
View File
@@ -67,7 +67,7 @@ void IRCDProto::SendSVSKill(BotInfo *source, User *user, const char *fmt, ...)
SendSVSKillInternal(source, user, buf);
}
void IRCDProto::SendMode(BotInfo *bi, const char *dest, const char *fmt, ...)
void IRCDProto::SendMode(BotInfo *bi, Channel *dest, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE] = "";
@@ -77,14 +77,14 @@ void IRCDProto::SendMode(BotInfo *bi, const char *dest, const char *fmt, ...)
SendModeInternal(bi, dest, buf);
}
void IRCDProto::SendMode(User *u, const char *fmt, ...)
void IRCDProto::SendMode(BotInfo *bi, User *u, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZE] = "";
va_start(args, fmt);
vsnprintf(buf, BUFSIZE - 1, fmt, args);
va_end(args);
SendModeInternal(u, buf);
SendModeInternal(bi, u, buf);
}
void IRCDProto::SendKick(BotInfo *bi, Channel *chan, User *user, const char *fmt, ...)
+12 -10
View File
@@ -141,17 +141,17 @@ void bahamut_cmd_chghost(const char *nick, const char *vhost)
class BahamutIRCdProto : public IRCDProto
{
void SendModeInternal(BotInfo *source, const char *dest, const char *buf)
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
if (ircdcap->tsmode && (uplink_capab & ircdcap->tsmode)) send_cmd(source->nick, "MODE %s 0 %s", dest, buf);
else send_cmd(source->nick, "MODE %s %s", dest, buf);
if (ircdcap->tsmode && (uplink_capab & ircdcap->tsmode)) send_cmd(source->nick, "MODE %s 0 %s", dest->name, buf);
else send_cmd(source->nick, "MODE %s %s", dest->name, buf);
}
void SendModeInternal(User *u, const char *buf)
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
send_cmd(Config.ServerName, "SVSMODE %s %ld %s", u->nick, static_cast<long>(u->timestamp), buf);
send_cmd(bi ? bi->nick : Config.ServerName, "SVSMODE %s %ld %s", u->nick, static_cast<long>(u->timestamp), buf);
}
/* SVSHOLD - set */
@@ -271,7 +271,7 @@ class BahamutIRCdProto : public IRCDProto
*/
void SendSVSMode(User *u, int ac, const char **av)
{
this->SendModeInternal(u, merge_args(ac, av));
this->SendModeInternal(NULL, u, merge_args(ac, av));
}
void SendEOB()
@@ -302,8 +302,9 @@ class BahamutIRCdProto : public IRCDProto
/* nc_change was = 1, and there is no na->status */
void SendUnregisteredNick(User *u)
{
u->RemoveMode(UMODE_REGISTERED);
ircdproto->SendMode(u, "+d 1");
BotInfo *bi = findbot(Config.s_NickServ);
u->RemoveMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d 1");
}
/* SERVER */
@@ -340,8 +341,9 @@ class BahamutIRCdProto : public IRCDProto
u->nc->Extend("authenticationtoken", sstrdup(svidbuf));
u->SetMode(UMODE_REGISTERED);
ircdproto->SendMode(u, "+d %s", svidbuf);
BotInfo *bi = findbot(Config.s_NickServ);
u->SetMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d %s", svidbuf);
}
} ircd_proto;
+6 -7
View File
@@ -197,7 +197,7 @@ class InspIRCdProto : public IRCDProto
void SendSVSMode(User *u, int ac, const char **av)
{
this->SendModeInternal(u, merge_args(ac, av));
this->SendModeInternal(NULL, u, merge_args(ac, av));
}
void SendNumericInternal(const char *source, int numeric, const char *dest, const char *buf)
@@ -210,17 +210,16 @@ class InspIRCdProto : public IRCDProto
send_cmd(Config.ServerName, "NICK %ld %s %s %s %s +%s 0.0.0.0 :%s", static_cast<long>(time(NULL)), nick, host, host, user, modes, real);
}
void SendModeInternal(BotInfo *source, const char *dest, const char *buf)
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
Channel *c = findchan(dest);
send_cmd(source ? source->nick : Config.s_OperServ, "FMODE %s %u %s", dest, static_cast<unsigned>(c ? c->creation_time : time(NULL)), buf);
send_cmd(source ? source->nick : Config.s_OperServ, "FMODE %s %u %s", dest->name, static_cast<unsigned>(dest->creation_time), buf);
}
void SendModeInternal(User *u, const char *buf)
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
send_cmd(Config.s_NickServ, "MODE %s %s", u->nick, buf);
send_cmd(bi ? bi->nick : Config.ServerName, "MODE %s %s", u->nick, buf);
}
void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid)
@@ -331,7 +330,7 @@ class InspIRCdProto : public IRCDProto
/* SVSMODE +- */
void SendUnregisteredNick(User *u)
{
u->RemoveMode(UMODE_REGISTERED);
u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
}
void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param)
+9 -10
View File
@@ -204,7 +204,7 @@ class InspIRCdProto : public IRCDProto
void SendSVSMode(User *u, int ac, const char **av)
{
this->SendModeInternal(u, merge_args(ac, av));
this->SendModeInternal(NULL, u, merge_args(ac, av));
}
void SendNumericInternal(const char *source, int numeric, const char *dest, const char *buf)
@@ -217,16 +217,15 @@ class InspIRCdProto : public IRCDProto
send_cmd(TS6SID, "UID %ld %s %s %s %s +%s 0.0.0.0 :%s", static_cast<long>(time(NULL)), nick, host, host, user, modes, real);
}
void SendModeInternal(BotInfo *source, const char *dest, const char *buf)
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
Channel *c = findchan(dest);
send_cmd(source ? source->uid : TS6SID, "FMODE %s %u %s", dest, static_cast<unsigned>(c ? c->creation_time : time(NULL)), buf);
send_cmd(source ? source->uid : TS6SID, "FMODE %s %u %s", dest->name, static_cast<unsigned>(dest->creation_time), buf);
}
void SendModeInternal(User *u, const char *buf)
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
send_cmd(findbot(Config.s_NickServ)->uid, "MODE %s %s", u->GetUID().c_str(), buf);
send_cmd(bi ? bi->uid : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf);
}
void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid)
@@ -338,7 +337,7 @@ class InspIRCdProto : public IRCDProto
/* SVSMODE -r */
void SendUnregisteredNick(User *u)
{
u->RemoveMode(UMODE_REGISTERED);
u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
}
void SendSVSJoin(const char *source, const char *nick, const char *chan, const char *param)
@@ -398,7 +397,7 @@ class InspIRCdProto : public IRCDProto
if (!u->nc)
return;
u->SetMode(UMODE_REGISTERED);
u->SetMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
}
} ircd_proto;
@@ -839,7 +838,7 @@ int anope_event_uid(const char *source, int ac, const char **av)
{
validate_user(user);
if (user->HasMode(UMODE_REGISTERED))
user->RemoveMode(UMODE_REGISTERED);
user->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
}
user = NULL;
@@ -1125,7 +1124,7 @@ int anope_event_endburst(const char *source, int ac, const char **av)
{
validate_user(u);
if (u->HasMode(UMODE_REGISTERED))
u->RemoveMode(UMODE_REGISTERED);
u->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
}
alog("Processed ENDBURST for %s", s->name);
+6 -6
View File
@@ -219,7 +219,7 @@ class RatboxProto : public IRCDTS6Proto
void SendSVSMode(User *u, int ac, const char **av)
{
this->SendModeInternal(u, merge_args(ac, av));
this->SendModeInternal(NULL, u, merge_args(ac, av));
}
/* SERVER name hop descript */
@@ -259,19 +259,19 @@ class RatboxProto : public IRCDTS6Proto
send_cmd(TS6SID, "%03d %s %s", numeric, dest, buf);
}
void SendModeInternal(BotInfo *bi, const char *dest, const char *buf)
void SendModeInternal(BotInfo *bi, Channel *dest, const char *buf)
{
if (bi)
{
send_cmd(bi->uid, "MODE %s %s", dest, buf);
send_cmd(bi->uid, "MODE %s %s", dest->name, buf);
}
else send_cmd(TS6SID, "MODE %s %s", dest, buf);
else send_cmd(TS6SID, "MODE %s %s", dest->name, buf);
}
void SendModeInternal(User *u, const char *buf)
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
send_cmd(TS6SID, "SVSMODE %s %s", u->nick, buf);
send_cmd(bi ? bi->uid : TS6SID, "SVSMODE %s %s", u->nick, buf);
}
void SendKickInternal(BotInfo *bi, Channel *chan, User *user, const char *buf)
+17 -12
View File
@@ -186,9 +186,12 @@ class UnrealIRCdProto : public IRCDProto
void SendVhostDel(User *u)
{
u->RemoveMode(UMODE_CLOAK);
u->RemoveMode(UMODE_VHOST);
u->SetMode(UMODE_CLOAK);
BotInfo *bi = findbot(Config.s_HostServ);
u->RemoveMode(bi, UMODE_CLOAK);
u->RemoveMode(bi, UMODE_VHOST);
ModeManager::ProcessModes();
u->SetMode(bi, UMODE_CLOAK);
ModeManager::ProcessModes();
}
void SendAkill(Akill *ak)
@@ -215,20 +218,20 @@ class UnrealIRCdProto : public IRCDProto
{
if (ac >= 1) {
if (!u || !av[0]) return;
this->SendModeInternal(u, merge_args(ac, av));
this->SendModeInternal(NULL, u, merge_args(ac, av));
}
}
void SendModeInternal(BotInfo *source, const char *dest, const char *buf)
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
if (!buf) return;
send_cmd(source->nick, "G %s %s", dest, buf);
send_cmd(source->nick, "G %s %s", dest->name, buf);
}
void SendModeInternal(User *u, const char *buf)
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
send_cmd(Config.ServerName, "v %s %s", u->nick, buf);
send_cmd(bi ? bi->nick : Config.ServerName, "v %s %s", u->nick, buf);
}
void SendClientIntroduction(const char *nick, const char *user, const char *host, const char *real, const char *modes, const char *uid)
@@ -462,14 +465,16 @@ class UnrealIRCdProto : public IRCDProto
u->nc->Extend("authenticationtoken", sstrdup(svidbuf));
u->SetMode(UMODE_REGISTERED);
ircdproto->SendMode(u, "+d %s", svidbuf);
BotInfo *bi = findbot(Config.s_NickServ);
u->SetMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d %s", svidbuf);
}
void SendUnregisteredNick(User *u)
{
u->RemoveMode(UMODE_REGISTERED);
ircdproto->SendMode(u, "+d 1");
BotInfo *bi = findbot(Config.s_NickServ);
u->RemoveMode(bi, UMODE_REGISTERED);
ircdproto->SendMode(bi, u, "+d 1");
}
} ircd_proto;
+1 -1
View File
@@ -79,7 +79,7 @@ ChannelInfo::~ChannelInfo()
if (this->c && this->c->HasMode(CMODE_PERM))
{
this->c->RemoveMode(NULL, CMODE_PERM);
ircdproto->SendMode(whosends(this), this->name, "-%c", ModeManager::FindChannelModeByName(CMODE_PERM)->ModeChar);
ircdproto->SendMode(whosends(this), this->c, "-%c", ModeManager::FindChannelModeByName(CMODE_PERM)->ModeChar);
}
if (debug)
+24 -17
View File
@@ -506,68 +506,75 @@ void User::RemoveModeInternal(UserMode *um)
}
/** Set a mode on the user
* @param bi The client setting the mode
* @param um The user mode
* @param Param Optional param for the mode
*/
void User::SetMode(UserMode *um, const std::string &Param)
void User::SetMode(BotInfo *bi, UserMode *um, const std::string &Param)
{
if (!um)
return;
ModeManager::StackerAdd(bi, this, um, true, Param);
SetModeInternal(um, Param);
ModeManager::StackerAdd(NULL, this, um, true, Param);
}
/** Set a mode on the user
* @param bi The client setting the mode
* @param Name The mode name
* @param param Optional param for the mode
*/
void User::SetMode(UserModeName Name, const std::string &Param)
void User::SetMode(BotInfo *bi, UserModeName Name, const std::string &Param)
{
SetMode(ModeManager::FindUserModeByName(Name), Param);
SetMode(bi, ModeManager::FindUserModeByName(Name), Param);
}
/* Set a mode on the user
* @param bi The client setting the mode
* @param ModeChar The mode char
* @param param Optional param for the mode
*/
void User::SetMode(char ModeChar, const std::string &Param)
void User::SetMode(BotInfo *bi, char ModeChar, const std::string &Param)
{
SetMode(ModeManager::FindUserModeByChar(ModeChar), Param);
SetMode(bi, ModeManager::FindUserModeByChar(ModeChar), Param);
}
/** Remove a mode on the user
* @param bi The client setting the mode
* @param um The user mode
*/
void User::RemoveMode(UserMode *um)
void User::RemoveMode(BotInfo *bi, UserMode *um)
{
if (!um)
return;
ModeManager::StackerAdd(bi, this, um, false);
RemoveModeInternal(um);
ModeManager::StackerAdd(NULL, this, um, false);
}
/** Remove a mode from the user
* @param bi The client setting the mode
* @param Name The mode name
*/
void User::RemoveMode(UserModeName Name)
void User::RemoveMode(BotInfo *bi, UserModeName Name)
{
RemoveMode(ModeManager::FindUserModeByName(Name));
RemoveMode(bi, ModeManager::FindUserModeByName(Name));
}
/** Remove a mode from the user
* @param bi The client setting the mode
* @param ModeChar The mode char
*/
void User::RemoveMode(char ModeChar)
void User::RemoveMode(BotInfo *bi, char ModeChar)
{
RemoveMode(ModeManager::FindUserModeByChar(ModeChar));
RemoveMode(bi, ModeManager::FindUserModeByChar(ModeChar));
}
/** Set a string of modes on a user
* @param bi The client setting the mode
* @param modes The modes
*/
void User::SetModes(const std::string &modes, ...)
void User::SetModes(BotInfo *bi, const std::string &modes, ...)
{
char buf[BUFSIZE] = "";
va_list args;
@@ -602,13 +609,13 @@ void User::SetModes(const std::string &modes, ...)
if (add)
{
if (um->Type == MODE_PARAM && sep.GetToken(sbuf))
this->SetMode(um, sbuf);
this->SetMode(bi, um, sbuf);
else
this->SetMode(um);
this->SetMode(bi, um);
}
else if (add == 0)
{
this->RemoveMode(um);
this->RemoveMode(bi, um);
}
}
}
@@ -1248,7 +1255,7 @@ void UserSetInternalModes(User *user, int ac, const char **av)
break;
case UMODE_REGISTERED:
if (add && !nick_identified(user))
user->RemoveMode(UMODE_REGISTERED);
user->RemoveMode(findbot(Config.s_NickServ), UMODE_REGISTERED);
break;
case UMODE_CLOAK:
case UMODE_VHOST: