Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Refactored to use centralized downloader. #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
15 changes: 0 additions & 15 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,11 @@
target-dir="Model/" />

<!-- sources for Network folder -->
<source-file src="src/ios/Network/HCPApplicationConfig+Downloader.m"
target-dir="Network/" />
<header-file src="src/ios/Network/HCPApplicationConfig+Downloader.h"
target-dir="Network/" />

<source-file src="src/ios/Network/HCPContentManifest+Downloader.m"
target-dir="Network/" />
<header-file src="src/ios/Network/HCPContentManifest+Downloader.h"
target-dir="Network/" />

<source-file src="src/ios/Network/HCPFileDownloader.m"
target-dir="Network/" />
<header-file src="src/ios/Network/HCPFileDownloader.h"
target-dir="Network/" />

<source-file src="src/ios/Network/HCPJsonDownloader.m"
target-dir="Network/" />
<header-file src="src/ios/Network/HCPJsonDownloader.h"
target-dir="Network/" />

<!-- sources for Storage folder -->
<source-file src="src/ios/Storage/HCPApplicationConfigStorage.m"
target-dir="Storage/" />
Expand Down
2 changes: 0 additions & 2 deletions src/ios/HCPPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#import <Cordova/CDVConfigParser.h>

#import "HCPPlugin.h"
#import "HCPApplicationConfig+Downloader.h"
#import "HCPContentManifest+Downloader.h"
#import "HCPFileDownloader.h"
#import "HCPFilesStructure.h"
#import "HCPFilesStructureImpl.h"
Expand Down
42 changes: 0 additions & 42 deletions src/ios/Network/HCPApplicationConfig+Downloader.h

This file was deleted.

35 changes: 0 additions & 35 deletions src/ios/Network/HCPApplicationConfig+Downloader.m

This file was deleted.

42 changes: 0 additions & 42 deletions src/ios/Network/HCPContentManifest+Downloader.h

This file was deleted.

35 changes: 0 additions & 35 deletions src/ios/Network/HCPContentManifest+Downloader.m

This file was deleted.

39 changes: 7 additions & 32 deletions src/ios/Network/HCPFileDownloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,32 @@
*
* @param holds information about occured error; <code>nil</code> if everything is fine
*/
typedef void (^HCPFileDownloadComplitionBlock)(NSError *error);
typedef void (^HCPFileDownloadCompletionBlock)(NSError *);
typedef void (^HCPDataDownloadCompletionBlock)(NSData*, NSError *);

/**
* Helper class to download files from the server.
*/
@interface HCPFileDownloader : NSObject

/**
* Download file asynchronously.
* Download data asynchronously.
*
* @param url url to the downloaded file
* @param filePath url in local file system where to put loaded file
* @param checksum hash of the file to check if it's not corrupted
* @param block download complition block
* @param block data download completion block, called with the data when it is available.
*/
- (void)downloadFileFromUrl:(NSURL *)url saveToFile:(NSURL *)filePath checksum:(NSString *)checksum complitionBlock:(HCPFileDownloadComplitionBlock)block;
- (void) downloadDataFromUrl:(NSURL*) url completionBlock:(HCPDataDownloadCompletionBlock) block;

/**
* Download list of files asynchronously.
*
* @param filesList list of files to download. Files are instances of HCPManifestFile class.
* @param contentURL url on the server where all files are located. Full URL to the file is constructed from this one and the files mame.
* @param folderURL url to the directory in local file system where to put all loaded files
* @param block download complition block
* @param block download completion block
*
* @see HCPManifestFile
*/
- (void)downloadFiles:(NSArray *)filesList fromURL:(NSURL *)contentURL toFolder:(NSURL *)folderURL complitionBlock:(HCPFileDownloadComplitionBlock)block;

/**
* Download list of files synchronously.
*
* @param filesList list of files to download. Files are instances of HCPManifestFile class.
* @param contentURL url on the server where all files are located. Full URL to the file is constructed from this one and the files mame.
* @param folderURL url to the directory in local file system where to put all loaded files
* @param error holds information about occured error; <code>nil</code> if everything is fine
* @return <code>YES</code> when all files are loaded; <code>NO</code> on download error
* @see HCPManifestFile
*/
- (BOOL)downloadFilesSync:(NSArray *)filesList fromURL:(NSURL *)contentURL toFolder:(NSURL *)folderURL error:(NSError **)error;

/**
* Download file synchronously.
*
* @param url url to the downloaded file
* @param filePath url in local file system where to put loaded file
* @param checksum hash of the file to check if it's not corrupted
* @param error holds information about occured error; <code>nil</code> if everything is fine
*
* @return <code>YES</code> when file is loaded; <code>NO</code> on download error
*/
- (BOOL)downloadFileSyncFromUrl:(NSURL *)url saveToFile:(NSURL *)filePath checksum:(NSString *)checksum error:(NSError **)error;
- (void) downloadFiles:(NSArray *)filesList fromURL:(NSURL *)contentURL toFolder:(NSURL *)folderURL completionBlock:(HCPFileDownloadCompletionBlock)block;

@end
Loading