Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moving XMPPStream ivar declarations from header file to implementatio…

…n file. Also replacing some global dispatch queues with private queues.
  • Loading branch information...
commit 0f208eed680c56a1188764657a91fe23559523a3 1 parent 300cb9a
@robbiehanson authored
View
4 Authentication/Anonymous/XMPPAnonymousAuthentication.m
@@ -117,10 +117,10 @@ - (BOOL)authenticateAnonymously:(NSError **)errPtr
}
}};
- if (dispatch_get_current_queue() == xmppQueue)
+ if (dispatch_get_current_queue() == self.xmppQueue)
block();
else
- dispatch_sync(xmppQueue, block);
+ dispatch_sync(self.xmppQueue, block);
if (errPtr)
*errPtr = err;
View
10 Authentication/Deprecated-Digest/XMPPDeprecatedDigestAuthentication.m
@@ -122,7 +122,7 @@ - (BOOL)supportsDeprecatedDigestAuthentication
// The root element can be properly queried for authentication mechanisms anytime after the
// stream:features are received, and TLS has been setup (if required)
- if (state >= STATE_XMPP_POST_NEGOTIATION)
+ if (self.state >= STATE_XMPP_POST_NEGOTIATION)
{
// Search for an iq element within the rootElement.
// Recall that some servers might stupidly add a "jabber:client" namespace which might cause problems
@@ -130,10 +130,10 @@ - (BOOL)supportsDeprecatedDigestAuthentication
NSXMLElement *iq = nil;
- NSUInteger i, count = [rootElement childCount];
+ NSUInteger i, count = [self.rootElement childCount];
for (i = 0; i < count; i++)
{
- NSXMLNode *childNode = [rootElement childAtIndex:i];
+ NSXMLNode *childNode = [self.rootElement childAtIndex:i];
if ([childNode kind] == NSXMLElementKind)
{
@@ -151,10 +151,10 @@ - (BOOL)supportsDeprecatedDigestAuthentication
}
}};
- if (dispatch_get_current_queue() == xmppQueue)
+ if (dispatch_get_current_queue() == self.xmppQueue)
block();
else
- dispatch_sync(xmppQueue, block);
+ dispatch_sync(self.xmppQueue, block);
return result;
}
View
10 Authentication/Deprecated-Plain/XMPPDeprecatedPlainAuthentication.m
@@ -116,7 +116,7 @@ - (BOOL)supportsDeprecatedPlainAuthentication
// The root element can be properly queried for authentication mechanisms anytime after the
// stream:features are received, and TLS has been setup (if required)
- if (state >= STATE_XMPP_POST_NEGOTIATION)
+ if (self.state >= STATE_XMPP_POST_NEGOTIATION)
{
// Search for an iq element within the rootElement.
// Recall that some servers might stupidly add a "jabber:client" namespace which might cause problems
@@ -124,10 +124,10 @@ - (BOOL)supportsDeprecatedPlainAuthentication
NSXMLElement *iq = nil;
- NSUInteger i, count = [rootElement childCount];
+ NSUInteger i, count = [self.rootElement childCount];
for (i = 0; i < count; i++)
{
- NSXMLNode *childNode = [rootElement childAtIndex:i];
+ NSXMLNode *childNode = [self.rootElement childAtIndex:i];
if ([childNode kind] == NSXMLElementKind)
{
@@ -145,10 +145,10 @@ - (BOOL)supportsDeprecatedPlainAuthentication
}
}};
- if (dispatch_get_current_queue() == xmppQueue)
+ if (dispatch_get_current_queue() == self.xmppQueue)
block();
else
- dispatch_sync(xmppQueue, block);
+ dispatch_sync(self.xmppQueue, block);
return result;
}
View
16 Authentication/X-Facebook-Platform/XMPPXFacebookPlatformAuthentication.m
@@ -232,7 +232,7 @@ - (id)initWithFacebookAppId:(NSString *)fbAppId
if ((self = [self init])) // Note: Using [self init], NOT [super init]
{
self.facebookAppId = fbAppId;
- myJID_setByClient = [XMPPJID jidWithString:XMPPFacebookChatHostName];
+ self.myJID = [XMPPJID jidWithString:XMPPFacebookChatHostName];
// As of October 8, 2011, Facebook doesn't have their XMPP SRV records set.
// And, as per the XMPP specification, we MUST check the XMPP SRV records for an IP address,
@@ -240,7 +240,7 @@ - (id)initWithFacebookAppId:(NSString *)fbAppId
//
// So we're setting the hostname as a minor optimization to avoid the SRV timeout delay.
- hostName = XMPPFacebookChatHostName;
+ self.hostName = XMPPFacebookChatHostName;
}
return self;
}
@@ -253,10 +253,10 @@ - (NSString *)facebookAppId
result = objc_getAssociatedObject(self, &facebookAppIdKey);
};
- if (dispatch_get_current_queue() == xmppQueue)
+ if (dispatch_get_current_queue() == self.xmppQueue)
block();
else
- dispatch_sync(xmppQueue, block);
+ dispatch_sync(self.xmppQueue, block);
return result;
}
@@ -269,10 +269,10 @@ - (void)setFacebookAppId:(NSString *)inFacebookAppId
objc_setAssociatedObject(self, &facebookAppIdKey, newFacebookAppId, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
};
- if (dispatch_get_current_queue() == xmppQueue)
+ if (dispatch_get_current_queue() == self.xmppQueue)
block();
else
- dispatch_async(xmppQueue, block);
+ dispatch_async(self.xmppQueue, block);
}
- (BOOL)supportsXFacebookPlatformAuthentication
@@ -314,10 +314,10 @@ - (BOOL)authenticateWithFacebookAccessToken:(NSString *)accessToken error:(NSErr
}};
- if (dispatch_get_current_queue() == xmppQueue)
+ if (dispatch_get_current_queue() == self.xmppQueue)
block();
else
- dispatch_sync(xmppQueue, block);
+ dispatch_sync(self.xmppQueue, block);
if (errPtr)
*errPtr = err;
View
3  Core/XMPPInternal.h
@@ -48,8 +48,9 @@ typedef enum XMPPStreamState XMPPStreamState;
**/
extern NSString *const XMPPStreamDidChangeMyJIDNotification;
-@interface XMPPStream (Internal)
+@interface XMPPStream (/* Internal */)
+@property (readonly) dispatch_queue_t xmppQueue;
@property (readonly) XMPPStreamState state;
/**
View
2  Core/XMPPMessage.m
@@ -86,7 +86,7 @@ - (BOOL)isChatMessage
- (BOOL)isChatMessageWithBody
{
- if([self isChatMessage])
+ if ([self isChatMessage])
{
return [self isMessageWithBody];
}
View
2  Core/XMPPModule.h
@@ -15,7 +15,7 @@
**/
@interface XMPPModule : NSObject
{
- __strong XMPPStream *xmppStream;
+ XMPPStream *xmppStream;
dispatch_queue_t moduleQueue;
id multicastDelegate;
View
51 Core/XMPPStream.h
@@ -39,57 +39,6 @@ typedef enum XMPPStreamErrorCode XMPPStreamErrorCode;
@interface XMPPStream : NSObject <GCDAsyncSocketDelegate>
-{
- dispatch_queue_t xmppQueue;
- dispatch_queue_t parserQueue;
-
- GCDMulticastDelegate <XMPPStreamDelegate> *multicastDelegate;
-
- int state;
-
- GCDAsyncSocket *asyncSocket;
- NSMutableData *socketBuffer;
-
- UInt64 numberOfBytesSent;
- UInt64 numberOfBytesReceived;
-
- XMPPParser *parser;
- NSError *parserError;
-
- Byte flags;
- Byte config;
-
- NSString *hostName;
- UInt16 hostPort;
-
- id <XMPPSASLAuthentication> auth;
-
- XMPPJID *myJID_setByClient;
- XMPPJID *myJID_setByServer;
- XMPPJID *remoteJID;
-
- XMPPPresence *myPresence;
- NSXMLElement *rootElement;
-
- NSTimeInterval keepAliveInterval;
- dispatch_source_t keepAliveTimer;
- NSTimeInterval lastSendReceiveTime;
- NSData *keepAliveData;
-
- NSMutableArray *registeredModules;
- NSMutableDictionary *autoDelegateDict;
-
- XMPPSRVResolver *srvResolver;
- NSArray *srvResults;
- NSUInteger srvResultsIndex;
-
- NSMutableArray *receipts;
-
- NSThread *xmppUtilityThread;
- NSRunLoop *xmppUtilityRunLoop;
-
- id userTag;
-}
/**
* Standard XMPP initialization.
View
81 Core/XMPPStream.m
@@ -4,7 +4,6 @@
#import "XMPPInternal.h"
#import "XMPPSRVResolver.h"
#import "NSData+XMPP.h"
-#import "DDList.h"
#import <objc/runtime.h>
#import <libkern/OSAtomic.h>
@@ -90,9 +89,63 @@
#pragma mark -
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-@interface XMPPStream (PrivateAPI)
+@interface XMPPStream ()
+{
+ dispatch_queue_t xmppQueue;
+ dispatch_queue_t parserQueue;
+
+ dispatch_queue_t willSendIqQueue;
+ dispatch_queue_t willSendMessageQueue;
+ dispatch_queue_t willSendPresenceQueue;
+
+ GCDMulticastDelegate <XMPPStreamDelegate> *multicastDelegate;
+
+ int state;
+
+ GCDAsyncSocket *asyncSocket;
+ NSMutableData *socketBuffer;
+
+ UInt64 numberOfBytesSent;
+ UInt64 numberOfBytesReceived;
+
+ XMPPParser *parser;
+ NSError *parserError;
+
+ Byte flags;
+ Byte config;
+
+ NSString *hostName;
+ UInt16 hostPort;
+
+ id <XMPPSASLAuthentication> auth;
+
+ XMPPJID *myJID_setByClient;
+ XMPPJID *myJID_setByServer;
+ XMPPJID *remoteJID;
+
+ XMPPPresence *myPresence;
+ NSXMLElement *rootElement;
+
+ NSTimeInterval keepAliveInterval;
+ dispatch_source_t keepAliveTimer;
+ NSTimeInterval lastSendReceiveTime;
+ NSData *keepAliveData;
+
+ NSMutableArray *registeredModules;
+ NSMutableDictionary *autoDelegateDict;
+
+ XMPPSRVResolver *srvResolver;
+ NSArray *srvResults;
+ NSUInteger srvResultsIndex;
+
+ NSMutableArray *receipts;
+
+ NSThread *xmppUtilityThread;
+ NSRunLoop *xmppUtilityRunLoop;
+
+ id userTag;
+}
-- (void)cleanup;
- (void)setIsSecure:(BOOL)flag;
- (void)setIsAuthenticated:(BOOL)flag;
- (void)continueSendIQ:(XMPPIQ *)iq withTag:(long)tag;
@@ -127,8 +180,12 @@ @implementation XMPPStream
**/
- (void)commonInit
{
- xmppQueue = dispatch_queue_create("xmppStreamQueue", NULL);
- parserQueue = dispatch_queue_create("xmppParserQueue", NULL);
+ xmppQueue = dispatch_queue_create("xmpp", NULL);
+ parserQueue = dispatch_queue_create("xmpp.parser", NULL);
+
+ willSendIqQueue = dispatch_queue_create("xmpp.willSendIq", NULL);
+ willSendMessageQueue = dispatch_queue_create("xmpp.willSendMessage", NULL);
+ willSendPresenceQueue = dispatch_queue_create("xmpp.willSendPresence", NULL);
multicastDelegate = (GCDMulticastDelegate <XMPPStreamDelegate> *)[[GCDMulticastDelegate alloc] init];
@@ -207,6 +264,9 @@ - (void)dealloc
#if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(xmppQueue);
dispatch_release(parserQueue);
+ dispatch_release(willSendIqQueue);
+ dispatch_release(willSendMessageQueue);
+ dispatch_release(willSendPresenceQueue);
#endif
[asyncSocket setDelegate:nil delegateQueue:NULL];
@@ -234,6 +294,8 @@ - (void)dealloc
#pragma mark Properties
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+@synthesize xmppQueue;
+
- (XMPPStreamState)state
{
__block XMPPStreamState result = STATE_XMPP_DISCONNECTED;
@@ -1778,8 +1840,7 @@ - (void)sendIQ:(XMPPIQ *)iq withTag:(long)tag
GCDMulticastDelegateEnumerator *delegateEnumerator = [multicastDelegate delegateEnumerator];
- dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
- dispatch_async(concurrentQueue, ^{ @autoreleasepool {
+ dispatch_async(willSendIqQueue, ^{ @autoreleasepool {
// Allow delegates to modify and/or filter outgoing element
@@ -1849,8 +1910,7 @@ - (void)sendMessage:(XMPPMessage *)message withTag:(long)tag
GCDMulticastDelegateEnumerator *delegateEnumerator = [multicastDelegate delegateEnumerator];
- dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
- dispatch_async(concurrentQueue, ^{ @autoreleasepool {
+ dispatch_async(willSendMessageQueue, ^{ @autoreleasepool {
// Allow delegates to modify outgoing element
@@ -1920,8 +1980,7 @@ - (void)sendPresence:(XMPPPresence *)presence withTag:(long)tag
GCDMulticastDelegateEnumerator *delegateEnumerator = [multicastDelegate delegateEnumerator];
- dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
- dispatch_async(concurrentQueue, ^{ @autoreleasepool {
+ dispatch_async(willSendPresenceQueue, ^{ @autoreleasepool {
// Allow delegates to modify outgoing element
Please sign in to comment.
Something went wrong with that request. Please try again.