diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-09-05 11:29:34 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-09-05 12:45:52 (GMT) |
commit | c9ab4b6c41eef3ccfe6627f62e7bc085c6743a41 (patch) | |
tree | d29d63b3100061e4ef54ce3310eb7658996a8a3e /Swiften/Client | |
parent | 0630c01cf274a9de6b67856b8c00b1503b39353e (diff) | |
download | swift-contrib-c9ab4b6c41eef3ccfe6627f62e7bc085c6743a41.zip swift-contrib-c9ab4b6c41eef3ccfe6627f62e7bc085c6743a41.tar.bz2 |
Clear VCardUpdateManager's cache upon login.
Resolves: #554
Diffstat (limited to 'Swiften/Client')
-rw-r--r-- | Swiften/Client/Client.cpp | 10 | ||||
-rw-r--r-- | Swiften/Client/Client.h | 1 | ||||
-rw-r--r-- | Swiften/Client/DummyStanzaChannel.h | 10 | ||||
-rw-r--r-- | Swiften/Client/StanzaChannel.h | 1 |
4 files changed, 18 insertions, 4 deletions
diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp index 2406b0f..bf651cc 100644 --- a/Swiften/Client/Client.cpp +++ b/Swiften/Client/Client.cpp @@ -37,7 +37,7 @@ Client::~Client() { } bool Client::isAvailable() { - return session_; + return session_ && session_->getState() == ClientSession::Initialized; } void Client::connect() { @@ -80,7 +80,7 @@ void Client::handleConnectorFinished(boost::shared_ptr<Connection> connection, C sessionStream_->initialize(); session_ = ClientSession::create(jid_, sessionStream_); - session_->onInitialized.connect(boost::bind(boost::ref(onConnected))); + session_->onInitialized.connect(boost::bind(&Client::handleSessionInitialized, this)); session_->onStanzaAcked.connect(boost::bind(&Client::handleStanzaAcked, this, _1)); session_->onFinished.connect(boost::bind(&Client::handleSessionFinished, this, _1)); session_->onNeedCredentials.connect(boost::bind(&Client::handleNeedCredentials, this)); @@ -162,6 +162,7 @@ void Client::setCertificate(const String& certificate) { void Client::handleSessionFinished(boost::shared_ptr<Error> error) { session_.reset(); closeConnection(); + onAvailableChanged(false); if (error) { ClientError clientError; if (boost::shared_ptr<ClientSession::Error> actualError = boost::dynamic_pointer_cast<ClientSession::Error>(error)) { @@ -242,4 +243,9 @@ void Client::handleStanzaAcked(boost::shared_ptr<Stanza> stanza) { onStanzaAcked(stanza); } +void Client::handleSessionInitialized() { + onConnected(); + onAvailableChanged(true); +} + } diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h index 57228ef..1023108 100644 --- a/Swiften/Client/Client.h +++ b/Swiften/Client/Client.h @@ -58,6 +58,7 @@ namespace Swift { private: void handleConnectorFinished(boost::shared_ptr<Connection>, Connector::ref); + void handleSessionInitialized(); void send(boost::shared_ptr<Stanza>); virtual String getNewIQID(); void handleStanza(boost::shared_ptr<Stanza>); diff --git a/Swiften/Client/DummyStanzaChannel.h b/Swiften/Client/DummyStanzaChannel.h index d43d68a..05066a8 100644 --- a/Swiften/Client/DummyStanzaChannel.h +++ b/Swiften/Client/DummyStanzaChannel.h @@ -13,12 +13,17 @@ namespace Swift { class DummyStanzaChannel : public StanzaChannel { public: - DummyStanzaChannel() {} + DummyStanzaChannel() : available_(true) {} virtual void sendStanza(boost::shared_ptr<Stanza> stanza) { sentStanzas.push_back(stanza); } + void setAvailable(bool available) { + available_ = available; + onAvailableChanged(available); + } + virtual void sendIQ(boost::shared_ptr<IQ> iq) { sentStanzas.push_back(iq); } @@ -36,7 +41,7 @@ namespace Swift { } virtual bool isAvailable() { - return true; + return available_; } virtual bool getStreamManagementEnabled() const { @@ -49,5 +54,6 @@ namespace Swift { } std::vector<boost::shared_ptr<Stanza> > sentStanzas; + bool available_; }; } diff --git a/Swiften/Client/StanzaChannel.h b/Swiften/Client/StanzaChannel.h index 09a6db3..f7bb26a 100644 --- a/Swiften/Client/StanzaChannel.h +++ b/Swiften/Client/StanzaChannel.h @@ -21,6 +21,7 @@ namespace Swift { virtual bool isAvailable() = 0; virtual bool getStreamManagementEnabled() const = 0; + boost::signal<void (bool /* isAvailable */)> onAvailableChanged; boost::signal<void (boost::shared_ptr<Message>)> onMessageReceived; boost::signal<void (boost::shared_ptr<Presence>) > onPresenceReceived; boost::signal<void (boost::shared_ptr<Stanza>)> onStanzaAcked; |