diff options
Diffstat (limited to 'src/Server')
11 files changed, 43 insertions, 51 deletions
diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index 279304c..9235700 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -46,8 +46,8 @@ namespace Server { ConnectionManager ConnectionManager::connectionManager; -bool ConnectionManager::Connection::send(const Net::Packet &packet) { - return connection->send(packet); +void ConnectionManager::Connection::send(const Net::Packet &packet) { + connection->send(packet); } ConnectionManager::Connection::Connection(Net::ServerConnection *connection0, ConnectionType type0) @@ -100,7 +100,7 @@ bool ConnectionManager::handleConfigEntry(const Common::ConfigEntry &entry, bool try { listenerAddresses.push_back(Net::IPAddress(entry[0][0])); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { // TODO Log error } @@ -149,7 +149,7 @@ void ConnectionManager::configFinished() { try { listeners.push_back(new Net::Listener(x509CertFile, x509KeyFile)); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { // TODO Log error } } @@ -158,7 +158,7 @@ void ConnectionManager::configFinished() { try { listeners.push_back(new Net::Listener(x509CertFile, x509KeyFile, *address)); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { // TODO Log error } } @@ -233,14 +233,14 @@ void ConnectionManager::run() { } } -Common::Connection* ConnectionManager::getDaemonConnection(const std::string &name) const throw (Common::Exception&) { +Common::Connection* ConnectionManager::getDaemonConnection(const std::string &name) const throw (Net::Exception&) { const Common::HostInfo *hostInfo; try { hostInfo = &daemonInfo.at(name); } catch(std::out_of_range&) { - throw Common::Exception(Common::Exception::UNKNOWN_DAEMON); + throw Net::Exception(Net::Exception::UNKNOWN_DAEMON); } if(hostInfo->getState() != Common::HostInfo::INACTIVE) { @@ -251,10 +251,10 @@ Common::Connection* ConnectionManager::getDaemonConnection(const std::string &na } } - throw(Common::Exception::NOT_AVAILABLE); + throw(Net::Exception::NOT_AVAILABLE); } -std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Common::Exception&) { +std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Net::Exception&) { const Connection *connection = dynamic_cast<const Connection*>(con); if(connection) { @@ -263,22 +263,22 @@ std::string ConnectionManager::getDaemonName(const Common::Connection *con) cons } } - throw Common::Exception(Common::Exception::UNKNOWN_DAEMON); + throw Net::Exception(Net::Exception::UNKNOWN_DAEMON); } -void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Common::Exception&) { +void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Net::Exception&) { // TODO Logging Connection *connection = dynamic_cast<Connection*>(con); if(!connection || (connection->getConnectionType() != Connection::DAEMON)) - throw Common::Exception(Common::Exception::INVALID_ACTION); + throw Net::Exception(Net::Exception::INVALID_ACTION); if(connection->isIdentified()) - throw Common::Exception(Common::Exception::ALREADY_IDENTIFIED); + throw Net::Exception(Net::Exception::ALREADY_IDENTIFIED); if(daemonInfo.count(name) == 0) - throw Common::Exception(Common::Exception::UNKNOWN_DAEMON); + throw Net::Exception(Net::Exception::UNKNOWN_DAEMON); Common::HostInfo *hostInfo = &daemonInfo[name]; @@ -287,7 +287,7 @@ void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const getDaemonConnection(name)->disconnect(); Common::Logger::log(Common::Logger::WARNING, "Disconnecting old connection."); } - catch(Common::Exception&) {} + catch(Net::Exception&) {} } connection->identify(hostInfo); diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index 5072897..62ecc37 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -25,7 +25,6 @@ #include <map> #include <Common/Configurable.h> -#include <Common/Exception.h> #include <Common/HostInfo.h> #include <Common/Initializable.h> #include <Common/RequestManager.h> @@ -56,7 +55,7 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa Common::HostInfo *hostInfo; protected: - virtual bool send(const Net::Packet &packet); + virtual void send(const Net::Packet &packet); public: Connection(Net::ServerConnection *connection0, ConnectionType type0); @@ -118,10 +117,10 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa void run(); - Common::Connection* getDaemonConnection(const std::string &name) const throw (Common::Exception&); - std::string getDaemonName(const Common::Connection *con) const throw (Common::Exception&); + Common::Connection* getDaemonConnection(const std::string &name) const throw (Net::Exception&); + std::string getDaemonName(const Common::Connection *con) const throw (Net::Exception&); - void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Common::Exception&); + void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Net::Exception&); std::vector<Common::HostInfo> getDaemonList() const; }; diff --git a/src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp b/src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp index 7c1efb9..314aa97 100644 --- a/src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp +++ b/src/Server/RequestHandlers/DaemonCommandRequestHandler.cpp @@ -33,7 +33,7 @@ void DaemonCommandRequestHandler::handlePacket(const Common::XmlPacket &packet) Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -50,7 +50,7 @@ void DaemonCommandRequestHandler::handlePacket(const Common::XmlPacket &packet) Common::RequestManager::get()->sendRequest<Requests::CommandRequest>(daemonCon, sigc::mem_fun(this, &DaemonCommandRequestHandler::requestFinished), command == "reboot"); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { Common::XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", e.getErrorCode()); @@ -66,7 +66,7 @@ void DaemonCommandRequestHandler::requestFinished(const Common::Request &request try { sendPacket(request.getResult()); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { Common::XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", e.getErrorCode()); diff --git a/src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp b/src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp index 9ccca40..eadc0d5 100644 --- a/src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp +++ b/src/Server/RequestHandlers/DaemonFSInfoRequestHandler.cpp @@ -33,7 +33,7 @@ void DaemonFSInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -48,7 +48,7 @@ void DaemonFSInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::RequestManager::get()->sendRequest<Common::Requests::FSInfoRequest>(daemonCon, sigc::mem_fun(this, &DaemonFSInfoRequestHandler::requestFinished)); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { Common::XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", e.getErrorCode()); @@ -64,7 +64,7 @@ void DaemonFSInfoRequestHandler::requestFinished(const Common::Request &request) try { sendPacket(request.getResult()); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { Common::XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", e.getErrorCode()); diff --git a/src/Server/RequestHandlers/DaemonListRequestHandler.cpp b/src/Server/RequestHandlers/DaemonListRequestHandler.cpp index c4b4143..2b21a29 100644 --- a/src/Server/RequestHandlers/DaemonListRequestHandler.cpp +++ b/src/Server/RequestHandlers/DaemonListRequestHandler.cpp @@ -31,7 +31,7 @@ void DaemonListRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); diff --git a/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp index 07e0c4c..9e21127 100644 --- a/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp +++ b/src/Server/RequestHandlers/DaemonStatusRequestHandler.cpp @@ -33,7 +33,7 @@ void DaemonStatusRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -50,7 +50,7 @@ void DaemonStatusRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::RequestManager::get()->sendRequest<Common::Requests::StatusRequest>(daemonCon, sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished)); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { Common::XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", e.getErrorCode()); @@ -66,7 +66,7 @@ void DaemonStatusRequestHandler::requestFinished(const Common::Request &request) try { sendPacket(request.getResult()); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { Common::XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", e.getErrorCode()); diff --git a/src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp b/src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp index c665843..5272d7a 100644 --- a/src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp +++ b/src/Server/RequestHandlers/GSSAPIAuthRequestHandler.cpp @@ -18,9 +18,8 @@ */ #include "GSSAPIAuthRequestHandler.h" -#include <Common/Exception.h> #include <Common/Logger.h> -#include <Net/Connection.h> +#include <Net/Exception.h> #include <cstring> @@ -36,7 +35,7 @@ void GSSAPIAuthRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -73,10 +72,7 @@ void GSSAPIAuthRequestHandler::handlePacket(const Common::XmlPacket &packet) { ret.setType("AuthGSSAPI"); ret.addBinary("authToken", sendBuffer.value, sendBuffer.length); - if(!sendPacket(ret)) { - gss_release_buffer(&minStat, &sendBuffer); - return; - } + sendPacket(ret); gss_release_buffer(&minStat, &sendBuffer); } @@ -102,10 +98,7 @@ void GSSAPIAuthRequestHandler::handlePacket(const Common::XmlPacket &packet) { ret.setType("AuthGSSAPI"); ret.addBinary("certMic", sendBuffer.value, sendBuffer.length); - if(!sendPacket(ret)) { - gss_release_buffer(&minStat, &sendBuffer); - return; - } + sendPacket(ret); gss_release_buffer(&minStat, &sendBuffer); diff --git a/src/Server/RequestHandlers/IdentifyRequestHandler.cpp b/src/Server/RequestHandlers/IdentifyRequestHandler.cpp index 9db9411..ac8bb42 100644 --- a/src/Server/RequestHandlers/IdentifyRequestHandler.cpp +++ b/src/Server/RequestHandlers/IdentifyRequestHandler.cpp @@ -32,7 +32,7 @@ void IdentifyRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -48,7 +48,7 @@ void IdentifyRequestHandler::handlePacket(const Common::XmlPacket &packet) { ret.setType("OK"); sendPacket(ret); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { Common::XmlPacket ret; ret.setType("Error"); ret.add("ErrorCode", e.getErrorCode()); diff --git a/src/Server/RequestHandlers/LogRequestHandler.cpp b/src/Server/RequestHandlers/LogRequestHandler.cpp index ae64921..557a97c 100644 --- a/src/Server/RequestHandlers/LogRequestHandler.cpp +++ b/src/Server/RequestHandlers/LogRequestHandler.cpp @@ -32,7 +32,7 @@ void LogRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -46,7 +46,7 @@ void LogRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::LogManager::get()->log(packet["category"], packet["level"], packet["timestamp"], packet["message"], ConnectionManager::get()->getDaemonName(getConnection())); } - catch(Common::Exception &e) { + catch(Net::Exception &e) { Common::Logger::logf(Common::Logger::ERROR, "Can't determine daemon name: %s", e.strerror().c_str()); } diff --git a/src/Server/RequestHandlers/UserInfoRequestHandler.cpp b/src/Server/RequestHandlers/UserInfoRequestHandler.cpp index 16003a2..39fa63e 100644 --- a/src/Server/RequestHandlers/UserInfoRequestHandler.cpp +++ b/src/Server/RequestHandlers/UserInfoRequestHandler.cpp @@ -19,7 +19,7 @@ #include "UserInfoRequestHandler.h" #include "../UserManager.h" -#include <Common/Exception.h> +#include <Net/Exception.h> #include <Common/Logger.h> namespace Mad { @@ -32,7 +32,7 @@ void UserInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -45,7 +45,7 @@ void UserInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(!UserManager::get()->getUserInfo(packet["uid"], sigc::mem_fun(this, &UserInfoRequestHandler::userInfoHandler))) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::NOT_IMPLEMENTED); + ret.add("ErrorCode", Net::Exception::NOT_IMPLEMENTED); sendPacket(ret); signalFinished().emit(); diff --git a/src/Server/RequestHandlers/UserListRequestHandler.cpp b/src/Server/RequestHandlers/UserListRequestHandler.cpp index 696b1d4..66f67bd 100644 --- a/src/Server/RequestHandlers/UserListRequestHandler.cpp +++ b/src/Server/RequestHandlers/UserListRequestHandler.cpp @@ -19,7 +19,7 @@ #include "UserListRequestHandler.h" #include "../UserManager.h" -#include <Common/Exception.h> +#include <Net/Exception.h> #include <Common/Logger.h> namespace Mad { @@ -32,7 +32,7 @@ void UserListRequestHandler::handlePacket(const Common::XmlPacket &packet) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::UNEXPECTED_PACKET); + ret.add("ErrorCode", Net::Exception::UNEXPECTED_PACKET); sendPacket(ret); @@ -45,7 +45,7 @@ void UserListRequestHandler::handlePacket(const Common::XmlPacket &packet) { if(!UserManager::get()->getUserList(sigc::mem_fun(this, &UserListRequestHandler::userListHandler))) { Common::XmlPacket ret; ret.setType("Error"); - ret.add("ErrorCode", Common::Exception::NOT_IMPLEMENTED); + ret.add("ErrorCode", Net::Exception::NOT_IMPLEMENTED); sendPacket(ret); signalFinished().emit(); |