Commit 7c9e7939 authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

Initial import

parents
Upgrade instructions
1. Right-click on the DropboxSDK group in the file browser and select Delete
2. Select "Also move to trash" option when prompted
3. Follow the installation instructions from the README to install the
newest version of the SDK
Changes from 1.3.13 to 1.3.14
- Check for and use the Dropbox EMM app for dauth if the Dropbox app is not available. You must add
dbapi-8-emm to your LSApplicationQueriesSchemes whitelist to allow the SDK to detect the Dropbox EMM app.
This is in addition to the dbapi-2 that you should already have in your LSApplicationQueriesSchemes
whitelist to detect the Dropbox app.
- Minimum iOS version raised to 6.0 to support bitcode.
- Bug fixes
Changes from 1.3.12 to 1.3.13
- Fix for "Cannot validate a certificate for the host" issue
Changes from 1.3.11 to 1.3.12
- Swift compatibility
Changes from 1.3.10 to 1.3.11
- Fix 404s on page transitions during authentication on iOS
- Upgrade project files for use with XCode 5.1
Changes from 1.3.9 to 1.3.10
- Stricter validation of server certificates on HTTP requests
- Fix an issue in DBRoulette sample when switching between users
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!
Changes from 1.3.1 to 1.3.2
- Bug fixes
- Added support for iPhone 5
Changes from 1.3 to 1.3.1
- Bug fixes
- Improved iOS 3 compatibility
- OS X SDK now mutes desktop notifications on the same machine
Changes from 1.2.3 to 1.3
- The SDK now supports uploading large files using
-[DBRestClient uploadFileChunk:offset:fromPath:] and
-[DBRestClient uploadFile:toPath:withParentRev:fromUploadId:]. See
the developers site and DBRestClient.h for more information on using them.
- There is a new method, -[DBRestClient loadSharableLinkForFile:shortUrl], that
allows you to create links that are not shortened with the db.tt url
shortener.
Changes from 1.2.2 to 1.2.3
- Cancelling from the embedded login flow on iOS now correctly sends a cancel
url to the app delegate.
Changes from 1.2.1 to 1.2.2
- Fixes for building the OS X SDK using Xcode3 and on older versions of OS X
- iOS authentication now happens inside an embedded web view if the
Dropbox app is not installed. QuartzCore is also now a required framework on
iOS, so you'll need to add it if you don't have it yet.
Changes from 1.2 to 1.2.1
- Made DropboxOSX.framework compatible with 32-bit apps
- Added the -[DBRestClient cancelAllRequests] method
- Store all access tokens in the keychain rather than userDefaults. The SDK
will migrate and remove existing credentials stored in your app's userDefaults
Changes from 1.1 to 1.2
- The copy and move delegate callbacks have been changed to return the metadata
of the file copied/moved rather than just the path it was copied/moved to.
The new delegate callbacks are named restClient:copiedPath:to: and
restClient:movedPath:to:
- DBMetadata objects have a new field, clientMtime, which is a displayable
time for the last time the files contents were modified.
- Added DropboxOSX.framework, an OSX compatible version of the Dropbox SDK
- -[DBRestClient loadDelta:] method added, which loads a list of metadata
entries that have changed since the last time the method was called.
- -[DBRestClient createCopyRef] and -[DBRestClient copyFromRef:toPath:] methods
were also added, which give you the ability to copy files between Dropboxes
without downloading and re-uploading the file
Changes from 1.0 to 1.1
- The SBJson library included in the DropboxSDK framework has been renamed to
DBJson to prevent duplicate symbols with other libraries that use SBJson
- The loadFile and loadThumbnail APIs now support callbacks that also return
metadata. loadFile - for the file being downloaded. loadThumbnail - for the
file whose thumbnail is being downloaded.
- Removed email from DBAccountInfo. This field is being deprecated from the API.
userId is the recommended way to reference an account.
- Various bug fixes
Changes from 0.3 to 1.0
- The SDK is now packaged as a framework rather than importing the source
directly into your project. This allows the SDK to work with projects
that are using ARC.
- Because the SDK is now a framework, you need to import DropboxSDK.h like this:
#import <DropboxSDK/DropboxSDK.h>
- The SDK uses an all new authentication method. First, the SDK is no longer
able to login or create accounts directly, instead you need to call link
on the DBSession object. This will launch the official iOS app if it's
installed, and Safari otherwise, and the user will have the option of
approving your app for access. See the Authentication guide on
https://www.dropbox.com/developers for more details.
- The SDK can now handle linking multiple users to the same app.
- DBMetadata objects now have a "rev" field, which deprecates the old revision
field.
- You can now load a list of past revisions for a file using
loadRevisionsForFile: on DBRestClient. This call returns a list of DBMetadata
objects that represent each revision. To restore the file to that state,
you can call restoreFile:toRev:. You can also download the contents of the
file at that state using loadFile:atRev:intoPath:.
- The upload call has been updated in several ways. First it takes an optional
parentRev parameter, which indicates the parent version of the file you are
uploading. If the file on the server does not have the same rev, it will
spin off a conflicted copy with a different name. If you do not provide a rev,
it will assume the file is new, and uploading to that file will spin off a
conflicted copy if any file with the same name exists there. The upload
DBRestClientDelegate callback also provides the metadata of the newly uploaded
file, called restClient:uploadedFile:from:metadata:. The metadata will contain
the path of the file if it is not the same as specified on upload due to
conflicts.
- Searching the contents of the user's Dropbox is now possible using the
searchPath:forKeyword: method on DBRestClient
- Generate links to files that can be shared with other users using the
loadSharableLinkForFile: method on DBRestClient
- Get a link that can be used to stream audio and video for a limited amount of
time using the loadStreamableURLForFile: method on DBRestClient
- Downloading a thumbnail of a .png or .gif will now download a .png instead of
.jpeg to cut down on artifacts
- Various bug fixes
Changes from 0.2 to 0.3
- Made DBLoginController compatibile with iOS 5
Changes from 0.1 to 0.2
DBRestClient.h:
- Various bug fixes
- Added a new upload callback that gives you the Dropbox path of the file that
was just uploaded in addition to the source path.
DBSession.h:
- You can now get a callback when a request fails due to authentication error.
Set yourself as the delegate to DBSession to get these events.
For an example of how to implement this check out DBRouletteAppDelegate
where it implements sessionDidReceiveAuthorizationFailure:
Changes from beta version in 0.1
README:
- This file now has step-by-step instructions to getting started using the SDK
DropboxSDK.h:
- A single file has been added that you can import to get all important SDK
classes
DBRestClient:
- initWithSession:root: has been deprecated. All apps are by default have
full access.
- The delegate response restClient:loadedMetadata: now returns a DBMetadata*
object instead of a raw dictionary.
- The possible delegate responses from loadMetadata:withHash: now includes
restClient:metadataUnchangedAtPath: when no changes to the metadata has
occurred since the last loadMetadata:withHash: call.
- The delegate response restClient:loadedAccountInfo: now returns a
DBAccountInfo* object.
- The delegate response restClient:createdFolder: now returns a DBMetadata*
object
DBLoginController:
- This class has been added to provide a well designed login form with an easy
to use interface for developers. It is recommended that you use it in your
app for the least amount of code and best user experience.
- Simply create it and call [loginController presentFromController:self] to
display on both iPhone and iPad
//
// DBAccountInfo.h
// DropboxSDK
//
// Created by Brian Smith on 5/3/10.
// Copyright 2010 Dropbox, Inc. All rights reserved.
//
#import "DBQuota.h"
@interface DBAccountInfo : NSObject <NSCoding> {
NSString* email;
NSString* country;
NSString* displayName;
DBQuota* quota;
NSString* userId;
NSString* referralLink;
NSDictionary* original;
}
- (id)initWithDictionary:(NSDictionary*)dict;
@property (nonatomic, readonly) NSString* email;
@property (nonatomic, readonly) NSString* country;
@property (nonatomic, readonly) NSString* displayName;
@property (nonatomic, readonly) DBQuota* quota;
@property (nonatomic, readonly) NSString* userId;
@property (nonatomic, readonly) NSString* referralLink;
@end
/*
* Base64Transcoder.h
* Base64Test
*
* Created by Jonathan Wight on Tue Mar 18 2003.
* Copyright (c) 2003 Toxic Software. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
#include <stdlib.h>
#include <stdbool.h>
size_t DBEstimateBas64EncodedDataSize(size_t inDataSize);
size_t DBEstimateBas64DecodedDataSize(size_t inDataSize);
bool DBBase64EncodeData(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize);
bool DBBase64DecodeData(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize);
//
// DBDeltaEntry.h
// DropboxSDK
//
// Created by Brian Smith on 3/25/12.
// Copyright (c) 2012 Dropbox. All rights reserved.
//
#import "DBMetadata.h"
@interface DBDeltaEntry : NSObject <NSCoding> {
NSString *lowercasePath;
DBMetadata *metadata;
}
- (id)initWithArray:(NSArray *)array;
@property (nonatomic, readonly) NSString *lowercasePath;
@property (nonatomic, readonly) DBMetadata *metadata; // nil if file has been deleted
@end
//
// DBError.h
// DropboxSDK
//
// Created by Brian Smith on 7/21/10.
// Copyright 2010 Dropbox, Inc. All rights reserved.
//
/* This file contains error codes and the dropbox error domain */
extern NSString* DBErrorDomain;
// Error codes in the dropbox.com domain represent the HTTP status code if less than 1000
typedef enum {
DBErrorNone = 0,
DBErrorGenericError = 1000,
DBErrorFileNotFound,
DBErrorInsufficientDiskSpace,
DBErrorIllegalFileType, // Error sent if you try to upload a directory
DBErrorInvalidResponse, // Sent when the client does not get valid JSON when it's expecting it
} DBErrorCode;
/*
Copyright (C) 2007-2009 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import "DBJsonParser.h"
#import "DBJsonWriter.h"
/**
@brief Facade for DBJsonWriter/DBJsonParser.
Requests are forwarded to instances of DBJsonWriter and DBJsonParser.
*/
@interface DBJSON : DBJsonBase <DBJsonParser, DBJsonWriter> {
@private
DBJsonParser *jsonParser;
DBJsonWriter *jsonWriter;
}
/// Return the fragment represented by the given string
- (id)fragmentWithString:(NSString*)jsonrep
error:(NSError**)error;
/// Return the object represented by the given string
- (id)objectWithString:(NSString*)jsonrep
error:(NSError**)error;
/// Parse the string and return the represented object (or scalar)
- (id)objectWithString:(id)value
allowScalar:(BOOL)x
error:(NSError**)error;
/// Return JSON representation of an array or dictionary
- (NSString*)stringWithObject:(id)value
error:(NSError**)error;
/// Return JSON representation of any legal JSON value
- (NSString*)stringWithFragment:(id)value
error:(NSError**)error;
/// Return JSON representation (or fragment) for the given object
- (NSString*)stringWithObject:(id)value
allowScalar:(BOOL)x
error:(NSError**)error;
@end
/*
Copyright (C) 2009 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
extern NSString * DBJSONErrorDomain;
enum {
EUNSUPPORTED = 1,
EPARSENUM,
EPARSE,
EFRAGMENT,
ECTRL,
EUNICODE,
EDEPTH,
EESCAPE,
ETRAILCOMMA,
ETRAILGARBAGE,
EEOF,
EINPUT
};
/**
@brief Common base class for parsing & writing.
This class contains the common error-handling code and option between the parser/writer.
*/
@interface DBJsonBase : NSObject {
NSMutableArray *errorTrace;
@protected
NSUInteger depth, maxDepth;
}
/**
@brief The maximum recursing depth.
Defaults to 512. If the input is nested deeper than this the input will be deemed to be
malicious and the parser returns nil, signalling an error. ("Nested too deep".) You can
turn off this security feature by setting the maxDepth value to 0.
*/
@property NSUInteger maxDepth;
/**
@brief Return an error trace, or nil if there was no errors.
Note that this method returns the trace of the last method that failed.
You need to check the return value of the call you're making to figure out
if the call actually failed, before you know call this method.
*/
@property(copy,readonly) NSArray* errorTrace;
/// @internal for use in subclasses to add errors to the stack trace
- (void)addErrorWithCode:(NSUInteger)code description:(NSString*)str;
/// @internal for use in subclasess to clear the error before a new parsing attempt
- (void)clearErrorTrace;
@end
/*
Copyright (C) 2009 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import "DBJsonBase.h"
/**
@brief Options for the parser class.
This exists so the DBJSON facade can implement the options in the parser without having to re-declare them.
*/
@protocol DBJsonParser
/**
@brief Return the object represented by the given string.
Returns the object represented by the passed-in string or nil on error. The returned object can be
a string, number, boolean, null, array or dictionary.
@param repr the json string to parse
*/
- (id)objectWithString:(NSString *)repr;
@end
/**
@brief The JSON parser class.
JSON is mapped to Objective-C types in the following way:
@li Null -> NSNull
@li String -> NSMutableString
@li Array -> NSMutableArray
@li Object -> NSMutableDictionary
@li Boolean -> NSNumber (initialised with -initWithBool:)
@li Number -> NSDecimalNumber
Since Objective-C doesn't have a dedicated class for boolean values, these turns into NSNumber
instances. These are initialised with the -initWithBool: method, and
round-trip back to JSON properly. (They won't silently suddenly become 0 or 1; they'll be
represented as 'true' and 'false' again.)
JSON numbers turn into NSDecimalNumber instances,
as we can thus avoid any loss of precision. (JSON allows ridiculously large numbers.)
*/
@interface DBJsonParser : DBJsonBase <DBJsonParser> {
@private
const char *c;
}
@end
// don't use - exists for backwards compatibility with 2.1.x only. Will be removed in 2.3.
@interface DBJsonParser (Private)
- (id)fragmentWithString:(id)repr;
@end
/*
Copyright (C) 2009 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import "DBJsonBase.h"
/**
@brief Options for the writer class.
This exists so the DBJSON facade can implement the options in the writer without having to re-declare them.
*/
@protocol DBJsonWriter
/**
@brief Whether we are generating human-readable (multiline) JSON.
Set whether or not to generate human-readable JSON. The default is NO, which produces
JSON without any whitespace. (Except inside strings.) If set to YES, generates human-readable
JSON with linebreaks after each array value and dictionary key/value pair, indented two
spaces per nesting level.
*/
@property BOOL humanReadable;
/**
@brief Whether or not to sort the dictionary keys in the output.
If this is set to YES, the dictionary keys in the JSON output will be in sorted order.
(This is useful if you need to compare two structures, for example.) The default is NO.
*/
@property BOOL sortKeys;
/**
@brief Return JSON representation (or fragment) for the given object.