Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -57,8 +57,8 @@ dnl We don't call AC_PROG_CPP, but only AC_PROG_OBJCPP and set CPP to OBJCPP dnl and add OBJCPPA.FLAGS to CPPFLAGS, thus we need to AC_SUBST these ourself AC_SUBST(CPP) AC_SUBST(CPPFLAGS) -AC_SUBST(PACKAGE, ObjFW) +AC_SUBST(PACKAGE, ObjXMPP) AC_CONFIG_FILES([buildsys.mk extra.mk]) AC_OUTPUT Index: src/XMPPRoster.h ================================================================== --- src/XMPPRoster.h +++ src/XMPPRoster.h @@ -26,16 +26,17 @@ @class XMPPRosterItem; @interface XMPPRoster: OFObject { XMPPConnection *connection; - OFMutableDictionary *groups; + OFMutableDictionary *rosterItems; } - initWithConnection: (XMPPConnection*)conn; - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem; -- (OFArray*)groups; -- (OFArray*)rosterItemsInGroup: (OFString*)group; +- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem; +- (void)XMPP_deleteRosterItem: (XMPPRosterItem*)rosterItem; +- (OFDictionary*)rosterItems; - (void)addRosterItem: (XMPPRosterItem*)rosterItem; - (void)updateRosterItem: (XMPPRosterItem*)rosterItem; - (void)deleteRosterItem: (XMPPRosterItem*)rosterItem; @end Index: src/XMPPRoster.m ================================================================== --- src/XMPPRoster.m +++ src/XMPPRoster.m @@ -31,11 +31,11 @@ { self = [super init]; @try { connection = [conn retain]; - groups = [[OFMutableDictionary alloc] init]; + rosterItems = [[OFMutableDictionary alloc] init]; } @catch (id e) { [self release]; @throw e; } @@ -49,60 +49,27 @@ [super dealloc]; } - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem { - if ([[rosterItem groups] count] > 0) { - OFEnumerator *enumerator; - OFString *group; - - enumerator = [[rosterItem groups] objectEnumerator]; - while ((group = [enumerator nextObject]) != nil) { - OFMutableArray *rosterGroup = - [groups objectForKey: group]; - - if (rosterGroup == nil) { - rosterGroup = [OFMutableArray array]; - [groups setObject: rosterGroup - forKey: group]; - } - - [rosterGroup addObject: rosterItem]; - } - } else { - OFMutableArray *rosterGroup = [groups objectForKey: @""]; - - if (rosterGroup == nil) { - rosterGroup = [OFMutableArray array]; - [groups setObject: rosterGroup - forKey: @""]; - } - - [rosterGroup addObject: rosterItem]; - } -} - -- (OFArray*)groups -{ - OFMutableArray *ret = [OFMutableArray array]; - OFEnumerator *enumerator; - OFString *group; - - enumerator = [groups keyEnumerator]; - while ((group = [enumerator nextObject]) != nil) - [ret addObject: group]; - - ret->isa = [OFArray class]; - return ret; -} - -- (OFArray*)rosterItemsInGroup: (OFString*)group -{ - if (group == nil) - group = @""; - - return [[[groups objectForKey: group] copy] autorelease]; + return [self XMPP_updateRosterItem: rosterItem]; +} + +- (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem +{ + [rosterItems setObject: rosterItem + forKey: [[rosterItem JID] bareJID]]; +} + +- (void)XMPP_deleteRosterItem: (XMPPRosterItem*)rosterItem +{ + [rosterItems removeObjectForKey: [[rosterItem JID] bareJID]]; +} + +- (OFDictionary*)rosterItems +{ + return [[rosterItems copy] autorelease]; } - (void)addRosterItem: (XMPPRosterItem*)rosterItem { [self updateRosterItem: rosterItem]; Index: tests/test.m ================================================================== --- tests/test.m +++ tests/test.m @@ -124,18 +124,12 @@ } - (void)connectionDidReceiveRoster :(XMPPConnection*)conn { XMPPPresence *pres; - OFEnumerator *enumerator; - OFString *group; - - of_log(@"Got roster! Groups: %@", [[conn roster] groups]); - enumerator = [[[conn roster] groups] objectEnumerator]; - while ((group = [enumerator nextObject]) != nil) - of_log(@"Group %@: %@", group, - [[conn roster] rosterItemsInGroup: group]); + + of_log(@"Got roster: %@", [[conn roster] rosterItems]); pres = [XMPPPresence presence]; [pres addPriority: 10]; [pres addStatus: @"ObjXMPP test is working!"];