︙ | | |
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
+
-
+
-
-
+
+
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* 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 "XMPPContactManager.h"
#import "XMPPContact.h"
#import "XMPPContactManager.h"
#import "XMPPContact+Private.h"
#import "XMPPJID.h"
#import "XMPPMulticastDelegate.h"
#import "XMPPPresence.h"
#import "XMPPRosterItem.h"
@implementation XMPPContactManager
@synthesize contacts = _contacts;
- initWithConnection: (XMPPConnection*)connection
roster: (XMPPRoster*)roster
- initWithConnection: (XMPPConnection *)connection
roster: (XMPPRoster *)roster
{
self = [super init];
@try {
_connection = connection;
[_connection addDelegate: self];
_roster = roster;
|
︙ | | |
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
-
+
-
+
-
+
|
[_delegates release];
[_contacts release];
[super dealloc];
}
- (void)sendSubscribedToJID: (XMPPJID*)subscriber
- (void)sendSubscribedToJID: (XMPPJID *)subscriber
{
XMPPPresence *presence = [XMPPPresence presenceWithType: @"subscribed"];
[presence setTo: subscriber];
[_connection sendStanza: presence];
}
- (void)sendUnsubscribedToJID: (XMPPJID*)subscriber
- (void)sendUnsubscribedToJID: (XMPPJID *)subscriber
{
XMPPPresence *presence =
[XMPPPresence presenceWithType: @"unsubscribed"];
[presence setTo: subscriber];
[_connection sendStanza: presence];
}
- (void)addDelegate: (id <XMPPContactManagerDelegate>)delegate
{
[_delegates addDelegate: delegate];
}
- (void)removeDelegate: (id <XMPPContactManagerDelegate>)delegate
{
[_delegates removeDelegate: delegate];
}
- (void)rosterWasReceived: (XMPPRoster*)roster
- (void)rosterWasReceived: (XMPPRoster *)roster
{
OFEnumerator *contactEnumerator;
XMPPContact *contact;
OFDictionary *rosterItems;
OFEnumerator *rosterItemEnumerator;
OFString *bareJID;
|
︙ | | |
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
-
-
+
+
|
[_delegates broadcastSelector: @selector(contactManager:
didAddContact:)
withObject: self
withObject: contact];
}
}
- (void)roster: (XMPPRoster*)roster
didReceiveRosterItem: (XMPPRosterItem*)rosterItem
- (void)roster: (XMPPRoster *)roster
didReceiveRosterItem: (XMPPRosterItem *)rosterItem
{
XMPPContact *contact;
OFString *bareJID = [[rosterItem JID] bareJID];
contact = [_contacts objectForKey: bareJID];
if ([[rosterItem subscription] isEqual: @"remove"]) {
|
︙ | | |
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
-
-
+
+
|
willUpdateWithRosterItem:)
withObject: contact
withObject: rosterItem];
[contact XMPP_setRosterItem: rosterItem];
}
}
- (void)connection: (XMPPConnection*)connection
didReceivePresence: (XMPPPresence*)presence
- (void)connection: (XMPPConnection *)connection
didReceivePresence: (XMPPPresence *)presence
{
XMPPContact *contact;
XMPPJID *JID = [presence from];
OFString *type = [presence type];
/* Subscription request */
if ([type isEqual: @"subscribe"]) {
|
︙ | | |
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
-
-
+
+
|
didSendPresence:)
withObject: contact
withObject: presence];
return;
}
}
- (void)connection: (XMPPConnection*)connection
didReceiveMessage: (XMPPMessage*)message
- (void)connection: (XMPPConnection *)connection
didReceiveMessage: (XMPPMessage *)message
{
XMPPJID *JID = [message from];
XMPPContact *contact = [_contacts objectForKey: [JID bareJID]];
if (contact == nil)
return;
|
︙ | | |