Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKIP_INSTALL needs to be YES for OS X frameworks #1

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ Upgrade instructions
3. Follow the installation instructions from the README to install the
newest version of the SDK

Changes from 1.3.8 to 1.3.9
- You will *not* believe the 64 bit support in this version

Changes from 1.3.7 to 1.3.8
- Correctly fix the iOS7 background operation bug for users who have already linked Dropbox

Changes from 1.3.6 to 1.3.7
- Better 64 bit support for iOS
- Fix a bug when using iOS7's background operation while a passcode is set

Changes from 1.3.5 to 1.3.6
- Optimized the SDK for iOS7

Changes from 1.3.4 to 1.3.5
- Fixed bug where cancel url wasn't always getting sent when the user cancelled
the authentication flow.
- Fixed a bug where uploads would sometimes fail on iOS 5
- Added a new optional delegate method,
-[DBRestClient restClient:uploadFileChunkProgress:forFile:offset:fromPath:],
which allows you to get the progress of chunks you're uploading.

Changes from 1.3.3 to 1.3.4
- Added a new DBRestClientDelegate callback, -restClient:createdCopyRef:forPath:
that replaces the existing method -restClient:createdCopyRef
- Fix authentication bug

Changes from 1.3.2 to 1.3.3
- Bug fixes for chunked uploads and more!

Expand Down
9 changes: 9 additions & 0 deletions DropboxSDK/64bit.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// 64bit.xcconfig
// DropboxSDK
//
// Created by brian on 9/23/13.
//
//
ARCHS = arm64 x86_64
IPHONEOS_DEPLOYMENT_TARGET=6.0
12 changes: 9 additions & 3 deletions DropboxSDK/Classes/DBConnectController.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ - (id)initWithUrl:(NSURL *)connectUrl fromController:(UIViewController *)pRootCo
[[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)]
autorelease];

#ifdef __IPHONE_7_0 // Temporary until we can switch to XCode 5 for release.
if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
#endif
}
return self;
}
Expand Down Expand Up @@ -254,7 +260,7 @@ - (void)alertView:(UIAlertView *)pAlertView clickedButtonAtIndex:(NSInteger)butt
if ([self.navigationController.viewControllers count] > 1) {
[self.navigationController popViewControllerAnimated:YES];
} else {
[self dismiss];
[self cancel];
}
}

Expand All @@ -275,7 +281,7 @@ - (BOOL)openUrl:(NSURL *)openUrl {
id<UIApplicationDelegate> delegate = app.delegate;

if ([delegate respondsToSelector:@selector(application:openURL:sourceApplication:annotation:)]) {
[delegate application:app openURL:openUrl sourceApplication:@"com.getdropbox.Dropbox" annotation:nil];
[delegate application:app openURL:openUrl sourceApplication:@"com.getdropbox.Dropbox" annotation:@""];
} else if ([delegate respondsToSelector:@selector(application:handleOpenURL:)]) {
[delegate application:app handleOpenURL:openUrl];
} else {
Expand All @@ -301,7 +307,7 @@ - (void)dismissAnimated:(BOOL)animated {
if ([webView isLoading]) {
[webView stopLoading];
}
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
[self.navigationController dismissViewControllerAnimated:animated completion:NULL];
}

- (void)dismiss {
Expand Down
10 changes: 0 additions & 10 deletions DropboxSDK/Classes/DBDefines.h

This file was deleted.

8 changes: 4 additions & 4 deletions DropboxSDK/Classes/DBKeychain-iOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ + (NSDictionary *)credentials {
return [NSKeyedUnarchiver unarchiveObjectWithData:foundValue];
} else {
if (status != errSecItemNotFound) {
DBLogWarning(@"DropboxSDK: error reading stored credentials (%li)", status);
DBLogWarning(@"DropboxSDK: error reading stored credentials (%i)", (int32_t)status);
}
return nil;
}
Expand All @@ -53,7 +53,7 @@ + (void)setCredentials:(NSDictionary *)credentials {

NSArray *version = [[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."];
if ([[version objectAtIndex:0] intValue] >= 4) {
[attrDict setObject:(id)kSecAttrAccessibleWhenUnlocked forKey:(id)kSecAttrAccessible];
[attrDict setObject:(id)kSecAttrAccessibleAfterFirstUnlock forKey:(id)kSecAttrAccessible];
}

OSStatus status = noErr;
Expand All @@ -66,15 +66,15 @@ + (void)setCredentials:(NSDictionary *)credentials {
}

if (status != noErr) {
DBLogWarning(@"DropboxSDK: error saving credentials (%li)", status);
DBLogWarning(@"DropboxSDK: error saving credentials (%i)", (int32_t)status);
}
}

+ (void)deleteCredentials {
OSStatus status = SecItemDelete((CFDictionaryRef)kDBKeychainDict);

if (status != noErr) {
DBLogWarning(@"DropboxSDK: error deleting credentials (%li)", status);
DBLogWarning(@"DropboxSDK: error deleting credentials (%i)", (int32_t)status);
}
}

Expand Down
11 changes: 11 additions & 0 deletions DropboxSDK/Classes/DBRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ - (void) dealloc {
[fileHandle release];
[fileManager release];
[userInfo release];
[sourcePath release];
[response release];
[xDropboxMetadataJSON release];
[resultFilename release];
Expand All @@ -65,6 +66,7 @@ - (void) dealloc {
@synthesize downloadProgressSelector;
@synthesize uploadProgressSelector;
@synthesize userInfo;
@synthesize sourcePath;
@synthesize request;
@synthesize response;
@synthesize xDropboxMetadataJSON;
Expand Down Expand Up @@ -287,6 +289,15 @@ - (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheRespo
return nil;
}

- (NSInputStream *)connection:(NSURLConnection *)connection needNewBodyStream:(NSURLRequest *)req {
if (!sourcePath) {
DBLogWarning(@"DropboxSDK: need new body stream, but none available");
return nil;
}
return [NSInputStream inputStreamWithFileAtPath:sourcePath];
}



#pragma mark private methods

Expand Down
19 changes: 18 additions & 1 deletion DropboxSDK/Classes/DBRestClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ - (void)uploadFile:(NSString*)filename toPath:(NSString*)path fromPath:(NSString
request.uploadProgressSelector = @selector(requestUploadProgress:);
request.userInfo =
[NSDictionary dictionaryWithObjectsAndKeys:sourcePath, @"sourcePath", destPath, @"destinationPath", nil];
request.sourcePath = sourcePath;

[uploadRequests setObject:request forKey:destPath];
}
Expand Down Expand Up @@ -672,14 +673,27 @@ - (void)uploadFileChunk:(NSString *)uploadId offset:(unsigned long long)offset f
[[[DBRequest alloc]
initWithURLRequest:urlRequest andInformTarget:self selector:@selector(requestDidUploadChunk:)]
autorelease];
request.uploadProgressSelector = @selector(requestChunkedUploadProgress:);
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithLongLong:offset], @"offset",
localPath, @"fromPath",
uploadId, @"upload_id", nil];
request.userInfo = userInfo;
request.sourcePath = localPath;
[requests addObject:request];
}

- (void)requestChunkedUploadProgress:(DBRequest*)request {
NSString *uploadId = [request.userInfo objectForKey:@"upload_id"];
unsigned long long offset = [[request.userInfo objectForKey:@"offset"] longLongValue];
NSString *fromPath = [request.userInfo objectForKey:@"fromPath"];

if ([delegate respondsToSelector:@selector(restClient:uploadFileChunkProgress:forFile:offset:fromPath:)]) {
[delegate restClient:self uploadFileChunkProgress:request.uploadProgress
forFile:uploadId offset:offset fromPath:fromPath];
}
}

- (void)requestDidUploadChunk:(DBRequest *)request {
NSDictionary *resp = [request parseResponseAsType:[NSDictionary class]];

Expand Down Expand Up @@ -942,7 +956,10 @@ - (void)requestDidCreateCopyRef:(DBRequest *)request {
}
} else {
NSString *copyRef = [result objectForKey:@"copy_ref"];
if ([delegate respondsToSelector:@selector(restClient:createdCopyRef:)]) {
NSString *path = [request.userInfo objectForKey:@"path"];
if ([delegate respondsToSelector:@selector(restClient:createdCopyRef:forPath:)]) {
[delegate restClient:self createdCopyRef:copyRef forPath:path];
} else if ([delegate respondsToSelector:@selector(restClient:createdCopyRef:)]) {
[delegate restClient:self createdCopyRef:copyRef];
}
}
Expand Down
39 changes: 31 additions & 8 deletions DropboxSDK/Classes/DBSession+iOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
#import "DBLog.h"


static NSString *kDBProtocolDropbox = @"dbapi-1";
static NSString *kDBProtocolDropbox = @"dbapi-2";

/* A key to keep track of the nonce for the current link flow */
static NSString *kDBLinkNonce = @"dropbox.sync.nonce";


@implementation DBSession (iOS)

Expand Down Expand Up @@ -71,28 +75,37 @@ - (void)linkUserId:(NSString *)userId fromController:(UIViewController *)rootCon
NSData *consumerSecret =
[[baseCredentials objectForKey:kMPOAuthCredentialConsumerSecret] dataUsingEncoding:NSUTF8StringEncoding];
unsigned char md[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(consumerSecret.bytes, [consumerSecret length], md);
NSUInteger sha_32 = htonl(((NSUInteger *)md)[CC_SHA1_DIGEST_LENGTH/sizeof(NSUInteger) - 1]);
CC_SHA1(consumerSecret.bytes, (uint32_t)[consumerSecret length], md);
uint32_t sha_32 = htonl(((uint32_t *)md)[CC_SHA1_DIGEST_LENGTH/sizeof(uint32_t) - 1]);
NSString *secret = [NSString stringWithFormat:@"%x", sha_32];

CFUUIDRef uuid = CFUUIDCreate(NULL);
CFStringRef uuid_str = CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
NSString *nonce = [(NSString *)uuid_str autorelease];
[[NSUserDefaults standardUserDefaults] setObject:nonce forKey:kDBLinkNonce];
[[NSUserDefaults standardUserDefaults] synchronize];

NSString *urlStr = nil;

NSURL *dbURL =
[NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/connect", kDBProtocolDropbox, kDBDropboxAPIVersion]];
if ([[UIApplication sharedApplication] canOpenURL:dbURL]) {
urlStr = [NSString stringWithFormat:@"%@?k=%@&s=%@%@", dbURL, consumerKey, secret, userIdStr];
urlStr = [NSString stringWithFormat:@"%@?k=%@&s=%@&state=%@%@",
dbURL, consumerKey, secret, nonce, userIdStr];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlStr]];
} else {
urlStr = [NSString stringWithFormat:@"%@://%@/%@/connect_login?k=%@&s=%@&easl=1%@",
kDBProtocolHTTPS, kDBDropboxWebHost, kDBDropboxAPIVersion, consumerKey, secret, userIdStr];
UIViewController *connectController = [[[DBConnectController alloc] initWithUrl:[NSURL URLWithString:urlStr] fromController:rootController] autorelease];
urlStr = [NSString stringWithFormat:@"%@://%@/%@/connect_login?k=%@&s=%@&state=%@&easl=1%@",
kDBProtocolHTTPS, kDBDropboxWebHost, kDBDropboxAPIVersion,
consumerKey, secret, nonce, userIdStr];
UIViewController *connectController = [[[DBConnectController alloc] initWithUrl:[NSURL URLWithString:urlStr] fromController:rootController session:self] autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:connectController] autorelease];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
connectController.modalPresentationStyle = UIModalPresentationFormSheet;
navController.modalPresentationStyle = UIModalPresentationFormSheet;
}

[rootController presentViewController:navController animated:YES completion:nil];
[rootController presentViewController:navController animated:YES completion:NULL];
}
}

Expand All @@ -114,6 +127,16 @@ - (BOOL)handleOpenURL:(NSURL *)url {
NSString *token = [params objectForKey:@"oauth_token"];
NSString *secret = [params objectForKey:@"oauth_token_secret"];
NSString *userId = [params objectForKey:@"uid"];

NSString *state = [params objectForKey:@"state"];
NSString *nonce = [[NSUserDefaults standardUserDefaults] objectForKey:kDBLinkNonce];
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kDBLinkNonce];
[[NSUserDefaults standardUserDefaults] synchronize];
if (![nonce isEqual:state]) {
DBLogError(@"unable to verify link request");
return NO;
}

[self updateAccessToken:token accessTokenSecret:secret forUserId:userId];
} else if ([methodName isEqual:@"cancel"]) {
DBLogInfo(@"DropboxSDK: user cancelled Dropbox link");
Expand Down
14 changes: 10 additions & 4 deletions DropboxSDK/Classes/DBSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "MPOAuthCredentialConcreteStore.h"
#import "MPOAuthSignatureParameter.h"

NSString *kDBSDKVersion = @"1.3.3"; // TODO: parameterize from build system
NSString *kDBSDKVersion = @"1.3.9"; // TODO: parameterize from build system

NSString *kDBDropboxAPIHost = @"api.dropbox.com";
NSString *kDBDropboxAPIContentHost = @"api-content.dropbox.com";
Expand All @@ -33,7 +33,7 @@
static NSString *kDBDropboxUserCredentials = @"kDBDropboxUserCredentials";
static NSString *kDBDropboxUserId = @"kDBDropboxUserId";
static NSString *kDBCredentialsVersionKey = @"DBCredentialVersion";
static int kDBCredentialsVersion = 2;
static int kDBCredentialsVersion = 3;



Expand Down Expand Up @@ -109,13 +109,19 @@ - (id)initWithAppKey:(NSString *)key appSecret:(NSString *)secret root:(NSString
NSString *secret = [savedCredentials objectForKey:kMPOAuthCredentialAccessTokenSecret];
[self updateAccessToken:token accessTokenSecret:secret forUserId:kDBDropboxUnknownUserId];
} else {
// These credentials are version 2 in the keychain
// These credentials are version 2 or 3 in the keychain
NSArray *allUserCredentials = [savedCredentials objectForKey:kDBDropboxUserCredentials];
for (NSDictionary *userCredentials in allUserCredentials) {
NSString *userId = [userCredentials objectForKey:kDBDropboxUserId];
NSString *token = [userCredentials objectForKey:kMPOAuthCredentialAccessToken];
NSString *secret = [userCredentials objectForKey:kMPOAuthCredentialAccessTokenSecret];
[self setAccessToken:token accessTokenSecret:secret forUserId:userId];
if (version < 3) {
// version 2 of the API used a different keychain access mode and needs
// to be set again with the newer one
[self updateAccessToken:token accessTokenSecret:secret forUserId:userId];
} else {
[self setAccessToken:token accessTokenSecret:secret forUserId:userId];
}
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion DropboxSDK/Classes/DropboxOSX-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
Expand Down
2 changes: 1 addition & 1 deletion DropboxSDK/Classes/DropboxSDK-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
Expand Down
2 changes: 2 additions & 0 deletions DropboxSDK/Classes/DropboxSDK/DBRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
NSString* resultFilename;
NSString* tempFilename;
NSDictionary* userInfo;
NSString *sourcePath;

NSHTTPURLResponse* response;
NSDictionary* xDropboxMetadataJSON;
Expand Down Expand Up @@ -55,6 +56,7 @@
@property (nonatomic, assign) SEL uploadProgressSelector; // To receive upload progress events set this
@property (nonatomic, retain) NSString* resultFilename; // The file to put the HTTP body in, otherwise body is stored in resultData
@property (nonatomic, retain) NSDictionary* userInfo;
@property (nonatomic, retain) NSString *sourcePath; // Used by methods that upload to refresh the input stream

@property (nonatomic, readonly) NSURLRequest* request;
@property (nonatomic, readonly) NSHTTPURLResponse* response;
Expand Down
7 changes: 6 additions & 1 deletion DropboxSDK/Classes/DropboxSDK/DBRestClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@
- (void)restClient:(DBRestClient *)client uploadedFileChunk:(NSString *)uploadId newOffset:(unsigned long long)offset
fromFile:(NSString *)localPath expires:(NSDate *)expiresDate;
- (void)restClient:(DBRestClient *)client uploadFileChunkFailedWithError:(NSError *)error;
- (void)restClient:(DBRestClient *)client uploadFileChunkProgress:(CGFloat)progress
forFile:(NSString *)uploadId offset:(unsigned long long)offset fromPath:(NSString *)localPath;

- (void)restClient:(DBRestClient *)client uploadedFile:(NSString *)destPath fromUploadId:(NSString *)uploadId
metadata:(DBMetadata *)metadata;
Expand Down Expand Up @@ -192,9 +194,12 @@
- (void)restClient:(DBRestClient*)client copyPathFailedWithError:(NSError*)error;
// [error userInfo] contains the root and path

- (void)restClient:(DBRestClient*)client createdCopyRef:(NSString *)copyRef;
- (void)restClient:(DBRestClient*)client createdCopyRef:(NSString *)copyRef forPath:(NSString *)path;
- (void)restClient:(DBRestClient*)client createCopyRefFailedWithError:(NSError *)error;

// Deprecated copy ref callback
- (void)restClient:(DBRestClient*)client createdCopyRef:(NSString *)copyRef;

- (void)restClient:(DBRestClient*)client copiedRef:(NSString *)copyRef to:(DBMetadata *)to;
- (void)restClient:(DBRestClient*)client copyFromRefFailedWithError:(NSError*)error;

Expand Down
4 changes: 0 additions & 4 deletions DropboxSDK/Classes/JSON/NSObject+DBJSON.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#import "NSObject+DBJSON.h"
#import "DBJsonWriter.h"

#import "DBDefines.h"


@implementation NSObject (NSObject_DBJSON)

Expand All @@ -54,5 +52,3 @@ - (NSString *)JSONRepresentation {
}

@end

DB_FIX_CATEGORY_BUG(NSObject_DBJSON)
Loading