Skip to content

Commit

Permalink
Update XMPPFramework
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisballinger committed Dec 8, 2012
1 parent 1a6b6bc commit fb5068e
Show file tree
Hide file tree
Showing 471 changed files with 3,607 additions and 845 deletions.
1 change: 1 addition & 0 deletions OTRKit/OTRKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
COPY_PHASE_STRIP = NO;
DSTROOT = /tmp/OTRKit.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OTRKit/OTRKit-Prefix.pch";
Expand Down
4 changes: 2 additions & 2 deletions Off the Record.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,6 @@
D93750B1160801160059321E /* XMPP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMPP.h; sourceTree = "<group>"; };
D93750B2160801160059321E /* XMPPElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMPPElement.h; sourceTree = "<group>"; };
D93750B3160801160059321E /* XMPPElement.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMPPElement.m; sourceTree = "<group>"; };
D93750B4160801160059321E /* XMPPFramework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMPPFramework.h; sourceTree = "<group>"; };
D93750B5160801160059321E /* XMPPInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMPPInternal.h; sourceTree = "<group>"; };
D93750B6160801160059321E /* XMPPIQ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMPPIQ.h; sourceTree = "<group>"; };
D93750B7160801160059321E /* XMPPIQ.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMPPIQ.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -953,6 +952,7 @@
D9ABC98F15D48B7E00AAB730 /* OTRXMPPAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRXMPPAccount.m; sourceTree = "<group>"; };
D9ABC99115D48C4E00AAB730 /* OTROscarAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTROscarAccount.h; sourceTree = "<group>"; };
D9ABC99215D48C4F00AAB730 /* OTROscarAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTROscarAccount.m; sourceTree = "<group>"; };
D9B1FAE61673E765008ACC4F /* XMPPFramework.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XMPPFramework.h; sourceTree = "<group>"; };
D9BBCD3A1491F7AB00AF1B9F /* 19-gear.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "19-gear.png"; sourceTree = "<group>"; };
D9BBCD3C1491F8B400AF1B9F /* OTRAboutViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRAboutViewController.h; sourceTree = "<group>"; };
D9BBCD3D1491F8B400AF1B9F /* OTRAboutViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRAboutViewController.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1176,6 +1176,7 @@
D9375090160801160059321E /* XMPPFramework */ = {
isa = PBXGroup;
children = (
D9B1FAE61673E765008ACC4F /* XMPPFramework.h */,
D9375094160801160059321E /* Authentication */,
D93750A8160801160059321E /* Categories */,
D93750B0160801160059321E /* Core */,
Expand Down Expand Up @@ -1273,7 +1274,6 @@
D93750B1160801160059321E /* XMPP.h */,
D93750B2160801160059321E /* XMPPElement.h */,
D93750B3160801160059321E /* XMPPElement.m */,
D93750B4160801160059321E /* XMPPFramework.h */,
D93750B5160801160059321E /* XMPPInternal.h */,
D93750B6160801160059321E /* XMPPIQ.h */,
D93750B7160801160059321E /* XMPPIQ.m */,
Expand Down
2 changes: 1 addition & 1 deletion Off the Record/OTRSettingsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ - (void) populateSettings

#ifdef CRITTERCISM_ENABLED
OTRBoolSetting *crittercismSetting = [[OTRBoolSetting alloc] initWithTitle:CRITTERCISM_TITLE_STRING description:CRITTERCISM_DESCRIPTION_STRING settingsKey:kOTRSettingKeyCrittercismOptIn];
OTRSettingsGroup *otherGroup = [[OTRSettingsGroup alloc] initWithTitle:OTHER_STRING settings:[NSArray arrayWithObjects:shareViewSetting,feedbackViewSetting,crittercismSetting,nil]];
OTRSettingsGroup *otherGroup = [[OTRSettingsGroup alloc] initWithTitle:OTHER_STRING settings:[NSArray arrayWithObjects:languageSetting, shareViewSetting,feedbackViewSetting,crittercismSetting,nil]];
[newSettingsDictionary setObject:crittercismSetting forKey:kOTRSettingKeyCrittercismOptIn];
[settingsGroups addObject:otherGroup];
#else
Expand Down
Empty file.
4 changes: 2 additions & 2 deletions XMPPFramework/Authentication/Anonymous/XMPPAnonymousAuthentication.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Empty file.
10 changes: 5 additions & 5 deletions XMPPFramework/Authentication/Deprecated-Digest/XMPPDeprecatedDigestAuthentication.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ - (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
// if we simply used the elementForName method.

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)
{
Expand All @@ -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;
}
Expand Down
Empty file.
10 changes: 5 additions & 5 deletions XMPPFramework/Authentication/Deprecated-Plain/XMPPDeprecatedPlainAuthentication.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ - (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
// if we simply used the elementForName method.

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)
{
Expand All @@ -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;
}
Expand Down
Empty file.
Empty file.
Empty file modified XMPPFramework/Authentication/Plain/XMPPPlainAuthentication.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Authentication/Plain/XMPPPlainAuthentication.m
100755 → 100644
Empty file.
Empty file.
16 changes: 8 additions & 8 deletions XMPPFramework/Authentication/X-Facebook-Platform/XMPPXFacebookPlatformAuthentication.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,15 @@ - (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,
// before falling back to a traditional A record lookup.
//
// So we're setting the hostname as a minor optimization to avoid the SRV timeout delay.

hostName = XMPPFacebookChatHostName;
self.hostName = XMPPFacebookChatHostName;
}
return self;
}
Expand All @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Empty file modified XMPPFramework/Authentication/XMPPSASLAuthentication.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Categories/NSData+XMPP.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Categories/NSData+XMPP.m
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Categories/NSNumber+XMPP.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Categories/NSNumber+XMPP.m
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Categories/NSXMLElement+XMPP.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Categories/NSXMLElement+XMPP.m
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Core/XMPP.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Core/XMPPElement.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Core/XMPPElement.m
100755 → 100644
Empty file.
39 changes: 0 additions & 39 deletions XMPPFramework/Core/XMPPFramework.h

This file was deleted.

Empty file modified XMPPFramework/Core/XMPPIQ.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Core/XMPPIQ.m
100755 → 100644
Empty file.
40 changes: 26 additions & 14 deletions XMPPFramework/Core/XMPPInternal.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,8 @@
// This file is for XMPPStream and various internal components.
//

#import "XMPPSASLAuthentication.h"

// Define the various timeouts (in seconds) for retreiving various parts of the XML stream
#define TIMEOUT_XMPP_WRITE -1
#define TIMEOUT_XMPP_READ_START 10
#define TIMEOUT_XMPP_READ_STREAM -1

// Define the various tags we'll use to differentiate what it is we're currently reading or writing
#define TAG_XMPP_READ_START 100
#define TAG_XMPP_READ_STREAM 101
#define TAG_XMPP_WRITE_START 200
#define TAG_XMPP_WRITE_STREAM 201
#define TAG_XMPP_WRITE_RECEIPT 202
#import "XMPPStream.h"
#import "XMPPModule.h"

// Define the various states we'll use to track our progress
enum XMPPStreamState
Expand Down Expand Up @@ -48,8 +37,14 @@ typedef enum XMPPStreamState XMPPStreamState;
**/
extern NSString *const XMPPStreamDidChangeMyJIDNotification;

@interface XMPPStream (Internal)
@interface XMPPStream (/* Internal */)

/**
* Categories on XMPPStream should maintain thread safety by dispatching through the internal xmppQueue.
* They may also need to ensure the stream is in the proper state for their activity.
**/

@property (readonly) dispatch_queue_t xmppQueue;
@property (readonly) XMPPStreamState state;

/**
Expand All @@ -59,4 +54,21 @@ extern NSString *const XMPPStreamDidChangeMyJIDNotification;
**/
- (void)sendAuthElement:(NSXMLElement *)element;

/**
* This method allows you to inject an element into the stream as if it was received on the socket.
* This is an advanced technique, but makes for some interesting possibilities.
**/
- (void)injectElement:(NSXMLElement *)element;

@end

@interface XMPPModule (/* Internal */)

/**
* Used internally by methods like XMPPStream's unregisterModule:.
* Normally removing a delegate is a synchronous operation, but due to multiple dispatch_sync operations,
* it must occasionally be done asynchronously to avoid deadlock.
**/
- (void)removeDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue synchronously:(BOOL)synchronously;

@end
Empty file modified XMPPFramework/Core/XMPPJID.h
100755 → 100644
Empty file.
Empty file modified XMPPFramework/Core/XMPPJID.m
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions XMPPFramework/Core/XMPPLogging.h
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* In order to provide fast and flexible logging, this project uses Cocoa Lumberjack.
*
* The Google Code page has a wealth of documentation if you have any questions.
* http://code.google.com/p/cocoalumberjack/
* The GitHub project page has a wealth of documentation if you have any questions.
* https://github.com/robbiehanson/CocoaLumberjack
*
* Here's what you need to know concerning how logging is setup for XMPPFramework:
*
Expand Down
Empty file modified XMPPFramework/Core/XMPPMessage.h
100755 → 100644
Empty file.
6 changes: 2 additions & 4 deletions XMPPFramework/Core/XMPPMessage.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ - (BOOL)isChatMessage

- (BOOL)isChatMessageWithBody
{
if([self isChatMessage])
if ([self isChatMessage])
{
return [self isMessageWithBody];
}
Expand All @@ -112,9 +112,7 @@ - (NSError *)errorMessage {

- (BOOL)isMessageWithBody
{
NSString *body = [[self elementForName:@"body"] stringValue];

return ([body length] > 0);
return ([self elementForName:@"body"] != nil);
}

@end
2 changes: 1 addition & 1 deletion XMPPFramework/Core/XMPPModule.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
**/
@interface XMPPModule : NSObject
{
__strong XMPPStream *xmppStream;
XMPPStream *xmppStream;

dispatch_queue_t moduleQueue;
id multicastDelegate;
Expand Down
30 changes: 13 additions & 17 deletions XMPPFramework/Core/XMPPModule.m
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -178,36 +178,32 @@ - (void)addDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue
dispatch_async(moduleQueue, block);
}

- (void)removeDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue
- (void)removeDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue synchronously:(BOOL)synchronously
{
// Synchronous operation
//
// Delegate removal MUST always be synchronous.

dispatch_block_t block = ^{
[multicastDelegate removeDelegate:delegate delegateQueue:delegateQueue];
};

if (dispatch_get_current_queue() == moduleQueue)
block();
else
else if (synchronously)
dispatch_sync(moduleQueue, block);
else
dispatch_async(moduleQueue, block);

}
- (void)removeDelegate:(id)delegate delegateQueue:(dispatch_queue_t)delegateQueue
{
// Synchronous operation (common-case default)

[self removeDelegate:delegate delegateQueue:delegateQueue synchronously:YES];
}

- (void)removeDelegate:(id)delegate
{
// Synchronous operation
//
// Delegate remove MUST always be synchronous.

dispatch_block_t block = ^{
[multicastDelegate removeDelegate:delegate];
};
// Synchronous operation (common-case default)

if (dispatch_get_current_queue() == moduleQueue)
block();
else
dispatch_sync(moduleQueue, block);
[self removeDelegate:delegate delegateQueue:NULL synchronously:YES];
}

- (NSString *)moduleName
Expand Down
Loading

0 comments on commit fb5068e

Please sign in to comment.