diff options
Diffstat (limited to 'Swiften/Disco')
-rw-r--r-- | Swiften/Disco/CapsManager.cpp | 5 | ||||
-rw-r--r-- | Swiften/Disco/CapsManager.h | 6 | ||||
-rw-r--r-- | Swiften/Disco/UnitTest/CapsManagerTest.cpp | 1 |
3 files changed, 11 insertions, 1 deletions
diff --git a/Swiften/Disco/CapsManager.cpp b/Swiften/Disco/CapsManager.cpp index 185f8e6..a5023d3 100644 --- a/Swiften/Disco/CapsManager.cpp +++ b/Swiften/Disco/CapsManager.cpp @@ -16,7 +16,7 @@ namespace Swift { -CapsManager::CapsManager(CapsStorage* capsStorage, StanzaChannel* stanzaChannel, IQRouter* iqRouter) : iqRouter(iqRouter), capsStorage(capsStorage) { +CapsManager::CapsManager(CapsStorage* capsStorage, StanzaChannel* stanzaChannel, IQRouter* iqRouter) : iqRouter(iqRouter), capsStorage(capsStorage), warnOnInvalidHash(true) { stanzaChannel->onPresenceReceived.connect(boost::bind(&CapsManager::handlePresenceReceived, this, _1)); stanzaChannel->onAvailableChanged.connect(boost::bind(&CapsManager::handleStanzaChannelAvailableChanged, this, _1)); } @@ -51,6 +51,9 @@ void CapsManager::handleStanzaChannelAvailableChanged(bool available) { void CapsManager::handleDiscoInfoReceived(const JID& from, const String& hash, DiscoInfo::ref discoInfo, const boost::optional<ErrorPayload>& error) { requestedDiscoInfos.erase(hash); if (error || CapsInfoGenerator("").generateCapsInfo(*discoInfo.get()).getVersion() != hash) { + if (warnOnInvalidHash && !error) { + std::cerr << "Warning: Caps from " << from.toString() << " do not verify" << std::endl; + } failingCaps.insert(std::make_pair(from, hash)); std::map<String, std::set< std::pair<JID, String> > >::iterator i = fallbacks.find(hash); if (i != fallbacks.end() && !i->second.empty()) { diff --git a/Swiften/Disco/CapsManager.h b/Swiften/Disco/CapsManager.h index 3188a07..e2a8901 100644 --- a/Swiften/Disco/CapsManager.h +++ b/Swiften/Disco/CapsManager.h @@ -26,6 +26,11 @@ namespace Swift { DiscoInfo::ref getCaps(const String&) const; + // Mainly for testing purposes + void setWarnOnInvalidHash(bool b) { + warnOnInvalidHash = b; + } + private: void handlePresenceReceived(boost::shared_ptr<Presence>); void handleStanzaChannelAvailableChanged(bool); @@ -35,6 +40,7 @@ namespace Swift { private: IQRouter* iqRouter; CapsStorage* capsStorage; + bool warnOnInvalidHash; std::set<String> requestedDiscoInfos; std::set< std::pair<JID, String> > failingCaps; std::map<String, std::set< std::pair<JID, String> > > fallbacks; diff --git a/Swiften/Disco/UnitTest/CapsManagerTest.cpp b/Swiften/Disco/UnitTest/CapsManagerTest.cpp index 7925ae7..d5b9896 100644 --- a/Swiften/Disco/UnitTest/CapsManagerTest.cpp +++ b/Swiften/Disco/UnitTest/CapsManagerTest.cpp @@ -234,6 +234,7 @@ class CapsManagerTest : public CppUnit::TestFixture { private: std::auto_ptr<CapsManager> createManager() { std::auto_ptr<CapsManager> manager(new CapsManager(storage, stanzaChannel, iqRouter)); + manager->setWarnOnInvalidHash(false); //manager->onCapsChanged.connect(boost::bind(&CapsManagerTest::handleCapsChanged, this, _1)); return manager; } |