summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-30 17:46:24 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-30 17:51:32 (GMT)
commitba333999576d89f3340c271b2a3331d6a3e64ac7 (patch)
tree7f2d0dd20d6d6a302a26c904468a90c22150b481 /Swiften
parent59be74ec6fc7bc495f2a261b8f274b8555aee306 (diff)
downloadswift-ba333999576d89f3340c271b2a3331d6a3e64ac7.zip
swift-ba333999576d89f3340c271b2a3331d6a3e64ac7.tar.bz2
Disconnect client cleanly before quitting.
Resolves: #671, #420
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Client/CoreClient.cpp10
-rw-r--r--Swiften/Client/CoreClient.h7
2 files changed, 12 insertions, 5 deletions
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index 9511dfb..d9b21bc 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -62,6 +62,7 @@ void CoreClient::connect(const JID& jid) {
}
void CoreClient::connect(const String& host) {
+ disconnectRequested_ = false;
assert(!connector_);
connector_ = Connector::create(host, &resolver_, connectionFactory_, timerFactory_);
connector_->onConnectFinished.connect(boost::bind(&CoreClient::handleConnectorFinished, this, _1));
@@ -105,12 +106,7 @@ void CoreClient::disconnect() {
}
else if (connector_) {
connector_->stop();
- assert(!session_);
}
- assert(!session_);
- assert(!sessionStream_);
- assert(!connector_);
- disconnectRequested_ = false;
}
void CoreClient::setCertificate(const String& certificate) {
@@ -214,4 +210,8 @@ void CoreClient::sendPresence(boost::shared_ptr<Presence> presence) {
stanzaChannel_->sendPresence(presence);
}
+bool CoreClient::isActive() const {
+ return session_ || connector_;
+}
+
}
diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h
index e9e81ec..2b7113f 100644
--- a/Swiften/Client/CoreClient.h
+++ b/Swiften/Client/CoreClient.h
@@ -96,6 +96,13 @@ namespace Swift {
}
/**
+ * Checks whether the client is active.
+ *
+ * A client is active when it is connected or connecting to the server.
+ */
+ bool isActive() const;
+
+ /**
* Returns the JID of the client.
* After the session was initialized, this returns the bound JID.
*/