ObjXMPP  Diff

Differences From Artifact [162b90dd45]:

To Artifact [c09c538201]:


219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
			assert(0);
		}
	}

	parser.delegate = elementBuilder;
}

- (void)_addAuthMechanisms: (OFXMLElement*)mechanisms_
{
	for (OFXMLElement *mechanism in mechanisms_.children)
		[mechanisms addObject:
		    [mechanism.children.firstObject stringValue]];
}

- (void)_sendPLAINAuth
{
	OFXMLElement *authTag;
	OFDataArray *message;

	message = [OFDataArray dataArrayWithItemSize: 1];
	/* XXX: authzid would go here */







<
<
<
<
<
<
<







219
220
221
222
223
224
225







226
227
228
229
230
231
232
			assert(0);
		}
	}

	parser.delegate = elementBuilder;
}








- (void)_sendPLAINAuth
{
	OFXMLElement *authTag;
	OFDataArray *message;

	message = [OFDataArray dataArrayWithItemSize: 1];
	/* XXX: authzid would go here */
257
258
259
260
261
262
263
264

265
266
267
268
269
270
271
	    [message stringByBase64Encoding]]];

	[self sendStanza: authTag];
}

- (void)_sendResourceBind
{
	XMPPIQ *iq = [XMPPIQ IQWithType: @"set" ID: @"bind0"];

	OFXMLElement *bind = [OFXMLElement elementWithName: @"bind"
						 namespace: NS_BIND];
	if (resource)
		[bind addChild: [OFXMLElement elementWithName: @"resource"
						  stringValue: resource]];
	[iq addChild: bind];








|
>







250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
	    [message stringByBase64Encoding]]];

	[self sendStanza: authTag];
}

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

283
284
285
286
287
288
289
290
291
292
293
294
295
296
297


298
299
300



301
302
303
304
305
306
307
		    [jidElem.children.firstObject stringValue]];
		of_log(@"Bound to JID: %@", [JID fullJID]);
	}
}

- (void)_handleFeatures: (OFXMLElement*)elem
{
	for (OFXMLElement *child in elem.children) {
		if ([[child name] isEqual: @"mechanisms"] &&
		    [[child namespace] isEqual: NS_SASL])
			[self _addAuthMechanisms: child];
		else if ([[child name] isEqual: @"bind"] &&
		    [[child namespace] isEqual: NS_BIND])
			[self _sendResourceBind];
	}



	if ([mechanisms containsObject: @"PLAIN"])
		[self _sendPLAINAuth];



}

- (void)elementBuilder: (OFXMLElementBuilder*)b
       didBuildElement: (OFXMLElement*)elem
{
	elem.defaultNamespace = NS_CLIENT;
	[elem setPrefix: @"stream"







<
|
|
<
|
|
<
|
>
>



>
>
>







277
278
279
280
281
282
283

284
285

286
287

288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
		    [jidElem.children.firstObject stringValue]];
		of_log(@"Bound to JID: %@", [JID fullJID]);
	}
}

- (void)_handleFeatures: (OFXMLElement*)elem
{

	OFArray *mechs = [elem elementsForName: @"mechanisms"
				     namespace: NS_SASL];

	OFXMLElement *bind = [elem elementsForName: @"bind"
					 namespace: NS_BIND].firstObject;


	for (OFXMLElement *mech in mechs)
		[mechanisms addObject: mech.name];

	if ([mechanisms containsObject: @"PLAIN"])
		[self _sendPLAINAuth];

	if (bind != nil)
		[self _sendResourceBind];
}

- (void)elementBuilder: (OFXMLElementBuilder*)b
       didBuildElement: (OFXMLElement*)elem
{
	elem.defaultNamespace = NS_CLIENT;
	[elem setPrefix: @"stream"