ObjXMPP  Check-in [471aef0278]

Overview
Comment:Fix roster versioning

This fixes two things:
1) We reset the version we stored for the roster, even though it was
still up to date
2) Since we make mutable copies of the items dictionary in
XMPP_updateRosterItem our memory was rather high.
Use a AutoreleasePool around it for now.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 471aef0278bb6646bfab6236bff381f91f6491e3a551c46a1469d8f9c7248b44
User & Date: florob@babelmonkeys.de on 2013-02-10 16:09:34
Other Links: manifest | tags
Context
2013-02-10
16:31
Implement -hash for XMPPJID check-in: 7df3923343 user: florob@babelmonkeys.de tags: trunk
16:09
Fix roster versioning check-in: 471aef0278 user: florob@babelmonkeys.de tags: trunk
2013-02-02
21:59
Fix initialization of XMPPContact check-in: 3a055c9030 user: florob@babelmonkeys.de tags: trunk
Changes

Modified src/XMPPRoster.m from [3d07ff17e7] to [1569eac957].

307
308
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



337
338
339
340



341
342
343
344

345
346
347

348
349
350
351
352
353
354
355
356
357

- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection_
					   IQ: (XMPPIQ*)iq
{
	OFXMLElement *rosterElement;
	OFEnumerator *enumerator;
	OFXMLElement *element;
	XMPPRosterItem *rosterItem;

	rosterElement = [iq elementForName: @"query"
				 namespace: XMPP_NS_ROSTER];

	if ([connection supportsRosterVersioning] && rosterElement == nil) {

		OFDictionary *items = [dataStorage
		    dictionaryForPath: @"roster.items"];
		OFEnumerator *enumerator = [items objectEnumerator];
		OFDictionary *item;

		while ((item = [enumerator nextObject]) != nil) {



			rosterItem = [XMPPRosterItem rosterItem];
			[rosterItem setJID: [XMPPJID JIDWithString:
			    [item objectForKey: @"JID"]]];

			[rosterItem setName: [item objectForKey: @"name"]];

			[rosterItem setSubscription:
			    [item objectForKey: @"subscription"]];
			[rosterItem setGroups: [item objectForKey: @"groups"]];


			[rosterItems setObject: rosterItem
					forKey: [[rosterItem JID] bareJID]];
		}



	}

	enumerator = [[rosterElement children] objectEnumerator];
	while ((element = [enumerator nextObject]) != nil) {



		if (![[element name] isEqual: @"item"] ||
		    ![[element namespace] isEqual: XMPP_NS_ROSTER])
			continue;


		rosterItem = [self XMPP_rosterItemWithXMLElement: element];

		[self XMPP_updateRosterItem: rosterItem];

	}

	if ([connection supportsRosterVersioning]) {
		OFString *ver =
		    [[rosterElement attributeForName: @"ver"] stringValue];
		[dataStorage setStringValue: ver
				    forPath: @"roster.ver"];
		[dataStorage save];
	}








<




|
>
|
|
|
|

|
>
>
>
|
|
|
>
|
>
|
|
|
>

|
|
|
>
>
>




>
>
>




>



>


|







307
308
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371

- (void)XMPP_handleInitialRosterForConnection: (XMPPConnection*)connection_
					   IQ: (XMPPIQ*)iq
{
	OFXMLElement *rosterElement;
	OFEnumerator *enumerator;
	OFXMLElement *element;


	rosterElement = [iq elementForName: @"query"
				 namespace: XMPP_NS_ROSTER];

	if ([connection supportsRosterVersioning]) {
		if (rosterElement == nil) {
			OFDictionary *items = [dataStorage
			    dictionaryForPath: @"roster.items"];
			OFEnumerator *enumerator = [items objectEnumerator];
			OFDictionary *item;

			while ((item = [enumerator nextObject]) != nil) {
				XMPPRosterItem *rosterItem;
				XMPPJID *JID;

				rosterItem = [XMPPRosterItem rosterItem];
				JID = [XMPPJID JIDWithString:
					  [item objectForKey: @"JID"]];
				[rosterItem setJID: JID];
				[rosterItem setName:
				    [item objectForKey: @"name"]];
				[rosterItem setSubscription:
				    [item objectForKey: @"subscription"]];
				[rosterItem setGroups:
				    [item objectForKey: @"groups"]];

				[rosterItems setObject: rosterItem
						forKey: [JID bareJID]];
			}
		} else
			[dataStorage setDictionary: nil
					   forPath: @"roster.items"];
	}

	enumerator = [[rosterElement children] objectEnumerator];
	while ((element = [enumerator nextObject]) != nil) {
		OFAutoreleasePool *pool;
		XMPPRosterItem *rosterItem;

		if (![[element name] isEqual: @"item"] ||
		    ![[element namespace] isEqual: XMPP_NS_ROSTER])
			continue;

		pool = [OFAutoreleasePool new];
		rosterItem = [self XMPP_rosterItemWithXMLElement: element];

		[self XMPP_updateRosterItem: rosterItem];
		[pool release];
	}

	if ([connection supportsRosterVersioning] && rosterElement != nil) {
		OFString *ver =
		    [[rosterElement attributeForName: @"ver"] stringValue];
		[dataStorage setStringValue: ver
				    forPath: @"roster.ver"];
		[dataStorage save];
	}