ObjXMPP  Check-in [fbe5acc621]

Overview
Comment:Make use of -[elementsForName:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fbe5acc6216d9c5efdf9154674c769d99b189a8e75ef3815e955bcd6d896539e
User & Date: js on 2011-02-19 16:23:36
Other Links: manifest | tags
Context
2011-02-19
16:38
Make XMPPJID conform to OFCopying. check-in: 58db21b120 user: js tags: trunk
16:23
Make use of -[elementsForName:]. check-in: fbe5acc621 user: js tags: trunk
15:08
Remove old attributes before adding new ones. check-in: 51f917ae30 user: js tags: trunk
Changes

Modified src/XMPPConnection.m from [162b90dd45] to [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"