]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Incorporating InspTimer into safelist as a test
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 23 Feb 2006 19:39:38 +0000 (19:39 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 23 Feb 2006 19:39:38 +0000 (19:39 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3301 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
include/timer.h
src/inspircd.cpp
src/modules.cpp
src/modules/m_safelist.cpp

index 8c37a8cc28ae312cf45edd810eac4874f5344d32..56bf2d18f57b25b01882cb1a63280c1f5c5582f8 100644 (file)
@@ -1390,6 +1390,10 @@ class Server : public classbase
         */
        virtual int CountUsers(chanrec* c);
 
+       /** Adds an InspTimer which will trigger at a future time
+        */
+       virtual void AddTimer(InspTimer* T);
+
        /** Attempts to look up a nick and return a pointer to it.
         * This function will return NULL if the nick does not exist.
         */
index 894a0d0e1251ba4cc69804ab866f9c50d0a5d25a..143ff4d9701d58d5b8b8f9bd3a3540a5eaa335d6 100644 (file)
@@ -12,4 +12,6 @@ class InspTimer
        virtual void Tick(time_t TIME) {}
 };
 
+void TickTimers(time_t TIME);
+void AddTimer(InspTimer* T);
 
index 2b57a2292f9a33a91b751a8f351347de851d95e7..6e8040d871ae98d74e9ddf6b409fb924c634a6b7 100644 (file)
@@ -57,6 +57,7 @@ using namespace std;
 #include "socket.h"
 #include "typedefs.h"
 #include "command_parse.h"
+#include "timer.h"
 
 InspIRCd* ServerInstance;
 
@@ -655,6 +656,11 @@ int InspIRCd::Run()
                        if (TIME < OLDTIME)
                                WriteOpers("*** \002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %d secs.",abs(OLDTIME-TIME));
                        DoBackgroundUserStuff(TIME);
+
+                       /*
+                        * Trigger all InspTimers that are pending
+                        */
+                       TickTimers(TIME);
                }
 
                /* Process timeouts on module sockets each time around
index 6f1236f605a00765d1d18898b39aa9dd64b0c5c3..7640f0edc2c7dcb7db624b6baf1701242b3723bc 100644 (file)
@@ -50,6 +50,7 @@ using namespace std;
 #include "typedefs.h"
 #include "modules.h"
 #include "command_parse.h"
+#include "timer.h"
 
 extern ServerConfig *Config;
 extern InspIRCd* ServerInstance;
@@ -414,6 +415,11 @@ chanrec* Server::GetChannelIndex(long index)
        return NULL;
 }
 
+void Server::AddTimer(InspTimer* T)
+{
+       AddTimer(T);
+}
+
 void Server::SendOpers(std::string s)
 {
        WriteOpers("%s",s.c_str());
index 641fd7559a5d04fcd693dbedf6dbd07e26e7f6f1..52e5e36a0c6455ec55e142a4d47e3f95309c9660 100644 (file)
@@ -40,15 +40,36 @@ class ListData
  
 typedef std::vector<userrec *> UserList;
 
+class ListTimer : public InspTimer
+{
+ private:
+       Server* Srv;
+ public:
+       ListTimer(long interval, Server* Me) : InspTimer(interval), Server(Me)
+       {
+       }
+
+       Tick(time_t TIME)
+       {
+               log(DEBUG,"*** Timer tick!");
+               MyTimer = new ListTimer(1);
+               Srv->AddTimer(MyTimer);
+       }
+};
+
 class ModuleSafeList : public Module
 {
  private:
         Server *Srv;
+        ListTimer* MyTimer;
         UserList listusers;    /* vector of people doing a /list */
  public:
        ModuleSafeList(Server* Me) : Module::Module(Me)
        {
                Srv = Me;
+
+               MyTimer = new ListTimer(1);
+               Srv->AddTimer(MyTimer,Me);
        }
  
        virtual ~ModuleSafeList()