From 61b396863d64e83c3a80b1356a4d4c7eb7f3ddd2 Mon Sep 17 00:00:00 2001 From: jpbl <jpbl> Date: Sat, 17 Sep 2005 16:28:16 +0000 Subject: [PATCH] Now the client works perfectly --- src/gui/official/Makefile.am | 2 +- src/gui/official/request.cpp | 28 +++++++++++++++++++++------ src/gui/official/requesterimpl.cpp | 2 +- src/gui/official/sessionio.cpp | 31 +++++++++++++++++++++++++----- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/gui/official/Makefile.am b/src/gui/official/Makefile.am index 391cbc949a..8fa0d163dd 100644 --- a/src/gui/official/Makefile.am +++ b/src/gui/official/Makefile.am @@ -13,7 +13,7 @@ CLEANFILES = \ test_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) -static test_LDADD = ../../../utilspp/libutilspp.la -lpthread $(LIBQT) KDE_CXXFLAGS = $(USE_EXCEPTIONS) -AM_CPPFLAGS = $(QT_INCLUDES) $(X_INCLUDES) -I$(top_srcdir) +AM_CPPFLAGS = $(QT_INCLUDES) $(X_INCLUDES) -I$(top_srcdir)/src diff --git a/src/gui/official/request.cpp b/src/gui/official/request.cpp index 27f1b4f699..cdf2e1a45f 100644 --- a/src/gui/official/request.cpp +++ b/src/gui/official/request.cpp @@ -20,6 +20,7 @@ #include <sstream> +#include "global.h" #include "request.h" #include "requester.h" @@ -32,16 +33,31 @@ Request::Request(const std::string &sequenceId, {} void -Request::onError(const std::string &, const std::string &) -{} +Request::onError(const std::string &code, const std::string &message) +{ + _debug("Received an error:\n Code: %s\n SequenceID: %s\n Message%s\n", + code.c_str(), + mSequenceId.c_str(), + message.c_str()); +} void -Request::onEntry(const std::string &, const std::string &) -{} +Request::onEntry(const std::string &code, const std::string &message) +{ + _debug("Received a temp info:\n Code: %s\n SequenceID: %s\n Message%s\n", + code.c_str(), + mSequenceId.c_str(), + message.c_str()); +} void -Request::onSuccess(const std::string &, const std::string &) -{} +Request::onSuccess(const std::string &code, const std::string &message) +{ + _debug("Received a success:\n Code: %s\n SequenceID: %s\n Message%s\n", + code.c_str(), + mSequenceId.c_str(), + message.c_str()); +} std::string Request::toString() diff --git a/src/gui/official/requesterimpl.cpp b/src/gui/official/requesterimpl.cpp index ffe3e6d372..0057541230 100644 --- a/src/gui/official/requesterimpl.cpp +++ b/src/gui/official/requesterimpl.cpp @@ -30,7 +30,7 @@ RequesterImpl::RequesterImpl() , mSessionIdCount(0) , mSequenceIdCount(0) { - registerObject< AccountRequest >(std::string("register")); + registerObject< Request >(std::string("register")); } SessionIO * diff --git a/src/gui/official/sessionio.cpp b/src/gui/official/sessionio.cpp index e0394e15e4..f6596985f0 100644 --- a/src/gui/official/sessionio.cpp +++ b/src/gui/official/sessionio.cpp @@ -18,6 +18,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "global.h" #include "sessionio.h" InputStreamer::InputStreamer(SessionIO *sessionIO) @@ -30,6 +31,8 @@ InputStreamer::run() while(mSessionIO->isUp()) { mSessionIO->receive(); } + + _debug("The Session input is down.\n"); } OutputStreamer::OutputStreamer(SessionIO *sessionIO) @@ -42,6 +45,8 @@ OutputStreamer::run() while(mSessionIO->isUp()) { mSessionIO->send(); } + + _debug("The Session output is down.\n"); } SessionIO::SessionIO(std::istream *input, std::ostream *output) @@ -105,16 +110,32 @@ SessionIO::receive(std::string &answer) void SessionIO::send() { - (*mOutput) << mOutputPool.pop(); - mOutput->flush(); + if(!mOutput->good()) { + mMutex.lock(); + mIsUp = false; + mMutex.unlock(); + } + else { + (*mOutput) << mOutputPool.pop(); + mOutput->flush(); + } } void SessionIO::receive() { - std::string s; - std::getline(*mInput, s); - mInputPool.push(s); + if(!mInput->good()) { + mMutex.lock(); + mIsUp = false; + mMutex.unlock(); + } + else { + std::string s; + std::getline(*mInput, s); + if(s.size() > 0) { + mInputPool.push(s); + } + } } -- GitLab