ObjXMPP  Diff

Differences From Artifact [b2823f282f]:

To Artifact [bdd589660a]:


187
188
189
190
191
192
193
194


195
196
197
198
199
200
201
187
188
189
190
191
192
193

194
195
196
197
198
199
200
201
202







-
+
+







{
	char buf[512];

	for (;;) {
		size_t len = [sock readNBytes: 512
				   intoBuffer: buf];

		if (len < 1)
		if (len < 1 && [delegate respondsToSelector:
		    @selector(connectionWasClosed:)])
			[delegate connectionWasClosed: self];

		[of_stdout writeNBytes: len
			    fromBuffer: buf];
		[parser parseBuffer: buf
			   withSize: len];
	}
262
263
264
265
266
267
268
269





270
271
272
273
274
275
276
263
264
265
266
267
268
269

270
271
272
273
274
275
276
277
278
279
280
281







-
+
+
+
+
+







	OFXMLElement *bindElem = iq.children.firstObject;

	if ([bindElem.name isEqual: @"bind"] &&
	    [bindElem.namespace isEqual: NS_BIND]) {
		OFXMLElement *jidElem = bindElem.children.firstObject;
		JID = [[XMPPJID alloc] initWithString:
		    [jidElem.children.firstObject stringValue]];
		of_log(@"Bound to JID: %@", [JID fullJID]);

		if ([delegate respondsToSelector:
		    @selector(connection:wasBoundToJID:)])
			[delegate connection: self
			       wasBoundToJID: JID];
	}
}

- (void)_handleFeatures: (OFXMLElement*)elem
{
	OFXMLElement *starttls = [elem
	    elementsForName: @"starttls"
309
310
311
312
313
314
315

316
317


318
319
320
321


322
323


324
325
326
327


328
329


330
331
332
333
334
335
336
314
315
316
317
318
319
320
321


322
323
324
325
326
327
328
329


330
331
332
333
334
335
336
337


338
339
340
341
342
343
344
345
346







+
-
-
+
+




+
+
-
-
+
+




+
+
-
-
+
+







{
	// FIXME: More checking!
	if ([iq.ID isEqual: @"bind0"] && [iq.type isEqual: @"result"]) {
		[self _handleResourceBind: iq];
		return;
	}

	if ([delegate respondsToSelector: @selector(connection:didReceiveIQ:)])
	[delegate connection: self
		didReceiveIQ: iq];
		    [delegate connection: self
			    didReceiveIQ: iq];
}

- (void)_handleMessage: (XMPPMessage*)msg
{
	if ([delegate respondsToSelector:
	    @selector(connection:didReceiveMessage:)])
	[delegate connection: self
	   didReceiveMessage: msg];
		[delegate connection: self
		   didReceiveMessage: msg];
}

- (void)_handlePresence: (XMPPPresence*)pres
{
	if ([delegate respondsToSelector:
	    @selector(connection:didReceivePresence:)])
	[delegate connection: self
	  didReceivePresence: pres];
		[delegate connection: self
		  didReceivePresence: pres];
}

- (void)elementBuilder: (OFXMLElementBuilder*)b
       didBuildElement: (OFXMLElement*)elem
{
	elem.defaultNamespace = NS_CLIENT;
	[elem setPrefix: @"stream"
404
405
406
407
408
409
410
411




412
413
414
415
416
417
418
414
415
416
417
418
419
420

421
422
423
424
425
426
427
428
429
430
431







-
+
+
+
+







			return;
		}

		if ([elem.name isEqual: @"success"]) {
			[authModule parseServerFinalMessage:
			    [OFDataArray dataArrayWithBase64EncodedString:
				[elem.children.firstObject stringValue]]];
			of_log(@"Auth successful");

			if ([delegate respondsToSelector:
			    @selector(connectionWasAuthenticated:)])
				[delegate connectionWasAuthenticated: self];

			/* Stream restart */
			parser.delegate = self;
			[self _startStream];
			return;
		}