diff options
Diffstat (limited to 'SmartDeviceLink')
-rw-r--r-- | SmartDeviceLink/SDLDeleteFileOperation.m | 29 | ||||
-rw-r--r-- | SmartDeviceLink/SDLDeleteFileResponse.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLDeleteFileResponse.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLFileManager.m | 10 | ||||
-rw-r--r-- | SmartDeviceLink/SDLListFilesOperation.m | 27 | ||||
-rw-r--r-- | SmartDeviceLink/SDLListFilesResponse.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLListFilesResponse.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPutFileResponse.h | 2 | ||||
-rw-r--r-- | SmartDeviceLink/SDLPutFileResponse.m | 4 | ||||
-rw-r--r-- | SmartDeviceLink/SDLUploadFileOperation.m | 7 |
10 files changed, 47 insertions, 44 deletions
diff --git a/SmartDeviceLink/SDLDeleteFileOperation.m b/SmartDeviceLink/SDLDeleteFileOperation.m index f45f3cbdd..4d974a2ad 100644 --- a/SmartDeviceLink/SDLDeleteFileOperation.m +++ b/SmartDeviceLink/SDLDeleteFileOperation.m @@ -48,20 +48,21 @@ NS_ASSUME_NONNULL_BEGIN SDLDeleteFile *deleteFile = [[SDLDeleteFile alloc] initWithFileName:self.fileName]; typeof(self) weakself = self; - [self.connectionManager sendConnectionManagerRequest:deleteFile - withResponseHandler:^(__kindof SDLRPCRequest *request, __kindof SDLRPCResponse *response, NSError *error) { - // Pull out the parameters - SDLDeleteFileResponse *deleteFileResponse = (SDLDeleteFileResponse *)response; - BOOL success = [deleteFileResponse.success boolValue]; - NSUInteger bytesAvailable = [deleteFileResponse.spaceAvailable unsignedIntegerValue]; - - // Callback - if (weakself.completionHandler != nil) { - weakself.completionHandler(success, bytesAvailable, error); - } - - [weakself finishOperation]; - }]; + [self.connectionManager sendConnectionManagerRequest:deleteFile withResponseHandler:^(__kindof SDLRPCRequest *request, __kindof SDLRPCResponse *response, NSError *error) { + // Pull out the parameters + SDLDeleteFileResponse *deleteFileResponse = (SDLDeleteFileResponse *)response; + BOOL success = [deleteFileResponse.success boolValue]; + + // If spaceAvailable is nil, set it to the max value + NSUInteger bytesAvailable = deleteFileResponse.spaceAvailable != nil ? deleteFileResponse.spaceAvailable.unsignedIntegerValue : 2000000000; + + // Callback + if (weakself.completionHandler != nil) { + weakself.completionHandler(success, bytesAvailable, error); + } + + [weakself finishOperation]; + }]; } diff --git a/SmartDeviceLink/SDLDeleteFileResponse.h b/SmartDeviceLink/SDLDeleteFileResponse.h index 8c3fc4fc5..c639dcdd7 100644 --- a/SmartDeviceLink/SDLDeleteFileResponse.h +++ b/SmartDeviceLink/SDLDeleteFileResponse.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN /** The remaining available space for your application to store data on the remote system. */ -@property (strong, nonatomic) NSNumber<SDLInt> *spaceAvailable; +@property (nullable, strong, nonatomic) NSNumber<SDLInt> *spaceAvailable; @end diff --git a/SmartDeviceLink/SDLDeleteFileResponse.m b/SmartDeviceLink/SDLDeleteFileResponse.m index 5c54b9852..42689fafe 100644 --- a/SmartDeviceLink/SDLDeleteFileResponse.m +++ b/SmartDeviceLink/SDLDeleteFileResponse.m @@ -17,11 +17,11 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (void)setSpaceAvailable:(NSNumber<SDLInt> *)spaceAvailable { +- (void)setSpaceAvailable:(nullable NSNumber<SDLInt> *)spaceAvailable { [parameters sdl_setObject:spaceAvailable forName:SDLNameSpaceAvailable]; } -- (NSNumber<SDLInt> *)spaceAvailable { +- (nullable NSNumber<SDLInt> *)spaceAvailable { return [parameters sdl_objectForName:SDLNameSpaceAvailable]; } diff --git a/SmartDeviceLink/SDLFileManager.m b/SmartDeviceLink/SDLFileManager.m index 717660f47..9ff7498ef 100644 --- a/SmartDeviceLink/SDLFileManager.m +++ b/SmartDeviceLink/SDLFileManager.m @@ -228,13 +228,13 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; __strong typeof(weakSelf) strongSelf = weakSelf; // Mutate self based on the changes - strongSelf.bytesAvailable = bytesAvailable; if (success) { + strongSelf.bytesAvailable = bytesAvailable; [strongSelf.mutableRemoteFileNames removeObject:name]; } if (handler != nil) { - handler(success, self.bytesAvailable, error); + handler(success, bytesAvailable, error); } }]; @@ -385,11 +385,9 @@ SDLFileManagerState *const SDLFileManagerStateStartupError = @"StartupError"; if (self.uploadsInProgress[file.name]) { [self.uploadsInProgress removeObjectForKey:file.name]; } - - if (bytesAvailable != 0) { - weakSelf.bytesAvailable = bytesAvailable; - } + if (success) { + weakSelf.bytesAvailable = bytesAvailable; [weakSelf.mutableRemoteFileNames addObject:fileName]; [weakSelf.uploadedEphemeralFileNames addObject:fileName]; } else { diff --git a/SmartDeviceLink/SDLListFilesOperation.m b/SmartDeviceLink/SDLListFilesOperation.m index 0cfd85460..ca45ac928 100644 --- a/SmartDeviceLink/SDLListFilesOperation.m +++ b/SmartDeviceLink/SDLListFilesOperation.m @@ -47,19 +47,20 @@ NS_ASSUME_NONNULL_BEGIN SDLListFiles *listFiles = [[SDLListFiles alloc] init]; __weak typeof(self) weakSelf = self; - [self.connectionManager sendConnectionManagerRequest:listFiles - withResponseHandler:^(__kindof SDLRPCRequest *request, __kindof SDLRPCResponse *response, NSError *error) { - SDLListFilesResponse *listFilesResponse = (SDLListFilesResponse *)response; - BOOL success = [listFilesResponse.success boolValue]; - NSUInteger bytesAvailable = [listFilesResponse.spaceAvailable unsignedIntegerValue]; - NSArray<NSString *> *fileNames = [NSArray arrayWithArray:listFilesResponse.filenames]; - - if (weakSelf.completionHandler != nil) { - weakSelf.completionHandler(success, bytesAvailable, fileNames, error); - } - - [weakSelf finishOperation]; - }]; + [self.connectionManager sendConnectionManagerRequest:listFiles withResponseHandler:^(__kindof SDLRPCRequest *request, __kindof SDLRPCResponse *response, NSError *error) { + SDLListFilesResponse *listFilesResponse = (SDLListFilesResponse *)response; + BOOL success = [listFilesResponse.success boolValue]; + NSArray<NSString *> *fileNames = [NSArray arrayWithArray:listFilesResponse.filenames]; + + // If spaceAvailable is nil, set it to the max value + NSUInteger bytesAvailable = listFilesResponse.spaceAvailable != nil ? listFilesResponse.spaceAvailable.unsignedIntegerValue : 2000000000; + + if (weakSelf.completionHandler != nil) { + weakSelf.completionHandler(success, bytesAvailable, fileNames, error); + } + + [weakSelf finishOperation]; + }]; } diff --git a/SmartDeviceLink/SDLListFilesResponse.h b/SmartDeviceLink/SDLListFilesResponse.h index b269b11c4..b5ddef16e 100644 --- a/SmartDeviceLink/SDLListFilesResponse.h +++ b/SmartDeviceLink/SDLListFilesResponse.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN /** Provides the total local space available on the module for the registered app. */ -@property (strong, nonatomic) NSNumber<SDLInt> *spaceAvailable; +@property (nullable, strong, nonatomic) NSNumber<SDLInt> *spaceAvailable; @end diff --git a/SmartDeviceLink/SDLListFilesResponse.m b/SmartDeviceLink/SDLListFilesResponse.m index f78d83acb..376e81702 100644 --- a/SmartDeviceLink/SDLListFilesResponse.m +++ b/SmartDeviceLink/SDLListFilesResponse.m @@ -25,11 +25,11 @@ NS_ASSUME_NONNULL_BEGIN return [parameters sdl_objectForName:SDLNameFilenames]; } -- (void)setSpaceAvailable:(NSNumber<SDLInt> *)spaceAvailable { +- (void)setSpaceAvailable:(nullable NSNumber<SDLInt> *)spaceAvailable { [parameters sdl_setObject:spaceAvailable forName:SDLNameSpaceAvailable]; } -- (NSNumber<SDLInt> *)spaceAvailable { +- (nullable NSNumber<SDLInt> *)spaceAvailable { return [parameters sdl_objectForName:SDLNameSpaceAvailable]; } diff --git a/SmartDeviceLink/SDLPutFileResponse.h b/SmartDeviceLink/SDLPutFileResponse.h index 322ab47d4..0c8772125 100644 --- a/SmartDeviceLink/SDLPutFileResponse.h +++ b/SmartDeviceLink/SDLPutFileResponse.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Provides the total local space available in SDL Core for the registered app. If the transfer has systemFile enabled, then the value will be set to 0 automatically. */ -@property (strong, nonatomic) NSNumber<SDLInt> *spaceAvailable; +@property (nullable, strong, nonatomic) NSNumber<SDLInt> *spaceAvailable; @end diff --git a/SmartDeviceLink/SDLPutFileResponse.m b/SmartDeviceLink/SDLPutFileResponse.m index 2d3de3352..93d0caa5e 100644 --- a/SmartDeviceLink/SDLPutFileResponse.m +++ b/SmartDeviceLink/SDLPutFileResponse.m @@ -17,11 +17,11 @@ NS_ASSUME_NONNULL_BEGIN return self; } -- (void)setSpaceAvailable:(NSNumber<SDLInt> *)spaceAvailable { +- (void)setSpaceAvailable:(nullable NSNumber<SDLInt> *)spaceAvailable { [parameters sdl_setObject:spaceAvailable forName:SDLNameSpaceAvailable]; } -- (NSNumber<SDLInt> *)spaceAvailable { +- (nullable NSNumber<SDLInt> *)spaceAvailable { return [parameters sdl_objectForName:SDLNameSpaceAvailable]; } diff --git a/SmartDeviceLink/SDLUploadFileOperation.m b/SmartDeviceLink/SDLUploadFileOperation.m index 3eea620ba..620d0f833 100644 --- a/SmartDeviceLink/SDLUploadFileOperation.m +++ b/SmartDeviceLink/SDLUploadFileOperation.m @@ -66,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)sdl_sendFile:(SDLFile *)file mtuSize:(NSUInteger)mtuSize withCompletion:(SDLFileManagerUploadCompletionHandler)completion { __block NSError *streamError = nil; - __block NSUInteger bytesAvailable = 0; + __block NSUInteger bytesAvailable = 2000000000; __block NSInteger highestCorrelationIDReceived = -1; if (self.isCancelled) { @@ -128,6 +128,7 @@ NS_ASSUME_NONNULL_BEGIN __weak typeof(self) weakself = self; [self.connectionManager sendConnectionManagerRequest:putFile withResponseHandler:^(__kindof SDLRPCRequest *_Nullable request, __kindof SDLRPCResponse *_Nullable response, NSError *_Nullable error) { typeof(weakself) strongself = weakself; + SDLPutFileResponse *putFileResponse = (SDLPutFileResponse *)response; // Check if the upload process has been cancelled by another packet. If so, stop the upload process. // TODO: Is this the right way to handle this case? Should we just abort everything in the future? Should we be deleting what we sent? Should we have an automatic retry strategy based on what the error was? @@ -147,7 +148,9 @@ NS_ASSUME_NONNULL_BEGIN // If no errors, watch for a response containing the amount of storage left on the SDL Core if ([self.class sdl_newHighestCorrelationID:request highestCorrelationIDReceived:highestCorrelationIDReceived]) { highestCorrelationIDReceived = [request.correlationID integerValue]; - bytesAvailable = [(SDLPutFileResponse *)response spaceAvailable].unsignedIntegerValue; + + // If spaceAvailable is nil, set it to the max value + bytesAvailable = putFileResponse.spaceAvailable != nil ? putFileResponse.spaceAvailable.unsignedIntegerValue : 2000000000; } dispatch_group_leave(putFileGroup); |