summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-26 11:41:09 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-26 11:42:47 (GMT)
commit23e82d08519c747e6d8d2add53d7e84b363687bb (patch)
treec78b371e240eb07fb2cd413d46da4ec2305f708c /Swiften
parent8d14d9b2e0e459df6ca974dadee447abb3293a98 (diff)
downloadswift-23e82d08519c747e6d8d2add53d7e84b363687bb.zip
swift-23e82d08519c747e6d8d2add53d7e84b363687bb.tar.bz2
Added an option to not use stream compression.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Client/ClientSession.cpp3
-rw-r--r--Swiften/Client/ClientSession.h5
-rw-r--r--Swiften/Client/CoreClient.cpp7
-rw-r--r--Swiften/Client/CoreClient.h6
-rw-r--r--Swiften/QA/ScriptedTests/MultipleClients.lua1
5 files changed, 20 insertions, 2 deletions
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index 98e3065..8d9e678 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -49,6 +49,7 @@ ClientSession::ClientSession(
state(Initial),
stream(stream),
allowPLAINOverNonTLS(false),
+ useStreamCompression(true),
needSessionStart(false),
needResourceBind(false),
needAcking(false),
@@ -173,7 +174,7 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
state = WaitingForEncrypt;
stream->writeElement(boost::shared_ptr<StartTLSRequest>(new StartTLSRequest()));
}
- else if (streamFeatures->hasCompressionMethod("zlib")) {
+ else if (useStreamCompression && streamFeatures->hasCompressionMethod("zlib")) {
state = Compressing;
stream->writeElement(boost::shared_ptr<CompressRequest>(new CompressRequest("zlib")));
}
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h
index e15a707..ee3992d 100644
--- a/Swiften/Client/ClientSession.h
+++ b/Swiften/Client/ClientSession.h
@@ -71,6 +71,10 @@ namespace Swift {
allowPLAINOverNonTLS = b;
}
+ void setUseStreamCompression(bool b) {
+ useStreamCompression = b;
+ }
+
bool getStreamManagementEnabled() const {
return stanzaAckRequester_;
}
@@ -134,6 +138,7 @@ namespace Swift {
State state;
boost::shared_ptr<SessionStream> stream;
bool allowPLAINOverNonTLS;
+ bool useStreamCompression;
bool needSessionStart;
bool needResourceBind;
bool needAcking;
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index edb7643..a199b16 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -22,7 +22,7 @@
namespace Swift {
-CoreClient::CoreClient(const JID& jid, const std::string& password, NetworkFactories* networkFactories) : jid_(jid), password_(password), networkFactories(networkFactories), disconnectRequested_(false), certificateTrustChecker(NULL) {
+CoreClient::CoreClient(const JID& jid, const std::string& password, NetworkFactories* networkFactories) : jid_(jid), password_(password), networkFactories(networkFactories), useStreamCompression(true), disconnectRequested_(false), certificateTrustChecker(NULL) {
stanzaChannel_ = new ClientSessionStanzaChannel();
stanzaChannel_->onMessageReceived.connect(boost::bind(&CoreClient::handleMessageReceived, this, _1));
stanzaChannel_->onPresenceReceived.connect(boost::bind(&CoreClient::handlePresenceReceived, this, _1));
@@ -82,6 +82,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio
session_ = ClientSession::create(jid_, sessionStream_);
session_->setCertificateTrustChecker(certificateTrustChecker);
+ session_->setUseStreamCompression(useStreamCompression);
stanzaChannel_->setSession(session_);
session_->onFinished.connect(boost::bind(&CoreClient::handleSessionFinished, this, _1));
session_->onNeedCredentials.connect(boost::bind(&CoreClient::handleNeedCredentials, this));
@@ -262,5 +263,9 @@ void CoreClient::handleStanzaAcked(Stanza::ref stanza) {
onStanzaAcked(stanza);
}
+void CoreClient::setUseStreamCompression(bool b) {
+ useStreamCompression = b;
+}
+
}
diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h
index 92cd197..ee73396 100644
--- a/Swiften/Client/CoreClient.h
+++ b/Swiften/Client/CoreClient.h
@@ -143,6 +143,11 @@ namespace Swift {
*/
void setCertificateTrustChecker(CertificateTrustChecker*);
+ /**
+ * Sets whether ZLib stream compression should be used when available.
+ */
+ void setUseStreamCompression(bool b);
+
public:
/**
* Emitted when the client was disconnected from the network.
@@ -207,6 +212,7 @@ namespace Swift {
JID jid_;
std::string password_;
NetworkFactories* networkFactories;
+ bool useStreamCompression;
ClientSessionStanzaChannel* stanzaChannel_;
IQRouter* iqRouter_;
Connector::ref connector_;
diff --git a/Swiften/QA/ScriptedTests/MultipleClients.lua b/Swiften/QA/ScriptedTests/MultipleClients.lua
index 76eba74..ce51481 100644
--- a/Swiften/QA/ScriptedTests/MultipleClients.lua
+++ b/Swiften/QA/ScriptedTests/MultipleClients.lua
@@ -14,6 +14,7 @@ clients = {}
for i = 1, num_clients do
jid = os.getenv("SWIFT_CLIENTTEST_JID") .. "/Client" .. i
client = sluift.new_client(jid, os.getenv("SWIFT_CLIENTTEST_PASS"))
+ client:set_options({compress = false})
client:async_connect()
table.insert(clients, client)
end