├── .gitignore ├── GSDownloaderSDK ├── GSDownloaderSDK.xcodeproj │ └── project.pbxproj ├── GSDownloaderSDK │ ├── Frameworks │ │ ├── GSCoreThirdParty.framework │ │ │ ├── GSCoreThirdParty │ │ │ ├── Headers │ │ │ ├── Resources │ │ │ └── Versions │ │ │ │ ├── A │ │ │ │ ├── GSCoreThirdParty │ │ │ │ ├── Headers │ │ │ │ │ ├── AFHTTPClient.h │ │ │ │ │ ├── AFHTTPRequestOperation.h │ │ │ │ │ ├── AFImageRequestOperation.h │ │ │ │ │ ├── AFJSONRequestOperation.h │ │ │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ │ │ ├── AFNetworking.h │ │ │ │ │ ├── AFPropertyListRequestOperation.h │ │ │ │ │ ├── AFURLConnectionOperation.h │ │ │ │ │ ├── AFXMLRequestOperation.h │ │ │ │ │ ├── GSCoreThirdParty.h │ │ │ │ │ ├── JSONKit.h │ │ │ │ │ ├── MKAnnotationView+WebCache.h │ │ │ │ │ ├── NSData+ImageContentType.h │ │ │ │ │ ├── SDImageCache.h │ │ │ │ │ ├── SDWebImageCompat.h │ │ │ │ │ ├── SDWebImageDecoder.h │ │ │ │ │ ├── SDWebImageDownloader.h │ │ │ │ │ ├── SDWebImageDownloaderOperation.h │ │ │ │ │ ├── SDWebImageManager.h │ │ │ │ │ ├── SDWebImageOperation.h │ │ │ │ │ ├── SDWebImagePrefetcher.h │ │ │ │ │ ├── UIButton+WebCache.h │ │ │ │ │ ├── UIImage+GIF.h │ │ │ │ │ ├── UIImage+MultiFormat.h │ │ │ │ │ ├── UIImage+WebP.h │ │ │ │ │ ├── UIImageView+AFNetworking.h │ │ │ │ │ └── UIImageView+WebCache.h │ │ │ │ └── Resources │ │ │ │ │ ├── Info.plist │ │ │ │ │ └── en.lproj │ │ │ │ │ └── InfoPlist.strings │ │ │ │ └── Current │ │ └── GSUtilitiesSDK.framework │ │ │ ├── GSUtilitiesSDK │ │ │ ├── Headers │ │ │ ├── Resources │ │ │ └── Versions │ │ │ ├── A │ │ │ ├── GSUtilitiesSDK │ │ │ ├── Headers │ │ │ │ ├── GSCommonUtil.h │ │ │ │ ├── GSDateUtil.h │ │ │ │ ├── GSDeviceUtil.h │ │ │ │ ├── GSEncryptUtl.h │ │ │ │ ├── GSJSONParseUtil.h │ │ │ │ ├── GSReachabilityUtil.h │ │ │ │ ├── GSScreenUtil.h │ │ │ │ ├── GSStringUtil.h │ │ │ │ └── GSUtilitiesSDK.h │ │ │ └── Resources │ │ │ │ ├── Info.plist │ │ │ │ └── en.lproj │ │ │ │ └── InfoPlist.strings │ │ │ └── Current │ ├── GSDownloadEvenHandler.h │ ├── GSDownloadFileModel.h │ ├── GSDownloadFileModel.m │ ├── GSDownloadTask.h │ ├── GSDownloadTask.m │ ├── GSDownloaderClient.h │ ├── GSDownloaderClient.m │ ├── GSDownloaderSDK-Info.plist │ ├── GSDownloaderSDK-Prefix.pch │ ├── GSDownloaderSDK.h │ ├── GSDownloaderSDKTest.h │ ├── GSDownloaderSDKTest.m │ ├── Protocol │ │ ├── GSDownloadUIBindProtocol.h │ │ └── GSSingleDownloadTaskProtocol.h │ ├── Queue │ │ ├── GSDownloadTaskQueue.h │ │ └── GSDownloadTaskQueue.m │ ├── ThirdParty │ │ ├── NSObject+KVOBlock.h │ │ └── NSObject+KVOBlock.m │ ├── UtilitiesSDK │ │ ├── GSFileUtil.h │ │ └── GSFileUtil.m │ └── en.lproj │ │ └── InfoPlist.strings ├── Products │ └── GSDownloaderSDK.framework │ │ ├── GSDownloaderSDK │ │ ├── Headers │ │ ├── Resources │ │ └── Versions │ │ ├── A │ │ ├── GSDownloaderSDK │ │ ├── Headers │ │ │ ├── GSDownloadEvenHandler.h │ │ │ ├── GSDownloadFileModel.h │ │ │ ├── GSDownloadTask.h │ │ │ ├── GSDownloadUIBindProtocol.h │ │ │ ├── GSDownloaderClient.h │ │ │ ├── GSDownloaderSDK.h │ │ │ ├── GSDownloaderSDKTest.h │ │ │ ├── GSFileUtil.h │ │ │ └── NSObject+KVOBlock.h │ │ └── Resources │ │ │ ├── Info.plist │ │ │ └── en.lproj │ │ │ └── InfoPlist.strings │ │ └── Current └── pre_build.sh ├── GSDownloaderSDKDemo ├── GSDownloaderSDKDemo.xcodeproj │ └── project.pbxproj └── GSDownloaderSDKDemo │ ├── GSDownloaderSDKDemo-Info.plist │ ├── GSDownloaderSDKDemo-Prefix.pch │ ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json │ ├── MTDAppDelegate.h │ ├── MTDAppDelegate.m │ ├── MTDDownloadFileModel.h │ ├── MTDDownloadFileModel.m │ ├── MTDDownloadTableViewCell.h │ ├── MTDDownloadTableViewCell.m │ ├── MTDDownloadTableViewCellDelegate.h │ ├── MTDDownloadTesterViewController.h │ ├── MTDDownloadTesterViewController.m │ ├── en.lproj │ └── InfoPlist.strings │ └── main.m ├── GSDownloaderSDKWorkspace.xcworkspace └── contents.xcworkspacedata ├── README.md └── Screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | GSDownloaderSDK/GSDownloaderSDK.xcodeproj/xcuserdata/asm.xcuserdatad/xcschemes/GSDownloaderSDK.xcscheme 3 | 4 | GSDownloaderSDK/GSDownloaderSDK.xcodeproj/xcuserdata/asm.xcuserdatad/xcschemes/xcschememanagement.plist 5 | 6 | GSDownloaderSDKDemo/GSDownloaderSDKDemo.xcodeproj/xcuserdata/asm.xcuserdatad/xcschemes/GSDownloaderSDKDemo.xcscheme 7 | 8 | GSDownloaderSDKDemo/GSDownloaderSDKDemo.xcodeproj/xcuserdata/asm.xcuserdatad/xcschemes/xcschememanagement.plist 9 | 10 | GSDownloaderSDKWorkspace.xcworkspace/xcuserdata/asm.xcuserdatad/UserInterfaceState.xcuserstate 11 | 12 | GSDownloaderSDKWorkspace.xcworkspace/xcuserdata/asm.xcuserdatad/WorkspaceSettings.xcsettings 13 | 14 | GSDownloaderSDKWorkspace.xcworkspace/xcuserdata/asm.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist 15 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/GSCoreThirdParty: -------------------------------------------------------------------------------- 1 | Versions/Current/GSCoreThirdParty -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Headers: -------------------------------------------------------------------------------- 1 | Versions/Current/Headers -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Resources: -------------------------------------------------------------------------------- 1 | Versions/Current/Resources -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/GSCoreThirdParty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/GSCoreThirdParty -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFURLConnectionOperation.h" 25 | 26 | /** 27 | `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. 28 | */ 29 | @interface AFHTTPRequestOperation : AFURLConnectionOperation 30 | 31 | ///---------------------------------------------- 32 | /// @name Getting HTTP URL Connection Information 33 | ///---------------------------------------------- 34 | 35 | /** 36 | The last HTTP response received by the operation's connection. 37 | */ 38 | @property (readonly, nonatomic, strong) NSHTTPURLResponse *response; 39 | 40 | ///---------------------------------------------------------- 41 | /// @name Managing And Checking For Acceptable HTTP Responses 42 | ///---------------------------------------------------------- 43 | 44 | /** 45 | A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`. 46 | */ 47 | @property (nonatomic, readonly) BOOL hasAcceptableStatusCode; 48 | 49 | /** 50 | A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`. 51 | */ 52 | @property (nonatomic, readonly) BOOL hasAcceptableContentType; 53 | 54 | /** 55 | The callback dispatch queue on success. If `NULL` (default), the main queue is used. 56 | */ 57 | @property (nonatomic, assign) dispatch_queue_t successCallbackQueue; 58 | 59 | /** 60 | The callback dispatch queue on failure. If `NULL` (default), the main queue is used. 61 | */ 62 | @property (nonatomic, assign) dispatch_queue_t failureCallbackQueue; 63 | 64 | ///------------------------------------------------------------ 65 | /// @name Managing Acceptable HTTP Status Codes & Content Types 66 | ///------------------------------------------------------------ 67 | 68 | /** 69 | Returns an `NSIndexSet` object containing the ranges of acceptable HTTP status codes. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 70 | 71 | By default, this is the range 200 to 299, inclusive. 72 | */ 73 | + (NSIndexSet *)acceptableStatusCodes; 74 | 75 | /** 76 | Adds status codes to the set of acceptable HTTP status codes returned by `+acceptableStatusCodes` in subsequent calls by this class and its descendants. 77 | 78 | @param statusCodes The status codes to be added to the set of acceptable HTTP status codes 79 | */ 80 | + (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes; 81 | 82 | /** 83 | Returns an `NSSet` object containing the acceptable MIME types. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 84 | 85 | By default, this is `nil`. 86 | */ 87 | + (NSSet *)acceptableContentTypes; 88 | 89 | /** 90 | Adds content types to the set of acceptable MIME types returned by `+acceptableContentTypes` in subsequent calls by this class and its descendants. 91 | 92 | @param contentTypes The content types to be added to the set of acceptable MIME types 93 | */ 94 | + (void)addAcceptableContentTypes:(NSSet *)contentTypes; 95 | 96 | 97 | ///----------------------------------------------------- 98 | /// @name Determining Whether A Request Can Be Processed 99 | ///----------------------------------------------------- 100 | 101 | /** 102 | A Boolean value determining whether or not the class can process the specified request. For example, `AFJSONRequestOperation` may check to make sure the content type was `application/json` or the URL path extension was `.json`. 103 | 104 | @param urlRequest The request that is determined to be supported or not supported for this class. 105 | */ 106 | + (BOOL)canProcessRequest:(NSURLRequest *)urlRequest; 107 | 108 | ///----------------------------------------------------------- 109 | /// @name Setting Completion Block Success / Failure Callbacks 110 | ///----------------------------------------------------------- 111 | 112 | /** 113 | Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. 114 | 115 | This method should be overridden in subclasses in order to specify the response object passed into the success block. 116 | 117 | @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. 118 | @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. 119 | */ 120 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 121 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; 122 | 123 | @end 124 | 125 | ///---------------- 126 | /// @name Functions 127 | ///---------------- 128 | 129 | /** 130 | Returns a set of MIME types detected in an HTTP `Accept` or `Content-Type` header. 131 | */ 132 | extern NSSet * AFContentTypesFromHTTPHeader(NSString *string); 133 | 134 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/AFImageRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFImageRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFHTTPRequestOperation.h" 25 | 26 | #import 27 | 28 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 29 | #import 30 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 31 | #import 32 | #endif 33 | 34 | /** 35 | `AFImageRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and processing images. 36 | 37 | ## Acceptable Content Types 38 | 39 | By default, `AFImageRequestOperation` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: 40 | 41 | - `image/tiff` 42 | - `image/jpeg` 43 | - `image/gif` 44 | - `image/png` 45 | - `image/ico` 46 | - `image/x-icon` 47 | - `image/bmp` 48 | - `image/x-bmp` 49 | - `image/x-xbitmap` 50 | - `image/x-win-bitmap` 51 | */ 52 | @interface AFImageRequestOperation : AFHTTPRequestOperation 53 | 54 | /** 55 | An image constructed from the response data. If an error occurs during the request, `nil` will be returned, and the `error` property will be set to the error. 56 | */ 57 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 58 | @property (readonly, nonatomic, strong) UIImage *responseImage; 59 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 60 | @property (readonly, nonatomic, strong) NSImage *responseImage; 61 | #endif 62 | 63 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 64 | /** 65 | The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. 66 | */ 67 | @property (nonatomic, assign) CGFloat imageScale; 68 | 69 | /** 70 | Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. 71 | */ 72 | @property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; 73 | #endif 74 | 75 | /** 76 | Creates and returns an `AFImageRequestOperation` object and sets the specified success callback. 77 | 78 | @param urlRequest The request object to be loaded asynchronously during execution of the operation. 79 | @param success A block object to be executed when the request finishes successfully. This block has no return value and takes a single argument, the image created from the response data of the request. 80 | 81 | @return A new image request operation 82 | */ 83 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 84 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 85 | success:(void (^)(UIImage *image))success; 86 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 87 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 88 | success:(void (^)(NSImage *image))success; 89 | #endif 90 | 91 | /** 92 | Creates and returns an `AFImageRequestOperation` object and sets the specified success callback. 93 | 94 | @param urlRequest The request object to be loaded asynchronously during execution of the operation. 95 | @param imageProcessingBlock A block object to be executed after the image request finishes successfully, but before the image is returned in the `success` block. This block takes a single argument, the image loaded from the response body, and returns the processed image. 96 | @param success A block object to be executed when the request finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the image created from the response data. 97 | @param failure A block object to be executed when the request finishes unsuccessfully. This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the error associated with the cause for the unsuccessful operation. 98 | 99 | @return A new image request operation 100 | */ 101 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 102 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 103 | imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock 104 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 105 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; 106 | #elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) 107 | + (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest 108 | imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock 109 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success 110 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; 111 | #endif 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/AFJSONRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFJSONRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFHTTPRequestOperation.h" 25 | 26 | /** 27 | `AFJSONRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with JSON response data. 28 | 29 | ## Acceptable Content Types 30 | 31 | By default, `AFJSONRequestOperation` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: 32 | 33 | - `application/json` 34 | - `text/json` 35 | 36 | @warning JSON parsing will use the built-in `NSJSONSerialization` class. 37 | */ 38 | @interface AFJSONRequestOperation : AFHTTPRequestOperation 39 | 40 | ///---------------------------- 41 | /// @name Getting Response Data 42 | ///---------------------------- 43 | 44 | /** 45 | A JSON object constructed from the response data. If an error occurs while parsing, `nil` will be returned, and the `error` property will be set to the error. 46 | */ 47 | @property (readonly, nonatomic, strong) id responseJSON; 48 | 49 | /** 50 | Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". 51 | */ 52 | @property (nonatomic, assign) NSJSONReadingOptions JSONReadingOptions; 53 | 54 | ///---------------------------------- 55 | /// @name Creating Request Operations 56 | ///---------------------------------- 57 | 58 | /** 59 | Creates and returns an `AFJSONRequestOperation` object and sets the specified success and failure callbacks. 60 | 61 | @param urlRequest The request object to be loaded asynchronously during execution of the operation 62 | @param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the JSON object created from the response data of request. 63 | @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as JSON. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred. 64 | 65 | @return A new JSON request operation 66 | */ 67 | + (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest 68 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success 69 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | #import 29 | 30 | /** 31 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. 32 | 33 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: 34 | 35 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 36 | 37 | By setting `isNetworkActivityIndicatorVisible` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. 38 | 39 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 40 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 41 | */ 42 | @interface AFNetworkActivityIndicatorManager : NSObject 43 | 44 | /** 45 | A Boolean value indicating whether the manager is enabled. 46 | 47 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 48 | */ 49 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 50 | 51 | /** 52 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. 53 | */ 54 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; 55 | 56 | /** 57 | Returns the shared network activity indicator manager object for the system. 58 | 59 | @return The systemwide network activity indicator manager. 60 | */ 61 | + (instancetype)sharedManager; 62 | 63 | /** 64 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 65 | */ 66 | - (void)incrementActivityCount; 67 | 68 | /** 69 | Decrements the number of active network requests. If this number becomes zero before decrementing, this will stop animating the status bar network activity indicator. 70 | */ 71 | - (void)decrementActivityCount; 72 | 73 | @end 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | 26 | #ifndef _AFNETWORKING_ 27 | #define _AFNETWORKING_ 28 | 29 | #import "AFURLConnectionOperation.h" 30 | 31 | #import "AFHTTPRequestOperation.h" 32 | #import "AFJSONRequestOperation.h" 33 | #import "AFXMLRequestOperation.h" 34 | #import "AFPropertyListRequestOperation.h" 35 | #import "AFHTTPClient.h" 36 | 37 | #import "AFImageRequestOperation.h" 38 | 39 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 40 | #import "AFNetworkActivityIndicatorManager.h" 41 | #import "UIImageView+AFNetworking.h" 42 | #endif 43 | #endif /* _AFNETWORKING_ */ 44 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/AFPropertyListRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFPropertyListRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFHTTPRequestOperation.h" 25 | 26 | /** 27 | `AFPropertyListRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and deserializing objects with property list (plist) response data. 28 | 29 | ## Acceptable Content Types 30 | 31 | By default, `AFPropertyListRequestOperation` accepts the following MIME types: 32 | 33 | - `application/x-plist` 34 | */ 35 | @interface AFPropertyListRequestOperation : AFHTTPRequestOperation 36 | 37 | ///---------------------------- 38 | /// @name Getting Response Data 39 | ///---------------------------- 40 | 41 | /** 42 | An object deserialized from a plist constructed using the response data. 43 | */ 44 | @property (readonly, nonatomic) id responsePropertyList; 45 | 46 | ///-------------------------------------- 47 | /// @name Managing Property List Behavior 48 | ///-------------------------------------- 49 | 50 | /** 51 | One of the `NSPropertyListMutabilityOptions` options, specifying the mutability of objects deserialized from the property list. By default, this is `NSPropertyListImmutable`. 52 | */ 53 | @property (nonatomic, assign) NSPropertyListReadOptions propertyListReadOptions; 54 | 55 | /** 56 | Creates and returns an `AFPropertyListRequestOperation` object and sets the specified success and failure callbacks. 57 | 58 | @param urlRequest The request object to be loaded asynchronously during execution of the operation 59 | @param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the object deserialized from a plist constructed using the response data. 60 | @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while deserializing the object from a property list. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred. 61 | 62 | @return A new property list request operation 63 | */ 64 | + (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)urlRequest 65 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success 66 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure; 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/AFXMLRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFXMLRequestOperation.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFHTTPRequestOperation.h" 25 | 26 | #import 27 | 28 | /** 29 | `AFXMLRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with XML response data. 30 | 31 | ## Acceptable Content Types 32 | 33 | By default, `AFXMLRequestOperation` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: 34 | 35 | - `application/xml` 36 | - `text/xml` 37 | 38 | ## Use With AFHTTPClient 39 | 40 | When `AFXMLRequestOperation` is registered with `AFHTTPClient`, the response object in the success callback of `HTTPRequestOperationWithRequest:success:failure:` will be an instance of `NSXMLParser`. On platforms that support `NSXMLDocument`, you have the option to ignore the response object, and simply use the `responseXMLDocument` property of the operation argument of the callback. 41 | */ 42 | @interface AFXMLRequestOperation : AFHTTPRequestOperation 43 | 44 | ///---------------------------- 45 | /// @name Getting Response Data 46 | ///---------------------------- 47 | 48 | /** 49 | An `NSXMLParser` object constructed from the response data. 50 | */ 51 | @property (readonly, nonatomic, strong) NSXMLParser *responseXMLParser; 52 | 53 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 54 | /** 55 | An `NSXMLDocument` object constructed from the response data. If an error occurs while parsing, `nil` will be returned, and the `error` property will be set to the error. 56 | */ 57 | @property (readonly, nonatomic, strong) NSXMLDocument *responseXMLDocument; 58 | #endif 59 | 60 | /** 61 | Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks. 62 | 63 | @param urlRequest The request object to be loaded asynchronously during execution of the operation 64 | @param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the XML parser constructed with the response data of request. 65 | @param failure A block object to be executed when the operation finishes unsuccessfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network error that occurred. 66 | 67 | @return A new XML request operation 68 | */ 69 | + (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest 70 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success 71 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure; 72 | 73 | 74 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 75 | /** 76 | Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks. 77 | 78 | @param urlRequest The request object to be loaded asynchronously during execution of the operation 79 | @param success A block object to be executed when the operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the XML document created from the response data of request. 80 | @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as XML. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error describing the network or parsing error that occurred. 81 | 82 | @return A new XML request operation 83 | */ 84 | + (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest 85 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success 86 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure; 87 | #endif 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/GSCoreThirdParty.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSCoreThirdParty.h 3 | // GSCoreThirdParty 4 | // 5 | // Created by Chaoqian Wu on 14-3-4. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #ifndef GSCoreThirdParty_GSCoreThirdParty_h 10 | #define GSCoreThirdParty_GSCoreThirdParty_h 11 | 12 | //AFNetworking 13 | #import 14 | 15 | //JSONKit 16 | #import 17 | 18 | //SDWebImage 19 | #import 20 | #import 21 | #import 22 | #import 23 | #import 24 | #import 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | #import 31 | #import 32 | #import 33 | #import 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/JSONKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // JSONKit.h 3 | // http://github.com/johnezang/JSONKit 4 | // Dual licensed under either the terms of the BSD License, or alternatively 5 | // under the terms of the Apache License, Version 2.0, as specified below. 6 | // 7 | 8 | /* 9 | Copyright (c) 2011, John Engelhart 10 | 11 | All rights reserved. 12 | 13 | Redistribution and use in source and binary forms, with or without 14 | modification, are permitted provided that the following conditions are met: 15 | 16 | * Redistributions of source code must retain the above copyright 17 | notice, this list of conditions and the following disclaimer. 18 | 19 | * Redistributions in binary form must reproduce the above copyright 20 | notice, this list of conditions and the following disclaimer in the 21 | documentation and/or other materials provided with the distribution. 22 | 23 | * Neither the name of the Zang Industries nor the names of its 24 | contributors may be used to endorse or promote products derived from 25 | this software without specific prior written permission. 26 | 27 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 33 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 34 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 35 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 36 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 37 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 | */ 39 | 40 | /* 41 | Copyright 2011 John Engelhart 42 | 43 | Licensed under the Apache License, Version 2.0 (the "License"); 44 | you may not use this file except in compliance with the License. 45 | You may obtain a copy of the License at 46 | 47 | http://www.apache.org/licenses/LICENSE-2.0 48 | 49 | Unless required by applicable law or agreed to in writing, software 50 | distributed under the License is distributed on an "AS IS" BASIS, 51 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 52 | See the License for the specific language governing permissions and 53 | limitations under the License. 54 | */ 55 | 56 | #include 57 | #include 58 | #include 59 | #include 60 | #include 61 | 62 | #ifdef __OBJC__ 63 | #import 64 | #import 65 | #import 66 | #import 67 | #import 68 | #import 69 | #endif // __OBJC__ 70 | 71 | #ifdef __cplusplus 72 | extern "C" { 73 | #endif 74 | 75 | 76 | // For Mac OS X < 10.5. 77 | #ifndef NSINTEGER_DEFINED 78 | #define NSINTEGER_DEFINED 79 | #if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 80 | typedef long NSInteger; 81 | typedef unsigned long NSUInteger; 82 | #define NSIntegerMin LONG_MIN 83 | #define NSIntegerMax LONG_MAX 84 | #define NSUIntegerMax ULONG_MAX 85 | #else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 86 | typedef int NSInteger; 87 | typedef unsigned int NSUInteger; 88 | #define NSIntegerMin INT_MIN 89 | #define NSIntegerMax INT_MAX 90 | #define NSUIntegerMax UINT_MAX 91 | #endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 92 | #endif // NSINTEGER_DEFINED 93 | 94 | 95 | #ifndef _JSONKIT_H_ 96 | #define _JSONKIT_H_ 97 | 98 | #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465) 99 | #define JK_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) 100 | #else 101 | #define JK_DEPRECATED_ATTRIBUTE 102 | #endif 103 | 104 | #define JSONKIT_VERSION_MAJOR 1 105 | #define JSONKIT_VERSION_MINOR 4 106 | 107 | typedef NSUInteger JKFlags; 108 | 109 | /* 110 | JKParseOptionComments : Allow C style // and /_* ... *_/ (without a _, obviously) comments in JSON. 111 | JKParseOptionUnicodeNewlines : Allow Unicode recommended (?:\r\n|[\n\v\f\r\x85\p{Zl}\p{Zp}]) newlines. 112 | JKParseOptionLooseUnicode : Normally the decoder will stop with an error at any malformed Unicode. 113 | This option allows JSON with malformed Unicode to be parsed without reporting an error. 114 | Any malformed Unicode is replaced with \uFFFD, or "REPLACEMENT CHARACTER". 115 | */ 116 | 117 | enum { 118 | JKParseOptionNone = 0, 119 | JKParseOptionStrict = 0, 120 | JKParseOptionComments = (1 << 0), 121 | JKParseOptionUnicodeNewlines = (1 << 1), 122 | JKParseOptionLooseUnicode = (1 << 2), 123 | JKParseOptionPermitTextAfterValidJSON = (1 << 3), 124 | JKParseOptionValidFlags = (JKParseOptionComments | JKParseOptionUnicodeNewlines | JKParseOptionLooseUnicode | JKParseOptionPermitTextAfterValidJSON), 125 | }; 126 | typedef JKFlags JKParseOptionFlags; 127 | 128 | enum { 129 | JKSerializeOptionNone = 0, 130 | JKSerializeOptionPretty = (1 << 0), 131 | JKSerializeOptionEscapeUnicode = (1 << 1), 132 | JKSerializeOptionEscapeForwardSlashes = (1 << 4), 133 | JKSerializeOptionValidFlags = (JKSerializeOptionPretty | JKSerializeOptionEscapeUnicode | JKSerializeOptionEscapeForwardSlashes), 134 | }; 135 | typedef JKFlags JKSerializeOptionFlags; 136 | 137 | #ifdef __OBJC__ 138 | 139 | typedef struct JKParseState JKParseState; // Opaque internal, private type. 140 | 141 | // As a general rule of thumb, if you use a method that doesn't accept a JKParseOptionFlags argument, it defaults to JKParseOptionStrict 142 | 143 | @interface JSONDecoder : NSObject { 144 | JKParseState *parseState; 145 | } 146 | + (id)decoder; 147 | + (id)decoderWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 148 | - (id)initWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 149 | - (void)clearCache; 150 | 151 | // The parse... methods were deprecated in v1.4 in favor of the v1.4 objectWith... methods. 152 | - (id)parseUTF8String:(const unsigned char *)string length:(size_t)length JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length: instead. 153 | - (id)parseUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length:error: instead. 154 | // The NSData MUST be UTF8 encoded JSON. 155 | - (id)parseJSONData:(NSData *)jsonData JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData: instead. 156 | - (id)parseJSONData:(NSData *)jsonData error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData:error: instead. 157 | 158 | // Methods that return immutable collection objects. 159 | - (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length; 160 | - (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error; 161 | // The NSData MUST be UTF8 encoded JSON. 162 | - (id)objectWithData:(NSData *)jsonData; 163 | - (id)objectWithData:(NSData *)jsonData error:(NSError **)error; 164 | 165 | // Methods that return mutable collection objects. 166 | - (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length; 167 | - (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error; 168 | // The NSData MUST be UTF8 encoded JSON. 169 | - (id)mutableObjectWithData:(NSData *)jsonData; 170 | - (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error; 171 | 172 | @end 173 | 174 | //////////// 175 | #pragma mark Deserializing methods 176 | //////////// 177 | 178 | @interface NSString (JSONKitDeserializing) 179 | - (id)objectFromJSONString; 180 | - (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 181 | - (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error; 182 | - (id)mutableObjectFromJSONString; 183 | - (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 184 | - (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error; 185 | @end 186 | 187 | @interface NSData (JSONKitDeserializing) 188 | // The NSData MUST be UTF8 encoded JSON. 189 | - (id)objectFromJSONData; 190 | - (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 191 | - (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error; 192 | - (id)mutableObjectFromJSONData; 193 | - (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags; 194 | - (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error; 195 | @end 196 | 197 | //////////// 198 | #pragma mark Serializing methods 199 | //////////// 200 | 201 | @interface NSString (JSONKitSerializing) 202 | // Convenience methods for those that need to serialize the receiving NSString (i.e., instead of having to serialize a NSArray with a single NSString, you can "serialize to JSON" just the NSString). 203 | // Normally, a string that is serialized to JSON has quotation marks surrounding it, which you may or may not want when serializing a single string, and can be controlled with includeQuotes: 204 | // includeQuotes:YES `a "test"...` -> `"a \"test\"..."` 205 | // includeQuotes:NO `a "test"...` -> `a \"test\"...` 206 | - (NSData *)JSONData; // Invokes JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES 207 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error; 208 | - (NSString *)JSONString; // Invokes JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES 209 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error; 210 | @end 211 | 212 | @interface NSArray (JSONKitSerializing) 213 | - (NSData *)JSONData; 214 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error; 215 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error; 216 | - (NSString *)JSONString; 217 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error; 218 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error; 219 | @end 220 | 221 | @interface NSDictionary (JSONKitSerializing) 222 | - (NSData *)JSONData; 223 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error; 224 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error; 225 | - (NSString *)JSONString; 226 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error; 227 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error; 228 | @end 229 | 230 | #ifdef __BLOCKS__ 231 | 232 | @interface NSArray (JSONKitSerializingBlockAdditions) 233 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error; 234 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error; 235 | @end 236 | 237 | @interface NSDictionary (JSONKitSerializingBlockAdditions) 238 | - (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error; 239 | - (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error; 240 | @end 241 | 242 | #endif 243 | 244 | 245 | #endif // __OBJC__ 246 | 247 | #endif // _JSONKIT_H_ 248 | 249 | #ifdef __cplusplus 250 | } // extern "C" 251 | #endif 252 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/MKAnnotationView+WebCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // MKAnnotationView+WebCache.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 14/03/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "MapKit/MapKit.h" 10 | #import "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with MKAnnotationView. 14 | */ 15 | @interface MKAnnotationView (WebCache) 16 | 17 | /** 18 | * Set the imageView `image` with an `url`. 19 | * 20 | * The downloand is asynchronous and cached. 21 | * 22 | * @param url The url for the image. 23 | */ 24 | - (void)setImageWithURL:(NSURL *)url; 25 | 26 | /** 27 | * Set the imageView `image` with an `url` and a placeholder. 28 | * 29 | * The downloand is asynchronous and cached. 30 | * 31 | * @param url The url for the image. 32 | * @param placeholder The image to be set initially, until the image request finishes. 33 | * @see setImageWithURL:placeholderImage:options: 34 | */ 35 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; 36 | 37 | /** 38 | * Set the imageView `image` with an `url`, placeholder and custom options. 39 | * 40 | * The downloand is asynchronous and cached. 41 | * 42 | * @param url The url for the image. 43 | * @param placeholder The image to be set initially, until the image request finishes. 44 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 45 | */ 46 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 47 | 48 | /** 49 | * Set the imageView `image` with an `url`. 50 | * 51 | * The downloand is asynchronous and cached. 52 | * 53 | * @param url The url for the image. 54 | * @param completedBlock A block called when operation has been completed. This block as no return value 55 | * and takes the requested UIImage as first parameter. In case of error the image parameter 56 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 57 | * indicating if the image was retrived from the local cache of from the network. 58 | */ 59 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock; 60 | 61 | /** 62 | * Set the imageView `image` with an `url`, placeholder. 63 | * 64 | * The downloand is asynchronous and cached. 65 | * 66 | * @param url The url for the image. 67 | * @param placeholder The image to be set initially, until the image request finishes. 68 | * @param completedBlock A block called when operation has been completed. This block as no return value 69 | * and takes the requested UIImage as first parameter. In case of error the image parameter 70 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 71 | * indicating if the image was retrived from the local cache of from the network. 72 | */ 73 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock; 74 | 75 | /** 76 | * Set the imageView `image` with an `url`, placeholder and custom options. 77 | * 78 | * The downloand is asynchronous and cached. 79 | * 80 | * @param url The url for the image. 81 | * @param placeholder The image to be set initially, until the image request finishes. 82 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 83 | * @param completedBlock A block called when operation has been completed. This block as no return value 84 | * and takes the requested UIImage as first parameter. In case of error the image parameter 85 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 86 | * indicating if the image was retrived from the local cache of from the network. 87 | */ 88 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock; 89 | 90 | /** 91 | * Cancel the current download 92 | */ 93 | - (void)cancelCurrentImageLoad; 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import 7 | 8 | @interface NSData (ImageContentType) 9 | + (NSString *)contentTypeForImageData:(NSData *)data; 10 | @end 11 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/SDImageCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | 12 | typedef NS_ENUM(NSInteger, SDImageCacheType) { 13 | /** 14 | * The image wasn't available the SDWebImage caches, but was downloaded from the web. 15 | */ 16 | SDImageCacheTypeNone, 17 | /** 18 | * The image was obtained from the disk cache. 19 | */ 20 | SDImageCacheTypeDisk, 21 | /** 22 | * The image was obtained from the memory cache. 23 | */ 24 | SDImageCacheTypeMemory 25 | }; 26 | 27 | /** 28 | * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed 29 | * asynchronous so it doesn’t add unnecessary latency to the UI. 30 | */ 31 | @interface SDImageCache : NSObject 32 | 33 | /** 34 | * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. 35 | */ 36 | @property (assign, nonatomic) NSUInteger maxMemoryCost; 37 | 38 | /** 39 | * The maximum length of time to keep an image in the cache, in seconds 40 | */ 41 | @property (assign, nonatomic) NSInteger maxCacheAge; 42 | 43 | /** 44 | * The maximum size of the cache, in bytes. 45 | */ 46 | @property (assign, nonatomic) NSUInteger maxCacheSize; 47 | 48 | /** 49 | * Returns global shared cache instance 50 | * 51 | * @return SDImageCache global instance 52 | */ 53 | + (SDImageCache *)sharedImageCache; 54 | 55 | /** 56 | * Init a new cache store with a specific namespace 57 | * 58 | * @param ns The namespace to use for this cache store 59 | */ 60 | - (id)initWithNamespace:(NSString *)ns; 61 | 62 | /** 63 | * Add a read-only cache path to search for images pre-cached by SDImageCache 64 | * Useful if you want to bundle pre-loaded images with your app 65 | * 66 | * @param path The path to use for this read-only cache path 67 | */ 68 | - (void)addReadOnlyCachePath:(NSString *)path; 69 | 70 | /** 71 | * Store an image into memory and disk cache at the given key. 72 | * 73 | * @param image The image to store 74 | * @param key The unique image cache key, usually it's image absolute URL 75 | */ 76 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key; 77 | 78 | /** 79 | * Store an image into memory and optionally disk cache at the given key. 80 | * 81 | * @param image The image to store 82 | * @param key The unique image cache key, usually it's image absolute URL 83 | * @param toDisk Store the image to disk cache if YES 84 | */ 85 | - (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk; 86 | 87 | /** 88 | * Store an image into memory and optionally disk cache at the given key. 89 | * 90 | * @param image The image to store 91 | * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage 92 | * @param imageData The image data as returned by the server, this representation will be used for disk storage 93 | * instead of converting the given image object into a storable/compressed image format in order 94 | * to save quality and CPU 95 | * @param key The unique image cache key, usually it's image absolute URL 96 | * @param toDisk Store the image to disk cache if YES 97 | */ 98 | - (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk; 99 | 100 | /** 101 | * Query the disk cache asynchronously. 102 | * 103 | * @param key The unique key used to store the wanted image 104 | */ 105 | - (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(void (^)(UIImage *image, SDImageCacheType cacheType))doneBlock; 106 | 107 | /** 108 | * Query the memory cache synchronously. 109 | * 110 | * @param key The unique key used to store the wanted image 111 | */ 112 | - (UIImage *)imageFromMemoryCacheForKey:(NSString *)key; 113 | 114 | /** 115 | * Query the disk cache synchronously after checking the memory cache. 116 | * 117 | * @param key The unique key used to store the wanted image 118 | */ 119 | - (UIImage *)imageFromDiskCacheForKey:(NSString *)key; 120 | 121 | /** 122 | * Remove the image from memory and disk cache synchronously 123 | * 124 | * @param key The unique image cache key 125 | */ 126 | - (void)removeImageForKey:(NSString *)key; 127 | 128 | /** 129 | * Remove the image from memory and optionaly disk cache synchronously 130 | * 131 | * @param key The unique image cache key 132 | * @param fromDisk Also remove cache entry from disk if YES 133 | */ 134 | - (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk; 135 | 136 | /** 137 | * Clear all memory cached images 138 | */ 139 | - (void)clearMemory; 140 | 141 | /** 142 | * Clear all disk cached images 143 | */ 144 | - (void)clearDisk; 145 | - (void)clearDiskOnCompletion:(void (^)())completion; 146 | 147 | /** 148 | * Remove all expired cached image from disk 149 | */ 150 | - (void)cleanDisk; 151 | 152 | /** 153 | * Get the size used by the disk cache 154 | */ 155 | - (NSUInteger)getSize; 156 | 157 | /** 158 | * Get the number of images in the disk cache 159 | */ 160 | - (int)getDiskCount; 161 | 162 | /** 163 | * Asynchronously calculate the disk cache's size. 164 | */ 165 | - (void)calculateSizeWithCompletionBlock:(void (^)(NSUInteger fileCount, NSUInteger totalSize))completionBlock; 166 | 167 | /** 168 | * Check if image exists in cache already 169 | */ 170 | - (BOOL)diskImageExistsWithKey:(NSString *)key; 171 | 172 | @end 173 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Jamie Pinkham 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import 11 | 12 | #ifdef __OBJC_GC__ 13 | #error SDWebImage does not support Objective-C Garbage Collection 14 | #endif 15 | 16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 17 | #error SDWebImage doesn't support Deployement Target version < 5.0 18 | #endif 19 | 20 | #if !TARGET_OS_IPHONE 21 | #import 22 | #ifndef UIImage 23 | #define UIImage NSImage 24 | #endif 25 | #ifndef UIImageView 26 | #define UIImageView NSImageView 27 | #endif 28 | #else 29 | 30 | #import 31 | 32 | #endif 33 | 34 | #ifndef NS_ENUM 35 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 36 | #endif 37 | 38 | #ifndef NS_OPTIONS 39 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 40 | #endif 41 | 42 | #if OS_OBJECT_USE_OBJC 43 | #undef SDDispatchQueueRelease 44 | #undef SDDispatchQueueSetterSementics 45 | #define SDDispatchQueueRelease(q) 46 | #define SDDispatchQueueSetterSementics strong 47 | #else 48 | #undef SDDispatchQueueRelease 49 | #undef SDDispatchQueueSetterSementics 50 | #define SDDispatchQueueRelease(q) (dispatch_release(q)) 51 | #define SDDispatchQueueSetterSementics assign 52 | #endif 53 | 54 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); 55 | 56 | #define dispatch_main_sync_safe(block)\ 57 | if ([NSThread isMainThread])\ 58 | {\ 59 | block();\ 60 | }\ 61 | else\ 62 | {\ 63 | dispatch_sync(dispatch_get_main_queue(), block);\ 64 | } 65 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import 12 | #import "SDWebImageCompat.h" 13 | 14 | @interface UIImage (ForceDecode) 15 | 16 | + (UIImage *)decodedImageWithImage:(UIImage *)image; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/SDWebImageDownloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { 14 | SDWebImageDownloaderLowPriority = 1 << 0, 15 | SDWebImageDownloaderProgressiveDownload = 1 << 1, 16 | /** 17 | * By default, request prevent the of NSURLCache. With this flag, NSURLCache 18 | * is used with default policies. 19 | */ 20 | SDWebImageDownloaderUseNSURLCache = 1 << 2, 21 | /** 22 | * Call completion block with nil image/imageData if the image was read from NSURLCache 23 | * (to be combined with `SDWebImageDownloaderUseNSURLCache`). 24 | */ 25 | SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, 26 | /** 27 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for 28 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled. 29 | */ 30 | SDWebImageDownloaderContinueInBackground = 1 << 4, 31 | /** 32 | * Handles cookies stored in NSHTTPCookieStore by setting 33 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES; 34 | */ 35 | SDWebImageDownloaderHandleCookies = 1 << 5, 36 | /** 37 | * Enable to allow untrusted SSL ceriticates. 38 | * Useful for testing purposes. Use with caution in production. 39 | */ 40 | SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6 41 | 42 | }; 43 | 44 | typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { 45 | SDWebImageDownloaderFIFOExecutionOrder, 46 | /** 47 | * Default value. All download operations will execute in queue style (first-in-first-out). 48 | */ 49 | SDWebImageDownloaderLIFOExecutionOrder 50 | /** 51 | * All download operations will execute in stack style (last-in-first-out). 52 | */ 53 | }; 54 | 55 | extern NSString *const SDWebImageDownloadStartNotification; 56 | extern NSString *const SDWebImageDownloadStopNotification; 57 | 58 | typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); 59 | 60 | typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); 61 | 62 | /** 63 | * Asynchronous downloader dedicated and optimized for image loading. 64 | */ 65 | @interface SDWebImageDownloader : NSObject 66 | 67 | @property (assign, nonatomic) NSInteger maxConcurrentDownloads; 68 | 69 | /** 70 | * Shows the current amount of downloads that still need to be downloaded 71 | */ 72 | 73 | @property (readonly, nonatomic) NSUInteger currentDownloadCount; 74 | 75 | 76 | /** 77 | * The timeout value (in seconds) for the download operation. Default: 15.0. 78 | */ 79 | @property (assign, nonatomic) NSTimeInterval downloadTimeout; 80 | 81 | 82 | /** 83 | * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. 84 | */ 85 | @property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; 86 | 87 | + (SDWebImageDownloader *)sharedDownloader; 88 | 89 | /** 90 | * Set filter to pick headers for downloading image HTTP request. 91 | * 92 | * This block will be invoked for each downloading image request, returned 93 | * NSDictionary will be used as headers in corresponding HTTP request. 94 | */ 95 | @property (nonatomic, strong) NSDictionary *(^headersFilter)(NSURL *url, NSDictionary *headers); 96 | 97 | /** 98 | * Set a value for a HTTP header to be appended to each download HTTP request. 99 | * 100 | * @param value The value for the header field. Use `nil` value to remove the header. 101 | * @param field The name of the header field to set. 102 | */ 103 | - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field; 104 | 105 | /** 106 | * Returns the value of the specified HTTP header field. 107 | * 108 | * @return The value associated with the header field field, or `nil` if there is no corresponding header field. 109 | */ 110 | - (NSString *)valueForHTTPHeaderField:(NSString *)field; 111 | 112 | /** 113 | * Creates a SDWebImageDownloader async downloader instance with a given URL 114 | * 115 | * The delegate will be informed when the image is finish downloaded or an error has happen. 116 | * 117 | * @see SDWebImageDownloaderDelegate 118 | * 119 | * @param url The URL to the image to download 120 | * @param options The options to be used for this download 121 | * @param progressBlock A block called repeatedly while the image is downloading 122 | * @param completedBlock A block called once the download is completed. 123 | * If the download succeeded, the image parameter is set, in case of error, 124 | * error parameter is set with the error. The last parameter is always YES 125 | * if SDWebImageDownloaderProgressiveDownload isn't use. With the 126 | * SDWebImageDownloaderProgressiveDownload option, this block is called 127 | * repeatedly with the partial image object and the finished argument set to NO 128 | * before to be called a last time with the full image and finished argument 129 | * set to YES. In case of error, the finished argument is always YES. 130 | * 131 | * @return A cancellable SDWebImageOperation 132 | */ 133 | - (id )downloadImageWithURL:(NSURL *)url 134 | options:(SDWebImageDownloaderOptions)options 135 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 136 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock; 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageDownloader.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | @interface SDWebImageDownloaderOperation : NSOperation 14 | 15 | @property (strong, nonatomic, readonly) NSURLRequest *request; 16 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; 17 | 18 | - (id)initWithRequest:(NSURLRequest *)request 19 | options:(SDWebImageDownloaderOptions)options 20 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 21 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock 22 | cancelled:(void (^)())cancelBlock; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/SDWebImageManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDWebImageOperation.h" 11 | #import "SDWebImageDownloader.h" 12 | #import "SDImageCache.h" 13 | 14 | typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { 15 | /** 16 | * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. 17 | * This flag disable this blacklisting. 18 | */ 19 | SDWebImageRetryFailed = 1 << 0, 20 | /** 21 | * By default, image downloads are started during UI interactions, this flags disable this feature, 22 | * leading to delayed download on UIScrollView deceleration for instance. 23 | */ 24 | SDWebImageLowPriority = 1 << 1, 25 | /** 26 | * This flag disables on-disk caching 27 | */ 28 | SDWebImageCacheMemoryOnly = 1 << 2, 29 | /** 30 | * This flag enables progressive download, the image is displayed progressively during download as a browser would do. 31 | * By default, the image is only displayed once completely downloaded. 32 | */ 33 | SDWebImageProgressiveDownload = 1 << 3, 34 | /** 35 | * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. 36 | * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. 37 | * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. 38 | * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. 39 | * 40 | * Use this flag only if you can't make your URLs static with embeded cache busting parameter. 41 | */ 42 | SDWebImageRefreshCached = 1 << 4, 43 | 44 | /** 45 | * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for 46 | * extra time in background to let the request finish. If the background task expires the operation will be cancelled. 47 | */ 48 | SDWebImageContinueInBackground = 1 << 5, 49 | /** 50 | * Handles cookies stored in NSHTTPCookieStore by setting 51 | * NSMutableURLRequest.HTTPShouldHandleCookies = YES; 52 | */ 53 | SDWebImageHandleCookies = 1 << 6, 54 | /** 55 | * Enable to allow untrusted SSL ceriticates. 56 | * Useful for testing purposes. Use with caution in production. 57 | */ 58 | SDWebImageAllowInvalidSSLCertificates = 1 << 7 59 | }; 60 | 61 | typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType); 62 | 63 | typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished); 64 | 65 | 66 | @class SDWebImageManager; 67 | 68 | @protocol SDWebImageManagerDelegate 69 | 70 | @optional 71 | 72 | /** 73 | * Controls which image should be downloaded when the image is not found in the cache. 74 | * 75 | * @param imageManager The current `SDWebImageManager` 76 | * @param imageURL The url of the image to be downloaded 77 | * 78 | * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied. 79 | */ 80 | - (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL; 81 | 82 | /** 83 | * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory. 84 | * NOTE: This method is called from a global queue in order to not to block the main thread. 85 | * 86 | * @param imageManager The current `SDWebImageManager` 87 | * @param image The image to transform 88 | * @param imageURL The url of the image to transform 89 | * 90 | * @return The transformed image object. 91 | */ 92 | - (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL; 93 | 94 | @end 95 | 96 | /** 97 | * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes. 98 | * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache). 99 | * You can use this class directly to benefit from web image downloading with caching in another context than 100 | * a UIView. 101 | * 102 | * Here is a simple example of how to use SDWebImageManager: 103 | * 104 | * @code 105 | 106 | SDWebImageManager *manager = [SDWebImageManager sharedManager]; 107 | [manager downloadWithURL:imageURL 108 | options:0 109 | progress:nil 110 | completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) 111 | { 112 | if (image) 113 | { 114 | // do something with image 115 | } 116 | }]; 117 | 118 | * @endcode 119 | */ 120 | @interface SDWebImageManager : NSObject 121 | 122 | @property (weak, nonatomic) id delegate; 123 | 124 | @property (strong, nonatomic, readonly) SDImageCache *imageCache; 125 | @property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader; 126 | 127 | /** 128 | * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can 129 | * be used to remove dynamic part of an image URL. 130 | * 131 | * The following example sets a filter in the application delegate that will remove any query-string from the 132 | * URL before to use it as a cache key: 133 | * 134 | * @code 135 | 136 | [[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) 137 | { 138 | url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; 139 | return [url absoluteString]; 140 | }]; 141 | 142 | * @endcode 143 | */ 144 | @property (strong) NSString *(^cacheKeyFilter)(NSURL *url); 145 | 146 | /** 147 | * Returns global SDWebImageManager instance. 148 | * 149 | * @return SDWebImageManager shared instance 150 | */ 151 | + (SDWebImageManager *)sharedManager; 152 | 153 | /** 154 | * Downloads the image at the given URL if not present in cache or return the cached version otherwise. 155 | * 156 | * @param url The URL to the image 157 | * @param options A mask to specify options to use for this request 158 | * @param progressBlock A block called while image is downloading 159 | * @param completedBlock A block called when operation has been completed. 160 | * 161 | * This parameter is required. 162 | * 163 | * This block has no return value and takes the requested UIImage as first parameter. 164 | * In case of error the image parameter is nil and the second parameter may contain an NSError. 165 | * 166 | * The third parameter is an `SDImageCacheType` enum indicating if the image was retrived from the local cache 167 | * or from the memory cache or from the network. 168 | * 169 | * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is 170 | * downloading. This block is thus called repetidly with a partial image. When image is fully downloaded, the 171 | * block is called a last time with the full image and the last parameter set to YES. 172 | * 173 | * @return Returns a cancellable NSOperation 174 | */ 175 | - (id )downloadWithURL:(NSURL *)url 176 | options:(SDWebImageOptions)options 177 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 178 | completed:(SDWebImageCompletedWithFinishedBlock)completedBlock; 179 | 180 | /** 181 | * Cancel all current opreations 182 | */ 183 | - (void)cancelAll; 184 | 185 | /** 186 | * Check one or more operations running 187 | */ 188 | - (BOOL)isRunning; 189 | 190 | /** 191 | * Check if image has already been cached 192 | */ 193 | - (BOOL)diskImageExistsForURL:(NSURL *)url; 194 | 195 | @end 196 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | 11 | @protocol SDWebImageOperation 12 | 13 | - (void)cancel; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @class SDWebImagePrefetcher; 13 | 14 | @protocol SDWebImagePrefetcherDelegate 15 | 16 | @optional 17 | 18 | /** 19 | * Called when an image was prefetched. 20 | * 21 | * @param imagePrefetcher The current image prefetcher 22 | * @param imageURL The image url that was prefetched 23 | * @param finishedCount The total number of images that were prefetched 24 | * @param totalCount The total number of images that need to be prefetched 25 | */ 26 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; 27 | 28 | /** 29 | * Called when all images are prefetched. 30 | * @param imagePrefetcher The current image prefetcher 31 | * @param totalCount The total number of images that need to be prefetched 32 | * @param skippedCount The total number of images that were skipped 33 | */ 34 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; 35 | 36 | @end 37 | 38 | 39 | /** 40 | * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. 41 | */ 42 | @interface SDWebImagePrefetcher : NSObject 43 | 44 | /** 45 | * Maximum number of URLs to prefetch at the same time. Defaults to 3. 46 | */ 47 | @property (nonatomic, assign) NSUInteger maxConcurrentDownloads; 48 | 49 | /** 50 | * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. 51 | */ 52 | @property (nonatomic, assign) SDWebImageOptions options; 53 | 54 | @property (weak, nonatomic) id delegate; 55 | 56 | /** 57 | * Return the global image prefetcher instance. 58 | */ 59 | + (SDWebImagePrefetcher *)sharedImagePrefetcher; 60 | 61 | /** 62 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 63 | * currently one image is downloaded at a time, 64 | * and skips images for failed downloads and proceed to the next image in the list 65 | * 66 | * @param urls list of URLs to prefetch 67 | */ 68 | - (void)prefetchURLs:(NSArray *)urls; 69 | 70 | /** 71 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 72 | * currently one image is downloaded at a time, 73 | * and skips images for failed downloads and proceed to the next image in the list 74 | * 75 | * @param urls list of URLs to prefetch 76 | * @param progressBlock block to be called when progress updates 77 | * @param completionBlock block to be called when prefetching is completed 78 | */ 79 | - (void)prefetchURLs:(NSArray *)urls progress:(void (^)(NSUInteger, NSUInteger))progressBlock completed:(void (^)(NSUInteger, NSUInteger))completionBlock; 80 | 81 | /** 82 | * Remove and cancel queued list 83 | */ 84 | - (void)cancelPrefetching; 85 | 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/UIButton+WebCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with UIButtonView. 14 | */ 15 | @interface UIButton (WebCache) 16 | 17 | /** 18 | * Set the imageView `image` with an `url`. 19 | * 20 | * The downloand is asynchronous and cached. 21 | * 22 | * @param url The url for the image. 23 | * @param state The state that uses the specified title. The values are described in UIControlState. 24 | */ 25 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state; 26 | 27 | /** 28 | * Set the imageView `image` with an `url` and a placeholder. 29 | * 30 | * The downloand is asynchronous and cached. 31 | * 32 | * @param url The url for the image. 33 | * @param state The state that uses the specified title. The values are described in UIControlState. 34 | * @param placeholder The image to be set initially, until the image request finishes. 35 | * @see setImageWithURL:placeholderImage:options: 36 | */ 37 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; 38 | 39 | /** 40 | * Set the imageView `image` with an `url`, placeholder and custom options. 41 | * 42 | * The downloand is asynchronous and cached. 43 | * 44 | * @param url The url for the image. 45 | * @param state The state that uses the specified title. The values are described in UIControlState. 46 | * @param placeholder The image to be set initially, until the image request finishes. 47 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 48 | */ 49 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 50 | 51 | /** 52 | * Set the imageView `image` with an `url`. 53 | * 54 | * The downloand is asynchronous and cached. 55 | * 56 | * @param url The url for the image. 57 | * @param state The state that uses the specified title. The values are described in UIControlState. 58 | * @param completedBlock A block called when operation has been completed. This block as no return value 59 | * and takes the requested UIImage as first parameter. In case of error the image parameter 60 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 61 | * indicating if the image was retrived from the local cache of from the network. 62 | */ 63 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock; 64 | 65 | /** 66 | * Set the imageView `image` with an `url`, placeholder. 67 | * 68 | * The downloand is asynchronous and cached. 69 | * 70 | * @param url The url for the image. 71 | * @param state The state that uses the specified title. The values are described in UIControlState. 72 | * @param placeholder The image to be set initially, until the image request finishes. 73 | * @param completedBlock A block called when operation has been completed. This block as no return value 74 | * and takes the requested UIImage as first parameter. In case of error the image parameter 75 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 76 | * indicating if the image was retrived from the local cache of from the network. 77 | */ 78 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock; 79 | 80 | /** 81 | * Set the imageView `image` with an `url`, placeholder and custom options. 82 | * 83 | * The downloand is asynchronous and cached. 84 | * 85 | * @param url The url for the image. 86 | * @param state The state that uses the specified title. The values are described in UIControlState. 87 | * @param placeholder The image to be set initially, until the image request finishes. 88 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 89 | * @param completedBlock A block called when operation has been completed. This block as no return value 90 | * and takes the requested UIImage as first parameter. In case of error the image parameter 91 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 92 | * indicating if the image was retrived from the local cache of from the network. 93 | */ 94 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock; 95 | 96 | /** 97 | * Set the backgroundImageView `image` with an `url`. 98 | * 99 | * The downloand is asynchronous and cached. 100 | * 101 | * @param url The url for the image. 102 | * @param state The state that uses the specified title. The values are described in UIControlState. 103 | */ 104 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state; 105 | 106 | /** 107 | * Set the backgroundImageView `image` with an `url` and a placeholder. 108 | * 109 | * The downloand is asynchronous and cached. 110 | * 111 | * @param url The url for the image. 112 | * @param state The state that uses the specified title. The values are described in UIControlState. 113 | * @param placeholder The image to be set initially, until the image request finishes. 114 | * @see setImageWithURL:placeholderImage:options: 115 | */ 116 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; 117 | 118 | /** 119 | * Set the backgroundImageView `image` with an `url`, placeholder and custom options. 120 | * 121 | * The downloand is asynchronous and cached. 122 | * 123 | * @param url The url for the image. 124 | * @param state The state that uses the specified title. The values are described in UIControlState. 125 | * @param placeholder The image to be set initially, until the image request finishes. 126 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 127 | */ 128 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 129 | 130 | /** 131 | * Set the backgroundImageView `image` with an `url`. 132 | * 133 | * The downloand is asynchronous and cached. 134 | * 135 | * @param url The url for the image. 136 | * @param state The state that uses the specified title. The values are described in UIControlState. 137 | * @param completedBlock A block object to be executed after the request operation 138 | * completed. This block has no return value and takes three argument: the requested 139 | * `UIImage` object, the `NSError` object describing error that occurred, and an 140 | * `SDImageCacheType` enum describing the source of the image obtained from. 141 | */ 142 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock; 143 | 144 | /** 145 | * Set the backgroundImageView `image` with an `url`, placeholder. 146 | * 147 | * The downloand is asynchronous and cached. 148 | * 149 | * @param url The url for the image. 150 | * @param state The state that uses the specified title. The values are described in UIControlState. 151 | * @param placeholder The image to be set initially, until the image request finishes. 152 | * @param completedBlock A block object to be executed after the request operation 153 | * completed. This block has no return value and takes three argument: the requested 154 | * `UIImage` object, the `NSError` object describing error that occurred, and an 155 | * `SDImageCacheType` enum describing the source of the image obtained from. 156 | */ 157 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock; 158 | 159 | /** 160 | * Set the backgroundImageView `image` with an `url`, placeholder and custom options. 161 | * 162 | * The downloand is asynchronous and cached. 163 | * 164 | * @param url The url for the image. 165 | * @param placeholder The image to be set initially, until the image request finishes. 166 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 167 | * @param completedBlock A block object to be executed after the request operation 168 | * completed. This block has no return value and takes three argument: the requested 169 | * `UIImage` object, the `NSError` object describing error that occurred, and an 170 | * `SDImageCacheType` enum describing the source of the image obtained from. 171 | */ 172 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock; 173 | 174 | /** 175 | * Cancel the current download 176 | */ 177 | - (void)cancelCurrentImageLoad; 178 | 179 | @end 180 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.h 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (GIF) 12 | 13 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name; 14 | 15 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data; 16 | 17 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (MultiFormat) 12 | 13 | + (UIImage *)sd_imageWithData:(NSData *)data; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/UIImage+WebP.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+WebP.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #ifdef SD_WEBP 10 | 11 | #import 12 | 13 | // Fix for issue #416 Undefined symbols for architecture armv7 since WebP introduction when deploying to device 14 | void WebPInitPremultiplyNEON(void); 15 | 16 | void WebPInitUpsamplersNEON(void); 17 | 18 | void VP8DspInitNEON(void); 19 | 20 | @interface UIImage (WebP) 21 | 22 | + (UIImage *)sd_imageWithWebPData:(NSData *)data; 23 | 24 | @end 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.h 2 | // 3 | // Copyright (c) 2011 Gowalla (http://gowalla.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFImageRequestOperation.h" 25 | 26 | #import 27 | 28 | #if __IPHONE_OS_VERSION_MIN_REQUIRED 29 | #import 30 | 31 | /** 32 | This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. 33 | */ 34 | @interface UIImageView (AFNetworking) 35 | 36 | /** 37 | Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL, and sets it the request is finished. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 38 | 39 | By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 40 | 41 | @param url The URL used for the image request. 42 | */ 43 | - (void)setImageWithURL:(NSURL *)url; 44 | 45 | /** 46 | Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 47 | 48 | By default, URL requests have a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` 49 | 50 | @param url The URL used for the image request. 51 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. 52 | */ 53 | - (void)setImageWithURL:(NSURL *)url 54 | placeholderImage:(UIImage *)placeholderImage; 55 | 56 | /** 57 | Creates and enqueues an image request operation, which asynchronously downloads the image with the specified URL request object. Any previous image request for the receiver will be cancelled. If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. 58 | 59 | If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is executed. 60 | 61 | @param urlRequest The URL request used for the image request. 62 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. 63 | @param success A block to be executed when the image request operation finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`. 64 | @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. 65 | */ 66 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 67 | placeholderImage:(UIImage *)placeholderImage 68 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 69 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; 70 | 71 | /** 72 | Cancels any executing image request operation for the receiver, if one exists. 73 | */ 74 | - (void)cancelImageRequestOperation; 75 | 76 | @end 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Headers/UIImageView+WebCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImageCompat.h" 10 | #import "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView. 14 | * 15 | * Usage with a UITableViewCell sub-class: 16 | * 17 | * @code 18 | 19 | #import 20 | 21 | ... 22 | 23 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 24 | { 25 | static NSString *MyIdentifier = @"MyIdentifier"; 26 | 27 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 28 | 29 | if (cell == nil) 30 | { 31 | cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] 32 | autorelease]; 33 | } 34 | 35 | // Here we use the provided setImageWithURL: method to load the web image 36 | // Ensure you use a placeholder image otherwise cells will be initialized with no image 37 | [cell.imageView setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] 38 | placeholderImage:[UIImage imageNamed:@"placeholder"]]; 39 | 40 | cell.textLabel.text = @"My Text"; 41 | return cell; 42 | } 43 | 44 | * @endcode 45 | */ 46 | @interface UIImageView (WebCache) 47 | 48 | /** 49 | * Set the imageView `image` with an `url`. 50 | * 51 | * The downloand is asynchronous and cached. 52 | * 53 | * @param url The url for the image. 54 | */ 55 | - (void)setImageWithURL:(NSURL *)url; 56 | 57 | /** 58 | * Set the imageView `image` with an `url` and a placeholder. 59 | * 60 | * The downloand is asynchronous and cached. 61 | * 62 | * @param url The url for the image. 63 | * @param placeholder The image to be set initially, until the image request finishes. 64 | * @see setImageWithURL:placeholderImage:options: 65 | */ 66 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; 67 | 68 | /** 69 | * Set the imageView `image` with an `url`, placeholder and custom options. 70 | * 71 | * The downloand is asynchronous and cached. 72 | * 73 | * @param url The url for the image. 74 | * @param placeholder The image to be set initially, until the image request finishes. 75 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 76 | */ 77 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 78 | 79 | /** 80 | * Set the imageView `image` with an `url`. 81 | * 82 | * The downloand is asynchronous and cached. 83 | * 84 | * @param url The url for the image. 85 | * @param completedBlock A block called when operation has been completed. This block as no return value 86 | * and takes the requested UIImage as first parameter. In case of error the image parameter 87 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 88 | * indicating if the image was retrived from the local cache of from the network. 89 | */ 90 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock; 91 | 92 | /** 93 | * Set the imageView `image` with an `url`, placeholder. 94 | * 95 | * The downloand is asynchronous and cached. 96 | * 97 | * @param url The url for the image. 98 | * @param placeholder The image to be set initially, until the image request finishes. 99 | * @param completedBlock A block called when operation has been completed. This block as no return value 100 | * and takes the requested UIImage as first parameter. In case of error the image parameter 101 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 102 | * indicating if the image was retrived from the local cache of from the network. 103 | */ 104 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock; 105 | 106 | /** 107 | * Set the imageView `image` with an `url`, placeholder and custom options. 108 | * 109 | * The downloand is asynchronous and cached. 110 | * 111 | * @param url The url for the image. 112 | * @param placeholder The image to be set initially, until the image request finishes. 113 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 114 | * @param completedBlock A block called when operation has been completed. This block as no return value 115 | * and takes the requested UIImage as first parameter. In case of error the image parameter 116 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 117 | * indicating if the image was retrived from the local cache of from the network. 118 | */ 119 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock; 120 | 121 | /** 122 | * Set the imageView `image` with an `url`, placeholder and custom options. 123 | * 124 | * The downloand is asynchronous and cached. 125 | * 126 | * @param url The url for the image. 127 | * @param placeholder The image to be set initially, until the image request finishes. 128 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 129 | * @param progressBlock A block called while image is downloading 130 | * @param completedBlock A block called when operation has been completed. This block as no return value 131 | * and takes the requested UIImage as first parameter. In case of error the image parameter 132 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 133 | * indicating if the image was retrived from the local cache of from the network. 134 | */ 135 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock; 136 | 137 | /** 138 | * Download an array of images and starts them in an animation loop 139 | * 140 | *@param arrayOfURLs An array of NSURL 141 | */ 142 | - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; 143 | 144 | /** 145 | * Cancel the current download 146 | */ 147 | - (void)cancelCurrentImageLoad; 148 | 149 | - (void)cancelCurrentArrayLoad; 150 | 151 | @end 152 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Resources/Info.plist -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Resources/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/A/Resources/en.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSCoreThirdParty.framework/Versions/Current: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/GSUtilitiesSDK: -------------------------------------------------------------------------------- 1 | Versions/Current/GSUtilitiesSDK -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Headers: -------------------------------------------------------------------------------- 1 | Versions/Current/Headers -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Resources: -------------------------------------------------------------------------------- 1 | Versions/Current/Resources -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/GSUtilitiesSDK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/GSUtilitiesSDK -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSCommonUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSCommonUtil.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 13-12-23. 6 | // Copyright (c) 2013年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSCommonUtil : NSObject 12 | 13 | + (void)clearWebViewBackground:(UIWebView*)webView; 14 | 15 | + (NSString*)getAppVersion; 16 | 17 | + (NSString*)getBundleID; 18 | 19 | + (NSString*)getAppDisplayName; 20 | 21 | + (NSString*)getCurrentLanguage; 22 | 23 | + (NSString*)getCurrentLocale; 24 | 25 | + (BOOL)isAppFirstLaunch; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSDateUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDateUtil.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 13-12-16. 6 | // Copyright (c) 2013年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSDateUtil : NSObject 12 | 13 | /** 14 | * 判断两个日期是否是同一天 15 | * 16 | * @param day1 Day1 17 | * @param day2 Day2 18 | * 19 | * @return 是否是同一天 20 | */ 21 | + (BOOL)isSameDay:(NSDate*)day1 and:(NSDate*)day2; 22 | 23 | /** 24 | * 判断d1是否在d2之前 25 | * 26 | * @param d1 day1 27 | * @param d2 day2 28 | * 29 | * @return YES/NO 30 | */ 31 | + (BOOL)isDay:(NSDate*)date1 before:(NSDate*)date2; 32 | 33 | 34 | /** 35 | * 转换yyyy-MM-dd HH:mm:ss格式时间 36 | * 37 | * @param dateStr yyyy-MM-dd HH:mm:ss 38 | * 39 | * @return data 40 | */ 41 | + (NSDate*)dateWithString:(NSString*)dateStr; 42 | 43 | /** 44 | * 将日期转换为指定格式的时间字符串 45 | * 46 | * @param date 日期 47 | * @param format 格式 48 | * 49 | * @return 50 | */ 51 | + (NSString*)stringWithDate:(NSDate*)date withFormat:(NSString*)format; 52 | 53 | /** 54 | * 将iOS默认GMT时间转换为北京时间 55 | * 56 | * @param date 日期对象 57 | * 58 | * @return date 59 | */ 60 | + (NSDate*)dateWithBeijing:(NSDate*)date; 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSDeviceUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDeviceUtil.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 13-11-20. 6 | // Copyright (c) 2013年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSDeviceUtil : NSObject 12 | 13 | /** 14 | * 获取系统iOS主版本号 15 | * 16 | * @return iOS主版本号 17 | */ 18 | + (NSUInteger)getDeviceSystemMajorVersion; 19 | 20 | /** 21 | * 获取系统iOS版本号 22 | * 23 | * @return iOS版本号 24 | */ 25 | + (NSString*)getDeviceSystemVersionString; 26 | 27 | /** 28 | * 获取设备机型 29 | * 30 | * @return 机型 31 | */ 32 | + (NSString*)getDeviceModel; 33 | 34 | /** 35 | * 获取屏幕分辨率 36 | * 37 | * @return 屏幕分辨率 38 | */ 39 | + (NSString*)getDeviceScreenResolution; 40 | 41 | /** 42 | * 获取设备名称 43 | * 44 | * @return 设备名称 45 | */ 46 | + (NSString*)getDeviceName; 47 | 48 | /** 49 | * 根据Keychain文件,获取设备UUID 50 | * 51 | * @return 52 | */ 53 | + (NSString*)getDeviceUUID; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSEncryptUtl.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSEncryptUtl.h 3 | // GSCoreCommon 4 | // 5 | // Created by  imac_hjq on 14-1-22. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | @interface GSEncryptUtl : NSObject 14 | /** 15 | * 加密解密字符串 16 | * 17 | * @param sTextIn 字符串 18 | * @param sKey key 19 | * @param encryptOrDecrypt 加密or解密 20 | * 21 | * @return reslut 22 | */ 23 | + (NSString *)doCipher:(NSString *)sTextIn key:(NSString *)sKey 24 | context:(CCOperation)encryptOrDecrypt; 25 | 26 | + (NSString *)encodeBase64WithString:(NSString *)strData; 27 | 28 | + (NSData *)decodeBase64WithString:(NSString *)strBase64; 29 | 30 | + (NSString *)encodeBase64WithData:(NSData *)objData; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSJSONParseUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSJSONParseUtil.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 13-12-16. 6 | // Copyright (c) 2013年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSJSONParseUtil : NSObject 12 | 13 | + (long long)getLongValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 14 | 15 | + (int)getIntValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 16 | 17 | + (BOOL)getBoolValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 18 | 19 | + (float)getFloatValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 20 | 21 | + (NSNumber*)getNumberValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 22 | 23 | + (NSString*)getStringValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 24 | 25 | + (NSDictionary*)getDictionaryValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 26 | 27 | + (NSArray*)getArrayValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 28 | 29 | + (NSMutableArray*)getMutableArrayValueInDict:(NSDictionary*)dict withKey:(NSString*)key; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSReachabilityUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSReachabilityUtil.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 13-11-14. 6 | // Copyright (c) 2013年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | typedef enum 12 | { 13 | GSNetworkStatusWIFI = 0, 14 | GSNetworkStatus3G = 1, 15 | GSNetworkStatusOFFLINE = 2 16 | 17 | } GSNetworkStatus; 18 | 19 | #define NETWORK_STATUS_KEY @"GSNetworkStatusKey" 20 | #define NETWORK_TEST_WEBSITE @"www.baidu.com" 21 | 22 | @interface GSReachabilityUtil : NSObject 23 | 24 | /** 25 | * 注册网络状态变化监听者 26 | * 27 | * @param observer 外部观察者,如果为空,则使用内置默认观察者 28 | * @param aSelector 外部通知接收方法,如果为空,则使用内置默认方法 29 | * @param anObject 事件接收对象,默认为空 30 | */ 31 | + (void)registerReachabilityChangedObserver:(id)observer selector:(SEL)aSelector object:(id)anObject; 32 | 33 | /** 34 | * 默认网络状态变化监听者 35 | */ 36 | + (void)registerReachabilityChangedObserver; 37 | 38 | /** 39 | * 获取缓存的网络状态 40 | * 41 | * @return 网络状态值 42 | */ 43 | + (GSNetworkStatus)getCachedNetworkStatus; 44 | 45 | /** 46 | * 获取当前的网络状态 47 | * 48 | * @return 网络状态值 49 | */ 50 | + (GSNetworkStatus)getCurrentNetworkStatus; 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSScreenUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSScreenUtil.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 13-11-20. 6 | // Copyright (c) 2013年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSScreenUtil : NSObject 12 | 13 | /** 14 | * 获取竖屏模式下的屏幕宽度 15 | * 16 | * @return 屏幕宽度 17 | */ 18 | + (float) getVerticalWidthOfScreen; 19 | 20 | /** 21 | * 获取竖屏模式下的屏幕高度 22 | * 23 | * @return 屏幕高度 24 | */ 25 | + (float) getVerticalHeightOfScreen; 26 | 27 | /** 28 | * 获取横屏模式下的屏幕宽度 29 | * 30 | * @return 屏幕宽度 31 | */ 32 | + (float) getHorizontalWidthOfScreen; 33 | 34 | /** 35 | * 获取横屏模式下的屏幕高度 36 | * 37 | * @return 屏幕高度 38 | */ 39 | + (float) getHorizontalHeightOfScreen; 40 | 41 | /** 42 | * 获取状态栏高度 43 | * 44 | * @return 状态栏高度 45 | */ 46 | + (float) getStatusBarHeight; 47 | 48 | /** 49 | * 获取导航条高度 50 | * 51 | * @param navigationBar 导航条对象 52 | * 53 | * @return 导航条高度 54 | */ 55 | + (float) getNavigationBarHeightOf:(UINavigationBar*)navigationBar; 56 | 57 | /** 58 | * 获取TabBar高度 59 | * 60 | * @param tabBar TabBar对象 61 | * 62 | * @return TabBar高度 63 | */ 64 | + (float) getTabBarHeightOf:(UITabBar*)tabBar; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSStringUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSStringUtil.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 13-12-16. 6 | // Copyright (c) 2013年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSStringUtil : NSObject 12 | 13 | /** 14 | * 获取字符串的实际长度,比如123的实际长度为3,123呵的实际长度为5 15 | * 16 | * @param string 字符串 17 | * 18 | * @return 实际长度 19 | */ 20 | + (int)getStringRealLength:(NSString*)string; 21 | 22 | /** 23 | * 从itunesUrl解析出来 24 | * 25 | * @param itunesUrl 应用在AppStore的地址 26 | * 27 | * @return 28 | */ 29 | + (NSString*)parseAppIdFromItunesURL:(NSString*)itunesUrl; 30 | 31 | /** 32 | * 判断是否为空字符串 33 | * 34 | * @param string 需要判断的字符串 35 | * 36 | * @return 37 | */ 38 | + (BOOL)isEmptyString:(NSString*)string; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Headers/GSUtilitiesSDK.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSUtilitiesSDK.h 3 | // GSUtilitiesSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-4. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #ifndef GSUtilitiesSDK_GSUtilitiesSDK_h 10 | #define GSUtilitiesSDK_GSUtilitiesSDK_h 11 | 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | #import 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Resources/Info.plist -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Resources/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/A/Resources/en.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Frameworks/GSUtilitiesSDK.framework/Versions/Current: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloadEvenHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadEvenHandler.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 14-2-26. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #ifndef GSCoreCommon_GSDownloadEvenHandler_h 10 | #define GSCoreCommon_GSDownloadEvenHandler_h 11 | 12 | /** 13 | * 异步下载开始前,执行自定义的事件 14 | * 15 | * @return 16 | */ 17 | typedef void (^GSDownloadBeginEventHandler) (); 18 | 19 | /** 20 | * 异步下载中,执行自定义的事件 21 | * 22 | * @param bytesRead 距离上次执行后又下载了多少字节 23 | * @param totalBytesRead 已经下载了多少字节 24 | * @param totalBytesExpectedToRead 总共需要下载多少字节 25 | * @param bytesPerSecond 实时下载速度(Bytes/s) 26 | * 27 | * @return 28 | */ 29 | typedef void (^GSDownloadingEventHandler) (NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead,double bytesPerSecond); 30 | 31 | /** 32 | * 异步下载结束后,执行自定义的事件 33 | * 34 | * @param error 错误对象(如果成功,error传nil) 35 | * 36 | * @return 37 | */ 38 | typedef void (^GSDownloadedEventHandler) (NSError* error ); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloadFileModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadFileModel.h 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-6. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSDownloadFileModel : NSObject 12 | 13 | @property(nonatomic, strong, getter = getDownloadFileName) NSString* downloadFileName; 14 | 15 | @property(nonatomic, strong, getter = getDownloadFileAvatorURL) NSString* downloadFileAvatorURL; 16 | 17 | @property(nonatomic, strong, getter = getDownloadFinishTime) NSString* downloadFinishTime; 18 | 19 | @property(nonatomic, strong, getter = getDownloadFileSize) NSNumber* downloadFileSize; 20 | 21 | @property(nonatomic, strong, getter = getDownloadedFileSize) NSNumber* downloadedFileSize; 22 | 23 | @property(nonatomic, strong, getter = getDownloadFileVersion) NSString* downloadFileVersion; 24 | 25 | @property(nonatomic, strong, getter = getDownloadTaskURL) NSString* downloadTaskURL; 26 | 27 | @property(nonatomic, strong, getter = getDownloadFileSavePath) NSString* downloadFileSavePath; 28 | 29 | @property(nonatomic, strong, getter = getDownloadTempSavePath) NSString* downloadTempSavePath; 30 | 31 | @property(nonatomic, strong, getter = getDownloadFilePlistURL) NSString* downloadFilePlistURL; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloadFileModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadFileModel.m 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-6. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "GSDownloadFileModel.h" 10 | 11 | @implementation GSDownloadFileModel 12 | 13 | - (id)init 14 | { 15 | self = [super init]; 16 | if (self) { 17 | _downloadFileName = @""; 18 | _downloadFileAvatorURL = @""; 19 | _downloadFinishTime = @""; 20 | _downloadFileSize = [NSNumber numberWithLongLong:0]; 21 | _downloadFileVersion = @""; 22 | _downloadTaskURL = @""; 23 | _downloadFileSavePath = @""; 24 | _downloadTempSavePath = @""; 25 | _downloadFilePlistURL = @""; 26 | } 27 | 28 | return self; 29 | } 30 | @end 31 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloadTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadTask.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-11. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "GSSingleDownloadTaskProtocol.h" 11 | #import "GSDownloadFileModel.h" 12 | #import "GSDownloadUIBindProtocol.h" 13 | 14 | /** 15 | * 实现下载任务(依赖GSSingleDownloadTaskProtocol协议) 16 | * 外部使用前,需要指定下载文件模型(实现GSDownloadFileModelProtocol接口)和关联的UI对象(实现GSDownloadUIBindProtocol) 17 | */ 18 | @interface GSDownloadTask : NSObject 19 | 20 | @property (nonatomic,getter = getDownloadStatus) GSDownloadStatus downloadStatus; 21 | 22 | // add by zhenwei 23 | @property (nonatomic) NSUInteger bytesRead; 24 | 25 | @property (nonatomic) long long totalBytesRead; 26 | 27 | @property (nonatomic) long long totalBytesExpectedToRead; 28 | 29 | @property (nonatomic) double bytesPerSecond; 30 | 31 | @property (nonatomic,strong,getter = getDownloadTaskId) NSString* downloadTaskId; 32 | 33 | @property (nonatomic,strong,getter = getDownloadFileModel) GSDownloadFileModel* downloadFileModel; 34 | 35 | @property (nonatomic,strong,getter = getDownloadUIBinder) id downloadUIBinder; 36 | // end 37 | 38 | - (BOOL)isEqualToDownloadTask:(GSDownloadTask*)downloadTask; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloadTask.m: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadTask.m 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-11. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "GSDownloadTask.h" 10 | #import "NSObject+KVOBlock.h" 11 | 12 | @implementation GSDownloadTask 13 | { 14 | AFHTTPRequestOperation* _downloadOperation; 15 | 16 | int _failureCount; 17 | 18 | id _downloadStatusKVO; 19 | } 20 | 21 | - (id)init 22 | { 23 | self = [super init]; 24 | if (self) { 25 | _downloadStatus = GSDownloadStatusTaskNotCreated; 26 | [self initDownloadStatusObserver]; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | - (void)initDownloadStatusObserver 33 | { 34 | _downloadStatusKVO = [self addKVOBlockForKeyPath:@"downloadStatus" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld handler:^(NSString *keyPath, id object, NSDictionary *change) { 35 | 36 | //GSDownloadStatus oldStatusValue = [[change objectForKey:NSKeyValueChangeOldKey] integerValue]; 37 | 38 | 39 | GSDownloadTask* task = object; 40 | [task.getDownloadUIBinder updateUIWithTask:task]; 41 | }]; 42 | 43 | } 44 | 45 | 46 | - (BOOL)isEqualToDownloadTask:(GSDownloadTask*)downloadTask 47 | { 48 | if ([[self getDownloadTaskId]compare:[downloadTask getDownloadTaskId]] == 0) { 49 | return YES; 50 | } 51 | return NO; 52 | } 53 | 54 | #pragma mark - GSSingleDownloadTaskProtocol 55 | 56 | - (void)setDownloadOperation:(AFHTTPRequestOperation *)downloadOperation 57 | { 58 | _downloadOperation = downloadOperation; 59 | } 60 | 61 | - (void)startDownloadTask:(void (^)())bindDoSomething 62 | { 63 | [_downloadOperation start]; 64 | 65 | if (bindDoSomething) 66 | { 67 | bindDoSomething(); 68 | } 69 | } 70 | 71 | - (void)pauseDownloadTask:(void (^)())bindDoSomething 72 | { 73 | [_downloadOperation pause]; 74 | 75 | if (bindDoSomething) 76 | { 77 | bindDoSomething(); 78 | } 79 | } 80 | 81 | - (void)continueDownloadTask:(void (^)())bindDoSomething 82 | { 83 | if ([_downloadOperation isPaused]) { 84 | [_downloadOperation resume]; 85 | } 86 | 87 | if (bindDoSomething) 88 | { 89 | bindDoSomething(); 90 | } 91 | } 92 | 93 | - (void)cancelDownloadTask:(void (^)())bindDoSomething 94 | { 95 | [_downloadOperation cancel]; 96 | 97 | if (bindDoSomething) 98 | { 99 | bindDoSomething(); 100 | } 101 | } 102 | 103 | - (int)increaseFailureCount 104 | { 105 | _failureCount++; 106 | 107 | return _failureCount; 108 | } 109 | 110 | #pragma mark - dealloc 111 | - (void)dealloc 112 | { 113 | NSLog(@"%@ dealloc",[self class]); 114 | 115 | [self removeKVOBlockForToken:_downloadStatusKVO]; 116 | } 117 | 118 | @end 119 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloaderClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloaderClient.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "GSDownloadEvenHandler.h" 11 | #import "GSDownloadTask.h" 12 | 13 | /** 14 | * 下载客户端类 15 | * 16 | */ 17 | @interface GSDownloaderClient : NSObject 18 | 19 | /** 20 | * 获取单例下载客户端 21 | * 22 | * @return 23 | */ 24 | + (GSDownloaderClient*)sharedDownloaderClient; 25 | 26 | /** 27 | * 指定最高下载队列容量数 28 | */ 29 | @property (nonatomic) int maxDownload; 30 | 31 | /** 32 | * 指定最高等待队列容量数 33 | */ 34 | @property (nonatomic) int maxWaiting; 35 | 36 | /** 37 | * 指定最高暂停队列容量数 38 | */ 39 | @property (nonatomic) int maxPaused; 40 | 41 | /** 42 | * 指定最高重试机会 43 | */ 44 | @property (nonatomic) int maxFailureRetryChance; 45 | 46 | /** 47 | * 开始一次下载任务(都统一先放进等待队列) 48 | * 49 | * @param downloadTask 一条下载任务 50 | * @param begin 下载开始前回调 51 | * @param progress 处理下载中回调 52 | * @param complete 完成回调 53 | */ 54 | - (void)downloadDataAsyncWithTask:(GSDownloadTask*)downloadTask 55 | begin:(GSDownloadBeginEventHandler)begin 56 | progress:(GSDownloadingEventHandler)progress 57 | complete:(GSDownloadedEventHandler)complete; 58 | 59 | /** 60 | * 继续一条下载任务 61 | * 62 | * @param downloadTask 指定下载任务 63 | */ 64 | - (void)continueOneDownloadTaskWith:(GSDownloadTask*)downloadTask; 65 | 66 | /** 67 | * 暂停一条下载任务 68 | * 69 | * @param downloadTask 指定下载任务 70 | */ 71 | - (void)pauseOneDownloadTaskWith:(GSDownloadTask*)downloadTask; 72 | 73 | /** 74 | * 取消一条下载任务 75 | * 76 | * @param downloadTask 指定下载任务 77 | */ 78 | - (void)cancelOneDownloadTaskWith:(GSDownloadTask*)downloadTask; 79 | 80 | /** 81 | * 开始全部下载任务 82 | */ 83 | - (void)startAllDownloadTask; 84 | 85 | /** 86 | * 暂停全部下载任务 87 | */ 88 | - (void)pauseAllDownloadTask; 89 | 90 | /** 91 | * 取消全部下载任务 92 | */ 93 | - (void)cancelAllDownloadTask; 94 | 95 | /** 96 | * 测试队列KVO是否有效 97 | */ 98 | - (void)testQueueKVO; 99 | 100 | /** 101 | * 添加下载任务 102 | * 103 | * @param task 104 | */ 105 | -(void)addDownloadTask:(GSDownloadTask*)task; 106 | 107 | /** 108 | * 获取下载任务列表 109 | * 110 | * @return 111 | */ 112 | -(NSArray*)downloadTasks; 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloaderSDK-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.4399.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | CFPlugInDynamicRegisterFunction 26 | 27 | CFPlugInDynamicRegistration 28 | NO 29 | CFPlugInFactories 30 | 31 | 00000000-0000-0000-0000-000000000000 32 | MyFactoryFunction 33 | 34 | CFPlugInTypes 35 | 36 | 00000000-0000-0000-0000-000000000000 37 | 38 | 00000000-0000-0000-0000-000000000000 39 | 40 | 41 | CFPlugInUnloadFunction 42 | 43 | NSHumanReadableCopyright 44 | Copyright © 2014年 4399 Network CO.ltd. All rights reserved. 45 | 46 | 47 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloaderSDK-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #import 10 | #import 11 | #import 12 | #endif 13 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloaderSDK.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloaderSDK.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #ifndef GSDownloaderSDK_GSDownloaderSDK_h 10 | #define GSDownloaderSDK_GSDownloaderSDK_h 11 | 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | 20 | //NSObject+KVOBlock 21 | #import 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloaderSDKTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloaderSDKTest.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSDownloaderSDKTest : NSObject 12 | 13 | + (void)printTest; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/GSDownloaderSDKTest.m: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloaderSDKTest.m 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "GSDownloaderSDKTest.h" 10 | 11 | @implementation GSDownloaderSDKTest 12 | 13 | + (void)printTest 14 | { 15 | NSLog(@"GSDownloaderSDK.framework运行成功!"); 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Protocol/GSDownloadUIBindProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadUIBindProtocol.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-10. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol GSSingleDownloadTaskProtocol; 12 | 13 | 14 | /** 15 | * 用于绑定外部UI更新操作的接口 16 | */ 17 | @protocol GSDownloadUIBindProtocol 18 | 19 | @required 20 | 21 | /** 22 | * 根据任务状态改变UI 23 | * 24 | * @param downloadTask 25 | */ 26 | - (void)updateUIWithTask:(id)downloadTask; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Protocol/GSSingleDownloadTaskProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSSingleDownloadTaskProtocol.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-6. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * 标记任务下载状态 13 | */ 14 | typedef enum 15 | { 16 | GSDownloadStatusTaskNotCreated = 0, //任务还未创建(默认状态) 17 | GSDownloadStatusWaitingForStart, //等待启动 18 | GSDownloadStatusDownloading, //下载中 19 | GSDownloadStatusPaused, //被暂停 20 | GSDownloadStatusWaitingForResume, //等待恢复 21 | GSDownloadStatusCanceled, //被取消 22 | GSDownloadStatusSuccess, //下载成功 23 | GSDownloadStatusFailure //下载失败 24 | 25 | } GSDownloadStatus; 26 | 27 | /** 28 | * 定义一项下载任务接口,用于建立起对应的每款游戏下载任务,并进行对应任务的管理 29 | */ 30 | @protocol GSSingleDownloadTaskProtocol 31 | 32 | @required 33 | 34 | /** 35 | * 保存下载请求操作 36 | * 37 | * @param downloadOperation 38 | */ 39 | - (void)setDownloadOperation:(AFHTTPRequestOperation*)downloadOperation; 40 | 41 | /** 42 | * 开始一条下载任务 43 | * 44 | * @param bindDoSomething 附带执行的捆绑操作 45 | */ 46 | - (void)startDownloadTask:(void (^)())bindDoSomething; 47 | 48 | /** 49 | * 暂停一条下载任务 50 | * 51 | * @param bindDoSomething 附带执行的捆绑操作 52 | */ 53 | - (void)pauseDownloadTask:(void (^)())bindDoSomething; 54 | 55 | /** 56 | * 继续一条下载任务 57 | * 58 | * @param bindDoSomething 59 | */ 60 | - (void)continueDownloadTask:(void (^)())bindDoSomething; 61 | 62 | /** 63 | * 取消一条下载任务 64 | * 65 | * @param bindDoSomething 附带执行的捆绑操作 66 | */ 67 | - (void)cancelDownloadTask:(void (^)())bindDoSomething; 68 | 69 | /** 70 | * 标记失败次数增1 71 | * 72 | * @return 返回已失败次数 73 | */ 74 | - (int)increaseFailureCount; 75 | 76 | 77 | @end 78 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Queue/GSDownloadTaskQueue.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadTaskQueue.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * 下载任务队列(线程安全的) 13 | */ 14 | @interface GSDownloadTaskQueue : NSObject 15 | { 16 | NSMutableArray* _operationQueue; 17 | } 18 | 19 | @property (nonatomic) BOOL isEmpty; 20 | @property (nonatomic) BOOL isFull; 21 | 22 | /** 23 | * 初始化一个下载任务队列,并指定初始队列容量 24 | * 25 | * @param maxCapacity 26 | * 27 | * @return 28 | */ 29 | - (id)initWithMaxCapacity:(int)maxCapacity; 30 | 31 | /** 32 | * 任务队列最大容量 33 | */ 34 | @property (nonatomic) int maxCapacity; 35 | 36 | /** 37 | * 元素入队 38 | * 39 | * @param anObject 要添加的对象 40 | */ 41 | - (void)enqueue:(id)anObject; 42 | 43 | /** 44 | * 元素出队 45 | * 46 | * @return 47 | */ 48 | - (id)dequeue; 49 | 50 | /** 51 | * 是否为空 52 | * 53 | * @return YES/NO 54 | */ 55 | - (BOOL)empty; 56 | 57 | /** 58 | * 判断队列是否是满的 59 | * 60 | * @return 61 | */ 62 | - (BOOL)full; 63 | 64 | /** 65 | * 从队列中移除掉一指定对象(如果对象不存在于队列中,什么都不干) 66 | * 67 | * @param anObject 要移除的对象 68 | * 69 | * @return 70 | */ 71 | - (void)remove:(id)anObject; 72 | 73 | /** 74 | * 获得队列数量 75 | * 76 | * @return 77 | */ 78 | - (int)queueCount; 79 | 80 | /** 81 | * 获取队列中指定索引的对象 82 | * 83 | * @param index 队列索引 84 | * 85 | * @return 86 | */ 87 | - (id)peekAtIndex:(int)index; 88 | 89 | /** 90 | * 清空队列 91 | */ 92 | - (void)clearQueue; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/Queue/GSDownloadTaskQueue.m: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadTaskQueue.m 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "GSDownloadTaskQueue.h" 10 | 11 | @implementation GSDownloadTaskQueue 12 | 13 | - (id)initWithMaxCapacity:(int)maxCapacity 14 | { 15 | self = [super init]; 16 | if (self) { 17 | _maxCapacity = maxCapacity; 18 | 19 | _operationQueue = [[NSMutableArray alloc] init]; 20 | 21 | self.isEmpty = YES; 22 | self.isFull = NO; 23 | } 24 | 25 | return self; 26 | } 27 | 28 | - (void)enqueue:(id)anObject 29 | { 30 | @synchronized(_operationQueue) 31 | { 32 | if (anObject == nil) { 33 | return; 34 | } 35 | 36 | //如果超过指定最大容量,则禁止入队 37 | if (_operationQueue.count == _maxCapacity) { 38 | return; 39 | } 40 | 41 | //如果队列中已经存在该对象 42 | if ([_operationQueue containsObject:anObject]) { 43 | return; 44 | } 45 | 46 | [_operationQueue addObject:anObject]; 47 | 48 | [self checkQueueEmptyAndFull]; 49 | } 50 | } 51 | 52 | - (id)dequeue 53 | { 54 | @synchronized(_operationQueue) 55 | { 56 | if ([_operationQueue count] == 0) { 57 | return nil; 58 | } 59 | 60 | id queueObject = [_operationQueue objectAtIndex:0]; 61 | [_operationQueue removeObjectAtIndex:0]; 62 | 63 | [self checkQueueEmptyAndFull]; 64 | 65 | return queueObject; 66 | } 67 | } 68 | 69 | - (BOOL)empty 70 | { 71 | @synchronized(_operationQueue) 72 | { 73 | return _operationQueue.count == 0; 74 | } 75 | } 76 | 77 | - (BOOL)full 78 | { 79 | @synchronized(_operationQueue) 80 | { 81 | return _operationQueue.count == _maxCapacity; 82 | } 83 | } 84 | 85 | - (void)remove:(id)anObject 86 | { 87 | @synchronized(_operationQueue) 88 | { 89 | [_operationQueue removeObject:anObject]; 90 | 91 | [self checkQueueEmptyAndFull]; 92 | } 93 | } 94 | 95 | /** 96 | * 检查队列是否空或满 97 | */ 98 | - (void)checkQueueEmptyAndFull 99 | { 100 | self.isEmpty = ([_operationQueue count] == 0); 101 | self.isFull = ([_operationQueue count] == _maxCapacity); 102 | } 103 | 104 | - (int)queueCount 105 | { 106 | @synchronized(_operationQueue) 107 | { 108 | return (int)_operationQueue.count; 109 | } 110 | } 111 | 112 | - (id)peekAtIndex:(int)index 113 | { 114 | @synchronized(_operationQueue) 115 | { 116 | if (index < 0 || index > _operationQueue.count) { 117 | return nil; 118 | } 119 | 120 | id queueObject = [_operationQueue objectAtIndex:index]; 121 | 122 | return queueObject; 123 | } 124 | } 125 | 126 | - (void)clearQueue 127 | { 128 | @synchronized(_operationQueue) 129 | { 130 | [_operationQueue removeAllObjects]; 131 | } 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/ThirdParty/NSObject+KVOBlock.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KVOBlock.h 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 07/24/11. 6 | // Copyright 2011 toxicsoftware.com. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without modification, are 9 | // permitted provided that the following conditions are met: 10 | // 11 | // 1. Redistributions of source code must retain the above copyright notice, this list of 12 | // conditions and the following disclaimer. 13 | // 14 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list 15 | // of conditions and the following disclaimer in the documentation and/or other materials 16 | // provided with the distribution. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY TOXICSOFTWARE.COM ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TOXICSOFTWARE.COM OR 21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // The views and conclusions contained in the software and documentation are those of the 29 | // authors and should not be interpreted as representing official policies, either expressed 30 | // or implied, of toxicsoftware.com. 31 | 32 | #import 33 | 34 | typedef void (^KVOFullBlock)(NSString *keyPath, id object, NSDictionary *change); 35 | 36 | @interface NSObject (NSObject_KVOBlock) 37 | 38 | - (id)addKVOBlockForKeyPath:(NSString *)inKeyPath options:(NSKeyValueObservingOptions)inOptions handler:(KVOFullBlock)inHandler; 39 | - (void)removeKVOBlockForToken:(id)inToken; 40 | 41 | /// One shot blocks remove themselves after they've been fired once. 42 | - (id)addOneShotKVOBlockForKeyPath:(NSString *)inKeyPath options:(NSKeyValueObservingOptions)inOptions handler:(KVOFullBlock)inHandler; 43 | 44 | @end 45 | 46 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/ThirdParty/NSObject+KVOBlock.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KVOBlock.m 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 07/24/11. 6 | // Copyright 2011 toxicsoftware.com. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without modification, are 9 | // permitted provided that the following conditions are met: 10 | // 11 | // 1. Redistributions of source code must retain the above copyright notice, this list of 12 | // conditions and the following disclaimer. 13 | // 14 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list 15 | // of conditions and the following disclaimer in the documentation and/or other materials 16 | // provided with the distribution. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY TOXICSOFTWARE.COM ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TOXICSOFTWARE.COM OR 21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // The views and conclusions contained in the software and documentation are those of the 29 | // authors and should not be interpreted as representing official policies, either expressed 30 | // or implied, of toxicsoftware.com. 31 | 32 | #import "NSObject+KVOBlock.h" 33 | 34 | #import 35 | 36 | @class CKVOToken; 37 | 38 | @interface CKVOBlockHelper : NSObject 39 | @property (readonly, nonatomic, weak) id observedObject; 40 | @property (readonly, nonatomic, strong) NSMutableDictionary *tokensByContext; 41 | @property (readwrite, nonatomic, assign) NSInteger nextIdentifier; 42 | - (id)initWithObject:(id)inObject; 43 | - (CKVOToken *)insertNewTokenForKeyPath:(NSString *)inKeyPath block:(KVOFullBlock)inBlock; 44 | - (void)removeHandlerForKey:(CKVOToken *)inToken; 45 | - (void)dump; 46 | @end 47 | 48 | #pragma mark - 49 | 50 | @interface CKVOToken : NSObject 51 | @property (readonly, nonatomic, copy) NSString *keypath; 52 | @property (readonly, nonatomic, assign) NSInteger index; 53 | @property (readonly, nonatomic, copy) KVOFullBlock block; 54 | @property (readonly, nonatomic, assign) void *context; 55 | - (id)initWithKeyPath:(NSString *)inKey index:(NSInteger)inIndex block:(KVOFullBlock)inBlock; 56 | @end 57 | 58 | #pragma mark - 59 | 60 | @implementation NSObject (NSObject_KVOBlock) 61 | 62 | static void *KVO; 63 | 64 | - (id)addKVOBlockForKeyPath:(NSString *)inKeyPath options:(NSKeyValueObservingOptions)inOptions handler:(KVOFullBlock)inHandler 65 | { 66 | NSParameterAssert(inHandler); 67 | NSParameterAssert(inKeyPath); 68 | NSParameterAssert([NSThread isMainThread]); // TODO -- remove and grow a pair. 69 | 70 | CKVOBlockHelper *theHelper = KVOBlockHelperForObject(self, YES); 71 | NSParameterAssert(theHelper != NULL); 72 | 73 | CKVOToken *theToken = [theHelper insertNewTokenForKeyPath:inKeyPath block:inHandler]; 74 | NSParameterAssert(theToken != NULL); 75 | 76 | void *theContext = theToken.context; 77 | NSParameterAssert(theContext != NULL); 78 | 79 | [self addObserver:theHelper forKeyPath:inKeyPath options:inOptions context:theContext]; 80 | 81 | return(theToken); 82 | } 83 | 84 | - (void)removeKVOBlockForToken:(CKVOToken *)inToken 85 | { 86 | NSParameterAssert([NSThread isMainThread]); // TODO -- remove and grow a pair. 87 | CKVOBlockHelper *theHelper = KVOBlockHelperForObject(self, NO); 88 | NSParameterAssert(theHelper != NULL); 89 | 90 | void *theContext = inToken.context; 91 | NSParameterAssert(theContext); 92 | NSString *theKeyPath = inToken.keypath; 93 | NSParameterAssert(theKeyPath.length > 0); 94 | [self removeObserver:theHelper forKeyPath:theKeyPath context:theContext]; 95 | 96 | [theHelper removeHandlerForKey:inToken]; 97 | } 98 | 99 | #pragma mark - 100 | 101 | - (id)addOneShotKVOBlockForKeyPath:(NSString *)inKeyPath options:(NSKeyValueObservingOptions)inOptions handler:(KVOFullBlock)inHandler 102 | { 103 | __block CKVOToken *theToken = NULL; 104 | KVOFullBlock theBlock = ^(NSString *keyPath, id object, NSDictionary *change) { 105 | inHandler(keyPath, object, change); 106 | [self removeKVOBlockForToken:theToken]; 107 | }; 108 | 109 | theToken = [self addKVOBlockForKeyPath:inKeyPath options:inOptions handler:theBlock]; 110 | return(theToken); 111 | } 112 | 113 | #pragma mark - 114 | 115 | static CKVOBlockHelper *KVOBlockHelperForObject(NSObject *object, BOOL inCreate) 116 | { 117 | CKVOBlockHelper *theHelper = objc_getAssociatedObject(object, &KVO); 118 | if (theHelper == NULL && inCreate == YES) 119 | { 120 | theHelper = [[CKVOBlockHelper alloc] initWithObject:object]; 121 | 122 | objc_setAssociatedObject(object, &KVO, theHelper, OBJC_ASSOCIATION_RETAIN); 123 | } 124 | return(theHelper); 125 | } 126 | 127 | @end 128 | 129 | #pragma mark - 130 | 131 | @implementation CKVOBlockHelper 132 | 133 | - (id)initWithObject:(id)inObject 134 | { 135 | if ((self = [super init]) != NULL) 136 | { 137 | _observedObject = inObject; 138 | } 139 | return(self); 140 | } 141 | 142 | - (void)dealloc 143 | { 144 | __strong NSObject *strong_observedObject = self.observedObject; 145 | 146 | for (CKVOToken *theToken in [_tokensByContext allValues]) 147 | { 148 | void *theContext = theToken.context; 149 | NSParameterAssert(theContext != NULL); 150 | NSString *theKeypath = theToken.keypath; 151 | NSParameterAssert(theKeypath != NULL); 152 | [strong_observedObject removeObserver:self forKeyPath:theKeypath context:theContext]; 153 | } 154 | } 155 | 156 | - (NSString *)debugDescription 157 | { 158 | __strong NSObject *strong_observedObject = self.observedObject; 159 | NSString *theDescription = [NSString stringWithFormat:@"%@ (%@, %@, %@)", [self description], strong_observedObject, self.tokensByContext, [strong_observedObject observationInfo]]; 160 | return (theDescription); 161 | } 162 | 163 | - (void)dump 164 | { 165 | __strong NSObject *strong_observedObject = self.observedObject; 166 | printf("*******************************************************\n"); 167 | printf("%s\n", [[self description] UTF8String]); 168 | printf("\tObserved Object: %p\n", (__bridge void *)strong_observedObject); 169 | printf("\tKeys:\n"); 170 | [_tokensByContext enumerateKeysAndObjectsUsingBlock:^(NSNumber *index, CKVOToken *token, BOOL *stop) { 171 | printf("\t\t%s\n", [[index description] UTF8String]); 172 | }]; 173 | printf("\tObservationInfo: %s\n", [[(__bridge id)[strong_observedObject observationInfo] description] UTF8String]); 174 | } 175 | 176 | - (void)removeHandlerForKey:(CKVOToken *)inToken 177 | { 178 | [_tokensByContext removeObjectForKey:@(inToken.index)]; 179 | if (_tokensByContext.count == 0) 180 | { 181 | _tokensByContext = NULL; 182 | } 183 | } 184 | 185 | - (CKVOToken *)insertNewTokenForKeyPath:(NSString *)inKeyPath block:(KVOFullBlock)inBlock 186 | { 187 | CKVOToken *theToken = [[CKVOToken alloc] initWithKeyPath:inKeyPath index:++self.nextIdentifier block:inBlock]; 188 | if (_tokensByContext == NULL) 189 | { 190 | _tokensByContext = [NSMutableDictionary dictionary]; 191 | } 192 | _tokensByContext[@(theToken.index)] = theToken; 193 | return(theToken); 194 | } 195 | 196 | #pragma mark - 197 | 198 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; 199 | { 200 | NSParameterAssert(context); 201 | 202 | NSNumber *theKey = @((NSInteger)context); 203 | 204 | CKVOToken *theToken= _tokensByContext[theKey]; 205 | if (theToken == NULL) 206 | { 207 | NSLog(@"Warning: Could not find block for key: %@", theKey); 208 | } 209 | else 210 | { 211 | theToken.block(keyPath, object, change); 212 | } 213 | } 214 | 215 | @end 216 | 217 | @implementation CKVOToken 218 | 219 | - (id)initWithKeyPath:(NSString *)inKey index:(NSInteger)inIndex block:(KVOFullBlock)inBlock 220 | { 221 | if ((self = [super init]) != NULL) 222 | { 223 | _keypath = inKey; 224 | _index = inIndex; 225 | _block = inBlock; 226 | } 227 | return self; 228 | } 229 | 230 | - (NSString *)description 231 | { 232 | return([NSString stringWithFormat:@"%@ (%@ #%ld)", [super description], self.keypath, (unsigned long)self.index]); 233 | } 234 | 235 | - (void *)context 236 | { 237 | return((void *)self.index); 238 | } 239 | 240 | @end 241 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/UtilitiesSDK/GSFileUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSFileUtil.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * 文件工具类 13 | */ 14 | @interface GSFileUtil : NSObject 15 | 16 | /** 17 | * 获取文件大小 18 | * 19 | * @param path 文件路径 20 | * 21 | * @return 文件大小 22 | */ 23 | + (unsigned long long)fileSizeForPath:(NSString*)path; 24 | 25 | /** 26 | * 获取指定文件的临时文件存放路径 27 | * 28 | * @param path 文件路径 29 | * @param saveIn 文件保存子路径 30 | * 31 | * @return 临时文件路径 32 | */ 33 | + (NSString*)tempPathFor:(NSString*)path saveIn:(NSString*)saveIn; 34 | 35 | /** 36 | * 获取Documents文件夹内子文件夹的路径 37 | * 38 | * @param subFolder 子文件夹路径 39 | * @param needCeate 如果不存在,是否需要创建 40 | * 41 | * @return 42 | */ 43 | + (NSString*)getPathInDocumentsDirBy:(NSString*)subFolder createIfNotExist:(BOOL)needCeate; 44 | 45 | /** 46 | * 获取Cache文件夹内子文件夹的路径 47 | * 48 | * @param subFolder 子文件夹路径 49 | * @param needCeate 如果不存在,是否需要创建 50 | * 51 | * @return 52 | */ 53 | + (NSString*)getPathInCacheDirBy:(NSString*)subFolder createIfNotExist:(BOOL)needCeate; 54 | 55 | /** 56 | * 判断指定路径下的文件是否存在 57 | * 58 | * @param path 59 | * 60 | * @return 61 | */ 62 | + (BOOL)fileExistsAtPath:(NSString*)path; 63 | 64 | /** 65 | * 删除指定路径下的文件 66 | * 67 | * @param path 68 | * 69 | * @return 70 | */ 71 | + (BOOL)deleteFileAtPath:(NSString*)path; 72 | 73 | /** 74 | * 将指定文件剪切到指定位置 75 | * 76 | * @param srcPath 源文件地址 77 | * @param dstPath 目标文件地址 78 | * 79 | * @return 80 | */ 81 | + (BOOL)cutFileAtPath:(NSString*)srcPath toPath:(NSString*)dstPath; 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/UtilitiesSDK/GSFileUtil.m: -------------------------------------------------------------------------------- 1 | // 2 | // GSFileUtil.m 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "GSFileUtil.h" 10 | 11 | @implementation GSFileUtil 12 | 13 | + (unsigned long long)fileSizeForPath:(NSString*)path 14 | { 15 | unsigned long long fileSize = 0; 16 | 17 | NSFileManager* fileManager = [[NSFileManager alloc] init]; 18 | 19 | if ([fileManager fileExistsAtPath:path]) { 20 | NSError* error = nil; 21 | NSDictionary* fileDict = [fileManager attributesOfItemAtPath:path error:&error]; 22 | if (!error && fileDict) { 23 | fileSize = [fileDict fileSize]; 24 | } 25 | } 26 | 27 | return fileSize; 28 | } 29 | 30 | + (NSString*)tempPathFor:(NSString*)path saveIn:(NSString *)saveIn 31 | { 32 | NSString* tempFilePath = nil; 33 | 34 | NSString* tempFileName = [path lastPathComponent]; 35 | 36 | tempFilePath = [[GSFileUtil getPathInCacheDirBy:saveIn createIfNotExist:YES] stringByAppendingPathComponent:tempFileName]; 37 | 38 | return tempFilePath; 39 | } 40 | 41 | + (NSString*)getPathInDocumentsDirBy:(NSString*)subFolder createIfNotExist:(BOOL)needCeate 42 | { 43 | NSString* subPath; 44 | 45 | NSString* dir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; 46 | subPath = [dir stringByAppendingPathComponent:subFolder]; 47 | 48 | if (![GSFileUtil fileExistsAtPath:subPath]) 49 | { 50 | if (needCeate) 51 | { 52 | NSError* error = nil; 53 | if (![[NSFileManager new] createDirectoryAtPath:subPath withIntermediateDirectories:YES attributes:nil error:&error]) { 54 | NSLog(@"创建%@失败,Error=%@", subFolder,error); 55 | } 56 | } 57 | } 58 | 59 | return subPath; 60 | } 61 | 62 | + (NSString*)getPathInCacheDirBy:(NSString*)subFolder createIfNotExist:(BOOL)needCeate 63 | { 64 | 65 | NSString* subPath; 66 | 67 | NSString* dir = [NSHomeDirectory() stringByAppendingPathComponent:@"Cache"]; 68 | subPath = [dir stringByAppendingPathComponent:subFolder]; 69 | 70 | if (![GSFileUtil fileExistsAtPath:subPath]) 71 | { 72 | 73 | if (needCeate) 74 | { 75 | NSError* error = nil; 76 | if (![[NSFileManager new] createDirectoryAtPath:subPath withIntermediateDirectories:YES attributes:nil error:&error]) { 77 | NSLog(@"创建%@失败,Error=%@", subFolder,error); 78 | } 79 | } 80 | } 81 | 82 | return subPath; 83 | } 84 | 85 | + (BOOL)fileExistsAtPath:(NSString *)path 86 | { 87 | NSFileManager* fileManager = [NSFileManager defaultManager]; 88 | 89 | BOOL isExist = [fileManager fileExistsAtPath:path]; 90 | 91 | // NSLog(@"fileExistsAtPath:%@ = %@",path, (isExist ? @"YES" : @"NO")); 92 | 93 | return isExist; 94 | 95 | } 96 | 97 | + (BOOL)deleteFileAtPath:(NSString *)path 98 | { 99 | NSFileManager* fileManager = [NSFileManager defaultManager]; 100 | NSError* error = nil; 101 | BOOL result = NO; 102 | 103 | if ([GSFileUtil fileExistsAtPath:path]) 104 | { 105 | result = [fileManager removeItemAtPath:path error:&error]; 106 | } 107 | else 108 | { 109 | result = YES; 110 | } 111 | 112 | if (error) 113 | { 114 | // NSLog(@"removeItemAtPath:%@ 失败,error = %@",path,error); 115 | } 116 | else 117 | { 118 | // NSLog(@"removeItemAtPath:%@ 成功,error = %@",path,error); 119 | } 120 | 121 | return result; 122 | } 123 | 124 | + (BOOL) cutFileAtPath:(NSString *)srcPath toPath:(NSString *)dstPath 125 | { 126 | NSFileManager* fileManager = [NSFileManager defaultManager]; 127 | NSError* error = nil; 128 | BOOL result = NO; 129 | 130 | if ([GSFileUtil deleteFileAtPath:dstPath]) 131 | { 132 | 133 | if ([GSFileUtil fileExistsAtPath:srcPath]) 134 | { 135 | result = [fileManager moveItemAtPath:srcPath toPath:dstPath error:&error]; 136 | } 137 | 138 | } 139 | 140 | if (error) 141 | { 142 | // NSLog(@"moveItemAtPath:%@ toPath:%@ 失败,error = %@",srcPath,dstPath,error); 143 | } 144 | else 145 | { 146 | // NSLog(@"moveItemAtPath:%@ toPath:%@ 成功,error = %@",srcPath,dstPath,error); 147 | } 148 | 149 | return result; 150 | } 151 | 152 | @end 153 | -------------------------------------------------------------------------------- /GSDownloaderSDK/GSDownloaderSDK/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/GSDownloaderSDK: -------------------------------------------------------------------------------- 1 | Versions/Current/GSDownloaderSDK -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Headers: -------------------------------------------------------------------------------- 1 | Versions/Current/Headers -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Resources: -------------------------------------------------------------------------------- 1 | Versions/Current/Resources -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/GSDownloaderSDK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/GSDownloaderSDK -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/GSDownloadEvenHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadEvenHandler.h 3 | // GSCoreCommon 4 | // 5 | // Created by Chaoqian Wu on 14-2-26. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #ifndef GSCoreCommon_GSDownloadEvenHandler_h 10 | #define GSCoreCommon_GSDownloadEvenHandler_h 11 | 12 | /** 13 | * 异步下载开始前,执行自定义的事件 14 | * 15 | * @return 16 | */ 17 | typedef void (^GSDownloadBeginEventHandler) (); 18 | 19 | /** 20 | * 异步下载中,执行自定义的事件 21 | * 22 | * @param bytesRead 距离上次执行后又下载了多少字节 23 | * @param totalBytesRead 已经下载了多少字节 24 | * @param totalBytesExpectedToRead 总共需要下载多少字节 25 | * @param bytesPerSecond 实时下载速度(Bytes/s) 26 | * 27 | * @return 28 | */ 29 | typedef void (^GSDownloadingEventHandler) (NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead,double bytesPerSecond); 30 | 31 | /** 32 | * 异步下载结束后,执行自定义的事件 33 | * 34 | * @param error 错误对象(如果成功,error传nil) 35 | * 36 | * @return 37 | */ 38 | typedef void (^GSDownloadedEventHandler) (NSError* error ); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/GSDownloadFileModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadFileModel.h 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-6. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSDownloadFileModel : NSObject 12 | 13 | @property(nonatomic, strong, getter = getDownloadFileName) NSString* downloadFileName; 14 | 15 | @property(nonatomic, strong, getter = getDownloadFileAvatorURL) NSString* downloadFileAvatorURL; 16 | 17 | @property(nonatomic, strong, getter = getDownloadFinishTime) NSString* downloadFinishTime; 18 | 19 | @property(nonatomic, strong, getter = getDownloadFileSize) NSNumber* downloadFileSize; 20 | 21 | @property(nonatomic, strong, getter = getDownloadedFileSize) NSNumber* downloadedFileSize; 22 | 23 | @property(nonatomic, strong, getter = getDownloadFileVersion) NSString* downloadFileVersion; 24 | 25 | @property(nonatomic, strong, getter = getDownloadTaskURL) NSString* downloadTaskURL; 26 | 27 | @property(nonatomic, strong, getter = getDownloadFileSavePath) NSString* downloadFileSavePath; 28 | 29 | @property(nonatomic, strong, getter = getDownloadTempSavePath) NSString* downloadTempSavePath; 30 | 31 | @property(nonatomic, strong, getter = getDownloadFilePlistURL) NSString* downloadFilePlistURL; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/GSDownloadTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadTask.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-11. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "GSSingleDownloadTaskProtocol.h" 11 | #import "GSDownloadFileModel.h" 12 | #import "GSDownloadUIBindProtocol.h" 13 | 14 | /** 15 | * 实现下载任务(依赖GSSingleDownloadTaskProtocol协议) 16 | * 外部使用前,需要指定下载文件模型(实现GSDownloadFileModelProtocol接口)和关联的UI对象(实现GSDownloadUIBindProtocol) 17 | */ 18 | @interface GSDownloadTask : NSObject 19 | 20 | @property (nonatomic,getter = getDownloadStatus) GSDownloadStatus downloadStatus; 21 | 22 | // add by zhenwei 23 | @property (nonatomic) NSUInteger bytesRead; 24 | 25 | @property (nonatomic) long long totalBytesRead; 26 | 27 | @property (nonatomic) long long totalBytesExpectedToRead; 28 | 29 | @property (nonatomic) double bytesPerSecond; 30 | 31 | @property (nonatomic,strong,getter = getDownloadTaskId) NSString* downloadTaskId; 32 | 33 | @property (nonatomic,strong,getter = getDownloadFileModel) GSDownloadFileModel* downloadFileModel; 34 | 35 | @property (nonatomic,strong,getter = getDownloadUIBinder) id downloadUIBinder; 36 | // end 37 | 38 | - (BOOL)isEqualToDownloadTask:(GSDownloadTask*)downloadTask; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/GSDownloadUIBindProtocol.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloadUIBindProtocol.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-10. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol GSSingleDownloadTaskProtocol; 12 | 13 | 14 | /** 15 | * 用于绑定外部UI更新操作的接口 16 | */ 17 | @protocol GSDownloadUIBindProtocol 18 | 19 | @required 20 | 21 | /** 22 | * 根据任务状态改变UI 23 | * 24 | * @param downloadTask 25 | */ 26 | - (void)updateUIWithTask:(id)downloadTask; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/GSDownloaderClient.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloaderClient.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "GSDownloadEvenHandler.h" 11 | #import "GSDownloadTask.h" 12 | 13 | /** 14 | * 下载客户端类 15 | * 16 | */ 17 | @interface GSDownloaderClient : NSObject 18 | 19 | /** 20 | * 获取单例下载客户端 21 | * 22 | * @return 23 | */ 24 | + (GSDownloaderClient*)sharedDownloaderClient; 25 | 26 | /** 27 | * 指定最高下载队列容量数 28 | */ 29 | @property (nonatomic) int maxDownload; 30 | 31 | /** 32 | * 指定最高等待队列容量数 33 | */ 34 | @property (nonatomic) int maxWaiting; 35 | 36 | /** 37 | * 指定最高暂停队列容量数 38 | */ 39 | @property (nonatomic) int maxPaused; 40 | 41 | /** 42 | * 指定最高重试机会 43 | */ 44 | @property (nonatomic) int maxFailureRetryChance; 45 | 46 | /** 47 | * 开始一次下载任务(都统一先放进等待队列) 48 | * 49 | * @param downloadTask 一条下载任务 50 | * @param begin 下载开始前回调 51 | * @param progress 处理下载中回调 52 | * @param complete 完成回调 53 | */ 54 | - (void)downloadDataAsyncWithTask:(GSDownloadTask*)downloadTask 55 | begin:(GSDownloadBeginEventHandler)begin 56 | progress:(GSDownloadingEventHandler)progress 57 | complete:(GSDownloadedEventHandler)complete; 58 | 59 | /** 60 | * 继续一条下载任务 61 | * 62 | * @param downloadTask 指定下载任务 63 | */ 64 | - (void)continueOneDownloadTaskWith:(GSDownloadTask*)downloadTask; 65 | 66 | /** 67 | * 暂停一条下载任务 68 | * 69 | * @param downloadTask 指定下载任务 70 | */ 71 | - (void)pauseOneDownloadTaskWith:(GSDownloadTask*)downloadTask; 72 | 73 | /** 74 | * 取消一条下载任务 75 | * 76 | * @param downloadTask 指定下载任务 77 | */ 78 | - (void)cancelOneDownloadTaskWith:(GSDownloadTask*)downloadTask; 79 | 80 | /** 81 | * 开始全部下载任务 82 | */ 83 | - (void)startAllDownloadTask; 84 | 85 | /** 86 | * 暂停全部下载任务 87 | */ 88 | - (void)pauseAllDownloadTask; 89 | 90 | /** 91 | * 取消全部下载任务 92 | */ 93 | - (void)cancelAllDownloadTask; 94 | 95 | /** 96 | * 测试队列KVO是否有效 97 | */ 98 | - (void)testQueueKVO; 99 | 100 | /** 101 | * 添加下载任务 102 | * 103 | * @param task 104 | */ 105 | -(void)addDownloadTask:(GSDownloadTask*)task; 106 | 107 | /** 108 | * 获取下载任务列表 109 | * 110 | * @return 111 | */ 112 | -(NSArray*)downloadTasks; 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/GSDownloaderSDK.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloaderSDK.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #ifndef GSDownloaderSDK_GSDownloaderSDK_h 10 | #define GSDownloaderSDK_GSDownloaderSDK_h 11 | 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | 20 | //NSObject+KVOBlock 21 | #import 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/GSDownloaderSDKTest.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSDownloaderSDKTest.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GSDownloaderSDKTest : NSObject 12 | 13 | + (void)printTest; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/GSFileUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSFileUtil.h 3 | // GSDownloaderSDK 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * 文件工具类 13 | */ 14 | @interface GSFileUtil : NSObject 15 | 16 | /** 17 | * 获取文件大小 18 | * 19 | * @param path 文件路径 20 | * 21 | * @return 文件大小 22 | */ 23 | + (unsigned long long)fileSizeForPath:(NSString*)path; 24 | 25 | /** 26 | * 获取指定文件的临时文件存放路径 27 | * 28 | * @param path 文件路径 29 | * @param saveIn 文件保存子路径 30 | * 31 | * @return 临时文件路径 32 | */ 33 | + (NSString*)tempPathFor:(NSString*)path saveIn:(NSString*)saveIn; 34 | 35 | /** 36 | * 获取Documents文件夹内子文件夹的路径 37 | * 38 | * @param subFolder 子文件夹路径 39 | * @param needCeate 如果不存在,是否需要创建 40 | * 41 | * @return 42 | */ 43 | + (NSString*)getPathInDocumentsDirBy:(NSString*)subFolder createIfNotExist:(BOOL)needCeate; 44 | 45 | /** 46 | * 获取Cache文件夹内子文件夹的路径 47 | * 48 | * @param subFolder 子文件夹路径 49 | * @param needCeate 如果不存在,是否需要创建 50 | * 51 | * @return 52 | */ 53 | + (NSString*)getPathInCacheDirBy:(NSString*)subFolder createIfNotExist:(BOOL)needCeate; 54 | 55 | /** 56 | * 判断指定路径下的文件是否存在 57 | * 58 | * @param path 59 | * 60 | * @return 61 | */ 62 | + (BOOL)fileExistsAtPath:(NSString*)path; 63 | 64 | /** 65 | * 删除指定路径下的文件 66 | * 67 | * @param path 68 | * 69 | * @return 70 | */ 71 | + (BOOL)deleteFileAtPath:(NSString*)path; 72 | 73 | /** 74 | * 将指定文件剪切到指定位置 75 | * 76 | * @param srcPath 源文件地址 77 | * @param dstPath 目标文件地址 78 | * 79 | * @return 80 | */ 81 | + (BOOL)cutFileAtPath:(NSString*)srcPath toPath:(NSString*)dstPath; 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Headers/NSObject+KVOBlock.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+KVOBlock.h 3 | // TouchCode 4 | // 5 | // Created by Jonathan Wight on 07/24/11. 6 | // Copyright 2011 toxicsoftware.com. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without modification, are 9 | // permitted provided that the following conditions are met: 10 | // 11 | // 1. Redistributions of source code must retain the above copyright notice, this list of 12 | // conditions and the following disclaimer. 13 | // 14 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list 15 | // of conditions and the following disclaimer in the documentation and/or other materials 16 | // provided with the distribution. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY TOXICSOFTWARE.COM ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TOXICSOFTWARE.COM OR 21 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 | // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | // The views and conclusions contained in the software and documentation are those of the 29 | // authors and should not be interpreted as representing official policies, either expressed 30 | // or implied, of toxicsoftware.com. 31 | 32 | #import 33 | 34 | typedef void (^KVOFullBlock)(NSString *keyPath, id object, NSDictionary *change); 35 | 36 | @interface NSObject (NSObject_KVOBlock) 37 | 38 | - (id)addKVOBlockForKeyPath:(NSString *)inKeyPath options:(NSKeyValueObservingOptions)inOptions handler:(KVOFullBlock)inHandler; 39 | - (void)removeKVOBlockForToken:(id)inToken; 40 | 41 | /// One shot blocks remove themselves after they've been fired once. 42 | - (id)addOneShotKVOBlockForKeyPath:(NSString *)inKeyPath options:(NSKeyValueObservingOptions)inOptions handler:(KVOFullBlock)inHandler; 43 | 44 | @end 45 | 46 | -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Resources/Info.plist -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Resources/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/A/Resources/en.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /GSDownloaderSDK/Products/GSDownloaderSDK.framework/Versions/Current: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /GSDownloaderSDK/pre_build.sh: -------------------------------------------------------------------------------- 1 | # Sets the target folders and the final framework product. 2 | 3 | FMK_NAME=GSDownloaderSDK 4 | 5 | FMK_VERSION=A 6 | 7 | 8 | 9 | # Install dir will be the final output to the framework. 10 | 11 | # The following line create it in the root folder of the current project. 12 | 13 | INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework 14 | 15 | # Working dir will be deleted after the framework creation. 16 | 17 | #WRK_DIR=build 18 | 19 | DEVICE_DIR=Release-iphoneos/${FMK_NAME}.framework 20 | 21 | SIMULATOR_DIR=Release-iphonesimulator/${FMK_NAME}.framework 22 | 23 | cd ${PROJECT_DIR} 24 | rm -rf build 25 | 26 | # Building both architectures. 27 | 28 | xcodebuild -sdk iphoneos -configuration "Release" 29 | 30 | xcodebuild -sdk iphonesimulator -configuration "Release" 31 | 32 | 33 | 34 | # Cleaning the oldest. 35 | 36 | if [ -d "${INSTALL_DIR}" ] 37 | 38 | then 39 | 40 | rm -rf "${INSTALL_DIR}" 41 | 42 | fi 43 | 44 | 45 | 46 | # Creates and renews the final product folder. 47 | 48 | mkdir -p "${INSTALL_DIR}" 49 | 50 | mkdir -p "${INSTALL_DIR}/Versions" 51 | 52 | mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}" 53 | 54 | mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources" 55 | 56 | mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers" 57 | 58 | 59 | 60 | # Creates the internal links. 61 | 62 | # It MUST uses relative path, otherwise will not work when the folder is copied/moved. 63 | 64 | ln -s "${FMK_VERSION}" "${INSTALL_DIR}/Versions/Current" 65 | 66 | ln -s "Versions/Current/Headers" "${INSTALL_DIR}/Headers" 67 | 68 | ln -s "Versions/Current/Resources" "${INSTALL_DIR}/Resources" 69 | 70 | ln -s "Versions/Current/${FMK_NAME}" "${INSTALL_DIR}/${FMK_NAME}" 71 | 72 | #into build 73 | cd build 74 | 75 | # Copies the headers and resources files to the final product folder. 76 | 77 | cp -R "${DEVICE_DIR}/Headers/" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers/" 78 | 79 | cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/" 80 | 81 | 82 | 83 | # Removes the binary and header from the resources folder. 84 | 85 | rm -r "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/Headers" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/${FMK_NAME}" 86 | 87 | 88 | 89 | # Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product. 90 | 91 | lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}" 92 | 93 | cd .. 94 | 95 | rm -rf build 96 | 97 | #rm -r "${WRK_DIR}" -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/GSDownloaderSDKDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | cn.4399.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/GSDownloaderSDKDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #import 17 | #import 18 | #import 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/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" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTDAppDelegate.h 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MTDAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTDAppDelegate.m 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "MTDAppDelegate.h" 10 | #import "MTDDownloadTesterViewController.h" 11 | 12 | @implementation MTDAppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | // Override point for customization after application launch. 18 | self.window.backgroundColor = [UIColor whiteColor]; 19 | [self.window makeKeyAndVisible]; 20 | 21 | MTDDownloadTesterViewController* testVC = [[MTDDownloadTesterViewController alloc] init]; 22 | 23 | self.window.rootViewController = testVC; 24 | 25 | return YES; 26 | } 27 | 28 | - (void)applicationWillResignActive:(UIApplication *)application 29 | { 30 | // 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. 31 | // 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. 32 | } 33 | 34 | - (void)applicationDidEnterBackground:(UIApplication *)application 35 | { 36 | // 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. 37 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 38 | } 39 | 40 | - (void)applicationWillEnterForeground:(UIApplication *)application 41 | { 42 | // 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. 43 | } 44 | 45 | - (void)applicationDidBecomeActive:(UIApplication *)application 46 | { 47 | // 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. 48 | } 49 | 50 | - (void)applicationWillTerminate:(UIApplication *)application 51 | { 52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDDownloadFileModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTDDownloadFileModel.h 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-6. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MTDDownloadFileModel : GSDownloadFileModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDDownloadFileModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTDDownloadFileModel.m 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-6. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "MTDDownloadFileModel.h" 10 | 11 | @implementation MTDDownloadFileModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDDownloadTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTDDownloadTableViewCell.h 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-10. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MTDDownloadTableViewCellDelegate.h" 11 | 12 | @protocol GSSingleDownloadTaskProtocol; 13 | 14 | @interface MTDDownloadTableViewCell : UITableViewCell 15 | { 16 | 17 | } 18 | 19 | @property (nonatomic) int index; 20 | 21 | @property (nonatomic,assign) id delegate; 22 | 23 | @property (nonatomic,strong) UIButton* downloadButton; 24 | 25 | @property (nonatomic,strong) UILabel* downloadRateLabel; 26 | 27 | @property (nonatomic,strong) UILabel* downloadPercentLabel; 28 | 29 | @property (nonatomic,strong) UIProgressView* downloadProgress; 30 | 31 | - (void)customCellByDownloadTask:(GSDownloadTask*)task; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDDownloadTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTDDownloadTableViewCell.m 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-10. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "MTDDownloadTableViewCell.h" 10 | 11 | @implementation MTDDownloadTableViewCell 12 | 13 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 14 | { 15 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 16 | if (self) { 17 | // Initialization code 18 | 19 | [self commonInit]; 20 | 21 | } 22 | return self; 23 | } 24 | 25 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated 26 | { 27 | [super setSelected:selected animated:animated]; 28 | 29 | // Configure the view for the selected state 30 | } 31 | 32 | - (void)commonInit 33 | { 34 | 35 | self.selectionStyle = UITableViewCellSelectionStyleNone; 36 | self.contentView.backgroundColor = [UIColor cyanColor]; 37 | 38 | _downloadButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 39 | _downloadButton.backgroundColor = [UIColor greenColor]; 40 | [_downloadButton setTitle:@"开始下载" forState:UIControlStateNormal]; 41 | [_downloadButton addTarget:self action:@selector(downloadAction) forControlEvents:UIControlEventTouchUpInside]; 42 | [self.contentView addSubview:_downloadButton]; 43 | 44 | _downloadProgress = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; 45 | _downloadProgress.backgroundColor = [UIColor orangeColor]; 46 | [self.contentView addSubview:_downloadProgress]; 47 | 48 | _downloadRateLabel = [[UILabel alloc] init]; 49 | _downloadRateLabel.textAlignment = NSTextAlignmentLeft; 50 | _downloadRateLabel.backgroundColor = [UIColor yellowColor]; 51 | [self.contentView addSubview:_downloadRateLabel]; 52 | 53 | _downloadPercentLabel = [[UILabel alloc] init]; 54 | _downloadPercentLabel.textAlignment = NSTextAlignmentRight; 55 | _downloadPercentLabel.backgroundColor = [UIColor yellowColor]; 56 | [self.contentView addSubview:_downloadPercentLabel]; 57 | 58 | } 59 | 60 | - (void)layoutSubviews 61 | { 62 | [super layoutSubviews]; 63 | 64 | CGRect frame = self.frame; 65 | 66 | int buttonY = 10; 67 | int buttonWith = 70; 68 | int buttonHeight = frame.size.height - 2*buttonY; 69 | int buttonX = frame.size.width - 10 - buttonWith; 70 | _downloadButton.frame = CGRectMake(buttonX, buttonY, buttonWith, buttonHeight); 71 | 72 | int progressX = 10; 73 | int progressHeight = 20; 74 | int progressY = (frame.size.height - progressHeight) / 2; 75 | int progressWidth = buttonX - 2*progressX; 76 | _downloadProgress.frame = CGRectMake(progressX, progressY, progressWidth, progressHeight); 77 | 78 | int alabelX = progressX; 79 | int alabelY = _downloadProgress.frame.origin.y + 10; 80 | int alabelHeight = frame.size.height - alabelY - 10; 81 | int alabelWidth = _downloadProgress.frame.size.width / 2; 82 | _downloadRateLabel.frame = CGRectMake(alabelX, alabelY, alabelWidth, alabelHeight); 83 | 84 | int blabelX = alabelX + alabelWidth; 85 | int blabelY = alabelY; 86 | int blabelWidth = alabelWidth; 87 | int blabelHeight = alabelHeight; 88 | _downloadPercentLabel.frame = CGRectMake(blabelX, blabelY, blabelWidth, blabelHeight); 89 | 90 | } 91 | 92 | - (void)downloadAction 93 | { 94 | [self.delegate downloadActionAtIndex:self.index]; 95 | } 96 | 97 | - (void)customCellByDownloadTask:(GSDownloadTask*)task 98 | { 99 | switch (task.downloadStatus) { 100 | case GSDownloadStatusTaskNotCreated: 101 | [_downloadButton setTitle:@"开始下载" forState:UIControlStateNormal]; 102 | self.downloadRateLabel.text = nil; 103 | self.downloadPercentLabel.text = nil; 104 | self.downloadProgress.progress = 0.0f; 105 | break; 106 | case GSDownloadStatusWaitingForStart: 107 | [_downloadButton setTitle:@"等待中" forState:UIControlStateNormal]; 108 | break; 109 | 110 | case GSDownloadStatusDownloading: 111 | [_downloadButton setTitle:@"下载中" forState:UIControlStateNormal]; 112 | break; 113 | 114 | case GSDownloadStatusPaused: 115 | [_downloadButton setTitle:@"继续下载" forState:UIControlStateNormal]; 116 | break; 117 | 118 | case GSDownloadStatusWaitingForResume: 119 | [_downloadButton setTitle:@"等待中" forState:UIControlStateNormal]; 120 | break; 121 | 122 | case GSDownloadStatusCanceled: 123 | [_downloadButton setTitle:@"取消了" forState:UIControlStateNormal]; 124 | break; 125 | 126 | case GSDownloadStatusSuccess: 127 | [_downloadButton setTitle:@"成功了" forState:UIControlStateNormal]; 128 | self.downloadPercentLabel.backgroundColor = [UIColor greenColor]; 129 | break; 130 | 131 | case GSDownloadStatusFailure: 132 | [_downloadButton setTitle:@"失败了" forState:UIControlStateNormal]; 133 | self.downloadPercentLabel.backgroundColor = [UIColor redColor]; 134 | break; 135 | 136 | default: 137 | [_downloadButton setTitle:@"等待中" forState:UIControlStateNormal]; 138 | break; 139 | } 140 | [self updateUIWhenDownloadProgressChanged:task.bytesRead totalBytesRead:task.totalBytesRead totalBytesExpectedToRead:task.totalBytesExpectedToRead bytesPerSecond:task.bytesPerSecond]; 141 | } 142 | 143 | - (void)updateUIWhenDownloadProgressChanged:(NSUInteger)bytesRead 144 | totalBytesRead:(long long)totalBytesRead 145 | totalBytesExpectedToRead:(long long)totalBytesExpectedToRead 146 | bytesPerSecond:(double)bytesPerSecond 147 | { 148 | NSString* downloadProgress = [NSString stringWithFormat:@"%0.2f",(float)totalBytesRead/(float)totalBytesExpectedToRead]; 149 | float downloadProgressFloat = [downloadProgress floatValue]; 150 | 151 | self.downloadProgress.progress = downloadProgressFloat; 152 | if (totalBytesExpectedToRead > 0.0) { 153 | self.downloadPercentLabel.text = [[NSString alloc] initWithFormat:@"%0.2f%%",(float)totalBytesRead/(float)totalBytesExpectedToRead*100]; 154 | self.downloadRateLabel.text = [[NSString alloc] initWithFormat:@"%0.0fK/s",(float)bytesPerSecond/1000]; 155 | } 156 | else{ 157 | self.downloadPercentLabel.text = nil; 158 | self.downloadRateLabel.text = nil; 159 | } 160 | } 161 | 162 | 163 | @end 164 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDDownloadTableViewCellDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTDDownloadTableViewCellDelegate.h 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-10. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol MTDDownloadTableViewCellDelegate 12 | 13 | @required 14 | 15 | - (void)downloadActionAtIndex:(int)index; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDDownloadTesterViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MTDDownloadTesterViewController.h 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MTDDownloadTableViewCellDelegate.h" 11 | 12 | @interface MTDDownloadTesterViewController : UIViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/MTDDownloadTesterViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MTDDownloadTesterViewController.m 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import "MTDDownloadTesterViewController.h" 10 | #import "MTDDownloadFileModel.h" 11 | #import "MTDDownloadTableViewCell.h" 12 | 13 | @interface MTDDownloadTesterViewController () 14 | { 15 | UIButton* _startDownloadBtn; 16 | 17 | UIButton* _pauseDownloadBtn; 18 | 19 | UIButton* _continueDownloadBtn; 20 | 21 | UIButton* _cancelBtn; 22 | 23 | GSDownloaderClient* _client; 24 | 25 | int _downdloadCount; 26 | 27 | //任务表格视图 28 | UITableView* _downloadTaskTableView; 29 | } 30 | 31 | @end 32 | 33 | @implementation MTDDownloadTesterViewController 34 | 35 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 36 | { 37 | self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 38 | if (self) { 39 | // Custom initialization 40 | 41 | _startDownloadBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 42 | _startDownloadBtn.backgroundColor = [UIColor yellowColor]; 43 | [_startDownloadBtn setTitle:@"添加下载" forState:UIControlStateNormal]; 44 | [_startDownloadBtn addTarget:self action:@selector(addDownload) forControlEvents:UIControlEventTouchUpInside]; 45 | 46 | _pauseDownloadBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 47 | _pauseDownloadBtn.backgroundColor = [UIColor yellowColor]; 48 | [_pauseDownloadBtn setTitle:@"全部暂停" forState:UIControlStateNormal]; 49 | [_pauseDownloadBtn addTarget:self action:@selector(pauseAllDownload) forControlEvents:UIControlEventTouchUpInside]; 50 | 51 | _continueDownloadBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 52 | _continueDownloadBtn.backgroundColor = [UIColor yellowColor]; 53 | [_continueDownloadBtn setTitle:@"全部开始" forState:UIControlStateNormal]; 54 | [_continueDownloadBtn addTarget:self action:@selector(continueAllDownload) forControlEvents:UIControlEventTouchUpInside]; 55 | 56 | _cancelBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 57 | _cancelBtn.backgroundColor = [UIColor yellowColor]; 58 | [_cancelBtn setTitle:@"全部取消" forState:UIControlStateNormal]; 59 | [_cancelBtn addTarget:self action:@selector(cancelAllDownload) forControlEvents:UIControlEventTouchUpInside]; 60 | 61 | _downloadTaskTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; 62 | _downloadTaskTableView.delegate = self; 63 | _downloadTaskTableView.dataSource = self; 64 | _downloadTaskTableView.separatorStyle = UITableViewCellSeparatorStyleNone; 65 | 66 | _client = [GSDownloaderClient sharedDownloaderClient]; 67 | _client.maxDownload = 6; 68 | _client.maxWaiting = NSIntegerMax; 69 | _client.maxPaused = NSIntegerMax; 70 | _client.maxFailureRetryChance = 10; 71 | 72 | _downdloadCount = 0; 73 | 74 | } 75 | return self; 76 | } 77 | 78 | - (void)viewDidLoad 79 | { 80 | [super viewDidLoad]; 81 | // Do any additional setup after loading the view. 82 | 83 | _startDownloadBtn.frame = CGRectMake(10, 30, 70, 40); 84 | [self.view addSubview:_startDownloadBtn]; 85 | 86 | _pauseDownloadBtn.frame = CGRectMake(_startDownloadBtn.frame.origin.x + _startDownloadBtn.frame.size.width + 10, 87 | _startDownloadBtn.frame.origin.y, 88 | _startDownloadBtn.frame.size.width, 89 | _startDownloadBtn.frame.size.height); 90 | [self.view addSubview:_pauseDownloadBtn]; 91 | 92 | _continueDownloadBtn.frame = CGRectMake(_pauseDownloadBtn.frame.origin.x + _pauseDownloadBtn.frame.size.width + 10, 93 | _pauseDownloadBtn.frame.origin.y, 94 | _pauseDownloadBtn.frame.size.width, 95 | _pauseDownloadBtn.frame.size.height); 96 | [self.view addSubview:_continueDownloadBtn]; 97 | 98 | 99 | _cancelBtn.frame = CGRectMake(_continueDownloadBtn.frame.origin.x + _continueDownloadBtn.frame.size.width + 10, 100 | _continueDownloadBtn.frame.origin.y, 101 | _continueDownloadBtn.frame.size.width, 102 | _continueDownloadBtn.frame.size.height); 103 | [self.view addSubview:_cancelBtn]; 104 | 105 | _downloadTaskTableView.frame = CGRectMake(0, 80, self.view.frame.size.width, self.view.frame.size.height - 80); 106 | [self.view addSubview:_downloadTaskTableView]; 107 | 108 | 109 | } 110 | 111 | - (void)didReceiveMemoryWarning 112 | { 113 | [super didReceiveMemoryWarning]; 114 | // Dispose of any resources that can be recreated. 115 | } 116 | 117 | - (void)addDownload 118 | { 119 | NSLog(@"添加下载..."); 120 | 121 | _downdloadCount++; 122 | 123 | NSString* fromUrl = @"http://sj.img4399.com/game_list/com.tencent.pao/tencent.pao.v32077.apk"; 124 | 125 | NSString* tmpFileName = [NSString stringWithFormat:@"tencent.pao.v32077-%d.tmp",_downdloadCount]; 126 | NSString* saveFileName= [NSString stringWithFormat:@"tencent.pao.v32077-%d.ipa",_downdloadCount]; 127 | 128 | NSString* savePath = [GSFileUtil getPathInDocumentsDirBy:@"Downloads/Games" createIfNotExist:YES]; 129 | NSString* saveFile = [savePath stringByAppendingPathComponent:saveFileName]; 130 | 131 | NSLog(@"成功下载路径为:%@",savePath); 132 | NSLog(@"成功文件为:%@",saveFile); 133 | 134 | NSString* tempPath = [GSFileUtil getPathInDocumentsDirBy:@"Downloads/Tmp" createIfNotExist:YES]; 135 | NSString* tempFile = [tempPath stringByAppendingPathComponent:tmpFileName]; 136 | 137 | NSLog(@"临时下载路径为:%@",tempPath); 138 | NSLog(@"临时文件为:%@",tempFile); 139 | 140 | MTDDownloadFileModel* downloadFileModel = [[MTDDownloadFileModel alloc] init]; 141 | [downloadFileModel setDownloadFileName:@"全民酷跑"]; 142 | [downloadFileModel setDownloadFileAvatorURL:@"http://f1.img4399.com/mi~136383~124x124?1392195212"]; 143 | [downloadFileModel setDownloadTaskURL:fromUrl]; 144 | [downloadFileModel setDownloadFileSavePath:saveFile]; 145 | [downloadFileModel setDownloadTempSavePath:tempFile]; 146 | [downloadFileModel setDownloadFileVersion:@"2.0"]; 147 | [downloadFileModel setDownloadFilePlistURL:@""]; 148 | 149 | GSDownloadTask* downloadTask = [[GSDownloadTask alloc] init]; 150 | [downloadTask setDownloadTaskId:[NSString stringWithFormat:@"%d", _downdloadCount]]; 151 | [downloadTask setDownloadFileModel:downloadFileModel]; 152 | [downloadTask setDownloadUIBinder:self]; 153 | 154 | [_client addDownloadTask:downloadTask]; 155 | 156 | //[self startDownloadWithTask:downloadTask]; 157 | 158 | [_downloadTaskTableView reloadData]; 159 | 160 | [self startDownloadWithTask:downloadTask]; 161 | } 162 | 163 | - (void)pauseAllDownload 164 | { 165 | NSLog(@"暂停下载..."); 166 | 167 | [_client pauseAllDownloadTask]; 168 | } 169 | 170 | - (void)continueAllDownload 171 | { 172 | NSLog(@"继续下载..."); 173 | 174 | [_client startAllDownloadTask]; 175 | } 176 | 177 | - (void)cancelAllDownload 178 | { 179 | NSLog(@"取消下载..."); 180 | 181 | [_client cancelAllDownloadTask]; 182 | } 183 | 184 | - (void)doTester 185 | { 186 | NSLog(@"执行测试..."); 187 | 188 | [_client testQueueKVO]; 189 | } 190 | 191 | - (void)startDownloadWithTask:(GSDownloadTask*)downloadTask 192 | { 193 | 194 | [_client downloadDataAsyncWithTask:downloadTask 195 | begin:^{ 196 | NSLog(@"准备开始下载..."); 197 | } 198 | progress:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead, double bytesPerSecond) { 199 | downloadTask.bytesRead = bytesRead; 200 | downloadTask.totalBytesRead = totalBytesRead; 201 | downloadTask.totalBytesExpectedToRead = totalBytesExpectedToRead; 202 | downloadTask.bytesPerSecond = bytesPerSecond; 203 | [self updateUIWithTask:downloadTask]; 204 | } 205 | complete:^(NSError *error) { 206 | 207 | if (error) 208 | { 209 | NSLog(@"下载失败,%@",error); 210 | downloadTask.downloadStatus = GSDownloadStatusFailure; 211 | [self updateUIWithTask:downloadTask]; 212 | } 213 | else 214 | { 215 | NSLog(@"下载成功"); 216 | downloadTask.downloadStatus = GSDownloadStatusSuccess; 217 | [self updateUIWithTask:downloadTask]; 218 | } 219 | 220 | }]; 221 | } 222 | 223 | - (void)pauseDownloadWithTask:(GSDownloadTask*)downloadTask 224 | { 225 | [_client pauseOneDownloadTaskWith:downloadTask]; 226 | } 227 | 228 | - (void)continueDownloadWithTask:(GSDownloadTask*)downloadTask 229 | { 230 | [_client continueOneDownloadTaskWith:downloadTask]; 231 | } 232 | 233 | #pragma mark - MTDDownloadTableViewCellDelegate 234 | - (void)downloadActionAtIndex:(int)index 235 | { 236 | GSDownloadTask* downloadTask = [[_client downloadTasks] objectAtIndex:index]; 237 | 238 | switch ([downloadTask getDownloadStatus]) { 239 | case GSDownloadStatusTaskNotCreated: 240 | [self startDownloadWithTask:downloadTask]; 241 | break; 242 | 243 | case GSDownloadStatusDownloading: 244 | [self pauseDownloadWithTask:downloadTask]; 245 | break; 246 | 247 | case GSDownloadStatusPaused: 248 | [self continueDownloadWithTask:downloadTask]; 249 | break; 250 | default: 251 | break; 252 | } 253 | 254 | } 255 | 256 | 257 | 258 | #pragma mark - UITableViewDelegate 259 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 260 | { 261 | return 60; 262 | } 263 | 264 | 265 | #pragma mark - UITableViewDataSource 266 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 267 | { 268 | return [_client downloadTasks].count; 269 | } 270 | 271 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 272 | { 273 | 274 | static NSString* identifier = @"DownloadTaskTableViewCell"; 275 | 276 | MTDDownloadTableViewCell* cell = (MTDDownloadTableViewCell*)[tableView dequeueReusableCellWithIdentifier:identifier]; 277 | 278 | if (cell == nil) 279 | { 280 | cell = [[MTDDownloadTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; 281 | } 282 | 283 | cell.index = indexPath.row; 284 | cell.delegate = self; 285 | 286 | GSDownloadTask* task = [[_client downloadTasks]objectAtIndex:indexPath.row]; 287 | [cell customCellByDownloadTask:task]; 288 | 289 | return cell; 290 | 291 | } 292 | 293 | #pragma mark - GSDownloadUIBindProtocol 294 | - (void)updateUIWithTask:(id)downloadTask 295 | { 296 | NSMutableArray* indexPaths = [[NSMutableArray alloc] init]; 297 | for (int i = 0; i < [_client downloadTasks].count; i++) { 298 | GSDownloadTask* task = [_client downloadTasks][i]; 299 | if ([task isEqualToDownloadTask:downloadTask]) { 300 | NSIndexPath* indexPath = [NSIndexPath indexPathForRow:i inSection:0]; 301 | 302 | [indexPaths addObject:indexPath]; 303 | }; 304 | } 305 | 306 | [_downloadTaskTableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone]; 307 | } 308 | 309 | @end 310 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /GSDownloaderSDKDemo/GSDownloaderSDKDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // GSDownloaderSDKDemo 4 | // 5 | // Created by Chaoqian Wu on 14-3-5. 6 | // Copyright (c) 2014年 4399 Network CO.ltd. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "MTDAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([MTDAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /GSDownloaderSDKWorkspace.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GSDownloaderSDK 2 | =============== 3 | 4 | 基于AFNetworking 1.x封装的一个下载SDK,对外提供任务下载、暂停、恢复、取消及相关批量操作。详细使用可以参考Demo代码。 5 | 6 |

7 | GSDownloaderSDK 8 |

9 | 10 | 11 | 适用平台: 12 | -------------------- 13 | 考虑到通用性,底层没有使用最新只适用于iOS7的AFNetworking 2.x,而是最高版本的AFNetworking 1.x。适用平台:iOS5.0+ 14 | 15 | 如何编译SDK: 16 | -------------------- 17 | 1:open workspace with xcode 18 | 19 | 2:edit GSDownloaderSDK scheme 20 | 21 | 3:copy below script into Build/Pre-actions.(note:must select Provide build settings from:GSDownloaderSDK) 22 | 23 | # Sets the target folders and the final framework product. 24 | 25 | FMK_NAME=GSDownloaderSDK 26 | 27 | FMK_VERSION=A 28 | 29 | 30 | 31 | # Install dir will be the final output to the framework. 32 | 33 | # The following line create it in the root folder of the current project. 34 | 35 | INSTALL_DIR=${SRCROOT}/Products/${FMK_NAME}.framework 36 | 37 | # Working dir will be deleted after the framework creation. 38 | 39 | #WRK_DIR=build 40 | 41 | DEVICE_DIR=Release-iphoneos/${FMK_NAME}.framework 42 | 43 | SIMULATOR_DIR=Release-iphonesimulator/${FMK_NAME}.framework 44 | 45 | cd ${PROJECT_DIR} 46 | rm -rf build 47 | 48 | # Building both architectures. 49 | 50 | xcodebuild -sdk iphoneos -configuration "Release" 51 | 52 | xcodebuild -sdk iphonesimulator -configuration "Release" 53 | 54 | 55 | 56 | # Cleaning the oldest. 57 | 58 | if [ -d "${INSTALL_DIR}" ] 59 | 60 | then 61 | 62 | rm -rf "${INSTALL_DIR}" 63 | 64 | fi 65 | 66 | 67 | 68 | # Creates and renews the final product folder. 69 | 70 | mkdir -p "${INSTALL_DIR}" 71 | 72 | mkdir -p "${INSTALL_DIR}/Versions" 73 | 74 | mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}" 75 | 76 | mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources" 77 | 78 | mkdir -p "${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers" 79 | 80 | 81 | 82 | # Creates the internal links. 83 | 84 | # It MUST uses relative path, otherwise will not work when the folder is copied/moved. 85 | 86 | ln -s "${FMK_VERSION}" "${INSTALL_DIR}/Versions/Current" 87 | 88 | ln -s "Versions/Current/Headers" "${INSTALL_DIR}/Headers" 89 | 90 | ln -s "Versions/Current/Resources" "${INSTALL_DIR}/Resources" 91 | 92 | ln -s "Versions/Current/${FMK_NAME}" "${INSTALL_DIR}/${FMK_NAME}" 93 | 94 | #into build 95 | cd build 96 | 97 | # Copies the headers and resources files to the final product folder. 98 | 99 | cp -R "${DEVICE_DIR}/Headers/" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Headers/" 100 | 101 | cp -R "${DEVICE_DIR}/" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/" 102 | 103 | 104 | 105 | # Removes the binary and header from the resources folder. 106 | 107 | rm -r "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/Headers" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/${FMK_NAME}" 108 | 109 | 110 | 111 | # Uses the Lipo Tool to merge both binary files (i386 + armv6/armv7) into one Universal final product. 112 | 113 | lipo -create "${DEVICE_DIR}/${FMK_NAME}" "${SIMULATOR_DIR}/${FMK_NAME}" -output "${INSTALL_DIR}/Versions/${FMK_VERSION}/${FMK_NAME}" 114 | 115 | cd .. 116 | 117 | rm -rf build 118 | 119 | #rm -r "${WRK_DIR}" 120 | 121 | 4:select GSDownloaderSDK scheme,and cmd+B. 122 | 123 | GSDownloaderSDK.framework will create into GSDownloaderSDK/Products 124 | 125 | 如何编译Demo: 126 | -------------------- 127 | 由于GSDownloaderSDK工程内,依赖了我自己封装的另外两个framework(GSUtiliesSDK.framework和GSCoreThirdParty.framework),用于我自己的项目。我把这两个framework放在SDK工程下的Frameworks目录下。Demo工程直接引用SDK工程下的framework文件。所以导致Demo工程下的Framework Search路径无法写成相对路径的形式(或者是我不知道怎么写) 128 | 所以第一次编译Demo工程前,先需要将对应Frameworks下的GSUtiliesSDK.framework和GSCoreThirdParty.framework重新引用一遍即可。 129 | 130 | 将要做的事: 131 | -------------------- 132 | 取消framework的形式(做成framewok只是为自身项目提供封装),将Demo和SDK统一为一份工程文件。 -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqiansunboy/GSDownloaderSDK/9c21b16efa66daa1fffe8d2f63b3c9d073ad4f70/Screenshot.png --------------------------------------------------------------------------------