diff options
Diffstat (limited to 'Swiften/Session/Session.h')
-rw-r--r-- | Swiften/Session/Session.h | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/Swiften/Session/Session.h b/Swiften/Session/Session.h index a6dae80..d01833d 100644 --- a/Swiften/Session/Session.h +++ b/Swiften/Session/Session.h @@ -19,97 +19,97 @@ #include <Swiften/StreamStack/ConnectionLayer.h> namespace Swift { - class ProtocolHeader; - class StreamStack; - class JID; - class Element; - class PayloadParserFactoryCollection; - class PayloadSerializerCollection; - class XMPPLayer; - class XMLParserFactory; - - class SWIFTEN_API Session : public boost::enable_shared_from_this<Session> { - public: - enum SessionError { - ConnectionReadError, - ConnectionWriteError, - XMLError, - AuthenticationFailedError, - NoSupportedAuthMechanismsError, - UnexpectedElementError, - ResourceBindError, - SessionStartError, - TLSError, - ClientCertificateLoadError, - ClientCertificateError - }; - - Session( - boost::shared_ptr<Connection> connection, - PayloadParserFactoryCollection* payloadParserFactories, - PayloadSerializerCollection* payloadSerializers, - XMLParserFactory* xmlParserFactory); - virtual ~Session(); - - void startSession(); - void finishSession(); - - void sendElement(boost::shared_ptr<ToplevelElement>); - - const JID& getLocalJID() const { - return localJID; - } - - const JID& getRemoteJID() const { - return remoteJID; - } - - boost::signal<void (boost::shared_ptr<ToplevelElement>)> onElementReceived; - boost::signal<void (const boost::optional<SessionError>&)> onSessionFinished; - boost::signal<void (const SafeByteArray&)> onDataWritten; - boost::signal<void (const SafeByteArray&)> onDataRead; - - protected: - void setRemoteJID(const JID& j) { - remoteJID = j; - } - - void setLocalJID(const JID& j) { - localJID = j; - } - - void finishSession(const SessionError&); - - virtual void handleSessionStarted() {} - virtual void handleSessionFinished(const boost::optional<SessionError>&) {} - virtual void handleElement(boost::shared_ptr<ToplevelElement>) = 0; - virtual void handleStreamStart(const ProtocolHeader&) = 0; - - void initializeStreamStack(); - - XMPPLayer* getXMPPLayer() const { - return xmppLayer; - } - - StreamStack* getStreamStack() const { - return streamStack; - } - - void setFinished(); - - private: - void handleDisconnected(const boost::optional<Connection::Error>& error); - - private: - JID localJID; - JID remoteJID; - boost::shared_ptr<Connection> connection; - PayloadParserFactoryCollection* payloadParserFactories; - PayloadSerializerCollection* payloadSerializers; - XMLParserFactory* xmlParserFactory; - XMPPLayer* xmppLayer; - ConnectionLayer* connectionLayer; - StreamStack* streamStack; - bool finishing; - }; + class ProtocolHeader; + class StreamStack; + class JID; + class Element; + class PayloadParserFactoryCollection; + class PayloadSerializerCollection; + class XMPPLayer; + class XMLParserFactory; + + class SWIFTEN_API Session : public boost::enable_shared_from_this<Session> { + public: + enum SessionError { + ConnectionReadError, + ConnectionWriteError, + XMLError, + AuthenticationFailedError, + NoSupportedAuthMechanismsError, + UnexpectedElementError, + ResourceBindError, + SessionStartError, + TLSError, + ClientCertificateLoadError, + ClientCertificateError + }; + + Session( + boost::shared_ptr<Connection> connection, + PayloadParserFactoryCollection* payloadParserFactories, + PayloadSerializerCollection* payloadSerializers, + XMLParserFactory* xmlParserFactory); + virtual ~Session(); + + void startSession(); + void finishSession(); + + void sendElement(boost::shared_ptr<ToplevelElement>); + + const JID& getLocalJID() const { + return localJID; + } + + const JID& getRemoteJID() const { + return remoteJID; + } + + boost::signal<void (boost::shared_ptr<ToplevelElement>)> onElementReceived; + boost::signal<void (const boost::optional<SessionError>&)> onSessionFinished; + boost::signal<void (const SafeByteArray&)> onDataWritten; + boost::signal<void (const SafeByteArray&)> onDataRead; + + protected: + void setRemoteJID(const JID& j) { + remoteJID = j; + } + + void setLocalJID(const JID& j) { + localJID = j; + } + + void finishSession(const SessionError&); + + virtual void handleSessionStarted() {} + virtual void handleSessionFinished(const boost::optional<SessionError>&) {} + virtual void handleElement(boost::shared_ptr<ToplevelElement>) = 0; + virtual void handleStreamStart(const ProtocolHeader&) = 0; + + void initializeStreamStack(); + + XMPPLayer* getXMPPLayer() const { + return xmppLayer; + } + + StreamStack* getStreamStack() const { + return streamStack; + } + + void setFinished(); + + private: + void handleDisconnected(const boost::optional<Connection::Error>& error); + + private: + JID localJID; + JID remoteJID; + boost::shared_ptr<Connection> connection; + PayloadParserFactoryCollection* payloadParserFactories; + PayloadSerializerCollection* payloadSerializers; + XMLParserFactory* xmlParserFactory; + XMPPLayer* xmppLayer; + ConnectionLayer* connectionLayer; + StreamStack* streamStack; + bool finishing; + }; } |