summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-25 19:19:28 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-25 19:20:53 (GMT)
commitdb00adc9810377500e6ab27900b29496a0d05afe (patch)
tree0f13d821883e0e99e9b6e7f15c84e3371375cd96 /Swiften/Client
parentc198064db0a6444a24220eee65cbf747eb7fbfb0 (diff)
downloadswift-contrib-db00adc9810377500e6ab27900b29496a0d05afe.zip
swift-contrib-db00adc9810377500e6ab27900b29496a0d05afe.tar.bz2
Enabled stream compression again.
Diffstat (limited to 'Swiften/Client')
-rw-r--r--Swiften/Client/Client.cpp3
-rw-r--r--Swiften/Client/ClientError.h1
-rw-r--r--Swiften/Client/ClientSession.cpp17
-rw-r--r--Swiften/Client/ClientSession.h1
-rw-r--r--Swiften/Client/UnitTest/ClientSessionTest.cpp7
5 files changed, 28 insertions, 1 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp
index 3962281..19f7ee5 100644
--- a/Swiften/Client/Client.cpp
+++ b/Swiften/Client/Client.cpp
@@ -145,6 +145,9 @@ void Client::handleSessionFinished(boost::shared_ptr<Error> error) {
case ClientSession::Error::AuthenticationFailedError:
clientError = ClientError(ClientError::AuthenticationFailedError);
break;
+ case ClientSession::Error::CompressionFailedError:
+ clientError = ClientError(ClientError::CompressionFailedError);
+ break;
case ClientSession::Error::ServerVerificationFailedError:
clientError = ClientError(ClientError::ServerVerificationFailedError);
break;
diff --git a/Swiften/Client/ClientError.h b/Swiften/Client/ClientError.h
index 55c57fc..a0557d4 100644
--- a/Swiften/Client/ClientError.h
+++ b/Swiften/Client/ClientError.h
@@ -11,6 +11,7 @@ namespace Swift {
ConnectionWriteError,
XMLError,
AuthenticationFailedError,
+ CompressionFailedError,
ServerVerificationFailedError,
NoSupportedAuthMechanismsError,
UnexpectedElementError,
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index 61ce8ef..8427d27 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -12,6 +12,9 @@
#include "Swiften/Elements/AuthFailure.h"
#include "Swiften/Elements/AuthChallenge.h"
#include "Swiften/Elements/AuthResponse.h"
+#include "Swiften/Elements/Compressed.h"
+#include "Swiften/Elements/CompressFailure.h"
+#include "Swiften/Elements/CompressRequest.h"
#include "Swiften/Elements/StartSession.h"
#include "Swiften/Elements/IQ.h"
#include "Swiften/Elements/ResourceBind.h"
@@ -70,6 +73,10 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
state = WaitingForEncrypt;
stream->writeElement(boost::shared_ptr<StartTLSRequest>(new StartTLSRequest()));
}
+ else if (streamFeatures->hasCompressionMethod("zlib")) {
+ state = Compressing;
+ stream->writeElement(boost::shared_ptr<CompressRequest>(new CompressRequest("zlib")));
+ }
else if (streamFeatures->hasAuthenticationMechanisms()) {
if (stream->hasTLSCertificate()) {
if (streamFeatures->hasAuthenticationMechanism("EXTERNAL")) {
@@ -120,6 +127,16 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
}
}
}
+ else if (boost::dynamic_pointer_cast<Compressed>(element)) {
+ checkState(Compressing);
+ state = WaitingForStreamStart;
+ stream->addZLibCompression();
+ stream->resetXMPPParser();
+ sendStreamHeader();
+ }
+ else if (boost::dynamic_pointer_cast<CompressFailure>(element)) {
+ finishSession(Error::CompressionFailedError);
+ }
else if (AuthChallenge* challenge = dynamic_cast<AuthChallenge*>(element.get())) {
checkState(Authenticating);
assert(authenticator);
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h
index 5e5acbc..ef4d747 100644
--- a/Swiften/Client/ClientSession.h
+++ b/Swiften/Client/ClientSession.h
@@ -34,6 +34,7 @@ namespace Swift {
struct Error : public Swift::Error {
enum Type {
AuthenticationFailedError,
+ CompressionFailedError,
ServerVerificationFailedError,
NoSupportedAuthMechanismsError,
UnexpectedElementError,
diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp
index 9fe2a3d..e035ba3 100644
--- a/Swiften/Client/UnitTest/ClientSessionTest.cpp
+++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp
@@ -173,7 +173,7 @@ class ClientSessionTest : public CppUnit::TestFixture {
bool footer;
};
- MockSessionStream() : available(true), canTLSEncrypt(true), tlsEncrypted(false), whitespacePingEnabled(false), resetCount(0) {
+ MockSessionStream() : available(true), canTLSEncrypt(true), tlsEncrypted(false), compressed(false), whitespacePingEnabled(false), resetCount(0) {
}
virtual bool isAvailable() {
@@ -200,6 +200,10 @@ class ClientSessionTest : public CppUnit::TestFixture {
tlsEncrypted = true;
}
+ virtual void addZLibCompression() {
+ compressed = true;
+ }
+
virtual void setWhitespacePingEnabled(bool enabled) {
whitespacePingEnabled = enabled;
}
@@ -286,6 +290,7 @@ class ClientSessionTest : public CppUnit::TestFixture {
bool available;
bool canTLSEncrypt;
bool tlsEncrypted;
+ bool compressed;
bool whitespacePingEnabled;
int resetCount;
std::deque<Event> receivedEvents;