summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-11-01 17:01:36 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-11-03 12:17:42 (GMT)
commitf03b5eee1d92f686f4f2ccc8a0b10c18bac05e72 (patch)
treebd4292069a7c184b752c5228dfa4d94d0fad3f56
parent7e921ec72997493c5ab06cc13d7cf82bb7e8f643 (diff)
downloadswift-contrib-f03b5eee1d92f686f4f2ccc8a0b10c18bac05e72.zip
swift-contrib-f03b5eee1d92f686f4f2ccc8a0b10c18bac05e72.tar.bz2
Centralizing predefined features in DiscoInfo.
-rw-r--r--Swift/Controllers/MainController.cpp4
-rw-r--r--Swiften/Chat/ChatStateNotifier.cpp2
-rw-r--r--Swiften/Chat/UnitTest/ChatStateNotifierTest.cpp2
-rw-r--r--Swiften/Elements/ChatState.h2
-rw-r--r--Swiften/Elements/DiscoInfo.cpp4
-rw-r--r--Swiften/Elements/DiscoInfo.h3
6 files changed, 12 insertions, 5 deletions
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<DiscoInfo> ref;
+ static const String ChatStatesFeature;
+ static const String SecurityLabelsFeature;
+
const static std::string SecurityLabels;
class Identity {
public: