forked from MobileOrg/mobileorg
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
1,796 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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> | ||
|
||
extern size_t EstimateBas64EncodedDataSize(size_t inDataSize); | ||
extern size_t EstimateBas64DecodedDataSize(size_t inDataSize); | ||
|
||
extern bool Base64EncodeData(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize); | ||
extern bool Base64DecodeData(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// 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* country; | ||
NSString* displayName; | ||
DBQuota* quota; | ||
NSString* userId; | ||
NSString* referralLink; | ||
NSDictionary* original; | ||
} | ||
|
||
- (id)initWithDictionary:(NSDictionary*)dict; | ||
|
||
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// DBDefines.h | ||
// DropboxSDK | ||
// | ||
// Created by Brian Smith on 8/8/11. | ||
// Copyright 2011 Dropbox, Inc. All rights reserved. | ||
// | ||
|
||
// Taken from three20 (http://three20.info/) | ||
#define DB_FIX_CATEGORY_BUG(name) @interface DB_FIX_CATEGORY_BUG##name @end @implementation DB_FIX_CATEGORY_BUG##name @end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
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 | ||
|
||
|
Oops, something went wrong.