ObjXMPP  Check-in [109b15316d]

Overview
Comment:Add stanza classes XMPPStanza, XMPPIQ, XMPPMessage and XMPPPresence
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 109b15316d89ab7714ce3997c438846918b4f223f981b260f8fd5c7dad3ab035
User & Date: florob@babelmonkeys.de on 2011-02-10 02:54:08
Other Links: manifest | tags
Context
2011-02-10
15:36
Handle resource binding check-in: 28b1848edc user: florob@babelmonkeys.de tags: trunk
02:54
Add stanza classes XMPPStanza, XMPPIQ, XMPPMessage and XMPPPresence check-in: 109b15316d user: florob@babelmonkeys.de tags: trunk
2011-02-08
19:45
Initial commit. check-in: acb2c5cbf0 user: js tags: trunk
Changes

Modified XMPPConnection.m from [376ec31f52] to [65b3fffac0].

1

2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
9

+







#import "XMPPConnection.h"
#import "XMPPStanza.h"

#define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind"
#define NS_CLIENT @"jabber:client"
#define NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl"
#define NS_STREAM @"http://etherx.jabber.org/streams"

@implementation XMPPConnection
131
132
133
134
135
136
137
138
139

140
141
142
143
144
145
146
132
133
134
135
136
137
138


139
140
141
142
143
144
145
146







-
-
+







	    [message stringByBase64Encoding]]];

	[sock writeString: [authTag stringValue]];
}

- (void)_sendResourceBind
{
	OFXMLElement *iq = [OFXMLElement elementWithName: @"iq"];
	[iq addAttributeWithName: @"type" stringValue: @"set"];
	XMPPIQ *iq = [XMPPIQ IQWithType: @"set" ID: @"bind0"];
	[iq addChild: [OFXMLElement elementWithName: @"bind"
					  namespace: NS_BIND]];

	[sock writeString: [iq stringValue]];
}

- (void)_handleFeatures: (OFXMLElement*)elem

Added XMPPStanza.h version [ea5e90b255].

Added XMPPStanza.m version [aa9b33c527].

Added XMPPStanza.o version [00d9730d3b].

Modified test.m from [6897d0dd8c] to [3f14c4e76b].

1


2

3
4
5
6
7
8
9
10
11
12
13
14
15
16






































17
18
19
20
21
22
23

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
59
60
61
62
63
-
+
+

+














+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#include <ObjFW/ObjFW.h>
#include <assert.h>
#import <ObjFW/ObjFW.h>
#import "XMPPConnection.h"
#import "XMPPStanza.h"

@interface AppDelegate: OFObject
{
	XMPPConnection *conn;
}
@end

OF_APPLICATION_DELEGATE(AppDelegate)

@implementation AppDelegate
- (void)applicationDidFinishLaunching
{
	OFArray *arguments = [OFApplication arguments];

	XMPPPresence *pres = [XMPPPresence presence];
	[pres addShow: @"chat"];
	[pres addStatus: @"Bored"];
	[pres addPriority: 20];
	pres.to = @"alice@example.com";
	pres.from = @"bob@example.org";
	assert([[pres stringValue] isEqual: @"<presence to='alice@example.com' "
			@"from='bob@example.org'><show>chat</show>"
			@"<status>Bored</status><priority>20</priority>"
			@"</presence>"]);

	XMPPMessage *msg = [XMPPMessage messageWithType: @"chat"];
	[msg addBody: @"Hello everyone"];
	msg.to = @"jdev@conference.jabber.org";
	msg.from = @"alice@example.com";
	assert([[msg stringValue] isEqual: @"<message type='chat' "
			@"to='jdev@conference.jabber.org' "
			@"from='alice@example.com'><body>Hello everyone</body>"
			@"</message>"]);

	XMPPIQ *iq = [XMPPIQ IQWithType: @"set" ID: @"128"];
	iq.to = @"juliet@capulet.lit";
	iq.from = @"romeo@montague.lit";
	assert([[iq stringValue] isEqual: @"<iq type='set' id='128' "
			@"to='juliet@capulet.lit' "
			@"from='romeo@montague.lit'/>"]);

	OFXMLElement *elem = [OFXMLElement elementWithName: @"iq"];
	[elem addAttributeWithName: @"from" stringValue: @"bob@localhost"];
	[elem addAttributeWithName: @"to" stringValue: @"alice@localhost"];
	[elem addAttributeWithName: @"type" stringValue: @"get"];
	[elem addAttributeWithName: @"id" stringValue: @"42"];
	XMPPStanza *stanza = [XMPPStanza stanzaWithElement: elem];
	assert([[elem stringValue] isEqual: [stanza stringValue]]);
	assert(([[OFString stringWithFormat: @"%@, %@, %@, %@", stanza.from,
			stanza.to, stanza.type, stanza.ID]
			isEqual: @"bob@localhost, alice@localhost, get, 42"]));

	conn = [[XMPPConnection alloc] init];

	if (arguments.count != 3) {
		of_log(@"Invalid count of command line arguments!");
		[OFApplication terminateWithStatus: 1];
	}