From f6c537a9e9276e2ca9b837618a0a9631b63ee6f8 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Mon, 6 Feb 2012 14:49:37 +0100 Subject: [PATCH] Detect support for roster versioning. --- src/XMPPConnection.h | 9 ++++++--- src/XMPPConnection.m | 9 +++++++++ src/namespaces.h | 5 +++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/XMPPConnection.h b/src/XMPPConnection.h index eca20c7..bc171f8 100644 --- a/src/XMPPConnection.h +++ b/src/XMPPConnection.h @@ -149,6 +149,7 @@ OFString *domain, *domainToASCII; XMPPJID *JID; uint16_t port; + id dataStorage; OFString *language; XMPPMulticastDelegate *delegates; OFMutableDictionary *callbacks; @@ -156,8 +157,8 @@ BOOL streamOpen; BOOL needsSession; BOOL encryptionRequired, encrypted; + BOOL rosterVersioningSupported; unsigned int lastID; - id dataStorage; /// \endcond } @@ -186,14 +187,16 @@ @property (copy, readonly) XMPPJID *JID; /// \brief The port to connect to @property uint16_t port; +/// \brief An object for data storage, conforming to the XMPPStorage protocol +@property (assign) id dataStorage; /// \brief The socket used for the connection @property (readonly, retain, getter=socket) OFTCPSocket *sock; /// \brief Whether encryption is required @property BOOL encryptionRequired; /// \brief Whether the connection is encrypted @property (readonly) BOOL encrypted; -/// \brief An object for data storage, conforming to the XMPPStorage protocol -@property (assign) id dataStorage; +/// \brief Whether roster versioning is supported +@property (readonly) BOOL rosterVersioningSupported; #endif /** diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index cc97013..99613d6 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -350,6 +350,11 @@ return streamOpen; } +- (BOOL)rosterVersioningSupported +{ + return rosterVersioningSupported; +} + - (BOOL)checkCertificateAndGetReason: (OFString**)reason { X509Certificate *cert; @@ -845,6 +850,10 @@ /* TODO: Find/create an exception to throw here */ @throw [OFException exceptionWithClass: isa]; + if ([element elementForName: @"ver" + namespace: XMPP_NS_ROSTERVER] != nil) + rosterVersioningSupported = YES; + if (mechs != nil) { OFEnumerator *enumerator; OFXMLElement *mech; diff --git a/src/namespaces.h b/src/namespaces.h index 58ce329..a3f9df2 100644 --- a/src/namespaces.h +++ b/src/namespaces.h @@ -23,9 +23,10 @@ #define XMPP_NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind" #define XMPP_NS_CLIENT @"jabber:client" #define XMPP_NS_ROSTER @"jabber:iq:roster" +#define XMPP_NS_ROSTERVER @"urn:xmpp:features:rosterver" #define XMPP_NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl" +#define XMPP_NS_SESSION @"urn:ietf:params:xml:ns:xmpp-session" #define XMPP_NS_STARTTLS @"urn:ietf:params:xml:ns:xmpp-tls" #define XMPP_NS_STANZAS @"urn:ietf:params:xml:ns:xmpp-stanzas" -#define XMPP_NS_SESSION @"urn:ietf:params:xml:ns:xmpp-session" -#define XMPP_NS_XMPP_STREAM @"urn:ietf:params:xml:ns:xmpp-streams" #define XMPP_NS_STREAM @"http://etherx.jabber.org/streams" +#define XMPP_NS_XMPP_STREAM @"urn:ietf:params:xml:ns:xmpp-streams"