summaryrefslogtreecommitdiff
path: root/modules/core/cs_suspend.cpp
diff options
context:
space:
mode:
authorNaram Qashat <cyberbotx@cyberbotx.com>2010-07-25 21:58:20 -0400
committerNaram Qashat <cyberbotx@cyberbotx.com>2010-07-25 21:58:20 -0400
commitae38212c1ce829c783edf971081c90137abb49a0 (patch)
tree5c652d9cdc38103dec6fa112d57fca882b4e3e44 /modules/core/cs_suspend.cpp
parent15d7f0f6fe8bb903275f603f734c13f65f3aa906 (diff)
Epic commit to replace most of the strings in Anope with a single Anope::string class, plus some other little fixes here and there. If you follow 1.9.x development and are testing things, THIS is one of those things that NEEDS testing.
Diffstat (limited to 'modules/core/cs_suspend.cpp')
-rw-r--r--modules/core/cs_suspend.cpp56
1 files changed, 24 insertions, 32 deletions
diff --git a/modules/core/cs_suspend.cpp b/modules/core/cs_suspend.cpp
index 8878e5552..53bbaec92 100644
--- a/modules/core/cs_suspend.cpp
+++ b/modules/core/cs_suspend.cpp
@@ -20,16 +20,16 @@ class CommandCSSuspend : public Command
{
}
- CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- const char *chan = params[0].c_str();
- const char *reason = params.size() > 1 ? params[1].c_str() : NULL;
+ Anope::string chan = params[0];
+ Anope::string reason = params.size() > 1 ? params[1] : "";
ChannelInfo *ci = cs_findchan(chan);
Channel *c;
/* Assumes that permission checking has already been done. */
- if (Config.ForceForbidReason && !reason)
+ if (Config.ForceForbidReason && reason.empty())
{
this->OnSyntaxError(u, "");
return MOD_CONT;
@@ -44,7 +44,7 @@ class CommandCSSuspend : public Command
/* You should not SUSPEND a FORBIDEN channel */
if (ci->HasFlag(CI_FORBIDDEN))
{
- notice_lang(Config.s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan);
+ notice_lang(Config.s_ChanServ, u, CHAN_MAY_NOT_BE_REGISTERED, chan.c_str());
return MOD_CONT;
}
@@ -54,9 +54,9 @@ class CommandCSSuspend : public Command
if (ci)
{
ci->SetFlag(CI_SUSPENDED);
- ci->forbidby = sstrdup(u->nick.c_str());
- if (reason)
- ci->forbidreason = sstrdup(reason);
+ ci->forbidby = u->nick;
+ if (!reason.empty())
+ ci->forbidreason = reason;
if ((c = findchan(ci->name)))
{
@@ -67,7 +67,7 @@ class CommandCSSuspend : public Command
if (is_oper(uc->user))
continue;
- c->Kick(NULL, uc->user, "%s", reason ? reason : getstring(uc->user->Account(), CHAN_SUSPEND_REASON));
+ c->Kick(NULL, uc->user, "%s", !reason.empty() ? reason.c_str() : getstring(uc->user->Account(), CHAN_SUSPEND_REASON));
}
}
@@ -75,25 +75,25 @@ class CommandCSSuspend : public Command
ircdproto->SendGlobops(ChanServ, "\2%s\2 used SUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
Alog() << Config.s_ChanServ << ": " << u->GetMask() << " set SUSPEND for channel " << ci->name;
- notice_lang(Config.s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan);
+ notice_lang(Config.s_ChanServ, u, CHAN_SUSPEND_SUCCEEDED, chan.c_str());
FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci));
}
else
{
Alog() << Config.s_ChanServ << ": Valid SUSPEND for " << ci->name << " by " << u->GetMask() << " failed";
- notice_lang(Config.s_ChanServ, u, CHAN_SUSPEND_FAILED, chan);
+ notice_lang(Config.s_ChanServ, u, CHAN_SUSPEND_FAILED, chan.c_str());
}
return MOD_CONT;
}
- bool OnHelp(User *u, const ci::string &subcommand)
+ bool OnHelp(User *u, const Anope::string &subcommand)
{
notice_help(Config.s_ChanServ, u, CHAN_SERVADMIN_HELP_SUSPEND);
return true;
}
- void OnSyntaxError(User *u, const ci::string &subcommand)
+ void OnSyntaxError(User *u, const Anope::string &subcommand)
{
syntax_error(Config.s_ChanServ, u, "SUSPEND", Config.ForceForbidReason ? CHAN_SUSPEND_SYNTAX_REASON : CHAN_SUSPEND_SYNTAX);
}
@@ -112,9 +112,9 @@ class CommandCSUnSuspend : public Command
this->SetFlag(CFLAG_ALLOW_SUSPENDED);
}
- CommandReturn Execute(User *u, const std::vector<ci::string> &params)
+ CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- const char *chan = params[0].c_str();
+ Anope::string chan = params[0];
ChannelInfo *ci = cs_findchan(chan);
if (chan[0] != '#')
@@ -126,49 +126,41 @@ class CommandCSUnSuspend : public Command
notice_lang(Config.s_ChanServ, u, READ_ONLY_MODE);
/* Only UNSUSPEND already suspended channels */
- if (!(ci->HasFlag(CI_SUSPENDED)))
+ if (!ci->HasFlag(CI_SUSPENDED))
{
- notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan);
+ notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan.c_str());
return MOD_CONT;
}
if (ci)
{
ci->UnsetFlag(CI_SUSPENDED);
- if (ci->forbidreason)
- {
- delete [] ci->forbidreason;
- ci->forbidreason = NULL;
- }
- if (ci->forbidby)
- {
- delete [] ci->forbidby;
- ci->forbidby = NULL;
- }
+ ci->forbidreason.clear();
+ ci->forbidby.clear();
if (Config.WallForbid)
ircdproto->SendGlobops(ChanServ, "\2%s\2 used UNSUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
Alog() << Config.s_ChanServ << ": " << u->GetMask() << " set UNSUSPEND for channel " << ci->name;
- notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan);
+ notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_SUCCEEDED, chan.c_str());
FOREACH_MOD(I_OnChanUnsuspend, OnChanUnsuspend(ci));
}
else
{
Alog() << Config.s_ChanServ << ": Valid UNSUSPEND for " << chan << " by " << u->nick << " failed";
- notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan);
+ notice_lang(Config.s_ChanServ, u, CHAN_UNSUSPEND_FAILED, chan.c_str());
}
return MOD_CONT;
}
- bool OnHelp(User *u, const ci::string &subcommand)
+ bool OnHelp(User *u, const Anope::string &subcommand)
{
notice_help(Config.s_ChanServ, u, CHAN_SERVADMIN_HELP_UNSUSPEND);
return true;
}
- void OnSyntaxError(User *u, const ci::string &subcommand)
+ void OnSyntaxError(User *u, const Anope::string &subcommand)
{
syntax_error(Config.s_ChanServ, u, "UNSUSPEND", CHAN_UNSUSPEND_SYNTAX);
}
@@ -182,7 +174,7 @@ class CommandCSUnSuspend : public Command
class CSSuspend : public Module
{
public:
- CSSuspend(const std::string &modname, const std::string &creator) : Module(modname, creator)
+ CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
this->SetAuthor("Anope");
this->SetType(CORE);