Compare commits
No commits in common. "master" and "2.0.3" have entirely different histories.
214 changed files with 9227 additions and 4108 deletions
49
.travis.yml
49
.travis.yml
|
@ -3,47 +3,18 @@ python:
|
||||||
- "2.7_with_system_site_packages"
|
- "2.7_with_system_site_packages"
|
||||||
virtualenv:
|
virtualenv:
|
||||||
system_site_packages: true
|
system_site_packages: true
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
sudo: required
|
sudo: required
|
||||||
- os: osx
|
dist: trusty
|
||||||
allow_failures:
|
|
||||||
- os: osx
|
|
||||||
before_script:
|
before_script:
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
- curl -k https://swift.im/keys/packages.key | sudo apt-key add -
|
||||||
export DEBIAN_FRONTEND=noninteractive;
|
- echo "deb http://swift.im/packages/ubuntu/trusty development main" | sudo tee -a /etc/apt/sources.list
|
||||||
export APT_LISTCHANGES_FRONTEND=none;
|
- echo "deb http://packages.spectrum.im/spectrum2/ trusty main" | sudo tee -a /etc/apt/sources.list
|
||||||
echo force-confold | sudo tee -a /etc/dpkg/dpkg.cfg;
|
- echo " deb http://packages.prosody.im/debian trusty main" | sudo tee -a /etc/apt/sources.list
|
||||||
curl -k https://swift.im/keys/packages.key | sudo apt-key add -;
|
- sudo apt-get update -qq
|
||||||
echo 'deb http://us.archive.ubuntu.com/ubuntu xenial main restricted universe multiverse' | sudo tee /etc/apt/sources.list.d/xenial.list > /dev/null;
|
- sudo apt-get install -y --force-yes prosody ngircd python-sleekxmpp libswiften-dev libprotobuf-dev protobuf-compiler pidgin-dev liblog4cxx10-dev libpopt-dev libboost-dev libboost-signals-dev libboost-system-dev libboost-thread-dev libboost-locale-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libboost-date-time-dev libcppunit-dev libcommuni-dev
|
||||||
echo 'deb http://us.archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse' | sudo tee -a /etc/apt/sources.list.d/xenial.list > /dev/null;
|
- sudo killall lua5.1
|
||||||
echo 'deb http://us.archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse' | sudo tee -a /etc/apt/sources.list.d/xenial.list > /dev/null;
|
install: "pip install --user sleekxmpp"
|
||||||
echo 'deb http://us.archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse' | sudo tee -a /etc/apt/sources.list.d/xenial.list > /dev/null;
|
|
||||||
echo "deb http://packages.spectrum.im/spectrum2/ xenial main" | sudo tee -a /etc/apt/sources.list;
|
|
||||||
echo "deb http://swift.im/packages/ubuntu/xenial beta main" | sudo tee -a /etc/apt/sources.list;
|
|
||||||
echo "deb http://packages.prosody.im/debian $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list;
|
|
||||||
sudo apt-get update -qq;
|
|
||||||
sudo apt-get purge chromium-browser;
|
|
||||||
sudo apt-get install -y --force-yes build-essential prosody ngircd python-sleekxmpp libswiften-dev libprotobuf-dev protobuf-compiler libpurple-dev libglib2.0-dev libdbus-glib-1-dev liblog4cxx10-dev libpopt-dev libboost-dev libboost-signals-dev libboost-system-dev libboost-thread-dev libboost-locale-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libboost-date-time-dev libcppunit-dev libcommuni-dev libminiupnpc-dev libnatpmp-dev;
|
|
||||||
sudo killall lua5.1;
|
|
||||||
else
|
|
||||||
brew update;
|
|
||||||
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e6e43cf6a3%5E/Formula/cppunit.rb;
|
|
||||||
brew install protobuf log4cxx popt boost;
|
|
||||||
travis_wait 30 brew install -s libswiften;
|
|
||||||
fi
|
|
||||||
install:
|
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
|
||||||
pip install --user sleekxmpp;
|
|
||||||
fi
|
|
||||||
script:
|
script:
|
||||||
- cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON . && make
|
- cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON . && make && make extended_test
|
||||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
|
||||||
make extended_test;
|
|
||||||
else
|
|
||||||
make test;
|
|
||||||
fi
|
|
||||||
notifications:
|
notifications:
|
||||||
slack: spectrum2:CIlYHtxGMAaxs3qVHfwBzCuy
|
slack: spectrum2:CIlYHtxGMAaxs3qVHfwBzCuy
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
project(libtransport)
|
project(libtransport)
|
||||||
|
|
||||||
if(${CMAKE_MAJOR_VERSION} GREATER 2)
|
if(${CMAKE_MAJOR_VERSION} GREATER 2)
|
||||||
cmake_policy(SET CMP0037 OLD)
|
cmake_policy(SET CMP0037 OLD)
|
||||||
endif()
|
endif()
|
||||||
include(CPack)
|
|
||||||
message(STATUS "Variables to override default places where to find libraries:")
|
message(STATUS "Variables to override default places where to find libraries:")
|
||||||
message(STATUS "|- cppunit : -DCPPUNIT_INCLUDE_DIR, -DCPPUNIT_LIBRARY")
|
message(STATUS "|- cppunit : -DCPPUNIT_INCLUDE_DIR, -DCPPUNIT_LIBRARY")
|
||||||
message(STATUS "|- swiften : -DSWIFTEN_INCLUDE_DIR, -DSWIFTEN_LIBRARY")
|
message(STATUS "|- swiften : -DSWIFTEN_INCLUDE_DIR, -DSWIFTEN_LIBRARY")
|
||||||
|
@ -26,7 +27,8 @@ option(ENABLE_FROTZ "Build Frotz plugin" ON)
|
||||||
option(ENABLE_IRC "Build IRC plugin" ON)
|
option(ENABLE_IRC "Build IRC plugin" ON)
|
||||||
option(ENABLE_PURPLE "Build Libpurple plugin" ON)
|
option(ENABLE_PURPLE "Build Libpurple plugin" ON)
|
||||||
option(ENABLE_SMSTOOLS3 "Build SMSTools3 plugin" ON)
|
option(ENABLE_SMSTOOLS3 "Build SMSTools3 plugin" ON)
|
||||||
option(ENABLE_XMPP "Build XMPP plugin" ON)
|
option(ENABLE_SKYPE "Build Skype plugin" ON)
|
||||||
|
option(ENABLE_SWIFTEN "Build Swiften plugin" ON)
|
||||||
option(ENABLE_TWITTER "Build Twitter plugin" ON)
|
option(ENABLE_TWITTER "Build Twitter plugin" ON)
|
||||||
|
|
||||||
option(ENABLE_DOCS "Build Docs" ON)
|
option(ENABLE_DOCS "Build Docs" ON)
|
||||||
|
@ -74,8 +76,7 @@ if(NOT SWIFTEN_FOUND)
|
||||||
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Secur32")
|
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Secur32")
|
||||||
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Iphlpapi")
|
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Iphlpapi")
|
||||||
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Winscard")
|
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Winscard")
|
||||||
message(STATUS "XXXUsing swiften: ${SWIFTEN_INCLUDE_DIR} ${SWIFTEN_LIBRARY}
|
message(STATUS "Using swiften: ${SWIFTEN_INCLUDE_DIR} ${SWIFTEN_LIBRARY}")
|
||||||
Version: ${SWIFTEN_VERSION}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# FIND BOOST
|
# FIND BOOST
|
||||||
|
@ -83,9 +84,20 @@ if (WIN32)
|
||||||
set(Boost_USE_STATIC_LIBS ON)
|
set(Boost_USE_STATIC_LIBS ON)
|
||||||
set(Boost_USE_MULTITHREADED ON)
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
endif(WIN32)
|
|
||||||
set(Boost_FIND_QUIETLY ON)
|
|
||||||
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals locale REQUIRED)
|
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals locale REQUIRED)
|
||||||
|
else(WIN32)
|
||||||
|
LIST_CONTAINS(contains -lboost_program_options ${SWIFTEN_LIBRARY})
|
||||||
|
if(contains)
|
||||||
|
message(STATUS "Using non-multithreaded boost")
|
||||||
|
set(Boost_USE_MULTITHREADED 0)
|
||||||
|
endif(contains)
|
||||||
|
set(Boost_FIND_QUIETLY ON)
|
||||||
|
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread-mt signals locale)
|
||||||
|
if (NOT Boost_FOUND)
|
||||||
|
set(Boost_FIND_QUIETLY OFF)
|
||||||
|
find_package(Boost COMPONENTS program_options date_time system filesystem regex thread signals locale REQUIRED)
|
||||||
|
endif()
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
message( STATUS "Found Boost: ${Boost_VERSION}, ${Boost_LIBRARIES}, ${Boost_INCLUDE_DIR}")
|
message( STATUS "Found Boost: ${Boost_VERSION}, ${Boost_LIBRARIES}, ${Boost_INCLUDE_DIR}")
|
||||||
|
|
||||||
|
@ -152,7 +164,7 @@ if(ENABLE_PURPLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# FIND GLIB
|
# FIND GLIB
|
||||||
if(ENABLE_PURPLE)
|
if(ENABLE_SKYPE OR ENABLE_PURPLE)
|
||||||
# if (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
|
# if (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
|
||||||
# set(GLIB2_FOUND TRUE)
|
# set(GLIB2_FOUND TRUE)
|
||||||
# else()
|
# else()
|
||||||
|
@ -249,10 +261,10 @@ else (SPECTRUM_VERSION)
|
||||||
OUTPUT_VARIABLE GIT_REVISION
|
OUTPUT_VARIABLE GIT_REVISION
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
set(SPECTRUM_VERSION 2.0.5-git-${GIT_REVISION})
|
set(SPECTRUM_VERSION 2.0.3-git-${GIT_REVISION})
|
||||||
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
|
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
|
||||||
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
||||||
set(SPECTRUM_VERSION 2.0.5)
|
set(SPECTRUM_VERSION 2.0.3)
|
||||||
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
|
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
|
||||||
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
||||||
endif (SPECTRUM_VERSION)
|
endif (SPECTRUM_VERSION)
|
||||||
|
@ -366,7 +378,7 @@ if (PROTOBUF_FOUND)
|
||||||
message("Skype plugin : no (does not run on Win32)")
|
message("Skype plugin : no (does not run on Win32)")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_XMPP)
|
if(ENABLE_SWIFTEN)
|
||||||
message("Swiften plugin : yes")
|
message("Swiften plugin : yes")
|
||||||
else()
|
else()
|
||||||
message("Swiften plugin : no (user disabled)")
|
message("Swiften plugin : no (user disabled)")
|
||||||
|
@ -473,3 +485,4 @@ if(NOT SQLITE3_FOUND AND NOT MYSQL_FOUND AND NOT PQXX_FOUND)
|
||||||
message("Please enable at least one of SQLITE3, MYSQL, PQXX databases to use transport mode.")
|
message("Please enable at least one of SQLITE3, MYSQL, PQXX databases to use transport mode.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
12
ChangeLog
12
ChangeLog
|
@ -1,15 +1,3 @@
|
||||||
Version 2.0.5 (2017-08-09):
|
|
||||||
Minor bugfixes:
|
|
||||||
* fix purple-hangouts login
|
|
||||||
* fix Debian packages dependencies
|
|
||||||
|
|
||||||
Version 2.0.4 (2017-08-03):
|
|
||||||
General:
|
|
||||||
* Add support for Swiften 4.0rc2. Swiften 3.x and 2.x are still supported.
|
|
||||||
* Add support for passwordless libpurple backends (e.g. purple-hangouts).
|
|
||||||
* Partial support for groupchats with case-sensitive names (e.g. purple-telegram).
|
|
||||||
* Various small bugfixes, see Git commit descriptions for the full list of changes.
|
|
||||||
|
|
||||||
Version 2.0.3 (2016-02-29):
|
Version 2.0.3 (2016-02-29):
|
||||||
General:
|
General:
|
||||||
* Swift 3.0rc2 is now minimum Swift 3.x version needed to compile Spectrum2,
|
* Swift 3.0rc2 is now minimum Swift 3.x version needed to compile Spectrum2,
|
||||||
|
|
23
Dockerfile
23
Dockerfile
|
@ -6,7 +6,7 @@ ARG commit=unknown
|
||||||
RUN echo $commit
|
RUN echo $commit
|
||||||
|
|
||||||
# Spectrum 2
|
# Spectrum 2
|
||||||
RUN dnf install protobuf protobuf swiften gcc gcc-c++ make libpqxx-devel libpurple-devel protobuf-devel swiften-devel rpm-build avahi-devel boost-devel cmake cppunit-devel expat-devel libcommuni-devel libidn-devel libsqlite3x-devel log4cxx-devel gettext libgcrypt-devel libwebp-devel libpurple-devel zlib-devel json-glib-devel python-pip zlib-devel libjpeg-devel python-devel mysql-devel popt-devel git libevent-devel qt-devel dbus-glib-devel libcurl-devel wget mercurial libtool libgnome-keyring-devel nss-devel -y && \
|
RUN dnf install protobuf protobuf swiften gcc gcc-c++ make libpqxx-devel libpurple-devel protobuf-devel swiften-devel rpm-build avahi-devel boost-devel cmake cppunit-devel expat-devel libcommuni-devel libidn-devel libsqlite3x-devel log4cxx-devel gettext libgcrypt-devel libwebp-devel libpurple-devel zlib-devel json-glib-devel python-pip zlib-devel libjpeg-devel python-devel mysql-devel popt-devel git libevent-devel qt-devel dbus-glib-devel libcurl-devel wget -y && \
|
||||||
echo "---> Installing Spectrum 2" && \
|
echo "---> Installing Spectrum 2" && \
|
||||||
git clone git://github.com/hanzz/spectrum2.git && \
|
git clone git://github.com/hanzz/spectrum2.git && \
|
||||||
cd spectrum2 && \
|
cd spectrum2 && \
|
||||||
|
@ -17,10 +17,8 @@ RUN dnf install protobuf protobuf swiften gcc gcc-c++ make libpqxx-devel libpurp
|
||||||
rm -rf spectrum2 && \
|
rm -rf spectrum2 && \
|
||||||
rm -rf ~/rpmbuild && \
|
rm -rf ~/rpmbuild && \
|
||||||
echo "---> Installing purple-facebook" && \
|
echo "---> Installing purple-facebook" && \
|
||||||
wget https://github.com/dequis/purple-facebook/releases/download/v0.9.5-9ff9acf9fa14/purple-facebook-0.9.5-9ff9acf9fa14.tar.gz && \
|
wget https://github.com/jgeboski/purple-facebook/releases/download/6a0a79182ebc/purple-facebook-6a0a79182ebc.tar.gz && \
|
||||||
tar -xf purple-facebook-0.9.5-9ff9acf9fa14.tar.gz && \
|
tar -xf purple-facebook-6a0a79182ebc.tar.gz && cd purple-facebook-6a0a79182ebc && \
|
||||||
cd purple-facebook-0.9.5-9ff9acf9fa14 && \
|
|
||||||
./autogen.sh && \
|
|
||||||
./configure && \
|
./configure && \
|
||||||
make && \
|
make && \
|
||||||
make install && \
|
make install && \
|
||||||
|
@ -53,22 +51,7 @@ RUN dnf install protobuf protobuf swiften gcc gcc-c++ make libpqxx-devel libpurp
|
||||||
./configure && \
|
./configure && \
|
||||||
make && \
|
make && \
|
||||||
make install && \
|
make install && \
|
||||||
cd .. && \
|
|
||||||
rm -rf telegram-purple && \
|
rm -rf telegram-purple && \
|
||||||
echo "---> Install Discord" && \
|
|
||||||
git clone https://github.com/EionRobb/purple-discord.git && \
|
|
||||||
cd purple-discord && \
|
|
||||||
make && \
|
|
||||||
make install && \
|
|
||||||
cd .. && \
|
|
||||||
rm -rf purple-discord && \
|
|
||||||
echo "---> Install Steam" && \
|
|
||||||
git clone https://github.com/EionRobb/pidgin-opensteamworks.git && \
|
|
||||||
cd pidgin-opensteamworks/steam-mobile && \
|
|
||||||
make && \
|
|
||||||
make install && \
|
|
||||||
cd ../.. && \
|
|
||||||
rm -rf pidgin-opensteamworks && \
|
|
||||||
echo "---> cleanup" && \
|
echo "---> cleanup" && \
|
||||||
rm -rf /usr/share/locale/* && \
|
rm -rf /usr/share/locale/* && \
|
||||||
rm -rf /usr/share/doc/* && \
|
rm -rf /usr/share/doc/* && \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[](https://travis-ci.org/SpectrumIM/spectrum2)
|
[](https://travis-ci.org/hanzz/spectrum2)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ if (PROTOBUF_FOUND)
|
||||||
ADD_SUBDIRECTORY(libcommuni)
|
ADD_SUBDIRECTORY(libcommuni)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_XMPP)
|
if (ENABLE_SWIFTEN)
|
||||||
ADD_SUBDIRECTORY(swiften)
|
ADD_SUBDIRECTORY(swiften)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "transport/Config.h"
|
#include "transport/Config.h"
|
||||||
#include "transport/NetworkPlugin.h"
|
#include "transport/NetworkPlugin.h"
|
||||||
#include "Swiften/Swiften.h"
|
#include "Swiften/Swiften.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
|
@ -149,14 +148,14 @@ class FrotzNetworkPlugin : public NetworkPlugin {
|
||||||
public:
|
public:
|
||||||
Swift::BoostNetworkFactories *m_factories;
|
Swift::BoostNetworkFactories *m_factories;
|
||||||
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
|
boost::shared_ptr<Swift::Connection> m_conn;
|
||||||
|
|
||||||
FrotzNetworkPlugin(Config *config, Swift::SimpleEventLoop *loop, const std::string &host, int port) : NetworkPlugin() {
|
FrotzNetworkPlugin(Config *config, Swift::SimpleEventLoop *loop, const std::string &host, int port) : NetworkPlugin() {
|
||||||
this->config = config;
|
this->config = config;
|
||||||
m_factories = new Swift::BoostNetworkFactories(loop);
|
m_factories = new Swift::BoostNetworkFactories(loop);
|
||||||
m_conn = m_factories->getConnectionFactory()->createConnection();
|
m_conn = m_factories->getConnectionFactory()->createConnection();
|
||||||
m_conn->onDataRead.connect(boost::bind(&FrotzNetworkPlugin::_handleDataRead, this, _1));
|
m_conn->onDataRead.connect(boost::bind(&FrotzNetworkPlugin::_handleDataRead, this, _1));
|
||||||
m_conn->connect(Swift::HostAddressPort(SWIFT_HOSTADDRESS(host), port));
|
m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port));
|
||||||
// m_conn->onConnectFinished.connect(boost::bind(&FrotzNetworkPlugin::_handleConnected, this, _1));
|
// m_conn->onConnectFinished.connect(boost::bind(&FrotzNetworkPlugin::_handleConnected, this, _1));
|
||||||
// m_conn->onDisconnected.connect(boost::bind(&FrotzNetworkPlugin::handleDisconnected, this));
|
// m_conn->onDisconnected.connect(boost::bind(&FrotzNetworkPlugin::handleDisconnected, this));
|
||||||
}
|
}
|
||||||
|
@ -165,7 +164,7 @@ class FrotzNetworkPlugin : public NetworkPlugin {
|
||||||
m_conn->write(Swift::createSafeByteArray(string));
|
m_conn->write(Swift::createSafeByteArray(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data) {
|
void _handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data) {
|
||||||
std::string d(data->begin(), data->end());
|
std::string d(data->begin(), data->end());
|
||||||
handleDataRead(d);
|
handleDataRead(d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ircnetworkplugin.h"
|
||||||
#include <IrcCommand>
|
#include <IrcCommand>
|
||||||
#include <IrcMessage>
|
#include <IrcMessage>
|
||||||
#include "ircnetworkplugin.h"
|
|
||||||
#include "transport/Logging.h"
|
#include "transport/Logging.h"
|
||||||
|
|
||||||
DEFINE_LOGGER(logger, "IRCNetworkPlugin");
|
DEFINE_LOGGER(logger, "IRCNetworkPlugin");
|
||||||
|
|
|
@ -21,11 +21,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN
|
#ifndef Q_MOC_RUN
|
||||||
|
#include "transport/Config.h"
|
||||||
|
#include "transport/NetworkPlugin.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
#include "transport/Config.h"
|
|
||||||
#include "transport/NetworkPlugin.h"
|
|
||||||
#include "Swiften/EventLoop/Qt/QtEventLoop.h"
|
#include "Swiften/EventLoop/Qt/QtEventLoop.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,12 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
|
||||||
*/
|
*/
|
||||||
#include <QtCore>
|
|
||||||
#include <QtNetwork>
|
|
||||||
#include "transport/Config.h"
|
#include "transport/Config.h"
|
||||||
#include "transport/NetworkPlugin.h"
|
#include "transport/NetworkPlugin.h"
|
||||||
#include "transport/Logging.h"
|
#include "transport/Logging.h"
|
||||||
|
#include <QtCore>
|
||||||
|
#include <QtNetwork>
|
||||||
#include "Swiften/EventLoop/Qt/QtEventLoop.h"
|
#include "Swiften/EventLoop/Qt/QtEventLoop.h"
|
||||||
#include "ircnetworkplugin.h"
|
#include "ircnetworkplugin.h"
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,12 @@ FILE(GLOB SRC *.cpp)
|
||||||
ADD_EXECUTABLE(spectrum2_libpurple_backend ${SRC})
|
ADD_EXECUTABLE(spectrum2_libpurple_backend ${SRC})
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_link_libraries(spectrum2_libpurple_backend transport ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin ${PROTOBUF_LIBRARY})
|
target_link_libraries(spectrum2_libpurple_backend sqlite3 ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin ${PROTOBUF_LIBRARY})
|
||||||
else()
|
else()
|
||||||
if (NOT WIN32)
|
if (NOT WIN32)
|
||||||
target_link_libraries(spectrum2_libpurple_backend transport ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin pthread)
|
target_link_libraries(spectrum2_libpurple_backend ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin pthread)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(spectrum2_libpurple_backend transport ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin)
|
target_link_libraries(spectrum2_libpurple_backend ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -14,19 +14,15 @@
|
||||||
#include "transport/NetworkPlugin.h"
|
#include "transport/NetworkPlugin.h"
|
||||||
#include "transport/Logging.h"
|
#include "transport/Logging.h"
|
||||||
#include "transport/Config.h"
|
#include "transport/Config.h"
|
||||||
#include "transport/StorageBackend.h"
|
|
||||||
#include "geventloop.h"
|
#include "geventloop.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
// #include "valgrind/memcheck.h"
|
// #include "valgrind/memcheck.h"
|
||||||
#if !defined(__FreeBSD__) && !defined(__APPLE__)
|
#if !defined(__FreeBSD__) && !defined(__APPLE__)
|
||||||
#include "malloc.h"
|
#include "malloc.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include <algorithm>
|
||||||
#include "errno.h"
|
#include "errno.h"
|
||||||
#include <boost/make_shared.hpp>
|
#include <boost/make_shared.hpp>
|
||||||
#include <boost/locale.hpp>
|
|
||||||
#include <boost/locale/conversion.hpp>
|
|
||||||
#include <boost/thread/mutex.hpp>
|
|
||||||
|
|
||||||
#ifdef WITH_LIBEVENT
|
#ifdef WITH_LIBEVENT
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
|
@ -83,9 +79,8 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
|
||||||
|
|
||||||
class SpectrumNetworkPlugin;
|
class SpectrumNetworkPlugin;
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Config> config;
|
boost::shared_ptr<Config> config;
|
||||||
SpectrumNetworkPlugin *np;
|
SpectrumNetworkPlugin *np;
|
||||||
StorageBackend *storagebackend;
|
|
||||||
|
|
||||||
static std::string host;
|
static std::string host;
|
||||||
static int port = 10000;
|
static int port = 10000;
|
||||||
|
@ -123,24 +118,49 @@ struct authRequest {
|
||||||
std::string mainJID; // JID of user connected with this request
|
std::string mainJID; // JID of user connected with this request
|
||||||
};
|
};
|
||||||
|
|
||||||
struct inputRequest {
|
static void * requestInput(const char *title, const char *primary,const char *secondary, const char *default_value, gboolean multiline, gboolean masked, gchar *hint,const char *ok_text, GCallback ok_cb,const char *cancel_text, GCallback cancel_cb, PurpleAccount *account, const char *who,PurpleConversation *conv, void *user_data) {
|
||||||
PurpleRequestInputCb ok_cb;
|
if (primary) {
|
||||||
void *user_data;
|
std::string primaryString(primary);
|
||||||
std::string who;
|
if (primaryString == "Authorization Request Message:") {
|
||||||
PurpleAccount *account;
|
LOG4CXX_INFO(logger, "Authorization Request Message: calling ok_cb(...)");
|
||||||
std::string mainJID; // JID of user connected with this request
|
((PurpleRequestInputCb) ok_cb)(user_data, "Please authorize me.");
|
||||||
};
|
return NULL;
|
||||||
|
}
|
||||||
|
else if (primaryString == "Authorization Request Message:") {
|
||||||
|
LOG4CXX_INFO(logger, "Authorization Request Message: calling ok_cb(...)");
|
||||||
|
((PurpleRequestInputCb) ok_cb)(user_data, "Please authorize me.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else if (primaryString == "Authorization Denied Message:") {
|
||||||
|
LOG4CXX_INFO(logger, "Authorization Deined Message: calling ok_cb(...)");
|
||||||
|
((PurpleRequestInputCb) ok_cb)(user_data, "Authorization denied.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG4CXX_WARN(logger, "Unhandled request input. primary=" << primaryString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (title) {
|
||||||
|
std::string titleString(title);
|
||||||
|
if (titleString == "Xfire Invitation Message") {
|
||||||
|
LOG4CXX_INFO(logger, "Authorization Request Message: calling ok_cb(...)");
|
||||||
|
((PurpleRequestInputCb) ok_cb)(user_data, "Please authorize me.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG4CXX_WARN(logger, "Unhandled request input. title=" << titleString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG4CXX_WARN(logger, "Request input without primary string");
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void *requestAction(const char *title, const char *primary, const char *secondary, int default_action, PurpleAccount *account, const char *who,PurpleConversation *conv, void *user_data, size_t action_count, va_list actions){
|
static void *requestAction(const char *title, const char *primary, const char *secondary, int default_action, PurpleAccount *account, const char *who,PurpleConversation *conv, void *user_data, size_t action_count, va_list actions){
|
||||||
std::string t(title ? title : "NULL");
|
std::string t(title ? title : "NULL");
|
||||||
if (t == "SSL Certificate Verification") {
|
if (t == "SSL Certificate Verification") {
|
||||||
if (CONFIG_BOOL_DEFAULTED(config, "service.verify_certs", false)) {
|
|
||||||
LOG4CXX_INFO(logger, "rejecting SSL certificate");
|
|
||||||
va_arg(actions, char *);
|
|
||||||
va_arg(actions, GCallback);
|
|
||||||
} else {
|
|
||||||
LOG4CXX_INFO(logger, "accepting SSL certificate");
|
LOG4CXX_INFO(logger, "accepting SSL certificate");
|
||||||
}
|
|
||||||
va_arg(actions, char *);
|
va_arg(actions, char *);
|
||||||
((PurpleRequestActionCb) va_arg(actions, GCallback)) (user_data, 2);
|
((PurpleRequestActionCb) va_arg(actions, GCallback)) (user_data, 2);
|
||||||
}
|
}
|
||||||
|
@ -156,10 +176,6 @@ static void *requestAction(const char *title, const char *primary, const char *s
|
||||||
std::string headerString(title);
|
std::string headerString(title);
|
||||||
LOG4CXX_INFO(logger, "header string: " << headerString);
|
LOG4CXX_INFO(logger, "header string: " << headerString);
|
||||||
if (headerString == "SSL Certificate Verification") {
|
if (headerString == "SSL Certificate Verification") {
|
||||||
if (CONFIG_BOOL_DEFAULTED(config, "service.verify_certs", false)) {
|
|
||||||
va_arg(actions, char *);
|
|
||||||
va_arg(actions, GCallback);
|
|
||||||
}
|
|
||||||
va_arg(actions, char *);
|
va_arg(actions, char *);
|
||||||
((PurpleRequestActionCb) va_arg(actions, GCallback)) (user_data, 2);
|
((PurpleRequestActionCb) va_arg(actions, GCallback)) (user_data, 2);
|
||||||
}
|
}
|
||||||
|
@ -183,39 +199,10 @@ static std::string getAlias(PurpleBuddy *m_buddy) {
|
||||||
return alias;
|
return alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boost::mutex dblock;
|
|
||||||
static std::string OAUTH_TOKEN = "hangouts_oauth_token";
|
|
||||||
|
|
||||||
static bool getUserOAuthToken(const std::string user, std::string &token)
|
|
||||||
{
|
|
||||||
boost::mutex::scoped_lock lock(dblock);
|
|
||||||
UserInfo info;
|
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
token = "";
|
|
||||||
int type = TYPE_STRING;
|
|
||||||
storagebackend->getUserSetting((long)info.id, OAUTH_TOKEN, type, token);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool storeUserOAuthToken(const std::string user, const std::string OAuthToken)
|
|
||||||
{
|
|
||||||
boost::mutex::scoped_lock lock(dblock);
|
|
||||||
UserInfo info;
|
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
storagebackend->updateUserSetting((long)info.id, OAUTH_TOKEN, OAuthToken);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
class SpectrumNetworkPlugin : public NetworkPlugin {
|
class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
public:
|
public:
|
||||||
SpectrumNetworkPlugin() : NetworkPlugin() {
|
SpectrumNetworkPlugin() : NetworkPlugin() {
|
||||||
LOG4CXX_INFO(logger, "Starting libpurple backend " << SPECTRUM_VERSION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleExitRequest() {
|
void handleExitRequest() {
|
||||||
|
@ -278,7 +265,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
found = true;
|
found = true;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PURPLE_PREF_BOOLEAN:
|
case PURPLE_PREF_BOOLEAN:
|
||||||
purple_account_set_bool_wrapped(account, strippedKey.c_str(), keyItem.second.as<bool>());
|
purple_account_set_bool_wrapped(account, strippedKey.c_str(), fromString<bool>(keyItem.second.as<std::string>()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PURPLE_PREF_INT:
|
case PURPLE_PREF_INT:
|
||||||
|
@ -360,19 +347,11 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
std::string protocol;
|
std::string protocol;
|
||||||
getProtocolAndName(legacyName, name, protocol);
|
getProtocolAndName(legacyName, name, protocol);
|
||||||
|
|
||||||
if (password.empty() && protocol != "prpl-telegram" && protocol != "prpl-hangouts") {
|
if (password.empty() && CONFIG_STRING(config, "service.protocol") != "prpl-telegram") {
|
||||||
LOG4CXX_INFO(logger, name.c_str() << ": Empty password");
|
LOG4CXX_INFO(logger, name.c_str() << ": Empty password");
|
||||||
np->handleDisconnected(user, 1, "Empty password.");
|
np->handleDisconnected(user, 1, "Empty password.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (protocol == "prpl-hangouts") {
|
|
||||||
adminLegacyName = "hangouts";
|
|
||||||
adminAlias = "hangouts";
|
|
||||||
}
|
|
||||||
else if (protocol == "prpl-steam-mobile") {
|
|
||||||
adminLegacyName = "steam-mobile";
|
|
||||||
adminAlias = "steam-mobile";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!purple_find_prpl_wrapped(protocol.c_str())) {
|
if (!purple_find_prpl_wrapped(protocol.c_str())) {
|
||||||
LOG4CXX_INFO(logger, name.c_str() << ": Invalid protocol '" << protocol << "'");
|
LOG4CXX_INFO(logger, name.c_str() << ": Invalid protocol '" << protocol << "'");
|
||||||
|
@ -405,12 +384,6 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
purple_account_set_bool_wrapped(account, "custom_smileys", FALSE);
|
purple_account_set_bool_wrapped(account, "custom_smileys", FALSE);
|
||||||
purple_account_set_bool_wrapped(account, "direct_connect", FALSE);
|
purple_account_set_bool_wrapped(account, "direct_connect", FALSE);
|
||||||
purple_account_set_bool_wrapped(account, "compat-verification", TRUE);
|
purple_account_set_bool_wrapped(account, "compat-verification", TRUE);
|
||||||
if (protocol == "prpl-hangouts") {
|
|
||||||
std::string token;
|
|
||||||
if (getUserOAuthToken(user, token)) {
|
|
||||||
purple_account_set_password_wrapped(account, token.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setDefaultAccountOptions(account);
|
setDefaultAccountOptions(account);
|
||||||
|
|
||||||
|
@ -428,11 +401,6 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
if (status_type != NULL) {
|
if (status_type != NULL) {
|
||||||
purple_account_set_status_wrapped(account, purple_status_type_get_id_wrapped(status_type), TRUE, NULL);
|
purple_account_set_status_wrapped(account, purple_status_type_get_id_wrapped(status_type), TRUE, NULL);
|
||||||
}
|
}
|
||||||
// OAuth helper
|
|
||||||
if (protocol == "prpl-hangouts") {
|
|
||||||
LOG4CXX_INFO(logger, user << ": Adding Buddy " << adminLegacyName << " " << adminAlias);
|
|
||||||
handleBuddyChanged(user, adminLegacyName, adminAlias, std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleLogoutRequest(const std::string &user, const std::string &legacyName) {
|
void handleLogoutRequest(const std::string &user, const std::string &legacyName) {
|
||||||
|
@ -522,21 +490,11 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
PurpleAccount *account = m_sessions[user];
|
PurpleAccount *account = m_sessions[user];
|
||||||
if (account) {
|
if (account) {
|
||||||
LOG4CXX_INFO(logger, "Sending message to '" << legacyName << "'");
|
LOG4CXX_INFO(logger, "Sending message to '" << legacyName << "'");
|
||||||
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, LegacyNameToName(account, legacyName).c_str(), account);
|
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, legacyName.c_str(), account);
|
||||||
if (legacyName == adminLegacyName) {
|
|
||||||
// expect OAuth code
|
|
||||||
if (m_inputRequests.find(user) != m_inputRequests.end()) {
|
|
||||||
LOG4CXX_INFO(logger, "Updating token for '" << user << "'");
|
|
||||||
m_inputRequests[user]->ok_cb(m_inputRequests[user]->user_data, message.c_str());
|
|
||||||
m_inputRequests.erase(user);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!conv) {
|
if (!conv) {
|
||||||
conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_IM, LegacyNameToName(account, legacyName).c_str(), account);
|
conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_IM, legacyName.c_str(), account);
|
||||||
if (!conv) {
|
if (!conv) {
|
||||||
conv = purple_conversation_new_wrapped(PURPLE_CONV_TYPE_IM, account, LegacyNameToName(account, legacyName).c_str());
|
conv = purple_conversation_new_wrapped(PURPLE_CONV_TYPE_IM, account, legacyName.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (xhtml.empty()) {
|
if (xhtml.empty()) {
|
||||||
|
@ -563,7 +521,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
void handleRoomSubjectChangedRequest(const std::string &user, const std::string &legacyName, const std::string &message) {
|
void handleRoomSubjectChangedRequest(const std::string &user, const std::string &legacyName, const std::string &message) {
|
||||||
PurpleAccount *account = m_sessions[user];
|
PurpleAccount *account = m_sessions[user];
|
||||||
if (account) {
|
if (account) {
|
||||||
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, LegacyNameToName(account, legacyName).c_str(), account);
|
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, legacyName.c_str(), account);
|
||||||
if (!conv) {
|
if (!conv) {
|
||||||
LOG4CXX_ERROR(logger, user << ": Cannot set room subject. There is now conversation " << legacyName);
|
LOG4CXX_ERROR(logger, user << ": Cannot set room subject. There is now conversation " << legacyName);
|
||||||
return;
|
return;
|
||||||
|
@ -734,29 +692,6 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string LegacyNameToName(PurpleAccount *account, const std::string &legacyName) {
|
|
||||||
std::string conversationName = legacyName;
|
|
||||||
BOOST_FOREACH(std::string _room, m_rooms[np->m_accounts[account]]) {
|
|
||||||
std::string lowercased_room = boost::locale::to_lower(_room);
|
|
||||||
if (lowercased_room.compare(conversationName) == 0) {
|
|
||||||
conversationName = _room;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return conversationName;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string NameToLegacyName(PurpleAccount *account, const std::string &legacyName) {
|
|
||||||
std::string conversationName = legacyName;
|
|
||||||
BOOST_FOREACH(std::string _room, m_rooms[np->m_accounts[account]]) {
|
|
||||||
if (_room.compare(conversationName) == 0) {
|
|
||||||
conversationName = boost::locale::to_lower(legacyName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return conversationName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &pasword) {
|
void handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &pasword) {
|
||||||
PurpleAccount *account = m_sessions[user];
|
PurpleAccount *account = m_sessions[user];
|
||||||
if (!account) {
|
if (!account) {
|
||||||
|
@ -765,17 +700,17 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
|
|
||||||
PurpleConnection *gc = purple_account_get_connection_wrapped(account);
|
PurpleConnection *gc = purple_account_get_connection_wrapped(account);
|
||||||
GHashTable *comps = NULL;
|
GHashTable *comps = NULL;
|
||||||
std::string roomName = LegacyNameToName(account, room);
|
|
||||||
// Check if the PurpleChat is not stored in buddy list
|
// Check if the PurpleChat is not stored in buddy list
|
||||||
PurpleChat *chat = purple_blist_find_chat_wrapped(account, roomName.c_str());
|
PurpleChat *chat = purple_blist_find_chat_wrapped(account, room.c_str());
|
||||||
if (chat) {
|
if (chat) {
|
||||||
comps = purple_chat_get_components_wrapped(chat);
|
comps = purple_chat_get_components_wrapped(chat);
|
||||||
}
|
}
|
||||||
else if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) {
|
else if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) {
|
||||||
if (CONFIG_STRING(config, "service.protocol") == "prpl-jabber") {
|
if (CONFIG_STRING(config, "service.protocol") == "prpl-jabber") {
|
||||||
comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, (roomName + "/" + nickname).c_str());
|
comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, (room + "/" + nickname).c_str());
|
||||||
} else {
|
} else {
|
||||||
comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, roomName.c_str());
|
comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, room.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +728,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << ": Joining the room " << roomName);
|
LOG4CXX_INFO(logger, user << ": Joining the room " << room);
|
||||||
if (comps) {
|
if (comps) {
|
||||||
serv_join_chat_wrapped(gc, comps);
|
serv_join_chat_wrapped(gc, comps);
|
||||||
g_hash_table_destroy(comps);
|
g_hash_table_destroy(comps);
|
||||||
|
@ -806,7 +741,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, LegacyNameToName(account, room).c_str(), account);
|
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, room.c_str(), account);
|
||||||
purple_conversation_destroy_wrapped(conv);
|
purple_conversation_destroy_wrapped(conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -877,13 +812,9 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
std::map<PurpleAccount *, std::string> m_accounts;
|
std::map<PurpleAccount *, std::string> m_accounts;
|
||||||
std::map<std::string, unsigned int> m_vcards;
|
std::map<std::string, unsigned int> m_vcards;
|
||||||
std::map<std::string, authRequest *> m_authRequests;
|
std::map<std::string, authRequest *> m_authRequests;
|
||||||
std::map<std::string, inputRequest *> m_inputRequests;
|
|
||||||
std::map<std::string, std::list<std::string> > m_rooms;
|
|
||||||
std::map<unsigned long, PurpleXfer *> m_xfers;
|
std::map<unsigned long, PurpleXfer *> m_xfers;
|
||||||
std::map<std::string, PurpleXfer *> m_unhandledXfers;
|
std::map<std::string, PurpleXfer *> m_unhandledXfers;
|
||||||
std::vector<PurpleXfer *> m_waitingXfers;
|
std::vector<PurpleXfer *> m_waitingXfers;
|
||||||
std::string adminLegacyName;
|
|
||||||
std::string adminAlias;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool getStatus(PurpleBuddy *m_buddy, pbnetwork::StatusType &status, std::string &statusMessage) {
|
static bool getStatus(PurpleBuddy *m_buddy, pbnetwork::StatusType &status, std::string &statusMessage) {
|
||||||
|
@ -1188,9 +1119,8 @@ static void conv_write(PurpleConversation *conv, const char *who, const char *al
|
||||||
np->handleMessage(np->m_accounts[account], w, message_, "", xhtml_, timestamp);
|
np->handleMessage(np->m_accounts[account], w, message_, "", xhtml_, timestamp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::string conversationName = purple_conversation_get_name_wrapped(conv);
|
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' name='" << purple_conversation_get_name_wrapped(conv) << "' " << who);
|
||||||
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' name='" << conversationName << "' " << who);
|
np->handleMessage(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), message_, who, xhtml_, timestamp);
|
||||||
np->handleMessage(np->m_accounts[account], np->NameToLegacyName(account, conversationName), message_, who, xhtml_, timestamp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1338,9 +1268,8 @@ static void conv_write_im(PurpleConversation *conv, const char *who, const char
|
||||||
np->handleMessage(np->m_accounts[account], w, message_, n, xhtml_, timestamp);
|
np->handleMessage(np->m_accounts[account], w, message_, n, xhtml_, timestamp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::string conversationName = purple_conversation_get_name_wrapped(conv);
|
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' xhtml='" << xhtml_ << "' name='" << purple_conversation_get_name_wrapped(conv) << "' " << who);
|
||||||
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' xhtml='" << xhtml_ << "' name='" << conversationName << "' " << who);
|
np->handleMessage(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), message_, who, xhtml_, timestamp);
|
||||||
np->handleMessage(np->m_accounts[account], np->NameToLegacyName(account, conversationName), message_, who, xhtml_, timestamp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,8 +1297,8 @@ static void conv_chat_add_users(PurpleConversation *conv, GList *cbuddies, gbool
|
||||||
// item->addAttribute("affiliation", "member");
|
// item->addAttribute("affiliation", "member");
|
||||||
// item->addAttribute("role", "participant");
|
// item->addAttribute("role", "participant");
|
||||||
}
|
}
|
||||||
std::string conversationName = purple_conversation_get_name_wrapped(conv);
|
|
||||||
np->handleParticipantChanged(np->m_accounts[account], name, np->NameToLegacyName(account, conversationName), (int) flags, pbnetwork::STATUS_ONLINE, "", "", alias);
|
np->handleParticipantChanged(np->m_accounts[account], name, purple_conversation_get_name_wrapped(conv), (int) flags, pbnetwork::STATUS_ONLINE, "", "", alias);
|
||||||
|
|
||||||
l = l->next;
|
l = l->next;
|
||||||
}
|
}
|
||||||
|
@ -1381,8 +1310,7 @@ static void conv_chat_remove_users(PurpleConversation *conv, GList *users) {
|
||||||
GList *l = users;
|
GList *l = users;
|
||||||
while (l != NULL) {
|
while (l != NULL) {
|
||||||
std::string name((char *) l->data);
|
std::string name((char *) l->data);
|
||||||
std::string conversationName = purple_conversation_get_name_wrapped(conv);
|
np->handleParticipantChanged(np->m_accounts[account], name, purple_conversation_get_name_wrapped(conv), 0, pbnetwork::STATUS_NONE);
|
||||||
np->handleParticipantChanged(np->m_accounts[account], name, np->NameToLegacyName(account, conversationName), 0, pbnetwork::STATUS_NONE);
|
|
||||||
|
|
||||||
l = l->next;
|
l = l->next;
|
||||||
}
|
}
|
||||||
|
@ -1395,7 +1323,7 @@ static gboolean conv_has_focus(PurpleConversation *conv) {
|
||||||
static void conv_chat_topic_changed(PurpleConversation *conv, const char *who, const char *topic) {
|
static void conv_chat_topic_changed(PurpleConversation *conv, const char *who, const char *topic) {
|
||||||
LOG4CXX_INFO(logger, "Conversation topic changed");
|
LOG4CXX_INFO(logger, "Conversation topic changed");
|
||||||
PurpleAccount *account = purple_conversation_get_account_wrapped(conv);
|
PurpleAccount *account = purple_conversation_get_account_wrapped(conv);
|
||||||
np->handleSubject(np->m_accounts[account], np->NameToLegacyName(account, purple_conversation_get_name_wrapped(conv)), topic ? topic : "", who ? who : "Spectrum 2");
|
np->handleSubject(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), topic ? topic : "", who ? who : "Spectrum 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void conv_present(PurpleConversation *conv) {
|
static void conv_present(PurpleConversation *conv) {
|
||||||
|
@ -1588,69 +1516,6 @@ static void *notify_user_info(PurpleConnection *gc, const char *who, PurpleNotif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * requestInput(const char *title, const char *primary,const char *secondary, const char *default_value, gboolean multiline, gboolean masked, gchar *hint,const char *ok_text, GCallback ok_cb,const char *cancel_text, GCallback cancel_cb, PurpleAccount *account, const char *who,PurpleConversation *conv, void *user_data) {
|
|
||||||
if (primary) {
|
|
||||||
std::string primaryString(primary);
|
|
||||||
if (primaryString == "Authorization Request Message:") {
|
|
||||||
LOG4CXX_INFO(logger, "Authorization Request Message: calling ok_cb(...)");
|
|
||||||
((PurpleRequestInputCb) ok_cb)(user_data, "Please authorize me.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if (primaryString == "Authorization Request Message:") {
|
|
||||||
LOG4CXX_INFO(logger, "Authorization Request Message: calling ok_cb(...)");
|
|
||||||
((PurpleRequestInputCb) ok_cb)(user_data, "Please authorize me.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if (primaryString == "Authorization Denied Message:") {
|
|
||||||
LOG4CXX_INFO(logger, "Authorization Deined Message: calling ok_cb(...)");
|
|
||||||
((PurpleRequestInputCb) ok_cb)(user_data, "Authorization denied.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if (boost::starts_with(primaryString, "https://accounts.google.com/o/oauth2/auth") ||
|
|
||||||
boost::starts_with(primaryString, "https://www.youtube.com/watch?v=hlDhp-eNLMU")) {
|
|
||||||
LOG4CXX_INFO(logger, "prpl-hangouts oauth request");
|
|
||||||
np->handleMessage(np->m_accounts[account], np->adminLegacyName, std::string("Please visit the following link and authorize this application: ") + primaryString, "");
|
|
||||||
np->handleMessage(np->m_accounts[account], np->adminLegacyName, std::string("Reply with code provided by Google: "));
|
|
||||||
inputRequest *req = new inputRequest;
|
|
||||||
req->ok_cb = (PurpleRequestInputCb)ok_cb;
|
|
||||||
req->user_data = user_data;
|
|
||||||
req->account = account;
|
|
||||||
req->mainJID = np->m_accounts[account];
|
|
||||||
np->m_inputRequests[req->mainJID] = req;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else if (primaryString == "Set your Steam Guard Code") {
|
|
||||||
LOG4CXX_INFO(logger, "prpl-steam-mobile steam guard request");
|
|
||||||
np->handleMessage(np->m_accounts[account], np->adminLegacyName, std::string("Steam Guard code: "));
|
|
||||||
inputRequest *req = new inputRequest;
|
|
||||||
req->ok_cb = (PurpleRequestInputCb)ok_cb;
|
|
||||||
req->user_data = user_data;
|
|
||||||
req->account = account;
|
|
||||||
req->mainJID = np->m_accounts[account];
|
|
||||||
np->m_inputRequests[req->mainJID] = req;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG4CXX_WARN(logger, "Unhandled request input. primary=" << primaryString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (title) {
|
|
||||||
std::string titleString(title);
|
|
||||||
if (titleString == "Xfire Invitation Message") {
|
|
||||||
LOG4CXX_INFO(logger, "Authorization Request Message: calling ok_cb(...)");
|
|
||||||
((PurpleRequestInputCb) ok_cb)(user_data, "Please authorize me.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG4CXX_WARN(logger, "Unhandled request input. title=" << titleString);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG4CXX_WARN(logger, "Request input without primary string");
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PurpleNotifyUiOps notifyUiOps =
|
static PurpleNotifyUiOps notifyUiOps =
|
||||||
{
|
{
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1879,10 +1744,11 @@ static void RoomlistProgress(PurpleRoomlist *list, gboolean in_progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
GList *rooms;
|
GList *rooms;
|
||||||
|
std::list<std::string> m_rooms;
|
||||||
std::list<std::string> m_topics;
|
std::list<std::string> m_topics;
|
||||||
for (rooms = list->rooms; rooms != NULL; rooms = rooms->next) {
|
for (rooms = list->rooms; rooms != NULL; rooms = rooms->next) {
|
||||||
PurpleRoomlistRoom *room = (PurpleRoomlistRoom *)rooms->data;
|
PurpleRoomlistRoom *room = (PurpleRoomlistRoom *)rooms->data;
|
||||||
np->m_rooms[np->m_accounts[list->account]].push_back(room->name);
|
m_rooms.push_back(room->name);
|
||||||
|
|
||||||
if (topicId == -1) {
|
if (topicId == -1) {
|
||||||
m_topics.push_back(room->name);
|
m_topics.push_back(room->name);
|
||||||
|
@ -1917,7 +1783,7 @@ static void RoomlistProgress(PurpleRoomlist *list, gboolean in_progress)
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, "RoomList is fetched for user " << user);
|
LOG4CXX_INFO(logger, "RoomList is fetched for user " << user);
|
||||||
np->handleRoomList(user, np->m_rooms[user], m_topics);
|
np->handleRoomList(user, m_rooms, m_topics);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG4CXX_INFO(logger, "RoomList is still in progress");
|
LOG4CXX_INFO(logger, "RoomList is still in progress");
|
||||||
|
@ -2049,9 +1915,6 @@ static void signed_on(PurpleConnection *gc, gpointer unused) {
|
||||||
|
|
||||||
// For prpl-gg
|
// For prpl-gg
|
||||||
execute_purple_plugin_action(gc, "Download buddylist from Server");
|
execute_purple_plugin_action(gc, "Download buddylist from Server");
|
||||||
if (CONFIG_STRING(config, "service.protocol") == "prpl-hangouts") {
|
|
||||||
storeUserOAuthToken(np->m_accounts[account], purple_account_get_password_wrapped(account));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printDebug(PurpleDebugLevel level, const char *category, const char *arg_s) {
|
static void printDebug(PurpleDebugLevel level, const char *category, const char *arg_s) {
|
||||||
|
@ -2230,10 +2093,7 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
|
||||||
if (CONFIG_STRING(config, "service.protocol") == "prpl-telegram") {
|
if (CONFIG_STRING(config, "service.protocol") == "prpl-telegram") {
|
||||||
cfg.setNeedPassword(false);
|
cfg.setNeedPassword(false);
|
||||||
}
|
}
|
||||||
if (CONFIG_STRING(config, "service.protocol") == "prpl-hangouts") {
|
if (CONFIG_STRING(config, "service.protocol") == "prpl-irc") {
|
||||||
cfg.setNeedPassword(false);
|
|
||||||
}
|
|
||||||
if (CONFIG_BOOL(config, "service.server_mode") || CONFIG_STRING(config, "service.protocol") == "prpl-irc") {
|
|
||||||
cfg.setNeedRegistration(false);
|
cfg.setNeedRegistration(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2254,8 +2114,6 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
boost::locale::generator gen;
|
|
||||||
std::locale::global(gen(""));
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#if !defined(__FreeBSD__) && !defined(__APPLE__)
|
#if !defined(__FreeBSD__) && !defined(__APPLE__)
|
||||||
mallopt(M_CHECK_ACTION, 2);
|
mallopt(M_CHECK_ACTION, 2);
|
||||||
|
@ -2277,22 +2135,9 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Config>(cfg);
|
config = boost::shared_ptr<Config>(cfg);
|
||||||
|
|
||||||
Logging::initBackendLogging(config.get());
|
Logging::initBackendLogging(config.get());
|
||||||
if (CONFIG_STRING(config, "service.protocol") == "prpl-hangouts") {
|
|
||||||
storagebackend = StorageBackend::createBackend(config.get(), error);
|
|
||||||
if (storagebackend == NULL) {
|
|
||||||
LOG4CXX_ERROR(logger, "Error creating StorageBackend! " << error);
|
|
||||||
LOG4CXX_ERROR(logger, "Hangouts backend needs storage backend configured to work! " << error);
|
|
||||||
return NetworkPlugin::StorageBackendNeeded;
|
|
||||||
}
|
|
||||||
else if (!storagebackend->connect()) {
|
|
||||||
LOG4CXX_ERROR(logger, "Can't connect to database!");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
initPurple();
|
initPurple();
|
||||||
|
|
||||||
main_socket = create_socket(host.c_str(), port);
|
main_socket = create_socket(host.c_str(), port);
|
||||||
|
|
|
@ -12,7 +12,6 @@ purple_account_set_proxy_info_wrapped_fnc purple_account_set_proxy_info_wrapped
|
||||||
purple_accounts_find_wrapped_fnc purple_accounts_find_wrapped = NULL;
|
purple_accounts_find_wrapped_fnc purple_accounts_find_wrapped = NULL;
|
||||||
purple_account_new_wrapped_fnc purple_account_new_wrapped = NULL;
|
purple_account_new_wrapped_fnc purple_account_new_wrapped = NULL;
|
||||||
purple_accounts_add_wrapped_fnc purple_accounts_add_wrapped = NULL;
|
purple_accounts_add_wrapped_fnc purple_accounts_add_wrapped = NULL;
|
||||||
purple_account_get_password_wrapped_fnc purple_account_get_password_wrapped = NULL;
|
|
||||||
purple_account_set_password_wrapped_fnc purple_account_set_password_wrapped = NULL;
|
purple_account_set_password_wrapped_fnc purple_account_set_password_wrapped = NULL;
|
||||||
purple_account_set_enabled_wrapped_fnc purple_account_set_enabled_wrapped = NULL;
|
purple_account_set_enabled_wrapped_fnc purple_account_set_enabled_wrapped = NULL;
|
||||||
purple_account_set_privacy_type_wrapped_fnc purple_account_set_privacy_type_wrapped = NULL;
|
purple_account_set_privacy_type_wrapped_fnc purple_account_set_privacy_type_wrapped = NULL;
|
||||||
|
@ -193,10 +192,6 @@ bool resolvePurpleFunctions() {
|
||||||
if (!purple_accounts_add_wrapped)
|
if (!purple_accounts_add_wrapped)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
purple_account_get_password_wrapped = (purple_account_get_password_wrapped_fnc)GetProcAddress(f_hPurple, "purple_account_get_password");
|
|
||||||
if (!purple_account_get_password_wrapped)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
purple_account_set_password_wrapped = (purple_account_set_password_wrapped_fnc)GetProcAddress(f_hPurple, "purple_account_set_password");
|
purple_account_set_password_wrapped = (purple_account_set_password_wrapped_fnc)GetProcAddress(f_hPurple, "purple_account_set_password");
|
||||||
if (!purple_account_set_password_wrapped)
|
if (!purple_account_set_password_wrapped)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -44,9 +44,6 @@ extern purple_account_new_wrapped_fnc purple_account_new_wrapped;
|
||||||
typedef void (_cdecl * purple_accounts_add_wrapped_fnc)(PurpleAccount *account);
|
typedef void (_cdecl * purple_accounts_add_wrapped_fnc)(PurpleAccount *account);
|
||||||
extern purple_accounts_add_wrapped_fnc purple_accounts_add_wrapped;
|
extern purple_accounts_add_wrapped_fnc purple_accounts_add_wrapped;
|
||||||
|
|
||||||
typedef const char * (_cdecl * purple_account_get_password_wrapped_fnc)(const PurpleAccount *account);
|
|
||||||
extern purple_account_get_password_wrapped_fnc purple_account_get_password_wrapped;
|
|
||||||
|
|
||||||
typedef void (_cdecl * purple_account_set_password_wrapped_fnc)(PurpleAccount *account, const char *password);
|
typedef void (_cdecl * purple_account_set_password_wrapped_fnc)(PurpleAccount *account, const char *password);
|
||||||
extern purple_account_set_password_wrapped_fnc purple_account_set_password_wrapped;
|
extern purple_account_set_password_wrapped_fnc purple_account_set_password_wrapped;
|
||||||
|
|
||||||
|
@ -479,7 +476,6 @@ extern wpurple_g_io_channel_win32_new_socket_wrapped_fnc wpurple_g_io_channel_wi
|
||||||
#define purple_accounts_find_wrapped purple_accounts_find
|
#define purple_accounts_find_wrapped purple_accounts_find
|
||||||
#define purple_account_new_wrapped purple_account_new
|
#define purple_account_new_wrapped purple_account_new
|
||||||
#define purple_accounts_add_wrapped purple_accounts_add
|
#define purple_accounts_add_wrapped purple_accounts_add
|
||||||
#define purple_account_get_password_wrapped purple_account_get_password
|
|
||||||
#define purple_account_set_password_wrapped purple_account_set_password
|
#define purple_account_set_password_wrapped purple_account_set_password
|
||||||
#define purple_account_set_enabled_wrapped purple_account_set_enabled
|
#define purple_account_set_enabled_wrapped purple_account_set_enabled
|
||||||
#define purple_account_set_privacy_type_wrapped purple_account_set_privacy_type
|
#define purple_account_set_privacy_type_wrapped purple_account_set_privacy_type
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "transport/PQXXBackend.h"
|
#include "transport/PQXXBackend.h"
|
||||||
#include "transport/StorageBackend.h"
|
#include "transport/StorageBackend.h"
|
||||||
#include "Swiften/Swiften.h"
|
#include "Swiften/Swiften.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
|
@ -46,7 +45,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
|
||||||
public:
|
public:
|
||||||
Swift::BoostNetworkFactories *m_factories;
|
Swift::BoostNetworkFactories *m_factories;
|
||||||
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
|
boost::shared_ptr<Swift::Connection> m_conn;
|
||||||
Swift::Timer::ref m_timer;
|
Swift::Timer::ref m_timer;
|
||||||
int m_internalUser;
|
int m_internalUser;
|
||||||
StorageBackend *storageBackend;
|
StorageBackend *storageBackend;
|
||||||
|
@ -57,7 +56,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
|
||||||
m_factories = new Swift::BoostNetworkFactories(loop);
|
m_factories = new Swift::BoostNetworkFactories(loop);
|
||||||
m_conn = m_factories->getConnectionFactory()->createConnection();
|
m_conn = m_factories->getConnectionFactory()->createConnection();
|
||||||
m_conn->onDataRead.connect(boost::bind(&SMSNetworkPlugin::_handleDataRead, this, _1));
|
m_conn->onDataRead.connect(boost::bind(&SMSNetworkPlugin::_handleDataRead, this, _1));
|
||||||
m_conn->connect(Swift::HostAddressPort(SWIFT_HOSTADDRESS(host), port));
|
m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port));
|
||||||
// m_conn->onConnectFinished.connect(boost::bind(&FrotzNetworkPlugin::_handleConnected, this, _1));
|
// m_conn->onConnectFinished.connect(boost::bind(&FrotzNetworkPlugin::_handleConnected, this, _1));
|
||||||
// m_conn->onDisconnected.connect(boost::bind(&FrotzNetworkPlugin::handleDisconnected, this));
|
// m_conn->onDisconnected.connect(boost::bind(&FrotzNetworkPlugin::handleDisconnected, this));
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
|
||||||
|
|
||||||
|
|
||||||
void handleSMS(const std::string &sms) {
|
void handleSMS(const std::string &sms) {
|
||||||
LOG4CXX_INFO(logger, "Handling SMS " << sms << ".");
|
LOG4CXX_INFO(logger, "Handling SMS " << sms << ".")
|
||||||
std::ifstream t(sms.c_str());
|
std::ifstream t(sms.c_str());
|
||||||
std::string str;
|
std::string str;
|
||||||
|
|
||||||
|
@ -170,7 +169,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
|
||||||
m_conn->write(Swift::createSafeByteArray(string));
|
m_conn->write(Swift::createSafeByteArray(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data) {
|
void _handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data) {
|
||||||
std::string d(data->begin(), data->end());
|
std::string d(data->begin(), data->end());
|
||||||
handleDataRead(d);
|
handleDataRead(d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
// Swiften
|
// Swiften
|
||||||
#include "Swiften/Swiften.h"
|
#include "Swiften/Swiften.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
#include <Swiften/Version.h>
|
#include <Swiften/Version.h>
|
||||||
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
|
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ class ForwardIQHandler : public Swift::IQHandler {
|
||||||
m_user = user;
|
m_user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleIQ(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ> iq) {
|
bool handleIQ(boost::shared_ptr<Swift::IQ> iq) {
|
||||||
if (iq->getPayload<Swift::RosterPayload>() != NULL) {
|
if (iq->getPayload<Swift::RosterPayload>() != NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +75,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
public:
|
public:
|
||||||
Swift::BoostNetworkFactories *m_factories;
|
Swift::BoostNetworkFactories *m_factories;
|
||||||
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
|
boost::shared_ptr<Swift::Connection> m_conn;
|
||||||
bool m_firstPing;
|
bool m_firstPing;
|
||||||
|
|
||||||
Swift::FullPayloadSerializerCollection collection;
|
Swift::FullPayloadSerializerCollection collection;
|
||||||
|
@ -89,7 +88,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
m_factories = new Swift::BoostNetworkFactories(loop);
|
m_factories = new Swift::BoostNetworkFactories(loop);
|
||||||
m_conn = m_factories->getConnectionFactory()->createConnection();
|
m_conn = m_factories->getConnectionFactory()->createConnection();
|
||||||
m_conn->onDataRead.connect(boost::bind(&SwiftenPlugin::_handleDataRead, this, _1));
|
m_conn->onDataRead.connect(boost::bind(&SwiftenPlugin::_handleDataRead, this, _1));
|
||||||
m_conn->connect(Swift::HostAddressPort(SWIFT_HOSTADDRESS(host), port));
|
m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port));
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
serializer = new Swift::XMPPSerializer(&collection, Swift::ClientStreamType, false);
|
serializer = new Swift::XMPPSerializer(&collection, Swift::ClientStreamType, false);
|
||||||
#else
|
#else
|
||||||
|
@ -107,7 +106,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method has to call handleDataRead with all received data from network plugin server
|
// This method has to call handleDataRead with all received data from network plugin server
|
||||||
void _handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data) {
|
void _handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data) {
|
||||||
if (m_firstPing) {
|
if (m_firstPing) {
|
||||||
m_firstPing = false;
|
m_firstPing = false;
|
||||||
NetworkPlugin::PluginConfig cfg;
|
NetworkPlugin::PluginConfig cfg;
|
||||||
|
@ -121,36 +120,36 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
|
|
||||||
void handleStreamStart(const Swift::ProtocolHeader&) {}
|
void handleStreamStart(const Swift::ProtocolHeader&) {}
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::ToplevelElement> element) {
|
void handleElement(boost::shared_ptr<Swift::ToplevelElement> element) {
|
||||||
#else
|
#else
|
||||||
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Element> element) {
|
void handleElement(boost::shared_ptr<Swift::Element> element) {
|
||||||
#endif
|
#endif
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Stanza> stanza = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Swift::Stanza>(element);
|
boost::shared_ptr<Swift::Stanza> stanza = boost::dynamic_pointer_cast<Swift::Stanza>(element);
|
||||||
if (!stanza) {
|
if (!stanza) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string user = stanza->getFrom().toBare();
|
std::string user = stanza->getFrom().toBare();
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
|
boost::shared_ptr<Swift::Client> client = m_users[user];
|
||||||
if (!client)
|
if (!client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stanza->setFrom(client->getJID());
|
stanza->setFrom(client->getJID());
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> message = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Swift::Message>(stanza);
|
boost::shared_ptr<Swift::Message> message = boost::dynamic_pointer_cast<Swift::Message>(stanza);
|
||||||
if (message) {
|
if (message) {
|
||||||
client->sendMessage(message);
|
client->sendMessage(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Presence> presence = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Swift::Presence>(stanza);
|
boost::shared_ptr<Swift::Presence> presence = boost::dynamic_pointer_cast<Swift::Presence>(stanza);
|
||||||
if (presence) {
|
if (presence) {
|
||||||
client->sendPresence(presence);
|
client->sendPresence(presence);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ> iq = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Swift::IQ>(stanza);
|
boost::shared_ptr<Swift::IQ> iq = boost::dynamic_pointer_cast<Swift::IQ>(stanza);
|
||||||
if (iq) {
|
if (iq) {
|
||||||
if (m_handlers[user]->m_id2resource.find(stanza->getID()) != m_handlers[user]->m_id2resource.end()) {
|
if (m_handlers[user]->m_id2resource.find(stanza->getID()) != m_handlers[user]->m_id2resource.end()) {
|
||||||
std::string resource = m_handlers[user]->m_id2resource[stanza->getID()];
|
std::string resource = m_handlers[user]->m_id2resource[stanza->getID()];
|
||||||
|
@ -212,7 +211,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
LOG4CXX_INFO(logger, user << ": Disconnected " << message);
|
LOG4CXX_INFO(logger, user << ": Disconnected " << message);
|
||||||
handleDisconnected(user, reconnect ? 0 : 3, message);
|
handleDisconnected(user, reconnect ? 0 : 3, message);
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
|
boost::shared_ptr<Swift::Client> client = m_users[user];
|
||||||
if (client) {
|
if (client) {
|
||||||
client->onConnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
|
client->onConnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
|
||||||
client->onDisconnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftDisconnected, this, user, _1));
|
client->onDisconnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftDisconnected, this, user, _1));
|
||||||
|
@ -251,7 +250,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSwiftPresenceChanged(const std::string &user, Swift::Presence::ref presence) {
|
void handleSwiftPresenceChanged(const std::string &user, Swift::Presence::ref presence) {
|
||||||
// SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
|
// boost::shared_ptr<Swift::Client> client = m_users[user];
|
||||||
// if (client->getMUCRegistry()->isMUC(presence->getFrom().toBare())) {
|
// if (client->getMUCRegistry()->isMUC(presence->getFrom().toBare())) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
@ -265,7 +264,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
// std::string message = presence->getStatus();
|
// std::string message = presence->getStatus();
|
||||||
// std::string photo = "";
|
// std::string photo = "";
|
||||||
//
|
//
|
||||||
// SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCardUpdate> update = presence->getPayload<Swift::VCardUpdate>();
|
// boost::shared_ptr<Swift::VCardUpdate> update = presence->getPayload<Swift::VCardUpdate>();
|
||||||
// if (update) {
|
// if (update) {
|
||||||
// photo = update->getPhotoHash();
|
// photo = update->getPhotoHash();
|
||||||
// }
|
// }
|
||||||
|
@ -306,7 +305,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
if (legacyName.find("/") == std::string::npos) {
|
if (legacyName.find("/") == std::string::npos) {
|
||||||
jid = Swift::JID(legacyName + "/Spectrum");
|
jid = Swift::JID(legacyName + "/Spectrum");
|
||||||
}
|
}
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = SWIFTEN_SHRPTR_NAMESPACE::make_shared<Swift::Client>(jid, password, m_factories);
|
boost::shared_ptr<Swift::Client> client = boost::make_shared<Swift::Client>(jid, password, m_factories);
|
||||||
m_users[user] = client;
|
m_users[user] = client;
|
||||||
client->setAlwaysTrustCertificates();
|
client->setAlwaysTrustCertificates();
|
||||||
client->onConnected.connect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
|
client->onConnected.connect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
|
||||||
|
@ -322,7 +321,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
opt.allowPLAINWithoutTLS = true;
|
opt.allowPLAINWithoutTLS = true;
|
||||||
client->connect(opt);
|
client->connect(opt);
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ForwardIQHandler> handler = SWIFTEN_SHRPTR_NAMESPACE::make_shared<ForwardIQHandler>(this, user);
|
boost::shared_ptr<ForwardIQHandler> handler = boost::make_shared<ForwardIQHandler>(this, user);
|
||||||
client->getIQRouter()->addHandler(handler);
|
client->getIQRouter()->addHandler(handler);
|
||||||
m_handlers[user] = handler;
|
m_handlers[user] = handler;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +339,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleLogoutRequest(const std::string &user, const std::string &legacyName) {
|
void handleLogoutRequest(const std::string &user, const std::string &legacyName) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
|
boost::shared_ptr<Swift::Client> client = m_users[user];
|
||||||
if (client) {
|
if (client) {
|
||||||
client->onConnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
|
client->onConnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
|
||||||
// client->onDisconnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftDisconnected, this, user, _1));
|
// client->onDisconnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftDisconnected, this, user, _1));
|
||||||
|
@ -358,7 +357,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups) {
|
void handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
|
boost::shared_ptr<Swift::Client> client = m_users[user];
|
||||||
if (client) {
|
if (client) {
|
||||||
LOG4CXX_INFO(logger, user << ": Added/Updated buddy " << buddyName << ".");
|
LOG4CXX_INFO(logger, user << ": Added/Updated buddy " << buddyName << ".");
|
||||||
if (!client->getRoster()->containsJID(buddyName) || client->getRoster()->getSubscriptionStateForJID(buddyName) != Swift::RosterItemPayload::Both) {
|
if (!client->getRoster()->containsJID(buddyName) || client->getRoster()->getSubscriptionStateForJID(buddyName) != Swift::RosterItemPayload::Both) {
|
||||||
|
@ -366,7 +365,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
item.setName(alias);
|
item.setName(alias);
|
||||||
item.setJID(buddyName);
|
item.setJID(buddyName);
|
||||||
item.setGroups(groups);
|
item.setGroups(groups);
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::RosterPayload> roster(new Swift::RosterPayload());
|
boost::shared_ptr<Swift::RosterPayload> roster(new Swift::RosterPayload());
|
||||||
roster->addItem(item);
|
roster->addItem(item);
|
||||||
Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(roster, client->getIQRouter());
|
Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(roster, client->getIQRouter());
|
||||||
// request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster));
|
// request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster));
|
||||||
|
@ -377,7 +376,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
Swift::JID contact(buddyName);
|
Swift::JID contact(buddyName);
|
||||||
Swift::RosterItemPayload item(contact, alias, client->getRoster()->getSubscriptionStateForJID(contact));
|
Swift::RosterItemPayload item(contact, alias, client->getRoster()->getSubscriptionStateForJID(contact));
|
||||||
item.setGroups(groups);
|
item.setGroups(groups);
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::RosterPayload> roster(new Swift::RosterPayload());
|
boost::shared_ptr<Swift::RosterPayload> roster(new Swift::RosterPayload());
|
||||||
roster->addItem(item);
|
roster->addItem(item);
|
||||||
Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(roster, client->getIQRouter());
|
Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(roster, client->getIQRouter());
|
||||||
// request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster));
|
// request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster));
|
||||||
|
@ -388,10 +387,10 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleBuddyRemovedRequest(const std::string &user, const std::string &buddyName, const std::vector<std::string> &groups) {
|
void handleBuddyRemovedRequest(const std::string &user, const std::string &buddyName, const std::vector<std::string> &groups) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
|
boost::shared_ptr<Swift::Client> client = m_users[user];
|
||||||
if (client) {
|
if (client) {
|
||||||
Swift::RosterItemPayload item(buddyName, "", Swift::RosterItemPayload::Remove);
|
Swift::RosterItemPayload item(buddyName, "", Swift::RosterItemPayload::Remove);
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::RosterPayload> roster(new Swift::RosterPayload());
|
boost::shared_ptr<Swift::RosterPayload> roster(new Swift::RosterPayload());
|
||||||
roster->addItem(item);
|
roster->addItem(item);
|
||||||
Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(roster, client->getIQRouter());
|
Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(roster, client->getIQRouter());
|
||||||
// request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster));
|
// request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster));
|
||||||
|
@ -409,8 +408,8 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Config *config;
|
Config *config;
|
||||||
std::map<std::string, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> > m_users;
|
std::map<std::string, boost::shared_ptr<Swift::Client> > m_users;
|
||||||
std::map<std::string, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ForwardIQHandler> > m_handlers;
|
std::map<std::string, boost::shared_ptr<ForwardIQHandler> > m_handlers;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
|
@ -20,7 +20,7 @@ Plugin::Plugin(Config *config, Swift::SimpleEventLoop *loop, const std::string &
|
||||||
m_factories = new Swift::BoostNetworkFactories(loop);
|
m_factories = new Swift::BoostNetworkFactories(loop);
|
||||||
m_conn = m_factories->getConnectionFactory()->createConnection();
|
m_conn = m_factories->getConnectionFactory()->createConnection();
|
||||||
m_conn->onDataRead.connect(boost::bind(&Plugin::_handleDataRead, this, _1));
|
m_conn->onDataRead.connect(boost::bind(&Plugin::_handleDataRead, this, _1));
|
||||||
m_conn->connect(Swift::HostAddressPort(SWIFT_HOSTADDRESS(host), port));
|
m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port));
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, "Starting the plugin.");
|
LOG4CXX_INFO(logger, "Starting the plugin.");
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ void Plugin::sendData(const std::string &string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method has to call handleDataRead with all received data from network plugin server
|
// 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) {
|
void Plugin::_handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data) {
|
||||||
std::string d(data->begin(), data->end());
|
std::string d(data->begin(), data->end());
|
||||||
handleDataRead(d);
|
handleDataRead(d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Swiften/Swiften.h"
|
#include "Swiften/Swiften.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
#include "transport/Config.h"
|
#include "transport/Config.h"
|
||||||
#include "transport/NetworkPlugin.h"
|
#include "transport/NetworkPlugin.h"
|
||||||
|
@ -25,11 +24,11 @@ class Plugin : public Transport::NetworkPlugin {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This method has to call handleDataRead with all received data from network plugin server
|
// This method has to call handleDataRead with all received data from network plugin server
|
||||||
void _handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data);
|
void _handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Swift::BoostNetworkFactories *m_factories;
|
Swift::BoostNetworkFactories *m_factories;
|
||||||
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
|
boost::shared_ptr<Swift::Connection> m_conn;
|
||||||
Transport::Config *config;
|
Transport::Config *config;
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ bool HTTPRequest::init()
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
curl_easy_setopt(curlhandle, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LOG4CXX_ERROR(logger, "Couldn't Initialize curl!");
|
LOG4CXX_ERROR(logger, "Couldn't Initialize curl!")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ void HTTPRequest::setProxy(std::string IP, std::string port, std::string usernam
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_PROXYUSERPWD, proxyUserPass.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_PROXYUSERPWD, proxyUserPass.c_str());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG4CXX_ERROR(logger, "Trying to set proxy while CURL isn't initialized");
|
LOG4CXX_ERROR(logger, "Trying to set proxy while CURL isn't initialized")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ bool HTTPRequest::GET(std::string url, std::string &data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG4CXX_ERROR(logger, "CURL not initialized!");
|
LOG4CXX_ERROR(logger, "CURL not initialized!")
|
||||||
strcpy(curl_errorbuffer, "CURL not initialized!");
|
strcpy(curl_errorbuffer, "CURL not initialized!");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -4,16 +4,16 @@ DEFINE_LOGGER(logger, "CreateFriendRequest")
|
||||||
|
|
||||||
void CreateFriendRequest::run()
|
void CreateFriendRequest::run()
|
||||||
{
|
{
|
||||||
LOG4CXX_INFO(logger, user << " - Sending follow request for " << frnd);
|
LOG4CXX_INFO(logger, user << " - Sending follow request for " << frnd)
|
||||||
replyMsg = "";
|
replyMsg = "";
|
||||||
success = twitObj->friendshipCreate(frnd, false);
|
success = twitObj->friendshipCreate(frnd, false);
|
||||||
if(success) {
|
if(success) {
|
||||||
twitObj->getLastWebResponse(replyMsg);
|
twitObj->getLastWebResponse(replyMsg);
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << replyMsg);
|
LOG4CXX_INFO(logger, user << replyMsg)
|
||||||
|
|
||||||
friendInfo = getUser(replyMsg);
|
friendInfo = getUser(replyMsg);
|
||||||
if(friendInfo.getScreenName() == "") LOG4CXX_INFO(logger, user << " - Was unable to fetch user info for " << frnd);
|
if(friendInfo.getScreenName() == "") {LOG4CXX_INFO(logger, user << " - Was unable to fetch user info for " << frnd)}
|
||||||
|
|
||||||
HTTPRequest req;
|
HTTPRequest req;
|
||||||
std::string img;
|
std::string img;
|
||||||
|
@ -37,14 +37,14 @@ void CreateFriendRequest::finalize()
|
||||||
std::string curlerror;
|
std::string curlerror;
|
||||||
twitObj->getLastCurlError(curlerror);
|
twitObj->getLastCurlError(curlerror);
|
||||||
error.setMessage(curlerror);
|
error.setMessage(curlerror);
|
||||||
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror);
|
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror)
|
||||||
callBack(user, friendInfo, profileImg, error);
|
callBack(user, friendInfo, profileImg, error);
|
||||||
} else {
|
} else {
|
||||||
error = getErrorMessage(replyMsg);
|
error = getErrorMessage(replyMsg);
|
||||||
if(error.getMessage().length()) {
|
if(error.getMessage().length()) {
|
||||||
LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
|
LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
|
||||||
}
|
}
|
||||||
else LOG4CXX_INFO(logger, user << ": Now following " << frnd);
|
else LOG4CXX_INFO(logger, user << ": Now following " << frnd)
|
||||||
callBack(user, friendInfo, profileImg, error);
|
callBack(user, friendInfo, profileImg, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ void DestroyFriendRequest::run()
|
||||||
if(success) {
|
if(success) {
|
||||||
twitObj->getLastWebResponse(replyMsg);
|
twitObj->getLastWebResponse(replyMsg);
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << replyMsg);
|
LOG4CXX_INFO(logger, user << replyMsg)
|
||||||
|
|
||||||
|
|
||||||
friendInfo = getUser(replyMsg);
|
friendInfo = getUser(replyMsg);
|
||||||
|
@ -23,11 +23,11 @@ void DestroyFriendRequest::finalize()
|
||||||
std::string curlerror;
|
std::string curlerror;
|
||||||
twitObj->getLastCurlError(curlerror);
|
twitObj->getLastCurlError(curlerror);
|
||||||
error.setMessage(curlerror);
|
error.setMessage(curlerror);
|
||||||
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror);
|
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror)
|
||||||
callBack(user, friendInfo, error);
|
callBack(user, friendInfo, error);
|
||||||
} else {
|
} else {
|
||||||
error = getErrorMessage(replyMsg);
|
error = getErrorMessage(replyMsg);
|
||||||
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
|
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
|
||||||
callBack(user, friendInfo, error);
|
callBack(user, friendInfo, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,8 @@ void DirectMessageRequest::finalize()
|
||||||
callBack(user, username, messages, error);
|
callBack(user, username, messages, error);
|
||||||
} else {
|
} else {
|
||||||
error = getErrorMessage(replyMsg);
|
error = getErrorMessage(replyMsg);
|
||||||
if(error.getMessage().length()) {
|
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
|
||||||
LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
|
else LOG4CXX_INFO(logger, user << " - " << replyMsg)
|
||||||
} else {
|
|
||||||
LOG4CXX_INFO(logger, user << " - " << replyMsg);
|
|
||||||
}
|
|
||||||
callBack(user, username, messages, error);
|
callBack(user, username, messages, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ void FetchFriends::run()
|
||||||
friendAvatars.push_back("");
|
friendAvatars.push_back("");
|
||||||
if(req.GET(friends[i].getProfileImgURL(), img)) friendAvatars[i] = img;
|
if(req.GET(friends[i].getProfileImgURL(), img)) friendAvatars[i] = img;
|
||||||
else {
|
else {
|
||||||
LOG4CXX_INFO(logger, "Warning: Couldn't fetch Profile Image for " << user << "'s friend " << friends[i].getScreenName());
|
LOG4CXX_INFO(logger, "Warning: Couldn't fetch Profile Image for " << user << "'s friend " << friends[i].getScreenName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,11 @@ void FetchFriends::finalize()
|
||||||
std::string curlerror;
|
std::string curlerror;
|
||||||
twitObj->getLastCurlError(curlerror);
|
twitObj->getLastCurlError(curlerror);
|
||||||
error.setMessage(curlerror);
|
error.setMessage(curlerror);
|
||||||
LOG4CXX_ERROR(logger, user << " - " << curlerror);
|
LOG4CXX_ERROR(logger, user << " - " << curlerror)
|
||||||
callBack(user, friends, friendAvatars, error);
|
callBack(user, friends, friendAvatars, error);
|
||||||
} else {
|
} else {
|
||||||
error = getErrorMessage(replyMsg);
|
error = getErrorMessage(replyMsg);
|
||||||
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
|
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
|
||||||
callBack(user, friends, friendAvatars, error);
|
callBack(user, friends, friendAvatars, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
DEFINE_LOGGER(logger, "PINExchangeProcess")
|
DEFINE_LOGGER(logger, "PINExchangeProcess")
|
||||||
void PINExchangeProcess::run()
|
void PINExchangeProcess::run()
|
||||||
{
|
{
|
||||||
LOG4CXX_INFO(logger, user << ": Sending PIN " << data);
|
LOG4CXX_INFO(logger, user << ": Sending PIN " << data)
|
||||||
LOG4CXX_INFO(logger, user << " " << twitObj->getProxyServerIp() << " " << twitObj->getProxyServerPort());
|
LOG4CXX_INFO(logger, user << " " << twitObj->getProxyServerIp() << " " << twitObj->getProxyServerPort())
|
||||||
twitObj->getOAuth().setOAuthPin( data );
|
twitObj->getOAuth().setOAuthPin( data );
|
||||||
success = twitObj->oAuthAccessToken();
|
success = twitObj->oAuthAccessToken();
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ void PINExchangeProcess::run()
|
||||||
void PINExchangeProcess::finalize()
|
void PINExchangeProcess::finalize()
|
||||||
{
|
{
|
||||||
if(!success) {
|
if(!success) {
|
||||||
LOG4CXX_ERROR(logger, user << ": Error while exchanging PIN for Access Token!");
|
LOG4CXX_ERROR(logger, user << ": Error while exchanging PIN for Access Token!")
|
||||||
np->handleMessage(user, "twitter.com", "Error while exchanging PIN for Access Token!");
|
np->handleMessage(user, "twitter.com", "Error while exchanging PIN for Access Token!");
|
||||||
np->handleLogoutRequest(user, "");
|
np->handleLogoutRequest(user, "");
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,7 +22,7 @@ void PINExchangeProcess::finalize()
|
||||||
|
|
||||||
Error error = getErrorMessage(replyMsg);
|
Error error = getErrorMessage(replyMsg);
|
||||||
if(error.getMessage().length()) {
|
if(error.getMessage().length()) {
|
||||||
LOG4CXX_ERROR(logger, user << ": Error while exchanging PIN for Access Token! " << error.getMessage());
|
LOG4CXX_ERROR(logger, user << ": Error while exchanging PIN for Access Token! " << error.getMessage())
|
||||||
np->handleMessage(user, "twitter.com", error.getMessage());
|
np->handleMessage(user, "twitter.com", error.getMessage());
|
||||||
np->handleLogoutRequest(user, "");
|
np->handleLogoutRequest(user, "");
|
||||||
return;
|
return;
|
||||||
|
@ -47,7 +47,7 @@ void PINExchangeProcess::finalize()
|
||||||
/*void handlePINExchange(const std::string &user, std::string &data) {
|
/*void handlePINExchange(const std::string &user, std::string &data) {
|
||||||
sessions[user]->getOAuth().setOAuthPin( data );
|
sessions[user]->getOAuth().setOAuthPin( data );
|
||||||
if (sessions[user]->oAuthAccessToken() == false) {
|
if (sessions[user]->oAuthAccessToken() == false) {
|
||||||
LOG4CXX_ERROR(logger, user << ": Error while exchanging PIN for Access Token!");
|
LOG4CXX_ERROR(logger, user << ": Error while exchanging PIN for Access Token!")
|
||||||
handleLogoutRequest(user, "");
|
handleLogoutRequest(user, "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ void PINExchangeProcess::finalize()
|
||||||
|
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
handleLogoutRequest(user, "");
|
handleLogoutRequest(user, "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ void ProfileImageRequest::finalize()
|
||||||
{
|
{
|
||||||
Error errResponse;
|
Error errResponse;
|
||||||
if(!success) {
|
if(!success) {
|
||||||
LOG4CXX_ERROR(logger, user << " - " << error);
|
LOG4CXX_ERROR(logger, user << " - " << error)
|
||||||
img = "";
|
img = "";
|
||||||
errResponse.setMessage(error);
|
errResponse.setMessage(error);
|
||||||
callBack(user, buddy, img, reqID, errResponse);
|
callBack(user, buddy, img, reqID, errResponse);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
DEFINE_LOGGER(logger, "RetweetRequest")
|
DEFINE_LOGGER(logger, "RetweetRequest")
|
||||||
void RetweetRequest::run()
|
void RetweetRequest::run()
|
||||||
{
|
{
|
||||||
LOG4CXX_INFO(logger, user << " Retweeting " << data);
|
LOG4CXX_INFO(logger, user << " Retweeting " << data)
|
||||||
success = twitObj->retweetById( data );
|
success = twitObj->retweetById( data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,16 +13,13 @@ void RetweetRequest::finalize()
|
||||||
std::string curlerror;
|
std::string curlerror;
|
||||||
twitObj->getLastCurlError(curlerror);
|
twitObj->getLastCurlError(curlerror);
|
||||||
error.setMessage(curlerror);
|
error.setMessage(curlerror);
|
||||||
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror);
|
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror)
|
||||||
callBack(user, error);
|
callBack(user, error);
|
||||||
} else {
|
} else {
|
||||||
twitObj->getLastWebResponse(replyMsg);
|
twitObj->getLastWebResponse(replyMsg);
|
||||||
error = getErrorMessage(replyMsg);
|
error = getErrorMessage(replyMsg);
|
||||||
if(error.getMessage().length()) {
|
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
|
||||||
LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
|
else LOG4CXX_INFO(logger, user << " " << replyMsg);
|
||||||
} else {
|
|
||||||
LOG4CXX_INFO(logger, user << " " << replyMsg);
|
|
||||||
}
|
|
||||||
callBack(user, error);
|
callBack(user, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,8 @@ void StatusUpdateRequest::finalize()
|
||||||
callBack(user, error);
|
callBack(user, error);
|
||||||
} else {
|
} else {
|
||||||
error = getErrorMessage(replyMsg);
|
error = getErrorMessage(replyMsg);
|
||||||
if(error.getMessage().length()) {
|
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
|
||||||
LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
|
else LOG4CXX_INFO(logger, "Updated status for " << user << ": " << data);
|
||||||
} else {
|
|
||||||
LOG4CXX_INFO(logger, "Updated status for " << user << ": " << data);
|
|
||||||
}
|
|
||||||
callBack(user, error);
|
callBack(user, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
DEFINE_LOGGER(logger, "TimelineRequest")
|
DEFINE_LOGGER(logger, "TimelineRequest")
|
||||||
void TimelineRequest::run()
|
void TimelineRequest::run()
|
||||||
{
|
{
|
||||||
LOG4CXX_INFO(logger, "Sending timeline request for user " << userRequested);
|
LOG4CXX_INFO(logger, "Sending timeline request for user " << userRequested)
|
||||||
|
|
||||||
if(userRequested != "") success = twitObj->timelineUserGet(false, false, 20, userRequested, false);
|
if(userRequested != "") success = twitObj->timelineUserGet(false, false, 20, userRequested, false);
|
||||||
else success = twitObj->timelineHomeGet(since_id);
|
else success = twitObj->timelineHomeGet(since_id);
|
||||||
|
@ -22,11 +22,11 @@ void TimelineRequest::finalize()
|
||||||
std::string curlerror;
|
std::string curlerror;
|
||||||
twitObj->getLastCurlError(curlerror);
|
twitObj->getLastCurlError(curlerror);
|
||||||
error.setMessage(curlerror);
|
error.setMessage(curlerror);
|
||||||
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror);
|
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror)
|
||||||
callBack(user, userRequested, tweets, error);
|
callBack(user, userRequested, tweets, error);
|
||||||
} else {
|
} else {
|
||||||
error = getErrorMessage(replyMsg);
|
error = getErrorMessage(replyMsg);
|
||||||
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
|
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
|
||||||
callBack(user, userRequested, tweets, error);
|
callBack(user, userRequested, tweets, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, Stora
|
||||||
m_factories = new Swift::BoostNetworkFactories(loop);
|
m_factories = new Swift::BoostNetworkFactories(loop);
|
||||||
m_conn = m_factories->getConnectionFactory()->createConnection();
|
m_conn = m_factories->getConnectionFactory()->createConnection();
|
||||||
m_conn->onDataRead.connect(boost::bind(&TwitterPlugin::_handleDataRead, this, _1));
|
m_conn->onDataRead.connect(boost::bind(&TwitterPlugin::_handleDataRead, this, _1));
|
||||||
m_conn->connect(Swift::HostAddressPort(SWIFT_HOSTADDRESS(host), port));
|
m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port));
|
||||||
|
|
||||||
tp = new ThreadPool(loop_, 10);
|
tp = new ThreadPool(loop_, 10);
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, Stora
|
||||||
message_timer->start();
|
message_timer->start();
|
||||||
|
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
cryptoProvider = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::CryptoProvider>(Swift::PlatformCryptoProvider::create());
|
cryptoProvider = boost::shared_ptr<Swift::CryptoProvider>(Swift::PlatformCryptoProvider::create());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ void TwitterPlugin::sendData(const std::string &string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Receive date from the NetworkPlugin server and invoke the appropirate payload handler (implement in the NetworkPlugin class)
|
// Receive date from the NetworkPlugin server and invoke the appropirate payload handler (implement in the NetworkPlugin class)
|
||||||
void TwitterPlugin::_handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data)
|
void TwitterPlugin::_handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data)
|
||||||
{
|
{
|
||||||
if (m_firstPing) {
|
if (m_firstPing) {
|
||||||
m_firstPing = false;
|
m_firstPing = false;
|
||||||
|
@ -130,31 +130,31 @@ void TwitterPlugin::handleLoginRequest(const std::string &user, const std::strin
|
||||||
if(userdb.count(user) && (userdb[user].connectionState == NEW ||
|
if(userdb.count(user) && (userdb[user].connectionState == NEW ||
|
||||||
userdb[user].connectionState == CONNECTED ||
|
userdb[user].connectionState == CONNECTED ||
|
||||||
userdb[user].connectionState == WAITING_FOR_PIN)) {
|
userdb[user].connectionState == WAITING_FOR_PIN)) {
|
||||||
LOG4CXX_INFO(logger, std::string("A session corresponding to ") + user + std::string(" is already active"));
|
LOG4CXX_INFO(logger, std::string("A session corresponding to ") + user + std::string(" is already active"))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, std::string("Received login request for ") + user);
|
LOG4CXX_INFO(logger, std::string("Received login request for ") + user)
|
||||||
initUserSession(user, legacyName, password);
|
initUserSession(user, legacyName, password);
|
||||||
handleConnected(user);
|
handleConnected(user);
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, "SPECTRUM 1 USER? - " << (userdb[user].spectrum1User? "true" : "false"));
|
LOG4CXX_INFO(logger, "SPECTRUM 1 USER? - " << (userdb[user].spectrum1User? "true" : "false"))
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << ": Adding Buddy " << adminLegacyName << " " << adminAlias);
|
LOG4CXX_INFO(logger, user << ": Adding Buddy " << adminLegacyName << " " << adminAlias)
|
||||||
handleBuddyChanged(user, adminLegacyName, adminAlias, std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
|
handleBuddyChanged(user, adminLegacyName, adminAlias, std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
|
||||||
userdb[user].nickName = "";
|
userdb[user].nickName = "";
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, "Querying database for usersettings of " << user);
|
LOG4CXX_INFO(logger, "Querying database for usersettings of " << user)
|
||||||
std::string key, secret;
|
std::string key, secret;
|
||||||
getUserOAuthKeyAndSecret(user, key, secret);
|
getUserOAuthKeyAndSecret(user, key, secret);
|
||||||
|
|
||||||
if(key == "" || secret == "") {
|
if(key == "" || secret == "") {
|
||||||
LOG4CXX_INFO(logger, "Intiating OAuth Flow for user " << user);
|
LOG4CXX_INFO(logger, "Intiating OAuth Flow for user " << user)
|
||||||
setTwitterMode(user, 0);
|
setTwitterMode(user, 0);
|
||||||
tp->runAsThread(new OAuthFlow(np, userdb[user].sessions, user, userdb[user].sessions->getTwitterUsername()));
|
tp->runAsThread(new OAuthFlow(np, userdb[user].sessions, user, userdb[user].sessions->getTwitterUsername()));
|
||||||
} else {
|
} else {
|
||||||
LOG4CXX_INFO(logger, user << " is already registerd. Using the stored oauth key and secret");
|
LOG4CXX_INFO(logger, user << " is already registerd. Using the stored oauth key and secret")
|
||||||
LOG4CXX_INFO(logger, key << " " << secret);
|
LOG4CXX_INFO(logger, key << " " << secret)
|
||||||
pinExchangeComplete(user, key, secret);
|
pinExchangeComplete(user, key, secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ void TwitterPlugin::handleLogoutRequest(const std::string &user, const std::stri
|
||||||
void TwitterPlugin::handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &password)
|
void TwitterPlugin::handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &password)
|
||||||
{
|
{
|
||||||
if(room == adminChatRoom) {
|
if(room == adminChatRoom) {
|
||||||
LOG4CXX_INFO(logger, "Received Join Twitter room request for " << user << " '" << nickname << "'");
|
LOG4CXX_INFO(logger, "Received Join Twitter room request for " << user << " '" << nickname << "'")
|
||||||
|
|
||||||
setTwitterMode(user, 2);
|
setTwitterMode(user, 2);
|
||||||
handleParticipantChanged(user, nickname, room, 0, pbnetwork::STATUS_ONLINE);
|
handleParticipantChanged(user, nickname, room, 0, pbnetwork::STATUS_ONLINE);
|
||||||
|
@ -188,7 +188,7 @@ void TwitterPlugin::handleJoinRoomRequest(const std::string &user, const std::st
|
||||||
boost::bind(&TwitterPlugin::populateRoster, this, _1, _2, _3, _4)));
|
boost::bind(&TwitterPlugin::populateRoster, this, _1, _2, _3, _4)));
|
||||||
} else {
|
} else {
|
||||||
setTwitterMode(user, 0);
|
setTwitterMode(user, 0);
|
||||||
LOG4CXX_ERROR(logger, "Couldn't connect to chatroom - " << room <<"! Try twitter-chatroom as the chatroom to access Twitter account");
|
LOG4CXX_ERROR(logger, "Couldn't connect to chatroom - " << room <<"! Try twitter-chatroom as the chatroom to access Twitter account")
|
||||||
handleMessage(user, adminLegacyName, "Couldn't connect to chatroom! Try twitter-chatroom as the chatroom to access Twitter account");
|
handleMessage(user, adminLegacyName, "Couldn't connect to chatroom! Try twitter-chatroom as the chatroom to access Twitter account");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ void TwitterPlugin::handleJoinRoomRequest(const std::string &user, const std::st
|
||||||
void TwitterPlugin::handleLeaveRoomRequest(const std::string &user, const std::string &room)
|
void TwitterPlugin::handleLeaveRoomRequest(const std::string &user, const std::string &room)
|
||||||
{
|
{
|
||||||
if(room == adminChatRoom && onlineUsers.count(user)) {
|
if(room == adminChatRoom && onlineUsers.count(user)) {
|
||||||
LOG4CXX_INFO(logger, "Leaving chatroom! Switching back to default mode 0");
|
LOG4CXX_INFO(logger, "Leaving chatroom! Switching back to default mode 0")
|
||||||
setTwitterMode(user, 0);
|
setTwitterMode(user, 0);
|
||||||
handleBuddyChanged(user, adminLegacyName, adminAlias, std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
|
handleBuddyChanged(user, adminLegacyName, adminAlias, std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ void TwitterPlugin::handleLeaveRoomRequest(const std::string &user, const std::s
|
||||||
void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std::string &legacyName, const std::string &message, const std::string &xhtml, const std::string &/*id*/)
|
void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std::string &legacyName, const std::string &message, const std::string &xhtml, const std::string &/*id*/)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, "Received " << user << " --> " << legacyName << " - " << message);
|
LOG4CXX_INFO(logger, "Received " << user << " --> " << legacyName << " - " << message)
|
||||||
|
|
||||||
if(legacyName == adminLegacyName || legacyName == adminChatRoom) {
|
if(legacyName == adminLegacyName || legacyName == adminChatRoom) {
|
||||||
std::string cmd = "", data = "";
|
std::string cmd = "", data = "";
|
||||||
|
@ -265,7 +265,7 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
|
||||||
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
||||||
std::string("Changed mode to ") + data, userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
std::string("Changed mode to ") + data, userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << ": Changed mode to " << data << " <" << (userdb[user].twitterMode == CHATROOM ? adminNickName : "") << ">" );
|
LOG4CXX_INFO(logger, user << ": Changed mode to " << data << " <" << (userdb[user].twitterMode == CHATROOM ? adminNickName : "") << ">" )
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(userdb[user].twitterMode == CHATROOM) {
|
else if(userdb[user].twitterMode == CHATROOM) {
|
||||||
|
@ -296,11 +296,11 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
|
||||||
void TwitterPlugin::handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups)
|
void TwitterPlugin::handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups)
|
||||||
{
|
{
|
||||||
if(userdb[user].connectionState != CONNECTED) {
|
if(userdb[user].connectionState != CONNECTED) {
|
||||||
LOG4CXX_ERROR(logger, user << " is not connected to twitter!");
|
LOG4CXX_ERROR(logger, user << " is not connected to twitter!")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << " - Adding Twitter contact " << buddyName);
|
LOG4CXX_INFO(logger, user << " - Adding Twitter contact " << buddyName)
|
||||||
tp->runAsThread(new CreateFriendRequest(userdb[user].sessions, user, buddyName,
|
tp->runAsThread(new CreateFriendRequest(userdb[user].sessions, user, buddyName,
|
||||||
boost::bind(&TwitterPlugin::createFriendResponse, this, _1, _2, _3, _4)));
|
boost::bind(&TwitterPlugin::createFriendResponse, this, _1, _2, _3, _4)));
|
||||||
}
|
}
|
||||||
|
@ -308,16 +308,16 @@ void TwitterPlugin::handleBuddyUpdatedRequest(const std::string &user, const std
|
||||||
void TwitterPlugin::handleBuddyRemovedRequest(const std::string &user, const std::string &buddyName, const std::vector<std::string> &groups)
|
void TwitterPlugin::handleBuddyRemovedRequest(const std::string &user, const std::string &buddyName, const std::vector<std::string> &groups)
|
||||||
{
|
{
|
||||||
if(userdb[user].connectionState != CONNECTED) {
|
if(userdb[user].connectionState != CONNECTED) {
|
||||||
LOG4CXX_ERROR(logger, user << " is not connected to twitter!");
|
LOG4CXX_ERROR(logger, user << " is not connected to twitter!")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getTwitterMode(user) == MULTIPLECONTACT) {
|
if (getTwitterMode(user) == MULTIPLECONTACT) {
|
||||||
LOG4CXX_ERROR(logger, user << " not removing Twitter contact " << buddyName << ", because the mode is not MULTIPLECONTACT");
|
LOG4CXX_ERROR(logger, user << " not removing Twitter contact " << buddyName << ", because the mode is not MULTIPLECONTACT")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << " - Removing Twitter contact " << buddyName);
|
LOG4CXX_INFO(logger, user << " - Removing Twitter contact " << buddyName)
|
||||||
tp->runAsThread(new DestroyFriendRequest(userdb[user].sessions, user, buddyName,
|
tp->runAsThread(new DestroyFriendRequest(userdb[user].sessions, user, buddyName,
|
||||||
boost::bind(&TwitterPlugin::deleteFriendResponse, this, _1, _2, _3)));
|
boost::bind(&TwitterPlugin::deleteFriendResponse, this, _1, _2, _3)));
|
||||||
}
|
}
|
||||||
|
@ -325,11 +325,11 @@ void TwitterPlugin::handleBuddyRemovedRequest(const std::string &user, const std
|
||||||
void TwitterPlugin::handleVCardRequest(const std::string &user, const std::string &legacyName, unsigned int id)
|
void TwitterPlugin::handleVCardRequest(const std::string &user, const std::string &legacyName, unsigned int id)
|
||||||
{
|
{
|
||||||
if(userdb[user].connectionState != CONNECTED) {
|
if(userdb[user].connectionState != CONNECTED) {
|
||||||
LOG4CXX_ERROR(logger, user << " is not connected to twitter!");
|
LOG4CXX_ERROR(logger, user << " is not connected to twitter!")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << " - VCardRequest for " << legacyName << ", " << userdb[user].buddiesInfo[legacyName].getProfileImgURL());
|
LOG4CXX_INFO(logger, user << " - VCardRequest for " << legacyName << ", " << userdb[user].buddiesInfo[legacyName].getProfileImgURL())
|
||||||
|
|
||||||
if(getTwitterMode(user) != SINGLECONTACT && userdb[user].buddies.count(legacyName)
|
if(getTwitterMode(user) != SINGLECONTACT && userdb[user].buddies.count(legacyName)
|
||||||
&& userdb[user].buddiesInfo[legacyName].getProfileImgURL().length()) {
|
&& userdb[user].buddiesInfo[legacyName].getProfileImgURL().length()) {
|
||||||
|
@ -374,7 +374,7 @@ bool TwitterPlugin::getUserOAuthKeyAndSecret(const std::string user, std::string
|
||||||
|
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ bool TwitterPlugin::checkSpectrum1User(const std::string user)
|
||||||
|
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ bool TwitterPlugin::checkSpectrum1User(const std::string user)
|
||||||
int type = TYPE_STRING;
|
int type = TYPE_STRING;
|
||||||
storagebackend->getUserSetting((long)info.id, "first_synchronization_done", type, first_synchronization_done);
|
storagebackend->getUserSetting((long)info.id, "first_synchronization_done", type, first_synchronization_done);
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, "first_synchronization_done: " << first_synchronization_done);
|
LOG4CXX_INFO(logger, "first_synchronization_done: " << first_synchronization_done)
|
||||||
|
|
||||||
if(first_synchronization_done.length()) return true;
|
if(first_synchronization_done.length()) return true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -410,7 +410,7 @@ int TwitterPlugin::getTwitterMode(const std::string user)
|
||||||
|
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,12 +431,12 @@ bool TwitterPlugin::setTwitterMode(const std::string user, int m)
|
||||||
|
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m < 0 || m > 2) {
|
if(m < 0 || m > 2) {
|
||||||
LOG4CXX_ERROR(logger, "Unknown mode " << m <<". Using default mode 0");
|
LOG4CXX_ERROR(logger, "Unknown mode " << m <<". Using default mode 0")
|
||||||
m = 0;
|
m = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ bool TwitterPlugin::setTwitterMode(const std::string user, int m)
|
||||||
|
|
||||||
//int type;
|
//int type;
|
||||||
std::string s_m = std::string(1,m+'0');
|
std::string s_m = std::string(1,m+'0');
|
||||||
LOG4CXX_INFO(logger, "Storing mode " << m <<" for user " << user);
|
LOG4CXX_INFO(logger, "Storing mode " << m <<" for user " << user)
|
||||||
storagebackend->updateUserSetting((long)info.id, MODE, s_m);
|
storagebackend->updateUserSetting((long)info.id, MODE, s_m);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ bool TwitterPlugin::storeUserOAuthKeyAndSecret(const std::string user, const std
|
||||||
|
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ void TwitterPlugin::initUserSession(const std::string user, const std::string le
|
||||||
|
|
||||||
std::string username = legacyName;
|
std::string username = legacyName;
|
||||||
std::string passwd = password;
|
std::string passwd = password;
|
||||||
LOG4CXX_INFO(logger, username + " " + passwd);
|
LOG4CXX_INFO(logger, username + " " + passwd)
|
||||||
|
|
||||||
userdb[user].sessions = new twitCurl();
|
userdb[user].sessions = new twitCurl();
|
||||||
if(CONFIG_HAS_KEY(config,"proxy.server")) {
|
if(CONFIG_HAS_KEY(config,"proxy.server")) {
|
||||||
|
@ -484,7 +484,7 @@ void TwitterPlugin::initUserSession(const std::string user, const std::string le
|
||||||
std::string puser = CONFIG_STRING(config,"proxy.user");
|
std::string puser = CONFIG_STRING(config,"proxy.user");
|
||||||
std::string ppasswd = CONFIG_STRING(config,"proxy.password");
|
std::string ppasswd = CONFIG_STRING(config,"proxy.password");
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, ip << " " << port << " " << puser << " " << ppasswd);
|
LOG4CXX_INFO(logger, ip << " " << port << " " << puser << " " << ppasswd)
|
||||||
|
|
||||||
if(ip != "localhost" && port != "0") {
|
if(ip != "localhost" && port != "0") {
|
||||||
userdb[user].sessions->setProxyServerIp(ip);
|
userdb[user].sessions->setProxyServerIp(ip);
|
||||||
|
@ -545,7 +545,7 @@ void TwitterPlugin::updateLastTweetID(const std::string user, const std::string
|
||||||
|
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ std::string TwitterPlugin::getMostRecentTweetIDUnsafe(const std::string user)
|
||||||
int type = TYPE_STRING;
|
int type = TYPE_STRING;
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
storagebackend->getUserSetting(info.id, "twitter_last_tweet", type, ID);
|
storagebackend->getUserSetting(info.id, "twitter_last_tweet", type, ID);
|
||||||
|
@ -584,7 +584,7 @@ void TwitterPlugin::updateLastDMID(const std::string user, const std::string ID)
|
||||||
|
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ std::string TwitterPlugin::getMostRecentDMIDUnsafe(const std::string user) {
|
||||||
int type = TYPE_STRING;
|
int type = TYPE_STRING;
|
||||||
UserInfo info;
|
UserInfo info;
|
||||||
if(storagebackend->getUser(user, info) == false) {
|
if(storagebackend->getUser(user, info) == false) {
|
||||||
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
|
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
storagebackend->getUserSetting(info.id, "twitter_last_dm", type, ID);
|
storagebackend->getUserSetting(info.id, "twitter_last_dm", type, ID);
|
||||||
|
@ -813,7 +813,7 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(maxID == getMostRecentDMID(user)) LOG4CXX_INFO(logger, "No new direct messages for " << user);
|
if(maxID == getMostRecentDMID(user)) LOG4CXX_INFO(logger, "No new direct messages for " << user)
|
||||||
updateLastDMID(user, maxID);
|
updateLastDMID(user, maxID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -837,7 +837,7 @@ void TwitterPlugin::createFriendResponse(std::string &user, User &frnd, std::str
|
||||||
userdb[user].buddiesInfo[frnd.getScreenName()] = frnd;
|
userdb[user].buddiesInfo[frnd.getScreenName()] = frnd;
|
||||||
userdb[user].buddiesImgs[frnd.getScreenName()] = img;
|
userdb[user].buddiesImgs[frnd.getScreenName()] = img;
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << " - " << frnd.getScreenName() << ", " << frnd.getProfileImgURL());
|
LOG4CXX_INFO(logger, user << " - " << frnd.getScreenName() << ", " << frnd.getProfileImgURL())
|
||||||
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
handleBuddyChanged(user, frnd.getScreenName(), frnd.getUserName(), std::vector<std::string>(), pbnetwork::STATUS_ONLINE, "", Swift::byteArrayToString(cryptoProvider->getSHA1Hash(Swift::createByteArray(img))));
|
handleBuddyChanged(user, frnd.getScreenName(), frnd.getUserName(), std::vector<std::string>(), pbnetwork::STATUS_ONLINE, "", Swift::byteArrayToString(cryptoProvider->getSHA1Hash(Swift::createByteArray(img))));
|
||||||
|
@ -861,7 +861,7 @@ void TwitterPlugin::deleteFriendResponse(std::string &user, User &frnd, Error &e
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << " - " << frnd.getScreenName() << ", " << frnd.getProfileImgURL());
|
LOG4CXX_INFO(logger, user << " - " << frnd.getScreenName() << ", " << frnd.getProfileImgURL())
|
||||||
userdb[user].buddies.erase(frnd.getScreenName());
|
userdb[user].buddies.erase(frnd.getScreenName());
|
||||||
|
|
||||||
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
||||||
|
@ -902,7 +902,7 @@ void TwitterPlugin::profileImageResponse(std::string &user, std::string &buddy,
|
||||||
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
||||||
errMsg.getMessage(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
errMsg.getMessage(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
||||||
} else {
|
} else {
|
||||||
LOG4CXX_INFO(logger, user << " - Sending VCard for " << buddy);
|
LOG4CXX_INFO(logger, user << " - Sending VCard for " << buddy)
|
||||||
handleVCard(user, reqID, buddy, buddy, "", img);
|
handleVCard(user, reqID, buddy, buddy, "", img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "transport/ThreadPool.h"
|
#include "transport/ThreadPool.h"
|
||||||
|
|
||||||
#include "Swiften/Swiften.h"
|
#include "Swiften/Swiften.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include "unistd.h"
|
#include "unistd.h"
|
||||||
#include "signal.h"
|
#include "signal.h"
|
||||||
|
@ -56,9 +55,9 @@ class TwitterPlugin : public NetworkPlugin {
|
||||||
public:
|
public:
|
||||||
Swift::BoostNetworkFactories *m_factories;
|
Swift::BoostNetworkFactories *m_factories;
|
||||||
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
Swift::BoostIOServiceThread m_boostIOServiceThread;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
|
boost::shared_ptr<Swift::Connection> m_conn;
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::CryptoProvider> cryptoProvider;
|
boost::shared_ptr<Swift::CryptoProvider> cryptoProvider;
|
||||||
#endif
|
#endif
|
||||||
Swift::Timer::ref tweet_timer;
|
Swift::Timer::ref tweet_timer;
|
||||||
Swift::Timer::ref message_timer;
|
Swift::Timer::ref message_timer;
|
||||||
|
@ -71,7 +70,7 @@ class TwitterPlugin : public NetworkPlugin {
|
||||||
void sendData(const std::string &string);
|
void sendData(const std::string &string);
|
||||||
|
|
||||||
// Receive date from the NetworkPlugin server and invoke the appropirate payload handler (implement in the NetworkPlugin class)
|
// Receive date from the NetworkPlugin server and invoke the appropirate payload handler (implement in the NetworkPlugin class)
|
||||||
void _handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data);
|
void _handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data);
|
||||||
|
|
||||||
// User trying to login into his twitter account
|
// User trying to login into his twitter account
|
||||||
void handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password);
|
void handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password);
|
||||||
|
|
|
@ -53,7 +53,7 @@ EmbeddedStatus getEmbeddedStatus(const rapidjson::Value &element)
|
||||||
{
|
{
|
||||||
EmbeddedStatus status;
|
EmbeddedStatus status;
|
||||||
if(!element.IsObject()) {
|
if(!element.IsObject()) {
|
||||||
LOG4CXX_ERROR(logger, "Not a status element!");
|
LOG4CXX_ERROR(logger, "Not a status element!")
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
status.setCreationTime( toIsoTime ( std::string( element[TwitterReponseTypes::created_at.c_str()].GetString() ) ) );
|
status.setCreationTime( toIsoTime ( std::string( element[TwitterReponseTypes::created_at.c_str()].GetString() ) ) );
|
||||||
|
@ -76,7 +76,7 @@ User getUser(const rapidjson::Value &element)
|
||||||
{
|
{
|
||||||
User user;
|
User user;
|
||||||
if(!element.IsObject()) {
|
if(!element.IsObject()) {
|
||||||
LOG4CXX_ERROR(logger, "Not a user element!");
|
LOG4CXX_ERROR(logger, "Not a user element!")
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,14 +142,14 @@ std::vector<Status> getTimeline(std::string &json)
|
||||||
rapidjson::Document rootElement;
|
rapidjson::Document rootElement;
|
||||||
|
|
||||||
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
||||||
LOG4CXX_ERROR(logger, "Error while parsing JSON");
|
LOG4CXX_ERROR(logger, "Error while parsing JSON")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return statuses;
|
return statuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!rootElement.IsArray()) {
|
if(!rootElement.IsArray()) {
|
||||||
LOG4CXX_ERROR(logger, "JSON doesn't correspond to timeline:");
|
LOG4CXX_ERROR(logger, "JSON doesn't correspond to timeline:")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return statuses;
|
return statuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,14 +166,14 @@ std::vector<DirectMessage> getDirectMessages(std::string &json)
|
||||||
|
|
||||||
|
|
||||||
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
||||||
LOG4CXX_ERROR(logger, "Error while parsing JSON");
|
LOG4CXX_ERROR(logger, "Error while parsing JSON")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return DMs;
|
return DMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!rootElement.IsArray()) {
|
if(!rootElement.IsArray()) {
|
||||||
LOG4CXX_ERROR(logger, "JSON doesn't correspond to direct messages:");
|
LOG4CXX_ERROR(logger, "JSON doesn't correspond to direct messages:")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return DMs;
|
return DMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,14 +190,14 @@ std::vector<User> getUsers(std::string &json)
|
||||||
|
|
||||||
|
|
||||||
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
||||||
LOG4CXX_ERROR(logger, "Error while parsing JSON");
|
LOG4CXX_ERROR(logger, "Error while parsing JSON")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!rootElement.IsArray()) {
|
if(!rootElement.IsArray()) {
|
||||||
LOG4CXX_ERROR(logger, "JSON doesn't correspond to user list:");
|
LOG4CXX_ERROR(logger, "JSON doesn't correspond to user list:")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,14 +213,14 @@ User getUser(std::string &json)
|
||||||
rapidjson::Document rootElement;
|
rapidjson::Document rootElement;
|
||||||
|
|
||||||
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
||||||
LOG4CXX_ERROR(logger, "Error while parsing JSON");
|
LOG4CXX_ERROR(logger, "Error while parsing JSON")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!rootElement.IsObject()) {
|
if(!rootElement.IsObject()) {
|
||||||
LOG4CXX_ERROR(logger, "JSON doesn't correspond to user object");
|
LOG4CXX_ERROR(logger, "JSON doesn't correspond to user object")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,14 +233,14 @@ std::vector<std::string> getIDs(std::string &json)
|
||||||
rapidjson::Document rootElement;
|
rapidjson::Document rootElement;
|
||||||
|
|
||||||
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
||||||
LOG4CXX_ERROR(logger, "Error while parsing JSON");
|
LOG4CXX_ERROR(logger, "Error while parsing JSON")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return IDs;
|
return IDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!rootElement.IsObject()) {
|
if(!rootElement.IsObject()) {
|
||||||
LOG4CXX_ERROR(logger, "JSON doesn't correspond to id_list");
|
LOG4CXX_ERROR(logger, "JSON doesn't correspond to id_list");
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return IDs;
|
return IDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,8 +260,8 @@ Error getErrorMessage(std::string &json)
|
||||||
rapidjson::Document rootElement;
|
rapidjson::Document rootElement;
|
||||||
|
|
||||||
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
|
||||||
LOG4CXX_ERROR(logger, "Error while parsing JSON");
|
LOG4CXX_ERROR(logger, "Error while parsing JSON")
|
||||||
LOG4CXX_ERROR(logger, json);
|
LOG4CXX_ERROR(logger, json)
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
if (rootElement.IsObject()) {
|
if (rootElement.IsObject()) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ int main (int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!storagebackend->connect()) {
|
else if (!storagebackend->connect()) {
|
||||||
LOG4CXX_ERROR(logger, "Can't connect to database!");
|
LOG4CXX_ERROR(logger, "Can't connect to database!")
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
FIND_LIBRARY(SWIFTEN_LIBRARY NAMES Swiften Swiften3 Swiften4 HINTS ../lib)
|
FIND_LIBRARY(SWIFTEN_LIBRARY NAMES Swiften Swiften3 HINTS ../lib)
|
||||||
FIND_PATH(SWIFTEN_INCLUDE_DIR NAMES "Swiften/Swiften.h" PATH_SUFFIXES libSwiften Swiften HINTS ../include)
|
FIND_PATH(SWIFTEN_INCLUDE_DIR NAMES "Swiften/Swiften.h" PATH_SUFFIXES libSwiften Swiften HINTS ../include)
|
||||||
|
|
||||||
if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
|
if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
|
||||||
find_program(SWIFTEN_CONFIG_EXECUTABLE NAMES swiften-config DOC "swiften-config executable" HINTS ../bin)
|
find_program(SWIFTEN_CONFIG_EXECUTABLE NAMES swiften-config DOC "swiften-config executable" HINTS ../bin)
|
||||||
set( SWIFTEN_CFLAGS "" )
|
set( SWIFTEN_CFLAGS "" )
|
||||||
if (SWIFTEN_CONFIG_EXECUTABLE)
|
if (SWIFTEN_CONFIG_EXECUTABLE)
|
||||||
# Libs
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${SWIFTEN_CONFIG_EXECUTABLE} --libs
|
COMMAND ${SWIFTEN_CONFIG_EXECUTABLE} --libs
|
||||||
OUTPUT_VARIABLE SWIFTEN_LIB)
|
OUTPUT_VARIABLE SWIFTEN_LIB)
|
||||||
|
@ -31,20 +30,6 @@ if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
|
||||||
list(APPEND SWIFTEN_LIBRARY ${f})
|
list(APPEND SWIFTEN_LIBRARY ${f})
|
||||||
endif()
|
endif()
|
||||||
endforeach(f)
|
endforeach(f)
|
||||||
|
|
||||||
# Version
|
|
||||||
execute_process(
|
|
||||||
COMMAND ${SWIFTEN_CONFIG_EXECUTABLE} --version
|
|
||||||
OUTPUT_VARIABLE SWIFTEN_VERSION)
|
|
||||||
string(REGEX REPLACE "[\r\n]" " " SWIFTEN_VERSION "${SWIFTEN_VERSION}")
|
|
||||||
string(REGEX REPLACE " +$" "" SWIFTEN_VERSION "${SWIFTEN_VERSION}")
|
|
||||||
string(REGEX REPLACE "swiften-config " "" SWIFTEN_VERSION "${SWIFTEN_VERSION}")
|
|
||||||
|
|
||||||
if("${SWIFTEN_VERSION}" STRGREATER "4" AND NOT MSVC)
|
|
||||||
message( STATUS "Found Swiften > 4 requesting C++11")
|
|
||||||
add_definitions(-std=c++11)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set( SWIFTEN_FOUND 1 )
|
set( SWIFTEN_FOUND 1 )
|
||||||
else()
|
else()
|
||||||
message( STATUS "Could NOT find swiften-config" )
|
message( STATUS "Could NOT find swiften-config" )
|
||||||
|
|
|
@ -7,7 +7,7 @@ h2. Install Swiften from git repository:
|
||||||
<pre>
|
<pre>
|
||||||
git clone git://swift.im/swift
|
git clone git://swift.im/swift
|
||||||
cd swift
|
cd swift
|
||||||
git checkout swift-3.0
|
git checkout swift-2.0beta1
|
||||||
./scons V=1 swiften_dll=1 Swiften SWIFTEN_INSTALLDIR=/usr/local force-configure=1
|
./scons V=1 swiften_dll=1 Swiften SWIFTEN_INSTALLDIR=/usr/local force-configure=1
|
||||||
sudo ./scons V=1 swiften_dll=1 Swiften SWIFTEN_INSTALLDIR=/usr/local /usr/local
|
sudo ./scons V=1 swiften_dll=1 Swiften SWIFTEN_INSTALLDIR=/usr/local /usr/local
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -12,12 +12,10 @@
|
||||||
|
|
||||||
#include <Swiften/Elements/Payload.h>
|
#include <Swiften/Elements/Payload.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class AttentionPayload : public Payload {
|
class AttentionPayload : public Payload {
|
||||||
public:
|
public:
|
||||||
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AttentionPayload> ref;
|
typedef boost::shared_ptr<AttentionPayload> ref;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AttentionPayload();
|
AttentionPayload();
|
||||||
|
|
|
@ -12,14 +12,12 @@
|
||||||
|
|
||||||
#include <Swiften/Elements/Payload.h>
|
#include <Swiften/Elements/Payload.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
// This payload is NOT part of ANY XEP and it is only
|
// This payload is NOT part of ANY XEP and it is only
|
||||||
// libtransport related extension.
|
// libtransport related extension.
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class InvisiblePayload : public Payload {
|
class InvisiblePayload : public Payload {
|
||||||
public:
|
public:
|
||||||
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<InvisiblePayload> ref;
|
typedef boost::shared_ptr<InvisiblePayload> ref;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InvisiblePayload();
|
InvisiblePayload();
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include "CombinedOutgoingFileTransferManager.h"
|
#include "CombinedOutgoingFileTransferManager.h"
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/smart_ptr/make_shared.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
#include <Swiften/JID/JID.h>
|
#include <Swiften/JID/JID.h>
|
||||||
|
@ -19,6 +18,7 @@
|
||||||
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
|
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
|
||||||
#include <Swiften/Base/IDGenerator.h>
|
#include <Swiften/Base/IDGenerator.h>
|
||||||
#include <Swiften/Elements/Presence.h>
|
#include <Swiften/Elements/Presence.h>
|
||||||
|
#include <Swiften/Base/foreach.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
@ -31,30 +31,30 @@ CombinedOutgoingFileTransferManager::~CombinedOutgoingFileTransferManager() {
|
||||||
delete idGenerator;
|
delete idGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<OutgoingFileTransfer> CombinedOutgoingFileTransferManager::createOutgoingFileTransfer(const JID& from, const JID& receipient, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ReadBytestream> readBytestream, const StreamInitiationFileInfo& fileInfo) {
|
boost::shared_ptr<OutgoingFileTransfer> CombinedOutgoingFileTransferManager::createOutgoingFileTransfer(const JID& from, const JID& receipient, boost::shared_ptr<ReadBytestream> readBytestream, const StreamInitiationFileInfo& fileInfo) {
|
||||||
// check if receipient support Jingle FT
|
// check if receipient support Jingle FT
|
||||||
boost::optional<JID> fullJID = highestPriorityJIDSupportingJingle(receipient);
|
boost::optional<JID> fullJID = highestPriorityJIDSupportingJingle(receipient);
|
||||||
if (!fullJID.is_initialized()) {
|
if (!fullJID.is_initialized()) {
|
||||||
fullJID = highestPriorityJIDSupportingSI(receipient);
|
fullJID = highestPriorityJIDSupportingSI(receipient);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JingleSessionImpl::ref jingleSession = SWIFTEN_SHRPTR_NAMESPACE::make_shared<JingleSessionImpl>(from, receipient, idGenerator->generateID(), iqRouter);
|
JingleSessionImpl::ref jingleSession = boost::make_shared<JingleSessionImpl>(from, receipient, idGenerator->generateID(), iqRouter);
|
||||||
|
|
||||||
//jsManager->getSession(receipient, idGenerator->generateID());
|
//jsManager->getSession(receipient, idGenerator->generateID());
|
||||||
assert(jingleSession);
|
assert(jingleSession);
|
||||||
jsManager->registerOutgoingSession(from, jingleSession);
|
jsManager->registerOutgoingSession(from, jingleSession);
|
||||||
#if !HAVE_SWIFTEN_3
|
#if !HAVE_SWIFTEN_3
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<OutgoingJingleFileTransfer> jingleFT = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer(jingleSession, remoteFactory, localFactory, iqRouter, idGenerator, from, receipient, readBytestream, fileInfo, bytestreamRegistry, bytestreamProxy));
|
boost::shared_ptr<OutgoingJingleFileTransfer> jingleFT = boost::shared_ptr<OutgoingJingleFileTransfer>(new OutgoingJingleFileTransfer(jingleSession, remoteFactory, localFactory, iqRouter, idGenerator, from, receipient, readBytestream, fileInfo, bytestreamRegistry, bytestreamProxy));
|
||||||
return jingleFT;
|
return jingleFT;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fullJID.is_initialized()) {
|
if (!fullJID.is_initialized()) {
|
||||||
return SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<OutgoingFileTransfer>();
|
return boost::shared_ptr<OutgoingFileTransfer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise try SI
|
// otherwise try SI
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<MyOutgoingSIFileTransfer> jingleFT = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<MyOutgoingSIFileTransfer>(new MyOutgoingSIFileTransfer(idGenerator->generateID(), from, fullJID.get(), fileInfo.getName(), fileInfo.getSize(), fileInfo.getDescription(), readBytestream, iqRouter, bytestreamServer, bytestreamRegistry));
|
boost::shared_ptr<MyOutgoingSIFileTransfer> jingleFT = boost::shared_ptr<MyOutgoingSIFileTransfer>(new MyOutgoingSIFileTransfer(idGenerator->generateID(), from, fullJID.get(), fileInfo.getName(), fileInfo.getSize(), fileInfo.getDescription(), readBytestream, iqRouter, bytestreamServer, bytestreamRegistry));
|
||||||
// else fail
|
// else fail
|
||||||
|
|
||||||
return jingleFT;
|
return jingleFT;
|
||||||
|
@ -68,7 +68,7 @@ boost::optional<JID> CombinedOutgoingFileTransferManager::highestPriorityJIDSupp
|
||||||
std::vector<Presence::ref> presences = presenceOracle->getAllPresence(bareJID);
|
std::vector<Presence::ref> presences = presenceOracle->getAllPresence(bareJID);
|
||||||
|
|
||||||
//iterate over them
|
//iterate over them
|
||||||
BOOST_FOREACH(Presence::ref pres, presences) {
|
foreach(Presence::ref pres, presences) {
|
||||||
if (pres->getPriority() > priority) {
|
if (pres->getPriority() > priority) {
|
||||||
// look up caps from the jid
|
// look up caps from the jid
|
||||||
DiscoInfo::ref info = capsProvider->getCaps(pres->getFrom());
|
DiscoInfo::ref info = capsProvider->getCaps(pres->getFrom());
|
||||||
|
@ -92,7 +92,7 @@ boost::optional<JID> CombinedOutgoingFileTransferManager::highestPriorityJIDSupp
|
||||||
std::vector<Presence::ref> presences = presenceOracle->getAllPresence(bareJID);
|
std::vector<Presence::ref> presences = presenceOracle->getAllPresence(bareJID);
|
||||||
|
|
||||||
//iterate over them
|
//iterate over them
|
||||||
BOOST_FOREACH(Presence::ref pres, presences) {
|
foreach(Presence::ref pres, presences) {
|
||||||
if (pres->getPriority() > priority) {
|
if (pres->getPriority() > priority) {
|
||||||
// look up caps from the jid
|
// look up caps from the jid
|
||||||
DiscoInfo::ref info = capsProvider->getCaps(pres->getFrom());
|
DiscoInfo::ref info = capsProvider->getCaps(pres->getFrom());
|
||||||
|
|
|
@ -12,9 +12,6 @@
|
||||||
#include <Swiften/JID/JID.h>
|
#include <Swiften/JID/JID.h>
|
||||||
|
|
||||||
#include "transport/PresenceOracle.h"
|
#include "transport/PresenceOracle.h"
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
|
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
|
||||||
#include <Swiften/Version.h>
|
#include <Swiften/Version.h>
|
||||||
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
|
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
|
||||||
|
@ -41,7 +38,7 @@ public:
|
||||||
CombinedOutgoingFileTransferManager(JingleSessionManager* jingleSessionManager, IQRouter* router, EntityCapsProvider* capsProvider, RemoteJingleTransportCandidateSelectorFactory* remoteFactory, LocalJingleTransportCandidateGeneratorFactory* localFactory, SOCKS5BytestreamRegistry* bytestreamRegistry, SOCKS5BytestreamProxy* bytestreamProxy, Transport::PresenceOracle* presOracle, SOCKS5BytestreamServer *server);
|
CombinedOutgoingFileTransferManager(JingleSessionManager* jingleSessionManager, IQRouter* router, EntityCapsProvider* capsProvider, RemoteJingleTransportCandidateSelectorFactory* remoteFactory, LocalJingleTransportCandidateGeneratorFactory* localFactory, SOCKS5BytestreamRegistry* bytestreamRegistry, SOCKS5BytestreamProxy* bytestreamProxy, Transport::PresenceOracle* presOracle, SOCKS5BytestreamServer *server);
|
||||||
~CombinedOutgoingFileTransferManager();
|
~CombinedOutgoingFileTransferManager();
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<OutgoingFileTransfer> createOutgoingFileTransfer(const JID& from, const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ReadBytestream>, const StreamInitiationFileInfo&);
|
boost::shared_ptr<OutgoingFileTransfer> createOutgoingFileTransfer(const JID& from, const JID& to, boost::shared_ptr<ReadBytestream>, const StreamInitiationFileInfo&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::optional<JID> highestPriorityJIDSupportingJingle(const JID& bareJID);
|
boost::optional<JID> highestPriorityJIDSupportingJingle(const JID& bareJID);
|
||||||
|
|
|
@ -14,11 +14,9 @@
|
||||||
#include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h>
|
#include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h>
|
||||||
#include <Swiften/FileTransfer/IBBSendSession.h>
|
#include <Swiften/FileTransfer/IBBSendSession.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
MyOutgoingSIFileTransfer::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) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer), registry(registry) {
|
MyOutgoingSIFileTransfer::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) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer), registry(registry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyOutgoingSIFileTransfer::start() {
|
void MyOutgoingSIFileTransfer::start() {
|
||||||
|
@ -71,7 +69,7 @@ void MyOutgoingSIFileTransfer::handleStreamInitiationRequestResponse(StreamIniti
|
||||||
request->send();
|
request->send();
|
||||||
}
|
}
|
||||||
else if (response->getRequestedMethod() == "http://jabber.org/protocol/ibb") {
|
else if (response->getRequestedMethod() == "http://jabber.org/protocol/ibb") {
|
||||||
ibbSession = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IBBSendSession>(new IBBSendSession(id, from, to, bytestream, iqRouter));
|
ibbSession = boost::shared_ptr<IBBSendSession>(new IBBSendSession(id, from, to, bytestream, iqRouter));
|
||||||
ibbSession->onFinished.connect(boost::bind(&MyOutgoingSIFileTransfer::handleIBBSessionFinished, this, _1));
|
ibbSession->onFinished.connect(boost::bind(&MyOutgoingSIFileTransfer::handleIBBSessionFinished, this, _1));
|
||||||
ibbSession->start();
|
ibbSession->start();
|
||||||
#if !HAVE_SWIFTEN_3
|
#if !HAVE_SWIFTEN_3
|
||||||
|
|
|
@ -7,12 +7,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/signals.hpp>
|
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
|
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
|
||||||
#include <Swiften/FileTransfer/ReadBytestream.h>
|
#include <Swiften/FileTransfer/ReadBytestream.h>
|
||||||
|
#include <Swiften/Base/boost_bsignals.h>
|
||||||
#include <Swiften/FileTransfer/FileTransferError.h>
|
#include <Swiften/FileTransfer/FileTransferError.h>
|
||||||
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
|
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
|
||||||
#include <Swiften/JID/JID.h>
|
#include <Swiften/JID/JID.h>
|
||||||
|
@ -30,7 +28,7 @@ namespace Swift {
|
||||||
|
|
||||||
class MyOutgoingSIFileTransfer : public OutgoingFileTransfer {
|
class MyOutgoingSIFileTransfer : public OutgoingFileTransfer {
|
||||||
public:
|
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);
|
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 start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
@ -51,10 +49,10 @@ namespace Swift {
|
||||||
std::string name;
|
std::string name;
|
||||||
int size;
|
int size;
|
||||||
std::string description;
|
std::string description;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ReadBytestream> bytestream;
|
boost::shared_ptr<ReadBytestream> bytestream;
|
||||||
IQRouter* iqRouter;
|
IQRouter* iqRouter;
|
||||||
SOCKS5BytestreamServer* socksServer;
|
SOCKS5BytestreamServer* socksServer;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IBBSendSession> ibbSession;
|
boost::shared_ptr<IBBSendSession> ibbSession;
|
||||||
SOCKS5BytestreamRegistry *registry;
|
SOCKS5BytestreamRegistry *registry;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,12 @@
|
||||||
|
|
||||||
#include <Swiften/Network/DummyConnectionServer.h>
|
#include <Swiften/Network/DummyConnectionServer.h>
|
||||||
|
|
||||||
#include <boost/signal.hpp>
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/system/system_error.hpp>
|
#include <boost/system/system_error.hpp>
|
||||||
#include <boost/asio/placeholders.hpp>
|
#include <boost/asio/placeholders.hpp>
|
||||||
|
|
||||||
#include <Swiften/EventLoop/EventLoop.h>
|
#include <Swiften/EventLoop/EventLoop.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
DummyConnectionServer::DummyConnectionServer(EventLoop* eventLoop) : eventLoop(eventLoop) {
|
DummyConnectionServer::DummyConnectionServer(EventLoop* eventLoop) : eventLoop(eventLoop) {
|
||||||
|
@ -28,9 +25,10 @@ void DummyConnectionServer::stop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DummyConnectionServer::acceptConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> connection) {
|
void DummyConnectionServer::acceptConnection(boost::shared_ptr<Swift::Connection> connection) {
|
||||||
eventLoop->postEvent(
|
eventLoop->postEvent(
|
||||||
boost::bind(boost::ref(onNewConnection), connection));
|
boost::bind(boost::ref(onNewConnection), connection),
|
||||||
|
shared_from_this());
|
||||||
// connection->listen();
|
// connection->listen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,27 +10,28 @@
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/asio/ip/tcp.hpp>
|
#include <boost/asio/ip/tcp.hpp>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
|
#include <Swiften/Base/boost_bsignals.h>
|
||||||
|
|
||||||
#include <Swiften/Network/DummyConnection.h>
|
#include <Swiften/Network/DummyConnection.h>
|
||||||
#include <Swiften/Network/ConnectionServer.h>
|
#include <Swiften/Network/ConnectionServer.h>
|
||||||
#include <Swiften/EventLoop/EventOwner.h>
|
#include <Swiften/EventLoop/EventOwner.h>
|
||||||
#include <Swiften/Version.h>
|
#include <Swiften/Version.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class DummyConnectionServer : public ConnectionServer {
|
class DummyConnectionServer : public ConnectionServer, public EventOwner, public boost::enable_shared_from_this<DummyConnectionServer> {
|
||||||
public:
|
public:
|
||||||
|
typedef boost::shared_ptr<DummyConnectionServer> ref;
|
||||||
|
|
||||||
enum Error {
|
enum Error {
|
||||||
Conflict,
|
Conflict,
|
||||||
UnknownError
|
UnknownError
|
||||||
};
|
};
|
||||||
|
|
||||||
static SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DummyConnectionServer> create(EventLoop* eventLoop) {
|
static ref create(EventLoop* eventLoop) {
|
||||||
return SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DummyConnectionServer>(new DummyConnectionServer(eventLoop));
|
return ref(new DummyConnectionServer(eventLoop));
|
||||||
}
|
}
|
||||||
|
|
||||||
void acceptConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> connection);
|
void acceptConnection(boost::shared_ptr<Swift::Connection> connection);
|
||||||
|
|
||||||
#if (SWIFTEN_VERSION >= 0x030000)
|
#if (SWIFTEN_VERSION >= 0x030000)
|
||||||
virtual boost::optional<ConnectionServer::Error> tryStart() {
|
virtual boost::optional<ConnectionServer::Error> tryStart() {
|
||||||
|
|
|
@ -12,11 +12,11 @@ namespace Swift {
|
||||||
DummyConnectionServerFactory::DummyConnectionServerFactory(EventLoop* eventLoop) : eventLoop(eventLoop) {
|
DummyConnectionServerFactory::DummyConnectionServerFactory(EventLoop* eventLoop) : eventLoop(eventLoop) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> DummyConnectionServerFactory::createConnectionServer(int port) {
|
boost::shared_ptr<ConnectionServer> DummyConnectionServerFactory::createConnectionServer(int port) {
|
||||||
return DummyConnectionServer::create(eventLoop);
|
return DummyConnectionServer::create(eventLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> DummyConnectionServerFactory::createConnectionServer(const Swift::HostAddress &hostAddress, int port) {
|
boost::shared_ptr<ConnectionServer> DummyConnectionServerFactory::createConnectionServer(const Swift::HostAddress &hostAddress, int port) {
|
||||||
return DummyConnectionServer::create(eventLoop);
|
return DummyConnectionServer::create(eventLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
#include <Swiften/Network/ConnectionServerFactory.h>
|
#include <Swiften/Network/ConnectionServerFactory.h>
|
||||||
#include <Swiften/Network/DummyConnectionServer.h>
|
#include <Swiften/Network/DummyConnectionServer.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class ConnectionServer;
|
class ConnectionServer;
|
||||||
|
|
||||||
|
@ -20,9 +18,9 @@ namespace Swift {
|
||||||
public:
|
public:
|
||||||
DummyConnectionServerFactory(EventLoop* eventLoop);
|
DummyConnectionServerFactory(EventLoop* eventLoop);
|
||||||
|
|
||||||
virtual SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> createConnectionServer(int port);
|
virtual boost::shared_ptr<ConnectionServer> createConnectionServer(int port);
|
||||||
|
|
||||||
virtual SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress &hostAddress, int port);
|
virtual boost::shared_ptr<ConnectionServer> createConnectionServer(const Swift::HostAddress &hostAddress, int port);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventLoop* eventLoop;
|
EventLoop* eventLoop;
|
||||||
|
|
|
@ -22,7 +22,7 @@ DummyNetworkFactories::DummyNetworkFactories(EventLoop* eventLoop) {
|
||||||
timerFactory = new DummyTimerFactory();
|
timerFactory = new DummyTimerFactory();
|
||||||
connectionFactory = new DummyConnectionFactory(eventLoop);
|
connectionFactory = new DummyConnectionFactory(eventLoop);
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
idnConverter = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
|
idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
|
||||||
domainNameResolver = new PlatformDomainNameResolver(idnConverter.get(), eventLoop);
|
domainNameResolver = new PlatformDomainNameResolver(idnConverter.get(), eventLoop);
|
||||||
cryptoProvider = PlatformCryptoProvider::create();
|
cryptoProvider = PlatformCryptoProvider::create();
|
||||||
networkEnvironment = new PlatformNetworkEnvironment();
|
networkEnvironment = new PlatformNetworkEnvironment();
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
#include <Swiften/IDN/PlatformIDNConverter.h>
|
#include <Swiften/IDN/PlatformIDNConverter.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class EventLoop;
|
class EventLoop;
|
||||||
|
|
||||||
|
@ -79,7 +77,7 @@ namespace Swift {
|
||||||
TimerFactory* timerFactory;
|
TimerFactory* timerFactory;
|
||||||
ConnectionFactory* connectionFactory;
|
ConnectionFactory* connectionFactory;
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IDNConverter> idnConverter;
|
boost::shared_ptr<IDNConverter> idnConverter;
|
||||||
CryptoProvider* cryptoProvider;
|
CryptoProvider* cryptoProvider;
|
||||||
NetworkEnvironment* networkEnvironment;
|
NetworkEnvironment* networkEnvironment;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
|
|
||||||
#include <Swiften/Parser/PayloadParsers/GatewayPayloadParser.h>
|
#include <Swiften/Parser/PayloadParsers/GatewayPayloadParser.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
|
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
|
||||||
#include <Swiften/Parser/PayloadParserFactory.h>
|
#include <Swiften/Parser/PayloadParserFactory.h>
|
||||||
|
#include <Swiften/Base/foreach.h>
|
||||||
#include <Swiften/Elements/MUCOccupant.h>
|
#include <Swiften/Elements/MUCOccupant.h>
|
||||||
#include <Swiften/Parser/Tree/TreeReparser.h>
|
#include <Swiften/Parser/Tree/TreeReparser.h>
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
void GatewayPayloadParser::handleTree(ParserElement::ref root) {
|
void GatewayPayloadParser::handleTree(ParserElement::ref root) {
|
||||||
BOOST_FOREACH (ParserElement::ref child, root->getAllChildren()) {
|
foreach (ParserElement::ref child, root->getAllChildren()) {
|
||||||
if (child->getName() == "desc") {
|
if (child->getName() == "desc") {
|
||||||
getPayloadInternal()->setDesc(child->getText());
|
getPayloadInternal()->setDesc(child->getText());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
|
|
||||||
#include <Swiften/Parser/PayloadParsers/MUCPayloadParser.h>
|
#include <Swiften/Parser/PayloadParsers/MUCPayloadParser.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
|
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
|
||||||
#include <Swiften/Parser/PayloadParserFactory.h>
|
#include <Swiften/Parser/PayloadParserFactory.h>
|
||||||
|
#include <Swiften/Base/foreach.h>
|
||||||
#include <Swiften/Elements/MUCOccupant.h>
|
#include <Swiften/Elements/MUCOccupant.h>
|
||||||
#include <Swiften/Parser/Tree/TreeReparser.h>
|
#include <Swiften/Parser/Tree/TreeReparser.h>
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
void MUCPayloadParser::handleTree(ParserElement::ref root) {
|
void MUCPayloadParser::handleTree(ParserElement::ref root) {
|
||||||
BOOST_FOREACH (ParserElement::ref child, root->getAllChildren()) {
|
foreach (ParserElement::ref child, root->getAllChildren()) {
|
||||||
if (child->getName() == "password" && child->getNamespace() == root->getNamespace()) {
|
if (child->getName() == "password" && child->getNamespace() == root->getNamespace()) {
|
||||||
getPayloadInternal()->setPassword(child->getText());
|
getPayloadInternal()->setPassword(child->getText());
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,8 @@
|
||||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <Swiften/Parser/PayloadParsers/XHTMLIMParser.h>
|
#include <Swiften/Parser/PayloadParsers/XHTMLIMParser.h>
|
||||||
#include <Swiften/Parser/SerializingParser.h>
|
#include <Swiften/Parser/SerializingParser.h>
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
|
@ -52,7 +50,7 @@ void XHTMLIMParser::handleCharacterData(const std::string& data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XHTMLIMPayload> XHTMLIMParser::getLabelPayload() const {
|
boost::shared_ptr<XHTMLIMPayload> XHTMLIMParser::getLabelPayload() const {
|
||||||
return getPayloadInternal();
|
return getPayloadInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
#include <Swiften/Elements/XHTMLIMPayload.h>
|
#include <Swiften/Elements/XHTMLIMPayload.h>
|
||||||
#include <Swiften/Parser/GenericPayloadParser.h>
|
#include <Swiften/Parser/GenericPayloadParser.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class SerializingParser;
|
class SerializingParser;
|
||||||
|
|
||||||
|
@ -21,7 +19,7 @@ namespace Swift {
|
||||||
virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes);
|
virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes);
|
||||||
virtual void handleEndElement(const std::string& element, const std::string&);
|
virtual void handleEndElement(const std::string& element, const std::string&);
|
||||||
virtual void handleCharacterData(const std::string& data);
|
virtual void handleCharacterData(const std::string& data);
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XHTMLIMPayload> getLabelPayload() const;
|
boost::shared_ptr<XHTMLIMPayload> getLabelPayload() const;
|
||||||
private:
|
private:
|
||||||
enum Level {
|
enum Level {
|
||||||
TopLevel = 0,
|
TopLevel = 0,
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <Swiften/Parser/PlatformXMLParserFactory.h>
|
#include <Swiften/Parser/PlatformXMLParserFactory.h>
|
||||||
#include <Swiften/Parser/Tree/ParserElement.h>
|
#include <Swiften/Parser/Tree/ParserElement.h>
|
||||||
#include <Swiften/Parser/XMLParser.h>
|
#include <Swiften/Parser/XMLParser.h>
|
||||||
#include <Swiften/Version.h>
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
|
@ -29,17 +28,11 @@ class DefaultStringTreeParser : public StringTreeParser {
|
||||||
ParserElement::ref StringTreeParser::parse(const std::string &xml) {
|
ParserElement::ref StringTreeParser::parse(const std::string &xml) {
|
||||||
PlatformXMLParserFactory factory;
|
PlatformXMLParserFactory factory;
|
||||||
DefaultStringTreeParser client;
|
DefaultStringTreeParser client;
|
||||||
#if (SWIFTEN_VERSION >= 0x040000)
|
|
||||||
std::unique_ptr<XMLParser> parser = factory.createXMLParser(&client);
|
|
||||||
#else
|
|
||||||
XMLParser *parser = factory.createXMLParser(&client);
|
XMLParser *parser = factory.createXMLParser(&client);
|
||||||
#endif
|
|
||||||
|
|
||||||
parser->parse(xml);
|
parser->parse(xml);
|
||||||
ParserElement::ref root = client.getRoot();
|
ParserElement::ref root = client.getRoot();
|
||||||
#if (SWIFTEN_VERSION < 0x040000)
|
|
||||||
delete parser;
|
delete parser;
|
||||||
#endif
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
#include <Swiften/Parser/Tree/ParserElement.h>
|
#include <Swiften/Parser/Tree/ParserElement.h>
|
||||||
#include <Swiften/Parser/XMLParserClient.h>
|
#include <Swiften/Parser/XMLParserClient.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
/**
|
/**
|
||||||
* Generics parser offering something a bit like a DOM to work with.
|
* Generics parser offering something a bit like a DOM to work with.
|
||||||
|
@ -26,7 +24,7 @@ namespace Swift {
|
||||||
|
|
||||||
virtual void handleStartElement(const std::string& element, const std::string& xmlns, const AttributeMap& attributes) {
|
virtual void handleStartElement(const std::string& element, const std::string& xmlns, const AttributeMap& attributes) {
|
||||||
if (!root_) {
|
if (!root_) {
|
||||||
root_ = SWIFTEN_SHRPTR_NAMESPACE::make_shared<ParserElement>(element, xmlns, attributes);
|
root_ = boost::make_shared<ParserElement>(element, xmlns, attributes);
|
||||||
elementStack_.push_back(root_);
|
elementStack_.push_back(root_);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Swift {
|
||||||
AttentionSerializer::AttentionSerializer() : GenericPayloadSerializer<AttentionPayload>() {
|
AttentionSerializer::AttentionSerializer() : GenericPayloadSerializer<AttentionPayload>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AttentionSerializer::serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AttentionPayload> attention) const {
|
std::string AttentionSerializer::serializePayload(boost::shared_ptr<AttentionPayload> attention) const {
|
||||||
XMLElement attentionElement("attention", "urn:xmpp:attention:0");
|
XMLElement attentionElement("attention", "urn:xmpp:attention:0");
|
||||||
|
|
||||||
return attentionElement.serialize();
|
return attentionElement.serialize();
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
||||||
#include <Swiften/Elements/AttentionPayload.h>
|
#include <Swiften/Elements/AttentionPayload.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class AttentionSerializer : public GenericPayloadSerializer<AttentionPayload> {
|
class AttentionSerializer : public GenericPayloadSerializer<AttentionPayload> {
|
||||||
public:
|
public:
|
||||||
AttentionSerializer();
|
AttentionSerializer();
|
||||||
|
|
||||||
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AttentionPayload>) const;
|
virtual std::string serializePayload(boost::shared_ptr<AttentionPayload>) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,34 +5,33 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Swiften/Serializer/PayloadSerializers/GatewayPayloadSerializer.h>
|
#include <Swiften/Serializer/PayloadSerializers/GatewayPayloadSerializer.h>
|
||||||
|
#include <Swiften/Base/foreach.h>
|
||||||
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
||||||
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
||||||
#include <Swiften/Serializer/XML/XMLElement.h>
|
#include <Swiften/Serializer/XML/XMLElement.h>
|
||||||
#include <Swiften/Serializer/PayloadSerializerCollection.h>
|
#include <Swiften/Serializer/PayloadSerializerCollection.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
GatewayPayloadSerializer::GatewayPayloadSerializer()
|
GatewayPayloadSerializer::GatewayPayloadSerializer()
|
||||||
: GenericPayloadSerializer<GatewayPayload>() {
|
: GenericPayloadSerializer<GatewayPayload>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GatewayPayloadSerializer::serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<GatewayPayload> payload) const {
|
std::string GatewayPayloadSerializer::serializePayload(boost::shared_ptr<GatewayPayload> payload) const {
|
||||||
XMLElement query("query", "jabber:iq:gateway");
|
XMLElement query("query", "jabber:iq:gateway");
|
||||||
|
|
||||||
if (payload->getJID().isValid()) {
|
if (payload->getJID().isValid()) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XMLElement> jid(new XMLElement("jid", "", payload->getJID().toBare().toString()));
|
boost::shared_ptr<XMLElement> jid(new XMLElement("jid", "", payload->getJID().toBare().toString()));
|
||||||
query.addNode(jid);
|
query.addNode(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!payload->getDesc().empty()) {
|
if (!payload->getDesc().empty()) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XMLElement> desc(new XMLElement("desc", "", payload->getDesc()));
|
boost::shared_ptr<XMLElement> desc(new XMLElement("desc", "", payload->getDesc()));
|
||||||
query.addNode(desc);
|
query.addNode(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!payload->getPrompt().empty()) {
|
if (!payload->getPrompt().empty()) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XMLElement> prompt(new XMLElement("prompt", "", payload->getPrompt()));
|
boost::shared_ptr<XMLElement> prompt(new XMLElement("prompt", "", payload->getPrompt()));
|
||||||
query.addNode(prompt);
|
query.addNode(prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
||||||
#include <Swiften/Elements/GatewayPayload.h>
|
#include <Swiften/Elements/GatewayPayload.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class GatewayPayloadSerializer : public GenericPayloadSerializer<GatewayPayload> {
|
class GatewayPayloadSerializer : public GenericPayloadSerializer<GatewayPayload> {
|
||||||
public:
|
public:
|
||||||
GatewayPayloadSerializer();
|
GatewayPayloadSerializer();
|
||||||
|
|
||||||
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<GatewayPayload> item) const;
|
virtual std::string serializePayload(boost::shared_ptr<GatewayPayload> item) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Swift {
|
||||||
InvisibleSerializer::InvisibleSerializer() : GenericPayloadSerializer<InvisiblePayload>() {
|
InvisibleSerializer::InvisibleSerializer() : GenericPayloadSerializer<InvisiblePayload>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string InvisibleSerializer::serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<InvisiblePayload> attention) const {
|
std::string InvisibleSerializer::serializePayload(boost::shared_ptr<InvisiblePayload> attention) const {
|
||||||
XMLElement attentionElement("invisible", "urn:xmpp:invisible:0");
|
XMLElement attentionElement("invisible", "urn:xmpp:invisible:0");
|
||||||
|
|
||||||
return attentionElement.serialize();
|
return attentionElement.serialize();
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
||||||
#include <Swiften/Elements/InvisiblePayload.h>
|
#include <Swiften/Elements/InvisiblePayload.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
// This payload is NOT part of ANY XEP and it is only
|
// This payload is NOT part of ANY XEP and it is only
|
||||||
// libtransport related extension.
|
// libtransport related extension.
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
@ -18,6 +16,6 @@ namespace Swift {
|
||||||
public:
|
public:
|
||||||
InvisibleSerializer();
|
InvisibleSerializer();
|
||||||
|
|
||||||
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<InvisiblePayload>) const;
|
virtual std::string serializePayload(boost::shared_ptr<InvisiblePayload>) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
|
|
||||||
#include <Swiften/Serializer/PayloadSerializers/SpectrumErrorSerializer.h>
|
#include <Swiften/Serializer/PayloadSerializers/SpectrumErrorSerializer.h>
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include <Swiften/Base/foreach.h>
|
||||||
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
||||||
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
||||||
#include <Swiften/Serializer/XML/XMLElement.h>
|
#include <Swiften/Serializer/XML/XMLElement.h>
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
@ -17,7 +19,7 @@ namespace Swift {
|
||||||
SpectrumErrorSerializer::SpectrumErrorSerializer() : GenericPayloadSerializer<SpectrumErrorPayload>() {
|
SpectrumErrorSerializer::SpectrumErrorSerializer() : GenericPayloadSerializer<SpectrumErrorPayload>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SpectrumErrorSerializer::serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SpectrumErrorPayload> error) const {
|
std::string SpectrumErrorSerializer::serializePayload(boost::shared_ptr<SpectrumErrorPayload> error) const {
|
||||||
std::string data;
|
std::string data;
|
||||||
switch (error->getError()) {
|
switch (error->getError()) {
|
||||||
case SpectrumErrorPayload::CONNECTION_ERROR_NETWORK_ERROR: data = "CONNECTION_ERROR_NETWORK_ERROR"; break;
|
case SpectrumErrorPayload::CONNECTION_ERROR_NETWORK_ERROR: data = "CONNECTION_ERROR_NETWORK_ERROR"; break;
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
||||||
#include <Swiften/Elements/SpectrumErrorPayload.h>
|
#include <Swiften/Elements/SpectrumErrorPayload.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class SpectrumErrorSerializer : public GenericPayloadSerializer<SpectrumErrorPayload> {
|
class SpectrumErrorSerializer : public GenericPayloadSerializer<SpectrumErrorPayload> {
|
||||||
public:
|
public:
|
||||||
SpectrumErrorSerializer();
|
SpectrumErrorSerializer();
|
||||||
|
|
||||||
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SpectrumErrorPayload>) const;
|
virtual std::string serializePayload(boost::shared_ptr<SpectrumErrorPayload>) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,25 +4,24 @@
|
||||||
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
* See Documentation/Licenses/BSD-simplified.txt for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
|
|
||||||
#include <Swiften/Serializer/PayloadSerializers/StatsSerializer.h>
|
#include <Swiften/Serializer/PayloadSerializers/StatsSerializer.h>
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
|
#include <Swiften/Base/foreach.h>
|
||||||
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
||||||
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
||||||
#include <Swiften/Serializer/XML/XMLElement.h>
|
#include <Swiften/Serializer/XML/XMLElement.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
StatsSerializer::StatsSerializer() : GenericPayloadSerializer<StatsPayload>() {
|
StatsSerializer::StatsSerializer() : GenericPayloadSerializer<StatsPayload>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StatsSerializer::serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<StatsPayload> stats) const {
|
std::string StatsSerializer::serializePayload(boost::shared_ptr<StatsPayload> stats) const {
|
||||||
XMLElement queryElement("query", "http://jabber.org/protocol/stats");
|
XMLElement queryElement("query", "http://jabber.org/protocol/stats");
|
||||||
BOOST_FOREACH(const StatsPayload::Item& item, stats->getItems()) {
|
foreach(const StatsPayload::Item& item, stats->getItems()) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XMLElement> statElement(new XMLElement("stat"));
|
boost::shared_ptr<XMLElement> statElement(new XMLElement("stat"));
|
||||||
statElement->setAttribute("name", item.getName());
|
statElement->setAttribute("name", item.getName());
|
||||||
if (!item.getUnits().empty()) {
|
if (!item.getUnits().empty()) {
|
||||||
statElement->setAttribute("units", item.getUnits());
|
statElement->setAttribute("units", item.getUnits());
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
||||||
#include <Swiften/Elements/StatsPayload.h>
|
#include <Swiften/Elements/StatsPayload.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class StatsSerializer : public GenericPayloadSerializer<StatsPayload> {
|
class StatsSerializer : public GenericPayloadSerializer<StatsPayload> {
|
||||||
public:
|
public:
|
||||||
StatsSerializer();
|
StatsSerializer();
|
||||||
|
|
||||||
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<StatsPayload>) const;
|
virtual std::string serializePayload(boost::shared_ptr<StatsPayload>) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,22 +5,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Swiften/Serializer/PayloadSerializers/XHTMLIMSerializer.h>
|
#include <Swiften/Serializer/PayloadSerializers/XHTMLIMSerializer.h>
|
||||||
|
#include <Swiften/Base/foreach.h>
|
||||||
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
|
||||||
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
#include <Swiften/Serializer/XML/XMLTextNode.h>
|
||||||
#include <Swiften/Serializer/XML/XMLElement.h>
|
#include <Swiften/Serializer/XML/XMLElement.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
|
||||||
XHTMLIMSerializer::XHTMLIMSerializer() : GenericPayloadSerializer<XHTMLIMPayload>() {
|
XHTMLIMSerializer::XHTMLIMSerializer() : GenericPayloadSerializer<XHTMLIMPayload>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string XHTMLIMSerializer::serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XHTMLIMPayload> payload) const {
|
std::string XHTMLIMSerializer::serializePayload(boost::shared_ptr<XHTMLIMPayload> payload) const {
|
||||||
XMLElement html("html", "http://jabber.org/protocol/xhtml-im");
|
XMLElement html("html", "http://jabber.org/protocol/xhtml-im");
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XMLElement> body(new XMLElement("body", "http://www.w3.org/1999/xhtml"));
|
boost::shared_ptr<XMLElement> body(new XMLElement("body", "http://www.w3.org/1999/xhtml"));
|
||||||
body->addNode(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(payload->getBody())));
|
body->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(payload->getBody())));
|
||||||
html.addNode(body);
|
html.addNode(body);
|
||||||
|
|
||||||
return html.serialize();
|
return html.serialize();
|
||||||
|
|
|
@ -9,13 +9,11 @@
|
||||||
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
#include <Swiften/Serializer/GenericPayloadSerializer.h>
|
||||||
#include <Swiften/Elements/XHTMLIMPayload.h>
|
#include <Swiften/Elements/XHTMLIMPayload.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class XHTMLIMSerializer : public GenericPayloadSerializer<XHTMLIMPayload> {
|
class XHTMLIMSerializer : public GenericPayloadSerializer<XHTMLIMPayload> {
|
||||||
public:
|
public:
|
||||||
XHTMLIMSerializer();
|
XHTMLIMSerializer();
|
||||||
|
|
||||||
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XHTMLIMPayload> xhtml) const;
|
virtual std::string serializePayload(boost::shared_ptr<XHTMLIMPayload> xhtml) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/signal.hpp>
|
|
||||||
|
|
||||||
#include "Swiften/Base/String.h"
|
#include "Swiften/Base/String.h"
|
||||||
|
#include "Swiften/Base/foreach.h"
|
||||||
#include "Swiften/Network/Connection.h"
|
#include "Swiften/Network/Connection.h"
|
||||||
#include "Swiften/Network/ConnectionServer.h"
|
#include "Swiften/Network/ConnectionServer.h"
|
||||||
#include "Swiften/Network/ConnectionServerFactory.h"
|
#include "Swiften/Network/ConnectionServerFactory.h"
|
||||||
|
@ -70,7 +69,7 @@ void Server::start() {
|
||||||
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(port_);
|
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(port_);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(SWIFT_HOSTADDRESS(address_), port_);
|
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(Swift::HostAddress(address_), port_);
|
||||||
}
|
}
|
||||||
serverFromClientConnectionServerSignalConnections.push_back(
|
serverFromClientConnectionServerSignalConnections.push_back(
|
||||||
serverFromClientConnectionServer->onNewConnection.connect(
|
serverFromClientConnectionServer->onNewConnection.connect(
|
||||||
|
@ -89,14 +88,14 @@ void Server::stop() {
|
||||||
|
|
||||||
stopping = true;
|
stopping = true;
|
||||||
|
|
||||||
// foreach(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session, serverFromClientSessions) {
|
// foreach(boost::shared_ptr<ServerFromClientSession> session, serverFromClientSessions) {
|
||||||
// session->finishSession();
|
// session->finishSession();
|
||||||
// }
|
// }
|
||||||
serverFromClientSessions.clear();
|
serverFromClientSessions.clear();
|
||||||
|
|
||||||
if (serverFromClientConnectionServer) {
|
if (serverFromClientConnectionServer) {
|
||||||
serverFromClientConnectionServer->stop();
|
serverFromClientConnectionServer->stop();
|
||||||
BOOST_FOREACH(SWIFTEN_SIGNAL_NAMESPACE::connection& connection, serverFromClientConnectionServerSignalConnections) {
|
foreach(boost::bsignals::connection& connection, serverFromClientConnectionServerSignalConnections) {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
serverFromClientConnectionServerSignalConnections.clear();
|
serverFromClientConnectionServerSignalConnections.clear();
|
||||||
|
@ -107,9 +106,9 @@ void Server::stop() {
|
||||||
// onStopped(e);
|
// onStopped(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleNewClientConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> connection) {
|
void Server::handleNewClientConnection(boost::shared_ptr<Connection> connection) {
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> serverFromClientSession = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>(
|
boost::shared_ptr<ServerFromClientSession> serverFromClientSession = boost::shared_ptr<ServerFromClientSession>(
|
||||||
new ServerFromClientSession(idGenerator.generateID(), connection,
|
new ServerFromClientSession(idGenerator.generateID(), connection,
|
||||||
getPayloadParserFactories(), getPayloadSerializers(), userRegistry_, parserFactory_));
|
getPayloadParserFactories(), getPayloadSerializers(), userRegistry_, parserFactory_));
|
||||||
//serverFromClientSession->setAllowSASLEXTERNAL();
|
//serverFromClientSession->setAllowSASLEXTERNAL();
|
||||||
|
@ -139,11 +138,11 @@ void Server::handleDataWritten(const SafeByteArray& data) {
|
||||||
onDataWritten(data);
|
onDataWritten(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleSessionStarted(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session) {
|
void Server::handleSessionStarted(boost::shared_ptr<ServerFromClientSession> session) {
|
||||||
dynamic_cast<ServerStanzaChannel *>(stanzaChannel_)->addSession(session);
|
dynamic_cast<ServerStanzaChannel *>(stanzaChannel_)->addSession(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::handleSessionFinished(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session) {
|
void Server::handleSessionFinished(boost::shared_ptr<ServerFromClientSession> session) {
|
||||||
// if (!session->getRemoteJID().isValid()) {
|
// if (!session->getRemoteJID().isValid()) {
|
||||||
// Swift::Presence::ref presence = Swift::Presence::create();
|
// Swift::Presence::ref presence = Swift::Presence::create();
|
||||||
// presence->setFrom(session->getBareJID());
|
// presence->setFrom(session->getBareJID());
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/signals2.hpp>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Swiften/Network/BoostIOServiceThread.h"
|
#include "Swiften/Network/BoostIOServiceThread.h"
|
||||||
|
@ -22,7 +21,6 @@
|
||||||
#include "Swiften/Entity/Entity.h"
|
#include "Swiften/Entity/Entity.h"
|
||||||
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
|
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
|
||||||
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
|
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
#include <Swiften/TLS/CertificateWithKey.h>
|
#include <Swiften/TLS/CertificateWithKey.h>
|
||||||
#include <Swiften/Parser/PlatformXMLParserFactory.h>
|
#include <Swiften/Parser/PlatformXMLParserFactory.h>
|
||||||
|
|
||||||
|
@ -55,7 +53,7 @@ namespace Swift {
|
||||||
return iqRouter_;
|
return iqRouter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> getConnectionServer() const {
|
boost::shared_ptr<ConnectionServer> getConnectionServer() const {
|
||||||
return serverFromClientConnectionServer;
|
return serverFromClientConnectionServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +63,10 @@ namespace Swift {
|
||||||
void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert);
|
void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleNewClientConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> c);
|
void handleNewClientConnection(boost::shared_ptr<Connection> c);
|
||||||
void handleSessionStarted(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>);
|
void handleSessionStarted(boost::shared_ptr<ServerFromClientSession>);
|
||||||
void handleSessionFinished(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>);
|
void handleSessionFinished(boost::shared_ptr<ServerFromClientSession>);
|
||||||
void handleElementReceived(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session);
|
void handleElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<ServerFromClientSession> session);
|
||||||
void handleDataRead(const SafeByteArray&);
|
void handleDataRead(const SafeByteArray&);
|
||||||
void handleDataWritten(const SafeByteArray&);
|
void handleDataWritten(const SafeByteArray&);
|
||||||
|
|
||||||
|
@ -79,9 +77,9 @@ namespace Swift {
|
||||||
EventLoop* eventLoop;
|
EventLoop* eventLoop;
|
||||||
NetworkFactories* networkFactories_;
|
NetworkFactories* networkFactories_;
|
||||||
bool stopping;
|
bool stopping;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> serverFromClientConnectionServer;
|
boost::shared_ptr<ConnectionServer> serverFromClientConnectionServer;
|
||||||
std::vector<SWIFTEN_SIGNAL_NAMESPACE::connection> serverFromClientConnectionServerSignalConnections;
|
std::vector<boost::bsignals::connection> serverFromClientConnectionServerSignalConnections;
|
||||||
std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > serverFromClientSessions;
|
std::list<boost::shared_ptr<ServerFromClientSession> > serverFromClientSessions;
|
||||||
JID selfJID;
|
JID selfJID;
|
||||||
StanzaChannel *stanzaChannel_;
|
StanzaChannel *stanzaChannel_;
|
||||||
IQRouter *iqRouter_;
|
IQRouter *iqRouter_;
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <Swiften/TLS/CertificateWithKey.h>
|
#include <Swiften/TLS/CertificateWithKey.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
#include <Swiften/Version.h>
|
#include <Swiften/Version.h>
|
||||||
#if (SWIFTEN_VERSION >= 0x030000)
|
#if (SWIFTEN_VERSION >= 0x030000)
|
||||||
#include <Swiften/Elements/ToplevelElement.h>
|
#include <Swiften/Elements/ToplevelElement.h>
|
||||||
|
@ -40,7 +38,7 @@ namespace Swift {
|
||||||
|
|
||||||
ServerFromClientSession::ServerFromClientSession(
|
ServerFromClientSession::ServerFromClientSession(
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> connection,
|
boost::shared_ptr<Connection> connection,
|
||||||
PayloadParserFactoryCollection* payloadParserFactories,
|
PayloadParserFactoryCollection* payloadParserFactories,
|
||||||
PayloadSerializerCollection* payloadSerializers,
|
PayloadSerializerCollection* payloadSerializers,
|
||||||
UserRegistry* userRegistry,
|
UserRegistry* userRegistry,
|
||||||
|
@ -65,7 +63,7 @@ ServerFromClientSession::~ServerFromClientSession() {
|
||||||
|
|
||||||
void ServerFromClientSession::handlePasswordValid() {
|
void ServerFromClientSession::handlePasswordValid() {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
getXMPPLayer()->writeElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AuthSuccess>(new AuthSuccess()));
|
getXMPPLayer()->writeElement(boost::shared_ptr<AuthSuccess>(new AuthSuccess()));
|
||||||
authenticated_ = true;
|
authenticated_ = true;
|
||||||
getXMPPLayer()->resetParser();
|
getXMPPLayer()->resetParser();
|
||||||
}
|
}
|
||||||
|
@ -73,9 +71,9 @@ void ServerFromClientSession::handlePasswordValid() {
|
||||||
|
|
||||||
void ServerFromClientSession::handlePasswordInvalid(const std::string &error) {
|
void ServerFromClientSession::handlePasswordInvalid(const std::string &error) {
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
getXMPPLayer()->writeElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AuthFailure>(new AuthFailure));
|
getXMPPLayer()->writeElement(boost::shared_ptr<AuthFailure>(new AuthFailure));
|
||||||
if (!error.empty()) {
|
if (!error.empty()) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<StreamError> msg(new StreamError(StreamError::UndefinedCondition, error));
|
boost::shared_ptr<StreamError> msg(new StreamError(StreamError::UndefinedCondition, error));
|
||||||
getXMPPLayer()->writeElement(msg);
|
getXMPPLayer()->writeElement(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,9 +82,9 @@ void ServerFromClientSession::handlePasswordInvalid(const std::string &error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (SWIFTEN_VERSION >= 0x030000)
|
#if (SWIFTEN_VERSION >= 0x030000)
|
||||||
void ServerFromClientSession::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ToplevelElement> element) {
|
void ServerFromClientSession::handleElement(boost::shared_ptr<ToplevelElement> element) {
|
||||||
#else
|
#else
|
||||||
void ServerFromClientSession::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element) {
|
void ServerFromClientSession::handleElement(boost::shared_ptr<Element> element) {
|
||||||
#endif
|
#endif
|
||||||
if (isInitialized()) {
|
if (isInitialized()) {
|
||||||
onElementReceived(element);
|
onElementReceived(element);
|
||||||
|
@ -95,7 +93,7 @@ void ServerFromClientSession::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr
|
||||||
if (AuthRequest* authRequest = dynamic_cast<AuthRequest*>(element.get())) {
|
if (AuthRequest* authRequest = dynamic_cast<AuthRequest*>(element.get())) {
|
||||||
if (authRequest->getMechanism() == "PLAIN" || (allowSASLEXTERNAL && authRequest->getMechanism() == "EXTERNAL")) {
|
if (authRequest->getMechanism() == "PLAIN" || (allowSASLEXTERNAL && authRequest->getMechanism() == "EXTERNAL")) {
|
||||||
if (authRequest->getMechanism() == "EXTERNAL") {
|
if (authRequest->getMechanism() == "EXTERNAL") {
|
||||||
getXMPPLayer()->writeElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AuthSuccess>(new AuthSuccess()));
|
getXMPPLayer()->writeElement(boost::shared_ptr<AuthSuccess>(new AuthSuccess()));
|
||||||
authenticated_ = true;
|
authenticated_ = true;
|
||||||
getXMPPLayer()->resetParser();
|
getXMPPLayer()->resetParser();
|
||||||
}
|
}
|
||||||
|
@ -106,25 +104,25 @@ void ServerFromClientSession::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
getXMPPLayer()->writeElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AuthFailure>(new AuthFailure));
|
getXMPPLayer()->writeElement(boost::shared_ptr<AuthFailure>(new AuthFailure));
|
||||||
finishSession(NoSupportedAuthMechanismsError);
|
finishSession(NoSupportedAuthMechanismsError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<StartTLSRequest*>(element.get()) != NULL) {
|
else if (dynamic_cast<StartTLSRequest*>(element.get()) != NULL) {
|
||||||
getXMPPLayer()->writeElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSProceed>(new TLSProceed));
|
getXMPPLayer()->writeElement(boost::shared_ptr<TLSProceed>(new TLSProceed));
|
||||||
getStreamStack()->addLayer(tlsLayer);
|
getStreamStack()->addLayer(tlsLayer);
|
||||||
tlsLayer->connect();
|
tlsLayer->connect();
|
||||||
getXMPPLayer()->resetParser();
|
getXMPPLayer()->resetParser();
|
||||||
}
|
}
|
||||||
else if (IQ* iq = dynamic_cast<IQ*>(element.get())) {
|
else if (IQ* iq = dynamic_cast<IQ*>(element.get())) {
|
||||||
if (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ResourceBind> resourceBind = iq->getPayload<ResourceBind>()) {
|
if (boost::shared_ptr<ResourceBind> resourceBind = iq->getPayload<ResourceBind>()) {
|
||||||
std::string bucket = "abcdefghijklmnopqrstuvwxyz";
|
std::string bucket = "abcdefghijklmnopqrstuvwxyz";
|
||||||
std::string uuid;
|
std::string uuid;
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
uuid += bucket[rand() % bucket.size()];
|
uuid += bucket[rand() % bucket.size()];
|
||||||
}
|
}
|
||||||
setRemoteJID(JID(user_, getLocalJID().getDomain(), uuid));
|
setRemoteJID(JID(user_, getLocalJID().getDomain(), uuid));
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ResourceBind> resultResourceBind(new ResourceBind());
|
boost::shared_ptr<ResourceBind> resultResourceBind(new ResourceBind());
|
||||||
resultResourceBind->setJID(getRemoteJID());
|
resultResourceBind->setJID(getRemoteJID());
|
||||||
getXMPPLayer()->writeElement(IQ::createResult(JID(), iq->getID(), resultResourceBind));
|
getXMPPLayer()->writeElement(IQ::createResult(JID(), iq->getID(), resultResourceBind));
|
||||||
}
|
}
|
||||||
|
@ -143,7 +141,7 @@ void ServerFromClientSession::handleStreamStart(const ProtocolHeader& incomingHe
|
||||||
header.setID(id_);
|
header.setID(id_);
|
||||||
getXMPPLayer()->writeHeader(header);
|
getXMPPLayer()->writeHeader(header);
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<StreamFeatures> features(new StreamFeatures());
|
boost::shared_ptr<StreamFeatures> features(new StreamFeatures());
|
||||||
|
|
||||||
if (!authenticated_) {
|
if (!authenticated_) {
|
||||||
if (tlsLayer && !tlsConnected) {
|
if (tlsLayer && !tlsConnected) {
|
||||||
|
@ -179,7 +177,7 @@ void ServerFromClientSession::addTLSEncryption(TLSServerContextFactory* tlsConte
|
||||||
if (!tlsLayer->setServerCertificate(cert)) {
|
if (!tlsLayer->setServerCertificate(cert)) {
|
||||||
// std::cout << "error\n";
|
// std::cout << "error\n";
|
||||||
// TODO:
|
// TODO:
|
||||||
// onClosed(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Error>(new Error(Error::InvalidTLSCertificateError)));
|
// onClosed(boost::shared_ptr<Error>(new Error(Error::InvalidTLSCertificateError)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tlsLayer->onError.connect(boost::bind(&ServerFromClientSession::handleTLSError, this));
|
tlsLayer->onError.connect(boost::bind(&ServerFromClientSession::handleTLSError, this));
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <Swiften/Base/boost_bsignals.h>
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <boost/signals.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Swiften/Session/Session.h>
|
#include <Swiften/Session/Session.h>
|
||||||
|
@ -19,8 +19,6 @@
|
||||||
#include <Swiften/Version.h>
|
#include <Swiften/Version.h>
|
||||||
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
|
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class ProtocolHeader;
|
class ProtocolHeader;
|
||||||
class Element;
|
class Element;
|
||||||
|
@ -40,7 +38,7 @@ namespace Swift {
|
||||||
public:
|
public:
|
||||||
ServerFromClientSession(
|
ServerFromClientSession(
|
||||||
const std::string& id,
|
const std::string& id,
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> connection,
|
boost::shared_ptr<Connection> connection,
|
||||||
PayloadParserFactoryCollection* payloadParserFactories,
|
PayloadParserFactoryCollection* payloadParserFactories,
|
||||||
PayloadSerializerCollection* payloadSerializers,
|
PayloadSerializerCollection* payloadSerializers,
|
||||||
UserRegistry* userRegistry,
|
UserRegistry* userRegistry,
|
||||||
|
@ -65,9 +63,9 @@ namespace Swift {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ToplevelElement>);
|
void handleElement(boost::shared_ptr<ToplevelElement>);
|
||||||
#else
|
#else
|
||||||
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element>);
|
void handleElement(boost::shared_ptr<Element>);
|
||||||
#endif
|
#endif
|
||||||
void handleStreamStart(const ProtocolHeader& header);
|
void handleStreamStart(const ProtocolHeader& header);
|
||||||
void handleSessionFinished(const boost::optional<SessionError>&);
|
void handleSessionFinished(const boost::optional<SessionError>&);
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
|
|
||||||
#include <Swiften/Elements/Stanza.h>
|
#include <Swiften/Elements/Stanza.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class ServerSession {
|
class ServerSession {
|
||||||
public:
|
public:
|
||||||
|
@ -20,6 +18,6 @@ namespace Swift {
|
||||||
virtual const JID& getJID() const = 0;
|
virtual const JID& getJID() const = 0;
|
||||||
virtual int getPriority() const = 0;
|
virtual int getPriority() const = 0;
|
||||||
|
|
||||||
virtual void sendStanza(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza>) = 0;
|
virtual void sendStanza(boost::shared_ptr<Stanza>) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,41 +21,41 @@ namespace {
|
||||||
|
|
||||||
struct HasJID {
|
struct HasJID {
|
||||||
HasJID(const JID& jid) : jid(jid) {}
|
HasJID(const JID& jid) : jid(jid) {}
|
||||||
bool operator()(const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session) const {
|
bool operator()(const boost::shared_ptr<ServerFromClientSession> session) const {
|
||||||
return session->getRemoteJID().equals(jid, JID::WithResource);
|
return session->getRemoteJID().equals(jid, JID::WithResource);
|
||||||
}
|
}
|
||||||
JID jid;
|
JID jid;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::addSession(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session) {
|
void ServerStanzaChannel::addSession(boost::shared_ptr<ServerFromClientSession> session) {
|
||||||
sessions[session->getRemoteJID().toBare().toString()].push_back(session);
|
sessions[session->getRemoteJID().toBare().toString()].push_back(session);
|
||||||
session->onSessionFinished.connect(boost::bind(&ServerStanzaChannel::handleSessionFinished, this, _1, session));
|
session->onSessionFinished.connect(boost::bind(&ServerStanzaChannel::handleSessionFinished, this, _1, session));
|
||||||
session->onElementReceived.connect(boost::bind(&ServerStanzaChannel::handleElement, this, _1, session));
|
session->onElementReceived.connect(boost::bind(&ServerStanzaChannel::handleElement, this, _1, session));
|
||||||
session->onDataRead.connect(boost::bind(&ServerStanzaChannel::handleDataRead, this, _1, session));
|
session->onDataRead.connect(boost::bind(&ServerStanzaChannel::handleDataRead, this, _1, session));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::removeSession(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session) {
|
void ServerStanzaChannel::removeSession(boost::shared_ptr<ServerFromClientSession> session) {
|
||||||
session->onSessionFinished.disconnect(boost::bind(&ServerStanzaChannel::handleSessionFinished, this, _1, session));
|
session->onSessionFinished.disconnect(boost::bind(&ServerStanzaChannel::handleSessionFinished, this, _1, session));
|
||||||
session->onElementReceived.disconnect(boost::bind(&ServerStanzaChannel::handleElement, this, _1, session));
|
session->onElementReceived.disconnect(boost::bind(&ServerStanzaChannel::handleElement, this, _1, session));
|
||||||
session->onDataRead.disconnect(boost::bind(&ServerStanzaChannel::handleDataRead, this, _1, session));
|
session->onDataRead.disconnect(boost::bind(&ServerStanzaChannel::handleDataRead, this, _1, session));
|
||||||
std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > &lst = sessions[session->getRemoteJID().toBare().toString()];
|
std::list<boost::shared_ptr<ServerFromClientSession> > &lst = sessions[session->getRemoteJID().toBare().toString()];
|
||||||
lst.erase(std::remove(lst.begin(), lst.end(), session), lst.end());
|
lst.erase(std::remove(lst.begin(), lst.end(), session), lst.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::sendIQ(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IQ> iq) {
|
void ServerStanzaChannel::sendIQ(boost::shared_ptr<IQ> iq) {
|
||||||
send(iq);
|
send(iq);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::sendMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Message> message) {
|
void ServerStanzaChannel::sendMessage(boost::shared_ptr<Message> message) {
|
||||||
send(message);
|
send(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::sendPresence(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Presence> presence) {
|
void ServerStanzaChannel::sendPresence(boost::shared_ptr<Presence> presence) {
|
||||||
send(presence);
|
send(presence);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::handleDataRead(const SafeByteArray &data, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> &session) {
|
void ServerStanzaChannel::handleDataRead(const SafeByteArray &data, const boost::shared_ptr<ServerFromClientSession> &session) {
|
||||||
if (safeByteArrayToString(data).find("</stream:stream>") != std::string::npos) {
|
if (safeByteArrayToString(data).find("</stream:stream>") != std::string::npos) {
|
||||||
Swift::Presence::ref presence = Swift::Presence::create();
|
Swift::Presence::ref presence = Swift::Presence::create();
|
||||||
presence->setFrom(session->getRemoteJID());
|
presence->setFrom(session->getRemoteJID());
|
||||||
|
@ -64,16 +64,16 @@ void ServerStanzaChannel::handleDataRead(const SafeByteArray &data, const SWIFTE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
void ServerStanzaChannel::finishSession(const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ToplevelElement> element, bool last) {
|
void ServerStanzaChannel::finishSession(const JID& to, boost::shared_ptr<ToplevelElement> element, bool last) {
|
||||||
#else
|
#else
|
||||||
void ServerStanzaChannel::finishSession(const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, bool last) {
|
void ServerStanzaChannel::finishSession(const JID& to, boost::shared_ptr<Element> element, bool last) {
|
||||||
#endif
|
#endif
|
||||||
std::vector<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > candidateSessions;
|
std::vector<boost::shared_ptr<ServerFromClientSession> > candidateSessions;
|
||||||
for (std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> >::const_iterator i = sessions[to.toBare().toString()].begin(); i != sessions[to.toBare().toString()].end(); ++i) {
|
for (std::list<boost::shared_ptr<ServerFromClientSession> >::const_iterator i = sessions[to.toBare().toString()].begin(); i != sessions[to.toBare().toString()].end(); ++i) {
|
||||||
candidateSessions.push_back(*i);
|
candidateSessions.push_back(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> >::const_iterator i = candidateSessions.begin(); i != candidateSessions.end(); ++i) {
|
for (std::vector<boost::shared_ptr<ServerFromClientSession> >::const_iterator i = candidateSessions.begin(); i != candidateSessions.end(); ++i) {
|
||||||
removeSession(*i);
|
removeSession(*i);
|
||||||
if (element) {
|
if (element) {
|
||||||
(*i)->sendElement(element);
|
(*i)->sendElement(element);
|
||||||
|
@ -98,7 +98,7 @@ std::string ServerStanzaChannel::getNewIQID() {
|
||||||
return idGenerator.generateID();
|
return idGenerator.generateID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza) {
|
void ServerStanzaChannel::send(boost::shared_ptr<Stanza> stanza) {
|
||||||
JID to = stanza->getTo();
|
JID to = stanza->getTo();
|
||||||
assert(to.isValid());
|
assert(to.isValid());
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ void ServerStanzaChannel::send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stan
|
||||||
|
|
||||||
// For a full JID, first try to route to a session with the full JID
|
// For a full JID, first try to route to a session with the full JID
|
||||||
if (!to.isBare()) {
|
if (!to.isBare()) {
|
||||||
std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> >::const_iterator i = std::find_if(sessions[stanza->getTo().toBare().toString()].begin(), sessions[stanza->getTo().toBare().toString()].end(), HasJID(to));
|
std::list<boost::shared_ptr<ServerFromClientSession> >::const_iterator i = std::find_if(sessions[stanza->getTo().toBare().toString()].begin(), sessions[stanza->getTo().toBare().toString()].end(), HasJID(to));
|
||||||
if (i != sessions[stanza->getTo().toBare().toString()].end()) {
|
if (i != sessions[stanza->getTo().toBare().toString()].end()) {
|
||||||
(*i)->sendElement(stanza);
|
(*i)->sendElement(stanza);
|
||||||
return;
|
return;
|
||||||
|
@ -117,8 +117,8 @@ void ServerStanzaChannel::send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stan
|
||||||
|
|
||||||
// Look for candidate sessions
|
// Look for candidate sessions
|
||||||
to = to.toBare();
|
to = to.toBare();
|
||||||
std::vector<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > candidateSessions;
|
std::vector<boost::shared_ptr<ServerFromClientSession> > candidateSessions;
|
||||||
for (std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> >::const_iterator i = sessions[stanza->getTo().toBare().toString()].begin(); i != sessions[stanza->getTo().toBare().toString()].end(); ++i) {
|
for (std::list<boost::shared_ptr<ServerFromClientSession> >::const_iterator i = sessions[stanza->getTo().toBare().toString()].begin(); i != sessions[stanza->getTo().toBare().toString()].end(); ++i) {
|
||||||
if ((*i)->getRemoteJID().equals(to, JID::WithoutResource)) {
|
if ((*i)->getRemoteJID().equals(to, JID::WithoutResource)) {
|
||||||
candidateSessions.push_back(*i);
|
candidateSessions.push_back(*i);
|
||||||
(*i)->sendElement(stanza);
|
(*i)->sendElement(stanza);
|
||||||
|
@ -134,7 +134,7 @@ void ServerStanzaChannel::send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stan
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::handleSessionFinished(const boost::optional<Session::SessionError>&, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>& session) {
|
void ServerStanzaChannel::handleSessionFinished(const boost::optional<Session::SessionError>&, const boost::shared_ptr<ServerFromClientSession>& session) {
|
||||||
removeSession(session);
|
removeSession(session);
|
||||||
|
|
||||||
// if (!session->initiatedFinish()) {
|
// if (!session->initiatedFinish()) {
|
||||||
|
@ -145,8 +145,8 @@ void ServerStanzaChannel::handleSessionFinished(const boost::optional<Session::S
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerStanzaChannel::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>& session) {
|
void ServerStanzaChannel::handleElement(boost::shared_ptr<Element> element, const boost::shared_ptr<ServerFromClientSession>& session) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Stanza>(element);
|
boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element);
|
||||||
if (!stanza) {
|
if (!stanza) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -157,19 +157,19 @@ void ServerStanzaChannel::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Ele
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Message> message = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Message>(stanza);
|
boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(stanza);
|
||||||
if (message) {
|
if (message) {
|
||||||
onMessageReceived(message);
|
onMessageReceived(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Presence> presence = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Presence>(stanza);
|
boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(stanza);
|
||||||
if (presence) {
|
if (presence) {
|
||||||
onPresenceReceived(presence);
|
onPresenceReceived(presence);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IQ> iq = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<IQ>(stanza);
|
boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(stanza);
|
||||||
if (iq) {
|
if (iq) {
|
||||||
onIQReceived(iq);
|
onIQReceived(iq);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -25,16 +25,16 @@ namespace Swift {
|
||||||
ServerStanzaChannel(const JID &selfJID) : StanzaChannel() {
|
ServerStanzaChannel(const JID &selfJID) : StanzaChannel() {
|
||||||
m_jid = selfJID;
|
m_jid = selfJID;
|
||||||
}
|
}
|
||||||
void addSession(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session);
|
void addSession(boost::shared_ptr<ServerFromClientSession> session);
|
||||||
void removeSession(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session);
|
void removeSession(boost::shared_ptr<ServerFromClientSession> session);
|
||||||
|
|
||||||
void sendIQ(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IQ> iq);
|
void sendIQ(boost::shared_ptr<IQ> iq);
|
||||||
void sendMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Message> message);
|
void sendMessage(boost::shared_ptr<Message> message);
|
||||||
void sendPresence(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Presence> presence);
|
void sendPresence(boost::shared_ptr<Presence> presence);
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
void finishSession(const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ToplevelElement> element, bool last = false);
|
void finishSession(const JID& to, boost::shared_ptr<ToplevelElement> element, bool last = false);
|
||||||
#else
|
#else
|
||||||
void finishSession(const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, bool last = false);
|
void finishSession(const JID& to, boost::shared_ptr<Element> element, bool last = false);
|
||||||
#endif
|
#endif
|
||||||
bool getStreamManagementEnabled() const {
|
bool getStreamManagementEnabled() const {
|
||||||
return false;
|
return false;
|
||||||
|
@ -50,17 +50,17 @@ namespace Swift {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string getNewIQID();
|
std::string getNewIQID();
|
||||||
void send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza);
|
void send(boost::shared_ptr<Stanza> stanza);
|
||||||
void handleSessionFinished(const boost::optional<Session::SessionError>&, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> &session);
|
void handleSessionFinished(const boost::optional<Session::SessionError>&, const boost::shared_ptr<ServerFromClientSession> &session);
|
||||||
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> &session);
|
void handleElement(boost::shared_ptr<Element> element, const boost::shared_ptr<ServerFromClientSession> &session);
|
||||||
void handleDataRead(const SafeByteArray &data, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> &session);
|
void handleDataRead(const SafeByteArray &data, const boost::shared_ptr<ServerFromClientSession> &session);
|
||||||
void handleSessionInitialized();
|
void handleSessionInitialized();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JID m_jid;
|
JID m_jid;
|
||||||
IDGenerator idGenerator;
|
IDGenerator idGenerator;
|
||||||
// [JID][resources][ServerFromClientSession]
|
// [JID][resources][ServerFromClientSession]
|
||||||
std::map<std::string, std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > > sessions;
|
std::map<std::string, std::list<boost::shared_ptr<ServerFromClientSession> > > sessions;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace {
|
||||||
ServerStanzaRouter::ServerStanzaRouter() {
|
ServerStanzaRouter::ServerStanzaRouter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerStanzaRouter::routeStanza(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza) {
|
bool ServerStanzaRouter::routeStanza(boost::shared_ptr<Stanza> stanza) {
|
||||||
JID to = stanza->getTo();
|
JID to = stanza->getTo();
|
||||||
assert(to.isValid());
|
assert(to.isValid());
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
#include <Swiften/JID/JID.h>
|
#include <Swiften/JID/JID.h>
|
||||||
#include <Swiften/Elements/Stanza.h>
|
#include <Swiften/Elements/Stanza.h>
|
||||||
|
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class ServerSession;
|
class ServerSession;
|
||||||
|
|
||||||
|
@ -21,7 +19,7 @@ namespace Swift {
|
||||||
public:
|
public:
|
||||||
ServerStanzaRouter();
|
ServerStanzaRouter();
|
||||||
|
|
||||||
bool routeStanza(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza>);
|
bool routeStanza(boost::shared_ptr<Stanza>);
|
||||||
|
|
||||||
void addClientSession(ServerSession*);
|
void addClientSession(ServerSession*);
|
||||||
void removeClientSession(ServerSession*);
|
void removeClientSession(ServerSession*);
|
||||||
|
|
|
@ -45,7 +45,7 @@ Certificate::ref TLSServerLayer::getPeerCertificate() const {
|
||||||
return context->getPeerCertificate();
|
return context->getPeerCertificate();
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> TLSServerLayer::getPeerCertificateVerificationError() const {
|
boost::shared_ptr<CertificateVerificationError> TLSServerLayer::getPeerCertificateVerificationError() const {
|
||||||
return context->getPeerCertificateVerificationError();
|
return context->getPeerCertificateVerificationError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,13 @@
|
||||||
* See Documentation/Licenses/GPLv3.txt for more information.
|
* See Documentation/Licenses/GPLv3.txt for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <boost/signals.hpp>
|
#include "Swiften/Base/boost_bsignals.h"
|
||||||
|
|
||||||
#include "Swiften/Base/SafeByteArray.h"
|
#include "Swiften/Base/SafeByteArray.h"
|
||||||
#include "Swiften/StreamStack/StreamLayer.h"
|
#include "Swiften/StreamStack/StreamLayer.h"
|
||||||
#include "Swiften/TLS/Certificate.h"
|
#include "Swiften/TLS/Certificate.h"
|
||||||
#include <Swiften/TLS/CertificateWithKey.h>
|
#include <Swiften/TLS/CertificateWithKey.h>
|
||||||
#include "Swiften/TLS/CertificateVerificationError.h"
|
#include "Swiften/TLS/CertificateVerificationError.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
class TLSServerContext;
|
class TLSServerContext;
|
||||||
|
@ -27,7 +26,7 @@ namespace Swift {
|
||||||
bool setServerCertificate(CertificateWithKey::ref cert);
|
bool setServerCertificate(CertificateWithKey::ref cert);
|
||||||
|
|
||||||
Certificate::ref getPeerCertificate() const;
|
Certificate::ref getPeerCertificate() const;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
|
boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
|
||||||
|
|
||||||
void writeData(const SafeByteArray& data);
|
void writeData(const SafeByteArray& data);
|
||||||
void handleDataRead(const SafeByteArray& data);
|
void handleDataRead(const SafeByteArray& data);
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* Swift compatibility
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016, Vladimir Matena <vlada.matena@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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 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_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_SHRPTR_NAMESPACE std
|
|
||||||
#define SWIFTEN_SIGNAL_NAMESPACE boost::signals2
|
|
||||||
#define SWIFT_HOSTADDRESS(x) *(Swift::HostAddress::fromString(x))
|
|
||||||
#else
|
|
||||||
#define SWIFTEN_SHRPTR_NAMESPACE boost
|
|
||||||
#define SWIFTEN_SIGNAL_NAMESPACE boost::signals
|
|
||||||
#define SWIFT_HOSTADDRESS(x) Swift::HostAddress(x)
|
|
||||||
#endif
|
|
|
@ -181,7 +181,7 @@ void OpenSSLServerContext::sendPendingDataToApplication() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenSSLServerContext::setServerCertificate(CertificateWithKey::ref certref) {
|
bool OpenSSLServerContext::setServerCertificate(CertificateWithKey::ref certref) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<PKCS12Certificate> certificate = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<PKCS12Certificate>(certref);
|
boost::shared_ptr<PKCS12Certificate> certificate = boost::dynamic_pointer_cast<PKCS12Certificate>(certref);
|
||||||
if (certificate->isNull()) {
|
if (certificate->isNull()) {
|
||||||
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate can't be loaded.");
|
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate can't be loaded.");
|
||||||
return false;
|
return false;
|
||||||
|
@ -190,7 +190,7 @@ bool OpenSSLServerContext::setServerCertificate(CertificateWithKey::ref certref)
|
||||||
// Create a PKCS12 structure
|
// Create a PKCS12 structure
|
||||||
BIO* bio = BIO_new(BIO_s_mem());
|
BIO* bio = BIO_new(BIO_s_mem());
|
||||||
BIO_write(bio, vecptr(certificate->getData()), certificate->getData().size());
|
BIO_write(bio, vecptr(certificate->getData()), certificate->getData().size());
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<PKCS12> pkcs12(d2i_PKCS12_bio(bio, NULL), PKCS12_free);
|
boost::shared_ptr<PKCS12> pkcs12(d2i_PKCS12_bio(bio, NULL), PKCS12_free);
|
||||||
BIO_free(bio);
|
BIO_free(bio);
|
||||||
if (!pkcs12) {
|
if (!pkcs12) {
|
||||||
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate is not in PKCS#12 format.");
|
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate is not in PKCS#12 format.");
|
||||||
|
@ -206,9 +206,9 @@ bool OpenSSLServerContext::setServerCertificate(CertificateWithKey::ref certref)
|
||||||
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate is not in PKCS#12 format.");
|
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate is not in PKCS#12 format.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<X509> cert(certPtr, X509_free);
|
boost::shared_ptr<X509> cert(certPtr, X509_free);
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<EVP_PKEY> privateKey(privateKeyPtr, EVP_PKEY_free);
|
boost::shared_ptr<EVP_PKEY> privateKey(privateKeyPtr, EVP_PKEY_free);
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<STACK_OF(X509)> caCerts(caCertsPtr, freeX509Stack);
|
boost::shared_ptr<STACK_OF(X509)> caCerts(caCertsPtr, freeX509Stack);
|
||||||
|
|
||||||
// Use the key & certificates
|
// Use the key & certificates
|
||||||
if (SSL_CTX_use_certificate(context_, cert.get()) != 1) {
|
if (SSL_CTX_use_certificate(context_, cert.get()) != 1) {
|
||||||
|
@ -223,7 +223,7 @@ bool OpenSSLServerContext::setServerCertificate(CertificateWithKey::ref certref)
|
||||||
}
|
}
|
||||||
|
|
||||||
Certificate::ref OpenSSLServerContext::getPeerCertificate() const {
|
Certificate::ref OpenSSLServerContext::getPeerCertificate() const {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<X509> x509Cert(SSL_get_peer_certificate(handle_), X509_free);
|
boost::shared_ptr<X509> x509Cert(SSL_get_peer_certificate(handle_), X509_free);
|
||||||
if (x509Cert) {
|
if (x509Cert) {
|
||||||
return Certificate::ref(new OpenSSLCertificate(x509Cert));
|
return Certificate::ref(new OpenSSLCertificate(x509Cert));
|
||||||
}
|
}
|
||||||
|
@ -232,13 +232,13 @@ Certificate::ref OpenSSLServerContext::getPeerCertificate() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> OpenSSLServerContext::getPeerCertificateVerificationError() const {
|
boost::shared_ptr<CertificateVerificationError> OpenSSLServerContext::getPeerCertificateVerificationError() const {
|
||||||
int verifyResult = SSL_get_verify_result(handle_);
|
int verifyResult = SSL_get_verify_result(handle_);
|
||||||
if (verifyResult != X509_V_OK) {
|
if (verifyResult != X509_V_OK) {
|
||||||
return SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError>(new CertificateVerificationError(getVerificationErrorTypeForResult(verifyResult)));
|
return boost::shared_ptr<CertificateVerificationError>(new CertificateVerificationError(getVerificationErrorTypeForResult(verifyResult)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError>();
|
return boost::shared_ptr<CertificateVerificationError>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
#include "Swiften/Base/boost_bsignals.h"
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
#include "Swiften/TLS/TLSServerContext.h"
|
#include "Swiften/TLS/TLSServerContext.h"
|
||||||
#include "Swiften/Base/ByteArray.h"
|
#include "Swiften/Base/ByteArray.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
#include <Swiften/TLS/CertificateWithKey.h>
|
#include <Swiften/TLS/CertificateWithKey.h>
|
||||||
|
|
||||||
namespace Swift {
|
namespace Swift {
|
||||||
|
@ -29,7 +29,7 @@ namespace Swift {
|
||||||
void handleDataFromApplication(const SafeByteArray&);
|
void handleDataFromApplication(const SafeByteArray&);
|
||||||
|
|
||||||
Certificate::ref getPeerCertificate() const;
|
Certificate::ref getPeerCertificate() const;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
|
boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
|
||||||
|
|
||||||
virtual ByteArray getFinishMessage() const;
|
virtual ByteArray getFinishMessage() const;
|
||||||
|
|
||||||
|
|
|
@ -520,7 +520,7 @@ void SchannelServerContext::encryptAndSendData(const SafeByteArray& data)
|
||||||
|
|
||||||
bool SchannelServerContext::setServerCertificate(CertificateWithKey::ref certificate)
|
bool SchannelServerContext::setServerCertificate(CertificateWithKey::ref certificate)
|
||||||
{
|
{
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CAPICertificate> capiCertificate = std::dynamic_pointer_cast<CAPICertificate>(certificate);
|
boost::shared_ptr<CAPICertificate> capiCertificate = boost::dynamic_pointer_cast<CAPICertificate>(certificate);
|
||||||
if (!capiCertificate || capiCertificate->isNull()) {
|
if (!capiCertificate || capiCertificate->isNull()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,7 @@ Certificate::ref SchannelServerContext::getPeerCertificate() const
|
||||||
|
|
||||||
CertificateVerificationError::ref SchannelServerContext::getPeerCertificateVerificationError() const
|
CertificateVerificationError::ref SchannelServerContext::getPeerCertificateVerificationError() const
|
||||||
{
|
{
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> pCertError;
|
boost::shared_ptr<CertificateVerificationError> pCertError;
|
||||||
|
|
||||||
if (m_state == Error)
|
if (m_state == Error)
|
||||||
pCertError.reset( new CertificateVerificationError(m_verificationError) );
|
pCertError.reset( new CertificateVerificationError(m_verificationError) );
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Swiften/Base/boost_bsignals.h"
|
||||||
|
|
||||||
#include "Swiften/TLS/TLSServerContext.h"
|
#include "Swiften/TLS/TLSServerContext.h"
|
||||||
#include "Swiften/TLS/Schannel/SchannelUtil.h"
|
#include "Swiften/TLS/Schannel/SchannelUtil.h"
|
||||||
#include <Swiften/TLS/CertificateWithKey.h>
|
#include <Swiften/TLS/CertificateWithKey.h>
|
||||||
#include "Swiften/Base/ByteArray.h"
|
#include "Swiften/Base/ByteArray.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
#define SECURITY_WIN32
|
#define SECURITY_WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
@ -25,7 +26,7 @@ namespace Swift
|
||||||
class SchannelServerContext : public TLSServerContext, boost::noncopyable
|
class SchannelServerContext : public TLSServerContext, boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SchannelServerContext> sp_t;
|
typedef boost::shared_ptr<SchannelServerContext> sp_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SchannelServerContext();
|
SchannelServerContext();
|
||||||
|
|
|
@ -38,16 +38,16 @@ class SecureTransportServerContext : public TLSServerContext {
|
||||||
static std::string stateToString(State state);
|
static std::string stateToString(State state);
|
||||||
void setState(State newState);
|
void setState(State newState);
|
||||||
|
|
||||||
static SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSError> nativeToTLSError(OSStatus error);
|
static boost::shared_ptr<TLSError> nativeToTLSError(OSStatus error);
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> CSSMErrorToVerificationError(OSStatus resultCode);
|
boost::shared_ptr<CertificateVerificationError> CSSMErrorToVerificationError(OSStatus resultCode);
|
||||||
|
|
||||||
void processHandshake();
|
void processHandshake();
|
||||||
void verifyServerCertificate();
|
void verifyServerCertificate();
|
||||||
|
|
||||||
void fatalError(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSError> error, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> certificateError);
|
void fatalError(boost::shared_ptr<TLSError> error, boost::shared_ptr<CertificateVerificationError> certificateError);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SSLContext> sslContext_;
|
boost::shared_ptr<SSLContext> sslContext_;
|
||||||
SafeByteArray readingBuffer_;
|
SafeByteArray readingBuffer_;
|
||||||
State state_;
|
State state_;
|
||||||
CertificateVerificationError::ref verificationError_;
|
CertificateVerificationError::ref verificationError_;
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace {
|
||||||
|
|
||||||
|
|
||||||
CFArrayRef CreateClientCertificateChainAsCFArrayRef(CertificateWithKey::ref key) {
|
CFArrayRef CreateClientCertificateChainAsCFArrayRef(CertificateWithKey::ref key) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<PKCS12Certificate> pkcs12 = std::dynamic_pointer_cast<PKCS12Certificate>(key);
|
boost::shared_ptr<PKCS12Certificate> pkcs12 = boost::dynamic_pointer_cast<PKCS12Certificate>(key);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ CFArrayRef CreateClientCertificateChainAsCFArrayRef(CertificateWithKey::ref key)
|
||||||
}
|
}
|
||||||
|
|
||||||
SecureTransportContext::SecureTransportServerContext(bool checkCertificateRevocation) : state_(None), checkCertificateRevocation_(checkCertificateRevocation) {
|
SecureTransportContext::SecureTransportServerContext(bool checkCertificateRevocation) : state_(None), checkCertificateRevocation_(checkCertificateRevocation) {
|
||||||
sslContext_ = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SSLContext>(SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType), CFRelease);
|
sslContext_ = boost::shared_ptr<SSLContext>(SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType), CFRelease);
|
||||||
|
|
||||||
OSStatus error = noErr;
|
OSStatus error = noErr;
|
||||||
// set IO callbacks
|
// set IO callbacks
|
||||||
|
@ -163,7 +163,7 @@ void SecureTransportServerContext::connect() {
|
||||||
if (clientCertificate_) {
|
if (clientCertificate_) {
|
||||||
CFArrayRef certs = CreateClientCertificateChainAsCFArrayRef(clientCertificate_);
|
CFArrayRef certs = CreateClientCertificateChainAsCFArrayRef(clientCertificate_);
|
||||||
if (certs) {
|
if (certs) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CFArray> certRefs(certs, CFRelease);
|
boost::shared_ptr<CFArray> certRefs(certs, CFRelease);
|
||||||
OSStatus result = SSLSetCertificate(sslContext_.get(), certRefs.get());
|
OSStatus result = SSLSetCertificate(sslContext_.get(), certRefs.get());
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
SWIFT_LOG(error) << "SSLSetCertificate failed with error " << result << "." << std::endl;
|
SWIFT_LOG(error) << "SSLSetCertificate failed with error " << result << "." << std::endl;
|
||||||
|
@ -191,7 +191,7 @@ void SecureTransportServerContext::processHandshake() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SWIFT_LOG(debug) << "Error returned from SSLHandshake call is " << error << "." << std::endl;
|
SWIFT_LOG(debug) << "Error returned from SSLHandshake call is " << error << "." << std::endl;
|
||||||
fatalError(nativeToTLSError(error), SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>());
|
fatalError(nativeToTLSError(error), boost::make_shared<CertificateVerificationError>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,15 +203,15 @@ void SecureTransportServerContext::verifyServerCertificate() {
|
||||||
SecTrustRef trust = NULL;
|
SecTrustRef trust = NULL;
|
||||||
OSStatus error = SSLCopyPeerTrust(sslContext_.get(), &trust);
|
OSStatus error = SSLCopyPeerTrust(sslContext_.get(), &trust);
|
||||||
if (error != noErr) {
|
if (error != noErr) {
|
||||||
fatalError(SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>(), SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>());
|
fatalError(boost::make_shared<TLSError>(), boost::make_shared<CertificateVerificationError>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SecTrust> trustRef = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SecTrust>(trust, CFRelease);
|
boost::shared_ptr<SecTrust> trustRef = boost::shared_ptr<SecTrust>(trust, CFRelease);
|
||||||
|
|
||||||
if (checkCertificateRevocation_) {
|
if (checkCertificateRevocation_) {
|
||||||
error = SecTrustSetOptions(trust, kSecTrustOptionRequireRevPerCert | kSecTrustOptionFetchIssuerFromNet);
|
error = SecTrustSetOptions(trust, kSecTrustOptionRequireRevPerCert | kSecTrustOptionFetchIssuerFromNet);
|
||||||
if (error != noErr) {
|
if (error != noErr) {
|
||||||
fatalError(SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>(), SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>());
|
fatalError(boost::make_shared<TLSError>(), boost::make_shared<CertificateVerificationError>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ void SecureTransportServerContext::verifyServerCertificate() {
|
||||||
SecTrustResultType trustResult;
|
SecTrustResultType trustResult;
|
||||||
error = SecTrustEvaluate(trust, &trustResult);
|
error = SecTrustEvaluate(trust, &trustResult);
|
||||||
if (error != errSecSuccess) {
|
if (error != errSecSuccess) {
|
||||||
fatalError(SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>(), SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>());
|
fatalError(boost::make_shared<TLSError>(), boost::make_shared<CertificateVerificationError>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ void SecureTransportServerContext::verifyServerCertificate() {
|
||||||
CSSM_TP_APPLE_EVIDENCE_INFO* statusChain;
|
CSSM_TP_APPLE_EVIDENCE_INFO* statusChain;
|
||||||
error = SecTrustGetResult(trustRef.get(), &trustResult, &certChain, &statusChain);
|
error = SecTrustGetResult(trustRef.get(), &trustResult, &certChain, &statusChain);
|
||||||
if (error == errSecSuccess) {
|
if (error == errSecSuccess) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CFArray> certChainRef = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CFArray>(certChain, CFRelease);
|
boost::shared_ptr<CFArray> certChainRef = boost::shared_ptr<CFArray>(certChain, CFRelease);
|
||||||
for (CFIndex index = 0; index < CFArrayGetCount(certChainRef.get()); index++) {
|
for (CFIndex index = 0; index < CFArrayGetCount(certChainRef.get()); index++) {
|
||||||
for (CFIndex n = 0; n < statusChain[index].NumStatusCodes; n++) {
|
for (CFIndex n = 0; n < statusChain[index].NumStatusCodes; n++) {
|
||||||
// Even though Secure Transport reported CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK on the whole certificate
|
// Even though Secure Transport reported CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK on the whole certificate
|
||||||
|
@ -259,11 +259,11 @@ void SecureTransportServerContext::verifyServerCertificate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
verificationError_ = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
|
verificationError_ = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kSecTrustResultOtherError:
|
case kSecTrustResultOtherError:
|
||||||
verificationError_ = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
|
verificationError_ = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SWIFT_LOG(warning) << "Unhandled trust result " << trustResult << "." << std::endl;
|
SWIFT_LOG(warning) << "Unhandled trust result " << trustResult << "." << std::endl;
|
||||||
|
@ -274,7 +274,7 @@ void SecureTransportServerContext::verifyServerCertificate() {
|
||||||
setState(Error);
|
setState(Error);
|
||||||
SSLClose(sslContext_.get());
|
SSLClose(sslContext_.get());
|
||||||
sslContext_.reset();
|
sslContext_.reset();
|
||||||
onError(SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>());
|
onError(boost::make_shared<TLSError>());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// proceed with handshake
|
// proceed with handshake
|
||||||
|
@ -326,7 +326,7 @@ void SecureTransportServerContext::handleDataFromNetwork(const SafeByteArray& da
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SWIFT_LOG(error) << "SSLRead failed with error " << error << ", read bytes: " << bytesRead << "." << std::endl;
|
SWIFT_LOG(error) << "SSLRead failed with error " << error << ", read bytes: " << bytesRead << "." << std::endl;
|
||||||
fatalError(SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>(), SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>());
|
fatalError(boost::make_shared<TLSError>(), boost::make_shared<CertificateVerificationError>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ void SecureTransportServerContext::handleDataFromApplication(const SafeByteArray
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
SWIFT_LOG(warning) << "SSLWrite returned error code: " << error << ", processed bytes: " << processedBytes << std::endl;
|
SWIFT_LOG(warning) << "SSLWrite returned error code: " << error << ", processed bytes: " << processedBytes << std::endl;
|
||||||
fatalError(SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>(), SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError>());
|
fatalError(boost::make_shared<TLSError>(), boost::shared_ptr<CertificateVerificationError>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,18 +367,18 @@ std::vector<Certificate::ref> SecureTransportServerContext::getPeerCertificateCh
|
||||||
|
|
||||||
if (sslContext_) {
|
if (sslContext_) {
|
||||||
typedef boost::remove_pointer<SecTrustRef>::type SecTrust;
|
typedef boost::remove_pointer<SecTrustRef>::type SecTrust;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SecTrust> securityTrust;
|
boost::shared_ptr<SecTrust> securityTrust;
|
||||||
|
|
||||||
SecTrustRef secTrust = NULL;;
|
SecTrustRef secTrust = NULL;;
|
||||||
OSStatus error = SSLCopyPeerTrust(sslContext_.get(), &secTrust);
|
OSStatus error = SSLCopyPeerTrust(sslContext_.get(), &secTrust);
|
||||||
if (error == noErr) {
|
if (error == noErr) {
|
||||||
securityTrust = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SecTrust>(secTrust, CFRelease);
|
securityTrust = boost::shared_ptr<SecTrust>(secTrust, CFRelease);
|
||||||
|
|
||||||
CFIndex chainSize = SecTrustGetCertificateCount(securityTrust.get());
|
CFIndex chainSize = SecTrustGetCertificateCount(securityTrust.get());
|
||||||
for (CFIndex n = 0; n < chainSize; n++) {
|
for (CFIndex n = 0; n < chainSize; n++) {
|
||||||
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(securityTrust.get(), n);
|
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(securityTrust.get(), n);
|
||||||
if (certificate) {
|
if (certificate) {
|
||||||
peerCertificateChain.push_back(SWIFTEN_SHRPTR_NAMESPACE::make_shared<SecureTransportCertificate>(certificate));
|
peerCertificateChain.push_back(boost::make_shared<SecureTransportCertificate>(certificate));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,30 +436,30 @@ OSStatus SecureTransportServerContext::SSLSocketWriteCallback(SSLConnectionRef c
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSError> SecureTransportServerContext::nativeToTLSError(OSStatus /* error */) {
|
boost::shared_ptr<TLSError> SecureTransportServerContext::nativeToTLSError(OSStatus /* error */) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSError> swiftenError;
|
boost::shared_ptr<TLSError> swiftenError;
|
||||||
swiftenError = SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>();
|
swiftenError = boost::make_shared<TLSError>();
|
||||||
return swiftenError;
|
return swiftenError;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> SecureTransportServerContext::CSSMErrorToVerificationError(OSStatus resultCode) {
|
boost::shared_ptr<CertificateVerificationError> SecureTransportServerContext::CSSMErrorToVerificationError(OSStatus resultCode) {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> error;
|
boost::shared_ptr<CertificateVerificationError> error;
|
||||||
switch(resultCode) {
|
switch(resultCode) {
|
||||||
case CSSMERR_TP_NOT_TRUSTED:
|
case CSSMERR_TP_NOT_TRUSTED:
|
||||||
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_NOT_TRUSTED" << std::endl;
|
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_NOT_TRUSTED" << std::endl;
|
||||||
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::Untrusted);
|
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::Untrusted);
|
||||||
break;
|
break;
|
||||||
case CSSMERR_TP_CERT_NOT_VALID_YET:
|
case CSSMERR_TP_CERT_NOT_VALID_YET:
|
||||||
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_NOT_VALID_YET" << std::endl;
|
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_NOT_VALID_YET" << std::endl;
|
||||||
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::NotYetValid);
|
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::NotYetValid);
|
||||||
break;
|
break;
|
||||||
case CSSMERR_TP_CERT_EXPIRED:
|
case CSSMERR_TP_CERT_EXPIRED:
|
||||||
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_EXPIRED" << std::endl;
|
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_EXPIRED" << std::endl;
|
||||||
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::Expired);
|
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::Expired);
|
||||||
break;
|
break;
|
||||||
case CSSMERR_TP_CERT_REVOKED:
|
case CSSMERR_TP_CERT_REVOKED:
|
||||||
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_REVOKED" << std::endl;
|
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_CERT_REVOKED" << std::endl;
|
||||||
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::Revoked);
|
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::Revoked);
|
||||||
break;
|
break;
|
||||||
case CSSMERR_TP_VERIFY_ACTION_FAILED:
|
case CSSMERR_TP_VERIFY_ACTION_FAILED:
|
||||||
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_VERIFY_ACTION_FAILED" << std::endl;
|
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_TP_VERIFY_ACTION_FAILED" << std::endl;
|
||||||
|
@ -467,28 +467,28 @@ SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> SecureTranspo
|
||||||
case CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK:
|
case CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK:
|
||||||
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK" << std::endl;
|
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK" << std::endl;
|
||||||
if (checkCertificateRevocation_) {
|
if (checkCertificateRevocation_) {
|
||||||
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed);
|
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CSSMERR_APPLETP_OCSP_UNAVAILABLE:
|
case CSSMERR_APPLETP_OCSP_UNAVAILABLE:
|
||||||
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_OCSP_UNAVAILABLE" << std::endl;
|
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_OCSP_UNAVAILABLE" << std::endl;
|
||||||
if (checkCertificateRevocation_) {
|
if (checkCertificateRevocation_) {
|
||||||
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed);
|
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE:
|
case CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE:
|
||||||
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE" << std::endl;
|
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE" << std::endl;
|
||||||
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::InvalidPurpose);
|
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::InvalidPurpose);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SWIFT_LOG(warning) << "unhandled CSSM error: " << resultCode << ", CSSM_TP_BASE_TP_ERROR: " << CSSM_TP_BASE_TP_ERROR << std::endl;
|
SWIFT_LOG(warning) << "unhandled CSSM error: " << resultCode << ", CSSM_TP_BASE_TP_ERROR: " << CSSM_TP_BASE_TP_ERROR << std::endl;
|
||||||
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
|
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SecureTransportServerContext::fatalError(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSError> error, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> certificateError) {
|
void SecureTransportServerContext::fatalError(boost::shared_ptr<TLSError> error, boost::shared_ptr<CertificateVerificationError> certificateError) {
|
||||||
setState(Error);
|
setState(Error);
|
||||||
if (sslContext_) {
|
if (sslContext_) {
|
||||||
SSLClose(sslContext_.get());
|
SSLClose(sslContext_.get());
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Swiften/Base/boost_bsignals.h"
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <boost/signals.hpp>
|
|
||||||
|
|
||||||
#include "Swiften/Base/SafeByteArray.h"
|
#include "Swiften/Base/SafeByteArray.h"
|
||||||
#include "Swiften/TLS/Certificate.h"
|
#include "Swiften/TLS/Certificate.h"
|
||||||
|
|
|
@ -30,11 +30,11 @@ namespace boost { namespace dll {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <class T>
|
template <class T>
|
||||||
class refc_function {
|
class refc_function {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<shared_library> lib_;
|
boost::shared_ptr<shared_library> lib_;
|
||||||
T* func_ptr_;
|
T* func_ptr_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
refc_function(const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<shared_library>& lib, T* func_ptr) BOOST_NOEXCEPT
|
refc_function(const boost::shared_ptr<shared_library>& lib, T* func_ptr) BOOST_NOEXCEPT
|
||||||
: lib_(lib)
|
: lib_(lib)
|
||||||
, func_ptr_(func_ptr)
|
, func_ptr_(func_ptr)
|
||||||
{}
|
{}
|
||||||
|
@ -57,8 +57,8 @@ namespace detail {
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct import_type<T, typename boost::enable_if<boost::is_object<T> >::type> {
|
struct import_type<T, typename boost::enable_if<boost::is_object<T> >::type> {
|
||||||
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<T> base_type;
|
typedef boost::shared_ptr<T> base_type;
|
||||||
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<T> type;
|
typedef boost::shared_ptr<T> type;
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ namespace detail {
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns boost::function<T> or SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<T> that holds an imported function or variable
|
* Returns boost::function<T> or boost::shared_ptr<T> that holds an imported function or variable
|
||||||
* from the loaded library and refcounts usage
|
* from the loaded library and refcounts usage
|
||||||
* of the loaded shared library, so that it won't get unload until all copies of return value
|
* of the loaded shared library, so that it won't get unload until all copies of return value
|
||||||
* are not destroyed.
|
* are not destroyed.
|
||||||
|
@ -82,7 +82,7 @@ namespace detail {
|
||||||
* \b Examples:
|
* \b Examples:
|
||||||
* \code
|
* \code
|
||||||
* boost::function<int(int)> f = import<int(int)>(
|
* boost::function<int(int)> f = import<int(int)>(
|
||||||
* SWIFTEN_SHRPTR_NAMESPACE::make_shared<shared_library>("test_lib.so"),
|
* boost::make_shared<shared_library>("test_lib.so"),
|
||||||
* "integer_func_name"
|
* "integer_func_name"
|
||||||
* );
|
* );
|
||||||
* \endcode
|
* \endcode
|
||||||
|
@ -92,7 +92,7 @@ namespace detail {
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<int> i = import<int>("test_lib.so", "integer_name");
|
* boost::shared_ptr<int> i = import<int>("test_lib.so", "integer_name");
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \b Template \b parameter \b T: Type of the symbol that we are going to import. Must be explicitly specified.
|
* \b Template \b parameter \b T: Type of the symbol that we are going to import. Must be explicitly specified.
|
||||||
|
@ -101,7 +101,7 @@ namespace detail {
|
||||||
* \param name Null-terminated C or C++ mangled name of the function to import. Can handle std::string, char*, const char*.
|
* \param name Null-terminated C or C++ mangled name of the function to import. Can handle std::string, char*, const char*.
|
||||||
* \param mode An mode that will be used on library load.
|
* \param mode An mode that will be used on library load.
|
||||||
*
|
*
|
||||||
* \return boost::function<T> if T is a function type, or SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<T> if T is an object type.
|
* \return boost::function<T> if T is a function type, or boost::shared_ptr<T> if T is an object type.
|
||||||
*
|
*
|
||||||
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
|
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
|
||||||
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
|
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
|
||||||
|
@ -116,28 +116,28 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const st
|
||||||
load_mode::type mode = load_mode::default_mode)
|
load_mode::type mode = load_mode::default_mode)
|
||||||
{
|
{
|
||||||
return boost::dll::import<T>(
|
return boost::dll::import<T>(
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::make_shared<boost::dll::shared_library>(lib, mode),
|
boost::make_shared<boost::dll::shared_library>(lib, mode),
|
||||||
name.c_str()
|
name.c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
|
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
|
||||||
template <class T>
|
template <class T>
|
||||||
BOOST_DLL_IMPORT_RESULT_TYPE import(const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<shared_library>& lib, const char* name) {
|
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::shared_ptr<shared_library>& lib, const char* name) {
|
||||||
typedef typename boost::dll::detail::import_type<T>::base_type type;
|
typedef typename boost::dll::detail::import_type<T>::base_type type;
|
||||||
return type(lib, &lib->get<T>(name));
|
return type(lib, &lib->get<T>(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
|
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
|
||||||
template <class T>
|
template <class T>
|
||||||
BOOST_DLL_IMPORT_RESULT_TYPE import(const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<shared_library>& lib, const std::string& name) {
|
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::shared_ptr<shared_library>& lib, const std::string& name) {
|
||||||
return boost::dll::import<T>(lib, name.c_str());
|
return boost::dll::import<T>(lib, name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const char* name, load_mode::type mode) {
|
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const char* name, load_mode::type mode) {
|
||||||
return boost::dll::import<T>(
|
return boost::dll::import<T>(
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::make_shared<boost::dll::shared_library>(lib, mode),
|
boost::make_shared<boost::dll::shared_library>(lib, mode),
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const ch
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns boost::function<T> or SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<T> that holds an imported function or variable
|
* Returns boost::function<T> or boost::shared_ptr<T> that holds an imported function or variable
|
||||||
* from the loaded library and refcounts usage
|
* from the loaded library and refcounts usage
|
||||||
* of the loaded shared library, so that it won't get unload until all copies of return value
|
* of the loaded shared library, so that it won't get unload until all copies of return value
|
||||||
* are not destroyed.
|
* are not destroyed.
|
||||||
|
@ -159,7 +159,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const ch
|
||||||
* \b Examples:
|
* \b Examples:
|
||||||
* \code
|
* \code
|
||||||
* boost::function<int(int)> f = import_alias<int(int)>(
|
* boost::function<int(int)> f = import_alias<int(int)>(
|
||||||
* SWIFTEN_SHRPTR_NAMESPACE::make_shared<shared_library>("test_lib.so"),
|
* boost::make_shared<shared_library>("test_lib.so"),
|
||||||
* "integer_func_alias_name"
|
* "integer_func_alias_name"
|
||||||
* );
|
* );
|
||||||
* \endcode
|
* \endcode
|
||||||
|
@ -169,7 +169,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const ch
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
* SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<int> i = import_alias<int>("test_lib.so", "integer_alias_name");
|
* boost::shared_ptr<int> i = import_alias<int>("test_lib.so", "integer_alias_name");
|
||||||
* \endcode
|
* \endcode
|
||||||
*
|
*
|
||||||
* \b Template \b parameter \b T: Type of the symbol alias that we are going to import. Must be explicitly specified.
|
* \b Template \b parameter \b T: Type of the symbol alias that we are going to import. Must be explicitly specified.
|
||||||
|
@ -178,7 +178,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const ch
|
||||||
* \param name Null-terminated C or C++ mangled name of the function or variable to import. Can handle std::string, char*, const char*.
|
* \param name Null-terminated C or C++ mangled name of the function or variable to import. Can handle std::string, char*, const char*.
|
||||||
* \param mode An mode that will be used on library load.
|
* \param mode An mode that will be used on library load.
|
||||||
*
|
*
|
||||||
* \return boost::function<T> if T is a function type, or SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<T> if T is an object type.
|
* \return boost::function<T> if T is a function type, or boost::shared_ptr<T> if T is an object type.
|
||||||
*
|
*
|
||||||
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
|
* \throw boost::system::system_error if symbol does not exist or if the DLL/DSO was not loaded.
|
||||||
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
|
* Overload that accepts path also throws std::bad_alloc in case of insufficient memory.
|
||||||
|
@ -193,20 +193,20 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::filesystem::path& lib, co
|
||||||
load_mode::type mode = load_mode::default_mode)
|
load_mode::type mode = load_mode::default_mode)
|
||||||
{
|
{
|
||||||
return boost::dll::import_alias<T>(
|
return boost::dll::import_alias<T>(
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::make_shared<boost::dll::shared_library>(lib, mode),
|
boost::make_shared<boost::dll::shared_library>(lib, mode),
|
||||||
name.c_str()
|
name.c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
|
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
|
||||||
template <class T>
|
template <class T>
|
||||||
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<shared_library>& lib, const std::string& name) {
|
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::shared_ptr<shared_library>& lib, const std::string& name) {
|
||||||
return boost::dll::import_alias<T>(lib, name.c_str());
|
return boost::dll::import_alias<T>(lib, name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
|
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
|
||||||
template <class T>
|
template <class T>
|
||||||
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<shared_library>& lib, const char* name) {
|
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::shared_ptr<shared_library>& lib, const char* name) {
|
||||||
typedef typename boost::dll::detail::import_type<T>::base_type type;
|
typedef typename boost::dll::detail::import_type<T>::base_type type;
|
||||||
return type(lib, lib->get<T*>(name));
|
return type(lib, lib->get<T*>(name));
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const SWIFTEN_SHRPTR_NAMESPACE::shared
|
||||||
template <class T>
|
template <class T>
|
||||||
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode) {
|
BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode) {
|
||||||
return boost::dll::import_alias<T>(
|
return boost::dll::import_alias<T>(
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::make_shared<boost::dll::shared_library>(lib, mode),
|
boost::make_shared<boost::dll::shared_library>(lib, mode),
|
||||||
name
|
name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,6 @@
|
||||||
/// \brief Contains the boost::dll::shared_library class, core class for all the
|
/// \brief Contains the boost::dll::shared_library class, core class for all the
|
||||||
/// DLL/DSO operations.
|
/// DLL/DSO operations.
|
||||||
|
|
||||||
// Walkaround for compatibility with boost 1.54
|
|
||||||
#include <boost/move/move.hpp>
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/predef/os.h>
|
#include <boost/predef/os.h>
|
||||||
#include <boost/utility/explicit_operator_bool.hpp>
|
#include <boost/utility/explicit_operator_bool.hpp>
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* Walkaroung for Boost, Qt namespace clash
|
|
||||||
*
|
|
||||||
* Taken from boost documantation:
|
|
||||||
* http://www.boost.org/doc/libs/1_55_0/doc/html/signals/s04.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef SIGNALSLIB_HPP_INCLUDED
|
|
||||||
#define SIGNALSLIB_HPP_INCLUDED
|
|
||||||
|
|
||||||
#if defined(signals) && defined(QOBJECTDEFS_H) && \
|
|
||||||
!defined(QT_MOC_CPP)
|
|
||||||
# undef signals
|
|
||||||
# define signals signals
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/signal.hpp>
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
namespace signalslib = signals;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(signals) && defined(QOBJECTDEFS_H) && \
|
|
||||||
!defined(QT_MOC_CPP)
|
|
||||||
# undef signals
|
|
||||||
// Restore the macro definition of "signals", as it was
|
|
||||||
// defined by Qt's <qobjectdefs.h>.
|
|
||||||
# define signals protected
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ class StorageBackend;
|
||||||
class UserManager;
|
class UserManager;
|
||||||
class NetworkPluginServer;
|
class NetworkPluginServer;
|
||||||
class UserRegistration;
|
class UserRegistration;
|
||||||
class AdminInterfaceCommand;
|
|
||||||
|
|
||||||
class AdminInterface {
|
class AdminInterface {
|
||||||
public:
|
public:
|
||||||
|
@ -42,18 +41,15 @@ class AdminInterface {
|
||||||
|
|
||||||
void handleQuery(Swift::Message::ref message);
|
void handleQuery(Swift::Message::ref message);
|
||||||
|
|
||||||
void addCommand(AdminInterfaceCommand *command);
|
|
||||||
|
|
||||||
void handleMessageReceived(Swift::Message::ref message);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void handleMessageReceived(Swift::Message::ref message);
|
||||||
|
|
||||||
Component *m_component;
|
Component *m_component;
|
||||||
StorageBackend *m_storageBackend;
|
StorageBackend *m_storageBackend;
|
||||||
UserManager *m_userManager;
|
UserManager *m_userManager;
|
||||||
NetworkPluginServer *m_server;
|
NetworkPluginServer *m_server;
|
||||||
UserRegistration *m_userRegistration;
|
UserRegistration *m_userRegistration;
|
||||||
std::map<std::string, AdminInterfaceCommand *> m_commands;
|
time_t m_start;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,135 +0,0 @@
|
||||||
/**
|
|
||||||
* libtransport -- C++ library for easy XMPP Transports development
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016, Jan Kaluza <hanzz.k@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* 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 <string>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include "Swiften/Elements/Message.h"
|
|
||||||
#include "transport/StorageBackend.h"
|
|
||||||
|
|
||||||
namespace Transport {
|
|
||||||
|
|
||||||
class User;
|
|
||||||
|
|
||||||
class AdminInterfaceCommand {
|
|
||||||
public:
|
|
||||||
typedef enum {
|
|
||||||
GlobalContext,
|
|
||||||
UserContext
|
|
||||||
} Context;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
None = 0,
|
|
||||||
Get = 1,
|
|
||||||
Set = 2,
|
|
||||||
Execute = 4
|
|
||||||
} Actions;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
AdminMode,
|
|
||||||
UserMode
|
|
||||||
} AccessMode;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
General,
|
|
||||||
Users,
|
|
||||||
Messages,
|
|
||||||
Frontend,
|
|
||||||
Backends,
|
|
||||||
Memory
|
|
||||||
} Category;
|
|
||||||
|
|
||||||
class Arg {
|
|
||||||
public:
|
|
||||||
Arg(const std::string &_name, const std::string &_label, const std::string &_type, const std::string &_example) :
|
|
||||||
name(_name), label(_label), type(_type), example(_example) {}
|
|
||||||
~Arg() {}
|
|
||||||
|
|
||||||
std::string name;
|
|
||||||
std::string label;
|
|
||||||
std::string type;
|
|
||||||
std::string example;
|
|
||||||
};
|
|
||||||
|
|
||||||
AdminInterfaceCommand(const std::string &name, Category category, Context context, AccessMode accessMode, Actions actions, const std::string &label = "");
|
|
||||||
|
|
||||||
virtual ~AdminInterfaceCommand() { }
|
|
||||||
|
|
||||||
void setDescription(const std::string &desc) {
|
|
||||||
m_desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &getDescription() {
|
|
||||||
return m_desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &getName() {
|
|
||||||
return m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
Actions getActions() {
|
|
||||||
return m_actions;
|
|
||||||
}
|
|
||||||
|
|
||||||
Category getCategory() {
|
|
||||||
return m_category;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string getCategoryName(Category category);
|
|
||||||
|
|
||||||
Context getContext() {
|
|
||||||
return m_context;
|
|
||||||
}
|
|
||||||
|
|
||||||
AccessMode getAccessMode() {
|
|
||||||
return m_accessMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addArg(const std::string &name, const std::string &label, const std::string &type = "string", const std::string &example = "") {
|
|
||||||
Arg arg(name, label, type, example);
|
|
||||||
m_args.push_back(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::list<Arg> &getArgs() {
|
|
||||||
return m_args;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &getLabel() {
|
|
||||||
return m_label;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::string handleSetRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
|
|
||||||
virtual std::string handleGetRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
|
|
||||||
virtual std::string handleExecuteRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_name;
|
|
||||||
Category m_category;
|
|
||||||
Context m_context;
|
|
||||||
AccessMode m_accessMode;
|
|
||||||
Actions m_actions;
|
|
||||||
std::string m_desc;
|
|
||||||
std::list<Arg> m_args;
|
|
||||||
std::string m_label;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/assign.hpp>
|
#include <boost/assign.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/signalslib.hpp>
|
#include <boost/signal.hpp>
|
||||||
|
|
||||||
namespace Transport {
|
namespace Transport {
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "Swiften/Elements/Message.h"
|
#include "Swiften/Elements/Message.h"
|
||||||
#include "Swiften/Elements/Presence.h"
|
#include "Swiften/Elements/Presence.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Transport {
|
namespace Transport {
|
||||||
|
|
||||||
|
@ -64,9 +63,9 @@ class Conversation {
|
||||||
|
|
||||||
/// \param message Message received from legacy network.
|
/// \param message Message received from legacy network.
|
||||||
/// \param nickname For MUC conversation this is nickname of room participant who sent this message.
|
/// \param nickname For MUC conversation this is nickname of room participant who sent this message.
|
||||||
void handleMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &message, const std::string &nickname = "");
|
void handleMessage(boost::shared_ptr<Swift::Message> &message, const std::string &nickname = "");
|
||||||
|
|
||||||
void handleRawMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &message);
|
void handleRawMessage(boost::shared_ptr<Swift::Message> &message);
|
||||||
void handleRawPresence(Swift::Presence::ref presence);
|
void handleRawPresence(Swift::Presence::ref presence);
|
||||||
|
|
||||||
/// Handles participant change in MUC.
|
/// Handles participant change in MUC.
|
||||||
|
@ -108,7 +107,7 @@ class Conversation {
|
||||||
/// Sends message to Legacy network.
|
/// Sends message to Legacy network.
|
||||||
|
|
||||||
/// \param message Message.
|
/// \param message Message.
|
||||||
virtual void sendMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &message) = 0;
|
virtual void sendMessage(boost::shared_ptr<Swift::Message> &message) = 0;
|
||||||
|
|
||||||
/// Returns ConversationManager associated with this Conversation.
|
/// Returns ConversationManager associated with this Conversation.
|
||||||
|
|
||||||
|
@ -148,7 +147,7 @@ class Conversation {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Swift::Presence::ref generatePresence(const std::string &nick, int flag, int status, const std::string &statusMessage, const std::string &newname = "", const std::string &iconhash = "");
|
Swift::Presence::ref generatePresence(const std::string &nick, int flag, int status, const std::string &statusMessage, const std::string &newname = "", const std::string &iconhash = "");
|
||||||
void cacheMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &message);
|
void cacheMessage(boost::shared_ptr<Swift::Message> &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConversationManager *m_conversationManager;
|
ConversationManager *m_conversationManager;
|
||||||
|
@ -168,8 +167,8 @@ class Conversation {
|
||||||
// connected to single room, we store all those things 10 times.
|
// connected to single room, we store all those things 10 times.
|
||||||
// It would be also great to store last 100 messages per room
|
// It would be also great to store last 100 messages per room
|
||||||
// every time, so we can get history messages for IRC for example.
|
// every time, so we can get history messages for IRC for example.
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> m_subject;
|
boost::shared_ptr<Swift::Message> m_subject;
|
||||||
std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> > m_cachedMessages;
|
std::list<boost::shared_ptr<Swift::Message> > m_cachedMessages;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Swift::Presence::ref presence;
|
Swift::Presence::ref presence;
|
||||||
|
|
|
@ -49,16 +49,16 @@ class Buddy;
|
||||||
class FileTransferManager {
|
class FileTransferManager {
|
||||||
public:
|
public:
|
||||||
typedef struct Transfer {
|
typedef struct Transfer {
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::OutgoingFileTransfer> ft;
|
boost::shared_ptr<Swift::OutgoingFileTransfer> ft;
|
||||||
Swift::JID from;
|
Swift::JID from;
|
||||||
Swift::JID to;
|
Swift::JID to;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::ReadBytestream> readByteStream;
|
boost::shared_ptr<Swift::ReadBytestream> readByteStream;
|
||||||
} Transfer;
|
} Transfer;
|
||||||
|
|
||||||
FileTransferManager(Component *component, UserManager *userManager);
|
FileTransferManager(Component *component, UserManager *userManager);
|
||||||
virtual ~FileTransferManager();
|
virtual ~FileTransferManager();
|
||||||
|
|
||||||
FileTransferManager::Transfer sendFile(User *user, Buddy *buddy, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::ReadBytestream> byteStream, const Swift::StreamInitiationFileInfo &info);
|
FileTransferManager::Transfer sendFile(User *user, Buddy *buddy, boost::shared_ptr<Swift::ReadBytestream> byteStream, const Swift::StreamInitiationFileInfo &info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Component *m_component;
|
Component *m_component;
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "Swiften/Elements/IQ.h"
|
#include "Swiften/Elements/IQ.h"
|
||||||
#include "Swiften/Elements/DiscoInfo.h"
|
#include "Swiften/Elements/DiscoInfo.h"
|
||||||
#include "Swiften/Elements/Presence.h"
|
#include "Swiften/Elements/Presence.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
#include <boost/signal.hpp>
|
#include <boost/signal.hpp>
|
||||||
|
|
||||||
|
@ -75,11 +74,11 @@ class Frontend {
|
||||||
|
|
||||||
virtual void sendRosterRequest(Swift::RosterPayload::ref, Swift::JID to) = 0;
|
virtual void sendRosterRequest(Swift::RosterPayload::ref, Swift::JID to) = 0;
|
||||||
|
|
||||||
virtual void sendMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> message) = 0;
|
virtual void sendMessage(boost::shared_ptr<Swift::Message> message) = 0;
|
||||||
|
|
||||||
virtual void sendIQ(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ>) = 0;
|
virtual void sendIQ(boost::shared_ptr<Swift::IQ>) = 0;
|
||||||
|
|
||||||
virtual SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> sendCapabilitiesRequest(Swift::JID to) = 0;
|
virtual boost::shared_ptr<Swift::DiscoInfo> sendCapabilitiesRequest(Swift::JID to) = 0;
|
||||||
|
|
||||||
virtual void reconnectUser(const std::string &user) = 0;
|
virtual void reconnectUser(const std::string &user) = 0;
|
||||||
|
|
||||||
|
@ -95,18 +94,19 @@ class Frontend {
|
||||||
virtual std::string setOAuth2Code(const std::string &code, const std::string &state) { return "OAuth2 code is not needed for this frontend."; }
|
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 getOAuth2URL(const std::vector<std::string> &args) { return ""; }
|
||||||
virtual std::string getRegistrationFields() { return "Jabber ID\n3rd-party network username\n3rd-party network password"; }
|
virtual std::string getRegistrationFields() { return "Jabber ID\n3rd-party network username\n3rd-party network password"; }
|
||||||
|
virtual bool handleAdminMessage(Swift::Message::ref /*message*/) { return false; }
|
||||||
|
|
||||||
virtual bool isRawXMLEnabled() { return false; }
|
virtual bool isRawXMLEnabled() { return false; }
|
||||||
|
|
||||||
boost::signal<void (User *, const std::string &name, unsigned int id)> onVCardRequired;
|
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 (User *, boost::shared_ptr<Swift::VCard> vcard)> onVCardUpdated;
|
||||||
boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyUpdated;
|
boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyUpdated;
|
||||||
boost::signal<void (Buddy *)> onBuddyRemoved;
|
boost::signal<void (Buddy *)> onBuddyRemoved;
|
||||||
boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyAdded;
|
boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyAdded;
|
||||||
boost::signal<void (Swift::Message::ref message)> onMessageReceived;
|
boost::signal<void (Swift::Message::ref message)> onMessageReceived;
|
||||||
boost::signal<void (bool /* isAvailable */)> onAvailableChanged;
|
boost::signal<void (bool /* isAvailable */)> onAvailableChanged;
|
||||||
boost::signal<void (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Presence>) > onPresenceReceived;
|
boost::signal<void (boost::shared_ptr<Swift::Presence>) > onPresenceReceived;
|
||||||
boost::signal<void (const Swift::JID& jid, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info)> onCapabilitiesReceived;
|
boost::signal<void (const Swift::JID& jid, boost::shared_ptr<Swift::DiscoInfo> info)> onCapabilitiesReceived;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <boost/signal.hpp>
|
|
||||||
|
|
||||||
#include "Swiften/FileTransfer/ReadBytestream.h"
|
#include "Swiften/FileTransfer/ReadBytestream.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Transport {
|
namespace Transport {
|
||||||
|
|
||||||
|
@ -36,7 +34,7 @@ class MemoryReadBytestream : public Swift::ReadBytestream {
|
||||||
|
|
||||||
unsigned long appendData(const std::string &data);
|
unsigned long appendData(const std::string &data);
|
||||||
|
|
||||||
virtual SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<std::vector<unsigned char> > read(size_t size);
|
virtual boost::shared_ptr<std::vector<unsigned char> > read(size_t size);
|
||||||
|
|
||||||
void setFinished() { m_finished = true; }
|
void setFinished() { m_finished = true; }
|
||||||
bool isFinished() const;
|
bool isFinished() const;
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "Swiften/Parser/XMPPParser.h"
|
#include "Swiften/Parser/XMPPParser.h"
|
||||||
#include "Swiften/Parser/XMPPParserClient.h"
|
#include "Swiften/Parser/XMPPParserClient.h"
|
||||||
#include "Swiften/Serializer/XMPPSerializer.h"
|
#include "Swiften/Serializer/XMPPSerializer.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
#include <Swiften/Version.h>
|
#include <Swiften/Version.h>
|
||||||
#include <Swiften/FileTransfer/FileTransfer.h>
|
#include <Swiften/FileTransfer/FileTransfer.h>
|
||||||
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
|
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
|
||||||
|
@ -69,7 +68,7 @@ class NetworkPluginServer : Swift::XMPPParserClient {
|
||||||
int pongReceived;
|
int pongReceived;
|
||||||
std::list<User *> users;
|
std::list<User *> users;
|
||||||
Swift::SafeByteArray data;
|
Swift::SafeByteArray data;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> connection;
|
boost::shared_ptr<Swift::Connection> connection;
|
||||||
unsigned long res;
|
unsigned long res;
|
||||||
unsigned long init_res;
|
unsigned long init_res;
|
||||||
unsigned long shared;
|
unsigned long shared;
|
||||||
|
@ -105,13 +104,13 @@ class NetworkPluginServer : Swift::XMPPParserClient {
|
||||||
|
|
||||||
bool moveToLongRunBackend(User *user);
|
bool moveToLongRunBackend(User *user);
|
||||||
|
|
||||||
void handleMessageReceived(NetworkConversation *conv, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &message);
|
void handleMessageReceived(NetworkConversation *conv, boost::shared_ptr<Swift::Message> &message);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void handleNewClientConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> c);
|
void handleNewClientConnection(boost::shared_ptr<Swift::Connection> c);
|
||||||
void handleSessionFinished(Backend *c);
|
void handleSessionFinished(Backend *c);
|
||||||
void handlePongReceived(Backend *c);
|
void handlePongReceived(Backend *c);
|
||||||
void handleDataRead(Backend *c, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data);
|
void handleDataRead(Backend *c, boost::shared_ptr<Swift::SafeByteArray> data);
|
||||||
|
|
||||||
void handleConnectedPayload(const std::string &payload);
|
void handleConnectedPayload(const std::string &payload);
|
||||||
void handleDisconnectedPayload(const std::string &payload);
|
void handleDisconnectedPayload(const std::string &payload);
|
||||||
|
@ -149,7 +148,7 @@ class NetworkPluginServer : Swift::XMPPParserClient {
|
||||||
|
|
||||||
void handleBlockToggled(Buddy *buddy);
|
void handleBlockToggled(Buddy *buddy);
|
||||||
|
|
||||||
void handleVCardUpdated(User *user, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCard> vcard);
|
void handleVCardUpdated(User *user, boost::shared_ptr<Swift::VCard> vcard);
|
||||||
void handleVCardRequired(User *user, const std::string &name, unsigned int id);
|
void handleVCardRequired(User *user, const std::string &name, unsigned int id);
|
||||||
|
|
||||||
void handleFTStateChanged(Swift::FileTransfer::State state, const std::string &userName, const std::string &buddyName, const std::string &fileName, unsigned long size, unsigned long id);
|
void handleFTStateChanged(Swift::FileTransfer::State state, const std::string &userName, const std::string &buddyName, const std::string &fileName, unsigned long size, unsigned long id);
|
||||||
|
@ -159,7 +158,7 @@ class NetworkPluginServer : Swift::XMPPParserClient {
|
||||||
|
|
||||||
void handlePIDTerminated(unsigned long pid);
|
void handlePIDTerminated(unsigned long pid);
|
||||||
private:
|
private:
|
||||||
void send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> &, const std::string &data);
|
void send(boost::shared_ptr<Swift::Connection> &, const std::string &data);
|
||||||
|
|
||||||
void pingTimeout();
|
void pingTimeout();
|
||||||
void sendPing(Backend *c);
|
void sendPing(Backend *c);
|
||||||
|
@ -167,14 +166,14 @@ class NetworkPluginServer : Swift::XMPPParserClient {
|
||||||
Backend *getFreeClient(bool acceptUsers = true, bool longRun = false, bool check = false);
|
Backend *getFreeClient(bool acceptUsers = true, bool longRun = false, bool check = false);
|
||||||
void connectWaitingUsers();
|
void connectWaitingUsers();
|
||||||
void loginDelayFinished();
|
void loginDelayFinished();
|
||||||
void handleRawIQReceived(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ> iq);
|
void handleRawIQReceived(boost::shared_ptr<Swift::IQ> iq);
|
||||||
void handleRawPresenceReceived(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Presence> presence);
|
void handleRawPresenceReceived(boost::shared_ptr<Swift::Presence> presence);
|
||||||
|
|
||||||
void handleStreamStart(const Swift::ProtocolHeader&) {}
|
void handleStreamStart(const Swift::ProtocolHeader&) {}
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::ToplevelElement> element);
|
void handleElement(boost::shared_ptr<Swift::ToplevelElement> element);
|
||||||
#else
|
#else
|
||||||
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Element> element);
|
void handleElement(boost::shared_ptr<Swift::Element> element);
|
||||||
#endif
|
#endif
|
||||||
void handleStreamEnd() {}
|
void handleStreamEnd() {}
|
||||||
|
|
||||||
|
@ -183,7 +182,7 @@ class NetworkPluginServer : Swift::XMPPParserClient {
|
||||||
RosterResponder *m_rosterResponder;
|
RosterResponder *m_rosterResponder;
|
||||||
BlockResponder *m_blockResponder;
|
BlockResponder *m_blockResponder;
|
||||||
Config *m_config;
|
Config *m_config;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::ConnectionServer> m_server;
|
boost::shared_ptr<Swift::ConnectionServer> m_server;
|
||||||
std::list<Backend *> m_clients;
|
std::list<Backend *> m_clients;
|
||||||
std::vector<unsigned long> m_pids;
|
std::vector<unsigned long> m_pids;
|
||||||
Swift::Timer::ref m_pingTimer;
|
Swift::Timer::ref m_pingTimer;
|
||||||
|
|
|
@ -22,12 +22,12 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <boost/signals.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Swiften/Elements/Presence.h>
|
#include <Swiften/Elements/Presence.h>
|
||||||
#include <Swiften/Client/StanzaChannel.h>
|
#include <Swiften/Client/StanzaChannel.h>
|
||||||
|
|
||||||
|
#include <Swiften/Base/boost_bsignals.h>
|
||||||
|
|
||||||
namespace Transport {
|
namespace Transport {
|
||||||
|
|
||||||
class Frontend;
|
class Frontend;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <boost/signal.hpp>
|
|
||||||
#include <boost/pool/pool_alloc.hpp>
|
#include <boost/pool/pool_alloc.hpp>
|
||||||
#include <boost/pool/object_pool.hpp>
|
#include <boost/pool/object_pool.hpp>
|
||||||
// #include "rosterstorage.h"
|
// #include "rosterstorage.h"
|
||||||
|
@ -44,7 +43,7 @@ class RosterStorage;
|
||||||
/// Manages roster of one XMPP user.
|
/// Manages roster of one XMPP user.
|
||||||
class RosterManager {
|
class RosterManager {
|
||||||
public:
|
public:
|
||||||
typedef std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<const std::string, Buddy *> > > BuddiesMap;
|
typedef std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > > BuddiesMap;
|
||||||
/// Creates new RosterManager.
|
/// Creates new RosterManager.
|
||||||
/// \param user User associated with this RosterManager.
|
/// \param user User associated with this RosterManager.
|
||||||
/// \param component Transport instance associated with this roster.
|
/// \param component Transport instance associated with this roster.
|
||||||
|
@ -121,7 +120,7 @@ class RosterManager {
|
||||||
void sendUnavailablePresences(const Swift::JID &to);
|
void sendUnavailablePresences(const Swift::JID &to);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<const std::string, Buddy *> > > m_buddies;
|
std::map<std::string, Buddy *, std::less<std::string>, boost::pool_allocator< std::pair<std::string, Buddy *> > > m_buddies;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Component *m_component;
|
Component *m_component;
|
||||||
|
|
|
@ -68,7 +68,6 @@ class ThreadPool
|
||||||
void scheduleFromQueue();
|
void scheduleFromQueue();
|
||||||
int getFreeThread();
|
int getFreeThread();
|
||||||
void releaseThread(int i);
|
void releaseThread(int i);
|
||||||
void workerBody(Thread *t, int wid);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/signal.hpp>
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include "Swiften/Network/BoostTimerFactory.h"
|
#include "Swiften/Network/BoostTimerFactory.h"
|
||||||
#include "Swiften/Network/BoostIOServiceThread.h"
|
#include "Swiften/Network/BoostIOServiceThread.h"
|
||||||
|
@ -29,7 +28,6 @@
|
||||||
#include "Swiften/Elements/DiscoInfo.h"
|
#include "Swiften/Elements/DiscoInfo.h"
|
||||||
#include "Swiften/Elements/Presence.h"
|
#include "Swiften/Elements/Presence.h"
|
||||||
#include "Swiften/Elements/IQ.h"
|
#include "Swiften/Elements/IQ.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Transport {
|
namespace Transport {
|
||||||
class StorageBackend;
|
class StorageBackend;
|
||||||
|
@ -40,7 +38,6 @@ namespace Transport {
|
||||||
class Factory;
|
class Factory;
|
||||||
class Config;
|
class Config;
|
||||||
class UserManager;
|
class UserManager;
|
||||||
class AdminInterface;
|
|
||||||
|
|
||||||
class Component {
|
class Component {
|
||||||
public:
|
public:
|
||||||
|
@ -110,9 +107,7 @@ namespace Transport {
|
||||||
/// \param presence Presence.
|
/// \param presence Presence.
|
||||||
boost::signal<void (Swift::Presence::ref presence)> onUserPresenceReceived;
|
boost::signal<void (Swift::Presence::ref presence)> onUserPresenceReceived;
|
||||||
|
|
||||||
boost::signal<void (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ>)> onRawIQReceived;
|
boost::signal<void (boost::shared_ptr<Swift::IQ>)> onRawIQReceived;
|
||||||
|
|
||||||
boost::signal<void ()> onAdminInterfaceSet;
|
|
||||||
|
|
||||||
void handlePresence(Swift::Presence::ref presence);
|
void handlePresence(Swift::Presence::ref presence);
|
||||||
void handleConnected();
|
void handleConnected();
|
||||||
|
@ -126,17 +121,8 @@ namespace Transport {
|
||||||
|
|
||||||
PresenceOracle *getPresenceOracle();
|
PresenceOracle *getPresenceOracle();
|
||||||
|
|
||||||
void setAdminInterface(AdminInterface *adminInterface) {
|
|
||||||
m_adminInterface = adminInterface;
|
|
||||||
onAdminInterfaceSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
AdminInterface *getAdminInterface() {
|
|
||||||
return m_adminInterface;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleDiscoInfoResponse(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info, Swift::ErrorPayload::ref error, const Swift::JID& jid);
|
void handleDiscoInfoResponse(boost::shared_ptr<Swift::DiscoInfo> info, Swift::ErrorPayload::ref error, const Swift::JID& jid);
|
||||||
void handleCapsChanged(const Swift::JID& jid);
|
void handleCapsChanged(const Swift::JID& jid);
|
||||||
|
|
||||||
void handleBackendConfigChanged();
|
void handleBackendConfigChanged();
|
||||||
|
@ -153,7 +139,6 @@ namespace Transport {
|
||||||
Factory *m_factory;
|
Factory *m_factory;
|
||||||
Swift::EventLoop *m_loop;
|
Swift::EventLoop *m_loop;
|
||||||
Frontend *m_frontend;
|
Frontend *m_frontend;
|
||||||
AdminInterface *m_adminInterface;
|
|
||||||
|
|
||||||
friend class User;
|
friend class User;
|
||||||
friend class UserRegistration;
|
friend class UserRegistration;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/signal.hpp>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "transport/StorageBackend.h"
|
#include "transport/StorageBackend.h"
|
||||||
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
|
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
|
||||||
|
@ -31,7 +30,6 @@
|
||||||
#include "Swiften/Elements/DiscoInfo.h"
|
#include "Swiften/Elements/DiscoInfo.h"
|
||||||
#include "Swiften/Network/Timer.h"
|
#include "Swiften/Network/Timer.h"
|
||||||
#include "Swiften/Network/Connection.h"
|
#include "Swiften/Network/Connection.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Transport {
|
namespace Transport {
|
||||||
|
|
||||||
|
@ -91,7 +89,7 @@ class User {
|
||||||
|
|
||||||
void handleSubscription(Swift::Presence::ref presence);
|
void handleSubscription(Swift::Presence::ref presence);
|
||||||
|
|
||||||
void handleDiscoInfo(const Swift::JID& jid, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info);
|
void handleDiscoInfo(const Swift::JID& jid, boost::shared_ptr<Swift::DiscoInfo> info);
|
||||||
|
|
||||||
time_t &getLastActivity() {
|
time_t &getLastActivity() {
|
||||||
return m_lastActivity;
|
return m_lastActivity;
|
||||||
|
@ -171,10 +169,10 @@ class User {
|
||||||
bool m_readyForConnect;
|
bool m_readyForConnect;
|
||||||
bool m_ignoreDisconnect;
|
bool m_ignoreDisconnect;
|
||||||
Swift::Timer::ref m_reconnectTimer;
|
Swift::Timer::ref m_reconnectTimer;
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> connection;
|
boost::shared_ptr<Swift::Connection> connection;
|
||||||
time_t m_lastActivity;
|
time_t m_lastActivity;
|
||||||
std::map<Swift::JID, Swift::DiscoInfo::ref> m_legacyCaps;
|
std::map<Swift::JID, Swift::DiscoInfo::ref> m_legacyCaps;
|
||||||
std::vector<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::OutgoingFileTransfer> > m_filetransfers;
|
std::vector<boost::shared_ptr<Swift::OutgoingFileTransfer> > m_filetransfers;
|
||||||
int m_resources;
|
int m_resources;
|
||||||
int m_reconnectCounter;
|
int m_reconnectCounter;
|
||||||
std::list<Swift::Presence::ref> m_joinedRooms;
|
std::list<Swift::Presence::ref> m_joinedRooms;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/signal.hpp>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "Swiften/Elements/Message.h"
|
#include "Swiften/Elements/Message.h"
|
||||||
|
@ -30,7 +29,6 @@
|
||||||
#include "Swiften/Elements/DiscoInfo.h"
|
#include "Swiften/Elements/DiscoInfo.h"
|
||||||
#include "Swiften/Elements/VCard.h"
|
#include "Swiften/Elements/VCard.h"
|
||||||
#include "Swiften/Network/Timer.h"
|
#include "Swiften/Network/Timer.h"
|
||||||
#include "Swiften/SwiftenCompat.h"
|
|
||||||
|
|
||||||
namespace Transport {
|
namespace Transport {
|
||||||
|
|
||||||
|
@ -145,7 +143,7 @@ class UserManager /*: public Swift::EntityCapsProvider*/ {
|
||||||
void handleSubscription(Swift::Presence::ref presence);
|
void handleSubscription(Swift::Presence::ref presence);
|
||||||
void handleMUCPresence(Swift::Presence::ref presence);
|
void handleMUCPresence(Swift::Presence::ref presence);
|
||||||
void handleRemoveTimeout(const std::string jid, User *user, bool reconnect);
|
void handleRemoveTimeout(const std::string jid, User *user, bool reconnect);
|
||||||
void handleDiscoInfo(const Swift::JID& jid, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info);
|
void handleDiscoInfo(const Swift::JID& jid, boost::shared_ptr<Swift::DiscoInfo> info);
|
||||||
void addUser(User *user);
|
void addUser(User *user);
|
||||||
|
|
||||||
long m_onlineBuddies;
|
long m_onlineBuddies;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue