Quiet annoying mutex debug logging messages
[clinton/bobotpp.git] / source / Bot.C
index f479d81..ed8aa50 100644 (file)
@@ -48,7 +48,6 @@
 #include "ServerList.H"
 #include "ShitList.H"
 #include "StringTokenizer.H"
-#include "TodoList.H"
 #include "User.H"
 #include "UserCommands.H"
 #include "UserList.H"
@@ -128,11 +127,10 @@ Bot::Bot(String filename, bool debug_on)
   readConfig();
   userList = new UserList(userListFileName);
   shitList = new ShitList(shitListFileName);
-  todoList = new TodoList();
   dccConnections = new DCCManager ();
 
   // Let's read the alias file
-  std::ifstream initFile(initFileName);
+  std::ifstream initFile(initFileName.c_str ());
 
   if (initFile) 
     {
@@ -209,7 +207,6 @@ Bot::~Bot()
   shitList->save();
   delete channelList;
   delete userList;
-  delete todoList;
   delete serverList;
   delete shitList;
   delete serverConnection;
@@ -238,7 +235,7 @@ Bot::logLine(String line)
 void
 Bot::readConfig()
 {
-  std::ifstream file(configFileName);
+  std::ifstream file(configFileName.c_str ());
   String temp;
   int line = 1;
 
@@ -327,7 +324,7 @@ Bot::readConfig()
     else if (command == "LOCALIP")
       localIP = parameters;
     else if (command == "MAXNICKLENGTH")
-      MAX_NICKLENGTH = std::atoi (parameters);
+      MAX_NICKLENGTH = std::atoi (parameters.c_str ());
     else if (command == "SERVER") {
       if (parameters.indexOf(' ') == -1)
         serverList->addServer(new Server(parameters));
@@ -445,10 +442,12 @@ Bot::waitForInput()
       if ((*it).second > 0)
         (*it).second--;
 
-    String line;
-    while ((line = todoList->getNext()) != "") {
-      serverConnection->queue->sendChannelMode(line);
-    }
+    for (std::map<String, Channel *, std::less<String> >::iterator it = channelList->begin ();
+        it != channelList->end ();
+        ++it)
+      {
+       it->second->purge_expired_bans ();
+      }
 #ifdef USESCRIPTS
     botInterp->RunTimers(currentTime);
 
@@ -508,8 +507,8 @@ Bot::canChangeServer()
        it != channelList->end(); ++it) {
     channel = (*it).first;
     c = channelList->getChannel(channel);
-    if (c->countOp == 1 &&
-        c->count > 1 && this->iAmOp(channel))
+    if (c->operator_count () == 1 &&
+        c->user_count () > 1 && this->iAmOp(channel))
       return false;
   }
   return true;
@@ -626,7 +625,7 @@ Bot::getUserhost(String channel, String nick)
 
 
   if (c && c->hasNick(nick))
-    return c->getUser(nick)->userhost;
+    return c->getUser(nick).userhost;
 
   unsigned long num = sentUserhostID++;
 
@@ -648,8 +647,7 @@ Bot::getUserhost(String channel, String nick)
 bool
 Bot::iAmOp(String channel)
 {
-  User * me = channelList->getChannel(channel)->getUser(nickName);
-  return (me->mode & User::OP_MODE);
+  return channelList->getChannel(channel)->getUser(nickName).mode & User::OP_MODE;
 }
 
 void
@@ -758,10 +756,10 @@ Bot::set_log_file (String name)
   logFile.close ();
   logFile.clear ();
 #if HAVE_IOSBASE
-  logFile.open(logs_dir + logFileName, std::ios_base::out | 
+  logFile.open((logs_dir + logFileName).c_str (), std::ios_base::out | 
               std::ios_base::ate | std::ios_base::app);
 #else
-  logFile.open(logs_dir + logFileName, ios::out | ios::ate 
+  logFile.open((logs_dir + logFileName).c_str (), ios::out | ios::ate 
              | ios::app);
 #endif
 
@@ -773,11 +771,11 @@ Bot::set_log_dir (String dir)
 {
   logs_dir = dir;
 
-  DIR *temp = opendir (logs_dir);
+  DIR *temp = opendir (logs_dir.c_str ());
 
   if (!temp)
     {
-      mkdir (logs_dir, S_IRWXU);
+      mkdir (logs_dir.c_str (), S_IRWXU);
     }
   else
     {