Compare commits
No commits in common. "master" and "2.0.2" have entirely different histories.
240 changed files with 9624 additions and 5709 deletions
51
.travis.yml
51
.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:
|
sudo: required
|
||||||
include:
|
dist: trusty
|
||||||
- os: linux
|
|
||||||
dist: trusty
|
|
||||||
sudo: required
|
|
||||||
- os: osx
|
|
||||||
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,8 @@
|
||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
project(libtransport)
|
project(libtransport)
|
||||||
if(${CMAKE_MAJOR_VERSION} GREATER 2)
|
|
||||||
cmake_policy(SET CMP0037 OLD)
|
cmake_policy(SET CMP0037 OLD)
|
||||||
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 +25,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 +74,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 +82,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 +162,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 +259,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.2-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.2)
|
||||||
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 +376,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 +483,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()
|
||||||
|
|
||||||
|
|
57
ChangeLog
57
ChangeLog
|
@ -1,60 +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):
|
|
||||||
General:
|
|
||||||
* Swift 3.0rc2 is now minimum Swift 3.x version needed to compile Spectrum2,
|
|
||||||
Swith 2.x remains supported.
|
|
||||||
* Rename user when he tries to connect to room from the second client
|
|
||||||
with different nickname than he used with the first client.
|
|
||||||
* Send self presence as the first presence from the MUC room.
|
|
||||||
* Send the icon hash to the backend with other buddies information.
|
|
||||||
* Send unavailable presence as a response to presence for exiting
|
|
||||||
the room. Fixes room rejoin in Pidgin.
|
|
||||||
* Fix memory leak in HTTPRequest - currently used only in Slack frontend.
|
|
||||||
|
|
||||||
Slack frontend:
|
|
||||||
* For IRC allow registering without providing account name/password.
|
|
||||||
* Do not reconnect to Slack RTM when no URL is available after disconnect.
|
|
||||||
* Handle "account_inactive" Slack error.
|
|
||||||
|
|
||||||
Web interface:
|
|
||||||
* Show warning when trying to register already registered username.
|
|
||||||
* Allow registering with empty password for networks like IRC where
|
|
||||||
password is not needed.
|
|
||||||
* Allow showing examples of username or server in registration form. This
|
|
||||||
is configured in config file.
|
|
||||||
* Fix `service.base_location` setting for register.shtml page.
|
|
||||||
|
|
||||||
Libpurple backend:
|
|
||||||
* Make the conversation active according to chatstates notifications.
|
|
||||||
Should fix the issue with repeating messages with prpl-facebook.
|
|
||||||
* When `service.web_directory` and `service.web_url` is set, images sent
|
|
||||||
in messages are stored to `service.web_directory` and link is forwarded
|
|
||||||
to the user. Tested only with prpl-facebook for now.
|
|
||||||
* Treat empty password as fatal error - do no try to reconnect
|
|
||||||
automatically in that case.
|
|
||||||
|
|
||||||
Libcommuni backend:
|
|
||||||
* Latest libcommuni 3.4.0 is now needed.
|
|
||||||
* Libcommuni backend has been improved to use the newest libcommuni
|
|
||||||
features.
|
|
||||||
* Ports can now be set in `service.irc_server` option and in the JID. When
|
|
||||||
'+' character is used before the port number, SSL is used automatically.
|
|
||||||
When port 6697 is used, SSL is used automatically too.
|
|
||||||
|
|
||||||
Swiften backend:
|
|
||||||
* Respect the resource when connecting to 3rd-party XMPP network.
|
|
||||||
|
|
||||||
Version 2.0.2 (2016-02-09):
|
Version 2.0.2 (2016-02-09):
|
||||||
General:
|
General:
|
||||||
* Fix joining the room when using JID Escaping even for '@' character.
|
* Fix joining the room when using JID Escaping even for '@' character.
|
||||||
|
|
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");
|
||||||
|
@ -90,38 +91,20 @@ MyIrcSession *IRCNetworkPlugin::createSession(const std::string &user, const std
|
||||||
session->setUserName(FROM_UTF8(nickname));
|
session->setUserName(FROM_UTF8(nickname));
|
||||||
session->setNickName(FROM_UTF8(nickname));
|
session->setNickName(FROM_UTF8(nickname));
|
||||||
session->setRealName(FROM_UTF8(nickname));
|
session->setRealName(FROM_UTF8(nickname));
|
||||||
|
session->setHost(FROM_UTF8(hostname));
|
||||||
|
session->setPort(6667);
|
||||||
// session->setEncoding("UTF8");
|
// session->setEncoding("UTF8");
|
||||||
|
|
||||||
std::vector<std::string> hostname_parts;
|
|
||||||
boost::split(hostname_parts, hostname, boost::is_any_of(":/"));
|
|
||||||
if (hostname_parts.size() == 2 && !hostname_parts[0].empty() && !hostname_parts[1].empty()) { // hostname was splitted
|
|
||||||
session->setHost(FROM_UTF8(hostname_parts[0])); // real hostname
|
|
||||||
int port = atoi(hostname_parts[1].c_str()); // user port
|
|
||||||
if (hostname_parts[1][0] == '+' || port == 6697) { // use SSL
|
|
||||||
port = (port < 1 || port > 65535) ? 6697 : port; // default to standard SSL port
|
|
||||||
session->setSecure(true);
|
|
||||||
} else { // use TCP
|
|
||||||
port = (port < 1 || port > 65535) ? 6667 : port; // default to standart TCP port
|
|
||||||
}
|
|
||||||
session->setPort(port);
|
|
||||||
} else { // hostname was not splitted: default to old behaviour
|
|
||||||
session->setHost(FROM_UTF8(hostname));
|
|
||||||
session->setPort(6667);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!password.empty()) {
|
if (!password.empty()) {
|
||||||
std::string identify = m_identify;
|
std::string identify = m_identify;
|
||||||
boost::replace_all(identify, "$password", password);
|
boost::replace_all(identify, "$password", password);
|
||||||
boost::replace_all(identify, "$name", nickname);
|
boost::replace_all(identify, "$name", nickname);
|
||||||
if (CONFIG_BOOL_DEFAULTED(m_config, "service.irc_send_pass", false)) {
|
session->setIdentify(identify);
|
||||||
session->setPassword(FROM_UTF8(password)); // use IRC PASS
|
|
||||||
} else {
|
|
||||||
session->setIdentify(identify); // use identify supplied
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session->createBufferModel();
|
LOG4CXX_INFO(logger, user << ": Connecting " << hostname << " as " << nickname << ", suffix=" << suffix);
|
||||||
LOG4CXX_INFO(logger, user << ": Connecting " << hostname << " as " << nickname << ", port=" << session->port() << ", suffix=" << suffix);
|
|
||||||
|
session->open();
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +118,6 @@ void IRCNetworkPlugin::handleLoginRequest(const std::string &user, const std::st
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sessions[user] = createSession(user, m_servers[m_currentServer], legacyName, password, "");
|
m_sessions[user] = createSession(user, m_servers[m_currentServer], legacyName, password, "");
|
||||||
m_sessions[user]->open();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We are waiting for first room join to connect user to IRC network, because we don't know which
|
// We are waiting for first room join to connect user to IRC network, because we don't know which
|
||||||
|
@ -145,10 +127,6 @@ void IRCNetworkPlugin::handleLoginRequest(const std::string &user, const std::st
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCNetworkPlugin::handleVCardRequest(const std::string &user, const std::string &legacyName, unsigned int id) {
|
|
||||||
handleVCard(user, id, legacyName, "", "", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
void IRCNetworkPlugin::handleLogoutRequest(const std::string &user, const std::string &legacyName) {
|
void IRCNetworkPlugin::handleLogoutRequest(const std::string &user, const std::string &legacyName) {
|
||||||
if (m_sessions[user] == NULL) {
|
if (m_sessions[user] == NULL) {
|
||||||
LOG4CXX_WARN(logger, user << ": Already disconnected.");
|
LOG4CXX_WARN(logger, user << ": Already disconnected.");
|
||||||
|
@ -232,14 +210,12 @@ void IRCNetworkPlugin::handleJoinRoomRequest(const std::string &user, const std:
|
||||||
std::string target = getTargetName(room);
|
std::string target = getTargetName(room);
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << ": Session name: " << session << ", Joining room " << target);
|
LOG4CXX_INFO(logger, user << ": Session name: " << session << ", Joining room " << target);
|
||||||
bool createdSession = false;
|
|
||||||
if (m_sessions[session] == NULL) {
|
if (m_sessions[session] == NULL) {
|
||||||
if (m_servers.empty()) {
|
if (m_servers.empty()) {
|
||||||
// in gateway mode we want to login this user to network according to legacyName
|
// in gateway mode we want to login this user to network according to legacyName
|
||||||
if (room.find("@") != std::string::npos) {
|
if (room.find("@") != std::string::npos) {
|
||||||
// suffix is %irc.freenode.net to let MyIrcSession return #room%irc.freenode.net
|
// suffix is %irc.freenode.net to let MyIrcSession return #room%irc.freenode.net
|
||||||
m_sessions[session] = createSession(user, room.substr(room.find("@") + 1), nickname, "", room.substr(room.find("@")));
|
m_sessions[session] = createSession(user, room.substr(room.find("@") + 1), nickname, "", room.substr(room.find("@")));
|
||||||
createdSession = true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG4CXX_WARN(logger, user << ": There's no proper server defined in room to which this user wants to join: " << room);
|
LOG4CXX_WARN(logger, user << ": There's no proper server defined in room to which this user wants to join: " << room);
|
||||||
|
@ -252,18 +228,12 @@ void IRCNetworkPlugin::handleJoinRoomRequest(const std::string &user, const std:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_sessions[session]->addAutoJoinChannel(target, password);
|
||||||
m_sessions[session]->sendCommand(IrcCommand::createJoin(FROM_UTF8(target), FROM_UTF8(password)));
|
m_sessions[session]->sendCommand(IrcCommand::createJoin(FROM_UTF8(target), FROM_UTF8(password)));
|
||||||
m_sessions[session]->rooms += 1;
|
m_sessions[session]->rooms += 1;
|
||||||
|
|
||||||
if (createdSession) {
|
|
||||||
m_sessions[session]->open();
|
|
||||||
}
|
|
||||||
|
|
||||||
// update nickname, because we have nickname per session, no nickname per room.
|
// update nickname, because we have nickname per session, no nickname per room.
|
||||||
if (nickname != TO_UTF8(m_sessions[session]->nickName())) {
|
handleRoomNicknameChanged(user, target, TO_UTF8(m_sessions[session]->nickName()));
|
||||||
handleRoomNicknameChanged(user, room, TO_UTF8(m_sessions[session]->nickName()));
|
|
||||||
handleParticipantChanged(user, nickname, room, 0, pbnetwork::STATUS_ONLINE, "", TO_UTF8(m_sessions[session]->nickName()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCNetworkPlugin::handleLeaveRoomRequest(const std::string &user, const std::string &room) {
|
void IRCNetworkPlugin::handleLeaveRoomRequest(const std::string &user, const std::string &room) {
|
||||||
|
@ -275,6 +245,7 @@ void IRCNetworkPlugin::handleLeaveRoomRequest(const std::string &user, const std
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_sessions[session]->sendCommand(IrcCommand::createPart(FROM_UTF8(target)));
|
m_sessions[session]->sendCommand(IrcCommand::createPart(FROM_UTF8(target)));
|
||||||
|
m_sessions[session]->removeAutoJoinChannel(target);
|
||||||
m_sessions[session]->rooms -= 1;
|
m_sessions[session]->rooms -= 1;
|
||||||
|
|
||||||
if (m_sessions[session]->rooms <= 0 && m_servers.empty()) {
|
if (m_sessions[session]->rooms <= 0 && m_servers.empty()) {
|
||||||
|
@ -284,18 +255,3 @@ void IRCNetworkPlugin::handleLeaveRoomRequest(const std::string &user, const std
|
||||||
m_sessions.erase(session);
|
m_sessions.erase(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRCNetworkPlugin::handleStatusChangeRequest(const std::string &user, int status, const std::string &statusMessage) {
|
|
||||||
if (m_sessions[user] == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == pbnetwork::STATUS_AWAY) {
|
|
||||||
LOG4CXX_INFO(logger, user << ": User is now away.");
|
|
||||||
m_sessions[user]->sendCommand(IrcCommand::createAway(statusMessage.empty() ? "Away" : FROM_UTF8(statusMessage)));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG4CXX_INFO(logger, user << ": User is not away anymore.");
|
|
||||||
m_sessions[user]->sendCommand(IrcCommand::createAway(""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -47,16 +47,8 @@ class IRCNetworkPlugin : public QObject, public NetworkPlugin {
|
||||||
|
|
||||||
void handleRoomSubjectChangedRequest(const std::string &user, const std::string &room, const std::string &message);
|
void handleRoomSubjectChangedRequest(const std::string &user, const std::string &room, const std::string &message);
|
||||||
|
|
||||||
void handleVCardRequest(const std::string &user, const std::string &legacyName, unsigned int id);
|
|
||||||
|
|
||||||
void handleStatusChangeRequest(const std::string &user, int status, const std::string &statusMessage);
|
|
||||||
|
|
||||||
void tryNextServer();
|
void tryNextServer();
|
||||||
|
|
||||||
Config *getConfig() {
|
|
||||||
return m_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void readData();
|
void readData();
|
||||||
void sendData(const std::string &string);
|
void sendData(const std::string &string);
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <IrcCommand>
|
#include <IrcCommand>
|
||||||
#include <IrcMessage>
|
#include <IrcMessage>
|
||||||
#include <IrcUser>
|
|
||||||
#include <IrcChannel>
|
|
||||||
#include "backports.h"
|
#include "backports.h"
|
||||||
|
|
||||||
#include "ircnetworkplugin.h"
|
#include "ircnetworkplugin.h"
|
||||||
|
@ -36,6 +34,8 @@
|
||||||
|
|
||||||
DEFINE_LOGGER(logger, "IRCConnection");
|
DEFINE_LOGGER(logger, "IRCConnection");
|
||||||
|
|
||||||
|
// static bool sentList;
|
||||||
|
|
||||||
MyIrcSession::MyIrcSession(const std::string &user, IRCNetworkPlugin *np, const std::string &suffix, QObject* parent) : IrcConnection(parent)
|
MyIrcSession::MyIrcSession(const std::string &user, IRCNetworkPlugin *np, const std::string &suffix, QObject* parent) : IrcConnection(parent)
|
||||||
{
|
{
|
||||||
m_np = np;
|
m_np = np;
|
||||||
|
@ -43,136 +43,35 @@ MyIrcSession::MyIrcSession(const std::string &user, IRCNetworkPlugin *np, const
|
||||||
m_suffix = suffix;
|
m_suffix = suffix;
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
rooms = 0;
|
rooms = 0;
|
||||||
m_bufferModel = NULL;
|
|
||||||
|
|
||||||
connect(this, SIGNAL(disconnected()), SLOT(on_disconnected()));
|
connect(this, SIGNAL(disconnected()), SLOT(on_disconnected()));
|
||||||
connect(this, SIGNAL(socketError(QAbstractSocket::SocketError)), SLOT(on_socketError(QAbstractSocket::SocketError)));
|
connect(this, SIGNAL(socketError(QAbstractSocket::SocketError)), SLOT(on_socketError(QAbstractSocket::SocketError)));
|
||||||
connect(this, SIGNAL(connected()), SLOT(on_connected()));
|
connect(this, SIGNAL(connected()), SLOT(on_connected()));
|
||||||
|
connect(this, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(onMessageReceived(IrcMessage*)));
|
||||||
|
|
||||||
m_awayTimer = new QTimer(this);
|
m_awayTimer = new QTimer(this);
|
||||||
connect(m_awayTimer, SIGNAL(timeout()), this, SLOT(awayTimeout()));
|
connect(m_awayTimer, SIGNAL(timeout()), this, SLOT(awayTimeout()));
|
||||||
m_awayTimer->start(1 * 1000);
|
m_awayTimer->start(5*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
MyIrcSession::~MyIrcSession() {
|
MyIrcSession::~MyIrcSession() {
|
||||||
delete m_awayTimer;
|
delete m_awayTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyIrcSession::createBufferModel() {
|
|
||||||
m_bufferModel = new IrcBufferModel(this);
|
|
||||||
connect(m_bufferModel, SIGNAL(added(IrcBuffer*)), this, SLOT(onBufferAdded(IrcBuffer*)));
|
|
||||||
connect(m_bufferModel, SIGNAL(removed(IrcBuffer*)), this, SLOT(onBufferRemoved(IrcBuffer*)));
|
|
||||||
|
|
||||||
// keep the command parser aware of the context
|
|
||||||
// connect(m_bufferModel, SIGNAL(channelsChanged(QStringList)), parser, SLOT(setChannels(QStringList)));
|
|
||||||
|
|
||||||
// create a server buffer for non-targeted messages...
|
|
||||||
IrcBuffer* serverBuffer = m_bufferModel->add(host());
|
|
||||||
// ...and connect it to IrcBufferModel::messageIgnored()
|
|
||||||
// TODO: Make this configurable, so users can show the MOTD and other stuff as in normal
|
|
||||||
// IRC client.
|
|
||||||
connect(m_bufferModel, SIGNAL(messageIgnored(IrcMessage*)), serverBuffer, SLOT(receiveMessage(IrcMessage*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::onBufferAdded(IrcBuffer* buffer) {
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": Created IrcBuffer " << TO_UTF8(buffer->name()));
|
|
||||||
|
|
||||||
connect(buffer, SIGNAL(messageReceived(IrcMessage*)), this, SLOT(onMessageReceived(IrcMessage*)));
|
|
||||||
|
|
||||||
if (buffer->isChannel()) {
|
|
||||||
QVariantMap userData;
|
|
||||||
userData["awayCycle"] = boost::lexical_cast<int>(CONFIG_STRING_DEFAULTED(m_np->getConfig(), "service.irc_away_timeout", "60")) + m_userModels.size();
|
|
||||||
userData["awayTick"] = 0;
|
|
||||||
buffer->setUserData(userData);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a model for buffer users
|
|
||||||
IrcUserModel* userModel = new IrcUserModel(buffer);
|
|
||||||
connect(userModel, SIGNAL(added(IrcUser*)), this, SLOT(onIrcUserAdded(IrcUser*)));
|
|
||||||
connect(userModel, SIGNAL(removed(IrcUser*)), this, SLOT(onIrcUserRemoved(IrcUser*)));
|
|
||||||
m_userModels.insert(buffer, userModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::onBufferRemoved(IrcBuffer* buffer) {
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": Removed IrcBuffer " << TO_UTF8(buffer->name()));
|
|
||||||
// the buffer specific models and documents are no longer needed
|
|
||||||
delete m_userModels.take(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MyIrcSession::hasIrcUser(const std::string &channel_, const std::string &name) {
|
|
||||||
std::string channel = channel_;
|
|
||||||
if (channel[0] != '#') {
|
|
||||||
channel = "#" + channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
IrcBuffer *buffer = m_bufferModel->find(FROM_UTF8(channel));
|
|
||||||
if (!buffer) {
|
|
||||||
LOG4CXX_ERROR(logger, m_user << ": Cannot find IrcBuffer '" << channel << "'");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IrcUserModel *userModel = m_userModels.value(buffer);
|
|
||||||
if (!userModel) {
|
|
||||||
LOG4CXX_ERROR(logger, m_user << ": Cannot find UserModel for IrcBuffer " << channel);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return userModel->contains(FROM_UTF8(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::sendUserToFrontend(IrcUser *user, pbnetwork::StatusType statusType, const std::string &statusMessage, const std::string &newNick) {
|
|
||||||
std::string target = "#" + TO_UTF8(user->channel()->name().toLower()) + m_suffix;
|
|
||||||
int op = user->mode() == "o";
|
|
||||||
|
|
||||||
if (statusType != pbnetwork::STATUS_NONE) {
|
|
||||||
if (user->isAway()) {
|
|
||||||
statusType = pbnetwork::STATUS_AWAY;
|
|
||||||
}
|
|
||||||
if (newNick.empty()) {
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": IrcUser connected: " << target << "/" << TO_UTF8(user->name()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": IrcUser changed nickname: " << target << "/" << TO_UTF8(user->name()) << ", newNick=" << newNick);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": IrcUser disconnected: " << target << "/" << TO_UTF8(user->name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_np->handleParticipantChanged(m_user, TO_UTF8(user->name()), target, op, statusType, statusMessage, newNick);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::onIrcUserChanged(bool dummy) {
|
|
||||||
IrcUser *user = dynamic_cast<IrcUser *>(QObject::sender());
|
|
||||||
if (!user) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": IrcUser " << TO_UTF8(user->name()) << " changed.");
|
|
||||||
sendUserToFrontend(user, pbnetwork::STATUS_ONLINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::onIrcUserChanged(const QString &) {
|
|
||||||
onIrcUserChanged(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::onIrcUserAdded(IrcUser *user) {
|
|
||||||
sendUserToFrontend(user, pbnetwork::STATUS_ONLINE);
|
|
||||||
connect(user, SIGNAL(modeChanged(const QString&)), this, SLOT(onIrcUserChanged(const QString&)));
|
|
||||||
connect(user, SIGNAL(awayChanged(bool)), this, SLOT(onIrcUserChanged(bool)));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::onIrcUserRemoved(IrcUser *user) {
|
|
||||||
sendUserToFrontend(user, pbnetwork::STATUS_NONE);
|
|
||||||
disconnect(user, SIGNAL(modeChanged(const QString&)), this, SLOT(onIrcUserChanged(const QString&)));
|
|
||||||
disconnect(user, SIGNAL(awayChanged(bool)), this, SLOT(onIrcUserChanged(bool)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::on_connected() {
|
void MyIrcSession::on_connected() {
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
if (m_suffix.empty()) {
|
if (m_suffix.empty()) {
|
||||||
m_np->handleConnected(m_user);
|
m_np->handleConnected(m_user);
|
||||||
|
// if (!sentList) {
|
||||||
|
// sendCommand(IrcCommand::createList("", ""));
|
||||||
|
// sentList = true;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
// sendCommand(IrcCommand::createCapability("REQ", QStringList("away-notify")));
|
||||||
|
|
||||||
|
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
|
sendCommand(IrcCommand::createJoin(FROM_UTF8(it->second->getChannel()), FROM_UTF8(it->second->getPassword())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getIdentify().find(" ") != std::string::npos) {
|
if (getIdentify().find(" ") != std::string::npos) {
|
||||||
|
@ -205,18 +104,14 @@ void MyIrcSession::on_socketError(QAbstractSocket::SocketError error) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!m_suffix.empty()) {
|
if (!m_suffix.empty()) {
|
||||||
foreach (IrcBuffer *buffer, m_bufferModel->buffers()) {
|
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
if (!buffer->isChannel()) {
|
m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, pbnetwork::PARTICIPANT_FLAG_ROOM_NOT_FOUND, pbnetwork::STATUS_NONE, reason);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), TO_UTF8(buffer->title()) + m_suffix, pbnetwork::PARTICIPANT_FLAG_ROOM_NOT_FOUND, pbnetwork::STATUS_NONE, reason);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_np->handleDisconnected(m_user, 0, reason);
|
m_np->handleDisconnected(m_user, 0, reason);
|
||||||
m_np->tryNextServer();
|
m_np->tryNextServer();
|
||||||
}
|
}
|
||||||
LOG4CXX_INFO(logger, m_user << ": Disconnected from IRC network: " << reason);
|
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,81 +123,95 @@ void MyIrcSession::on_disconnected() {
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyIrcSession::correctNickname(std::string &nick) {
|
bool MyIrcSession::correctNickname(std::string &nickname) {
|
||||||
if (nick.empty()) {
|
bool flags = 0;
|
||||||
return;
|
if (!nickname.empty()) {
|
||||||
}
|
switch(nickname.at(0)) {
|
||||||
|
case '@': nickname = nickname.substr(1); flags = 1; break;
|
||||||
switch(nick.at(0)) {
|
case '+': nickname = nickname.substr(1); break;
|
||||||
case '@':
|
case '~': nickname = nickname.substr(1); break;
|
||||||
case '+':
|
case '&': nickname = nickname.substr(1); break;
|
||||||
case '~':
|
case '%': nickname = nickname.substr(1); break;
|
||||||
case '&':
|
default: break;
|
||||||
case '%':
|
}
|
||||||
nick.erase(0, 1);
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrcUser *MyIrcSession::getIrcUser(IrcBuffer *buffer, std::string &nick) {
|
void MyIrcSession::on_joined(IrcMessage *message) {
|
||||||
correctNickname(nick);
|
IrcJoinMessage *m = (IrcJoinMessage *) message;
|
||||||
IrcUserModel *userModel = m_userModels.value(buffer);
|
std::string nickname = TO_UTF8(m->nick());
|
||||||
if (!userModel) {
|
bool op = correctNickname(nickname);
|
||||||
LOG4CXX_ERROR(logger, m_user << ": Cannot find UserModel for IrcBuffer " << TO_UTF8(buffer->name()));
|
getIRCBuddy(TO_UTF8(m->channel().toLower()), nickname).setOp(op);
|
||||||
return NULL;
|
m_np->handleParticipantChanged(m_user, nickname, TO_UTF8(m->channel().toLower()) + m_suffix, op, pbnetwork::STATUS_ONLINE);
|
||||||
}
|
LOG4CXX_INFO(logger, m_user << ": " << nickname << " joined " << TO_UTF8(m->channel().toLower()) + m_suffix);
|
||||||
|
|
||||||
return userModel->find(FROM_UTF8(nick));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IrcUser *MyIrcSession::getIrcUser(IrcBuffer *buffer, IrcMessage *message) {
|
|
||||||
std::string nick = TO_UTF8(message->nick());
|
|
||||||
return getIrcUser(buffer, nick);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::on_parted(IrcMessage *message) {
|
void MyIrcSession::on_parted(IrcMessage *message) {
|
||||||
// TODO: We currently use onIrcUserRemoved, but this does not allow sending
|
IrcPartMessage *m = (IrcPartMessage *) message;
|
||||||
// part/quit message. We should use this method instead and write version
|
std::string nickname = TO_UTF8(m->nick());
|
||||||
// of sendUserToFrontend which takes nickname instead of IrcUser just for
|
bool op = correctNickname(nickname);
|
||||||
// part/quit messages.
|
removeIRCBuddy(TO_UTF8(m->channel().toLower()), nickname);
|
||||||
// IrcPartMessage *m = (IrcPartMessage *) message;
|
LOG4CXX_INFO(logger, m_user << ": " << nickname << " parted " << TO_UTF8(m->channel().toLower()) + m_suffix);
|
||||||
// IrcBuffer *buffer = dynamic_cast<IrcBuffer *>(QObject::sender());
|
m_np->handleParticipantChanged(m_user, nickname, TO_UTF8(m->channel().toLower()) + m_suffix, op, pbnetwork::STATUS_NONE, TO_UTF8(m->reason()));
|
||||||
// IrcUser *user = getIrcUser(buffer, message);
|
|
||||||
// if (!user) {
|
|
||||||
// LOG4CXX_ERROR(logger, m_user << ": Part: IrcUser " << TO_UTF8(message->nick()) << " not in channel " << TO_UTF8(buffer->name()));
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// sendUserToFrontend(user, pbnetwork::STATUS_NONE, TO_UTF8(m->reason()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyIrcSession::on_quit(IrcMessage *message) {
|
void MyIrcSession::on_quit(IrcMessage *message) {
|
||||||
// TODO: We currently use onIrcUserRemoved, but this does not allow sending
|
IrcQuitMessage *m = (IrcQuitMessage *) message;
|
||||||
// part/quit message. We should use this method instead and write version
|
std::string nickname = TO_UTF8(m->nick());
|
||||||
// of sendUserToFrontend which takes nickname instead of IrcUser just for
|
bool op = correctNickname(nickname);
|
||||||
// part/quit messages.
|
|
||||||
// IrcQuitMessage *m = (IrcQuitMessage *) message;
|
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
// IrcBuffer *buffer = dynamic_cast<IrcBuffer *>(QObject::sender());
|
if (!hasIRCBuddy(it->second->getChannel(), nickname)) {
|
||||||
// IrcUser *user = getIrcUser(buffer, message);
|
continue;
|
||||||
// if (!user) {
|
}
|
||||||
// LOG4CXX_ERROR(logger, m_user << ": Quit: IrcUser " << TO_UTF8(message->nick()) << " not in channel " << TO_UTF8(buffer->name()));
|
removeIRCBuddy(it->second->getChannel(), nickname);
|
||||||
// return;
|
LOG4CXX_INFO(logger, m_user << ": " << nickname << " quit " << it->second->getChannel() + m_suffix);
|
||||||
// }
|
m_np->handleParticipantChanged(m_user, nickname, it->second->getChannel() + m_suffix, op, pbnetwork::STATUS_NONE, TO_UTF8(m->reason()));
|
||||||
//
|
}
|
||||||
// sendUserToFrontend(user, pbnetwork::STATUS_NONE, TO_UTF8(m->reason()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyIrcSession::on_nickChanged(IrcMessage *message) {
|
void MyIrcSession::on_nickChanged(IrcMessage *message) {
|
||||||
IrcNickMessage *m = (IrcNickMessage *) message;
|
IrcNickMessage *m = (IrcNickMessage *) message;
|
||||||
IrcBuffer *buffer = dynamic_cast<IrcBuffer *>(QObject::sender());
|
std::string nickname = TO_UTF8(m->nick());
|
||||||
IrcUser *user = getIrcUser(buffer, message);
|
correctNickname(nickname);
|
||||||
if (!user) {
|
|
||||||
LOG4CXX_ERROR(logger, m_user << ": NickChanged: IrcUser " << TO_UTF8(message->nick()) << " not in channel " << TO_UTF8(buffer->name()));
|
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
|
if (!hasIRCBuddy(it->second->getChannel(), nickname)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
IRCBuddy &buddy = getIRCBuddy(it->second->getChannel(), nickname);
|
||||||
|
LOG4CXX_INFO(logger, m_user << ": " << nickname << " changed nickname to " << TO_UTF8(m->nick()));
|
||||||
|
m_np->handleParticipantChanged(m_user, nickname, it->second->getChannel() + m_suffix,(int) buddy.isOp(), pbnetwork::STATUS_ONLINE, "", TO_UTF8(m->nick()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyIrcSession::on_modeChanged(IrcMessage *message) {
|
||||||
|
IrcModeMessage *m = (IrcModeMessage *) message;
|
||||||
|
|
||||||
|
// mode changed: "#testik" "HanzZ" "+o" "hanzz_k"
|
||||||
|
std::string nickname = TO_UTF8(m->argument());
|
||||||
|
std::string mode = TO_UTF8(m->mode());
|
||||||
|
if (nickname.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
correctNickname(nickname);
|
||||||
|
|
||||||
|
if (!hasIRCBuddy(TO_UTF8(m->target().toLower()), nickname)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
IRCBuddy &buddy = getIRCBuddy(TO_UTF8(m->target().toLower()), nickname);
|
||||||
|
if (mode == "+o") {
|
||||||
|
buddy.setOp(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buddy.setOp(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_np->handleParticipantChanged(m_user, nickname, TO_UTF8(m->target().toLower()) + m_suffix,(int) buddy.isOp(), pbnetwork::STATUS_ONLINE, "");
|
||||||
|
|
||||||
sendUserToFrontend(user, pbnetwork::STATUS_ONLINE, "", TO_UTF8(m->newNick()));
|
LOG4CXX_INFO(logger, m_user << ": " << nickname << " changed mode to " << mode << " in " << TO_UTF8(m->target().toLower()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyIrcSession::on_topicChanged(IrcMessage *message) {
|
void MyIrcSession::on_topicChanged(IrcMessage *message) {
|
||||||
|
@ -336,23 +245,6 @@ void MyIrcSession::on_whoisMessageReceived(IrcMessage *message) {
|
||||||
m_whois.erase(nickname);
|
m_whois.erase(nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyIrcSession::on_namesMessageReceived(IrcMessage *message) {
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": NAMES received");
|
|
||||||
IrcBuffer *buffer = dynamic_cast<IrcBuffer *>(QObject::sender());
|
|
||||||
IrcUserModel *userModel = m_userModels.value(buffer);
|
|
||||||
if (!userModel) {
|
|
||||||
LOG4CXX_ERROR(logger, m_user << ": Cannot find UserModel for IrcBuffer " << TO_UTF8(buffer->name()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (IrcUser *user, userModel->users()) {
|
|
||||||
sendUserToFrontend(user, pbnetwork::STATUS_ONLINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, m_user << "Asking /who for channel " << TO_UTF8(buffer->name()));
|
|
||||||
sendCommand(IrcCommand::createWho(buffer->name()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyIrcSession::sendMessageToFrontend(const std::string &channel, const std::string &nick, const std::string &msg) {
|
void MyIrcSession::sendMessageToFrontend(const std::string &channel, const std::string &nick, const std::string &msg) {
|
||||||
QString html = "";//msg;
|
QString html = "";//msg;
|
||||||
// CommuniBackport::toPlainText(msg);
|
// CommuniBackport::toPlainText(msg);
|
||||||
|
@ -375,7 +267,7 @@ void MyIrcSession::sendMessageToFrontend(const std::string &channel, const std::
|
||||||
if (m_pms.find(nickname) != m_pms.end()) {
|
if (m_pms.find(nickname) != m_pms.end()) {
|
||||||
std::string room = m_pms[nickname].substr(0, m_pms[nickname].find("/"));
|
std::string room = m_pms[nickname].substr(0, m_pms[nickname].find("/"));
|
||||||
room = room.substr(0, room.find("@"));
|
room = room.substr(0, room.find("@"));
|
||||||
if (hasIrcUser(room, nickname)) {
|
if (hasIRCBuddy(room, nickname)) {
|
||||||
m_np->handleMessage(m_user, room + m_suffix, msg, nickname, TO_UTF8(html), "", false, true);
|
m_np->handleMessage(m_user, room + m_suffix, msg, nickname, TO_UTF8(html), "", false, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -384,20 +276,12 @@ void MyIrcSession::sendMessageToFrontend(const std::string &channel, const std::
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (IrcBuffer *buffer, m_bufferModel->buffers()) {
|
for (AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
std::string room = "#" + TO_UTF8(buffer->name());
|
if (!hasIRCBuddy(it->second->getChannel(), nickname)) {
|
||||||
IrcUserModel *userModel = m_userModels.value(buffer);
|
|
||||||
if (!userModel) {
|
|
||||||
LOG4CXX_ERROR(logger, m_user << ": Cannot find UserModel for IrcBuffer " << TO_UTF8(buffer->name()));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
addPM(nickname, it->second->getChannel());
|
||||||
if (!userModel->contains(FROM_UTF8(nickname))) {
|
m_np->handleMessage(m_user, it->second->getChannel() + m_suffix, msg, nickname, TO_UTF8(html), "", false, true);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
addPM(nickname, room + "/" + nickname);
|
|
||||||
m_np->handleMessage(m_user, room + m_suffix, msg, nickname, TO_UTF8(html), "", false, true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,10 +320,15 @@ void MyIrcSession::on_numericMessageReceived(IrcMessage *message) {
|
||||||
IrcNumericMessage *m = (IrcNumericMessage *) message;
|
IrcNumericMessage *m = (IrcNumericMessage *) message;
|
||||||
QStringList parameters = m->parameters();
|
QStringList parameters = m->parameters();
|
||||||
switch (m->code()) {
|
switch (m->code()) {
|
||||||
case Irc::RPL_TOPIC:
|
case 301:
|
||||||
|
break;
|
||||||
|
case 315:
|
||||||
|
LOG4CXX_INFO(logger, "End of /who request " << TO_UTF8(parameters[1]));
|
||||||
|
break;
|
||||||
|
case 332:
|
||||||
m_topicData = TO_UTF8(parameters[2]);
|
m_topicData = TO_UTF8(parameters[2]);
|
||||||
break;
|
break;
|
||||||
case Irc::RPL_TOPICWHOTIME:
|
case 333:
|
||||||
nick = TO_UTF8(parameters[2]);
|
nick = TO_UTF8(parameters[2]);
|
||||||
if (nick.find("!") != std::string::npos) {
|
if (nick.find("!") != std::string::npos) {
|
||||||
nick = nick.substr(0, nick.find("!"));
|
nick = nick.substr(0, nick.find("!"));
|
||||||
|
@ -449,49 +338,71 @@ void MyIrcSession::on_numericMessageReceived(IrcMessage *message) {
|
||||||
}
|
}
|
||||||
m_np->handleSubject(m_user, TO_UTF8(parameters[1].toLower()) + m_suffix, m_topicData, nick);
|
m_np->handleSubject(m_user, TO_UTF8(parameters[1].toLower()) + m_suffix, m_topicData, nick);
|
||||||
break;
|
break;
|
||||||
case Irc::ERR_NOSUCHNICK:
|
case 352: {
|
||||||
case Irc::ERR_NOSUCHSERVER:
|
channel = parameters[1].toLower();
|
||||||
|
nick = TO_UTF8(parameters[5]);
|
||||||
|
IRCBuddy &buddy = getIRCBuddy(TO_UTF8(channel), nick);
|
||||||
|
|
||||||
|
if (parameters[6].toUpper().startsWith("G")) {
|
||||||
|
if (!buddy.isAway()) {
|
||||||
|
buddy.setAway(true);
|
||||||
|
m_np->handleParticipantChanged(m_user, nick, TO_UTF8(channel) + m_suffix, buddy.isOp(), pbnetwork::STATUS_AWAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (buddy.isAway()) {
|
||||||
|
buddy.setAway(false);
|
||||||
|
m_np->handleParticipantChanged(m_user, nick, TO_UTF8(channel) + m_suffix, buddy.isOp(), pbnetwork::STATUS_ONLINE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 353:
|
||||||
|
channel = parameters[2].toLower();
|
||||||
|
members = parameters[3].split(" ");
|
||||||
|
|
||||||
|
LOG4CXX_INFO(logger, m_user << ": Received members for " << TO_UTF8(channel) << m_suffix);
|
||||||
|
for (int i = 0; i < members.size(); i++) {
|
||||||
|
bool op = 0;
|
||||||
|
std::string nickname = TO_UTF8(members.at(i));
|
||||||
|
op = correctNickname(nickname);
|
||||||
|
IRCBuddy &buddy = getIRCBuddy(TO_UTF8(channel), nickname);
|
||||||
|
buddy.setOp(op);
|
||||||
|
m_np->handleParticipantChanged(m_user, nickname, TO_UTF8(channel) + m_suffix, buddy.isOp(), pbnetwork::STATUS_ONLINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 366:
|
||||||
|
// ask /who to get away states
|
||||||
|
channel = parameters[1].toLower();
|
||||||
|
LOG4CXX_INFO(logger, m_user << "Asking /who for channel " << TO_UTF8(channel));
|
||||||
|
sendCommand(IrcCommand::createWho(channel));
|
||||||
|
break;
|
||||||
|
case 401:
|
||||||
|
case 402:
|
||||||
nick = TO_UTF8(parameters[1]);
|
nick = TO_UTF8(parameters[1]);
|
||||||
if (m_whois.find(nick) != m_whois.end()) {
|
if (m_whois.find(nick) != m_whois.end()) {
|
||||||
sendMessageToFrontend(m_whois[nick], "whois", nick + ": No such client");
|
sendMessageToFrontend(m_whois[nick], "whois", nick + ": No such client");
|
||||||
m_whois.erase(nick);
|
m_whois.erase(nick);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Irc::ERR_ERRONEUSNICKNAME:
|
case 432:
|
||||||
m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Erroneous Nickname");
|
m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Erroneous Nickname");
|
||||||
break;
|
break;
|
||||||
case Irc::ERR_NICKNAMEINUSE:
|
case 433:
|
||||||
case Irc::ERR_NICKCOLLISION:
|
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
foreach (IrcBuffer *buffer, m_bufferModel->buffers()) {
|
m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
|
||||||
if (!buffer->isChannel()) {
|
}
|
||||||
continue;
|
if (m_suffix.empty()) {
|
||||||
}
|
m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname is already in use");
|
||||||
m_np->handleRoomNicknameChanged(m_user, TO_UTF8(buffer->title()) + m_suffix, TO_UTF8(nickName() + "_"));
|
|
||||||
m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), TO_UTF8(buffer->title()) + m_suffix, 0, pbnetwork::STATUS_ONLINE, "", TO_UTF8(nickName() + "_"));
|
|
||||||
}
|
}
|
||||||
setNickName(nickName() + "_");
|
|
||||||
open();
|
|
||||||
// for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
|
||||||
// m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
|
|
||||||
// }
|
|
||||||
// if (m_suffix.empty()) {
|
|
||||||
// m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname is already in use");
|
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
// foreach (IrcBuffer *buffer, m_bufferModel->buffers()) {
|
case 436:
|
||||||
// if (!buffer->isChannel()) {
|
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
// continue;
|
m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
|
||||||
// }
|
}
|
||||||
// m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), TO_UTF8(buffer->title()) + m_suffix, pbnetwork::PARTICIPANT_FLAG_CONFLICT);
|
m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname collision KILL");
|
||||||
// }
|
case 464:
|
||||||
// m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Nickname collision KILL");
|
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
// break;
|
m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), it->second->getChannel() + m_suffix, pbnetwork::PARTICIPANT_FLAG_NOT_AUTHORIZED);
|
||||||
case Irc::ERR_PASSWDMISMATCH:
|
|
||||||
foreach (IrcBuffer *buffer, m_bufferModel->buffers()) {
|
|
||||||
if (!buffer->isChannel()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
m_np->handleParticipantChanged(m_user, TO_UTF8(nickName()), TO_UTF8(buffer->title()) + m_suffix, pbnetwork::PARTICIPANT_FLAG_NOT_AUTHORIZED);
|
|
||||||
}
|
}
|
||||||
if (m_suffix.empty()) {
|
if (m_suffix.empty()) {
|
||||||
m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Password incorrect");
|
m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_INVALID_USERNAME, "Password incorrect");
|
||||||
|
@ -514,31 +425,14 @@ void MyIrcSession::on_numericMessageReceived(IrcMessage *message) {
|
||||||
if (m->code() >= 400 && m->code() < 500) {
|
if (m->code() >= 400 && m->code() < 500) {
|
||||||
LOG4CXX_INFO(logger, m_user << ": Error message received: " << message->toData().data());
|
LOG4CXX_INFO(logger, m_user << ": Error message received: " << message->toData().data());
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": Numeric message received: " << message->toData().data());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyIrcSession::awayTimeout() {
|
void MyIrcSession::awayTimeout() {
|
||||||
foreach (IrcBuffer *buffer, m_bufferModel->buffers()) {
|
for(AutoJoinMap::iterator it = m_autoJoin.begin(); it != m_autoJoin.end(); it++) {
|
||||||
if (!buffer->isChannel()) {
|
if (it->second->shouldAskWho()) {
|
||||||
continue;
|
LOG4CXX_INFO(logger, "The time has come. Asking /who " << it->second->getChannel() << " again to get current away states.");
|
||||||
|
sendCommand(IrcCommand::createWho(FROM_UTF8(it->second->getChannel())));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap userData = buffer->userData();
|
|
||||||
int awayCycle = userData["awayCycle"].toInt();
|
|
||||||
int awayTick = userData["awayTick"].toInt();
|
|
||||||
|
|
||||||
if (awayTick == awayCycle) {
|
|
||||||
LOG4CXX_INFO(logger, m_user << ": The time has come. Asking /who " << TO_UTF8(buffer->title()) << " again to get current away states.");
|
|
||||||
sendCommand(IrcCommand::createWho(buffer->title()));
|
|
||||||
awayTick = 0;
|
|
||||||
}
|
|
||||||
awayTick++;
|
|
||||||
|
|
||||||
userData["awayCycle"] = awayCycle;
|
|
||||||
userData["awayTick"] = awayTick;
|
|
||||||
buffer->setUserData(userData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,14 +440,46 @@ void MyIrcSession::on_noticeMessageReceived(IrcMessage *message) {
|
||||||
IrcNoticeMessage *m = (IrcNoticeMessage *) message;
|
IrcNoticeMessage *m = (IrcNoticeMessage *) message;
|
||||||
LOG4CXX_INFO(logger, m_user << ": NOTICE " << TO_UTF8(m->content()));
|
LOG4CXX_INFO(logger, m_user << ": NOTICE " << TO_UTF8(m->content()));
|
||||||
|
|
||||||
std::string msg = TO_UTF8(m->content());
|
QString msg = m->content();
|
||||||
|
CommuniBackport::toPlainText(msg);
|
||||||
|
|
||||||
std::string target = TO_UTF8(m->target().toLower());
|
std::string target = TO_UTF8(m->target().toLower());
|
||||||
std::string nickname = TO_UTF8(m->nick());
|
if (target.find("#") == 0) {
|
||||||
sendMessageToFrontend(target, nickname, msg);
|
std::string nickname = TO_UTF8(m->nick());
|
||||||
|
correctNickname(nickname);
|
||||||
|
m_np->handleMessage(m_user, target + m_suffix, TO_UTF8(msg), nickname);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::string nickname = TO_UTF8(m->nick());
|
||||||
|
correctNickname(nickname);
|
||||||
|
if (nickname.find(".") != std::string::npos) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_pms.find(nickname) != m_pms.end()) {
|
||||||
|
std::string room = m_pms[nickname].substr(0, m_pms[nickname].find("/"));
|
||||||
|
room = room.substr(0, room.find("@"));
|
||||||
|
if (hasIRCBuddy(room, nickname)) {
|
||||||
|
m_np->handleMessage(m_user, room + m_suffix, TO_UTF8(msg), nickname, "", "", false, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nickname = nickname + m_suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nickname = nickname + m_suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG4CXX_INFO(logger, nickname);
|
||||||
|
m_np->handleMessage(m_user, nickname, TO_UTF8(msg), "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyIrcSession::onMessageReceived(IrcMessage *message) {
|
void MyIrcSession::onMessageReceived(IrcMessage *message) {
|
||||||
switch (message->type()) {
|
switch (message->type()) {
|
||||||
|
case IrcMessage::Join:
|
||||||
|
on_joined(message);
|
||||||
|
break;
|
||||||
case IrcMessage::Part:
|
case IrcMessage::Part:
|
||||||
on_parted(message);
|
on_parted(message);
|
||||||
break;
|
break;
|
||||||
|
@ -563,6 +489,9 @@ void MyIrcSession::onMessageReceived(IrcMessage *message) {
|
||||||
case IrcMessage::Nick:
|
case IrcMessage::Nick:
|
||||||
on_nickChanged(message);
|
on_nickChanged(message);
|
||||||
break;
|
break;
|
||||||
|
case IrcMessage::Mode:
|
||||||
|
on_modeChanged(message);
|
||||||
|
break;
|
||||||
case IrcMessage::Topic:
|
case IrcMessage::Topic:
|
||||||
on_topicChanged(message);
|
on_topicChanged(message);
|
||||||
break;
|
break;
|
||||||
|
@ -578,9 +507,6 @@ void MyIrcSession::onMessageReceived(IrcMessage *message) {
|
||||||
case IrcMessage::Whois:
|
case IrcMessage::Whois:
|
||||||
on_whoisMessageReceived(message);
|
on_whoisMessageReceived(message);
|
||||||
break;
|
break;
|
||||||
case IrcMessage::Names:
|
|
||||||
on_namesMessageReceived(message);
|
|
||||||
break;
|
|
||||||
default:break;
|
default:break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,6 @@
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN
|
#ifndef Q_MOC_RUN
|
||||||
#include <IrcConnection>
|
#include <IrcConnection>
|
||||||
#include <IrcBufferModel>
|
|
||||||
#include <IrcBuffer>
|
|
||||||
#include <IrcUserModel>
|
|
||||||
#include <transport/NetworkPlugin.h>
|
#include <transport/NetworkPlugin.h>
|
||||||
#include "Swiften/Swiften.h"
|
#include "Swiften/Swiften.h"
|
||||||
#include <boost/smart_ptr/make_shared.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
@ -41,10 +38,58 @@ class MyIrcSession : public IrcConnection
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
class AutoJoinChannel {
|
||||||
|
public:
|
||||||
|
AutoJoinChannel(const std::string &channel = "", const std::string &password = "", int awayCycle = 12) : m_channel(channel), m_password(password),
|
||||||
|
m_awayCycle(awayCycle), m_currentAwayTick(0) {}
|
||||||
|
virtual ~AutoJoinChannel() {}
|
||||||
|
|
||||||
|
const std::string &getChannel() { return m_channel; }
|
||||||
|
const std::string &getPassword() { return m_password; }
|
||||||
|
bool shouldAskWho() {
|
||||||
|
if (m_currentAwayTick == m_awayCycle) {
|
||||||
|
m_currentAwayTick = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
m_currentAwayTick++;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_channel;
|
||||||
|
std::string m_password;
|
||||||
|
int m_awayCycle;
|
||||||
|
int m_currentAwayTick;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IRCBuddy {
|
||||||
|
public:
|
||||||
|
IRCBuddy(bool op = false, bool away = false) : m_op(op), m_away(away) {};
|
||||||
|
|
||||||
|
void setOp(bool op) { m_op = op; }
|
||||||
|
bool isOp() { return m_op; }
|
||||||
|
void setAway(bool away) { m_away = away; }
|
||||||
|
bool isAway() { return m_away; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_op;
|
||||||
|
bool m_away;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<std::string, boost::shared_ptr<AutoJoinChannel> > AutoJoinMap;
|
||||||
|
typedef std::map<std::string, std::map<std::string, IRCBuddy> > IRCBuddyMap;
|
||||||
|
|
||||||
MyIrcSession(const std::string &user, IRCNetworkPlugin *np, const std::string &suffix = "", QObject* parent = 0);
|
MyIrcSession(const std::string &user, IRCNetworkPlugin *np, const std::string &suffix = "", QObject* parent = 0);
|
||||||
virtual ~MyIrcSession();
|
virtual ~MyIrcSession();
|
||||||
|
|
||||||
void createBufferModel();
|
void addAutoJoinChannel(const std::string &channel, const std::string &password) {
|
||||||
|
m_autoJoin[channel] = boost::make_shared<AutoJoinChannel>(channel, password, 12 + m_autoJoin.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeAutoJoinChannel(const std::string &channel) {
|
||||||
|
m_autoJoin.erase(channel);
|
||||||
|
removeIRCBuddies(channel);
|
||||||
|
}
|
||||||
|
|
||||||
// We are sending PM message. On XMPP side, user is sending PM using the particular channel,
|
// We are sending PM message. On XMPP side, user is sending PM using the particular channel,
|
||||||
// for example #room@irc.freenode.org/hanzz. On IRC side, we are forwarding this message
|
// for example #room@irc.freenode.org/hanzz. On IRC side, we are forwarding this message
|
||||||
|
@ -60,26 +105,37 @@ public:
|
||||||
return m_identify;
|
return m_identify;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasIrcUser(const std::string &channel, const std::string &name);
|
bool hasIRCBuddy(const std::string &channel, const std::string &name) {
|
||||||
|
return m_buddies[channel].find(name) != m_buddies[channel].end();
|
||||||
|
}
|
||||||
|
|
||||||
void correctNickname(std::string &nick);
|
IRCBuddy &getIRCBuddy(const std::string &channel, const std::string &name) {
|
||||||
IrcUser *getIrcUser(IrcBuffer *buffer, IrcMessage *message);
|
return m_buddies[channel][name];
|
||||||
IrcUser *getIrcUser(IrcBuffer *buffer, std::string &nick);
|
}
|
||||||
|
|
||||||
|
void removeIRCBuddy(const std::string &channel, const std::string &name) {
|
||||||
|
m_buddies[channel].erase(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeIRCBuddies(const std::string &channel) {
|
||||||
|
m_buddies.erase(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool correctNickname(std::string &nickname);
|
||||||
|
|
||||||
void sendWhoisCommand(const std::string &channel, const std::string &to);
|
void sendWhoisCommand(const std::string &channel, const std::string &to);
|
||||||
void sendMessageToFrontend(const std::string &channel, const std::string &nickname, const std::string &msg);
|
void sendMessageToFrontend(const std::string &channel, const std::string &nickname, const std::string &msg);
|
||||||
void sendUserToFrontend(IrcUser *user, pbnetwork::StatusType statusType, const std::string &statusMessage = "", const std::string &newNick = "");
|
|
||||||
|
|
||||||
void on_joined(IrcMessage *message);
|
void on_joined(IrcMessage *message);
|
||||||
void on_parted(IrcMessage *message);
|
void on_parted(IrcMessage *message);
|
||||||
void on_quit(IrcMessage *message);
|
void on_quit(IrcMessage *message);
|
||||||
void on_nickChanged(IrcMessage *message);
|
void on_nickChanged(IrcMessage *message);
|
||||||
|
void on_modeChanged(IrcMessage *message);
|
||||||
void on_topicChanged(IrcMessage *message);
|
void on_topicChanged(IrcMessage *message);
|
||||||
void on_messageReceived(IrcMessage *message);
|
void on_messageReceived(IrcMessage *message);
|
||||||
void on_numericMessageReceived(IrcMessage *message);
|
void on_numericMessageReceived(IrcMessage *message);
|
||||||
void on_noticeMessageReceived(IrcMessage *message);
|
void on_noticeMessageReceived(IrcMessage *message);
|
||||||
void on_whoisMessageReceived(IrcMessage *message);
|
void on_whoisMessageReceived(IrcMessage *message);
|
||||||
void on_namesMessageReceived(IrcMessage *message);
|
|
||||||
|
|
||||||
int rooms;
|
int rooms;
|
||||||
|
|
||||||
|
@ -88,32 +144,24 @@ protected Q_SLOTS:
|
||||||
void on_disconnected();
|
void on_disconnected();
|
||||||
void on_socketError(QAbstractSocket::SocketError error);
|
void on_socketError(QAbstractSocket::SocketError error);
|
||||||
|
|
||||||
void onBufferAdded(IrcBuffer* buffer);
|
|
||||||
void onBufferRemoved(IrcBuffer* buffer);
|
|
||||||
|
|
||||||
void onIrcUserAdded(IrcUser *user);
|
|
||||||
void onIrcUserChanged(const QString &);
|
|
||||||
void onIrcUserChanged(bool);
|
|
||||||
void onIrcUserRemoved(IrcUser *user);
|
|
||||||
|
|
||||||
void onMessageReceived(IrcMessage* message);
|
void onMessageReceived(IrcMessage* message);
|
||||||
void awayTimeout();
|
void awayTimeout();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
IRCNetworkPlugin *m_np;
|
IRCNetworkPlugin *m_np;
|
||||||
IrcBufferModel *m_bufferModel;
|
|
||||||
std::string m_user;
|
std::string m_user;
|
||||||
std::string m_identify;
|
std::string m_identify;
|
||||||
|
AutoJoinMap m_autoJoin;
|
||||||
std::string m_topicData;
|
std::string m_topicData;
|
||||||
bool m_connected;
|
bool m_connected;
|
||||||
std::list<std::string> m_rooms;
|
std::list<std::string> m_rooms;
|
||||||
std::list<std::string> m_names;
|
std::list<std::string> m_names;
|
||||||
std::map<std::string, std::string> m_pms;
|
std::map<std::string, std::string> m_pms;
|
||||||
|
IRCBuddyMap m_buddies;
|
||||||
QTimer *m_awayTimer;
|
QTimer *m_awayTimer;
|
||||||
std::string m_suffix;
|
std::string m_suffix;
|
||||||
std::map<std::string, std::string> m_whois;
|
std::map<std::string, std::string> m_whois;
|
||||||
QHash<IrcBuffer*, IrcUserModel*> m_userModels;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SESSION_H
|
#endif // SESSION_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()
|
||||||
|
|
||||||
|
|
|
@ -9,24 +9,19 @@
|
||||||
#include "purple.h"
|
#include "purple.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#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 +78,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 +117,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, "accepting SSL certificate");
|
||||||
LOG4CXX_INFO(logger, "rejecting SSL certificate");
|
|
||||||
va_arg(actions, char *);
|
|
||||||
va_arg(actions, GCallback);
|
|
||||||
} else {
|
|
||||||
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 +175,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 +198,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() {
|
||||||
|
@ -274,11 +260,11 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
if (strippedKey != key2) {
|
if (strippedKey != key2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
||||||
|
@ -313,9 +299,9 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
std::string username(purple_account_get_username_wrapped(account));
|
std::string username(purple_account_get_username_wrapped(account));
|
||||||
std::vector <std::string> u = split(username, '@');
|
std::vector <std::string> u = split(username, '@');
|
||||||
purple_account_set_username_wrapped(account, (const char*) u.front().c_str());
|
purple_account_set_username_wrapped(account, (const char*) u.front().c_str());
|
||||||
std::vector <std::string> s = split(u.back(), ':');
|
std::vector <std::string> s = split(u.back(), ':');
|
||||||
purple_account_set_string_wrapped(account, "server", s.front().c_str());
|
purple_account_set_string_wrapped(account, "server", s.front().c_str());
|
||||||
purple_account_set_int_wrapped(account, "port", atoi(s.back().c_str()));
|
purple_account_set_int_wrapped(account, "port", atoi(s.back().c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CONFIG_STRING_DEFAULTED(config, "proxy.type", "").empty()) {
|
if (!CONFIG_STRING_DEFAULTED(config, "proxy.type", "").empty()) {
|
||||||
|
@ -360,23 +346,15 @@ 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, 0, "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 << "'");
|
||||||
np->handleDisconnected(user, 1, "Invalid protocol " + protocol);
|
np->handleDisconnected(user, 0, "Invalid protocol " + protocol);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +362,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
account = purple_accounts_find_wrapped(name.c_str(), protocol.c_str());
|
account = purple_accounts_find_wrapped(name.c_str(), protocol.c_str());
|
||||||
if (m_accounts.find(account) != m_accounts.end() && m_accounts[account] != user) {
|
if (m_accounts.find(account) != m_accounts.end() && m_accounts[account] != user) {
|
||||||
LOG4CXX_INFO(logger, "Account '" << name << "' is already used by '" << m_accounts[account] << "'");
|
LOG4CXX_INFO(logger, "Account '" << name << "' is already used by '" << m_accounts[account] << "'");
|
||||||
np->handleDisconnected(user, 1, "Account '" + name + "' is already used by '" + m_accounts[account] + "'");
|
np->handleDisconnected(user, 0, "Account '" + name + "' is already used by '" + m_accounts[account] + "'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG4CXX_INFO(logger, "Using previously created account with name '" << name.c_str() << "' and protocol '" << protocol << "'");
|
LOG4CXX_INFO(logger, "Using previously created account with name '" << name.c_str() << "' and protocol '" << protocol << "'");
|
||||||
|
@ -405,12 +383,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 +400,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 +489,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 +520,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;
|
||||||
|
@ -691,23 +648,11 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateConversationActivity(PurpleAccount *account, const std::string &buddyName) {
|
|
||||||
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, buddyName.c_str(), account);
|
|
||||||
if (!conv) {
|
|
||||||
conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_IM, buddyName.c_str(), account);
|
|
||||||
}
|
|
||||||
if (conv) {
|
|
||||||
purple_conversation_set_data_wrapped(conv, "unseen_count", 0);
|
|
||||||
purple_conversation_update_wrapped(conv, PURPLE_CONV_UPDATE_UNSEEN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void handleTypingRequest(const std::string &user, const std::string &buddyName) {
|
void handleTypingRequest(const std::string &user, const std::string &buddyName) {
|
||||||
PurpleAccount *account = m_sessions[user];
|
PurpleAccount *account = m_sessions[user];
|
||||||
if (account) {
|
if (account) {
|
||||||
LOG4CXX_INFO(logger, user << ": sending typing notify to " << buddyName);
|
LOG4CXX_INFO(logger, user << ": sending typing notify to " << buddyName);
|
||||||
serv_send_typing_wrapped(purple_account_get_connection_wrapped(account), buddyName.c_str(), PURPLE_TYPING);
|
serv_send_typing_wrapped(purple_account_get_connection_wrapped(account), buddyName.c_str(), PURPLE_TYPING);
|
||||||
updateConversationActivity(account, buddyName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,7 +660,6 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
PurpleAccount *account = m_sessions[user];
|
PurpleAccount *account = m_sessions[user];
|
||||||
if (account) {
|
if (account) {
|
||||||
serv_send_typing_wrapped(purple_account_get_connection_wrapped(account), buddyName.c_str(), PURPLE_TYPED);
|
serv_send_typing_wrapped(purple_account_get_connection_wrapped(account), buddyName.c_str(), PURPLE_TYPED);
|
||||||
updateConversationActivity(account, buddyName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,7 +667,14 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
PurpleAccount *account = m_sessions[user];
|
PurpleAccount *account = m_sessions[user];
|
||||||
if (account) {
|
if (account) {
|
||||||
serv_send_typing_wrapped(purple_account_get_connection_wrapped(account), buddyName.c_str(), PURPLE_NOT_TYPING);
|
serv_send_typing_wrapped(purple_account_get_connection_wrapped(account), buddyName.c_str(), PURPLE_NOT_TYPING);
|
||||||
updateConversationActivity(account, buddyName);
|
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, buddyName.c_str(), account);
|
||||||
|
if (!conv) {
|
||||||
|
conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_IM, buddyName.c_str(), account);
|
||||||
|
}
|
||||||
|
if (conv) {
|
||||||
|
purple_conversation_set_data_wrapped(conv, "unseen_count", 0);
|
||||||
|
purple_conversation_update_wrapped(conv, PURPLE_CONV_UPDATE_UNSEEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,29 +685,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 +693,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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,14 +714,13 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
disp = purple_account_get_username(account);
|
disp = purple_account_get_username(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, user << ": Display name is " << disp << ", nickname is " << nickname);
|
|
||||||
if (nickname != disp) {
|
if (nickname != disp) {
|
||||||
handleRoomNicknameChanged(np->m_accounts[account], room, disp);
|
handleRoomNicknameChanged(np->m_accounts[account], room, disp);
|
||||||
np->handleParticipantChanged(np->m_accounts[account], nickname, room, 0, pbnetwork::STATUS_ONLINE, "", disp);
|
np->handleParticipantChanged(np->m_accounts[account], nickname, room, 0, pbnetwork::STATUS_ONLINE, "", disp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +733,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,7 +742,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
||||||
if (xfer) {
|
if (xfer) {
|
||||||
m_unhandledXfers.erase(user + fileName + buddyName);
|
m_unhandledXfers.erase(user + fileName + buddyName);
|
||||||
FTData *ftData = (FTData *) xfer->ui_data;
|
FTData *ftData = (FTData *) xfer->ui_data;
|
||||||
|
|
||||||
ftData->id = ftID;
|
ftData->id = ftID;
|
||||||
m_xfers[ftID] = xfer;
|
m_xfers[ftID] = xfer;
|
||||||
purple_xfer_request_accepted_wrapped(xfer, fileName.c_str());
|
purple_xfer_request_accepted_wrapped(xfer, fileName.c_str());
|
||||||
|
@ -877,13 +804,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) {
|
||||||
|
@ -1035,7 +958,7 @@ void buddyListNewNode(PurpleBlistNode *node) {
|
||||||
cache->nodes[node] = 1;
|
cache->nodes[node] = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> groups = getGroups(buddy);
|
std::vector<std::string> groups = getGroups(buddy);
|
||||||
LOG4CXX_INFO(logger, "Buddy updated " << np->m_accounts[account] << " " << purple_buddy_get_name_wrapped(buddy) << " " << getAlias(buddy) << " group (" << groups.size() << ")=" << groups[0]);
|
LOG4CXX_INFO(logger, "Buddy updated " << np->m_accounts[account] << " " << purple_buddy_get_name_wrapped(buddy) << " " << getAlias(buddy) << " group (" << groups.size() << ")=" << groups[0]);
|
||||||
|
@ -1188,39 +1111,12 @@ 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *calculate_data_hash(guchar *data, size_t len,
|
|
||||||
const gchar *hash_algo)
|
|
||||||
{
|
|
||||||
PurpleCipherContext *context;
|
|
||||||
static gchar digest[129]; /* 512 bits hex + \0 */
|
|
||||||
|
|
||||||
context = purple_cipher_context_new_by_name(hash_algo, NULL);
|
|
||||||
if (context == NULL)
|
|
||||||
{
|
|
||||||
purple_debug_error("jabber", "Could not find %s cipher\n", hash_algo);
|
|
||||||
g_return_val_if_reached(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Hash the data */
|
|
||||||
purple_cipher_context_append(context, data, len);
|
|
||||||
if (!purple_cipher_context_digest_to_str(context, sizeof(digest), digest, NULL))
|
|
||||||
{
|
|
||||||
purple_debug_error("jabber", "Failed to get digest for %s cipher.\n",
|
|
||||||
hash_algo);
|
|
||||||
g_return_val_if_reached(NULL);
|
|
||||||
}
|
|
||||||
purple_cipher_context_destroy(context);
|
|
||||||
|
|
||||||
return g_strdup(digest);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void conv_write_im(PurpleConversation *conv, const char *who, const char *msg, PurpleMessageFlags flags, time_t mtime) {
|
static void conv_write_im(PurpleConversation *conv, const char *who, const char *msg, PurpleMessageFlags flags, time_t mtime) {
|
||||||
// Don't forwards our own messages.
|
// Don't forwards our own messages.
|
||||||
if (purple_conversation_get_type_wrapped(conv) == PURPLE_CONV_TYPE_IM && (flags & PURPLE_MESSAGE_SEND || flags & PURPLE_MESSAGE_SYSTEM)) {
|
if (purple_conversation_get_type_wrapped(conv) == PURPLE_CONV_TYPE_IM && (flags & PURPLE_MESSAGE_SEND || flags & PURPLE_MESSAGE_SYSTEM)) {
|
||||||
|
@ -1228,84 +1124,23 @@ static void conv_write_im(PurpleConversation *conv, const char *who, const char
|
||||||
}
|
}
|
||||||
PurpleAccount *account = purple_conversation_get_account_wrapped(conv);
|
PurpleAccount *account = purple_conversation_get_account_wrapped(conv);
|
||||||
|
|
||||||
std::string message_;
|
// char *striped = purple_markup_strip_html_wrapped(message);
|
||||||
std::string xhtml_;
|
// std::string msg = striped;
|
||||||
|
// g_free(striped);
|
||||||
|
|
||||||
if (flags & PURPLE_MESSAGE_IMAGES && !CONFIG_STRING(config, "service.web_directory").empty() && !CONFIG_STRING(config, "service.web_url").empty() ) {
|
|
||||||
LOG4CXX_INFO(logger, "Received image body='" << msg << "'");
|
|
||||||
std::string body = msg;
|
|
||||||
std::string plain = msg;
|
|
||||||
size_t i;
|
|
||||||
while ((i = body.find("<img id=\"")) != std::string::npos) {
|
|
||||||
int from = i + strlen("<img id=\"");
|
|
||||||
int to = body.find("\"", from + 1);
|
|
||||||
std::string id = body.substr(from, to - from);
|
|
||||||
LOG4CXX_INFO(logger, "Image ID = '" << id << "' " << from << " " << to);
|
|
||||||
|
|
||||||
PurpleStoredImage *image = purple_imgstore_find_by_id(atoi(id.c_str()));
|
// Escape HTML characters.
|
||||||
if (!image) {
|
char *newline = purple_strdup_withhtml_wrapped(msg);
|
||||||
LOG4CXX_ERROR(logger, "Cannot find image with id " << id << ".");
|
char *strip, *xhtml;
|
||||||
return;
|
purple_markup_html_to_xhtml_wrapped(newline, &xhtml, &strip);
|
||||||
}
|
// xhtml_linkified = spectrum_markup_linkify(xhtml);
|
||||||
|
std::string message_(strip);
|
||||||
|
|
||||||
std::string ext = "icon";
|
std::string xhtml_(xhtml);
|
||||||
std::string name;
|
g_free(newline);
|
||||||
guchar * data = (guchar *) purple_imgstore_get_data_wrapped(image);
|
g_free(xhtml);
|
||||||
size_t len = purple_imgstore_get_size_wrapped(image);
|
// g_free(xhtml_linkified);
|
||||||
if (len < 1000000 && data) {
|
g_free(strip);
|
||||||
ext = purple_imgstore_get_extension(image);
|
|
||||||
char *hash = calculate_data_hash(data, len, "sha1");
|
|
||||||
if (!hash) {
|
|
||||||
LOG4CXX_WARN(logger, "Cannot compute hash for the image.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
name = hash;
|
|
||||||
g_free(hash);
|
|
||||||
|
|
||||||
std::ofstream output;
|
|
||||||
LOG4CXX_INFO(logger, "Storing image to " << std::string(CONFIG_STRING(config, "service.web_directory") + "/" + name + "." + ext));
|
|
||||||
output.open(std::string(CONFIG_STRING(config, "service.web_directory") + "/" + name + "." + ext).c_str(), std::ios::out | std::ios::binary);
|
|
||||||
if (output.fail()) {
|
|
||||||
LOG4CXX_ERROR(logger, "Open file failure: " << strerror(errno));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
output.write((char *)data, len);
|
|
||||||
output.close();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG4CXX_WARN(logger, "Image bigger than 1MB.");
|
|
||||||
purple_imgstore_unref_wrapped(image);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
purple_imgstore_unref_wrapped(image);
|
|
||||||
|
|
||||||
std::string src = CONFIG_STRING(config, "service.web_url") + "/" + name + "." + ext;
|
|
||||||
std::string img = "<img src=\"" + src + "\"/>";
|
|
||||||
boost::replace_all(body, "<img id=\"" + id + "\">", img);
|
|
||||||
boost::replace_all(plain, "<img id=\"" + id + "\">", src);
|
|
||||||
}
|
|
||||||
LOG4CXX_INFO(logger, "New image body='" << body << "'");
|
|
||||||
char *strip, *xhtml;
|
|
||||||
purple_markup_html_to_xhtml_wrapped(body.c_str(), &xhtml, &strip);
|
|
||||||
message_ = strip;
|
|
||||||
if (message_.empty()) {
|
|
||||||
message_ = plain;
|
|
||||||
}
|
|
||||||
xhtml_ = xhtml;
|
|
||||||
g_free(xhtml);
|
|
||||||
g_free(strip);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Escape HTML characters.
|
|
||||||
char *newline = purple_strdup_withhtml_wrapped(msg);
|
|
||||||
char *strip, *xhtml;
|
|
||||||
purple_markup_html_to_xhtml_wrapped(newline, &xhtml, &strip);
|
|
||||||
message_ = strip;
|
|
||||||
xhtml_ = xhtml;
|
|
||||||
g_free(newline);
|
|
||||||
g_free(xhtml);
|
|
||||||
g_free(strip);
|
|
||||||
}
|
|
||||||
|
|
||||||
// AIM and XMPP adds <body>...</body> here...
|
// AIM and XMPP adds <body>...</body> here...
|
||||||
if (xhtml_.find("<body>") == 0) {
|
if (xhtml_.find("<body>") == 0) {
|
||||||
|
@ -1326,6 +1161,8 @@ static void conv_write_im(PurpleConversation *conv, const char *who, const char
|
||||||
timestamp = buf;
|
timestamp = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LOG4CXX_INFO(logger, "Received message body='" << message_ << "' xhtml='" << xhtml_ << "'");
|
||||||
|
|
||||||
if (purple_conversation_get_type_wrapped(conv) == PURPLE_CONV_TYPE_IM) {
|
if (purple_conversation_get_type_wrapped(conv) == PURPLE_CONV_TYPE_IM) {
|
||||||
std::string w = purple_normalize_wrapped(account, who);
|
std::string w = purple_normalize_wrapped(account, who);
|
||||||
std::string n;
|
std::string n;
|
||||||
|
@ -1334,13 +1171,12 @@ static void conv_write_im(PurpleConversation *conv, const char *who, const char
|
||||||
n = w.substr((int) pos + 1, w.length() - (int) pos);
|
n = w.substr((int) pos + 1, w.length() - (int) pos);
|
||||||
w.erase((int) pos, w.length() - (int) pos);
|
w.erase((int) pos, w.length() - (int) pos);
|
||||||
}
|
}
|
||||||
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' xhtml='" << xhtml_ << "' name='" << w << "'");
|
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' name='" << w);
|
||||||
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_ << "' 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 +1204,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,37 +1217,12 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean conv_has_focus(PurpleConversation *conv) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void conv_chat_topic_changed(PurpleConversation *conv, const char *who, const char *topic) {
|
|
||||||
LOG4CXX_INFO(logger, "Conversation topic changed");
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void conv_present(PurpleConversation *conv) {
|
|
||||||
if (purple_conversation_get_type_wrapped(conv) == PURPLE_CONV_TYPE_CHAT) {
|
|
||||||
LOG4CXX_INFO(logger, "Conversation presented");
|
|
||||||
conv_chat_add_users(conv, PURPLE_CONV_CHAT_WRAPPED(conv)->in_room, TRUE);
|
|
||||||
const char *topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT_WRAPPED(conv));
|
|
||||||
if (topic && *topic != '\0') {
|
|
||||||
conv_chat_topic_changed(conv, topic, PURPLE_CONV_CHAT_WRAPPED(conv)->who);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LOG4CXX_INFO(logger, "Conversation created with an empty topic");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static PurpleConversationUiOps conversation_ui_ops =
|
static PurpleConversationUiOps conversation_ui_ops =
|
||||||
{
|
{
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -1423,8 +1234,8 @@ static PurpleConversationUiOps conversation_ui_ops =
|
||||||
NULL,//conv_chat_rename_user, /* chat_rename_user */
|
NULL,//conv_chat_rename_user, /* chat_rename_user */
|
||||||
conv_chat_remove_users, /* chat_remove_users */
|
conv_chat_remove_users, /* chat_remove_users */
|
||||||
NULL,//pidgin_conv_chat_update_user, /* chat_update_user */
|
NULL,//pidgin_conv_chat_update_user, /* chat_update_user */
|
||||||
conv_present,//pidgin_conv_present_conversation, /* present */
|
NULL,//pidgin_conv_present_conversation, /* present */
|
||||||
conv_has_focus,//pidgin_conv_has_focus, /* has_focus */
|
NULL,//pidgin_conv_has_focus, /* has_focus */
|
||||||
NULL,//pidgin_conv_custom_smiley_add, /* custom_smiley_add */
|
NULL,//pidgin_conv_custom_smiley_add, /* custom_smiley_add */
|
||||||
NULL,//pidgin_conv_custom_smiley_write, /* custom_smiley_write */
|
NULL,//pidgin_conv_custom_smiley_write, /* custom_smiley_write */
|
||||||
NULL,//pidgin_conv_custom_smiley_close, /* custom_smiley_close */
|
NULL,//pidgin_conv_custom_smiley_close, /* custom_smiley_close */
|
||||||
|
@ -1488,7 +1299,7 @@ static void *notify_user_info(PurpleConnection *gc, const char *who, PurpleNotif
|
||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
name.erase((int) pos, name.length() - (int) pos);
|
name.erase((int) pos, name.length() - (int) pos);
|
||||||
|
|
||||||
|
|
||||||
GList *vcardEntries = purple_notify_user_info_get_entries_wrapped(user_info);
|
GList *vcardEntries = purple_notify_user_info_get_entries_wrapped(user_info);
|
||||||
PurpleNotifyUserInfoEntry *vcardEntry;
|
PurpleNotifyUserInfoEntry *vcardEntry;
|
||||||
std::string firstName;
|
std::string firstName;
|
||||||
|
@ -1588,69 +1399,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,
|
||||||
|
@ -1834,7 +1582,7 @@ static gssize XferRead(PurpleXfer *xfer, guchar **buffer, gssize size) {
|
||||||
// int data_size = repeater->getDataToSend(buffer, size);
|
// int data_size = repeater->getDataToSend(buffer, size);
|
||||||
// if (data_size == 0)
|
// if (data_size == 0)
|
||||||
// return 0;
|
// return 0;
|
||||||
//
|
//
|
||||||
// return data_size;
|
// return data_size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1879,10 +1627,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 +1666,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");
|
||||||
|
@ -1948,7 +1697,7 @@ static void transport_core_ui_init(void)
|
||||||
purple_connections_set_ui_ops_wrapped(&conn_ui_ops);
|
purple_connections_set_ui_ops_wrapped(&conn_ui_ops);
|
||||||
purple_conversations_set_ui_ops_wrapped(&conversation_ui_ops);
|
purple_conversations_set_ui_ops_wrapped(&conversation_ui_ops);
|
||||||
purple_roomlist_set_ui_ops_wrapped(&roomlist_ui_ops);
|
purple_roomlist_set_ui_ops_wrapped(&roomlist_ui_ops);
|
||||||
|
|
||||||
// #ifndef WIN32
|
// #ifndef WIN32
|
||||||
// purple_dnsquery_set_ui_ops_wrapped(getDNSUiOps());
|
// purple_dnsquery_set_ui_ops_wrapped(getDNSUiOps());
|
||||||
// #endif
|
// #endif
|
||||||
|
@ -2019,7 +1768,7 @@ debug_init(void)
|
||||||
REGISTER_G_LOG_HANDLER("GLib-GObject");
|
REGISTER_G_LOG_HANDLER("GLib-GObject");
|
||||||
REGISTER_G_LOG_HANDLER("GThread");
|
REGISTER_G_LOG_HANDLER("GThread");
|
||||||
REGISTER_G_LOG_HANDLER("GConf");
|
REGISTER_G_LOG_HANDLER("GConf");
|
||||||
|
|
||||||
|
|
||||||
#undef REGISTER_G_LOD_HANDLER
|
#undef REGISTER_G_LOD_HANDLER
|
||||||
}
|
}
|
||||||
|
@ -2046,12 +1795,9 @@ static void signed_on(PurpleConnection *gc, gpointer unused) {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
purple_roomlist_get_list_wrapped(gc);
|
purple_roomlist_get_list_wrapped(gc);
|
||||||
|
|
||||||
// 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) {
|
||||||
|
@ -2113,6 +1859,11 @@ static void gotAttention(PurpleAccount *account, const char *who, PurpleConversa
|
||||||
np->handleAttention(np->m_accounts[account], w, "");
|
np->handleAttention(np->m_accounts[account], w, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void conv_chat_topic_changed(PurpleConversation *conv, const char *who, const char *topic) {
|
||||||
|
PurpleAccount *account = purple_conversation_get_account_wrapped(conv);
|
||||||
|
np->handleSubject(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), topic ? topic : "", who ? who : "Spectrum 2");
|
||||||
|
}
|
||||||
|
|
||||||
static bool initPurple() {
|
static bool initPurple() {
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
|
@ -2130,7 +1881,7 @@ static bool initPurple() {
|
||||||
std::string cacertsDir = CONFIG_STRING_DEFAULTED(config, "purple.cacerts_dir", "./ca-certs");
|
std::string cacertsDir = CONFIG_STRING_DEFAULTED(config, "purple.cacerts_dir", "./ca-certs");
|
||||||
LOG4CXX_INFO(logger, "Setting libpurple cacerts directory to: " << cacertsDir);
|
LOG4CXX_INFO(logger, "Setting libpurple cacerts directory to: " << cacertsDir);
|
||||||
purple_certificate_add_ca_search_path_wrapped(cacertsDir.c_str());
|
purple_certificate_add_ca_search_path_wrapped(cacertsDir.c_str());
|
||||||
|
|
||||||
std::string userDir = CONFIG_STRING_DEFAULTED(config, "service.working_dir", "./");
|
std::string userDir = CONFIG_STRING_DEFAULTED(config, "service.working_dir", "./");
|
||||||
LOG4CXX_INFO(logger, "Setting libpurple user directory to: " << userDir);
|
LOG4CXX_INFO(logger, "Setting libpurple user directory to: " << userDir);
|
||||||
|
|
||||||
|
@ -2197,7 +1948,7 @@ static bool initPurple() {
|
||||||
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-recv-request", &xfer_handle, PURPLE_CALLBACK(newXfer), NULL);
|
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-recv-request", &xfer_handle, PURPLE_CALLBACK(newXfer), NULL);
|
||||||
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-recv-complete", &xfer_handle, PURPLE_CALLBACK(XferReceiveComplete), NULL);
|
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-recv-complete", &xfer_handle, PURPLE_CALLBACK(XferReceiveComplete), NULL);
|
||||||
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-send-complete", &xfer_handle, PURPLE_CALLBACK(XferSendComplete), NULL);
|
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-send-complete", &xfer_handle, PURPLE_CALLBACK(XferSendComplete), NULL);
|
||||||
//
|
//
|
||||||
// purple_commands_init();
|
// purple_commands_init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2225,20 +1976,14 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
|
||||||
|
|
||||||
if (firstPing) {
|
if (firstPing) {
|
||||||
firstPing = false;
|
firstPing = false;
|
||||||
NetworkPlugin::PluginConfig cfg;
|
NetworkPlugin::PluginConfig cfg;
|
||||||
cfg.setSupportMUC(true);
|
cfg.setSupportMUC(true);
|
||||||
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 {
|
|
||||||
cfg.setNeedRegistration(true);
|
|
||||||
}
|
|
||||||
np->sendConfig(cfg);
|
np->sendConfig(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2254,8 +1999,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,28 +2020,15 @@ 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);
|
||||||
purple_input_add_wrapped(main_socket, PURPLE_INPUT_READ, &transportDataReceived, NULL);
|
purple_input_add_wrapped(main_socket, PURPLE_INPUT_READ, &transportDataReceived, NULL);
|
||||||
purple_timeout_add_seconds_wrapped(30, pingTimeout, NULL);
|
purple_timeout_add_seconds_wrapped(30, pingTimeout, NULL);
|
||||||
|
|
||||||
np = new SpectrumNetworkPlugin();
|
np = new SpectrumNetworkPlugin();
|
||||||
bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";
|
bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendSMS(const std::string &to, const std::string &msg) {
|
void sendSMS(const std::string &to, const std::string &msg) {
|
||||||
// TODO: Probably
|
// TODO: Probably
|
||||||
std::string data = "To: " + to + "\n";
|
std::string data = "To: " + to + "\n";
|
||||||
data += "\n";
|
data += "\n";
|
||||||
data += msg;
|
data += msg;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -232,7 +231,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Config *config;
|
Config *config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -69,16 +68,16 @@ class ForwardIQHandler : public Swift::IQHandler {
|
||||||
private:
|
private:
|
||||||
NetworkPlugin *m_np;
|
NetworkPlugin *m_np;
|
||||||
std::string m_user;
|
std::string m_user;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
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;
|
||||||
Swift::XMPPParser *m_xmppParser;
|
Swift::XMPPParser *m_xmppParser;
|
||||||
Swift::FullPayloadParserFactoryCollection m_collection2;
|
Swift::FullPayloadParserFactoryCollection m_collection2;
|
||||||
|
@ -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,45 +120,45 @@ 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()];
|
||||||
if (resource.empty()) {
|
if (resource.empty()) {
|
||||||
iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain()));
|
iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain()));
|
||||||
} else {
|
} else {
|
||||||
iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain(), resource));
|
iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain(), resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_handlers[user]->m_id2resource.erase(stanza->getID());
|
m_handlers[user]->m_id2resource.erase(stanza->getID());
|
||||||
}
|
}
|
||||||
client->getIQRouter()->sendIQ(iq);
|
client->getIQRouter()->sendIQ(iq);
|
||||||
|
@ -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));
|
||||||
|
@ -246,38 +245,38 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
Swift::Presence::ref lastPresence = oracle->getLastPresence(item.getJID());
|
Swift::Presence::ref lastPresence = oracle->getLastPresence(item.getJID());
|
||||||
pbnetwork::StatusType status = lastPresence ? ((pbnetwork::StatusType) lastPresence->getShow()) : pbnetwork::STATUS_NONE;
|
pbnetwork::StatusType status = lastPresence ? ((pbnetwork::StatusType) lastPresence->getShow()) : pbnetwork::STATUS_NONE;
|
||||||
handleBuddyChanged(user, item.getJID().toBare().toString(),
|
handleBuddyChanged(user, item.getJID().toBare().toString(),
|
||||||
item.getName(), item.getGroups(), status);
|
item.getName(), item.getGroups(), status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (presence->getPayload<Swift::MUCUserPayload>() != NULL || presence->getPayload<Swift::MUCPayload>() != NULL) {
|
// if (presence->getPayload<Swift::MUCUserPayload>() != NULL || presence->getPayload<Swift::MUCPayload>() != NULL) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// LOG4CXX_INFO(logger, user << ": " << presence->getFrom().toBare().toString() << " presence changed");
|
// LOG4CXX_INFO(logger, user << ": " << presence->getFrom().toBare().toString() << " presence changed");
|
||||||
//
|
//
|
||||||
// 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();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// boost::optional<Swift::XMPPRosterItem> item = m_users[user]->getRoster()->getItem(presence->getFrom());
|
// boost::optional<Swift::XMPPRosterItem> item = m_users[user]->getRoster()->getItem(presence->getFrom());
|
||||||
// if (item) {
|
// if (item) {
|
||||||
// handleBuddyChanged(user, presence->getFrom().toBare().toString(), item->getName(), item->getGroups(), (pbnetwork::StatusType) presence->getShow(), message, photo);
|
// handleBuddyChanged(user, presence->getFrom().toBare().toString(), item->getName(), item->getGroups(), (pbnetwork::StatusType) presence->getShow(), message, photo);
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
// std::vector<std::string> groups;
|
// std::vector<std::string> groups;
|
||||||
// handleBuddyChanged(user, presence->getFrom().toBare().toString(), presence->getFrom().toBare(), groups, (pbnetwork::StatusType) presence->getShow(), message, photo);
|
// handleBuddyChanged(user, presence->getFrom().toBare().toString(), presence->getFrom().toBare(), groups, (pbnetwork::StatusType) presence->getShow(), message, photo);
|
||||||
// }
|
// }
|
||||||
presence->setTo(user);
|
presence->setTo(user);
|
||||||
std::string xml = safeByteArrayToString(serializer->serializeElement(presence));
|
std::string xml = safeByteArrayToString(serializer->serializeElement(presence));
|
||||||
sendRawXML(xml);
|
sendRawXML(xml);
|
||||||
|
@ -302,11 +301,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
|
||||||
|
|
||||||
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) {
|
||||||
LOG4CXX_INFO(logger, user << ": connecting as " << legacyName);
|
LOG4CXX_INFO(logger, user << ": connecting as " << legacyName);
|
||||||
Swift::JID jid(legacyName);
|
boost::shared_ptr<Swift::Client> client = boost::make_shared<Swift::Client>(Swift::JID(legacyName + "/Spectrum"), password, m_factories);
|
||||||
if (legacyName.find("/") == std::string::npos) {
|
|
||||||
jid = Swift::JID(legacyName + "/Spectrum");
|
|
||||||
}
|
|
||||||
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = SWIFTEN_SHRPTR_NAMESPACE::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 +317,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,10 +335,10 @@ 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));
|
||||||
client->onMessageReceived.disconnect(boost::bind(&SwiftenPlugin::handleSwiftMessageReceived, this, user, _1));
|
client->onMessageReceived.disconnect(boost::bind(&SwiftenPlugin::handleSwiftMessageReceived, this, user, _1));
|
||||||
client->getRoster()->onInitialRosterPopulated.disconnect(boost::bind(&SwiftenPlugin::handleSwiftRosterReceived, this, user));
|
client->getRoster()->onInitialRosterPopulated.disconnect(boost::bind(&SwiftenPlugin::handleSwiftRosterReceived, this, user));
|
||||||
client->getPresenceOracle()->onPresenceChange.disconnect(boost::bind(&SwiftenPlugin::handleSwiftPresenceChanged, this, user, _1));
|
client->getPresenceOracle()->onPresenceChange.disconnect(boost::bind(&SwiftenPlugin::handleSwiftPresenceChanged, this, user, _1));
|
||||||
|
@ -358,7 +353,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,10 +361,10 @@ 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));
|
||||||
request->send();
|
request->send();
|
||||||
client->getSubscriptionManager()->requestSubscription(buddyName);
|
client->getSubscriptionManager()->requestSubscription(buddyName);
|
||||||
}
|
}
|
||||||
|
@ -377,10 +372,10 @@ 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));
|
||||||
request->send();
|
request->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,13 +383,13 @@ 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));
|
||||||
request->send();
|
request->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,8 +404,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,47 +25,47 @@ 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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int HTTPRequest::curlCallBack(char* data, size_t size, size_t nmemb, HTTPRequest* obj)
|
int HTTPRequest::curlCallBack(char* data, size_t size, size_t nmemb, HTTPRequest* obj)
|
||||||
{
|
{
|
||||||
int writtenSize = 0;
|
int writtenSize = 0;
|
||||||
if(obj && data) {
|
if(obj && data) {
|
||||||
obj->callbackdata.append(data, size*nmemb);
|
obj->callbackdata.append(data, size*nmemb);
|
||||||
writtenSize = (int)(size*nmemb);
|
writtenSize = (int)(size*nmemb);
|
||||||
}
|
}
|
||||||
return writtenSize;
|
return writtenSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool HTTPRequest::GET(std::string url, std::string &data)
|
bool HTTPRequest::GET(std::string url, std::string &data)
|
||||||
{
|
{
|
||||||
if(curlhandle) {
|
if(curlhandle) {
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_CUSTOMREQUEST, NULL);
|
curl_easy_setopt(curlhandle, CURLOPT_CUSTOMREQUEST, NULL);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_ENCODING, "");
|
curl_easy_setopt(curlhandle, CURLOPT_ENCODING, "");
|
||||||
|
|
||||||
data = "";
|
data = "";
|
||||||
callbackdata = "";
|
callbackdata = "";
|
||||||
memset(curl_errorbuffer, 0, 1024);
|
memset(curl_errorbuffer, 0, 1024);
|
||||||
|
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_ERRORBUFFER, curl_errorbuffer);
|
curl_easy_setopt(curlhandle, CURLOPT_ERRORBUFFER, curl_errorbuffer);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, curlCallBack);
|
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, curlCallBack);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_WRITEDATA, this);
|
curl_easy_setopt(curlhandle, CURLOPT_WRITEDATA, this);
|
||||||
|
|
||||||
/* Set http request and url */
|
/* Set http request and url */
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_HTTPGET, 1);
|
curl_easy_setopt(curlhandle, CURLOPT_HTTPGET, 1);
|
||||||
// curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1);
|
// curl_easy_setopt(curlhandle, CURLOPT_VERBOSE, 1);
|
||||||
curl_easy_setopt(curlhandle, CURLOPT_URL, url.c_str());
|
curl_easy_setopt(curlhandle, CURLOPT_URL, url.c_str());
|
||||||
|
|
||||||
/* Send http request and return status*/
|
/* Send http request and return status*/
|
||||||
if(CURLE_OK == curl_easy_perform(curlhandle)) {
|
if(CURLE_OK == curl_easy_perform(curlhandle)) {
|
||||||
data = callbackdata;
|
data = callbackdata;
|
||||||
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,20 +4,20 @@ 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;
|
||||||
|
|
||||||
req.init();
|
req.init();
|
||||||
req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
|
req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
|
||||||
|
|
||||||
|
@ -36,15 +36,15 @@ void CreateFriendRequest::finalize()
|
||||||
if(!success) {
|
if(!success) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ void DestroyFriendRequest::run()
|
||||||
success = twitObj->friendshipDestroy(frnd, false);
|
success = twitObj->friendshipDestroy(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);
|
||||||
|
@ -22,12 +22,12 @@ void DestroyFriendRequest::finalize()
|
||||||
if(!success) {
|
if(!success) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
DEFINE_LOGGER(logger, "DirectMessageRequest")
|
DEFINE_LOGGER(logger, "DirectMessageRequest")
|
||||||
|
|
||||||
void DirectMessageRequest::run()
|
void DirectMessageRequest::run()
|
||||||
{
|
{
|
||||||
replyMsg = "";
|
replyMsg = "";
|
||||||
if(username != "") success = twitObj->directMessageSend(username, data, false);
|
if(username != "") success = twitObj->directMessageSend(username, data, false);
|
||||||
|
@ -20,16 +20,13 @@ void DirectMessageRequest::finalize()
|
||||||
if(!success) {
|
if(!success) {
|
||||||
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, 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 {
|
callBack(user, username, messages, error);
|
||||||
LOG4CXX_INFO(logger, user << " - " << replyMsg);
|
|
||||||
}
|
|
||||||
callBack(user, username, messages, error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,16 +3,16 @@
|
||||||
|
|
||||||
DEFINE_LOGGER(logger, "FetchFriends")
|
DEFINE_LOGGER(logger, "FetchFriends")
|
||||||
|
|
||||||
void FetchFriends::run()
|
void FetchFriends::run()
|
||||||
{
|
{
|
||||||
replyMsg = "";
|
replyMsg = "";
|
||||||
std::string next = "";
|
std::string next = "";
|
||||||
success = twitObj->friendsIdsGet(next, twitObj->getTwitterUsername(), false);
|
success = twitObj->friendsIdsGet(next, twitObj->getTwitterUsername(), false);
|
||||||
if(!success) return;
|
if(!success) return;
|
||||||
|
|
||||||
twitObj->getLastWebResponse( replyMsg );
|
twitObj->getLastWebResponse( replyMsg );
|
||||||
std::vector<std::string> IDs = getIDs( replyMsg );
|
std::vector<std::string> IDs = getIDs( replyMsg );
|
||||||
|
|
||||||
success = twitObj->userLookup(IDs, true);
|
success = twitObj->userLookup(IDs, true);
|
||||||
if(!success) return;
|
if(!success) return;
|
||||||
|
|
||||||
|
@ -22,13 +22,13 @@ void FetchFriends::run()
|
||||||
HTTPRequest req;
|
HTTPRequest req;
|
||||||
req.init();
|
req.init();
|
||||||
req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
|
req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
|
||||||
|
|
||||||
for(int i=0 ; i<friends.size() ; i++) {
|
for(int i=0 ; i<friends.size() ; i++) {
|
||||||
std::string img;
|
std::string img;
|
||||||
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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ void FetchFriends::finalize()
|
||||||
if(!success) {
|
if(!success) {
|
||||||
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,24 +47,24 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OAuthAccessTokenKey, OAuthAccessTokenSecret;
|
std::string OAuthAccessTokenKey, OAuthAccessTokenSecret;
|
||||||
sessions[user]->getOAuth().getOAuthTokenKey( OAuthAccessTokenKey );
|
sessions[user]->getOAuth().getOAuthTokenKey( OAuthAccessTokenKey );
|
||||||
sessions[user]->getOAuth().getOAuthTokenSecret( OAuthAccessTokenSecret );
|
sessions[user]->getOAuth().getOAuthTokenSecret( OAuthAccessTokenSecret );
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
storagebackend->updateUserSetting((long)info.id, OAUTH_KEY, OAuthAccessTokenKey);
|
storagebackend->updateUserSetting((long)info.id, OAUTH_KEY, OAuthAccessTokenKey);
|
||||||
storagebackend->updateUserSetting((long)info.id, OAUTH_SECRET, OAuthAccessTokenSecret);
|
storagebackend->updateUserSetting((long)info.id, OAUTH_SECRET, OAuthAccessTokenSecret);
|
||||||
|
|
||||||
connectionState[user] = CONNECTED;
|
connectionState[user] = CONNECTED;
|
||||||
LOG4CXX_INFO(logger, user << ": Sent PIN " << data << " and obtained Access Token");
|
LOG4CXX_INFO(logger, user << ": Sent PIN " << data << " and obtained Access Token");
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "ProfileImageRequest.h"
|
#include "ProfileImageRequest.h"
|
||||||
#include "../HTTPRequest.h"
|
#include "../HTTPRequest.h"
|
||||||
DEFINE_LOGGER(logger, "ProfileImageRequest")
|
DEFINE_LOGGER(logger, "ProfileImageRequest")
|
||||||
void ProfileImageRequest::run()
|
void ProfileImageRequest::run()
|
||||||
{
|
{
|
||||||
HTTPRequest req;
|
HTTPRequest req;
|
||||||
req.init();
|
req.init();
|
||||||
req.setProxy(ip, port, puser, ppasswd);
|
req.setProxy(ip, port, puser, ppasswd);
|
||||||
|
@ -14,13 +14,13 @@ 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);
|
||||||
} else {
|
} else {
|
||||||
LOG4CXX_INFO(logger, user << " - " << callbackdata);
|
LOG4CXX_INFO(logger, user << " - " << callbackdata);
|
||||||
img = callbackdata;
|
img = callbackdata;
|
||||||
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,17 +12,14 @@ void RetweetRequest::finalize()
|
||||||
if(!success) {
|
if(!success) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "../TwitterResponseParser.h"
|
#include "../TwitterResponseParser.h"
|
||||||
|
|
||||||
DEFINE_LOGGER(logger, "StatusUpdateRequest")
|
DEFINE_LOGGER(logger, "StatusUpdateRequest")
|
||||||
void StatusUpdateRequest::run()
|
void StatusUpdateRequest::run()
|
||||||
{
|
{
|
||||||
replyMsg = "";
|
replyMsg = "";
|
||||||
success = twitObj->statusUpdate(data);
|
success = twitObj->statusUpdate(data);
|
||||||
|
@ -18,16 +18,13 @@ void StatusUpdateRequest::finalize()
|
||||||
if(!success) {
|
if(!success) {
|
||||||
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 {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#include "TimelineRequest.h"
|
#include "TimelineRequest.h"
|
||||||
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);
|
||||||
|
|
||||||
if(!success) return;
|
if(!success) return;
|
||||||
|
|
||||||
replyMsg = "";
|
replyMsg = "";
|
||||||
twitObj->getLastWebResponse( replyMsg );
|
twitObj->getLastWebResponse( replyMsg );
|
||||||
//LOG4CXX_INFO(logger, user << " - " << replyMsg.length() << " " << replyMsg << "\n" );
|
//LOG4CXX_INFO(logger, user << " - " << replyMsg.length() << " " << replyMsg << "\n" );
|
||||||
tweets = getTimeline(replyMsg);
|
tweets = getTimeline(replyMsg);
|
||||||
|
@ -21,12 +21,12 @@ void TimelineRequest::finalize()
|
||||||
if(!success) {
|
if(!success) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,20 +23,20 @@ const std::string OLD_APP_SECRET = "EveLmCXJIg2R7BTCpm6OWV8YyX49nI0pxnYXh7JMvDg"
|
||||||
#define abs(x) ((x)<0?-(x):(x))
|
#define abs(x) ((x)<0?-(x):(x))
|
||||||
#define SHA(x) (Swift::Hexify::hexify(Swift::SHA1::getHash(Swift::createByteArray((x)))))
|
#define SHA(x) (Swift::Hexify::hexify(Swift::SHA1::getHash(Swift::createByteArray((x)))))
|
||||||
|
|
||||||
//Compares two +ve intergers 'a' and 'b' represented as strings
|
//Compares two +ve intergers 'a' and 'b' represented as strings
|
||||||
static int cmp(std::string a, std::string b)
|
static int cmp(std::string a, std::string b)
|
||||||
{
|
{
|
||||||
int diff = abs((int)a.size() - (int)b.size());
|
int diff = abs((int)a.size() - (int)b.size());
|
||||||
if(a.size() < b.size()) a = std::string(diff,'0') + a;
|
if(a.size() < b.size()) a = std::string(diff,'0') + a;
|
||||||
else b = std::string(diff,'0') + b;
|
else b = std::string(diff,'0') + b;
|
||||||
|
|
||||||
if(a == b) return 0;
|
if(a == b) return 0;
|
||||||
if(a < b) return -1;
|
if(a < b) return -1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, StorageBackend *storagebackend, const std::string &host, int port) : NetworkPlugin()
|
TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, StorageBackend *storagebackend, const std::string &host, int port) : NetworkPlugin()
|
||||||
{
|
{
|
||||||
this->config = config;
|
this->config = config;
|
||||||
this->storagebackend = storagebackend;
|
this->storagebackend = storagebackend;
|
||||||
|
@ -60,9 +60,9 @@ TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, Stora
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
adminLegacyName = "twitter.com";
|
adminLegacyName = "twitter.com";
|
||||||
adminChatRoom = "#twitter";
|
adminChatRoom = "#twitter";
|
||||||
adminNickName = "twitter";
|
adminNickName = "twitter";
|
||||||
adminAlias = "twitter";
|
adminAlias = "twitter";
|
||||||
|
|
||||||
OAUTH_KEY = "twitter_oauth_token";
|
OAUTH_KEY = "twitter_oauth_token";
|
||||||
|
@ -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,14 +87,14 @@ 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
|
||||||
|
|
||||||
|
|
||||||
LOG4CXX_INFO(logger, "Starting the plugin.");
|
LOG4CXX_INFO(logger, "Starting the plugin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
TwitterPlugin::~TwitterPlugin()
|
TwitterPlugin::~TwitterPlugin()
|
||||||
{
|
{
|
||||||
delete storagebackend;
|
delete storagebackend;
|
||||||
std::set<std::string>::iterator it;
|
std::set<std::string>::iterator it;
|
||||||
|
@ -103,13 +103,13 @@ TwitterPlugin::~TwitterPlugin()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send data to NetworkPlugin server
|
// Send data to NetworkPlugin server
|
||||||
void TwitterPlugin::sendData(const std::string &string)
|
void TwitterPlugin::sendData(const std::string &string)
|
||||||
{
|
{
|
||||||
m_conn->write(Swift::createSafeByteArray(string));
|
m_conn->write(Swift::createSafeByteArray(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;
|
||||||
|
@ -125,42 +125,42 @@ void TwitterPlugin::_handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::
|
||||||
}
|
}
|
||||||
|
|
||||||
// User trying to login into his twitter account
|
// User trying to login into his twitter account
|
||||||
void TwitterPlugin::handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password)
|
void TwitterPlugin::handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// User logging out
|
// User logging out
|
||||||
void TwitterPlugin::handleLogoutRequest(const std::string &user, const std::string &legacyName)
|
void TwitterPlugin::handleLogoutRequest(const std::string &user, const std::string &legacyName)
|
||||||
{
|
{
|
||||||
if (userdb.count(user)) {
|
if (userdb.count(user)) {
|
||||||
delete userdb[user].sessions;
|
delete userdb[user].sessions;
|
||||||
|
@ -176,8 +176,8 @@ void TwitterPlugin::handleLogoutRequest(const std::string &user, const std::stri
|
||||||
// User joining a Chatroom
|
// User joining a Chatroom
|
||||||
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,62 +188,62 @@ 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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// User leaving a Chatroom
|
// User leaving a Chatroom
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Messages to be sent to Twitter
|
// Messages to be sent to Twitter
|
||||||
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 = "";
|
||||||
|
|
||||||
/** Parsing the message - Assuming message format to be <cmd>[ ]*<data>**/
|
/** Parsing the message - Assuming message format to be <cmd>[ ]*<data>**/
|
||||||
int i;
|
int i;
|
||||||
for(i=0 ; i<message.size() && message[i] != ' '; i++) cmd += message[i];
|
for(i=0 ; i<message.size() && message[i] != ' '; i++) cmd += message[i];
|
||||||
while(i<message.size() && message[i] == ' ') i++;
|
while(i<message.size() && message[i] == ' ') i++;
|
||||||
data = message.substr(i);
|
data = message.substr(i);
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
|
||||||
if(cmd == "#pin")
|
if(cmd == "#pin")
|
||||||
tp->runAsThread(new PINExchangeProcess(np, userdb[user].sessions, user, data));
|
tp->runAsThread(new PINExchangeProcess(np, userdb[user].sessions, user, data));
|
||||||
else if(cmd == "#help")
|
else if(cmd == "#help")
|
||||||
tp->runAsThread(new HelpMessageRequest(user, CONFIG_STRING(config, "service.jid"), boost::bind(&TwitterPlugin::helpMessageResponse, this, _1, _2)));
|
tp->runAsThread(new HelpMessageRequest(user, CONFIG_STRING(config, "service.jid"), boost::bind(&TwitterPlugin::helpMessageResponse, this, _1, _2)));
|
||||||
else if(cmd[0] == '@') {
|
else if(cmd[0] == '@') {
|
||||||
std::string username = cmd.substr(1);
|
std::string username = cmd.substr(1);
|
||||||
tp->runAsThread(new DirectMessageRequest(userdb[user].sessions, user, username, data,
|
tp->runAsThread(new DirectMessageRequest(userdb[user].sessions, user, username, data,
|
||||||
boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3, _4)));
|
boost::bind(&TwitterPlugin::directMessageResponse, this, _1, _2, _3, _4)));
|
||||||
}
|
}
|
||||||
else if(cmd == "#status")
|
else if(cmd == "#status")
|
||||||
tp->runAsThread(new StatusUpdateRequest(userdb[user].sessions, user, data,
|
tp->runAsThread(new StatusUpdateRequest(userdb[user].sessions, user, data,
|
||||||
boost::bind(&TwitterPlugin::statusUpdateResponse, this, _1, _2)));
|
boost::bind(&TwitterPlugin::statusUpdateResponse, this, _1, _2)));
|
||||||
else if(cmd == "#timeline")
|
else if(cmd == "#timeline")
|
||||||
tp->runAsThread(new TimelineRequest(userdb[user].sessions, user, data, "",
|
tp->runAsThread(new TimelineRequest(userdb[user].sessions, user, data, "",
|
||||||
boost::bind(&TwitterPlugin::displayTweets, this, _1, _2, _3, _4)));
|
boost::bind(&TwitterPlugin::displayTweets, this, _1, _2, _3, _4)));
|
||||||
else if(cmd == "#friends")
|
else if(cmd == "#friends")
|
||||||
tp->runAsThread(new FetchFriends(userdb[user].sessions, user,
|
tp->runAsThread(new FetchFriends(userdb[user].sessions, user,
|
||||||
boost::bind(&TwitterPlugin::displayFriendlist, this, _1, _2, _3, _4)));
|
boost::bind(&TwitterPlugin::displayFriendlist, this, _1, _2, _3, _4)));
|
||||||
else if(cmd == "#follow")
|
else if(cmd == "#follow")
|
||||||
tp->runAsThread(new CreateFriendRequest(userdb[user].sessions, user, data.substr(0,data.find('@')),
|
tp->runAsThread(new CreateFriendRequest(userdb[user].sessions, user, data.substr(0,data.find('@')),
|
||||||
boost::bind(&TwitterPlugin::createFriendResponse, this, _1, _2, _3, _4)));
|
boost::bind(&TwitterPlugin::createFriendResponse, this, _1, _2, _3, _4)));
|
||||||
else if(cmd == "#unfollow")
|
else if(cmd == "#unfollow")
|
||||||
tp->runAsThread(new DestroyFriendRequest(userdb[user].sessions, user, data.substr(0,data.find('@')),
|
tp->runAsThread(new DestroyFriendRequest(userdb[user].sessions, user, data.substr(0,data.find('@')),
|
||||||
boost::bind(&TwitterPlugin::deleteFriendResponse, this, _1, _2, _3)));
|
boost::bind(&TwitterPlugin::deleteFriendResponse, this, _1, _2, _3)));
|
||||||
else if(cmd == "#retweet")
|
else if(cmd == "#retweet")
|
||||||
tp->runAsThread(new RetweetRequest(userdb[user].sessions, user, data,
|
tp->runAsThread(new RetweetRequest(userdb[user].sessions, user, data,
|
||||||
boost::bind(&TwitterPlugin::RetweetResponse, this, _1, _2)));
|
boost::bind(&TwitterPlugin::RetweetResponse, this, _1, _2)));
|
||||||
else if(cmd == "#mode") {
|
else if(cmd == "#mode") {
|
||||||
|
@ -259,13 +259,13 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
|
||||||
|
|
||||||
setTwitterMode(user, m);
|
setTwitterMode(user, m);
|
||||||
if((userdb[user].twitterMode == SINGLECONTACT || userdb[user].twitterMode == CHATROOM) && prevm == MULTIPLECONTACT) clearRoster(user);
|
if((userdb[user].twitterMode == SINGLECONTACT || userdb[user].twitterMode == CHATROOM) && prevm == MULTIPLECONTACT) clearRoster(user);
|
||||||
else if(userdb[user].twitterMode == MULTIPLECONTACT)
|
else if(userdb[user].twitterMode == MULTIPLECONTACT)
|
||||||
tp->runAsThread(new FetchFriends(userdb[user].sessions, user, boost::bind(&TwitterPlugin::populateRoster, this, _1, _2, _3, _4)));
|
tp->runAsThread(new FetchFriends(userdb[user].sessions, user, boost::bind(&TwitterPlugin::populateRoster, this, _1, _2, _3, _4)));
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -281,9 +281,9 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
|
||||||
}
|
}
|
||||||
else handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
else handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
||||||
"Unknown command! Type #help for a list of available commands.", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
"Unknown command! Type #help for a list of available commands.", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
std::string buddy = legacyName;
|
std::string buddy = legacyName;
|
||||||
if(userdb[user].twitterMode == CHATROOM) buddy = legacyName.substr(legacyName.find("/") + 1);
|
if(userdb[user].twitterMode == CHATROOM) buddy = legacyName.substr(legacyName.find("/") + 1);
|
||||||
if(legacyName != "twitter") {
|
if(legacyName != "twitter") {
|
||||||
|
@ -293,45 +293,45 @@ 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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
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()) {
|
||||||
if(userdb[user].buddiesImgs.count(legacyName) == 0) {
|
if(userdb[user].buddiesImgs.count(legacyName) == 0) {
|
||||||
tp->runAsThread(new ProfileImageRequest(config, user, legacyName, userdb[user].buddiesInfo[legacyName].getProfileImgURL(), id,
|
tp->runAsThread(new ProfileImageRequest(config, user, legacyName, userdb[user].buddiesInfo[legacyName].getProfileImgURL(), id,
|
||||||
|
@ -368,13 +368,13 @@ void TwitterPlugin::pollForDirectMessages()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TwitterPlugin::getUserOAuthKeyAndSecret(const std::string user, std::string &key, std::string &secret)
|
bool TwitterPlugin::getUserOAuthKeyAndSecret(const std::string user, std::string &key, std::string &secret)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(dblock);
|
boost::mutex::scoped_lock lock(dblock);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,13 +384,13 @@ bool TwitterPlugin::getUserOAuthKeyAndSecret(const std::string user, std::string
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitterPlugin::checkSpectrum1User(const std::string user)
|
bool TwitterPlugin::checkSpectrum1User(const std::string user)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(dblock);
|
boost::mutex::scoped_lock lock(dblock);
|
||||||
|
|
||||||
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,19 +398,19 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TwitterPlugin::getTwitterMode(const std::string user)
|
int TwitterPlugin::getTwitterMode(const std::string user)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(dblock);
|
boost::mutex::scoped_lock lock(dblock);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,18 +425,18 @@ int TwitterPlugin::getTwitterMode(const std::string user)
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitterPlugin::setTwitterMode(const std::string user, int m)
|
bool TwitterPlugin::setTwitterMode(const std::string user, int m)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(dblock);
|
boost::mutex::scoped_lock lock(dblock);
|
||||||
|
|
||||||
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,23 +444,23 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TwitterPlugin::storeUserOAuthKeyAndSecret(const std::string user, const std::string OAuthKey, const std::string OAuthSecret)
|
bool TwitterPlugin::storeUserOAuthKeyAndSecret(const std::string user, const std::string OAuthKey, const std::string OAuthSecret)
|
||||||
{
|
{
|
||||||
|
|
||||||
boost::mutex::scoped_lock lock(dblock);
|
boost::mutex::scoped_lock lock(dblock);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
storagebackend->updateUserSetting((long)info.id, OAUTH_KEY, OAuthKey);
|
storagebackend->updateUserSetting((long)info.id, OAUTH_KEY, OAuthKey);
|
||||||
storagebackend->updateUserSetting((long)info.id, OAUTH_SECRET, OAuthSecret);
|
storagebackend->updateUserSetting((long)info.id, OAUTH_SECRET, OAuthSecret);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -471,21 +471,21 @@ 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")) {
|
||||||
std::string ip = CONFIG_STRING(config,"proxy.server");
|
std::string ip = CONFIG_STRING(config,"proxy.server");
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << CONFIG_INT(config,"proxy.port");
|
out << CONFIG_INT(config,"proxy.port");
|
||||||
std::string port = out.str();
|
std::string port = out.str();
|
||||||
|
|
||||||
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);
|
||||||
userdb[user].sessions->setProxyServerPort(port);
|
userdb[user].sessions->setProxyServerPort(port);
|
||||||
|
@ -498,7 +498,7 @@ void TwitterPlugin::initUserSession(const std::string user, const std::string le
|
||||||
userdb[user].spectrum1User = checkSpectrum1User(user);
|
userdb[user].spectrum1User = checkSpectrum1User(user);
|
||||||
|
|
||||||
userdb[user].connectionState = NEW;
|
userdb[user].connectionState = NEW;
|
||||||
userdb[user].legacyName = username;
|
userdb[user].legacyName = username;
|
||||||
userdb[user].sessions->setTwitterUsername(username);
|
userdb[user].sessions->setTwitterUsername(username);
|
||||||
userdb[user].sessions->setTwitterPassword(passwd);
|
userdb[user].sessions->setTwitterPassword(passwd);
|
||||||
|
|
||||||
|
@ -511,24 +511,24 @@ void TwitterPlugin::initUserSession(const std::string user, const std::string le
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitterPlugin::OAuthFlowComplete(const std::string user, twitCurl *obj)
|
void TwitterPlugin::OAuthFlowComplete(const std::string user, twitCurl *obj)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(userlock);
|
boost::mutex::scoped_lock lock(userlock);
|
||||||
|
|
||||||
delete userdb[user].sessions;
|
delete userdb[user].sessions;
|
||||||
userdb[user].sessions = obj->clone();
|
userdb[user].sessions = obj->clone();
|
||||||
userdb[user].connectionState = WAITING_FOR_PIN;
|
userdb[user].connectionState = WAITING_FOR_PIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitterPlugin::pinExchangeComplete(const std::string user, const std::string OAuthAccessTokenKey, const std::string OAuthAccessTokenSecret)
|
void TwitterPlugin::pinExchangeComplete(const std::string user, const std::string OAuthAccessTokenKey, const std::string OAuthAccessTokenSecret)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(userlock);
|
boost::mutex::scoped_lock lock(userlock);
|
||||||
|
|
||||||
userdb[user].sessions->getOAuth().setOAuthTokenKey( OAuthAccessTokenKey );
|
userdb[user].sessions->getOAuth().setOAuthTokenKey( OAuthAccessTokenKey );
|
||||||
userdb[user].sessions->getOAuth().setOAuthTokenSecret( OAuthAccessTokenSecret );
|
userdb[user].sessions->getOAuth().setOAuthTokenSecret( OAuthAccessTokenSecret );
|
||||||
userdb[user].connectionState = CONNECTED;
|
userdb[user].connectionState = CONNECTED;
|
||||||
userdb[user].twitterMode = (mode)getTwitterMode(user);
|
userdb[user].twitterMode = (mode)getTwitterMode(user);
|
||||||
|
|
||||||
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
||||||
tp->runAsThread(new FetchFriends(userdb[user].sessions, user, boost::bind(&TwitterPlugin::populateRoster, this, _1, _2, _3, _4)));
|
tp->runAsThread(new FetchFriends(userdb[user].sessions, user, boost::bind(&TwitterPlugin::populateRoster, this, _1, _2, _3, _4)));
|
||||||
}
|
}
|
||||||
|
@ -536,16 +536,16 @@ void TwitterPlugin::pinExchangeComplete(const std::string user, const std::strin
|
||||||
onlineUsers.insert(user);
|
onlineUsers.insert(user);
|
||||||
userdb[user].mostRecentTweetID = "";
|
userdb[user].mostRecentTweetID = "";
|
||||||
userdb[user].mostRecentDirectMessageID = "";
|
userdb[user].mostRecentDirectMessageID = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitterPlugin::updateLastTweetID(const std::string user, const std::string ID)
|
void TwitterPlugin::updateLastTweetID(const std::string user, const std::string ID)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(userlock);
|
boost::mutex::scoped_lock lock(userlock);
|
||||||
userdb[user].mostRecentTweetID = ID;
|
userdb[user].mostRecentTweetID = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ void TwitterPlugin::updateLastTweetID(const std::string user, const std::string
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TwitterPlugin::getMostRecentTweetIDUnsafe(const std::string user)
|
std::string TwitterPlugin::getMostRecentTweetIDUnsafe(const std::string user)
|
||||||
{
|
{
|
||||||
std::string ID = "";
|
std::string ID = "";
|
||||||
if(onlineUsers.count(user)) {
|
if(onlineUsers.count(user)) {
|
||||||
ID = userdb[user].mostRecentTweetID;
|
ID = userdb[user].mostRecentTweetID;
|
||||||
|
@ -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);
|
||||||
|
@ -572,19 +572,19 @@ std::string TwitterPlugin::getMostRecentTweetIDUnsafe(const std::string user)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TwitterPlugin::getMostRecentTweetID(const std::string user)
|
std::string TwitterPlugin::getMostRecentTweetID(const std::string user)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(userlock);
|
boost::mutex::scoped_lock lock(userlock);
|
||||||
return getMostRecentTweetIDUnsafe(user);
|
return getMostRecentTweetIDUnsafe(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitterPlugin::updateLastDMID(const std::string user, const std::string ID)
|
void TwitterPlugin::updateLastDMID(const std::string user, const std::string ID)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(userlock);
|
boost::mutex::scoped_lock lock(userlock);
|
||||||
userdb[user].mostRecentDirectMessageID = ID;
|
userdb[user].mostRecentDirectMessageID = 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);
|
||||||
|
@ -611,7 +611,7 @@ std::string TwitterPlugin::getMostRecentDMIDUnsafe(const std::string user) {
|
||||||
|
|
||||||
std::string TwitterPlugin::getMostRecentDMID(const std::string user)
|
std::string TwitterPlugin::getMostRecentDMID(const std::string user)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(userlock);
|
boost::mutex::scoped_lock lock(userlock);
|
||||||
return getMostRecentDMIDUnsafe(user);
|
return getMostRecentDMIDUnsafe(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,19 +648,19 @@ void TwitterPlugin::clearRoster(const std::string user)
|
||||||
userdb[user].buddies.clear();
|
userdb[user].buddies.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends, std::vector<std::string> &friendAvatars, Error &errMsg)
|
void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends, std::vector<std::string> &friendAvatars, Error &errMsg)
|
||||||
{
|
{
|
||||||
if(errMsg.getMessage().length() == 0)
|
if(errMsg.getMessage().length() == 0)
|
||||||
{
|
{
|
||||||
for(int i=0 ; i<friends.size() ; i++) {
|
for(int i=0 ; i<friends.size() ; i++) {
|
||||||
userdb[user].buddies.insert(friends[i].getScreenName());
|
userdb[user].buddies.insert(friends[i].getScreenName());
|
||||||
userdb[user].buddiesInfo[friends[i].getScreenName()] = friends[i];
|
userdb[user].buddiesInfo[friends[i].getScreenName()] = friends[i];
|
||||||
userdb[user].buddiesImgs[friends[i].getScreenName()] = friendAvatars[i];
|
userdb[user].buddiesImgs[friends[i].getScreenName()] = friendAvatars[i];
|
||||||
|
|
||||||
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
||||||
std::string lastTweet = friends[i].getLastStatus().getTweet();
|
std::string lastTweet = friends[i].getLastStatus().getTweet();
|
||||||
//LOG4CXX_INFO(logger, user << " - " << SHA(friendAvatars[i]))
|
//LOG4CXX_INFO(logger, user << " - " << SHA(friendAvatars[i]))
|
||||||
handleBuddyChanged(user, friends[i].getScreenName(), friends[i].getUserName(), std::vector<std::string>(),
|
handleBuddyChanged(user, friends[i].getScreenName(), friends[i].getUserName(), std::vector<std::string>(),
|
||||||
#if HAVE_SWIFTEN_3
|
#if HAVE_SWIFTEN_3
|
||||||
pbnetwork::STATUS_ONLINE, lastTweet, Swift::Hexify::hexify(cryptoProvider->getSHA1Hash(Swift::createByteArray(friendAvatars[i]))));
|
pbnetwork::STATUS_ONLINE, lastTweet, Swift::Hexify::hexify(cryptoProvider->getSHA1Hash(Swift::createByteArray(friendAvatars[i]))));
|
||||||
#else
|
#else
|
||||||
|
@ -669,9 +669,9 @@ void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends
|
||||||
}
|
}
|
||||||
else if(userdb[user].twitterMode == CHATROOM)
|
else if(userdb[user].twitterMode == CHATROOM)
|
||||||
handleParticipantChanged(user, friends[i].getScreenName(), adminChatRoom, 0, pbnetwork::STATUS_ONLINE);
|
handleParticipantChanged(user, friends[i].getScreenName(), adminChatRoom, 0, pbnetwork::STATUS_ONLINE);
|
||||||
|
|
||||||
/*handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
/*handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
||||||
friends[i].getScreenName() + " - " + friends[i].getLastStatus().getTweet(),
|
friends[i].getScreenName() + " - " + friends[i].getLastStatus().getTweet(),
|
||||||
userdb[user].twitterMode == CHATROOM ? adminNickName : "");*/
|
userdb[user].twitterMode == CHATROOM ? adminNickName : "");*/
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -688,24 +688,24 @@ void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends
|
||||||
|
|
||||||
void TwitterPlugin::displayFriendlist(std::string &user, std::vector<User> &friends, std::vector<std::string> &friendAvatars, Error &errMsg)
|
void TwitterPlugin::displayFriendlist(std::string &user, std::vector<User> &friends, std::vector<std::string> &friendAvatars, Error &errMsg)
|
||||||
{
|
{
|
||||||
if(errMsg.getMessage().length() == 0)
|
if(errMsg.getMessage().length() == 0)
|
||||||
{
|
{
|
||||||
std::string userlist = "\n***************USER LIST****************\n";
|
std::string userlist = "\n***************USER LIST****************\n";
|
||||||
for(int i=0 ; i < friends.size() ; i++) {
|
for(int i=0 ; i < friends.size() ; i++) {
|
||||||
userlist += " - " + friends[i].getUserName() + " (" + friends[i].getScreenName() + ")\n";
|
userlist += " - " + friends[i].getUserName() + " (" + friends[i].getScreenName() + ")\n";
|
||||||
}
|
}
|
||||||
userlist += "***************************************\n";
|
userlist += "***************************************\n";
|
||||||
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
||||||
userlist, userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
userlist, userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
||||||
} else {
|
} else {
|
||||||
if (errMsg.isCurlError()) {
|
if (errMsg.isCurlError()) {
|
||||||
handleDisconnected(user, 3, errMsg.getMessage());
|
handleDisconnected(user, 3, errMsg.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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 : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitterPlugin::displayTweets(std::string &user, std::string &userRequested, std::vector<Status> &tweets , Error &errMsg)
|
void TwitterPlugin::displayTweets(std::string &user, std::string &userRequested, std::vector<Status> &tweets , Error &errMsg)
|
||||||
|
@ -727,13 +727,13 @@ void TwitterPlugin::displayTweets(std::string &user, std::string &userRequested,
|
||||||
tweets[i].getTweet() + " (MsgId: " + (tweets[i].getRetweetID().empty() ? tweets[i].getID() : tweets[i].getRetweetID()) + ")", tweets[i].getUserData().getScreenName(), "", tweets[i].getCreationTime(), true);
|
tweets[i].getTweet() + " (MsgId: " + (tweets[i].getRetweetID().empty() ? tweets[i].getID() : tweets[i].getRetweetID()) + ")", tweets[i].getUserData().getScreenName(), "", tweets[i].getCreationTime(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
||||||
//Set as status user's last tweet
|
//Set as status user's last tweet
|
||||||
for(it=lastTweet.begin() ; it!=lastTweet.end() ; it++) {
|
for(it=lastTweet.begin() ; it!=lastTweet.end() ; it++) {
|
||||||
int t = it->second;
|
int t = it->second;
|
||||||
if (userdb[user].buddies.count(tweets[t].getUserData().getScreenName()) != 0) {
|
if (userdb[user].buddies.count(tweets[t].getUserData().getScreenName()) != 0) {
|
||||||
handleBuddyChanged(user, tweets[t].getUserData().getScreenName(), tweets[t].getUserData().getUserName(),
|
handleBuddyChanged(user, tweets[t].getUserData().getScreenName(), tweets[t].getUserData().getUserName(),
|
||||||
std::vector<std::string>(), pbnetwork::STATUS_ONLINE, tweets[t].getTweet());
|
std::vector<std::string>(), pbnetwork::STATUS_ONLINE, tweets[t].getTweet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -750,7 +750,7 @@ void TwitterPlugin::displayTweets(std::string &user, std::string &userRequested,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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 : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,30 +776,30 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
|
||||||
|
|
||||||
if(username != "") {
|
if(username != "") {
|
||||||
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
||||||
"Message delivered!", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
"Message delivered!", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!messages.size()) return;
|
if(!messages.size()) return;
|
||||||
|
|
||||||
if(userdb[user].twitterMode == SINGLECONTACT) {
|
if(userdb[user].twitterMode == SINGLECONTACT) {
|
||||||
|
|
||||||
std::string msglist = "";
|
std::string msglist = "";
|
||||||
std::string msgID = getMostRecentDMID(user);
|
std::string msgID = getMostRecentDMID(user);
|
||||||
std::string maxID = msgID;
|
std::string maxID = msgID;
|
||||||
|
|
||||||
for(int i=0 ; i < messages.size() ; i++) {
|
for(int i=0 ; i < messages.size() ; i++) {
|
||||||
if(cmp(msgID, messages[i].getID()) == -1) {
|
if(cmp(msgID, messages[i].getID()) == -1) {
|
||||||
msglist += " - " + messages[i].getSenderData().getScreenName() + ": " + messages[i].getMessage() + "\n";
|
msglist += " - " + messages[i].getSenderData().getScreenName() + ": " + messages[i].getMessage() + "\n";
|
||||||
if(cmp(maxID, messages[i].getID()) == -1) maxID = messages[i].getID();
|
if(cmp(maxID, messages[i].getID()) == -1) maxID = messages[i].getID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(msglist.length()) handleMessage(user, adminLegacyName, msglist, "");
|
if(msglist.length()) handleMessage(user, adminLegacyName, msglist, "");
|
||||||
updateLastDMID(user, maxID);
|
updateLastDMID(user, maxID);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
std::string msgID = getMostRecentDMID(user);
|
std::string msgID = getMostRecentDMID(user);
|
||||||
std::string maxID = msgID;
|
std::string maxID = msgID;
|
||||||
|
|
||||||
|
@ -811,9 +811,9 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
|
||||||
handleMessage(user, adminChatRoom, messages[i].getMessage() + " - <Direct Message>", messages[i].getSenderData().getScreenName());
|
handleMessage(user, adminChatRoom, messages[i].getMessage() + " - <Direct Message>", messages[i].getSenderData().getScreenName());
|
||||||
if(cmp(maxID, messages[i].getID()) == -1) maxID = messages[i].getID();
|
if(cmp(maxID, messages[i].getID()) == -1) maxID = messages[i].getID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -832,12 +832,12 @@ void TwitterPlugin::createFriendResponse(std::string &user, User &frnd, std::str
|
||||||
|
|
||||||
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
|
||||||
std::string("You are now following ") + frnd.getScreenName(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
std::string("You are now following ") + frnd.getScreenName(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
||||||
|
|
||||||
userdb[user].buddies.insert(frnd.getScreenName());
|
userdb[user].buddies.insert(frnd.getScreenName());
|
||||||
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))));
|
||||||
|
@ -856,24 +856,24 @@ void TwitterPlugin::deleteFriendResponse(std::string &user, User &frnd, Error &e
|
||||||
handleDisconnected(user, 3, errMsg.getMessage());
|
handleDisconnected(user, 3, errMsg.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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 : "");
|
||||||
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,
|
||||||
std::string("You are not following ") + frnd.getScreenName() + " anymore", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
std::string("You are not following ") + frnd.getScreenName() + " anymore", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
|
||||||
|
|
||||||
if (userdb[user].twitterMode == CHATROOM) {
|
if (userdb[user].twitterMode == CHATROOM) {
|
||||||
handleParticipantChanged(user, frnd.getScreenName(), adminLegacyName, 0, pbnetwork::STATUS_NONE);
|
handleParticipantChanged(user, frnd.getScreenName(), adminLegacyName, 0, pbnetwork::STATUS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
if(userdb[user].twitterMode == MULTIPLECONTACT) {
|
||||||
handleBuddyRemoved(user, frnd.getScreenName());
|
handleBuddyRemoved(user, frnd.getScreenName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
|
@ -45,7 +45,7 @@ static std::string toIsoTime(std::string in) {
|
||||||
output_facet->format("%Y%m%dT%H%M%S"); // boost::local_time::local_time_facet::iso_time_format_specifier ?
|
output_facet->format("%Y%m%dT%H%M%S"); // boost::local_time::local_time_facet::iso_time_format_specifier ?
|
||||||
ss >> ldt;
|
ss >> ldt;
|
||||||
ss.str("");
|
ss.str("");
|
||||||
ss << ldt;
|
ss << ldt;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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() ) ) );
|
||||||
|
@ -68,15 +68,15 @@ EmbeddedStatus getEmbeddedStatus(const rapidjson::Value &element)
|
||||||
"" : std::string(element[TwitterReponseTypes::in_reply_to_screen_name.c_str()].GetString()) );
|
"" : std::string(element[TwitterReponseTypes::in_reply_to_screen_name.c_str()].GetString()) );
|
||||||
status.setRetweetCount( element[TwitterReponseTypes::retweet_count.c_str()].GetInt64() );
|
status.setRetweetCount( element[TwitterReponseTypes::retweet_count.c_str()].GetInt64() );
|
||||||
status.setFavorited( element[TwitterReponseTypes::favorited.c_str()].GetBool() );
|
status.setFavorited( element[TwitterReponseTypes::favorited.c_str()].GetBool() );
|
||||||
status.setRetweeted( element[TwitterReponseTypes::retweeted.c_str()].GetBool());
|
status.setRetweeted( element[TwitterReponseTypes::retweeted.c_str()].GetBool());
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
User getUser(const rapidjson::Value &element)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,12 +85,12 @@ User getUser(const rapidjson::Value &element)
|
||||||
user.setUserName( std::string( element[TwitterReponseTypes::name.c_str()].GetString() ) );
|
user.setUserName( std::string( element[TwitterReponseTypes::name.c_str()].GetString() ) );
|
||||||
user.setProfileImgURL( std::string( element[TwitterReponseTypes::profile_image_url.c_str()].GetString() ) );
|
user.setProfileImgURL( std::string( element[TwitterReponseTypes::profile_image_url.c_str()].GetString() ) );
|
||||||
user.setNumberOfTweets( element[TwitterReponseTypes::statuses_count.c_str()].GetInt64() );
|
user.setNumberOfTweets( element[TwitterReponseTypes::statuses_count.c_str()].GetInt64() );
|
||||||
if(element[TwitterReponseTypes::status.c_str()].IsObject())
|
if(element[TwitterReponseTypes::status.c_str()].IsObject())
|
||||||
user.setLastStatus(getEmbeddedStatus(element[TwitterReponseTypes::status.c_str()]));
|
user.setLastStatus(getEmbeddedStatus(element[TwitterReponseTypes::status.c_str()]));
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status getStatus(const rapidjson::Value &element)
|
Status getStatus(const rapidjson::Value &element)
|
||||||
{
|
{
|
||||||
Status status;
|
Status status;
|
||||||
|
|
||||||
|
@ -116,14 +116,14 @@ Status getStatus(const rapidjson::Value &element)
|
||||||
status.setCreationTime( toIsoTime ( std::string (rt[TwitterReponseTypes::created_at.c_str()].GetString() ) ) );
|
status.setCreationTime( toIsoTime ( std::string (rt[TwitterReponseTypes::created_at.c_str()].GetString() ) ) );
|
||||||
status.setUserData( getUser ( rt[TwitterReponseTypes::user.c_str()]) );
|
status.setUserData( getUser ( rt[TwitterReponseTypes::user.c_str()]) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectMessage getDirectMessage(const rapidjson::Value &element)
|
DirectMessage getDirectMessage(const rapidjson::Value &element)
|
||||||
{
|
{
|
||||||
DirectMessage DM;
|
DirectMessage DM;
|
||||||
|
|
||||||
DM.setCreationTime( toIsoTime ( std::string( element[TwitterReponseTypes::created_at.c_str()].GetString() ) ) );
|
DM.setCreationTime( toIsoTime ( std::string( element[TwitterReponseTypes::created_at.c_str()].GetString() ) ) );
|
||||||
DM.setID( stringOf( element[TwitterReponseTypes::id.c_str()].GetInt64() ) );
|
DM.setID( stringOf( element[TwitterReponseTypes::id.c_str()].GetInt64() ) );
|
||||||
DM.setMessage( unescape ( std::string( element[TwitterReponseTypes::text.c_str()].GetString() ), getUrlEntities(element) ) );
|
DM.setMessage( unescape ( std::string( element[TwitterReponseTypes::text.c_str()].GetString() ), getUrlEntities(element) ) );
|
||||||
|
@ -140,16 +140,16 @@ std::vector<Status> getTimeline(std::string &json)
|
||||||
{
|
{
|
||||||
std::vector<Status> statuses;
|
std::vector<Status> statuses;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,17 +163,17 @@ std::vector<DirectMessage> getDirectMessages(std::string &json)
|
||||||
{
|
{
|
||||||
std::vector<DirectMessage> DMs;
|
std::vector<DirectMessage> DMs;
|
||||||
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 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,40 +187,40 @@ std::vector<User> getUsers(std::string &json)
|
||||||
{
|
{
|
||||||
std::vector<User> users;
|
std::vector<User> users;
|
||||||
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 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(rapidjson::SizeType i = 0; i < rootElement.Size(); i++) {
|
for(rapidjson::SizeType i = 0; i < rootElement.Size(); i++) {
|
||||||
users.push_back(getUser(rootElement[i]));
|
users.push_back(getUser(rootElement[i]));
|
||||||
}
|
}
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
User getUser(std::string &json)
|
User getUser(std::string &json)
|
||||||
{
|
{
|
||||||
User user;
|
User user;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,21 +231,21 @@ std::vector<std::string> getIDs(std::string &json)
|
||||||
{
|
{
|
||||||
std::vector<std::string> IDs;
|
std::vector<std::string> IDs;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rapidjson::Value & ids = rootElement[TwitterReponseTypes::ids.c_str()];
|
const rapidjson::Value & ids = rootElement[TwitterReponseTypes::ids.c_str()];
|
||||||
|
|
||||||
for(int i=0 ; i<ids.Size() ; i++) {
|
for(int i=0 ; i<ids.Size() ; i++) {
|
||||||
IDs.push_back(stringOf( ids[i].GetInt64()) );
|
IDs.push_back(stringOf( ids[i].GetInt64()) );
|
||||||
}
|
}
|
||||||
|
@ -258,14 +258,14 @@ Error getErrorMessage(std::string &json)
|
||||||
std::string code = "0";
|
std::string code = "0";
|
||||||
Error resp;
|
Error resp;
|
||||||
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()) {
|
||||||
if (!rootElement["errors"].IsNull()) {
|
if (!rootElement["errors"].IsNull()) {
|
||||||
const rapidjson::Value &errorElement = rootElement["errors"][0u]; // first error
|
const rapidjson::Value &errorElement = rootElement["errors"][0u]; // first error
|
||||||
error = std::string(errorElement["message"].GetString());
|
error = std::string(errorElement["message"].GetString());
|
||||||
code = stringOf(errorElement["code"].GetInt64());
|
code = stringOf(errorElement["code"].GetInt64());
|
||||||
|
@ -277,22 +277,22 @@ Error getErrorMessage(std::string &json)
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UrlEntity> getUrlEntities(const rapidjson::Value &element)
|
std::vector<UrlEntity> getUrlEntities(const rapidjson::Value &element)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<UrlEntity> url_entities;
|
std::vector<UrlEntity> url_entities;
|
||||||
|
|
||||||
const rapidjson::Value &entities = element["entities"];
|
const rapidjson::Value &entities = element["entities"];
|
||||||
|
|
||||||
if (entities.IsObject()) {
|
if (entities.IsObject()) {
|
||||||
const rapidjson::Value &urls = entities["urls"];
|
const rapidjson::Value &urls = entities["urls"];
|
||||||
if (urls.IsArray()) {
|
if (urls.IsArray()) {
|
||||||
for (rapidjson::SizeType i = 0; i < urls.Size(); i++) {
|
for (rapidjson::SizeType i = 0; i < urls.Size(); i++) {
|
||||||
UrlEntity entity(urls[i]["url"].GetString(), urls[i]["expanded_url"].GetString());
|
UrlEntity entity(urls[i]["url"].GetString(), urls[i]["expanded_url"].GetString());
|
||||||
url_entities.push_back(entity);
|
url_entities.push_back(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return url_entities;
|
return url_entities;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,9 @@ FIND_PATH(IRC_INCLUDE_DIR NAMES "IrcCore/ircglobal.h" PATHS ${QT_INCLUDE_DIR} PA
|
||||||
|
|
||||||
# message( STATUS ${IRC_LIBRARY})
|
# message( STATUS ${IRC_LIBRARY})
|
||||||
if( IRC_LIBRARY AND IRC_INCLUDE_DIR )
|
if( IRC_LIBRARY AND IRC_INCLUDE_DIR )
|
||||||
FIND_LIBRARY(IRC_MODEL_LIBRARY NAMES IrcModel PATHS ${QT_LIBRARY_DIR})
|
set(IRC_INCLUDE_DIR ${IRC_INCLUDE_DIR}/IrcCore ${IRC_INCLUDE_DIR}/IrcUtil ${IRC_INCLUDE_DIR}/IrcModel)
|
||||||
if (IRC_MODEL_LIBRARY)
|
message( STATUS "Found libCommuni ${IRC_LIBRARY}, ${IRC_INCLUDE_DIR}")
|
||||||
set(IRC_LIBRARY ${IRC_LIBRARY} ${IRC_MODEL_LIBRARY})
|
set( IRC_FOUND 1 )
|
||||||
set(IRC_INCLUDE_DIR ${IRC_INCLUDE_DIR}/IrcCore ${IRC_INCLUDE_DIR}/IrcUtil ${IRC_INCLUDE_DIR}/IrcModel)
|
|
||||||
message( STATUS "Found libCommuni ${IRC_LIBRARY}, ${IRC_INCLUDE_DIR}")
|
|
||||||
set( IRC_FOUND 1 )
|
|
||||||
else()
|
|
||||||
message( STATUS "Could NOT find libCommuni - IrcModel library" )
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
message( STATUS "Could NOT find libCommuni - IrcCore library" )
|
message( STATUS "Could NOT find libCommuni" )
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -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)
|
||||||
|
@ -30,21 +29,7 @@ if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
|
||||||
else()
|
else()
|
||||||
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();
|
||||||
|
@ -40,11 +40,6 @@ DummyNetworkFactories::~DummyNetworkFactories() {
|
||||||
delete connectionFactory;
|
delete connectionFactory;
|
||||||
delete timerFactory;
|
delete timerFactory;
|
||||||
delete m_platformXMLParserFactory;
|
delete m_platformXMLParserFactory;
|
||||||
|
|
||||||
#if HAVE_SWIFTEN_3
|
|
||||||
delete cryptoProvider;
|
|
||||||
delete networkEnvironment;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
||||||
|
|
||||||
|
@ -140,7 +139,7 @@ class Conversation {
|
||||||
void destroyRoom();
|
void destroyRoom();
|
||||||
|
|
||||||
std::string getParticipants();
|
std::string getParticipants();
|
||||||
void sendParticipants(const Swift::JID &to, const std::string &nickname);
|
void sendParticipants(const Swift::JID &to);
|
||||||
|
|
||||||
void sendCachedMessages(const Swift::JID &to = Swift::JID());
|
void sendCachedMessages(const Swift::JID &to = Swift::JID());
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -161,15 +160,14 @@ class Conversation {
|
||||||
bool m_sentInitialPresence;
|
bool m_sentInitialPresence;
|
||||||
bool m_nicknameChanged;
|
bool m_nicknameChanged;
|
||||||
bool m_mucEscaping;
|
bool m_mucEscaping;
|
||||||
bool m_sentInitialSubject;
|
|
||||||
|
|
||||||
// TODO: Move this to some extra class to cache the most used
|
// TODO: Move this to some extra class to cache the most used
|
||||||
// rooms across different accounts. Just now if we have 10 users
|
// rooms across different accounts. Just now if we have 10 users
|
||||||
// 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,12 @@ class HTTPRequest : public Thread {
|
||||||
HTTPRequest(ThreadPool *tp, Type type, const std::string &url, Callback callback);
|
HTTPRequest(ThreadPool *tp, Type type, const std::string &url, Callback callback);
|
||||||
HTTPRequest(Type type, const std::string &url);
|
HTTPRequest(Type type, const std::string &url);
|
||||||
|
|
||||||
virtual ~HTTPRequest();
|
virtual ~HTTPRequest() {
|
||||||
|
if(curlhandle) {
|
||||||
|
curl_easy_cleanup(curlhandle);
|
||||||
|
curlhandle = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setProxy(std::string, std::string, std::string, std::string);
|
void setProxy(std::string, std::string, std::string, std::string);
|
||||||
bool execute();
|
bool execute();
|
||||||
|
@ -40,14 +45,6 @@ class HTTPRequest : public Thread {
|
||||||
|
|
||||||
boost::signal<void ()> onRequestFinished;
|
boost::signal<void ()> onRequestFinished;
|
||||||
|
|
||||||
static void globalInit() {
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void globalCleanup() {
|
|
||||||
curl_global_cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init();
|
bool init();
|
||||||
bool GET(std::string url, std::string &output);
|
bool GET(std::string url, std::string &output);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue