summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-09-26 14:27:00 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-09-26 14:27:00 (GMT)
commit101053d01cf2274e8eb75c520cce0bfee4d15618 (patch)
tree5487512084f05005573149bdb9c56cd5eddb6eae
parent6c45edc9b3235ae52826c51971dff65afe10fbf6 (diff)
downloadswift-contrib-101053d01cf2274e8eb75c520cce0bfee4d15618.zip
swift-contrib-101053d01cf2274e8eb75c520cce0bfee4d15618.tar.bz2
Allow disabling of 198-acks in Swiften
-rw-r--r--Swiften/Client/ClientOptions.h8
-rw-r--r--Swiften/Client/ClientSession.cpp5
-rw-r--r--Swiften/Client/ClientSession.h5
-rw-r--r--Swiften/Client/CoreClient.cpp1
4 files changed, 16 insertions, 3 deletions
diff --git a/Swiften/Client/ClientOptions.h b/Swiften/Client/ClientOptions.h
index 6b15f18..3b51a87 100644
--- a/Swiften/Client/ClientOptions.h
+++ b/Swiften/Client/ClientOptions.h
@@ -8,19 +8,19 @@
namespace Swift {
struct ClientOptions {
enum UseTLS {
NeverUseTLS,
UseTLSWhenAvailable,
RequireTLS
};
- ClientOptions() : useStreamCompression(true), useTLS(UseTLSWhenAvailable), allowPLAINWithoutTLS(false), useStreamResumption(false), forgetPassword(false) {
+ ClientOptions() : useStreamCompression(true), useTLS(UseTLSWhenAvailable), allowPLAINWithoutTLS(false), useStreamResumption(false), forgetPassword(false), useAcks(true) {
}
/**
* Whether ZLib stream compression should be used when available.
*
* Default: true
*/
bool useStreamCompression;
@@ -49,11 +49,17 @@ namespace Swift {
/**
* Forget the password once it's used.
* This makes the Client useless after the first login attempt.
*
* FIXME: This is a temporary workaround.
*
* Default: false
*/
bool forgetPassword;
+
+ /**
+ * Use XEP-0198 acks in the stream when available.
+ * Default: true
+ */
+ bool useAcks;
};
}
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index 2eeb3c0..275f913 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -51,19 +51,20 @@ ClientSession::ClientSession(
stream(stream),
allowPLAINOverNonTLS(false),
useStreamCompression(true),
useTLS(UseTLSWhenAvailable),
needSessionStart(false),
needResourceBind(false),
needAcking(false),
rosterVersioningSupported(false),
authenticator(NULL),
- certificateTrustChecker(NULL) {
+ certificateTrustChecker(NULL),
+ useAcks(true) {
}
ClientSession::~ClientSession() {
}
void ClientSession::start() {
stream->onStreamStartReceived.connect(boost::bind(&ClientSession::handleStreamStart, shared_from_this(), _1));
stream->onElementReceived.connect(boost::bind(&ClientSession::handleElement, shared_from_this(), _1));
stream->onClosed.connect(boost::bind(&ClientSession::handleStreamClosed, shared_from_this(), _1));
@@ -226,19 +227,19 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
finishSession(Error::NoSupportedAuthMechanismsError);
}
}
else {
// Start the session
rosterVersioningSupported = streamFeatures->hasRosterVersioning();
stream->setWhitespacePingEnabled(true);
needSessionStart = streamFeatures->hasSession();
needResourceBind = streamFeatures->hasResourceBind();
- needAcking = streamFeatures->hasStreamManagement();
+ needAcking = streamFeatures->hasStreamManagement() && useAcks;
if (!needResourceBind) {
// Resource binding is a MUST
finishSession(Error::ResourceBindError);
}
else {
continueSessionInitialization();
}
}
}
diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h
index e58e758..939e96e 100644
--- a/Swiften/Client/ClientSession.h
+++ b/Swiften/Client/ClientSession.h
@@ -79,18 +79,22 @@ namespace Swift {
void setUseStreamCompression(bool b) {
useStreamCompression = b;
}
void setUseTLS(UseTLS b) {
useTLS = b;
}
+ void setUseAcks(bool b) {
+ useAcks = b;
+ }
+
bool getStreamManagementEnabled() const {
return stanzaAckRequester_;
}
bool getRosterVersioningSupported() const {
return rosterVersioningSupported;
}
@@ -153,16 +157,17 @@ namespace Swift {
State state;
boost::shared_ptr<SessionStream> stream;
bool allowPLAINOverNonTLS;
bool useStreamCompression;
UseTLS useTLS;
bool needSessionStart;
bool needResourceBind;
bool needAcking;
bool rosterVersioningSupported;
+ bool useAcks;
ClientAuthenticator* authenticator;
boost::shared_ptr<StanzaAckRequester> stanzaAckRequester_;
boost::shared_ptr<StanzaAckResponder> stanzaAckResponder_;
boost::shared_ptr<Swift::Error> error_;
CertificateTrustChecker* certificateTrustChecker;
};
}
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index 37055e4..a223e3d 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -117,18 +117,19 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio
session_->setUseTLS(ClientSession::UseTLSWhenAvailable);
break;
case ClientOptions::NeverUseTLS:
session_->setUseTLS(ClientSession::NeverUseTLS);
break;
case ClientOptions::RequireTLS:
session_->setUseTLS(ClientSession::RequireTLS);
break;
}
+ session_->setUseAcks(options.useAcks);
stanzaChannel_->setSession(session_);
session_->onFinished.connect(boost::bind(&CoreClient::handleSessionFinished, this, _1));
session_->onNeedCredentials.connect(boost::bind(&CoreClient::handleNeedCredentials, this));
session_->start();
}
}
void CoreClient::disconnect() {
// FIXME: We should be able to do without this boolean. We just have to make sure we can tell the difference between