diff options
Diffstat (limited to 'Swiften/Session/SessionStream.h')
-rw-r--r-- | Swiften/Session/SessionStream.h | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/Swiften/Session/SessionStream.h b/Swiften/Session/SessionStream.h index 17d9a24..6bba237 100644 --- a/Swiften/Session/SessionStream.h +++ b/Swiften/Session/SessionStream.h @@ -5,23 +5,62 @@ #include "Swiften/Elements/ProtocolHeader.h" #include "Swiften/Elements/Element.h" +#include "Swiften/Base/Error.h" +#include "Swiften/TLS/PKCS12Certificate.h" namespace Swift { class SessionStream { public: + class Error : public Swift::Error { + public: + enum Type { + ParseError, + TLSError, + InvalidTLSCertificateError, + ConnectionError + }; + + Error(Type type) : type(type) {} + + Type type; + }; + virtual ~SessionStream(); + virtual bool isAvailable() = 0; + virtual void writeHeader(const ProtocolHeader& header) = 0; + virtual void writeFooter() = 0; virtual void writeElement(boost::shared_ptr<Element>) = 0; virtual bool supportsTLSEncryption() = 0; virtual void addTLSEncryption() = 0; - - virtual void addWhitespacePing() = 0; + virtual void setWhitespacePingEnabled(bool enabled) = 0; virtual void resetXMPPParser() = 0; + void setTLSCertificate(const PKCS12Certificate& cert) { + certificate = cert; + } + + virtual bool hasTLSCertificate() { + return !certificate.isNull(); + } + + boost::signal<void (const ProtocolHeader&)> onStreamStartReceived; boost::signal<void (boost::shared_ptr<Element>)> onElementReceived; + boost::signal<void (boost::shared_ptr<Error>)> onError; + boost::signal<void ()> onTLSEncrypted; + boost::signal<void (const String&)> onDataRead; + boost::signal<void (const String&)> onDataWritten; + + protected: + const PKCS12Certificate& getTLSCertificate() const { + return certificate; + } + + private: + PKCS12Certificate certificate; }; } |