Improve BanEntry
authorclinton <clinton@unknownlamer.org>
Sun, 16 Nov 2008 00:09:59 +0000 (00:09 +0000)
committerclinton <clinton@unknownlamer.org>
Sun, 16 Nov 2008 00:09:59 +0000 (00:09 +0000)
* 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
source/BanEntry.H
source/Channel.C
source/Commands.C
source/UserCommands.C

index 88ea4e8..bc6efb7 100644 (file)
@@ -33,8 +33,8 @@ BanEntry::setExpirationDate(time_t exp)
   expirationDate = exp;
 }
 
-String
-BanEntry::getMask()
+const Mask&
+BanEntry::getMask() const
 {
-  return banMask.getMask();
+  return banMask;
 }
index 8d594de..0ed0b2f 100644 (file)
@@ -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
index 56b51bb..5d35728 100644 (file)
@@ -177,7 +177,7 @@ Channel::addBan(String mask, std::time_t expiration)
 {
   for (std::vector<BanEntry *>::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<BanEntry *>::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;
index 70a1d05..ede6428 100644 (file)
@@ -177,8 +177,8 @@ Commands::Ban(Bot *bot, String channel, String who)
 
   for (std::vector<BanEntry *>::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<BanEntry *>::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());
        }
     }
 
index 457ebf5..0ad6ba7 100644 (file)
@@ -330,9 +330,9 @@ UserCommands::BanList(ServerConnection *cnx, Person *from,
   for (std::vector<BanEntry *>::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<BanEntry *>::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);