Add xml:lang support.
This commit is contained in:
parent
1b9c63195a
commit
6ddf416e50
4 changed files with 53 additions and 4 deletions
|
@ -146,6 +146,7 @@
|
|||
OFString *domain, *domainToASCII;
|
||||
XMPPJID *JID;
|
||||
uint16_t port;
|
||||
OFString *language;
|
||||
XMPPMulticastDelegate *delegates;
|
||||
OFMutableDictionary *callbacks;
|
||||
XMPPAuthenticator *authModule;
|
||||
|
@ -170,6 +171,8 @@
|
|||
@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
|
||||
|
@ -321,6 +324,8 @@
|
|||
- (XMPPJID*)JID;
|
||||
- (void)setPort: (uint16_t)port;
|
||||
- (uint16_t)port;
|
||||
- (void)setLanguage: (OFString*)language;
|
||||
- (OFString*)language;
|
||||
|
||||
/// \cond internal
|
||||
- (void)XMPP_startStream;
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#import "XMPPXMLElementBuilder.h"
|
||||
#import "namespaces.h"
|
||||
|
||||
#import <ObjFW/macros.h>
|
||||
|
||||
@implementation XMPPConnection
|
||||
+ connection
|
||||
{
|
||||
|
@ -528,6 +530,8 @@
|
|||
|
||||
- (void)XMPP_startStream
|
||||
{
|
||||
OFString *langString = @"";
|
||||
|
||||
/* Make sure we don't get any old events */
|
||||
[parser setDelegate: nil];
|
||||
[elementBuilder setDelegate: nil];
|
||||
|
@ -545,11 +549,16 @@
|
|||
elementBuilder = [[XMPPXMLElementBuilder alloc] init];
|
||||
[elementBuilder setDelegate: self];
|
||||
|
||||
if (language != nil)
|
||||
langString = [OFString stringWithFormat: @"xml:lang='%@' ",
|
||||
language];
|
||||
|
||||
[sock writeFormat: @"<?xml version='1.0'?>\n"
|
||||
@"<stream:stream to='%@' "
|
||||
@"xmlns='" XMPP_NS_CLIENT @"' "
|
||||
@"xmlns:stream='" XMPP_NS_STREAM @"' "
|
||||
@"version='1.0'>", domain];
|
||||
@"xmlns:stream='" XMPP_NS_STREAM @"' %@"
|
||||
@"version='1.0'>", domain, langString];
|
||||
|
||||
streamOpen = YES;
|
||||
}
|
||||
|
||||
|
@ -1042,6 +1051,16 @@
|
|||
return port;
|
||||
}
|
||||
|
||||
- (void)setLanguage: (OFString*)language_
|
||||
{
|
||||
OF_SETTER(language, language_, YES, YES)
|
||||
}
|
||||
|
||||
- (OFString*)language
|
||||
{
|
||||
OF_GETTER(language, YES)
|
||||
}
|
||||
|
||||
- (void)addDelegate: (id <XMPPConnectionDelegate>)delegate
|
||||
{
|
||||
[delegates addDelegate: delegate];
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
XMPPJID *to;
|
||||
OFString *type;
|
||||
OFString *ID;
|
||||
OFString *language;
|
||||
/// \endcond
|
||||
}
|
||||
|
||||
|
@ -47,6 +48,7 @@
|
|||
@property (copy) OFString *type;
|
||||
/// \brief The value of the stanza's id attribute
|
||||
@property (copy) OFString *ID;
|
||||
/// \brief The stanza's xml:lang
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -158,4 +160,6 @@
|
|||
- (OFString*)type;
|
||||
- (void)setID: (OFString*)ID;
|
||||
- (OFString*)ID;
|
||||
- (void)setLanguage: (OFString*)language;
|
||||
- (OFString*)language;
|
||||
@end
|
||||
|
|
|
@ -219,11 +219,32 @@
|
|||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue