From f03b5eee1d92f686f4f2ccc8a0b10c18bac05e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Mon, 1 Nov 2010 18:01:36 +0100 Subject: Centralizing predefined features in DiscoInfo. diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 5556a00..43817b5 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -239,8 +239,8 @@ void MainController::handleConnected() { DiscoInfo discoInfo; discoInfo.addIdentity(DiscoInfo::Identity(CLIENT_NAME, "client", "pc")); - discoInfo.addFeature("urn:xmpp:sec-label:0"); - discoInfo.addFeature(ChatState::getFeatureNamespace()); + discoInfo.addFeature(DiscoInfo::ChatStatesFeature); + discoInfo.addFeature(DiscoInfo::SecurityLabelsFeature); client_->getDiscoManager()->setCapsNode(CLIENT_NODE); client_->getDiscoManager()->setDiscoInfo(discoInfo); diff --git a/Swiften/Chat/ChatStateNotifier.cpp b/Swiften/Chat/ChatStateNotifier.cpp index cb7fa9a..6e0f458 100644 --- a/Swiften/Chat/ChatStateNotifier.cpp +++ b/Swiften/Chat/ChatStateNotifier.cpp @@ -84,7 +84,7 @@ void ChatStateNotifier::addChatStateRequest(Message::ref message) { void ChatStateNotifier::handleCapsChanged(const JID& jid) { if (jid == contact_) { DiscoInfo::ref caps = entityCapsManager_->getCaps(contact_); - bool hasCSN = caps && caps->hasFeature(ChatState::getFeatureNamespace()); + bool hasCSN = caps && caps->hasFeature(DiscoInfo::ChatStatesFeature); contactHas85Caps_ = hasCSN; } } diff --git a/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp b/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp index 8380330..00fc11d 100644 --- a/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp +++ b/Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp @@ -132,7 +132,7 @@ public: private: void setContactHas85Caps() { DiscoInfo::ref caps(new DiscoInfo()); - caps->addFeature(ChatState::getFeatureNamespace()); + caps->addFeature(DiscoInfo::ChatStatesFeature); entityCapsProvider->caps[JID("foo@bar.com/baz")] = caps; entityCapsProvider->onCapsChanged(JID("foo@bar.com/baz")); } diff --git a/Swiften/Elements/ChatState.h b/Swiften/Elements/ChatState.h index 8a96bf1..8dcf77c 100644 --- a/Swiften/Elements/ChatState.h +++ b/Swiften/Elements/ChatState.h @@ -19,7 +19,7 @@ namespace Swift { ChatStateType getChatState() { return state_; } void setChatState(ChatStateType state) {state_ = state;} - static String getFeatureNamespace() {return "http://jabber.org/protocol/chatstates";} + private: ChatStateType state_; }; diff --git a/Swiften/Elements/DiscoInfo.cpp b/Swiften/Elements/DiscoInfo.cpp index 7c939f6..276b341 100644 --- a/Swiften/Elements/DiscoInfo.cpp +++ b/Swiften/Elements/DiscoInfo.cpp @@ -8,6 +8,10 @@ namespace Swift { +const String DiscoInfo::ChatStatesFeature = String("http://jabber.org/protocol/chatstates"); +const String DiscoInfo::SecurityLabelsFeature = String("urn:xmpp:sec-label:0"); + + bool DiscoInfo::Identity::operator<(const Identity& other) const { if (category_ == other.category_) { if (type_ == other.type_) { diff --git a/Swiften/Elements/DiscoInfo.h b/Swiften/Elements/DiscoInfo.h index 249f9ac..038a2f1 100644 --- a/Swiften/Elements/DiscoInfo.h +++ b/Swiften/Elements/DiscoInfo.h @@ -19,6 +19,9 @@ namespace Swift { public: typedef boost::shared_ptr ref; + static const String ChatStatesFeature; + static const String SecurityLabelsFeature; + const static std::string SecurityLabels; class Identity { public: -- cgit v0.10.2-6-g49f6