summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-08-29 14:35:58 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-08-29 14:35:58 (GMT)
commit8310fa230b40122fff897727fe6850a67a4b73be (patch)
tree16afece093a6409ed2b3588f5c270f9781a40a75
parent0091fcc571758791442f82ece2a72444b6fe79cf (diff)
downloadswift-8310fa230b40122fff897727fe6850a67a4b73be.zip
swift-8310fa230b40122fff897727fe6850a67a4b73be.tar.bz2
Added Stream Management support to Stream Features.
-rw-r--r--Swiften/Elements/StreamFeatures.h11
-rw-r--r--Swiften/Parser/StreamFeaturesParser.cpp3
-rw-r--r--Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp2
-rw-r--r--Swiften/Serializer/StreamFeaturesSerializer.cpp3
-rw-r--r--Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp2
5 files changed, 20 insertions, 1 deletions
diff --git a/Swiften/Elements/StreamFeatures.h b/Swiften/Elements/StreamFeatures.h
index ec27014..d8a6af7 100644
--- a/Swiften/Elements/StreamFeatures.h
+++ b/Swiften/Elements/StreamFeatures.h
@@ -17,7 +17,7 @@ namespace Swift {
class StreamFeatures : public Element
{
public:
- StreamFeatures() : hasStartTLS_(false), hasResourceBind_(false), hasSession_(false) {}
+ StreamFeatures() : hasStartTLS_(false), hasResourceBind_(false), hasSession_(false), hasStreamManagement_(false) {}
void setHasStartTLS() {
hasStartTLS_ = true;
@@ -71,12 +71,21 @@ namespace Swift {
return !authenticationMechanisms_.empty();
}
+ bool hasStreamManagement() const {
+ return hasStreamManagement_;
+ }
+
+ void setHasStreamManagement() {
+ hasStreamManagement_ = true;
+ }
+
private:
bool hasStartTLS_;
std::vector<String> compressionMethods_;
std::vector<String> authenticationMechanisms_;
bool hasResourceBind_;
bool hasSession_;
+ bool hasStreamManagement_;
};
}
diff --git a/Swiften/Parser/StreamFeaturesParser.cpp b/Swiften/Parser/StreamFeaturesParser.cpp
index f9e5b05..02e70be 100644
--- a/Swiften/Parser/StreamFeaturesParser.cpp
+++ b/Swiften/Parser/StreamFeaturesParser.cpp
@@ -22,6 +22,9 @@ void StreamFeaturesParser::handleStartElement(const String& element, const Strin
else if (element == "bind" && ns == "urn:ietf:params:xml:ns:xmpp-bind") {
getElementGeneric()->setHasResourceBind();
}
+ else if (element == "sm" && ns == "urn:xmpp:sm:2") {
+ getElementGeneric()->setHasStreamManagement();
+ }
else if (element == "mechanisms" && ns == "urn:ietf:params:xml:ns:xmpp-sasl") {
inMechanisms_ = true;
}
diff --git a/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp b/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
index 1c6fa50..7f5a398 100644
--- a/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
+++ b/Swiften/Parser/UnitTest/StreamFeaturesParserTest.cpp
@@ -38,6 +38,7 @@ class StreamFeaturesParserTest : public CppUnit::TestFixture
"<mechanism>PLAIN</mechanism>"
"</mechanisms>"
"<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
+ "<sm xmlns='urn:xmpp:sm:2'/>"
"<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
"</stream:features>"));
@@ -50,6 +51,7 @@ class StreamFeaturesParserTest : public CppUnit::TestFixture
CPPUNIT_ASSERT(element->hasAuthenticationMechanisms());
CPPUNIT_ASSERT(element->hasAuthenticationMechanism("DIGEST-MD5"));
CPPUNIT_ASSERT(element->hasAuthenticationMechanism("PLAIN"));
+ CPPUNIT_ASSERT(element->hasStreamManagement());
}
void testParse_Empty() {
diff --git a/Swiften/Serializer/StreamFeaturesSerializer.cpp b/Swiften/Serializer/StreamFeaturesSerializer.cpp
index 540a8d1..ec21983 100644
--- a/Swiften/Serializer/StreamFeaturesSerializer.cpp
+++ b/Swiften/Serializer/StreamFeaturesSerializer.cpp
@@ -46,6 +46,9 @@ String StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element)
if (streamFeatures->hasSession()) {
streamFeaturesElement.addNode(boost::shared_ptr<XMLElement>(new XMLElement("session", "urn:ietf:params:xml:ns:xmpp-session")));
}
+ if (streamFeatures->hasStreamManagement()) {
+ streamFeaturesElement.addNode(boost::shared_ptr<XMLElement>(new XMLElement("sm", "urn:xmpp:sm:2")));
+ }
return streamFeaturesElement.serialize();
}
diff --git a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
index 81eeacb..bd39bd8 100644
--- a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
+++ b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp
@@ -31,6 +31,7 @@ class StreamFeaturesSerializerTest : public CppUnit::TestFixture
streamFeatures->addAuthenticationMechanism("PLAIN");
streamFeatures->setHasResourceBind();
streamFeatures->setHasSession();
+ streamFeatures->setHasStreamManagement();
CPPUNIT_ASSERT_EQUAL(String(
"<stream:features>"
@@ -45,6 +46,7 @@ class StreamFeaturesSerializerTest : public CppUnit::TestFixture
"</mechanisms>"
"<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"
"<session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/>"
+ "<sm xmlns=\"urn:xmpp:sm:2\"/>"
"</stream:features>"), testling.serialize(streamFeatures));
}
};