summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-08 16:12:48 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-08 18:32:15 (GMT)
commitf1d74218cb432513c376b46aa115acb3e107ed3a (patch)
tree24df6a3233f1fd3c2c2592637cfcfd1846040dee /Swiften/Session/BasicSessionStream.cpp
parentb6003bea740e8898127ec135e230eed421924370 (diff)
downloadswift-f1d74218cb432513c376b46aa115acb3e107ed3a.zip
swift-f1d74218cb432513c376b46aa115acb3e107ed3a.tar.bz2
Added Error class.
Diffstat (limited to 'Swiften/Session/BasicSessionStream.cpp')
-rw-r--r--Swiften/Session/BasicSessionStream.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp
index 46d4e16..73eaf5b 100644
--- a/Swiften/Session/BasicSessionStream.cpp
+++ b/Swiften/Session/BasicSessionStream.cpp
@@ -13,13 +13,16 @@
namespace Swift {
-BasicSessionStream::BasicSessionStream(boost::shared_ptr<Connection> connection, PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers, TLSLayerFactory* tlsLayerFactory) : tlsLayerFactory(tlsLayerFactory) {
+BasicSessionStream::BasicSessionStream(boost::shared_ptr<Connection> connection, PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers, TLSLayerFactory* tlsLayerFactory) : connection(connection), payloadParserFactories(payloadParserFactories), payloadSerializers(payloadSerializers), tlsLayerFactory(tlsLayerFactory) {
+}
+
+void BasicSessionStream::initialize() {
xmppLayer = boost::shared_ptr<XMPPLayer>(
new XMPPLayer(payloadParserFactories, payloadSerializers));
- xmppLayer->onStreamStart.connect(boost::ref(onStreamStartReceived));
- xmppLayer->onElement.connect(boost::ref(onElementReceived));
+ xmppLayer->onStreamStart.connect(boost::bind(&BasicSessionStream::handleStreamStartReceived, shared_from_this(), _1));
+ xmppLayer->onElement.connect(boost::bind(&BasicSessionStream::handleElementReceived, shared_from_this(), _1));
xmppLayer->onError.connect(boost::bind(
- &BasicSessionStream::handleXMPPError, this));
+ &BasicSessionStream::handleXMPPError, shared_from_this()));
connectionLayer = boost::shared_ptr<ConnectionLayer>(
new ConnectionLayer(connection));
@@ -47,7 +50,7 @@ void BasicSessionStream::addTLSEncryption() {
tlsLayer = tlsLayerFactory->createTLSLayer();
streamStack->addLayer(tlsLayer);
// TODO: Add tls layer certificate if needed
- tlsLayer->onError.connect(boost::bind(&BasicSessionStream::handleTLSError, this));
+ tlsLayer->onError.connect(boost::bind(&BasicSessionStream::handleTLSError, shared_from_this()));
tlsLayer->connect();
}
@@ -61,12 +64,20 @@ void BasicSessionStream::resetXMPPParser() {
xmppLayer->resetParser();
}
+void BasicSessionStream::handleStreamStartReceived(const ProtocolHeader& header) {
+ onStreamStartReceived(header);
+}
+
+void BasicSessionStream::handleElementReceived(boost::shared_ptr<Element> element) {
+ onElementReceived(element);
+}
+
void BasicSessionStream::handleXMPPError() {
- // TODO
+ onError(boost::shared_ptr<Error>(new Error()));
}
void BasicSessionStream::handleTLSError() {
- // TODO
+ onError(boost::shared_ptr<Error>(new Error()));
}
};