diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-11-07 14:58:23 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-11-07 18:04:57 (GMT) |
commit | e2f2e48f6e01739ccaa763ff7f037306131d4e61 (patch) | |
tree | 92fefe8ff9255356d849d1eadcad45666bde52e5 /Swiften/Client/CoreClient.cpp | |
parent | 832d109bfabc16ef2834790743c1d235b254d781 (diff) | |
download | swift-contrib-e2f2e48f6e01739ccaa763ff7f037306131d4e61.zip swift-contrib-e2f2e48f6e01739ccaa763ff7f037306131d4e61.tar.bz2 |
Added security error handling to Swiften.
Diffstat (limited to 'Swiften/Client/CoreClient.cpp')
-rw-r--r-- | Swiften/Client/CoreClient.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp index 214e6b1..4202483 100644 --- a/Swiften/Client/CoreClient.cpp +++ b/Swiften/Client/CoreClient.cpp @@ -23,7 +23,7 @@ namespace Swift { -CoreClient::CoreClient(EventLoop* eventLoop, const JID& jid, const String& password) : resolver_(eventLoop), jid_(jid), password_(password), eventLoop(eventLoop), disconnectRequested_(false) { +CoreClient::CoreClient(EventLoop* eventLoop, const JID& jid, const String& password) : resolver_(eventLoop), jid_(jid), password_(password), eventLoop(eventLoop), disconnectRequested_(false), ignoreSecurityErrors(true) { stanzaChannel_ = new ClientSessionStanzaChannel(); stanzaChannel_->onMessageReceived.connect(boost::ref(onMessageReceived)); stanzaChannel_->onPresenceReceived.connect(boost::ref(onPresenceReceived)); @@ -93,6 +93,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio stanzaChannel_->setSession(session_); session_->onFinished.connect(boost::bind(&CoreClient::handleSessionFinished, this, _1)); session_->onNeedCredentials.connect(boost::bind(&CoreClient::handleNeedCredentials, this)); + session_->onSecurityError.connect(boost::bind(&CoreClient::handleSecurityError, this, _1)); session_->start(); } } @@ -114,6 +115,7 @@ void CoreClient::setCertificate(const String& certificate) { } void CoreClient::handleSessionFinished(boost::shared_ptr<Error> error) { + session_->onSecurityError.disconnect(boost::bind(&CoreClient::handleSecurityError, this, _1)); session_->onFinished.disconnect(boost::bind(&CoreClient::handleSessionFinished, this, _1)); session_->onNeedCredentials.disconnect(boost::bind(&CoreClient::handleNeedCredentials, this)); session_.reset(); @@ -214,4 +216,17 @@ bool CoreClient::isActive() const { return session_ || connector_; } +void CoreClient::handleSecurityError(const SecurityError& error) { + if (ignoreSecurityErrors) { + session_->continueAfterSecurityError(); + } + else { + onSecurityError(error); + } +} + +void CoreClient::continueAfterSecurityError() { + session_->continueAfterSecurityError(); +} + } |