summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Session')
-rw-r--r--Swiften/Session/BasicSessionStream.cpp26
-rw-r--r--Swiften/Session/BasicSessionStream.h11
-rw-r--r--Swiften/Session/Session.cpp6
-rw-r--r--Swiften/Session/Session.h16
-rw-r--r--Swiften/Session/SessionStream.cpp2
-rw-r--r--Swiften/Session/SessionStream.h19
-rw-r--r--Swiften/Session/SessionTracer.cpp28
-rw-r--r--Swiften/Session/SessionTracer.h21
8 files changed, 74 insertions, 55 deletions
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp
index c783e01..d08be4f 100644
--- a/Swiften/Session/BasicSessionStream.cpp
+++ b/Swiften/Session/BasicSessionStream.cpp
@@ -4,18 +4,18 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/Session/BasicSessionStream.h"
+#include <Swiften/Session/BasicSessionStream.h>
#include <boost/bind.hpp>
-#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/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>
namespace Swift {
@@ -192,12 +192,12 @@ void BasicSessionStream::handleConnectionFinished(const boost::optional<Connecti
}
}
-void BasicSessionStream::handleDataRead(const ByteArray& data) {
- onDataRead(data.toString());
+void BasicSessionStream::handleDataRead(const SafeByteArray& data) {
+ onDataRead(data);
}
-void BasicSessionStream::handleDataWritten(const ByteArray& data) {
- onDataWritten(data.toString());
+void BasicSessionStream::handleDataWritten(const SafeByteArray& data) {
+ onDataWritten(data);
}
};
diff --git a/Swiften/Session/BasicSessionStream.h b/Swiften/Session/BasicSessionStream.h
index b3f7421..2a1ed8a 100644
--- a/Swiften/Session/BasicSessionStream.h
+++ b/Swiften/Session/BasicSessionStream.h
@@ -8,9 +8,10 @@
#include <boost/shared_ptr.hpp>
-#include "Swiften/Network/Connection.h"
-#include "Swiften/Session/SessionStream.h"
-#include "Swiften/Elements/StreamType.h"
+#include <Swiften/Base/SafeByteArray.h>
+#include <Swiften/Network/Connection.h>
+#include <Swiften/Session/SessionStream.h>
+#include <Swiften/Elements/StreamType.h>
namespace Swift {
class TLSContextFactory;
@@ -64,8 +65,8 @@ namespace Swift {
void handleTLSError();
void handleStreamStartReceived(const ProtocolHeader&);
void handleElementReceived(boost::shared_ptr<Element>);
- void handleDataRead(const ByteArray& data);
- void handleDataWritten(const ByteArray& data);
+ void handleDataRead(const SafeByteArray& data);
+ void handleDataWritten(const SafeByteArray& data);
private:
bool available;
diff --git a/Swiften/Session/Session.cpp b/Swiften/Session/Session.cpp
index 39fab14..1d78640 100644
--- a/Swiften/Session/Session.cpp
+++ b/Swiften/Session/Session.cpp
@@ -4,12 +4,12 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/Session/Session.h"
+#include <Swiften/Session/Session.h>
#include <boost/bind.hpp>
-#include "Swiften/StreamStack/XMPPLayer.h"
-#include "Swiften/StreamStack/StreamStack.h"
+#include <Swiften/StreamStack/XMPPLayer.h>
+#include <Swiften/StreamStack/StreamStack.h>
namespace Swift {
diff --git a/Swiften/Session/Session.h b/Swiften/Session/Session.h
index f8c8f0a..9e954c7 100644
--- a/Swiften/Session/Session.h
+++ b/Swiften/Session/Session.h
@@ -7,21 +7,21 @@
#pragma once
#include <boost/shared_ptr.hpp>
-#include "Swiften/Base/boost_bsignals.h"
+#include <Swiften/Base/boost_bsignals.h>
#include <boost/optional.hpp>
#include <boost/enable_shared_from_this.hpp>
-#include "Swiften/JID/JID.h"
-#include "Swiften/Elements/Element.h"
-#include "Swiften/Network/Connection.h"
-#include "Swiften/StreamStack/ConnectionLayer.h"
+#include <Swiften/JID/JID.h>
+#include <Swiften/Elements/Element.h>
+#include <Swiften/Network/Connection.h>
+#include <Swiften/StreamStack/ConnectionLayer.h>
+#include <Swiften/Base/SafeByteArray.h>
namespace Swift {
class ProtocolHeader;
class StreamStack;
class JID;
class Element;
- class ByteArray;
class PayloadParserFactoryCollection;
class PayloadSerializerCollection;
class XMPPLayer;
@@ -63,8 +63,8 @@ namespace Swift {
boost::signal<void (boost::shared_ptr<Element>)> onElementReceived;
boost::signal<void (const boost::optional<SessionError>&)> onSessionFinished;
- boost::signal<void (const ByteArray&)> onDataWritten;
- boost::signal<void (const ByteArray&)> onDataRead;
+ boost::signal<void (const SafeByteArray&)> onDataWritten;
+ boost::signal<void (const SafeByteArray&)> onDataRead;
protected:
void setRemoteJID(const JID& j) {
diff --git a/Swiften/Session/SessionStream.cpp b/Swiften/Session/SessionStream.cpp
index 5bca0aa..0d73b63 100644
--- a/Swiften/Session/SessionStream.cpp
+++ b/Swiften/Session/SessionStream.cpp
@@ -4,7 +4,7 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/Session/SessionStream.h"
+#include <Swiften/Session/SessionStream.h>
namespace Swift {
diff --git a/Swiften/Session/SessionStream.h b/Swiften/Session/SessionStream.h
index 2753878..e6b9469 100644
--- a/Swiften/Session/SessionStream.h
+++ b/Swiften/Session/SessionStream.h
@@ -6,16 +6,17 @@
#pragma once
-#include "Swiften/Base/boost_bsignals.h"
+#include <Swiften/Base/boost_bsignals.h>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
-#include "Swiften/Elements/ProtocolHeader.h"
-#include "Swiften/Elements/Element.h"
-#include "Swiften/Base/Error.h"
-#include "Swiften/TLS/PKCS12Certificate.h"
-#include "Swiften/TLS/Certificate.h"
-#include "Swiften/TLS/CertificateVerificationError.h"
+#include <Swiften/Elements/ProtocolHeader.h>
+#include <Swiften/Elements/Element.h>
+#include <Swiften/Base/Error.h>
+#include <Swiften/Base/SafeByteArray.h>
+#include <Swiften/TLS/PKCS12Certificate.h>
+#include <Swiften/TLS/Certificate.h>
+#include <Swiften/TLS/CertificateVerificationError.h>
namespace Swift {
class SessionStream {
@@ -71,8 +72,8 @@ namespace Swift {
boost::signal<void (boost::shared_ptr<Element>)> onElementReceived;
boost::signal<void (boost::shared_ptr<Error>)> onClosed;
boost::signal<void ()> onTLSEncrypted;
- boost::signal<void (const std::string&)> onDataRead;
- boost::signal<void (const std::string&)> onDataWritten;
+ boost::signal<void (const SafeByteArray&)> onDataRead;
+ boost::signal<void (const SafeByteArray&)> onDataWritten;
protected:
const PKCS12Certificate& getTLSCertificate() const {
diff --git a/Swiften/Session/SessionTracer.cpp b/Swiften/Session/SessionTracer.cpp
new file mode 100644
index 0000000..e0a39bf
--- /dev/null
+++ b/Swiften/Session/SessionTracer.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swiften/Session/SessionTracer.h>
+
+#include <iostream>
+#include <boost/bind.hpp>
+
+namespace Swift {
+
+SessionTracer::SessionTracer(boost::shared_ptr<Session> session) : session(session) {
+ session->onDataRead.connect(boost::bind(&SessionTracer::printData, this, '<', _1));
+ session->onDataWritten.connect(boost::bind(&SessionTracer::printData, this, '>', _1));
+}
+
+void SessionTracer::printData(char direction, const SafeByteArray& data) {
+ std::cerr << direction << direction << " " << session->getLocalJID() << " ";
+ for (unsigned int i = 0; i < 72 - session->getLocalJID().toString().size() - session->getRemoteJID().toString().size(); ++i) {
+ std::cerr << direction;
+ }
+ std::cerr << " " << session->getRemoteJID()<< " " << direction << direction << std::endl;
+ std::cerr << byteArrayToString(ByteArray(data.begin(), data.end())) << std::endl;
+}
+
+}
diff --git a/Swiften/Session/SessionTracer.h b/Swiften/Session/SessionTracer.h
index cce45eb..72c93b4 100644
--- a/Swiften/Session/SessionTracer.h
+++ b/Swiften/Session/SessionTracer.h
@@ -6,29 +6,18 @@
#pragma once
-#include <iostream>
-
-#include "Swiften/Session/Session.h"
#include <string>
-#include "Swiften/Base/ByteArray.h"
+
+#include <Swiften/Session/Session.h>
+#include <Swiften/Base/SafeByteArray.h>
namespace Swift {
class SessionTracer {
public:
- SessionTracer(boost::shared_ptr<Session> session) : session(session) {
- session->onDataRead.connect(boost::bind(&SessionTracer::printData, this, '<', _1));
- session->onDataWritten.connect(boost::bind(&SessionTracer::printData, this, '>', _1));
- }
+ SessionTracer(boost::shared_ptr<Session> session);
private:
- void printData(char direction, const ByteArray& data) {
- std::cerr << direction << direction << " " << session->getLocalJID() << " ";
- for (unsigned int i = 0; i < 72 - session->getLocalJID().toString().size() - session->getRemoteJID().toString().size(); ++i) {
- std::cerr << direction;
- }
- std::cerr << " " << session->getRemoteJID()<< " " << direction << direction << std::endl;
- std::cerr << data.toString() << std::endl;
- }
+ void printData(char direction, const SafeByteArray& data);
boost::shared_ptr<Session> session;
};