Overview
Comment: | Add XMPPRoster class. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
010bd227d2544029c5d338fe6a2cf169 |
User & Date: | js on 2011-03-28 13:14:27 |
Other Links: | manifest | tags |
Context
2011-03-28
| ||
13:56 | gcc 4.6 does not seem to create implicit ivars. check-in: 5a9500d050 user: js tags: trunk | |
13:14 | Add XMPPRoster class. check-in: 010bd227d2 user: js tags: trunk | |
2011-03-27
| ||
23:55 | Add autorelease pools. check-in: 69621da29a user: js tags: trunk | |
Changes
Modified ObjXMPP.xcodeproj/project.pbxproj from [f446e9346b] to [af2addadc8].
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 4BC559FB1337AC0900E345C7 /* XMPPPresence.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559E91337AC0900E345C7 /* XMPPPresence.m */; }; 4BC559FC1337AC0900E345C7 /* XMPPSCRAMAuth.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BC55A001337AC1800E345C7 /* XMPPSCRAMAuth.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */; }; 4BC55A011337AC1800E345C7 /* XMPPStanza.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559FE1337AC1800E345C7 /* XMPPStanza.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BC55A021337AC1800E345C7 /* XMPPStanza.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559FF1337AC1800E345C7 /* XMPPStanza.m */; }; 4BD9BF59134003F700DAB43A /* XMPPRosterItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */; }; 4BD9BF5A134003F700DAB43A /* XMPPRosterItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ 4B1295DE1337BD2D00154B25 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = /usr/share/man/man1/; | > > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 4BC559FB1337AC0900E345C7 /* XMPPPresence.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559E91337AC0900E345C7 /* XMPPPresence.m */; }; 4BC559FC1337AC0900E345C7 /* XMPPSCRAMAuth.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BC55A001337AC1800E345C7 /* XMPPSCRAMAuth.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */; }; 4BC55A011337AC1800E345C7 /* XMPPStanza.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559FE1337AC1800E345C7 /* XMPPStanza.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4BC55A021337AC1800E345C7 /* XMPPStanza.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BC559FF1337AC1800E345C7 /* XMPPStanza.m */; }; 4BD9BF59134003F700DAB43A /* XMPPRosterItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */; }; 4BD9BF5A134003F700DAB43A /* XMPPRosterItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */; }; 4BDEF8071340B240000156D1 /* XMPPRoster.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BDEF8051340B240000156D1 /* XMPPRoster.h */; }; 4BDEF8081340B240000156D1 /* XMPPRoster.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BDEF8061340B240000156D1 /* XMPPRoster.m */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ 4B1295DE1337BD2D00154B25 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = /usr/share/man/man1/; |
︙ | ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 88 | 4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPSCRAMAuth.h; path = src/XMPPSCRAMAuth.h; sourceTree = SOURCE_ROOT; }; 4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPSCRAMAuth.m; path = src/XMPPSCRAMAuth.m; sourceTree = SOURCE_ROOT; }; 4BC559FE1337AC1800E345C7 /* XMPPStanza.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPStanza.h; path = src/XMPPStanza.h; sourceTree = SOURCE_ROOT; }; 4BC559FF1337AC1800E345C7 /* XMPPStanza.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPStanza.m; path = src/XMPPStanza.m; sourceTree = SOURCE_ROOT; }; 4BC55A051337ADA800E345C7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; 4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPRosterItem.h; path = src/XMPPRosterItem.h; sourceTree = SOURCE_ROOT; }; 4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPRosterItem.m; path = src/XMPPRosterItem.m; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 4B1295DD1337BD2D00154B25 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( | > > | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | 4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPSCRAMAuth.h; path = src/XMPPSCRAMAuth.h; sourceTree = SOURCE_ROOT; }; 4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPSCRAMAuth.m; path = src/XMPPSCRAMAuth.m; sourceTree = SOURCE_ROOT; }; 4BC559FE1337AC1800E345C7 /* XMPPStanza.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPStanza.h; path = src/XMPPStanza.h; sourceTree = SOURCE_ROOT; }; 4BC559FF1337AC1800E345C7 /* XMPPStanza.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPStanza.m; path = src/XMPPStanza.m; sourceTree = SOURCE_ROOT; }; 4BC55A051337ADA800E345C7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; 4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPRosterItem.h; path = src/XMPPRosterItem.h; sourceTree = SOURCE_ROOT; }; 4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPRosterItem.m; path = src/XMPPRosterItem.m; sourceTree = SOURCE_ROOT; }; 4BDEF8051340B240000156D1 /* XMPPRoster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPRoster.h; path = src/XMPPRoster.h; sourceTree = SOURCE_ROOT; }; 4BDEF8061340B240000156D1 /* XMPPRoster.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPRoster.m; path = src/XMPPRoster.m; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 4B1295DD1337BD2D00154B25 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( |
︙ | ︙ | |||
155 156 157 158 159 160 161 162 163 164 165 166 167 168 | 4BC559E31337AC0900E345C7 /* XMPPJID.m */, 4BC559E41337AC0900E345C7 /* XMPPMessage.h */, 4BC559E51337AC0900E345C7 /* XMPPMessage.m */, 4BC559E61337AC0900E345C7 /* XMPPPLAINAuth.h */, 4BC559E71337AC0900E345C7 /* XMPPPLAINAuth.m */, 4BC559E81337AC0900E345C7 /* XMPPPresence.h */, 4BC559E91337AC0900E345C7 /* XMPPPresence.m */, 4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */, 4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */, 4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */, 4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */, 4BC559FE1337AC1800E345C7 /* XMPPStanza.h */, 4BC559FF1337AC1800E345C7 /* XMPPStanza.m */, 4BC559D91337AC0900E345C7 /* arc4random_uniform.m */, | > > | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | 4BC559E31337AC0900E345C7 /* XMPPJID.m */, 4BC559E41337AC0900E345C7 /* XMPPMessage.h */, 4BC559E51337AC0900E345C7 /* XMPPMessage.m */, 4BC559E61337AC0900E345C7 /* XMPPPLAINAuth.h */, 4BC559E71337AC0900E345C7 /* XMPPPLAINAuth.m */, 4BC559E81337AC0900E345C7 /* XMPPPresence.h */, 4BC559E91337AC0900E345C7 /* XMPPPresence.m */, 4BDEF8051340B240000156D1 /* XMPPRoster.h */, 4BDEF8061340B240000156D1 /* XMPPRoster.m */, 4BD9BF57134003F700DAB43A /* XMPPRosterItem.h */, 4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */, 4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */, 4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */, 4BC559FE1337AC1800E345C7 /* XMPPStanza.h */, 4BC559FF1337AC1800E345C7 /* XMPPStanza.m */, 4BC559D91337AC0900E345C7 /* arc4random_uniform.m */, |
︙ | ︙ | |||
192 193 194 195 196 197 198 199 200 201 202 203 204 205 | 4BC559F41337AC0900E345C7 /* XMPPJID.h in Headers */, 4BC559F61337AC0900E345C7 /* XMPPMessage.h in Headers */, 4BC559F81337AC0900E345C7 /* XMPPPLAINAuth.h in Headers */, 4BC559FA1337AC0900E345C7 /* XMPPPresence.h in Headers */, 4BC559FC1337AC0900E345C7 /* XMPPSCRAMAuth.h in Headers */, 4BC55A011337AC1800E345C7 /* XMPPStanza.h in Headers */, 4BD9BF59134003F700DAB43A /* XMPPRosterItem.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 4B1295DF1337BD2D00154B25 /* ObjXMPPTests */ = { | > | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | 4BC559F41337AC0900E345C7 /* XMPPJID.h in Headers */, 4BC559F61337AC0900E345C7 /* XMPPMessage.h in Headers */, 4BC559F81337AC0900E345C7 /* XMPPPLAINAuth.h in Headers */, 4BC559FA1337AC0900E345C7 /* XMPPPresence.h in Headers */, 4BC559FC1337AC0900E345C7 /* XMPPSCRAMAuth.h in Headers */, 4BC55A011337AC1800E345C7 /* XMPPStanza.h in Headers */, 4BD9BF59134003F700DAB43A /* XMPPRosterItem.h in Headers */, 4BDEF8071340B240000156D1 /* XMPPRoster.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ 4B1295DF1337BD2D00154B25 /* ObjXMPPTests */ = { |
︙ | ︙ | |||
291 292 293 294 295 296 297 298 299 300 301 302 303 304 | 4BC559F51337AC0900E345C7 /* XMPPJID.m in Sources */, 4BC559F71337AC0900E345C7 /* XMPPMessage.m in Sources */, 4BC559F91337AC0900E345C7 /* XMPPPLAINAuth.m in Sources */, 4BC559FB1337AC0900E345C7 /* XMPPPresence.m in Sources */, 4BC55A001337AC1800E345C7 /* XMPPSCRAMAuth.m in Sources */, 4BC55A021337AC1800E345C7 /* XMPPStanza.m in Sources */, 4BD9BF5A134003F700DAB43A /* XMPPRosterItem.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ 4B1295EA1337BD2D00154B25 /* Debug */ = { | > | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | 4BC559F51337AC0900E345C7 /* XMPPJID.m in Sources */, 4BC559F71337AC0900E345C7 /* XMPPMessage.m in Sources */, 4BC559F91337AC0900E345C7 /* XMPPPLAINAuth.m in Sources */, 4BC559FB1337AC0900E345C7 /* XMPPPresence.m in Sources */, 4BC55A001337AC1800E345C7 /* XMPPSCRAMAuth.m in Sources */, 4BC55A021337AC1800E345C7 /* XMPPStanza.m in Sources */, 4BD9BF5A134003F700DAB43A /* XMPPRosterItem.m in Sources */, 4BDEF8081340B240000156D1 /* XMPPRoster.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ 4B1295EA1337BD2D00154B25 /* Debug */ = { |
︙ | ︙ |
Modified src/XMPPConnection.h from [f58e7a76cd] to [efa53c7c60].
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | @class XMPPConnection; @class XMPPJID; @class XMPPIQ; @class XMPPMessage; @class XMPPPresence; @class XMPPAuthenticator; @protocol XMPPConnectionDelegate @optional - (void)connectionWasAuthenticated: (XMPPConnection*)conn; - (void)connection: (XMPPConnection*)conn wasBoundToJID: (XMPPJID*)jid; - (void)connectionDidReceiveRoster: (XMPPConnection*)conn; | > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | @class XMPPConnection; @class XMPPJID; @class XMPPIQ; @class XMPPMessage; @class XMPPPresence; @class XMPPAuthenticator; @class XMPPRoster; @protocol XMPPConnectionDelegate @optional - (void)connectionWasAuthenticated: (XMPPConnection*)conn; - (void)connection: (XMPPConnection*)conn wasBoundToJID: (XMPPJID*)jid; - (void)connectionDidReceiveRoster: (XMPPConnection*)conn; |
︙ | ︙ | |||
60 61 62 63 64 65 66 | /// Whether to use TLS BOOL useTLS; id <XMPPConnectionDelegate, OFObject> delegate; XMPPAuthenticator *authModule; BOOL needsSession; unsigned int lastID; OFString *bindID, *sessionID, *rosterID; | | | | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | /// Whether to use TLS BOOL useTLS; id <XMPPConnectionDelegate, OFObject> delegate; XMPPAuthenticator *authModule; BOOL needsSession; unsigned int lastID; OFString *bindID, *sessionID, *rosterID; XMPPRoster *roster; } @property (copy) OFString *username, *password, *server, *resource; @property (copy, readonly) XMPPJID *JID; @property (assign) uint16_t port; @property (assign) BOOL useTLS; @property (retain) id <XMPPConnectionDelegate> delegate; @property (readonly, retain) XMPPRoster *roster; /** * Connects to the XMPP service. */ - (void)connect; /** |
︙ | ︙ |
Modified src/XMPPConnection.m from [c3167bab5a] to [ff0b9d6b21].
︙ | ︙ | |||
32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #import "XMPPSCRAMAuth.h" #import "XMPPPLAINAuth.h" #import "XMPPStanza.h" #import "XMPPJID.h" #import "XMPPIQ.h" #import "XMPPMessage.h" #import "XMPPPresence.h" #import "XMPPRosterItem.h" #import "XMPPExceptions.h" #define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind" #define NS_CLIENT @"jabber:client" #define NS_ROSTER @"jabber:iq:roster" #define NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl" | > | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #import "XMPPSCRAMAuth.h" #import "XMPPPLAINAuth.h" #import "XMPPStanza.h" #import "XMPPJID.h" #import "XMPPIQ.h" #import "XMPPMessage.h" #import "XMPPPresence.h" #import "XMPPRoster.h" #import "XMPPRosterItem.h" #import "XMPPExceptions.h" #define NS_BIND @"urn:ietf:params:xml:ns:xmpp-bind" #define NS_CLIENT @"jabber:client" #define NS_ROSTER @"jabber:iq:roster" #define NS_SASL @"urn:ietf:params:xml:ns:xmpp-sasl" |
︙ | ︙ | |||
77 78 79 80 81 82 83 | port = 5222; useTLS = YES; parser.delegate = self; elementBuilder.delegate = self; | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | port = 5222; useTLS = YES; parser.delegate = self; elementBuilder.delegate = self; roster = [[XMPPRoster alloc] initWithConnection: self]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
485 486 487 488 489 490 491 | if (starttls != nil) { [self sendStanza: [OFXMLElement elementWithName: @"starttls" namespace: NS_STARTTLS]]; return; } | | | 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | if (starttls != nil) { [self sendStanza: [OFXMLElement elementWithName: @"starttls" namespace: NS_STARTTLS]]; return; } if (mechs.count > 0) { for (OFXMLElement *mech in [mechs.firstObject children]) [mechanisms addObject: [mech.children.firstObject stringValue]]; if ([mechanisms containsObject: @"SCRAM-SHA-1"]) { authModule = [[XMPPSCRAMAuth alloc] initWithAuthcid: username |
︙ | ︙ | |||
650 651 652 653 654 655 656 | if (![elem.name isEqual: @"item"] || ![elem.ns isEqual: NS_ROSTER]) continue; rosterItem = [XMPPRosterItem rosterItem]; rosterItem.JID = [XMPPJID JIDWithString: | | < | | | < < | < < < < < | < | | | < < < < < < < < < < | < | 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | if (![elem.name isEqual: @"item"] || ![elem.ns isEqual: NS_ROSTER]) continue; rosterItem = [XMPPRosterItem rosterItem]; rosterItem.JID = [XMPPJID JIDWithString: [elem attributeForName: @"jid"].stringValue]; rosterItem.name = [elem attributeForName: @"name"].stringValue; rosterItem.subscription = [elem attributeForName: @"subscription"].stringValue; for (OFXMLElement *groupElem in [elem elementsForName: @"group" namespace: NS_ROSTER]) [groups addObject: [groupElem.children.firstObject stringValue]]; if (groups.count > 0) rosterItem.groups = groups; [roster XMPP_addRosterItem: rosterItem]; } if ([delegate respondsToSelector: @selector(connectionDidReceiveRoster:)]) [delegate connectionDidReceiveRoster: self]; [rosterID release]; rosterID = nil; } @end |
Modified src/XMPPJID.m from [abcbfecd4e] to [d13b6bf988].
︙ | ︙ | |||
197 198 199 200 201 202 203 204 | if (node != nil) return [OFString stringWithFormat: @"%@@%@/%@", node, domain, resource]; else return [OFString stringWithFormat: @"%@/%@", domain, resource]; } @end | > > > > > | 197 198 199 200 201 202 203 204 205 206 207 208 209 | if (node != nil) return [OFString stringWithFormat: @"%@@%@/%@", node, domain, resource]; else return [OFString stringWithFormat: @"%@/%@", domain, resource]; } - (OFString*)description { return [self fullJID]; } @end |
Added src/XMPPRoster.h version [bf1a5ace38].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * Copyright (c) 2011, Jonathan Schleifer <js@webkeks.org> * * https://webkeks.org/hg/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice is present in all copies. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 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. */ #import <ObjFW/ObjFW.h> @class XMPPConnection; @class XMPPRosterItem; @interface XMPPRoster: OFObject { XMPPConnection *connection; OFMutableDictionary *groups; } - initWithConnection: (XMPPConnection*)conn; - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem; - (OFArray*)groups; - (OFArray*)rosterItemsInGroup: (OFString*)group; @end |
Added src/XMPPRoster.m version [91d328c416].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 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 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 | /* * Copyright (c) 2011, Jonathan Schleifer <js@webkeks.org> * * https://webkeks.org/hg/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice is present in all copies. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 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. */ #import "XMPPRoster.h" #import "XMPPRosterItem.h" @implementation XMPPRoster - initWithConnection: (XMPPConnection*)conn { self = [super init]; @try { connection = [conn retain]; groups = [[OFMutableDictionary alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [connection release]; [super dealloc]; } - (void)XMPP_addRosterItem: (XMPPRosterItem*)rosterItem { if (rosterItem.groups.count > 0) { for (OFString *group in rosterItem.groups) { OFMutableArray *rosterGroup = [groups objectForKey: group]; if (rosterGroup == nil) { rosterGroup = [OFMutableArray array]; [groups setObject: rosterGroup forKey: group]; } [rosterGroup addObject: rosterItem]; } } else { OFMutableArray *rosterGroup = [groups objectForKey: @""]; if (rosterGroup == nil) { rosterGroup = [OFMutableArray array]; [groups setObject: rosterGroup forKey: @""]; } [rosterGroup addObject: rosterItem]; } } - (OFArray*)groups { OFMutableArray *ret = [OFMutableArray array]; for (OFString *group in groups) [ret addObject: group]; ret->isa = [OFArray class]; return ret; } - (OFArray*)rosterItemsInGroup: (OFString*)group { if (group == nil) group = @""; return [[[groups objectForKey: group] copy] autorelease]; } @end |
Added src/XMPPRosterItem.h version [8f1d733b5b].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright (c) 2011, Jonathan Schleifer <js@webkeks.org> * * https://webkeks.org/hg/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice is present in all copies. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 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. */ #import <ObjFW/ObjFW.h> @class XMPPJID; @interface XMPPRosterItem: OFObject @property (copy) XMPPJID *JID; @property (copy) OFString *name; @property (copy) OFString *subscription; @property (copy) OFArray *groups; + rosterItem; @end |
Added src/XMPPRosterItem.m version [ce2010eba9].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | /* * Copyright (c) 2011, Jonathan Schleifer <js@webkeks.org> * * https://webkeks.org/hg/objxmpp/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice is present in all copies. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * 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. */ #import "XMPPRosterItem.h" @implementation XMPPRosterItem @synthesize JID, name, subscription, groups; + rosterItem { return [[[self alloc] init] autorelease]; } - (OFString*)description { return [OFString stringWithFormat: @"<XMPPRosterItem, JID=%@, name=%@, " @"subscription=%@, groups=%@>", JID, name, subscription, groups]; } @end |
Modified tests/test.m from [0b259b0e5c] to [fff72eb7c7].
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #import "XMPPConnection.h" #import "XMPPJID.h" #import "XMPPStanza.h" #import "XMPPIQ.h" #import "XMPPMessage.h" #import "XMPPPresence.h" @interface AppDelegate: OFObject <OFApplicationDelegate, XMPPConnectionDelegate> @end OF_APPLICATION_DELEGATE(AppDelegate) @implementation AppDelegate | > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #import "XMPPConnection.h" #import "XMPPJID.h" #import "XMPPStanza.h" #import "XMPPIQ.h" #import "XMPPMessage.h" #import "XMPPPresence.h" #import "XMPPRoster.h" @interface AppDelegate: OFObject <OFApplicationDelegate, XMPPConnectionDelegate> @end OF_APPLICATION_DELEGATE(AppDelegate) @implementation AppDelegate |
︙ | ︙ | |||
116 117 118 119 120 121 122 | [conn requestRoster]; } - (void)connectionDidReceiveRoster :(XMPPConnection*)conn { XMPPPresence *pres; | | > > > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | [conn requestRoster]; } - (void)connectionDidReceiveRoster :(XMPPConnection*)conn { XMPPPresence *pres; of_log(@"Got roster! Groups: %@", conn.roster.groups); for (OFString *group in conn.roster.groups) of_log(@"Group %@: %@", group, [conn.roster rosterItemsInGroup: group]); pres = [XMPPPresence presence]; [pres addPriority: 10]; [pres addStatus: @"ObjXMPP test is working!"]; [conn sendStanza: pres]; } |
︙ | ︙ |