summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-20 18:23:22 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-20 18:23:22 (GMT)
commit059ace39c432a89845e245604af03f5f71e1da84 (patch)
tree0c756410892adac6be4640cec4391c26798459a7 /Swiften/Client/ClientSession.cpp
parentcf8e2aca04c9a4021448f829e5b264dad25b28c8 (diff)
downloadswift-059ace39c432a89845e245604af03f5f71e1da84.zip
swift-059ace39c432a89845e245604af03f5f71e1da84.tar.bz2
Added ClientSessionTest.
Diffstat (limited to 'Swiften/Client/ClientSession.cpp')
-rw-r--r--Swiften/Client/ClientSession.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp
index f7fc073..a95c058 100644
--- a/Swiften/Client/ClientSession.cpp
+++ b/Swiften/Client/ClientSession.cpp
@@ -171,54 +171,55 @@ void ClientSession::handleElement(boost::shared_ptr<Element> element) {
// FIXME Not correct?
state = Initialized;
onInitialized();
}
}
void ClientSession::sendSessionStart() {
state = StartingSession;
stream->writeElement(IQ::createRequest(IQ::Set, JID(), "session-start", boost::shared_ptr<StartSession>(new StartSession())));
}
bool ClientSession::checkState(State state) {
if (state != state) {
finishSession(Error::UnexpectedElementError);
return false;
}
return true;
}
void ClientSession::sendCredentials(const String& password) {
assert(WaitingForCredentials);
state = Authenticating;
stream->writeElement(boost::shared_ptr<Element>(new AuthRequest("PLAIN", PLAINMessage(localJID.getNode(), password).getValue())));
}
void ClientSession::handleTLSEncrypted() {
checkState(WaitingForEncrypt);
state = WaitingForStreamStart;
stream->resetXMPPParser();
sendStreamHeader();
}
void ClientSession::handleStreamError(boost::shared_ptr<Swift::Error> error) {
finishSession(error);
}
void ClientSession::finish() {
if (stream->isAvailable()) {
stream->writeFooter();
}
finishSession(boost::shared_ptr<Error>());
}
void ClientSession::finishSession(Error::Type error) {
finishSession(boost::shared_ptr<Swift::ClientSession::Error>(new Swift::ClientSession::Error(error)));
}
void ClientSession::finishSession(boost::shared_ptr<Swift::Error> error) {
+ state = Finished;
stream->setWhitespacePingEnabled(false);
onFinished(error);
}
}