summaryrefslogtreecommitdiffstats
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/ModuleManager.cpp16
-rw-r--r--src/Common/ModuleManager.h2
-rw-r--r--src/Common/UserManager.cpp81
-rw-r--r--src/Common/UserManager.h2
4 files changed, 33 insertions, 68 deletions
diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp
index be25f9e..c119eab 100644
--- a/src/Common/ModuleManager.cpp
+++ b/src/Common/ModuleManager.cpp
@@ -58,18 +58,12 @@ ModuleManager::~ModuleManager() {
}
}
-bool ModuleManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
- if(handled)
- return false;
-
- if(entry[0].getKey().matches("LoadModule") && entry[1].isEmpty()) {
- if(!loadModule(entry[0][0].toLocale()))
- application->logf(Core::Logger::LOG_ERROR, "Can't load module '%s'.", entry[0][0].toLocale().c_str());
-
- return true;
+void ModuleManager::configure() {
+ std::vector<const Core::ConfigEntry*> entries = application->getConfigManager()->getEntries("LoadModule");
+ for(std::vector<const Core::ConfigEntry*>::iterator entry = entries.begin(); entry != entries.end(); ++entry) {
+ if(!loadModule((*entry)->getValue().toLocale()))
+ application->logf(Core::Logger::LOG_ERROR, "Can't load module '%s'.", (*entry)->getValue().toLocale().c_str());
}
-
- return false;
}
bool ModuleManager::loadModule(const std::string &name) {
diff --git a/src/Common/ModuleManager.h b/src/Common/ModuleManager.h
index 1c6a195..dbb35cd 100644
--- a/src/Common/ModuleManager.h
+++ b/src/Common/ModuleManager.h
@@ -68,7 +68,7 @@ class MAD_COMMON_EXPORT ModuleManager : public Core::Configurable, private boost
void unloadModule(const std::string &name);
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
+ virtual void configure();
public:
bool loadModule(const std::string &name);
diff --git a/src/Common/UserManager.cpp b/src/Common/UserManager.cpp
index 90a0435..e71c38e 100644
--- a/src/Common/UserManager.cpp
+++ b/src/Common/UserManager.cpp
@@ -28,7 +28,7 @@
namespace Mad {
namespace Common {
-UserManager::UserManager(Application *application0) : application(application0), minUid(1000), maxUid(29999), minGid(1000), maxGid(29999) {
+UserManager::UserManager(Application *application0) : application(application0) {
application->getConfigManager()->registerConfigurable(this);
}
@@ -36,63 +36,34 @@ UserManager::~UserManager() {
application->getConfigManager()->unregisterConfigurable(this);
}
-bool UserManager::handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/) {
- if(entry[0].getKey().matches("UserManager")) {
- if(entry[1].getKey().matches("MinUid")) {
- if(entry[2].isEmpty()) {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 10);
- if(entry[1][0].isEmpty() || *endptr) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinUid '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- minUid = val;
- }
- }
- }
- else if(entry[1].getKey().matches("MaxUid")) {
- if(entry[2].isEmpty()) {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 10);
- if(entry[1][0].isEmpty() || *endptr) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxUid '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- maxUid = val;
- }
- }
- }
- else if(entry[1].getKey().matches("MinGid")) {
- if(entry[2].isEmpty()) {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 10);
- if(entry[1][0].isEmpty() || *endptr) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinGid '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- minGid = val;
- }
- }
- }
- else if(entry[1].getKey().matches("MaxGid")) {
- if(entry[2].isEmpty()) {
- char *endptr;
- unsigned long val = std::strtoul(entry[1][0].toString().c_str(), &endptr, 10);
- if(entry[1][0].isEmpty() || *endptr) {
- application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxGid '%s'", entry[1][0].toLocale().c_str());
- }
- else {
- maxGid = val;
- }
- }
- }
- else if(!entry[1].isEmpty())
- return false;
+void UserManager::configure() {
+ minUid = std::strtoul(application->getConfigManager()->get("UserManager.MinUid", "1000").toString().c_str(), 0, 10);
+ if(minUid == 0) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinUid '%s'",
+ application->getConfigManager()->get("UserManager.MinUid").toLocale().c_str());
+ minUid = 1000;
+ }
+
+ maxUid = std::strtoul(application->getConfigManager()->get("UserManager.MaxUid", "29999").toString().c_str(), 0, 10);
+ if(maxUid == 0) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxUid '%s'",
+ application->getConfigManager()->get("UserManager.MaxUid").toLocale().c_str());
+ maxUid = 29999;
+ }
- return true;
+ minGid = std::strtoul(application->getConfigManager()->get("UserManager.MinGid", "1000").toString().c_str(), 0, 10);
+ if(minGid == 0) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MinGid '%s'",
+ application->getConfigManager()->get("UserManager.MinGid").toLocale().c_str());
+ minGid = 1000;
}
- return false;
+ maxGid = std::strtoul(application->getConfigManager()->get("UserManager.MaxGid", "29999").toString().c_str(), 0, 10);
+ if(maxGid == 0) {
+ application->logf(Core::Logger::LOG_WARNING, "UserBackendHome: Invalid configuration: MaxGid '%s'",
+ application->getConfigManager()->get("UserManager.MaxGid").toLocale().c_str());
+ maxGid = 29999;
+ }
}
void UserManager::registerBackend(boost::shared_ptr<UserDBBackend> backend) {
diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h
index 0cf7fca..4319713 100644
--- a/src/Common/UserManager.h
+++ b/src/Common/UserManager.h
@@ -65,7 +65,7 @@ class MAD_COMMON_EXPORT UserManager : public Core::Configurable, private boost::
~UserManager();
protected:
- virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool /*handled*/);
+ virtual void configure();
public:
void registerBackend(boost::shared_ptr<UserDBBackend> backend);