32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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
84
85
86
87
88
89
90
91
|
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 = [[OFMutableDictionary alloc] init];
roster = [[XMPPRoster alloc] initWithConnection: self];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
|
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) {
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
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
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
|
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:
[rosterElem attributeForName: @"jid"].stringValue];
[elem attributeForName: @"jid"].stringValue];
rosterItem.name =
[rosterElem attributeForName: @"name"].stringValue;
rosterItem.name = [elem attributeForName: @"name"].stringValue;
rosterItem.subscription =
[rosterElem attributeForName: @"subscription"].stringValue;
[elem attributeForName: @"subscription"].stringValue;
for (OFXMLElement *groupElem in
[elem elementsForName: @"group"
namespace: NS_ROSTER]) {
namespace: NS_ROSTER])
OFMutableArray *rosterGroup =
[roster objectForKey: rosterElem.stringValue];
[groups addObject:
if (rosterGroup == nil) {
rosterGroup = [OFMutableArray array];
[roster setObject: rosterGroup
forKey: rosterElem.stringValue];
}
[groupElem.children.firstObject stringValue]];
[rosterGroup addObject: rosterItem];
}
rosterItem.groups = groups;
if (groups.count > 0)
rosterItem.groups = groups;
if (groups.count == 0) {
OFMutableArray *rosterGroup =
[roster objectForKey: @""];
if (rosterGroup == nil) {
rosterGroup = [OFMutableArray array];
[roster setObject: rosterGroup
forKey: @""];
}
[rosterGroup addObject: rosterItem];
[roster XMPP_addRosterItem: rosterItem];
}
}
if ([delegate respondsToSelector:
@selector(connectionDidReceiveRoster:)])
[delegate connectionDidReceiveRoster: self];
[rosterID release];
rosterID = nil;
}
@end
|