Overview
Comment: | Move all roster handling code to XMPPRoster. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
55e37a4da242fe5f19e676a137a4867c |
User & Date: | js on 2011-04-25 17:48:30 |
Other Links: | manifest | tags |
Context
2011-04-25
| ||
23:04 | Improve +[XMPPStanza stanzaWithElement:]. check-in: 29d84637d6 user: js tags: trunk | |
17:48 | Move all roster handling code to XMPPRoster. check-in: 55e37a4da2 user: js tags: trunk | |
2011-04-23
| ||
22:41 | Correctly handle stream restart. check-in: 758ecec9ee user: js tags: trunk | |
Changes
Modified src/XMPPConnection.h from [2a89c085aa] to [f70626456f].
︙ | |||
80 81 82 83 84 85 86 | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | - + | OFString *username, *password, *server, *resource; XMPPJID *JID; uint16_t port; id <XMPPConnectionDelegate, OFObject> delegate; XMPPAuthenticator *authModule; BOOL needsSession; unsigned int lastID; |
︙ | |||
139 140 141 142 143 144 145 | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | - - - - - | /** * Generates a new, unique stanza ID. * * \return A new, generated, unique stanza ID. */ - (OFString*)generateStanzaID; |
︙ | |||
173 174 175 176 177 178 179 | 168 169 170 171 172 173 174 175 176 177 178 | - | - (void)XMPP_handleMessage: (XMPPMessage*)message; - (void)XMPP_handlePresence: (XMPPPresence*)presence; - (void)XMPP_handleFeatures: (OFXMLElement*)element; - (void)XMPP_sendResourceBind; - (void)XMPP_handleResourceBind: (XMPPIQ*)iq; - (void)XMPP_sendSession; - (void)XMPP_handleSession: (XMPPIQ*)iq; |
Modified src/XMPPConnection.m from [c97c429eb9] to [a3f2e17a8e].
︙ | |||
73 74 75 76 77 78 79 | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | - | [server release]; [resource release]; [JID release]; [delegate release]; [authModule release]; [bindID release]; [sessionID release]; |
︙ | |||
227 228 229 230 231 232 233 | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | - - - - - + + + + - - - + - | if (length < 1 && [delegate respondsToSelector: @selector(connectionWasClosed:)]) [delegate connectionWasClosed: self]; [parser parseBuffer: buffer withLength: length]; |
︙ | |||
564 565 566 567 568 569 570 | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | - - - + + + - | if ([[iq ID] isEqual: sessionID]) { [self XMPP_handleSession: iq]; return; } if ([iq elementForName: @"query" |
︙ | |||
758 759 760 761 762 763 764 | 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | [delegate connection: self wasBoundToJID: JID]; [sessionID release]; sessionID = nil; } |
︙ |
Modified src/XMPPRoster.h from [1f83f6aa00] to [7a403464fd].
︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | + + + + | * POSSIBILITY OF SUCH DAMAGE. */ #import <ObjFW/ObjFW.h> @class XMPPConnection; @class XMPPRosterItem; @class XMPPIQ; @interface XMPPRoster: OFObject { XMPPConnection *connection; OFMutableDictionary *rosterItems; OFString *rosterID; } - initWithConnection: (XMPPConnection*)conn; - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem; - (void)XMPP_updateRosterItem: (XMPPRosterItem*)rosterItem; - (void)XMPP_deleteRosterItem: (XMPPRosterItem*)rosterItem; - (OFDictionary*)rosterItems; - (BOOL)handleIQ: (XMPPIQ*)iq; - (void)requestRoster; - (void)addRosterItem: (XMPPRosterItem*)rosterItem; - (void)updateRosterItem: (XMPPRosterItem*)rosterItem; - (void)deleteRosterItem: (XMPPRosterItem*)rosterItem; @end |
Modified src/XMPPRoster.m from [4eed8628a8] to [e2d29521b2].
︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | + + | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * 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. */ #include <assert.h> #import "XMPPRoster.h" #import "XMPPRosterItem.h" #import "XMPPConnection.h" #import "XMPPIQ.h" #import "XMPPJID.h" |
︙ | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | + + | return self; } - (void)dealloc { [connection release]; [rosterItems release]; [rosterID release]; [super dealloc]; } - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem { return [self XMPP_updateRosterItem: rosterItem]; |
︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | 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 99 100 101 102 103 104 105 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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | [rosterItems removeObjectForKey: [[rosterItem JID] bareJID]]; } - (OFDictionary*)rosterItems { return [[rosterItems copy] autorelease]; } - (void)requestRoster { XMPPIQ *iq; if (rosterID != nil) assert(0); rosterID = [[connection generateStanzaID] retain]; iq = [XMPPIQ IQWithType: @"get" ID: rosterID]; [iq addChild: [OFXMLElement elementWithName: @"query" namespace: XMPP_NS_ROSTER]]; [connection sendStanza: iq]; } - (BOOL)handleIQ: (XMPPIQ*)iq { OFXMLElement *rosterElement; OFXMLElement *element; XMPPRosterItem *rosterItem = nil; OFString *subscription; OFEnumerator *enumerator; BOOL isPush = ![[iq ID] isEqual: rosterID]; rosterElement = [iq elementForName: @"query" namespace: XMPP_NS_ROSTER]; if (rosterElement == nil) return NO; if (isPush) { if (![[iq type] isEqual: @"set"]) return NO; } else { if (![[iq type] isEqual: @"result"]) return NO; } enumerator = [[rosterElement children] objectEnumerator]; while ((element = [enumerator nextObject]) != nil) { OFMutableArray *groups = [OFMutableArray array]; OFEnumerator *groupEnumerator; OFXMLElement *groupElement; if (![[element name] isEqual: @"item"] || ![[element namespace] isEqual: XMPP_NS_ROSTER]) continue; rosterItem = [XMPPRosterItem rosterItem]; [rosterItem setJID: [XMPPJID JIDWithString: [[element attributeForName: @"jid"] stringValue]]]; [rosterItem setName: [[element attributeForName: @"name"] stringValue]]; subscription = [[element attributeForName: @"subscription"] stringValue]; if (![subscription isEqual: @"none"] && ![subscription isEqual: @"to"] && ![subscription isEqual: @"from"] && ![subscription isEqual: @"both"] && (![subscription isEqual: @"remove"] || !isPush)) subscription = @"none"; [rosterItem setSubscription: subscription]; groupEnumerator = [[element elementsForName: @"group" namespace: XMPP_NS_ROSTER] objectEnumerator]; while ((groupElement = [groupEnumerator nextObject]) != nil) [groups addObject: [groupElement stringValue]]; if ([groups count] > 0) [rosterItem setGroups: groups]; if ([subscription isEqual: @"remove"]) [self XMPP_deleteRosterItem: rosterItem]; else [self XMPP_addRosterItem: rosterItem]; if (isPush && [[connection delegate] respondsToSelector: @selector(connection:didReceiveRosterItem:)]) [[connection delegate] connection: connection didReceiveRosterItem: rosterItem]; } if (isPush) { XMPPIQ *response = [XMPPIQ IQWithType: @"result" ID: [iq ID]]; [response setTo: [iq from]]; [connection sendStanza: response]; } else { if ([[connection delegate] respondsToSelector: @selector(connectionDidReceiveRoster:)]) [[connection delegate] connectionDidReceiveRoster: connection]; [rosterID release]; rosterID = nil; } return YES; } - (void)addRosterItem: (XMPPRosterItem*)rosterItem { [self updateRosterItem: rosterItem]; } - (void)updateRosterItem: (XMPPRosterItem*)rosterItem |
︙ |
Modified tests/test.m from [03eb4d2c68] to [f856f65516].
︙ | |||
116 117 118 119 120 121 122 | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | - + | } - (void)connection: (XMPPConnection*)conn wasBoundToJID: (XMPPJID*)jid { of_log(@"Bound to JID: %@", [jid fullJID]); |
︙ |