mirror of
https://github.com/anope/anope.git
synced 2026-07-04 14:53:12 +02:00
Move last of events that are in the core distro over to newevents.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2115 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
@@ -15,8 +15,6 @@
|
||||
#define EVENT_START "start"
|
||||
//#define EVENT_STOP "stop"
|
||||
|
||||
#define EVENT_DB_BACKUP "db_backup"
|
||||
#define EVENT_NEWNICK "newnick"
|
||||
#define EVENT_BOT_JOIN "bot_join"
|
||||
#define EVENT_BOT_CREATE "bot_create"
|
||||
#define EVENT_BOT_CHANGE "bot_change"
|
||||
|
||||
+6
-1
@@ -522,6 +522,11 @@ class CoreExport Module
|
||||
* XXX.
|
||||
*/
|
||||
virtual void OnSaveDatabase() MARK_DEPRECATED { }
|
||||
|
||||
/** Called when anope backs up databases.
|
||||
* NOTE: This event is deprecated pending new database handling.
|
||||
*/
|
||||
virtual void OnBackupDatabase() MARK_DEPRECATED { }
|
||||
};
|
||||
|
||||
|
||||
@@ -530,7 +535,7 @@ class CoreExport Module
|
||||
enum Implementation
|
||||
{
|
||||
I_BEGIN,
|
||||
I_OnUserKicked, I_OnReload, I_OnBotAssign, I_OnBotUnAssign, I_OnSaveDatabase, I_OnUserConnect,
|
||||
I_OnUserKicked, I_OnReload, I_OnBotAssign, I_OnBotUnAssign, I_OnSaveDatabase, I_OnUserConnect, I_OnBackupDatabase,
|
||||
I_END
|
||||
};
|
||||
|
||||
|
||||
+3
-2
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "services.h"
|
||||
#include "datafiles.h"
|
||||
#include "modules.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
static int curday = 0;
|
||||
@@ -671,8 +672,9 @@ void backup_databases()
|
||||
|
||||
char ext[9];
|
||||
|
||||
send_event(EVENT_DB_BACKUP, 1, EVENT_START);
|
||||
|
||||
alog("Backing up databases");
|
||||
FOREACH_MOD(I_OnBackupDatabase, OnBackupDatabase())
|
||||
|
||||
remove_backups();
|
||||
|
||||
@@ -694,7 +696,6 @@ void backup_databases()
|
||||
rename_database(OperDBName, ext);
|
||||
rename_database(NewsDBName, ext);
|
||||
rename_database(ExceptionDBName, ext);
|
||||
send_event(EVENT_DB_BACKUP, 1, "stop");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ void my_memo_lang(User *u, char *name, int z, int number, ...);
|
||||
void req_send_memos(User *u, char *vHost);
|
||||
|
||||
void hsreq_load_db();
|
||||
int hsreqevt_db_backup(int argc, char **argv);
|
||||
|
||||
void my_load_config();
|
||||
void my_add_languages();
|
||||
@@ -441,8 +440,6 @@ class HSRequest : public Module
|
||||
public:
|
||||
HSRequest(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
EvtHook *hook;
|
||||
|
||||
me = this;
|
||||
|
||||
this->AddCommand(HOSTSERV, new CommandHSRequest(), MOD_HEAD);
|
||||
@@ -454,9 +451,7 @@ class HSRequest : public Module
|
||||
this->AddCommand(NICKSERV, new CommandNSDrop(), MOD_HEAD);
|
||||
|
||||
ModuleManager::Attach(I_OnSaveDatabase, this);
|
||||
|
||||
hook = createEventHook(EVENT_DB_BACKUP, hsreqevt_db_backup);
|
||||
this->AddEventHook(hook);
|
||||
ModuleManager::Attach(I_OnBackupDatabase, this);
|
||||
|
||||
this->SetHostHelp(hs_help);
|
||||
this->SetAuthor(AUTHOR);
|
||||
@@ -768,6 +763,14 @@ class HSRequest : public Module
|
||||
if (debug)
|
||||
alog("[hs_request] Succesfully saved database");
|
||||
}
|
||||
|
||||
void OnBackupDatabase()
|
||||
{
|
||||
if (HSRequestDBName)
|
||||
ModuleDatabaseBackup(HSRequestDBName);
|
||||
else
|
||||
ModuleDatabaseBackup(HSREQ_DEFAULT_DBNAME);
|
||||
}
|
||||
};
|
||||
|
||||
void my_memo_lang(User *u, char *name, int z, int number, ...)
|
||||
@@ -936,19 +939,6 @@ void hsreq_load_db()
|
||||
alog("[hs_request] Succesfully loaded database");
|
||||
}
|
||||
|
||||
int hsreqevt_db_backup(int argc, char **argv)
|
||||
{
|
||||
if (argc >= 1 && !stricmp(argv[0], EVENT_START))
|
||||
{
|
||||
if (HSRequestDBName)
|
||||
ModuleDatabaseBackup(HSRequestDBName);
|
||||
else
|
||||
ModuleDatabaseBackup(HSREQ_DEFAULT_DBNAME);
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
void my_load_config()
|
||||
{
|
||||
ConfigReader config;
|
||||
|
||||
@@ -67,7 +67,6 @@ int new_write_db_entry(const char *key, DBFile *dbptr, const char *fmt, ...);
|
||||
int new_write_db_endofblock(DBFile *dbptr);
|
||||
void fill_db_ptr(DBFile *dbptr, int version, int core_version, char service[256], char filename[256]);
|
||||
|
||||
int backup_ignoredb(int argc, char **argv);
|
||||
void load_ignore_db();
|
||||
void load_config();
|
||||
|
||||
@@ -78,7 +77,6 @@ class OSIgnoreDB : public Module
|
||||
public:
|
||||
OSIgnoreDB(const std::string &modname, const std::string &creator) : Module(modname, creator)
|
||||
{
|
||||
EvtHook *hook;
|
||||
IgnoreDB = NULL;
|
||||
|
||||
this->SetAuthor(AUTHOR);
|
||||
@@ -86,10 +84,7 @@ class OSIgnoreDB : public Module
|
||||
this->SetType(SUPPORTED);
|
||||
|
||||
ModuleManager::Attach(I_OnSaveDatabase, this);
|
||||
|
||||
hook = createEventHook(EVENT_DB_BACKUP, backup_ignoredb);
|
||||
if (this->AddEventHook(hook) != MOD_ERR_OK)
|
||||
throw ModuleException("os_ignore_db: Can't hook to EVENT_DB_BACKUP event");
|
||||
ModuleManager::Attach(I_OnBackupDatabase, this);
|
||||
|
||||
load_config();
|
||||
/* Load the ignore database and re-add them to anopes ignorelist. */
|
||||
@@ -165,12 +160,15 @@ class OSIgnoreDB : public Module
|
||||
}
|
||||
}
|
||||
|
||||
void OnBackupDatabase()
|
||||
{
|
||||
ModuleDatabaseBackup(IgnoreDB);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
|
||||
void load_config() {
|
||||
@@ -185,18 +183,6 @@ void load_config() {
|
||||
alog("[os_ignore_db] debug: Set config vars: OSIgnoreDBName='%s'", IgnoreDB);
|
||||
}
|
||||
|
||||
/**
|
||||
* When anope backs her databases up, we do the same.
|
||||
**/
|
||||
int backup_ignoredb(int argc, char **argv) {
|
||||
if ((argc >= 1) && (!stricmp(argv[0], "stop"))) {
|
||||
if (debug)
|
||||
alog("[os_ignore_db] debug: Backing up %s database...", IgnoreDB);
|
||||
ModuleDatabaseBackup(IgnoreDB);
|
||||
}
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
|
||||
/**************************************************************************
|
||||
|
||||
+6
-15
@@ -46,7 +46,6 @@ void mMainChanHelp(User *u);
|
||||
void mMainNickHelp(User *u);
|
||||
|
||||
int mLoadData();
|
||||
int mBackupData(int argc, char **argv);
|
||||
int mLoadConfig();
|
||||
|
||||
static Module *me;
|
||||
@@ -304,9 +303,7 @@ class OSInfo : public Module
|
||||
status = this->AddCommand(CHANSERV, new CommandCSInfo(), MOD_TAIL);
|
||||
|
||||
ModuleManager::Attach(I_OnSaveDatabase, this);
|
||||
|
||||
hook = createEventHook(EVENT_DB_BACKUP, mBackupData);
|
||||
status = this->AddEventHook(hook);
|
||||
ModuleManager::Attach(I_OnBackupDatabase, this);
|
||||
|
||||
this->SetNickHelp(mMainNickHelp);
|
||||
this->SetChanHelp(mMainChanHelp);
|
||||
@@ -601,6 +598,11 @@ class OSInfo : public Module
|
||||
}
|
||||
}
|
||||
|
||||
void OnBackupDatabase()
|
||||
{
|
||||
ModuleDatabaseBackup(OSInfoDBName);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
@@ -666,17 +668,6 @@ int mLoadData()
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup our databases using the commands provided by Anope
|
||||
* @return MOD_CONT
|
||||
**/
|
||||
int mBackupData(int argc, char **argv)
|
||||
{
|
||||
ModuleDatabaseBackup(OSInfoDBName);
|
||||
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration directives from Services configuration file.
|
||||
* @return 0 for success
|
||||
|
||||
Reference in New Issue
Block a user