summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Client')
-rw-r--r--Swiften/Client/ClientError.h1
-rw-r--r--Swiften/Client/ClientSession.cpp4
-rw-r--r--Swiften/Client/ClientSession.h1
-rw-r--r--Swiften/Client/CoreClient.cpp3
-rw-r--r--Swiften/Client/UnitTest/ClientSessionTest.cpp18
5 files changed, 27 insertions, 0 deletions
diff --git a/Swiften/Client/ClientError.h b/Swiften/Client/ClientError.h
index 7ba0322..baf1b0a 100644
--- a/Swiften/Client/ClientError.h
+++ b/Swiften/Client/ClientError.h
@@ -23,6 +23,7 @@ namespace Swift {
UnexpectedElementError,
ResourceBindError,
SessionStartError,
+ StreamError,
TLSError,
ClientCertificateLoadError,
ClientCertificateError,
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index 13816d3..a7f39b6 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -13,6 +13,7 @@
#include "Swiften/Elements/ProtocolHeader.h"
#include "Swiften/Elements/StreamFeatures.h"
+#include "Swiften/Elements/StreamError.h"
#include "Swiften/Elements/StartTLSRequest.h"
#include "Swiften/Elements/StartTLSFailure.h"
#include "Swiften/Elements/TLSProceed.h"
@@ -151,6 +152,9 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
std::cerr << "Warning: Ignoring ack" << std::endl;
}
}
+ else if (StreamError::ref streamError = boost::dynamic_pointer_cast<StreamError>(element)) {
+ finishSession(Error::StreamError);
+ }
else if (getState() == Initialized) {
boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element);
if (stanza) {
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h
index 20573a0..170491f 100644
--- a/Swiften/Client/ClientSession.h
+++ b/Swiften/Client/ClientSession.h
@@ -51,6 +51,7 @@ namespace Swift {
SessionStartError,
TLSClientCertificateError,
TLSError,
+ StreamError,
} type;
Error(Type type) : type(type) {}
};
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index c4e5225..ed9302d 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -152,6 +152,9 @@ void CoreClient::handleSessionFinished(boost::shared_ptr<Error> error) {
case ClientSession::Error::TLSClientCertificateError:
clientError = ClientError(ClientError::ClientCertificateError);
break;
+ case ClientSession::Error::StreamError:
+ clientError = ClientError(ClientError::StreamError);
+ break;
}
}
else if (boost::shared_ptr<SessionStream::Error> actualError = boost::dynamic_pointer_cast<SessionStream::Error>(error)) {
diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp
index 74f3376..dbed9aa 100644
--- a/Swiften/Client/UnitTest/ClientSessionTest.cpp
+++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp
@@ -9,11 +9,13 @@
#include <deque>
#include <boost/bind.hpp>
#include <boost/optional.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include "Swiften/Session/SessionStream.h"
#include "Swiften/Client/ClientSession.h"
#include "Swiften/Elements/StartTLSRequest.h"
#include "Swiften/Elements/StreamFeatures.h"
+#include "Swiften/Elements/StreamError.h"
#include "Swiften/Elements/TLSProceed.h"
#include "Swiften/Elements/StartTLSFailure.h"
#include "Swiften/Elements/AuthRequest.h"
@@ -32,6 +34,7 @@ using namespace Swift;
class ClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ClientSessionTest);
CPPUNIT_TEST(testStart_Error);
+ CPPUNIT_TEST(testStart_StreamError);
CPPUNIT_TEST(testStartTLS);
CPPUNIT_TEST(testStartTLS_ServerError);
CPPUNIT_TEST(testStartTLS_ConnectError);
@@ -77,6 +80,17 @@ class ClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_ASSERT(sessionFinishedError);
}
+ void testStart_StreamError() {
+ boost::shared_ptr<ClientSession> session(createSession());
+ session->start();
+ server->sendStreamStart();
+ server->sendStreamError();
+
+ CPPUNIT_ASSERT_EQUAL(ClientSession::Finished, session->getState());
+ CPPUNIT_ASSERT(sessionFinishedReceived);
+ CPPUNIT_ASSERT(sessionFinishedError);
+ }
+
void testStartTLS() {
boost::shared_ptr<ClientSession> session(createSession());
session->setCertificateTrustChecker(blindCertificateTrustChecker);
@@ -351,6 +365,10 @@ class ClientSessionTest : public CppUnit::TestFixture {
onElementReceived(streamFeatures);
}
+ void sendStreamError() {
+ onElementReceived(boost::make_shared<StreamError>());
+ }
+
void sendTLSProceed() {
onElementReceived(boost::shared_ptr<TLSProceed>(new TLSProceed()));
}