]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_watch.cpp
Add initial query support to m_mysql [patch by Athenon]
[user/henk/code/inspircd.git] / src / modules / m_watch.cpp
index e70270424978a17b0a7aad85ed83f8394ba0784a..1cda4484fd6820149783c20e6dc558cceeead89b 100644 (file)
@@ -103,9 +103,8 @@ watchentries* whos_watching_me;
 class CommandSVSWatch : public Command
 {
  public:
-       CommandSVSWatch (InspIRCd* Instance) : Command(Instance,"SVSWATCH", 0, 2)
+       CommandSVSWatch (InspIRCd* Instance, Module* Creator) : Command(Instance, Creator,"SVSWATCH", 0, 2)
        {
-               this->source = "m_watch.so";
                syntax = "<target> [C|L|S]|[+|-<nick>]";
                TRANSLATE3(TR_NICK, TR_TEXT, TR_END); /* we watch for a nick. not a UID. */
        }
@@ -227,13 +226,6 @@ class CommandWatch : public Command
                        User* target = ServerInstance->FindNick(nick);
                        if (target)
                        {
-                               if (target->Visibility && !target->Visibility->VisibleTo(user))
-                               {
-                                       (*wl)[nick] = "";
-                                       user->WriteNumeric(605, "%s %s * * 0 :is offline",user->nick.c_str(), nick);
-                                       return CMD_FAILURE;
-                               }
-
                                (*wl)[nick] = std::string(target->ident).append(" ").append(target->dhost).append(" ").append(ConvToStr(target->age));
                                user->WriteNumeric(604, "%s %s %s :is online",user->nick.c_str(), nick, (*wl)[nick].c_str());
                                if (IS_AWAY(target))
@@ -251,9 +243,8 @@ class CommandWatch : public Command
                return CMD_LOCALONLY;
        }
 
-       CommandWatch (InspIRCd* Instance, unsigned int &maxwatch) : Command(Instance,"WATCH",0,0), MAX_WATCH(maxwatch)
+       CommandWatch (InspIRCd* Instance, Module* parent, unsigned int &maxwatch) : Command(Instance,parent,"WATCH",0,0), MAX_WATCH(maxwatch)
        {
-               this->source = "m_watch.so";
                syntax = "[C|L|S]|[+|-<nick>]";
                TRANSLATE2(TR_TEXT, TR_END); /* we watch for a nick. not a UID. */
        }
@@ -367,20 +358,18 @@ class CommandWatch : public Command
 
 class Modulewatch : public Module
 {
-       CommandWatch* mycommand;
-       CommandSVSWatch *sw;
        unsigned int maxwatch;
+       CommandWatch cmdw;
+       CommandSVSWatch sw;
 
  public:
        Modulewatch(InspIRCd* Me)
-               : Module(Me), maxwatch(32)
+               : Module(Me), maxwatch(32), cmdw(Me, this, maxwatch), sw(Me,this) 
        {
                OnRehash(NULL);
                whos_watching_me = new watchentries();
-               mycommand = new CommandWatch(ServerInstance, maxwatch);
-               ServerInstance->AddCommand(mycommand);
-               sw = new CommandSVSWatch(ServerInstance);
-               ServerInstance->AddCommand(sw);
+               ServerInstance->AddCommand(&cmdw);
+               ServerInstance->AddCommand(&sw);
                Implementation eventlist[] = { I_OnRehash, I_OnGarbageCollect, I_OnCleanup, I_OnUserQuit, I_OnPostConnect, I_OnUserPostNick, I_On005Numeric, I_OnSetAway };
                ServerInstance->Modules->Attach(eventlist, this, 8);
        }
@@ -393,7 +382,7 @@ class Modulewatch : public Module
                        maxwatch = 32;
        }
 
-       virtual int OnSetAway(User *user, const std::string &awaymsg)
+       virtual ModResult OnSetAway(User *user, const std::string &awaymsg)
        {
                std::string numeric;
                int inum;
@@ -414,12 +403,11 @@ class Modulewatch : public Module
                {
                        for (std::deque<User*>::iterator n = x->second.begin(); n != x->second.end(); n++)
                        {
-                               if (!user->Visibility || user->Visibility->VisibleTo(user))
-                                       (*n)->WriteNumeric(inum, numeric);
+                               (*n)->WriteNumeric(inum, numeric);
                        }
                }
 
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 
        virtual void OnUserQuit(User* user, const std::string &reason, const std::string &oper_message)
@@ -429,8 +417,7 @@ class Modulewatch : public Module
                {
                        for (std::deque<User*>::iterator n = x->second.begin(); n != x->second.end(); n++)
                        {
-                               if (!user->Visibility || user->Visibility->VisibleTo(*n))
-                                       (*n)->WriteNumeric(601, "%s %s %s %s %lu :went offline", (*n)->nick.c_str() ,user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) ServerInstance->Time());
+                               (*n)->WriteNumeric(601, "%s %s %s %s %lu :went offline", (*n)->nick.c_str() ,user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) ServerInstance->Time());
 
                                watchlist* wl;
                                if ((*n)->GetExt("watchlist", wl))
@@ -500,8 +487,7 @@ class Modulewatch : public Module
                {
                        for (std::deque<User*>::iterator n = x->second.begin(); n != x->second.end(); n++)
                        {
-                               if (!user->Visibility || user->Visibility->VisibleTo(*n))
-                                       (*n)->WriteNumeric(600, "%s %s %s %s %lu :arrived online", (*n)->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) user->age);
+                               (*n)->WriteNumeric(600, "%s %s %s %s %lu :arrived online", (*n)->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) user->age);
 
                                watchlist* wl;
                                if ((*n)->GetExt("watchlist", wl))
@@ -523,8 +509,7 @@ class Modulewatch : public Module
                                watchlist* wl;
                                if ((*n)->GetExt("watchlist", wl))
                                {
-                                       if (!user->Visibility || user->Visibility->VisibleTo(*n))
-                                               (*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);
+                                       (*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()] = "";
                                }
                        }
@@ -538,8 +523,7 @@ class Modulewatch : public Module
                                if ((*n)->GetExt("watchlist", wl))
                                {
                                        (*wl)[user->nick.c_str()] = std::string(user->ident).append(" ").append(user->dhost).append(" ").append(ConvToStr(user->age));
-                                       if (!user->Visibility || user->Visibility->VisibleTo(*n))
-                                               (*n)->WriteNumeric(600, "%s %s %s :arrived online", (*n)->nick.c_str(), user->nick.c_str(), (*wl)[user->nick.c_str()].c_str());
+                                       (*n)->WriteNumeric(600, "%s %s %s :arrived online", (*n)->nick.c_str(), user->nick.c_str(), (*wl)[user->nick.c_str()].c_str());
                                }
                        }
                }