summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-12-13 17:09:18 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-12-13 17:09:18 (GMT)
commit169e5fa001c817b170da6f991edfa994cf2d7f45 (patch)
treeba5004e8ded97ddcc9f518fbe8c99db97637f6d2
parent902e2ee8e61acb18d2819e8a59a28921f85bbd77 (diff)
downloadswift-contrib-169e5fa001c817b170da6f991edfa994cf2d7f45.zip
swift-contrib-169e5fa001c817b170da6f991edfa994cf2d7f45.tar.bz2
Fix use of int randoms for populating long
-rw-r--r--Swiften/Network/HTTPConnectProxiedConnection.cpp1
-rw-r--r--Swiften/Session/BOSHSessionStream.cpp4
2 files changed, 3 insertions, 2 deletions
diff --git a/Swiften/Network/HTTPConnectProxiedConnection.cpp b/Swiften/Network/HTTPConnectProxiedConnection.cpp
index edbdd82..9ef63f0 100644
--- a/Swiften/Network/HTTPConnectProxiedConnection.cpp
+++ b/Swiften/Network/HTTPConnectProxiedConnection.cpp
@@ -2,70 +2,71 @@
* Copyright (c) 2010-2011 Thilo Cestonaro
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
* Copyright (c) 2011 Kevin Smith
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Network/HTTPConnectProxiedConnection.h>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <boost/lexical_cast.hpp>
#include <Swiften/Base/Algorithm.h>
#include <Swiften/Base/Log.h>
#include <Swiften/Base/String.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/Network/HostAddressPort.h>
#include <Swiften/Network/ConnectionFactory.h>
#include <Swiften/StringCodecs/Base64.h>
using namespace Swift;
HTTPConnectProxiedConnection::HTTPConnectProxiedConnection(ConnectionFactory* connectionFactory, HostAddressPort proxy, const SafeString& authID, const SafeString& authPassword) : connectionFactory_(connectionFactory), proxy_(proxy), server_(HostAddressPort(HostAddress("0.0.0.0"), 0)), authID_(authID), authPassword_(authPassword) {
connected_ = false;
}
HTTPConnectProxiedConnection::~HTTPConnectProxiedConnection() {
if (connection_) {
+ connection_->onConnectFinished.disconnect(boost::bind(&HTTPConnectProxiedConnection::handleConnectionConnectFinished, shared_from_this(), _1));
connection_->onDataRead.disconnect(boost::bind(&HTTPConnectProxiedConnection::handleDataRead, shared_from_this(), _1));
connection_->onDisconnected.disconnect(boost::bind(&HTTPConnectProxiedConnection::handleDisconnected, shared_from_this(), _1));
}
if (connected_) {
std::cerr << "Warning: Connection was still established." << std::endl;
}
}
void HTTPConnectProxiedConnection::connect(const HostAddressPort& server) {
server_ = server;
connection_ = connectionFactory_->createConnection();
connection_->onConnectFinished.connect(boost::bind(&HTTPConnectProxiedConnection::handleConnectionConnectFinished, shared_from_this(), _1));
connection_->onDataRead.connect(boost::bind(&HTTPConnectProxiedConnection::handleDataRead, shared_from_this(), _1));
connection_->onDisconnected.connect(boost::bind(&HTTPConnectProxiedConnection::handleDisconnected, shared_from_this(), _1));
connection_->connect(proxy_);
}
void HTTPConnectProxiedConnection::listen() {
assert(false);
connection_->listen();
}
void HTTPConnectProxiedConnection::disconnect() {
connected_ = false;
connection_->disconnect();
}
void HTTPConnectProxiedConnection::handleDisconnected(const boost::optional<Error>& error) {
onDisconnected(error);
}
void HTTPConnectProxiedConnection::write(const SafeByteArray& data) {
connection_->write(data);
}
diff --git a/Swiften/Session/BOSHSessionStream.cpp b/Swiften/Session/BOSHSessionStream.cpp
index 95390f4..73bbfd6 100644
--- a/Swiften/Session/BOSHSessionStream.cpp
+++ b/Swiften/Session/BOSHSessionStream.cpp
@@ -16,73 +16,73 @@
#include <Swiften/Elements/StreamType.h>
#include <Swiften/StreamStack/XMPPLayer.h>
#include <Swiften/StreamStack/StreamStack.h>
#include <Swiften/StreamStack/ConnectionLayer.h>
#include <Swiften/StreamStack/WhitespacePingLayer.h>
#include <Swiften/StreamStack/CompressionLayer.h>
#include <Swiften/StreamStack/TLSLayer.h>
#include <Swiften/TLS/TLSContextFactory.h>
#include <Swiften/TLS/TLSContext.h>
#include <Swiften/EventLoop/EventLoop.h>
namespace Swift {
BOSHSessionStream::BOSHSessionStream(
boost::shared_ptr<BOSHConnectionFactory> connectionFactory, /*FIXME: probably rip out*/
PayloadParserFactoryCollection* payloadParserFactories,
PayloadSerializerCollection* payloadSerializers,
TLSContextFactory* tlsContextFactory,
TimerFactory* timerFactory,
XMLParserFactory* xmlParserFactory,
EventLoop* eventLoop,
const std::string& to,
const URL& boshHTTPConnectProxyURL,
const SafeString& boshHTTPConnectProxyAuthID,
const SafeString& boshHTTPConnectProxyAuthPassword) :
available(false),
payloadParserFactories(payloadParserFactories),
payloadSerializers(payloadSerializers),
tlsContextFactory(tlsContextFactory),
timerFactory(timerFactory),
xmlParserFactory(xmlParserFactory),
eventLoop(eventLoop),
firstHeader(true) {
boost::mt19937 random;
- boost::uniform_int<> dist(0, LONG_MAX);
+ boost::uniform_int<long> dist(0, LONG_MAX);
random.seed(time(NULL));
- boost::variate_generator<boost::mt19937&, boost::uniform_int<> > randomRID(random, dist);
+ boost::variate_generator<boost::mt19937&, boost::uniform_int<long> > randomRID(random, dist);
long initialRID = randomRID();
connectionPool = new BOSHConnectionPool(connectionFactory, to, initialRID, boshHTTPConnectProxyURL, boshHTTPConnectProxyAuthID, boshHTTPConnectProxyAuthPassword);
connectionPool->onSessionTerminated.connect(boost::bind(&BOSHSessionStream::handlePoolSessionTerminated, this, _1));
connectionPool->onSessionStarted.connect(boost::bind(&BOSHSessionStream::handlePoolSessionStarted, this));
connectionPool->onXMPPDataRead.connect(boost::bind(&BOSHSessionStream::handlePoolXMPPDataRead, this, _1));
connectionPool->onBOSHDataRead.connect(boost::bind(&BOSHSessionStream::handlePoolBOSHDataRead, this, _1));
connectionPool->onBOSHDataWritten.connect(boost::bind(&BOSHSessionStream::handlePoolBOSHDataWritten, this, _1));
xmppLayer = new XMPPLayer(payloadParserFactories, payloadSerializers, xmlParserFactory, ClientStreamType);
xmppLayer->onStreamStart.connect(boost::bind(&BOSHSessionStream::handleStreamStartReceived, this, _1));
xmppLayer->onElement.connect(boost::bind(&BOSHSessionStream::handleElementReceived, this, _1));
xmppLayer->onError.connect(boost::bind(&BOSHSessionStream::handleXMPPError, this));
xmppLayer->onWriteData.connect(boost::bind(&BOSHSessionStream::handleXMPPLayerDataWritten, this, _1));
available = true;
}
BOSHSessionStream::~BOSHSessionStream() {
close();
connectionPool->onSessionTerminated.disconnect(boost::bind(&BOSHSessionStream::handlePoolSessionTerminated, this, _1));
connectionPool->onSessionStarted.disconnect(boost::bind(&BOSHSessionStream::handlePoolSessionStarted, this));
connectionPool->onXMPPDataRead.disconnect(boost::bind(&BOSHSessionStream::handlePoolXMPPDataRead, this, _1));
connectionPool->onBOSHDataRead.disconnect(boost::bind(&BOSHSessionStream::handlePoolBOSHDataRead, this, _1));
connectionPool->onBOSHDataWritten.disconnect(boost::bind(&BOSHSessionStream::handlePoolBOSHDataWritten, this, _1));
delete connectionPool;
connectionPool = NULL;
xmppLayer->onStreamStart.disconnect(boost::bind(&BOSHSessionStream::handleStreamStartReceived, this, _1));
xmppLayer->onElement.disconnect(boost::bind(&BOSHSessionStream::handleElementReceived, this, _1));
xmppLayer->onError.disconnect(boost::bind(&BOSHSessionStream::handleXMPPError, this));
xmppLayer->onWriteData.disconnect(boost::bind(&BOSHSessionStream::handleXMPPLayerDataWritten, this, _1));
delete xmppLayer;
xmppLayer = NULL;
}