ObjXMPP  Check-in [93625a9695]

Overview
Comment:Add xml:lang support.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 93625a969595c134064f4d5207e196d7f4bfa511371573e74e02db180636ae25
User & Date: js on 2012-02-03 16:26:34
Other Links: manifest | tags
Context
2012-02-04
11:52
Add the XMPPConnection to xmpp_calback_block_t. check-in: 779fac15b1 user: js tags: trunk
2012-02-03
16:26
Add xml:lang support. check-in: 93625a9695 user: js tags: trunk
15:46
Let -[checkCertificate] return a BOOL and a reason. check-in: aa0dc6e2b4 user: js tags: trunk
Changes

Modified src/XMPPConnection.h from [abde314206] to [a038cc0172].

142
143
144
145
146
147
148

149
150
151
152
153
154
155
	OFXMLParser *parser, *oldParser;
	OFXMLElementBuilder *elementBuilder, *oldElementBuilder;
	OFString *username, *password, *server, *resource;
	OFString *privateKeyFile, *certificateFile;
	OFString *domain, *domainToASCII;
	XMPPJID *JID;
	uint16_t port;

	XMPPMulticastDelegate *delegates;
	OFMutableDictionary *callbacks;
	XMPPAuthenticator *authModule;
	BOOL streamOpen;
	BOOL needsSession;
	BOOL encryptionRequired, encrypted;
	unsigned int lastID;







>







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
	OFXMLParser *parser, *oldParser;
	OFXMLElementBuilder *elementBuilder, *oldElementBuilder;
	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;
	BOOL encryptionRequired, encrypted;
	unsigned int lastID;
166
167
168
169
170
171
172


173
174
175
176
177
178
179
 * This is useful if the address of the server is different from the domain.
 */
@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 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
@property (copy, readonly) XMPPJID *JID;
/// \brief The port to connect to







>
>







167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
 * This is useful if the address of the server is different from the domain.
 */
@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
@property (copy, readonly) XMPPJID *JID;
/// \brief The port to connect to
317
318
319
320
321
322
323


324
325
326
327
328
329
330
- (void)setDomain: (OFString*)domain;
- (OFString*)domain;
- (void)setResource: (OFString*)resource;
- (OFString*)resource;
- (XMPPJID*)JID;
- (void)setPort: (uint16_t)port;
- (uint16_t)port;



/// \cond internal
- (void)XMPP_startStream;
- (void)XMPP_handleStream: (OFXMLElement*)element;
- (void)XMPP_handleTLS: (OFXMLElement*)element;
- (void)XMPP_handleSASL: (OFXMLElement*)element;
- (void)XMPP_handleStanza: (OFXMLElement*)element;







>
>







320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
- (void)setDomain: (OFString*)domain;
- (OFString*)domain;
- (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;
- (void)XMPP_handleSASL: (OFXMLElement*)element;
- (void)XMPP_handleStanza: (OFXMLElement*)element;

Modified src/XMPPConnection.m from [4cfcab5b18] to [e6f55ed039].

47
48
49
50
51
52
53


54
55
56
57
58
59
60
#import "XMPPIQ.h"
#import "XMPPMessage.h"
#import "XMPPPresence.h"
#import "XMPPMulticastDelegate.h"
#import "XMPPExceptions.h"
#import "XMPPXMLElementBuilder.h"
#import "namespaces.h"



@implementation XMPPConnection
+ connection
{
	return [[[self alloc] init] autorelease];
}








>
>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#import "XMPPIQ.h"
#import "XMPPMessage.h"
#import "XMPPPresence.h"
#import "XMPPMulticastDelegate.h"
#import "XMPPExceptions.h"
#import "XMPPXMLElementBuilder.h"
#import "namespaces.h"

#import <ObjFW/macros.h>

@implementation XMPPConnection
+ connection
{
	return [[[self alloc] init] autorelease];
}

524
525
526
527
528
529
530


531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546




547
548
549
550
551
552

553
554
555
556
557
558
559
	else {
		[self close];
	}
}

- (void)XMPP_startStream
{


	/* Make sure we don't get any old events */
	[parser setDelegate: nil];
	[elementBuilder setDelegate: nil];

	/*
	 * We can't release them now, as we are currently inside them. Release
	 * them the next time the parser returns.
	 */
	oldParser = parser;
	oldElementBuilder = elementBuilder;

	parser = [[OFXMLParser alloc] init];
	[parser setDelegate: self];

	elementBuilder = [[XMPPXMLElementBuilder alloc] init];
	[elementBuilder setDelegate: self];





	[sock writeFormat: @"<?xml version='1.0'?>\n"
			   @"<stream:stream to='%@' "
			   @"xmlns='" XMPP_NS_CLIENT @"' "
			   @"xmlns:stream='" XMPP_NS_STREAM @"' "
			   @"version='1.0'>", domain];

	streamOpen = YES;
}

- (void)close
{
	if (streamOpen) {
		[sock writeString: @"</stream:stream>"];







>
>
















>
>
>
>




|
|
>







526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
	else {
		[self close];
	}
}

- (void)XMPP_startStream
{
	OFString *langString = @"";

	/* Make sure we don't get any old events */
	[parser setDelegate: nil];
	[elementBuilder setDelegate: nil];

	/*
	 * We can't release them now, as we are currently inside them. Release
	 * them the next time the parser returns.
	 */
	oldParser = parser;
	oldElementBuilder = elementBuilder;

	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: @"<?xml version='1.0'?>\n"
			   @"<stream:stream to='%@' "
			   @"xmlns='" XMPP_NS_CLIENT @"' "
			   @"xmlns:stream='" XMPP_NS_STREAM @"' %@"
			   @"version='1.0'>", domain, langString];

	streamOpen = YES;
}

- (void)close
{
	if (streamOpen) {
		[sock writeString: @"</stream:stream>"];
1037
1038
1039
1040
1041
1042
1043










1044
1045
1046
1047
1048
1049
1050
	port = port_;
}

- (uint16_t)port
{
	return port;
}











- (void)addDelegate: (id <XMPPConnectionDelegate>)delegate
{
	[delegates addDelegate: delegate];
}

- (void)removeDelegate: (id <XMPPConnectionDelegate>)delegate







>
>
>
>
>
>
>
>
>
>







1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
	port = port_;
}

- (uint16_t)port
{
	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];
}

- (void)removeDelegate: (id <XMPPConnectionDelegate>)delegate

Modified src/XMPPStanza.h from [b1e074823d] to [d3b0b8d84c].

31
32
33
34
35
36
37

38
39
40
41
42
43
44
45
46
47
48
49

50
51
52
53
54
55
56
@interface XMPPStanza: OFXMLElement
{
/// \cond internal
	XMPPJID *from;
	XMPPJID *to;
	OFString *type;
	OFString *ID;

/// \endcond
}

#ifdef OF_HAVE_PROPERTIES
/// \brief The value of the stanza's from attribute
@property (copy) XMPPJID *from;
/// \brief The value of the stanza's to attribute
@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;

#endif

/**
 * \brief Creates a new autoreleased XMPPStanza with the specified name.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \return A new autoreleased XMPPStanza







>












>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@interface XMPPStanza: OFXMLElement
{
/// \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
@property (copy) XMPPJID *from;
/// \brief The value of the stanza's to attribute
@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.
 *
 * \param name The stanza's name (one of iq, message or presence)
 * \return A new autoreleased XMPPStanza
154
155
156
157
158
159
160


161
- (XMPPJID*)from;
- (void)setTo: (XMPPJID*)to;
- (XMPPJID*)to;
- (void)setType: (OFString*)type;
- (OFString*)type;
- (void)setID: (OFString*)ID;
- (OFString*)ID;


@end







>
>

156
157
158
159
160
161
162
163
164
165
- (XMPPJID*)from;
- (void)setTo: (XMPPJID*)to;
- (XMPPJID*)to;
- (void)setType: (OFString*)type;
- (OFString*)type;
- (void)setID: (OFString*)ID;
- (OFString*)ID;
- (void)setLanguage: (OFString*)language;
- (OFString*)language;
@end

Modified src/XMPPStanza.m from [446ca28bd0] to [06dd8ee876].

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228





















229
- (OFString*)type
{
	return [[type copy] autorelease];
}

- (void)setID: (OFString*)ID_
{
	OFString* old = ID;
	ID = [ID_ copy];
	[old release];

	[self removeAttributeForName: @"id"];

	if (ID_ != nil)
		[self addAttributeWithName: @"id"
			       stringValue: ID];
}

- (OFString*)ID
{
	return [[ID copy] autorelease];
}





















@end







|







|






>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
- (OFString*)type
{
	return [[type copy] autorelease];
}

- (void)setID: (OFString*)ID_
{
	OFString *old = ID;
	ID = [ID_ copy];
	[old release];

	[self removeAttributeForName: @"id"];

	if (ID_ != nil)
		[self addAttributeWithName: @"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