summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-08-16 12:10:55 +0200
committerattilamolnar <attilamolnar@hush.com>2013-08-30 13:15:10 +0200
commitc202dea024542b9c6c6b771bb9a3a081d9eacdc5 (patch)
tree64f4d5f5c18e685d3cd360107664eec644d5585d /include
parent1031f333332cf1b09db4fd632f141143ee637c34 (diff)
Replace OnRehash() with ReadConfig() that is called on boot, on module load and on rehash
This eliminates the need for calling OnRehash() in init()
Diffstat (limited to 'include')
-rw-r--r--include/configreader.h11
-rw-r--r--include/modules.h24
-rw-r--r--include/typedefs.h1
3 files changed, 27 insertions, 9 deletions
diff --git a/include/configreader.h b/include/configreader.h
index 6786604b5..0fbf234c3 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -614,3 +614,14 @@ class CoreExport ConfigReaderThread : public Thread
void Finish();
bool IsDone() { return done; }
};
+
+class CoreExport ConfigStatus
+{
+ public:
+ User* const srcuser;
+
+ ConfigStatus(User* user = NULL)
+ : srcuser(user)
+ {
+ }
+};
diff --git a/include/modules.h b/include/modules.h
index d13ff58b0..68044ae89 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -250,7 +250,7 @@ enum Priority { PRIORITY_FIRST, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER }
enum Implementation
{
I_BEGIN,
- I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart, I_OnRehash,
+ I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart,
I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper, I_OnInfo, I_OnWhois,
I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick,
I_OnUserMessage, I_OnMode, I_OnGetServerDescription, I_OnSyncUser,
@@ -319,6 +319,13 @@ class CoreExport Module : public classbase, public usecountbase
{
}
+ /** This method is called when you should reload module specific configuration:
+ * on boot, on a /REHASH and on module load.
+ * @param status The current status, can be inspected for more information;
+ * also used for reporting configuration errors and warnings.
+ */
+ virtual void ReadConfig(ConfigStatus& status);
+
/** Returns the version number of a Module.
* The method should return a Version object with its version information assigned via
* Version::Version
@@ -409,14 +416,6 @@ class CoreExport Module : public classbase, public usecountbase
*/
virtual void OnModuleRehash(User* user, const std::string &parameter);
- /** Called on rehash.
- * This method is called after a rehash has completed. You should use it to reload any module
- * configuration from the main configuration file.
- * @param user The user that performed the rehash, if it was initiated by a user and that user
- * is still connected.
- */
- virtual void OnRehash(User* user);
-
/** Called whenever a snotice is about to be sent to a snomask.
* snomask and type may both be modified; the message may not.
* @param snomask The snomask the message is going to (e.g. 'A')
@@ -1191,7 +1190,9 @@ class CoreExport ModuleManager
/** Internal unload module hook */
bool CanUnload(Module*);
+
public:
+ typedef std::map<std::string, Module*> ModuleMap;
/** Event handler hooks.
* This needs to be public to be used by FOREACH_MOD and friends.
@@ -1353,6 +1354,11 @@ class CoreExport ModuleManager
* @return The list of module names
*/
const std::vector<std::string> GetAllModuleNames(int filter);
+
+ /** Get a map of all loaded modules keyed by their name
+ * @return A ModuleMap containing all loaded modules
+ */
+ const ModuleMap& GetModules() const { return Modules; }
};
/** Do not mess with these functions unless you know the C preprocessor
diff --git a/include/typedefs.h b/include/typedefs.h
index c38f89d4d..98ea4a0b9 100644
--- a/include/typedefs.h
+++ b/include/typedefs.h
@@ -25,6 +25,7 @@ class BanCacheManager;
class BufferedSocket;
class Channel;
class Command;
+class ConfigStatus;
class ConfigTag;
class Extensible;
class FakeUser;