Skip to content

Commit

Permalink
Fixed DBNilObject bug, added longer timeout, fixed Reachability prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cobbe committed Sep 28, 2016
1 parent d8c8b61 commit d6e0012
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Format/UmbrellaHeader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#import "DropboxSDKImportsMobile.h"
#import "DropboxSDKImportsDesktop.h"
3 changes: 2 additions & 1 deletion Format/generate_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ else
echo "Copying all sdk files to tmp directory..."
find ../Source/ObjectiveDropboxOfficial/ -name \*.[h,m] -exec cp {} $tmp_location \;
cp ../README.md $tmp_location
cp ./UmbrellaHeader.h $tmp_location

echo "Generating documents..."
jazzy --objc --readme $tmp_location/README.md --umbrella-header $tmp_location/DropboxSDKImports.h --framework-root $tmp_location --config ../.jazzy.json -o $docs_location
jazzy --objc --readme $tmp_location/README.md --umbrella-header $tmp_location/UmbrellaHeader.h --framework-root $tmp_location --config ../.jazzy.json -o $docs_location

cp jazzy.css $docs_location/css/

Expand Down
2 changes: 1 addition & 1 deletion ObjectiveDropboxOfficial.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ObjectiveDropboxOfficial'
s.version = '1.0.11'
s.version = '1.0.12'
s.summary = 'Dropbox Objective C SDK for APIv2'
s.homepage = 'https://dropbox.com/developers/'
s.license = 'MIT'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ brew install carthage

```
# ObjectiveDropboxOfficial
github "https://github.com/dropbox/dropbox-sdk-obj-c" ~> 1.0.11
github "https://github.com/dropbox/dropbox-sdk-obj-c" ~> 1.0.12
```

Then, run the following command to checkout and build the Dropbox Objective-C SDK repository:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>

typedef enum : NSInteger { NotReachable = 0, ReachableViaWiFi, ReachableViaWWAN } DBNetworkStatus;
typedef enum : NSInteger { DBNotReachable = 0, DBReachableViaWiFi, DBReachableViaWWAN } DBNetworkStatus;

#pragma mark IPv6 Support
// Reachability fully support IPv6. For full details, see ReadMe.md.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ - (DBNetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags {
PrintReachabilityFlags(flags, "networkStatusForFlags");
if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
// The target host is not reachable.
return NotReachable;
return DBNotReachable;
}

DBNetworkStatus returnValue = NotReachable;
DBNetworkStatus returnValue = DBNotReachable;

if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) {
/*
If the target host is reachable and no connection is required then we'll assume (for now) that you're on Wi-Fi...
*/
returnValue = ReachableViaWiFi;
returnValue = DBReachableViaWiFi;
}

if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) ||
Expand All @@ -163,7 +163,7 @@ - (DBNetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags {
/*
... and no [user] intervention is needed...
*/
returnValue = ReachableViaWiFi;
returnValue = DBReachableViaWiFi;
}
}

Expand All @@ -172,7 +172,7 @@ - (DBNetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags {
/*
... but WWAN connections are OK if the calling application is using the CFNetwork APIs.
*/
returnValue = ReachableViaWWAN;
returnValue = DBReachableViaWWAN;
}
#endif

Expand All @@ -192,7 +192,7 @@ - (BOOL)connectionRequired {

- (DBNetworkStatus)currentReachabilityStatus {
NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef");
DBNetworkStatus returnValue = NotReachable;
DBNetworkStatus returnValue = DBNotReachable;
SCNetworkReachabilityFlags flags;

if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ - (DBRpcTask *)response:(NSOperationQueue *)queue response:(void (^)(id, id, DBE
responseBlock(nil, nil, [[DBError alloc] initAsClientError:serializationError]);
return;
}
result = !_route.resultType ? [DBNilObject new] : result;
responseBlock(result, nil, nil);
};

Expand Down Expand Up @@ -242,6 +243,7 @@ - (DBUploadTask *)response:(NSOperationQueue *)queue response:(void (^)(id, id,
responseBlock(nil, nil, [[DBError alloc] initAsClientError:serializationError]);
return;
}
result = !_route.resultType ? [DBNilObject new] : result;
responseBlock(result, nil, nil);
};

Expand Down Expand Up @@ -353,6 +355,7 @@ - (DBDownloadUrlTask *)response:(NSOperationQueue *)queue
responseBlock(nil, nil, [[DBError alloc] initAsClientError:serializationError], _destination);
return;
}
result = !_route.resultType ? [DBNilObject new] : result;
responseBlock(result, nil, nil, _destination);
};

Expand Down Expand Up @@ -434,6 +437,7 @@ - (DBDownloadDataTask *)response:(NSOperationQueue *)queue
responseBlock(nil, nil, [[DBError alloc] initAsClientError:serializationError], nil);
return;
}
result = !_route.resultType ? [DBNilObject new] : result;
responseBlock(result, nil, nil, [NSData dataWithContentsOfFile:[location path]]);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "DBTasks.h"
#import "DBTransportClient.h"

static NSString const *const kVersion = @"1.0.11";
static NSString const *const kVersion = @"1.0.12";
static NSString const *const kDefaultUserAgentPrefix = @"OfficialDropboxObjCSDKv2";
static NSString const *const kBackgroundSessionId = @"com.dropbox.dropbox_sdk_obj_c_background";

Expand Down Expand Up @@ -65,13 +65,20 @@ - (instancetype)initWithAccessToken:(NSString *)accessToken
if (self) {
_delegateQueue = delegateQueue ?: [NSOperationQueue mainQueue];
_delegate = [[DBDelegate alloc] initWithQueue:_delegateQueue];
_session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]

NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfig.timeoutIntervalForRequest = 100.0;

_session = [NSURLSession sessionWithConfiguration:sessionConfig
delegate:_delegate
delegateQueue:_delegateQueue];
NSString *backgroundId =
backgroundSessionId ?: [NSString stringWithFormat:@"%@.%@", kBackgroundSessionId, [NSUUID UUID].UUIDString];
NSURLSessionConfiguration *backgroundSessionConfig =
[NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:backgroundId];
backgroundSessionConfig.timeoutIntervalForRequest = 100.0;
_backgroundSession = [NSURLSession
sessionWithConfiguration:[NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:backgroundId]
sessionWithConfiguration:backgroundSessionConfig
delegate:_delegate
delegateQueue:_delegateQueue];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ - (DBOAuthResult *)handleRedirectURL:(NSURL *)url {
}

- (void)authorizeFromSharedApplication:(id<DBSharedApplication>)sharedApplication browserAuth:(BOOL)browserAuth {
if ([[DBReachability reachabilityForInternetConnection] currentReachabilityStatus] == NotReachable) {
if ([[DBReachability reachabilityForInternetConnection] currentReachabilityStatus] == DBNotReachable) {
NSString *message = @"Try again once you have an internet connection.";
NSString *title = @"No internet connection";

Expand Down Expand Up @@ -138,7 +138,6 @@ - (BOOL)conformsToAppScheme {
for (NSDictionary *urlType in urlTypes) {
NSArray<NSString *> *schemes = [urlType objectForKey:@"CFBundleURLSchemes"];
for (NSString *scheme in schemes) {
NSLog(@"%@\n", scheme);
if ([scheme isEqualToString:appScheme]) {
return YES;
}
Expand Down

0 comments on commit d6e0012

Please sign in to comment.