Split XMPPSRVEnumerator into XMPPSRVLookup and XMPPSRVEnumerator.
This commit is contained in:
parent
1337fdded1
commit
d15fd9971c
5 changed files with 55 additions and 28 deletions
|
@ -11,8 +11,8 @@
|
||||||
4B1295EF1337BD5F00154B25 /* test.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B1295EE1337BD5F00154B25 /* test.m */; };
|
4B1295EF1337BD5F00154B25 /* test.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B1295EE1337BD5F00154B25 /* test.m */; };
|
||||||
4B1295F11337C37E00154B25 /* ObjXMPP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559911337A65400E345C7 /* ObjXMPP.framework */; };
|
4B1295F11337C37E00154B25 /* ObjXMPP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559911337A65400E345C7 /* ObjXMPP.framework */; };
|
||||||
4B1295F21337C3CF00154B25 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559D61337ABD300E345C7 /* ObjFW.framework */; };
|
4B1295F21337C3CF00154B25 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559D61337ABD300E345C7 /* ObjFW.framework */; };
|
||||||
4B4844F5138BBC7500EB48A5 /* XMPPSRVEnumerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B4844F3138BBC7400EB48A5 /* XMPPSRVEnumerator.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
4B4844F5138BBC7500EB48A5 /* XMPPSRVLookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B4844F3138BBC7400EB48A5 /* XMPPSRVLookup.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
4B4844F6138BBC7500EB48A5 /* XMPPSRVEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B4844F4138BBC7500EB48A5 /* XMPPSRVEnumerator.m */; };
|
4B4844F6138BBC7500EB48A5 /* XMPPSRVLookup.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B4844F4138BBC7500EB48A5 /* XMPPSRVLookup.m */; };
|
||||||
4B484501138BBEEB00EB48A5 /* libresolv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B484500138BBEEB00EB48A5 /* libresolv.dylib */; };
|
4B484501138BBEEB00EB48A5 /* libresolv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B484500138BBEEB00EB48A5 /* libresolv.dylib */; };
|
||||||
4BC559D71337ABD300E345C7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559D61337ABD300E345C7 /* ObjFW.framework */; };
|
4BC559D71337ABD300E345C7 /* ObjFW.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC559D61337ABD300E345C7 /* ObjFW.framework */; };
|
||||||
4BC559EC1337AC0900E345C7 /* XMPPAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559DA1337AC0900E345C7 /* XMPPAuthenticator.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
4BC559EC1337AC0900E345C7 /* XMPPAuthenticator.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BC559DA1337AC0900E345C7 /* XMPPAuthenticator.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
@ -59,8 +59,8 @@
|
||||||
4B01D01F137C7E7D005624EA /* namespaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = namespaces.h; path = src/namespaces.h; sourceTree = SOURCE_ROOT; };
|
4B01D01F137C7E7D005624EA /* namespaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = namespaces.h; path = src/namespaces.h; sourceTree = SOURCE_ROOT; };
|
||||||
4B1295E01337BD2D00154B25 /* ObjXMPPTests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ObjXMPPTests; sourceTree = BUILT_PRODUCTS_DIR; };
|
4B1295E01337BD2D00154B25 /* ObjXMPPTests */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ObjXMPPTests; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
4B1295EE1337BD5F00154B25 /* test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = test.m; path = tests/test.m; sourceTree = SOURCE_ROOT; };
|
4B1295EE1337BD5F00154B25 /* test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = test.m; path = tests/test.m; sourceTree = SOURCE_ROOT; };
|
||||||
4B4844F3138BBC7400EB48A5 /* XMPPSRVEnumerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPSRVEnumerator.h; path = src/XMPPSRVEnumerator.h; sourceTree = SOURCE_ROOT; };
|
4B4844F3138BBC7400EB48A5 /* XMPPSRVLookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XMPPSRVLookup.h; path = src/XMPPSRVLookup.h; sourceTree = SOURCE_ROOT; };
|
||||||
4B4844F4138BBC7500EB48A5 /* XMPPSRVEnumerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPSRVEnumerator.m; path = src/XMPPSRVEnumerator.m; sourceTree = SOURCE_ROOT; };
|
4B4844F4138BBC7500EB48A5 /* XMPPSRVLookup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XMPPSRVLookup.m; path = src/XMPPSRVLookup.m; sourceTree = SOURCE_ROOT; };
|
||||||
4B484500138BBEEB00EB48A5 /* libresolv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libresolv.dylib; path = usr/lib/libresolv.dylib; sourceTree = SDKROOT; };
|
4B484500138BBEEB00EB48A5 /* libresolv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libresolv.dylib; path = usr/lib/libresolv.dylib; sourceTree = SDKROOT; };
|
||||||
4BC559911337A65400E345C7 /* ObjXMPP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ObjXMPP.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
4BC559911337A65400E345C7 /* ObjXMPP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ObjXMPP.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
4BC559D61337ABD300E345C7 /* ObjFW.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFW.framework; path = ../../../../Library/Frameworks/ObjFW.framework; sourceTree = "<group>"; };
|
4BC559D61337ABD300E345C7 /* ObjFW.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ObjFW.framework; path = ../../../../Library/Frameworks/ObjFW.framework; sourceTree = "<group>"; };
|
||||||
|
@ -186,8 +186,8 @@
|
||||||
4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */,
|
4BD9BF58134003F700DAB43A /* XMPPRosterItem.m */,
|
||||||
4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */,
|
4BC559EA1337AC0900E345C7 /* XMPPSCRAMAuth.h */,
|
||||||
4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */,
|
4BC559FD1337AC1800E345C7 /* XMPPSCRAMAuth.m */,
|
||||||
4B4844F3138BBC7400EB48A5 /* XMPPSRVEnumerator.h */,
|
4B4844F3138BBC7400EB48A5 /* XMPPSRVLookup.h */,
|
||||||
4B4844F4138BBC7500EB48A5 /* XMPPSRVEnumerator.m */,
|
4B4844F4138BBC7500EB48A5 /* XMPPSRVLookup.m */,
|
||||||
4BC559FE1337AC1800E345C7 /* XMPPStanza.h */,
|
4BC559FE1337AC1800E345C7 /* XMPPStanza.h */,
|
||||||
4BC559FF1337AC1800E345C7 /* XMPPStanza.m */,
|
4BC559FF1337AC1800E345C7 /* XMPPStanza.m */,
|
||||||
4B01D01F137C7E7D005624EA /* namespaces.h */,
|
4B01D01F137C7E7D005624EA /* namespaces.h */,
|
||||||
|
@ -222,7 +222,7 @@
|
||||||
4BDEF8071340B240000156D1 /* XMPPRoster.h in Headers */,
|
4BDEF8071340B240000156D1 /* XMPPRoster.h in Headers */,
|
||||||
4BD9BF59134003F700DAB43A /* XMPPRosterItem.h in Headers */,
|
4BD9BF59134003F700DAB43A /* XMPPRosterItem.h in Headers */,
|
||||||
4BC559FC1337AC0900E345C7 /* XMPPSCRAMAuth.h in Headers */,
|
4BC559FC1337AC0900E345C7 /* XMPPSCRAMAuth.h in Headers */,
|
||||||
4B4844F5138BBC7500EB48A5 /* XMPPSRVEnumerator.h in Headers */,
|
4B4844F5138BBC7500EB48A5 /* XMPPSRVLookup.h in Headers */,
|
||||||
4BC55A011337AC1800E345C7 /* XMPPStanza.h in Headers */,
|
4BC55A011337AC1800E345C7 /* XMPPStanza.h in Headers */,
|
||||||
4B01D020137C7E7D005624EA /* namespaces.h in Headers */,
|
4B01D020137C7E7D005624EA /* namespaces.h in Headers */,
|
||||||
);
|
);
|
||||||
|
@ -324,7 +324,7 @@
|
||||||
4BC55A021337AC1800E345C7 /* XMPPStanza.m in Sources */,
|
4BC55A021337AC1800E345C7 /* XMPPStanza.m in Sources */,
|
||||||
4BD9BF5A134003F700DAB43A /* XMPPRosterItem.m in Sources */,
|
4BD9BF5A134003F700DAB43A /* XMPPRosterItem.m in Sources */,
|
||||||
4BDEF8081340B240000156D1 /* XMPPRoster.m in Sources */,
|
4BDEF8081340B240000156D1 /* XMPPRoster.m in Sources */,
|
||||||
4B4844F6138BBC7500EB48A5 /* XMPPSRVEnumerator.m in Sources */,
|
4B4844F6138BBC7500EB48A5 /* XMPPSRVLookup.m in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,7 @@ SRCS = XMPPAuthenticator.m \
|
||||||
XMPPRoster.m \
|
XMPPRoster.m \
|
||||||
XMPPRosterItem.m \
|
XMPPRosterItem.m \
|
||||||
XMPPSCRAMAuth.m \
|
XMPPSCRAMAuth.m \
|
||||||
XMPPSRVEnumerator.m \
|
XMPPSRVLookup.m \
|
||||||
XMPPStanza.m
|
XMPPStanza.m
|
||||||
|
|
||||||
INCLUDES = ${SRCS:.m=.h} \
|
INCLUDES = ${SRCS:.m=.h} \
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#import <ObjOpenSSL/SSLSocket.h>
|
#import <ObjOpenSSL/SSLSocket.h>
|
||||||
|
|
||||||
#import "XMPPConnection.h"
|
#import "XMPPConnection.h"
|
||||||
#import "XMPPSRVEnumerator.h"
|
#import "XMPPSRVLookup.h"
|
||||||
#import "XMPPSCRAMAuth.h"
|
#import "XMPPSCRAMAuth.h"
|
||||||
#import "XMPPPLAINAuth.h"
|
#import "XMPPPLAINAuth.h"
|
||||||
#import "XMPPStanza.h"
|
#import "XMPPStanza.h"
|
||||||
|
@ -197,13 +197,11 @@
|
||||||
- (void)connect
|
- (void)connect
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
XMPPSRVEnumerator *SRVEnumerator =
|
XMPPSRVLookup *SRVLookup = [XMPPSRVLookup lookupWithDomain: server];
|
||||||
[XMPPSRVEnumerator enumeratorWithDomain: server];
|
OFEnumerator *enumerator = [SRVLookup objectEnumerator];
|
||||||
XMPPSRVEntry *candidate;
|
XMPPSRVEntry *candidate;
|
||||||
|
|
||||||
[SRVEnumerator lookUpEntries];
|
while ((candidate = [enumerator nextObject]) != nil) {
|
||||||
|
|
||||||
while ((candidate = [SRVEnumerator nextObject]) != nil) {
|
|
||||||
@try {
|
@try {
|
||||||
[sock connectToHost: [candidate target]
|
[sock connectToHost: [candidate target]
|
||||||
onPort: [candidate port]];
|
onPort: [candidate port]];
|
||||||
|
|
|
@ -62,23 +62,30 @@
|
||||||
- (OFString*)target;
|
- (OFString*)target;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface XMPPSRVEnumerator: OFEnumerator
|
@interface XMPPSRVLookup: OFObject <OFEnumerating>
|
||||||
{
|
{
|
||||||
OFString *domain;
|
OFString *domain;
|
||||||
struct __res_state resState;
|
struct __res_state resState;
|
||||||
OFList *list;
|
OFList *list;
|
||||||
of_list_object_t *listIter;
|
|
||||||
OFList *subListCopy;
|
|
||||||
BOOL done;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OF_HAVE_PROPERTIES
|
#ifdef OF_HAVE_PROPERTIES
|
||||||
@property (readonly, copy) OFString *domain;
|
@property (readonly, copy) OFString *domain;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+ enumeratorWithDomain: (OFString*)domain;
|
+ lookupWithDomain: (OFString*)domain;
|
||||||
- initWithDomain: (OFString*)domain;
|
- initWithDomain: (OFString*)domain;
|
||||||
- (OFString*)domain;
|
- (void)XMPP_lookup;
|
||||||
- (void)lookUpEntries;
|
|
||||||
- (void)XMPP_addEntry: (XMPPSRVEntry*)item;
|
- (void)XMPP_addEntry: (XMPPSRVEntry*)item;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@interface XMPPSRVEnumerator: OFEnumerator
|
||||||
|
{
|
||||||
|
OFList *list;
|
||||||
|
of_list_object_t *listIter;
|
||||||
|
OFList *subListCopy;
|
||||||
|
BOOL done;
|
||||||
|
}
|
||||||
|
|
||||||
|
- initWithList: (OFList*)list;
|
||||||
|
@end
|
|
@ -30,7 +30,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
#import "XMPPSRVEnumerator.h"
|
#import "XMPPSRVLookup.h"
|
||||||
|
|
||||||
@implementation XMPPSRVEntry
|
@implementation XMPPSRVEntry
|
||||||
+ entryWithPriority: (uint16_t)priority
|
+ entryWithPriority: (uint16_t)priority
|
||||||
|
@ -153,10 +153,10 @@
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation XMPPSRVEnumerator
|
@implementation XMPPSRVLookup
|
||||||
+ enumeratorWithDomain: (OFString*)domain_
|
+ lookupWithDomain: (OFString*)domain
|
||||||
{
|
{
|
||||||
return [[[self alloc] initWithDomain: domain_] autorelease];
|
return [[[self alloc] initWithDomain: domain] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithDomain: (OFString*)domain_
|
- initWithDomain: (OFString*)domain_
|
||||||
|
@ -166,6 +166,8 @@
|
||||||
@try {
|
@try {
|
||||||
list = [[OFList alloc] init];
|
list = [[OFList alloc] init];
|
||||||
domain = [domain_ copy];
|
domain = [domain_ copy];
|
||||||
|
|
||||||
|
[self XMPP_lookup];
|
||||||
} @catch (id e) {
|
} @catch (id e) {
|
||||||
[self release];
|
[self release];
|
||||||
@throw e;
|
@throw e;
|
||||||
|
@ -178,7 +180,6 @@
|
||||||
{
|
{
|
||||||
[list release];
|
[list release];
|
||||||
[domain release];
|
[domain release];
|
||||||
[subListCopy release];
|
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -188,7 +189,7 @@
|
||||||
OF_GETTER(domain, YES)
|
OF_GETTER(domain, YES)
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)lookUpEntries
|
- (void)XMPP_lookup
|
||||||
{
|
{
|
||||||
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
|
||||||
unsigned char *answer = NULL;
|
unsigned char *answer = NULL;
|
||||||
|
@ -284,6 +285,27 @@
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (OFEnumerator*)objectEnumerator
|
||||||
|
{
|
||||||
|
return [[[XMPPSRVEnumerator alloc] initWithList: list] autorelease];
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation XMPPSRVEnumerator
|
||||||
|
- initWithList: (OFList*)list_
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
|
||||||
|
@try {
|
||||||
|
list = [list_ copy];
|
||||||
|
} @catch (id e) {
|
||||||
|
[self release];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
- (id)nextObject
|
- (id)nextObject
|
||||||
{
|
{
|
||||||
XMPPSRVEntry *ret;
|
XMPPSRVEntry *ret;
|
Loading…
Add table
Add a link
Reference in a new issue