Changeset - 90ef6e3128f2
backends/libyahoo2/main.cpp
Show inline comments
 
// Transport includes
 
#include "transport/config.h"
 
#include "transport/networkplugin.h"
 
#include "transport/logging.h"
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
// Yahoo2
 
#include <yahoo2.h>
 
#include <yahoo2_callbacks.h>
 
#include <stdio.h>
 
#include <stdarg.h>
 
#include <stdlib.h>
 

	
 
#include "yahoohandler.h"
 
#include "yahoolocalaccount.h"
 
#include "httpfetch.h"
 

	
backends/swiften/main.cpp
Show inline comments
 
// Transport includes
 
#include "transport/config.h"
 
#include "transport/networkplugin.h"
 
#include "transport/logging.h"
 

	
 
#include "boost/date_time/posix_time/posix_time.hpp"
 

	
 
// Swiften
 
#include "Swiften/Swiften.h"
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
#ifndef WIN32
 
// for signal handler
 
#include "unistd.h"
 
#include "signal.h"
 
#include "sys/wait.h"
 
#include "sys/signal.h"
 
#endif
 

	
 
#ifndef __FreeBSD__
 
#ifndef __MACH__
 
// malloc_trim
backends/twitter/TwitterPlugin.h
Show inline comments
 
@@ -24,25 +24,25 @@
 

	
 
#include "twitcurl.h"
 
#include "TwitterResponseParser.h"
 

	
 
#include <iostream>
 
#include <sstream>
 
#include <map>
 
#include <vector>
 
#include <queue>
 
#include <set>
 
#include <cstdio>
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#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;
 

	
 
#define STR(x) (std::string("(") + x.from + ", " + x.to + ", " + x.message + ")")
 

	
include/Swiften/FileTransfer/CombinedOutgoingFileTransferManager.h
Show inline comments
 
@@ -5,25 +5,25 @@
 
 */
 

	
 
#pragma once
 

	
 
#include <boost/shared_ptr.hpp>
 
#include <boost/optional.hpp>
 

	
 
#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
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Swift {
 

	
 
class JingleSessionManager;
 
class IQRouter;
 
class EntityCapsProvider;
 
class RemoteJingleTransportCandidateSelectorFactory;
 
class LocalJingleTransportCandidateGeneratorFactory;
 
class OutgoingFileTransfer;
 
class JID;
 
class IDGenerator;
 
class ReadBytestream;
include/Swiften/FileTransfer/MyOutgoingSIFileTransfer.h
Show inline comments
 
@@ -10,25 +10,25 @@
 

	
 
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
 
#include <Swiften/FileTransfer/ReadBytestream.h>
 
#include <Swiften/Base/boost_bsignals.h>
 
#include <Swiften/FileTransfer/FileTransferError.h>
 
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
 
#include <Swiften/JID/JID.h>
 
#include <Swiften/Elements/StreamInitiation.h>
 
#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
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Swift {
 
	class IQRouter;
 
	class SOCKS5BytestreamServer;
 
	class SOCKS5BytestreamRegistry;
 

	
 
	class MyOutgoingSIFileTransfer : public OutgoingFileTransfer {
 
		public:
 
			MyOutgoingSIFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, int size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer, SOCKS5BytestreamRegistry* registry);
 

	
 
			virtual void start();
 
			virtual void stop();
include/Swiften/Network/DummyConnectionServer.h
Show inline comments
 
@@ -6,44 +6,47 @@
 

	
 
#pragma once
 

	
 
#include <boost/shared_ptr.hpp>
 
#include <boost/asio/io_service.hpp>
 
#include <boost/asio/ip/tcp.hpp>
 
#include <boost/enable_shared_from_this.hpp>
 
#include <Swiften/Base/boost_bsignals.h>
 

	
 
#include <Swiften/Network/DummyConnection.h>
 
#include <Swiften/Network/ConnectionServer.h>
 
#include <Swiften/EventLoop/EventOwner.h>
 
#include <Swiften/Version.h>
 

	
 
namespace Swift {
 
	class DummyConnectionServer : public ConnectionServer, public EventOwner, public boost::enable_shared_from_this<DummyConnectionServer> {
 
		public:
 
			typedef boost::shared_ptr<DummyConnectionServer> ref;
 

	
 
			enum Error {
 
				Conflict,
 
				UnknownError
 
			};
 

	
 
			static ref create(EventLoop* eventLoop) {
 
				return ref(new DummyConnectionServer(eventLoop));
 
			}
 

	
 
			void acceptConnection(boost::shared_ptr<Swift::Connection> connection);
 

	
 
			virtual boost::optional<Swift::ConnectionServer::Error> tryStart() {
 
				return boost::optional<Swift::ConnectionServer::Error>();
 
#if (SWIFTEN_VERSION >= 0x030000)
 
			virtual boost::optional<ConnectionServer::Error> tryStart() {
 
				return boost::optional<ConnectionServer::Error>();
 
			}
 
#endif
 

	
 
			virtual void start();
 
			virtual void stop();
 

	
 
			virtual HostAddressPort getAddressPort() const;
 

	
 

	
 
		private:
 
			DummyConnectionServer(EventLoop* eventLoop);
 

	
 

	
 
		private:
include/Swiften/Network/DummyNetworkFactories.h
Show inline comments
 
/*
 
 * Copyright (c) 2010 Remko Tronçon
 
 * Licensed under the GNU General Public License v3.
 
 * See Documentation/Licenses/GPLv3.txt for more information.
 
 */
 

	
 
#pragma once
 

	
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
#include <Swiften/Network/NetworkFactories.h>
 
#include <Swiften/Parser/PlatformXMLParserFactory.h>
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/IDN/IDNConverter.h>
 
#include <Swiften/IDN/PlatformIDNConverter.h>
 
#endif
 

	
 
namespace Swift {
 
	class EventLoop;
 

	
 
	class DummyNetworkFactories : public NetworkFactories {
include/Swiften/Server/ServerFromClientSession.cpp
Show inline comments
 
@@ -20,24 +20,29 @@
 
#include <Swiften/Elements/IQ.h>
 
#include <Swiften/Elements/AuthSuccess.h>
 
#include <Swiften/Elements/AuthFailure.h>
 
#include <Swiften/Elements/AuthRequest.h>
 
#include <Swiften/SASL/PLAINMessage.h>
 
#include <Swiften/StreamStack/StreamStack.h>
 
#include <Swiften/StreamStack/TLSServerLayer.h>
 
#include <Swiften/Elements/StartTLSRequest.h>
 
#include <Swiften/Elements/TLSProceed.h>
 
#include <iostream>
 
#include <Swiften/TLS/CertificateWithKey.h>
 

	
 
#include <Swiften/Version.h>
 
#if (SWIFTEN_VERSION >= 0x030000)
 
#include <Swiften/Elements/ToplevelElement.h>
 
#endif
 

	
 
namespace Swift {
 

	
 
ServerFromClientSession::ServerFromClientSession(
 
		const std::string& id,
 
		boost::shared_ptr<Connection> connection, 
 
		PayloadParserFactoryCollection* payloadParserFactories, 
 
		PayloadSerializerCollection* payloadSerializers,
 
		UserRegistry* userRegistry,
 
		XMLParserFactory* factory,
 
		Swift::JID remoteJID) : 
 
			Session(connection, payloadParserFactories, payloadSerializers, factory),
 
			id_(id),
 
@@ -67,25 +72,29 @@ void ServerFromClientSession::handlePasswordValid() {
 
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);
 
	}
 
}
 

	
 
#if (SWIFTEN_VERSION >= 0x030000)
 
void ServerFromClientSession::handleElement(boost::shared_ptr<ToplevelElement> element) {
 
#else
 
void ServerFromClientSession::handleElement(boost::shared_ptr<Element> element) {	
 
#endif
 
	if (isInitialized()) {
 
		onElementReceived(element);
 
	}
 
	else {
 
		if (AuthRequest* authRequest = dynamic_cast<AuthRequest*>(element.get())) {
 
			if (authRequest->getMechanism() == "PLAIN" || (allowSASLEXTERNAL && authRequest->getMechanism() == "EXTERNAL")) {
 
				if (authRequest->getMechanism() == "EXTERNAL") {
 
						getXMPPLayer()->writeElement(boost::shared_ptr<AuthSuccess>(new AuthSuccess()));
 
						authenticated_ = true;
 
						getXMPPLayer()->resetParser();
 
				}
 
				else {
include/Swiften/Server/ServerFromClientSession.h
Show inline comments
 
@@ -8,25 +8,25 @@
 

	
 
#include <boost/shared_ptr.hpp>
 
#include <Swiften/Base/boost_bsignals.h>
 
#include <boost/enable_shared_from_this.hpp>
 

	
 
#include <string>
 
#include <Swiften/Session/Session.h>
 
#include <Swiften/JID/JID.h>
 
#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
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Swift {
 
	class ProtocolHeader;
 
	class Element;
 
	class Stanza;
 
	class PayloadParserFactoryCollection;
 
	class PayloadSerializerCollection;
 
	class StreamStack;
 
	class UserRegistry;
 
	class XMPPLayer;
 
	class ConnectionLayer;
 
	class Connection;
include/Swiften/Server/ServerStanzaChannel.h
Show inline comments
 
@@ -7,25 +7,25 @@
 
#pragma once
 

	
 
#include <boost/shared_ptr.hpp>
 

	
 
#include "Swiften/Base/IDGenerator.h"
 
#include "Swiften/Server/ServerFromClientSession.h"
 
#include "Swiften/Client/StanzaChannel.h"
 
#include "Swiften/Elements/Message.h"
 
#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
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Swift {
 
	class Error;
 
	class ServerStanzaChannel : public StanzaChannel {
 
		public:
 
			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);
 
#if HAVE_SWIFTEN_3
include/transport/filetransfermanager.h
Show inline comments
 
@@ -11,41 +11,40 @@
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#pragma once
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#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
 

	
 

	
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h>
 
#include <Swiften/FileTransfer/SOCKS5BytestreamServerManager.h>
 
#else
 
#include <Swiften/FileTransfer/ConnectivityManager.h>
 
#include <Swiften/FileTransfer/DefaultLocalJingleTransportCandidateGeneratorFactory.h>
 
#include <Swiften/FileTransfer/DefaultRemoteJingleTransportCandidateSelectorFactory.h>
 
#include <Swiften/FileTransfer/SOCKS5BytestreamProxy.h>
 
#endif
 

	
 
namespace Transport {
 

	
 
class UserManager;
 
class User;
 
class Component;
 
class Buddy;
 

	
 
class FileTransferManager {
 
	public:
include/transport/networkpluginserver.h
Show inline comments
 
@@ -27,25 +27,25 @@
 
#include "Swiften/Network/Connection.h"
 
#include "Swiften/Elements/ChatState.h"
 
#include "Swiften/Elements/RosterItemPayload.h"
 
#include "Swiften/Elements/VCard.h"
 
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
 
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
 
#include "Swiften/Parser/XMPPParser.h"
 
#include "Swiften/Parser/XMPPParserClient.h"
 
#include "Swiften/Serializer/XMPPSerializer.h"
 
#include "storagebackend.h"
 
#include "transport/filetransfermanager.h"
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Transport {
 

	
 
class UserManager;
 
class User;
 
class Component;
 
class Buddy;
 
class LocalBuddy;
 
class Config;
 
class NetworkConversation;
 
class VCardResponder;
 
class RosterResponder;
include/transport/settingsadhoccommand.h
Show inline comments
 
@@ -17,25 +17,25 @@
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#pragma once
 

	
 
#include <string>
 
#include <algorithm>
 
#include <map>
 
#include "transport/adhoccommand.h"
 
#include "transport/adhoccommandfactory.h"
 
#include <Swiften/Version.h>
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 

	
 
namespace Transport {
 

	
 
class Component;
 
class UserManager;
 
class StorageBackend;
 

	
 
class SettingsAdHocCommand : public AdHocCommand {
 
	public:
 
		typedef enum { Init, WaitingForResponse } State;
 

	
include/transport/userregistration.h
Show inline comments
 
@@ -16,25 +16,25 @@
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#pragma once
 

	
 
#include "Swiften/Queries/Responder.h"
 
#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
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Transport {
 

	
 
struct UserInfo;
 
class Component;
 
class StorageBackend;
 
class UserManager;
 
class Config;
 

	
 
/// Allows users to register the transport using service discovery.
 
class UserRegistration : public Swift::Responder<Swift::InBandRegistrationPayload> {
 
	public:
src/discoinforesponder.h
Show inline comments
 
@@ -18,25 +18,25 @@
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#pragma once
 

	
 
#include <vector>
 
#include <list>
 
#include <boost/signal.hpp>
 
#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
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/Crypto/CryptoProvider.h>
 
#include <Swiften/Crypto/PlatformCryptoProvider.h>
 
#endif
 

	
 

	
 
namespace Transport {
 

	
 
class Config;
 

	
 
class DiscoInfoResponder : public Swift::GetResponder<Swift::DiscoInfo> {
 
	public:
src/tests/basictest.h
Show inline comments
 
@@ -36,25 +36,25 @@
 
#include "transport/discoitemsresponder.h"
 
#include "transport/localbuddy.h"
 
#include "transport/storagebackend.h"
 

	
 
#include <Swiften/Swiften.h>
 
#include <Swiften/EventLoop/DummyEventLoop.h>
 
#include <Swiften/Server/Server.h>
 
#include <Swiften/Network/DummyNetworkFactories.h>
 
#include <Swiften/Network/DummyConnectionServer.h>
 
#include "Swiften/Server/ServerStanzaChannel.h"
 
#include "Swiften/Server/ServerFromClientSession.h"
 
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
 
#define HAVE_SWIFTEN_3  SWIFTEN_VERSION >= 0x030000
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
using namespace Transport;
 

	
 
class TestingConversation : public Conversation {
 
	public:
 
		TestingConversation(ConversationManager *conversationManager, const std::string &legacyName, bool muc = false) : Conversation(conversationManager, legacyName, muc) {
 
		}
 

	
 
		// Called when there's new message to legacy network from XMPP network
 
		void sendMessage(boost::shared_ptr<Swift::Message> &message) {
 
			onMessageToSend(this, message);
 
		}
src/tests/settingsadhoccommand.cpp
Show inline comments
 
@@ -10,24 +10,25 @@
 
#include "transport/settingsadhoccommand.h"
 
#include "transport/adhocmanager.h"
 
#include <cppunit/TestFixture.h>
 
#include <cppunit/extensions/HelperMacros.h>
 
#include <Swiften/Swiften.h>
 
#include <Swiften/EventLoop/DummyEventLoop.h>
 
#include <Swiften/Server/Server.h>
 
#include <Swiften/Network/DummyNetworkFactories.h>
 
#include <Swiften/Network/DummyConnectionServer.h>
 
#include "Swiften/Server/ServerStanzaChannel.h"
 
#include "Swiften/Server/ServerFromClientSession.h"
 
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
 
#include "Swiften/Version.h"
 
#include "basictest.h"
 

	
 
using namespace Transport;
 

	
 
class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
 
	CPPUNIT_TEST_SUITE(SettingsAdHocCommandTest);
 
	CPPUNIT_TEST(getItems);
 
	CPPUNIT_TEST(getInfo);
 
	CPPUNIT_TEST(getInfoBare);
 
	CPPUNIT_TEST(execute);
 
	CPPUNIT_TEST(executeTwoCommands);
 
	CPPUNIT_TEST(executeBadSessionID);
 
@@ -138,25 +139,29 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
 

	
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>());
 
			CPPUNIT_ASSERT_EQUAL(std::string("settings"), getStanza(received[0])->getPayload<Swift::Command>()->getNode());
 
			CPPUNIT_ASSERT_EQUAL(Swift::Command::Executing, getStanza(received[0])->getPayload<Swift::Command>()->getStatus());
 

	
 
			// form element
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>()->getForm());
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>()->getForm()->getField("enable_transport"));
 

	
 
			// set enabled_transport = 0
 
			Swift::FormField::ref f = getStanza(received[0])->getPayload<Swift:: Command>()->getForm()->getField("enable_transport");
 
#if (SWIFTEN_VERSION >= 0x030000)
 
			f->setBoolValue(false);
 
#else
 
			boost::dynamic_pointer_cast<Swift::BooleanFormField>(f)->setValue(false);
 
#endif
 

	
 
			std::string sessionId = getStanza(received[0])->getPayload<Swift::Command>()->getSessionID();
 

	
 
			{
 
			std::string value = "0";
 
			int type;
 
			storage->getUserSetting(1, "enable_transport", type, value);
 
			CPPUNIT_ASSERT_EQUAL(std::string("1"), value);
 
			}
 

	
 
			// finish the command
 
			payload = boost::shared_ptr<Swift::Command>(new Swift::Command("settings"));
 
@@ -198,25 +203,29 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
 

	
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>());
 
			CPPUNIT_ASSERT_EQUAL(std::string("settings"), getStanza(received[0])->getPayload<Swift::Command>()->getNode());
 
			CPPUNIT_ASSERT_EQUAL(Swift::Command::Executing, getStanza(received[0])->getPayload<Swift::Command>()->getStatus());
 

	
 
			// form element
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>()->getForm());
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>()->getForm()->getField("enable_transport"));
 

	
 
			// set enabled_transport = 0
 
			f = getStanza(received[0])->getPayload<Swift:: Command>()->getForm()->getField("enable_transport");
 
#if (SWIFTEN_VERSION >= 0x030000)
 
			CPPUNIT_ASSERT_EQUAL(false, f->getBoolValue());
 
#else
 
			CPPUNIT_ASSERT_EQUAL(false, boost::dynamic_pointer_cast<Swift::BooleanFormField>(f)->getValue());
 
#endif
 
		}
 

	
 
		void executeTwoCommands() {
 
			addUser();
 
			boost::shared_ptr<Swift::Command> payload(new Swift::Command("settings"));
 
			boost::shared_ptr<Swift::IQ> iq = Swift::IQ::createRequest(Swift::IQ::Set, Swift::JID("localhost"), "id", payload);
 
			iq->setFrom("user@localhost");
 
			injectIQ(iq);
 
			loop->processEvents();
 

	
 
			CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
 

	
 
@@ -346,25 +355,29 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
 

	
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>());
 
			CPPUNIT_ASSERT_EQUAL(std::string("settings"), getStanza(received[0])->getPayload<Swift::Command>()->getNode());
 
			CPPUNIT_ASSERT_EQUAL(Swift::Command::Executing, getStanza(received[0])->getPayload<Swift::Command>()->getStatus());
 

	
 
			// form element
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>()->getForm());
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>()->getForm()->getField("send_headlines"));
 

	
 
			// set enabled_transport = 0
 
			Swift::FormField::ref f = getStanza(received[0])->getPayload<Swift:: Command>()->getForm()->getField("send_headlines");
 
#if (SWIFTEN_VERSION >= 0x030000)
 
			f->setBoolValue(true);
 
#else
 
			boost::dynamic_pointer_cast<Swift::BooleanFormField>(f)->setValue(true);
 
#endif
 

	
 
			std::string sessionId = getStanza(received[0])->getPayload<Swift::Command>()->getSessionID();
 

	
 
			// finish the command
 
			payload = boost::shared_ptr<Swift::Command>(new Swift::Command("settings"));
 
			payload->setSessionID(sessionId);
 
			payload->setForm(getStanza(received[0])->getPayload<Swift::Command>()->getForm());
 
			iq = Swift::IQ::createRequest(Swift::IQ::Set, Swift::JID("localhost"), "id", payload);
 
			iq->setFrom("user@localhost");
 
			received.clear();
 
			injectIQ(iq);
 
			loop->processEvents();
 
@@ -388,18 +401,22 @@ class SettingsAdHocCommandTest : public CPPUNIT_NS :: TestFixture, public BasicT
 

	
 
			CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[0])));
 
			CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
 

	
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>());
 
			CPPUNIT_ASSERT_EQUAL(std::string("settings"), getStanza(received[0])->getPayload<Swift::Command>()->getNode());
 
			CPPUNIT_ASSERT_EQUAL(Swift::Command::Executing, getStanza(received[0])->getPayload<Swift::Command>()->getStatus());
 

	
 
			// form element
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>()->getForm());
 
			CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::Command>()->getForm()->getField("send_headlines"));
 
			Swift::FormField::ref f = getStanza(received[0])->getPayload<Swift:: Command>()->getForm()->getField("send_headlines");
 
#if (SWIFTEN_VERSION >= 0x030000)
 
			CPPUNIT_ASSERT_EQUAL(true, f->getBoolValue());
 
#else
 
			CPPUNIT_ASSERT_EQUAL(true, boost::dynamic_pointer_cast<Swift::BooleanFormField>(f)->getValue());
 
#endif
 
		}
 

	
 
};
 

	
 
CPPUNIT_TEST_SUITE_REGISTRATION (SettingsAdHocCommandTest);
0 comments (0 inline, 0 general)