├── GoogleDriveSample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── GoogleDriveSample ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── GTL │ ├── GTLBase64.h │ ├── GTLBase64.m │ ├── GTLBatchQuery.h │ ├── GTLBatchQuery.m │ ├── GTLBatchResult.h │ ├── GTLBatchResult.m │ ├── GTLDateTime.h │ ├── GTLDateTime.m │ ├── GTLDefines.h │ ├── GTLErrorObject.h │ ├── GTLErrorObject.m │ ├── GTLFramework.h │ ├── GTLFramework.m │ ├── GTLJSONParser.h │ ├── GTLJSONParser.m │ ├── GTLObject.h │ ├── GTLObject.m │ ├── GTLQuery.h │ ├── GTLQuery.m │ ├── GTLRuntimeCommon.h │ ├── GTLRuntimeCommon.m │ ├── GTLService.h │ ├── GTLService.m │ ├── GTLTargetNamespace.h │ ├── GTLUploadParameters.h │ ├── GTLUploadParameters.m │ ├── GTLUtilities.h │ ├── GTLUtilities.m │ ├── GTMGatherInputStream.h │ ├── GTMGatherInputStream.m │ ├── GTMHTTPFetchHistory.h │ ├── GTMHTTPFetchHistory.m │ ├── GTMHTTPFetcher.h │ ├── GTMHTTPFetcher.m │ ├── GTMHTTPFetcherLogging.h │ ├── GTMHTTPFetcherLogging.m │ ├── GTMHTTPFetcherService.h │ ├── GTMHTTPFetcherService.m │ ├── GTMHTTPUploadFetcher.h │ ├── GTMHTTPUploadFetcher.m │ ├── GTMMIMEDocument.h │ ├── GTMMIMEDocument.m │ ├── GTMOAuth2Authentication.h │ ├── GTMOAuth2Authentication.m │ ├── GTMOAuth2SignIn.h │ ├── GTMOAuth2SignIn.m │ ├── GTMOAuth2ViewControllerTouch.h │ ├── GTMOAuth2ViewControllerTouch.m │ ├── GTMOAuth2ViewTouch.xib │ ├── GTMReadMonitorInputStream.h │ └── GTMReadMonitorInputStream.m ├── GoogleDrive │ ├── GTLDrive.h │ ├── GTLDriveAbout.h │ ├── GTLDriveAbout.m │ ├── GTLDriveApp.h │ ├── GTLDriveApp.m │ ├── GTLDriveAppList.h │ ├── GTLDriveAppList.m │ ├── GTLDriveChange.h │ ├── GTLDriveChange.m │ ├── GTLDriveChangeList.h │ ├── GTLDriveChangeList.m │ ├── GTLDriveChannel.h │ ├── GTLDriveChannel.m │ ├── GTLDriveChildList.h │ ├── GTLDriveChildList.m │ ├── GTLDriveChildReference.h │ ├── GTLDriveChildReference.m │ ├── GTLDriveComment.h │ ├── GTLDriveComment.m │ ├── GTLDriveCommentList.h │ ├── GTLDriveCommentList.m │ ├── GTLDriveCommentReply.h │ ├── GTLDriveCommentReply.m │ ├── GTLDriveCommentReplyList.h │ ├── GTLDriveCommentReplyList.m │ ├── GTLDriveConstants.h │ ├── GTLDriveConstants.m │ ├── GTLDriveFile.h │ ├── GTLDriveFile.m │ ├── GTLDriveFileList.h │ ├── GTLDriveFileList.m │ ├── GTLDriveParentList.h │ ├── GTLDriveParentList.m │ ├── GTLDriveParentReference.h │ ├── GTLDriveParentReference.m │ ├── GTLDrivePermission.h │ ├── GTLDrivePermission.m │ ├── GTLDrivePermissionId.h │ ├── GTLDrivePermissionId.m │ ├── GTLDrivePermissionList.h │ ├── GTLDrivePermissionList.m │ ├── GTLDriveProperty.h │ ├── GTLDriveProperty.m │ ├── GTLDrivePropertyList.h │ ├── GTLDrivePropertyList.m │ ├── GTLDriveRevision.h │ ├── GTLDriveRevision.m │ ├── GTLDriveRevisionList.h │ ├── GTLDriveRevisionList.m │ ├── GTLDriveUser.h │ ├── GTLDriveUser.m │ ├── GTLQueryDrive.h │ ├── GTLQueryDrive.m │ ├── GTLServiceDrive.h │ └── GTLServiceDrive.m ├── GoogleDriveSample-Bridging-Header.h ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Info.plist └── ViewController.swift ├── GoogleDriveSampleTests ├── GoogleDriveSampleTests.swift └── Info.plist └── README.md /GoogleDriveSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GoogleDriveSample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // GoogleDriveSample 4 | // 5 | // Created by Ng Hui Qin on 4/9/15. 6 | // Copyright (c) 2015 huiqin.testing. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /GoogleDriveSample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /GoogleDriveSample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLBase64.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | NSData *GTLDecodeBase64(NSString *base64Str); 19 | NSString *GTLEncodeBase64(NSData *data); 20 | 21 | // "Web-safe" encoding substitutes - and _ for + and / in the encoding table, 22 | // per http://www.ietf.org/rfc/rfc4648.txt section 5. 23 | 24 | NSData *GTLDecodeWebSafeBase64(NSString *base64Str); 25 | NSString *GTLEncodeWebSafeBase64(NSData *data); 26 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLBase64.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GTLBase64.h" 17 | 18 | // Based on Cyrus Najmabadi's elegent little encoder and decoder from 19 | // http://www.cocoadev.com/index.pl?BaseSixtyFour 20 | 21 | static char gStandardEncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 22 | static char gWebSafeEncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; 23 | 24 | #pragma mark Encode 25 | 26 | static NSString *EncodeBase64StringCommon(NSData *data, const char *table) { 27 | if (data == nil) return nil; 28 | 29 | const uint8_t* input = [data bytes]; 30 | NSUInteger length = [data length]; 31 | 32 | NSUInteger bufferSize = ((length + 2) / 3) * 4; 33 | NSMutableData* buffer = [NSMutableData dataWithLength:bufferSize]; 34 | 35 | int8_t *output = [buffer mutableBytes]; 36 | 37 | for (NSUInteger i = 0; i < length; i += 3) { 38 | NSUInteger value = 0; 39 | for (NSUInteger j = i; j < (i + 3); j++) { 40 | value <<= 8; 41 | 42 | if (j < length) { 43 | value |= (0xFF & input[j]); 44 | } 45 | } 46 | 47 | NSInteger idx = (i / 3) * 4; 48 | output[idx + 0] = table[(value >> 18) & 0x3F]; 49 | output[idx + 1] = table[(value >> 12) & 0x3F]; 50 | output[idx + 2] = (i + 1) < length ? table[(value >> 6) & 0x3F] : '='; 51 | output[idx + 3] = (i + 2) < length ? table[(value >> 0) & 0x3F] : '='; 52 | } 53 | 54 | NSString *result = [[[NSString alloc] initWithData:buffer 55 | encoding:NSASCIIStringEncoding] autorelease]; 56 | return result; 57 | } 58 | 59 | NSString *GTLEncodeBase64(NSData *data) { 60 | return EncodeBase64StringCommon(data, gStandardEncodingTable); 61 | } 62 | 63 | NSString *GTLEncodeWebSafeBase64(NSData *data) { 64 | return EncodeBase64StringCommon(data, gWebSafeEncodingTable); 65 | } 66 | 67 | #pragma mark Decode 68 | 69 | static void CreateDecodingTable(const char *encodingTable, 70 | size_t encodingTableSize, char *decodingTable) { 71 | memset(decodingTable, 0, 128); 72 | for (unsigned int i = 0; i < encodingTableSize; i++) { 73 | decodingTable[(unsigned int) encodingTable[i]] = (char)i; 74 | } 75 | } 76 | 77 | static NSData *DecodeBase64StringCommon(NSString *base64Str, 78 | char *decodingTable) { 79 | // The input string should be plain ASCII 80 | const char *cString = [base64Str cStringUsingEncoding:NSASCIIStringEncoding]; 81 | if (cString == nil) return nil; 82 | 83 | NSInteger inputLength = (NSInteger)strlen(cString); 84 | if (inputLength % 4 != 0) return nil; 85 | if (inputLength == 0) return [NSData data]; 86 | 87 | while (inputLength > 0 && cString[inputLength - 1] == '=') { 88 | inputLength--; 89 | } 90 | 91 | NSInteger outputLength = inputLength * 3 / 4; 92 | NSMutableData* data = [NSMutableData dataWithLength:(NSUInteger)outputLength]; 93 | uint8_t *output = [data mutableBytes]; 94 | 95 | NSInteger inputPoint = 0; 96 | NSInteger outputPoint = 0; 97 | char *table = decodingTable; 98 | 99 | while (inputPoint < inputLength) { 100 | int i0 = cString[inputPoint++]; 101 | int i1 = cString[inputPoint++]; 102 | int i2 = inputPoint < inputLength ? cString[inputPoint++] : 'A'; // 'A' will decode to \0 103 | int i3 = inputPoint < inputLength ? cString[inputPoint++] : 'A'; 104 | 105 | output[outputPoint++] = (uint8_t)((table[i0] << 2) | (table[i1] >> 4)); 106 | if (outputPoint < outputLength) { 107 | output[outputPoint++] = (uint8_t)(((table[i1] & 0xF) << 4) | (table[i2] >> 2)); 108 | } 109 | if (outputPoint < outputLength) { 110 | output[outputPoint++] = (uint8_t)(((table[i2] & 0x3) << 6) | table[i3]); 111 | } 112 | } 113 | 114 | return data; 115 | } 116 | 117 | NSData *GTLDecodeBase64(NSString *base64Str) { 118 | static char decodingTable[128]; 119 | static BOOL hasInited = NO; 120 | 121 | if (!hasInited) { 122 | CreateDecodingTable(gStandardEncodingTable, sizeof(gStandardEncodingTable), 123 | decodingTable); 124 | hasInited = YES; 125 | } 126 | return DecodeBase64StringCommon(base64Str, decodingTable); 127 | } 128 | 129 | NSData *GTLDecodeWebSafeBase64(NSString *base64Str) { 130 | static char decodingTable[128]; 131 | static BOOL hasInited = NO; 132 | 133 | if (!hasInited) { 134 | CreateDecodingTable(gWebSafeEncodingTable, sizeof(gWebSafeEncodingTable), 135 | decodingTable); 136 | hasInited = YES; 137 | } 138 | return DecodeBase64StringCommon(base64Str, decodingTable); 139 | } 140 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLBatchQuery.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLBatchQuery.h 18 | // 19 | 20 | // Batch query documentation: 21 | // https://code.google.com/p/google-api-objectivec-client/wiki/Introduction#Batch_Operations 22 | 23 | #import "GTLQuery.h" 24 | 25 | @interface GTLBatchQuery : NSObject { 26 | @private 27 | NSMutableArray *queries_; 28 | NSMutableDictionary *requestIDMap_; 29 | BOOL skipAuthorization_; 30 | NSDictionary *additionalHTTPHeaders_; 31 | NSDictionary *urlQueryParameters_; 32 | GTLQueryTestBlock testBlock_; 33 | } 34 | 35 | // Queries included in this batch. Each query should have a unique requestID. 36 | @property (retain) NSArray *queries; 37 | 38 | // Clients may set this to YES to disallow authorization. Defaults to NO. 39 | @property (assign) BOOL shouldSkipAuthorization; 40 | 41 | // Any additional HTTP headers for this batch. 42 | // 43 | // These headers override the same keys from the service object's 44 | // additionalHTTPHeaders. 45 | @property (copy) NSDictionary *additionalHTTPHeaders; 46 | 47 | // Any URL query parameters to add to the query (useful for debugging with some 48 | // services). 49 | @property (copy) NSDictionary *urlQueryParameters; 50 | 51 | // Apps may provide a test block on the query or service to avoid network activity 52 | // during testing. 53 | // 54 | // See the description of GTLQueryTestBlock for additional details. 55 | @property (copy) GTLQueryTestBlock testBlock; 56 | 57 | + (id)batchQuery; 58 | + (id)batchQueryWithQueries:(NSArray *)array; 59 | 60 | - (void)addQuery:(GTLQuery *)query GTL_NONNULL((1)); 61 | 62 | - (GTLQuery *)queryForRequestID:(NSString *)requestID GTL_NONNULL((1)); 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLBatchQuery.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLBatchQuery.m 18 | // 19 | 20 | #import "GTLBatchQuery.h" 21 | 22 | @implementation GTLBatchQuery 23 | 24 | @synthesize shouldSkipAuthorization = skipAuthorization_, 25 | additionalHTTPHeaders = additionalHTTPHeaders_, 26 | urlQueryParameters = urlQueryParameters_, 27 | testBlock = testBlock_; 28 | 29 | + (id)batchQuery { 30 | GTLBatchQuery *obj = [[[self alloc] init] autorelease]; 31 | return obj; 32 | } 33 | 34 | + (id)batchQueryWithQueries:(NSArray *)queries { 35 | GTLBatchQuery *obj = [self batchQuery]; 36 | obj.queries = queries; 37 | return obj; 38 | } 39 | 40 | - (id)copyWithZone:(NSZone *)zone { 41 | // Deep copy the list of queries 42 | NSArray *copiesOfQueries = [[[NSArray alloc] initWithArray:self.queries 43 | copyItems:YES] autorelease]; 44 | GTLBatchQuery *newBatch = [[[self class] allocWithZone:zone] init]; 45 | newBatch.queries = copiesOfQueries; 46 | newBatch.shouldSkipAuthorization = self.shouldSkipAuthorization; 47 | newBatch.additionalHTTPHeaders = self.additionalHTTPHeaders; 48 | newBatch.testBlock = self.testBlock; 49 | return newBatch; 50 | } 51 | 52 | - (void)dealloc { 53 | [queries_ release]; 54 | [additionalHTTPHeaders_ release]; 55 | [urlQueryParameters_ release]; 56 | [requestIDMap_ release]; 57 | [testBlock_ release]; 58 | 59 | [super dealloc]; 60 | } 61 | 62 | - (NSString *)description { 63 | NSArray *queries = self.queries; 64 | NSArray *methodNames = [queries valueForKey:@"methodName"]; 65 | NSArray *dedupedNames = [[NSSet setWithArray:methodNames] allObjects]; 66 | NSString *namesStr = [dedupedNames componentsJoinedByString:@","]; 67 | 68 | return [NSString stringWithFormat:@"%@ %p (queries:%lu methods:%@)", 69 | [self class], self, (unsigned long) [queries count], namesStr]; 70 | } 71 | 72 | #pragma mark - 73 | 74 | - (BOOL)isBatchQuery { 75 | return YES; 76 | } 77 | 78 | - (GTLUploadParameters *)uploadParameters { 79 | // File upload is not supported for batches 80 | return nil; 81 | } 82 | 83 | - (void)executionDidStop { 84 | NSArray *queries = self.queries; 85 | [queries makeObjectsPerformSelector:@selector(executionDidStop)]; 86 | } 87 | 88 | - (GTLQuery *)queryForRequestID:(NSString *)requestID { 89 | GTLQuery *result = [requestIDMap_ objectForKey:requestID]; 90 | if (result) return result; 91 | 92 | // We've not before tried to look up a query, or the map is stale 93 | [requestIDMap_ release]; 94 | requestIDMap_ = [[NSMutableDictionary alloc] init]; 95 | 96 | for (GTLQuery *query in queries_) { 97 | [requestIDMap_ setObject:query forKey:query.requestID]; 98 | } 99 | 100 | result = [requestIDMap_ objectForKey:requestID]; 101 | return result; 102 | } 103 | 104 | #pragma mark - 105 | 106 | - (void)setQueries:(NSArray *)array { 107 | #if DEBUG 108 | for (id obj in array) { 109 | GTLQuery *query = obj; 110 | GTL_DEBUG_ASSERT([query isKindOfClass:[GTLQuery class]], 111 | @"unexpected query class: %@", [obj class]); 112 | GTL_DEBUG_ASSERT(query.uploadParameters == nil, 113 | @"batch may not contain upload: %@", query); 114 | } 115 | #endif 116 | 117 | [queries_ autorelease]; 118 | queries_ = [array mutableCopy]; 119 | } 120 | 121 | - (NSArray *)queries { 122 | return queries_; 123 | } 124 | 125 | - (void)addQuery:(GTLQuery *)query { 126 | GTL_DEBUG_ASSERT([query isKindOfClass:[GTLQuery class]], 127 | @"unexpected query class: %@", [query class]); 128 | GTL_DEBUG_ASSERT(query.uploadParameters == nil, 129 | @"batch may not contain upload: %@", query); 130 | 131 | if (queries_ == nil) { 132 | queries_ = [[NSMutableArray alloc] init]; 133 | } 134 | 135 | [queries_ addObject:query]; 136 | } 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLBatchResult.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLBatchResult.h 18 | // 19 | 20 | #import "GTLObject.h" 21 | 22 | @interface GTLBatchResult : GTLObject { 23 | @private 24 | NSMutableDictionary *successes_; 25 | NSMutableDictionary *failures_; 26 | } 27 | 28 | // Dictionaries of results for all queries in the batch 29 | // 30 | // Dictionary keys are requestID strings; objects are results or 31 | // GTLErrorObjects. 32 | // 33 | // For successes with no returned object (such as from delete operations), 34 | // the object for the dictionary entry is NSNull. 35 | // 36 | // 37 | // The original query for each result is available from the service ticket, 38 | // for example 39 | // 40 | // NSDictionary *successes = batchResults.successes; 41 | // for (NSString *requestID in successes) { 42 | // GTLObject *obj = [successes objectForKey:requestID]; 43 | // GTLQuery *query = [ticket queryForRequestID:requestID]; 44 | // NSLog(@"Query %@ returned object %@", query, obj); 45 | // } 46 | // 47 | // NSDictionary *failures = batchResults.failures; 48 | // for (NSString *requestID in failures) { 49 | // GTLErrorObject *errorObj = [failures objectForKey:requestID]; 50 | // GTLQuery *query = [ticket queryForRequestID:requestID]; 51 | // NSLog(@"Query %@ failed with error %@", query, errorObj); 52 | // } 53 | // 54 | 55 | @property (retain) NSMutableDictionary *successes; 56 | @property (retain) NSMutableDictionary *failures; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLBatchResult.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLBatchResult.m 18 | // 19 | 20 | #import "GTLBatchResult.h" 21 | 22 | #import "GTLErrorObject.h" 23 | 24 | @implementation GTLBatchResult 25 | 26 | @synthesize successes = successes_, 27 | failures = failures_; 28 | 29 | - (id)copyWithZone:(NSZone *)zone { 30 | GTLBatchResult* newObject = [super copyWithZone:zone]; 31 | newObject.successes = [[self.successes mutableCopyWithZone:zone] autorelease]; 32 | newObject.failures = [[self.failures mutableCopyWithZone:zone] autorelease]; 33 | return newObject; 34 | } 35 | 36 | - (void)dealloc { 37 | [successes_ release]; 38 | [failures_ release]; 39 | 40 | [super dealloc]; 41 | } 42 | 43 | - (NSString *)description { 44 | return [NSString stringWithFormat:@"%@ %p (successes:%lu failures:%lu)", 45 | [self class], self, 46 | (unsigned long) [self.successes count], 47 | (unsigned long) [self.failures count]]; 48 | } 49 | 50 | #pragma mark - 51 | 52 | - (void)createItemsWithClassMap:(NSDictionary *)batchClassMap { 53 | // This is called by GTLObject objectForJSON:defaultClass: 54 | // JSON is defined to be a dictionary, but for batch results, it really 55 | // is any array. 56 | id json = self.JSON; 57 | GTL_DEBUG_ASSERT([json isKindOfClass:[NSArray class]], 58 | @"didn't get an array for the batch results"); 59 | NSArray *jsonArray = json; 60 | 61 | NSMutableDictionary *successes = [NSMutableDictionary dictionary]; 62 | NSMutableDictionary *failures = [NSMutableDictionary dictionary]; 63 | 64 | for (NSMutableDictionary *rpcResponse in jsonArray) { 65 | NSString *responseID = [rpcResponse objectForKey:@"id"]; 66 | 67 | NSMutableDictionary *errorJSON = [rpcResponse objectForKey:@"error"]; 68 | if (errorJSON) { 69 | GTLErrorObject *errorObject = [GTLErrorObject objectWithJSON:errorJSON]; 70 | [failures setValue:errorObject forKey:responseID]; 71 | } else { 72 | NSMutableDictionary *resultJSON = [rpcResponse objectForKey:@"result"]; 73 | 74 | NSDictionary *surrogates = self.surrogates; 75 | Class defaultClass = [batchClassMap objectForKey:responseID]; 76 | 77 | id resultObject = [[self class] objectForJSON:resultJSON 78 | defaultClass:defaultClass 79 | surrogates:surrogates 80 | batchClassMap:nil]; 81 | if (resultObject == nil) { 82 | // methods like delete return no object 83 | resultObject = [NSNull null]; 84 | } 85 | [successes setValue:resultObject forKey:responseID]; 86 | } 87 | } 88 | self.successes = successes; 89 | self.failures = failures; 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLDateTime.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDateTime.h 18 | // 19 | // This is an immutable class representing a date and optionally a 20 | // time with time zone. 21 | // 22 | 23 | #import 24 | #import "GTLDefines.h" 25 | 26 | @interface GTLDateTime : NSObject { 27 | NSDateComponents *dateComponents_; 28 | NSInteger milliseconds_; // This is only for the fraction of a second 0-999 29 | NSInteger offsetSeconds_; // may be NSUndefinedDateComponent 30 | BOOL isUniversalTime_; // preserves "Z" 31 | NSTimeZone *timeZone_; // specific time zone by name, if known 32 | } 33 | 34 | + (GTLDateTime *)dateTimeWithRFC3339String:(NSString *)str; 35 | 36 | // timeZone may be nil if the time zone is not known. 37 | + (GTLDateTime *)dateTimeWithDate:(NSDate *)date timeZone:(NSTimeZone *)tz; 38 | 39 | // Use this method to make a dateTime for an all-day event (date only, so 40 | // hasTime is NO.) 41 | + (GTLDateTime *)dateTimeForAllDayWithDate:(NSDate *)date; 42 | 43 | + (GTLDateTime *)dateTimeWithDateComponents:(NSDateComponents *)date; 44 | 45 | @property (nonatomic, readonly) NSDate *date; 46 | @property (nonatomic, readonly) NSCalendar *calendar; 47 | 48 | @property (nonatomic, readonly) NSString *RFC3339String; 49 | @property (nonatomic, readonly) NSString *stringValue; // same as RFC3339String 50 | 51 | @property (nonatomic, readonly, retain) NSTimeZone *timeZone; 52 | @property (nonatomic, readonly, copy) NSDateComponents *dateComponents; 53 | @property (nonatomic, readonly) NSInteger milliseconds; // This is only for the fraction of a second 0-999 54 | 55 | @property (nonatomic, readonly) BOOL hasTime; 56 | @property (nonatomic, readonly) NSInteger offsetSeconds; 57 | @property (nonatomic, readonly, getter=isUniversalTime) BOOL universalTime; 58 | 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLDefines.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDefines.h 18 | // 19 | 20 | // Ensure Apple's conditionals we depend on are defined. 21 | #import 22 | #import 23 | 24 | // 25 | // The developer may choose to define these in the project: 26 | // 27 | // #define GTL_TARGET_NAMESPACE Xxx // preface all GTL class names with Xxx (recommended for building plug-ins) 28 | // #define GTL_FOUNDATION_ONLY 1 // builds without AppKit or Carbon (default for iPhone builds) 29 | // #define STRIP_GTM_FETCH_LOGGING 1 // omit http logging code (default for iPhone release builds) 30 | // 31 | // Mac developers may find GTL_SIMPLE_DESCRIPTIONS and STRIP_GTM_FETCH_LOGGING useful for 32 | // reducing code size. 33 | // 34 | 35 | // Define later OS versions when building on earlier versions 36 | #ifdef MAC_OS_X_VERSION_10_0 37 | #ifndef MAC_OS_X_VERSION_10_6 38 | #define MAC_OS_X_VERSION_10_6 1060 39 | #endif 40 | #endif 41 | 42 | 43 | #ifdef GTL_TARGET_NAMESPACE 44 | // prefix all GTL class names with GTL_TARGET_NAMESPACE for this target 45 | #import "GTLTargetNamespace.h" 46 | #endif 47 | 48 | // Provide a common definition for externing constants/functions 49 | #if defined(__cplusplus) 50 | #define GTL_EXTERN extern "C" 51 | #else 52 | #define GTL_EXTERN extern 53 | #endif 54 | 55 | #if TARGET_OS_IPHONE // iPhone SDK 56 | 57 | #define GTL_IPHONE 1 58 | 59 | #endif 60 | 61 | #if GTL_IPHONE 62 | 63 | #define GTL_FOUNDATION_ONLY 1 64 | 65 | #endif 66 | 67 | // 68 | // GTL_ASSERT is like NSAssert, but takes a variable number of arguments: 69 | // 70 | // GTL_ASSERT(condition, @"Problem in argument %@", argStr); 71 | // 72 | // GTL_DEBUG_ASSERT is similar, but compiles in only for debug builds 73 | // 74 | 75 | #ifndef GTL_ASSERT 76 | // we directly invoke the NSAssert handler so we can pass on the varargs 77 | #if !defined(NS_BLOCK_ASSERTIONS) 78 | #define GTL_ASSERT(condition, ...) \ 79 | do { \ 80 | if (!(condition)) { \ 81 | [[NSAssertionHandler currentHandler] \ 82 | handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] \ 83 | file:[NSString stringWithUTF8String:__FILE__] \ 84 | lineNumber:__LINE__ \ 85 | description:__VA_ARGS__]; \ 86 | } \ 87 | } while(0) 88 | #else 89 | #define GTL_ASSERT(condition, ...) do { } while (0) 90 | #endif // !defined(NS_BLOCK_ASSERTIONS) 91 | #endif // GTL_ASSERT 92 | 93 | #ifndef GTL_DEBUG_ASSERT 94 | #if DEBUG 95 | #define GTL_DEBUG_ASSERT(condition, ...) GTL_ASSERT(condition, __VA_ARGS__) 96 | #else 97 | #define GTL_DEBUG_ASSERT(condition, ...) do { } while (0) 98 | #endif 99 | #endif 100 | 101 | #ifndef GTL_DEBUG_LOG 102 | #if DEBUG 103 | #define GTL_DEBUG_LOG(...) NSLog(__VA_ARGS__) 104 | #else 105 | #define GTL_DEBUG_LOG(...) do { } while (0) 106 | #endif 107 | #endif 108 | 109 | #ifndef STRIP_GTM_FETCH_LOGGING 110 | #if GTL_IPHONE && !DEBUG 111 | #define STRIP_GTM_FETCH_LOGGING 1 112 | #else 113 | #define STRIP_GTM_FETCH_LOGGING 0 114 | #endif 115 | #endif 116 | 117 | // Some support for advanced clang static analysis functionality 118 | // See http://clang-analyzer.llvm.org/annotations.html 119 | #ifndef __has_feature // Optional. 120 | #define __has_feature(x) 0 // Compatibility with non-clang compilers. 121 | #endif 122 | #ifndef NS_RETURNS_NOT_RETAINED 123 | #if __has_feature(attribute_ns_returns_not_retained) 124 | #define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained)) 125 | #else 126 | #define NS_RETURNS_NOT_RETAINED 127 | #endif 128 | #endif 129 | 130 | #ifndef __has_attribute 131 | #define __has_attribute(x) 0 132 | #endif 133 | 134 | #if 1 135 | // We will start using nonnull declarations once the static analyzer seems 136 | // to support it without false positives. 137 | #define GTL_NONNULL(x) 138 | #else 139 | #if __has_attribute(nonnull) 140 | #define GTL_NONNULL(x) __attribute__((nonnull x)) 141 | #else 142 | #define GTL_NONNULL(x) 143 | #endif 144 | #endif 145 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLErrorObject.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLErrorObject.h 18 | // 19 | 20 | #import "GTLObject.h" 21 | 22 | @class GTLErrorObjectData; 23 | 24 | @interface GTLErrorObject : GTLObject 25 | @property (retain) NSNumber *code; 26 | @property (retain) NSString *message; 27 | @property (retain) NSArray *data; // of GTLErrorObjectData 28 | 29 | // Convenience accessor for creating an NSError from a GTLErrorObject. 30 | @property (readonly) NSError *foundationError; 31 | 32 | // Convenience accessor for extracting the GTLErrorObject that was used to 33 | // create an NSError. 34 | // 35 | // Returns nil if the error was not originally from a GTLErrorObject. 36 | + (GTLErrorObject *)underlyingObjectForError:(NSError *)foundationError; 37 | 38 | @end 39 | 40 | @interface GTLErrorObjectData : GTLObject 41 | @property (retain) NSString *domain; 42 | @property (retain) NSString *reason; 43 | @property (retain) NSString *message; 44 | @property (retain) NSString *location; 45 | @end 46 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLErrorObject.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLErrorObject.m 18 | // 19 | 20 | #import "GTLErrorObject.h" 21 | #import "GTLService.h" 22 | 23 | @implementation GTLErrorObject 24 | 25 | @dynamic code; 26 | @dynamic message; 27 | @dynamic data; 28 | 29 | + (NSDictionary *)arrayPropertyToClassMap { 30 | NSDictionary *map = [NSDictionary dictionaryWithObject:[GTLErrorObjectData class] 31 | forKey:@"data"]; 32 | return map; 33 | } 34 | 35 | - (NSError *)foundationError { 36 | NSMutableDictionary *userInfo; 37 | 38 | // This structured GTLErrorObject will be available in the error's userInfo 39 | // dictionary 40 | userInfo = [NSMutableDictionary dictionaryWithObject:self 41 | forKey:kGTLStructuredErrorKey]; 42 | 43 | NSString *reasonStr = self.message; 44 | if (reasonStr) { 45 | // We always store an error in the userInfo key "error" 46 | [userInfo setObject:reasonStr 47 | forKey:kGTLServerErrorStringKey]; 48 | 49 | // Store a user-readable "reason" to show up when an error is logged, 50 | // in parentheses like NSError does it 51 | NSString *parenthesized = [NSString stringWithFormat:@"(%@)", reasonStr]; 52 | [userInfo setObject:parenthesized 53 | forKey:NSLocalizedFailureReasonErrorKey]; 54 | } 55 | 56 | NSInteger code = [self.code integerValue]; 57 | NSError *error = [NSError errorWithDomain:kGTLJSONRPCErrorDomain 58 | code:code 59 | userInfo:userInfo]; 60 | return error; 61 | } 62 | 63 | + (GTLErrorObject *)underlyingObjectForError:(NSError *)foundationError { 64 | NSDictionary *userInfo = [foundationError userInfo]; 65 | GTLErrorObject *errorObj = [userInfo objectForKey:kGTLStructuredErrorKey]; 66 | return errorObj; 67 | } 68 | 69 | @end 70 | 71 | @implementation GTLErrorObjectData 72 | @dynamic domain; 73 | @dynamic reason; 74 | @dynamic message; 75 | @dynamic location; 76 | @end 77 | 78 | 79 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLFramework.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 17 | #ifndef _GTLFRAMEWORK_H_ 18 | #define _GTLFRAMEWORK_H_ 19 | 20 | #import 21 | 22 | #import "GTLDefines.h" 23 | 24 | 25 | // Returns the version of the framework. Major and minor should 26 | // match the bundle version in the Info.plist file. 27 | // 28 | // Pass NULL to ignore any of the parameters. 29 | 30 | void GTLFrameworkVersion(NSUInteger* major, NSUInteger* minor, NSUInteger* release); 31 | 32 | // Returns the version in @"a.b" or @"a.b.c" format 33 | NSString *GTLFrameworkVersionString(void); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLFramework.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #include "GTLFramework.h" 17 | 18 | void GTLFrameworkVersion(NSUInteger* major, NSUInteger* minor, NSUInteger* release) { 19 | // version 2.0.0 20 | if (major) *major = 2; 21 | if (minor) *minor = 0; 22 | if (release) *release = 0; 23 | } 24 | 25 | NSString *GTLFrameworkVersionString(void) { 26 | NSUInteger major, minor, release; 27 | NSString *libVersionString; 28 | 29 | GTLFrameworkVersion(&major, &minor, &release); 30 | 31 | // most library releases will have a release value of zero 32 | if (release != 0) { 33 | libVersionString = [NSString stringWithFormat:@"%d.%d.%d", 34 | (int)major, (int)minor, (int)release]; 35 | } else { 36 | libVersionString = [NSString stringWithFormat:@"%d.%d", 37 | (int)major, (int)minor]; 38 | } 39 | return libVersionString; 40 | } 41 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLJSONParser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLJSONParser.h 18 | // 19 | 20 | // This class is a thin wrapper around the JSON parser. It uses 21 | // NSJSONSerialization when available, and SBJSON otherwise. 22 | 23 | #import 24 | 25 | #import "GTLDefines.h" 26 | 27 | @interface GTLJSONParser : NSObject 28 | + (NSString*)stringWithObject:(id)value 29 | humanReadable:(BOOL)humanReadable 30 | error:(NSError**)error; 31 | 32 | + (NSData *)dataWithObject:(id)obj 33 | humanReadable:(BOOL)humanReadable 34 | error:(NSError**)error; 35 | 36 | + (id)objectWithString:(NSString *)jsonStr 37 | error:(NSError **)error; 38 | 39 | + (id)objectWithData:(NSData *)jsonData 40 | error:(NSError **)error; 41 | @end 42 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLJSONParser.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLJSONParser.m 18 | // 19 | 20 | #import "GTLJSONParser.h" 21 | 22 | // We can assume NSJSONSerialization is present on Mac OS X 10.7 and iOS 5 23 | #if !defined(GTL_REQUIRES_NSJSONSERIALIZATION) 24 | #if (!TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)) || \ 25 | (TARGET_OS_IPHONE && (__IPHONE_OS_VERSION_MIN_REQUIRED >= 50000)) 26 | #define GTL_REQUIRES_NSJSONSERIALIZATION 1 27 | #endif 28 | #endif 29 | 30 | // If GTMNSJSONSerialization is available, it is used for parsing and 31 | // formatting JSON 32 | #if !GTL_REQUIRES_NSJSONSERIALIZATION 33 | @interface GTMNSJSONSerialization : NSObject 34 | + (NSData *)dataWithJSONObject:(id)obj options:(NSUInteger)opt error:(NSError **)error; 35 | + (id)JSONObjectWithData:(NSData *)data options:(NSUInteger)opt error:(NSError **)error; 36 | @end 37 | 38 | // As a fallback, SBJSON is used for parsing and formatting JSON 39 | @interface GTLSBJSON 40 | - (void)setHumanReadable:(BOOL)flag; 41 | - (NSString*)stringWithObject:(id)value error:(NSError**)error; 42 | - (id)objectWithString:(NSString*)jsonrep error:(NSError**)error; 43 | @end 44 | #endif // !GTL_REQUIRES_NSJSONSERIALIZATION 45 | 46 | @implementation GTLJSONParser 47 | 48 | #if DEBUG && !GTL_REQUIRES_NSJSONSERIALIZATION 49 | // When compiling for iOS 4 compatibility, SBJSON must be available 50 | + (void)load { 51 | Class writer = NSClassFromString(@"SBJsonWriter"); 52 | Class parser = NSClassFromString(@"SBJsonParser"); 53 | Class oldParser = NSClassFromString(@"SBJSON"); 54 | GTL_ASSERT((oldParser != Nil) 55 | || (writer != Nil && parser != Nil), 56 | @"No parsing class found"); 57 | } 58 | #endif // DEBUG && !GTL_REQUIRES_NSJSONSERIALIZATION 59 | 60 | + (NSString *)stringWithObject:(id)obj 61 | humanReadable:(BOOL)humanReadable 62 | error:(NSError **)error { 63 | NSData *data = [self dataWithObject:obj 64 | humanReadable:humanReadable 65 | error:error]; 66 | if (data) { 67 | NSString *jsonStr = [[[NSString alloc] initWithData:data 68 | encoding:NSUTF8StringEncoding] autorelease]; 69 | return jsonStr; 70 | } 71 | return nil; 72 | } 73 | 74 | + (NSData *)dataWithObject:(id)obj 75 | humanReadable:(BOOL)humanReadable 76 | error:(NSError **)error { 77 | if (obj == nil) return nil; 78 | 79 | const NSUInteger kOpts = humanReadable ? (1UL << 0) : 0; // NSJSONWritingPrettyPrinted 80 | 81 | #if GTL_REQUIRES_NSJSONSERIALIZATION 82 | NSData *data = [NSJSONSerialization dataWithJSONObject:obj 83 | options:kOpts 84 | error:error]; 85 | return data; 86 | #else 87 | Class serializer = NSClassFromString(@"NSJSONSerialization"); 88 | if (serializer) { 89 | NSData *data = [serializer dataWithJSONObject:obj 90 | options:kOpts 91 | error:error]; 92 | return data; 93 | } else { 94 | Class jsonWriteClass = NSClassFromString(@"SBJsonWriter"); 95 | if (!jsonWriteClass) { 96 | jsonWriteClass = NSClassFromString(@"SBJSON"); 97 | } 98 | 99 | if (error) *error = nil; 100 | 101 | GTLSBJSON *writer = [[[jsonWriteClass alloc] init] autorelease]; 102 | [writer setHumanReadable:humanReadable]; 103 | NSString *jsonStr = [writer stringWithObject:obj 104 | error:error]; 105 | NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding]; 106 | return data; 107 | } 108 | #endif 109 | } 110 | 111 | + (id)objectWithString:(NSString *)jsonStr 112 | error:(NSError **)error { 113 | NSData *data = [jsonStr dataUsingEncoding:NSUTF8StringEncoding]; 114 | return [self objectWithData:data 115 | error:error]; 116 | } 117 | 118 | + (id)objectWithData:(NSData *)jsonData 119 | error:(NSError **)error { 120 | #if GTL_REQUIRES_NSJSONSERIALIZATION 121 | NSMutableDictionary *obj = [NSJSONSerialization JSONObjectWithData:jsonData 122 | options:NSJSONReadingMutableContainers 123 | error:error]; 124 | return obj; 125 | #else 126 | Class serializer = NSClassFromString(@"NSJSONSerialization"); 127 | if (serializer) { 128 | const NSUInteger kOpts = (1UL << 0); // NSJSONReadingMutableContainers 129 | NSMutableDictionary *obj = [serializer JSONObjectWithData:jsonData 130 | options:kOpts 131 | error:error]; 132 | return obj; 133 | } else { 134 | Class jsonParseClass = NSClassFromString(@"SBJsonParser"); 135 | if (!jsonParseClass) { 136 | jsonParseClass = NSClassFromString(@"SBJSON"); 137 | } 138 | 139 | if (error) *error = nil; 140 | 141 | GTLSBJSON *parser = [[[jsonParseClass alloc] init] autorelease]; 142 | 143 | NSString *jsonrep = [[[NSString alloc] initWithData:jsonData 144 | encoding:NSUTF8StringEncoding] autorelease]; 145 | id obj = [parser objectWithString:jsonrep 146 | error:error]; 147 | return obj; 148 | } 149 | #endif 150 | } 151 | 152 | @end 153 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLRuntimeCommon.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLRuntimeCommon.h 18 | // 19 | 20 | 21 | #import 22 | 23 | #import "GTLDefines.h" 24 | 25 | // This protocol and support class are an internal implementation detail so 26 | // GTLObject and GTLQuery can share some code. 27 | 28 | @protocol GTLRuntimeCommon 29 | @required 30 | // Get/Set properties 31 | - (void)setJSONValue:(id)obj forKey:(NSString *)key; 32 | - (id)JSONValueForKey:(NSString *)key; 33 | // Child cache 34 | - (void)setCacheChild:(id)obj forKey:(NSString *)key; 35 | - (id)cacheChildForKey:(NSString *)key; 36 | // Surrogate class mappings. 37 | - (NSDictionary *)surrogates; 38 | // Key map 39 | + (NSDictionary *)propertyToJSONKeyMapForClass:(Class)aClass; 40 | // Array item types 41 | + (NSDictionary *)arrayPropertyToClassMapForClass:(Class)aClass; 42 | // The parent class for dynamic support 43 | + (Class)ancestorClass; 44 | @end 45 | 46 | @interface GTLRuntimeCommon : NSObject 47 | // Wire things up. 48 | + (BOOL)resolveInstanceMethod:(SEL)sel onClass:(Class)onClass; 49 | // Helpers 50 | + (id)objectFromJSON:(id)json 51 | defaultClass:(Class)defaultClass 52 | surrogates:(NSDictionary *)surrogates 53 | isCacheable:(BOOL*)isCacheable; 54 | + (id)jsonFromAPIObject:(id)obj 55 | expectedClass:(Class)expectedClass 56 | isCacheable:(BOOL*)isCacheable; 57 | @end 58 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLTargetNamespace.h: -------------------------------------------------------------------------------- 1 | // 2 | // Makes the value of GTL_TARGET_NAMESPACE a prefix for all GTL 3 | // library class names 4 | // 5 | 6 | // 7 | // To avoid global namespace issues, define GTL_TARGET_NAMESPACE to a short 8 | // string in your target if you are using the GTL library in a shared-code 9 | // environment like a plug-in. 10 | // 11 | // For example: -DGTL_TARGET_NAMESPACE=MyPlugin 12 | // 13 | 14 | // 15 | // com.google.GTLFramework v. 2.0 (29 classes) 2011-10-25 19:25:36 -0700 16 | // 17 | 18 | #if defined(__OBJC__) && defined(GTL_TARGET_NAMESPACE) 19 | 20 | #define _GTL_NS_SYMBOL_INNER(ns, symbol) ns ## _ ## symbol 21 | #define _GTL_NS_SYMBOL_MIDDLE(ns, symbol) _GTL_NS_SYMBOL_INNER(ns, symbol) 22 | #define _GTL_NS_SYMBOL(symbol) _GTL_NS_SYMBOL_MIDDLE(GTL_TARGET_NAMESPACE, symbol) 23 | 24 | #define _GTL_NS_STRING_INNER(ns) #ns 25 | #define _GTL_NS_STRING_MIDDLE(ns) _GTL_NS_STRING_INNER(ns) 26 | #define GTL_TARGET_NAMESPACE_STRING _GTL_NS_STRING_MIDDLE(GTL_TARGET_NAMESPACE) 27 | 28 | #define GTLBatchQuery _GTL_NS_SYMBOL(GTLBatchQuery) 29 | #define GTLBatchResult _GTL_NS_SYMBOL(GTLBatchResult) 30 | #define GTLCollectionObject _GTL_NS_SYMBOL(GTLCollectionObject) 31 | #define GTLDateTime _GTL_NS_SYMBOL(GTLDateTime) 32 | #define GTLErrorObject _GTL_NS_SYMBOL(GTLErrorObject) 33 | #define GTLErrorObjectData _GTL_NS_SYMBOL(GTLErrorObjectData) 34 | #define GTLJSONParser _GTL_NS_SYMBOL(GTLJSONParser) 35 | #define GTLObject _GTL_NS_SYMBOL(GTLObject) 36 | #define GTLQuery _GTL_NS_SYMBOL(GTLQuery) 37 | #define GTLRuntimeCommon _GTL_NS_SYMBOL(GTLRuntimeCommon) 38 | #define GTLService _GTL_NS_SYMBOL(GTLService) 39 | #define GTLServiceTicket _GTL_NS_SYMBOL(GTLServiceTicket) 40 | #define GTLUploadParameters _GTL_NS_SYMBOL(GTLUploadParameters) 41 | #define GTLUtilities _GTL_NS_SYMBOL(GTLUtilities) 42 | #define GTMCachedURLResponse _GTL_NS_SYMBOL(GTMCachedURLResponse) 43 | #define GTMCookieStorage _GTL_NS_SYMBOL(GTMCookieStorage) 44 | #define GTMGatherInputStream _GTL_NS_SYMBOL(GTMGatherInputStream) 45 | #define GTMHTTPFetcher _GTL_NS_SYMBOL(GTMHTTPFetcher) 46 | #define GTMHTTPFetcherService _GTL_NS_SYMBOL(GTMHTTPFetcherService) 47 | #define GTMHTTPFetchHistory _GTL_NS_SYMBOL(GTMHTTPFetchHistory) 48 | #define GTMHTTPUploadFetcher _GTL_NS_SYMBOL(GTMHTTPUploadFetcher) 49 | #define GTMMIMEDocument _GTL_NS_SYMBOL(GTMMIMEDocument) 50 | #define GTMMIMEPart _GTL_NS_SYMBOL(GTMMIMEPart) 51 | #define GTMOAuth2Authentication _GTL_NS_SYMBOL(GTMOAuth2Authentication) 52 | #define GTMOAuth2AuthorizationArgs _GTL_NS_SYMBOL(GTMOAuth2AuthorizationArgs) 53 | #define GTMOAuth2SignIn _GTL_NS_SYMBOL(GTMOAuth2SignIn) 54 | #define GTMOAuth2WindowController _GTL_NS_SYMBOL(GTMOAuth2WindowController) 55 | #define GTMReadMonitorInputStream _GTL_NS_SYMBOL(GTMReadMonitorInputStream) 56 | #define GTMURLCache _GTL_NS_SYMBOL(GTMURLCache) 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLUploadParameters.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLUploadParameters.h 18 | // 19 | 20 | // Uploading documentation: 21 | // https://code.google.com/p/google-api-objectivec-client/wiki/Introduction#Uploading_Files 22 | 23 | #import 24 | 25 | #import "GTLDefines.h" 26 | 27 | @interface GTLUploadParameters : NSObject { 28 | @private 29 | NSString *MIMEType_; 30 | NSData *data_; 31 | NSFileHandle *fileHandle_; 32 | NSURL *fileURL_; 33 | NSURL *uploadLocationURL_; 34 | NSString *slug_; 35 | BOOL shouldSendUploadOnly_; 36 | } 37 | 38 | // Uploading requires MIME type and one of 39 | // - data to be uploaded 40 | // - URL of file to be uploaded (preferred for large files) 41 | // - file handle for uploading 42 | @property (copy) NSString *MIMEType; 43 | @property (retain) NSData *data; 44 | @property (retain) NSFileHandle *fileHandle; 45 | @property (retain) NSURL *fileURL; 46 | 47 | // Resuming an in-progress upload is done with the upload location URL, 48 | // and requires a file handle for uploading 49 | @property (retain) NSURL *uploadLocationURL; 50 | 51 | // Some services need a slug (filename) header 52 | @property (copy) NSString *slug; 53 | 54 | // Uploads may be done without a JSON body in the initial request 55 | @property (assign) BOOL shouldSendUploadOnly; 56 | 57 | + (instancetype)uploadParametersWithData:(NSData *)data 58 | MIMEType:(NSString *)mimeType GTL_NONNULL((1,2)); 59 | 60 | + (instancetype)uploadParametersWithFileHandle:(NSFileHandle *)fileHandle 61 | MIMEType:(NSString *)mimeType GTL_NONNULL((1,2)); 62 | 63 | + (instancetype)uploadParametersWithFileURL:(NSURL *)fileHandle 64 | MIMEType:(NSString *)mimeType GTL_NONNULL((1,2)); 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLUploadParameters.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLObject.m 18 | // 19 | 20 | #include 21 | 22 | #import "GTLUploadParameters.h" 23 | 24 | @implementation GTLUploadParameters 25 | 26 | @synthesize MIMEType = MIMEType_, 27 | data = data_, 28 | fileHandle = fileHandle_, 29 | uploadLocationURL = uploadLocationURL_, 30 | fileURL = fileURL_, 31 | slug = slug_, 32 | shouldSendUploadOnly = shouldSendUploadOnly_; 33 | 34 | + (instancetype)uploadParametersWithData:(NSData *)data 35 | MIMEType:(NSString *)mimeType { 36 | GTLUploadParameters *params = [[[self alloc] init] autorelease]; 37 | params.data = data; 38 | params.MIMEType = mimeType; 39 | return params; 40 | } 41 | 42 | + (instancetype)uploadParametersWithFileHandle:(NSFileHandle *)fileHandle 43 | MIMEType:(NSString *)mimeType { 44 | GTLUploadParameters *params = [[[self alloc] init] autorelease]; 45 | params.fileHandle = fileHandle; 46 | params.MIMEType = mimeType; 47 | return params; 48 | } 49 | 50 | + (instancetype)uploadParametersWithFileURL:(NSURL *)fileURL 51 | MIMEType:(NSString *)mimeType { 52 | GTLUploadParameters *params = [[[self alloc] init] autorelease]; 53 | params.fileURL = fileURL; 54 | params.MIMEType = mimeType; 55 | return params; 56 | } 57 | 58 | - (id)copyWithZone:(NSZone *)zone { 59 | GTLUploadParameters *newParams = [[[self class] allocWithZone:zone] init]; 60 | newParams.MIMEType = self.MIMEType; 61 | newParams.data = self.data; 62 | newParams.fileHandle = self.fileHandle; 63 | newParams.fileURL = self.fileURL; 64 | newParams.uploadLocationURL = self.uploadLocationURL; 65 | newParams.slug = self.slug; 66 | newParams.shouldSendUploadOnly = self.shouldSendUploadOnly; 67 | return newParams; 68 | } 69 | 70 | - (void)dealloc { 71 | [MIMEType_ release]; 72 | [data_ release]; 73 | [fileHandle_ release]; 74 | [fileURL_ release]; 75 | [uploadLocationURL_ release]; 76 | [slug_ release]; 77 | 78 | [super dealloc]; 79 | } 80 | 81 | - (NSString *)description { 82 | NSMutableArray *array = [NSMutableArray array]; 83 | NSString *str = [NSString stringWithFormat:@"MIMEType:%@", MIMEType_]; 84 | [array addObject:str]; 85 | 86 | if (data_) { 87 | str = [NSString stringWithFormat:@"data:%llu bytes", 88 | (unsigned long long)[data_ length]]; 89 | [array addObject:str]; 90 | } 91 | 92 | if (fileHandle_) { 93 | str = [NSString stringWithFormat:@"fileHandle:%@", fileHandle_]; 94 | [array addObject:str]; 95 | } 96 | 97 | if (fileURL_) { 98 | str = [NSString stringWithFormat:@"file:%@", [fileURL_ path]]; 99 | [array addObject:str]; 100 | } 101 | 102 | if (uploadLocationURL_) { 103 | str = [NSString stringWithFormat:@"uploadLocation:%@", 104 | [uploadLocationURL_ absoluteString]]; 105 | [array addObject:str]; 106 | } 107 | 108 | if (slug_) { 109 | str = [NSString stringWithFormat:@"slug:%@", slug_]; 110 | [array addObject:str]; 111 | } 112 | 113 | if (shouldSendUploadOnly_) { 114 | [array addObject:@"shouldSendUploadOnly"]; 115 | } 116 | 117 | NSString *descStr = [array componentsJoinedByString:@", "]; 118 | str = [NSString stringWithFormat:@"%@ %p: {%@}", 119 | [self class], self, descStr]; 120 | return str; 121 | } 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTLUtilities.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | #ifndef SKIP_GTL_DEFINES 19 | #import "GTLDefines.h" 20 | #endif 21 | 22 | // helper functions for implementing isEqual: 23 | BOOL GTL_AreEqualOrBothNil(id obj1, id obj2); 24 | BOOL GTL_AreBoolsEqual(BOOL b1, BOOL b2); 25 | 26 | // Helper to ensure a number is a number. 27 | // 28 | // The GoogleAPI servers will send numbers >53 bits as strings to avoid 29 | // bugs in some JavaScript implementations. Work around this by catching 30 | // the string and turning it back into a number. 31 | NSNumber *GTL_EnsureNSNumber(NSNumber *num); 32 | 33 | @interface GTLUtilities : NSObject 34 | 35 | // 36 | // String encoding 37 | // 38 | 39 | // URL encoding, different for parts of URLs and parts of URL parameters 40 | // 41 | // +stringByURLEncodingString just makes a string legal for a URL 42 | // 43 | // +stringByURLEncodingForURI also encodes some characters that are legal in 44 | // URLs but should not be used in URIs, 45 | // per http://bitworking.org/projects/atom/rfc5023.html#rfc.section.9.7 46 | // 47 | // +stringByURLEncodingStringParameter is like +stringByURLEncodingForURI but 48 | // replaces space characters with + characters rather than percent-escaping them 49 | // 50 | + (NSString *)stringByURLEncodingString:(NSString *)str; 51 | + (NSString *)stringByURLEncodingForURI:(NSString *)str; 52 | + (NSString *)stringByURLEncodingStringParameter:(NSString *)str; 53 | 54 | // Percent-encoded UTF-8 55 | + (NSString *)stringByPercentEncodingUTF8ForString:(NSString *)str; 56 | 57 | // Key-value coding searches in an array 58 | // 59 | // Utilities to get from an array objects having a known value (or nil) 60 | // at a keyPath 61 | 62 | + (NSArray *)objectsFromArray:(NSArray *)sourceArray 63 | withValue:(id)desiredValue 64 | forKeyPath:(NSString *)keyPath; 65 | 66 | + (id)firstObjectFromArray:(NSArray *)sourceArray 67 | withValue:(id)desiredValue 68 | forKeyPath:(NSString *)keyPath; 69 | 70 | // 71 | // Version helpers 72 | // 73 | 74 | + (NSComparisonResult)compareVersion:(NSString *)ver1 toVersion:(NSString *)ver2; 75 | 76 | // 77 | // URL builder 78 | // 79 | 80 | // If there are already query parameters on urlString, the new ones are simple 81 | // appended after them. 82 | + (NSURL *)URLWithString:(NSString *)urlString 83 | queryParameters:(NSDictionary *)queryParameters; 84 | 85 | // Walk up the class tree merging dictionaries and return the result. 86 | + (NSDictionary *)mergedClassDictionaryForSelector:(SEL)selector 87 | startClass:(Class)startClass 88 | ancestorClass:(Class)ancestorClass 89 | cache:(NSMutableDictionary *)cache; 90 | @end 91 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTMGatherInputStream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 17 | // The GTMGatherInput stream is an input stream implementation that is to be 18 | // instantiated with an NSArray of NSData objects. It works in the traditional 19 | // scatter/gather vector I/O model. Rather than allocating a big NSData object 20 | // to hold all of the data and performing a copy into that object, the 21 | // GTMGatherInputStream will maintain a reference to the NSArray and read from 22 | // each NSData in turn as the read method is called. You should not alter the 23 | // underlying set of NSData objects until all read operations on this input 24 | // stream have completed. 25 | 26 | #import 27 | 28 | #if defined(GTL_TARGET_NAMESPACE) 29 | // we need NSInteger for the 10.4 SDK, or we're using target namespace macros 30 | #import "GTLDefines.h" 31 | #elif defined(GDATA_TARGET_NAMESPACE) 32 | #import "GDataDefines.h" 33 | #endif 34 | 35 | // Define only for Mac OS X 10.6+ or iPhone OS 4.0+. 36 | #undef GTM_NSSTREAM_DELEGATE 37 | #if (TARGET_OS_MAC && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)) || \ 38 | (TARGET_OS_IPHONE && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 40000)) 39 | #define GTM_NSSTREAM_DELEGATE 40 | #else 41 | #define GTM_NSSTREAM_DELEGATE 42 | #endif 43 | 44 | @interface GTMGatherInputStream : NSInputStream GTM_NSSTREAM_DELEGATE { 45 | 46 | NSArray* dataArray_; // NSDatas that should be "gathered" and streamed. 47 | NSUInteger arrayIndex_; // Index in the array of the current NSData. 48 | long long dataOffset_; // Offset in the current NSData we are processing. 49 | 50 | id delegate_; // WEAK, stream delegate, defaults to self 51 | 52 | // Since various undocumented methods get called on a stream, we'll 53 | // use a 1-byte dummy stream object to handle all unexpected messages. 54 | // Actual reads from the stream we will perform using the data array, not 55 | // from the dummy stream. 56 | NSInputStream* dummyStream_; 57 | NSData* dummyData_; 58 | } 59 | 60 | + (NSInputStream *)streamWithArray:(NSArray *)dataArray; 61 | 62 | - (id)initWithArray:(NSArray *)dataArray; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTMGatherInputStream.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GTMGatherInputStream.h" 17 | 18 | @implementation GTMGatherInputStream 19 | 20 | + (NSInputStream *)streamWithArray:(NSArray *)dataArray { 21 | return [[[self alloc] initWithArray:dataArray] autorelease]; 22 | } 23 | 24 | - (id)initWithArray:(NSArray *)dataArray { 25 | self = [super init]; 26 | if (self) { 27 | dataArray_ = [dataArray retain]; 28 | arrayIndex_ = 0; 29 | dataOffset_ = 0; 30 | 31 | [self setDelegate:self]; // An NSStream's default delegate should be self. 32 | 33 | // We use a dummy input stream to handle all the various undocumented 34 | // messages the system sends to an input stream. 35 | // 36 | // Contrary to documentation, inputStreamWithData neither copies nor 37 | // retains the data in Mac OS X 10.4, so we must retain it. 38 | // (Radar 5167591) 39 | 40 | dummyData_ = [[NSData alloc] initWithBytes:"x" length:1]; 41 | dummyStream_ = [[NSInputStream alloc] initWithData:dummyData_]; 42 | } 43 | return self; 44 | } 45 | 46 | - (void)dealloc { 47 | [dataArray_ release]; 48 | [dummyStream_ release]; 49 | [dummyData_ release]; 50 | 51 | [super dealloc]; 52 | } 53 | 54 | - (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len { 55 | 56 | NSInteger bytesRead = 0; 57 | NSUInteger bytesRemaining = len; 58 | 59 | // read bytes from the currently-indexed array 60 | while ((bytesRemaining > 0) && (arrayIndex_ < [dataArray_ count])) { 61 | 62 | NSData* data = [dataArray_ objectAtIndex:arrayIndex_]; 63 | 64 | NSUInteger dataLen = [data length]; 65 | NSUInteger dataBytesLeft = dataLen - (NSUInteger)dataOffset_; 66 | 67 | NSUInteger bytesToCopy = MIN(bytesRemaining, dataBytesLeft); 68 | NSRange range = NSMakeRange((NSUInteger) dataOffset_, bytesToCopy); 69 | 70 | [data getBytes:(buffer + bytesRead) range:range]; 71 | 72 | bytesRead += bytesToCopy; 73 | dataOffset_ += bytesToCopy; 74 | bytesRemaining -= bytesToCopy; 75 | 76 | if (dataOffset_ == (long long)dataLen) { 77 | dataOffset_ = 0; 78 | arrayIndex_++; 79 | } 80 | } 81 | 82 | if (bytesRead == 0) { 83 | // We are at the end our our stream, so we read all of the data on our 84 | // dummy input stream to make sure it is in the "fully read" state. 85 | uint8_t leftOverBytes[2]; 86 | (void) [dummyStream_ read:leftOverBytes maxLength:sizeof(leftOverBytes)]; 87 | } 88 | 89 | return bytesRead; 90 | } 91 | 92 | - (BOOL)getBuffer:(uint8_t **)buffer length:(NSUInteger *)len { 93 | return NO; // We don't support this style of reading. 94 | } 95 | 96 | - (BOOL)hasBytesAvailable { 97 | // if we return no, the read never finishes, even if we've already 98 | // delivered all the bytes 99 | return YES; 100 | } 101 | 102 | #pragma mark - 103 | 104 | // Pass other expected messages on to the dummy input stream 105 | 106 | - (void)open { 107 | [dummyStream_ open]; 108 | } 109 | 110 | - (void)close { 111 | [dummyStream_ close]; 112 | 113 | // 10.4's NSURLConnection tends to retain streams needlessly, 114 | // so we'll free up the data array right away 115 | [dataArray_ release]; 116 | dataArray_ = nil; 117 | } 118 | 119 | - (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent { 120 | if (delegate_ != self) { 121 | [delegate_ stream:self handleEvent:streamEvent]; 122 | } 123 | } 124 | 125 | - (id)delegate { 126 | return delegate_; 127 | } 128 | 129 | - (void)setDelegate:(id)delegate { 130 | if (delegate == nil) { 131 | delegate_ = self; 132 | [dummyStream_ setDelegate:nil]; 133 | } else { 134 | delegate_ = delegate; 135 | [dummyStream_ setDelegate:self]; 136 | } 137 | } 138 | 139 | - (id)propertyForKey:(NSString *)key { 140 | return [dummyStream_ propertyForKey:key]; 141 | } 142 | 143 | - (BOOL)setProperty:(id)property forKey:(NSString *)key { 144 | return [dummyStream_ setProperty:property forKey:key]; 145 | } 146 | 147 | - (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode { 148 | [dummyStream_ scheduleInRunLoop:aRunLoop forMode:mode]; 149 | } 150 | 151 | - (void)removeFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode { 152 | [dummyStream_ removeFromRunLoop:aRunLoop forMode:mode]; 153 | } 154 | 155 | - (NSStreamStatus)streamStatus { 156 | return [dummyStream_ streamStatus]; 157 | } 158 | - (NSError *)streamError { 159 | return [dummyStream_ streamError]; 160 | } 161 | 162 | #pragma mark - 163 | 164 | // We'll forward all unexpected messages to our dummy stream 165 | 166 | + (NSMethodSignature*)methodSignatureForSelector:(SEL)selector { 167 | return [NSInputStream methodSignatureForSelector:selector]; 168 | } 169 | 170 | + (void)forwardInvocation:(NSInvocation*)invocation { 171 | [invocation invokeWithTarget:[NSInputStream class]]; 172 | } 173 | 174 | - (BOOL)respondsToSelector:(SEL)selector { 175 | return [dummyStream_ respondsToSelector:selector]; 176 | } 177 | 178 | - (NSMethodSignature*)methodSignatureForSelector:(SEL)selector { 179 | return [dummyStream_ methodSignatureForSelector:selector]; 180 | } 181 | 182 | - (void)forwardInvocation:(NSInvocation*)invocation { 183 | 184 | #if 0 185 | // uncomment this section to see the messages the NSInputStream receives 186 | SEL selector; 187 | NSString *selName; 188 | 189 | selector=[invocation selector]; 190 | selName=NSStringFromSelector(selector); 191 | NSLog(@"-forwardInvocation: %@",selName); 192 | #endif 193 | 194 | [invocation invokeWithTarget:dummyStream_]; 195 | } 196 | 197 | @end 198 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTMHTTPFetcherLogging.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import "GTMHTTPFetcher.h" 17 | 18 | // GTM HTTP Logging 19 | // 20 | // All traffic using GTMHTTPFetcher can be easily logged. Call 21 | // 22 | // [GTMHTTPFetcher setLoggingEnabled:YES]; 23 | // 24 | // to begin generating log files. 25 | // 26 | // Log files are put into a folder on the desktop called "GTMHTTPDebugLogs" 27 | // unless another directory is specified with +setLoggingDirectory. 28 | // 29 | // In the iPhone simulator, the default logs location is the user's home 30 | // directory in ~/Library/Application Support. On the iPhone device, the 31 | // default logs location is the application's documents directory on the device. 32 | // 33 | // Tip: use the Finder's "Sort By Date" to find the most recent logs. 34 | // 35 | // Each run of an application gets a separate set of log files. An html 36 | // file is generated to simplify browsing the run's http transactions. 37 | // The html file includes javascript links for inline viewing of uploaded 38 | // and downloaded data. 39 | // 40 | // A symlink is created in the logs folder to simplify finding the html file 41 | // for the latest run of the application; the symlink is called 42 | // 43 | // AppName_http_log_newest.html 44 | // 45 | // For better viewing of XML logs, use Camino or Firefox rather than Safari. 46 | // 47 | // Each fetcher may be given a comment to be inserted as a label in the logs, 48 | // such as 49 | // [fetcher setCommentWithFormat:@"retrieve item %@", itemName]; 50 | // 51 | // Projects may define STRIP_GTM_FETCH_LOGGING to remove logging code. 52 | 53 | #if !STRIP_GTM_FETCH_LOGGING 54 | 55 | @interface GTMHTTPFetcher (GTMHTTPFetcherLogging) 56 | 57 | // Note: the default logs directory is ~/Desktop/GTMHTTPDebugLogs; it will be 58 | // created as needed. If a custom directory is set, the directory should 59 | // already exist. 60 | + (void)setLoggingDirectory:(NSString *)path; 61 | + (NSString *)loggingDirectory; 62 | 63 | // client apps can turn logging on and off 64 | + (void)setLoggingEnabled:(BOOL)flag; 65 | + (BOOL)isLoggingEnabled; 66 | 67 | // client apps can turn off logging to a file if they want to only check 68 | // the fetcher's log property 69 | + (void)setLoggingToFileEnabled:(BOOL)flag; 70 | + (BOOL)isLoggingToFileEnabled; 71 | 72 | // client apps can optionally specify process name and date string used in 73 | // log file names 74 | + (void)setLoggingProcessName:(NSString *)str; 75 | + (NSString *)loggingProcessName; 76 | 77 | + (void)setLoggingDateStamp:(NSString *)str; 78 | + (NSString *)loggingDateStamp; 79 | 80 | // the directory used for the log of the current app run. 81 | + (NSString *)logDirectoryForCurrentRun; 82 | 83 | // internal; called by fetcher 84 | - (void)logFetchWithError:(NSError *)error; 85 | - (BOOL)logCapturePostStream; 86 | 87 | // internal; accessors useful for viewing logs 88 | + (NSString *)processNameLogPrefix; 89 | + (NSString *)symlinkNameSuffix; 90 | + (NSString *)htmlFileName; 91 | 92 | // Applications may provide alternative body strings to be displayed in the 93 | // log, such as for binary requests or responses. If deferring is turned 94 | // on, the response log will not be sent until deferring is turned off, 95 | // allowing the application to write the response body after the response 96 | // data has been parsed. 97 | - (void)setLogRequestBody:(NSString *)bodyString; 98 | - (NSString *)logRequestBody; 99 | - (void)setLogResponseBody:(NSString *)bodyString; 100 | - (NSString *)logResponseBody; 101 | - (void)setShouldDeferResponseBodyLogging:(BOOL)flag; 102 | - (BOOL)shouldDeferResponseBodyLogging; 103 | 104 | @end 105 | 106 | #endif // !STRIP_GTM_FETCH_LOGGING 107 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTMHTTPFetcherService.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTMHTTPFetcherService.h 18 | // 19 | 20 | // The fetcher service class maintains a history to be used by a sequence 21 | // of fetchers objects generated by the service. 22 | // 23 | // Fetchers that do not need to share a history may be generated independently, 24 | // like 25 | // 26 | // GTMHTTPFetcher* myFetcher = [GTMHTTPFetcher fetcherWithRequest:request]; 27 | // 28 | // Fetchers that should share cookies or an ETagged data cache should be 29 | // generated by a common GTMHTTPFetcherService instance, like 30 | // 31 | // GTMHTTPFetcherService *myFetcherService = [[GTMHTTPFetcherService alloc] init]; 32 | // GTMHTTPFetcher* myFirstFetcher = [myFetcherService fetcherWithRequest:request1]; 33 | // GTMHTTPFetcher* mySecondFetcher = [myFetcherService fetcherWithRequest:request2]; 34 | 35 | #import "GTMHTTPFetcher.h" 36 | #import "GTMHTTPFetchHistory.h" 37 | 38 | @interface GTMHTTPFetcherService : NSObject { 39 | @private 40 | NSMutableDictionary *delayedHosts_; 41 | NSMutableDictionary *runningHosts_; 42 | NSUInteger maxRunningFetchersPerHost_; 43 | 44 | GTMHTTPFetchHistory *fetchHistory_; 45 | NSOperationQueue *delegateQueue_; 46 | NSArray *runLoopModes_; 47 | NSString *userAgent_; 48 | NSTimeInterval timeout_; 49 | NSURLCredential *credential_; // username & password 50 | NSURLCredential *proxyCredential_; // credential supplied to proxy servers 51 | NSInteger cookieStorageMethod_; 52 | 53 | NSArray *allowedInsecureSchemes_; 54 | BOOL allowLocalhostRequest_; 55 | 56 | BOOL shouldFetchInBackground_; 57 | 58 | id authorizer_; 59 | } 60 | 61 | // Create a fetcher 62 | // 63 | // These methods will return an autoreleased fetcher, but if 64 | // the fetcher is successfully created, the connection will retain the 65 | // fetcher for the life of the connection as well. So the caller doesn't have 66 | // to retain the fetcher explicitly unless they want to be able to monitor 67 | // or cancel it. 68 | - (GTMHTTPFetcher *)fetcherWithRequest:(NSURLRequest *)request; 69 | - (GTMHTTPFetcher *)fetcherWithURL:(NSURL *)requestURL; 70 | - (GTMHTTPFetcher *)fetcherWithURLString:(NSString *)requestURLString; 71 | - (id)fetcherWithRequest:(NSURLRequest *)request 72 | fetcherClass:(Class)fetcherClass; 73 | 74 | // Queues of delayed and running fetchers. Each dictionary contains arrays 75 | // of fetchers, keyed by host 76 | // 77 | // A max value of 0 means no fetchers should be delayed. 78 | // 79 | // The default limit is 10 simultaneous fetchers targeting each host. 80 | @property (assign) NSUInteger maxRunningFetchersPerHost; 81 | @property (retain, readonly) NSDictionary *delayedHosts; 82 | @property (retain, readonly) NSDictionary *runningHosts; 83 | 84 | - (BOOL)isDelayingFetcher:(GTMHTTPFetcher *)fetcher; 85 | 86 | - (NSUInteger)numberOfFetchers; // running + delayed fetchers 87 | - (NSUInteger)numberOfRunningFetchers; 88 | - (NSUInteger)numberOfDelayedFetchers; 89 | 90 | // Search for running or delayed fetchers with the specified URL. 91 | // 92 | // Returns an array of fetcher objects found, or nil if none found. 93 | - (NSArray *)issuedFetchersWithRequestURL:(NSURL *)requestURL; 94 | 95 | - (void)stopAllFetchers; 96 | 97 | // Properties to be applied to each fetcher; 98 | // see GTMHTTPFetcher.h for descriptions 99 | @property (copy) NSString *userAgent; 100 | @property (assign) NSTimeInterval timeout; 101 | @property (retain) NSOperationQueue *delegateQueue; 102 | @property (retain) NSArray *runLoopModes; 103 | @property (retain) NSURLCredential *credential; 104 | @property (retain) NSURLCredential *proxyCredential; 105 | @property (assign) BOOL shouldFetchInBackground; 106 | @property (copy) NSArray *allowedInsecureSchemes; 107 | @property (assign) BOOL allowLocalhostRequest; 108 | 109 | // Fetch history 110 | @property (retain) GTMHTTPFetchHistory *fetchHistory; 111 | 112 | @property (assign) NSInteger cookieStorageMethod; 113 | @property (assign) BOOL shouldRememberETags; // default: NO 114 | @property (assign) BOOL shouldCacheETaggedData; // default: NO 115 | 116 | - (void)clearETaggedDataCache; 117 | - (void)clearHistory; 118 | 119 | @property (nonatomic, retain) id authorizer; 120 | 121 | // Spin the run loop, discarding events, until all running and delayed fetchers 122 | // have completed 123 | // 124 | // This is only for use in testing or in tools without a user interface. 125 | // 126 | // Synchronous fetches should never be done by shipping apps; they are 127 | // sufficient reason for rejection from the app store. 128 | - (void)waitForCompletionOfAllFetchersWithTimeout:(NSTimeInterval)timeoutInSeconds; 129 | 130 | @end 131 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTMHTTPUploadFetcher.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTMHTTPUploadFetcher.h 18 | // 19 | 20 | #if (!GDATA_REQUIRE_SERVICE_INCLUDES) || GDATA_INCLUDE_DOCS_SERVICE || \ 21 | GDATA_INCLUDE_YOUTUBE_SERVICE || GDATA_INCLUDE_PHOTOS_SERVICE 22 | 23 | // 24 | // This subclass of GTMHTTPFetcher simulates the series of fetches 25 | // needed for chunked upload as a single fetch operation. 26 | // 27 | // Protocol document: 28 | // http://code.google.com/p/gears/wiki/ResumableHttpRequestsProposal 29 | // 30 | // To the client, the only fetcher that exists is this class; the subsidiary 31 | // fetchers needed for uploading chunks are not visible (though the most recent 32 | // chunk fetcher may be accessed via the -activeFetcher method, and 33 | // -responseHeaders and -statusCode reflect results from the most recent chunk 34 | // fetcher.) 35 | // 36 | // Chunk fetchers are discarded as soon as they have completed. 37 | // 38 | 39 | #pragma once 40 | 41 | #import "GTMHTTPFetcher.h" 42 | #import "GTMHTTPFetcherService.h" 43 | 44 | // async retrieval of an http get or post 45 | @interface GTMHTTPUploadFetcher : GTMHTTPFetcher { 46 | GTMHTTPFetcher *chunkFetcher_; 47 | 48 | // we'll call through to the delegate's sentData and finished selectors 49 | SEL delegateSentDataSEL_; 50 | SEL delegateFinishedSEL_; 51 | 52 | BOOL needsManualProgress_; 53 | 54 | // the initial fetch's body length and bytes actually sent are 55 | // needed for calculating progress during subsequent chunk uploads 56 | NSUInteger initialBodyLength_; 57 | NSUInteger initialBodySent_; 58 | 59 | NSURL *locationURL_; 60 | #if NS_BLOCKS_AVAILABLE 61 | void (^locationChangeBlock_)(NSURL *); 62 | #elif !__LP64__ 63 | // placeholders: for 32-bit builds, keep the size of the object's ivar section 64 | // the same with and without blocks 65 | #ifndef __clang_analyzer__ 66 | id locationChangePlaceholder_; 67 | #endif 68 | #endif 69 | 70 | // uploadData_ or uploadFileHandle_ may be set, but not both 71 | NSData *uploadData_; 72 | NSFileHandle *uploadFileHandle_; 73 | NSInteger uploadFileHandleLength_; 74 | NSString *uploadMIMEType_; 75 | NSUInteger chunkSize_; 76 | BOOL isPaused_; 77 | BOOL isRestartedUpload_; 78 | 79 | // we keep the latest offset into the upload data just for 80 | // progress reporting 81 | NSUInteger currentOffset_; 82 | 83 | // we store the response headers and status code for the most recent 84 | // chunk fetcher 85 | NSDictionary *responseHeaders_; 86 | NSInteger statusCode_; 87 | } 88 | 89 | + (GTMHTTPUploadFetcher *)uploadFetcherWithRequest:(NSURLRequest *)request 90 | uploadData:(NSData *)data 91 | uploadMIMEType:(NSString *)uploadMIMEType 92 | chunkSize:(NSUInteger)chunkSize 93 | fetcherService:(GTMHTTPFetcherService *)fetcherServiceOrNil; 94 | 95 | + (GTMHTTPUploadFetcher *)uploadFetcherWithRequest:(NSURLRequest *)request 96 | uploadFileHandle:(NSFileHandle *)fileHandle 97 | uploadMIMEType:(NSString *)uploadMIMEType 98 | chunkSize:(NSUInteger)chunkSize 99 | fetcherService:(GTMHTTPFetcherService *)fetcherServiceOrNil; 100 | 101 | + (GTMHTTPUploadFetcher *)uploadFetcherWithLocation:(NSURL *)locationURL 102 | uploadFileHandle:(NSFileHandle *)fileHandle 103 | uploadMIMEType:(NSString *)uploadMIMEType 104 | chunkSize:(NSUInteger)chunkSize 105 | fetcherService:(GTMHTTPFetcherService *)fetcherServiceOrNil; 106 | - (void)pauseFetching; 107 | - (void)resumeFetching; 108 | - (BOOL)isPaused; 109 | 110 | @property (retain) NSURL *locationURL; 111 | @property (retain) NSData *uploadData; 112 | @property (retain) NSFileHandle *uploadFileHandle; 113 | @property (copy) NSString *uploadMIMEType; 114 | @property (assign) NSUInteger chunkSize; 115 | @property (assign) NSUInteger currentOffset; 116 | 117 | #if NS_BLOCKS_AVAILABLE 118 | // When the upload location changes, the optional locationChangeBlock will be 119 | // called. It will be called with nil once upload succeeds or can no longer 120 | // be attempted. 121 | @property (copy) void (^locationChangeBlock)(NSURL *locationURL); 122 | #endif 123 | 124 | // the fetcher for the current data chunk, if any 125 | @property (retain) GTMHTTPFetcher *chunkFetcher; 126 | 127 | // the active fetcher is the last chunk fetcher, or the upload fetcher itself 128 | // if no chunk fetcher has yet been created 129 | @property (readonly) GTMHTTPFetcher *activeFetcher; 130 | 131 | // the response headers from the most recently-completed fetch 132 | @property (retain) NSDictionary *responseHeaders; 133 | 134 | // the status code from the most recently-completed fetch 135 | @property (assign) NSInteger statusCode; 136 | 137 | @end 138 | 139 | #endif // #if !GDATA_REQUIRE_SERVICE_INCLUDES 140 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTMMIMEDocument.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2010 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 17 | // This is a simple class to create a MIME document. To use, allocate 18 | // a new GTMMIMEDocument and start adding parts as necessary. When you are 19 | // done adding parts, call generateInputStream to get an NSInputStream 20 | // containing the contents of your MIME document. 21 | // 22 | // A good reference for MIME is http://en.wikipedia.org/wiki/MIME 23 | 24 | #import 25 | 26 | #if defined(GTL_TARGET_NAMESPACE) 27 | // we're using target namespace macros 28 | #import "GTLDefines.h" 29 | #elif defined(GDATA_TARGET_NAMESPACE) 30 | #import "GDataDefines.h" 31 | #endif 32 | 33 | @interface GTMMIMEDocument : NSObject { 34 | NSMutableArray* parts_; // Contains an ordered set of MimeParts 35 | unsigned long long length_; // Length in bytes of the document. 36 | u_int32_t randomSeed_; // for testing 37 | } 38 | 39 | + (GTMMIMEDocument *)MIMEDocument; 40 | 41 | // Adds a new part to this mime document with the given headers and body. The 42 | // headers keys and values should be NSStrings 43 | - (void)addPartWithHeaders:(NSDictionary *)headers 44 | body:(NSData *)body; 45 | 46 | // An inputstream that can be used to efficiently read the contents of the 47 | // mime document. 48 | - (void)generateInputStream:(NSInputStream **)outStream 49 | length:(unsigned long long*)outLength 50 | boundary:(NSString **)outBoundary; 51 | 52 | // ------ UNIT TESTING ONLY BELOW ------ 53 | 54 | // For unittesting only, seeds the random number generator 55 | - (void)seedRandomWith:(u_int32_t)seed; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /GoogleDriveSample/GTL/GTMReadMonitorInputStream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | #import 17 | 18 | 19 | // Define only for Mac OS X 10.6+ or iPhone OS 4.0+. 20 | #ifndef GTM_NSSTREAM_DELEGATE 21 | #if (TARGET_OS_MAC && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)) || \ 22 | (TARGET_OS_IPHONE && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 40000)) 23 | #define GTM_NSSTREAM_DELEGATE 24 | #else 25 | #define GTM_NSSTREAM_DELEGATE 26 | #endif 27 | #endif // !defined(GTM_NSSTREAM_DELEGATE) 28 | 29 | #ifdef GTM_TARGET_NAMESPACE 30 | // we're using target namespace macros 31 | #import "GTMDefines.h" 32 | #endif 33 | 34 | @interface GTMReadMonitorInputStream : NSInputStream GTM_NSSTREAM_DELEGATE { 35 | @protected 36 | NSInputStream *inputStream_; // encapsulated stream that does the work 37 | 38 | NSThread *thread_; // thread in which this object was created 39 | NSArray *runLoopModes_; // modes for calling callbacks, when necessary 40 | 41 | @private 42 | id readDelegate_; 43 | SEL readSelector_; 44 | } 45 | 46 | // length is passed to the progress callback; it may be zero 47 | // if the progress callback can handle that 48 | + (id)inputStreamWithStream:(NSInputStream *)input; 49 | 50 | - (id)initWithStream:(NSInputStream *)input; 51 | 52 | // The read monitor selector is called when bytes have been read. It should 53 | // have a signature matching 54 | // 55 | // - (void)inputStream:(GTMReadMonitorInputStream *)stream 56 | // readIntoBuffer:(uint8_t *)buffer 57 | // length:(NSUInteger)length; 58 | 59 | @property (assign) id readDelegate; // WEAK 60 | @property (assign) SEL readSelector; 61 | 62 | // Modes for invoking callbacks, when necessary 63 | @property (retain) NSArray *runLoopModes; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrive.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrive.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | 29 | #import "GTLDriveConstants.h" 30 | 31 | #import "GTLDriveAbout.h" 32 | #import "GTLDriveApp.h" 33 | #import "GTLDriveAppList.h" 34 | #import "GTLDriveChange.h" 35 | #import "GTLDriveChangeList.h" 36 | #import "GTLDriveChannel.h" 37 | #import "GTLDriveChildList.h" 38 | #import "GTLDriveChildReference.h" 39 | #import "GTLDriveComment.h" 40 | #import "GTLDriveCommentList.h" 41 | #import "GTLDriveCommentReply.h" 42 | #import "GTLDriveCommentReplyList.h" 43 | #import "GTLDriveFile.h" 44 | #import "GTLDriveFileList.h" 45 | #import "GTLDriveParentList.h" 46 | #import "GTLDriveParentReference.h" 47 | #import "GTLDrivePermission.h" 48 | #import "GTLDrivePermissionId.h" 49 | #import "GTLDrivePermissionList.h" 50 | #import "GTLDriveProperty.h" 51 | #import "GTLDrivePropertyList.h" 52 | #import "GTLDriveRevision.h" 53 | #import "GTLDriveRevisionList.h" 54 | #import "GTLDriveUser.h" 55 | 56 | #import "GTLQueryDrive.h" 57 | #import "GTLServiceDrive.h" 58 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveApp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveApp.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveApp (0 custom class methods, 24 custom properties) 30 | // GTLDriveAppIconsItem (0 custom class methods, 3 custom properties) 31 | 32 | #if GTL_BUILT_AS_FRAMEWORK 33 | #import "GTL/GTLObject.h" 34 | #else 35 | #import "GTLObject.h" 36 | #endif 37 | 38 | @class GTLDriveAppIconsItem; 39 | 40 | // ---------------------------------------------------------------------------- 41 | // 42 | // GTLDriveApp 43 | // 44 | 45 | // The apps resource provides a list of the apps that a user has installed, with 46 | // information about each app's supported MIME types, file extensions, and other 47 | // details. 48 | 49 | @interface GTLDriveApp : GTLObject 50 | 51 | // Whether the app is authorized to access data on the user's Drive. 52 | @property (retain) NSNumber *authorized; // boolValue 53 | 54 | // The template url to create a new file with this app in a given folder. The 55 | // template will contain {folderId} to be replaced by the folder to create the 56 | // new file in. 57 | @property (copy) NSString *createInFolderTemplate; 58 | 59 | // The url to create a new file with this app. 60 | @property (copy) NSString *createUrl; 61 | 62 | // Whether the app has drive-wide scope. An app with drive-wide scope can access 63 | // all files in the user's drive. 64 | @property (retain) NSNumber *hasDriveWideScope; // boolValue 65 | 66 | // The various icons for the app. 67 | @property (retain) NSArray *icons; // of GTLDriveAppIconsItem 68 | 69 | // The ID of the app. 70 | // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). 71 | @property (copy) NSString *identifier; 72 | 73 | // Whether the app is installed. 74 | @property (retain) NSNumber *installed; // boolValue 75 | 76 | // This is always drive#app. 77 | @property (copy) NSString *kind; 78 | 79 | // A long description of the app. 80 | @property (copy) NSString *longDescription; 81 | 82 | // The name of the app. 83 | @property (copy) NSString *name; 84 | 85 | // The type of object this app creates (e.g. Chart). If empty, the app name 86 | // should be used instead. 87 | @property (copy) NSString *objectType; 88 | 89 | // The template url for opening files with this app. The template will contain 90 | // {ids} and/or {exportIds} to be replaced by the actual file ids. 91 | @property (copy) NSString *openUrlTemplate; 92 | 93 | // The list of primary file extensions. 94 | @property (retain) NSArray *primaryFileExtensions; // of NSString 95 | 96 | // The list of primary mime types. 97 | @property (retain) NSArray *primaryMimeTypes; // of NSString 98 | 99 | // The ID of the product listing for this app. 100 | @property (copy) NSString *productId; 101 | 102 | // A link to the product listing for this app. 103 | @property (copy) NSString *productUrl; 104 | 105 | // The list of secondary file extensions. 106 | @property (retain) NSArray *secondaryFileExtensions; // of NSString 107 | 108 | // The list of secondary mime types. 109 | @property (retain) NSArray *secondaryMimeTypes; // of NSString 110 | 111 | // A short description of the app. 112 | @property (copy) NSString *shortDescription; 113 | 114 | // Whether this app supports creating new objects. 115 | @property (retain) NSNumber *supportsCreate; // boolValue 116 | 117 | // Whether this app supports importing Google Docs. 118 | @property (retain) NSNumber *supportsImport; // boolValue 119 | 120 | // Whether this app supports opening more than one file. 121 | @property (retain) NSNumber *supportsMultiOpen; // boolValue 122 | 123 | // Whether this app supports creating new files when offline. 124 | @property (retain) NSNumber *supportsOfflineCreate; // boolValue 125 | 126 | // Whether the app is selected as the default handler for the types it supports. 127 | @property (retain) NSNumber *useByDefault; // boolValue 128 | 129 | @end 130 | 131 | 132 | // ---------------------------------------------------------------------------- 133 | // 134 | // GTLDriveAppIconsItem 135 | // 136 | 137 | @interface GTLDriveAppIconsItem : GTLObject 138 | 139 | // Category of the icon. Allowed values are: 140 | // - application - icon for the application 141 | // - document - icon for a file associated with the app 142 | // - documentShared - icon for a shared file associated with the app 143 | @property (copy) NSString *category; 144 | 145 | // URL for the icon. 146 | @property (copy) NSString *iconUrl; 147 | 148 | // Size of the icon. Represented as the maximum of the width and height. 149 | @property (retain) NSNumber *size; // intValue 150 | 151 | @end 152 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveApp.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveApp.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveApp (0 custom class methods, 24 custom properties) 30 | // GTLDriveAppIconsItem (0 custom class methods, 3 custom properties) 31 | 32 | #import "GTLDriveApp.h" 33 | 34 | // ---------------------------------------------------------------------------- 35 | // 36 | // GTLDriveApp 37 | // 38 | 39 | @implementation GTLDriveApp 40 | @dynamic authorized, createInFolderTemplate, createUrl, hasDriveWideScope, 41 | icons, identifier, installed, kind, longDescription, name, objectType, 42 | openUrlTemplate, primaryFileExtensions, primaryMimeTypes, productId, 43 | productUrl, secondaryFileExtensions, secondaryMimeTypes, 44 | shortDescription, supportsCreate, supportsImport, supportsMultiOpen, 45 | supportsOfflineCreate, useByDefault; 46 | 47 | + (NSDictionary *)propertyToJSONKeyMap { 48 | NSDictionary *map = 49 | [NSDictionary dictionaryWithObject:@"id" 50 | forKey:@"identifier"]; 51 | return map; 52 | } 53 | 54 | + (NSDictionary *)arrayPropertyToClassMap { 55 | NSDictionary *map = 56 | [NSDictionary dictionaryWithObjectsAndKeys: 57 | [GTLDriveAppIconsItem class], @"icons", 58 | [NSString class], @"primaryFileExtensions", 59 | [NSString class], @"primaryMimeTypes", 60 | [NSString class], @"secondaryFileExtensions", 61 | [NSString class], @"secondaryMimeTypes", 62 | nil]; 63 | return map; 64 | } 65 | 66 | + (void)load { 67 | [self registerObjectClassForKind:@"drive#app"]; 68 | } 69 | 70 | @end 71 | 72 | 73 | // ---------------------------------------------------------------------------- 74 | // 75 | // GTLDriveAppIconsItem 76 | // 77 | 78 | @implementation GTLDriveAppIconsItem 79 | @dynamic category, iconUrl, size; 80 | @end 81 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveAppList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveAppList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveAppList (0 custom class methods, 5 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveApp; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveAppList 42 | // 43 | 44 | // A list of third-party applications which the user has installed or given 45 | // access to Google Drive. 46 | 47 | // This class supports NSFastEnumeration over its "items" property. It also 48 | // supports -itemAtIndex: to retrieve individual objects from "items". 49 | 50 | @interface GTLDriveAppList : GTLCollectionObject 51 | 52 | // List of app IDs that the user has specified to use by default. The list is in 53 | // reverse-priority order (lowest to highest). 54 | @property (retain) NSArray *defaultAppIds; // of NSString 55 | 56 | // The ETag of the list. 57 | @property (copy) NSString *ETag; 58 | 59 | // The actual list of apps. 60 | @property (retain) NSArray *items; // of GTLDriveApp 61 | 62 | // This is always drive#appList. 63 | @property (copy) NSString *kind; 64 | 65 | // A link back to this list. 66 | @property (copy) NSString *selfLink; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveAppList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveAppList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveAppList (0 custom class methods, 5 custom properties) 30 | 31 | #import "GTLDriveAppList.h" 32 | 33 | #import "GTLDriveApp.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveAppList 38 | // 39 | 40 | @implementation GTLDriveAppList 41 | @dynamic defaultAppIds, ETag, items, kind, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"etag" 46 | forKey:@"ETag"]; 47 | return map; 48 | } 49 | 50 | + (NSDictionary *)arrayPropertyToClassMap { 51 | NSDictionary *map = 52 | [NSDictionary dictionaryWithObjectsAndKeys: 53 | [NSString class], @"defaultAppIds", 54 | [GTLDriveApp class], @"items", 55 | nil]; 56 | return map; 57 | } 58 | 59 | + (void)load { 60 | [self registerObjectClassForKind:@"drive#appList"]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChange.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChange.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChange (0 custom class methods, 7 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveFile; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveChange 42 | // 43 | 44 | // Representation of a change to a file. 45 | 46 | @interface GTLDriveChange : GTLObject 47 | 48 | // Whether the file has been deleted. 49 | @property (retain) NSNumber *deleted; // boolValue 50 | 51 | // The updated state of the file. Present if the file has not been deleted. 52 | @property (retain) GTLDriveFile *file; 53 | 54 | // The ID of the file associated with this change. 55 | @property (copy) NSString *fileId; 56 | 57 | // The ID of the change. 58 | // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). 59 | @property (retain) NSNumber *identifier; // longLongValue 60 | 61 | // This is always drive#change. 62 | @property (copy) NSString *kind; 63 | 64 | // The time of this modification. 65 | @property (retain) GTLDateTime *modificationDate; 66 | 67 | // A link back to this change. 68 | @property (copy) NSString *selfLink; 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChange.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChange.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChange (0 custom class methods, 7 custom properties) 30 | 31 | #import "GTLDriveChange.h" 32 | 33 | #import "GTLDriveFile.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveChange 38 | // 39 | 40 | @implementation GTLDriveChange 41 | @dynamic deleted, file, fileId, identifier, kind, modificationDate, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"id" 46 | forKey:@"identifier"]; 47 | return map; 48 | } 49 | 50 | + (void)load { 51 | [self registerObjectClassForKind:@"drive#change"]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChangeList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChangeList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChangeList (0 custom class methods, 7 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveChange; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveChangeList 42 | // 43 | 44 | // A list of changes for a user. 45 | 46 | // This class supports NSFastEnumeration over its "items" property. It also 47 | // supports -itemAtIndex: to retrieve individual objects from "items". 48 | 49 | @interface GTLDriveChangeList : GTLCollectionObject 50 | 51 | // The ETag of the list. 52 | @property (copy) NSString *ETag; 53 | 54 | // The actual list of changes. 55 | @property (retain) NSArray *items; // of GTLDriveChange 56 | 57 | // This is always drive#changeList. 58 | @property (copy) NSString *kind; 59 | 60 | // The current largest change ID. 61 | @property (retain) NSNumber *largestChangeId; // longLongValue 62 | 63 | // A link to the next page of changes. 64 | @property (copy) NSString *nextLink; 65 | 66 | // The page token for the next page of changes. 67 | @property (copy) NSString *nextPageToken; 68 | 69 | // A link back to this list. 70 | @property (copy) NSString *selfLink; 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChangeList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChangeList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChangeList (0 custom class methods, 7 custom properties) 30 | 31 | #import "GTLDriveChangeList.h" 32 | 33 | #import "GTLDriveChange.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveChangeList 38 | // 39 | 40 | @implementation GTLDriveChangeList 41 | @dynamic ETag, items, kind, largestChangeId, nextLink, nextPageToken, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"etag" 46 | forKey:@"ETag"]; 47 | return map; 48 | } 49 | 50 | + (NSDictionary *)arrayPropertyToClassMap { 51 | NSDictionary *map = 52 | [NSDictionary dictionaryWithObject:[GTLDriveChange class] 53 | forKey:@"items"]; 54 | return map; 55 | } 56 | 57 | + (void)load { 58 | [self registerObjectClassForKind:@"drive#changeList"]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChannel.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChannel.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChannel (0 custom class methods, 10 custom properties) 30 | // GTLDriveChannelParams (0 custom class methods, 0 custom properties) 31 | 32 | #if GTL_BUILT_AS_FRAMEWORK 33 | #import "GTL/GTLObject.h" 34 | #else 35 | #import "GTLObject.h" 36 | #endif 37 | 38 | @class GTLDriveChannelParams; 39 | 40 | // ---------------------------------------------------------------------------- 41 | // 42 | // GTLDriveChannel 43 | // 44 | 45 | // An notification channel used to watch for resource changes. 46 | 47 | @interface GTLDriveChannel : GTLObject 48 | 49 | // The address where notifications are delivered for this channel. 50 | @property (copy) NSString *address; 51 | 52 | // Date and time of notification channel expiration, expressed as a Unix 53 | // timestamp, in milliseconds. Optional. 54 | @property (retain) NSNumber *expiration; // longLongValue 55 | 56 | // A UUID or similar unique string that identifies this channel. 57 | // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). 58 | @property (copy) NSString *identifier; 59 | 60 | // Identifies this as a notification channel used to watch for changes to a 61 | // resource. Value: the fixed string "api#channel". 62 | @property (copy) NSString *kind; 63 | 64 | // Additional parameters controlling delivery channel behavior. Optional. 65 | @property (retain) GTLDriveChannelParams *params; 66 | 67 | // A Boolean value to indicate whether payload is wanted. Optional. 68 | @property (retain) NSNumber *payload; // boolValue 69 | 70 | // An opaque ID that identifies the resource being watched on this channel. 71 | // Stable across different API versions. 72 | @property (copy) NSString *resourceId; 73 | 74 | // A version-specific identifier for the watched resource. 75 | @property (copy) NSString *resourceUri; 76 | 77 | // An arbitrary string delivered to the target address with each notification 78 | // delivered over this channel. Optional. 79 | @property (copy) NSString *token; 80 | 81 | // The type of delivery mechanism used for this channel. 82 | @property (copy) NSString *type; 83 | 84 | @end 85 | 86 | 87 | // ---------------------------------------------------------------------------- 88 | // 89 | // GTLDriveChannelParams 90 | // 91 | 92 | @interface GTLDriveChannelParams : GTLObject 93 | // This object is documented as having more properties that are NSString. Use 94 | // -additionalJSONKeys and -additionalPropertyForName: to get the list of 95 | // properties and then fetch them; or -additionalProperties to fetch them all at 96 | // once. 97 | @end 98 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChannel.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChannel.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChannel (0 custom class methods, 10 custom properties) 30 | // GTLDriveChannelParams (0 custom class methods, 0 custom properties) 31 | 32 | #import "GTLDriveChannel.h" 33 | 34 | // ---------------------------------------------------------------------------- 35 | // 36 | // GTLDriveChannel 37 | // 38 | 39 | @implementation GTLDriveChannel 40 | @dynamic address, expiration, identifier, kind, params, payload, resourceId, 41 | resourceUri, token, type; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"id" 46 | forKey:@"identifier"]; 47 | return map; 48 | } 49 | 50 | + (void)load { 51 | [self registerObjectClassForKind:@"api#channel"]; 52 | } 53 | 54 | @end 55 | 56 | 57 | // ---------------------------------------------------------------------------- 58 | // 59 | // GTLDriveChannelParams 60 | // 61 | 62 | @implementation GTLDriveChannelParams 63 | 64 | + (Class)classForAdditionalProperties { 65 | return [NSString class]; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChildList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChildList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChildList (0 custom class methods, 6 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveChildReference; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveChildList 42 | // 43 | 44 | // A list of children of a file. 45 | 46 | // This class supports NSFastEnumeration over its "items" property. It also 47 | // supports -itemAtIndex: to retrieve individual objects from "items". 48 | 49 | @interface GTLDriveChildList : GTLCollectionObject 50 | 51 | // The ETag of the list. 52 | @property (copy) NSString *ETag; 53 | 54 | // The actual list of children. 55 | @property (retain) NSArray *items; // of GTLDriveChildReference 56 | 57 | // This is always drive#childList. 58 | @property (copy) NSString *kind; 59 | 60 | // A link to the next page of children. 61 | @property (copy) NSString *nextLink; 62 | 63 | // The page token for the next page of children. 64 | @property (copy) NSString *nextPageToken; 65 | 66 | // A link back to this list. 67 | @property (copy) NSString *selfLink; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChildList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChildList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChildList (0 custom class methods, 6 custom properties) 30 | 31 | #import "GTLDriveChildList.h" 32 | 33 | #import "GTLDriveChildReference.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveChildList 38 | // 39 | 40 | @implementation GTLDriveChildList 41 | @dynamic ETag, items, kind, nextLink, nextPageToken, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"etag" 46 | forKey:@"ETag"]; 47 | return map; 48 | } 49 | 50 | + (NSDictionary *)arrayPropertyToClassMap { 51 | NSDictionary *map = 52 | [NSDictionary dictionaryWithObject:[GTLDriveChildReference class] 53 | forKey:@"items"]; 54 | return map; 55 | } 56 | 57 | + (void)load { 58 | [self registerObjectClassForKind:@"drive#childList"]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChildReference.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChildReference.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChildReference (0 custom class methods, 4 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | // ---------------------------------------------------------------------------- 38 | // 39 | // GTLDriveChildReference 40 | // 41 | 42 | // A reference to a folder's child. 43 | 44 | @interface GTLDriveChildReference : GTLObject 45 | 46 | // A link to the child. 47 | @property (copy) NSString *childLink; 48 | 49 | // The ID of the child. 50 | // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). 51 | @property (copy) NSString *identifier; 52 | 53 | // This is always drive#childReference. 54 | @property (copy) NSString *kind; 55 | 56 | // A link back to this reference. 57 | @property (copy) NSString *selfLink; 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveChildReference.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveChildReference.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveChildReference (0 custom class methods, 4 custom properties) 30 | 31 | #import "GTLDriveChildReference.h" 32 | 33 | // ---------------------------------------------------------------------------- 34 | // 35 | // GTLDriveChildReference 36 | // 37 | 38 | @implementation GTLDriveChildReference 39 | @dynamic childLink, identifier, kind, selfLink; 40 | 41 | + (NSDictionary *)propertyToJSONKeyMap { 42 | NSDictionary *map = 43 | [NSDictionary dictionaryWithObject:@"id" 44 | forKey:@"identifier"]; 45 | return map; 46 | } 47 | 48 | + (void)load { 49 | [self registerObjectClassForKind:@"drive#childReference"]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveComment.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveComment.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveComment (0 custom class methods, 15 custom properties) 30 | // GTLDriveCommentContext (0 custom class methods, 2 custom properties) 31 | 32 | #if GTL_BUILT_AS_FRAMEWORK 33 | #import "GTL/GTLObject.h" 34 | #else 35 | #import "GTLObject.h" 36 | #endif 37 | 38 | @class GTLDriveCommentContext; 39 | @class GTLDriveCommentReply; 40 | @class GTLDriveUser; 41 | 42 | // ---------------------------------------------------------------------------- 43 | // 44 | // GTLDriveComment 45 | // 46 | 47 | // A JSON representation of a comment on a file in Google Drive. 48 | 49 | @interface GTLDriveComment : GTLObject 50 | 51 | // A region of the document represented as a JSON string. See anchor 52 | // documentation for details on how to define and interpret anchor properties. 53 | @property (copy) NSString *anchor; 54 | 55 | // The user who wrote this comment. 56 | @property (retain) GTLDriveUser *author; 57 | 58 | // The ID of the comment. 59 | @property (copy) NSString *commentId; 60 | 61 | // The plain text content used to create this comment. This is not HTML safe and 62 | // should only be used as a starting point to make edits to a comment's content. 63 | @property (copy) NSString *content; 64 | 65 | // The context of the file which is being commented on. 66 | @property (retain) GTLDriveCommentContext *context; 67 | 68 | // The date when this comment was first created. 69 | @property (retain) GTLDateTime *createdDate; 70 | 71 | // Whether this comment has been deleted. If a comment has been deleted the 72 | // content will be cleared and this will only represent a comment that once 73 | // existed. 74 | @property (retain) NSNumber *deleted; // boolValue 75 | 76 | // The file which this comment is addressing. 77 | @property (copy) NSString *fileId; 78 | 79 | // The title of the file which this comment is addressing. 80 | @property (copy) NSString *fileTitle; 81 | 82 | // HTML formatted content for this comment. 83 | @property (copy) NSString *htmlContent; 84 | 85 | // This is always drive#comment. 86 | @property (copy) NSString *kind; 87 | 88 | // The date when this comment or any of its replies were last modified. 89 | @property (retain) GTLDateTime *modifiedDate; 90 | 91 | // Replies to this post. 92 | @property (retain) NSArray *replies; // of GTLDriveCommentReply 93 | 94 | // A link back to this comment. 95 | @property (copy) NSString *selfLink; 96 | 97 | // The status of this comment. Status can be changed by posting a reply to a 98 | // comment with the desired status. 99 | // - "open" - The comment is still open. 100 | // - "resolved" - The comment has been resolved by one of its replies. 101 | @property (copy) NSString *status; 102 | 103 | @end 104 | 105 | 106 | // ---------------------------------------------------------------------------- 107 | // 108 | // GTLDriveCommentContext 109 | // 110 | 111 | @interface GTLDriveCommentContext : GTLObject 112 | 113 | // The MIME type of the context snippet. 114 | @property (copy) NSString *type; 115 | 116 | // Data representation of the segment of the file being commented on. In the 117 | // case of a text file for example, this would be the actual text that the 118 | // comment is about. 119 | @property (copy) NSString *value; 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveComment.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveComment.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveComment (0 custom class methods, 15 custom properties) 30 | // GTLDriveCommentContext (0 custom class methods, 2 custom properties) 31 | 32 | #import "GTLDriveComment.h" 33 | 34 | #import "GTLDriveCommentReply.h" 35 | #import "GTLDriveUser.h" 36 | 37 | // ---------------------------------------------------------------------------- 38 | // 39 | // GTLDriveComment 40 | // 41 | 42 | @implementation GTLDriveComment 43 | @dynamic anchor, author, commentId, content, context, createdDate, deleted, 44 | fileId, fileTitle, htmlContent, kind, modifiedDate, replies, selfLink, 45 | status; 46 | 47 | + (NSDictionary *)arrayPropertyToClassMap { 48 | NSDictionary *map = 49 | [NSDictionary dictionaryWithObject:[GTLDriveCommentReply class] 50 | forKey:@"replies"]; 51 | return map; 52 | } 53 | 54 | + (void)load { 55 | [self registerObjectClassForKind:@"drive#comment"]; 56 | } 57 | 58 | @end 59 | 60 | 61 | // ---------------------------------------------------------------------------- 62 | // 63 | // GTLDriveCommentContext 64 | // 65 | 66 | @implementation GTLDriveCommentContext 67 | @dynamic type, value; 68 | @end 69 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveCommentList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveCommentList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveCommentList (0 custom class methods, 5 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveComment; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveCommentList 42 | // 43 | 44 | // A JSON representation of a list of comments on a file in Google Drive. 45 | 46 | // This class supports NSFastEnumeration over its "items" property. It also 47 | // supports -itemAtIndex: to retrieve individual objects from "items". 48 | 49 | @interface GTLDriveCommentList : GTLCollectionObject 50 | 51 | // List of comments. 52 | @property (retain) NSArray *items; // of GTLDriveComment 53 | 54 | // This is always drive#commentList. 55 | @property (copy) NSString *kind; 56 | 57 | // A link to the next page of comments. 58 | @property (copy) NSString *nextLink; 59 | 60 | // The token to use to request the next page of results. 61 | @property (copy) NSString *nextPageToken; 62 | 63 | // A link back to this list. 64 | @property (copy) NSString *selfLink; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveCommentList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveCommentList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveCommentList (0 custom class methods, 5 custom properties) 30 | 31 | #import "GTLDriveCommentList.h" 32 | 33 | #import "GTLDriveComment.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveCommentList 38 | // 39 | 40 | @implementation GTLDriveCommentList 41 | @dynamic items, kind, nextLink, nextPageToken, selfLink; 42 | 43 | + (NSDictionary *)arrayPropertyToClassMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:[GTLDriveComment class] 46 | forKey:@"items"]; 47 | return map; 48 | } 49 | 50 | + (void)load { 51 | [self registerObjectClassForKind:@"drive#commentList"]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveCommentReply.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveCommentReply.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveCommentReply (0 custom class methods, 9 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveUser; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveCommentReply 42 | // 43 | 44 | // A JSON representation of a reply to a comment on a file in Google Drive. 45 | 46 | @interface GTLDriveCommentReply : GTLObject 47 | 48 | // The user who wrote this reply. 49 | @property (retain) GTLDriveUser *author; 50 | 51 | // The plain text content used to create this reply. This is not HTML safe and 52 | // should only be used as a starting point to make edits to a reply's content. 53 | // This field is required on inserts if no verb is specified (resolve/reopen). 54 | @property (copy) NSString *content; 55 | 56 | // The date when this reply was first created. 57 | @property (retain) GTLDateTime *createdDate; 58 | 59 | // Whether this reply has been deleted. If a reply has been deleted the content 60 | // will be cleared and this will only represent a reply that once existed. 61 | @property (retain) NSNumber *deleted; // boolValue 62 | 63 | // HTML formatted content for this reply. 64 | @property (copy) NSString *htmlContent; 65 | 66 | // This is always drive#commentReply. 67 | @property (copy) NSString *kind; 68 | 69 | // The date when this reply was last modified. 70 | @property (retain) GTLDateTime *modifiedDate; 71 | 72 | // The ID of the reply. 73 | @property (copy) NSString *replyId; 74 | 75 | // The action this reply performed to the parent comment. When creating a new 76 | // reply this is the action to be perform to the parent comment. Possible values 77 | // are: 78 | // - "resolve" - To resolve a comment. 79 | // - "reopen" - To reopen (un-resolve) a comment. 80 | @property (copy) NSString *verb; 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveCommentReply.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveCommentReply.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveCommentReply (0 custom class methods, 9 custom properties) 30 | 31 | #import "GTLDriveCommentReply.h" 32 | 33 | #import "GTLDriveUser.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveCommentReply 38 | // 39 | 40 | @implementation GTLDriveCommentReply 41 | @dynamic author, content, createdDate, deleted, htmlContent, kind, modifiedDate, 42 | replyId, verb; 43 | 44 | + (void)load { 45 | [self registerObjectClassForKind:@"drive#commentReply"]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveCommentReplyList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveCommentReplyList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveCommentReplyList (0 custom class methods, 5 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveCommentReply; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveCommentReplyList 42 | // 43 | 44 | // A JSON representation of a list of replies to a comment on a file in Google 45 | // Drive. 46 | 47 | // This class supports NSFastEnumeration over its "items" property. It also 48 | // supports -itemAtIndex: to retrieve individual objects from "items". 49 | 50 | @interface GTLDriveCommentReplyList : GTLCollectionObject 51 | 52 | // List of reply. 53 | @property (retain) NSArray *items; // of GTLDriveCommentReply 54 | 55 | // This is always drive#commentReplyList. 56 | @property (copy) NSString *kind; 57 | 58 | // A link to the next page of replies. 59 | @property (copy) NSString *nextLink; 60 | 61 | // The token to use to request the next page of results. 62 | @property (copy) NSString *nextPageToken; 63 | 64 | // A link back to this list. 65 | @property (copy) NSString *selfLink; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveCommentReplyList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveCommentReplyList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveCommentReplyList (0 custom class methods, 5 custom properties) 30 | 31 | #import "GTLDriveCommentReplyList.h" 32 | 33 | #import "GTLDriveCommentReply.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveCommentReplyList 38 | // 39 | 40 | @implementation GTLDriveCommentReplyList 41 | @dynamic items, kind, nextLink, nextPageToken, selfLink; 42 | 43 | + (NSDictionary *)arrayPropertyToClassMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:[GTLDriveCommentReply class] 46 | forKey:@"items"]; 47 | return map; 48 | } 49 | 50 | + (void)load { 51 | [self registerObjectClassForKind:@"drive#commentReplyList"]; 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveConstants.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveConstants.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | 29 | #import 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLDefines.h" 33 | #else 34 | #import "GTLDefines.h" 35 | #endif 36 | 37 | // Authorization scope 38 | // View and manage the files in your Google Drive 39 | GTL_EXTERN NSString * const kGTLAuthScopeDrive; // "https://www.googleapis.com/auth/drive" 40 | // View and manage its own configuration data in your Google Drive 41 | GTL_EXTERN NSString * const kGTLAuthScopeDriveAppdata; // "https://www.googleapis.com/auth/drive.appdata" 42 | // View your Google Drive apps 43 | GTL_EXTERN NSString * const kGTLAuthScopeDriveAppsReadonly; // "https://www.googleapis.com/auth/drive.apps.readonly" 44 | // View and manage Google Drive files that you have opened or created with this 45 | // app 46 | GTL_EXTERN NSString * const kGTLAuthScopeDriveFile; // "https://www.googleapis.com/auth/drive.file" 47 | // View metadata for files in your Google Drive 48 | GTL_EXTERN NSString * const kGTLAuthScopeDriveMetadataReadonly; // "https://www.googleapis.com/auth/drive.metadata.readonly" 49 | // View the files in your Google Drive 50 | GTL_EXTERN NSString * const kGTLAuthScopeDriveReadonly; // "https://www.googleapis.com/auth/drive.readonly" 51 | // Modify your Google Apps Script scripts' behavior 52 | GTL_EXTERN NSString * const kGTLAuthScopeDriveScripts; // "https://www.googleapis.com/auth/drive.scripts" 53 | 54 | // GTLQueryDrive - Corpus 55 | GTL_EXTERN NSString * const kGTLDriveCorpusDefault; // "DEFAULT" 56 | GTL_EXTERN NSString * const kGTLDriveCorpusDomain; // "DOMAIN" 57 | 58 | // GTLQueryDrive - Projection 59 | GTL_EXTERN NSString * const kGTLDriveProjectionBasic; // "BASIC" 60 | GTL_EXTERN NSString * const kGTLDriveProjectionFull; // "FULL" 61 | 62 | // GTLQueryDrive - Visibility 63 | GTL_EXTERN NSString * const kGTLDriveVisibilityDefault; // "DEFAULT" 64 | GTL_EXTERN NSString * const kGTLDriveVisibilityPrivate; // "PRIVATE" 65 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveConstants.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveConstants.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | 29 | #import "GTLDriveConstants.h" 30 | 31 | // Authorization scope 32 | NSString * const kGTLAuthScopeDrive = @"https://www.googleapis.com/auth/drive"; 33 | NSString * const kGTLAuthScopeDriveAppdata = @"https://www.googleapis.com/auth/drive.appdata"; 34 | NSString * const kGTLAuthScopeDriveAppsReadonly = @"https://www.googleapis.com/auth/drive.apps.readonly"; 35 | NSString * const kGTLAuthScopeDriveFile = @"https://www.googleapis.com/auth/drive.file"; 36 | NSString * const kGTLAuthScopeDriveMetadataReadonly = @"https://www.googleapis.com/auth/drive.metadata.readonly"; 37 | NSString * const kGTLAuthScopeDriveReadonly = @"https://www.googleapis.com/auth/drive.readonly"; 38 | NSString * const kGTLAuthScopeDriveScripts = @"https://www.googleapis.com/auth/drive.scripts"; 39 | 40 | // GTLQueryDrive - Corpus 41 | NSString * const kGTLDriveCorpusDefault = @"DEFAULT"; 42 | NSString * const kGTLDriveCorpusDomain = @"DOMAIN"; 43 | 44 | // GTLQueryDrive - Projection 45 | NSString * const kGTLDriveProjectionBasic = @"BASIC"; 46 | NSString * const kGTLDriveProjectionFull = @"FULL"; 47 | 48 | // GTLQueryDrive - Visibility 49 | NSString * const kGTLDriveVisibilityDefault = @"DEFAULT"; 50 | NSString * const kGTLDriveVisibilityPrivate = @"PRIVATE"; 51 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveFile.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveFile.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveFile (0 custom class methods, 51 custom properties) 30 | // GTLDriveFileExportLinks (0 custom class methods, 0 custom properties) 31 | // GTLDriveFileImageMediaMetadata (0 custom class methods, 21 custom properties) 32 | // GTLDriveFileIndexableText (0 custom class methods, 1 custom properties) 33 | // GTLDriveFileLabels (0 custom class methods, 5 custom properties) 34 | // GTLDriveFileOpenWithLinks (0 custom class methods, 0 custom properties) 35 | // GTLDriveFileThumbnail (0 custom class methods, 2 custom properties) 36 | // GTLDriveFileVideoMediaMetadata (0 custom class methods, 3 custom properties) 37 | // GTLDriveFileImageMediaMetadataLocation (0 custom class methods, 3 custom properties) 38 | 39 | #import "GTLDriveFile.h" 40 | 41 | #import "GTLDriveParentReference.h" 42 | #import "GTLDrivePermission.h" 43 | #import "GTLDriveProperty.h" 44 | #import "GTLDriveUser.h" 45 | 46 | // ---------------------------------------------------------------------------- 47 | // 48 | // GTLDriveFile 49 | // 50 | 51 | @implementation GTLDriveFile 52 | @dynamic alternateLink, appDataContents, copyable, createdDate, 53 | defaultOpenWithLink, descriptionProperty, downloadUrl, editable, 54 | embedLink, ETag, explicitlyTrashed, exportLinks, fileExtension, 55 | fileSize, folderColorRgb, headRevisionId, iconLink, identifier, 56 | imageMediaMetadata, indexableText, kind, labels, lastModifyingUser, 57 | lastModifyingUserName, lastViewedByMeDate, markedViewedByMeDate, 58 | md5Checksum, mimeType, modifiedByMeDate, modifiedDate, openWithLinks, 59 | originalFilename, ownerNames, owners, parents, permissions, properties, 60 | quotaBytesUsed, selfLink, shared, sharedWithMeDate, sharingUser, 61 | thumbnail, thumbnailLink, title, userPermission, version, 62 | videoMediaMetadata, webContentLink, webViewLink, writersCanShare; 63 | 64 | + (NSDictionary *)propertyToJSONKeyMap { 65 | NSDictionary *map = 66 | [NSDictionary dictionaryWithObjectsAndKeys: 67 | @"description", @"descriptionProperty", 68 | @"etag", @"ETag", 69 | @"id", @"identifier", 70 | nil]; 71 | return map; 72 | } 73 | 74 | + (NSDictionary *)arrayPropertyToClassMap { 75 | NSDictionary *map = 76 | [NSDictionary dictionaryWithObjectsAndKeys: 77 | [NSString class], @"ownerNames", 78 | [GTLDriveUser class], @"owners", 79 | [GTLDriveParentReference class], @"parents", 80 | [GTLDrivePermission class], @"permissions", 81 | [GTLDriveProperty class], @"properties", 82 | nil]; 83 | return map; 84 | } 85 | 86 | + (void)load { 87 | [self registerObjectClassForKind:@"drive#file"]; 88 | } 89 | 90 | @end 91 | 92 | 93 | // ---------------------------------------------------------------------------- 94 | // 95 | // GTLDriveFileExportLinks 96 | // 97 | 98 | @implementation GTLDriveFileExportLinks 99 | 100 | + (Class)classForAdditionalProperties { 101 | return [NSString class]; 102 | } 103 | 104 | @end 105 | 106 | 107 | // ---------------------------------------------------------------------------- 108 | // 109 | // GTLDriveFileImageMediaMetadata 110 | // 111 | 112 | @implementation GTLDriveFileImageMediaMetadata 113 | @dynamic aperture, cameraMake, cameraModel, colorSpace, date, exposureBias, 114 | exposureMode, exposureTime, flashUsed, focalLength, height, isoSpeed, 115 | lens, location, maxApertureValue, meteringMode, rotation, sensor, 116 | subjectDistance, whiteBalance, width; 117 | @end 118 | 119 | 120 | // ---------------------------------------------------------------------------- 121 | // 122 | // GTLDriveFileIndexableText 123 | // 124 | 125 | @implementation GTLDriveFileIndexableText 126 | @dynamic text; 127 | @end 128 | 129 | 130 | // ---------------------------------------------------------------------------- 131 | // 132 | // GTLDriveFileLabels 133 | // 134 | 135 | @implementation GTLDriveFileLabels 136 | @dynamic hidden, restricted, starred, trashed, viewed; 137 | @end 138 | 139 | 140 | // ---------------------------------------------------------------------------- 141 | // 142 | // GTLDriveFileOpenWithLinks 143 | // 144 | 145 | @implementation GTLDriveFileOpenWithLinks 146 | 147 | + (Class)classForAdditionalProperties { 148 | return [NSString class]; 149 | } 150 | 151 | @end 152 | 153 | 154 | // ---------------------------------------------------------------------------- 155 | // 156 | // GTLDriveFileThumbnail 157 | // 158 | 159 | @implementation GTLDriveFileThumbnail 160 | @dynamic image, mimeType; 161 | @end 162 | 163 | 164 | // ---------------------------------------------------------------------------- 165 | // 166 | // GTLDriveFileVideoMediaMetadata 167 | // 168 | 169 | @implementation GTLDriveFileVideoMediaMetadata 170 | @dynamic durationMillis, height, width; 171 | @end 172 | 173 | 174 | // ---------------------------------------------------------------------------- 175 | // 176 | // GTLDriveFileImageMediaMetadataLocation 177 | // 178 | 179 | @implementation GTLDriveFileImageMediaMetadataLocation 180 | @dynamic altitude, latitude, longitude; 181 | @end 182 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveFileList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveFileList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveFileList (0 custom class methods, 6 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveFile; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveFileList 42 | // 43 | 44 | // A list of files. 45 | 46 | // This class supports NSFastEnumeration over its "items" property. It also 47 | // supports -itemAtIndex: to retrieve individual objects from "items". 48 | 49 | @interface GTLDriveFileList : GTLCollectionObject 50 | 51 | // The ETag of the list. 52 | @property (copy) NSString *ETag; 53 | 54 | // The actual list of files. 55 | @property (retain) NSArray *items; // of GTLDriveFile 56 | 57 | // This is always drive#fileList. 58 | @property (copy) NSString *kind; 59 | 60 | // A link to the next page of files. 61 | @property (copy) NSString *nextLink; 62 | 63 | // The page token for the next page of files. 64 | @property (copy) NSString *nextPageToken; 65 | 66 | // A link back to this list. 67 | @property (copy) NSString *selfLink; 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveFileList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveFileList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveFileList (0 custom class methods, 6 custom properties) 30 | 31 | #import "GTLDriveFileList.h" 32 | 33 | #import "GTLDriveFile.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveFileList 38 | // 39 | 40 | @implementation GTLDriveFileList 41 | @dynamic ETag, items, kind, nextLink, nextPageToken, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"etag" 46 | forKey:@"ETag"]; 47 | return map; 48 | } 49 | 50 | + (NSDictionary *)arrayPropertyToClassMap { 51 | NSDictionary *map = 52 | [NSDictionary dictionaryWithObject:[GTLDriveFile class] 53 | forKey:@"items"]; 54 | return map; 55 | } 56 | 57 | + (void)load { 58 | [self registerObjectClassForKind:@"drive#fileList"]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveParentList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveParentList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveParentList (0 custom class methods, 4 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveParentReference; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveParentList 42 | // 43 | 44 | // A list of a file's parents. 45 | 46 | // This class supports NSFastEnumeration over its "items" property. It also 47 | // supports -itemAtIndex: to retrieve individual objects from "items". 48 | 49 | @interface GTLDriveParentList : GTLCollectionObject 50 | 51 | // The ETag of the list. 52 | @property (copy) NSString *ETag; 53 | 54 | // The actual list of parents. 55 | @property (retain) NSArray *items; // of GTLDriveParentReference 56 | 57 | // This is always drive#parentList. 58 | @property (copy) NSString *kind; 59 | 60 | // A link back to this list. 61 | @property (copy) NSString *selfLink; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveParentList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveParentList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveParentList (0 custom class methods, 4 custom properties) 30 | 31 | #import "GTLDriveParentList.h" 32 | 33 | #import "GTLDriveParentReference.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveParentList 38 | // 39 | 40 | @implementation GTLDriveParentList 41 | @dynamic ETag, items, kind, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"etag" 46 | forKey:@"ETag"]; 47 | return map; 48 | } 49 | 50 | + (NSDictionary *)arrayPropertyToClassMap { 51 | NSDictionary *map = 52 | [NSDictionary dictionaryWithObject:[GTLDriveParentReference class] 53 | forKey:@"items"]; 54 | return map; 55 | } 56 | 57 | + (void)load { 58 | [self registerObjectClassForKind:@"drive#parentList"]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveParentReference.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveParentReference.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveParentReference (0 custom class methods, 5 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | // ---------------------------------------------------------------------------- 38 | // 39 | // GTLDriveParentReference 40 | // 41 | 42 | // A reference to a file's parent. 43 | 44 | @interface GTLDriveParentReference : GTLObject 45 | 46 | // The ID of the parent. 47 | // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). 48 | @property (copy) NSString *identifier; 49 | 50 | // Whether or not the parent is the root folder. 51 | @property (retain) NSNumber *isRoot; // boolValue 52 | 53 | // This is always drive#parentReference. 54 | @property (copy) NSString *kind; 55 | 56 | // A link to the parent. 57 | @property (copy) NSString *parentLink; 58 | 59 | // A link back to this reference. 60 | @property (copy) NSString *selfLink; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveParentReference.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveParentReference.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveParentReference (0 custom class methods, 5 custom properties) 30 | 31 | #import "GTLDriveParentReference.h" 32 | 33 | // ---------------------------------------------------------------------------- 34 | // 35 | // GTLDriveParentReference 36 | // 37 | 38 | @implementation GTLDriveParentReference 39 | @dynamic identifier, isRoot, kind, parentLink, selfLink; 40 | 41 | + (NSDictionary *)propertyToJSONKeyMap { 42 | NSDictionary *map = 43 | [NSDictionary dictionaryWithObject:@"id" 44 | forKey:@"identifier"]; 45 | return map; 46 | } 47 | 48 | + (void)load { 49 | [self registerObjectClassForKind:@"drive#parentReference"]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrivePermission.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrivePermission.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDrivePermission (0 custom class methods, 14 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | // ---------------------------------------------------------------------------- 38 | // 39 | // GTLDrivePermission 40 | // 41 | 42 | // A permission for a file. 43 | 44 | @interface GTLDrivePermission : GTLObject 45 | 46 | // Additional roles for this user. Only commenter is currently allowed. 47 | @property (retain) NSArray *additionalRoles; // of NSString 48 | 49 | // The authkey parameter required for this permission. 50 | @property (copy) NSString *authKey; 51 | 52 | // The domain name of the entity this permission refers to. This is an 53 | // output-only field which is present when the permission type is user, group or 54 | // domain. 55 | @property (copy) NSString *domain; 56 | 57 | // The email address of the user or group this permission refers to. This is an 58 | // output-only field which is present when the permission type is user or group. 59 | @property (copy) NSString *emailAddress; 60 | 61 | // The ETag of the permission. 62 | @property (copy) NSString *ETag; 63 | 64 | // The ID of the user this permission refers to, and identical to the 65 | // permissionId in the About and Files resources. When making a 66 | // drive.permissions.insert request, exactly one of the id or value fields must 67 | // be specified. 68 | // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). 69 | @property (copy) NSString *identifier; 70 | 71 | // This is always drive#permission. 72 | @property (copy) NSString *kind; 73 | 74 | // The name for this permission. 75 | @property (copy) NSString *name; 76 | 77 | // A link to the profile photo, if available. 78 | @property (copy) NSString *photoLink; 79 | 80 | // The primary role for this user. Allowed values are: 81 | // - owner 82 | // - reader 83 | // - writer 84 | @property (copy) NSString *role; 85 | 86 | // A link back to this permission. 87 | @property (copy) NSString *selfLink; 88 | 89 | // The account type. Allowed values are: 90 | // - user 91 | // - group 92 | // - domain 93 | // - anyone 94 | @property (copy) NSString *type; 95 | 96 | // The email address or domain name for the entity. This is used during inserts 97 | // and is not populated in responses. When making a drive.permissions.insert 98 | // request, exactly one of the id or value fields must be specified. 99 | @property (copy) NSString *value; 100 | 101 | // Whether the link is required for this permission. 102 | @property (retain) NSNumber *withLink; // boolValue 103 | 104 | @end 105 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrivePermission.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrivePermission.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDrivePermission (0 custom class methods, 14 custom properties) 30 | 31 | #import "GTLDrivePermission.h" 32 | 33 | // ---------------------------------------------------------------------------- 34 | // 35 | // GTLDrivePermission 36 | // 37 | 38 | @implementation GTLDrivePermission 39 | @dynamic additionalRoles, authKey, domain, emailAddress, ETag, identifier, kind, 40 | name, photoLink, role, selfLink, type, value, withLink; 41 | 42 | + (NSDictionary *)propertyToJSONKeyMap { 43 | NSDictionary *map = 44 | [NSDictionary dictionaryWithObjectsAndKeys: 45 | @"etag", @"ETag", 46 | @"id", @"identifier", 47 | nil]; 48 | return map; 49 | } 50 | 51 | + (NSDictionary *)arrayPropertyToClassMap { 52 | NSDictionary *map = 53 | [NSDictionary dictionaryWithObject:[NSString class] 54 | forKey:@"additionalRoles"]; 55 | return map; 56 | } 57 | 58 | + (void)load { 59 | [self registerObjectClassForKind:@"drive#permission"]; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrivePermissionId.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrivePermissionId.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDrivePermissionId (0 custom class methods, 2 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | // ---------------------------------------------------------------------------- 38 | // 39 | // GTLDrivePermissionId 40 | // 41 | 42 | // An ID for a user or group as seen in Permission items. 43 | 44 | @interface GTLDrivePermissionId : GTLObject 45 | 46 | // The permission ID. 47 | // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). 48 | @property (copy) NSString *identifier; 49 | 50 | // This is always drive#permissionId. 51 | @property (copy) NSString *kind; 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrivePermissionId.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrivePermissionId.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDrivePermissionId (0 custom class methods, 2 custom properties) 30 | 31 | #import "GTLDrivePermissionId.h" 32 | 33 | // ---------------------------------------------------------------------------- 34 | // 35 | // GTLDrivePermissionId 36 | // 37 | 38 | @implementation GTLDrivePermissionId 39 | @dynamic identifier, kind; 40 | 41 | + (NSDictionary *)propertyToJSONKeyMap { 42 | NSDictionary *map = 43 | [NSDictionary dictionaryWithObject:@"id" 44 | forKey:@"identifier"]; 45 | return map; 46 | } 47 | 48 | + (void)load { 49 | [self registerObjectClassForKind:@"drive#permissionId"]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrivePermissionList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrivePermissionList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDrivePermissionList (0 custom class methods, 4 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDrivePermission; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDrivePermissionList 42 | // 43 | 44 | // A list of permissions associated with a file. 45 | 46 | // This class supports NSFastEnumeration over its "items" property. It also 47 | // supports -itemAtIndex: to retrieve individual objects from "items". 48 | 49 | @interface GTLDrivePermissionList : GTLCollectionObject 50 | 51 | // The ETag of the list. 52 | @property (copy) NSString *ETag; 53 | 54 | // The actual list of permissions. 55 | @property (retain) NSArray *items; // of GTLDrivePermission 56 | 57 | // This is always drive#permissionList. 58 | @property (copy) NSString *kind; 59 | 60 | // A link back to this list. 61 | @property (copy) NSString *selfLink; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrivePermissionList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrivePermissionList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDrivePermissionList (0 custom class methods, 4 custom properties) 30 | 31 | #import "GTLDrivePermissionList.h" 32 | 33 | #import "GTLDrivePermission.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDrivePermissionList 38 | // 39 | 40 | @implementation GTLDrivePermissionList 41 | @dynamic ETag, items, kind, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"etag" 46 | forKey:@"ETag"]; 47 | return map; 48 | } 49 | 50 | + (NSDictionary *)arrayPropertyToClassMap { 51 | NSDictionary *map = 52 | [NSDictionary dictionaryWithObject:[GTLDrivePermission class] 53 | forKey:@"items"]; 54 | return map; 55 | } 56 | 57 | + (void)load { 58 | [self registerObjectClassForKind:@"drive#permissionList"]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveProperty.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveProperty.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveProperty (0 custom class methods, 6 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | // ---------------------------------------------------------------------------- 38 | // 39 | // GTLDriveProperty 40 | // 41 | 42 | // A key-value pair that is either public or private to an application. 43 | 44 | @interface GTLDriveProperty : GTLObject 45 | 46 | // ETag of the property. 47 | @property (copy) NSString *ETag; 48 | 49 | // The key of this property. 50 | @property (copy) NSString *key; 51 | 52 | // This is always drive#property. 53 | @property (copy) NSString *kind; 54 | 55 | // The link back to this property. 56 | @property (copy) NSString *selfLink; 57 | 58 | // The value of this property. 59 | @property (copy) NSString *value; 60 | 61 | // The visibility of this property. 62 | @property (copy) NSString *visibility; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveProperty.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveProperty.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveProperty (0 custom class methods, 6 custom properties) 30 | 31 | #import "GTLDriveProperty.h" 32 | 33 | // ---------------------------------------------------------------------------- 34 | // 35 | // GTLDriveProperty 36 | // 37 | 38 | @implementation GTLDriveProperty 39 | @dynamic ETag, key, kind, selfLink, value, visibility; 40 | 41 | + (NSDictionary *)propertyToJSONKeyMap { 42 | NSDictionary *map = 43 | [NSDictionary dictionaryWithObject:@"etag" 44 | forKey:@"ETag"]; 45 | return map; 46 | } 47 | 48 | + (void)load { 49 | [self registerObjectClassForKind:@"drive#property"]; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrivePropertyList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrivePropertyList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDrivePropertyList (0 custom class methods, 4 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveProperty; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDrivePropertyList 42 | // 43 | 44 | // A collection of properties, key-value pairs that are either public or private 45 | // to an application. 46 | 47 | // This class supports NSFastEnumeration over its "items" property. It also 48 | // supports -itemAtIndex: to retrieve individual objects from "items". 49 | 50 | @interface GTLDrivePropertyList : GTLCollectionObject 51 | 52 | // The ETag of the list. 53 | @property (copy) NSString *ETag; 54 | 55 | // The list of properties. 56 | @property (retain) NSArray *items; // of GTLDriveProperty 57 | 58 | // This is always drive#propertyList. 59 | @property (copy) NSString *kind; 60 | 61 | // The link back to this list. 62 | @property (copy) NSString *selfLink; 63 | 64 | @end 65 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDrivePropertyList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDrivePropertyList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDrivePropertyList (0 custom class methods, 4 custom properties) 30 | 31 | #import "GTLDrivePropertyList.h" 32 | 33 | #import "GTLDriveProperty.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDrivePropertyList 38 | // 39 | 40 | @implementation GTLDrivePropertyList 41 | @dynamic ETag, items, kind, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"etag" 46 | forKey:@"ETag"]; 47 | return map; 48 | } 49 | 50 | + (NSDictionary *)arrayPropertyToClassMap { 51 | NSDictionary *map = 52 | [NSDictionary dictionaryWithObject:[GTLDriveProperty class] 53 | forKey:@"items"]; 54 | return map; 55 | } 56 | 57 | + (void)load { 58 | [self registerObjectClassForKind:@"drive#propertyList"]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveRevision.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveRevision.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveRevision (0 custom class methods, 18 custom properties) 30 | // GTLDriveRevisionExportLinks (0 custom class methods, 0 custom properties) 31 | 32 | #if GTL_BUILT_AS_FRAMEWORK 33 | #import "GTL/GTLObject.h" 34 | #else 35 | #import "GTLObject.h" 36 | #endif 37 | 38 | @class GTLDriveRevisionExportLinks; 39 | @class GTLDriveUser; 40 | 41 | // ---------------------------------------------------------------------------- 42 | // 43 | // GTLDriveRevision 44 | // 45 | 46 | // A revision of a file. 47 | 48 | @interface GTLDriveRevision : GTLObject 49 | 50 | // Short term download URL for the file. This will only be populated on files 51 | // with content stored in Drive. 52 | @property (copy) NSString *downloadUrl; 53 | 54 | // The ETag of the revision. 55 | @property (copy) NSString *ETag; 56 | 57 | // Links for exporting Google Docs to specific formats. 58 | @property (retain) GTLDriveRevisionExportLinks *exportLinks; 59 | 60 | // The size of the revision in bytes. This will only be populated on files with 61 | // content stored in Drive. 62 | @property (retain) NSNumber *fileSize; // longLongValue 63 | 64 | // The ID of the revision. 65 | // identifier property maps to 'id' in JSON (to avoid Objective C's 'id'). 66 | @property (copy) NSString *identifier; 67 | 68 | // This is always drive#revision. 69 | @property (copy) NSString *kind; 70 | 71 | // The last user to modify this revision. 72 | @property (retain) GTLDriveUser *lastModifyingUser; 73 | 74 | // Name of the last user to modify this revision. 75 | @property (copy) NSString *lastModifyingUserName; 76 | 77 | // An MD5 checksum for the content of this revision. This will only be populated 78 | // on files with content stored in Drive. 79 | @property (copy) NSString *md5Checksum; 80 | 81 | // The MIME type of the revision. 82 | @property (copy) NSString *mimeType; 83 | 84 | // Last time this revision was modified (formatted RFC 3339 timestamp). 85 | @property (retain) GTLDateTime *modifiedDate; 86 | 87 | // The original filename when this revision was created. This will only be 88 | // populated on files with content stored in Drive. 89 | @property (copy) NSString *originalFilename; 90 | 91 | // Whether this revision is pinned to prevent automatic purging. This will only 92 | // be populated and can only be modified on files with content stored in Drive 93 | // which are not Google Docs. Revisions can also be pinned when they are created 94 | // through the drive.files.insert/update/copy by using the pinned query 95 | // parameter. 96 | @property (retain) NSNumber *pinned; // boolValue 97 | 98 | // Whether subsequent revisions will be automatically republished. This is only 99 | // populated and can only be modified for Google Docs. 100 | @property (retain) NSNumber *publishAuto; // boolValue 101 | 102 | // Whether this revision is published. This is only populated and can only be 103 | // modified for Google Docs. 104 | @property (retain) NSNumber *published; // boolValue 105 | 106 | // A link to the published revision. 107 | @property (copy) NSString *publishedLink; 108 | 109 | // Whether this revision is published outside the domain. This is only populated 110 | // and can only be modified for Google Docs. 111 | @property (retain) NSNumber *publishedOutsideDomain; // boolValue 112 | 113 | // A link back to this revision. 114 | @property (copy) NSString *selfLink; 115 | 116 | @end 117 | 118 | 119 | // ---------------------------------------------------------------------------- 120 | // 121 | // GTLDriveRevisionExportLinks 122 | // 123 | 124 | @interface GTLDriveRevisionExportLinks : GTLObject 125 | // This object is documented as having more properties that are NSString. Use 126 | // -additionalJSONKeys and -additionalPropertyForName: to get the list of 127 | // properties and then fetch them; or -additionalProperties to fetch them all at 128 | // once. 129 | @end 130 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveRevision.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveRevision.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveRevision (0 custom class methods, 18 custom properties) 30 | // GTLDriveRevisionExportLinks (0 custom class methods, 0 custom properties) 31 | 32 | #import "GTLDriveRevision.h" 33 | 34 | #import "GTLDriveUser.h" 35 | 36 | // ---------------------------------------------------------------------------- 37 | // 38 | // GTLDriveRevision 39 | // 40 | 41 | @implementation GTLDriveRevision 42 | @dynamic downloadUrl, ETag, exportLinks, fileSize, identifier, kind, 43 | lastModifyingUser, lastModifyingUserName, md5Checksum, mimeType, 44 | modifiedDate, originalFilename, pinned, publishAuto, published, 45 | publishedLink, publishedOutsideDomain, selfLink; 46 | 47 | + (NSDictionary *)propertyToJSONKeyMap { 48 | NSDictionary *map = 49 | [NSDictionary dictionaryWithObjectsAndKeys: 50 | @"etag", @"ETag", 51 | @"id", @"identifier", 52 | nil]; 53 | return map; 54 | } 55 | 56 | + (void)load { 57 | [self registerObjectClassForKind:@"drive#revision"]; 58 | } 59 | 60 | @end 61 | 62 | 63 | // ---------------------------------------------------------------------------- 64 | // 65 | // GTLDriveRevisionExportLinks 66 | // 67 | 68 | @implementation GTLDriveRevisionExportLinks 69 | 70 | + (Class)classForAdditionalProperties { 71 | return [NSString class]; 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveRevisionList.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveRevisionList.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveRevisionList (0 custom class methods, 4 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLObject.h" 33 | #else 34 | #import "GTLObject.h" 35 | #endif 36 | 37 | @class GTLDriveRevision; 38 | 39 | // ---------------------------------------------------------------------------- 40 | // 41 | // GTLDriveRevisionList 42 | // 43 | 44 | // A list of revisions of a file. 45 | 46 | // This class supports NSFastEnumeration over its "items" property. It also 47 | // supports -itemAtIndex: to retrieve individual objects from "items". 48 | 49 | @interface GTLDriveRevisionList : GTLCollectionObject 50 | 51 | // The ETag of the list. 52 | @property (copy) NSString *ETag; 53 | 54 | // The actual list of revisions. 55 | @property (retain) NSArray *items; // of GTLDriveRevision 56 | 57 | // This is always drive#revisionList. 58 | @property (copy) NSString *kind; 59 | 60 | // A link back to this list. 61 | @property (copy) NSString *selfLink; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveRevisionList.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveRevisionList.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveRevisionList (0 custom class methods, 4 custom properties) 30 | 31 | #import "GTLDriveRevisionList.h" 32 | 33 | #import "GTLDriveRevision.h" 34 | 35 | // ---------------------------------------------------------------------------- 36 | // 37 | // GTLDriveRevisionList 38 | // 39 | 40 | @implementation GTLDriveRevisionList 41 | @dynamic ETag, items, kind, selfLink; 42 | 43 | + (NSDictionary *)propertyToJSONKeyMap { 44 | NSDictionary *map = 45 | [NSDictionary dictionaryWithObject:@"etag" 46 | forKey:@"ETag"]; 47 | return map; 48 | } 49 | 50 | + (NSDictionary *)arrayPropertyToClassMap { 51 | NSDictionary *map = 52 | [NSDictionary dictionaryWithObject:[GTLDriveRevision class] 53 | forKey:@"items"]; 54 | return map; 55 | } 56 | 57 | + (void)load { 58 | [self registerObjectClassForKind:@"drive#revisionList"]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveUser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveUser.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveUser (0 custom class methods, 6 custom properties) 30 | // GTLDriveUserPicture (0 custom class methods, 1 custom properties) 31 | 32 | #if GTL_BUILT_AS_FRAMEWORK 33 | #import "GTL/GTLObject.h" 34 | #else 35 | #import "GTLObject.h" 36 | #endif 37 | 38 | @class GTLDriveUserPicture; 39 | 40 | // ---------------------------------------------------------------------------- 41 | // 42 | // GTLDriveUser 43 | // 44 | 45 | // The JSON template for a user. 46 | 47 | @interface GTLDriveUser : GTLObject 48 | 49 | // A plain text displayable name for this user. 50 | @property (copy) NSString *displayName; 51 | 52 | // The email address of the user. 53 | @property (copy) NSString *emailAddress; 54 | 55 | // Whether this user is the same as the authenticated user for whom the request 56 | // was made. 57 | @property (retain) NSNumber *isAuthenticatedUser; // boolValue 58 | 59 | // This is always drive#user. 60 | @property (copy) NSString *kind; 61 | 62 | // The user's ID as visible in the permissions collection. 63 | @property (copy) NSString *permissionId; 64 | 65 | // The user's profile picture. 66 | @property (retain) GTLDriveUserPicture *picture; 67 | 68 | @end 69 | 70 | 71 | // ---------------------------------------------------------------------------- 72 | // 73 | // GTLDriveUserPicture 74 | // 75 | 76 | @interface GTLDriveUserPicture : GTLObject 77 | 78 | // A URL that points to a profile picture of this user. 79 | @property (copy) NSString *url; 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLDriveUser.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLDriveUser.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLDriveUser (0 custom class methods, 6 custom properties) 30 | // GTLDriveUserPicture (0 custom class methods, 1 custom properties) 31 | 32 | #import "GTLDriveUser.h" 33 | 34 | // ---------------------------------------------------------------------------- 35 | // 36 | // GTLDriveUser 37 | // 38 | 39 | @implementation GTLDriveUser 40 | @dynamic displayName, emailAddress, isAuthenticatedUser, kind, permissionId, 41 | picture; 42 | 43 | + (void)load { 44 | [self registerObjectClassForKind:@"drive#user"]; 45 | } 46 | 47 | @end 48 | 49 | 50 | // ---------------------------------------------------------------------------- 51 | // 52 | // GTLDriveUserPicture 53 | // 54 | 55 | @implementation GTLDriveUserPicture 56 | @dynamic url; 57 | @end 58 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLServiceDrive.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLServiceDrive.h 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLServiceDrive (0 custom class methods, 0 custom properties) 30 | 31 | #if GTL_BUILT_AS_FRAMEWORK 32 | #import "GTL/GTLService.h" 33 | #else 34 | #import "GTLService.h" 35 | #endif 36 | 37 | @interface GTLServiceDrive : GTLService 38 | 39 | // No new methods 40 | 41 | // Clients should create a standard query with any of the class methods in 42 | // GTLQueryDrive.h. The query can the be sent with GTLService's execute methods, 43 | // 44 | // - (GTLServiceTicket *)executeQuery:(GTLQuery *)query 45 | // completionHandler:(void (^)(GTLServiceTicket *ticket, 46 | // id object, NSError *error))handler; 47 | // or 48 | // - (GTLServiceTicket *)executeQuery:(GTLQuery *)query 49 | // delegate:(id)delegate 50 | // didFinishSelector:(SEL)finishedSelector; 51 | // 52 | // where finishedSelector has a signature of: 53 | // 54 | // - (void)serviceTicket:(GTLServiceTicket *)ticket 55 | // finishedWithObject:(id)object 56 | // error:(NSError *)error; 57 | // 58 | // The object passed to the completion handler or delegate method 59 | // is a subclass of GTLObject, determined by the query method executed. 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDrive/GTLServiceDrive.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Google Inc. 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | // 17 | // GTLServiceDrive.m 18 | // 19 | 20 | // ---------------------------------------------------------------------------- 21 | // NOTE: This file is generated from Google APIs Discovery Service. 22 | // Service: 23 | // Drive API (drive/v2) 24 | // Description: 25 | // The API to interact with Drive. 26 | // Documentation: 27 | // https://developers.google.com/drive/ 28 | // Classes: 29 | // GTLServiceDrive (0 custom class methods, 0 custom properties) 30 | 31 | #import "GTLDrive.h" 32 | 33 | @implementation GTLServiceDrive 34 | 35 | #if DEBUG 36 | // Method compiled in debug builds just to check that all the needed support 37 | // classes are present at link time. 38 | + (NSArray *)checkClasses { 39 | NSArray *classes = [NSArray arrayWithObjects: 40 | [GTLQueryDrive class], 41 | [GTLDriveAbout class], 42 | [GTLDriveApp class], 43 | [GTLDriveAppList class], 44 | [GTLDriveChange class], 45 | [GTLDriveChangeList class], 46 | [GTLDriveChannel class], 47 | [GTLDriveChildList class], 48 | [GTLDriveChildReference class], 49 | [GTLDriveComment class], 50 | [GTLDriveCommentList class], 51 | [GTLDriveCommentReply class], 52 | [GTLDriveCommentReplyList class], 53 | [GTLDriveFile class], 54 | [GTLDriveFileList class], 55 | [GTLDriveParentList class], 56 | [GTLDriveParentReference class], 57 | [GTLDrivePermission class], 58 | [GTLDrivePermissionId class], 59 | [GTLDrivePermissionList class], 60 | [GTLDriveProperty class], 61 | [GTLDrivePropertyList class], 62 | [GTLDriveRevision class], 63 | [GTLDriveRevisionList class], 64 | [GTLDriveUser class], 65 | nil]; 66 | return classes; 67 | } 68 | #endif // DEBUG 69 | 70 | - (id)init { 71 | self = [super init]; 72 | if (self) { 73 | // Version from discovery. 74 | self.apiVersion = @"v2"; 75 | 76 | // From discovery. Where to send JSON-RPC. 77 | // Turn off prettyPrint for this service to save bandwidth (especially on 78 | // mobile). The fetcher logging will pretty print. 79 | self.rpcURL = [NSURL URLWithString:@"https://www.googleapis.com/rpc?prettyPrint=false"]; 80 | self.rpcUploadURL = [NSURL URLWithString:@"https://www.googleapis.com/upload/rpc?uploadType=resumable&prettyPrint=false"]; 81 | } 82 | return self; 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /GoogleDriveSample/GoogleDriveSample-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "GTMOAuth2ViewControllerTouch.h" 6 | #import "GTLDrive.h" -------------------------------------------------------------------------------- /GoogleDriveSample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /GoogleDriveSample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "ipad", 6 | "minimum-system-version" : "7.0", 7 | "extent" : "full-screen", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "landscape", 12 | "idiom" : "ipad", 13 | "minimum-system-version" : "7.0", 14 | "extent" : "full-screen", 15 | "scale" : "1x" 16 | }, 17 | { 18 | "orientation" : "landscape", 19 | "idiom" : "ipad", 20 | "minimum-system-version" : "7.0", 21 | "extent" : "full-screen", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "orientation" : "portrait", 26 | "idiom" : "iphone", 27 | "minimum-system-version" : "7.0", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "minimum-system-version" : "7.0", 34 | "subtype" : "retina4", 35 | "scale" : "2x" 36 | }, 37 | { 38 | "orientation" : "portrait", 39 | "idiom" : "ipad", 40 | "minimum-system-version" : "7.0", 41 | "extent" : "full-screen", 42 | "scale" : "1x" 43 | } 44 | ], 45 | "info" : { 46 | "version" : 1, 47 | "author" : "xcode" 48 | } 49 | } -------------------------------------------------------------------------------- /GoogleDriveSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.huiqin.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /GoogleDriveSampleTests/GoogleDriveSampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GoogleDriveSampleTests.swift 3 | // GoogleDriveSampleTests 4 | // 5 | // Created by Ng Hui Qin on 4/9/15. 6 | // Copyright (c) 2015 huiqin.testing. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class GoogleDriveSampleTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /GoogleDriveSampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.huiqin.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS-Swift-GoogleDriveSample 2 | This is an example of integration of Google Drive API for iOS. 3 | The method implemented inside is to provide another solution to integrate the Google API. 4 | 5 | For further information, please look into my post in WordPress. 6 | https://nghuiqin.wordpress.com/2015/04/09/swift-notes-google-drive-api-library-integration-for-ios/ 7 | iOS integrate with Google Drive API 8 | --------------------------------------------------------------------------------