︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#import "XMPPRoster.h"
#import "XMPPRoster_private.h"
#import "XMPPRosterItem.h"
#import "XMPPConnection.h"
#import "XMPPIQ.h"
#import "XMPPJID.h"
@implementation XMPPRoster
- initWithConnection: (XMPPConnection*)conn
|
︙ | | |
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
-
-
+
+
+
+
+
+
|
[connection release];
[super dealloc];
}
- (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem
{
if (rosterItem.groups.count > 0) {
for (OFString *group in rosterItem.groups) {
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];
|
︙ | | |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
+
+
-
+
+
|
[rosterGroup addObject: rosterItem];
}
}
- (OFArray*)groups
{
OFMutableArray *ret = [OFMutableArray array];
OFEnumerator *enumerator;
OFString *group;
for (OFString *group in groups)
enumerator = [groups keyEnumerator];
while ((group = [enumerator nextObject]) != nil)
[ret addObject: group];
ret->isa = [OFArray class];
return ret;
}
- (OFArray*)rosterItemsInGroup: (OFString*)group
|
︙ | | |
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
+
+
-
-
+
+
-
+
-
+
+
-
+
|
{
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];
OFEnumerator *enumerator;
OFString *group;
[item addAttributeWithName: @"jid"
stringValue: rosterItem.JID.bareJID];
if (rosterItem.name != nil)
stringValue: [[rosterItem JID] bareJID]];
if ([rosterItem name] != nil)
[item addAttributeWithName: @"name"
stringValue: rosterItem.name];
stringValue: [rosterItem name]];
for (OFString *group in rosterItem.groups)
enumerator = [[rosterItem groups] objectEnumerator];
while ((group = [enumerator nextObject]) != nil)
[item addChild: [OFXMLElement elementWithName: @"group"
namespace: XMPP_NS_ROSTER
stringValue: group]];
[query addChild: item];
[iq addChild: query];
[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];
stringValue: [[rosterItem JID] bareJID]];
[item addAttributeWithName: @"subscription"
stringValue: @"remove"];
[query addChild: item];
[iq addChild: query];
[connection sendStanza: iq];
}
@end
|