summaryrefslogtreecommitdiffstats
path: root/src/Client
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 /src/Client
parent452320b5ec31447a526735016fa07589cb848032 (diff)
downloadmad-766c56a693e8b1bd4293459bb256abdc0515a0b5.tar
mad-766c56a693e8b1bd4293459bb256abdc0515a0b5.zip
Teile der Namespaces Common und Net in den neuen Namespace Core verschoben
Diffstat (limited to 'src/Client')
-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
5 files changed, 56 insertions, 55 deletions
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"];