From 71dc41a9b7b0e939314a886383daa6fb2e297a55 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 25 Apr 2009 16:27:03 +0200 Subject: SystemBackend und UserBackend in Backend und Manager aufgeteilt --- src/modules/SystemBackendPosix.cpp | 8 ++++---- src/modules/SystemBackendPosix.h | 12 ++++++------ src/modules/SystemBackendProc.cpp | 6 +++--- src/modules/SystemBackendProc.h | 10 +++++----- src/modules/UserBackendMysql.cpp | 13 +++++-------- src/modules/UserBackendMysql.h | 7 +++---- 6 files changed, 26 insertions(+), 30 deletions(-) (limited to 'src/modules') diff --git a/src/modules/SystemBackendPosix.cpp b/src/modules/SystemBackendPosix.cpp index c8135a3..21e5c75 100644 --- a/src/modules/SystemBackendPosix.cpp +++ b/src/modules/SystemBackendPosix.cpp @@ -70,8 +70,8 @@ SystemBackendPosix::~SystemBackendPosix() { } -void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback) { - std::vector ret; +void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback) { + std::vector ret; std::istringstream stream(output); std::string str; @@ -83,7 +83,7 @@ void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const si char *fsName = new char[str.length()+1]; char *mountedOn = new char[str.length()+1]; - FSInfo info; + Common::SystemManager::FSInfo info; if(std::sscanf(str.c_str(), "%s %lld %lld %lld %*d%% %s", fsName, &info.total, &info.used, &info.available, mountedOn) == 5) { info.fsName = fsName; @@ -99,7 +99,7 @@ void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const si callback(ret); } -bool SystemBackendPosix::fsInfo(const sigc::slot& > &callback) { +bool SystemBackendPosix::getFSInfo(const sigc::slot& > &callback) { std::vector argv; argv.push_back("/bin/df"); diff --git a/src/modules/SystemBackendPosix.h b/src/modules/SystemBackendPosix.h index a307f22..b12af6b 100644 --- a/src/modules/SystemBackendPosix.h +++ b/src/modules/SystemBackendPosix.h @@ -55,13 +55,13 @@ class SystemBackendPosix : private Common::SystemBackend { setChildHandler(); } - void fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback); + void fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback); protected: - virtual bool fsInfo(const sigc::slot& > &callback); + virtual bool getFSInfo(const sigc::slot& > &callback); - virtual bool doShutdown(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/halt");} - virtual bool doReboot(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/reboot");} + virtual bool shutdown(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/halt");} + virtual bool reboot(const sigc::slot &callback) {return exec(sigc::hide(callback), "/sbin/reboot");} public: ~SystemBackendPosix(); @@ -71,14 +71,14 @@ class SystemBackendPosix : private Common::SystemBackend { return; backend = new SystemBackendPosix(); - SystemBackend::registerBackend(backend); + Common::SystemManager::get()->registerBackend(backend); } static void unregisterBackend() { if(!backend) return; - SystemBackend::unregisterBackend(backend); + Common::SystemManager::get()->unregisterBackend(backend); delete backend; backend = 0; } diff --git a/src/modules/SystemBackendProc.cpp b/src/modules/SystemBackendProc.cpp index 3a0d33d..501f779 100644 --- a/src/modules/SystemBackendProc.cpp +++ b/src/modules/SystemBackendProc.cpp @@ -34,7 +34,7 @@ namespace Modules { SystemBackendProc *SystemBackendProc::backend = 0; -bool SystemBackendProc::uptimeInfo(const sigc::slot &callback) { +bool SystemBackendProc::getUptimeInfo(const sigc::slot &callback) { unsigned long uptime = 0, idleTime = 0; uptimeFile.seekg(0, std::ios::beg); @@ -58,7 +58,7 @@ bool SystemBackendProc::uptimeInfo(const sigc::slot &callback) { +bool SystemBackendProc::getMemoryInfo(const sigc::slot &callback) { unsigned long totalMem = 0, freeMem = 0, totalSwap = 0, freeSwap = 0; meminfoFile.seekg(0, std::ios::beg); @@ -95,7 +95,7 @@ bool SystemBackendProc::memoryInfo(const sigc::slot &callback) { +bool SystemBackendProc::getLoadInfo(const sigc::slot &callback) { unsigned long currentLoad = 0, nProcesses = 0; float loadAvg1 = 0, loadAvg5 = 0, loadAvg15 = 0; diff --git a/src/modules/SystemBackendProc.h b/src/modules/SystemBackendProc.h index bd4767d..7174551 100644 --- a/src/modules/SystemBackendProc.h +++ b/src/modules/SystemBackendProc.h @@ -38,9 +38,9 @@ class SystemBackendProc : private Common::SystemBackend { SystemBackendProc() : uptimeFile("/proc/uptime"), meminfoFile("/proc/meminfo"), loadFile("/proc/loadavg") {} protected: - virtual bool uptimeInfo(const sigc::slot &callback); - virtual bool memoryInfo(const sigc::slot &callback); - virtual bool loadInfo(const sigc::slot &callback); + virtual bool getUptimeInfo(const sigc::slot &callback); + virtual bool getMemoryInfo(const sigc::slot &callback); + virtual bool getLoadInfo(const sigc::slot &callback); public: static void registerBackend() { @@ -48,14 +48,14 @@ class SystemBackendProc : private Common::SystemBackend { return; backend = new SystemBackendProc(); - SystemBackend::registerBackend(backend); + Common::SystemManager::get()->registerBackend(backend); } static void unregisterBackend() { if(!backend) return; - SystemBackend::unregisterBackend(backend); + Common::SystemManager::get()->unregisterBackend(backend); delete backend; backend = 0; } diff --git a/src/modules/UserBackendMysql.cpp b/src/modules/UserBackendMysql.cpp index db3c32b..39b0652 100644 --- a/src/modules/UserBackendMysql.cpp +++ b/src/modules/UserBackendMysql.cpp @@ -22,6 +22,7 @@ #include "UserBackendMysql.h" #include #include +#include #include #include @@ -130,11 +131,11 @@ void UserBackendMysql::configFinished() { mysql = mysql_init(0); mysql_real_connect(mysql, host.c_str(), username.c_str(), passwd.c_str(), db.c_str(), port, unixSocket.empty() ? 0 : unixSocket.c_str(), 0); - UserBackend::registerBackend(backend); + Core::UserManager::get()->registerBackend(backend); } -bool UserBackendMysql::userList(const sigc::slot& > &callback) { +bool UserBackendMysql::getUserList(const sigc::slot& > &callback) { mysql_ping(mysql); mysql_real_query(mysql, queryListUsers.c_str(), queryListUsers.length()); @@ -159,7 +160,7 @@ bool UserBackendMysql::userList(const sigc::slot &callback) { +bool UserBackendMysql::getUserInfo(unsigned long uid, const sigc::slot &callback) { mysql_ping(mysql); std::string query = queryUserById; @@ -196,10 +197,6 @@ bool UserBackendMysql::userInfo(unsigned long uid, const sigc::slot &callback _UNUSED_PARAMETER_) { - return false; -} - void UserBackendMysql::registerBackend() { if(backend) @@ -214,7 +211,7 @@ void UserBackendMysql::unregisterBackend() { return; Common::ConfigManager::get()->unregisterConfigurable(backend); - UserBackend::unregisterBackend(backend); + Core::UserManager::get()->unregisterBackend(backend); delete backend; backend = 0; diff --git a/src/modules/UserBackendMysql.h b/src/modules/UserBackendMysql.h index 60b2bd9..ac82d67 100644 --- a/src/modules/UserBackendMysql.h +++ b/src/modules/UserBackendMysql.h @@ -21,8 +21,8 @@ #define MAD_MODULES_USERBACKENDMYSQL_H_ #include +#include #include -#include #include @@ -50,9 +50,8 @@ class UserBackendMysql : private Core::UserBackend, private Common::Configurable virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool); virtual void configFinished(); - virtual bool userList(const sigc::slot& > &callback); - virtual bool userInfo(unsigned long uid, const sigc::slot &callback); - virtual bool password(unsigned long uid, const std::string &password, const sigc::slot &callback); + virtual bool getUserList(const sigc::slot& > &callback); + virtual bool getUserInfo(unsigned long uid, const sigc::slot &callback); public: virtual ~UserBackendMysql() { -- cgit v1.2.3