int othersessions = 0;
/* XXX - why can't just use pinfo.size() like we do below, rather than iterating over the whole vector? -- w00t */
if (pinfo.size())
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
if (j->host == std::string(user->host))
othersessions++;
if (othersessions >= ConcurrentParks)
if (key == atoi(parameters[1]))
{
// first part the user from all chans theyre on, so things dont get messy
- for (unsigned int i = 0; i < user->chans.size(); i++)
- {
- if (user->chans[i].channel != NULL)
- {
- if (user->chans[i].channel->name)
- {
- Srv->PartUserFromChannel(user,user->chans[i].channel->name,"Unparking");
- }
+ for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++)
+ {
+ if (((ucrec*)(*i))->channel != NULL)
+ {
+ Srv->PartUserFromChannel(user,((ucrec*)(*i))->channel->name,"Unparking");
}
}
// remove all their old modes
- WriteServ(user->fd,"MODE %s -%s",user->nick,user->modes);
+ WriteServ(user->fd,"MODE %s -%s",user->nick,user->FormatModes());
// now, map them to the parked user, while nobody can see :p
Srv->PseudoToUser(user,unpark,"Unparked to "+std::string(parameters[0]));
// set all their new modes
- WriteServ(unpark->fd,"MODE %s +%s",unpark->nick,unpark->modes);
+ WriteServ(unpark->fd,"MODE %s +%s",unpark->nick,unpark->FormatModes());
// spool their away log to them
WriteServ(unpark->fd,"NOTICE %s :*** You are now unparked. You have successfully taken back the nickname and privilages of %s.",unpark->nick,unpark->nick);
for (awaylog::iterator i = awy->begin(); i != awy->end(); i++)
timebuf[strlen(timebuf)-1] = '\0';
WriteServ(unpark->fd,"NOTICE %s :From %s at %s: \2%s\2",unpark->nick,i->from.c_str(),timebuf,i->text.c_str());
}
- delete awy;
+ DELETE(awy);
unpark->Shrink("park_awaylog");
unpark->Shrink("park_key");
for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
ParkMaxTime = Conf->ReadInteger("park","maxtime",0,true);
ConcurrentParks = Conf->ReadInteger("park","maxperip",0,true);
ParkMaxMsgs = Conf->ReadInteger("park","maxmessages",0,true);
- delete Conf;
+ DELETE(Conf);
}
ModulePark(Server* Me)
List[I_On005Numeric] = List[I_OnRehash] = List[I_OnUserQuit] = List[I_OnUserPreMessage] = List[I_OnUserPreNick] = List[I_OnBackgroundTimer] = List[I_OnWhois] = 1;
}
- virtual void OnRehash(std::string parameter)
+ virtual void OnRehash(const std::string ¶meter)
{
this->ReadSettings();
}
- virtual void On005Numeric(std::string &output)
- {
- output = output + std::string(" PARK");
- }
+ virtual void On005Numeric(std::string &output)
+ {
+ output = output + std::string(" PARK");
+ }
- virtual void OnUserQuit(userrec* user, std::string reason)
- {
- std::string nick = user->nick;
- // track quits in our parked user list
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
- {
- if (j->nick == nick)
- {
- pinfo.erase(j);
- break;
- }
- }
- }
+ virtual void OnUserQuit(userrec* user, const std::string &reason)
+ {
+ std::string nick = user->nick;
+ // track quits in our parked user list
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ {
+ if (j->nick == nick)
+ {
+ pinfo.erase(j);
+ break;
+ }
+ }
+ }
- virtual void OnPrePrivmsg(userrec* user, userrec* dest, std::string text)
+ virtual void OnPrePrivmsg(userrec* user, userrec* dest, const std::string &text)
{
awaylog* awy = (awaylog*)dest->GetExt("park_awaylog");
if (awy)
}
}
- virtual int OnUserPreNick(userrec* user, std::string newnick)
+ virtual int OnUserPreNick(userrec* user, const std::string &newnick)
{
// track nickchanges in our parked user list
// (this isnt too efficient, i'll tidy it up some time)
/* XXX - perhaps extend the user record, or, that wouldn't work - perhaps use a map? -- w00t */
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
- {
- if (j->nick == std::string(user->nick))
- {
- j->nick = newnick;
- break;
- }
- }
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ {
+ if (j->nick == std::string(user->nick))
+ {
+ j->nick = newnick;
+ break;
+ }
+ }
return 0;
}
virtual void OnBackgroundTimer(time_t curtime)
{
- // look for parked clients which have timed out (this needs tidying)
- if (pinfo.empty())
- return;
- bool go_again = true;
- while (go_again)
- {
- go_again = false;
- for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
- {
- if (time(NULL) >= (j->parktime+ParkMaxTime))
- {
- userrec* thisnick = Srv->FindNick(j->nick);
+ // look for parked clients which have timed out (this needs tidying)
+ if (pinfo.empty())
+ return;
+ bool go_again = true;
+ while (go_again)
+ {
+ go_again = false;
+ for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++)
+ {
+ if (time(NULL) >= (j->parktime+ParkMaxTime))
+ {
+ userrec* thisnick = Srv->FindNick(j->nick);
// THIS MUST COME BEFORE THE QuitUser - QuitUser can
// create a recursive call to OnUserQuit in this module
// and then corrupt the pointer!
pinfo.erase(j);
- if (thisnick)
- Srv->QuitUser(thisnick,"PARK timeout");
- go_again = true;
- break;
- }
- }
- }
+ if (thisnick)
+ Srv->QuitUser(thisnick,"PARK timeout");
+ go_again = true;
+ break;
+ }
+ }
+ }
}
/* XXX - why is OnPrePrivmsg seperated here, I assume there is reason for the extra function call? --w00t */
return 0;
}
- virtual void OnWhois(userrec* src, userrec* dst)
- {
+ virtual void OnWhois(userrec* src, userrec* dst)
+ {
if (dst->GetExt("park_awaylog"))
- Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client");
- }
+ Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client");
+ }
virtual Version GetVersion()
{