summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Client/CommandParser.cpp63
-rw-r--r--src/Client/CommandParser.h2
-rw-r--r--src/Common/Makefile.am2
-rw-r--r--src/Common/Makefile.in2
-rw-r--r--src/Common/RequestManager.cpp2
-rw-r--r--src/Common/RequestManager.h4
-rw-r--r--src/Common/XmlRequest.h8
-rw-r--r--src/Common/XmlRequestBase.h39
-rw-r--r--src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp2
9 files changed, 15 insertions, 109 deletions
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index 6665ea2..ff93aec 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -242,9 +242,9 @@ void CommandParser::shutdownCommand(const std::vector<std::string> &args) {
void CommandParser::statusCommand(const std::vector<std::string> &args) {
if(args.size() == 1)
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequestBase>(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished))));
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequest>(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished))));
else if(args.size() == 2)
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequestBase>(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished))));
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequest>(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished))));
else {
Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
printUsage("status");
@@ -257,7 +257,7 @@ void CommandParser::statusCommand(const std::vector<std::string> &args) {
void CommandParser::listUsersCommand(const std::vector<std::string>&) {
++CommandManager::get()->activeRequests;
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequestBase>(new Common::Requests::UserListRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::userListRequestFinished))));
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequest>(new Common::Requests::UserListRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::userListRequestFinished))));
}
void CommandParser::exitCommand(const std::vector<std::string>&) {
@@ -266,63 +266,6 @@ void CommandParser::exitCommand(const std::vector<std::string>&) {
Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::DisconnectRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::disconnectRequestFinished))));
}
-bool CommandParser::split(const std::string &str, std::vector<std::string> &ret) {
- std::string temp;
- bool quoteSingle = false, quoteDouble = false, escape = false;
-
- size_t beg = 0;
-
- for(size_t cur = 0; cur < str.length(); ++cur) {
- if(!escape) {
- if(str[cur] == ' ' && !quoteSingle && !quoteDouble) {
- if(cur == beg && temp.empty()) {
- ++beg;
- }
- else {
- temp += str.substr(beg, cur-beg);
- ret.push_back(temp);
- temp.clear();
- beg = cur+1;
- }
-
- continue;
- }
-
- if(str[cur] == '"' && !quoteSingle) {
- temp += str.substr(beg, cur-beg);
- beg = cur+1;
-
- quoteDouble = !quoteDouble;
- continue;
- }
- if(str[cur] == '\'' && !quoteDouble) {
- temp += str.substr(beg, cur-beg);
- beg = cur+1;
-
- quoteSingle = !quoteSingle;
- continue;
- }
-
- if(str[cur] == '\\') {
- escape = true;
- continue;
- }
- }
-
- if(escape && ((!quoteSingle && !quoteDouble) || (quoteSingle && str[cur] == '\'') || (quoteDouble && (str[cur] == '"' || str[cur] == '\\')))) {
- temp += str.substr(beg, cur-beg-1);
- beg = cur;
- }
-
- escape = false;
- }
-
- temp += str.substr(beg, std::string::npos);
- ret.push_back(temp);
-
- return true;
-}
-
bool CommandParser::parse(const std::string &cmd) {
std::vector<std::string> splitCmd;
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h
index de65788..cb38588 100644
--- a/src/Client/CommandParser.h
+++ b/src/Client/CommandParser.h
@@ -53,8 +53,6 @@ class CommandParser {
Net::Connection *connection;
- bool split(const std::string &str, std::vector<std::string> &ret);
-
const Command* findCommand(const std::string& command);
void printUsage(const std::string& command);
diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am
index 2fd4edb..79948dd 100644
--- a/src/Common/Makefile.am
+++ b/src/Common/Makefile.am
@@ -9,4 +9,4 @@ libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandler
noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h \
Initializable.h Logger.h LoggerBase.h LogManager.h ModuleManager.h \
RemoteLogger.h Request.h RequestBase.h RequestHandler.h RequestManager.h \
- SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h XmlRequestHandler.h
+ SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h XmlRequest.h XmlRequestHandler.h
diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in
index 3638371..c7401d1 100644
--- a/src/Common/Makefile.in
+++ b/src/Common/Makefile.in
@@ -239,7 +239,7 @@ libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandlers
noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h Exception.h HostInfo.h \
Initializable.h Logger.h LoggerBase.h LogManager.h ModuleManager.h \
RemoteLogger.h Request.h RequestBase.h RequestHandler.h RequestManager.h \
- SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h XmlRequestHandler.h
+ SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h XmlRequest.h XmlRequestHandler.h
all: all-recursive
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index 03a2603..6b1bf8f 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -188,7 +188,7 @@ bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr<Requ
return true;
}
-bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr<XmlRequestBase> request) {
+bool RequestManager::sendRequest(Net::Connection *connection, std::auto_ptr<XmlRequest> request) {
std::map<Net::Connection*,XmlRequestMap*>::iterator it = xmlRequestMaps.find(connection);
if(it == xmlRequestMaps.end()) {
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index 00d940d..f4ad208 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -30,7 +30,7 @@ namespace Common {
class RequestBase;
class RequestHandler;
-class XmlRequestBase;
+class XmlRequest;
class XmlRequestHandler;
class RequestManager {
@@ -150,7 +150,7 @@ class RequestManager {
void unregisterPacketType(const std::string &type);
bool sendRequest(Net::Connection *connection, std::auto_ptr<RequestBase> request);
- bool sendRequest(Net::Connection *connection, std::auto_ptr<XmlRequestBase> request);
+ bool sendRequest(Net::Connection *connection, std::auto_ptr<XmlRequest> request);
virtual ~RequestManager();
};
diff --git a/src/Common/XmlRequest.h b/src/Common/XmlRequest.h
index 667b9a7..66635c2 100644
--- a/src/Common/XmlRequest.h
+++ b/src/Common/XmlRequest.h
@@ -21,7 +21,7 @@
#define MAD_COMMON_XMLREQUEST_H_
#include "XmlPacket.h"
-#include "XmlRequestBase.h"
+#include "XmlRequestHandler.h"
#include "Exception.h"
#include <memory>
@@ -30,8 +30,10 @@
namespace Mad {
namespace Common {
-class XmlRequest : public XmlRequestBase {
+class XmlRequest : public XmlRequestHandler {
private:
+ friend class RequestManager;
+
sigc::signal<void,const XmlRequest&> finished;
std::auto_ptr<XmlPacket> res;
@@ -50,6 +52,8 @@ class XmlRequest : public XmlRequestBase {
void finish(const XmlPacket& result) {res.reset(new XmlPacket(result)); finished(*this);}
void finishWithError(const Exception &e) {exp = e; finished(*this);}
+ virtual void sendRequest(Net::Connection *connection, uint16_t requestId) = 0;
+
public:
const XmlPacket& getResult() const throw(Exception) {
if(res.get())
diff --git a/src/Common/XmlRequestBase.h b/src/Common/XmlRequestBase.h
deleted file mode 100644
index fbecc71..0000000
--- a/src/Common/XmlRequestBase.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * RequestBase.h
- *
- * Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MAD_COMMON_XMLREQUESTBASE_H_
-#define MAD_COMMON_XMLREQUESTBASE_H_
-
-#include "XmlRequestHandler.h"
-#include <stdint.h>
-
-namespace Mad {
-namespace Common {
-
-class XmlRequestBase : public XmlRequestHandler {
- protected:
- virtual void sendRequest(Net::Connection *connection, uint16_t requestId) = 0;
-
- friend class RequestManager;
-};
-
-}
-}
-
-#endif /* MAD_COMMON_XMLREQUESTBASE_H_ */
diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
index a1dfdee..11c9eb9 100644
--- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
@@ -50,7 +50,7 @@ void DaemonStatusRequestHandler::handlePacket(Net::Connection *connection, uint1
try {
Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(daemonName);
- Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr<Common::XmlRequestBase>(new Common::Requests::StatusRequest(sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished))));
+ Common::RequestManager::get()->sendRequest(daemonCon, std::auto_ptr<Common::XmlRequest>(new Common::Requests::StatusRequest(sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished))));
}
catch(Common::Exception &e) {
Common::XmlPacket ret;