Changeset - 36b444536cb0
[Not reviewed]
0 7 0
Jan Kaluza - 10 years ago 2015-12-14 13:59:05
jkaluza@redhat.com
Fix regression when 'from' attribute has not been sent in some situations in server mode.
7 files changed with 19 insertions and 1 deletions:
0 comments (0 inline, 0 general)
include/Swiften/Server/Server.cpp
Show inline comments
 
@@ -45,13 +45,13 @@ Server::Server(
 
			eventLoop(eventLoop),
 
			networkFactories_(networkFactories),
 
			stopping(false),
 
			selfJID(jid),
 
			stanzaChannel_(),
 
			address_(address){
 
	stanzaChannel_ = new ServerStanzaChannel();
 
	stanzaChannel_ = new ServerStanzaChannel(selfJID);
 
	iqRouter_ = new IQRouter(stanzaChannel_);
 
	tlsFactory = NULL;
 
	parserFactory_ = new PlatformXMLParserFactory();
 
}
 

	
 
Server::~Server() {
include/Swiften/Server/ServerStanzaChannel.cpp
Show inline comments
 
@@ -99,12 +99,16 @@ std::string ServerStanzaChannel::getNewIQID() {
 
}
 

	
 
void ServerStanzaChannel::send(boost::shared_ptr<Stanza> stanza) {
 
	JID to = stanza->getTo();
 
	assert(to.isValid());
 

	
 
	if (!stanza->getFrom().isValid()) {
 
		stanza->setFrom(m_jid);
 
	}
 

	
 
	// For a full JID, first try to route to a session with the full JID
 
	if (!to.isBare()) {
 
		std::list<boost::shared_ptr<ServerFromClientSession> >::const_iterator i = std::find_if(sessions[stanza->getTo().toBare().toString()].begin(), sessions[stanza->getTo().toBare().toString()].end(), HasJID(to));
 
		if (i != sessions[stanza->getTo().toBare().toString()].end()) {
 
			(*i)->sendElement(stanza);
 
			return;
include/Swiften/Server/ServerStanzaChannel.h
Show inline comments
 
@@ -19,12 +19,15 @@
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Swift {
 
	class Error;
 
	class ServerStanzaChannel : public StanzaChannel {
 
		public:
 
			ServerStanzaChannel(const JID &selfJID) : StanzaChannel() {
 
				m_jid = selfJID;
 
			}
 
			void addSession(boost::shared_ptr<ServerFromClientSession> session);
 
			void removeSession(boost::shared_ptr<ServerFromClientSession> session);
 

	
 
			void sendIQ(boost::shared_ptr<IQ> iq);
 
			void sendMessage(boost::shared_ptr<Message> message);
 
			void sendPresence(boost::shared_ptr<Presence> presence);
 
@@ -51,12 +54,13 @@ namespace Swift {
 
			void handleSessionFinished(const boost::optional<Session::SessionError>&, const boost::shared_ptr<ServerFromClientSession> &session);
 
			void handleElement(boost::shared_ptr<Element> element, const boost::shared_ptr<ServerFromClientSession> &session);
 
			void handleDataRead(const SafeByteArray &data, const boost::shared_ptr<ServerFromClientSession> &session);
 
			void handleSessionInitialized();
 

	
 
		private:
 
			JID m_jid;
 
			IDGenerator idGenerator;
 
			// [JID][resources][ServerFromClientSession]
 
			std::map<std::string, std::list<boost::shared_ptr<ServerFromClientSession> > > sessions;
 
	};
 

	
 
}
spectrum/src/frontends/xmpp/XMPPUserManager.cpp
Show inline comments
 
@@ -28,12 +28,13 @@
 
#include "storageresponder.h"
 
#include "vcardresponder.h"
 
#include "XMPPFrontend.h"
 
#include "gatewayresponder.h"
 
#include "adhocmanager.h"
 
#include "settingsadhoccommand.h"
 
#include "RosterResponder.h"
 

	
 
#include "Swiften/Server/ServerStanzaChannel.h"
 
#include "Swiften/Elements/StreamError.h"
 
#include "Swiften/Elements/MUCPayload.h"
 
#include "Swiften/Elements/ChatState.h"
 
#ifndef __FreeBSD__ 
 
@@ -72,12 +73,15 @@ XMPPUserManager::XMPPUserManager(Component *component, UserRegistry *userRegistr
 
// 	StatsResponder statsResponder(component, this, &plugin, storageBackend);
 
// 	statsResponder.start();
 

	
 
	m_gatewayResponder = new GatewayResponder(frontend->getIQRouter(), this);
 
	m_gatewayResponder->start();
 

	
 
	m_rosterResponder = new RosterResponder(frontend->getIQRouter(), this);
 
	m_rosterResponder->start();
 

	
 
	m_adHocManager = new AdHocManager(component, frontend->getDiscoItemsResponder(), this, storageBackend);
 
	m_adHocManager->start();
 

	
 
	SettingsAdHocCommandFactory *m_settings = new SettingsAdHocCommandFactory();
 
	m_adHocManager->addAdHocCommand(m_settings);
 
}
 
@@ -94,12 +98,13 @@ XMPPUserManager::~XMPPUserManager() {
 
	}
 

	
 
	delete m_gatewayResponder;
 
	delete m_adHocManager;
 
	delete m_settings;
 
	delete m_vcardResponder;
 
	delete m_rosterResponder;
 
}
 

	
 
void XMPPUserManager::sendVCard(unsigned int id, Swift::VCard::ref vcard) {
 
	m_vcardResponder->sendVCard(id, vcard);
 
}
 

	
spectrum/src/frontends/xmpp/XMPPUserManager.h
Show inline comments
 
@@ -36,12 +36,13 @@ class StorageBackend;
 
class StorageResponder;
 
class VCardResponder;
 
class XMPPUserRegistration;
 
class GatewayResponder;
 
class AdHocManager;
 
class SettingsAdHocCommandFactory;
 
class RosterResponder;
 

	
 
class XMPPUserManager : public UserManager {
 
	public:
 
		XMPPUserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend = NULL);
 

	
 
		virtual ~XMPPUserManager();
 
@@ -58,9 +59,10 @@ class XMPPUserManager : public UserManager {
 
		VCardResponder *m_vcardResponder;
 
		Component *m_component;
 
		XMPPUserRegistration *m_userRegistration;
 
		GatewayResponder *m_gatewayResponder;
 
		AdHocManager *m_adHocManager;
 
		SettingsAdHocCommandFactory *m_settings;
 
		RosterResponder *m_rosterResponder;
 
};
 

	
 
}
spectrum/src/tests/irc_test.py
Show inline comments
 
@@ -40,12 +40,14 @@ class Client(sleekxmpp.ClientXMPP):
 
	def muc_message(self, msg):
 
		if msg['mucnick'] != self.nick:
 
			if msg['body'] == "echo abc":
 
				self.echo_received = True
 

	
 
	def start(self, event):
 
		self.getRoster()
 
		self.sendPresence()
 
		self.plugin['xep_0045'].joinMUC(self.room, self.nick, wait=True)
 
		self.send_message(mto=self.room, mbody="abc", mtype='groupchat')
 
		#time.sleep(10)
 
		#self.disconnect()
 

	
 
if __name__ == '__main__':
src/tests/rostermanager.cpp
Show inline comments
 
@@ -92,12 +92,13 @@ class RosterManagerTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
		Swift::RosterPayload::ref payload1 = getStanza(received[0])->getPayload<Swift::RosterPayload>();
 
		CPPUNIT_ASSERT(payload1);
 
		CPPUNIT_ASSERT_EQUAL(1, (int) payload1->getItems().size());
 
		Swift::RosterItemPayload item = payload1->getItems()[0];
 
		CPPUNIT_ASSERT_EQUAL(std::string("buddy1"), Buddy::JIDToLegacyName(item.getJID()));
 
		CPPUNIT_ASSERT_EQUAL(std::string("Buddy 1"), item.getName());
 
		CPPUNIT_ASSERT_EQUAL(std::string("localhost"), getStanza(received[0])->getFrom().toString());
 

	
 
		Swift::RosterPayload::ref payload2 = getStanza(received[2])->getPayload<Swift::RosterPayload>();
 
		CPPUNIT_ASSERT(payload2);
 
		CPPUNIT_ASSERT_EQUAL(1, (int) payload2->getItems().size());
 
		item = payload2->getItems()[0];
 
		CPPUNIT_ASSERT_EQUAL(std::string("buddy2"), Buddy::JIDToLegacyName(item.getJID()));
0 comments (0 inline, 0 general)