Skip to content

Commit cf3677e

Browse files
committed
WIP
1 parent e55d3e1 commit cf3677e

29 files changed

+146
-551
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ option(ENABLE_SMSTOOLS3 "Build SMSTools3 plugin" ON)
4141
option(ENABLE_XMPP "Build XMPP plugin" ON)
4242
option(ENABLE_TWITTER "Build Twitter plugin" ON)
4343
option(ENABLE_WEBUI "Build Web UI" ON)
44-
44+
option(ENABLE_SLACK_FRONTEND "Build Slack frontend" OFF)
4545
option(ENABLE_DOCS "Build Docs" ON)
4646
# option(ENABLE_LOG "Build with logging using Log4cxx" ON)
4747
option(ENABLE_TESTS "Build Tests using CppUnit" OFF)

backends/libcommuni/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ add_executable(spectrum2_libcommuni_backend ${SRC})
1313

1414
if(NOT WIN32)
1515
if(ENABLE_QT4)
16-
target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport pthread)
16+
target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport-plugin pthread)
1717
else()
18-
target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt5::Network Qt5::Core transport pthread)
18+
target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt5::Network Qt5::Core transport-plugin pthread)
1919
endif()
2020
else()
2121
if(ENABLE_QT4)
22-
target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport)
22+
target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt4::QtNetwork Qt4::QtCore transport-plugin)
2323
else()
24-
target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt5::Network Qt5::Core transport)
24+
target_link_libraries(spectrum2_libcommuni_backend ${IRC_LIBRARY} Qt5::Network Qt5::Core transport-plugin)
2525
endif()
2626
endif()
2727

backends/swiften/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ file(GLOB SRC *.cpp)
33
add_executable(spectrum2_swiften_backend ${SRC})
44

55
if(NOT WIN32)
6-
target_link_libraries(spectrum2_swiften_backend transport pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
6+
target_link_libraries(spectrum2_swiften_backend transport-plugin pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
77
else()
8-
target_link_libraries(spectrum2_swiften_backend transport ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
8+
target_link_libraries(spectrum2_swiften_backend transport-plugin ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
99
endif()
1010

1111
install(TARGETS spectrum2_swiften_backend RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})

backends/swiften/main.cpp

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,15 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
8080
Swift::XMPPParser *m_xmppParser;
8181
Swift::FullPayloadParserFactoryCollection m_collection2;
8282

83-
SwiftenPlugin(Config *config, Swift::SimpleEventLoop *loop, const std::string &host, int port) : NetworkPlugin() {
83+
SwiftenPlugin(Config *config, const std::string &host, int port) : NetworkPlugin() {
8484
this->config = config;
8585
m_firstPing = true;
86-
m_factories = new Swift::BoostNetworkFactories(loop);
87-
m_conn = m_factories->getConnectionFactory()->createConnection();
88-
m_conn->onDataRead.connect(boost::bind(&SwiftenPlugin::_handleDataRead, this, _1));
89-
m_conn->connect(Swift::HostAddressPort(*(Swift::HostAddress::fromString(host)), port));
9086
serializer = new Swift::XMPPSerializer(&collection, Swift::ClientStreamType, false);
9187
m_xmppParser = new Swift::XMPPParser(this, &m_collection2, m_factories->getXMLParserFactory());
9288
m_xmppParser->parse("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='localhost' version='1.0'>");
9389

9490
LOG4CXX_INFO(logger, "Starting the plugin.");
95-
}
96-
97-
// NetworkPlugin uses this method to send the data to networkplugin server
98-
void sendData(const std::string &string) {
99-
m_conn->write(Swift::createSafeByteArray(string));
100-
}
101-
102-
// This method has to call handleDataRead with all received data from network plugin server
103-
void _handleDataRead(std::shared_ptr<Swift::SafeByteArray> data) {
104-
if (m_firstPing) {
105-
m_firstPing = false;
106-
NetworkPlugin::PluginConfig cfg;
107-
cfg.setRawXML(true);
108-
cfg.setNeedRegistration(false);
109-
sendConfig(cfg);
110-
}
111-
std::string d(data->begin(), data->end());
112-
handleDataRead(d);
91+
connect(host, std::to_string(port));
11392
}
11493

11594
void handleStreamStart(const Swift::ProtocolHeader&) {}
@@ -446,10 +425,7 @@ int main (int argc, char* argv[]) {
446425

447426
Logging::initBackendLogging(cfg);
448427

449-
Swift::SimpleEventLoop eventLoop;
450-
loop_ = &eventLoop;
451-
np = new SwiftenPlugin(cfg, &eventLoop, host, port);
452-
loop_->run();
428+
np = new SwiftenPlugin(cfg, host, port);
453429

454430
return 0;
455431
}

backends/template/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ add_executable(spectrum2_template_backend ${SRC})
44

55
if(CMAKE_COMPILER_IS_GNUCXX)
66
if(NOT WIN32)
7-
target_link_libraries(spectrum2_template_backend transport pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
7+
target_link_libraries(spectrum2_template_backend transport-plugin pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
88
else()
9-
target_link_libraries(spectrum2_template_backend transport ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
9+
target_link_libraries(spectrum2_template_backend transport-plugin ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
1010
endif()
1111
else()
12-
target_link_libraries(spectrum2_template_backend transport ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
12+
target_link_libraries(spectrum2_template_backend transport-plugin ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
1313
endif()
1414

1515
#install(TARGETS spectrum2_template_backend RUNTIME DESTINATION bin)

backends/template/main.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
#include "transport/NetworkPlugin.h"
66
#include "transport/Logging.h"
77

8-
// Swiften
9-
#include "Swiften/Swiften.h"
10-
118
#ifndef _WIN32
129
// for signal handler
1310
#include "unistd.h"
@@ -17,6 +14,7 @@
1714
#endif
1815
// Boost
1916
#include <boost/algorithm/string.hpp>
17+
#include <boost/filesystem.hpp>
2018
using namespace boost::filesystem;
2119
using namespace boost::program_options;
2220
using namespace Transport;
@@ -60,9 +58,7 @@ int main (int argc, char* argv[]) {
6058

6159
Logging::initBackendLogging(cfg);
6260

63-
Swift::SimpleEventLoop eventLoop;
64-
Plugin p(cfg, &eventLoop, host, port);
65-
eventLoop.run();
61+
Plugin p(cfg, host, port);
6662

6763
return 0;
6864
}

backends/template/plugin.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,19 @@
44
#include "transport/NetworkPlugin.h"
55
#include "transport/Logging.h"
66

7-
// Swiften
8-
#include "Swiften/Swiften.h"
9-
107
// Boost
118
#include <boost/algorithm/string.hpp>
9+
#include <boost/filesystem.hpp>
1210
using namespace boost::filesystem;
1311
using namespace boost::program_options;
1412
using namespace Transport;
1513

1614
DEFINE_LOGGER(logger, "Backend Template");
1715

18-
Plugin::Plugin(Config *config, Swift::SimpleEventLoop *loop, const std::string &host, int port) : NetworkPlugin() {
16+
Plugin::Plugin(Config *config, const std::string &host, int port) : NetworkPlugin() {
1917
this->config = config;
20-
m_factories = new Swift::BoostNetworkFactories(loop);
21-
m_conn = m_factories->getConnectionFactory()->createConnection();
22-
m_conn->onDataRead.connect(boost::bind(&Plugin::_handleDataRead, this, _1));
23-
m_conn->connect(Swift::HostAddressPort(*(Swift::HostAddress::fromString(host)), port));
24-
2518
LOG4CXX_INFO(logger, "Starting the plugin.");
26-
}
27-
28-
// NetworkPlugin uses this method to send the data to networkplugin server
29-
void Plugin::sendData(const std::string &string) {
30-
m_conn->write(Swift::createSafeByteArray(string));
31-
}
32-
33-
// This method has to call handleDataRead with all received data from network plugin server
34-
void Plugin::_handleDataRead(std::shared_ptr<Swift::SafeByteArray> data) {
35-
std::string d(data->begin(), data->end());
36-
handleDataRead(d);
19+
connect(host, std::to_string(port));
3720
}
3821

3922
void Plugin::handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password, const std::map<std::string, std::string> &settings) {

backends/template/plugin.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#pragma once
22

3-
#include "Swiften/Swiften.h"
4-
53
#include "transport/Config.h"
64
#include "transport/NetworkPlugin.h"
75

86
class Plugin : public Transport::NetworkPlugin {
97
public:
10-
Plugin(Transport::Config *config, Swift::SimpleEventLoop *loop, const std::string &host, int port);
8+
Plugin(Transport::Config *config, const std::string &host, int port);
119

1210
// NetworkPlugin uses this method to send the data to networkplugin server
1311
void sendData(const std::string &string);
@@ -23,12 +21,5 @@ class Plugin : public Transport::NetworkPlugin {
2321
void handleBuddyRemovedRequest(const std::string &user, const std::string &buddyName, const std::vector<std::string> &groups);
2422

2523
private:
26-
// This method has to call handleDataRead with all received data from network plugin server
27-
void _handleDataRead(std::shared_ptr<Swift::SafeByteArray> data);
28-
29-
private:
30-
Swift::BoostNetworkFactories *m_factories;
31-
Swift::BoostIOServiceThread m_boostIOServiceThread;
32-
std::shared_ptr<Swift::Connection> m_conn;
3324
Transport::Config *config;
3425
};

backends/twitter/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ find_package(CURL)
88

99
if(CURL_FOUND)
1010
message(STATUS "Using curl ${CURL_VERSION_STRING}: ${CURL_INCLUDE_DIRS} ${CURL_LIBRARIES}")
11-
target_link_libraries(spectrum2_twitter_backend transport JsonCpp::JsonCpp ${CURL_LIBRARIES} ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
11+
target_link_libraries(spectrum2_twitter_backend transport-plugin ${CURL_LIBRARIES} ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
1212
else()
1313
message(FATAL_ERROR "curl not found")
1414
endif()

backends/twitter/HTTPRequest.h

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)