Changeset - b1e4aae55b26
[Not reviewed]
0 7 0
HanzZ - 14 years ago 2011-10-18 20:49:20
hanzz.k@gmail.com
Forward StreamError in onPasswordInvalid signal
7 files changed with 16 insertions and 9 deletions:
0 comments (0 inline, 0 general)
include/Swiften/Server/ServerFromClientSession.cpp
Show inline comments
 
@@ -9,6 +9,8 @@
 
#include <boost/bind.hpp>
 

	
 
#include <Swiften/Elements/ProtocolHeader.h>
 
#include <Swiften/Elements/StreamError.h>
 
#include <Swiften/Elements/Message.h>
 
#include <Swiften/Server/UserRegistry.h>
 
#include <Swiften/Network/Connection.h>
 
#include <Swiften/StreamStack/XMPPLayer.h>
 
@@ -59,9 +61,14 @@ void ServerFromClientSession::handlePasswordValid() {
 
	}
 
}
 

	
 
void ServerFromClientSession::handlePasswordInvalid() {
 
void ServerFromClientSession::handlePasswordInvalid(const std::string &error) {
 
	if (!isInitialized()) {
 
		getXMPPLayer()->writeElement(boost::shared_ptr<AuthFailure>(new AuthFailure));
 
		if (!error.empty()) {
 
			boost::shared_ptr<StreamError> msg(new StreamError(StreamError::UndefinedCondition, error));
 
			getXMPPLayer()->writeElement(msg);
 
		}
 
		
 
		finishSession(AuthenticationFailedError);
 
	}
 
}
include/Swiften/Server/ServerFromClientSession.h
Show inline comments
 
@@ -55,7 +55,7 @@ namespace Swift {
 
			}
 

	
 
			void handlePasswordValid();
 
			void handlePasswordInvalid();
 
			void handlePasswordInvalid(const std::string &error = "");
 

	
 
		private:
 
			void handleElement(boost::shared_ptr<Element>);
include/transport/userregistry.h
Show inline comments
 
@@ -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.
spectrum/src/sample.cfg
Show inline comments
 
@@ -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
src/networkpluginserver.cpp
Show inline comments
 
@@ -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) {
src/user.cpp
Show inline comments
 
@@ -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<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::Element>(new Swift::StreamError()));
 
		dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::Element>(new Swift::StreamError(Swift::StreamError::UndefinedCondition, "test")));
 
		if (m_userManager->getUser(jid) != NULL) {
 
			m_userManager->removeUser(this);
 
		}
src/userregistry.cpp
Show inline comments
 
@@ -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 {
0 comments (0 inline, 0 general)