ObjXMPP  Check-in [9ee7cd4433]

Overview
Comment:Add a delegate for incoming/outgoing elements.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9ee7cd4433223382f115514fb075f5c3063548aba2ae3ea65c8ac72f029ebbc5
User & Date: js on 2011-12-11 23:27:32
Other Links: manifest | tags
Context
2011-12-11
23:39
Eliminate dead code. check-in: b3b3413169 user: js tags: trunk
23:27
Add a delegate for incoming/outgoing elements. check-in: 9ee7cd4433 user: js tags: trunk
2011-11-22
22:07
Implement certificate checking. check-in: 91ee08a56a user: florob@babelmonkeys.de tags: trunk
Changes

Modified src/XMPPConnection.h from [57152f12f4] to [219552acf0].

36
37
38
39
40
41
42




43
44
45
46
47
48
49
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53







+
+
+
+







@protocol XMPPConnectionDelegate
#ifndef XMPP_CONNECTION_M
    <OFObject>
#endif
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
-  (void)connection: (XMPPConnection*)connection
  didReceiveElement: (OFXMLElement*)element;
- (void)connection: (XMPPConnection*)connection
    didSendElement: (OFXMLElement*)element;
- (void)connectionWasAuthenticated: (XMPPConnection*)connection;
- (void)connection: (XMPPConnection*)connection
     wasBoundToJID: (XMPPJID*)JID;
- (void)connectionDidReceiveRoster: (XMPPConnection*)connection;
- (BOOL)connection: (XMPPConnection*)connection
      didReceiveIQ: (XMPPIQ*)iq;
-   (void)connection: (XMPPConnection*)connection

Modified src/XMPPConnection.m from [ce3750af92] to [4cc1dbd235].

340
341
342
343
344
345
346




347

348
349
350
351
352
353
354
340
341
342
343
344
345
346
347
348
349
350

351
352
353
354
355
356
357
358







+
+
+
+
-
+







		@throw [SSLInvalidCertificateException
		    exceptionWithClass: isa
				reason: @"No matching identifier"];
}

- (void)sendStanza: (OFXMLElement*)element
{
	if ([delegate respondsToSelector:
	    @selector(connection:didSendElement:)])
		[delegate connection: self
		      didSendElement: element];
	of_log(@"Out: %@", element);

	[sock writeString: [element XMLString]];
}

- (OFString*)generateStanzaID
{
	return [OFString stringWithFormat: @"objxmpp_%u", lastID++];
}
400
401
402
403
404
405
406



407

408
409
410
411
412
413
414
404
405
406
407
408
409
410
411
412
413

414
415
416
417
418
419
420
421







+
+
+
-
+







	if ([element name] == nil)
		return;

	[element setDefaultNamespace: XMPP_NS_CLIENT];
	[element setPrefix: @"stream"
	      forNamespace: XMPP_NS_STREAM];

	if ([delegate respondsToSelector:
	    @selector(connection:didReceiveElement:)])
		[delegate connection: self
	of_log(@"In:  %@", element);
		   didReceiveElement: element];

	if ([[element namespace] isEqual: XMPP_NS_CLIENT])
		[self XMPP_handleStanza: element];

	if ([[element namespace] isEqual: XMPP_NS_STREAM])
		[self XMPP_handleStream: element];

Modified tests/test.m from [c0b9f87604] to [cf687a7428].

106
107
108
109
110
111
112












113
114
115
116
117
118
119
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131







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







	@try {
		[conn connect];
		[conn handleConnection];
	} @catch (id e) {
		of_log(@"%@", e);
	}
}

-  (void)connection: (XMPPConnection*)conn
  didReceiveElement: (OFXMLElement*)element
{
	of_log(@"In:  %@", element);
}

- (void)connection: (XMPPConnection*)conn
    didSendElement: (OFXMLElement*)element
{
	of_log(@"Out: %@", element);
}

- (void)connectionWasAuthenticated: (XMPPConnection*)conn
{
	of_log(@"Auth successful");
}

- (void)connection: (XMPPConnection*)conn