diff options
| author | Remko Tronçon <git@el-tramo.be> | 2009-11-09 20:34:44 (GMT) |
|---|---|---|
| committer | Remko Tronçon <git@el-tramo.be> | 2009-11-09 22:12:10 (GMT) |
| commit | c682941cd230ad8caed3f3d457de3dc0cd7172d4 (patch) | |
| tree | e4d4382a8627409d81bb7c79a62f1bc55f45b410 /Swiften/Client/Client.cpp | |
| parent | f1d74218cb432513c376b46aa115acb3e107ed3a (diff) | |
| download | swift-c682941cd230ad8caed3f3d457de3dc0cd7172d4.zip swift-c682941cd230ad8caed3f3d457de3dc0cd7172d4.tar.bz2 | |
Refactoring Client.
Diffstat (limited to 'Swiften/Client/Client.cpp')
| -rw-r--r-- | Swiften/Client/Client.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp index b3bea0d..adda6af 100644 --- a/Swiften/Client/Client.cpp +++ b/Swiften/Client/Client.cpp @@ -47,31 +47,32 @@ void Client::handleConnectionConnectFinished(bool error) { onError(ClientError::ConnectionError); } else { assert(!sessionStream_); sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(connection_, &payloadParserFactories_, &payloadSerializers_, tlsLayerFactory_)); sessionStream_->initialize(); - - session_ = boost::shared_ptr<ClientSession>(new ClientSession(jid_, connection_, tlsLayerFactory_, &payloadParserFactories_, &payloadSerializers_)); if (!certificate_.isEmpty()) { - session_->setCertificate(PKCS12Certificate(certificate_, password_)); + sessionStream_->setTLSCertificate(PKCS12Certificate(certificate_, password_)); } - session_->onSessionStarted.connect(boost::bind(boost::ref(onConnected))); - session_->onSessionFinished.connect(boost::bind(&Client::handleSessionFinished, this, _1)); - session_->onNeedCredentials.connect(boost::bind(&Client::handleNeedCredentials, this)); - session_->onDataRead.connect(boost::bind(&Client::handleDataRead, this, _1)); - session_->onDataWritten.connect(boost::bind(&Client::handleDataWritten, this, _1)); - session_->onElementReceived.connect(boost::bind(&Client::handleElement, this, _1)); - session_->startSession(); + //sessionStream_->onDataRead.connect(boost::bind(&Client::handleDataRead, this, _1)); + //sessionStream_->onDataWritten.connect(boost::bind(&Client::handleDataWritten, this, _1)); + + session_ = boost::shared_ptr<ClientSession>(new ClientSession(jid_, sessionStream_)); + session_->onInitialized.connect(boost::bind(boost::ref(onConnected))); + session_->onFinished.connect(boost::bind(&Client::handleSessionFinished, shared_from_this(), _1)); + session_->onNeedCredentials.connect(boost::bind(&Client::handleNeedCredentials, shared_from_this())); + session_->onElementReceived.connect(boost::bind(&Client::handleElement, shared_from_this(), _1)); + session_->start(); } } void Client::disconnect() { - if (session_) { - session_->finishSession(); - } + // TODO + //if (session_) { + // session_->finishSession(); + //} } void Client::send(boost::shared_ptr<Stanza> stanza) { session_->sendElement(stanza); } @@ -112,15 +113,16 @@ void Client::handleElement(boost::shared_ptr<Element> element) { } void Client::setCertificate(const String& certificate) { certificate_ = certificate; } -void Client::handleSessionFinished(const boost::optional<Session::SessionError>& error) { +void Client::handleSessionFinished(boost::shared_ptr<Error> error) { if (error) { ClientError clientError; + /* switch (*error) { case Session::ConnectionReadError: clientError = ClientError(ClientError::ConnectionReadError); break; case Session::ConnectionWriteError: clientError = ClientError(ClientError::ConnectionWriteError); @@ -150,12 +152,13 @@ void Client::handleSessionFinished(const boost::optional<Session::SessionError>& clientError = ClientError(ClientError::ClientCertificateLoadError); break; case Session::ClientCertificateError: clientError = ClientError(ClientError::ClientCertificateError); break; } + */ onError(clientError); } } void Client::handleNeedCredentials() { session_->sendCredentials(password_); |
Swift