diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-10-13 16:14:26 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-11-01 11:19:59 (GMT) |
commit | ee7c1b0ea8bd9483add1f8b06d5b6f745f1cfe27 (patch) | |
tree | a3d260f05c65b93f90d837788e8e97db73a0bade /Swiften | |
parent | 0f0cde0cdff42db72df4307ed68dac62e8acb1f3 (diff) | |
download | swift-contrib-ee7c1b0ea8bd9483add1f8b06d5b6f745f1cfe27.zip swift-contrib-ee7c1b0ea8bd9483add1f8b06d5b6f745f1cfe27.tar.bz2 |
Refactored some degenerate stuff out of base Session.
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Client/ClientSession.cpp | 6 | ||||
-rw-r--r-- | Swiften/Client/ClientSession.h | 1 | ||||
-rw-r--r-- | Swiften/LinkLocal/IncomingLinkLocalSession.cpp | 9 | ||||
-rw-r--r-- | Swiften/LinkLocal/IncomingLinkLocalSession.h | 8 | ||||
-rw-r--r-- | Swiften/LinkLocal/OutgoingLinkLocalSession.cpp | 1 | ||||
-rw-r--r-- | Swiften/Server/ServerFromClientSession.cpp | 9 | ||||
-rw-r--r-- | Swiften/Server/ServerFromClientSession.h | 8 | ||||
-rw-r--r-- | Swiften/Session/Session.cpp | 6 | ||||
-rw-r--r-- | Swiften/Session/Session.h | 10 |
9 files changed, 37 insertions, 21 deletions
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index ae98ee6..a0e1289 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -115,7 +115,7 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) { } else { state_ = SessionStarted; - setInitialized(); + onSessionStarted(); } } } @@ -171,7 +171,7 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) { else if (state_ == StartingSession) { if (iq->getType() == IQ::Result) { state_ = SessionStarted; - setInitialized(); + onSessionStarted(); } else if (iq->getType() == IQ::Error) { finishSession(SessionStartError); @@ -187,7 +187,7 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) { else { // FIXME Not correct? state_ = SessionStarted; - setInitialized(); + onSessionStarted(); } } diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h index cb1e098..fead182 100644 --- a/Swiften/Client/ClientSession.h +++ b/Swiften/Client/ClientSession.h @@ -74,6 +74,7 @@ namespace Swift { public: boost::signal<void ()> onNeedCredentials; + boost::signal<void ()> onSessionStarted; private: TLSLayerFactory* tlsLayerFactory_; diff --git a/Swiften/LinkLocal/IncomingLinkLocalSession.cpp b/Swiften/LinkLocal/IncomingLinkLocalSession.cpp index a1fb901..4c3a681 100644 --- a/Swiften/LinkLocal/IncomingLinkLocalSession.cpp +++ b/Swiften/LinkLocal/IncomingLinkLocalSession.cpp @@ -18,7 +18,8 @@ IncomingLinkLocalSession::IncomingLinkLocalSession( boost::shared_ptr<Connection> connection, PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers) : - Session(connection, payloadParserFactories, payloadSerializers) { + Session(connection, payloadParserFactories, payloadSerializers), + initialized(false) { setLocalJID(localJID); } @@ -52,5 +53,11 @@ void IncomingLinkLocalSession::handleElement(boost::shared_ptr<Element> element) onElementReceived(element); } +void IncomingLinkLocalSession::setInitialized() { + initialized = true; + onSessionStarted(); +} + + } diff --git a/Swiften/LinkLocal/IncomingLinkLocalSession.h b/Swiften/LinkLocal/IncomingLinkLocalSession.h index 2f1a45b..e3f0460 100644 --- a/Swiften/LinkLocal/IncomingLinkLocalSession.h +++ b/Swiften/LinkLocal/IncomingLinkLocalSession.h @@ -22,8 +22,16 @@ namespace Swift { PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers); + boost::signal<void ()> onSessionStarted; + private: void handleElement(boost::shared_ptr<Element>); void handleStreamStart(const ProtocolHeader&); + void setInitialized(); + bool isInitialized() const { + return initialized; + } + + bool initialized; }; } diff --git a/Swiften/LinkLocal/OutgoingLinkLocalSession.cpp b/Swiften/LinkLocal/OutgoingLinkLocalSession.cpp index 1c2fefb..7b71f82 100644 --- a/Swiften/LinkLocal/OutgoingLinkLocalSession.cpp +++ b/Swiften/LinkLocal/OutgoingLinkLocalSession.cpp @@ -31,7 +31,6 @@ void OutgoingLinkLocalSession::handleStreamStart(const ProtocolHeader&) { sendElement(stanza); } queuedElements_.clear(); - setInitialized(); } void OutgoingLinkLocalSession::handleElement(boost::shared_ptr<Element> element) { diff --git a/Swiften/Server/ServerFromClientSession.cpp b/Swiften/Server/ServerFromClientSession.cpp index 3efacd7..c974e18 100644 --- a/Swiften/Server/ServerFromClientSession.cpp +++ b/Swiften/Server/ServerFromClientSession.cpp @@ -26,7 +26,8 @@ ServerFromClientSession::ServerFromClientSession( Session(connection, payloadParserFactories, payloadSerializers), id_(id), userRegistry_(userRegistry), - authenticated_(false) { + authenticated_(false), + initialized(false) { } @@ -87,4 +88,10 @@ void ServerFromClientSession::handleStreamStart(const ProtocolHeader& incomingHe getXMPPLayer()->writeElement(features); } +void ServerFromClientSession::setInitialized() { + initialized = true; + onSessionStarted(); +} + + } diff --git a/Swiften/Server/ServerFromClientSession.h b/Swiften/Server/ServerFromClientSession.h index 748f7eb..33826a4 100644 --- a/Swiften/Server/ServerFromClientSession.h +++ b/Swiften/Server/ServerFromClientSession.h @@ -31,14 +31,22 @@ namespace Swift { PayloadSerializerCollection* payloadSerializers, UserRegistry* userRegistry); + boost::signal<void ()> onSessionStarted; + private: void handleElement(boost::shared_ptr<Element>); void handleStreamStart(const ProtocolHeader& header); + void setInitialized(); + bool isInitialized() const { + return initialized; + } + private: String id_; UserRegistry* userRegistry_; bool authenticated_; + bool initialized; String user_; }; } diff --git a/Swiften/Session/Session.cpp b/Swiften/Session/Session.cpp index 6f528c1..64456db 100644 --- a/Swiften/Session/Session.cpp +++ b/Swiften/Session/Session.cpp @@ -15,7 +15,6 @@ Session::Session( payloadParserFactories(payloadParserFactories), payloadSerializers(payloadSerializers), streamStack(0), - initialized(false), finishing(false) { } @@ -80,9 +79,4 @@ void Session::handleDisconnected(const boost::optional<Connection::Error>& conne } } -void Session::setInitialized() { - initialized = true; - onSessionStarted(); -} - } diff --git a/Swiften/Session/Session.h b/Swiften/Session/Session.h index 26d10c1..d63254a 100644 --- a/Swiften/Session/Session.h +++ b/Swiften/Session/Session.h @@ -44,6 +44,7 @@ namespace Swift { void startSession(); void finishSession(); + void sendElement(boost::shared_ptr<Element>); const JID& getLocalJID() const { @@ -55,19 +56,16 @@ namespace Swift { } boost::signal<void (boost::shared_ptr<Element>)> onElementReceived; - boost::signal<void ()> onSessionStarted; boost::signal<void (const boost::optional<SessionError>&)> onSessionFinished; boost::signal<void (const ByteArray&)> onDataWritten; boost::signal<void (const ByteArray&)> onDataRead; protected: void setRemoteJID(const JID& j) { - assert(!isInitialized()); remoteJID = j; } void setLocalJID(const JID& j) { - assert(!isInitialized()); localJID = j; } @@ -88,11 +86,6 @@ namespace Swift { return streamStack; } - void setInitialized(); - bool isInitialized() const { - return initialized; - } - void setFinished(); private: @@ -107,7 +100,6 @@ namespace Swift { boost::shared_ptr<XMPPLayer> xmppLayer; boost::shared_ptr<ConnectionLayer> connectionLayer; StreamStack* streamStack; - bool initialized; bool finishing; }; } |