Differences From Artifact [299be9c4c8]:
- File
src/XMPPRoster.m
— part of check-in
[840e61d391]
at
2012-01-30 13:35:50
on branch trunk
— Remove the roster delegate if it gets deallocated.
Maybe it's not a good idea altogether to add/remove the roster
automatically? (user: js, size: 7378) [annotate] [blame] [check-ins using]
To Artifact [eaf6a2879a]:
- File src/XMPPRoster.m — part of check-in [a77ad914f2] at 2012-01-30 17:45:43 on branch trunk — Make use of multicast delegates in XMPPRoster. (user: js, size: 7427) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | { self = [super init]; @try { rosterItems = [[OFMutableDictionary alloc] init]; connection = connection_; [connection addDelegate: self]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [connection removeDelegate: self]; [rosterItems release]; [super dealloc]; } - (OFDictionary*)rosterItems { | > > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | { self = [super init]; @try { rosterItems = [[OFMutableDictionary alloc] init]; connection = connection_; [connection addDelegate: self]; delegates = [[XMPPMulticastDelegate alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [connection removeDelegate: self]; [delegates release]; [rosterItems release]; [super dealloc]; } - (OFDictionary*)rosterItems { |
︙ | ︙ | |||
103 104 105 106 107 108 109 | rosterItem = [self XMPP_rosterItemWithXMLElement: element]; if ([[rosterItem subscription] isEqual: @"remove"]) [self XMPP_deleteRosterItem: rosterItem]; else [self XMPP_addRosterItem: rosterItem]; | | | | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | rosterItem = [self XMPP_rosterItemWithXMLElement: element]; if ([[rosterItem subscription] isEqual: @"remove"]) [self XMPP_deleteRosterItem: rosterItem]; else [self XMPP_addRosterItem: rosterItem]; [delegates broadcastSelector: @selector( roster:didReceiveRosterItem:) withObject: self withObject: rosterItem]; } [connection_ sendStanza: [iq resultIQ]]; return YES; } |
︙ | ︙ | |||
168 169 170 171 172 173 174 | [query addChild: item]; [iq addChild: query]; [connection sendStanza: iq]; } | | | | | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | [query addChild: item]; [iq addChild: query]; [connection sendStanza: iq]; } - (void)addDelegate: (id <XMPPRosterDelegate>)delegate { [delegates addDelegate: delegate]; } - (void)removeDelegate: (id <XMPPRosterDelegate>)delegate { [delegates removeDelegate: delegate]; } - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem { return [self XMPP_updateRosterItem: rosterItem]; } |
︙ | ︙ | |||
254 255 256 257 258 259 260 | if ([[rosterItem subscription] isEqual: @"remove"]) [self XMPP_deleteRosterItem: rosterItem]; else [self XMPP_addRosterItem: rosterItem]; } | | | | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | if ([[rosterItem subscription] isEqual: @"remove"]) [self XMPP_deleteRosterItem: rosterItem]; else [self XMPP_addRosterItem: rosterItem]; } [delegates broadcastSelector: @selector(rosterWasReceived:) withObject: self]; } @end @implementation OFObject (XMPPRosterDelegate) - (void)rosterWasReceived: (XMPPRoster*)roster { } - (void)roster: (XMPPRoster*)roster didReceiveRosterItem: (XMPPRosterItem*)rosterItem { } @end |