summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/StreamStack/XMPPLayer.h')
-rw-r--r--Swiften/StreamStack/XMPPLayer.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/Swiften/StreamStack/XMPPLayer.h b/Swiften/StreamStack/XMPPLayer.h
new file mode 100644
index 0000000..7974811
--- /dev/null
+++ b/Swiften/StreamStack/XMPPLayer.h
@@ -0,0 +1,55 @@
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+#include <boost/signal.hpp>
+#include <boost/noncopyable.hpp>
+
+#include "Swiften/Base/ByteArray.h"
+#include "Swiften/Elements/Element.h"
+#include "Swiften/Parser/XMPPParserClient.h"
+
+namespace Swift {
+ class ProtocolHeader;
+ class XMPPParser;
+ class PayloadParserFactoryCollection;
+ class XMPPSerializer;
+ class PayloadSerializerCollection;
+
+ class XMPPLayer : public XMPPParserClient, boost::noncopyable {
+ public:
+ XMPPLayer(
+ PayloadParserFactoryCollection* payloadParserFactories,
+ PayloadSerializerCollection* payloadSerializers);
+ ~XMPPLayer();
+
+ void writeHeader(const ProtocolHeader& header);
+ void writeFooter();
+ void writeElement(boost::shared_ptr<Element>);
+ void writeData(const String& data);
+
+ void parseData(ByteArray data);
+ void resetParser();
+
+ public:
+ boost::signal<void (const ProtocolHeader&)> onStreamStart;
+ boost::signal<void (boost::shared_ptr<Element>)> onElement;
+ boost::signal<void (const ByteArray&)> onWriteData;
+ boost::signal<void (const ByteArray&)> onDataRead;
+ boost::signal<void ()> onError;
+
+ private:
+ void handleStreamStart(const ProtocolHeader&);
+ void handleElement(boost::shared_ptr<Element>);
+ void handleStreamEnd();
+
+ void doResetParser();
+
+ private:
+ PayloadParserFactoryCollection* payloadParserFactories_;
+ XMPPParser* xmppParser_;
+ PayloadSerializerCollection* payloadSerializers_;
+ XMPPSerializer* xmppSerializer_;
+ bool resetParserAfterParse_;
+ bool inParser_;
+ };
+}