Changeset - 0d99e8c85d38
[Not reviewed]
! ! !
Vitaly Takmazov - 10 years ago 2015-03-31 13:14:15
vitalyster@gmail.com
Initial swiften 3 support
65 files changed with 306 insertions and 1114 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -77,7 +77,6 @@ if(NOT SWIFTEN_FOUND)
 
endif()
 
 
# FIND BOOST
 
set(Boost_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
 
if (WIN32)
 
	set(Boost_USE_STATIC_LIBS      ON)
 
	set(Boost_USE_MULTITHREADED      ON)
 
@@ -115,6 +114,7 @@ endif()
 
# FIND SQLITE3
 
if (ENABLE_SQLITE3)
 
	if (MSVC)
 
		set(SQLITE3_FOUND 1)
 
		ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/msvc-deps)
 
	else()
 
		if (WIN32)
backends/swiften/main.cpp
Show inline comments
 
@@ -7,6 +7,8 @@
 
 
// Swiften
 
#include "Swiften/Swiften.h"
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
#ifndef WIN32
 
// for signal handler
 
@@ -87,8 +89,11 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
 
			m_conn = m_factories->getConnectionFactory()->createConnection();
 
			m_conn->onDataRead.connect(boost::bind(&SwiftenPlugin::_handleDataRead, this, _1));
 
			m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port));
 

	
 
#if HAVE_SWIFTEN_3
 
			serializer = new Swift::XMPPSerializer(&collection, Swift::ClientStreamType, false);
 
#else
 
			serializer = new Swift::XMPPSerializer(&collection, Swift::ClientStreamType);
 
#endif
 
			m_xmppParser = new Swift::XMPPParser(this, &m_collection2, m_factories->getXMLParserFactory());
 
			m_xmppParser->parse("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='localhost' version='1.0'>");
 
 
@@ -113,8 +118,11 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
 
		}
 
 
		void handleStreamStart(const Swift::ProtocolHeader&) {}
 

	
 
#if HAVE_SWIFTEN_3
 
		void handleElement(boost::shared_ptr<Swift::ToplevelElement> element) {
 
#else
 
		void handleElement(boost::shared_ptr<Swift::Element> element) {
 
#endif
 
			boost::shared_ptr<Swift::Stanza> stanza = boost::dynamic_pointer_cast<Swift::Stanza>(element);
 
			if (!stanza) {
 
				return;
backends/twitter/CMakeLists.txt
Show inline comments
 
@@ -2,11 +2,14 @@ include_directories (${libtransport_SOURCE_DIR}/backends/twitter/libtwitcurl)
 
FILE(GLOB SRC *.cpp libtwitcurl/*.cpp Requests/*.cpp)
 
add_executable(spectrum2_twitter_backend ${SRC})
 

	
 
if (NOT WIN32)
 
target_link_libraries(spectrum2_twitter_backend curl transport pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
 
find_package(curl)
 

	
 
if(CURL_FOUND)
 
message(STATUS "Using curl ${CURL_VERSION_STRING}: ${CURL_INCLUDE_DIRS} ${CURL_LIBRARIES}")
 
include_directories (${CURL_INCLUDE_DIRS}) 
 
target_link_libraries(spectrum2_twitter_backend transport ${CURL_LIBRARIES} ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
 
else()
 
include_directories("${CMAKE_SOURCE_DIR}/msvc-deps/curl/include")
 
target_link_libraries(spectrum2_twitter_backend libcurl transport ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
 
message(FATAL_ERROR "curl not found")
 
endif()
 

	
 
INSTALL(TARGETS spectrum2_twitter_backend RUNTIME DESTINATION bin)
backends/twitter/TwitterPlugin.cpp
Show inline comments
 
@@ -649,7 +649,11 @@ void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends
 
				std::string lastTweet = friends[i].getLastStatus().getTweet();
 
				//LOG4CXX_INFO(logger, user << " - " << SHA(friendAvatars[i]))
 
				handleBuddyChanged(user, friends[i].getScreenName(), friends[i].getUserName(), std::vector<std::string>(), 
 
#if HAVE_SWIFTEN_3
 
					pbnetwork::STATUS_ONLINE, lastTweet, Swift::byteArrayToString(cryptoProvider->getSHA1Hash(Swift::createByteArray(friendAvatars[i]))));
 
#else
 
								   pbnetwork::STATUS_ONLINE, lastTweet, SHA(friendAvatars[i]));
 
#endif
 
			}
 
			else if(userdb[user].twitterMode == CHATROOM)
 
				handleParticipantChanged(user, friends[i].getScreenName(), adminChatRoom, 0, pbnetwork::STATUS_ONLINE);
 
@@ -821,7 +825,11 @@ void TwitterPlugin::createFriendResponse(std::string &user, User &frnd, std::str
 
	
 
	LOG4CXX_INFO(logger, user << " - " << frnd.getScreenName() << ", " << frnd.getProfileImgURL())
 
	if(userdb[user].twitterMode == MULTIPLECONTACT) {
 
#if HAVE_SWIFTEN_3
 
		handleBuddyChanged(user, frnd.getScreenName(), frnd.getUserName(), std::vector<std::string>(), pbnetwork::STATUS_ONLINE, "", Swift::byteArrayToString(cryptoProvider->getSHA1Hash(Swift::createByteArray(img))));
 
#else
 
		handleBuddyChanged(user, frnd.getScreenName(), frnd.getUserName(), std::vector<std::string>(), pbnetwork::STATUS_ONLINE, "", SHA(img));
 
#endif
 
	} else if(userdb[user].twitterMode == CHATROOM) {
 
		handleParticipantChanged(user, frnd.getScreenName(), adminChatRoom, 0, pbnetwork::STATUS_ONLINE);
 
	}
backends/twitter/TwitterPlugin.h
Show inline comments
 
@@ -32,9 +32,14 @@
 
#include <queue>
 
#include <set>
 
#include <cstdio>
 

	
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/Crypto/CryptoProvider.h>
 
#include <Swiften/Crypto/PlatformCryptoProvider.h>
 
#else
 
#include "Swiften/StringCodecs/SHA1.h"
 

	
 
#endif
 
using namespace boost::filesystem;
 
using namespace boost::program_options;
 
using namespace Transport;
 
@@ -51,6 +56,9 @@ class TwitterPlugin : public NetworkPlugin {
 
		Swift::BoostNetworkFactories *m_factories;
 
		Swift::BoostIOServiceThread m_boostIOServiceThread;
 
		boost::shared_ptr<Swift::Connection> m_conn;
 
#if HAVE_SWIFTEN_3
 
		boost::shared_ptr<Swift::CryptoProvider> cryptoProvider;
 
#endif
 
		Swift::Timer::ref tweet_timer;
 
		Swift::Timer::ref message_timer;
 
		StorageBackend *storagebackend;
backends/twitter/libtwitcurl/twitcurl.cpp
Show inline comments
 
#define NOMINMAX
 
#include <algorithm>
 
#include <memory.h>
 
#include "twitcurlurls.h"
 
#include "twitcurl.h"
cmake_modules/SwiftenConfig.cmake
Show inline comments
 
FIND_LIBRARY(SWIFTEN_LIBRARY NAMES Swiften HINTS ../lib)
 
FIND_LIBRARY(SWIFTEN_LIBRARY NAMES Swiften Swiften3 HINTS ../lib)
 
FIND_PATH(SWIFTEN_INCLUDE_DIR NAMES "Swiften/Swiften.h" PATH_SUFFIXES libSwiften Swiften HINTS ../include)
 
 
if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
include/Swiften/Elements/PubSubItem.cpp
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubItem.h
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubPayload.cpp
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubPayload.h
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubPublishPayload.cpp
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubPublishPayload.h
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubSubscribePayload.cpp
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubSubscribePayload.h
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubSubscriptionPayload.cpp
Show inline comments
 
deleted file
include/Swiften/Elements/PubSubSubscriptionPayload.h
Show inline comments
 
deleted file
include/Swiften/FileTransfer/CombinedOutgoingFileTransferManager.cpp
Show inline comments
 
@@ -43,8 +43,10 @@ boost::shared_ptr<OutgoingFileTransfer> CombinedOutgoingFileTransferManager::cre
 
		//jsManager->getSession(receipient, idGenerator->generateID());
 
		assert(jingleSession);
 
		jsManager->registerOutgoingSession(from, jingleSession);
 
#if !HAVE_SWIFTEN_3
 
		boost::shared_ptr<OutgoingJingleFileTransfer> jingleFT =  boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer(jingleSession, remoteFactory, localFactory, iqRouter, idGenerator, from, receipient, readBytestream, fileInfo, bytestreamRegistry, bytestreamProxy));
 
		return jingleFT;
 
#endif
 
	}
 
 
	if (!fullJID.is_initialized()) {
include/Swiften/FileTransfer/CombinedOutgoingFileTransferManager.h
Show inline comments
 
@@ -12,6 +12,9 @@
 
#include <Swiften/JID/JID.h>
 
 
#include "transport/presenceoracle.h"
 
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
namespace Swift {
 
include/Swiften/FileTransfer/MyOutgoingSIFileTransfer.cpp
Show inline comments
 
@@ -40,12 +40,14 @@ void MyOutgoingSIFileTransfer::cancel() {
 
	if (ibbSession) {
 
		ibbSession->stop();
 
	}
 
#if !HAVE_SWIFTEN_3
 
	SOCKS5BytestreamServerSession *serverSession = registry->getConnectedSession(SOCKS5BytestreamRegistry::getHostname(id, from, to));
 
	if (serverSession) {
 
		serverSession->stop();
 
	}
 
 
	onStateChange(FileTransfer::State(FileTransfer::State::Canceled));
 
#endif
 
}
 
 
void MyOutgoingSIFileTransfer::handleStreamInitiationRequestResponse(StreamInitiation::ref response, ErrorPayload::ref error) {
 
@@ -54,8 +56,10 @@ void MyOutgoingSIFileTransfer::handleStreamInitiationRequestResponse(StreamIniti
 
	}
 
	else {
 
		if (response->getRequestedMethod() == "http://jabber.org/protocol/bytestreams") {
 
#if !HAVE_SWIFTEN_3
 
			registry->addReadBytestream(SOCKS5BytestreamRegistry::getHostname(id, from, to), bytestream);
 
			socksServer->addReadBytestream(id, from, to, bytestream);
 
#endif
 
			Bytestreams::ref bytestreams(new Bytestreams());
 
			bytestreams->setStreamID(id);
 
			HostAddressPort addressPort = socksServer->getAddressPort();
 
@@ -68,8 +72,9 @@ void MyOutgoingSIFileTransfer::handleStreamInitiationRequestResponse(StreamIniti
 
			ibbSession = boost::shared_ptr<IBBSendSession>(new IBBSendSession(id, from, to, bytestream, iqRouter));
 
			ibbSession->onFinished.connect(boost::bind(&MyOutgoingSIFileTransfer::handleIBBSessionFinished, this, _1));
 
			ibbSession->start();
 

	
 
#if !HAVE_SWIFTEN_3
 
			onStateChange(FileTransfer::State(FileTransfer::State::Transferring));
 
#endif
 
		}
 
	}
 
}
 
@@ -79,13 +84,13 @@ void MyOutgoingSIFileTransfer::handleBytestreamsRequestResponse(Bytestreams::ref
 
		finish(FileTransferError());
 
		return;
 
	}
 

	
 
#if !HAVE_SWIFTEN_3
 
	SOCKS5BytestreamServerSession *serverSession = registry->getConnectedSession(SOCKS5BytestreamRegistry::getHostname(id, from, to));
 
// 	serverSession->onBytesSent.connect(boost::bind(boost::ref(onProcessedBytes), _1));
 
// 	serverSession->onFinished.connect(boost::bind(&OutgoingJingleFileTransfer::handleTransferFinished, this, _1));
 
	serverSession->startTransfer();
 
	onStateChange(FileTransfer::State(FileTransfer::State::Transferring));
 
	>
 
#endif	
 
	//socksServer->onTransferFinished.connect();
 
}
 
 
@@ -94,6 +99,7 @@ void MyOutgoingSIFileTransfer::finish(boost::optional<FileTransferError> error)
 
		ibbSession->onFinished.disconnect(boost::bind(&MyOutgoingSIFileTransfer::handleIBBSessionFinished, this, _1));
 
		ibbSession.reset();
 
	}
 
#if !HAVE_SWIFTEN_3
 
	socksServer->removeReadBytestream(id, from, to);
 
	if(error) {
 
		onStateChange(FileTransfer::State(FileTransfer::State::Canceled));
 
@@ -101,6 +107,7 @@ void MyOutgoingSIFileTransfer::finish(boost::optional<FileTransferError> error)
 
	else {
 
		onStateChange(FileTransfer::State(FileTransfer::State::Finished));
 
	}
 
#endif
 
	onFinished(error);
 
}
 
include/Swiften/FileTransfer/MyOutgoingSIFileTransfer.h
Show inline comments
 
@@ -18,6 +18,8 @@
 
#include <Swiften/Elements/Bytestreams.h>
 
#include <Swiften/Elements/ErrorPayload.h>
 
#include <Swiften/FileTransfer/IBBSendSession.h>
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
namespace Swift {
 
	class IQRouter;
include/Swiften/Network/DummyConnectionServer.cpp
Show inline comments
 
deleted file
include/Swiften/Network/DummyConnectionServer.h
Show inline comments
 
deleted file
include/Swiften/Network/DummyConnectionServerFactory.cpp
Show inline comments
 
deleted file
include/Swiften/Network/DummyConnectionServerFactory.h
Show inline comments
 
deleted file
include/Swiften/Network/DummyNetworkFactories.h
Show inline comments
 
@@ -7,9 +7,7 @@
 
#pragma once
 
 
#include <Swiften/Version.h>
 
//#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
// Swiften 3 was not released yet and these changes are not in 3.0alpha
 
#define HAVE_SWIFTEN_3 0
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
#include <Swiften/Network/NetworkFactories.h>
 
#include <Swiften/Parser/PlatformXMLParserFactory.h>
include/Swiften/Parser/PayloadParsers/PubSubItemParser.cpp
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubItemParser.h
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubPayloadParser.cpp
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubPayloadParser.h
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubPublishPayloadParser.cpp
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubPublishPayloadParser.h
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubSubscribePayloadParser.cpp
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubSubscribePayloadParser.h
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubSubscriptionPayloadParser.cpp
Show inline comments
 
deleted file
include/Swiften/Parser/PayloadParsers/PubSubSubscriptionPayloadParser.h
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.cpp
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubPayloadSerializer.cpp
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubPayloadSerializer.h
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubPublishPayloadSerializer.cpp
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubPublishPayloadSerializer.h
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubSubscribePayloadSerializer.cpp
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubSubscribePayloadSerializer.h
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionPayloadSerializer.cpp
Show inline comments
 
deleted file
include/Swiften/Serializer/PayloadSerializers/PubSubSubscriptionPayloadSerializer.h
Show inline comments
 
deleted file
include/Swiften/Server/ServerFromClientSession.cpp
Show inline comments
 
@@ -76,7 +76,7 @@ void ServerFromClientSession::handlePasswordInvalid(const std::string &error) {
 
	}
 
}
 
 
void ServerFromClientSession::handleElement(boost::shared_ptr<Element> element) {
 
void ServerFromClientSession::handleElement(boost::shared_ptr<ToplevelElement> element) {
 
	if (isInitialized()) {
 
		onElementReceived(element);
 
	}
include/Swiften/Server/ServerFromClientSession.h
Show inline comments
 
@@ -16,6 +16,8 @@
 
#include <Swiften/Network/Connection.h>
 
#include <Swiften/Base/ByteArray.h>
 
#include <Swiften/TLS/CertificateWithKey.h>
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
namespace Swift {
 
	class ProtocolHeader;
 
@@ -60,7 +62,11 @@ namespace Swift {
 
			void handlePasswordInvalid(const std::string &error = "");
 
 
		private:
 
#if HAVE_SWIFTEN_3
 
			void handleElement(boost::shared_ptr<ToplevelElement>);
 
#else		
 
			void handleElement(boost::shared_ptr<Element>);
 
#endif
 
			void handleStreamStart(const ProtocolHeader& header);
 
			void handleSessionFinished(const boost::optional<SessionError>&);
 
include/Swiften/Server/ServerStanzaChannel.cpp
Show inline comments
 
@@ -63,8 +63,11 @@ void ServerStanzaChannel::handleDataRead(const SafeByteArray &data, const boost:
 
		onPresenceReceived(presence);
 
	}
 
}
 

	
 
#if HAVE_SWIFTEN_3
 
void ServerStanzaChannel::finishSession(const JID& to, boost::shared_ptr<ToplevelElement> element, bool last) {
 
#else
 
void ServerStanzaChannel::finishSession(const JID& to, boost::shared_ptr<Element> element, bool last) {
 
#endif
 
	std::vector<boost::shared_ptr<ServerFromClientSession> > candidateSessions;
 
	for (std::list<boost::shared_ptr<ServerFromClientSession> >::const_iterator i = sessions[to.toBare().toString()].begin(); i != sessions[to.toBare().toString()].end(); ++i) {
 
		candidateSessions.push_back(*i);
include/Swiften/Server/ServerStanzaChannel.h
Show inline comments
 
@@ -15,6 +15,8 @@
 
#include "Swiften/Elements/IQ.h"
 
#include "Swiften/Elements/Presence.h"
 
#include "Swiften/TLS/Certificate.h"
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
namespace Swift {
 
	class Error;
 
@@ -26,9 +28,11 @@ namespace Swift {
 
			void sendIQ(boost::shared_ptr<IQ> iq);
 
			void sendMessage(boost::shared_ptr<Message> message);
 
			void sendPresence(boost::shared_ptr<Presence> presence);
 

	
 
#if HAVE_SWIFTEN_3
 
			void finishSession(const JID& to, boost::shared_ptr<ToplevelElement> element, bool last = false);
 
#else
 
			void finishSession(const JID& to, boost::shared_ptr<Element> element, bool last = false);
 

	
 
#endif
 
			bool getStreamManagementEnabled() const {
 
				return false;
 
			}
include/transport/filetransfermanager.h
Show inline comments
 
@@ -19,16 +19,26 @@
 
 */
 
 
#pragma once
 

	
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#include <Swiften/Elements/StreamInitiationFileInfo.h>
 
#if !HAVE_SWIFTEN_3
 
#include <Swiften/FileTransfer/ConnectivityManager.h>
 
#endif
 
#include <Swiften/FileTransfer/CombinedOutgoingFileTransferManager.h>
 
#include <Swiften/FileTransfer/IncomingFileTransferManager.h>
 
#if !HAVE_SWIFTEN_3
 
#include <Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGeneratorFactory.h>
 
#include <Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelectorFactory.h>
 
#else
 
#include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h>
 
#include <Swiften/FileTransfer/SOCKS5BytestreamServerManager.h>
 
#endif
 
#include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h>
 
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
 
#if !HAVE_SWIFTEN_3
 
#include <Swiften/FileTransfer/SOCKS5BytestreamProxy.h>
 
#endif
 
 
namespace Transport {
 
 
@@ -59,10 +69,15 @@ class FileTransferManager {
 
		Swift::LocalJingleTransportCandidateGeneratorFactory* m_localCandidateGeneratorFactory;
 
		Swift::JingleSessionManager *m_jingleSessionManager;
 
		Swift::SOCKS5BytestreamRegistry* m_bytestreamRegistry;
 
#if HAVE_SWIFTEN_3
 
		Swift::SOCKS5BytestreamServerManager* m_proxyServerManager;
 
		Swift::SOCKS5BytestreamProxiesManager *m_proxyManager;
 
#else
 
		Swift::SOCKS5BytestreamServer* m_bytestreamServer;
 
		Swift::SOCKS5BytestreamProxy* m_bytestreamProxy;
 
		Swift::SOCKS5BytestreamServer *bytestreamServer;
 
		Swift::ConnectivityManager* m_connectivityManager;
 
#endif
 
};
 
 
}
include/transport/networkpluginserver.h
Show inline comments
 
@@ -35,6 +35,8 @@
 
#include "Swiften/Serializer/XMPPSerializer.h"
 
#include "storagebackend.h"
 
#include "transport/filetransfermanager.h"
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
namespace Transport {
 
 
@@ -159,9 +161,11 @@ class NetworkPluginServer : Swift::XMPPParserClient {
 
		void handleRawPresenceReceived(boost::shared_ptr<Swift::Presence> presence);
 
 
		void handleStreamStart(const Swift::ProtocolHeader&) {}
 

	
 
#if HAVE_SWIFTEN_3
 
		void handleElement(boost::shared_ptr<Swift::ToplevelElement> element);
 
#else
 
		void handleElement(boost::shared_ptr<Swift::Element> element);
 

	
 
#endif
 
		void handleStreamEnd() {}
 
 
		UserManager *m_userManager;
include/transport/settingsadhoccommand.h
Show inline comments
 
@@ -25,6 +25,8 @@
 
#include <map>
 
#include "transport/adhoccommand.h"
 
#include "transport/adhoccommandfactory.h"
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
 
namespace Transport {
include/transport/userregistration.h
Show inline comments
 
@@ -24,6 +24,8 @@
 
#include "Swiften/Elements/InBandRegistrationPayload.h"
 
#include "Swiften/Elements/RosterPayload.h"
 
#include <boost/signal.hpp>
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
 
namespace Transport {
 
msvc-deps/CMakeLists.txt
Show inline comments
 
ADD_SUBDIRECTORY(sqlite3)
 
ADD_SUBDIRECTORY(curl)
msvc-deps/curl
Show inline comments
 
Subproject commit 9ce2d7001939b795b45a8ce7700d1a3dcde0475d
 
Subproject commit f39b1c080129c01c8204d3a5a40aad038c7a57f3
src/discoinforesponder.cpp
Show inline comments
 
@@ -44,6 +44,9 @@ DiscoInfoResponder::DiscoInfoResponder(Swift::IQRouter *router, Config *config)
 
	m_transportInfo.addIdentity(DiscoInfo::Identity(CONFIG_STRING(m_config, "identity.name"),
 
													CONFIG_STRING(m_config, "identity.category"),
 
													CONFIG_STRING(m_config, "identity.type")));
 
#if HAVE_SWIFTEN_3
 
	crypto = boost::shared_ptr<CryptoProvider>(PlatformCryptoProvider::create());
 
#endif
 
 
	updateFeatures();
 
}
 
@@ -93,8 +96,11 @@ void DiscoInfoResponder::setBuddyFeatures(std::list<std::string> &f) {
 
			m_buddyInfo->addFeature(*it);
 
		}
 
	}
 

	
 
#if HAVE_SWIFTEN_3
 
	CapsInfoGenerator caps("spectrum", crypto.get());
 
#else
 
	CapsInfoGenerator caps("spectrum");
 
#endif
 
	m_capsInfo = caps.generateCapsInfo(*m_buddyInfo);
 
	onBuddyCapsInfoChanged(m_capsInfo);
 
}
src/discoinforesponder.h
Show inline comments
 
@@ -26,6 +26,13 @@
 
#include "Swiften/Queries/GetResponder.h"
 
#include "Swiften/Elements/DiscoInfo.h"
 
#include "Swiften/Elements/CapsInfo.h"
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/Crypto/CryptoProvider.h>
 
#include <Swiften/Crypto/PlatformCryptoProvider.h>
 
#endif
 
 
 
namespace Transport {
 
 
@@ -60,6 +67,9 @@ class DiscoInfoResponder : public Swift::GetResponder<Swift::DiscoInfo> {
 
		Swift::CapsInfo m_capsInfo;
 
		std::map<std::string, std::string> m_rooms;
 
		std::map<std::string, std::string> m_commands;
 
#if HAVE_SWIFTEN_3
 
		boost::shared_ptr<Swift::CryptoProvider> crypto;
 
#endif
 
};
 
 
}
src/filetransfermanager.cpp
Show inline comments
 
@@ -35,38 +35,51 @@ FileTransferManager::FileTransferManager(Component *component, UserManager *user
 
	m_userManager = userManager;
 
 
	m_jingleSessionManager = new Swift::JingleSessionManager(m_component->getIQRouter());
 
#if !HAVE_SWIFTEN_3
 
	m_connectivityManager = new Swift::ConnectivityManager(m_component->getNetworkFactories()->getNATTraverser());
 
#endif
 
	m_bytestreamRegistry = new Swift::SOCKS5BytestreamRegistry();
 
#if !HAVE_SWIFTEN_3
 
	m_bytestreamProxy = new Swift::SOCKS5BytestreamProxy(m_component->getNetworkFactories()->getConnectionFactory(), m_component->getNetworkFactories()->getTimerFactory());
 

	
 
	m_localCandidateGeneratorFactory = new Swift::DefaultLocalJingleTransportCandidateGeneratorFactory(m_connectivityManager, m_bytestreamRegistry, m_bytestreamProxy, "thishouldnotbeused");
 
	m_remoteCandidateSelectorFactory = new Swift::DefaultRemoteJingleTransportCandidateSelectorFactory(m_component->getNetworkFactories()->getConnectionFactory(), m_component->getNetworkFactories()->getTimerFactory());
 

	
 
#else
 
	m_proxyManager = new Swift::SOCKS5BytestreamProxiesManager(m_component->getNetworkFactories()->getConnectionFactory(), m_component->getNetworkFactories()->getTimerFactory(), m_component->getNetworkFactories()->getDomainNameResolver(), m_component->getIQRouter(), "bar.com");
 
#endif
 
	boost::shared_ptr<Swift::ConnectionServer> server = m_component->getNetworkFactories()->getConnectionServerFactory()->createConnectionServer(19645);
 
	server->start();
 
#if HAVE_SWIFTEN_3
 
	m_proxyServerManager = new Swift::SOCKS5BytestreamServerManager(m_bytestreamRegistry, m_component->getNetworkFactories()->getConnectionServerFactory(), m_component->getNetworkFactories()->getNetworkEnvironment(), m_component->getNetworkFactories()->getNATTraverser());
 
#else
 
	m_bytestreamServer = new Swift::SOCKS5BytestreamServer(server, m_bytestreamRegistry);
 
	m_bytestreamServer->start();
 

	
 
	m_outgoingFTManager = new Swift::CombinedOutgoingFileTransferManager(m_jingleSessionManager, m_component->getIQRouter(),
 
		m_userManager, m_remoteCandidateSelectorFactory,
 
		m_localCandidateGeneratorFactory, m_bytestreamRegistry,
 
		m_bytestreamProxy, m_component->getPresenceOracle(),
 
		m_bytestreamServer);
 
#endif
 
 
	
 
 
// WARNING: Swiften crashes when this is uncommented... But we probably need it for working Jingle FT
 
// 	m_connectivityManager->addListeningPort(19645);
 
}
 
 
FileTransferManager::~FileTransferManager() {
 
#if !HAVE_SWIFTEN_3
 
	m_bytestreamServer->stop();
 
	delete m_outgoingFTManager;
 
	delete m_remoteCandidateSelectorFactory;
 
	delete m_localCandidateGeneratorFactory;
 
#endif
 
	delete m_outgoingFTManager;
 
	delete m_jingleSessionManager;
 
	delete m_bytestreamRegistry;
 
#if !HAVE_SWIFTEN_3
 
	delete m_bytestreamServer;
 
	delete m_bytestreamProxy;
 
	delete m_connectivityManager;
 
#endif
 
}
 
 
FileTransferManager::Transfer FileTransferManager::sendFile(User *user, Buddy *buddy, boost::shared_ptr<Swift::ReadBytestream> byteStream, const Swift::StreamInitiationFileInfo &info) {
src/networkpluginserver.cpp
Show inline comments
 
@@ -271,7 +271,11 @@ NetworkPluginServer::NetworkPluginServer(Component *component, Config *config, U
 
	m_lastLogin = 0;
 
	m_xmppParser = new Swift::XMPPParser(this, &m_collection, component->getNetworkFactories()->getXMLParserFactory());
 
	m_xmppParser->parse("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='localhost' version='1.0'>");
 
#if HAVE_SWIFTEN_3
 
	m_serializer = new Swift::XMPPSerializer(&m_collection2, Swift::ClientStreamType, false);
 
#else
 
	m_serializer = new Swift::XMPPSerializer(&m_collection2, Swift::ClientStreamType);
 
#endif
 
	m_discoItemsResponder = discoItemsResponder;
 
	m_component->m_factory = new NetworkFactory(this);
 
	m_userManager->onUserCreated.connect(boost::bind(&NetworkPluginServer::handleUserCreated, this, _1));
 
@@ -834,8 +838,10 @@ void NetworkPluginServer::handleFTStartPayload(const std::string &data) {
 
	}
 
 
	m_filetransfers[++bytestream_id] = transfer;
 
#if !HAVE_SWIFTEN_3
 
	transfer.ft->onStateChange.connect(boost::bind(&NetworkPluginServer::handleFTStateChanged, this, _1, payload.username(), payload.buddyname(), payload.filename(), payload.size(), bytestream_id));
 
	transfer.ft->start();
 
#endif
 
}
 
 
void NetworkPluginServer::handleFTFinishPayload(const std::string &data) {
 
@@ -991,8 +997,11 @@ void NetworkPluginServer::handleRoomListPayload(const std::string &data) {
 
		m_discoItemsResponder->addRoom(Swift::JID::getEscapedNode(payload.room(i)) + "@" + m_component->getJID().toString(), payload.name(i));
 
	}
 
}
 

	
 
#if HAVE_SWIFTEN_3
 
void NetworkPluginServer::handleElement(boost::shared_ptr<Swift::ToplevelElement> element) {
 
#else
 
void NetworkPluginServer::handleElement(boost::shared_ptr<Swift::Element> element) {
 
#endif
 
	boost::shared_ptr<Swift::Stanza> stanza = boost::dynamic_pointer_cast<Swift::Stanza>(element);
 
	if (!stanza) {
 
		return;
 
@@ -1877,12 +1886,14 @@ void NetworkPluginServer::handleFTStateChanged(Swift::FileTransfer::State state,
 
		// TODO: FIXME We have to remove filetransfer when use disconnects
 
		return;
 
	}
 
#if !HAVE_SWIFTEN_3
 
	if (state.state == Swift::FileTransfer::State::Transferring) {
 
		handleFTAccepted(user, buddyName, fileName, size, id);
 
	}
 
	else if (state.state == Swift::FileTransfer::State::Canceled) {
 
		handleFTRejected(user, buddyName, fileName, size);
 
	}
 
#endif
 
}
 
 
void NetworkPluginServer::sendPing(Backend *c) {
src/settingsadhoccommand.cpp
Show inline comments
 
@@ -34,19 +34,29 @@ DEFINE_LOGGER(logger, "SettingsAdHocCommand");
 
 
SettingsAdHocCommand::SettingsAdHocCommand(Component *component, UserManager *userManager, StorageBackend *storageBackend, const Swift::JID &initiator, const Swift::JID &to) : AdHocCommand(component, userManager, storageBackend, initiator, to) {
 
	m_state = Init;
 
#if HAVE_SWIFTEN_3
 
	Swift::FormField::ref field = boost::make_shared<Swift::FormField>(Swift::FormField::BooleanType, "1");
 
#else
 
	Swift::BooleanFormField::ref field;
 
 
	field = Swift::BooleanFormField::create(true);
 
#endif
 
	field->setName("enable_transport");
 
	field->setLabel("Enable transport");
 
	addFormField(field);
 

	
 
#if HAVE_SWIFTEN_3
 
	field = boost::make_shared<Swift::FormField>(Swift::FormField::BooleanType, CONFIG_STRING_DEFAULTED(component->getConfig(), "settings.send_headlines", "0"));
 
#else
 
	field = Swift::BooleanFormField::create(CONFIG_STRING_DEFAULTED(component->getConfig(), "settings.send_headlines", "0") == "1");
 
#endif
 
	field->setName("send_headlines");
 
	field->setLabel("Allow sending messages as headlines");
 
	addFormField(field);
 

	
 
#if HAVE_SWIFTEN_3
 
	field = boost::make_shared<Swift::FormField>(Swift::FormField::BooleanType, CONFIG_STRING_DEFAULTED(component->getConfig(), "settings.stay_connected", "0"));
 
#else
 
	field = Swift::BooleanFormField::create(CONFIG_STRING_DEFAULTED(component->getConfig(), "settings.stay_connected", "0") == "1");
 
#endif
 
	field->setName("stay_connected");
 
	field->setLabel("Stay connected to legacy network when offline on XMPP");
 
	addFormField(field);
 
@@ -59,7 +69,11 @@ boost::shared_ptr<Swift::Command> SettingsAdHocCommand::getForm() {
 
	if (!m_storageBackend) {
 
		boost::shared_ptr<Swift::Command> response(new Swift::Command("settings", m_id, Swift::Command::Completed));
 
		boost::shared_ptr<Swift::Form> form(new Swift::Form());
 
#if HAVE_SWIFTEN_3
 
		form->addField(boost::make_shared<Swift::FormField>(Swift::FormField::FixedType, "This server does not support transport settings. There is no storage backend configured"));
 
#else
 
		form->addField(Swift::FixedFormField::create("This server does not support transport settings. There is no storage backend configured"));
 
#endif
 
		response->setForm(form);
 
		return response;
 
	}
 
@@ -68,7 +82,11 @@ boost::shared_ptr<Swift::Command> SettingsAdHocCommand::getForm() {
 
	if (m_storageBackend->getUser(m_initiator.toBare().toString(), user) == false) {
 
		boost::shared_ptr<Swift::Command> response(new Swift::Command("settings", m_id, Swift::Command::Completed));
 
		boost::shared_ptr<Swift::Form> form(new Swift::Form());
 
#if HAVE_SWIFTEN_3
 
		form->addField(boost::make_shared<Swift::FormField>(Swift::FormField::FixedType, "You are not registered."));
 
#else
 
		form->addField(Swift::FixedFormField::create("You are not registered."));
 
#endif
 
		response->setForm(form);
 
		return response;
 
	}
 
@@ -78,6 +96,14 @@ boost::shared_ptr<Swift::Command> SettingsAdHocCommand::getForm() {
 
 
	BOOST_FOREACH(Swift::FormField::ref field, m_fields) {
 
		// FIXME: Support for more types than boolean
 
#if HAVE_SWIFTEN_3
 
		if (field->getType() == Swift::FormField::BooleanType) {
 
			std::string value = field->getBoolValue() ? "1" : "0";
 
			int type = (int) TYPE_BOOLEAN;
 
			m_storageBackend->getUserSetting(user.id, field->getName(), type, value);
 
			field->setBoolValue(value == "1");
 
		}
 
#else
 
		if (boost::dynamic_pointer_cast<Swift::BooleanFormField>(field)) {
 
			Swift::BooleanFormField::ref f(boost::dynamic_pointer_cast<Swift::BooleanFormField>(field));
 
			std::string value = f->getValue() ? "1" : "0";
 
@@ -85,6 +111,7 @@ boost::shared_ptr<Swift::Command> SettingsAdHocCommand::getForm() {
 
			m_storageBackend->getUserSetting(user.id, f->getName(), type, value);
 
			f->setValue(value == "1");
 
		}
 
#endif			
 
 
		form->addField(field);
 
	}
 
@@ -103,7 +130,14 @@ boost::shared_ptr<Swift::Command> SettingsAdHocCommand::handleResponse(boost::sh
 
			if (!received) {
 
				continue;
 
			}
 

	
 
#if HAVE_SWIFTEN_3
 
			if (received->getType() == Swift::FormField::BooleanType) {
 
				std::string value = received->getBoolValue() ? "1" : "0";
 
				m_storageBackend->updateUserSetting(user.id, received->getName(), value);
 
			} else if (received->getType() == Swift::FormField::TextSingleType) {
 
				m_storageBackend->updateUserSetting(user.id, received->getName(), received->getTextSingleValue());
 
			}
 
#else
 
			// FIXME: Support for more types than boolean
 
			if (boost::dynamic_pointer_cast<Swift::BooleanFormField>(received)) {
 
				Swift::BooleanFormField::ref f(boost::dynamic_pointer_cast<Swift::BooleanFormField>(received));
 
@@ -114,6 +148,7 @@ boost::shared_ptr<Swift::Command> SettingsAdHocCommand::handleResponse(boost::sh
 
				Swift::TextSingleFormField::ref f(boost::dynamic_pointer_cast<Swift::TextSingleFormField>(received));
 
				m_storageBackend->updateUserSetting(user.id, f->getName(), f->getValue());
 
			}
 
#endif
 
		}
 
	}
 
src/transport.cpp
Show inline comments
 
@@ -126,7 +126,11 @@ Component::Component(Swift::EventLoop *loop, Swift::NetworkFactories *factories,
 
	}
 
	else {
 
		LOG4CXX_INFO(logger, "Creating component in gateway mode");
 
#if HAVE_SWIFTEN_3
 
		m_component = new Swift::Component(m_jid, CONFIG_STRING(m_config, "service.password"), m_factories);
 
#else
 
		m_component = new Swift::Component(loop, m_factories, m_jid, CONFIG_STRING(m_config, "service.password"));
 
#endif
 
		m_component->setSoftwareVersion("Spectrum", SPECTRUM_VERSION);
 
		m_component->onConnected.connect(bind(&Component::handleConnected, this));
 
		m_component->onError.connect(boost::bind(&Component::handleConnectionError, this, _1));
 
@@ -155,7 +159,11 @@ Component::Component(Swift::EventLoop *loop, Swift::NetworkFactories *factories,
 
	}
 
 
	m_capsMemoryStorage = new CapsMemoryStorage();
 
#if HAVE_SWIFTEN_3
 
	m_capsManager = new CapsManager(m_capsMemoryStorage, m_stanzaChannel, m_iqRouter, m_factories->getCryptoProvider());
 
#else
 
	m_capsManager = new CapsManager(m_capsMemoryStorage, m_stanzaChannel, m_iqRouter);
 
#endif
 
	m_entityCapsManager = new EntityCapsManager(m_capsManager, m_stanzaChannel);
 
 	m_entityCapsManager->onCapsChanged.connect(boost::bind(&Component::handleCapsChanged, this, _1));
 
	
src/user.cpp
Show inline comments
 
@@ -70,7 +70,11 @@ User::User(const Swift::JID &jid, UserInfo &userInfo, Component *component, User
 
User::~User(){
 
	LOG4CXX_INFO(logger, m_jid.toString() << ": Destroying");
 
	if (m_component->inServerMode()) {
 
#if HAVE_SWIFTEN_3
 
		dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::ToplevelElement>());
 
#else
 
		dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::Element>());
 
#endif
 
	}
 
 
	m_reconnectTimer->stop();
 
@@ -487,7 +491,11 @@ void User::handleDisconnected(const std::string &error, Swift::SpectrumErrorPayl
 
		// 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();
 
#if HAVE_SWIFTEN_3
 
		dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::ToplevelElement>(new Swift::StreamError(Swift::StreamError::UndefinedCondition, error)));
 
#else
 
		dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(m_jid, boost::shared_ptr<Swift::Element>(new Swift::StreamError(Swift::StreamError::UndefinedCondition, error)));
 
#endif
 
		if (m_userManager->getUser(jid) != NULL) {
 
			m_userManager->removeUser(this);
 
		}
src/usermanager.cpp
Show inline comments
 
@@ -566,7 +566,11 @@ void UserManager::connectUser(const Swift::JID &user) {
 
				// Unavailable presence from old session has to be ignored, otherwise it would disconnect the user from legacy network.
 
				m_userRegistry->onPasswordValid(user);
 
				m_component->onUserPresenceReceived.disconnect(bind(&UserManager::handlePresence, this, _1));
 
#if HAVE_SWIFTEN_3
 
				dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(user, boost::shared_ptr<Swift::ToplevelElement>(new Swift::StreamError()), true);
 
#else				
 
				dynamic_cast<Swift::ServerStanzaChannel *>(m_component->getStanzaChannel())->finishSession(user, boost::shared_ptr<Swift::Element>(new Swift::StreamError()), true);
 
#endif
 
				m_component->onUserPresenceReceived.connect(bind(&UserManager::handlePresence, this, _1));
 
			}
 
		}
src/userregistration.cpp
Show inline comments
 
@@ -33,6 +33,9 @@
 
#include <boost/thread.hpp>
 
#include <boost/date_time/posix_time/posix_time.hpp>
 
#include <boost/regex.hpp> 
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/Elements/Form.h>
 
#endif
 
 
using namespace Swift;
 
 
@@ -245,35 +248,56 @@ bool UserRegistration::handleGetRequest(const Swift::JID& from, const Swift::JID
 
	Form::ref form(new Form(Form::FormType));
 
	form->setTitle((("Registration")));
 
	form->setInstructions((instructions));
 

	
 
#if HAVE_SWIFTEN_3
 
	FormField::ref type = boost::make_shared<FormField>(FormField::HiddenType, "jabber:iq:register");	
 
#else
 
	HiddenFormField::ref type = HiddenFormField::create();
 
	type->setName("FORM_TYPE");
 
	type->setValue("jabber:iq:register");
 
#endif
 
	type->setName("FORM_TYPE");
 
	form->addField(type);
 

	
 
#if HAVE_SWIFTEN_3
 
	FormField::ref username = boost::make_shared<FormField>(FormField::TextSingleType, res.uin);
 
#else
 
	TextSingleFormField::ref username = TextSingleFormField::create();
 
	username->setValue(res.uin);
 
#endif
 
	username->setName("username");
 
	username->setLabel((usernameField));
 
	username->setValue(res.uin);
 
	username->setRequired(true);
 
	form->addField(username);
 
 
	if (CONFIG_BOOL_DEFAULTED(m_config, "registration.needPassword", true)) {
 
#if HAVE_SWIFTEN_3
 
		FormField::ref password = boost::make_shared<FormField>(FormField::TextPrivateType);
 
#else
 
		TextPrivateFormField::ref password = TextPrivateFormField::create();
 
#endif
 
		password->setName("password");
 
		password->setLabel((("Password")));
 
		password->setRequired(true);
 
		form->addField(password);
 
	}
 

	
 
#if HAVE_SWIFTEN_3
 
	FormField::ref language = boost::make_shared<FormField>(FormField::ListSingleType);
 
#else
 
	ListSingleFormField::ref language = ListSingleFormField::create();
 
#endif
 
	language->setName("language");
 
	language->setLabel((("Language")));
 
	language->addOption(Swift::FormField::Option(CONFIG_STRING(m_config, "registration.language"), CONFIG_STRING(m_config, "registration.language")));
 
	if (registered)
 
#if HAVE_SWIFTEN_3
 
		language->addValue(res.language);
 
#else
 
		language->setValue(res.language);
 
#endif
 
	else
 
#if HAVE_SWIFTEN_3
 
		language->addValue(CONFIG_STRING(m_config, "registration.language"));
 
#else
 
		language->setValue(CONFIG_STRING(m_config, "registration.language"));
 
#endif
 
	form->addField(language);
 
 
//	TextSingleFormField::ref encoding = TextSingleFormField::create();
 
@@ -286,20 +310,32 @@ bool UserRegistration::handleGetRequest(const Swift::JID& from, const Swift::JID
 
//	form->addField(encoding);
 
 
	if (registered) {
 
#if HAVE_SWIFTEN_3
 
		FormField::ref boolean = boost::make_shared<FormField>(FormField::BooleanType, "0");
 
#else
 
		BooleanFormField::ref boolean = BooleanFormField::create();
 
		boolean->setValue(0);
 
#endif
 
		boolean->setName("unregister");
 
		boolean->setLabel((("Remove your registration")));		
 
		boolean->setValue(0);
 
		form->addField(boolean);
 
	} else {
 
		if (CONFIG_BOOL(m_config,"registration.require_local_account")) {
 
			std::string localUsernameField = CONFIG_STRING(m_config, "registration.local_username_label");
 
#if HAVE_SWIFTEN_3
 
			FormField::ref local_username = boost::make_shared<FormField>(FormField::TextSingleType);
 
#else
 
			TextSingleFormField::ref local_username = TextSingleFormField::create();
 
#endif
 
			local_username->setName("local_username");
 
			local_username->setLabel((localUsernameField));
 
			local_username->setRequired(true);
 
			form->addField(local_username);
 
#if HAVE_SWIFTEN_3
 
			FormField::ref local_password = boost::make_shared<FormField>(FormField::TextPrivateType);
 
#else
 
			TextPrivateFormField::ref local_password = TextPrivateFormField::create();
 
#endif
 
			local_password->setName("local_password");
 
			local_password->setLabel((("Local Password")));
 
			local_password->setRequired(true);
 
@@ -344,57 +380,114 @@ bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID
 
	if (form) {
 
		const std::vector<FormField::ref> fields = form->getFields();
 
		for (std::vector<FormField::ref>::const_iterator it = fields.begin(); it != fields.end(); it++) {
 
#if HAVE_SWIFTEN_3
 
			FormField::ref textSingle = *it;
 
			if (textSingle->getType() == FormField::TextSingleType) {
 
#else
 
			TextSingleFormField::ref textSingle = boost::dynamic_pointer_cast<TextSingleFormField>(*it);
 
			if (textSingle) {
 
#endif
 
				if (textSingle->getName() == "username") {
 
#if HAVE_SWIFTEN_3
 
					payload->setUsername(textSingle->getTextSingleValue());
 
#else
 
					payload->setUsername(textSingle->getValue());
 
#endif
 
				}
 
				else if (textSingle->getName() == "encoding") {
 
#if HAVE_SWIFTEN_3
 
					encoding = textSingle->getTextSingleValue();
 
#else
 
					encoding = textSingle->getValue();
 
#endif
 
				}
 
				// Pidgin sends it as textSingle, not sure why...
 
				else if (textSingle->getName() == "password") {
 
#if HAVE_SWIFTEN_3
 
					payload->setPassword(textSingle->getTextSingleValue());
 
#else
 
					payload->setPassword(textSingle->getValue());
 
#endif
 
				}
 
				else if (textSingle->getName() == "local_username") {
 
#if HAVE_SWIFTEN_3
 
					local_username = textSingle->getTextSingleValue();
 
#else
 
					local_username = textSingle->getValue();
 
#endif
 
				}
 
				// Pidgin sends it as textSingle, not sure why...
 
				else if (textSingle->getName() == "local_password") {
 
#if HAVE_SWIFTEN_3
 
					local_password = textSingle->getTextSingleValue();
 
#else
 
					local_password = textSingle->getValue();
 
#endif
 
				}
 
				// Pidgin sends it as textSingle, not sure why...
 
				else if (textSingle->getName() == "unregister") {
 
#if HAVE_SWIFTEN_3
 
					if (textSingle->getTextSingleValue() == "1" || textSingle->getTextSingleValue() == "true") {
 
#else
 
					if (textSingle->getValue() == "1" || textSingle->getValue() == "true") {
 
#endif
 
						payload->setRemove(true);
 
					}
 
				}
 
				continue;
 
			}
 

	
 
#if HAVE_SWIFTEN_3
 
			FormField::ref textPrivate = *it;
 
			if (textPrivate->getType() == FormField::TextPrivateType) {
 
#else
 
			TextPrivateFormField::ref textPrivate = boost::dynamic_pointer_cast<TextPrivateFormField>(*it);
 
			if (textPrivate) {
 
#endif
 
				if (textPrivate->getName() == "password") {
 
#if HAVE_SWIFTEN_3
 
					payload->setPassword(textPrivate->getTextPrivateValue());
 
#else
 
					payload->setPassword(textPrivate->getValue());
 
#endif
 
				}
 
				else if (textPrivate->getName() == "local_password") {
 
#if HAVE_SWIFTEN_3
 
					local_password = textPrivate->getTextPrivateValue();
 
#else
 
					local_password = textPrivate->getValue();
 
#endif
 
				}
 
				continue;
 
			}
 

	
 
#if HAVE_SWIFTEN_3
 
			FormField::ref listSingle = *it;
 
			if (listSingle->getType() == FormField::ListSingleType) {
 
#else
 
			ListSingleFormField::ref listSingle = boost::dynamic_pointer_cast<ListSingleFormField>(*it);
 
			if (listSingle) {
 
#endif
 
				if (listSingle->getName() == "language") {
 
#if HAVE_SWIFTEN_3
 
					language = listSingle->getValues()[0];
 
#else
 
					language = listSingle->getValue();
 
#endif
 
				}
 
				continue;
 
			}
 

	
 
#if HAVE_SWIFTEN_3
 
			FormField::ref boolean = *it;
 
			if (boolean->getType() == FormField::BooleanType) {
 
#else
 
			BooleanFormField::ref boolean = boost::dynamic_pointer_cast<BooleanFormField>(*it);
 
			if (boolean) {
 
#endif
 
				if (boolean->getName() == "unregister") {
 
#if HAVE_SWIFTEN_3
 
					if (boolean->getBoolValue()) {
 
#else
 
					if (boolean->getValue()) {
 
#endif
 
						payload->setRemove(true);
 
					}
 
				}
0 comments (0 inline, 0 general)