]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_watch.cpp
Fix m_ssl_gnutls and perhaps some other things on Windows by recognizing WSAEWOULDBLOCK
[user/henk/code/inspircd.git] / src / modules / m_watch.cpp
index 029055db4ee9cb8716f66115a32650ee80e11c49..ec38edc31b8727b55e922234bc31078af72a64d8 100644 (file)
  * Before you start screaming, this definition is only used here, so moving it to a header is pointless.
  * Yes, it's horrid. Blame cl for being different. -- w00t
  */
-#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED)
-       typedef nspace::hash_map<irc::string, std::deque<User*>, nspace::hash_compare<irc::string, std::less<irc::string> > > watchentries;
-#else
-       typedef nspace::hash_map<irc::string, std::deque<User*>, irc::hash> watchentries;
-#endif
+
+typedef nspace::hash_map<irc::string, std::deque<User*>, irc::hash> watchentries;
 typedef std::map<irc::string, std::string> watchlist;
 
 /* Who's watching each nickname.
@@ -252,7 +249,7 @@ class CommandWatch : public Command
                        }
                        else
                        {
-                               (*wl)[nick] = "";
+                               (*wl)[nick].clear();
                                user->WriteNumeric(605, "%s %s * * 0 :is offline",user->nick.c_str(), nick);
                        }
                }
@@ -380,21 +377,24 @@ class Modulewatch : public Module
 
  public:
        Modulewatch()
-               : maxwatch(32), cmdw(this, maxwatch), sw(this) 
+               : maxwatch(32), cmdw(this, maxwatch), sw(this)
        {
-               OnRehash(NULL);
                whos_watching_me = new watchentries();
-               ServerInstance->AddCommand(&cmdw);
-               ServerInstance->AddCommand(&sw);
-               ServerInstance->Extensions.Register(&cmdw.ext);
+       }
+
+       void init()
+       {
+               OnRehash(NULL);
+               ServerInstance->Modules->AddService(cmdw);
+               ServerInstance->Modules->AddService(sw);
+               ServerInstance->Modules->AddService(cmdw.ext);
                Implementation eventlist[] = { I_OnRehash, I_OnGarbageCollect, I_OnUserQuit, I_OnPostConnect, I_OnUserPostNick, I_On005Numeric, I_OnSetAway };
-               ServerInstance->Modules->Attach(eventlist, this, 7);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        virtual void OnRehash(User* user)
        {
-               ConfigReader Conf;
-               maxwatch = Conf.ReadInteger("watch", "maxentries", 0, true);
+               maxwatch = ServerInstance->Config->ConfValue("watch")->getInt("maxentries", 32);
                if (!maxwatch)
                        maxwatch = 32;
        }
@@ -406,12 +406,12 @@ class Modulewatch : public Module
 
                if (awaymsg.empty())
                {
-                       numeric = std::string(user->nick) + " " + user->ident + " " + user->dhost + " " + ConvToStr(ServerInstance->Time()) + " :is no longer away";
+                       numeric = user->nick + " " + user->ident + " " + user->dhost + " " + ConvToStr(ServerInstance->Time()) + " :is no longer away";
                        inum = 599;
                }
                else
                {
-                       numeric = std::string(user->nick) + " " + user->ident + " " + user->dhost + " " + ConvToStr(ServerInstance->Time()) + " :" + awaymsg;
+                       numeric = user->nick + " " + user->ident + " " + user->dhost + " " + ConvToStr(ServerInstance->Time()) + " :" + awaymsg;
                        inum = 598;
                }
 
@@ -439,7 +439,7 @@ class Modulewatch : public Module
                                watchlist* wl = cmdw.ext.get(*n);
                                if (wl)
                                        /* We were on somebody's notify list, set ourselves offline */
-                                       (*wl)[user->nick.c_str()] = "";
+                                       (*wl)[user->nick.c_str()].clear();
                        }
                }
 
@@ -508,7 +508,7 @@ class Modulewatch : public Module
                                if (wl)
                                {
                                        (*n)->WriteNumeric(601, "%s %s %s %s %lu :went offline", (*n)->nick.c_str(), oldnick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) user->age);
-                                       (*wl)[oldnick.c_str()] = "";
+                                       (*wl)[oldnick.c_str()].clear();
                                }
                        }
                }