Add XMPPRosterItem class.

This commit is contained in:
Jonathan Schleifer 2011-03-28 01:47:48 +02:00
parent 8ea345c02c
commit 56ddb5c8de
4 changed files with 36 additions and 12 deletions

View file

@ -33,6 +33,8 @@
4BC55A001337AC1800E345C7 /* XMPPSCRAMAuth.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */; };
4BC55A011337AC1800E345C7 /* XMPPStanza.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559FE1337AC1800E345C7 /* XMPPStanza.h */; settings = {ATTRIBUTES = (Public, ); }; };
4BC55A021337AC1800E345C7 /* XMPPStanza.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559FF1337AC1800E345C7 /* XMPPStanza.m */; };
4BD9BF59134003F700DAB43A /* XMPPRosterItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */; };
4BD9BF5A134003F700DAB43A /* XMPPRosterItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -75,6 +77,8 @@
4BC559FE1337AC1800E345C7 /* XMPPStanza.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPStanza.h; path = src/XMPPStanza.h; sourceTree = SOURCE_ROOT; };
4BC559FF1337AC1800E345C7 /* XMPPStanza.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPStanza.m; path = src/XMPPStanza.m; sourceTree = SOURCE_ROOT; };
4BC55A051337ADA800E345C7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPRosterItem.h; path = src/XMPPRosterItem.h; sourceTree = SOURCE_ROOT; };
4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPRosterItem.m; path = src/XMPPRosterItem.m; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -155,6 +159,8 @@
4BC559E71337AC0900E345C7 /* XMPPPLAINAuth.m */,
4BC559E81337AC0900E345C7 /* XMPPPresence.h */,
4BC559E91337AC0900E345C7 /* XMPPPresence.m */,
4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */,
4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */,
4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */,
4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */,
4BC559FE1337AC1800E345C7 /* XMPPStanza.h */,
@ -189,6 +195,7 @@
4BC559FA1337AC0900E345C7 /* XMPPPresence.h in Headers */,
4BC559FC1337AC0900E345C7 /* XMPPSCRAMAuth.h in Headers */,
4BC55A011337AC1800E345C7 /* XMPPStanza.h in Headers */,
4BD9BF59134003F700DAB43A /* XMPPRosterItem.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -287,6 +294,7 @@
4BC559FB1337AC0900E345C7 /* XMPPPresence.m in Sources */,
4BC55A001337AC1800E345C7 /* XMPPSCRAMAuth.m in Sources */,
4BC55A021337AC1800E345C7 /* XMPPStanza.m in Sources */,
4BD9BF5A134003F700DAB43A /* XMPPRosterItem.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View file

@ -36,6 +36,7 @@
#import "XMPPIQ.h"
#import "XMPPMessage.h"
#import "XMPPPresence.h"
#import "XMPPRosterItem.h"
#import "XMPPExceptions.h"
#define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind"
@ -631,29 +632,38 @@
assert(0);
for (OFXMLElement *elem in rosterElem.children) {
OFArray *groups;
XMPPRosterItem *rosterItem;
OFMutableArray *groups = [OFMutableArray array];
if (![elem.name isEqual: @"item"] ||
![elem.ns isEqual: NS_ROSTER])
continue;
groups = [elem elementsForName: @"group"
namespace: NS_ROSTER];
rosterItem = [XMPPRosterItem rosterItem];
rosterItem.JID = [XMPPJID JIDWithString:
[rosterElem attributeForName: @"jid"].stringValue];
rosterItem.name =
[rosterElem attributeForName: @"name"].stringValue;
rosterItem.subscription =
[rosterElem attributeForName: @"subscription"].stringValue;
for (OFXMLElement *groupElem in groups) {
OFString *group = groupElem.stringValue;
for (OFXMLElement *groupElem in
[elem elementsForName: @"group"
namespace: NS_ROSTER]) {
OFMutableArray *rosterGroup =
[roster objectForKey: group];
[roster objectForKey: rosterElem.stringValue];
if (rosterGroup == nil) {
rosterGroup = [OFMutableArray array];
[roster setObject: rosterGroup
forKey: group];
forKey: rosterElem.stringValue];
}
[rosterGroup addObject: elem];
[rosterGroup addObject: rosterItem];
}
rosterItem.groups = groups;
if (groups.count == 0) {
OFMutableArray *rosterGroup =
[roster objectForKey: @""];
@ -664,7 +674,7 @@
forKey: @""];
}
[rosterGroup addObject: elem];
[rosterGroup addObject: rosterItem];
}
}

View file

@ -39,9 +39,15 @@
- initWithString: (OFString*)str
{
size_t nodesep, resourcesep;
self = [super init];
size_t nodesep, resourcesep;
if (str == nil) {
[self release];
return nil;
}
nodesep = [str indexOfFirstOccurrenceOfString: @"@"];
resourcesep = [str indexOfFirstOccurrenceOfString: @"/"];

View file

@ -162,7 +162,7 @@
stringValue: from_.fullJID];
}
- (OFString*)from
- (XMPPJID*)from
{
return [[from copy] autorelease];
}
@ -180,7 +180,7 @@
stringValue: to_.fullJID];
}
- (OFString*)to
- (XMPPJID*)to
{
return [[to copy] autorelease];
}