diff --git a/include/Swiften/Server/ServerFromClientSession.cpp b/include/Swiften/Server/ServerFromClientSession.cpp index 2ab70237..109d0d8f 100644 --- a/include/Swiften/Server/ServerFromClientSession.cpp +++ b/include/Swiften/Server/ServerFromClientSession.cpp @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include #include @@ -59,9 +61,14 @@ void ServerFromClientSession::handlePasswordValid() { } } -void ServerFromClientSession::handlePasswordInvalid() { +void ServerFromClientSession::handlePasswordInvalid(const std::string &error) { if (!isInitialized()) { getXMPPLayer()->writeElement(boost::shared_ptr(new AuthFailure)); + if (!error.empty()) { + boost::shared_ptr msg(new StreamError(StreamError::UndefinedCondition, error)); + getXMPPLayer()->writeElement(msg); + } + finishSession(AuthenticationFailedError); } } diff --git a/include/Swiften/Server/ServerFromClientSession.h b/include/Swiften/Server/ServerFromClientSession.h index 77ed0f1b..1bb51fee 100644 --- a/include/Swiften/Server/ServerFromClientSession.h +++ b/include/Swiften/Server/ServerFromClientSession.h @@ -55,7 +55,7 @@ namespace Swift { } void handlePasswordValid(); - void handlePasswordInvalid(); + void handlePasswordInvalid(const std::string &error = ""); private: void handleElement(boost::shared_ptr); diff --git a/include/transport/userregistry.h b/include/transport/userregistry.h index 7465a3c5..0b6cac14 100644 --- a/include/transport/userregistry.h +++ b/include/transport/userregistry.h @@ -82,7 +82,7 @@ class UserRegistry : public Swift::UserRegistry { /// Informs user that the password is invalid and disconnects him. /// \param user JID. - void onPasswordInvalid(const Swift::JID &user); + void onPasswordInvalid(const Swift::JID &user, const std::string &error = ""); /// Removes session later. /// \param user JID. diff --git a/spectrum/src/sample.cfg b/spectrum/src/sample.cfg index 8e676756..6efc9561 100644 --- a/spectrum/src/sample.cfg +++ b/spectrum/src/sample.cfg @@ -11,9 +11,9 @@ admin_password=test #cert=server.pfx #patch to PKCS#12 certificate #cert_password=test #password to that certificate if any users_per_backend=10 -#backend=/home/hanzz/code/libtransport/backends/libpurple/spectrum2_libpurple_backend +backend=/home/hanzz/code/libtransport/backends/libpurple/spectrum2_libpurple_backend #backend=/usr/bin/mono /home/hanzz/code/networkplugin-csharp/msnp-sharp-backend/bin/Debug/msnp-sharp-backend.exe -backend=/home/hanzz/code/libtransport/backends/frotz/spectrum2_frotz_backend +#backend=/home/hanzz/code/libtransport/backends/frotz/spectrum2_frotz_backend #backend=../../backends/libircclient-qt/spectrum2_libircclient-qt_backend #protocol=prpl-msn protocol=any diff --git a/src/networkpluginserver.cpp b/src/networkpluginserver.cpp index 79717f85..e77bca35 100644 --- a/src/networkpluginserver.cpp +++ b/src/networkpluginserver.cpp @@ -369,7 +369,7 @@ void NetworkPluginServer::handleDisconnectedPayload(const std::string &data) { return; } - m_component->m_userRegistry->onPasswordInvalid(payload.user()); + m_component->m_userRegistry->onPasswordInvalid(payload.user(), payload.message()); User *user = m_userManager->getUser(payload.user()); if (!user) { diff --git a/src/user.cpp b/src/user.cpp index 2cf74cbd..3af346b8 100644 --- a/src/user.cpp +++ b/src/user.cpp @@ -299,7 +299,7 @@ void User::handleDisconnected(const std::string &error) { // We can't be sure finishSession sends unavailable presence everytime, so check if user gets removed // in finishSession(...) call and if not, remove it here. std::string jid = m_jid.toBare().toString(); - dynamic_cast(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr(new Swift::StreamError())); + dynamic_cast(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr(new Swift::StreamError(Swift::StreamError::UndefinedCondition, "test"))); if (m_userManager->getUser(jid) != NULL) { m_userManager->removeUser(this); } diff --git a/src/userregistry.cpp b/src/userregistry.cpp index 4f1a83df..b044ed49 100644 --- a/src/userregistry.cpp +++ b/src/userregistry.cpp @@ -103,11 +103,11 @@ void UserRegistry::onPasswordValid(const Swift::JID &user) { } } -void UserRegistry::onPasswordInvalid(const Swift::JID &user) { +void UserRegistry::onPasswordInvalid(const Swift::JID &user, const std::string &error) { std::string key = user.toBare().toString(); if (users.find(key) != users.end()) { LOG4CXX_INFO(logger, key << ": Password is invalid"); - users[key].session->handlePasswordInvalid(); + users[key].session->handlePasswordInvalid(error); users.erase(key); } else {