114 lines
3.1 KiB
C++
114 lines
3.1 KiB
C++
|
|
||
|
#include "nel/misc/types_nl.h"
|
||
|
#include "nel/net/module.h"
|
||
|
#include "nel/net/module_builder_parts.h"
|
||
|
|
||
|
#include "../server_share/backup_service_itf.h"
|
||
|
|
||
|
#include "backup_service.h"
|
||
|
|
||
|
|
||
|
using namespace std;
|
||
|
using namespace NLMISC;
|
||
|
using namespace NLNET;
|
||
|
|
||
|
|
||
|
namespace BS
|
||
|
{
|
||
|
|
||
|
|
||
|
class CBackupServiceMod:
|
||
|
public CEmptyModuleServiceBehav<CEmptyModuleCommBehav<CEmptySocketBehav<CModuleBase> > >,
|
||
|
public CBackupServiceSkel
|
||
|
{
|
||
|
public:
|
||
|
|
||
|
CBackupServiceMod()
|
||
|
{
|
||
|
CBackupServiceSkel::init(this);
|
||
|
}
|
||
|
|
||
|
// static const std::string &getInitStringHelp()
|
||
|
// {
|
||
|
// static string help("ring_db(host=<mysql_hostname> user=<user> password=<password> base=<database_name>)");
|
||
|
// return help;
|
||
|
// }
|
||
|
//
|
||
|
// bool initModule(const TParsedCommandLine &initInfo)
|
||
|
// {
|
||
|
// return CModuleBase::initModule(initInfo);
|
||
|
//
|
||
|
// }
|
||
|
|
||
|
void onModuleDown(IModuleProxy *proxy)
|
||
|
{
|
||
|
// we must check that this module is not in the listener list
|
||
|
CBackupService::getInstance()->onModuleDown(proxy);
|
||
|
}
|
||
|
|
||
|
// bool onProcessModuleMessage(IModuleProxy *sender, const CMessage &message)
|
||
|
// {
|
||
|
// if (CBackupServiceSkel::onDispatchMessage(sender, message))
|
||
|
// return true;
|
||
|
//
|
||
|
// nlwarning("CBackupServiceMod: Unknown message '%s' received", message.getName().c_str());
|
||
|
//
|
||
|
// return false;
|
||
|
// }
|
||
|
|
||
|
|
||
|
/////////////////////////////////////////////////////////////
|
||
|
//// CBackupServiceSkel interface impl
|
||
|
/////////////////////////////////////////////////////////////
|
||
|
|
||
|
// A module ask to save a file in the backup repository
|
||
|
void saveFile(NLNET::IModuleProxy *sender, const std::string &fileName, const NLNET::TBinBuffer &data)
|
||
|
{
|
||
|
CWriteFile* access = new CWriteFile(fileName, TRequester(sender), 0, data.getBuffer(), data.getBufferSize());
|
||
|
|
||
|
access->FailureMode = CWriteFile::MajorFailureIfFileUnwritable | CWriteFile::MajorFailureIfFileUnbackupable;
|
||
|
access->BackupFile = true;
|
||
|
access->Append = false;
|
||
|
|
||
|
CBackupService::getInstance()->FileManager.stackFileAccess(access);
|
||
|
|
||
|
}
|
||
|
|
||
|
// A module ask to load a file
|
||
|
void loadFile(NLNET::IModuleProxy *sender, const std::string &fileName, uint32 requestId)
|
||
|
{
|
||
|
CLoadFile* access = new CLoadFile(fileName, TRequester(sender), requestId);
|
||
|
|
||
|
CBackupService::getInstance()->FileManager.stackFileAccess(access);
|
||
|
}
|
||
|
|
||
|
|
||
|
/////////////////////////////////////////////////////////////
|
||
|
//// commands
|
||
|
/////////////////////////////////////////////////////////////
|
||
|
|
||
|
NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CBackupServiceMod, CModuleBase)
|
||
|
NLMISC_COMMAND_HANDLER_ADD(CBackupServiceMod, dump, "dump the module internal state", "no param");
|
||
|
// NLMISC_COMMAND_HANDLER_ADD(CMailForumNotifierFwd, simMailNotify, "Simulate a mail notification", "<charId>");
|
||
|
NLMISC_COMMAND_HANDLER_TABLE_END
|
||
|
|
||
|
NLMISC_CLASS_COMMAND_DECL(dump)
|
||
|
{
|
||
|
// call the base class dump
|
||
|
NLMISC_CLASS_COMMAND_CALL_BASE(CModuleBase, dump);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
NLNET_REGISTER_MODULE_FACTORY(CBackupServiceMod, "BackupServiceMod");
|
||
|
|
||
|
|
||
|
|
||
|
} // namespace RSMGR
|
||
|
|
||
|
// force module linking
|
||
|
void forceBackupServiceModLink()
|
||
|
{
|
||
|
}
|