]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules.h
Tidying, strlen, strcasecmp where not needed.
[user/henk/code/inspircd.git] / include / modules.h
index 07da2989f0772b01c6cd1d58a6cd93a6e16318e2..4dff5d48a566c218e040ba5af7bea536a50f2e37 100644 (file)
@@ -72,6 +72,7 @@ enum TargetTypeFlags {
 #include <deque>
 #include <sstream>
 #include <typeinfo>
+#include "timer.h"
 
 class Server;
 class ServerConfig;
@@ -287,14 +288,35 @@ class ExtMode : public classbase
 };
 
 
+/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
+ * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
+ * a class derived from ModuleException. If a module throws an exception during its constructor, the module will not
+ * be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
+ * attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
+ */
 class ModuleException
 {
+ private:
+       /** Holds the error message to be displayed
+        */
+       std::string err;
  public:
-       ModuleException() {};
+       /** Default constructor, just uses the error mesage 'Module threw an exception'.
+        */
+       ModuleException() : err("Module threw an exception") {}
+       /** This constructor can be used to specify an error message before throwing.
+        */
+       ModuleException(std::string message) : err(message) {}
+       /** This destructor solves world hunger, cancels the world debt, and causes the world to end.
+        * Actually no, it does nothing. Never mind.
+        */
        virtual ~ModuleException() {};
+       /** Returns the reason for the exception.
+        * The module should probably put something informative here as the user will see this upon failure.
+        */
        virtual char *GetReason()
        {
-               return "Module threw an exception";
+               return (char*)err.c_str();
        }
 };
 
@@ -329,6 +351,7 @@ class Module : public classbase
        /** Default constructor
         * Creates a module class.
         * @param Me An instance of the Server class which can be saved for future use
+        * \exception ModuleException Throwing this class, or any class derived from ModuleException, causes loading of the module to abort.
         */
        Module(Server* Me);
 
@@ -1368,6 +1391,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.
         */
@@ -1570,8 +1597,9 @@ class Server : public classbase
         * in the array. If you do not pass enough parameters to meet the minimum needed by the handler, the
         * functiom will silently ignore it. The final parameter is the user executing the command handler,
         * used for privilage checks, etc.
+        * @return True if the command exists
         */
-       virtual void CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user);
+       virtual bool CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user);
 
        /** This function returns true if the commandname exists, pcnt is equal to or greater than the number
         * of paramters the command requires, the user specified is allowed to execute the command, AND
@@ -1717,6 +1745,10 @@ class Server : public classbase
        virtual void DelSocket(InspSocket* sock);
 
        virtual void RehashServer();
+
+       virtual long GetChannelCount();
+
+       virtual chanrec* GetChannelIndex(long index);
 };