diff options
author | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-16 23:48:03 +0000 |
---|---|---|
committer | rburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-02-16 23:48:03 +0000 |
commit | d07de70fc3156e143beeb04c0e2bbfb592415ead (patch) | |
tree | c6f246b68054048f12bf9527c9179014eb544102 | |
parent | c1c9e17d7995f7e6684316f6dc71d1b43788533f (diff) |
Move EVENT_RELOAD to OnReload.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2103 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r-- | include/events.h | 1 | ||||
-rw-r--r-- | include/modules.h | 7 | ||||
-rw-r--r-- | src/core/os_news.c | 22 | ||||
-rw-r--r-- | src/core/os_reload.c | 3 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/modules/ns_maxemail.c | 18 | ||||
-rw-r--r-- | src/modules/os_ignore_db.c | 21 | ||||
-rw-r--r-- | src/modules/os_info.c | 34 |
8 files changed, 33 insertions, 75 deletions
diff --git a/include/events.h b/include/events.h index f642a8ee5..b9d0c8d63 100644 --- a/include/events.h +++ b/include/events.h @@ -38,7 +38,6 @@ #define EVENT_CONNECT "connect" #define EVENT_DB_EXPIRE "db_expire" #define EVENT_RESTART "restart" -#define EVENT_RELOAD "reload" #define EVENT_SHUTDOWN "shutdown" #define EVENT_SIGNAL "signal" #define EVENT_NICK_REGISTERED "nick_registered" diff --git a/include/modules.h b/include/modules.h index 0ec78cb47..cdd76301b 100644 --- a/include/modules.h +++ b/include/modules.h @@ -104,7 +104,7 @@ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFOR enum Implementation { I_BEGIN, - I_OnUserKicked, + I_OnUserKicked, I_OnReload, I_END }; @@ -490,6 +490,11 @@ class CoreExport Module * NOTE: We may want to add a second User arg for sender in the future. */ virtual void OnUserKicked(Channel *c, User *target, const std::string &kickmsg) { } + + /** Called when Services' configuration has been loaded. + * @param startup True if Services is starting for the first time, false otherwise. + */ + virtual void OnReload(bool startup) {} }; diff --git a/src/core/os_news.c b/src/core/os_news.c index cc32f8604..e17022e40 100644 --- a/src/core/os_news.c +++ b/src/core/os_news.c @@ -34,7 +34,6 @@ void myOperServHelp(User *u); -int reload_config(int argc, char **argv); struct newsmsgs { int16 type; @@ -381,10 +380,12 @@ class OSNews : public Module this->AddCommand(OPERSERV, new CommandOSRandomNews(), MOD_UNIQUE); this->SetOperHelp(myOperServHelp); + } - EvtHook *hook = createEventHook(EVENT_RELOAD, reload_config); - if (this->AddEventHook(hook) != MOD_ERR_OK) - throw ModuleException("os_news: Can't hook to EVENT_RELOAD event"); + void reload_config(bool starting) + { + OSLogonNews->UpdateHelpParam(); + OSOperNews->UpdateHelpParam(); } }; @@ -403,18 +404,5 @@ void myOperServHelp(User *u) } } -/** - * Upon /os reload refresh the count - **/ -int reload_config(int argc, char **argv) -{ - if (argc >= 1 && !stricmp(argv[0], EVENT_START)) - { - OSLogonNews->UpdateHelpParam(); - OSOperNews->UpdateHelpParam(); - } - - return MOD_CONT; -} MODULE_INIT("os_news", OSNews) diff --git a/src/core/os_reload.c b/src/core/os_reload.c index 400b61f3e..c7f651825 100644 --- a/src/core/os_reload.c +++ b/src/core/os_reload.c @@ -35,7 +35,8 @@ class CommandOSReload : public Command sprintf(const_cast<char *>(quitmsg), /* XXX */ "Error during the reload of the configuration file!"); quitting = 1; } - send_event(EVENT_RELOAD, 1, EVENT_START); + + FOREACH_MOD(I_OnReload, OnReload(false)); notice_lang(s_OperServ, u, OPER_RELOAD); return MOD_CONT; } diff --git a/src/main.c b/src/main.c index 9caa6b650..3968c4014 100644 --- a/src/main.c +++ b/src/main.c @@ -260,7 +260,7 @@ void sighandler(int signum) quitting = 1; } - send_event(EVENT_RELOAD, 1, EVENT_START); + FOREACH_MOD(I_OnReload, OnReload(true)); return; } else diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c index 38215dd60..5a6e4ff7e 100644 --- a/src/modules/ns_maxemail.c +++ b/src/modules/ns_maxemail.c @@ -20,7 +20,6 @@ void my_load_config(); void my_add_languages(); -int my_event_reload(int argc, char **argv); CommandReturn check_email_limit_reached(const char *email, User * u); int NSEmailMax = 0; @@ -90,10 +89,6 @@ class NSMaxEmail : public Module this->AddCommand(NICKSERV, new CommandNSRegister(), MOD_HEAD); this->AddCommand(NICKSERV, new CommandNSSet(), MOD_HEAD); - evt = createEventHook(EVENT_RELOAD, my_event_reload); - if ((status = this->AddEventHook(evt))) - throw ModuleException("ns_maxemail: Unable to hook to EVENT_RELOAD"); - my_load_config(); const char *langtable_en_us[] = { @@ -145,6 +140,11 @@ class NSMaxEmail : public Module this->InsertLanguage(LANG_RU, LNG_NUM_STRINGS, langtable_ru); this->InsertLanguage(LANG_IT, LNG_NUM_STRINGS, langtable_it); } + + void OnReload(bool started) + { + my_load_config(); + } }; @@ -185,14 +185,6 @@ CommandReturn check_email_limit_reached(const char *email, User * u) return MOD_STOP; } -int my_event_reload(int argc, char **argv) -{ - if (argc > 0 && !stricmp(argv[0], EVENT_START)) - my_load_config(); - - return MOD_CONT; -} - void my_load_config() { ConfigReader config; diff --git a/src/modules/os_ignore_db.c b/src/modules/os_ignore_db.c index 45a99a665..2497f3b94 100644 --- a/src/modules/os_ignore_db.c +++ b/src/modules/os_ignore_db.c @@ -72,7 +72,6 @@ int backup_ignoredb(int argc, char **argv); void load_ignore_db(); void save_ignore_db(); void load_config(); -int reload_config(int argc, char **argv); /* ------------------------------------------------------------------------------- */ @@ -88,10 +87,6 @@ class OSIgnoreDB : public Module this->SetVersion(VERSION); this->SetType(SUPPORTED); - hook = createEventHook(EVENT_RELOAD, reload_config); - if (this->AddEventHook(hook) != MOD_ERR_OK) - throw ModuleException("os_ignore_db: Can't hook to EVENT_RELOAD event"); - hook = createEventHook(EVENT_DB_SAVING, save_ignoredb); if (this->AddEventHook(hook) != MOD_ERR_OK) throw ModuleException("os_ignore_db: Can't hook to EVENT_DB_SAVING event"); @@ -113,6 +108,11 @@ class OSIgnoreDB : public Module if (IgnoreDB) delete [] IgnoreDB; } + + void OnReload(bool starting) + { + load_config(); + } }; @@ -132,17 +132,6 @@ void load_config() { alog("[os_ignore_db] debug: Set config vars: OSIgnoreDBName='%s'", IgnoreDB); } -/** - * Upon /os reload call the routines for reloading the configuration directives - **/ -int reload_config(int argc, char **argv) { - if (argc >= 1) { - if (!stricmp(argv[0], EVENT_START)) { - load_config(); - } - } - return MOD_CONT; -} /** * When anope saves her databases, we do the same. diff --git a/src/modules/os_info.c b/src/modules/os_info.c index 0c5e040b6..f6e0d3318 100644 --- a/src/modules/os_info.c +++ b/src/modules/os_info.c @@ -49,7 +49,6 @@ int mLoadData(); int mSaveData(int argc, char **argv); int mBackupData(int argc, char **argv); int mLoadConfig(); -int mEventReload(int argc, char **argv); static Module *me; @@ -311,9 +310,6 @@ class OSInfo : public Module hook = createEventHook(EVENT_DB_BACKUP, mBackupData); status = this->AddEventHook(hook); - hook = createEventHook(EVENT_RELOAD, mEventReload); - status = this->AddEventHook(hook); - this->SetNickHelp(mMainNickHelp); this->SetChanHelp(mMainChanHelp); @@ -557,6 +553,15 @@ class OSInfo : public Module if (OSInfoDBName) delete [] OSInfoDBName; } + + void OnReload(bool starting) + { + alog("os_info: Reloading configuration directives..."); + int ret = mLoadConfig(); + + if (ret) + alog("os_info.c: ERROR: An error has occured while reloading the configuration file"); + } }; /*************************************************************************/ @@ -710,27 +715,6 @@ int mLoadConfig() return 0; } -/** - * Manage the RELOAD EVENT - * @return MOD_CONT - **/ -int mEventReload(int argc, char **argv) -{ - int ret = 0; - if (argc >= 1) - { - if (!stricmp(argv[0], EVENT_START)) - { - alog("os_info: Reloading configuration directives..."); - ret = mLoadConfig(); - } - } - - if (ret) - alog("os_info.c: ERROR: An error has occured while reloading the configuration file"); - - return MOD_CONT; -} /*************************************************************************/ |