Add -[XMPPRoster deleteRosterItem:] and -[XMPPRosterItem copy].
This commit is contained in:
parent
823ea0eb5e
commit
993d0a7596
3 changed files with 44 additions and 0 deletions
|
@ -35,4 +35,6 @@
|
||||||
- (OFArray*)groups;
|
- (OFArray*)groups;
|
||||||
- (OFArray*)rosterItemsInGroup: (OFString*)group;
|
- (OFArray*)rosterItemsInGroup: (OFString*)group;
|
||||||
- (void)addRosterItem: (XMPPRosterItem*)rosterItem;
|
- (void)addRosterItem: (XMPPRosterItem*)rosterItem;
|
||||||
|
- (void)updateRosterItem: (XMPPRosterItem*)rosterItem;
|
||||||
|
- (void)deleteRosterItem: (XMPPRosterItem*)rosterItem;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -98,6 +98,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addRosterItem: (XMPPRosterItem*)rosterItem
|
- (void)addRosterItem: (XMPPRosterItem*)rosterItem
|
||||||
|
{
|
||||||
|
[self updateRosterItem: rosterItem];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)updateRosterItem: (XMPPRosterItem*)rosterItem
|
||||||
{
|
{
|
||||||
XMPPIQ *iq = [XMPPIQ IQWithType: @"set"
|
XMPPIQ *iq = [XMPPIQ IQWithType: @"set"
|
||||||
ID: [connection generateStanzaID]];
|
ID: [connection generateStanzaID]];
|
||||||
|
@ -122,4 +127,24 @@
|
||||||
|
|
||||||
[connection sendStanza: iq];
|
[connection sendStanza: iq];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)deleteRosterItem: (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];
|
||||||
|
[item addAttributeWithName: @"subscription"
|
||||||
|
stringValue: @"remove"];
|
||||||
|
|
||||||
|
[query addChild: item];
|
||||||
|
[iq addChild: query];
|
||||||
|
|
||||||
|
[connection sendStanza: iq];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -30,6 +30,23 @@
|
||||||
return [[[self alloc] init] autorelease];
|
return [[[self alloc] init] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- copy
|
||||||
|
{
|
||||||
|
XMPPRosterItem *new = [[XMPPRosterItem alloc] init];
|
||||||
|
|
||||||
|
@try {
|
||||||
|
new->JID = [JID copy];
|
||||||
|
new->name = [name copy];
|
||||||
|
new->subscription = [subscription copy];
|
||||||
|
new->groups = [groups copy];
|
||||||
|
} @catch (id e) {
|
||||||
|
[new release];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
- (OFString*)description
|
- (OFString*)description
|
||||||
{
|
{
|
||||||
return [OFString stringWithFormat: @"<XMPPRosterItem, JID=%@, name=%@, "
|
return [OFString stringWithFormat: @"<XMPPRosterItem, JID=%@, name=%@, "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue