Files @ 0729d364ca25
Branch filter:

Location: libtransport.git/backends/template/plugin.h

Vladimír Matěna
Fix double free in DummyConnectionServer

Do not create shared ptr from this as this lead to double free in
UserRegistryTest::login test. Shared ptr was needed to set event
owner in acceptConnection, actually it is never needed as events
are never filtered by owner. Thus it was removed and there is no
need to create shared ptr from this.
#pragma once

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

#include "transport/Config.h"
#include "transport/NetworkPlugin.h"

class Plugin : public Transport::NetworkPlugin {
	public:
		Plugin(Transport::Config *config, Swift::SimpleEventLoop *loop, const std::string &host, int port);

		// NetworkPlugin uses this method to send the data to networkplugin server
		void sendData(const std::string &string);

		void handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password);

		void handleLogoutRequest(const std::string &user, const std::string &legacyName);

		void handleMessageSendRequest(const std::string &user, const std::string &legacyName, const std::string &message, const std::string &xhtml = "", const std::string &id = "");

		void handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups);

		void handleBuddyRemovedRequest(const std::string &user, const std::string &buddyName, const std::vector<std::string> &groups);

	private:
		// This method has to call handleDataRead with all received data from network plugin server
		void _handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data);

	private:
		Swift::BoostNetworkFactories *m_factories;
		Swift::BoostIOServiceThread m_boostIOServiceThread;
		SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
		Transport::Config *config;
};