Move namespace definitions and add -[XMPPRoster addRosterItem:].

This commit is contained in:
Jonathan Schleifer 2011-03-28 17:30:40 +02:00
parent 902ab046c0
commit 823ea0eb5e
6 changed files with 103 additions and 37 deletions

View file

@ -21,7 +21,11 @@
*/
#import "XMPPRoster.h"
#import "XMPPRoster_private.h"
#import "XMPPRosterItem.h"
#import "XMPPConnection.h"
#import "XMPPIQ.h"
#import "XMPPJID.h"
@implementation XMPPRoster
- initWithConnection: (XMPPConnection*)conn
@ -92,4 +96,30 @@
return [[[groups objectForKey: group] copy] autorelease];
}
- (void)addRosterItem: (XMPPRosterItem*)rosterItem
{
XMPPIQ *iq = [XMPPIQ IQWithType: @"set"
ID: [connection generateStanzaID]];
OFXMLElement *query = [OFXMLElement elementWithName: @"query"
namespace: XMPP_NS_ROSTER];
OFXMLElement *item = [OFXMLElement elementWithName: @"item"
namespace: XMPP_NS_ROSTER];
[item addAttributeWithName: @"jid"
stringValue: rosterItem.JID.bareJID];
if (rosterItem.name != nil)
[item addAttributeWithName: @"name"
stringValue: rosterItem.name];
for (OFString *group in rosterItem.groups)
[item addChild: [OFXMLElement elementWithName: @"group"
namespace: XMPP_NS_ROSTER
stringValue: group]];
[query addChild: item];
[iq addChild: query];
[connection sendStanza: iq];
}
@end