summaryrefslogtreecommitdiffstats
path: root/src/Core
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-10-21 18:35:42 +0200
committerMatthias Schiffer <matthias@gamezock.de>2008-10-21 18:35:42 +0200
commit6bd58c61a1668d336f45443c602e850e965ad368 (patch)
treed48420599501a223eb3018dd998c886b49bbab96 /src/Core
parente3d0c98e5a867518800bc79c18f7b13755c056e0 (diff)
downloadmad-6bd58c61a1668d336f45443c602e850e965ad368.tar
mad-6bd58c61a1668d336f45443c602e850e965ad368.zip
Interface des ConfigManagers vereinfacht
Diffstat (limited to 'src/Core')
-rw-r--r--src/Core/ConnectionManager.cpp74
-rw-r--r--src/Core/ConnectionManager.h2
2 files changed, 31 insertions, 45 deletions
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index b99296e..ff44da3 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -18,11 +18,11 @@
*/
#include "ConnectionManager.h"
+#include <Common/ConfigEntry.h>
#include <Common/ConfigManager.h>
#include <Common/Logger.h>
#include <Common/RequestHandlers/FSInfoRequestHandler.h>
#include <Common/RequestHandlers/StatusRequestHandler.h>
-#include <Common/Util.h>
#include "Requests/DaemonStateUpdateRequest.h"
#include "RequestHandlers/DaemonCommandRequestHandler.h"
#include "RequestHandlers/DaemonFSInfoRequestHandler.h"
@@ -55,66 +55,52 @@ void ConnectionManager::updateState(const std::string &name, Common::HostInfo::S
}
}
-bool ConnectionManager::handleConfigEntry(const std::vector<std::vector<std::string> > &entry, bool handled) {
+bool ConnectionManager::handleConfigEntry(const Common::ConfigEntry &entry, bool handled) {
if(handled)
return false;
- if(Common::Util::tolower(entry.front().front()) == "listen" && entry.size() == 1) {
- if(entry.front().size() == 2) {
- try {
- listenerAddresses.push_back(Net::IPAddress(entry.front().back()));
- }
- catch(Common::Exception &e) {
- // TODO Log error
- }
-
- return true;
+ if(entry[0].getKey().matches("Listen") && entry[1].empty()) {
+ try {
+ listenerAddresses.push_back(Net::IPAddress(entry[0][0]));
+ }
+ catch(Common::Exception &e) {
+ // TODO Log error
}
+
+ return true;
}
- else if(Common::Util::tolower(entry.front().front()) == "x509trustfile" && entry.size() == 1) {
- if(entry.front().size() == 2) {
- x509TrustFile = entry.front().back();
+ else if(entry[0].getKey().matches("X509TrustFile") && entry[1].empty()) {
+ x509TrustFile = entry[0][0];
- return true;
- }
+ return true;
}
- else if(Common::Util::tolower(entry.front().front()) == "x509crlfile" && entry.size() == 1) {
- if(entry.front().size() == 2) {
- x509CrlFile = entry.front().back();
+ else if(entry[0].getKey().matches("X509CrlFile") && entry[1].empty()) {
+ x509CrlFile = entry[0][0];
- return true;
- }
+ return true;
}
- else if(Common::Util::tolower(entry.front().front()) == "x509certfile" && entry.size() == 1) {
- if(entry.front().size() == 2) {
- x509CertFile = entry.front().back();
+ else if(entry[0].getKey().matches("X509CertFile") && entry[1].empty()) {
+ x509CertFile = entry[0][0];
- return true;
- }
+ return true;
}
- else if(Common::Util::tolower(entry.front().front()) == "x509keyfile" && entry.size() == 1) {
- if(entry.front().size() == 2) {
- x509KeyFile = entry.front().back();
+ else if(entry[0].getKey().matches("X509KeyFile") && entry[1].empty()) {
+ x509KeyFile = entry[0][0];
- return true;
- }
+ return true;
}
- else if(Common::Util::tolower(entry.front().front()) == "daemon") {
- if(entry.front().size() == 2) {
- if(entry.size() == 1) {
- daemonInfo.insert(std::make_pair(entry.front().back(), Common::HostInfo(entry.front().back())));
- identifiedDaemonConnections.insert(std::make_pair<std::string,Net::ServerConnection*>(entry.front().back(), 0));
+ else if(entry[0].getKey().matches("Daemon")) {
+ if(entry[0].getSize() == 1) {
+ if(entry[1].empty()) {
+ daemonInfo.insert(std::make_pair(entry[0][0], Common::HostInfo(entry[0][0])));
+ identifiedDaemonConnections.insert(std::make_pair<std::string,Net::ServerConnection*>(entry[0][0], 0));
return true;
}
- else if(entry.size() == 2) {
- if(Common::Util::tolower(entry.back().front()) == "ipaddress") {
- if(entry.back().size() == 2) {
- daemonInfo[entry.front().back()].setIP(entry.back().back());
+ else if(entry[1].getKey().matches("IpAddress") && entry[2].empty()) {
+ daemonInfo[entry[0][0]].setIP(entry[1][0]);
- return true;
- }
- }
+ return true;
}
}
}
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h
index d5bb718..29ed280 100644
--- a/src/Core/ConnectionManager.h
+++ b/src/Core/ConnectionManager.h
@@ -67,7 +67,7 @@ class ConnectionManager : private Common::Configurable {
void updateState(const std::string &name, Common::HostInfo::State state);
protected:
- virtual bool handleConfigEntry(const std::vector<std::vector<std::string> > &entry, bool handled);
+ virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool handled);
virtual void configFinished();
public: