From 952376e7bc7d5cae14c45264113fda3c7274cb51 Mon Sep 17 00:00:00 2001 From: clinton Date: Sun, 16 Nov 2008 00:09:59 +0000 Subject: [PATCH] Improve BanEntry * No longer has any friend classes * BanEntry::getMask returns the actual Mask instead of the internal mask String - Updated all users of BanEntry to use slightly different interface --- source/BanEntry.C | 6 +++--- source/BanEntry.H | 8 +------- source/Channel.C | 4 ++-- source/Commands.C | 12 ++++++------ source/UserCommands.C | 8 ++++---- 5 files changed, 16 insertions(+), 22 deletions(-) diff --git a/source/BanEntry.C b/source/BanEntry.C index 88ea4e8..bc6efb7 100644 --- a/source/BanEntry.C +++ b/source/BanEntry.C @@ -33,8 +33,8 @@ BanEntry::setExpirationDate(time_t exp) expirationDate = exp; } -String -BanEntry::getMask() +const Mask& +BanEntry::getMask() const { - return banMask.getMask(); + return banMask; } diff --git a/source/BanEntry.H b/source/BanEntry.H index 8d594de..0ed0b2f 100644 --- a/source/BanEntry.H +++ b/source/BanEntry.H @@ -23,9 +23,6 @@ #include "Mask.H" -class Commands; -class UserCommands; - class BanEntry { Mask banMask; std::time_t expirationDate; @@ -37,10 +34,7 @@ public: std::time_t getExpirationDate() const; void setExpirationDate(std::time_t); - String getMask(); - - friend class Commands; - friend class UserCommands; + const Mask& getMask() const; }; #endif diff --git a/source/Channel.C b/source/Channel.C index 56b51bb..5d35728 100644 --- a/source/Channel.C +++ b/source/Channel.C @@ -177,7 +177,7 @@ Channel::addBan(String mask, std::time_t expiration) { for (std::vector::iterator it = channelBanlist.begin(); it != channelBanlist.end(); ++it) - if ((*it)->getMask() == mask) { + if ((*it)->getMask().getMask() == mask) { if (expiration > (*it)->getExpirationDate()) (*it)->setExpirationDate(expiration); return; @@ -190,7 +190,7 @@ Channel::delBan(String mask) { for (std::vector::iterator it = channelBanlist.begin(); it != channelBanlist.end(); ++it) - if (mask == (*it)->getMask()) { + if (mask == (*it)->getMask().getMask()) { BanEntry *b = *it; channelBanlist.erase(it); delete b; diff --git a/source/Commands.C b/source/Commands.C index 70a1d05..ede6428 100644 --- a/source/Commands.C +++ b/source/Commands.C @@ -177,8 +177,8 @@ Commands::Ban(Bot *bot, String channel, String who) for (std::vector::iterator it = c->channelBanlist.begin(); it != c->channelBanlist.end(); ++it) - if (m.matches((*it)->banMask) && (*it)->banMask.getMask() != m.getMask()) - QUEUE->sendChannelMode(channel, "-b", (*it)->banMask.getMask()); + if (m.matches((*it)->getMask ()) && (*it)->getMask().getMask() != m.getMask()) + QUEUE->sendChannelMode(channel, "-b", (*it)->getMask().getMask()); QUEUE->sendChannelMode(channel, "+b", dest); @@ -307,10 +307,10 @@ Commands::Deban(Bot *bot, String channel, String who) it != c->channelBanlist.end(); ++it) if (m.matches((*it)->getMask())) { // Let's see if the ban is in the shitlist - ShitEntry *se = bot->shitList->getShit((*it)->getMask(), channel); + ShitEntry *se = bot->shitList->getShit((*it)->getMask().getMask(), channel); if (!se || !se->isStillValid() || se->getShitLevel() < ShitEntry::SHIT_NODEBAN) - QUEUE->sendChannelMode(channel, "-b", (*it)->getMask()); + QUEUE->sendChannelMode(channel, "-b", (*it)->getMask().getMask()); } return Ok; @@ -828,9 +828,9 @@ Commands::TBan(Bot *bot, String channel, String who, int seconds) for (std::vector::iterator it = c->channelBanlist.begin(); it != c->channelBanlist.end(); ++it) { - if (m.matches((*it)->banMask)) + if (m.matches((*it)->getMask ())) { - QUEUE->sendChannelMode(channel, "-b", (*it)->banMask.getMask()); + QUEUE->sendChannelMode(channel, "-b", (*it)->getMask().getMask()); } } diff --git a/source/UserCommands.C b/source/UserCommands.C index 457ebf5..0ad6ba7 100644 --- a/source/UserCommands.C +++ b/source/UserCommands.C @@ -330,9 +330,9 @@ UserCommands::BanList(ServerConnection *cnx, Person *from, for (std::vector::iterator it = c->channelBanlist.begin(); it != c->channelBanlist.end(); ++it) if ((*it)->getExpirationDate() == -1) - from->sendNotice((*it)->getMask().pad(30) + " -1"); + from->sendNotice((*it)->getMask().getMask().pad(30) + " -1"); else - from->sendNotice((*it)->getMask().pad(30) + " " + + from->sendNotice((*it)->getMask().getMask().pad(30) + " " + String((long)((*it)->getExpirationDate()-current))); from->sendNotice("\002End of banlist.\002"); } @@ -1400,8 +1400,8 @@ UserCommands::TBan(ServerConnection *cnx, Person *from, for (std::vector::iterator it = c->channelBanlist.begin(); it != c->channelBanlist.end(); ++it) - if (m.matches((*it)->banMask)) - cnx->queue->sendChannelMode(channel, "-b", (*it)->banMask.getMask()); + if (m.matches((*it)->getMask())) + cnx->queue->sendChannelMode(channel, "-b", (*it)->getMask().getMask()); cnx->bot->channelList->getChannel(channel)->addBan(dest, w); cnx->queue->sendChannelMode(channel, "+b", dest); -- 2.20.1