Index: src/XMPPConnection.h ================================================================== --- src/XMPPConnection.h +++ src/XMPPConnection.h @@ -144,10 +144,11 @@ OFString *username, *password, *server, *resource; OFString *privateKeyFile, *certificateFile; OFString *domain, *domainToASCII; XMPPJID *JID; uint16_t port; + OFString *language; XMPPMulticastDelegate *delegates; OFMutableDictionary *callbacks; XMPPAuthenticator *authModule; BOOL streamOpen; BOOL needsSession; @@ -168,10 +169,12 @@ @property (copy) OFString *server; /// \brief The domain to connect to @property (copy) OFString *domain; /// \brief The resource to request for the connection @property (copy) OFString *resource; +/// \brief The language to request for the connection +@property (copy) OFString *language; /// \brief A private key file to use for authentication @property (copy) OFString *privateKeyFile; /// \brief A certificate file to use for authentication @property (copy) OFString *certificateFile; /// \brief The JID the server assigned to the connection after binding @@ -319,10 +322,12 @@ - (void)setResource: (OFString*)resource; - (OFString*)resource; - (XMPPJID*)JID; - (void)setPort: (uint16_t)port; - (uint16_t)port; +- (void)setLanguage: (OFString*)language; +- (OFString*)language; /// \cond internal - (void)XMPP_startStream; - (void)XMPP_handleStream: (OFXMLElement*)element; - (void)XMPP_handleTLS: (OFXMLElement*)element; Index: src/XMPPConnection.m ================================================================== --- src/XMPPConnection.m +++ src/XMPPConnection.m @@ -49,10 +49,12 @@ #import "XMPPPresence.h" #import "XMPPMulticastDelegate.h" #import "XMPPExceptions.h" #import "XMPPXMLElementBuilder.h" #import "namespaces.h" + +#import @implementation XMPPConnection + connection { return [[[self alloc] init] autorelease]; @@ -526,10 +528,12 @@ } } - (void)XMPP_startStream { + OFString *langString = @""; + /* Make sure we don't get any old events */ [parser setDelegate: nil]; [elementBuilder setDelegate: nil]; /* @@ -542,16 +546,21 @@ parser = [[OFXMLParser alloc] init]; [parser setDelegate: self]; elementBuilder = [[XMPPXMLElementBuilder alloc] init]; [elementBuilder setDelegate: self]; + + if (language != nil) + langString = [OFString stringWithFormat: @"xml:lang='%@' ", + language]; [sock writeFormat: @"\n" @"", domain]; + @"xmlns:stream='" XMPP_NS_STREAM @"' %@" + @"version='1.0'>", domain, langString]; + streamOpen = YES; } - (void)close { @@ -1039,10 +1048,20 @@ - (uint16_t)port { return port; } + +- (void)setLanguage: (OFString*)language_ +{ + OF_SETTER(language, language_, YES, YES) +} + +- (OFString*)language +{ + OF_GETTER(language, YES) +} - (void)addDelegate: (id )delegate { [delegates addDelegate: delegate]; } Index: src/XMPPStanza.h ================================================================== --- src/XMPPStanza.h +++ src/XMPPStanza.h @@ -33,10 +33,11 @@ /// \cond internal XMPPJID *from; XMPPJID *to; OFString *type; OFString *ID; + OFString *language; /// \endcond } #ifdef OF_HAVE_PROPERTIES /// \brief The value of the stanza's from attribute @@ -45,10 +46,11 @@ @property (copy) XMPPJID *to; /// \brief The value of the stanza's type attribute @property (copy) OFString *type; /// \brief The value of the stanza's id attribute @property (copy) OFString *ID; +/// \brief The stanza's xml:lang #endif /** * \brief Creates a new autoreleased XMPPStanza with the specified name. * @@ -156,6 +158,8 @@ - (XMPPJID*)to; - (void)setType: (OFString*)type; - (OFString*)type; - (void)setID: (OFString*)ID; - (OFString*)ID; +- (void)setLanguage: (OFString*)language; +- (OFString*)language; @end Index: src/XMPPStanza.m ================================================================== --- src/XMPPStanza.m +++ src/XMPPStanza.m @@ -209,21 +209,42 @@ return [[type copy] autorelease]; } - (void)setID: (OFString*)ID_ { - OFString* old = ID; + OFString *old = ID; ID = [ID_ copy]; [old release]; [self removeAttributeForName: @"id"]; if (ID_ != nil) [self addAttributeWithName: @"id" - stringValue: ID]; + stringValue: ID_]; } - (OFString*)ID { return [[ID copy] autorelease]; } + +- (void)setLanguage: (OFString*)language_ +{ + OFString *old = language; + language = [language_ copy]; + [old release]; + + [self removeAttributeForName: @"lang" + namespace: @"http://www.w3.org/XML/1998/namespace"]; + + if (language_ != nil) + [self addAttributeWithName: @"lang" + namespace: @"http://www.w3.org/XML/1998/" + @"namespace" + stringValue: language_]; +} + +- (OFString*)language +{ + return [[language copy] autorelease]; +} @end