Compare commits

..

No commits in common. "master" and "2.0.3" have entirely different histories.

214 changed files with 9227 additions and 4108 deletions

View file

@ -3,47 +3,18 @@ python:
- "2.7_with_system_site_packages"
virtualenv:
system_site_packages: true
matrix:
include:
- os: linux
dist: trusty
sudo: required
- os: osx
allow_failures:
- os: osx
sudo: required
dist: trusty
before_script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
export DEBIAN_FRONTEND=noninteractive;
export APT_LISTCHANGES_FRONTEND=none;
echo force-confold | sudo tee -a /etc/dpkg/dpkg.cfg;
curl -k https://swift.im/keys/packages.key | sudo apt-key add -;
echo 'deb http://us.archive.ubuntu.com/ubuntu xenial main restricted universe multiverse' | sudo tee /etc/apt/sources.list.d/xenial.list > /dev/null;
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;
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;
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
- curl -k https://swift.im/keys/packages.key | sudo apt-key add -
- echo "deb http://swift.im/packages/ubuntu/trusty development main" | sudo tee -a /etc/apt/sources.list
- echo "deb http://packages.spectrum.im/spectrum2/ trusty main" | sudo tee -a /etc/apt/sources.list
- echo " deb http://packages.prosody.im/debian trusty main" | sudo tee -a /etc/apt/sources.list
- sudo apt-get update -qq
- 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
- sudo killall lua5.1
install: "pip install --user sleekxmpp"
script:
- cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON . && make
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
make extended_test;
else
make test;
fi
- cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON . && make && make extended_test
notifications:
slack: spectrum2:CIlYHtxGMAaxs3qVHfwBzCuy

View file

@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 2.6)
project(libtransport)
if(${CMAKE_MAJOR_VERSION} GREATER 2)
cmake_policy(SET CMP0037 OLD)
endif()
include(CPack)
message(STATUS "Variables to override default places where to find libraries:")
message(STATUS "|- cppunit : -DCPPUNIT_INCLUDE_DIR, -DCPPUNIT_LIBRARY")
message(STATUS "|- swiften : -DSWIFTEN_INCLUDE_DIR, -DSWIFTEN_LIBRARY")
@ -26,7 +27,8 @@ option(ENABLE_FROTZ "Build Frotz plugin" ON)
option(ENABLE_IRC "Build IRC plugin" ON)
option(ENABLE_PURPLE "Build Libpurple 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_DOCS "Build Docs" ON)
@ -74,8 +76,7 @@ if(NOT SWIFTEN_FOUND)
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Secur32")
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Iphlpapi")
set(SWIFTEN_LIBRARY ${SWIFTEN_LIBRARY} "Winscard")
message(STATUS "XXXUsing swiften: ${SWIFTEN_INCLUDE_DIR} ${SWIFTEN_LIBRARY}
Version: ${SWIFTEN_VERSION}")
message(STATUS "Using swiften: ${SWIFTEN_INCLUDE_DIR} ${SWIFTEN_LIBRARY}")
endif()
# FIND BOOST
@ -83,9 +84,20 @@ if (WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
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)
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}")
@ -152,7 +164,7 @@ if(ENABLE_PURPLE)
endif()
# FIND GLIB
if(ENABLE_PURPLE)
if(ENABLE_SKYPE OR ENABLE_PURPLE)
# if (GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
# set(GLIB2_FOUND TRUE)
# else()
@ -249,10 +261,10 @@ else (SPECTRUM_VERSION)
OUTPUT_VARIABLE GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(SPECTRUM_VERSION 2.0.5-git-${GIT_REVISION})
set(SPECTRUM_VERSION 2.0.3-git-${GIT_REVISION})
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
set(SPECTRUM_VERSION 2.0.5)
set(SPECTRUM_VERSION 2.0.3)
ADD_DEFINITIONS(-DSPECTRUM_VERSION="${SPECTRUM_VERSION}")
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
endif (SPECTRUM_VERSION)
@ -366,7 +378,7 @@ if (PROTOBUF_FOUND)
message("Skype plugin : no (does not run on Win32)")
endif()
if(ENABLE_XMPP)
if(ENABLE_SWIFTEN)
message("Swiften plugin : yes")
else()
message("Swiften plugin : no (user disabled)")
@ -473,3 +485,4 @@ if(NOT SQLITE3_FOUND AND NOT MYSQL_FOUND AND NOT PQXX_FOUND)
message("Please enable at least one of SQLITE3, MYSQL, PQXX databases to use transport mode.")
endif()
endif()

View file

@ -1,15 +1,3 @@
Version 2.0.5 (2017-08-09):
Minor bugfixes:
* fix purple-hangouts login
* fix Debian packages dependencies
Version 2.0.4 (2017-08-03):
General:
* Add support for Swiften 4.0rc2. Swiften 3.x and 2.x are still supported.
* Add support for passwordless libpurple backends (e.g. purple-hangouts).
* Partial support for groupchats with case-sensitive names (e.g. purple-telegram).
* Various small bugfixes, see Git commit descriptions for the full list of changes.
Version 2.0.3 (2016-02-29):
General:
* Swift 3.0rc2 is now minimum Swift 3.x version needed to compile Spectrum2,

View file

@ -6,7 +6,7 @@ ARG commit=unknown
RUN echo $commit
# 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" && \
git clone git://github.com/hanzz/spectrum2.git && \
cd spectrum2 && \
@ -17,10 +17,8 @@ RUN dnf install protobuf protobuf swiften gcc gcc-c++ make libpqxx-devel libpurp
rm -rf spectrum2 && \
rm -rf ~/rpmbuild && \
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 && \
tar -xf purple-facebook-0.9.5-9ff9acf9fa14.tar.gz && \
cd purple-facebook-0.9.5-9ff9acf9fa14 && \
./autogen.sh && \
wget https://github.com/jgeboski/purple-facebook/releases/download/6a0a79182ebc/purple-facebook-6a0a79182ebc.tar.gz && \
tar -xf purple-facebook-6a0a79182ebc.tar.gz && cd purple-facebook-6a0a79182ebc && \
./configure && \
make && \
make install && \
@ -53,22 +51,7 @@ RUN dnf install protobuf protobuf swiften gcc gcc-c++ make libpqxx-devel libpurp
./configure && \
make && \
make install && \
cd .. && \
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" && \
rm -rf /usr/share/locale/* && \
rm -rf /usr/share/doc/* && \

View file

@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/SpectrumIM/spectrum2.svg?branch=master)](https://travis-ci.org/SpectrumIM/spectrum2)
[![Build Status](https://travis-ci.org/hanzz/spectrum2.png?branch=master)](https://travis-ci.org/hanzz/spectrum2)
![](http://spectrum.im/animation.gif)

View file

@ -7,7 +7,7 @@ if (PROTOBUF_FOUND)
ADD_SUBDIRECTORY(libcommuni)
endif()
if (ENABLE_XMPP)
if (ENABLE_SWIFTEN)
ADD_SUBDIRECTORY(swiften)
endif()

View file

@ -11,7 +11,6 @@
#include "transport/Config.h"
#include "transport/NetworkPlugin.h"
#include "Swiften/Swiften.h"
#include "Swiften/SwiftenCompat.h"
#include <boost/filesystem.hpp>
#include "unistd.h"
#include "signal.h"
@ -149,14 +148,14 @@ class FrotzNetworkPlugin : public NetworkPlugin {
public:
Swift::BoostNetworkFactories *m_factories;
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() {
this->config = config;
m_factories = new Swift::BoostNetworkFactories(loop);
m_conn = m_factories->getConnectionFactory()->createConnection();
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->onDisconnected.connect(boost::bind(&FrotzNetworkPlugin::handleDisconnected, this));
}
@ -165,7 +164,7 @@ class FrotzNetworkPlugin : public NetworkPlugin {
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());
handleDataRead(d);
}

View file

@ -17,9 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include "ircnetworkplugin.h"
#include <IrcCommand>
#include <IrcMessage>
#include "ircnetworkplugin.h"
#include "transport/Logging.h"
DEFINE_LOGGER(logger, "IRCNetworkPlugin");

View file

@ -21,11 +21,11 @@
#pragma once
#ifndef Q_MOC_RUN
#include "transport/Config.h"
#include "transport/NetworkPlugin.h"
#include "session.h"
#include <QtCore>
#include <QtNetwork>
#include "transport/Config.h"
#include "transport/NetworkPlugin.h"
#include "Swiften/EventLoop/Qt/QtEventLoop.h"
#endif

View file

@ -17,11 +17,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#include <QtCore>
#include <QtNetwork>
#include "transport/Config.h"
#include "transport/NetworkPlugin.h"
#include "transport/Logging.h"
#include <QtCore>
#include <QtNetwork>
#include "Swiften/EventLoop/Qt/QtEventLoop.h"
#include "ircnetworkplugin.h"

View file

@ -4,12 +4,12 @@ FILE(GLOB SRC *.cpp)
ADD_EXECUTABLE(spectrum2_libpurple_backend ${SRC})
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()
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()
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()

View file

@ -9,24 +9,20 @@
#include "purple.h"
#include <algorithm>
#include <iostream>
#include <fstream>
#include <fstream>
#include "transport/NetworkPlugin.h"
#include "transport/Logging.h"
#include "transport/Config.h"
#include "transport/StorageBackend.h"
#include "geventloop.h"
#include "Swiften/SwiftenCompat.h"
// #include "valgrind/memcheck.h"
#if !defined(__FreeBSD__) && !defined(__APPLE__)
#include "malloc.h"
#endif
#include <algorithm>
#include "errno.h"
#include <boost/make_shared.hpp>
#include <boost/locale.hpp>
#include <boost/locale/conversion.hpp>
#include <boost/thread/mutex.hpp>
#ifdef WITH_LIBEVENT
#include <event.h>
@ -83,9 +79,8 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
class SpectrumNetworkPlugin;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Config> config;
boost::shared_ptr<Config> config;
SpectrumNetworkPlugin *np;
StorageBackend *storagebackend;
static std::string host;
static int port = 10000;
@ -123,24 +118,49 @@ struct authRequest {
std::string mainJID; // JID of user connected with this request
};
struct inputRequest {
PurpleRequestInputCb ok_cb;
void *user_data;
std::string who;
PurpleAccount *account;
std::string mainJID; // JID of user connected with this request
};
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) {
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 {
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){
std::string t(title ? title : "NULL");
if (t == "SSL Certificate Verification") {
if (CONFIG_BOOL_DEFAULTED(config, "service.verify_certs", false)) {
LOG4CXX_INFO(logger, "rejecting SSL certificate");
va_arg(actions, char *);
va_arg(actions, GCallback);
} else {
LOG4CXX_INFO(logger, "accepting SSL certificate");
}
LOG4CXX_INFO(logger, "accepting SSL certificate");
va_arg(actions, char *);
((PurpleRequestActionCb) va_arg(actions, GCallback)) (user_data, 2);
}
@ -156,10 +176,6 @@ static void *requestAction(const char *title, const char *primary, const char *s
std::string headerString(title);
LOG4CXX_INFO(logger, "header string: " << headerString);
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 *);
((PurpleRequestActionCb) va_arg(actions, GCallback)) (user_data, 2);
}
@ -183,39 +199,10 @@ static std::string getAlias(PurpleBuddy *m_buddy) {
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 {
public:
SpectrumNetworkPlugin() : NetworkPlugin() {
LOG4CXX_INFO(logger, "Starting libpurple backend " << SPECTRUM_VERSION);
}
void handleExitRequest() {
@ -274,11 +261,11 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
if (strippedKey != key2) {
continue;
}
found = true;
switch (type) {
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;
case PURPLE_PREF_INT:
@ -313,9 +300,9 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
std::string username(purple_account_get_username_wrapped(account));
std::vector <std::string> u = split(username, '@');
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_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()) {
@ -360,19 +347,11 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
std::string 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");
np->handleDisconnected(user, 1, "Empty password.");
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())) {
LOG4CXX_INFO(logger, name.c_str() << ": Invalid protocol '" << protocol << "'");
@ -405,12 +384,6 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
purple_account_set_bool_wrapped(account, "custom_smileys", FALSE);
purple_account_set_bool_wrapped(account, "direct_connect", FALSE);
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);
@ -428,11 +401,6 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
if (status_type != 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) {
@ -522,21 +490,11 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
PurpleAccount *account = m_sessions[user];
if (account) {
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);
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;
}
PurpleConversation *conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_CHAT, legacyName.c_str(), account);
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) {
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()) {
@ -563,7 +521,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
void handleRoomSubjectChangedRequest(const std::string &user, const std::string &legacyName, const std::string &message) {
PurpleAccount *account = m_sessions[user];
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) {
LOG4CXX_ERROR(logger, user << ": Cannot set room subject. There is now conversation " << legacyName);
return;
@ -734,29 +692,6 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
}
}
std::string LegacyNameToName(PurpleAccount *account, const std::string &legacyName) {
std::string conversationName = legacyName;
BOOST_FOREACH(std::string _room, m_rooms[np->m_accounts[account]]) {
std::string lowercased_room = boost::locale::to_lower(_room);
if (lowercased_room.compare(conversationName) == 0) {
conversationName = _room;
break;
}
}
return conversationName;
}
std::string NameToLegacyName(PurpleAccount *account, const std::string &legacyName) {
std::string conversationName = legacyName;
BOOST_FOREACH(std::string _room, m_rooms[np->m_accounts[account]]) {
if (_room.compare(conversationName) == 0) {
conversationName = boost::locale::to_lower(legacyName);
break;
}
}
return conversationName;
}
void handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &pasword) {
PurpleAccount *account = m_sessions[user];
if (!account) {
@ -765,17 +700,17 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
PurpleConnection *gc = purple_account_get_connection_wrapped(account);
GHashTable *comps = NULL;
std::string roomName = LegacyNameToName(account, room);
// 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) {
comps = purple_chat_get_components_wrapped(chat);
}
else if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) {
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 {
comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, roomName.c_str());
comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, room.c_str());
}
}
@ -793,7 +728,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
}
}
LOG4CXX_INFO(logger, user << ": Joining the room " << roomName);
LOG4CXX_INFO(logger, user << ": Joining the room " << room);
if (comps) {
serv_join_chat_wrapped(gc, comps);
g_hash_table_destroy(comps);
@ -806,7 +741,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
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);
}
@ -815,7 +750,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
if (xfer) {
m_unhandledXfers.erase(user + fileName + buddyName);
FTData *ftData = (FTData *) xfer->ui_data;
ftData->id = ftID;
m_xfers[ftID] = xfer;
purple_xfer_request_accepted_wrapped(xfer, fileName.c_str());
@ -877,13 +812,9 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
std::map<PurpleAccount *, std::string> m_accounts;
std::map<std::string, unsigned int> m_vcards;
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<std::string, PurpleXfer *> m_unhandledXfers;
std::vector<PurpleXfer *> m_waitingXfers;
std::string adminLegacyName;
std::string adminAlias;
};
static bool getStatus(PurpleBuddy *m_buddy, pbnetwork::StatusType &status, std::string &statusMessage) {
@ -1035,7 +966,7 @@ void buddyListNewNode(PurpleBlistNode *node) {
cache->nodes[node] = 1;
return;
}
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]);
@ -1188,9 +1119,8 @@ static void conv_write(PurpleConversation *conv, const char *who, const char *al
np->handleMessage(np->m_accounts[account], w, message_, "", xhtml_, timestamp);
}
else {
std::string conversationName = purple_conversation_get_name_wrapped(conv);
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' name='" << conversationName << "' " << who);
np->handleMessage(np->m_accounts[account], np->NameToLegacyName(account, conversationName), message_, who, xhtml_, timestamp);
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' name='" << purple_conversation_get_name_wrapped(conv) << "' " << who);
np->handleMessage(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), message_, who, xhtml_, timestamp);
}
}
}
@ -1278,7 +1208,7 @@ static void conv_write_im(PurpleConversation *conv, const char *who, const char
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);
@ -1338,9 +1268,8 @@ static void conv_write_im(PurpleConversation *conv, const char *who, const char
np->handleMessage(np->m_accounts[account], w, message_, n, xhtml_, timestamp);
}
else {
std::string conversationName = purple_conversation_get_name_wrapped(conv);
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' xhtml='" << xhtml_ << "' name='" << conversationName << "' " << who);
np->handleMessage(np->m_accounts[account], np->NameToLegacyName(account, conversationName), message_, who, xhtml_, timestamp);
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' xhtml='" << xhtml_ << "' name='" << purple_conversation_get_name_wrapped(conv) << "' " << who);
np->handleMessage(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), message_, who, xhtml_, timestamp);
}
}
@ -1368,8 +1297,8 @@ static void conv_chat_add_users(PurpleConversation *conv, GList *cbuddies, gbool
// item->addAttribute("affiliation", "member");
// item->addAttribute("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;
}
@ -1381,8 +1310,7 @@ static void conv_chat_remove_users(PurpleConversation *conv, GList *users) {
GList *l = users;
while (l != NULL) {
std::string name((char *) l->data);
std::string conversationName = purple_conversation_get_name_wrapped(conv);
np->handleParticipantChanged(np->m_accounts[account], name, np->NameToLegacyName(account, conversationName), 0, pbnetwork::STATUS_NONE);
np->handleParticipantChanged(np->m_accounts[account], name, purple_conversation_get_name_wrapped(conv), 0, pbnetwork::STATUS_NONE);
l = l->next;
}
@ -1395,7 +1323,7 @@ static gboolean conv_has_focus(PurpleConversation *conv) {
static void conv_chat_topic_changed(PurpleConversation *conv, const char *who, const char *topic) {
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");
np->handleSubject(np->m_accounts[account], purple_conversation_get_name_wrapped(conv), topic ? topic : "", who ? who : "Spectrum 2");
}
static void conv_present(PurpleConversation *conv) {
@ -1488,7 +1416,7 @@ static void *notify_user_info(PurpleConnection *gc, const char *who, PurpleNotif
if (pos != std::string::npos)
name.erase((int) pos, name.length() - (int) pos);
GList *vcardEntries = purple_notify_user_info_get_entries_wrapped(user_info);
PurpleNotifyUserInfoEntry *vcardEntry;
std::string firstName;
@ -1588,69 +1516,6 @@ static void *notify_user_info(PurpleConnection *gc, const char *who, PurpleNotif
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 =
{
NULL,
@ -1834,7 +1699,7 @@ static gssize XferRead(PurpleXfer *xfer, guchar **buffer, gssize size) {
// int data_size = repeater->getDataToSend(buffer, size);
// if (data_size == 0)
// return 0;
//
//
// return data_size;
return 0;
}
@ -1879,10 +1744,11 @@ static void RoomlistProgress(PurpleRoomlist *list, gboolean in_progress)
}
GList *rooms;
std::list<std::string> m_rooms;
std::list<std::string> m_topics;
for (rooms = list->rooms; rooms != NULL; rooms = rooms->next) {
PurpleRoomlistRoom *room = (PurpleRoomlistRoom *)rooms->data;
np->m_rooms[np->m_accounts[list->account]].push_back(room->name);
PurpleRoomlistRoom *room = (PurpleRoomlistRoom *)rooms->data;
m_rooms.push_back(room->name);
if (topicId == -1) {
m_topics.push_back(room->name);
@ -1917,7 +1783,7 @@ static void RoomlistProgress(PurpleRoomlist *list, gboolean in_progress)
}
LOG4CXX_INFO(logger, "RoomList is fetched for user " << user);
np->handleRoomList(user, np->m_rooms[user], m_topics);
np->handleRoomList(user, m_rooms, m_topics);
}
else {
LOG4CXX_INFO(logger, "RoomList is still in progress");
@ -1948,7 +1814,7 @@ static void transport_core_ui_init(void)
purple_connections_set_ui_ops_wrapped(&conn_ui_ops);
purple_conversations_set_ui_ops_wrapped(&conversation_ui_ops);
purple_roomlist_set_ui_ops_wrapped(&roomlist_ui_ops);
// #ifndef WIN32
// purple_dnsquery_set_ui_ops_wrapped(getDNSUiOps());
// #endif
@ -2019,7 +1885,7 @@ debug_init(void)
REGISTER_G_LOG_HANDLER("GLib-GObject");
REGISTER_G_LOG_HANDLER("GThread");
REGISTER_G_LOG_HANDLER("GConf");
#undef REGISTER_G_LOD_HANDLER
}
@ -2046,12 +1912,9 @@ static void signed_on(PurpleConnection *gc, gpointer unused) {
#endif
#endif
purple_roomlist_get_list_wrapped(gc);
// For prpl-gg
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) {
@ -2130,7 +1993,7 @@ static bool initPurple() {
std::string cacertsDir = CONFIG_STRING_DEFAULTED(config, "purple.cacerts_dir", "./ca-certs");
LOG4CXX_INFO(logger, "Setting libpurple cacerts directory to: " << cacertsDir);
purple_certificate_add_ca_search_path_wrapped(cacertsDir.c_str());
std::string userDir = CONFIG_STRING_DEFAULTED(config, "service.working_dir", "./");
LOG4CXX_INFO(logger, "Setting libpurple user directory to: " << userDir);
@ -2197,7 +2060,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-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_commands_init();
}
@ -2225,15 +2088,12 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
if (firstPing) {
firstPing = false;
NetworkPlugin::PluginConfig cfg;
NetworkPlugin::PluginConfig cfg;
cfg.setSupportMUC(true);
if (CONFIG_STRING(config, "service.protocol") == "prpl-telegram") {
cfg.setNeedPassword(false);
}
if (CONFIG_STRING(config, "service.protocol") == "prpl-hangouts") {
cfg.setNeedPassword(false);
}
if (CONFIG_BOOL(config, "service.server_mode") || CONFIG_STRING(config, "service.protocol") == "prpl-irc") {
if (CONFIG_STRING(config, "service.protocol") == "prpl-irc") {
cfg.setNeedRegistration(false);
}
else {
@ -2254,8 +2114,6 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi
}
int main(int argc, char **argv) {
boost::locale::generator gen;
std::locale::global(gen(""));
#ifndef WIN32
#if !defined(__FreeBSD__) && !defined(__APPLE__)
mallopt(M_CHECK_ACTION, 2);
@ -2277,28 +2135,15 @@ int main(int argc, char **argv) {
return 1;
}
config = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Config>(cfg);
config = boost::shared_ptr<Config>(cfg);
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();
main_socket = create_socket(host.c_str(), port);
purple_input_add_wrapped(main_socket, PURPLE_INPUT_READ, &transportDataReceived, NULL);
purple_timeout_add_seconds_wrapped(30, pingTimeout, NULL);
np = new SpectrumNetworkPlugin();
bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";

View file

@ -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_account_new_wrapped_fnc purple_account_new_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_enabled_wrapped_fnc purple_account_set_enabled_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)
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");
if (!purple_account_set_password_wrapped)
return false;

View file

@ -44,9 +44,6 @@ extern purple_account_new_wrapped_fnc purple_account_new_wrapped;
typedef void (_cdecl * purple_accounts_add_wrapped_fnc)(PurpleAccount *account);
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);
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_account_new_wrapped purple_account_new
#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_enabled_wrapped purple_account_set_enabled
#define purple_account_set_privacy_type_wrapped purple_account_set_privacy_type

View file

@ -16,7 +16,6 @@
#include "transport/PQXXBackend.h"
#include "transport/StorageBackend.h"
#include "Swiften/Swiften.h"
#include "Swiften/SwiftenCompat.h"
#include <boost/filesystem.hpp>
#include "unistd.h"
#include "signal.h"
@ -46,7 +45,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
public:
Swift::BoostNetworkFactories *m_factories;
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;
int m_internalUser;
StorageBackend *storageBackend;
@ -57,7 +56,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
m_factories = new Swift::BoostNetworkFactories(loop);
m_conn = m_factories->getConnectionFactory()->createConnection();
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->onDisconnected.connect(boost::bind(&FrotzNetworkPlugin::handleDisconnected, this));
@ -82,7 +81,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
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::string str;
@ -149,7 +148,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
}
void sendSMS(const std::string &to, const std::string &msg) {
// TODO: Probably
// TODO: Probably
std::string data = "To: " + to + "\n";
data += "\n";
data += msg;
@ -170,7 +169,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
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());
handleDataRead(d);
}
@ -232,7 +231,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
private:
Config *config;
};

View file

@ -7,7 +7,6 @@
// Swiften
#include "Swiften/Swiften.h"
#include "Swiften/SwiftenCompat.h"
#include <Swiften/Version.h>
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
@ -52,7 +51,7 @@ class ForwardIQHandler : public Swift::IQHandler {
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) {
return false;
}
@ -69,16 +68,16 @@ class ForwardIQHandler : public Swift::IQHandler {
private:
NetworkPlugin *m_np;
std::string m_user;
};
class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
public:
Swift::BoostNetworkFactories *m_factories;
Swift::BoostIOServiceThread m_boostIOServiceThread;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
boost::shared_ptr<Swift::Connection> m_conn;
bool m_firstPing;
Swift::FullPayloadSerializerCollection collection;
Swift::XMPPParser *m_xmppParser;
Swift::FullPayloadParserFactoryCollection m_collection2;
@ -89,7 +88,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
m_factories = new Swift::BoostNetworkFactories(loop);
m_conn = m_factories->getConnectionFactory()->createConnection();
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
serializer = new Swift::XMPPSerializer(&collection, Swift::ClientStreamType, false);
#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
void _handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data) {
void _handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data) {
if (m_firstPing) {
m_firstPing = false;
NetworkPlugin::PluginConfig cfg;
@ -121,45 +120,45 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
void handleStreamStart(const Swift::ProtocolHeader&) {}
#if HAVE_SWIFTEN_3
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::ToplevelElement> element) {
void handleElement(boost::shared_ptr<Swift::ToplevelElement> element) {
#else
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Element> element) {
void handleElement(boost::shared_ptr<Swift::Element> element) {
#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) {
return;
}
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)
return;
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) {
client->sendMessage(message);
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) {
client->sendPresence(presence);
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 (m_handlers[user]->m_id2resource.find(stanza->getID()) != m_handlers[user]->m_id2resource.end()) {
std::string resource = m_handlers[user]->m_id2resource[stanza->getID()];
if (resource.empty()) {
iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain()));
iq->setTo(Swift::JID(iq->getTo().getNode(), iq->getTo().getDomain()));
} 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());
}
client->getIQRouter()->sendIQ(iq);
@ -212,7 +211,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
LOG4CXX_INFO(logger, user << ": Disconnected " << 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) {
client->onConnected.disconnect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
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());
pbnetwork::StatusType status = lastPresence ? ((pbnetwork::StatusType) lastPresence->getShow()) : pbnetwork::STATUS_NONE;
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) {
// SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
// if (client->getMUCRegistry()->isMUC(presence->getFrom().toBare())) {
// return;
// }
//
// if (presence->getPayload<Swift::MUCUserPayload>() != NULL || presence->getPayload<Swift::MUCPayload>() != NULL) {
// return;
// }
//
// LOG4CXX_INFO(logger, user << ": " << presence->getFrom().toBare().toString() << " presence changed");
//
// std::string message = presence->getStatus();
// std::string photo = "";
//
// SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::VCardUpdate> update = presence->getPayload<Swift::VCardUpdate>();
// if (update) {
// photo = update->getPhotoHash();
// }
//
// boost::optional<Swift::XMPPRosterItem> item = m_users[user]->getRoster()->getItem(presence->getFrom());
// if (item) {
// handleBuddyChanged(user, presence->getFrom().toBare().toString(), item->getName(), item->getGroups(), (pbnetwork::StatusType) presence->getShow(), message, photo);
// }
// else {
// std::vector<std::string> groups;
// handleBuddyChanged(user, presence->getFrom().toBare().toString(), presence->getFrom().toBare(), groups, (pbnetwork::StatusType) presence->getShow(), message, photo);
// }
// boost::shared_ptr<Swift::Client> client = m_users[user];
// if (client->getMUCRegistry()->isMUC(presence->getFrom().toBare())) {
// return;
// }
//
// if (presence->getPayload<Swift::MUCUserPayload>() != NULL || presence->getPayload<Swift::MUCPayload>() != NULL) {
// return;
// }
//
// LOG4CXX_INFO(logger, user << ": " << presence->getFrom().toBare().toString() << " presence changed");
//
// std::string message = presence->getStatus();
// std::string photo = "";
//
// boost::shared_ptr<Swift::VCardUpdate> update = presence->getPayload<Swift::VCardUpdate>();
// if (update) {
// photo = update->getPhotoHash();
// }
//
// boost::optional<Swift::XMPPRosterItem> item = m_users[user]->getRoster()->getItem(presence->getFrom());
// if (item) {
// handleBuddyChanged(user, presence->getFrom().toBare().toString(), item->getName(), item->getGroups(), (pbnetwork::StatusType) presence->getShow(), message, photo);
// }
// else {
// std::vector<std::string> groups;
// handleBuddyChanged(user, presence->getFrom().toBare().toString(), presence->getFrom().toBare(), groups, (pbnetwork::StatusType) presence->getShow(), message, photo);
// }
presence->setTo(user);
std::string xml = safeByteArrayToString(serializer->serializeElement(presence));
sendRawXML(xml);
@ -306,7 +305,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
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);
boost::shared_ptr<Swift::Client> client = boost::make_shared<Swift::Client>(jid, password, m_factories);
m_users[user] = client;
client->setAlwaysTrustCertificates();
client->onConnected.connect(boost::bind(&SwiftenPlugin::handleSwiftConnected, this, user));
@ -322,7 +321,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
opt.allowPLAINWithoutTLS = true;
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);
m_handlers[user] = handler;
}
@ -340,10 +339,10 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
}
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) {
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->getRoster()->onInitialRosterPopulated.disconnect(boost::bind(&SwiftenPlugin::handleSwiftRosterReceived, this, user));
client->getPresenceOracle()->onPresenceChange.disconnect(boost::bind(&SwiftenPlugin::handleSwiftPresenceChanged, this, user, _1));
@ -358,7 +357,7 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
}
void handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups) {
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Client> client = m_users[user];
boost::shared_ptr<Swift::Client> client = m_users[user];
if (client) {
LOG4CXX_INFO(logger, user << ": Added/Updated buddy " << buddyName << ".");
if (!client->getRoster()->containsJID(buddyName) || client->getRoster()->getSubscriptionStateForJID(buddyName) != Swift::RosterItemPayload::Both) {
@ -366,10 +365,10 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
item.setName(alias);
item.setJID(buddyName);
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);
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();
client->getSubscriptionManager()->requestSubscription(buddyName);
}
@ -377,10 +376,10 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
Swift::JID contact(buddyName);
Swift::RosterItemPayload item(contact, alias, client->getRoster()->getSubscriptionStateForJID(contact));
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);
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();
}
@ -388,13 +387,13 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
}
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) {
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);
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();
}
}
@ -409,8 +408,8 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
private:
Config *config;
std::map<std::string, SWIFTEN_SHRPTR_NAMESPACE::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<Swift::Client> > m_users;
std::map<std::string, boost::shared_ptr<ForwardIQHandler> > m_handlers;
};
#ifndef WIN32

View file

@ -20,7 +20,7 @@ Plugin::Plugin(Config *config, Swift::SimpleEventLoop *loop, const std::string &
m_factories = new Swift::BoostNetworkFactories(loop);
m_conn = m_factories->getConnectionFactory()->createConnection();
m_conn->onDataRead.connect(boost::bind(&Plugin::_handleDataRead, this, _1));
m_conn->connect(Swift::HostAddressPort(SWIFT_HOSTADDRESS(host), port));
m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port));
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
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());
handleDataRead(d);
}

View file

@ -1,7 +1,6 @@
#pragma once
#include "Swiften/Swiften.h"
#include "Swiften/SwiftenCompat.h"
#include "transport/Config.h"
#include "transport/NetworkPlugin.h"
@ -25,11 +24,11 @@ class Plugin : public Transport::NetworkPlugin {
private:
// This method has to call handleDataRead with all received data from network plugin server
void _handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::SafeByteArray> data);
void _handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data);
private:
Swift::BoostNetworkFactories *m_factories;
Swift::BoostIOServiceThread m_boostIOServiceThread;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
boost::shared_ptr<Swift::Connection> m_conn;
Transport::Config *config;
};

View file

@ -11,7 +11,7 @@ bool HTTPRequest::init()
curl_easy_setopt(curlhandle, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY);
return true;
}
LOG4CXX_ERROR(logger, "Couldn't Initialize curl!");
LOG4CXX_ERROR(logger, "Couldn't Initialize curl!")
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());
}
} 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 writtenSize = 0;
if(obj && data) {
obj->callbackdata.append(data, size*nmemb);
writtenSize = (int)(size*nmemb);
}
return writtenSize;
int writtenSize = 0;
if(obj && data) {
obj->callbackdata.append(data, size*nmemb);
writtenSize = (int)(size*nmemb);
}
return writtenSize;
}
bool HTTPRequest::GET(std::string url, std::string &data)
bool HTTPRequest::GET(std::string url, std::string &data)
{
if(curlhandle) {
curl_easy_setopt(curlhandle, CURLOPT_CUSTOMREQUEST, NULL);
curl_easy_setopt(curlhandle, CURLOPT_ENCODING, "");
data = "";
callbackdata = "";
memset(curl_errorbuffer, 0, 1024);
curl_easy_setopt(curlhandle, CURLOPT_ERRORBUFFER, curl_errorbuffer);
curl_easy_setopt(curlhandle, CURLOPT_WRITEFUNCTION, curlCallBack);
curl_easy_setopt(curlhandle, CURLOPT_WRITEDATA, this);
/* Set http request and url */
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());
/* Send http request and return status*/
if(CURLE_OK == curl_easy_perform(curlhandle)) {
data = callbackdata;
return true;
}
} else {
LOG4CXX_ERROR(logger, "CURL not initialized!");
LOG4CXX_ERROR(logger, "CURL not initialized!")
strcpy(curl_errorbuffer, "CURL not initialized!");
}
return false;

View file

@ -4,20 +4,20 @@ DEFINE_LOGGER(logger, "CreateFriendRequest")
void CreateFriendRequest::run()
{
LOG4CXX_INFO(logger, user << " - Sending follow request for " << frnd);
LOG4CXX_INFO(logger, user << " - Sending follow request for " << frnd)
replyMsg = "";
success = twitObj->friendshipCreate(frnd, false);
if(success) {
twitObj->getLastWebResponse(replyMsg);
LOG4CXX_INFO(logger, user << replyMsg);
LOG4CXX_INFO(logger, user << 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;
std::string img;
req.init();
req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
@ -36,15 +36,15 @@ void CreateFriendRequest::finalize()
if(!success) {
std::string curlerror;
twitObj->getLastCurlError(curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror)
callBack(user, friendInfo, profileImg, error);
} else {
error = getErrorMessage(replyMsg);
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);
}
}

View file

@ -7,9 +7,9 @@ void DestroyFriendRequest::run()
success = twitObj->friendshipDestroy(frnd, false);
if(success) {
twitObj->getLastWebResponse(replyMsg);
LOG4CXX_INFO(logger, user << replyMsg);
LOG4CXX_INFO(logger, user << replyMsg)
friendInfo = getUser(replyMsg);
if(friendInfo.getScreenName() == "") LOG4CXX_INFO(logger, user << " - Was unable to fetch user info for " << frnd);
@ -22,12 +22,12 @@ void DestroyFriendRequest::finalize()
if(!success) {
std::string curlerror;
twitObj->getLastCurlError(curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror)
callBack(user, friendInfo, error);
} else {
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);
}
}

View file

@ -2,7 +2,7 @@
DEFINE_LOGGER(logger, "DirectMessageRequest")
void DirectMessageRequest::run()
void DirectMessageRequest::run()
{
replyMsg = "";
if(username != "") success = twitObj->directMessageSend(username, data, false);
@ -20,16 +20,13 @@ void DirectMessageRequest::finalize()
if(!success) {
std::string curlerror;
twitObj->getLastCurlError(curlerror);
error.setMessage(curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror);
callBack(user, username, messages, error);
} else {
error = getErrorMessage(replyMsg);
if(error.getMessage().length()) {
LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
} else {
LOG4CXX_INFO(logger, user << " - " << replyMsg);
}
callBack(user, username, messages, error);
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
else LOG4CXX_INFO(logger, user << " - " << replyMsg)
callBack(user, username, messages, error);
}
}

View file

@ -3,16 +3,16 @@
DEFINE_LOGGER(logger, "FetchFriends")
void FetchFriends::run()
{
replyMsg = "";
void FetchFriends::run()
{
replyMsg = "";
std::string next = "";
success = twitObj->friendsIdsGet(next, twitObj->getTwitterUsername(), false);
if(!success) return;
if(!success) return;
twitObj->getLastWebResponse( replyMsg );
std::vector<std::string> IDs = getIDs( replyMsg );
success = twitObj->userLookup(IDs, true);
if(!success) return;
@ -22,13 +22,13 @@ void FetchFriends::run()
HTTPRequest req;
req.init();
req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
for(int i=0 ; i<friends.size() ; i++) {
std::string img;
friendAvatars.push_back("");
if(req.GET(friends[i].getProfileImgURL(), img)) friendAvatars[i] = img;
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) {
std::string curlerror;
twitObj->getLastCurlError(curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " - " << curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " - " << curlerror)
callBack(user, friends, friendAvatars, error);
} else {
error = getErrorMessage(replyMsg);
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
callBack(user, friends, friendAvatars, error);
}
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
callBack(user, friends, friendAvatars, error);
}
}

View file

@ -2,8 +2,8 @@
DEFINE_LOGGER(logger, "PINExchangeProcess")
void PINExchangeProcess::run()
{
LOG4CXX_INFO(logger, user << ": Sending PIN " << data);
LOG4CXX_INFO(logger, user << " " << twitObj->getProxyServerIp() << " " << twitObj->getProxyServerPort());
LOG4CXX_INFO(logger, user << ": Sending PIN " << data)
LOG4CXX_INFO(logger, user << " " << twitObj->getProxyServerIp() << " " << twitObj->getProxyServerPort())
twitObj->getOAuth().setOAuthPin( data );
success = twitObj->oAuthAccessToken();
}
@ -11,7 +11,7 @@ void PINExchangeProcess::run()
void PINExchangeProcess::finalize()
{
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->handleLogoutRequest(user, "");
} else {
@ -22,7 +22,7 @@ void PINExchangeProcess::finalize()
Error error = getErrorMessage(replyMsg);
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->handleLogoutRequest(user, "");
return;
@ -47,24 +47,24 @@ void PINExchangeProcess::finalize()
/*void handlePINExchange(const std::string &user, std::string &data) {
sessions[user]->getOAuth().setOAuthPin( data );
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, "");
return;
}
std::string OAuthAccessTokenKey, OAuthAccessTokenSecret;
sessions[user]->getOAuth().getOAuthTokenKey( OAuthAccessTokenKey );
sessions[user]->getOAuth().getOAuthTokenSecret( OAuthAccessTokenSecret );
UserInfo info;
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, "");
return;
}
storagebackend->updateUserSetting((long)info.id, OAUTH_KEY, OAuthAccessTokenKey);
storagebackend->updateUserSetting((long)info.id, OAUTH_SECRET, OAuthAccessTokenSecret);
storagebackend->updateUserSetting((long)info.id, OAUTH_KEY, OAuthAccessTokenKey);
storagebackend->updateUserSetting((long)info.id, OAUTH_SECRET, OAuthAccessTokenSecret);
connectionState[user] = CONNECTED;
LOG4CXX_INFO(logger, user << ": Sent PIN " << data << " and obtained Access Token");

View file

@ -1,8 +1,8 @@
#include "ProfileImageRequest.h"
#include "../HTTPRequest.h"
DEFINE_LOGGER(logger, "ProfileImageRequest")
void ProfileImageRequest::run()
{
void ProfileImageRequest::run()
{
HTTPRequest req;
req.init();
req.setProxy(ip, port, puser, ppasswd);
@ -14,13 +14,13 @@ void ProfileImageRequest::finalize()
{
Error errResponse;
if(!success) {
LOG4CXX_ERROR(logger, user << " - " << error);
LOG4CXX_ERROR(logger, user << " - " << error)
img = "";
errResponse.setMessage(error);
callBack(user, buddy, img, reqID, errResponse);
} else {
LOG4CXX_INFO(logger, user << " - " << callbackdata);
img = callbackdata;
callBack(user, buddy, img, reqID, errResponse);
}
callBack(user, buddy, img, reqID, errResponse);
}
}

View file

@ -2,7 +2,7 @@
DEFINE_LOGGER(logger, "RetweetRequest")
void RetweetRequest::run()
{
LOG4CXX_INFO(logger, user << " Retweeting " << data);
LOG4CXX_INFO(logger, user << " Retweeting " << data)
success = twitObj->retweetById( data );
}
@ -12,17 +12,14 @@ void RetweetRequest::finalize()
if(!success) {
std::string curlerror;
twitObj->getLastCurlError(curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " Curl error: " << curlerror)
callBack(user, error);
} else {
twitObj->getLastWebResponse(replyMsg);
error = getErrorMessage(replyMsg);
if(error.getMessage().length()) {
LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
} else {
LOG4CXX_INFO(logger, user << " " << replyMsg);
}
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
else LOG4CXX_INFO(logger, user << " " << replyMsg);
callBack(user, error);
}
}

View file

@ -2,7 +2,7 @@
#include "../TwitterResponseParser.h"
DEFINE_LOGGER(logger, "StatusUpdateRequest")
void StatusUpdateRequest::run()
void StatusUpdateRequest::run()
{
replyMsg = "";
success = twitObj->statusUpdate(data);
@ -18,16 +18,13 @@ void StatusUpdateRequest::finalize()
if(!success) {
std::string curlerror;
twitObj->getLastCurlError(curlerror);
error.setMessage(curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror);
callBack(user, error);
} else {
error = getErrorMessage(replyMsg);
if(error.getMessage().length()) {
LOG4CXX_ERROR(logger, user << " - " << error.getMessage());
} else {
LOG4CXX_INFO(logger, "Updated status for " << user << ": " << data);
}
if(error.getMessage().length()) LOG4CXX_ERROR(logger, user << " - " << error.getMessage())
else LOG4CXX_INFO(logger, "Updated status for " << user << ": " << data);
callBack(user, error);
}
}

View file

@ -1,15 +1,15 @@
#include "TimelineRequest.h"
DEFINE_LOGGER(logger, "TimelineRequest")
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);
else success = twitObj->timelineHomeGet(since_id);
if(!success) return;
replyMsg = "";
replyMsg = "";
twitObj->getLastWebResponse( replyMsg );
//LOG4CXX_INFO(logger, user << " - " << replyMsg.length() << " " << replyMsg << "\n" );
tweets = getTimeline(replyMsg);
@ -21,12 +21,12 @@ void TimelineRequest::finalize()
if(!success) {
std::string curlerror;
twitObj->getLastCurlError(curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror);
error.setMessage(curlerror);
LOG4CXX_ERROR(logger, user << " - Curl error: " << curlerror)
callBack(user, userRequested, tweets, error);
} else {
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);
}
}
}

View file

@ -23,20 +23,20 @@ const std::string OLD_APP_SECRET = "EveLmCXJIg2R7BTCpm6OWV8YyX49nI0pxnYXh7JMvDg"
#define abs(x) ((x)<0?-(x):(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)
{
int diff = abs((int)a.size() - (int)b.size());
if(a.size() < b.size()) a = std::string(diff,'0') + a;
else b = std::string(diff,'0') + b;
if(a == b) return 0;
if(a < b) 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->storagebackend = storagebackend;
@ -60,9 +60,9 @@ TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, Stora
exit(1);
}
adminLegacyName = "twitter.com";
adminChatRoom = "#twitter";
adminNickName = "twitter";
adminLegacyName = "twitter.com";
adminChatRoom = "#twitter";
adminNickName = "twitter";
adminAlias = "twitter";
OAUTH_KEY = "twitter_oauth_token";
@ -72,7 +72,7 @@ TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, Stora
m_factories = new Swift::BoostNetworkFactories(loop);
m_conn = m_factories->getConnectionFactory()->createConnection();
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);
@ -87,14 +87,14 @@ TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, Stora
message_timer->start();
#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
LOG4CXX_INFO(logger, "Starting the plugin.");
}
TwitterPlugin::~TwitterPlugin()
TwitterPlugin::~TwitterPlugin()
{
delete storagebackend;
std::set<std::string>::iterator it;
@ -103,13 +103,13 @@ TwitterPlugin::~TwitterPlugin()
}
// 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));
}
// 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) {
m_firstPing = false;
@ -125,42 +125,42 @@ void TwitterPlugin::_handleDataRead(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::
}
// 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 ||
userdb[user].connectionState == CONNECTED ||
if(userdb.count(user) && (userdb[user].connectionState == NEW ||
userdb[user].connectionState == CONNECTED ||
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;
}
LOG4CXX_INFO(logger, std::string("Received login request for ") + user);
LOG4CXX_INFO(logger, std::string("Received login request for ") + user)
initUserSession(user, legacyName, password);
handleConnected(user);
LOG4CXX_INFO(logger, "SPECTRUM 1 USER? - " << (userdb[user].spectrum1User? "true" : "false"));
LOG4CXX_INFO(logger, user << ": Adding Buddy " << adminLegacyName << " " << adminAlias);
LOG4CXX_INFO(logger, "SPECTRUM 1 USER? - " << (userdb[user].spectrum1User? "true" : "false"))
LOG4CXX_INFO(logger, user << ": Adding Buddy " << adminLegacyName << " " << adminAlias)
handleBuddyChanged(user, adminLegacyName, adminAlias, std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
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;
getUserOAuthKeyAndSecret(user, key, secret);
if(key == "" || secret == "") {
LOG4CXX_INFO(logger, "Intiating OAuth Flow for user " << user);
if(key == "" || secret == "") {
LOG4CXX_INFO(logger, "Intiating OAuth Flow for user " << user)
setTwitterMode(user, 0);
tp->runAsThread(new OAuthFlow(np, userdb[user].sessions, user, userdb[user].sessions->getTwitterUsername()));
} else {
LOG4CXX_INFO(logger, user << " is already registerd. Using the stored oauth key and secret");
LOG4CXX_INFO(logger, key << " " << secret);
LOG4CXX_INFO(logger, user << " is already registerd. Using the stored oauth key and secret")
LOG4CXX_INFO(logger, key << " " << secret)
pinExchangeComplete(user, key, secret);
}
}
// 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)) {
delete userdb[user].sessions;
@ -176,8 +176,8 @@ void TwitterPlugin::handleLogoutRequest(const std::string &user, const std::stri
// User joining a Chatroom
void TwitterPlugin::handleJoinRoomRequest(const std::string &user, const std::string &room, const std::string &nickname, const std::string &password)
{
if(room == adminChatRoom) {
LOG4CXX_INFO(logger, "Received Join Twitter room request for " << user << " '" << nickname << "'");
if(room == adminChatRoom) {
LOG4CXX_INFO(logger, "Received Join Twitter room request for " << user << " '" << nickname << "'")
setTwitterMode(user, 2);
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)));
} else {
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");
}
}
}
// User leaving a Chatroom
void TwitterPlugin::handleLeaveRoomRequest(const std::string &user, const std::string &room)
{
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);
handleBuddyChanged(user, adminLegacyName, adminAlias, std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
}
}
// 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*/)
// 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*/)
{
LOG4CXX_INFO(logger, "Received " << user << " --> " << legacyName << " - " << message);
LOG4CXX_INFO(logger, "Received " << user << " --> " << legacyName << " - " << message)
if(legacyName == adminLegacyName || legacyName == adminChatRoom) {
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;
for(i=0 ; i<message.size() && message[i] != ' '; i++) cmd += message[i];
while(i<message.size() && message[i] == ' ') i++;
data = message.substr(i);
/***********************************************************************/
if(cmd == "#pin")
if(cmd == "#pin")
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)));
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,
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,
boost::bind(&TwitterPlugin::statusUpdateResponse, this, _1, _2)));
else if(cmd == "#timeline")
else if(cmd == "#timeline")
tp->runAsThread(new TimelineRequest(userdb[user].sessions, user, data, "",
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,
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('@')),
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('@')),
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,
boost::bind(&TwitterPlugin::RetweetResponse, this, _1, _2)));
else if(cmd == "#mode") {
@ -259,13 +259,13 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
setTwitterMode(user, m);
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)));
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
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) {
@ -281,9 +281,9 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
}
else handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
"Unknown command! Type #help for a list of available commands.", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
}
}
else {
else {
std::string buddy = legacyName;
if(userdb[user].twitterMode == CHATROOM) buddy = legacyName.substr(legacyName.find("/") + 1);
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) {
LOG4CXX_ERROR(logger, user << " is not connected to twitter!");
LOG4CXX_ERROR(logger, user << " is not connected to twitter!")
return;
}
LOG4CXX_INFO(logger, user << " - Adding Twitter contact " << buddyName);
tp->runAsThread(new CreateFriendRequest(userdb[user].sessions, user, buddyName,
LOG4CXX_INFO(logger, user << " - Adding Twitter contact " << buddyName)
tp->runAsThread(new CreateFriendRequest(userdb[user].sessions, user, buddyName,
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) {
LOG4CXX_ERROR(logger, user << " is not connected to twitter!");
LOG4CXX_ERROR(logger, user << " is not connected to twitter!")
return;
}
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;
}
LOG4CXX_INFO(logger, user << " - Removing Twitter contact " << buddyName);
tp->runAsThread(new DestroyFriendRequest(userdb[user].sessions, user, buddyName,
LOG4CXX_INFO(logger, user << " - Removing Twitter contact " << buddyName)
tp->runAsThread(new DestroyFriendRequest(userdb[user].sessions, user, buddyName,
boost::bind(&TwitterPlugin::deleteFriendResponse, this, _1, _2, _3)));
}
void TwitterPlugin::handleVCardRequest(const std::string &user, const std::string &legacyName, unsigned int id)
{
if(userdb[user].connectionState != CONNECTED) {
LOG4CXX_ERROR(logger, user << " is not connected to twitter!");
LOG4CXX_ERROR(logger, user << " is not connected to twitter!")
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()) {
if(userdb[user].buddiesImgs.count(legacyName) == 0) {
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);
UserInfo info;
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;
}
@ -384,13 +384,13 @@ bool TwitterPlugin::getUserOAuthKeyAndSecret(const std::string user, std::string
return true;
}
bool TwitterPlugin::checkSpectrum1User(const std::string user)
bool TwitterPlugin::checkSpectrum1User(const std::string user)
{
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!");
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
return false;
}
@ -398,19 +398,19 @@ bool TwitterPlugin::checkSpectrum1User(const std::string user)
int type = TYPE_STRING;
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;
return false;
}
int TwitterPlugin::getTwitterMode(const std::string user)
int TwitterPlugin::getTwitterMode(const std::string user)
{
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!");
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
return -1;
}
@ -425,18 +425,18 @@ int TwitterPlugin::getTwitterMode(const std::string user)
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);
UserInfo info;
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;
}
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;
}
@ -444,23 +444,23 @@ bool TwitterPlugin::setTwitterMode(const std::string user, int m)
//int type;
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);
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);
UserInfo info;
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;
}
storagebackend->updateUserSetting((long)info.id, OAUTH_KEY, OAuthKey);
storagebackend->updateUserSetting((long)info.id, OAUTH_KEY, OAuthKey);
storagebackend->updateUserSetting((long)info.id, OAUTH_SECRET, OAuthSecret);
return true;
}
@ -471,21 +471,21 @@ void TwitterPlugin::initUserSession(const std::string user, const std::string le
std::string username = legacyName;
std::string passwd = password;
LOG4CXX_INFO(logger, username + " " + passwd);
LOG4CXX_INFO(logger, username + " " + passwd)
userdb[user].sessions = new twitCurl();
if(CONFIG_HAS_KEY(config,"proxy.server")) {
userdb[user].sessions = new twitCurl();
if(CONFIG_HAS_KEY(config,"proxy.server")) {
std::string ip = CONFIG_STRING(config,"proxy.server");
std::ostringstream out;
std::ostringstream out;
out << CONFIG_INT(config,"proxy.port");
std::string port = out.str();
std::string puser = CONFIG_STRING(config,"proxy.user");
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") {
userdb[user].sessions->setProxyServerIp(ip);
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].connectionState = NEW;
userdb[user].legacyName = username;
userdb[user].legacyName = username;
userdb[user].sessions->setTwitterUsername(username);
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;
userdb[user].sessions = obj->clone();
userdb[user].sessions = obj->clone();
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().setOAuthTokenSecret( OAuthAccessTokenSecret );
userdb[user].connectionState = CONNECTED;
userdb[user].twitterMode = (mode)getTwitterMode(user);
if(userdb[user].twitterMode == MULTIPLECONTACT) {
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);
userdb[user].mostRecentTweetID = "";
userdb[user].mostRecentDirectMessageID = "";
}
}
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;
UserInfo info;
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;
}
@ -553,7 +553,7 @@ void TwitterPlugin::updateLastTweetID(const std::string user, const std::string
}
std::string TwitterPlugin::getMostRecentTweetIDUnsafe(const std::string user)
{
{
std::string ID = "";
if(onlineUsers.count(user)) {
ID = userdb[user].mostRecentTweetID;
@ -561,7 +561,7 @@ std::string TwitterPlugin::getMostRecentTweetIDUnsafe(const std::string user)
int type = TYPE_STRING;
UserInfo info;
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 {
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)
{
{
boost::mutex::scoped_lock lock(userlock);
return getMostRecentTweetIDUnsafe(user);
}
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;
UserInfo info;
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;
}
@ -599,7 +599,7 @@ std::string TwitterPlugin::getMostRecentDMIDUnsafe(const std::string user) {
int type = TYPE_STRING;
UserInfo info;
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 {
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)
{
boost::mutex::scoped_lock lock(userlock);
boost::mutex::scoped_lock lock(userlock);
return getMostRecentDMIDUnsafe(user);
}
@ -648,19 +648,19 @@ void TwitterPlugin::clearRoster(const std::string user)
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++) {
userdb[user].buddies.insert(friends[i].getScreenName());
userdb[user].buddiesInfo[friends[i].getScreenName()] = friends[i];
userdb[user].buddiesImgs[friends[i].getScreenName()] = friendAvatars[i];
if(userdb[user].twitterMode == MULTIPLECONTACT) {
std::string lastTweet = friends[i].getLastStatus().getTweet();
//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
pbnetwork::STATUS_ONLINE, lastTweet, Swift::Hexify::hexify(cryptoProvider->getSHA1Hash(Swift::createByteArray(friendAvatars[i]))));
#else
@ -669,9 +669,9 @@ void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends
}
else if(userdb[user].twitterMode == CHATROOM)
handleParticipantChanged(user, friends[i].getScreenName(), adminChatRoom, 0, pbnetwork::STATUS_ONLINE);
/*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 : "");*/
}
} 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)
{
if(errMsg.getMessage().length() == 0)
if(errMsg.getMessage().length() == 0)
{
std::string userlist = "\n***************USER LIST****************\n";
for(int i=0 ; i < friends.size() ; i++) {
userlist += " - " + friends[i].getUserName() + " (" + friends[i].getScreenName() + ")\n";
}
}
userlist += "***************************************\n";
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
userlist, userdb[user].twitterMode == CHATROOM ? adminNickName : "");
userlist, userdb[user].twitterMode == CHATROOM ? adminNickName : "");
} else {
if (errMsg.isCurlError()) {
handleDisconnected(user, 3, errMsg.getMessage());
return;
}
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
errMsg.getMessage(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
errMsg.getMessage(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
}
}
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);
}
}
if(userdb[user].twitterMode == MULTIPLECONTACT) {
//Set as status user's last tweet
for(it=lastTweet.begin() ; it!=lastTweet.end() ; it++) {
int t = it->second;
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());
}
}
@ -750,7 +750,7 @@ void TwitterPlugin::displayTweets(std::string &user, std::string &userRequested,
return;
}
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 != "") {
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
"Message delivered!", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
"Message delivered!", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
return;
}
if(!messages.size()) return;
if(userdb[user].twitterMode == SINGLECONTACT) {
std::string msglist = "";
std::string msgID = getMostRecentDMID(user);
std::string maxID = msgID;
for(int i=0 ; i < messages.size() ; i++) {
if(cmp(msgID, messages[i].getID()) == -1) {
msglist += " - " + messages[i].getSenderData().getScreenName() + ": " + messages[i].getMessage() + "\n";
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);
} else {
std::string msgID = getMostRecentDMID(user);
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());
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);
}
}
@ -832,12 +832,12 @@ void TwitterPlugin::createFriendResponse(std::string &user, User &frnd, std::str
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
std::string("You are now following ") + frnd.getScreenName(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
userdb[user].buddies.insert(frnd.getScreenName());
userdb[user].buddiesInfo[frnd.getScreenName()] = frnd;
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 HAVE_SWIFTEN_3
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());
return;
}
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
errMsg.getMessage(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
return;
}
LOG4CXX_INFO(logger, user << " - " << frnd.getScreenName() << ", " << frnd.getProfileImgURL());
}
LOG4CXX_INFO(logger, user << " - " << frnd.getScreenName() << ", " << frnd.getProfileImgURL())
userdb[user].buddies.erase(frnd.getScreenName());
handleMessage(user, userdb[user].twitterMode == CHATROOM ? adminChatRoom : adminLegacyName,
std::string("You are not following ") + frnd.getScreenName() + " anymore", userdb[user].twitterMode == CHATROOM ? adminNickName : "");
if (userdb[user].twitterMode == CHATROOM) {
handleParticipantChanged(user, frnd.getScreenName(), adminLegacyName, 0, pbnetwork::STATUS_NONE);
}
if(userdb[user].twitterMode == MULTIPLECONTACT) {
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,
errMsg.getMessage(), userdb[user].twitterMode == CHATROOM ? adminNickName : "");
} else {
LOG4CXX_INFO(logger, user << " - Sending VCard for " << buddy);
LOG4CXX_INFO(logger, user << " - Sending VCard for " << buddy)
handleVCard(user, reqID, buddy, buddy, "", img);
}
}

View file

@ -11,7 +11,6 @@
#include "transport/ThreadPool.h"
#include "Swiften/Swiften.h"
#include "Swiften/SwiftenCompat.h"
#ifndef _WIN32
#include "unistd.h"
#include "signal.h"
@ -56,9 +55,9 @@ class TwitterPlugin : public NetworkPlugin {
public:
Swift::BoostNetworkFactories *m_factories;
Swift::BoostIOServiceThread m_boostIOServiceThread;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> m_conn;
boost::shared_ptr<Swift::Connection> m_conn;
#if HAVE_SWIFTEN_3
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::CryptoProvider> cryptoProvider;
boost::shared_ptr<Swift::CryptoProvider> cryptoProvider;
#endif
Swift::Timer::ref tweet_timer;
Swift::Timer::ref message_timer;
@ -71,7 +70,7 @@ class TwitterPlugin : public NetworkPlugin {
void sendData(const std::string &string);
// 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
void handleLoginRequest(const std::string &user, const std::string &legacyName, const std::string &password);

View file

@ -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 ?
ss >> ldt;
ss.str("");
ss << ldt;
ss << ldt;
return ss.str();
}
@ -53,7 +53,7 @@ EmbeddedStatus getEmbeddedStatus(const rapidjson::Value &element)
{
EmbeddedStatus status;
if(!element.IsObject()) {
LOG4CXX_ERROR(logger, "Not a status element!");
LOG4CXX_ERROR(logger, "Not a status element!")
return status;
}
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()) );
status.setRetweetCount( element[TwitterReponseTypes::retweet_count.c_str()].GetInt64() );
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;
}
User getUser(const rapidjson::Value &element)
User getUser(const rapidjson::Value &element)
{
User user;
if(!element.IsObject()) {
LOG4CXX_ERROR(logger, "Not a user element!");
LOG4CXX_ERROR(logger, "Not a user element!")
return user;
}
@ -85,12 +85,12 @@ User getUser(const rapidjson::Value &element)
user.setUserName( std::string( element[TwitterReponseTypes::name.c_str()].GetString() ) );
user.setProfileImgURL( std::string( element[TwitterReponseTypes::profile_image_url.c_str()].GetString() ) );
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()]));
return user;
}
Status getStatus(const rapidjson::Value &element)
Status getStatus(const rapidjson::Value &element)
{
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.setUserData( getUser ( rt[TwitterReponseTypes::user.c_str()]) );
}
return status;
}
DirectMessage getDirectMessage(const rapidjson::Value &element)
DirectMessage getDirectMessage(const rapidjson::Value &element)
{
DirectMessage DM;
DM.setCreationTime( toIsoTime ( std::string( element[TwitterReponseTypes::created_at.c_str()].GetString() ) ) );
DM.setID( stringOf( element[TwitterReponseTypes::id.c_str()].GetInt64() ) );
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;
rapidjson::Document rootElement;
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
LOG4CXX_ERROR(logger, "Error while parsing JSON");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "Error while parsing JSON")
LOG4CXX_ERROR(logger, json)
return statuses;
}
if(!rootElement.IsArray()) {
LOG4CXX_ERROR(logger, "JSON doesn't correspond to timeline:");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "JSON doesn't correspond to timeline:")
LOG4CXX_ERROR(logger, json)
return statuses;
}
@ -163,17 +163,17 @@ std::vector<DirectMessage> getDirectMessages(std::string &json)
{
std::vector<DirectMessage> DMs;
rapidjson::Document rootElement;
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
LOG4CXX_ERROR(logger, "Error while parsing JSON");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "Error while parsing JSON")
LOG4CXX_ERROR(logger, json)
return DMs;
}
if(!rootElement.IsArray()) {
LOG4CXX_ERROR(logger, "JSON doesn't correspond to direct messages:");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "JSON doesn't correspond to direct messages:")
LOG4CXX_ERROR(logger, json)
return DMs;
}
@ -187,40 +187,40 @@ std::vector<User> getUsers(std::string &json)
{
std::vector<User> users;
rapidjson::Document rootElement;
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
LOG4CXX_ERROR(logger, "Error while parsing JSON");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "Error while parsing JSON")
LOG4CXX_ERROR(logger, json)
return users;
}
if(!rootElement.IsArray()) {
LOG4CXX_ERROR(logger, "JSON doesn't correspond to user list:");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "JSON doesn't correspond to user list:")
LOG4CXX_ERROR(logger, json)
return users;
}
for(rapidjson::SizeType i = 0; i < rootElement.Size(); i++) {
users.push_back(getUser(rootElement[i]));
}
return users;
return users;
}
User getUser(std::string &json)
{
User user;
rapidjson::Document rootElement;
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
LOG4CXX_ERROR(logger, "Error while parsing JSON");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "Error while parsing JSON")
LOG4CXX_ERROR(logger, json)
return user;
}
if(!rootElement.IsObject()) {
LOG4CXX_ERROR(logger, "JSON doesn't correspond to user object");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "JSON doesn't correspond to user object")
LOG4CXX_ERROR(logger, json)
return user;
}
@ -231,21 +231,21 @@ std::vector<std::string> getIDs(std::string &json)
{
std::vector<std::string> IDs;
rapidjson::Document rootElement;
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
LOG4CXX_ERROR(logger, "Error while parsing JSON");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "Error while parsing JSON")
LOG4CXX_ERROR(logger, json)
return IDs;
}
if(!rootElement.IsObject()) {
LOG4CXX_ERROR(logger, "JSON doesn't correspond to id_list");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, json)
return IDs;
}
const rapidjson::Value & ids = rootElement[TwitterReponseTypes::ids.c_str()];
for(int i=0 ; i<ids.Size() ; i++) {
IDs.push_back(stringOf( ids[i].GetInt64()) );
}
@ -258,14 +258,14 @@ Error getErrorMessage(std::string &json)
std::string code = "0";
Error resp;
rapidjson::Document rootElement;
if(rootElement.Parse<0>(json.c_str()).HasParseError()) {
LOG4CXX_ERROR(logger, "Error while parsing JSON");
LOG4CXX_ERROR(logger, json);
LOG4CXX_ERROR(logger, "Error while parsing JSON")
LOG4CXX_ERROR(logger, json)
return resp;
}
if (rootElement.IsObject()) {
if (!rootElement["errors"].IsNull()) {
if (!rootElement["errors"].IsNull()) {
const rapidjson::Value &errorElement = rootElement["errors"][0u]; // first error
error = std::string(errorElement["message"].GetString());
code = stringOf(errorElement["code"].GetInt64());
@ -277,22 +277,22 @@ Error getErrorMessage(std::string &json)
return resp;
}
std::vector<UrlEntity> getUrlEntities(const rapidjson::Value &element)
std::vector<UrlEntity> getUrlEntities(const rapidjson::Value &element)
{
std::vector<UrlEntity> url_entities;
const rapidjson::Value &entities = element["entities"];
if (entities.IsObject()) {
const rapidjson::Value &urls = entities["urls"];
if (urls.IsArray()) {
if (urls.IsArray()) {
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);
}
}
}
return url_entities;
}

View file

@ -48,7 +48,7 @@ int main (int argc, char* argv[]) {
}
else if (!storagebackend->connect()) {
LOG4CXX_ERROR(logger, "Can't connect to database!");
LOG4CXX_ERROR(logger, "Can't connect to database!")
return -1;
}

View file

@ -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)
if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
find_program(SWIFTEN_CONFIG_EXECUTABLE NAMES swiften-config DOC "swiften-config executable" HINTS ../bin)
set( SWIFTEN_CFLAGS "" )
if (SWIFTEN_CONFIG_EXECUTABLE)
# Libs
execute_process(
COMMAND ${SWIFTEN_CONFIG_EXECUTABLE} --libs
OUTPUT_VARIABLE SWIFTEN_LIB)
@ -30,21 +29,7 @@ if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
else()
list(APPEND SWIFTEN_LIBRARY ${f})
endif()
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()
endforeach(f)
set( SWIFTEN_FOUND 1 )
else()
message( STATUS "Could NOT find swiften-config" )

View file

@ -7,7 +7,7 @@ h2. Install Swiften from git repository:
<pre>
git clone git://swift.im/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
sudo ./scons V=1 swiften_dll=1 Swiften SWIFTEN_INSTALLDIR=/usr/local /usr/local
</pre>

View file

@ -12,12 +12,10 @@
#include <Swiften/Elements/Payload.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class AttentionPayload : public Payload {
public:
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AttentionPayload> ref;
typedef boost::shared_ptr<AttentionPayload> ref;
public:
AttentionPayload();

View file

@ -12,14 +12,12 @@
#include <Swiften/Elements/Payload.h>
#include "Swiften/SwiftenCompat.h"
// This payload is NOT part of ANY XEP and it is only
// libtransport related extension.
namespace Swift {
class InvisiblePayload : public Payload {
public:
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<InvisiblePayload> ref;
typedef boost::shared_ptr<InvisiblePayload> ref;
public:
InvisiblePayload();

View file

@ -6,7 +6,6 @@
#include "CombinedOutgoingFileTransferManager.h"
#include <boost/foreach.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <Swiften/JID/JID.h>
@ -19,6 +18,7 @@
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
#include <Swiften/Base/IDGenerator.h>
#include <Swiften/Elements/Presence.h>
#include <Swiften/Base/foreach.h>
namespace Swift {
@ -31,30 +31,30 @@ CombinedOutgoingFileTransferManager::~CombinedOutgoingFileTransferManager() {
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
boost::optional<JID> fullJID = highestPriorityJIDSupportingJingle(receipient);
if (!fullJID.is_initialized()) {
fullJID = highestPriorityJIDSupportingSI(receipient);
}
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());
assert(jingleSession);
jsManager->registerOutgoingSession(from, jingleSession);
#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;
#endif
}
if (!fullJID.is_initialized()) {
return SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<OutgoingFileTransfer>();
return boost::shared_ptr<OutgoingFileTransfer>();
}
// 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
return jingleFT;
@ -68,7 +68,7 @@ boost::optional<JID> CombinedOutgoingFileTransferManager::highestPriorityJIDSupp
std::vector<Presence::ref> presences = presenceOracle->getAllPresence(bareJID);
//iterate over them
BOOST_FOREACH(Presence::ref pres, presences) {
foreach(Presence::ref pres, presences) {
if (pres->getPriority() > priority) {
// look up caps from the jid
DiscoInfo::ref info = capsProvider->getCaps(pres->getFrom());
@ -92,7 +92,7 @@ boost::optional<JID> CombinedOutgoingFileTransferManager::highestPriorityJIDSupp
std::vector<Presence::ref> presences = presenceOracle->getAllPresence(bareJID);
//iterate over them
BOOST_FOREACH(Presence::ref pres, presences) {
foreach(Presence::ref pres, presences) {
if (pres->getPriority() > priority) {
// look up caps from the jid
DiscoInfo::ref info = capsProvider->getCaps(pres->getFrom());

View file

@ -12,9 +12,6 @@
#include <Swiften/JID/JID.h>
#include "transport/PresenceOracle.h"
#include "Swiften/SwiftenCompat.h"
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
#include <Swiften/Version.h>
#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();
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:
boost::optional<JID> highestPriorityJIDSupportingJingle(const JID& bareJID);

View file

@ -14,11 +14,9 @@
#include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h>
#include <Swiften/FileTransfer/IBBSendSession.h>
#include "Swiften/SwiftenCompat.h"
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() {
@ -71,7 +69,7 @@ void MyOutgoingSIFileTransfer::handleStreamInitiationRequestResponse(StreamIniti
request->send();
}
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->start();
#if !HAVE_SWIFTEN_3

View file

@ -7,12 +7,10 @@
#pragma once
#include <boost/shared_ptr.hpp>
#include <boost/signals.hpp>
#include "Swiften/SwiftenCompat.h"
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
#include <Swiften/FileTransfer/ReadBytestream.h>
#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/FileTransfer/FileTransferError.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamServer.h>
#include <Swiften/JID/JID.h>
@ -30,7 +28,7 @@ namespace Swift {
class MyOutgoingSIFileTransfer : public OutgoingFileTransfer {
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 stop();
@ -51,10 +49,10 @@ namespace Swift {
std::string name;
int size;
std::string description;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ReadBytestream> bytestream;
boost::shared_ptr<ReadBytestream> bytestream;
IQRouter* iqRouter;
SOCKS5BytestreamServer* socksServer;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IBBSendSession> ibbSession;
boost::shared_ptr<IBBSendSession> ibbSession;
SOCKS5BytestreamRegistry *registry;
};
}

View file

@ -6,15 +6,12 @@
#include <Swiften/Network/DummyConnectionServer.h>
#include <boost/signal.hpp>
#include <boost/bind.hpp>
#include <boost/system/system_error.hpp>
#include <boost/asio/placeholders.hpp>
#include <Swiften/EventLoop/EventLoop.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
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(
boost::bind(boost::ref(onNewConnection), connection));
boost::bind(boost::ref(onNewConnection), connection),
shared_from_this());
// connection->listen();
}

View file

@ -10,27 +10,28 @@
#include <boost/asio/io_service.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <Swiften/Base/boost_bsignals.h>
#include <Swiften/Network/DummyConnection.h>
#include <Swiften/Network/ConnectionServer.h>
#include <Swiften/EventLoop/EventOwner.h>
#include <Swiften/Version.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class DummyConnectionServer : public ConnectionServer {
class DummyConnectionServer : public ConnectionServer, public EventOwner, public boost::enable_shared_from_this<DummyConnectionServer> {
public:
typedef boost::shared_ptr<DummyConnectionServer> ref;
enum Error {
Conflict,
UnknownError
};
static SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DummyConnectionServer> create(EventLoop* eventLoop) {
return SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DummyConnectionServer>(new DummyConnectionServer(eventLoop));
static ref create(EventLoop* 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)
virtual boost::optional<ConnectionServer::Error> tryStart() {

View file

@ -12,11 +12,11 @@ namespace Swift {
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);
}
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);
}

View file

@ -11,8 +11,6 @@
#include <Swiften/Network/ConnectionServerFactory.h>
#include <Swiften/Network/DummyConnectionServer.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class ConnectionServer;
@ -20,9 +18,9 @@ namespace Swift {
public:
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:
EventLoop* eventLoop;

View file

@ -22,7 +22,7 @@ DummyNetworkFactories::DummyNetworkFactories(EventLoop* eventLoop) {
timerFactory = new DummyTimerFactory();
connectionFactory = new DummyConnectionFactory(eventLoop);
#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);
cryptoProvider = PlatformCryptoProvider::create();
networkEnvironment = new PlatformNetworkEnvironment();

View file

@ -16,8 +16,6 @@
#include <Swiften/IDN/PlatformIDNConverter.h>
#endif
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class EventLoop;
@ -79,7 +77,7 @@ namespace Swift {
TimerFactory* timerFactory;
ConnectionFactory* connectionFactory;
#if HAVE_SWIFTEN_3
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IDNConverter> idnConverter;
boost::shared_ptr<IDNConverter> idnConverter;
CryptoProvider* cryptoProvider;
NetworkEnvironment* networkEnvironment;
#endif

View file

@ -6,18 +6,18 @@
#include <Swiften/Parser/PayloadParsers/GatewayPayloadParser.h>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
#include <Swiften/Parser/PayloadParserFactory.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/MUCOccupant.h>
#include <Swiften/Parser/Tree/TreeReparser.h>
namespace Swift {
void GatewayPayloadParser::handleTree(ParserElement::ref root) {
BOOST_FOREACH (ParserElement::ref child, root->getAllChildren()) {
foreach (ParserElement::ref child, root->getAllChildren()) {
if (child->getName() == "desc") {
getPayloadInternal()->setDesc(child->getText());
}

View file

@ -6,18 +6,18 @@
#include <Swiften/Parser/PayloadParsers/MUCPayloadParser.h>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <Swiften/Parser/PayloadParserFactoryCollection.h>
#include <Swiften/Parser/PayloadParserFactory.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Elements/MUCOccupant.h>
#include <Swiften/Parser/Tree/TreeReparser.h>
namespace Swift {
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()) {
getPayloadInternal()->setPassword(child->getText());
}

View file

@ -4,10 +4,8 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <cassert>
#include <Swiften/Parser/PayloadParsers/XHTMLIMParser.h>
#include <Swiften/Parser/SerializingParser.h>
#include "Swiften/SwiftenCompat.h"
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();
}

View file

@ -9,8 +9,6 @@
#include <Swiften/Elements/XHTMLIMPayload.h>
#include <Swiften/Parser/GenericPayloadParser.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class SerializingParser;
@ -21,7 +19,7 @@ namespace Swift {
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 handleCharacterData(const std::string& data);
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XHTMLIMPayload> getLabelPayload() const;
boost::shared_ptr<XHTMLIMPayload> getLabelPayload() const;
private:
enum Level {
TopLevel = 0,

View file

@ -8,7 +8,6 @@
#include <Swiften/Parser/PlatformXMLParserFactory.h>
#include <Swiften/Parser/Tree/ParserElement.h>
#include <Swiften/Parser/XMLParser.h>
#include <Swiften/Version.h>
namespace Swift {
@ -29,17 +28,11 @@ class DefaultStringTreeParser : public StringTreeParser {
ParserElement::ref StringTreeParser::parse(const std::string &xml) {
PlatformXMLParserFactory factory;
DefaultStringTreeParser client;
#if (SWIFTEN_VERSION >= 0x040000)
std::unique_ptr<XMLParser> parser = factory.createXMLParser(&client);
#else
XMLParser *parser = factory.createXMLParser(&client);
#endif
parser->parse(xml);
ParserElement::ref root = client.getRoot();
#if (SWIFTEN_VERSION < 0x040000)
delete parser;
#endif
return root;
}

View file

@ -14,8 +14,6 @@
#include <Swiften/Parser/Tree/ParserElement.h>
#include <Swiften/Parser/XMLParserClient.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
/**
* 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) {
if (!root_) {
root_ = SWIFTEN_SHRPTR_NAMESPACE::make_shared<ParserElement>(element, xmlns, attributes);
root_ = boost::make_shared<ParserElement>(element, xmlns, attributes);
elementStack_.push_back(root_);
}
else {

View file

@ -17,7 +17,7 @@ namespace Swift {
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");
return attentionElement.serialize();

View file

@ -9,13 +9,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Elements/AttentionPayload.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class AttentionSerializer : public GenericPayloadSerializer<AttentionPayload> {
public:
AttentionSerializer();
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AttentionPayload>) const;
virtual std::string serializePayload(boost::shared_ptr<AttentionPayload>) const;
};
}

View file

@ -5,34 +5,33 @@
*/
#include <Swiften/Serializer/PayloadSerializers/GatewayPayloadSerializer.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include <Swiften/Serializer/PayloadSerializerCollection.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
GatewayPayloadSerializer::GatewayPayloadSerializer()
: 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");
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);
}
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);
}
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);
}

View file

@ -9,13 +9,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Elements/GatewayPayload.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class GatewayPayloadSerializer : public GenericPayloadSerializer<GatewayPayload> {
public:
GatewayPayloadSerializer();
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<GatewayPayload> item) const;
virtual std::string serializePayload(boost::shared_ptr<GatewayPayload> item) const;
};
}

View file

@ -19,7 +19,7 @@ namespace Swift {
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");
return attentionElement.serialize();

View file

@ -9,8 +9,6 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Elements/InvisiblePayload.h>
#include "Swiften/SwiftenCompat.h"
// This payload is NOT part of ANY XEP and it is only
// libtransport related extension.
namespace Swift {
@ -18,6 +16,6 @@ namespace Swift {
public:
InvisibleSerializer();
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<InvisiblePayload>) const;
virtual std::string serializePayload(boost::shared_ptr<InvisiblePayload>) const;
};
}

View file

@ -6,10 +6,12 @@
#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/XMLRawTextNode.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include "Swiften/SwiftenCompat.h"
#include <boost/lexical_cast.hpp>
namespace Swift {
@ -17,7 +19,7 @@ namespace Swift {
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;
switch (error->getError()) {
case SpectrumErrorPayload::CONNECTION_ERROR_NETWORK_ERROR: data = "CONNECTION_ERROR_NETWORK_ERROR"; break;

View file

@ -9,13 +9,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Elements/SpectrumErrorPayload.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class SpectrumErrorSerializer : public GenericPayloadSerializer<SpectrumErrorPayload> {
public:
SpectrumErrorSerializer();
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SpectrumErrorPayload>) const;
virtual std::string serializePayload(boost::shared_ptr<SpectrumErrorPayload>) const;
};
}

View file

@ -4,25 +4,24 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <boost/foreach.hpp>
#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/XMLRawTextNode.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
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");
BOOST_FOREACH(const StatsPayload::Item& item, stats->getItems()) {
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XMLElement> statElement(new XMLElement("stat"));
foreach(const StatsPayload::Item& item, stats->getItems()) {
boost::shared_ptr<XMLElement> statElement(new XMLElement("stat"));
statElement->setAttribute("name", item.getName());
if (!item.getUnits().empty()) {
statElement->setAttribute("units", item.getUnits());

View file

@ -9,13 +9,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Elements/StatsPayload.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class StatsSerializer : public GenericPayloadSerializer<StatsPayload> {
public:
StatsSerializer();
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<StatsPayload>) const;
virtual std::string serializePayload(boost::shared_ptr<StatsPayload>) const;
};
}

View file

@ -5,22 +5,21 @@
*/
#include <Swiften/Serializer/PayloadSerializers/XHTMLIMSerializer.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Serializer/XML/XMLRawTextNode.h>
#include <Swiften/Serializer/XML/XMLTextNode.h>
#include <Swiften/Serializer/XML/XMLElement.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
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");
SWIFTEN_SHRPTR_NAMESPACE::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())));
boost::shared_ptr<XMLElement> body(new XMLElement("body", "http://www.w3.org/1999/xhtml"));
body->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(payload->getBody())));
html.addNode(body);
return html.serialize();

View file

@ -9,13 +9,11 @@
#include <Swiften/Serializer/GenericPayloadSerializer.h>
#include <Swiften/Elements/XHTMLIMPayload.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class XHTMLIMSerializer : public GenericPayloadSerializer<XHTMLIMPayload> {
public:
XHTMLIMSerializer();
virtual std::string serializePayload(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<XHTMLIMPayload> xhtml) const;
virtual std::string serializePayload(boost::shared_ptr<XHTMLIMPayload> xhtml) const;
};
}

View file

@ -8,10 +8,9 @@
#include <string>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/signal.hpp>
#include "Swiften/Base/String.h"
#include "Swiften/Base/foreach.h"
#include "Swiften/Network/Connection.h"
#include "Swiften/Network/ConnectionServer.h"
#include "Swiften/Network/ConnectionServerFactory.h"
@ -70,7 +69,7 @@ void Server::start() {
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(port_);
}
else {
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(SWIFT_HOSTADDRESS(address_), port_);
serverFromClientConnectionServer = networkFactories_->getConnectionServerFactory()->createConnectionServer(Swift::HostAddress(address_), port_);
}
serverFromClientConnectionServerSignalConnections.push_back(
serverFromClientConnectionServer->onNewConnection.connect(
@ -89,14 +88,14 @@ void Server::stop() {
stopping = true;
// foreach(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session, serverFromClientSessions) {
// foreach(boost::shared_ptr<ServerFromClientSession> session, serverFromClientSessions) {
// session->finishSession();
// }
serverFromClientSessions.clear();
if (serverFromClientConnectionServer) {
serverFromClientConnectionServer->stop();
BOOST_FOREACH(SWIFTEN_SIGNAL_NAMESPACE::connection& connection, serverFromClientConnectionServerSignalConnections) {
foreach(boost::bsignals::connection& connection, serverFromClientConnectionServerSignalConnections) {
connection.disconnect();
}
serverFromClientConnectionServerSignalConnections.clear();
@ -107,9 +106,9 @@ void Server::stop() {
// 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,
getPayloadParserFactories(), getPayloadSerializers(), userRegistry_, parserFactory_));
//serverFromClientSession->setAllowSASLEXTERNAL();
@ -139,11 +138,11 @@ void Server::handleDataWritten(const SafeByteArray& 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);
}
void Server::handleSessionFinished(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session) {
void Server::handleSessionFinished(boost::shared_ptr<ServerFromClientSession> session) {
// if (!session->getRemoteJID().isValid()) {
// Swift::Presence::ref presence = Swift::Presence::create();
// presence->setFrom(session->getBareJID());

View file

@ -8,7 +8,6 @@
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
#include <boost/signals2.hpp>
#include <vector>
#include "Swiften/Network/BoostIOServiceThread.h"
@ -22,7 +21,6 @@
#include "Swiften/Entity/Entity.h"
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
#include "Swiften/SwiftenCompat.h"
#include <Swiften/TLS/CertificateWithKey.h>
#include <Swiften/Parser/PlatformXMLParserFactory.h>
@ -55,7 +53,7 @@ namespace Swift {
return iqRouter_;
}
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> getConnectionServer() const {
boost::shared_ptr<ConnectionServer> getConnectionServer() const {
return serverFromClientConnectionServer;
}
@ -65,10 +63,10 @@ namespace Swift {
void addTLSEncryption(TLSServerContextFactory* tlsContextFactory, CertificateWithKey::ref cert);
private:
void handleNewClientConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> c);
void handleSessionStarted(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>);
void handleSessionFinished(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>);
void handleElementReceived(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session);
void handleNewClientConnection(boost::shared_ptr<Connection> c);
void handleSessionStarted(boost::shared_ptr<ServerFromClientSession>);
void handleSessionFinished(boost::shared_ptr<ServerFromClientSession>);
void handleElementReceived(boost::shared_ptr<Element> element, boost::shared_ptr<ServerFromClientSession> session);
void handleDataRead(const SafeByteArray&);
void handleDataWritten(const SafeByteArray&);
@ -79,9 +77,9 @@ namespace Swift {
EventLoop* eventLoop;
NetworkFactories* networkFactories_;
bool stopping;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ConnectionServer> serverFromClientConnectionServer;
std::vector<SWIFTEN_SIGNAL_NAMESPACE::connection> serverFromClientConnectionServerSignalConnections;
std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > serverFromClientSessions;
boost::shared_ptr<ConnectionServer> serverFromClientConnectionServer;
std::vector<boost::bsignals::connection> serverFromClientConnectionServerSignalConnections;
std::list<boost::shared_ptr<ServerFromClientSession> > serverFromClientSessions;
JID selfJID;
StanzaChannel *stanzaChannel_;
IQRouter *iqRouter_;

View file

@ -29,8 +29,6 @@
#include <iostream>
#include <Swiften/TLS/CertificateWithKey.h>
#include "Swiften/SwiftenCompat.h"
#include <Swiften/Version.h>
#if (SWIFTEN_VERSION >= 0x030000)
#include <Swiften/Elements/ToplevelElement.h>
@ -40,7 +38,7 @@ namespace Swift {
ServerFromClientSession::ServerFromClientSession(
const std::string& id,
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> connection,
boost::shared_ptr<Connection> connection,
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
UserRegistry* userRegistry,
@ -65,7 +63,7 @@ ServerFromClientSession::~ServerFromClientSession() {
void ServerFromClientSession::handlePasswordValid() {
if (!isInitialized()) {
getXMPPLayer()->writeElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AuthSuccess>(new AuthSuccess()));
getXMPPLayer()->writeElement(boost::shared_ptr<AuthSuccess>(new AuthSuccess()));
authenticated_ = true;
getXMPPLayer()->resetParser();
}
@ -73,9 +71,9 @@ void ServerFromClientSession::handlePasswordValid() {
void ServerFromClientSession::handlePasswordInvalid(const std::string &error) {
if (!isInitialized()) {
getXMPPLayer()->writeElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AuthFailure>(new AuthFailure));
getXMPPLayer()->writeElement(boost::shared_ptr<AuthFailure>(new AuthFailure));
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);
}
@ -84,9 +82,9 @@ void ServerFromClientSession::handlePasswordInvalid(const std::string &error) {
}
#if (SWIFTEN_VERSION >= 0x030000)
void ServerFromClientSession::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ToplevelElement> element) {
void ServerFromClientSession::handleElement(boost::shared_ptr<ToplevelElement> element) {
#else
void ServerFromClientSession::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element) {
void ServerFromClientSession::handleElement(boost::shared_ptr<Element> element) {
#endif
if (isInitialized()) {
onElementReceived(element);
@ -95,7 +93,7 @@ void ServerFromClientSession::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr
if (AuthRequest* authRequest = dynamic_cast<AuthRequest*>(element.get())) {
if (authRequest->getMechanism() == "PLAIN" || (allowSASLEXTERNAL && 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;
getXMPPLayer()->resetParser();
}
@ -106,25 +104,25 @@ void ServerFromClientSession::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr
}
}
else {
getXMPPLayer()->writeElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<AuthFailure>(new AuthFailure));
getXMPPLayer()->writeElement(boost::shared_ptr<AuthFailure>(new AuthFailure));
finishSession(NoSupportedAuthMechanismsError);
}
}
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);
tlsLayer->connect();
getXMPPLayer()->resetParser();
}
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 uuid;
for (int i = 0; i < 10; i++) {
uuid += bucket[rand() % bucket.size()];
}
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());
getXMPPLayer()->writeElement(IQ::createResult(JID(), iq->getID(), resultResourceBind));
}
@ -143,7 +141,7 @@ void ServerFromClientSession::handleStreamStart(const ProtocolHeader& incomingHe
header.setID(id_);
getXMPPLayer()->writeHeader(header);
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<StreamFeatures> features(new StreamFeatures());
boost::shared_ptr<StreamFeatures> features(new StreamFeatures());
if (!authenticated_) {
if (tlsLayer && !tlsConnected) {
@ -179,7 +177,7 @@ void ServerFromClientSession::addTLSEncryption(TLSServerContextFactory* tlsConte
if (!tlsLayer->setServerCertificate(cert)) {
// std::cout << "error\n";
// TODO:
// onClosed(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Error>(new Error(Error::InvalidTLSCertificateError)));
// onClosed(boost::shared_ptr<Error>(new Error(Error::InvalidTLSCertificateError)));
}
else {
tlsLayer->onError.connect(boost::bind(&ServerFromClientSession::handleTLSError, this));

View file

@ -7,8 +7,8 @@
#pragma once
#include <boost/shared_ptr.hpp>
#include <Swiften/Base/boost_bsignals.h>
#include <boost/enable_shared_from_this.hpp>
#include <boost/signals.hpp>
#include <string>
#include <Swiften/Session/Session.h>
@ -19,8 +19,6 @@
#include <Swiften/Version.h>
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class ProtocolHeader;
class Element;
@ -40,7 +38,7 @@ namespace Swift {
public:
ServerFromClientSession(
const std::string& id,
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Connection> connection,
boost::shared_ptr<Connection> connection,
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
UserRegistry* userRegistry,
@ -65,9 +63,9 @@ namespace Swift {
private:
#if HAVE_SWIFTEN_3
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ToplevelElement>);
void handleElement(boost::shared_ptr<ToplevelElement>);
#else
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element>);
void handleElement(boost::shared_ptr<Element>);
#endif
void handleStreamStart(const ProtocolHeader& header);
void handleSessionFinished(const boost::optional<SessionError>&);

View file

@ -10,8 +10,6 @@
#include <Swiften/Elements/Stanza.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class ServerSession {
public:
@ -20,6 +18,6 @@ namespace Swift {
virtual const JID& getJID() 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;
};
}

View file

@ -21,41 +21,41 @@ namespace {
struct HasJID {
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);
}
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);
session->onSessionFinished.connect(boost::bind(&ServerStanzaChannel::handleSessionFinished, this, _1, session));
session->onElementReceived.connect(boost::bind(&ServerStanzaChannel::handleElement, 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->onElementReceived.disconnect(boost::bind(&ServerStanzaChannel::handleElement, 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());
}
void ServerStanzaChannel::sendIQ(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IQ> iq) {
void ServerStanzaChannel::sendIQ(boost::shared_ptr<IQ> iq) {
send(iq);
}
void ServerStanzaChannel::sendMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Message> message) {
void ServerStanzaChannel::sendMessage(boost::shared_ptr<Message> message) {
send(message);
}
void ServerStanzaChannel::sendPresence(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Presence> presence) {
void ServerStanzaChannel::sendPresence(boost::shared_ptr<Presence> 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) {
Swift::Presence::ref presence = Swift::Presence::create();
presence->setFrom(session->getRemoteJID());
@ -64,16 +64,16 @@ void ServerStanzaChannel::handleDataRead(const SafeByteArray &data, const SWIFTE
}
}
#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
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
std::vector<SWIFTEN_SHRPTR_NAMESPACE::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) {
std::vector<boost::shared_ptr<ServerFromClientSession> > candidateSessions;
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);
}
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);
if (element) {
(*i)->sendElement(element);
@ -98,7 +98,7 @@ std::string ServerStanzaChannel::getNewIQID() {
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();
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
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()) {
(*i)->sendElement(stanza);
return;
@ -117,8 +117,8 @@ void ServerStanzaChannel::send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stan
// Look for candidate sessions
to = to.toBare();
std::vector<SWIFTEN_SHRPTR_NAMESPACE::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) {
std::vector<boost::shared_ptr<ServerFromClientSession> > candidateSessions;
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)) {
candidateSessions.push_back(*i);
(*i)->sendElement(stanza);
@ -134,7 +134,7 @@ void ServerStanzaChannel::send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stan
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);
// 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) {
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza = SWIFTEN_SHRPTR_NAMESPACE::dynamic_pointer_cast<Stanza>(element);
void ServerStanzaChannel::handleElement(boost::shared_ptr<Element> element, const boost::shared_ptr<ServerFromClientSession>& session) {
boost::shared_ptr<Stanza> stanza = boost::dynamic_pointer_cast<Stanza>(element);
if (!stanza) {
return;
}
@ -157,19 +157,19 @@ void ServerStanzaChannel::handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Ele
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) {
onMessageReceived(message);
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) {
onPresenceReceived(presence);
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) {
onIQReceived(iq);
return;

View file

@ -25,16 +25,16 @@ namespace Swift {
ServerStanzaChannel(const JID &selfJID) : StanzaChannel() {
m_jid = selfJID;
}
void addSession(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session);
void removeSession(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> session);
void addSession(boost::shared_ptr<ServerFromClientSession> session);
void removeSession(boost::shared_ptr<ServerFromClientSession> session);
void sendIQ(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<IQ> iq);
void sendMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Message> message);
void sendPresence(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Presence> presence);
void sendIQ(boost::shared_ptr<IQ> iq);
void sendMessage(boost::shared_ptr<Message> message);
void sendPresence(boost::shared_ptr<Presence> presence);
#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
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
bool getStreamManagementEnabled() const {
return false;
@ -50,17 +50,17 @@ namespace Swift {
private:
std::string getNewIQID();
void send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza);
void handleSessionFinished(const boost::optional<Session::SessionError>&, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> &session);
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> &session);
void handleDataRead(const SafeByteArray &data, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> &session);
void send(boost::shared_ptr<Stanza> stanza);
void handleSessionFinished(const boost::optional<Session::SessionError>&, const boost::shared_ptr<ServerFromClientSession> &session);
void handleElement(boost::shared_ptr<Element> element, const boost::shared_ptr<ServerFromClientSession> &session);
void handleDataRead(const SafeByteArray &data, const boost::shared_ptr<ServerFromClientSession> &session);
void handleSessionInitialized();
private:
JID m_jid;
IDGenerator idGenerator;
// [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;
};
}

View file

@ -32,7 +32,7 @@ namespace {
ServerStanzaRouter::ServerStanzaRouter() {
}
bool ServerStanzaRouter::routeStanza(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza) {
bool ServerStanzaRouter::routeStanza(boost::shared_ptr<Stanza> stanza) {
JID to = stanza->getTo();
assert(to.isValid());

View file

@ -12,8 +12,6 @@
#include <Swiften/JID/JID.h>
#include <Swiften/Elements/Stanza.h>
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class ServerSession;
@ -21,7 +19,7 @@ namespace Swift {
public:
ServerStanzaRouter();
bool routeStanza(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza>);
bool routeStanza(boost::shared_ptr<Stanza>);
void addClientSession(ServerSession*);
void removeClientSession(ServerSession*);

View file

@ -45,7 +45,7 @@ Certificate::ref TLSServerLayer::getPeerCertificate() const {
return context->getPeerCertificate();
}
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> TLSServerLayer::getPeerCertificateVerificationError() const {
boost::shared_ptr<CertificateVerificationError> TLSServerLayer::getPeerCertificateVerificationError() const {
return context->getPeerCertificateVerificationError();
}

View file

@ -4,14 +4,13 @@
* 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/StreamStack/StreamLayer.h"
#include "Swiften/TLS/Certificate.h"
#include <Swiften/TLS/CertificateWithKey.h>
#include "Swiften/TLS/CertificateVerificationError.h"
#include "Swiften/SwiftenCompat.h"
namespace Swift {
class TLSServerContext;
@ -27,7 +26,7 @@ namespace Swift {
bool setServerCertificate(CertificateWithKey::ref cert);
Certificate::ref getPeerCertificate() const;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
void writeData(const SafeByteArray& data);
void handleDataRead(const SafeByteArray& data);

View file

@ -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

View file

@ -181,7 +181,7 @@ void OpenSSLServerContext::sendPendingDataToApplication() {
}
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()) {
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate can't be loaded.");
return false;
@ -190,7 +190,7 @@ bool OpenSSLServerContext::setServerCertificate(CertificateWithKey::ref certref)
// Create a PKCS12 structure
BIO* bio = BIO_new(BIO_s_mem());
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);
if (!pkcs12) {
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.");
return false;
}
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<X509> cert(certPtr, X509_free);
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<EVP_PKEY> privateKey(privateKeyPtr, EVP_PKEY_free);
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<STACK_OF(X509)> caCerts(caCertsPtr, freeX509Stack);
boost::shared_ptr<X509> cert(certPtr, X509_free);
boost::shared_ptr<EVP_PKEY> privateKey(privateKeyPtr, EVP_PKEY_free);
boost::shared_ptr<STACK_OF(X509)> caCerts(caCertsPtr, freeX509Stack);
// Use the key & certificates
if (SSL_CTX_use_certificate(context_, cert.get()) != 1) {
@ -223,7 +223,7 @@ bool OpenSSLServerContext::setServerCertificate(CertificateWithKey::ref certref)
}
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) {
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_);
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 {
return SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError>();
return boost::shared_ptr<CertificateVerificationError>();
}
}

View file

@ -7,11 +7,11 @@
#pragma once
#include <openssl/ssl.h>
#include "Swiften/Base/boost_bsignals.h"
#include <boost/noncopyable.hpp>
#include "Swiften/TLS/TLSServerContext.h"
#include "Swiften/Base/ByteArray.h"
#include "Swiften/SwiftenCompat.h"
#include <Swiften/TLS/CertificateWithKey.h>
namespace Swift {
@ -29,7 +29,7 @@ namespace Swift {
void handleDataFromApplication(const SafeByteArray&);
Certificate::ref getPeerCertificate() const;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;
virtual ByteArray getFinishMessage() const;

View file

@ -520,7 +520,7 @@ void SchannelServerContext::encryptAndSendData(const SafeByteArray& data)
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()) {
return false;
}
@ -551,7 +551,7 @@ Certificate::ref SchannelServerContext::getPeerCertificate() const
CertificateVerificationError::ref SchannelServerContext::getPeerCertificateVerificationError() const
{
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> pCertError;
boost::shared_ptr<CertificateVerificationError> pCertError;
if (m_state == Error)
pCertError.reset( new CertificateVerificationError(m_verificationError) );

View file

@ -6,11 +6,12 @@
#pragma once
#include "Swiften/Base/boost_bsignals.h"
#include "Swiften/TLS/TLSServerContext.h"
#include "Swiften/TLS/Schannel/SchannelUtil.h"
#include <Swiften/TLS/CertificateWithKey.h>
#include "Swiften/Base/ByteArray.h"
#include "Swiften/SwiftenCompat.h"
#define SECURITY_WIN32
#include <Windows.h>
@ -25,7 +26,7 @@ namespace Swift
class SchannelServerContext : public TLSServerContext, boost::noncopyable
{
public:
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SchannelServerContext> sp_t;
typedef boost::shared_ptr<SchannelServerContext> sp_t;
public:
SchannelServerContext();

View file

@ -38,16 +38,16 @@ class SecureTransportServerContext : public TLSServerContext {
static std::string stateToString(State state);
void setState(State newState);
static SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSError> nativeToTLSError(OSStatus error);
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> CSSMErrorToVerificationError(OSStatus resultCode);
static boost::shared_ptr<TLSError> nativeToTLSError(OSStatus error);
boost::shared_ptr<CertificateVerificationError> CSSMErrorToVerificationError(OSStatus resultCode);
void processHandshake();
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:
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SSLContext> sslContext_;
boost::shared_ptr<SSLContext> sslContext_;
SafeByteArray readingBuffer_;
State state_;
CertificateVerificationError::ref verificationError_;

View file

@ -39,7 +39,7 @@ namespace {
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) {
return NULL;
}
@ -104,7 +104,7 @@ CFArrayRef CreateClientCertificateChainAsCFArrayRef(CertificateWithKey::ref key)
}
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;
// set IO callbacks
@ -163,7 +163,7 @@ void SecureTransportServerContext::connect() {
if (clientCertificate_) {
CFArrayRef certs = CreateClientCertificateChainAsCFArrayRef(clientCertificate_);
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());
if (result != noErr) {
SWIFT_LOG(error) << "SSLSetCertificate failed with error " << result << "." << std::endl;
@ -191,7 +191,7 @@ void SecureTransportServerContext::processHandshake() {
}
else {
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;
OSStatus error = SSLCopyPeerTrust(sslContext_.get(), &trust);
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;
}
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_) {
error = SecTrustSetOptions(trust, kSecTrustOptionRequireRevPerCert | kSecTrustOptionFetchIssuerFromNet);
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;
}
}
@ -219,7 +219,7 @@ void SecureTransportServerContext::verifyServerCertificate() {
SecTrustResultType trustResult;
error = SecTrustEvaluate(trust, &trustResult);
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;
}
@ -242,7 +242,7 @@ void SecureTransportServerContext::verifyServerCertificate() {
CSSM_TP_APPLE_EVIDENCE_INFO* statusChain;
error = SecTrustGetResult(trustRef.get(), &trustResult, &certChain, &statusChain);
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 n = 0; n < statusChain[index].NumStatusCodes; n++) {
// Even though Secure Transport reported CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK on the whole certificate
@ -259,11 +259,11 @@ void SecureTransportServerContext::verifyServerCertificate() {
}
}
else {
verificationError_ = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
verificationError_ = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
}
break;
case kSecTrustResultOtherError:
verificationError_ = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
verificationError_ = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::UnknownError);
break;
default:
SWIFT_LOG(warning) << "Unhandled trust result " << trustResult << "." << std::endl;
@ -274,7 +274,7 @@ void SecureTransportServerContext::verifyServerCertificate() {
setState(Error);
SSLClose(sslContext_.get());
sslContext_.reset();
onError(SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>());
onError(boost::make_shared<TLSError>());
}
else {
// proceed with handshake
@ -326,7 +326,7 @@ void SecureTransportServerContext::handleDataFromNetwork(const SafeByteArray& da
}
else {
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;
}
@ -358,7 +358,7 @@ void SecureTransportServerContext::handleDataFromApplication(const SafeByteArray
return;
default:
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_) {
typedef boost::remove_pointer<SecTrustRef>::type SecTrust;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SecTrust> securityTrust;
boost::shared_ptr<SecTrust> securityTrust;
SecTrustRef secTrust = NULL;;
OSStatus error = SSLCopyPeerTrust(sslContext_.get(), &secTrust);
if (error == noErr) {
securityTrust = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<SecTrust>(secTrust, CFRelease);
securityTrust = boost::shared_ptr<SecTrust>(secTrust, CFRelease);
CFIndex chainSize = SecTrustGetCertificateCount(securityTrust.get());
for (CFIndex n = 0; n < chainSize; n++) {
SecCertificateRef certificate = SecTrustGetCertificateAtIndex(securityTrust.get(), n);
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;
}
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSError> SecureTransportServerContext::nativeToTLSError(OSStatus /* error */) {
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<TLSError> swiftenError;
swiftenError = SWIFTEN_SHRPTR_NAMESPACE::make_shared<TLSError>();
boost::shared_ptr<TLSError> SecureTransportServerContext::nativeToTLSError(OSStatus /* error */) {
boost::shared_ptr<TLSError> swiftenError;
swiftenError = boost::make_shared<TLSError>();
return swiftenError;
}
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> SecureTransportServerContext::CSSMErrorToVerificationError(OSStatus resultCode) {
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<CertificateVerificationError> error;
boost::shared_ptr<CertificateVerificationError> SecureTransportServerContext::CSSMErrorToVerificationError(OSStatus resultCode) {
boost::shared_ptr<CertificateVerificationError> error;
switch(resultCode) {
case CSSMERR_TP_NOT_TRUSTED:
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;
case CSSMERR_TP_CERT_NOT_VALID_YET:
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;
case CSSMERR_TP_CERT_EXPIRED:
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;
case CSSMERR_TP_CERT_REVOKED:
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;
case CSSMERR_TP_VERIFY_ACTION_FAILED:
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:
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_INCOMPLETE_REVOCATION_CHECK" << std::endl;
if (checkCertificateRevocation_) {
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed);
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed);
}
break;
case CSSMERR_APPLETP_OCSP_UNAVAILABLE:
SWIFT_LOG(debug) << "CSSM result code: CSSMERR_APPLETP_OCSP_UNAVAILABLE" << std::endl;
if (checkCertificateRevocation_) {
error = SWIFTEN_SHRPTR_NAMESPACE::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed);
error = boost::make_shared<CertificateVerificationError>(CertificateVerificationError::RevocationCheckFailed);
}
break;
case CSSMERR_APPLETP_SSL_BAD_EXT_KEY_USE:
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;
default:
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;
}
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);
if (sslContext_) {
SSLClose(sslContext_.get());

View file

@ -6,8 +6,8 @@
#pragma once
#include "Swiften/Base/boost_bsignals.h"
#include <boost/shared_ptr.hpp>
#include <boost/signals.hpp>
#include "Swiften/Base/SafeByteArray.h"
#include "Swiften/TLS/Certificate.h"

View file

@ -30,11 +30,11 @@ namespace boost { namespace dll {
namespace detail {
template <class T>
class refc_function {
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<shared_library> lib_;
boost::shared_ptr<shared_library> lib_;
T* func_ptr_;
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)
, func_ptr_(func_ptr)
{}
@ -57,8 +57,8 @@ namespace detail {
template <class T>
struct import_type<T, typename boost::enable_if<boost::is_object<T> >::type> {
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<T> base_type;
typedef SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<T> type;
typedef boost::shared_ptr<T> base_type;
typedef boost::shared_ptr<T> type;
};
} // 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
* of the loaded shared library, so that it won't get unload until all copies of return value
* are not destroyed.
@ -82,7 +82,7 @@ namespace detail {
* \b Examples:
* \code
* 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"
* );
* \endcode
@ -92,7 +92,7 @@ namespace detail {
* \endcode
*
* \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
*
* \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 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.
* 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)
{
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()
);
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
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;
return type(lib, &lib->get<T>(name));
}
//! \overload boost::dll::import(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
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());
}
template <class T>
BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const char* name, load_mode::type mode) {
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
);
}
@ -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
* of the loaded shared library, so that it won't get unload until all copies of return value
* are not destroyed.
@ -159,7 +159,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const ch
* \b Examples:
* \code
* 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"
* );
* \endcode
@ -169,7 +169,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import(const boost::filesystem::path& lib, const ch
* \endcode
*
* \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
*
* \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 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.
* 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)
{
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()
);
}
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
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());
}
//! \overload boost::dll::import_alias(const boost::filesystem::path& lib, const char* name, load_mode::type mode)
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;
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>
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>(
SWIFTEN_SHRPTR_NAMESPACE::make_shared<boost::dll::shared_library>(lib, mode),
boost::make_shared<boost::dll::shared_library>(lib, mode),
name
);
}

View file

@ -12,9 +12,6 @@
/// \brief Contains the boost::dll::shared_library class, core class for all the
/// DLL/DSO operations.
// Walkaround for compatibility with boost 1.54
#include <boost/move/move.hpp>
#include <boost/config.hpp>
#include <boost/predef/os.h>
#include <boost/utility/explicit_operator_bool.hpp>

View file

@ -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

View file

@ -32,7 +32,6 @@ class StorageBackend;
class UserManager;
class NetworkPluginServer;
class UserRegistration;
class AdminInterfaceCommand;
class AdminInterface {
public:
@ -42,18 +41,15 @@ class AdminInterface {
void handleQuery(Swift::Message::ref message);
void addCommand(AdminInterfaceCommand *command);
void handleMessageReceived(Swift::Message::ref message);
private:
void handleMessageReceived(Swift::Message::ref message);
Component *m_component;
StorageBackend *m_storageBackend;
UserManager *m_userManager;
NetworkPluginServer *m_server;
UserRegistration *m_userRegistration;
std::map<std::string, AdminInterfaceCommand *> m_commands;
time_t m_start;
};
}

View file

@ -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;
};
}

View file

@ -26,7 +26,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/assign.hpp>
#include <boost/bind.hpp>
#include <boost/signalslib.hpp>
#include <boost/signal.hpp>
namespace Transport {

View file

@ -25,7 +25,6 @@
#include <list>
#include "Swiften/Elements/Message.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/SwiftenCompat.h"
namespace Transport {
@ -64,9 +63,9 @@ class Conversation {
/// \param message Message received from legacy network.
/// \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);
/// Handles participant change in MUC.
@ -108,7 +107,7 @@ class Conversation {
/// Sends message to Legacy network.
/// \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.
@ -148,7 +147,7 @@ class Conversation {
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 = "");
void cacheMessage(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> &message);
void cacheMessage(boost::shared_ptr<Swift::Message> &message);
private:
ConversationManager *m_conversationManager;
@ -168,8 +167,8 @@ class Conversation {
// connected to single room, we store all those things 10 times.
// It would be also great to store last 100 messages per room
// every time, so we can get history messages for IRC for example.
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> m_subject;
std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Message> > m_cachedMessages;
boost::shared_ptr<Swift::Message> m_subject;
std::list<boost::shared_ptr<Swift::Message> > m_cachedMessages;
typedef struct {
Swift::Presence::ref presence;

View file

@ -49,16 +49,16 @@ class Buddy;
class FileTransferManager {
public:
typedef struct Transfer {
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::OutgoingFileTransfer> ft;
boost::shared_ptr<Swift::OutgoingFileTransfer> ft;
Swift::JID from;
Swift::JID to;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::ReadBytestream> readByteStream;
boost::shared_ptr<Swift::ReadBytestream> readByteStream;
} Transfer;
FileTransferManager(Component *component, UserManager *userManager);
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:
Component *m_component;

View file

@ -30,7 +30,6 @@
#include "Swiften/Elements/IQ.h"
#include "Swiften/Elements/DiscoInfo.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/SwiftenCompat.h"
#include <boost/signal.hpp>
@ -75,11 +74,11 @@ class Frontend {
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;
@ -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 getOAuth2URL(const std::vector<std::string> &args) { return ""; }
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; }
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 *)> onBuddyRemoved;
boost::signal<void (Buddy *, const Swift::RosterItemPayload &item)> onBuddyAdded;
boost::signal<void (Swift::Message::ref message)> onMessageReceived;
boost::signal<void (bool /* isAvailable */)> onAvailableChanged;
boost::signal<void (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Presence>) > onPresenceReceived;
boost::signal<void (const Swift::JID& jid, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info)> onCapabilitiesReceived;
boost::signal<void (boost::shared_ptr<Swift::Presence>) > onPresenceReceived;
boost::signal<void (const Swift::JID& jid, boost::shared_ptr<Swift::DiscoInfo> info)> onCapabilitiesReceived;
};
}

View file

@ -22,10 +22,8 @@
#include <string>
#include <map>
#include <boost/signal.hpp>
#include "Swiften/FileTransfer/ReadBytestream.h"
#include "Swiften/SwiftenCompat.h"
namespace Transport {
@ -36,7 +34,7 @@ class MemoryReadBytestream : public Swift::ReadBytestream {
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; }
bool isFinished() const;

View file

@ -39,7 +39,6 @@
#include "Swiften/Parser/XMPPParser.h"
#include "Swiften/Parser/XMPPParserClient.h"
#include "Swiften/Serializer/XMPPSerializer.h"
#include "Swiften/SwiftenCompat.h"
#include <Swiften/Version.h>
#include <Swiften/FileTransfer/FileTransfer.h>
#define HAVE_SWIFTEN_3 (SWIFTEN_VERSION >= 0x030000)
@ -69,7 +68,7 @@ class NetworkPluginServer : Swift::XMPPParserClient {
int pongReceived;
std::list<User *> users;
Swift::SafeByteArray data;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> connection;
boost::shared_ptr<Swift::Connection> connection;
unsigned long res;
unsigned long init_res;
unsigned long shared;
@ -105,13 +104,13 @@ class NetworkPluginServer : Swift::XMPPParserClient {
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:
void handleNewClientConnection(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> c);
void handleNewClientConnection(boost::shared_ptr<Swift::Connection> c);
void handleSessionFinished(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 handleDisconnectedPayload(const std::string &payload);
@ -149,7 +148,7 @@ class NetworkPluginServer : Swift::XMPPParserClient {
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 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);
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 sendPing(Backend *c);
@ -167,14 +166,14 @@ class NetworkPluginServer : Swift::XMPPParserClient {
Backend *getFreeClient(bool acceptUsers = true, bool longRun = false, bool check = false);
void connectWaitingUsers();
void loginDelayFinished();
void handleRawIQReceived(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ> iq);
void handleRawPresenceReceived(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Presence> presence);
void handleRawIQReceived(boost::shared_ptr<Swift::IQ> iq);
void handleRawPresenceReceived(boost::shared_ptr<Swift::Presence> presence);
void handleStreamStart(const Swift::ProtocolHeader&) {}
#if HAVE_SWIFTEN_3
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::ToplevelElement> element);
void handleElement(boost::shared_ptr<Swift::ToplevelElement> element);
#else
void handleElement(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Element> element);
void handleElement(boost::shared_ptr<Swift::Element> element);
#endif
void handleStreamEnd() {}
@ -183,7 +182,7 @@ class NetworkPluginServer : Swift::XMPPParserClient {
RosterResponder *m_rosterResponder;
BlockResponder *m_blockResponder;
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::vector<unsigned long> m_pids;
Swift::Timer::ref m_pingTimer;

View file

@ -22,12 +22,12 @@
#include <map>
#include <boost/signals.hpp>
#include <string>
#include <Swiften/Elements/Presence.h>
#include <Swiften/Client/StanzaChannel.h>
#include <Swiften/Base/boost_bsignals.h>
namespace Transport {
class Frontend;

View file

@ -23,7 +23,6 @@
#include <string>
#include <algorithm>
#include <map>
#include <boost/signal.hpp>
#include <boost/pool/pool_alloc.hpp>
#include <boost/pool/object_pool.hpp>
// #include "rosterstorage.h"
@ -44,7 +43,7 @@ class RosterStorage;
/// Manages roster of one XMPP user.
class RosterManager {
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.
/// \param user User associated with this RosterManager.
/// \param component Transport instance associated with this roster.
@ -121,7 +120,7 @@ class RosterManager {
void sendUnavailablePresences(const Swift::JID &to);
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:
Component *m_component;

View file

@ -56,8 +56,8 @@ class ThreadPool
boost::mutex criticalregion;
Swift::EventLoop *loop;
boost::signals2::signal < void () > onWorkerAvailable;
boost::signals2::signal < void () > onWorkerAvailable;
public:
ThreadPool(Swift::EventLoop *loop, int maxthreads);
~ThreadPool();
@ -68,7 +68,6 @@ class ThreadPool
void scheduleFromQueue();
int getFreeThread();
void releaseThread(int i);
void workerBody(Thread *t, int wid);
};
}

View file

@ -21,7 +21,6 @@
#pragma once
#include <vector>
#include <boost/signal.hpp>
#include <boost/bind.hpp>
#include "Swiften/Network/BoostTimerFactory.h"
#include "Swiften/Network/BoostIOServiceThread.h"
@ -29,7 +28,6 @@
#include "Swiften/Elements/DiscoInfo.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/Elements/IQ.h"
#include "Swiften/SwiftenCompat.h"
namespace Transport {
class StorageBackend;
@ -40,7 +38,6 @@ namespace Transport {
class Factory;
class Config;
class UserManager;
class AdminInterface;
class Component {
public:
@ -110,9 +107,7 @@ namespace Transport {
/// \param presence Presence.
boost::signal<void (Swift::Presence::ref presence)> onUserPresenceReceived;
boost::signal<void (SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ>)> onRawIQReceived;
boost::signal<void ()> onAdminInterfaceSet;
boost::signal<void (boost::shared_ptr<Swift::IQ>)> onRawIQReceived;
void handlePresence(Swift::Presence::ref presence);
void handleConnected();
@ -126,17 +121,8 @@ namespace Transport {
PresenceOracle *getPresenceOracle();
void setAdminInterface(AdminInterface *adminInterface) {
m_adminInterface = adminInterface;
onAdminInterfaceSet();
}
AdminInterface *getAdminInterface() {
return m_adminInterface;
}
private:
void handleDiscoInfoResponse(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info, Swift::ErrorPayload::ref error, const Swift::JID& jid);
void handleDiscoInfoResponse(boost::shared_ptr<Swift::DiscoInfo> info, Swift::ErrorPayload::ref error, const Swift::JID& jid);
void handleCapsChanged(const Swift::JID& jid);
void handleBackendConfigChanged();
@ -153,7 +139,6 @@ namespace Transport {
Factory *m_factory;
Swift::EventLoop *m_loop;
Frontend *m_frontend;
AdminInterface *m_adminInterface;
friend class User;
friend class UserRegistration;

View file

@ -20,7 +20,6 @@
#pragma once
#include <boost/signal.hpp>
#include <time.h>
#include "transport/StorageBackend.h"
#include <Swiften/FileTransfer/OutgoingFileTransfer.h>
@ -31,7 +30,6 @@
#include "Swiften/Elements/DiscoInfo.h"
#include "Swiften/Network/Timer.h"
#include "Swiften/Network/Connection.h"
#include "Swiften/SwiftenCompat.h"
namespace Transport {
@ -91,7 +89,7 @@ class User {
void handleSubscription(Swift::Presence::ref presence);
void handleDiscoInfo(const Swift::JID& jid, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info);
void handleDiscoInfo(const Swift::JID& jid, boost::shared_ptr<Swift::DiscoInfo> info);
time_t &getLastActivity() {
return m_lastActivity;
@ -171,10 +169,10 @@ class User {
bool m_readyForConnect;
bool m_ignoreDisconnect;
Swift::Timer::ref m_reconnectTimer;
SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::Connection> connection;
boost::shared_ptr<Swift::Connection> connection;
time_t m_lastActivity;
std::map<Swift::JID, Swift::DiscoInfo::ref> m_legacyCaps;
std::vector<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::OutgoingFileTransfer> > m_filetransfers;
std::vector<boost::shared_ptr<Swift::OutgoingFileTransfer> > m_filetransfers;
int m_resources;
int m_reconnectCounter;
std::list<Swift::Presence::ref> m_joinedRooms;

View file

@ -20,7 +20,6 @@
#pragma once
#include <boost/signal.hpp>
#include <string>
#include <map>
#include "Swiften/Elements/Message.h"
@ -30,7 +29,6 @@
#include "Swiften/Elements/DiscoInfo.h"
#include "Swiften/Elements/VCard.h"
#include "Swiften/Network/Timer.h"
#include "Swiften/SwiftenCompat.h"
namespace Transport {
@ -145,7 +143,7 @@ class UserManager /*: public Swift::EntityCapsProvider*/ {
void handleSubscription(Swift::Presence::ref presence);
void handleMUCPresence(Swift::Presence::ref presence);
void handleRemoveTimeout(const std::string jid, User *user, bool reconnect);
void handleDiscoInfo(const Swift::JID& jid, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::DiscoInfo> info);
void handleDiscoInfo(const Swift::JID& jid, boost::shared_ptr<Swift::DiscoInfo> info);
void addUser(User *user);
long m_onlineBuddies;

Some files were not shown because too many files have changed in this diff Show more