summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-10-18 12:39:38 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-10-18 12:42:23 (GMT)
commitcc3828e7f77074064f92ddf306765da0780fa823 (patch)
tree6d819df0c04fb20c5a740f7d1f0921a333b0947b
parentd66625d2118fdcfa24e6426588ecdeb102a42966 (diff)
downloadswift-contrib-cc3828e7f77074064f92ddf306765da0780fa823.zip
swift-contrib-cc3828e7f77074064f92ddf306765da0780fa823.tar.bz2
Use the oldest error when closing streams.
Stops new errors overwriting cert validation errors and preventing Swift from prompting the user to trust the cert.
-rw-r--r--Swiften/Client/ClientSession.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index 791ee75..fd001a1 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -388,57 +388,59 @@ void ClientSession::handleStreamClosed(boost::shared_ptr<Swift::Error> streamErr
state = Finished;
if (stanzaAckRequester_) {
stanzaAckRequester_->onRequestAck.disconnect(boost::bind(&ClientSession::requestAck, shared_from_this()));
stanzaAckRequester_->onStanzaAcked.disconnect(boost::bind(&ClientSession::handleStanzaAcked, shared_from_this(), _1));
stanzaAckRequester_.reset();
}
if (stanzaAckResponder_) {
stanzaAckResponder_->onAck.disconnect(boost::bind(&ClientSession::ack, shared_from_this(), _1));
stanzaAckResponder_.reset();
}
stream->setWhitespacePingEnabled(false);
stream->onStreamStartReceived.disconnect(boost::bind(&ClientSession::handleStreamStart, shared_from_this(), _1));
stream->onElementReceived.disconnect(boost::bind(&ClientSession::handleElement, shared_from_this(), _1));
stream->onClosed.disconnect(boost::bind(&ClientSession::handleStreamClosed, shared_from_this(), _1));
stream->onTLSEncrypted.disconnect(boost::bind(&ClientSession::handleTLSEncrypted, shared_from_this()));
if (previousState == Finishing) {
onFinished(error_);
}
else {
onFinished(streamError);
}
}
void ClientSession::finish() {
finishSession(boost::shared_ptr<Error>());
}
void ClientSession::finishSession(Error::Type error) {
finishSession(boost::make_shared<Swift::ClientSession::Error>(error));
}
void ClientSession::finishSession(boost::shared_ptr<Swift::Error> error) {
state = Finishing;
- error_ = error;
+ if (!error_) {
+ error_ = error;
+ }
assert(stream->isOpen());
if (stanzaAckResponder_) {
stanzaAckResponder_->handleAckRequestReceived();
}
stream->writeFooter();
stream->close();
}
void ClientSession::requestAck() {
stream->writeElement(boost::make_shared<StanzaAckRequest>());
}
void ClientSession::handleStanzaAcked(boost::shared_ptr<Stanza> stanza) {
onStanzaAcked(stanza);
}
void ClientSession::ack(unsigned int handledStanzasCount) {
stream->writeElement(boost::make_shared<StanzaAck>(handledStanzasCount));
}
}