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
|
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;
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;
if ([connection supportsRosterVersioning]) {
if (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"]];
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: [[rosterItem JID] bareJID]];
}
[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]) {
if ([connection supportsRosterVersioning] && rosterElement != nil) {
OFString *ver =
[[rosterElement attributeForName: @"ver"] stringValue];
[dataStorage setStringValue: ver
forPath: @"roster.ver"];
[dataStorage save];
}
|