diff options
Diffstat (limited to 'src/Common/Requests')
-rw-r--r-- | src/Common/Requests/DisconnectRequest.cpp | 27 | ||||
-rw-r--r-- | src/Common/Requests/DisconnectRequest.h | 16 | ||||
-rw-r--r-- | src/Common/Requests/GSSAPIAuthRequest.cpp | 26 | ||||
-rw-r--r-- | src/Common/Requests/GSSAPIAuthRequest.h | 15 |
4 files changed, 22 insertions, 62 deletions
diff --git a/src/Common/Requests/DisconnectRequest.cpp b/src/Common/Requests/DisconnectRequest.cpp index 81208f2..d8e7ee9 100644 --- a/src/Common/Requests/DisconnectRequest.cpp +++ b/src/Common/Requests/DisconnectRequest.cpp @@ -18,42 +18,25 @@ */ #include "DisconnectRequest.h" -#include "../RequestManager.h" +#include <Net/Connection.h> namespace Mad { namespace Common { namespace Requests { -bool DisconnectRequest::send(Net::Connection *connection, const sigc::slot<void> &callback) { - DisconnectRequest *request = new DisconnectRequest(); - - request->finished.connect(callback); - - if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request)) - return true; - - delete request; - return false; -} - -bool DisconnectRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { - if(!connection->send(Net::Packet(Net::Packet::DISCONNECT, requestId))) - return false; - - return true; +void DisconnectRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { + connection->send(Net::Packet(Net::Packet::DISCONNECT, requestId)); } void DisconnectRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) { if(packet.getType() != Net::Packet::OK) { - signalFinished().emit(); + finishWithError(Exception(Exception::UNEXPECTED_PACKET)); return; // TODO Logging } connection->disconnect(); - finished(); - - signalFinished().emit(); + finish(); } } diff --git a/src/Common/Requests/DisconnectRequest.h b/src/Common/Requests/DisconnectRequest.h index dcc2b9c..602505a 100644 --- a/src/Common/Requests/DisconnectRequest.h +++ b/src/Common/Requests/DisconnectRequest.h @@ -22,23 +22,17 @@ #include "../Request.h" -#include <sigc++/signal.h> - namespace Mad { namespace Common { namespace Requests { -class DisconnectRequest : public Request { - private: - sigc::signal<void> finished; - - DisconnectRequest() {} +class DisconnectRequest : public Request<> { + protected: + virtual void sendRequest(Net::Connection *connection, uint16_t requestId); + virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); public: - static bool send(Net::Connection *connection, const sigc::slot<void> &callback); - - virtual bool sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); + DisconnectRequest(slot_type slot) : Request<>(slot) {} }; } diff --git a/src/Common/Requests/GSSAPIAuthRequest.cpp b/src/Common/Requests/GSSAPIAuthRequest.cpp index 91488d0..53d969f 100644 --- a/src/Common/Requests/GSSAPIAuthRequest.cpp +++ b/src/Common/Requests/GSSAPIAuthRequest.cpp @@ -18,7 +18,7 @@ */ #include "GSSAPIAuthRequest.h" -#include "../RequestManager.h" +#include <Net/Connection.h> #include <cstring> @@ -37,17 +37,7 @@ GSSAPIAuthRequest::~GSSAPIAuthRequest() { gss_release_name(&minStat, &gssServiceName); } -bool GSSAPIAuthRequest::send(Net::Connection *connection, const std::string &serviceName0) { - GSSAPIAuthRequest *request = new GSSAPIAuthRequest(serviceName0); - - if(Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, request)) - return true; - - delete request; - return false; -} - -bool GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { +void GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t requestId) { OM_uint32 majStat, minStat; gss_buffer_desc buffer; @@ -61,7 +51,7 @@ bool GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t reques if(majStat != GSS_S_COMPLETE) { gssServiceName = GSS_C_NO_NAME; - return false; + return; } majStat = gss_init_sec_context(&minStat, GSS_C_NO_CREDENTIAL, &gssContext, gssServiceName, GSS_C_NO_OID, GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG, @@ -73,22 +63,20 @@ bool GSSAPIAuthRequest::sendRequest(Net::Connection *connection, uint16_t reques } else if(majStat != GSS_S_CONTINUE_NEEDED) { gss_release_buffer(&minStat, &buffer); - return false; + return; } if(!connection->send(Net::Packet(Net::Packet::GSSAPI_AUTH, requestId, buffer.value, buffer.length))) { gss_release_buffer(&minStat, &buffer); - return false; + return; } gss_release_buffer(&minStat, &buffer); - - return true; } void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Packet &packet) { if(packet.getType() != Net::Packet::GSSAPI_AUTH) { - signalFinished().emit(); + finishWithError(Exception(Exception::UNEXPECTED_PACKET)); return; // TODO Logging } @@ -157,7 +145,7 @@ void GSSAPIAuthRequest::handlePacket(Net::Connection *connection, const Net::Pac gss_release_buffer(&minStat, &sendBuffer); - signalFinished().emit(); + finish(); } } diff --git a/src/Common/Requests/GSSAPIAuthRequest.h b/src/Common/Requests/GSSAPIAuthRequest.h index 336e4f0..8f2328b 100644 --- a/src/Common/Requests/GSSAPIAuthRequest.h +++ b/src/Common/Requests/GSSAPIAuthRequest.h @@ -26,14 +26,11 @@ namespace Mad { namespace Common { - -class RequestManager; - namespace Requests { // TODO Logging & error handling! -class GSSAPIAuthRequest : public Request { +class GSSAPIAuthRequest : public Request<> { private: std::string serviceName; gss_name_t gssServiceName; @@ -41,15 +38,13 @@ class GSSAPIAuthRequest : public Request { bool gssContinue; - GSSAPIAuthRequest(const std::string &serviceName0) : serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {} + virtual void sendRequest(Net::Connection *connection, uint16_t requestId); + virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); public: + GSSAPIAuthRequest(const std::string &serviceName0, slot_type slot) + : Request<>(slot), serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {} virtual ~GSSAPIAuthRequest(); - - static bool send(Net::Connection *connection, const std::string &serviceName0); - - virtual bool sendRequest(Net::Connection *connection, uint16_t requestId); - virtual void handlePacket(Net::Connection *connection, const Net::Packet &packet); }; } |