Files
@ 0729d364ca25
Branch filter:
Location: libtransport.git/backends/template/plugin.cpp - annotation
0729d364ca25
2.4 KiB
text/x-c++hdr
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.
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.
8b6068588621 8b6068588621 78e71f9345c7 78e71f9345c7 78e71f9345c7 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 6d2f8c192761 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 f7dc91ccb482 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 8b6068588621 | #include "plugin.h"
// Transport includes
#include "transport/Config.h"
#include "transport/NetworkPlugin.h"
#include "transport/Logging.h"
// Swiften
#include "Swiften/Swiften.h"
// Boost
#include <boost/algorithm/string.hpp>
using namespace boost::filesystem;
using namespace boost::program_options;
using namespace Transport;
DEFINE_LOGGER(logger, "Backend Template");
Plugin::Plugin(Config *config, Swift::SimpleEventLoop *loop, const std::string &host, int port) : NetworkPlugin() {
this->config = config;
m_factories = new Swift::BoostNetworkFactories(loop);
m_conn = m_factories->getConnectionFactory()->createConnection();
m_conn->onDataRead.connect(boost::bind(&Plugin::_handleDataRead, this, _1));
m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port));
LOG4CXX_INFO(logger, "Starting the plugin.");
}
// NetworkPlugin uses this method to send the data to networkplugin server
void Plugin::sendData(const std::string &string) {
m_conn->write(Swift::createSafeByteArray(string));
}
// This method has to call handleDataRead with all received data from network plugin server
void Plugin::_handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data) {
std::string d(data->begin(), data->end());
handleDataRead(d);
}
void Plugin::handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password) {
handleConnected(user);
LOG4CXX_INFO(logger, user << ": Added buddy - Echo.");
handleBuddyChanged(user, "echo", "Echo", std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
}
void Plugin::handleLogoutRequest(const std::string &user, const std::string &legacyName) {
}
void Plugin::handleMessageSendRequest(const std::string &user, const std::string &legacyName, const std::string &message, const std::string &xhtml, const std::string &id) {
LOG4CXX_INFO(logger, "Sending message from " << user << " to " << legacyName << ".");
if (legacyName == "echo") {
handleMessage(user, legacyName, message);
}
}
void Plugin::handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups) {
LOG4CXX_INFO(logger, user << ": Added buddy " << buddyName << ".");
handleBuddyChanged(user, buddyName, alias, groups, pbnetwork::STATUS_ONLINE);
}
void Plugin::handleBuddyRemovedRequest(const std::string &user, const std::string &buddyName, const std::vector<std::string> &groups) {
}
|