Changeset - ce2218d0864b
[Not reviewed]
0 43 0
Vitaly Takmazov - 8 years ago 2017-11-09 15:49:33
vitalyster@gmail.com
using boost::signals2 with compatibility for older swiften
43 files changed with 83 insertions and 120 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -393,28 +393,24 @@ else()
 
		message(FATAL_ERROR "Log4cxx           : no (install log4cxx-devel)")
 
	endif()
 
endif()
 

	
 
if (WIN32)
 
	ADD_DEFINITIONS(-DLOG4CXX_STATIC)
 
	ADD_DEFINITIONS(-D_WIN32_WINNT=0x501)
 
	ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
 
	ADD_DEFINITIONS(-DBOOST_USE_WINDOWS_H)
 
	ADD_DEFINITIONS(-DBOOST_THREAD_USE_LIB)
 
endif()
 

	
 
# We cannot use boost:signals2, because Swiften does not use them,
 
# for now, just ignore the deprecation warning.
 
ADD_DEFINITIONS(-DBOOST_SIGNALS_NO_DEPRECATION_WARNING)
 

	
 
if(CMAKE_BUILD_TYPE MATCHES Debug)
 
	if (CMAKE_COMPILER_IS_GNUCXX)
 
		ADD_DEFINITIONS(-O0)
 
		ADD_DEFINITIONS(-ggdb)
 
	endif()
 
	ADD_DEFINITIONS(-DDEBUG)
 
	message("Debug             : yes")
 
else(CMAKE_BUILD_TYPE MATCHES Debug)
 
	message("Debug             : no (run \"cmake . -DCMAKE_BUILD_TYPE=Debug\")")
 
endif(CMAKE_BUILD_TYPE MATCHES Debug)
 

	
 

	
backends/twitter/Requests/FetchFriends.h
Show inline comments
 
#ifndef FRIENDS_H
 
#define FRIENDS_H
 

	
 
#include "transport/ThreadPool.h"
 
#include "../libtwitcurl/twitcurl.h"
 
#include "../TwitterResponseParser.h"
 
#include "transport/Logging.h"
 
#include <string>
 
#include <boost/signals.hpp>
 
#include <boost/function.hpp>
 
#include <boost/bind.hpp>
 
#include <iostream>
 

	
 
using namespace Transport;
 

	
 
class FetchFriends : public Thread
 
{
 
	twitCurl *twitObj;
 
	std::string user;
 
	std::string replyMsg;
 
	std::vector<User> friends;
backends/twitter/Requests/ProfileImageRequest.h
Show inline comments
 
#ifndef PROFILEIMAGE_H
 
#define PROFILEIMAGE_H
 

	
 
#include "../TwitterResponseParser.h"
 
#include "transport/ThreadPool.h"
 
#include "transport/Logging.h"
 
#include "transport/Config.h"
 
#include <string>
 
#include <boost/signals.hpp>
 
#include <boost/function.hpp>
 
#include <boost/bind.hpp>
 
#include <iostream>
 
#include <sstream>
 

	
 
using namespace Transport;
 
using namespace boost::program_options;
 

	
 
class ProfileImageRequest : public Thread
 
{
 
	std::string user;
 
	std::string buddy;
backends/twitter/TwitterPlugin.h
Show inline comments
 
@@ -10,25 +10,24 @@
 
#include "transport/StorageBackend.h"
 
#include "transport/ThreadPool.h"
 

	
 
#include "Swiften/Swiften.h"
 
#include "Swiften/SwiftenCompat.h"
 
#ifndef _WIN32
 
#include "unistd.h"
 
#include "signal.h"
 
#include "sys/wait.h"
 
#include "sys/signal.h"
 
#endif
 
#include <boost/algorithm/string.hpp>
 
#include <boost/signal.hpp>
 
#include <boost/thread.hpp>
 
#include <boost/thread/mutex.hpp>
 

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

	
 
#include <iostream>
 
#include <sstream>
 
#include <map>
 
#include <vector>
 
#include <queue>
 
#include <set>
include/Swiften/FileTransfer/MyOutgoingSIFileTransfer.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 <boost/shared_ptr.hpp>
 
#include <boost/signals.hpp>
 

	
 
#include "Swiften/SwiftenCompat.h"
 

	
 
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
 
#include <Swiften/FileTransfer/ReadBytestream.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>
 
@@ -27,25 +26,25 @@ 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, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer, SOCKS5BytestreamRegistry* registry);
 

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

	
 
			boost::signal<void (const boost::optional<FileTransferError>&)> onFinished;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void (const boost::optional<FileTransferError>&)> onFinished;
 

	
 
		private:
 
			void handleStreamInitiationRequestResponse(StreamInitiation::ref, ErrorPayload::ref);
 
			void handleBytestreamsRequestResponse(Bytestreams::ref, ErrorPayload::ref);
 
			void finish(boost::optional<FileTransferError> error);
 
			void handleIBBSessionFinished(boost::optional<FileTransferError> error);
 

	
 
		private:
 
			std::string id;
 
			JID from;
 
			JID to;
 
			std::string name;
include/Swiften/Network/DummyConnectionServer.cpp
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.
 
 */
 

	
 
#include <Swiften/Network/DummyConnectionServer.h>
 

	
 
#include <boost/signal.hpp>
 
#include <boost/bind.hpp>
 
#include <boost/system/system_error.hpp>
 
#include <boost/asio/placeholders.hpp>
 

	
 
#include <Swiften/EventLoop/EventLoop.h>
 

	
 
#include "Swiften/SwiftenCompat.h"
 

	
 
namespace Swift {
 

	
 
DummyConnectionServer::DummyConnectionServer(EventLoop* eventLoop) : eventLoop(eventLoop) {
 
}
include/Swiften/Server/Server.cpp
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.
 
 */
 

	
 
#include "Swiften/Server/Server.h"
 

	
 
#include <string>
 
#include <boost/bind.hpp>
 
#include <boost/foreach.hpp>
 
#include <boost/signal.hpp>
 

	
 
#include "Swiften/Base/String.h"
 
#include "Swiften/Network/Connection.h"
 
#include "Swiften/Network/ConnectionServer.h"
 
#include "Swiften/Network/ConnectionServerFactory.h"
 
#include "Swiften/Elements/Element.h"
 
#include "Swiften/Elements/Presence.h"
 
#include "Swiften/Elements/RosterPayload.h"
 
#include "Swiften/Network/NetworkFactories.h"
 
#include "Swiften/Session/SessionTracer.h"
 
#include "Swiften/Elements/IQ.h"
 
#include "Swiften/Elements/VCard.h"
 
@@ -87,25 +86,25 @@ void Server::stop() {
 
		return;
 
	}
 

	
 
	stopping = true;
 

	
 
// 	foreach(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session, serverFromClientSessions) {
 
// 		session->finishSession();
 
// 	}
 
	serverFromClientSessions.clear();
 

	
 
	if (serverFromClientConnectionServer) {
 
		serverFromClientConnectionServer->stop();
 
		BOOST_FOREACH(SWIFTEN_SIGNAL_NAMESPACE::connection& connection, serverFromClientConnectionServerSignalConnections) {
 
		BOOST_FOREACH(SWIFTEN_SIGNAL_CONNECTION_NAMESPACE::connection& connection, serverFromClientConnectionServerSignalConnections) {
 
			connection.disconnect();
 
		}
 
		serverFromClientConnectionServerSignalConnections.clear();
 
		serverFromClientConnectionServer.reset();
 
	}
 

	
 
	stopping = false;
 
// 	onStopped(e);
 
}
 

	
 
void Server::handleNewClientConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> connection) {
 

	
include/Swiften/Server/Server.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 <boost/shared_ptr.hpp>
 
#include <boost/optional.hpp>
 
#include <boost/signals2.hpp>
 
#include <vector>
 

	
 
#include "Swiften/Network/BoostIOServiceThread.h"
 
#include "Swiften/Network/ConnectionServer.h"
 
#include "Swiften/Server/UserRegistry.h"
 
#include "Swiften/Server/ServerSession.h"
 
#include "Swiften/Base/IDGenerator.h"
 
#include "Swiften/Server/ServerFromClientSession.h"
 
#include "Swiften/JID/JID.h"
 
#include "Swiften/Base/ByteArray.h"
 
#include "Swiften/Entity/Entity.h"
 
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
 
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
 
#include "Swiften/SwiftenCompat.h"
 
#include <Swiften/TLS/CertificateWithKey.h>
 
#include <Swiften/Parser/PlatformXMLParserFactory.h>
 
#include <Swiften/SwiftenCompat.h>
 

	
 
namespace Swift {
 
	class ConnectionServer;
 
	class SessionTracer;
 
	class EventLoop;
 
	class NetworkFactories;
 
	class StanzaChannel;
 
	class IQRouter;
 
	class TLSServerContextFactory;
 

	
 
	class Server : public Entity {
 
		public:
 
@@ -50,44 +50,44 @@ namespace Swift {
 
			StanzaChannel* getStanzaChannel() const {
 
				return stanzaChannel_;
 
			}
 

	
 
			IQRouter* getIQRouter() const {
 
				return iqRouter_;
 
			}
 

	
 
			SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> getConnectionServer() const {
 
				return serverFromClientConnectionServer;
 
			}
 

	
 
			boost::signal<void (const SafeByteArray&)> onDataRead;
 
			boost::signal<void (const SafeByteArray&)> onDataWritten;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void (const SafeByteArray&)> onDataRead;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void (const SafeByteArray&)> onDataWritten;
 

	
 
			void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert);
 

	
 
		private:
 
			void handleNewClientConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> c);
 
			void handleSessionStarted(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>);
 
			void handleSessionFinished(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>);
 
			void handleElementReceived(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session);
 
			void handleDataRead(const SafeByteArray&);
 
			void handleDataWritten(const SafeByteArray&);
 

	
 
		private:
 
			IDGenerator idGenerator;
 
			UserRegistry *userRegistry_;
 
			int port_;
 
			EventLoop* eventLoop;
 
			NetworkFactories* networkFactories_;
 
			bool stopping;
 
			SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> serverFromClientConnectionServer;
 
			std::vector<SWIFTEN_SIGNAL_NAMESPACE::connection> serverFromClientConnectionServerSignalConnections;
 
			std::vector<SWIFTEN_SIGNAL_CONNECTION_NAMESPACE::connection> serverFromClientConnectionServerSignalConnections;
 
			std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > serverFromClientSessions;
 
			JID selfJID;
 
			StanzaChannel *stanzaChannel_;
 
			IQRouter *iqRouter_;
 
			TLSServerContextFactory *tlsFactory;
 
			CertificateWithKey::ref cert;
 
			PlatformXMLParserFactory *parserFactory_;
 
			std::string address_;
 
	};
 
}
include/Swiften/Server/ServerFromClientSession.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 <boost/shared_ptr.hpp>
 
#include <boost/enable_shared_from_this.hpp>
 
#include <boost/signals.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)
 

	
 
#include "Swiften/SwiftenCompat.h"
 

	
 
@@ -39,25 +38,25 @@ namespace Swift {
 
	class ServerFromClientSession : public Session {
 
		public:
 
			ServerFromClientSession(
 
					const std::string& id,
 
					SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> connection,
 
					PayloadParserFactoryCollection* payloadParserFactories, 
 
					PayloadSerializerCollection* payloadSerializers,
 
					UserRegistry* userRegistry,
 
					XMLParserFactory* factory,
 
					Swift::JID remoteJID = Swift::JID());
 
			~ServerFromClientSession();
 

	
 
			boost::signal<void ()> onSessionStarted;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onSessionStarted;
 
			void setAllowSASLEXTERNAL();
 
			const std::string &getUser() {
 
				return user_;
 
			}
 

	
 
			void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert);
 

	
 
			Swift::JID getBareJID() {
 
				return Swift::JID(user_, getLocalJID().getDomain());
 
			}
 

	
 
			void handlePasswordValid();
include/Swiften/Server/UserRegistry.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 <string>
 
#include <Swiften/Base/SafeByteArray.h>
 
#include <boost/signal.hpp>
 
#include "Swiften/Server/ServerFromClientSession.h"
 

	
 
namespace Swift {
 
	class JID;
 

	
 
	class UserRegistry {
 
		public:
 
			virtual ~UserRegistry();
 

	
 
			virtual void isValidUserPassword(const JID& user, ServerFromClientSession *session, const SafeByteArray& password) = 0;
 

	
 
			virtual void stopLogin(const JID &/*user*/, ServerFromClientSession *) {};
include/Swiften/StreamStack/TLSServerLayer.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.
 
 */
 

	
 
#include <boost/signals.hpp>
 

	
 
#include "Swiften/Base/SafeByteArray.h"
 
#include "Swiften/StreamStack/StreamLayer.h"
 
#include "Swiften/TLS/Certificate.h"
 
#include <Swiften/TLS/CertificateWithKey.h>
 
#include "Swiften/TLS/CertificateVerificationError.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
namespace Swift {
 
	class TLSServerContext;
 
	class TLSServerContextFactory;
 
	class PKCS12Certificate;
 

	
 
@@ -28,19 +26,19 @@ namespace Swift {
 

	
 
			Certificate::ref getPeerCertificate() const;
 
			SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
 

	
 
			void writeData(const SafeByteArray& data);
 
			void handleDataRead(const SafeByteArray& data);
 

	
 
			TLSServerContext* getContext() const {
 
				return context;
 
			}
 

	
 
		public:
 
			boost::signal<void ()> onError;
 
			boost::signal<void ()> onConnected;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onError;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onConnected;
 

	
 
		private:
 
			TLSServerContext* context;
 
	};
 
}
include/Swiften/SwiftenCompat.h
Show inline comments
 
@@ -17,32 +17,38 @@
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
 

	
 
#include <Swiften/Version.h>
 

	
 
/*
 
 * Define macros for Swiften compatible shared pointer and signal namespaces.
 
 *
 
 * Using these it is possible to declare shared pointers and signals like this:
 
 *
 
 * SWIFTEN_SIGNAL_NAMESPACE::signal signal;
 
 * SWIFTEN_SIGNAL_CONNECTION_NAMESPACE::connection &connection;
 
 * SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Type> ptr;
 
 *
 
 * These are guaranteed to be the same implementation as Swift uses internally,
 
 * thus can be used when passign/retrieveing data from/to swiften.
 
 *
 
 * This is due to Swift 4 moved from boost::shared_ptr to SWIFTEN_SHRPTR_NAMESPACE::shared_ptr
 
 * and from boost::signals to boost::signals2 .
 
 */
 

	
 
#if (SWIFTEN_VERSION >= 0x040000)
 
#define SWIFTEN_UNIQUE_PTR std::unique_ptr
 
#define SWIFTEN_SHRPTR_NAMESPACE std
 
#include <boost/signals2.hpp>
 
#define SWIFTEN_SIGNAL_NAMESPACE boost::signals2
 
#define SWIFTEN_SIGNAL_CONNECTION_NAMESPACE boost::signals2
 
#define SWIFT_HOSTADDRESS(x) *(Swift::HostAddress::fromString(x))
 
#else
 
#define SWIFTEN_UNIQUE_PTR std::auto_ptr
 
#define SWIFTEN_SHRPTR_NAMESPACE boost
 
#define SWIFTEN_SIGNAL_NAMESPACE boost::signals
 
#define BOOST_SIGNALS_NO_DEPRECATION_WARNING
 
#include <boost/signals.hpp>
 
#define SWIFTEN_SIGNAL_NAMESPACE boost
 
#define SWIFTEN_SIGNAL_CONNECTION_NAMESPACE boost::signals
 
#define SWIFT_HOSTADDRESS(x) Swift::HostAddress(x)
 
#endif
include/Swiften/TLS/TLSServerContext.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 <boost/shared_ptr.hpp>
 
#include <boost/signals.hpp>
 

	
 
#include "Swiften/Base/SafeByteArray.h"
 
#include "Swiften/TLS/Certificate.h"
 
#include <Swiften/TLS/CertificateWithKey.h>
 
#include "Swiften/TLS/CertificateVerificationError.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
namespace Swift {
 
	class PKCS12Certificate;
 

	
 
	class TLSServerContext {
 
		public:
 
			virtual ~TLSServerContext();
 

	
 
			virtual void connect() = 0;
 

	
 
			virtual bool setServerCertificate(CertificateWithKey::ref cert) = 0;
 

	
 
			virtual void handleDataFromNetwork(const SafeByteArray&) = 0;
 
			virtual void handleDataFromApplication(const SafeByteArray&) = 0;
 

	
 
			virtual Certificate::ref getPeerCertificate() const = 0;
 
			virtual CertificateVerificationError::ref getPeerCertificateVerificationError() const = 0;
 

	
 
			virtual ByteArray getFinishMessage() const = 0;
 

	
 
		public:
 
			boost::signal<void (const SafeByteArray&)> onDataForNetwork;
 
			boost::signal<void (const SafeByteArray&)> onDataForApplication;
 
			boost::signal<void ()> onError;
 
			boost::signal<void ()> onConnected;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void (const SafeByteArray&)> onDataForNetwork;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void (const SafeByteArray&)> onDataForApplication;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onError;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onConnected;
 
	};
 
}
include/transport/Config.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 <boost/program_options.hpp>
 
#include <boost/foreach.hpp>
 
#include <boost/format.hpp>
 
#include <boost/algorithm/string.hpp>
 
#include <boost/assign.hpp>
 
#include <boost/bind.hpp>
 
#include <boost/signalslib.hpp>
 
#include <Swiften/SwiftenCompat.h>
 

	
 
namespace Transport {
 

	
 
template <class myType>
 
const myType &safeAs(const boost::program_options::variable_value &var, const myType &def) {
 
	try  {
 
		return var.as<myType>();
 
	}
 
	catch(...) {
 
		return def;
 
	}
 
}
 
@@ -115,28 +115,28 @@ class Config {
 
			}
 
			return m_unregistered[key];
 
		}
 

	
 
		SectionValuesCont getSectionValues(const std::string& sectionName);
 
 
 
		std::string getCommandLineArgs() const;
 

	
 
		/// Returns path to config file from which data were loaded.
 
		const std::string &getConfigFile() { return m_file; }
 

	
 
		/// This signal is emitted when config is loaded/reloaded.
 
		boost::signal<void ()> onConfigReloaded;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onConfigReloaded;
 

	
 
		void updateBackendConfig(const std::string &backendConfig);
 
		boost::signal<void ()> onBackendConfigUpdated;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onBackendConfigUpdated;
 

	
 
		static Config *createFromArgs(int argc, char **argv, std::string &error, std::string &host, int &port);
 
	
 
	private:
 
		int m_argc;
 
		char **m_argv;
 
		Variables m_variables;
 
		Variables m_backendConfig;
 
		std::map<std::string, boost::program_options::variable_value> m_unregistered;
 
		std::string m_file;
 
		std::string m_jid;
 
};
include/transport/Frontend.h
Show inline comments
 
@@ -23,26 +23,24 @@
 
#include <string>
 
#include <algorithm>
 
#include <Swiften/EventLoop/EventLoop.h>
 
#include <Swiften/Network/NetworkFactories.h>
 
#include "Swiften/Elements/RosterPayload.h"
 
#include "Swiften/Elements/VCard.h"
 
#include "Swiften/Elements/Message.h"
 
#include "Swiften/Elements/IQ.h"
 
#include "Swiften/Elements/DiscoInfo.h"
 
#include "Swiften/Elements/Presence.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class Config;
 
class UserRegistry;
 
class Component;
 
class User;
 
class Buddy;
 
class RosterManager;
 
class UserManager;
 
class StorageBackend;
 
class Frontend;
 

	
 
@@ -89,24 +87,24 @@ class Frontend {
 

	
 
		virtual UserManager *createUserManager(Component *component, UserRegistry *userRegistry, StorageBackend *storageBackend = NULL) = 0;
 

	
 
		virtual void clearRoomList() = 0;
 
		virtual void addRoomToRoomList(const std::string &handle, const std::string &name) = 0;
 

	
 
		virtual std::string setOAuth2Code(const std::string &code, const std::string &state) { return "OAuth2 code is not needed for this frontend."; }
 
		virtual std::string getOAuth2URL(const std::vector<std::string> &args) { return ""; }
 
		virtual std::string getRegistrationFields() { return "Jabber ID\n3rd-party network username\n3rd-party network password"; }
 

	
 
		virtual bool isRawXMLEnabled() { return false; }
 

	
 
		boost::signal<void (User *, const std::string &name, unsigned int id)> onVCardRequired;
 
		boost::signal<void (User *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCard> vcard)> onVCardUpdated;
 
		boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyUpdated;
 
		boost::signal<void (Buddy *)> onBuddyRemoved;
 
		boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyAdded;
 
		boost::signal<void (Swift::Message::ref message)> onMessageReceived;
 
		boost::signal<void (bool /* isAvailable */)> onAvailableChanged;
 
		boost::signal<void (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Presence>) > onPresenceReceived;
 
		boost::signal<void (const Swift::JID& jid, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info)> onCapabilitiesReceived;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (User *, const std::string &name, unsigned int id)> onVCardRequired;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (User *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCard> vcard)> onVCardUpdated;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyUpdated;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *)> onBuddyRemoved;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyAdded;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Swift::Message::ref message)> onMessageReceived;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (bool /* isAvailable */)> onAvailableChanged;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Presence>) > onPresenceReceived;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const Swift::JID& jid, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info)> onCapabilitiesReceived;
 
};
 

	
 
}
include/transport/HTTPRequest.h
Show inline comments
 

	
 
#pragma once
 

	
 
#include "curl/curl.h"
 
#include "transport/Logging.h"
 
#include "transport/ThreadPool.h"
 
#include <iostream>
 
#include <sstream>
 
#include <string.h>
 
#include "rapidjson/document.h"
 

	
 
#include <boost/signal.hpp>
 
#include <Swiften/SwiftenCompat.h>
 

	
 
namespace Transport {
 

	
 
class HTTPRequest : public Thread {
 
	public:
 
		typedef enum { Get } Type;
 
		typedef boost::function< void (HTTPRequest *, bool, rapidjson::Document &json, const std::string &data) > Callback;
 

	
 
		HTTPRequest(ThreadPool *tp, Type type, const std::string &url, Callback callback);
 
		HTTPRequest(Type type, const std::string &url);
 

	
 
		virtual ~HTTPRequest();
 
@@ -29,25 +29,25 @@ class HTTPRequest : public Thread {
 
		std::string getError() {return std::string(curl_errorbuffer);}
 
		const std::string &getRawData() {
 
			return m_data;
 
		}
 

	
 
		void run();
 
		void finalize();
 

	
 
		const std::string &getURL() {
 
			return m_url;
 
		}
 

	
 
		boost::signal<void ()> onRequestFinished;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onRequestFinished;
 

	
 
		static void globalInit() {
 
			curl_global_init(CURL_GLOBAL_ALL);
 
		}
 

	
 
		static void globalCleanup() {
 
			curl_global_cleanup();
 
		}
 

	
 
	private:
 
		bool init();
 
		bool GET(std::string url, std::string &output);
include/transport/MemoryReadBytestream.h
Show inline comments
 
@@ -13,42 +13,41 @@
 
 * 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 <string>
 
#include <map>
 
#include <boost/signal.hpp>
 

	
 
#include "Swiften/FileTransfer/ReadBytestream.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
namespace Transport {
 

	
 
class MemoryReadBytestream : public Swift::ReadBytestream {
 
	public:
 
		MemoryReadBytestream(unsigned long size);
 
		virtual ~MemoryReadBytestream();
 

	
 
		unsigned long appendData(const std::string &data);
 

	
 
		virtual SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<std::vector<unsigned char> > read(size_t size);
 

	
 
		void setFinished() { m_finished = true; }
 
		bool isFinished() const;
 

	
 
		boost::signal<void ()> onDataNeeded;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onDataNeeded;
 

	
 
	private:
 
		bool m_finished;
 
		std::string m_data;
 
		bool neededData;
 
		unsigned long m_sent;
 
		unsigned long m_size;
 
};
 

	
 
}
include/transport/PresenceOracle.h
Show inline comments
 
@@ -13,47 +13,46 @@
 
 * 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 <map>
 

	
 
#include <boost/signals.hpp>
 

	
 
#include <string>
 
#include <Swiften/Elements/Presence.h>
 
#include <Swiften/Client/StanzaChannel.h>
 
#include <Swiften/SwiftenCompat.h>
 

	
 
namespace Transport {
 

	
 
class Frontend;
 

	
 
class PresenceOracle {
 
	public:
 
		PresenceOracle(Frontend* frontend);
 
		~PresenceOracle();
 

	
 
		Swift::Presence::ref getLastPresence(const Swift::JID&) const;
 
		Swift::Presence::ref getHighestPriorityPresence(const Swift::JID& bareJID) const;
 
		std::vector<Swift::Presence::ref> getAllPresence(const Swift::JID& bareJID) const;
 

	
 
		void clearPresences(const Swift::JID& bareJID);
 

	
 
	public:
 
		boost::signal<void (Swift::Presence::ref)> onPresenceChange;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Swift::Presence::ref)> onPresenceChange;
 

	
 
	private:
 
		void handleIncomingPresence(Swift::Presence::ref presence);
 
		void handleStanzaChannelAvailableChanged(bool);
 

	
 
	private:
 
		typedef std::map<Swift::JID, Swift::Presence::ref> PresenceMap;
 
		typedef std::map<Swift::JID, PresenceMap> PresencesMap;
 
		PresencesMap entries_;
 
		Frontend* frontend_;
 
};
 

	
include/transport/RosterManager.h
Show inline comments
 
@@ -14,33 +14,33 @@
 
 * 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 <string>
 
#include <algorithm>
 
#include <map>
 
#include <boost/signal.hpp>
 
#include <boost/pool/pool_alloc.hpp>
 
#include <boost/pool/object_pool.hpp>
 
// #include "rosterstorage.h"
 
#include "Swiften/Elements/RosterPayload.h"
 
#include "Swiften/Queries/GenericRequest.h"
 
#include "Swiften/Roster/SetRosterRequest.h"
 
#include "Swiften/Elements/Presence.h"
 
#include "Swiften/Network/Timer.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
namespace Transport {
 

	
 
class Buddy;
 
class User;
 
class Component;
 
class StorageBackend;
 
class RosterStorage;
 

	
 
/// Manages roster of one XMPP user.
 
class RosterManager {
 
	public:
 
@@ -85,33 +85,33 @@ class RosterManager {
 
		User *getUser() { return m_user; }
 

	
 
		const BuddiesMap &getBuddies() {
 
			return m_buddies;
 
		}
 

	
 
		bool isRemoteRosterSupported() {
 
			return m_supportRemoteRoster;
 
		}
 

	
 
		/// Called when new Buddy is added to this roster.
 
		/// \param buddy newly added Buddy
 
		boost::signal<void (Buddy *buddy)> onBuddySet;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *buddy)> onBuddySet;
 

	
 
		/// Called when Buddy has been removed from this roster.
 
		/// \param buddy removed Buddy
 
		boost::signal<void (Buddy *buddy)> onBuddyUnset;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *buddy)> onBuddyUnset;
 

	
 
		boost::signal<void (Buddy *buddy)> onBuddyAdded;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *buddy)> onBuddyAdded;
 
		
 
		boost::signal<void (Buddy *buddy)> onBuddyRemoved;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *buddy)> onBuddyRemoved;
 

	
 
		void handleBuddyChanged(Buddy *buddy);
 

	
 
		void handleSubscription(Swift::Presence::ref presence);
 

	
 
		void sendBuddyRosterRemove(Buddy *buddy);
 

	
 
		void sendBuddySubscribePresence(Buddy *buddy);
 
		
 
		void sendBuddyUnsubscribePresence(Buddy *buddy);
 

	
 
		void sendCurrentPresences(const Swift::JID &to);
include/transport/ThreadPool.h
Show inline comments
 
#pragma once 
 

	
 
#include <boost/thread.hpp>
 
#include <boost/thread/mutex.hpp>
 
#include <boost/signals2/signal.hpp>
 
#include <queue>
 
#include <iostream>
 
#include "Swiften/EventLoop/EventLoop.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
namespace Transport {
 

	
 
/*
 
 * Thread serves as a base class for any code that has to be excuted as a thread
 
 * by the ThreadPool class. The run method defines the code that has to be run
 
 * as a theard. For example, code in run could be sendinga request to a server
 
 * waiting for the response and storing the response. When the thread finishes
 
 * execution, the ThreadPool invokes finalize where one could have the code necessary
 
 * to collect all the responses and release any resources. 
 
 *
 
 * NOTE: The object of the Thread class must be valid (in scope) throughout the 
 
@@ -47,25 +47,25 @@ class ThreadPool
 
	const int MAX_THREADS;
 
	int activeThreads;
 
	std::queue<int> freeThreads;
 
	
 
	std::queue<Thread*> requestQueue;
 
	boost::thread **worker;
 

	
 
	boost::mutex count_lock;
 
	boost::mutex pool_lock;
 
	boost::mutex criticalregion;
 
	Swift::EventLoop *loop;
 

	
 
	boost::signals2::signal < void () > onWorkerAvailable;
 
	SWIFTEN_SIGNAL_NAMESPACE::signal < void () > onWorkerAvailable;
 
	
 
	public:
 
	ThreadPool(Swift::EventLoop *loop, int maxthreads);
 
	~ThreadPool();
 
	void runAsThread(Thread *t);
 
	int getActiveThreadCount(); 
 
	void updateActiveThreadCount(int k);
 
	void cleandUp(Thread *, int);
 
	void scheduleFromQueue();
 
	int getFreeThread();
 
	void releaseThread(int i);
 
	void workerBody(Thread *t, int wid);
include/transport/Transport.h
Show inline comments
 
@@ -12,25 +12,24 @@
 
 * 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 <vector>
 
#include <boost/signal.hpp>
 
#include <boost/bind.hpp>
 
#include "Swiften/Network/BoostTimerFactory.h"
 
#include "Swiften/Network/BoostIOServiceThread.h"
 
#include "Swiften/Network/NetworkFactories.h"
 
#include "Swiften/Elements/DiscoInfo.h"
 
#include "Swiften/Elements/Presence.h"
 
#include "Swiften/Elements/IQ.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
namespace Transport {
 
	class StorageBackend;
 
	class Factory;
 
@@ -86,42 +85,42 @@ namespace Transport {
 

	
 
			/// \return Swift::NetworkFactories which can be used to create new connections.
 
			Swift::NetworkFactories *getNetworkFactories() { return m_factories; }
 

	
 
			/// Returns Transport Factory used to create basic Transport components.
 

	
 
			/// \return Transport Factory used to create basic Transport components.
 
			Factory *getFactory() { return m_factory; }
 

	
 
			/// This signal is emitted when server disconnects the transport because of some error.
 

	
 
			/// \param error disconnection error
 
			boost::signal<void (const std::string &error)> onConnectionError;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void (const std::string &error)> onConnectionError;
 

	
 
			/// This signal is emitted when transport successfully connects the server.
 
			boost::signal<void ()> onConnected;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onConnected;
 

	
 
			/// This signal is emitted when XML stanza is sent to server.
 

	
 
			Config *getConfig() { return m_config; }
 

	
 
			/// It's emitted only for presences addressed to transport itself
 
			/// (for example to="j2j.domain.tld") and for presences comming to
 
			/// MUC (for example to="#chat%irc.freenode.org@irc.domain.tld")
 
			/// \param presence Presence.
 
			boost::signal<void (Swift::Presence::ref presence)> onUserPresenceReceived;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void (Swift::Presence::ref presence)> onUserPresenceReceived;
 

	
 
			boost::signal<void (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ>)> onRawIQReceived;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ>)> onRawIQReceived;
 

	
 
			boost::signal<void ()> onAdminInterfaceSet;
 
			SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onAdminInterfaceSet;
 
			
 
			void handlePresence(Swift::Presence::ref presence);
 
			void handleConnected();
 
			void handleConnectionError(const std::string &error);
 
			void handleDataRead(const std::string &data);
 
			void handleDataWritten(const std::string &data);
 

	
 
			Frontend *getFrontend() {
 
				return m_frontend;
 
			}
 

	
 
			PresenceOracle *getPresenceOracle();
include/transport/User.h
Show inline comments
 
@@ -11,25 +11,24 @@
 
 * 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 <boost/signal.hpp>
 
#include <time.h>
 
#include "transport/StorageBackend.h"
 
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
 
#include "Swiften/Elements/SpectrumErrorPayload.h"
 
#include "Swiften/JID/JID.h"
 
#include "Swiften/Elements/Presence.h"
 
#include "Swiften/Elements/Message.h"
 
#include "Swiften/Elements/DiscoInfo.h"
 
#include "Swiften/Network/Timer.h"
 
#include "Swiften/Network/Connection.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
@@ -140,30 +139,30 @@ class User {
 
		}
 

	
 
		void setReconnectLimit(int limit) {
 
			m_reconnectLimit = limit;
 
		}
 

	
 
		void setStorageBackend(StorageBackend *storageBackend) {
 
			m_storageBackend = storageBackend;
 
		}
 

	
 
		void leaveRoom(const std::string &room);
 

	
 
		boost::signal<void ()> onReadyToConnect;
 
		boost::signal<void (Swift::Presence::ref presence)> onPresenceChanged;
 
		boost::signal<void (Swift::Presence::ref presence)> onRawPresenceReceived;
 
		boost::signal<void (const Swift::JID &who, const std::string &room, const std::string &nickname, const std::string &password)> onRoomJoined;
 
		boost::signal<void (const std::string &room)> onRoomLeft;
 
		boost::signal<void ()> onDisconnected;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onReadyToConnect;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Swift::Presence::ref presence)> onPresenceChanged;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Swift::Presence::ref presence)> onRawPresenceReceived;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const Swift::JID &who, const std::string &room, const std::string &nickname, const std::string &password)> onRoomJoined;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const std::string &room)> onRoomLeft;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onDisconnected;
 

	
 
	private:
 
		void onConnectingTimeout();
 

	
 
		Swift::JID m_jid;
 
		Component *m_component;
 
		RosterManager *m_rosterManager;
 
		UserManager *m_userManager;
 
		ConversationManager *m_conversationManager;
 
		PresenceOracle *m_presenceOracle;
 
		UserInfo m_userInfo;
 
		void *m_data;
include/transport/UserManager.h
Show inline comments
 
@@ -11,25 +11,24 @@
 
 * 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 <boost/signal.hpp>
 
#include <string>
 
#include <map>
 
#include "Swiften/Elements/Message.h"
 
#include "Swiften/Elements/Presence.h"
 
#include "Swiften/JID/JID.h"
 
#include "Swiften/Disco/EntityCapsProvider.h"
 
#include "Swiften/Elements/DiscoInfo.h"
 
#include "Swiften/Elements/VCard.h"
 
#include "Swiften/Network/Timer.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
namespace Transport {
 
@@ -90,29 +89,29 @@ class UserManager /*: public Swift::EntityCapsProvider*/ {
 

	
 
		/// Removes user. This function disconnects user and safely removes
 
		/// User class. This does *not* remove user from StorageBackend.
 
		/// \param user User class to remove
 
		void removeUser(User *user, bool onUserBehalf = true);
 

	
 
		void removeAllUsers(bool onUserBehalf = true);
 

	
 
// 		Swift::DiscoInfo::ref getCaps(const Swift::JID&) const;
 

	
 
		/// Called when new User class is created.
 
		/// \param user newly created User class
 
		boost::signal<void (User *user)> onUserCreated;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (User *user)> onUserCreated;
 

	
 
		/// Called when User class is going to be removed
 
		/// \param user removed User class
 
		boost::signal<void (User *user)> onUserDestroyed;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (User *user)> onUserDestroyed;
 

	
 
		/// Returns true if user is connected.
 
		/// \return True if user is connected.
 
		bool isUserConnected(const std::string &barejid) const {
 
			return m_users.find(barejid) != m_users.end();
 
		}
 

	
 
		/// Returns pointer to UserRegistry.
 
		/// \return Pointer to UserRegistry.
 
		UserRegistry *getUserRegistry() {
 
			return m_userRegistry;
 
		}
include/transport/UserRegistration.h
Show inline comments
 
@@ -14,26 +14,26 @@
 
 * 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/Queries/Responder.h"
 
#include "Swiften/Elements/InBandRegistrationPayload.h"
 
#include "Swiften/Elements/RosterPayload.h"
 
#include <boost/signal.hpp>
 
#include <Swiften/Version.h>
 
#include "Swiften/SwiftenCompat.h"
 
#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 {
 
@@ -62,31 +62,31 @@ class UserRegistration {
 
		/// \param userInfo UserInfo struct with informations about registered user
 
		/// \return false if user is already registered
 
		virtual bool doUserRegistration(const UserInfo &userInfo) = 0;
 

	
 
		/// Unregisters user. This function removes all data about user from databa, unsubscribe all buddies
 
		/// managed by this transport and disconnects user if he's connected.
 
		/// \param barejid bare JID of user to unregister
 
		/// \return false if there is no such user registered
 
		virtual bool doUserUnregistration(const UserInfo &userInfo) = 0;
 

	
 
		/// Called when new user has been registered.
 
		/// \param userInfo UserInfo struct with informations about user
 
		boost::signal<void (const UserInfo &userInfo)> onUserRegistered;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const UserInfo &userInfo)> onUserRegistered;
 

	
 
		/// Called when user has been unregistered.
 
		/// \param userInfo UserInfo struct with informations about user
 
		boost::signal<void (const UserInfo &userInfo)> onUserUnregistered;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const UserInfo &userInfo)> onUserUnregistered;
 

	
 
		/// Called when user's registration has been updated.
 
		/// \param userInfo UserInfo struct with informations about user
 
		boost::signal<void (const UserInfo &userInfo)> onUserUpdated;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const UserInfo &userInfo)> onUserUpdated;
 

	
 
	private:
 
		Component *m_component;
 
		StorageBackend *m_storageBackend;
 
		UserManager *m_userManager;
 
		Config *m_config;
 

	
 
};
 

	
 
}
include/transport/UserRegistry.h
Show inline comments
 
@@ -87,28 +87,28 @@ class UserRegistry : public Swift::UserRegistry {
 
		/// \param user JID.
 
		void onPasswordInvalid(const Swift::JID &user, const std::string &error = "");
 

	
 
		/// Removes session later.
 
		/// \param user JID.
 
		void removeLater(const Swift::JID &user);
 

	
 
		/// Returns current password for particular user
 
		/// \param barejid JID.
 
		const std::string getUserPassword(const std::string &barejid);
 

	
 
		/// Emitted when user wants to connect legacy network to validate the password.
 
		boost::signal<void (const Swift::JID &user)> onConnectUser;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const Swift::JID &user)> onConnectUser;
 

	
 
		/// Emitted when user disconnected XMPP server and therefore should disconnect legacy network.
 
		boost::signal<void (const Swift::JID &user)> onDisconnectUser;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const Swift::JID &user)> onDisconnectUser;
 

	
 
	private:
 
		typedef struct {
 
			std::string password;
 
			Swift::ServerFromClientSession *session;
 
		} Sess;
 

	
 
		void handleRemoveTimeout(const Swift::JID &user);
 

	
 
		mutable std::map<std::string, Sess> users;
 
		mutable Config *config;
 
		Swift::Timer::ref m_removeTimer;
include/transport/WebSocketClient.h
Show inline comments
 
@@ -34,45 +34,43 @@
 
#include "Swiften/SwiftenCompat.h"
 

	
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/TLS/TLSOptions.h>
 
#endif
 

	
 
#include <string>
 
#include <algorithm>
 
#include <map>
 

	
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class Component;
 

	
 
class WebSocketClient {
 
	public:
 
		WebSocketClient(Component *component, const std::string &user);
 

	
 
		virtual ~WebSocketClient();
 

	
 
		void connectServer(const std::string &u);
 
		void disconnectServer();
 

	
 
		void write(const std::string &data);
 

	
 
		boost::signal<void (const std::string &payload)> onPayloadReceived;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const std::string &payload)> onPayloadReceived;
 

	
 
		boost::signal<void ()> onWebSocketConnected;
 
		boost::signal<void (const boost::optional<Swift::Connection::Error> &error)> onWebSocketDisconnected;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onWebSocketConnected;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const boost::optional<Swift::Connection::Error> &error)> onWebSocketDisconnected;
 

	
 
	private:
 
		void handleDNSResult(const std::vector<Swift::HostAddress>&, boost::optional<Swift::DomainNameResolveError>);
 
		void handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data);
 
		void handleConnected(bool error);
 
		void handleDisconnected(const boost::optional<Swift::Connection::Error> &error);
 

	
 
		void connectServer();
 

	
 
	private:
 
		Component *m_component;
 
		SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DomainNameAddressQuery> m_dnsQuery;
libtransport/NetworkPluginServer.cpp
Show inline comments
 
@@ -39,25 +39,24 @@
 
#include "Swiften/Elements/StreamError.h"
 
#include "Swiften/Network/BoostConnectionServer.h"
 
#include "Swiften/Network/ConnectionServerFactory.h"
 
#include "Swiften/Elements/AttentionPayload.h"
 
#include "Swiften/Elements/XHTMLIMPayload.h"
 
#include "Swiften/Elements/Delay.h"
 
#include "Swiften/Elements/DeliveryReceipt.h"
 
#include "Swiften/Elements/DeliveryReceiptRequest.h"
 
#include "Swiften/Elements/InvisiblePayload.h"
 
#include "Swiften/Elements/SpectrumErrorPayload.h"
 

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

	
 
#include "transport/utf8.h"
 

	
 
#include <Swiften/FileTransfer/ReadBytestream.h>
 
#include <Swiften/Elements/StreamInitiationFileInfo.h>
 

	
 
#ifdef _WIN32
 
#include "windows.h"
 
#include <stdint.h>
 
#else
 
#include "sys/wait.h"
 
#include "sys/signal.h"
 
@@ -78,25 +77,25 @@ DEFINE_LOGGER(logger, "NetworkPluginServer");
 
static NetworkPluginServer *_server;
 

	
 
class NetworkConversation : public Conversation {
 
	public:
 
		NetworkConversation(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(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &message) {
 
			onMessageToSend(this, message);
 
		}
 

	
 
		boost::signal<void (NetworkConversation *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &)> onMessageToSend;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (NetworkConversation *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &)> onMessageToSend;
 
};
 

	
 
class NetworkFactory : public Factory {
 
	public:
 
		NetworkFactory(NetworkPluginServer *nps) {
 
			m_nps = nps;
 
		}
 

	
 
		virtual ~NetworkFactory() {}
 

	
 
		// Creates new conversation (NetworkConversation in this case)
 
		Conversation *createConversation(ConversationManager *conversationManager, const std::string &legacyName, bool isMuc) {
spectrum/src/frontends/slack/SlackAPI.h
Show inline comments
 
@@ -19,26 +19,24 @@
 
 */
 

	
 
#pragma once
 

	
 
#include "transport/HTTPRequestQueue.h"
 
#include "transport/HTTPRequest.h"
 
#include "rapidjson/document.h"
 

	
 
#include <string>
 
#include <algorithm>
 
#include <map>
 

	
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class Component;
 
class StorageBackend;
 
class HTTPRequest;
 
class SlackIdManager;
 

	
 
class SlackChannelInfo {
 
	public:
 
		SlackChannelInfo() {}
 
		virtual ~SlackChannelInfo() {}
 

	
spectrum/src/frontends/slack/SlackIdManager.h
Show inline comments
 
@@ -38,26 +38,24 @@
 
#include "Swiften/Version.h"
 

	
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/TLS/TLSOptions.h>
 
#endif
 

	
 
#include <string>
 
#include <algorithm>
 
#include <map>
 

	
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class SlackIdManager {
 
	public:
 
		SlackIdManager();
 

	
 
		virtual ~SlackIdManager();
 

	
 
		std::map<std::string, SlackUserInfo> &getUsers() {
 
			return m_users;
 
		}
 

	
spectrum/src/frontends/slack/SlackRTM.h
Show inline comments
 
@@ -38,54 +38,52 @@
 
#include "Swiften/Version.h"
 

	
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
#if HAVE_SWIFTEN_3
 
#include <Swiften/TLS/TLSOptions.h>
 
#endif
 

	
 
#include <string>
 
#include <algorithm>
 
#include <map>
 

	
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class Component;
 
class StorageBackend;
 
class HTTPRequest;
 
class WebSocketClient;
 
class SlackAPI;
 
class SlackIdManager;
 

	
 
class SlackRTM {
 
	public:
 
		SlackRTM(Component *component, StorageBackend *storageBackend, SlackIdManager *idManager, UserInfo uinfo);
 

	
 
		virtual ~SlackRTM();
 

	
 
		void start();
 

	
 
		void sendPing();
 

	
 
		void sendMessage(const std::string &channel, const std::string &message);
 

	
 
		boost::signal<void ()> onRTMStarted;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onRTMStarted;
 

	
 
		SlackAPI *getAPI() {
 
			return m_api;
 
		}
 

	
 
		boost::signal<void (const std::string &channel, const std::string &user, const std::string &text, const std::string &ts)> onMessageReceived;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const std::string &channel, const std::string &user, const std::string &text, const std::string &ts)> onMessageReceived;
 

	
 
#ifndef LIBTRANSPORT_TEST
 
	private:
 
#endif
 
		void handlePayloadReceived(const std::string &payload);
 
		void handleRTMStart(HTTPRequest *req, bool ok, rapidjson::Document &resp, const std::string &data);
 
		void handleWebSocketConnected();
 
		void handleWebSocketDisconnected(const boost::optional<Swift::Connection::Error> &error);
 

	
 
	private:
 
		Component *m_component;
 
		StorageBackend *m_storageBackend;
spectrum/src/frontends/slack/SlackSession.h
Show inline comments
 
@@ -22,43 +22,41 @@
 

	
 
#include "transport/StorageBackend.h"
 
#include "rapidjson/document.h"
 

	
 
#include <string>
 
#include <algorithm>
 
#include <map>
 

	
 
#include "Swiften/Elements/Message.h"
 
#include "Swiften/Network/Timer.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class Component;
 
class StorageBackend;
 
class HTTPRequest;
 
class SlackRTM;
 
class SlackAPI;
 
class User;
 
class SlackIdManager;
 

	
 
class SlackSession {
 
	public:
 
		SlackSession(Component *component, StorageBackend *storageBackend, UserInfo uinfo);
 

	
 
		virtual ~SlackSession();
 

	
 
		boost::signal<void (const std::string &user)> onInstallationDone;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const std::string &user)> onInstallationDone;
 

	
 
		void sendMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> message);
 

	
 
		void sendMessageToAll(const std::string &msg);
 

	
 
		void setPurpose(const std::string &purpose, const std::string &channel = "");
 

	
 
		void setUser(User *user);
 

	
 
		void handleDisconnected();
 
		void handleConnected();
 

	
spectrum/src/frontends/slack/SlackUserRegistration.h
Show inline comments
 
@@ -13,26 +13,24 @@
 
 * 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 "transport/UserRegistration.h"
 

	
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

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

	
 
class SlackUserRegistration : public UserRegistration {
 
	public:
 
		SlackUserRegistration(Component *component, UserManager *userManager, StorageBackend *storageBackend);
spectrum/src/frontends/xmpp/RosterResponder.h
Show inline comments
 
@@ -16,38 +16,36 @@
 
 * 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 <vector>
 
#include "Swiften/Queries/Responder.h"
 
#include "Swiften/Elements/RosterPayload.h"
 
#include "Swiften/SwiftenCompat.h"
 

	
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class UserManager;
 
class Buddy;
 

	
 
class RosterResponder : public Swift::Responder<Swift::RosterPayload> {
 
	public:
 
		RosterResponder(Swift::IQRouter *router, UserManager *userManager);
 
		~RosterResponder();
 

	
 
		boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyUpdated;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyUpdated;
 

	
 
		boost::signal<void (Buddy *)> onBuddyRemoved;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *)> onBuddyRemoved;
 

	
 
		boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyAdded;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyAdded;
 

	
 
	private:
 
		virtual bool handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::RosterPayload> payload);
 
		virtual bool handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::RosterPayload> payload);
 
		UserManager *m_userManager;
 
		Swift::IQRouter *m_router;
 
};
 

	
 
}
spectrum/src/frontends/xmpp/XMPPUserRegistration.h
Show inline comments
 
@@ -16,25 +16,24 @@
 
 * 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 "Swiften/SwiftenCompat.h"
 

	
 
#include <boost/signal.hpp>
 
#include <Swiften/Version.h>
 
#include "transport/UserRegistration.h"
 
#define HAVE_SWIFTEN_3  (SWIFTEN_VERSION >= 0x030000)
 

	
 
namespace Transport {
 

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

	
spectrum/src/frontends/xmpp/blockresponder.h
Show inline comments
 
@@ -14,33 +14,32 @@
 
 * 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 <vector>
 
#include "Swiften/Queries/SetResponder.h"
 
#include "BlockPayload.h"
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class UserManager;
 
class Buddy;
 

	
 
class BlockResponder : public Swift::SetResponder<Transport::BlockPayload> {
 
	public:
 
		BlockResponder(Swift::IQRouter *router, UserManager *userManager);
 
		~BlockResponder();
 

	
 
		boost::signal<void (Buddy *)> onBlockToggled;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (Buddy *)> onBlockToggled;
 

	
 
	private:
 
		virtual bool handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Transport::BlockPayload> payload);
 

	
 
		UserManager *m_userManager;
 
};
 

	
 
}
spectrum/src/frontends/xmpp/discoinforesponder.h
Show inline comments
 
@@ -13,25 +13,24 @@
 
 * 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 <vector>
 
#include <list>
 
#include <boost/signal.hpp>
 
#include "Swiften/Queries/GetResponder.h"
 
#include "Swiften/Elements/DiscoInfo.h"
 
#include "Swiften/Elements/CapsInfo.h"
 
#include "Swiften/SwiftenCompat.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
 

	
 

	
 
@@ -44,25 +43,25 @@ class DiscoInfoResponder : public Swift::GetResponder<Swift::DiscoInfo> {
 
	public:
 
		DiscoInfoResponder(Swift::IQRouter *router, Config *config, UserManager *userManager);
 
		~DiscoInfoResponder();
 

	
 
		void setTransportFeatures(std::list<std::string> &features);
 
		void setBuddyFeatures(std::list<std::string> &features);
 

	
 
		void addRoom(const std::string &jid, const std::string &name);
 
		void clearRooms();
 

	
 
		void addAdHocCommand(const std::string &node, const std::string &name);
 

	
 
		boost::signal<void (const Swift::CapsInfo &capsInfo)> onBuddyCapsInfoChanged;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (const Swift::CapsInfo &capsInfo)> onBuddyCapsInfoChanged;
 

	
 
		Swift::CapsInfo &getBuddyCapsInfo() {
 
				return m_capsInfo;
 
		}
 

	
 
	private:
 
		virtual bool handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> payload);
 
		void updateFeatures();
 

	
 
		Swift::DiscoInfo m_transportInfo;
 
		Swift::DiscoInfo *m_buddyInfo;
 
		Config *m_config;
spectrum/src/frontends/xmpp/formutils.h
Show inline comments
 
@@ -14,25 +14,24 @@
 
 * 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/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)
 

	
 
namespace Transport {
 

	
 
	class AdHocCommand;
 

	
 
namespace FormUtils {
 

	
 
	void addHiddenField(Swift::Form::ref form, const std::string &name, const std::string &value);
 
	void addTextSingleField(Swift::Form::ref form, const std::string &name, const std::string &value,
 
							const std::string &label, bool required = false);
spectrum/src/frontends/xmpp/vcardresponder.h
Show inline comments
 
@@ -17,41 +17,40 @@
 
 * 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 <vector>
 
#include "Swiften/Queries/Responder.h"
 
#include "Swiften/Elements/VCard.h"
 
#include "Swiften/Network/NetworkFactories.h"
 
#include "Swiften/Network/Timer.h"
 
#include "Swiften/SwiftenCompat.h"
 
#include <boost/signal.hpp>
 

	
 
namespace Transport {
 

	
 
class StorageBackend;
 
class UserManager;
 
class User;
 

	
 
class VCardResponder : public Swift::Responder<Swift::VCard> {
 
	public:
 
		VCardResponder(Swift::IQRouter *router, Swift::NetworkFactories *factories, UserManager *userManager);
 
		~VCardResponder();
 

	
 
		void sendVCard(unsigned int id, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCard> vcard);
 

	
 
		boost::signal<void (User *, const std::string &name, unsigned int id)> onVCardRequired;
 
		boost::signal<void (User *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCard> vcard)> onVCardUpdated;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (User *, const std::string &name, unsigned int id)> onVCardRequired;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (User *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCard> vcard)> onVCardUpdated;
 

	
 
		void collectTimeouted();
 

	
 
	private:
 
		struct VCardData {
 
			Swift::JID from;
 
			Swift::JID to;
 
			std::string id;
 
			time_t received;
 
		};
 

	
 
		virtual bool handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCard> payload);
spectrum_manager/src/APIServer.h
Show inline comments
 
@@ -17,25 +17,24 @@
 
 * 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 <boost/program_options.hpp>
 
#include <boost/foreach.hpp>
 
#include <boost/format.hpp>
 
#include <boost/algorithm/string.hpp>
 
#include <boost/assign.hpp>
 
#include <boost/bind.hpp>
 
#include <boost/signal.hpp>
 

	
 
#include "rapidjson/document.h"
 

	
 
#include "mongoose.h"
 
#include "managerconfig.h"
 
#include "server.h"
 

	
 
#include "transport/Config.h"
 
#include "transport/SQLite3Backend.h"
 
#include "transport/MySQLBackend.h"
 
#include "transport/PQXXBackend.h"
 
#include "transport/StorageBackend.h"
spectrum_manager/src/managerconfig.h
Show inline comments
 
@@ -17,25 +17,26 @@
 
 * 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 <boost/program_options.hpp>
 
#include <boost/foreach.hpp>
 
#include <boost/format.hpp>
 
#include <boost/algorithm/string.hpp>
 
#include <boost/assign.hpp>
 
#include <boost/bind.hpp>
 
#include <boost/signal.hpp>
 

	
 
#include "Swiften/SwiftenCompat.h"
 

	
 
/// Represents variable:value pairs.
 
typedef boost::program_options::variables_map Variables;
 

	
 
/// Represents config file.
 

	
 
/// It's used to load config file and allows others parts of libtransport to be configured
 
/// properly. ManagerConfig files are text files which use "ini" format. Variables are divided into multiple
 
/// sections. Every class is configurable with some variables which change its behavior. Check particular
 
/// class documentation to get a list of all relevant variables for that class.
 
class ManagerConfig {
 
	public:
 
@@ -67,18 +68,18 @@ class ManagerConfig {
 
		const boost::program_options::variable_value &operator[] (const std::string &key) {
 
			return m_variables[key];
 
		}
 

	
 
		bool hasKey(const std::string &key) {
 
			return m_variables.find(key) != m_variables.end();
 
		}
 

	
 
		/// Returns path to config file from which data were loaded.
 
		const std::string &getManagerConfigFile() { return m_file; }
 

	
 
		/// This signal is emitted when config is loaded/reloaded.
 
		boost::signal<void ()> onManagerConfigReloaded;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void ()> onManagerConfigReloaded;
 
	
 
	private:
 
		Variables m_variables;
 
		std::string m_file;
 
};
spectrum_manager/src/methods.h
Show inline comments
 
@@ -17,25 +17,24 @@
 
 * 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 <boost/program_options.hpp>
 
#include <boost/foreach.hpp>
 
#include <boost/format.hpp>
 
#include <boost/algorithm/string.hpp>
 
#include <boost/assign.hpp>
 
#include <boost/bind.hpp>
 
#include <boost/signal.hpp>
 

	
 
#include "managerconfig.h"
 
#include "transport/Config.h"
 
#include "transport/protocol.pb.h"
 
#include "Swiften/Swiften.h"
 
#include "Swiften/EventLoop/SimpleEventLoop.h"
 

	
 

	
 

	
 
std::string searchForBinary(const std::string &binary);
 

	
 
// Executes new backend
spectrum_manager/src/server.h
Show inline comments
 
@@ -17,25 +17,24 @@
 
 * 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 <boost/program_options.hpp>
 
#include <boost/foreach.hpp>
 
#include <boost/format.hpp>
 
#include <boost/algorithm/string.hpp>
 
#include <boost/assign.hpp>
 
#include <boost/bind.hpp>
 
#include <boost/signal.hpp>
 

	
 
#include "mongoose.h"
 
#include "managerconfig.h"
 

	
 
#include "transport/Config.h"
 
#include "transport/Logging.h"
 
#include "transport/SQLite3Backend.h"
 
#include "transport/MySQLBackend.h"
 
#include "transport/PQXXBackend.h"
 
#include "transport/StorageBackend.h"
 

	
 
using namespace Transport;
tests/libtransport/basictest.h
Show inline comments
 
@@ -57,25 +57,25 @@
 
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(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &message) {
 
			onMessageToSend(this, message);
 
		}
 

	
 
		boost::signal<void (TestingConversation *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &)> onMessageToSend;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (TestingConversation *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &)> onMessageToSend;
 
};
 

	
 
class TestingFactory : public Factory {
 
	public:
 
		TestingFactory() {
 
		}
 

	
 
		// Creates new conversation (NetworkConversation in this case)
 
		Conversation *createConversation(ConversationManager *conversationManager, const std::string &legacyName, bool isMuc = false) {
 
			TestingConversation *nc = new TestingConversation(conversationManager, legacyName, isMuc);
 
			nc->onMessageToSend.connect(boost::bind(&TestingFactory::handleMessageToSend, this, _1, _2));
 
			return nc;
 
@@ -89,25 +89,25 @@ class TestingFactory : public Factory {
 
		Buddy *createBuddy(RosterManager *rosterManager, const BuddyInfo &buddyInfo) {
 
			LocalBuddy *buddy = new LocalBuddy(rosterManager, buddyInfo.id, buddyInfo.legacyName, buddyInfo.alias, buddyInfo.groups, (BuddyFlag) buddyInfo.flags);
 
			if (!buddy->isValid()) {
 
				delete buddy;
 
				return NULL;
 
			}
 
			buddy->setSubscription(Buddy::Ask);
 
			if (buddyInfo.settings.find("icon_hash") != buddyInfo.settings.end())
 
				buddy->setIconHash(buddyInfo.settings.find("icon_hash")->second.s);
 
			return buddy;
 
		}
 

	
 
		boost::signal<void (TestingConversation *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &)> onMessageToSend;
 
		SWIFTEN_SIGNAL_NAMESPACE::signal<void (TestingConversation *, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &)> onMessageToSend;
 
};
 

	
 
class TestingStorageBackend : public StorageBackend {
 
	public:
 
		bool connected;
 
		std::map<std::string, UserInfo> users;
 
		std::map<std::string, bool> online_users;
 
		std::map<int, std::map<std::string, std::string> > settings;
 
		long buddyid;
 

	
 
		TestingStorageBackend() {
 
			buddyid = 0;
0 comments (0 inline, 0 general)