summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-06-09 19:01:02 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-06-09 19:01:02 +0200
commit766c56a693e8b1bd4293459bb256abdc0515a0b5 (patch)
treeda8e51003cf801344e22b0b2b2e28a48d6a8b74c
parent452320b5ec31447a526735016fa07589cb848032 (diff)
downloadmad-766c56a693e8b1bd4293459bb256abdc0515a0b5.tar
mad-766c56a693e8b1bd4293459bb256abdc0515a0b5.zip
Teile der Namespaces Common und Net in den neuen Namespace Core verschoben
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Client/CommandParser.cpp30
-rw-r--r--src/Client/InformationManager.cpp8
-rw-r--r--src/Client/InformationManager.h7
-rw-r--r--src/Client/SystemCommands.cpp26
-rw-r--r--src/Client/UserCommands.cpp40
-rw-r--r--src/Common/CMakeLists.txt9
-rw-r--r--src/Common/ClientConnection.cpp5
-rw-r--r--src/Common/ClientConnection.h4
-rw-r--r--src/Common/Connection.h8
-rw-r--r--src/Common/ModuleManager.cpp8
-rw-r--r--src/Common/ModuleManager.h8
-rw-r--r--src/Common/Request.cpp4
-rw-r--r--src/Common/Request.h22
-rw-r--r--src/Common/RequestHandler.h8
-rw-r--r--src/Common/RequestHandlers/DisconnectRequestHandler.cpp8
-rw-r--r--src/Common/RequestHandlers/SimpleRequestHandler.cpp10
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.cpp2
-rw-r--r--src/Common/RequestManager.cpp18
-rw-r--r--src/Common/RequestManager.h5
-rw-r--r--src/Common/Requests/DisconnectRequest.cpp4
-rw-r--r--src/Common/SystemBackend.h24
-rw-r--r--src/Common/SystemManager.cpp48
-rw-r--r--src/Common/SystemManager.h14
-rw-r--r--src/Core/CMakeLists.txt25
-rw-r--r--src/Core/ConfigEntry.cpp (renamed from src/Common/ConfigEntry.cpp)2
-rw-r--r--src/Core/ConfigEntry.h (renamed from src/Common/ConfigEntry.h)8
-rw-r--r--src/Core/ConfigManager.cpp (renamed from src/Common/ConfigManager.cpp)2
-rw-r--r--src/Core/ConfigManager.h (renamed from src/Common/ConfigManager.h)8
-rw-r--r--src/Core/Configurable.h (renamed from src/Common/Configurable.h)8
-rw-r--r--src/Core/Exception.cpp (renamed from src/Net/Exception.cpp)2
-rw-r--r--src/Core/Exception.h (renamed from src/Net/Exception.h)8
-rw-r--r--src/Core/Initializable.cpp (renamed from src/Common/Initializable.cpp)4
-rw-r--r--src/Core/Initializable.h (renamed from src/Common/Initializable.h)8
-rw-r--r--src/Core/LogManager.cpp (renamed from src/Common/LogManager.cpp)2
-rw-r--r--src/Core/LogManager.h (renamed from src/Common/LogManager.h)13
-rw-r--r--src/Core/Logger.cpp (renamed from src/Common/Logger.cpp)2
-rw-r--r--src/Core/Logger.h (renamed from src/Common/Logger.h)8
-rw-r--r--src/Core/LoggerBase.h (renamed from src/Common/LoggerBase.h)8
-rw-r--r--src/Core/RemoteLogger.h (renamed from src/Common/RemoteLogger.h)8
-rw-r--r--src/Core/Signals.h (renamed from src/Net/Signals/Signals.h)12
-rw-r--r--src/Core/Signals/Connection.h (renamed from src/Net/Signals/Connection.h)8
-rw-r--r--src/Core/Signals/GenericSignal.h (renamed from src/Net/Signals/GenericSignal.h)8
-rw-r--r--src/Core/Signals/Signal0.h (renamed from src/Net/Signals/Signal0.h)12
-rw-r--r--src/Core/Signals/Signal1.h (renamed from src/Net/Signals/Signal1.h)12
-rw-r--r--src/Core/Signals/Signal2.h (renamed from src/Net/Signals/Signal2.h)12
-rw-r--r--src/Core/Signals/SignalBase.h (renamed from src/Net/Signals/SignalBase.h)8
-rw-r--r--src/Core/ThreadManager.cpp (renamed from src/Net/ThreadManager.cpp)21
-rw-r--r--src/Core/ThreadManager.h (renamed from src/Net/ThreadManager.h)18
-rw-r--r--src/Core/Tokenizer.cpp (renamed from src/Common/Tokenizer.cpp)2
-rw-r--r--src/Core/Tokenizer.h (renamed from src/Common/Tokenizer.h)8
-rw-r--r--src/Daemon/Backends/NetworkLogger.h6
-rw-r--r--src/Daemon/Requests/LogRequest.h8
-rw-r--r--src/Net/CMakeLists.txt13
-rw-r--r--src/Net/ClientConnection.cpp4
-rw-r--r--src/Net/ClientConnection.h6
-rw-r--r--src/Net/Connection.cpp12
-rw-r--r--src/Net/Connection.h25
-rw-r--r--src/Net/Listener.cpp20
-rw-r--r--src/Net/Listener.h12
-rw-r--r--src/Server/ConnectionManager.cpp47
-rw-r--r--src/Server/ConnectionManager.h16
-rw-r--r--src/Server/RequestHandlers/DaemonListRequestHandler.cpp1
-rw-r--r--src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp10
-rw-r--r--src/Server/RequestHandlers/DaemonRequestHandlerGroup.h4
-rw-r--r--src/Server/RequestHandlers/IdentifyRequestHandler.cpp1
-rw-r--r--src/Server/RequestHandlers/LogRequestHandler.cpp9
-rw-r--r--src/Server/RequestHandlers/UserRequestHandlerGroup.cpp2
-rw-r--r--src/Server/UserBackend.h44
-rw-r--r--src/Server/UserManager.cpp80
-rw-r--r--src/Server/UserManager.h22
-rw-r--r--src/mad-server.cpp12
-rw-r--r--src/mad.cpp25
-rw-r--r--src/madc.cpp19
-rw-r--r--src/modules/FileLogger/FileLogger.cpp6
-rw-r--r--src/modules/FileLogger/FileLogger.h16
-rw-r--r--src/modules/SystemBackendPosix/SystemBackendPosix.cpp20
-rw-r--r--src/modules/SystemBackendPosix/SystemBackendPosix.h6
-rw-r--r--src/modules/SystemBackendProc/SystemBackendProc.cpp24
-rw-r--r--src/modules/SystemBackendProc/SystemBackendProc.h6
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.cpp90
-rw-r--r--src/modules/UserBackendMysql/UserBackendMysql.h22
82 files changed, 567 insertions, 579 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eae793e..ddc9867 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,3 +1,4 @@
+add_subdirectory(Core)
add_subdirectory(Net)
add_subdirectory(Common)
add_subdirectory(Server)
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index 19aa8a9..be2383a 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -22,10 +22,10 @@
#include "SystemCommands.h"
#include "UserCommands.h"
-#include <Common/Logger.h>
-#include <Common/RequestManager.h>
-#include <Common/Tokenizer.h>
+#include <Core/Logger.h>
+#include <Core/Tokenizer.h>
+#include <Common/RequestManager.h>
#include <Common/Requests/DisconnectRequest.h>
#include <iostream>
@@ -71,7 +71,7 @@ void CommandParser::printUsage(const std::string& command) {
const CommandParser::Command *cmd = findCommand(command);
if(cmd)
- Common::Logger::logf("Usage: %s\n", cmd->cmdline);
+ Core::Logger::logf("Usage: %s\n", cmd->cmdline);
}
@@ -88,7 +88,7 @@ std::map<std::string, Common::HostInfo> CommandParser::parseHostList(const std::
}
if(ret.empty())
- Common::Logger::log("No hosts active.");
+ Core::Logger::log("No hosts active.");
}
else {
ret = hosts;
@@ -98,9 +98,9 @@ std::map<std::string, Common::HostInfo> CommandParser::parseHostList(const std::
std::map<std::string, Common::HostInfo>::const_iterator host = hosts.find(*arg);
if(host == hosts.end())
- Common::Logger::logf(Common::Logger::ERROR, "Host '%s' doesn't exist.", arg->c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "Host '%s' doesn't exist.", arg->c_str());
else if(mustBeActive && host->second.getState() == Common::HostInfo::INACTIVE)
- Common::Logger::logf(Common::Logger::WARNING, "Host '%s' is inactive.", arg->c_str());
+ Core::Logger::logf(Core::Logger::WARNING, "Host '%s' is inactive.", arg->c_str());
else
ret.insert(*host);
}
@@ -130,10 +130,10 @@ void CommandParser::helpCommand(const std::vector<std::string> &args, Common::Co
std::cout << command->longdesc << std::endl << std::endl;
}
else
- Common::Logger::logf(Common::Logger::WARNING, "%s: Command '%s' doesn't exist.", args[0].c_str(), args[1].c_str());
+ Core::Logger::logf(Core::Logger::WARNING, "%s: Command '%s' doesn't exist.", args[0].c_str(), args[1].c_str());
}
else {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
printUsage("help");
}
}
@@ -167,7 +167,7 @@ void CommandParser::listHostsCommand(const std::vector<std::string> &args, Commo
std::cout << std::endl;
}
else if(args.size() > 2) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
printUsage("list_hosts");
}
else if(args[1] == "-a") {
@@ -185,7 +185,7 @@ void CommandParser::listHostsCommand(const std::vector<std::string> &args, Commo
std::cout << std::endl;
}
else {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Don't understand argument '%s'.", args[0].c_str(), args[1].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Don't understand argument '%s'.", args[0].c_str(), args[1].c_str());
printUsage("list_hosts");
}
}
@@ -196,10 +196,10 @@ void CommandParser::exitCommand(const std::vector<std::string> &args _UNUSED_PAR
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = request->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(result.second)
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
else
commandParser.disconnect = true;
}
@@ -207,7 +207,7 @@ void CommandParser::exitCommand(const std::vector<std::string> &args _UNUSED_PAR
bool CommandParser::parse(const std::string &cmd) {
std::vector<std::string> splitCmd;
- Common::Tokenizer::tokenize(cmd, splitCmd);
+ Core::Tokenizer::tokenize(cmd, splitCmd);
if(splitCmd.empty())
return true;
@@ -217,7 +217,7 @@ bool CommandParser::parse(const std::string &cmd) {
if(command)
command->function(splitCmd, connection);
else
- Common::Logger::logf(Common::Logger::ERROR, "Unknown command '%s'.", splitCmd[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "Unknown command '%s'.", splitCmd[0].c_str());
return true;
}
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp
index 6bcdc8c..c5ff9f8 100644
--- a/src/Client/InformationManager.cpp
+++ b/src/Client/InformationManager.cpp
@@ -19,7 +19,7 @@
#include "InformationManager.h"
#include "Requests/DaemonListRequest.h"
-#include <Common/Logger.h>
+#include <Core/Logger.h>
#include <Common/RequestManager.h>
@@ -39,7 +39,7 @@ void InformationManager::DaemonStateUpdateRequestHandler::handleRequest(boost::s
if(host != informationManager.daemons.end())
host->second.setState((*packet)["state"]);
else
- Common::Logger::log(Common::Logger::WARNING, "Received a state update for an unknown host.");
+ Core::Logger::log(Core::Logger::WARNING, "Received a state update for an unknown host.");
}
ret->setType("OK");
@@ -68,11 +68,11 @@ void InformationManager::updateDaemonList(Common::Connection *con) {
updating = true;
}
-void InformationManager::daemonListRequestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Net::Exception error) {
+void InformationManager::daemonListRequestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Core::Exception error) {
boost::lock_guard<boost::mutex> lock(mutex);
if(!packet || error) {
- Common::Logger::logf(Common::Logger::CRITICAL, "Host list request failed: %s", error.strerror().c_str());
+ Core::Logger::logf(Core::Logger::CRITICAL, "Host list request failed: %s", error.strerror().c_str());
}
else {
const Common::XmlPacket::Element &hostInfo = (*packet)["hosts"];
diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h
index 78b1f88..ffc24cf 100644
--- a/src/Client/InformationManager.h
+++ b/src/Client/InformationManager.h
@@ -23,8 +23,9 @@
#include <map>
#include <memory>
+#include <Core/Initializable.h>
+
#include <Common/HostInfo.h>
-#include <Common/Initializable.h>
#include <Common/Request.h>
#include <Common/RequestHandlers/SimpleRequestHandler.h>
@@ -35,7 +36,7 @@
namespace Mad {
namespace Client {
-class InformationManager : public Common::Initializable, private boost::noncopyable {
+class InformationManager : public Core::Initializable, private boost::noncopyable {
private:
class DaemonStateUpdateRequestHandler : public Common::RequestHandlers::SimpleRequestHandler {
private:
@@ -57,7 +58,7 @@ class InformationManager : public Common::Initializable, private boost::noncopya
InformationManager() : updating(false) {}
- void daemonListRequestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Net::Exception error);
+ void daemonListRequestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Core::Exception error);
protected:
virtual void doInit();
diff --git a/src/Client/SystemCommands.cpp b/src/Client/SystemCommands.cpp
index 5409828..490f278 100644
--- a/src/Client/SystemCommands.cpp
+++ b/src/Client/SystemCommands.cpp
@@ -20,7 +20,7 @@
#include "SystemCommands.h"
#include "CommandParser.h"
-#include <Common/Logger.h>
+#include <Core/Logger.h>
#include <Common/RequestManager.h>
#include "Requests/DaemonFSInfoRequest.h"
@@ -146,7 +146,7 @@ void SystemCommands::fsinfoCommand(const std::vector<std::string> &args, Common:
else if(args.size() == 2)
request = boost::shared_ptr<Requests::DaemonFSInfoRequest>(new Requests::DaemonFSInfoRequest(args[1]));
else {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
CommandParser::printUsage("fsinfo");
return;
}
@@ -154,10 +154,10 @@ void SystemCommands::fsinfoCommand(const std::vector<std::string> &args, Common:
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = request->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
else {
if(args.size() == 1)
@@ -171,7 +171,7 @@ void SystemCommands::fsinfoCommand(const std::vector<std::string> &args, Common:
void SystemCommands::rebootCommand(const std::vector<std::string> &args, Common::Connection *connection) {
if(args.size() < 2) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: No host given.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: No host given.", args[0].c_str());
CommandParser::printUsage("reboot");
return;
}
@@ -191,16 +191,16 @@ void SystemCommands::rebootCommand(const std::vector<std::string> &args, Common:
(*request)->wait();
for(std::vector<boost::shared_ptr<Requests::DaemonCommandRequest> >::iterator request = requests.begin(); request != requests.end(); ++request) {
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = (*request)->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = (*request)->getResult();
if(result.second)
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
}
void SystemCommands::shutdownCommand(const std::vector<std::string> &args, Common::Connection *connection) {
if(args.size() < 2) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: No host given.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: No host given.", args[0].c_str());
CommandParser::printUsage("shutdown");
return;
}
@@ -220,10 +220,10 @@ void SystemCommands::shutdownCommand(const std::vector<std::string> &args, Commo
(*request)->wait();
for(std::vector<boost::shared_ptr<Requests::DaemonCommandRequest> >::iterator request = requests.begin(); request != requests.end(); ++request) {
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = (*request)->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = (*request)->getResult();
if(result.second)
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
}
@@ -235,7 +235,7 @@ void SystemCommands::statusCommand(const std::vector<std::string> &args, Common:
else if(args.size() == 2)
request = boost::shared_ptr<Requests::DaemonStatusRequest>(new Requests::DaemonStatusRequest(args[1]));
else {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
CommandParser::printUsage("status");
return;
}
@@ -243,10 +243,10 @@ void SystemCommands::statusCommand(const std::vector<std::string> &args, Common:
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = request->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
else {
if(args.size() == 1)
diff --git a/src/Client/UserCommands.cpp b/src/Client/UserCommands.cpp
index 6defbcf..97ea27b 100644
--- a/src/Client/UserCommands.cpp
+++ b/src/Client/UserCommands.cpp
@@ -20,7 +20,7 @@
#include "UserCommands.h"
#include "CommandParser.h"
-#include <Common/Logger.h>
+#include <Core/Logger.h>
#include <Common/RequestManager.h>
#include <Common/Requests/GroupListRequest.h>
@@ -37,12 +37,12 @@ namespace Client {
void UserCommands::userInfoCommand(const std::vector<std::string> &args, Common::Connection *connection) {
if(args.size() == 1) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: No user id given.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: No user id given.", args[0].c_str());
CommandParser::printUsage("user_info");
return;
}
if(args.size() > 2) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
CommandParser::printUsage("user_info");
return;
}
@@ -50,7 +50,7 @@ void UserCommands::userInfoCommand(const std::vector<std::string> &args, Common:
char *endptr;
unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10);
if(args[1].empty() || *endptr != '\0') {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Unable to parse user id.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Unable to parse user id.", args[0].c_str());
CommandParser::printUsage("user_info");
return;
}
@@ -59,10 +59,10 @@ void UserCommands::userInfoCommand(const std::vector<std::string> &args, Common:
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = request->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
else {
const Common::XmlPacket &packet = *result.first;
@@ -78,10 +78,10 @@ void UserCommands::listUsersCommand(const std::vector<std::string> &args _UNUSED
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = request->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
else {
const Common::XmlPacket::Element &users = (*result.first)["users"];
@@ -103,12 +103,12 @@ void UserCommands::listUsersCommand(const std::vector<std::string> &args _UNUSED
void UserCommands::listUserGroupsCommand(const std::vector<std::string> &args, Common::Connection *connection) {
if(args.size() == 1) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: No user id given.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: No user id given.", args[0].c_str());
CommandParser::printUsage("list_user_groups");
return;
}
if(args.size() > 2) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
CommandParser::printUsage("list_user_groups");
return;
}
@@ -116,7 +116,7 @@ void UserCommands::listUserGroupsCommand(const std::vector<std::string> &args, C
char *endptr;
unsigned long uid = std::strtoul(args[1].c_str(), &endptr, 10);
if(args[1].empty() || *endptr != '\0') {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Unable to parse user id.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Unable to parse user id.", args[0].c_str());
CommandParser::printUsage("list_user_groups");
return;
}
@@ -125,10 +125,10 @@ void UserCommands::listUserGroupsCommand(const std::vector<std::string> &args, C
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = request->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
else {
const Common::XmlPacket::Element &groups = (*result.first)["groups"];
@@ -155,10 +155,10 @@ void UserCommands::listGroupsCommand(const std::vector<std::string> &args _UNUSE
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = request->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
else {
const Common::XmlPacket::Element &groups = (*result.first)["groups"];
@@ -180,12 +180,12 @@ void UserCommands::listGroupsCommand(const std::vector<std::string> &args _UNUSE
void UserCommands::listGroupUsersCommand(const std::vector<std::string> &args, Common::Connection *connection) {
if(args.size() == 1) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: No group id given.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: No group id given.", args[0].c_str());
CommandParser::printUsage("list_group_users");
return;
}
if(args.size() > 2) {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
CommandParser::printUsage("list_group_users");
return;
}
@@ -193,7 +193,7 @@ void UserCommands::listGroupUsersCommand(const std::vector<std::string> &args, C
char *endptr;
unsigned long gid = std::strtoul(args[1].c_str(), &endptr, 10);
if(args[1].empty() || *endptr != '\0') {
- Common::Logger::logf(Common::Logger::ERROR, "%s: Unable to parse group id.", args[0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "%s: Unable to parse group id.", args[0].c_str());
CommandParser::printUsage("list_group_users");
return;
}
@@ -202,10 +202,10 @@ void UserCommands::listGroupUsersCommand(const std::vector<std::string> &args, C
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
- std::pair<boost::shared_ptr<const Common::XmlPacket>, Net::Exception> result = request->getResult();
+ std::pair<boost::shared_ptr<const Common::XmlPacket>, Core::Exception> result = request->getResult();
if(!result.first || result.second) {
- Common::Logger::logf(Common::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "An error occurred during your request: %s.", result.second.strerror().c_str());
}
else {
const Common::XmlPacket::Element &users = (*result.first)["users"];
diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt
index 25c3dee..078df71 100644
--- a/src/Common/CMakeLists.txt
+++ b/src/Common/CMakeLists.txt
@@ -8,25 +8,16 @@ link_directories(${LTDL_LIBRARY_DIR})
add_library(Common
Base64Encoder.cpp Base64Encoder.h
ClientConnection.cpp ClientConnection.h
- ConfigEntry.cpp ConfigEntry.h
- ConfigManager.cpp ConfigManager.h
- Configurable.h
Connection.cpp Connection.h
- Initializable.cpp Initializable.h
GroupInfo.h
HostInfo.h
- Logger.cpp Logger.h
- LoggerBase.h
- LogManager.cpp LogManager.h
ModuleManager.cpp ModuleManager.h
- RemoteLogger.h
Request.cpp Request.h
RequestHandler.cpp RequestHandler.h
RequestHandlerGroup.h
RequestManager.cpp RequestManager.h
SystemBackend.h
SystemManager.cpp SystemManager.h
- Tokenizer.cpp Tokenizer.h
UserInfo.h
XmlPacket.cpp XmlPacket.h
)
diff --git a/src/Common/ClientConnection.cpp b/src/Common/ClientConnection.cpp
index b9a6721..ba558f4 100644
--- a/src/Common/ClientConnection.cpp
+++ b/src/Common/ClientConnection.cpp
@@ -18,9 +18,8 @@
*/
#include "ClientConnection.h"
-#include <Net/ClientConnection.h>
-#include "Logger.h"
+#include <Net/ClientConnection.h>
namespace Mad {
namespace Common {
@@ -33,7 +32,7 @@ bool ClientConnection::send(const Net::Packet &packet) {
return connection->send(packet);
}
-void ClientConnection::connect(const boost::asio::ip::tcp::endpoint &address) throw(Net::Exception) {
+void ClientConnection::connect(const boost::asio::ip::tcp::endpoint &address) throw(Core::Exception) {
connection->connect(address);
}
diff --git a/src/Common/ClientConnection.h b/src/Common/ClientConnection.h
index a455c29..305df44 100644
--- a/src/Common/ClientConnection.h
+++ b/src/Common/ClientConnection.h
@@ -21,7 +21,7 @@
#define MAD_COMMON_CLIENTCONNECTION_H_
#include "Connection.h"
-#include <Net/Exception.h>
+#include <Core/Exception.h>
#include <boost/asio.hpp>
@@ -44,7 +44,7 @@ class ClientConnection : public Connection {
ClientConnection();
virtual ~ClientConnection() {}
- void connect(const boost::asio::ip::tcp::endpoint &address) throw(Net::Exception);
+ void connect(const boost::asio::ip::tcp::endpoint &address) throw(Core::Exception);
bool isConnecting() const;
bool isConnected() const;
diff --git a/src/Common/Connection.h b/src/Common/Connection.h
index c8ff3e8..6700574 100644
--- a/src/Common/Connection.h
+++ b/src/Common/Connection.h
@@ -20,7 +20,7 @@
#ifndef MAD_COMMON_CONNECTION_H_
#define MAD_COMMON_CONNECTION_H_
-#include <Net/Signals/Signals.h>
+#include <Core/Signals.h>
#include <stdint.h>
#include <sys/types.h>
@@ -39,7 +39,7 @@ class Connection : private boost::noncopyable {
private:
bool authenticated;
- Net::Signals::Signal2<boost::shared_ptr<const XmlPacket>, uint16_t> signalReceive;
+ Core::Signals::Signal2<boost::shared_ptr<const XmlPacket>, uint16_t> signalReceive;
protected:
Connection() : authenticated(0) {}
@@ -53,10 +53,10 @@ class Connection : private boost::noncopyable {
bool sendPacket(const XmlPacket &packet, uint16_t requestId);
- Net::Signals::Connection connectSignalReceive(const Net::Signals::Signal2<boost::shared_ptr<const XmlPacket>, uint16_t>::slot_type &slot) {
+ Core::Signals::Connection connectSignalReceive(const Core::Signals::Signal2<boost::shared_ptr<const XmlPacket>, uint16_t>::slot_type &slot) {
return signalReceive.connect(slot);
}
- void disconnectSignalReceive(const Net::Signals::Connection &con) {
+ void disconnectSignalReceive(const Core::Signals::Connection &con) {
signalReceive.disconnect(con);
}
diff --git a/src/Common/ModuleManager.cpp b/src/Common/ModuleManager.cpp
index 05a2b73..bec3618 100644
--- a/src/Common/ModuleManager.cpp
+++ b/src/Common/ModuleManager.cpp
@@ -22,8 +22,8 @@
#include "ModuleManager.h"
-#include "ConfigEntry.h"
-#include "Logger.h"
+#include <Core/ConfigEntry.h>
+#include <Core/Logger.h>
//extern const lt_dlsymlist lt_preloaded_symbols[];
@@ -58,13 +58,13 @@ void ModuleManager::doDeinit() {
lt_dlexit();
}
-bool ModuleManager::handleConfigEntry(const ConfigEntry &entry, bool handled) {
+bool ModuleManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
if(handled)
return false;
if(entry[0].getKey().matches("LoadModule")) {
if(!loadModule(entry[0][0].c_str()))
- Logger::logf(Logger::ERROR, "Can't load module '%s'.", entry[0][0].c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "Can't load module '%s'.", entry[0][0].c_str());
return true;
}
diff --git a/src/Common/ModuleManager.h b/src/Common/ModuleManager.h
index fa7316f..de5535f 100644
--- a/src/Common/ModuleManager.h
+++ b/src/Common/ModuleManager.h
@@ -20,8 +20,8 @@
#ifndef MAD_COMMON_MODULEMANAGER_H_
#define MAD_COMMON_MODULEMANAGER_H_
-#include "Configurable.h"
-#include "Initializable.h"
+#include <Core/Configurable.h>
+#include <Core/Initializable.h>
#include <map>
#include <stack>
@@ -32,7 +32,7 @@
namespace Mad {
namespace Common {
-class ModuleManager : public Configurable, public Initializable {
+class ModuleManager : public Core::Configurable, public Core::Initializable {
private:
static ModuleManager moduleManager;
@@ -47,7 +47,7 @@ class ModuleManager : public Configurable, public Initializable {
virtual void doInit();
virtual void doDeinit();
- virtual bool handleConfigEntry(const ConfigEntry &entry, bool handled);
+ virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
public:
lt_dlhandle loadModule(const std::string &name);
diff --git a/src/Common/Request.cpp b/src/Common/Request.cpp
index 723039f..9aafd7f 100644
--- a/src/Common/Request.cpp
+++ b/src/Common/Request.cpp
@@ -24,11 +24,11 @@ namespace Common {
void Request::handlePacket(boost::shared_ptr<const XmlPacket> packet) {
if(packet->getType() == "Error") {
- signalFinished(Net::Exception((*packet)["Where"], (*packet)["ErrorCode"], (*packet)["SubCode"], (*packet)["SubSubCode"]));
+ signalFinished(Core::Exception((*packet)["Where"], (*packet)["ErrorCode"], (*packet)["SubCode"], (*packet)["SubSubCode"]));
return;
}
else if(packet->getType() != "OK") {
- signalFinished(Net::Exception(Net::Exception::UNEXPECTED_PACKET));
+ signalFinished(Core::Exception(Core::Exception::UNEXPECTED_PACKET));
return; // TODO Logging
}
diff --git a/src/Common/Request.h b/src/Common/Request.h
index 4698ae5..ac59e45 100644
--- a/src/Common/Request.h
+++ b/src/Common/Request.h
@@ -21,7 +21,7 @@
#define MAD_COMMON_REQUEST_H_
#include "RequestHandler.h"
-#include <Net/Exception.h>
+#include <Core/Exception.h>
#include <memory>
@@ -42,14 +42,14 @@ class Request : public RequestHandler {
bool isFinished;
boost::shared_ptr<const XmlPacket> packet;
- Net::Exception exception;
+ Core::Exception exception;
- Net::Signals::Signal2<boost::shared_ptr<const XmlPacket>, Net::Exception> finished;
+ Core::Signals::Signal2<boost::shared_ptr<const XmlPacket>, Core::Exception> finished;
protected:
Request() : isFinished(false) {}
- void signalFinished(boost::shared_ptr<const XmlPacket> pkt, Net::Exception exp) {
+ void signalFinished(boost::shared_ptr<const XmlPacket> pkt, Core::Exception exp) {
{
boost::lock_guard<boost::mutex> lock(mutex);
@@ -65,25 +65,25 @@ class Request : public RequestHandler {
}
void signalFinished(boost::shared_ptr<const XmlPacket> packet) {
- signalFinished(packet, Net::Exception());
+ signalFinished(packet, Core::Exception());
}
- void signalFinished(Net::Exception exp) {
+ void signalFinished(Core::Exception exp) {
signalFinished(boost::shared_ptr<const XmlPacket>(), exp);
}
void signalFinished() {
- signalFinished(boost::shared_ptr<const XmlPacket>(), Net::Exception());
+ signalFinished(boost::shared_ptr<const XmlPacket>(), Core::Exception());
}
virtual void sendRequest() = 0;
virtual void handlePacket(boost::shared_ptr<const XmlPacket> packet);
public:
- Net::Signals::Connection connectSignalFinished(const Net::Signals::Signal2<boost::shared_ptr<const XmlPacket>, Net::Exception>::slot_type &slot) {
+ Core::Signals::Connection connectSignalFinished(const Core::Signals::Signal2<boost::shared_ptr<const XmlPacket>, Core::Exception>::slot_type &slot) {
return finished.connect(slot);
}
- void disconnectSignalFinished(const Net::Signals::Connection &con) {
+ void disconnectSignalFinished(const Core::Signals::Connection &con) {
finished.disconnect(con);
}
@@ -94,11 +94,11 @@ class Request : public RequestHandler {
finishCond.wait(lock);
}
- std::pair<boost::shared_ptr<const XmlPacket>, Net::Exception> getResult() {
+ std::pair<boost::shared_ptr<const XmlPacket>, Core::Exception> getResult() {
boost::lock_guard<boost::mutex> lock(mutex);
if(!isFinished)
- return std::make_pair(boost::shared_ptr<const XmlPacket>(), Net::Exception(Net::Exception::NOT_FINISHED));
+ return std::make_pair(boost::shared_ptr<const XmlPacket>(), Core::Exception(Core::Exception::NOT_FINISHED));
else
return std::make_pair(packet, exception);
}
diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h
index f01db41..3deb8c0 100644
--- a/src/Common/RequestHandler.h
+++ b/src/Common/RequestHandler.h
@@ -23,7 +23,7 @@
#include "Connection.h"
#include "XmlPacket.h"
-#include <Net/Signals/Signals.h>
+#include <Core/Signals.h>
#include <boost/cstdint.hpp>
#include <boost/thread/locks.hpp>
@@ -41,7 +41,7 @@ class RequestHandler : private boost::noncopyable {
boost::mutex mutex;
- Net::Signals::Signal0 finished;
+ Core::Signals::Signal0 finished;
protected:
RequestHandler() {}
@@ -59,10 +59,10 @@ class RequestHandler : private boost::noncopyable {
public:
virtual ~RequestHandler() {}
- Net::Signals::Connection connectSignalFinished(const Net::Signals::Signal0::slot_type &slot) {
+ Core::Signals::Connection connectSignalFinished(const Core::Signals::Signal0::slot_type &slot) {
return finished.connect(slot);
}
- void disconnectSignalFinished(const Net::Signals::Connection &con) {
+ void disconnectSignalFinished(const Core::Signals::Connection &con) {
finished.disconnect(con);
}
};
diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
index 942da0a..6c89ab2 100644
--- a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
+++ b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
@@ -18,8 +18,8 @@
*/
#include "DisconnectRequestHandler.h"
-#include <Net/Exception.h>
-#include "../Logger.h"
+#include <Core/Exception.h>
+#include <Core/Logger.h>
namespace Mad {
namespace Common {
@@ -27,11 +27,11 @@ namespace RequestHandlers {
void DisconnectRequestHandler::handlePacket(boost::shared_ptr<const XmlPacket> packet) {
if(packet->getType() != "Disconnect") {
- Logger::log(Logger::ERROR, "Received an unexpected packet.");
+ Core::Logger::log(Core::Logger::ERROR, "Received an unexpected packet.");
XmlPacket ret;
ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
+ ret.add("ErrorCode", Core::Exception::UNEXPECTED_PACKET);
sendPacket(ret);
diff --git a/src/Common/RequestHandlers/SimpleRequestHandler.cpp b/src/Common/RequestHandlers/SimpleRequestHandler.cpp
index 0abc484..b6de0f4 100644
--- a/src/Common/RequestHandlers/SimpleRequestHandler.cpp
+++ b/src/Common/RequestHandlers/SimpleRequestHandler.cpp
@@ -18,9 +18,9 @@
*/
#include "SimpleRequestHandler.h"
-#include "../Logger.h"
-#include <Net/Exception.h>
+#include <Core/Logger.h>
+#include <Core/Exception.h>
namespace Mad {
namespace Common {
@@ -28,11 +28,11 @@ namespace RequestHandlers {
void SimpleRequestHandler::handlePacket(boost::shared_ptr<const XmlPacket> packet) {
if(packet->getType() != type) {
- Logger::log(Logger::ERROR, "Received an unexpected packet.");
+ Core::Logger::log(Core::Logger::ERROR, "Received an unexpected packet.");
XmlPacket ret;
ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
+ ret.add("ErrorCode", Core::Exception::UNEXPECTED_PACKET);
sendPacket(ret);
@@ -47,7 +47,7 @@ void SimpleRequestHandler::handlePacket(boost::shared_ptr<const XmlPacket> packe
try {
handler(packet, &ret);
}
- catch(Net::Exception e) {
+ catch(Core::Exception e) {
ret.setType("Error");
ret.add("ErrorCode", e.getErrorCode());
ret.add("SubCode", e.getSubCode());
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.cpp b/src/Common/RequestHandlers/StatusRequestHandler.cpp
index 25d2f23..95bdd30 100644
--- a/src/Common/RequestHandlers/StatusRequestHandler.cpp
+++ b/src/Common/RequestHandlers/StatusRequestHandler.cpp
@@ -38,7 +38,7 @@ void StatusRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPack
SystemManager::get()->getMemoryInfo(&totalMem, &freeMem, &totalSwap, &freeSwap);
SystemManager::get()->getLoadInfo(&currentLoad, &nProcesses, &loadAvg1, &loadAvg5, &loadAvg15);
}
- catch(Net::Exception e) {}
+ catch(Core::Exception e) {}
ret->setType("OK");
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index b443292..a8b817f 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -19,7 +19,7 @@
#include "RequestManager.h"
#include "RequestHandlers/DisconnectRequestHandler.h"
-#include "Logger.h"
+#include <Core/Logger.h>
#include <boost/bind.hpp>
@@ -96,14 +96,14 @@ void RequestManager::receiveHandler(Connection *connection, boost::shared_ptr<co
boost::shared_ptr<RequestHandler> request = requestMap.findRequest(connection, requestId);
if(request) {
lock.unlock();
- Net::ThreadManager::get()->pushWork(boost::bind(&RequestHandler::handlePacket, request, packet));
+ Core::ThreadManager::get()->pushWork(boost::bind(&RequestHandler::handlePacket, request, packet));
return;
}
if(!requestMap.isConnectionRegistered(connection)) {
// TODO: Error
- Logger::log(Logger::ERROR, "Received a packet from an unregistered connection.");
+ Core::Logger::log(Core::Logger::ERROR, "Received a packet from an unregistered connection.");
return;
}
@@ -122,7 +122,7 @@ void RequestManager::receiveHandler(Connection *connection, boost::shared_ptr<co
}
lock.unlock();
- Net::ThreadManager::get()->pushWork(boost::bind(&RequestHandler::handlePacket, request, packet));
+ Core::ThreadManager::get()->pushWork(boost::bind(&RequestHandler::handlePacket, request, packet));
return;
}
@@ -130,11 +130,11 @@ void RequestManager::receiveHandler(Connection *connection, boost::shared_ptr<co
lock.unlock();
- Logger::logf(Logger::ERROR, "Received an unexpected packet with type '%s'.", packet->getType().c_str());
+ Core::Logger::logf(Core::Logger::ERROR, "Received an unexpected packet with type '%s'.", packet->getType().c_str());
XmlPacket ret;
ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
+ ret.add("ErrorCode", Core::Exception::UNEXPECTED_PACKET);
connection->sendPacket(ret, requestId);
}
@@ -143,20 +143,20 @@ bool RequestManager::sendRequest(Connection *connection, boost::shared_ptr<Reque
boost::unique_lock<boost::shared_mutex> lock(mutex);
if(!requestMap.isConnectionRegistered(connection)) {
- Logger::log(Logger::CRITICAL, "Trying to send a request over an unregistered connecion.");
+ Core::Logger::log(Core::Logger::CRITICAL, "Trying to send a request over an unregistered connecion.");
return false;
}
uint16_t requestId = _getUnusedRequestId(connection);
if(request->isFinished || !requestMap.addRequest(connection, requestId, request)) {
- Logger::log(Logger::CRITICAL, "Trying resend a request.");
+ Core::Logger::log(Core::Logger::CRITICAL, "Trying resend a request.");
return false;
}
request->connectSignalFinished(boost::bind(&RequestManager::handleRequestFinished, this, connection, requestId));
lock.unlock();
- Net::ThreadManager::get()->pushWork(boost::bind(&Request::sendRequest, request));
+ Core::ThreadManager::get()->pushWork(boost::bind(&Request::sendRequest, request));
return true;
}
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index e66b0c1..2dd892e 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -31,11 +31,6 @@
#include <boost/thread/shared_mutex.hpp>
namespace Mad {
-
-namespace Net {
-class Packet;
-}
-
namespace Common {
class RequestManager : boost::noncopyable {
diff --git a/src/Common/Requests/DisconnectRequest.cpp b/src/Common/Requests/DisconnectRequest.cpp
index 249bbc1..6c4fa0d 100644
--- a/src/Common/Requests/DisconnectRequest.cpp
+++ b/src/Common/Requests/DisconnectRequest.cpp
@@ -32,11 +32,11 @@ void DisconnectRequest::sendRequest() {
void DisconnectRequest::handlePacket(boost::shared_ptr<const XmlPacket> packet) {
if(packet->getType() == "Error") {
- signalFinished(Net::Exception((*packet)["Where"], (*packet)["ErrorCode"], (*packet)["SubCode"], (*packet)["SubSubCode"]));
+ signalFinished(Core::Exception((*packet)["Where"], (*packet)["ErrorCode"], (*packet)["SubCode"], (*packet)["SubSubCode"]));
return;
}
else if(packet->getType() != "OK") {
- signalFinished(Net::Exception(Net::Exception::UNEXPECTED_PACKET));
+ signalFinished(Core::Exception(Core::Exception::UNEXPECTED_PACKET));
return; // TODO Logging
}
diff --git a/src/Common/SystemBackend.h b/src/Common/SystemBackend.h
index 1543207..418fa2b 100644
--- a/src/Common/SystemBackend.h
+++ b/src/Common/SystemBackend.h
@@ -31,28 +31,28 @@ class SystemBackend {
protected:
friend class SystemManager;
- virtual void getUptimeInfo(unsigned long *uptime _UNUSED_PARAMETER_, unsigned long *idleTime _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw Net::Exception(Net::Exception::NOT_IMPLEMENTED);
+ virtual void getUptimeInfo(unsigned long *uptime _UNUSED_PARAMETER_, unsigned long *idleTime _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
- virtual void getMemoryInfo(unsigned long *totalMem _UNUSED_PARAMETER_, unsigned long *freeMem _UNUSED_PARAMETER_, unsigned long *totalSwap _UNUSED_PARAMETER_, unsigned long *freeSwap _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw Net::Exception(Net::Exception::NOT_IMPLEMENTED);
+ virtual void getMemoryInfo(unsigned long *totalMem _UNUSED_PARAMETER_, unsigned long *freeMem _UNUSED_PARAMETER_, unsigned long *totalSwap _UNUSED_PARAMETER_, unsigned long *freeSwap _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
- virtual void getLoadInfo(unsigned long *currentLoad _UNUSED_PARAMETER_, unsigned long *nProcesses _UNUSED_PARAMETER_, float *loadAvg1 _UNUSED_PARAMETER_, float *loadAvg5 _UNUSED_PARAMETER_, float *loadAvg15 _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw Net::Exception(Net::Exception::NOT_IMPLEMENTED);
+ virtual void getLoadInfo(unsigned long *currentLoad _UNUSED_PARAMETER_, unsigned long *nProcesses _UNUSED_PARAMETER_, float *loadAvg1 _UNUSED_PARAMETER_, float *loadAvg5 _UNUSED_PARAMETER_, float *loadAvg15 _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
- virtual void getFSInfo(std::vector<SystemManager::FSInfo> *fsInfo _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw Net::Exception(Net::Exception::NOT_IMPLEMENTED);
+ virtual void getFSInfo(std::vector<SystemManager::FSInfo> *fsInfo _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
- virtual void shutdown() throw(Net::Exception) {
- throw Net::Exception(Net::Exception::NOT_IMPLEMENTED);
+ virtual void shutdown() throw(Core::Exception) {
+ throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
- virtual void reboot() throw(Net::Exception) {
- throw Net::Exception(Net::Exception::NOT_IMPLEMENTED);
+ virtual void reboot() throw(Core::Exception) {
+ throw Core::Exception(Core::Exception::NOT_IMPLEMENTED);
}
virtual int getPriority() const {
diff --git a/src/Common/SystemManager.cpp b/src/Common/SystemManager.cpp
index e58c2ba..fac50d5 100644
--- a/src/Common/SystemManager.cpp
+++ b/src/Common/SystemManager.cpp
@@ -34,16 +34,16 @@ bool SystemManager::Compare::operator() (boost::shared_ptr<SystemBackend> b1, bo
}
-void SystemManager::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+void SystemManager::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->getUptimeInfo(uptime, idleTime);
return;
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -51,16 +51,16 @@ void SystemManager::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime
throw e;
}
-void SystemManager::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+void SystemManager::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->getMemoryInfo(totalMem, freeMem, totalSwap, freeSwap);
return;
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -68,16 +68,16 @@ void SystemManager::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMe
throw e;
}
-void SystemManager::getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+void SystemManager::getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->getLoadInfo(currentLoad, nProcesses, loadAvg1, loadAvg5, loadAvg15);
return;
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -85,16 +85,16 @@ void SystemManager::getLoadInfo(unsigned long *currentLoad, unsigned long *nProc
throw e;
}
-void SystemManager::getFSInfo(std::vector<FSInfo> *fsInfo) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+void SystemManager::getFSInfo(std::vector<FSInfo> *fsInfo) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->getFSInfo(fsInfo);
return;
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -102,16 +102,16 @@ void SystemManager::getFSInfo(std::vector<FSInfo> *fsInfo) throw(Net::Exception)
throw e;
}
-void SystemManager::shutdown() throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+void SystemManager::shutdown() throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->shutdown();
return;
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -119,16 +119,16 @@ void SystemManager::shutdown() throw(Net::Exception) {
throw e;
}
-void SystemManager::reboot() throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+void SystemManager::reboot() throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<SystemBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
(*backend)->reboot();
return;
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
diff --git a/src/Common/SystemManager.h b/src/Common/SystemManager.h
index 9252b2b..6870489 100644
--- a/src/Common/SystemManager.h
+++ b/src/Common/SystemManager.h
@@ -26,7 +26,7 @@
#include <boost/smart_ptr.hpp>
-#include <Net/Exception.h>
+#include <Core/Exception.h>
namespace Mad {
namespace Common {
@@ -62,14 +62,14 @@ class SystemManager {
backends.erase(backend);
}
- void getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Net::Exception);
- void getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Net::Exception);
- void getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Net::Exception);
+ void getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Core::Exception);
+ void getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Core::Exception);
+ void getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Core::Exception);
- void getFSInfo(std::vector<FSInfo> *fsInfo) throw(Net::Exception);
+ void getFSInfo(std::vector<FSInfo> *fsInfo) throw(Core::Exception);
- void shutdown() throw(Net::Exception);
- void reboot() throw(Net::Exception);
+ void shutdown() throw(Core::Exception);
+ void reboot() throw(Core::Exception);
static SystemManager *get() {
return &systemManager;
diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt
new file mode 100644
index 0000000..30947e3
--- /dev/null
+++ b/src/Core/CMakeLists.txt
@@ -0,0 +1,25 @@
+include_directories(${INCLUDES})
+link_directories(${Boost_LIBRARY_DIRS})
+
+add_library(Core
+ Signals/Connection.h
+ Signals/GenericSignal.h
+ Signals/Signal0.h
+ Signals/Signal1.h
+ Signals/Signal2.h
+ Signals/SignalBase.h
+
+ ConfigEntry.cpp ConfigEntry.h
+ ConfigManager.cpp ConfigManager.h
+ Configurable.h
+ Exception.cpp Exception.h
+ Initializable.cpp Initializable.h
+ Logger.cpp Logger.h
+ LoggerBase.h
+ LogManager.cpp LogManager.h
+ RemoteLogger.h
+ Signals.h
+ ThreadManager.cpp ThreadManager.h
+ Tokenizer.cpp Tokenizer.h
+)
+target_link_libraries(Core ${Boost_LIBRARIES})
diff --git a/src/Common/ConfigEntry.cpp b/src/Core/ConfigEntry.cpp
index f47cf7a..d85235a 100644
--- a/src/Common/ConfigEntry.cpp
+++ b/src/Core/ConfigEntry.cpp
@@ -20,7 +20,7 @@
#include "ConfigEntry.h"
namespace Mad {
-namespace Common {
+namespace Core {
ConfigEntry::String& ConfigEntry::Entry::operator[] (size_t i) {
try {
diff --git a/src/Common/ConfigEntry.h b/src/Core/ConfigEntry.h
index 8358726..42f8f91 100644
--- a/src/Common/ConfigEntry.h
+++ b/src/Core/ConfigEntry.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_CONFIGENTRY_H_
-#define MAD_COMMON_CONFIGENTRY_H_
+#ifndef MAD_CORE_CONFIGENTRY_H_
+#define MAD_CORE_CONFIGENTRY_H_
#include <stdexcept>
#include <string>
@@ -26,7 +26,7 @@
#include <vector>
namespace Mad {
-namespace Common {
+namespace Core {
class ConfigEntry {
public:
@@ -93,4 +93,4 @@ class ConfigEntry {
}
}
-#endif /* MAD_COMMON_CONFIGENTRY_H_ */
+#endif /* MAD_CORE_CONFIGENTRY_H_ */
diff --git a/src/Common/ConfigManager.cpp b/src/Core/ConfigManager.cpp
index 3bf0c85..8b1ebd4 100644
--- a/src/Common/ConfigManager.cpp
+++ b/src/Core/ConfigManager.cpp
@@ -28,7 +28,7 @@
#include <stdexcept>
namespace Mad {
-namespace Common {
+namespace Core {
ConfigManager ConfigManager::configManager;
diff --git a/src/Common/ConfigManager.h b/src/Core/ConfigManager.h
index e7885b8..2d49a97 100644
--- a/src/Common/ConfigManager.h
+++ b/src/Core/ConfigManager.h
@@ -17,15 +17,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_CONFIGMANAGER_H_
-#define MAD_COMMON_CONFIGMANAGER_H_
+#ifndef MAD_CORE_CONFIGMANAGER_H_
+#define MAD_CORE_CONFIGMANAGER_H_
#include <memory>
#include <set>
#include <string>
namespace Mad {
-namespace Common {
+namespace Core {
class ConfigEntry;
class Configurable;
@@ -66,4 +66,4 @@ class ConfigManager {
}
}
-#endif /* MAD_COMMON_CONFIGMANAGER_H_ */
+#endif /* MAD_CORE_CONFIGMANAGER_H_ */
diff --git a/src/Common/Configurable.h b/src/Core/Configurable.h
index 47f919d..db2e4a0 100644
--- a/src/Common/Configurable.h
+++ b/src/Core/Configurable.h
@@ -17,11 +17,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_CONFIGURABLE_H_
-#define MAD_COMMON_CONFIGURABLE_H_
+#ifndef MAD_CORE_CONFIGURABLE_H_
+#define MAD_CORE_CONFIGURABLE_H_
namespace Mad {
-namespace Common {
+namespace Core {
class ConfigEntry;
class ConfigManager;
@@ -44,4 +44,4 @@ class Configurable {
}
}
-#endif /* MAD_COMMON_CONFIGURABLE_H_ */
+#endif /* MAD_CORE_CONFIGURABLE_H_ */
diff --git a/src/Net/Exception.cpp b/src/Core/Exception.cpp
index e082948..fbae6aa 100644
--- a/src/Net/Exception.cpp
+++ b/src/Core/Exception.cpp
@@ -22,7 +22,7 @@
#include <cstring>
namespace Mad {
-namespace Net {
+namespace Core {
std::string Exception::strerror() const {
std::string ret;
diff --git a/src/Net/Exception.h b/src/Core/Exception.h
index 1ddf5f4..6c89549 100644
--- a/src/Net/Exception.h
+++ b/src/Core/Exception.h
@@ -17,13 +17,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_NET_EXCEPTION_H_
-#define MAD_NET_EXCEPTION_H_
+#ifndef MAD_CORE_EXCEPTION_H_
+#define MAD_CORE_EXCEPTION_H_
#include <string>
namespace Mad {
-namespace Net {
+namespace Core {
class Exception {
public:
@@ -62,4 +62,4 @@ class Exception {
}
}
-#endif /* MAD_NET_EXCEPTION_H_ */
+#endif /* MAD_CORE_EXCEPTION_H_ */
diff --git a/src/Common/Initializable.cpp b/src/Core/Initializable.cpp
index d2dc9fd..95d527f 100644
--- a/src/Common/Initializable.cpp
+++ b/src/Core/Initializable.cpp
@@ -23,10 +23,8 @@
#include "Configurable.h"
#include "Logger.h"
-#include <typeinfo>
-
namespace Mad {
-namespace Common {
+namespace Core {
std::stack<Initializable*> Initializable::initializedObjects;
diff --git a/src/Common/Initializable.h b/src/Core/Initializable.h
index 6f67678..e7d329d 100644
--- a/src/Common/Initializable.h
+++ b/src/Core/Initializable.h
@@ -17,13 +17,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_INITIALIZABLE_H_
-#define MAD_COMMON_INITIALIZABLE_H_
+#ifndef MAD_CORE_INITIALIZABLE_H_
+#define MAD_CORE_INITIALIZABLE_H_
#include <stack>
namespace Mad {
-namespace Common {
+namespace Core {
class Initializable {
private:
@@ -51,4 +51,4 @@ class Initializable {
}
}
-#endif /* MAD_COMMON_INITIALIZABLE_H_ */
+#endif /* MAD_CORE_INITIALIZABLE_H_ */
diff --git a/src/Common/LogManager.cpp b/src/Core/LogManager.cpp
index bd83a5e..bf9767b 100644
--- a/src/Common/LogManager.cpp
+++ b/src/Core/LogManager.cpp
@@ -23,7 +23,7 @@
#include <iostream>
namespace Mad {
-namespace Common {
+namespace Core {
LogManager LogManager::logManager;
diff --git a/src/Common/LogManager.h b/src/Core/LogManager.h
index 98bb6f7..6d75b82 100644
--- a/src/Common/LogManager.h
+++ b/src/Core/LogManager.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_LOGMANAGER_H_
-#define MAD_COMMON_LOGMANAGER_H_
+#ifndef MAD_CORE_LOGMANAGER_H_
+#define MAD_CORE_LOGMANAGER_H_
#include <config.h>
@@ -33,16 +33,13 @@
#include <boost/thread/mutex.hpp>
namespace Mad {
+namespace Core {
-namespace Net {
class ThreadManager;
-}
-
-namespace Common {
class LogManager : public Configurable {
private:
- friend class Net::ThreadManager;
+ friend class ThreadManager;
typedef LoggerBase::MessageCategory MessageCategory;
typedef LoggerBase::MessageLevel MessageLevel;
@@ -146,4 +143,4 @@ class LogManager : public Configurable {
}
}
-#endif /* MAD_COMMON_LOGMANAGER_H_ */
+#endif /* MAD_CORE_LOGMANAGER_H_ */
diff --git a/src/Common/Logger.cpp b/src/Core/Logger.cpp
index e746faf..e4e0341 100644
--- a/src/Common/Logger.cpp
+++ b/src/Core/Logger.cpp
@@ -23,7 +23,7 @@
#include <cstdlib>
namespace Mad {
-namespace Common {
+namespace Core {
void Logger::logfv(MessageCategory category, MessageLevel level, const char *format, va_list ap) {
int size = 100;
diff --git a/src/Common/Logger.h b/src/Core/Logger.h
index 436c232..3de22d2 100644
--- a/src/Common/Logger.h
+++ b/src/Core/Logger.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_LOGGER_H_
-#define MAD_COMMON_LOGGER_H_
+#ifndef MAD_CORE_LOGGER_H_
+#define MAD_CORE_LOGGER_H_
#include "LoggerBase.h"
@@ -27,7 +27,7 @@
#include <string>
namespace Mad {
-namespace Common {
+namespace Core {
class LogManager;
@@ -65,4 +65,4 @@ class Logger : public LoggerBase {
}
}
-#endif /* MAD_COMMON_LOGGER_H_ */
+#endif /* MAD_CORE_LOGGER_H_ */
diff --git a/src/Common/LoggerBase.h b/src/Core/LoggerBase.h
index 9843d4d..49be833 100644
--- a/src/Common/LoggerBase.h
+++ b/src/Core/LoggerBase.h
@@ -17,14 +17,14 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_LOGGERBASE_H_
-#define MAD_COMMON_LOGGERBASE_H_
+#ifndef MAD_CORE_LOGGERBASE_H_
+#define MAD_CORE_LOGGERBASE_H_
#include <bitset>
#include <list>
namespace Mad {
-namespace Common {
+namespace Core {
class LoggerBase {
public:
@@ -76,4 +76,4 @@ class LoggerBase {
}
}
-#endif /* MAD_COMMON_LOGGERBASE_H_ */
+#endif /* MAD_CORE_LOGGERBASE_H_ */
diff --git a/src/Common/RemoteLogger.h b/src/Core/RemoteLogger.h
index 579a54b..f5c8a6b 100644
--- a/src/Common/RemoteLogger.h
+++ b/src/Core/RemoteLogger.h
@@ -17,15 +17,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_REMOTELOGGER_H_
-#define MAD_COMMON_REMOTELOGGER_H_
+#ifndef MAD_CORE_REMOTELOGGER_H_
+#define MAD_CORE_REMOTELOGGER_H_
#include "LoggerBase.h"
#include <string>
namespace Mad {
-namespace Common {
+namespace Core {
class LogManager;
@@ -39,4 +39,4 @@ class RemoteLogger : public LoggerBase {
}
}
-#endif /* MAD_COMMON_REMOTELOGGER_H_ */
+#endif /* MAD_CORE_REMOTELOGGER_H_ */
diff --git a/src/Net/Signals/Signals.h b/src/Core/Signals.h
index 4ee4f95..3c129af 100644
--- a/src/Net/Signals/Signals.h
+++ b/src/Core/Signals.h
@@ -17,11 +17,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_SIGNALS_SIGNALS_H_
-#define MAD_SIGNALS_SIGNALS_H_
+#ifndef MAD_CORE_SIGNALS_SIGNALS_H_
+#define MAD_CORE_SIGNALS_SIGNALS_H_
-#include "Signal0.h"
-#include "Signal1.h"
-#include "Signal2.h"
+#include "Signals/Signal0.h"
+#include "Signals/Signal1.h"
+#include "Signals/Signal2.h"
-#endif /* MAD_SIGNALS_SIGNALS_H_ */
+#endif /* MAD_CORE_SIGNALS_SIGNALS_H_ */
diff --git a/src/Net/Signals/Connection.h b/src/Core/Signals/Connection.h
index 7730e13..5ce7b4a 100644
--- a/src/Net/Signals/Connection.h
+++ b/src/Core/Signals/Connection.h
@@ -17,11 +17,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_NET_SIGNALS_CONNECTION_H_
-#define MAD_NET_SIGNALS_CONNECTION_H_
+#ifndef MAD_CORE_SIGNALS_CONNECTION_H_
+#define MAD_CORE_SIGNALS_CONNECTION_H_
namespace Mad {
-namespace Net {
+namespace Core {
namespace Signals {
class SignalBase;
@@ -50,4 +50,4 @@ class Connection {
}
}
-#endif /* MAD_NET_SIGNALS_CONNECTION_H_ */
+#endif /* MAD_CORE_SIGNALS_CONNECTION_H_ */
diff --git a/src/Net/Signals/GenericSignal.h b/src/Core/Signals/GenericSignal.h
index aa6cfa1..641f575 100644
--- a/src/Net/Signals/GenericSignal.h
+++ b/src/Core/Signals/GenericSignal.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_NET_SIGNALS_GENERICSIGNAL_H_
-#define MAD_NET_SIGNALS_GENERICSIGNAL_H_
+#ifndef MAD_CORE_SIGNALS_GENERICSIGNAL_H_
+#define MAD_CORE_SIGNALS_GENERICSIGNAL_H_
#include "SignalBase.h"
@@ -26,7 +26,7 @@
#include <boost/thread/locks.hpp>
namespace Mad {
-namespace Net {
+namespace Core {
namespace Signals {
template <typename FunctionType>
@@ -58,4 +58,4 @@ class GenericSignal : protected SignalBase {
}
}
-#endif /* MAD_NET_SIGNALS_GENERICSIGNAL_H_ */
+#endif /* MAD_CORE_SIGNALS_GENERICSIGNAL_H_ */
diff --git a/src/Net/Signals/Signal0.h b/src/Core/Signals/Signal0.h
index 5c0a691..ccfb548 100644
--- a/src/Net/Signals/Signal0.h
+++ b/src/Core/Signals/Signal0.h
@@ -17,16 +17,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_NET_SIGNALS_SIGNAL0_H_
-#define MAD_NET_SIGNALS_SIGNAL0_H_
+#ifndef MAD_CORE_SIGNALS_SIGNAL0_H_
+#define MAD_CORE_SIGNALS_SIGNAL0_H_
#include "GenericSignal.h"
-#include <Net/ThreadManager.h>
+#include "../ThreadManager.h"
#include <boost/function.hpp>
namespace Mad {
-namespace Net {
+namespace Core {
namespace Signals {
class Signal0 : public GenericSignal<boost::function0<void> > {
@@ -35,7 +35,7 @@ class Signal0 : public GenericSignal<boost::function0<void> > {
boost::lock_guard<boost::mutex> lock(mutex);
for(std::map<Connection, slot_type>::iterator handler = handlers.begin(); handler != handlers.end(); ++handler)
- Net::ThreadManager::get()->pushWork(handler->second);
+ ThreadManager::get()->pushWork(handler->second);
}
};
@@ -43,4 +43,4 @@ class Signal0 : public GenericSignal<boost::function0<void> > {
}
}
-#endif /* MAD_NET_SIGNALS_SIGNAL0_H_ */
+#endif /* MAD_CORE_SIGNALS_SIGNAL0_H_ */
diff --git a/src/Net/Signals/Signal1.h b/src/Core/Signals/Signal1.h
index 331c5cb..e4a946c 100644
--- a/src/Net/Signals/Signal1.h
+++ b/src/Core/Signals/Signal1.h
@@ -17,16 +17,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_NET_SIGNALS_SIGNAL1_H_
-#define MAD_NET_SIGNALS_SIGNAL1_H_
+#ifndef MAD_CORE_SIGNALS_SIGNAL1_H_
+#define MAD_CORE_SIGNALS_SIGNAL1_H_
#include "GenericSignal.h"
-#include <Net/ThreadManager.h>
+#include "../ThreadManager.h"
#include <boost/function.hpp>
namespace Mad {
-namespace Net {
+namespace Core {
namespace Signals {
template <typename T1>
@@ -36,7 +36,7 @@ class Signal1 : public GenericSignal<boost::function1<void, T1> > {
boost::lock_guard<boost::mutex> lock(this->mutex);
for(typename std::map<Connection, typename GenericSignal<boost::function1<void, T1> >::slot_type>::iterator handler = this->handlers.begin(); handler != this->handlers.end(); ++handler)
- Net::ThreadManager::get()->pushWork(boost::bind(handler->second, arg1));
+ ThreadManager::get()->pushWork(boost::bind(handler->second, arg1));
}
};
@@ -44,4 +44,4 @@ class Signal1 : public GenericSignal<boost::function1<void, T1> > {
}
}
-#endif /* MAD_NET_SIGNALS_SIGNAL1_H_ */
+#endif /* MAD_CORE_SIGNALS_SIGNAL1_H_ */
diff --git a/src/Net/Signals/Signal2.h b/src/Core/Signals/Signal2.h
index 3fb9315..41045d7 100644
--- a/src/Net/Signals/Signal2.h
+++ b/src/Core/Signals/Signal2.h
@@ -17,16 +17,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_NET_SIGNALS_SIGNAL2_H_
-#define MAD_NET_SIGNALS_SIGNAL2_H_
+#ifndef MAD_CORE_SIGNALS_SIGNAL2_H_
+#define MAD_CORE_SIGNALS_SIGNAL2_H_
#include "GenericSignal.h"
-#include <Net/ThreadManager.h>
+#include "../ThreadManager.h"
#include <boost/function.hpp>
namespace Mad {
-namespace Net {
+namespace Core {
namespace Signals {
template <typename T1, typename T2>
@@ -36,7 +36,7 @@ class Signal2 : public GenericSignal<boost::function2<void, T1, T2> > {
boost::lock_guard<boost::mutex> lock(this->mutex);
for(typename std::map<Connection, typename GenericSignal<boost::function2<void, T1, T2> >::slot_type>::iterator handler = this->handlers.begin(); handler != this->handlers.end(); ++handler)
- Net::ThreadManager::get()->pushWork(boost::bind(handler->second, arg1, arg2));
+ ThreadManager::get()->pushWork(boost::bind(handler->second, arg1, arg2));
}
};
@@ -44,4 +44,4 @@ class Signal2 : public GenericSignal<boost::function2<void, T1, T2> > {
}
}
-#endif /* MAD_NET_SIGNALS_SIGNAL2_H_ */
+#endif /* MAD_CORE_SIGNALS_SIGNAL2_H_ */
diff --git a/src/Net/Signals/SignalBase.h b/src/Core/Signals/SignalBase.h
index ea1b1e9..1a5d5a3 100644
--- a/src/Net/Signals/SignalBase.h
+++ b/src/Core/Signals/SignalBase.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_SIGNALS_SIGNALBASE_H_
-#define MAD_SIGNALS_SIGNALBASE_H_
+#ifndef MAD_CORE_SIGNALS_SIGNALBASE_H_
+#define MAD_CORE_SIGNALS_SIGNALBASE_H_
#include "Connection.h"
@@ -26,7 +26,7 @@
#include <boost/thread/mutex.hpp>
namespace Mad {
-namespace Net {
+namespace Core {
namespace Signals {
class SignalBase : private boost::noncopyable {
@@ -50,4 +50,4 @@ class SignalBase : private boost::noncopyable {
}
}
-#endif /* MAD_SIGNALS_SIGNALBASE_H_ */
+#endif /* MAD_CORE_SIGNALS_SIGNALBASE_H_ */
diff --git a/src/Net/ThreadManager.cpp b/src/Core/ThreadManager.cpp
index 377e6e1..abc0bc6 100644
--- a/src/Net/ThreadManager.cpp
+++ b/src/Core/ThreadManager.cpp
@@ -18,17 +18,14 @@
*/
#include "ThreadManager.h"
-#include "Connection.h"
-#include <Common/Logger.h>
-#include <Common/LogManager.h>
+#include "Logger.h"
+#include "LogManager.h"
#include <boost/bind.hpp>
-#include <fcntl.h>
-
namespace Mad {
-namespace Net {
+namespace Core {
ThreadManager ThreadManager::threadManager;
@@ -64,7 +61,7 @@ void ThreadManager::workerFunc() {
void ThreadManager::detach() {
if(isThisMainThread()) {
- Common::Logger::log(Common::Logger::CRITICAL, "Tried to detach main thread! This is just WRONG!");
+ Logger::log(Logger::CRITICAL, "Tried to detach main thread! This is just WRONG!");
return;
}
@@ -99,12 +96,12 @@ void ThreadManager::doInit() {
threadLock.lock();
- ioWorker.reset(new boost::asio::io_service::work(Connection::ioService));
+ ioWorker.reset(new boost::asio::io_service::work(ioService));
mainThreadId = boost::this_thread::get_id();
workerThread.reset(new boost::thread(&ThreadManager::workerFunc, this));
- loggerThread.reset(new boost::thread(&Common::LogManager::loggerThread, Common::LogManager::get()));
- ioThread.reset(new boost::thread((std::size_t(boost::asio::io_service::*)())&boost::asio::io_service::run, &Connection::ioService));
+ loggerThread.reset(new boost::thread(&LogManager::loggerThread, LogManager::get()));
+ ioThread.reset(new boost::thread((std::size_t(boost::asio::io_service::*)())&boost::asio::io_service::run, &ioService));
threadLock.unlock();
}
@@ -134,11 +131,11 @@ void ThreadManager::doDeinit() {
// IO thread is next
ioWorker.reset();
- Connection::ioService.stop();
+ ioService.stop();
ioThread->join();
// Finally, the logger thread has to die
- Common::LogManager::get()->stopLoggerThread();
+ LogManager::get()->stopLoggerThread();
loggerThread->join();
}
diff --git a/src/Net/ThreadManager.h b/src/Core/ThreadManager.h
index b8c4bec..b512ad4 100644
--- a/src/Net/ThreadManager.h
+++ b/src/Core/ThreadManager.h
@@ -17,12 +17,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_NET_THREADMANAGER_H_
-#define MAD_NET_THREADMANAGER_H_
+#ifndef MAD_CORE_THREADMANAGER_H_
+#define MAD_CORE_THREADMANAGER_H_
#include <config.h>
-#include <Common/Initializable.h>
+#include "Initializable.h"
#include <queue>
#include <map>
@@ -34,9 +34,9 @@
#include <boost/thread/locks.hpp>
namespace Mad {
-namespace Net {
+namespace Core {
-class ThreadManager : public Common::Initializable {
+class ThreadManager : public Initializable {
private:
boost::thread::id mainThreadId;
boost::shared_ptr<boost::thread> workerThread, loggerThread, ioThread;
@@ -53,6 +53,8 @@ class ThreadManager : public Common::Initializable {
boost::scoped_ptr<boost::asio::io_service::work> ioWorker;
+ boost::asio::io_service ioService;
+
static ThreadManager threadManager;
ThreadManager() {}
@@ -92,6 +94,10 @@ class ThreadManager : public Common::Initializable {
return (workerThread->get_id() == boost::this_thread::get_id());
}
+ boost::asio::io_service& getIOService() {
+ return ioService;
+ }
+
void detach();
void pushWork(const boost::function0<void> &newWork);
@@ -104,4 +110,4 @@ class ThreadManager : public Common::Initializable {
}
}
-#endif /* MAD_NET_THREADMANAGER_H_ */
+#endif /* MAD_CORE_THREADMANAGER_H_ */
diff --git a/src/Common/Tokenizer.cpp b/src/Core/Tokenizer.cpp
index 8b01482..a812ed1 100644
--- a/src/Common/Tokenizer.cpp
+++ b/src/Core/Tokenizer.cpp
@@ -20,7 +20,7 @@
#include "Tokenizer.h"
namespace Mad {
-namespace Common {
+namespace Core {
const std::string Tokenizer::delimiters = " \t\n\"'\\";
diff --git a/src/Common/Tokenizer.h b/src/Core/Tokenizer.h
index 6b8436b..7b29fed 100644
--- a/src/Common/Tokenizer.h
+++ b/src/Core/Tokenizer.h
@@ -17,14 +17,14 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MAD_COMMON_TOKENIZER_H_
-#define MAD_COMMON_TOKENIZER_H_
+#ifndef MAD_CORE_TOKENIZER_H_
+#define MAD_CORE_TOKENIZER_H_
#include <string>
#include <vector>
namespace Mad {
-namespace Common {
+namespace Core {
class Tokenizer {
private:
@@ -41,4 +41,4 @@ class Tokenizer {
}
}
-#endif /* MAD_COMMON_TOKENIZER_H_ */
+#endif /* MAD_CORE_TOKENIZER_H_ */
diff --git a/src/Daemon/Backends/NetworkLogger.h b/src/Daemon/Backends/NetworkLogger.h
index 10f5d25..c0b123a 100644
--- a/src/Daemon/Backends/NetworkLogger.h
+++ b/src/Daemon/Backends/NetworkLogger.h
@@ -20,7 +20,7 @@
#ifndef MAD_DAEMON_BACKENDS_NETWORKLOGGER_H_
#define MAD_DAEMON_BACKENDS_NETWORKLOGGER_H_
-#include <Common/Logger.h>
+#include <Core/Logger.h>
#include <Common/RequestManager.h>
#include <Daemon/Requests/LogRequest.h>
@@ -28,12 +28,12 @@ namespace Mad {
namespace Daemon {
namespace Backends {
-class NetworkLogger : public Common::Logger {
+class NetworkLogger : public Core::Logger {
private:
Common::Connection *connection;
protected:
- virtual void logMessage(Common::Logger::MessageCategory category, Common::Logger::MessageLevel level, time_t messageTimestamp, const std::string &message) {
+ virtual void logMessage(Core::Logger::MessageCategory category, Core::Logger::MessageLevel level, time_t messageTimestamp, const std::string &message) {
boost::shared_ptr<Requests::LogRequest> request(new Requests::LogRequest(category, level, messageTimestamp, message));
Common::RequestManager::get()->sendRequest(connection, request);
}
diff --git a/src/Daemon/Requests/LogRequest.h b/src/Daemon/Requests/LogRequest.h
index bf675e3..6ee3b3d 100644
--- a/src/Daemon/Requests/LogRequest.h
+++ b/src/Daemon/Requests/LogRequest.h
@@ -21,7 +21,7 @@
#define MAD_DAEMON_REQUESTS_LOGREQUEST_H_
#include <Common/Request.h>
-#include <Common/Logger.h>
+#include <Core/Logger.h>
#include <ctime>
namespace Mad {
@@ -30,8 +30,8 @@ namespace Requests {
class LogRequest : public Common::Request {
private:
- Common::Logger::MessageCategory category;
- Common::Logger::MessageLevel level;
+ Core::Logger::MessageCategory category;
+ Core::Logger::MessageLevel level;
time_t messageTimestamp;
std::string message;
@@ -39,7 +39,7 @@ class LogRequest : public Common::Request {
virtual void sendRequest();
public:
- LogRequest(Common::Logger::MessageCategory category0, Common::Logger::MessageLevel level0, time_t messageTimestamp0, const std::string &message0)
+ LogRequest(Core::Logger::MessageCategory category0, Core::Logger::MessageLevel level0, time_t messageTimestamp0, const std::string &message0)
: category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0) {}
};
diff --git a/src/Net/CMakeLists.txt b/src/Net/CMakeLists.txt
index 6bf700e..298aebe 100644
--- a/src/Net/CMakeLists.txt
+++ b/src/Net/CMakeLists.txt
@@ -1,20 +1,9 @@
include_directories(${INCLUDES})
-link_directories(${Boost_LIBRARY_DIRS})
add_library(Net
- Signals/Connection.h
- Signals/GenericSignal.h
- Signals/Signal0.h
- Signals/Signal1.h
- Signals/Signal2.h
- Signals/SignalBase.h
- Signals/Signals.h
-
ClientConnection.cpp ClientConnection.h
Connection.cpp Connection.h
- Exception.cpp Exception.h
Listener.cpp Listener.h
Packet.cpp Packet.h
- ThreadManager.cpp ThreadManager.h
)
-target_link_libraries(Net ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES})
+target_link_libraries(Net Core ${OPENSSL_LIBRARIES})
diff --git a/src/Net/ClientConnection.cpp b/src/Net/ClientConnection.cpp
index 07a9121..9196d89 100644
--- a/src/Net/ClientConnection.cpp
+++ b/src/Net/ClientConnection.cpp
@@ -19,8 +19,6 @@
#include "ClientConnection.h"
-#include <Common/Logger.h>
-
namespace Mad {
namespace Net {
@@ -36,7 +34,7 @@ void ClientConnection::handleConnect(const boost::system::error_code& error) {
socket.async_handshake(boost::asio::ssl::stream_base::client, boost::bind(&ClientConnection::handleHandshake, this, boost::asio::placeholders::error));
}
-void ClientConnection::connect(const boost::asio::ip::tcp::endpoint &address) throw(Exception) {
+void ClientConnection::connect(const boost::asio::ip::tcp::endpoint &address) throw(Core::Exception) {
boost::lock_guard<boost::shared_mutex> lock(connectionLock);
if(_isConnected()) {
diff --git a/src/Net/ClientConnection.h b/src/Net/ClientConnection.h
index f93c2fc..dcb6906 100644
--- a/src/Net/ClientConnection.h
+++ b/src/Net/ClientConnection.h
@@ -21,7 +21,7 @@
#define MAD_NET_CLIENTCONNECTION_H_
#include "Connection.h"
-#include "Exception.h"
+#include <Core/Exception.h>
#include <boost/utility/base_from_member.hpp>
@@ -37,13 +37,13 @@ class ClientConnection : private boost::base_from_member<boost::asio::ssl::conte
public:
ClientConnection()
- : boost::base_from_member<boost::asio::ssl::context>(boost::ref(Connection::ioService), boost::asio::ssl::context::sslv23),
+ : boost::base_from_member<boost::asio::ssl::context>(boost::ref(Core::ThreadManager::get()->getIOService()), boost::asio::ssl::context::sslv23),
Connection(member)
{
member.set_verify_mode(boost::asio::ssl::context::verify_none);
}
- void connect(const boost::asio::ip::tcp::endpoint &address) throw(Exception);
+ void connect(const boost::asio::ip::tcp::endpoint &address) throw(Core::Exception);
};
}
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index d9ff994..81f4c64 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -19,7 +19,7 @@
#include "Connection.h"
-#include <Common/Logger.h>
+#include <Core/Logger.h>
#include <cstring>
#include <boost/bind.hpp>
@@ -27,8 +27,6 @@
namespace Mad {
namespace Net {
-boost::asio::io_service Connection::ioService;
-
Connection::~Connection() {
if(_isConnected())
@@ -37,7 +35,7 @@ Connection::~Connection() {
void Connection::handleHandshake(const boost::system::error_code& error) {
if(error) {
- Common::Logger::logf("Error: %s", error.message().c_str());
+ Core::Logger::logf("Error: %s", error.message().c_str());
// TODO Error handling
doDisconnect();
@@ -63,7 +61,7 @@ void Connection::handleShutdown(const boost::system::error_code& error) {
boost::lock_guard<boost::shared_mutex> lock(connectionLock);
if(error) {
- Common::Logger::logf(Common::Logger::VERBOSE, "Shutdown error: %s", error.message().c_str());
+ Core::Logger::logf(Core::Logger::VERBOSE, "Shutdown error: %s", error.message().c_str());
}
_setState(DISCONNECTED);
@@ -112,7 +110,7 @@ void Connection::handleDataReceive(const std::vector<boost::uint8_t> &data) {
void Connection::handleRead(const boost::system::error_code& error, std::size_t bytes_transferred, std::size_t length, const boost::function1<void, const std::vector<boost::uint8_t>& > &notify) {
if(error || (bytes_transferred+received) < length) {
- Common::Logger::logf(Common::Logger::VERBOSE, "Read error: %s", error.message().c_str());
+ Core::Logger::logf(Core::Logger::VERBOSE, "Read error: %s", error.message().c_str());
// TODO Error
doDisconnect();
@@ -185,7 +183,7 @@ void Connection::handleWrite(const boost::system::error_code& error, std::size_t
}
if(error) {
- Common::Logger::logf(Common::Logger::VERBOSE, "Write error: %s", error.message().c_str());
+ Core::Logger::logf(Core::Logger::VERBOSE, "Write error: %s", error.message().c_str());
// TODO Error
doDisconnect();
diff --git a/src/Net/Connection.h b/src/Net/Connection.h
index e1ca63b..6323164 100644
--- a/src/Net/Connection.h
+++ b/src/Net/Connection.h
@@ -23,7 +23,8 @@
#include <config.h>
#include "Packet.h"
-#include "Signals/Signals.h"
+#include <Core/Signals.h>
+#include <Core/ThreadManager.h>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
@@ -70,9 +71,9 @@ class Connection : boost::noncopyable {
Packet::Data header;
- Signals::Signal1<boost::shared_ptr<Packet> > receiveSignal;
- Signals::Signal0 connectedSignal;
- Signals::Signal0 disconnectedSignal;
+ Core::Signals::Signal1<boost::shared_ptr<Packet> > receiveSignal;
+ Core::Signals::Signal0 connectedSignal;
+ Core::Signals::Signal0 disconnectedSignal;
bool receiving;
unsigned long sending;
@@ -91,8 +92,6 @@ class Connection : boost::noncopyable {
void rawSend(const uint8_t *data, std::size_t length);
protected:
- static boost::asio::io_service ioService;
-
boost::shared_mutex connectionLock;
boost::asio::ssl::stream<boost::asio::ip::tcp::socket> socket;
@@ -117,7 +116,7 @@ class Connection : boost::noncopyable {
void doDisconnect();
Connection(boost::asio::ssl::context &sslContext) :
- state(DISCONNECTED), receiveBuffer(1024*1024), socket(ioService, sslContext) {}
+ state(DISCONNECTED), receiveBuffer(1024*1024), socket(Core::ThreadManager::get()->getIOService(), sslContext) {}
public:
virtual ~Connection();
@@ -171,24 +170,24 @@ class Connection : boost::noncopyable {
bool send(const Packet &packet);
- Signals::Connection connectSignalReceive(const Signals::Signal1<boost::shared_ptr<Packet> >::slot_type &slot) {
+ Core::Signals::Connection connectSignalReceive(const Core::Signals::Signal1<boost::shared_ptr<Packet> >::slot_type &slot) {
return receiveSignal.connect(slot);
}
- void disconnectSignalReceive(const Signals::Connection &connection) {
+ void disconnectSignalReceive(const Core::Signals::Connection &connection) {
receiveSignal.disconnect(connection);
}
- Signals::Connection connectSignalConnected(const Signals::Signal0::slot_type &slot) {
+ Core::Signals::Connection connectSignalConnected(const Core::Signals::Signal0::slot_type &slot) {
return connectedSignal.connect(slot);
}
- void disconnectSignalConnected(const Signals::Connection &connection) {
+ void disconnectSignalConnected(const Core::Signals::Connection &connection) {
connectedSignal.disconnect(connection);
}
- Signals::Connection connectSignalDisconnected(const Signals::Signal0::slot_type &slot) {
+ Core::Signals::Connection connectSignalDisconnected(const Core::Signals::Signal0::slot_type &slot) {
return disconnectedSignal.connect(slot);
}
- void disconnectSignalDisconnected(const Signals::Connection &connection) {
+ void disconnectSignalDisconnected(const Core::Signals::Connection &connection) {
disconnectedSignal.disconnect(connection);
}
};
diff --git a/src/Net/Listener.cpp b/src/Net/Listener.cpp
index 6da2762..780e862 100644
--- a/src/Net/Listener.cpp
+++ b/src/Net/Listener.cpp
@@ -19,7 +19,8 @@
#include "Listener.h"
-#include <Common/Logger.h>
+#include <Core/Logger.h>
+#include <Core/ThreadManager.h>
#include <cerrno>
#include <cstring>
@@ -39,8 +40,8 @@ void Listener::handleAccept(const boost::system::error_code &error, boost::share
con->_setState(Connection::CONNECT);
- Signals::Connection con1 = con->connectSignalConnected(boost::bind(&Listener::handleConnect, this, con));
- Signals::Connection con2 = con->connectSignalDisconnected(boost::bind(&Listener::handleDisconnect, this, con));
+ Core::Signals::Connection con1 = con->connectSignalConnected(boost::bind(&Listener::handleConnect, this, con));
+ Core::Signals::Connection con2 = con->connectSignalDisconnected(boost::bind(&Listener::handleDisconnect, this, con));
connections.insert(std::make_pair(con, std::make_pair(con1, con2)));
@@ -54,7 +55,7 @@ void Listener::handleAccept(const boost::system::error_code &error, boost::share
void Listener::handleConnect(boost::shared_ptr<Connection> con) {
{
boost::lock_guard<boost::mutex> lock(mutex);
- std::map<boost::shared_ptr<Connection>, std::pair<Signals::Connection, Signals::Connection> >::iterator it = connections.find(con);
+ std::map<boost::shared_ptr<Connection>, std::pair<Core::Signals::Connection, Core::Signals::Connection> >::iterator it = connections.find(con);
if(it == connections.end())
return;
@@ -76,9 +77,9 @@ void Listener::handleDisconnect(boost::shared_ptr<Connection> con) {
Listener::Listener(const std::string &x905CertFile0, const std::string &x905KeyFile0,
- const boost::asio::ip::tcp::endpoint &address0) throw(Exception)
-: x905CertFile(x905CertFile0), x905KeyFile(x905KeyFile0), address(address0), acceptor(Connection::ioService, address),
-sslContext(Connection::ioService, boost::asio::ssl::context::sslv23)
+ const boost::asio::ip::tcp::endpoint &address0) throw(Core::Exception)
+: x905CertFile(x905CertFile0), x905KeyFile(x905KeyFile0), address(address0), acceptor(Core::ThreadManager::get()->getIOService(), address),
+sslContext(Core::ThreadManager::get()->getIOService(), boost::asio::ssl::context::sslv23)
{
sslContext.set_options(boost::asio::ssl::context::default_workarounds
| boost::asio::ssl::context::no_sslv2
@@ -93,9 +94,10 @@ sslContext(Connection::ioService, boost::asio::ssl::context::sslv23)
}
Listener::~Listener() {
- for(std::map<boost::shared_ptr<Connection>,std::pair<Signals::Connection, Signals::Connection> >::iterator con = connections.begin(); con != connections.end(); ++con) {
+ for(std::map<boost::shared_ptr<Connection>,std::pair<Core::Signals::Connection, Core::Signals::Connection> >::iterator con = connections.begin(); con != connections.end(); ++con) {
con->first->disconnect();
- // TODO wait...
+ con->first->waitWhileConnected();
+ // TODO Optimize
}
}
diff --git a/src/Net/Listener.h b/src/Net/Listener.h
index 2e25051..af0888b 100644
--- a/src/Net/Listener.h
+++ b/src/Net/Listener.h
@@ -24,7 +24,7 @@
#include <string>
#include "Connection.h"
-#include "Exception.h"
+#include <Core/Exception.h>
namespace Mad {
namespace Net {
@@ -38,9 +38,9 @@ class Listener : boost::noncopyable {
boost::asio::ip::tcp::acceptor acceptor;
boost::asio::ssl::context sslContext;
- std::map<boost::shared_ptr<Connection>, std::pair<Signals::Connection, Signals::Connection> > connections;
+ std::map<boost::shared_ptr<Connection>, std::pair<Core::Signals::Connection, Core::Signals::Connection> > connections;
- Signals::Signal1<boost::shared_ptr<Connection> > signal;
+ Core::Signals::Signal1<boost::shared_ptr<Connection> > signal;
void handleAccept(const boost::system::error_code &error, boost::shared_ptr<Connection> con);
@@ -49,13 +49,13 @@ class Listener : boost::noncopyable {
public:
Listener(const std::string &x905CertFile0, const std::string &x905KeyFile0,
- const boost::asio::ip::tcp::endpoint &address0 = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 6666)) throw(Exception);
+ const boost::asio::ip::tcp::endpoint &address0 = boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 6666)) throw(Core::Exception);
virtual ~Listener();
- Signals::Connection connectSignalNewConnection(const Signals::Signal1<boost::shared_ptr<Connection> >::slot_type &slot) {
+ Core::Signals::Connection connectSignalNewConnection(const Core::Signals::Signal1<boost::shared_ptr<Connection> >::slot_type &slot) {
return signal.connect(slot);
}
- void disconnectSignalNewConnection(const Signals::Connection &connection) {
+ void disconnectSignalNewConnection(const Core::Signals::Connection &connection) {
signal.disconnect(connection);
}
};
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp
index f568f74..a15a516 100644
--- a/src/Server/ConnectionManager.cpp
+++ b/src/Server/ConnectionManager.cpp
@@ -18,16 +18,13 @@
*/
#include "ConnectionManager.h"
-#include <Common/ConfigEntry.h>
-#include <Common/ConfigManager.h>
-#include <Common/Logger.h>
+#include <Core/ConfigEntry.h>
+#include <Core/ConfigManager.h>
+#include <Core/Logger.h>
#include <Common/RequestHandlers/FSInfoRequestHandler.h>
#include <Common/RequestHandlers/StatusRequestHandler.h>
#include "Requests/DaemonStateUpdateRequest.h"
-//#include "RequestHandlers/DaemonCommandRequestHandler.h"
-//#include "RequestHandlers/DaemonFSInfoRequestHandler.h"
#include "RequestHandlers/DaemonListRequestHandler.h"
-//#include "RequestHandlers/DaemonStatusRequestHandler.h"
//#include "RequestHandlers/GSSAPIAuthRequestHandler.h"
#include "RequestHandlers/IdentifyRequestHandler.h"
#include "RequestHandlers/LogRequestHandler.h"
@@ -89,7 +86,7 @@ void ConnectionManager::updateState(Common::HostInfo *hostInfo, Common::HostInfo
}
}
-bool ConnectionManager::handleConfigEntry(const Common::ConfigEntry &entry, bool handled) {
+bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
if(handled)
return false;
@@ -97,7 +94,7 @@ bool ConnectionManager::handleConfigEntry(const Common::ConfigEntry &entry, bool
try {
listenerAddresses.push_back(boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(entry[0][0]), 6666));
}
- catch(Net::Exception &e) {
+ catch(Core::Exception &e) {
// TODO Log error
}
@@ -148,7 +145,7 @@ void ConnectionManager::configFinished() {
listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1));
listeners.push_back(listener);
}
- catch(Net::Exception &e) {
+ catch(Core::Exception &e) {
// TODO Log error
}
}
@@ -159,7 +156,7 @@ void ConnectionManager::configFinished() {
listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1));
listeners.push_back(listener);
}
- catch(Net::Exception &e) {
+ catch(Core::Exception &e) {
// TODO Log error
}
}
@@ -220,14 +217,14 @@ void ConnectionManager::doDeinit() {
Common::RequestManager::get()->unregisterPacketType("Log");
}
-boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(const std::string &name) const throw (Net::Exception&) {
+boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(const std::string &name) const throw (Core::Exception&) {
const Common::HostInfo *hostInfo;
try {
hostInfo = &daemonInfo.at(name);
}
catch(std::out_of_range&) {
- throw Net::Exception(Net::Exception::UNKNOWN_DAEMON);
+ throw Core::Exception(Core::Exception::UNKNOWN_DAEMON);
}
if(hostInfo->getState() != Common::HostInfo::INACTIVE) {
@@ -238,56 +235,56 @@ boost::shared_ptr<Common::Connection> ConnectionManager::getDaemonConnection(con
}
}
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Net::Exception&) {
+std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Core::Exception&) {
const ServerConnection *connection = dynamic_cast<const ServerConnection*>(con);
if(connection && connection->getConnectionType() == ServerConnection::DAEMON)
return connection->getHostInfo()->getName();
- throw Net::Exception(Net::Exception::UNKNOWN_DAEMON);
+ throw Core::Exception(Core::Exception::UNKNOWN_DAEMON);
}
-void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Net::Exception&) {
+void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Core::Exception&) {
// TODO Logging
ServerConnection *connection = dynamic_cast<ServerConnection*>(con);
if(!connection)
- throw Net::Exception(Net::Exception::INVALID_ACTION);
+ throw Core::Exception(Core::Exception::INVALID_ACTION);
if(connection->isIdentified())
- throw Net::Exception(Net::Exception::ALREADY_IDENTIFIED);
+ throw Core::Exception(Core::Exception::ALREADY_IDENTIFIED);
if(daemonInfo.count(name) == 0)
- throw Net::Exception(Net::Exception::UNKNOWN_DAEMON);
+ throw Core::Exception(Core::Exception::UNKNOWN_DAEMON);
Common::HostInfo *hostInfo = &daemonInfo[name];
if(hostInfo->getState() != Common::HostInfo::INACTIVE) {
try {
getDaemonConnection(name)->disconnect();
- Common::Logger::log(Common::Logger::WARNING, "Disconnecting old connection.");
+ Core::Logger::log(Core::Logger::WARNING, "Disconnecting old connection.");
}
- catch(Net::Exception&) {}
+ catch(Core::Exception&) {}
}
connection->identify(hostInfo);
updateState(hostInfo, Common::HostInfo::RUNNING);
- Common::Logger::logf("Identified as '%s'.", name.c_str());
+ Core::Logger::logf("Identified as '%s'.", name.c_str());
}
-void ConnectionManager::identifyClientConnection(Common::Connection *con) throw (Net::Exception&) {
+void ConnectionManager::identifyClientConnection(Common::Connection *con) throw (Core::Exception&) {
ServerConnection *connection = dynamic_cast<ServerConnection*>(con);
if(!connection)
- throw Net::Exception(Net::Exception::INVALID_ACTION);
+ throw Core::Exception(Core::Exception::INVALID_ACTION);
if(connection->isIdentified())
- throw Net::Exception(Net::Exception::ALREADY_IDENTIFIED);
+ throw Core::Exception(Core::Exception::ALREADY_IDENTIFIED);
connection->identify();
}
diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h
index 6573883..4cc12a5 100644
--- a/src/Server/ConnectionManager.h
+++ b/src/Server/ConnectionManager.h
@@ -20,9 +20,9 @@
#ifndef MAD_SERVER_CONNECTIONMANAGER_H_
#define MAD_SERVER_CONNECTIONMANAGER_H_
-#include <Common/Configurable.h>
+#include <Core/Configurable.h>
+#include <Core/Initializable.h>
#include <Common/HostInfo.h>
-#include <Common/Initializable.h>
#include <Common/RequestManager.h>
#include <list>
@@ -42,7 +42,7 @@ class Packet;
namespace Server {
-class ConnectionManager : public Common::Configurable, public Common::Initializable, boost::noncopyable {
+class ConnectionManager : public Core::Configurable, public Core::Initializable, boost::noncopyable {
private:
class ServerConnection : public Common::Connection {
public:
@@ -111,7 +111,7 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa
void handleDisconnect(boost::shared_ptr<ServerConnection> con);
protected:
- virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool handled);
+ virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
virtual void configFinished();
virtual void doInit();
@@ -122,11 +122,11 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa
return &connectionManager;
}
- boost::shared_ptr<Common::Connection> getDaemonConnection(const std::string &name) const throw (Net::Exception&);
- std::string getDaemonName(const Common::Connection *con) const throw (Net::Exception&);
+ boost::shared_ptr<Common::Connection> getDaemonConnection(const std::string &name) const throw (Core::Exception&);
+ std::string getDaemonName(const Common::Connection *con) const throw (Core::Exception&);
- void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Net::Exception&);
- void identifyClientConnection(Common::Connection *con) throw (Net::Exception&);
+ void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Core::Exception&);
+ void identifyClientConnection(Common::Connection *con) throw (Core::Exception&);
std::vector<Common::HostInfo> getDaemonList() const;
};
diff --git a/src/Server/RequestHandlers/DaemonListRequestHandler.cpp b/src/Server/RequestHandlers/DaemonListRequestHandler.cpp
index 6c17ce1..fc6900c 100644
--- a/src/Server/RequestHandlers/DaemonListRequestHandler.cpp
+++ b/src/Server/RequestHandlers/DaemonListRequestHandler.cpp
@@ -19,7 +19,6 @@
#include "DaemonListRequestHandler.h"
#include "../ConnectionManager.h"
-#include <Common/Logger.h>
namespace Mad {
namespace Server {
diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
index 4ff8c40..0e21fdd 100644
--- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.cpp
@@ -21,7 +21,7 @@
#include "../ConnectionManager.h"
#include "../Requests/CommandRequest.h"
-#include <Common/Logger.h>
+#include <Core/Logger.h>
#include <Common/Requests/FSInfoRequest.h>
#include <Common/Requests/StatusRequest.h>
@@ -31,11 +31,11 @@ namespace RequestHandlers {
void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared_ptr<const Common::XmlPacket> packet) {
if(packet->getType() != type) {
- Common::Logger::log(Common::Logger::ERROR, "Received an unexpected packet.");
+ Core::Logger::log(Core::Logger::ERROR, "Received an unexpected packet.");
Common::XmlPacket ret;
ret.setType("Error");
- ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET);
+ ret.add("ErrorCode", Core::Exception::UNEXPECTED_PACKET);
sendPacket(ret);
@@ -59,7 +59,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared
request->connectSignalFinished(boost::bind(&DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished, this, _1, _2));
Common::RequestManager::get()->sendRequest(daemonCon.get(), request);
}
- catch(Net::Exception &e) {
+ catch(Core::Exception &e) {
Common::XmlPacket ret;
ret.setType("Error");
ret.add("ErrorCode", e.getErrorCode());
@@ -72,7 +72,7 @@ void DaemonRequestHandlerGroup::DaemonRequestHandler::handlePacket(boost::shared
}
}
-void DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Net::Exception error) {
+void DaemonRequestHandlerGroup::DaemonRequestHandler::requestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Core::Exception error) {
if(error) {
Common::XmlPacket ret;
ret.setType("Error");
diff --git a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h
index 7c0b127..7a709f4 100644
--- a/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h
+++ b/src/Server/RequestHandlers/DaemonRequestHandlerGroup.h
@@ -21,7 +21,7 @@
#define MAD_SERVER_REQUESTHANDLERS_DAEMONREQUESTHANDLERGROUP_H_
#include <Common/RequestHandlerGroup.h>
-#include <Net/Exception.h>
+#include <Core/Exception.h>
namespace Mad {
namespace Server {
@@ -33,7 +33,7 @@ class DaemonRequestHandlerGroup : public Common::RequestHandlerGroup {
private:
std::string type;
- void requestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Net::Exception error);
+ void requestFinished(boost::shared_ptr<const Common::XmlPacket> packet, Core::Exception error);
protected:
virtual void handlePacket(boost::shared_ptr<const Common::XmlPacket> packet);
diff --git a/src/Server/RequestHandlers/IdentifyRequestHandler.cpp b/src/Server/RequestHandlers/IdentifyRequestHandler.cpp
index abee878..e48563b 100644
--- a/src/Server/RequestHandlers/IdentifyRequestHandler.cpp
+++ b/src/Server/RequestHandlers/IdentifyRequestHandler.cpp
@@ -19,7 +19,6 @@
#include "IdentifyRequestHandler.h"
#include "../ConnectionManager.h"
-#include <Common/Logger.h>
namespace Mad {
diff --git a/src/Server/RequestHandlers/LogRequestHandler.cpp b/src/Server/RequestHandlers/LogRequestHandler.cpp
index 1e3f5b4..f33aad4 100644
--- a/src/Server/RequestHandlers/LogRequestHandler.cpp
+++ b/src/Server/RequestHandlers/LogRequestHandler.cpp
@@ -18,8 +18,7 @@
*/
#include "LogRequestHandler.h"
-#include <Common/Logger.h>
-#include <Common/LogManager.h>
+#include <Core/LogManager.h>
#include "../ConnectionManager.h"
namespace Mad {
@@ -30,11 +29,11 @@ void LogRequestHandler::handleRequest(boost::shared_ptr<const Common::XmlPacket>
// TODO Require authentication
try {
- Common::LogManager::get()->log((*packet)["category"], (*packet)["level"], (*packet)["timestamp"], (*packet)["message"],
+ Core::LogManager::get()->log((*packet)["category"], (*packet)["level"], (*packet)["timestamp"], (*packet)["message"],
ConnectionManager::get()->getDaemonName(getConnection()));
}
- catch(Net::Exception &e) {
- Common::Logger::logf(Common::Logger::ERROR, "Can't determine daemon name: %s", e.strerror().c_str());
+ catch(Core::Exception &e) {
+ Core::Logger::logf(Core::Logger::ERROR, "Can't determine daemon name: %s", e.strerror().c_str());
}
ret->setType("OK");
diff --git a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
index 1ff8883..7836c34 100644
--- a/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
+++ b/src/Server/RequestHandlers/UserRequestHandlerGroup.cpp
@@ -18,8 +18,6 @@
*/
#include "UserRequestHandlerGroup.h"
-
-#include <Common/Logger.h>
#include "../UserManager.h"
namespace Mad {
diff --git a/src/Server/UserBackend.h b/src/Server/UserBackend.h
index c2f340e..4688bc7 100644
--- a/src/Server/UserBackend.h
+++ b/src/Server/UserBackend.h
@@ -22,11 +22,11 @@
#include <config.h>
+#include <Core/Exception.h>
+
#include <Common/UserInfo.h>
#include <Common/GroupInfo.h>
-#include <Net/Exception.h>
-
#include <map>
#include <set>
#include <string>
@@ -45,45 +45,45 @@ class UserBackend {
UserBackend() {}
- virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual std::string getGroupName(unsigned long gid _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual std::string getGroupName(unsigned long gid _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual unsigned long getGroupId(const std::string &name _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual unsigned long getGroupId(const std::string &name _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual void setPassword(unsigned long uid _UNUSED_PARAMETER_, const std::string &password _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual void setPassword(unsigned long uid _UNUSED_PARAMETER_, const std::string &password _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
- virtual void addUser(const Common::UserInfo &userInfo _UNUSED_PARAMETER_) throw(Net::Exception) {
- throw(Net::Exception(Net::Exception::NOT_IMPLEMENTED));
+ virtual void addUser(const Common::UserInfo &userInfo _UNUSED_PARAMETER_) throw(Core::Exception) {
+ throw(Core::Exception(Core::Exception::NOT_IMPLEMENTED));
}
virtual int getPriority() const {
diff --git a/src/Server/UserManager.cpp b/src/Server/UserManager.cpp
index 5f30a6b..0c45b78 100644
--- a/src/Server/UserManager.cpp
+++ b/src/Server/UserManager.cpp
@@ -34,15 +34,15 @@ bool UserManager::Compare::operator() (boost::shared_ptr<UserBackend> b1, boost:
}
-boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserManager::getUserList() throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserManager::getUserList() throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->getUserList();
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -50,15 +50,15 @@ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserManager::getUs
throw e;
}
-boost::shared_ptr<Common::UserInfo> UserManager::getUserInfo(unsigned long uid) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+boost::shared_ptr<Common::UserInfo> UserManager::getUserInfo(unsigned long uid) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->getUserInfo(uid);
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -66,15 +66,15 @@ boost::shared_ptr<Common::UserInfo> UserManager::getUserInfo(unsigned long uid)
throw e;
}
-boost::shared_ptr<Common::UserInfo> UserManager::getUserInfoByName(const std::string &name) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+boost::shared_ptr<Common::UserInfo> UserManager::getUserInfoByName(const std::string &name) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->getUserInfoByName(name);
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -82,15 +82,15 @@ boost::shared_ptr<Common::UserInfo> UserManager::getUserInfoByName(const std::st
throw e;
}
-boost::shared_ptr<std::set<unsigned long> > UserManager::getUserGroupList(unsigned long uid) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+boost::shared_ptr<std::set<unsigned long> > UserManager::getUserGroupList(unsigned long uid) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->getUserGroupList(uid);
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -98,15 +98,15 @@ boost::shared_ptr<std::set<unsigned long> > UserManager::getUserGroupList(unsign
throw e;
}
-boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserManager::getGroupList() throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserManager::getGroupList() throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->getGroupList();
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -114,15 +114,15 @@ boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserManager::getG
throw e;
}
-std::string UserManager::getGroupName(unsigned long gid) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+std::string UserManager::getGroupName(unsigned long gid) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->getGroupName(gid);
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -130,15 +130,15 @@ std::string UserManager::getGroupName(unsigned long gid) throw(Net::Exception) {
throw e;
}
-unsigned long UserManager::getGroupId(const std::string &name) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+unsigned long UserManager::getGroupId(const std::string &name) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->getGroupId(name);
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -146,15 +146,15 @@ unsigned long UserManager::getGroupId(const std::string &name) throw(Net::Except
throw e;
}
-boost::shared_ptr<std::set<unsigned long> > UserManager::getGroupUserList(unsigned long gid) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+boost::shared_ptr<std::set<unsigned long> > UserManager::getGroupUserList(unsigned long gid) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->getGroupUserList(gid);
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -162,15 +162,15 @@ boost::shared_ptr<std::set<unsigned long> > UserManager::getGroupUserList(unsign
throw e;
}
-void UserManager::setPassword(unsigned long uid, const std::string &password) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+void UserManager::setPassword(unsigned long uid, const std::string &password) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->setPassword(uid, password);
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
@@ -178,15 +178,15 @@ void UserManager::setPassword(unsigned long uid, const std::string &password) th
throw e;
}
-void UserManager::addUser(const Common::UserInfo &userInfo) throw(Net::Exception) {
- Net::Exception e(Net::Exception::NOT_IMPLEMENTED);
+void UserManager::addUser(const Common::UserInfo &userInfo) throw(Core::Exception) {
+ Core::Exception e(Core::Exception::NOT_IMPLEMENTED);
for(std::set<boost::shared_ptr<UserBackend> >::iterator backend = backends.begin(); backend != backends.end(); ++backend) {
try {
return (*backend)->addUser(userInfo);
}
- catch(Net::Exception e2) {
- if(e.getErrorCode() == Net::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Net::Exception::NOT_IMPLEMENTED)
+ catch(Core::Exception e2) {
+ if(e.getErrorCode() == Core::Exception::NOT_IMPLEMENTED && e2.getErrorCode() != Core::Exception::NOT_IMPLEMENTED)
e = e2;
}
}
diff --git a/src/Server/UserManager.h b/src/Server/UserManager.h
index 47c7318..31f50d5 100644
--- a/src/Server/UserManager.h
+++ b/src/Server/UserManager.h
@@ -23,7 +23,7 @@
#include <Common/UserInfo.h>
#include <Common/GroupInfo.h>
-#include <Net/Exception.h>
+#include <Core/Exception.h>
#include <map>
#include <set>
@@ -57,19 +57,19 @@ class UserManager : boost::noncopyable {
backends.erase(backend);
}
- boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Net::Exception);
- boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid) throw(Net::Exception);
- boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name) throw(Net::Exception);
- boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Net::Exception);
+ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception);
+ boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception);
+ boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception);
+ boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Core::Exception);
- boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Net::Exception);
- std::string getGroupName(unsigned long gid) throw(Net::Exception);
- unsigned long getGroupId(const std::string &name) throw(Net::Exception);
- boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Net::Exception);
+ boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception);
+ std::string getGroupName(unsigned long gid) throw(Core::Exception);
+ unsigned long getGroupId(const std::string &name) throw(Core::Exception);
+ boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Core::Exception);
- void setPassword(unsigned long uid, const std::string &password) throw(Net::Exception);
+ void setPassword(unsigned long uid, const std::string &password) throw(Core::Exception);
- void addUser(const Common::UserInfo &userInfo) throw(Net::Exception);
+ void addUser(const Common::UserInfo &userInfo) throw(Core::Exception);
static UserManager *get() {
return &userManager;
diff --git a/src/mad-server.cpp b/src/mad-server.cpp
index d55c049..a00f33d 100644
--- a/src/mad-server.cpp
+++ b/src/mad-server.cpp
@@ -17,16 +17,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Common/ConfigManager.h"
+#include "Core/ConfigManager.h"
+#include "Core/ThreadManager.h"
#include "Common/ModuleManager.h"
-#include "Net/ThreadManager.h"
#include "Server/ConnectionManager.h"
using namespace Mad;
int main() {
- Net::ThreadManager::get()->init();
+ Core::ThreadManager::get()->init();
Server::ConnectionManager::get()->init();
Common::ModuleManager::get()->loadModule("FileLogger");
@@ -35,13 +35,13 @@ int main() {
Common::ModuleManager::get()->loadModule("UserBackendMysql");
- Common::ConfigManager::get()->loadFile("mad-server.conf");
- Common::ConfigManager::get()->finish();
+ Core::ConfigManager::get()->loadFile("mad-server.conf");
+ Core::ConfigManager::get()->finish();
while(true)
sleep(1000);
- Common::Initializable::deinit();
+ Core::Initializable::deinit();
return 0;
}
diff --git a/src/mad.cpp b/src/mad.cpp
index 42afc87..107f240 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -17,10 +17,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Net/ThreadManager.h"
-#include "Common/ConfigManager.h"
-#include "Common/LogManager.h"
-#include "Common/Logger.h"
+#include "Core/ThreadManager.h"
+#include "Core/ConfigManager.h"
+#include "Core/LogManager.h"
#include "Common/ModuleManager.h"
#include "Common/RequestManager.h"
#include "Common/ClientConnection.h"
@@ -36,13 +35,13 @@ using namespace Mad;
int main() {
- Net::ThreadManager::get()->init();
+ Core::ThreadManager::get()->init();
Common::ModuleManager::get()->loadModule("FileLogger");
Common::ModuleManager::get()->loadModule("SystemBackendPosix");
Common::ModuleManager::get()->loadModule("SystemBackendProc");
- Common::ConfigManager::get()->finish();
+ Core::ConfigManager::get()->finish();
Common::RequestManager::get()->registerPacketType<Daemon::RequestHandlers::CommandRequestHandler>("Command");
Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>("FSInfo");
@@ -58,8 +57,8 @@ int main() {
Common::RequestManager::get()->registerConnection(connection);
- Common::Logger *networkLogger = new Daemon::Backends::NetworkLogger(connection);
- Common::LogManager::get()->registerLogger(networkLogger);
+ Core::Logger *networkLogger = new Daemon::Backends::NetworkLogger(connection);
+ Core::LogManager::get()->registerLogger(networkLogger);
//char hostname[256];
@@ -71,16 +70,16 @@ int main() {
Common::RequestManager::get()->sendRequest(connection, request);
request->wait();
}
- Common::Logger::log("Identified.");
+ Core::Logger::log("Identified.");
connection->waitWhileConnected();
- Common::LogManager::get()->unregisterLogger(networkLogger);
+ Core::LogManager::get()->unregisterLogger(networkLogger);
Common::RequestManager::get()->unregisterConnection(connection);
}
- catch(Net::Exception &e) {
- Common::Logger::logf(Common::Logger::CRITICAL, "Connection error: %s", e.strerror().c_str());
+ catch(Core::Exception &e) {
+ Core::Logger::logf(Core::Logger::CRITICAL, "Connection error: %s", e.strerror().c_str());
}
delete connection;
@@ -89,7 +88,7 @@ int main() {
Common::RequestManager::get()->unregisterPacketType("FSInfo");
Common::RequestManager::get()->unregisterPacketType("GetStatus");
- Common::Initializable::deinit();
+ Core::Initializable::deinit();
return 0;
}
diff --git a/src/madc.cpp b/src/madc.cpp
index 64078c8..ea32f2f 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -17,12 +17,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Net/ThreadManager.h"
+#include "Core/ConfigManager.h"
+#include "Core/Logger.h"
+#include "Core/ThreadManager.h"
+
#include "Common/ClientConnection.h"
-#include "Common/ConfigManager.h"
-#include "Common/Requests/IdentifyRequest.h"
-#include "Common/Logger.h"
#include "Common/RequestManager.h"
+#include "Common/Requests/IdentifyRequest.h"
#include "Client/CommandParser.h"
#include "Client/InformationManager.h"
@@ -47,10 +48,10 @@ int main(int argc, char *argv[]) {
std::exit(1);
}
- Net::ThreadManager::get()->init();
+ Core::ThreadManager::get()->init();
Client::InformationManager::get()->init();
- Common::ConfigManager::get()->finish();
+ Core::ConfigManager::get()->finish();
Common::ClientConnection *connection = new Common::ClientConnection;
@@ -96,13 +97,13 @@ int main(int argc, char *argv[]) {
Common::RequestManager::get()->unregisterConnection(connection);
}
- catch(Net::Exception &e) {
- Common::Logger::logf(Common::Logger::CRITICAL, "Connection error: %s", e.strerror().c_str());
+ catch(Core::Exception &e) {
+ Core::Logger::logf(Core::Logger::CRITICAL, "Connection error: %s", e.strerror().c_str());
}
delete connection;
- Common::Initializable::deinit();
+ Core::Initializable::deinit();
return 0;
}
diff --git a/src/modules/FileLogger/FileLogger.cpp b/src/modules/FileLogger/FileLogger.cpp
index 4655002..a78ab36 100644
--- a/src/modules/FileLogger/FileLogger.cpp
+++ b/src/modules/FileLogger/FileLogger.cpp
@@ -19,7 +19,7 @@
#include "FileLogger.h"
-#include <Common/ConfigEntry.h>
+#include <Core/ConfigEntry.h>
namespace Mad {
@@ -29,7 +29,7 @@ FileLogger::ConfigHelper FileLogger::configHelper;
std::set<FileLogger*> FileLogger::loggers;
-bool FileLogger::ConfigHelper::handleConfigEntry(const Common::ConfigEntry &entry, bool handled) {
+bool FileLogger::ConfigHelper::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
if(handled)
return false;
@@ -40,7 +40,7 @@ bool FileLogger::ConfigHelper::handleConfigEntry(const Common::ConfigEntry &entr
FileLogger *logger = new FileLogger(entry[0][1]);
loggers.insert(logger);
- Common::LogManager::get()->registerLogger(static_cast<Logger*>(logger));
+ Core::LogManager::get()->registerLogger(static_cast<Logger*>(logger));
}
else {
Logger::logf(Logger::WARNING, "FileLogger: no filename given.");
diff --git a/src/modules/FileLogger/FileLogger.h b/src/modules/FileLogger/FileLogger.h
index 2def986..04e2126 100644
--- a/src/modules/FileLogger/FileLogger.h
+++ b/src/modules/FileLogger/FileLogger.h
@@ -20,20 +20,20 @@
#ifndef MAD_MODULES_FILELOGGER_H_
#define MAD_MODULES_FILELOGGER_H_
-#include <Common/ConfigManager.h>
-#include <Common/Configurable.h>
-#include <Common/LogManager.h>
+#include <Core/ConfigManager.h>
+#include <Core/Configurable.h>
+#include <Core/LogManager.h>
#include <fstream>
namespace Mad {
namespace Modules {
-class FileLogger : private Common::Logger, private Common::RemoteLogger {
+class FileLogger : private Core::Logger, private Core::RemoteLogger {
private:
- class ConfigHelper : public Common::Configurable {
+ class ConfigHelper : public Core::Configurable {
protected:
- virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool handled);
+ virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
public:
virtual int getPriority() const {return 1;}
@@ -57,11 +57,11 @@ class FileLogger : private Common::Logger, private Common::RemoteLogger {
: file(filename.c_str(), std::ios::out|std::ios::app) {}
static void registerConfigHelper() {
- Common::ConfigManager::get()->registerConfigurable(&configHelper);
+ Core::ConfigManager::get()->registerConfigurable(&configHelper);
}
static void unregisterConfigHelper() {
- Common::ConfigManager::get()->unregisterConfigurable(&configHelper);
+ Core::ConfigManager::get()->unregisterConfigurable(&configHelper);
for(std::set<FileLogger*>::iterator logger = loggers.begin(); logger != loggers.end(); ++logger) {
delete *logger;
diff --git a/src/modules/SystemBackendPosix/SystemBackendPosix.cpp b/src/modules/SystemBackendPosix/SystemBackendPosix.cpp
index 35e6c4f..4eb5807 100644
--- a/src/modules/SystemBackendPosix/SystemBackendPosix.cpp
+++ b/src/modules/SystemBackendPosix/SystemBackendPosix.cpp
@@ -19,7 +19,7 @@
#include "SystemBackendPosix.h"
-#include <Net/ThreadManager.h>
+#include <Core/ThreadManager.h>
#include <stdio.h>
#include <stdlib.h>
@@ -29,12 +29,12 @@ namespace Modules {
boost::shared_ptr<SystemBackendPosix> SystemBackendPosix::backend;
-void SystemBackendPosix::getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+void SystemBackendPosix::getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
FILE *pipe = popen("/bin/df -P -k", "r");
if(!pipe)
- throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
+ throw(Core::Exception(Core::Exception::NOT_AVAILABLE));
char buffer[1024];
std::string output;
@@ -78,18 +78,18 @@ void SystemBackendPosix::getFSInfo(std::vector<Common::SystemManager::FSInfo> *f
return;
}
-void SystemBackendPosix::shutdown() throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+void SystemBackendPosix::shutdown() throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(system("/sbin/halt") != 0)
- throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
+ throw(Core::Exception(Core::Exception::NOT_AVAILABLE));
}
-void SystemBackendPosix::reboot() throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+void SystemBackendPosix::reboot() throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(system("/sbin/reboot") != 0)
- throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
+ throw(Core::Exception(Core::Exception::NOT_AVAILABLE));
}
}
diff --git a/src/modules/SystemBackendPosix/SystemBackendPosix.h b/src/modules/SystemBackendPosix/SystemBackendPosix.h
index e462b43..4aec7dd 100644
--- a/src/modules/SystemBackendPosix/SystemBackendPosix.h
+++ b/src/modules/SystemBackendPosix/SystemBackendPosix.h
@@ -38,10 +38,10 @@ class SystemBackendPosix : public Common::SystemBackend {
static boost::shared_ptr<SystemBackendPosix> backend;
protected:
- virtual void getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo) throw(Net::Exception);
+ virtual void getFSInfo(std::vector<Common::SystemManager::FSInfo> *fsInfo) throw(Core::Exception);
- virtual void shutdown() throw(Net::Exception);
- virtual void reboot() throw(Net::Exception);
+ virtual void shutdown() throw(Core::Exception);
+ virtual void reboot() throw(Core::Exception);
public:
static void registerBackend() {
diff --git a/src/modules/SystemBackendProc/SystemBackendProc.cpp b/src/modules/SystemBackendProc/SystemBackendProc.cpp
index ab074b2..e8b45cd 100644
--- a/src/modules/SystemBackendProc/SystemBackendProc.cpp
+++ b/src/modules/SystemBackendProc/SystemBackendProc.cpp
@@ -19,7 +19,7 @@
#include "SystemBackendProc.h"
-#include <Net/ThreadManager.h>
+#include <Core/ThreadManager.h>
#include <cstdio>
#include <cstring>
@@ -29,18 +29,18 @@ namespace Modules {
boost::shared_ptr<SystemBackendProc> SystemBackendProc::backend;
-void SystemBackendProc::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+void SystemBackendProc::getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
uptimeFile.seekg(0, std::ios::beg);
if(!uptimeFile.good())
- throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
+ throw(Core::Exception(Core::Exception::NOT_AVAILABLE));
float f;
uptimeFile >> f;
if(!uptimeFile.good())
- throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
+ throw(Core::Exception(Core::Exception::NOT_AVAILABLE));
if(uptime)
*uptime = (unsigned long)f;
@@ -50,8 +50,8 @@ void SystemBackendProc::getUptimeInfo(unsigned long *uptime, unsigned long *idle
*idleTime = (unsigned long)f;
}
-void SystemBackendProc::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+void SystemBackendProc::getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(totalMem)
*totalMem = 0;
@@ -65,7 +65,7 @@ void SystemBackendProc::getMemoryInfo(unsigned long *totalMem, unsigned long *fr
meminfoFile.seekg(0, std::ios::beg);
if(!meminfoFile.good())
- throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
+ throw(Core::Exception(Core::Exception::NOT_AVAILABLE));
while(!meminfoFile.eof() && meminfoFile.good()) {
std::string line;
@@ -92,8 +92,8 @@ void SystemBackendProc::getMemoryInfo(unsigned long *totalMem, unsigned long *fr
}
}
-void SystemBackendProc::getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+void SystemBackendProc::getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
unsigned long currentLoadValue = 0, nProcessesValue = 0;
float loadAvg1Value = 0, loadAvg5Value = 0, loadAvg15Value = 0;
@@ -101,13 +101,13 @@ void SystemBackendProc::getLoadInfo(unsigned long *currentLoad, unsigned long *n
loadFile.seekg(0, std::ios::beg);
if(!loadFile.good())
- throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
+ throw(Core::Exception(Core::Exception::NOT_AVAILABLE));
std::string line;
std::getline(loadFile, line);
if(line.empty())
- throw(Net::Exception(Net::Exception::NOT_AVAILABLE));
+ throw(Core::Exception(Core::Exception::NOT_AVAILABLE));
std::sscanf(line.c_str(), "%f %f %f %lu/%lu", &loadAvg1Value, &loadAvg5Value, &loadAvg15Value, &currentLoadValue, &nProcessesValue);
diff --git a/src/modules/SystemBackendProc/SystemBackendProc.h b/src/modules/SystemBackendProc/SystemBackendProc.h
index eb2f8a6..9a0cb71 100644
--- a/src/modules/SystemBackendProc/SystemBackendProc.h
+++ b/src/modules/SystemBackendProc/SystemBackendProc.h
@@ -39,9 +39,9 @@ class SystemBackendProc : public Common::SystemBackend, boost::noncopyable {
SystemBackendProc() : uptimeFile("/proc/uptime"), meminfoFile("/proc/meminfo"), loadFile("/proc/loadavg") {}
protected:
- virtual void getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Net::Exception);
- virtual void getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Net::Exception);
- virtual void getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Net::Exception);
+ virtual void getUptimeInfo(unsigned long *uptime, unsigned long *idleTime) throw(Core::Exception);
+ virtual void getMemoryInfo(unsigned long *totalMem, unsigned long *freeMem, unsigned long *totalSwap, unsigned long *freeSwap) throw(Core::Exception);
+ virtual void getLoadInfo(unsigned long *currentLoad, unsigned long *nProcesses, float *loadAvg1, float *loadAvg5, float *loadAvg15) throw(Core::Exception);
public:
static void registerBackend() {
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.cpp b/src/modules/UserBackendMysql/UserBackendMysql.cpp
index b020310..f0e9b2e 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.cpp
+++ b/src/modules/UserBackendMysql/UserBackendMysql.cpp
@@ -20,10 +20,10 @@
#include <config.h>
#include "UserBackendMysql.h"
-#include <Common/ConfigEntry.h>
-#include <Common/ConfigManager.h>
-#include <Common/Logger.h>
-#include <Net/ThreadManager.h>
+#include <Core/ConfigEntry.h>
+#include <Core/ConfigManager.h>
+#include <Core/Logger.h>
+#include <Core/ThreadManager.h>
#include <sstream>
@@ -36,7 +36,7 @@ namespace Modules {
boost::shared_ptr<UserBackendMysql> UserBackendMysql::backend;
-bool UserBackendMysql::handleConfigEntry(const Common::ConfigEntry &entry, bool handled) {
+bool UserBackendMysql::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) {
if(handled)
return false;
@@ -65,7 +65,7 @@ bool UserBackendMysql::handleConfigEntry(const Common::ConfigEntry &entry, bool
val = strtol(entry[1][0].c_str(), &endptr, 10);
if(endptr != 0 || val < 0 || val > 65535)
- Common::Logger::log(Common::Logger::WARNING, "UserBackendMysql: Invalid port");
+ Core::Logger::log(Core::Logger::WARNING, "UserBackendMysql: Invalid port");
else
port = val;
}
@@ -121,7 +121,7 @@ bool UserBackendMysql::handleConfigEntry(const Common::ConfigEntry &entry, bool
void UserBackendMysql::configFinished() {
if(db.empty()) {
- Common::Logger::log(Common::Logger::ERROR, "UserBackendMysql: No database name given");
+ Core::Logger::log(Core::Logger::ERROR, "UserBackendMysql: No database name given");
return;
}
@@ -132,17 +132,17 @@ void UserBackendMysql::configFinished() {
}
-boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::getUserList() throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(mysql_ping(mysql))
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
mysql_real_query(mysql, queryListUsers.c_str(), queryListUsers.length());
MYSQL_RES *result = mysql_use_result(mysql);
if(!result || mysql_num_fields(result) < 4)
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > users(new std::map<unsigned long, Common::UserInfo>());
@@ -158,11 +158,11 @@ boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > UserBackendMysql::
return users;
}
-boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long uid) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(mysql_ping(mysql))
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
std::string query = queryUserById;
@@ -177,7 +177,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long
MYSQL_RES *result = mysql_use_result(mysql);
if(!result || mysql_num_fields(result) < 4)
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
MYSQL_ROW row = mysql_fetch_row(result);
@@ -192,14 +192,14 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfo(unsigned long
return user;
}
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const std::string &name) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const std::string &name) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(mysql_ping(mysql))
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
boost::scoped_array<char> escapedName(new char[name.length()*2+1]);
@@ -211,7 +211,7 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const st
MYSQL_RES *result = mysql_use_result(mysql);
if(!result || mysql_num_fields(result) < 4)
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
MYSQL_ROW row = mysql_fetch_row(result);
@@ -226,14 +226,14 @@ boost::shared_ptr<Common::UserInfo> UserBackendMysql::getUserInfoByName(const st
return user;
}
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(unsigned long uid) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(mysql_ping(mysql))
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
std::ostringstream tmp;
tmp << '"';
@@ -246,7 +246,7 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(u
MYSQL_RES *result = mysql_use_result(mysql);
if(!result || mysql_num_fields(result) < 1)
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
boost::shared_ptr<std::set<unsigned long> > groups(new std::set<unsigned long>);
@@ -257,17 +257,17 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getUserGroupList(u
}
-boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql::getGroupList() throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(mysql_ping(mysql))
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
mysql_real_query(mysql, queryListGroups.c_str(), queryListGroups.length());
MYSQL_RES *result = mysql_use_result(mysql);
if(!result || mysql_num_fields(result) < 2)
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > groups(new std::map<unsigned long, Common::GroupInfo>());
@@ -280,11 +280,11 @@ boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > UserBackendMysql:
return groups;
}
-std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(mysql_ping(mysql))
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
std::string query = queryGroupById;
@@ -299,21 +299,21 @@ std::string UserBackendMysql::getGroupName(unsigned long gid) throw(Net::Excepti
MYSQL_RES *result = mysql_use_result(mysql);
if(!result || mysql_num_fields(result) < 2)
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
MYSQL_ROW row = mysql_fetch_row(result);
if(row)
return row[1];
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(mysql_ping(mysql))
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
boost::scoped_array<char> escapedName(new char[name.length()*2+1]);
@@ -325,21 +325,21 @@ unsigned long UserBackendMysql::getGroupId(const std::string &name) throw(Net::E
MYSQL_RES *result = mysql_use_result(mysql);
if(!result || mysql_num_fields(result) < 2)
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
MYSQL_ROW row = mysql_fetch_row(result);
if(row)
return strtoul(row[0], 0, 10);
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
}
-boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Net::Exception) {
- Net::ThreadManager::get()->detach();
+boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getGroupUserList(unsigned long gid) throw(Core::Exception) {
+ Core::ThreadManager::get()->detach();
if(mysql_ping(mysql))
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
std::ostringstream tmp;
tmp << '"';
@@ -352,7 +352,7 @@ boost::shared_ptr<std::set<unsigned long> > UserBackendMysql::getGroupUserList(u
MYSQL_RES *result = mysql_use_result(mysql);
if(!result || mysql_num_fields(result) < 1)
- throw Net::Exception(Net::Exception::NOT_AVAILABLE);
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
boost::shared_ptr<std::set<unsigned long> > users(new std::set<unsigned long>);
@@ -368,14 +368,14 @@ void UserBackendMysql::registerBackend() {
return;
backend.reset(new UserBackendMysql());
- Common::ConfigManager::get()->registerConfigurable(backend.get());
+ Core::ConfigManager::get()->registerConfigurable(backend.get());
}
void UserBackendMysql::unregisterBackend() {
if(!backend)
return;
- Common::ConfigManager::get()->unregisterConfigurable(backend.get());
+ Core::ConfigManager::get()->unregisterConfigurable(backend.get());
Server::UserManager::get()->unregisterBackend(backend);
backend.reset();
diff --git a/src/modules/UserBackendMysql/UserBackendMysql.h b/src/modules/UserBackendMysql/UserBackendMysql.h
index 26c7ef3..523806f 100644
--- a/src/modules/UserBackendMysql/UserBackendMysql.h
+++ b/src/modules/UserBackendMysql/UserBackendMysql.h
@@ -22,7 +22,7 @@
#include <Server/UserBackend.h>
#include <Server/UserManager.h>
-#include <Common/Configurable.h>
+#include <Core/Configurable.h>
#include <mysql/mysql.h>
@@ -30,7 +30,7 @@
namespace Mad {
namespace Modules {
-class UserBackendMysql : public Server::UserBackend, private Common::Configurable {
+class UserBackendMysql : public Server::UserBackend, private Core::Configurable {
private:
static boost::shared_ptr<UserBackendMysql> backend;
@@ -47,18 +47,18 @@ class UserBackendMysql : public Server::UserBackend, private Common::Configurabl
UserBackendMysql() : port(0), mysql(0) {}
protected:
- virtual bool handleConfigEntry(const Common::ConfigEntry &entry, bool);
+ virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool);
virtual void configFinished();
- virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Net::Exception);
- virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid) throw(Net::Exception);
- virtual boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name) throw(Net::Exception);
- virtual boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Net::Exception);
+ virtual boost::shared_ptr<std::map<unsigned long, Common::UserInfo> > getUserList() throw(Core::Exception);
+ virtual boost::shared_ptr<Common::UserInfo> getUserInfo(unsigned long uid) throw(Core::Exception);
+ virtual boost::shared_ptr<Common::UserInfo> getUserInfoByName(const std::string &name) throw(Core::Exception);
+ virtual boost::shared_ptr<std::set<unsigned long> > getUserGroupList(unsigned long uid) throw(Core::Exception);
- virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Net::Exception);
- virtual std::string getGroupName(unsigned long gid) throw(Net::Exception);
- virtual unsigned long getGroupId(const std::string &name) throw(Net::Exception);
- virtual boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Net::Exception);
+ virtual boost::shared_ptr<std::map<unsigned long, Common::GroupInfo> > getGroupList() throw(Core::Exception);
+ virtual std::string getGroupName(unsigned long gid) throw(Core::Exception);
+ virtual unsigned long getGroupId(const std::string &name) throw(Core::Exception);
+ virtual boost::shared_ptr<std::set<unsigned long> > getGroupUserList(unsigned long gid) throw(Core::Exception);
public:
virtual ~UserBackendMysql() {