├── .DS_Store ├── .eslintrc ├── README.md ├── client ├── .DS_Store ├── Podfile ├── Podfile.lock ├── Pods │ ├── AFNetworking │ │ ├── AFNetworking │ │ │ ├── AFHTTPRequestOperation.h │ │ │ ├── AFHTTPRequestOperation.m │ │ │ ├── AFHTTPRequestOperationManager.h │ │ │ ├── AFHTTPRequestOperationManager.m │ │ │ ├── AFHTTPSessionManager.h │ │ │ ├── AFHTTPSessionManager.m │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ ├── AFNetworkReachabilityManager.m │ │ │ ├── AFNetworking.h │ │ │ ├── AFSecurityPolicy.h │ │ │ ├── AFSecurityPolicy.m │ │ │ ├── AFURLConnectionOperation.h │ │ │ ├── AFURLConnectionOperation.m │ │ │ ├── AFURLRequestSerialization.h │ │ │ ├── AFURLRequestSerialization.m │ │ │ ├── AFURLResponseSerialization.h │ │ │ ├── AFURLResponseSerialization.m │ │ │ ├── AFURLSessionManager.h │ │ │ └── AFURLSessionManager.m │ │ ├── LICENSE │ │ ├── README.md │ │ └── UIKit+AFNetworking │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ ├── AFNetworkActivityIndicatorManager.m │ │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ │ ├── UIActivityIndicatorView+AFNetworking.m │ │ │ ├── UIAlertView+AFNetworking.h │ │ │ ├── UIAlertView+AFNetworking.m │ │ │ ├── UIButton+AFNetworking.h │ │ │ ├── UIButton+AFNetworking.m │ │ │ ├── UIImageView+AFNetworking.h │ │ │ ├── UIImageView+AFNetworking.m │ │ │ ├── UIKit+AFNetworking.h │ │ │ ├── UIProgressView+AFNetworking.h │ │ │ ├── UIProgressView+AFNetworking.m │ │ │ ├── UIRefreshControl+AFNetworking.h │ │ │ ├── UIRefreshControl+AFNetworking.m │ │ │ ├── UIWebView+AFNetworking.h │ │ │ └── UIWebView+AFNetworking.m │ ├── Headers │ │ ├── Build │ │ │ └── AFNetworking │ │ │ │ ├── AFHTTPRequestOperation.h │ │ │ │ ├── AFHTTPRequestOperationManager.h │ │ │ │ ├── AFHTTPSessionManager.h │ │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ │ ├── AFNetworking.h │ │ │ │ ├── AFSecurityPolicy.h │ │ │ │ ├── AFURLConnectionOperation.h │ │ │ │ ├── AFURLRequestSerialization.h │ │ │ │ ├── AFURLResponseSerialization.h │ │ │ │ ├── AFURLSessionManager.h │ │ │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ │ │ ├── UIAlertView+AFNetworking.h │ │ │ │ ├── UIButton+AFNetworking.h │ │ │ │ ├── UIImageView+AFNetworking.h │ │ │ │ ├── UIKit+AFNetworking.h │ │ │ │ ├── UIProgressView+AFNetworking.h │ │ │ │ ├── UIRefreshControl+AFNetworking.h │ │ │ │ └── UIWebView+AFNetworking.h │ │ └── Public │ │ │ └── AFNetworking │ │ │ ├── AFHTTPRequestOperation.h │ │ │ ├── AFHTTPRequestOperationManager.h │ │ │ ├── AFHTTPSessionManager.h │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ ├── AFNetworking.h │ │ │ ├── AFSecurityPolicy.h │ │ │ ├── AFURLConnectionOperation.h │ │ │ ├── AFURLRequestSerialization.h │ │ │ ├── AFURLResponseSerialization.h │ │ │ ├── AFURLSessionManager.h │ │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ │ ├── UIAlertView+AFNetworking.h │ │ │ ├── UIButton+AFNetworking.h │ │ │ ├── UIImageView+AFNetworking.h │ │ │ ├── UIKit+AFNetworking.h │ │ │ ├── UIProgressView+AFNetworking.h │ │ │ ├── UIRefreshControl+AFNetworking.h │ │ │ └── UIWebView+AFNetworking.h │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ ├── project.pbxproj │ │ └── xcuserdata │ │ │ └── kristjanmik.xcuserdatad │ │ │ └── xcschemes │ │ │ ├── Pods-s3streamer-AFNetworking.xcscheme │ │ │ ├── Pods-s3streamer.xcscheme │ │ │ └── xcschememanagement.plist │ └── Target Support Files │ │ ├── Pods-s3streamer-AFNetworking │ │ ├── Pods-s3streamer-AFNetworking-Private.xcconfig │ │ ├── Pods-s3streamer-AFNetworking-dummy.m │ │ ├── Pods-s3streamer-AFNetworking-prefix.pch │ │ └── Pods-s3streamer-AFNetworking.xcconfig │ │ └── Pods-s3streamer │ │ ├── Pods-s3streamer-acknowledgements.markdown │ │ ├── Pods-s3streamer-acknowledgements.plist │ │ ├── Pods-s3streamer-dummy.m │ │ ├── Pods-s3streamer-environment.h │ │ ├── Pods-s3streamer-resources.sh │ │ ├── Pods-s3streamer.debug.xcconfig │ │ └── Pods-s3streamer.release.xcconfig ├── README.md ├── s3streamer.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── kristjanmik.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── kristjanmik.xcuserdatad │ │ └── xcschemes │ │ ├── s3streamer.xcscheme │ │ └── xcschememanagement.plist ├── s3streamer.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── kristjanmik.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── s3streamer │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── image.png │ └── main.m └── s3streamerTests │ ├── Info.plist │ └── s3streamerTests.m └── server ├── .gitignore ├── README.md ├── index.js └── package.json /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kristjanmik/ios-nodejs-s3-streamer/bf9e3faf082b039f068c904430f476b4b96b77e5/.DS_Store -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "node": true 4 | }, 5 | "rules": { 6 | "block-scoped-var": 2, 7 | "brace-style": [2, "1tbs"], 8 | "camelcase": 1, 9 | "curly": 2, 10 | "eol-last": 2, 11 | "eqeqeq": [2, "smart"], 12 | "max-depth": [1, 3], 13 | "max-statements": [1, 15], 14 | "max-len": [1, 80], 15 | "new-cap": 1, 16 | "no-extend-native": 2, 17 | "no-mixed-spaces-and-tabs": 2, 18 | "no-trailing-spaces": 2, 19 | "no-use-before-define": [2, "nofunc"], 20 | "no-unused-vars": 1, 21 | "quotes": [2, "single", "avoid-escape"], 22 | "semi": [2, "always"], 23 | "space-after-keywords": [2, "always"], 24 | "space-in-brackets": [2, "never"], 25 | "space-unary-word-ops": 2 26 | } 27 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ios-nodejs-s3-streamer 2 | 3 | ## Usage 4 | 5 | Streaming files from an iOS device to a server can be hard and therefore this repo. Seperate readme files are located in client and server folder 6 | -------------------------------------------------------------------------------- /client/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kristjanmik/ios-nodejs-s3-streamer/bf9e3faf082b039f068c904430f476b4b96b77e5/client/.DS_Store -------------------------------------------------------------------------------- /client/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '6.0' 3 | 4 | target 's3streamer' do 5 | 6 | pod "AFNetworking", "~> 2.0" 7 | 8 | end 9 | 10 | target 's3streamerTests' do 11 | 12 | end 13 | 14 | -------------------------------------------------------------------------------- /client/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.5.3): 3 | - AFNetworking/NSURLConnection (= 2.5.3) 4 | - AFNetworking/NSURLSession (= 2.5.3) 5 | - AFNetworking/Reachability (= 2.5.3) 6 | - AFNetworking/Security (= 2.5.3) 7 | - AFNetworking/Serialization (= 2.5.3) 8 | - AFNetworking/UIKit (= 2.5.3) 9 | - AFNetworking/NSURLConnection (2.5.3): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.5.3): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.5.3) 18 | - AFNetworking/Security (2.5.3) 19 | - AFNetworking/Serialization (2.5.3) 20 | - AFNetworking/UIKit (2.5.3): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | 24 | DEPENDENCIES: 25 | - AFNetworking (~> 2.0) 26 | 27 | SPEC CHECKSUMS: 28 | AFNetworking: e1d86c2a96bb5d2e7408da36149806706ee122fe 29 | 30 | COCOAPODS: 0.35.0 31 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 | Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. 42 | 43 | @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value 44 | */ 45 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 46 | 47 | /** 48 | An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error. 49 | */ 50 | @property (readonly, nonatomic, strong) id responseObject; 51 | 52 | ///----------------------------------------------------------- 53 | /// @name Setting Completion Block Success / Failure Callbacks 54 | ///----------------------------------------------------------- 55 | 56 | /** 57 | 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. 58 | 59 | This method should be overridden in subclasses in order to specify the response object passed into the success block. 60 | 61 | @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. 62 | @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. 63 | */ 64 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 65 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "AFHTTPRequestOperation.h" 24 | 25 | static dispatch_queue_t http_request_operation_processing_queue() { 26 | static dispatch_queue_t af_http_request_operation_processing_queue; 27 | static dispatch_once_t onceToken; 28 | dispatch_once(&onceToken, ^{ 29 | af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT); 30 | }); 31 | 32 | return af_http_request_operation_processing_queue; 33 | } 34 | 35 | static dispatch_group_t http_request_operation_completion_group() { 36 | static dispatch_group_t af_http_request_operation_completion_group; 37 | static dispatch_once_t onceToken; 38 | dispatch_once(&onceToken, ^{ 39 | af_http_request_operation_completion_group = dispatch_group_create(); 40 | }); 41 | 42 | return af_http_request_operation_completion_group; 43 | } 44 | 45 | #pragma mark - 46 | 47 | @interface AFURLConnectionOperation () 48 | @property (readwrite, nonatomic, strong) NSURLRequest *request; 49 | @property (readwrite, nonatomic, strong) NSURLResponse *response; 50 | @end 51 | 52 | @interface AFHTTPRequestOperation () 53 | @property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; 54 | @property (readwrite, nonatomic, strong) id responseObject; 55 | @property (readwrite, nonatomic, strong) NSError *responseSerializationError; 56 | @property (readwrite, nonatomic, strong) NSRecursiveLock *lock; 57 | @end 58 | 59 | @implementation AFHTTPRequestOperation 60 | @dynamic response; 61 | @dynamic lock; 62 | 63 | - (instancetype)initWithRequest:(NSURLRequest *)urlRequest { 64 | self = [super initWithRequest:urlRequest]; 65 | if (!self) { 66 | return nil; 67 | } 68 | 69 | self.responseSerializer = [AFHTTPResponseSerializer serializer]; 70 | 71 | return self; 72 | } 73 | 74 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 75 | NSParameterAssert(responseSerializer); 76 | 77 | [self.lock lock]; 78 | _responseSerializer = responseSerializer; 79 | self.responseObject = nil; 80 | self.responseSerializationError = nil; 81 | [self.lock unlock]; 82 | } 83 | 84 | - (id)responseObject { 85 | [self.lock lock]; 86 | if (!_responseObject && [self isFinished] && !self.error) { 87 | NSError *error = nil; 88 | self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error]; 89 | if (error) { 90 | self.responseSerializationError = error; 91 | } 92 | } 93 | [self.lock unlock]; 94 | 95 | return _responseObject; 96 | } 97 | 98 | - (NSError *)error { 99 | if (_responseSerializationError) { 100 | return _responseSerializationError; 101 | } else { 102 | return [super error]; 103 | } 104 | } 105 | 106 | #pragma mark - AFHTTPRequestOperation 107 | 108 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 109 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 110 | { 111 | // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. 112 | #pragma clang diagnostic push 113 | #pragma clang diagnostic ignored "-Warc-retain-cycles" 114 | #pragma clang diagnostic ignored "-Wgnu" 115 | self.completionBlock = ^{ 116 | if (self.completionGroup) { 117 | dispatch_group_enter(self.completionGroup); 118 | } 119 | 120 | dispatch_async(http_request_operation_processing_queue(), ^{ 121 | if (self.error) { 122 | if (failure) { 123 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ 124 | failure(self, self.error); 125 | }); 126 | } 127 | } else { 128 | id responseObject = self.responseObject; 129 | if (self.error) { 130 | if (failure) { 131 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ 132 | failure(self, self.error); 133 | }); 134 | } 135 | } else { 136 | if (success) { 137 | dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ 138 | success(self, responseObject); 139 | }); 140 | } 141 | } 142 | } 143 | 144 | if (self.completionGroup) { 145 | dispatch_group_leave(self.completionGroup); 146 | } 147 | }); 148 | }; 149 | #pragma clang diagnostic pop 150 | } 151 | 152 | #pragma mark - AFURLRequestOperation 153 | 154 | - (void)pause { 155 | [super pause]; 156 | 157 | u_int64_t offset = 0; 158 | if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { 159 | offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; 160 | } else { 161 | offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; 162 | } 163 | 164 | NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; 165 | if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { 166 | [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; 167 | } 168 | [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; 169 | self.request = mutableURLRequest; 170 | } 171 | 172 | #pragma mark - NSSecureCoding 173 | 174 | + (BOOL)supportsSecureCoding { 175 | return YES; 176 | } 177 | 178 | - (id)initWithCoder:(NSCoder *)decoder { 179 | self = [super initWithCoder:decoder]; 180 | if (!self) { 181 | return nil; 182 | } 183 | 184 | self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; 185 | 186 | return self; 187 | } 188 | 189 | - (void)encodeWithCoder:(NSCoder *)coder { 190 | [super encodeWithCoder:coder]; 191 | 192 | [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; 193 | } 194 | 195 | #pragma mark - NSCopying 196 | 197 | - (id)copyWithZone:(NSZone *)zone { 198 | AFHTTPRequestOperation *operation = [super copyWithZone:zone]; 199 | 200 | operation.responseSerializer = [self.responseSerializer copyWithZone:zone]; 201 | operation.completionQueue = self.completionQueue; 202 | operation.completionGroup = self.completionGroup; 203 | 204 | return operation; 205 | } 206 | 207 | @end 208 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperationManager.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "AFHTTPRequestOperationManager.h" 26 | #import "AFHTTPRequestOperation.h" 27 | 28 | #import 29 | #import 30 | 31 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 32 | #import 33 | #endif 34 | 35 | @interface AFHTTPRequestOperationManager () 36 | @property (readwrite, nonatomic, strong) NSURL *baseURL; 37 | @end 38 | 39 | @implementation AFHTTPRequestOperationManager 40 | 41 | + (instancetype)manager { 42 | return [[self alloc] initWithBaseURL:nil]; 43 | } 44 | 45 | - (instancetype)init { 46 | return [self initWithBaseURL:nil]; 47 | } 48 | 49 | - (instancetype)initWithBaseURL:(NSURL *)url { 50 | self = [super init]; 51 | if (!self) { 52 | return nil; 53 | } 54 | 55 | // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected 56 | if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { 57 | url = [url URLByAppendingPathComponent:@""]; 58 | } 59 | 60 | self.baseURL = url; 61 | 62 | self.requestSerializer = [AFHTTPRequestSerializer serializer]; 63 | self.responseSerializer = [AFJSONResponseSerializer serializer]; 64 | 65 | self.securityPolicy = [AFSecurityPolicy defaultPolicy]; 66 | 67 | self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; 68 | 69 | self.operationQueue = [[NSOperationQueue alloc] init]; 70 | 71 | self.shouldUseCredentialStorage = YES; 72 | 73 | return self; 74 | } 75 | 76 | #pragma mark - 77 | 78 | #ifdef _SYSTEMCONFIGURATION_H 79 | #endif 80 | 81 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { 82 | NSParameterAssert(requestSerializer); 83 | 84 | _requestSerializer = requestSerializer; 85 | } 86 | 87 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 88 | NSParameterAssert(responseSerializer); 89 | 90 | _responseSerializer = responseSerializer; 91 | } 92 | 93 | #pragma mark - 94 | 95 | - (AFHTTPRequestOperation *)HTTPRequestOperationWithHTTPMethod:(NSString *)method 96 | URLString:(NSString *)URLString 97 | parameters:(id)parameters 98 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 99 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 100 | { 101 | NSError *serializationError = nil; 102 | NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; 103 | if (serializationError) { 104 | if (failure) { 105 | #pragma clang diagnostic push 106 | #pragma clang diagnostic ignored "-Wgnu" 107 | dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ 108 | failure(nil, serializationError); 109 | }); 110 | #pragma clang diagnostic pop 111 | } 112 | 113 | return nil; 114 | } 115 | 116 | return [self HTTPRequestOperationWithRequest:request success:success failure:failure]; 117 | } 118 | 119 | - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request 120 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 121 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 122 | { 123 | AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 124 | operation.responseSerializer = self.responseSerializer; 125 | operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; 126 | operation.credential = self.credential; 127 | operation.securityPolicy = self.securityPolicy; 128 | 129 | [operation setCompletionBlockWithSuccess:success failure:failure]; 130 | operation.completionQueue = self.completionQueue; 131 | operation.completionGroup = self.completionGroup; 132 | 133 | return operation; 134 | } 135 | 136 | #pragma mark - 137 | 138 | - (AFHTTPRequestOperation *)GET:(NSString *)URLString 139 | parameters:(id)parameters 140 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 141 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 142 | { 143 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; 144 | 145 | [self.operationQueue addOperation:operation]; 146 | 147 | return operation; 148 | } 149 | 150 | - (AFHTTPRequestOperation *)HEAD:(NSString *)URLString 151 | parameters:(id)parameters 152 | success:(void (^)(AFHTTPRequestOperation *operation))success 153 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 154 | { 155 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) { 156 | if (success) { 157 | success(requestOperation); 158 | } 159 | } failure:failure]; 160 | 161 | [self.operationQueue addOperation:operation]; 162 | 163 | return operation; 164 | } 165 | 166 | - (AFHTTPRequestOperation *)POST:(NSString *)URLString 167 | parameters:(id)parameters 168 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 169 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 170 | { 171 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; 172 | 173 | [self.operationQueue addOperation:operation]; 174 | 175 | return operation; 176 | } 177 | 178 | - (AFHTTPRequestOperation *)POST:(NSString *)URLString 179 | parameters:(id)parameters 180 | constructingBodyWithBlock:(void (^)(id formData))block 181 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 182 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 183 | { 184 | NSError *serializationError = nil; 185 | NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; 186 | if (serializationError) { 187 | if (failure) { 188 | #pragma clang diagnostic push 189 | #pragma clang diagnostic ignored "-Wgnu" 190 | dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ 191 | failure(nil, serializationError); 192 | }); 193 | #pragma clang diagnostic pop 194 | } 195 | 196 | return nil; 197 | } 198 | 199 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; 200 | 201 | [self.operationQueue addOperation:operation]; 202 | 203 | return operation; 204 | } 205 | 206 | - (AFHTTPRequestOperation *)PUT:(NSString *)URLString 207 | parameters:(id)parameters 208 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 209 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 210 | { 211 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; 212 | 213 | [self.operationQueue addOperation:operation]; 214 | 215 | return operation; 216 | } 217 | 218 | - (AFHTTPRequestOperation *)PATCH:(NSString *)URLString 219 | parameters:(id)parameters 220 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 221 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 222 | { 223 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; 224 | 225 | [self.operationQueue addOperation:operation]; 226 | 227 | return operation; 228 | } 229 | 230 | - (AFHTTPRequestOperation *)DELETE:(NSString *)URLString 231 | parameters:(id)parameters 232 | success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 233 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure 234 | { 235 | AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; 236 | 237 | [self.operationQueue addOperation:operation]; 238 | 239 | return operation; 240 | } 241 | 242 | #pragma mark - NSObject 243 | 244 | - (NSString *)description { 245 | return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.operationQueue]; 246 | } 247 | 248 | #pragma mark - NSSecureCoding 249 | 250 | + (BOOL)supportsSecureCoding { 251 | return YES; 252 | } 253 | 254 | - (id)initWithCoder:(NSCoder *)decoder { 255 | NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))]; 256 | 257 | self = [self initWithBaseURL:baseURL]; 258 | if (!self) { 259 | return nil; 260 | } 261 | 262 | self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; 263 | self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; 264 | 265 | return self; 266 | } 267 | 268 | - (void)encodeWithCoder:(NSCoder *)coder { 269 | [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; 270 | [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; 271 | [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; 272 | } 273 | 274 | #pragma mark - NSCopying 275 | 276 | - (id)copyWithZone:(NSZone *)zone { 277 | AFHTTPRequestOperationManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; 278 | 279 | HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; 280 | HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; 281 | 282 | return HTTPClient; 283 | } 284 | 285 | @end 286 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 NS_DESIGNATED_INITIALIZER 27 | #if __has_attribute(objc_designated_initializer) 28 | #define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) 29 | #else 30 | #define NS_DESIGNATED_INITIALIZER 31 | #endif 32 | #endif 33 | 34 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { 35 | AFNetworkReachabilityStatusUnknown = -1, 36 | AFNetworkReachabilityStatusNotReachable = 0, 37 | AFNetworkReachabilityStatusReachableViaWWAN = 1, 38 | AFNetworkReachabilityStatusReachableViaWiFi = 2, 39 | }; 40 | 41 | /** 42 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. 43 | 44 | Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. 45 | 46 | See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/) 47 | 48 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. 49 | */ 50 | @interface AFNetworkReachabilityManager : NSObject 51 | 52 | /** 53 | The current network reachability status. 54 | */ 55 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 56 | 57 | /** 58 | Whether or not the network is currently reachable. 59 | */ 60 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; 61 | 62 | /** 63 | Whether or not the network is currently reachable via WWAN. 64 | */ 65 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; 66 | 67 | /** 68 | Whether or not the network is currently reachable via WiFi. 69 | */ 70 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; 71 | 72 | ///--------------------- 73 | /// @name Initialization 74 | ///--------------------- 75 | 76 | /** 77 | Returns the shared network reachability manager. 78 | */ 79 | + (instancetype)sharedManager; 80 | 81 | /** 82 | Creates and returns a network reachability manager for the specified domain. 83 | 84 | @param domain The domain used to evaluate network reachability. 85 | 86 | @return An initialized network reachability manager, actively monitoring the specified domain. 87 | */ 88 | + (instancetype)managerForDomain:(NSString *)domain; 89 | 90 | /** 91 | Creates and returns a network reachability manager for the socket address. 92 | 93 | @param address The socket address (`sockaddr_in`) used to evaluate network reachability. 94 | 95 | @return An initialized network reachability manager, actively monitoring the specified socket address. 96 | */ 97 | + (instancetype)managerForAddress:(const void *)address; 98 | 99 | /** 100 | Initializes an instance of a network reachability manager from the specified reachability object. 101 | 102 | @param reachability The reachability object to monitor. 103 | 104 | @return An initialized network reachability manager, actively monitoring the specified reachability. 105 | */ 106 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; 107 | 108 | ///-------------------------------------------------- 109 | /// @name Starting & Stopping Reachability Monitoring 110 | ///-------------------------------------------------- 111 | 112 | /** 113 | Starts monitoring for changes in network reachability status. 114 | */ 115 | - (void)startMonitoring; 116 | 117 | /** 118 | Stops monitoring for changes in network reachability status. 119 | */ 120 | - (void)stopMonitoring; 121 | 122 | ///------------------------------------------------- 123 | /// @name Getting Localized Reachability Description 124 | ///------------------------------------------------- 125 | 126 | /** 127 | Returns a localized string representation of the current network reachability status. 128 | */ 129 | - (NSString *)localizedNetworkReachabilityStatusString; 130 | 131 | ///--------------------------------------------------- 132 | /// @name Setting Network Reachability Change Callback 133 | ///--------------------------------------------------- 134 | 135 | /** 136 | Sets a callback to be executed when the network availability of the `baseURL` host changes. 137 | 138 | @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. 139 | */ 140 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block; 141 | 142 | @end 143 | 144 | ///---------------- 145 | /// @name Constants 146 | ///---------------- 147 | 148 | /** 149 | ## Network Reachability 150 | 151 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. 152 | 153 | enum { 154 | AFNetworkReachabilityStatusUnknown, 155 | AFNetworkReachabilityStatusNotReachable, 156 | AFNetworkReachabilityStatusReachableViaWWAN, 157 | AFNetworkReachabilityStatusReachableViaWiFi, 158 | } 159 | 160 | `AFNetworkReachabilityStatusUnknown` 161 | The `baseURL` host reachability is not known. 162 | 163 | `AFNetworkReachabilityStatusNotReachable` 164 | The `baseURL` host cannot be reached. 165 | 166 | `AFNetworkReachabilityStatusReachableViaWWAN` 167 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. 168 | 169 | `AFNetworkReachabilityStatusReachableViaWiFi` 170 | The `baseURL` host can be reached via a Wi-Fi connection. 171 | 172 | ### Keys for Notification UserInfo Dictionary 173 | 174 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. 175 | 176 | `AFNetworkingReachabilityNotificationStatusItem` 177 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. 178 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. 179 | */ 180 | 181 | ///-------------------- 182 | /// @name Notifications 183 | ///-------------------- 184 | 185 | /** 186 | Posted when network reachability changes. 187 | This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. 188 | 189 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). 190 | */ 191 | extern NSString * const AFNetworkingReachabilityDidChangeNotification; 192 | extern NSString * const AFNetworkingReachabilityNotificationStatusItem; 193 | 194 | ///-------------------- 195 | /// @name Functions 196 | ///-------------------- 197 | 198 | /** 199 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value. 200 | */ 201 | extern NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); 202 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "AFNetworkReachabilityManager.h" 24 | 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | 31 | NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; 32 | NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; 33 | 34 | typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); 35 | 36 | typedef NS_ENUM(NSUInteger, AFNetworkReachabilityAssociation) { 37 | AFNetworkReachabilityForAddress = 1, 38 | AFNetworkReachabilityForAddressPair = 2, 39 | AFNetworkReachabilityForName = 3, 40 | }; 41 | 42 | NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { 43 | switch (status) { 44 | case AFNetworkReachabilityStatusNotReachable: 45 | return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); 46 | case AFNetworkReachabilityStatusReachableViaWWAN: 47 | return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); 48 | case AFNetworkReachabilityStatusReachableViaWiFi: 49 | return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); 50 | case AFNetworkReachabilityStatusUnknown: 51 | default: 52 | return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); 53 | } 54 | } 55 | 56 | static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { 57 | BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); 58 | BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); 59 | BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); 60 | BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); 61 | BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); 62 | 63 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; 64 | if (isNetworkReachable == NO) { 65 | status = AFNetworkReachabilityStatusNotReachable; 66 | } 67 | #if TARGET_OS_IPHONE 68 | else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { 69 | status = AFNetworkReachabilityStatusReachableViaWWAN; 70 | } 71 | #endif 72 | else { 73 | status = AFNetworkReachabilityStatusReachableViaWiFi; 74 | } 75 | 76 | return status; 77 | } 78 | 79 | static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { 80 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); 81 | AFNetworkReachabilityStatusBlock block = (__bridge AFNetworkReachabilityStatusBlock)info; 82 | if (block) { 83 | block(status); 84 | } 85 | 86 | 87 | dispatch_async(dispatch_get_main_queue(), ^{ 88 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 89 | NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; 90 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; 91 | }); 92 | 93 | } 94 | 95 | static const void * AFNetworkReachabilityRetainCallback(const void *info) { 96 | return Block_copy(info); 97 | } 98 | 99 | static void AFNetworkReachabilityReleaseCallback(const void *info) { 100 | if (info) { 101 | Block_release(info); 102 | } 103 | } 104 | 105 | @interface AFNetworkReachabilityManager () 106 | @property (readwrite, nonatomic, assign) SCNetworkReachabilityRef networkReachability; 107 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityAssociation networkReachabilityAssociation; 108 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 109 | @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; 110 | @end 111 | 112 | @implementation AFNetworkReachabilityManager 113 | 114 | + (instancetype)sharedManager { 115 | static AFNetworkReachabilityManager *_sharedManager = nil; 116 | static dispatch_once_t onceToken; 117 | dispatch_once(&onceToken, ^{ 118 | struct sockaddr_in address; 119 | bzero(&address, sizeof(address)); 120 | address.sin_len = sizeof(address); 121 | address.sin_family = AF_INET; 122 | 123 | _sharedManager = [self managerForAddress:&address]; 124 | }); 125 | 126 | return _sharedManager; 127 | } 128 | 129 | + (instancetype)managerForDomain:(NSString *)domain { 130 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); 131 | 132 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 133 | manager.networkReachabilityAssociation = AFNetworkReachabilityForName; 134 | 135 | return manager; 136 | } 137 | 138 | + (instancetype)managerForAddress:(const void *)address { 139 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); 140 | 141 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 142 | manager.networkReachabilityAssociation = AFNetworkReachabilityForAddress; 143 | 144 | return manager; 145 | } 146 | 147 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { 148 | self = [super init]; 149 | if (!self) { 150 | return nil; 151 | } 152 | 153 | self.networkReachability = reachability; 154 | self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; 155 | 156 | return self; 157 | } 158 | 159 | - (void)dealloc { 160 | [self stopMonitoring]; 161 | 162 | if (_networkReachability) { 163 | CFRelease(_networkReachability); 164 | _networkReachability = NULL; 165 | } 166 | } 167 | 168 | #pragma mark - 169 | 170 | - (BOOL)isReachable { 171 | return [self isReachableViaWWAN] || [self isReachableViaWiFi]; 172 | } 173 | 174 | - (BOOL)isReachableViaWWAN { 175 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; 176 | } 177 | 178 | - (BOOL)isReachableViaWiFi { 179 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; 180 | } 181 | 182 | #pragma mark - 183 | 184 | - (void)startMonitoring { 185 | [self stopMonitoring]; 186 | 187 | if (!self.networkReachability) { 188 | return; 189 | } 190 | 191 | __weak __typeof(self)weakSelf = self; 192 | AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { 193 | __strong __typeof(weakSelf)strongSelf = weakSelf; 194 | 195 | strongSelf.networkReachabilityStatus = status; 196 | if (strongSelf.networkReachabilityStatusBlock) { 197 | strongSelf.networkReachabilityStatusBlock(status); 198 | } 199 | 200 | }; 201 | 202 | SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; 203 | SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); 204 | SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 205 | 206 | switch (self.networkReachabilityAssociation) { 207 | case AFNetworkReachabilityForName: 208 | break; 209 | case AFNetworkReachabilityForAddress: 210 | case AFNetworkReachabilityForAddressPair: 211 | default: { 212 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ 213 | SCNetworkReachabilityFlags flags; 214 | SCNetworkReachabilityGetFlags(self.networkReachability, &flags); 215 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); 216 | dispatch_async(dispatch_get_main_queue(), ^{ 217 | callback(status); 218 | 219 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 220 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }]; 221 | 222 | 223 | }); 224 | }); 225 | } 226 | break; 227 | } 228 | } 229 | 230 | - (void)stopMonitoring { 231 | if (!self.networkReachability) { 232 | return; 233 | } 234 | 235 | SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 236 | } 237 | 238 | #pragma mark - 239 | 240 | - (NSString *)localizedNetworkReachabilityStatusString { 241 | return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); 242 | } 243 | 244 | #pragma mark - 245 | 246 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { 247 | self.networkReachabilityStatusBlock = block; 248 | } 249 | 250 | #pragma mark - NSKeyValueObserving 251 | 252 | + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { 253 | if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { 254 | return [NSSet setWithObject:@"networkReachabilityStatus"]; 255 | } 256 | 257 | return [super keyPathsForValuesAffectingValueForKey:key]; 258 | } 259 | 260 | @end 261 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.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 "AFURLRequestSerialization.h" 30 | #import "AFURLResponseSerialization.h" 31 | #import "AFSecurityPolicy.h" 32 | #import "AFNetworkReachabilityManager.h" 33 | 34 | #import "AFURLConnectionOperation.h" 35 | #import "AFHTTPRequestOperation.h" 36 | #import "AFHTTPRequestOperationManager.h" 37 | 38 | #if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ 39 | ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) ) 40 | #import "AFURLSessionManager.h" 41 | #import "AFHTTPSessionManager.h" 42 | #endif 43 | 44 | #endif /* _AFNETWORKING_ */ 45 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { 27 | AFSSLPinningModeNone, 28 | AFSSLPinningModePublicKey, 29 | AFSSLPinningModeCertificate, 30 | }; 31 | 32 | /** 33 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 34 | 35 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. 36 | */ 37 | @interface AFSecurityPolicy : NSObject 38 | 39 | /** 40 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. 41 | */ 42 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 43 | 44 | /** 45 | Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to `YES`. 46 | */ 47 | @property (nonatomic, assign) BOOL validatesCertificateChain; 48 | 49 | /** 50 | The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. 51 | */ 52 | @property (nonatomic, strong) NSArray *pinnedCertificates; 53 | 54 | /** 55 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 56 | */ 57 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 58 | 59 | /** 60 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. 61 | */ 62 | @property (nonatomic, assign) BOOL validatesDomainName; 63 | 64 | ///----------------------------------------- 65 | /// @name Getting Specific Security Policies 66 | ///----------------------------------------- 67 | 68 | /** 69 | Returns the shared default security policy, which does not allow invalid certificates, does not validate domain name, and does not validate against pinned certificates or public keys. 70 | 71 | @return The default security policy. 72 | */ 73 | + (instancetype)defaultPolicy; 74 | 75 | ///--------------------- 76 | /// @name Initialization 77 | ///--------------------- 78 | 79 | /** 80 | Creates and returns a security policy with the specified pinning mode. 81 | 82 | @param pinningMode The SSL pinning mode. 83 | 84 | @return A new security policy. 85 | */ 86 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 87 | 88 | ///------------------------------ 89 | /// @name Evaluating Server Trust 90 | ///------------------------------ 91 | 92 | /** 93 | Whether or not the specified server trust should be accepted, based on the security policy. 94 | 95 | This method should be used when responding to an authentication challenge from a server. 96 | 97 | @param serverTrust The X.509 certificate trust of the server. 98 | 99 | @return Whether or not to trust the server. 100 | 101 | @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. 102 | */ 103 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; 104 | 105 | /** 106 | Whether or not the specified server trust should be accepted, based on the security policy. 107 | 108 | This method should be used when responding to an authentication challenge from a server. 109 | 110 | @param serverTrust The X.509 certificate trust of the server. 111 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 112 | 113 | @return Whether or not to trust the server. 114 | */ 115 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 116 | forDomain:(NSString *)domain; 117 | 118 | @end 119 | 120 | ///---------------- 121 | /// @name Constants 122 | ///---------------- 123 | 124 | /** 125 | ## SSL Pinning Modes 126 | 127 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 128 | 129 | enum { 130 | AFSSLPinningModeNone, 131 | AFSSLPinningModePublicKey, 132 | AFSSLPinningModeCertificate, 133 | } 134 | 135 | `AFSSLPinningModeNone` 136 | Do not used pinned certificates to validate servers. 137 | 138 | `AFSSLPinningModePublicKey` 139 | Validate host certificates against public keys of pinned certificates. 140 | 141 | `AFSSLPinningModeCertificate` 142 | Validate host certificates against pinned certificates. 143 | */ 144 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "AFSecurityPolicy.h" 24 | 25 | #import 26 | 27 | #if !defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | static NSData * AFSecKeyGetData(SecKeyRef key) { 29 | CFDataRef data = NULL; 30 | 31 | __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); 32 | 33 | return (__bridge_transfer NSData *)data; 34 | 35 | _out: 36 | if (data) { 37 | CFRelease(data); 38 | } 39 | 40 | return nil; 41 | } 42 | #endif 43 | 44 | static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { 45 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 46 | return [(__bridge id)key1 isEqual:(__bridge id)key2]; 47 | #else 48 | return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; 49 | #endif 50 | } 51 | 52 | static id AFPublicKeyForCertificate(NSData *certificate) { 53 | id allowedPublicKey = nil; 54 | SecCertificateRef allowedCertificate; 55 | SecCertificateRef allowedCertificates[1]; 56 | CFArrayRef tempCertificates = nil; 57 | SecPolicyRef policy = nil; 58 | SecTrustRef allowedTrust = nil; 59 | SecTrustResultType result; 60 | 61 | allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); 62 | __Require_Quiet(allowedCertificate != NULL, _out); 63 | 64 | allowedCertificates[0] = allowedCertificate; 65 | tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); 66 | 67 | policy = SecPolicyCreateBasicX509(); 68 | __Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); 69 | __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); 70 | 71 | allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); 72 | 73 | _out: 74 | if (allowedTrust) { 75 | CFRelease(allowedTrust); 76 | } 77 | 78 | if (policy) { 79 | CFRelease(policy); 80 | } 81 | 82 | if (tempCertificates) { 83 | CFRelease(tempCertificates); 84 | } 85 | 86 | if (allowedCertificate) { 87 | CFRelease(allowedCertificate); 88 | } 89 | 90 | return allowedPublicKey; 91 | } 92 | 93 | static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { 94 | BOOL isValid = NO; 95 | SecTrustResultType result; 96 | __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); 97 | 98 | isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); 99 | 100 | _out: 101 | return isValid; 102 | } 103 | 104 | static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { 105 | CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); 106 | NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; 107 | 108 | for (CFIndex i = 0; i < certificateCount; i++) { 109 | SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); 110 | [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; 111 | } 112 | 113 | return [NSArray arrayWithArray:trustChain]; 114 | } 115 | 116 | static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { 117 | SecPolicyRef policy = SecPolicyCreateBasicX509(); 118 | CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); 119 | NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; 120 | for (CFIndex i = 0; i < certificateCount; i++) { 121 | SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); 122 | 123 | SecCertificateRef someCertificates[] = {certificate}; 124 | CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); 125 | 126 | SecTrustRef trust; 127 | __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); 128 | 129 | SecTrustResultType result; 130 | __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); 131 | 132 | [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; 133 | 134 | _out: 135 | if (trust) { 136 | CFRelease(trust); 137 | } 138 | 139 | if (certificates) { 140 | CFRelease(certificates); 141 | } 142 | 143 | continue; 144 | } 145 | CFRelease(policy); 146 | 147 | return [NSArray arrayWithArray:trustChain]; 148 | } 149 | 150 | #pragma mark - 151 | 152 | @interface AFSecurityPolicy() 153 | @property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 154 | @property (readwrite, nonatomic, strong) NSArray *pinnedPublicKeys; 155 | @end 156 | 157 | @implementation AFSecurityPolicy 158 | 159 | + (NSArray *)defaultPinnedCertificates { 160 | static NSArray *_defaultPinnedCertificates = nil; 161 | static dispatch_once_t onceToken; 162 | dispatch_once(&onceToken, ^{ 163 | NSBundle *bundle = [NSBundle bundleForClass:[self class]]; 164 | NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; 165 | 166 | NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; 167 | for (NSString *path in paths) { 168 | NSData *certificateData = [NSData dataWithContentsOfFile:path]; 169 | [certificates addObject:certificateData]; 170 | } 171 | 172 | _defaultPinnedCertificates = [[NSArray alloc] initWithArray:certificates]; 173 | }); 174 | 175 | return _defaultPinnedCertificates; 176 | } 177 | 178 | + (instancetype)defaultPolicy { 179 | AFSecurityPolicy *securityPolicy = [[self alloc] init]; 180 | securityPolicy.SSLPinningMode = AFSSLPinningModeNone; 181 | 182 | return securityPolicy; 183 | } 184 | 185 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { 186 | AFSecurityPolicy *securityPolicy = [[self alloc] init]; 187 | securityPolicy.SSLPinningMode = pinningMode; 188 | 189 | [securityPolicy setPinnedCertificates:[self defaultPinnedCertificates]]; 190 | 191 | return securityPolicy; 192 | } 193 | 194 | - (id)init { 195 | self = [super init]; 196 | if (!self) { 197 | return nil; 198 | } 199 | 200 | self.validatesCertificateChain = YES; 201 | self.validatesDomainName = YES; 202 | 203 | return self; 204 | } 205 | 206 | - (void)setPinnedCertificates:(NSArray *)pinnedCertificates { 207 | _pinnedCertificates = pinnedCertificates; 208 | 209 | if (self.pinnedCertificates) { 210 | NSMutableArray *mutablePinnedPublicKeys = [NSMutableArray arrayWithCapacity:[self.pinnedCertificates count]]; 211 | for (NSData *certificate in self.pinnedCertificates) { 212 | id publicKey = AFPublicKeyForCertificate(certificate); 213 | if (!publicKey) { 214 | continue; 215 | } 216 | [mutablePinnedPublicKeys addObject:publicKey]; 217 | } 218 | self.pinnedPublicKeys = [NSArray arrayWithArray:mutablePinnedPublicKeys]; 219 | } else { 220 | self.pinnedPublicKeys = nil; 221 | } 222 | } 223 | 224 | #pragma mark - 225 | 226 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust { 227 | return [self evaluateServerTrust:serverTrust forDomain:nil]; 228 | } 229 | 230 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 231 | forDomain:(NSString *)domain 232 | { 233 | NSMutableArray *policies = [NSMutableArray array]; 234 | if (self.validatesDomainName) { 235 | [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; 236 | } else { 237 | [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; 238 | } 239 | 240 | SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); 241 | 242 | if (self.SSLPinningMode == AFSSLPinningModeNone) { 243 | if (self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust)){ 244 | return YES; 245 | } else { 246 | return NO; 247 | } 248 | } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { 249 | return NO; 250 | } 251 | 252 | NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); 253 | switch (self.SSLPinningMode) { 254 | case AFSSLPinningModeNone: 255 | default: 256 | return NO; 257 | case AFSSLPinningModeCertificate: { 258 | NSMutableArray *pinnedCertificates = [NSMutableArray array]; 259 | for (NSData *certificateData in self.pinnedCertificates) { 260 | [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; 261 | } 262 | SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); 263 | 264 | if (!AFServerTrustIsValid(serverTrust)) { 265 | return NO; 266 | } 267 | 268 | if (!self.validatesCertificateChain) { 269 | return YES; 270 | } 271 | 272 | NSUInteger trustedCertificateCount = 0; 273 | for (NSData *trustChainCertificate in serverCertificates) { 274 | if ([self.pinnedCertificates containsObject:trustChainCertificate]) { 275 | trustedCertificateCount++; 276 | } 277 | } 278 | 279 | return trustedCertificateCount == [serverCertificates count]; 280 | } 281 | case AFSSLPinningModePublicKey: { 282 | NSUInteger trustedPublicKeyCount = 0; 283 | NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); 284 | if (!self.validatesCertificateChain && [publicKeys count] > 0) { 285 | publicKeys = @[[publicKeys firstObject]]; 286 | } 287 | 288 | for (id trustChainPublicKey in publicKeys) { 289 | for (id pinnedPublicKey in self.pinnedPublicKeys) { 290 | if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { 291 | trustedPublicKeyCount += 1; 292 | } 293 | } 294 | } 295 | 296 | return trustedPublicKeyCount > 0 && ((self.validatesCertificateChain && trustedPublicKeyCount == [serverCertificates count]) || (!self.validatesCertificateChain && trustedPublicKeyCount >= 1)); 297 | } 298 | } 299 | 300 | return NO; 301 | } 302 | 303 | #pragma mark - NSKeyValueObserving 304 | 305 | + (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { 306 | return [NSSet setWithObject:@"pinnedCertificates"]; 307 | } 308 | 309 | @end 310 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 | 29 | #import 30 | 31 | /** 32 | `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. 33 | 34 | 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: 35 | 36 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 37 | 38 | By setting `enabled` 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. 39 | 40 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 41 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 42 | */ 43 | @interface AFNetworkActivityIndicatorManager : NSObject 44 | 45 | /** 46 | A Boolean value indicating whether the manager is enabled. 47 | 48 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 49 | */ 50 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 51 | 52 | /** 53 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. 54 | */ 55 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; 56 | 57 | /** 58 | Returns the shared network activity indicator manager object for the system. 59 | 60 | @return The systemwide network activity indicator manager. 61 | */ 62 | + (instancetype)sharedManager; 63 | 64 | /** 65 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 66 | */ 67 | - (void)incrementActivityCount; 68 | 69 | /** 70 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 71 | */ 72 | - (void)decrementActivityCount; 73 | 74 | @end 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "AFNetworkActivityIndicatorManager.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; 34 | 35 | static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { 36 | if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) { 37 | return [(AFURLConnectionOperation *)[notification object] request]; 38 | } 39 | 40 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 41 | if ([[notification object] respondsToSelector:@selector(originalRequest)]) { 42 | return [(NSURLSessionTask *)[notification object] originalRequest]; 43 | } 44 | #endif 45 | 46 | return nil; 47 | } 48 | 49 | @interface AFNetworkActivityIndicatorManager () 50 | @property (readwrite, nonatomic, assign) NSInteger activityCount; 51 | @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; 52 | @property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 53 | 54 | - (void)updateNetworkActivityIndicatorVisibility; 55 | - (void)updateNetworkActivityIndicatorVisibilityDelayed; 56 | @end 57 | 58 | @implementation AFNetworkActivityIndicatorManager 59 | @dynamic networkActivityIndicatorVisible; 60 | 61 | + (instancetype)sharedManager { 62 | static AFNetworkActivityIndicatorManager *_sharedManager = nil; 63 | static dispatch_once_t oncePredicate; 64 | dispatch_once(&oncePredicate, ^{ 65 | _sharedManager = [[self alloc] init]; 66 | }); 67 | 68 | return _sharedManager; 69 | } 70 | 71 | + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { 72 | return [NSSet setWithObject:@"activityCount"]; 73 | } 74 | 75 | - (id)init { 76 | self = [super init]; 77 | if (!self) { 78 | return nil; 79 | } 80 | 81 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; 82 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; 83 | 84 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 85 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; 86 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; 87 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; 88 | #endif 89 | 90 | return self; 91 | } 92 | 93 | - (void)dealloc { 94 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 95 | 96 | [_activityIndicatorVisibilityTimer invalidate]; 97 | } 98 | 99 | - (void)updateNetworkActivityIndicatorVisibilityDelayed { 100 | if (self.enabled) { 101 | // Delay hiding of activity indicator for a short interval, to avoid flickering 102 | if (![self isNetworkActivityIndicatorVisible]) { 103 | [self.activityIndicatorVisibilityTimer invalidate]; 104 | self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; 105 | [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; 106 | } else { 107 | [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; 108 | } 109 | } 110 | } 111 | 112 | - (BOOL)isNetworkActivityIndicatorVisible { 113 | return self.activityCount > 0; 114 | } 115 | 116 | - (void)updateNetworkActivityIndicatorVisibility { 117 | #if !defined(AF_APP_EXTENSIONS) 118 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; 119 | #endif 120 | } 121 | 122 | - (void)setActivityCount:(NSInteger)activityCount { 123 | @synchronized(self) { 124 | _activityCount = activityCount; 125 | } 126 | 127 | dispatch_async(dispatch_get_main_queue(), ^{ 128 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 129 | }); 130 | } 131 | 132 | - (void)incrementActivityCount { 133 | [self willChangeValueForKey:@"activityCount"]; 134 | @synchronized(self) { 135 | _activityCount++; 136 | } 137 | [self didChangeValueForKey:@"activityCount"]; 138 | 139 | dispatch_async(dispatch_get_main_queue(), ^{ 140 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 141 | }); 142 | } 143 | 144 | - (void)decrementActivityCount { 145 | [self willChangeValueForKey:@"activityCount"]; 146 | @synchronized(self) { 147 | #pragma clang diagnostic push 148 | #pragma clang diagnostic ignored "-Wgnu" 149 | _activityCount = MAX(_activityCount - 1, 0); 150 | #pragma clang diagnostic pop 151 | } 152 | [self didChangeValueForKey:@"activityCount"]; 153 | 154 | dispatch_async(dispatch_get_main_queue(), ^{ 155 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 156 | }); 157 | } 158 | 159 | - (void)networkRequestDidStart:(NSNotification *)notification { 160 | if ([AFNetworkRequestFromNotification(notification) URL]) { 161 | [self incrementActivityCount]; 162 | } 163 | } 164 | 165 | - (void)networkRequestDidFinish:(NSNotification *)notification { 166 | if ([AFNetworkRequestFromNotification(notification) URL]) { 167 | [self decrementActivityCount]; 168 | } 169 | } 170 | 171 | @end 172 | 173 | #endif 174 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 | 29 | #import 30 | 31 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task. 35 | */ 36 | @interface UIActivityIndicatorView (AFNetworking) 37 | 38 | ///---------------------------------- 39 | /// @name Animating for Session Tasks 40 | ///---------------------------------- 41 | 42 | /** 43 | Binds the animating state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 49 | #endif 50 | 51 | ///--------------------------------------- 52 | /// @name Animating for Request Operations 53 | ///--------------------------------------- 54 | 55 | /** 56 | Binds the animating state to the execution state of the specified operation. 57 | 58 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 59 | */ 60 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation; 61 | 62 | @end 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "UIActivityIndicatorView+AFNetworking.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | @implementation UIActivityIndicatorView (AFNetworking) 34 | 35 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 36 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 37 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 38 | 39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 41 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 42 | 43 | if (task) { 44 | if (task.state != NSURLSessionTaskStateCompleted) { 45 | if (task.state == NSURLSessionTaskStateRunning) { 46 | [self startAnimating]; 47 | } else { 48 | [self stopAnimating]; 49 | } 50 | 51 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 52 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 53 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 54 | } 55 | } 56 | } 57 | #endif 58 | 59 | #pragma mark - 60 | 61 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { 62 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 63 | 64 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 65 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 66 | 67 | if (operation) { 68 | if (![operation isFinished]) { 69 | if ([operation isExecuting]) { 70 | [self startAnimating]; 71 | } else { 72 | [self stopAnimating]; 73 | } 74 | 75 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation]; 76 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation]; 77 | } 78 | } 79 | } 80 | 81 | #pragma mark - 82 | 83 | - (void)af_startAnimating { 84 | dispatch_async(dispatch_get_main_queue(), ^{ 85 | [self startAnimating]; 86 | }); 87 | } 88 | 89 | - (void)af_stopAnimating { 90 | dispatch_async(dispatch_get_main_queue(), ^{ 91 | [self stopAnimating]; 92 | }); 93 | } 94 | 95 | @end 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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) && !defined(AF_APP_EXTENSIONS) 28 | 29 | #import 30 | 31 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error. 35 | */ 36 | @interface UIAlertView (AFNetworking) 37 | 38 | ///------------------------------------- 39 | /// @name Showing Alert for Session Task 40 | ///------------------------------------- 41 | 42 | /** 43 | Shows an alert view with the error of the specified session task, if any. 44 | 45 | @param task The session task. 46 | @param delegate The alert view delegate. 47 | */ 48 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 49 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 50 | delegate:(id)delegate; 51 | #endif 52 | 53 | /** 54 | Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. 55 | 56 | @param task The session task. 57 | @param delegate The alert view delegate. 58 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. 59 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. 60 | */ 61 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 62 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 63 | delegate:(id)delegate 64 | cancelButtonTitle:(NSString *)cancelButtonTitle 65 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; 66 | #endif 67 | 68 | ///------------------------------------------ 69 | /// @name Showing Alert for Request Operation 70 | ///------------------------------------------ 71 | 72 | /** 73 | Shows an alert view with the error of the specified request operation, if any. 74 | 75 | @param operation The request operation. 76 | @param delegate The alert view delegate. 77 | */ 78 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 79 | delegate:(id)delegate; 80 | 81 | /** 82 | Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. 83 | 84 | @param operation The request operation. 85 | @param delegate The alert view delegate. 86 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. 87 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. 88 | */ 89 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 90 | delegate:(id)delegate 91 | cancelButtonTitle:(NSString *)cancelButtonTitle 92 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; 93 | 94 | @end 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "UIAlertView+AFNetworking.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) 26 | 27 | #import "AFURLConnectionOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) { 34 | if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) { 35 | *title = error.localizedDescription; 36 | 37 | if (error.localizedRecoverySuggestion) { 38 | *message = error.localizedRecoverySuggestion; 39 | } else { 40 | *message = error.localizedFailureReason; 41 | } 42 | } else if (error.localizedDescription) { 43 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 44 | *message = error.localizedDescription; 45 | } else { 46 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 47 | *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code]; 48 | } 49 | } 50 | 51 | @implementation UIAlertView (AFNetworking) 52 | 53 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 54 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 55 | delegate:(id)delegate 56 | { 57 | [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 58 | } 59 | 60 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 61 | delegate:(id)delegate 62 | cancelButtonTitle:(NSString *)cancelButtonTitle 63 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 64 | { 65 | NSMutableArray *mutableOtherTitles = [NSMutableArray array]; 66 | va_list otherButtonTitleList; 67 | va_start(otherButtonTitleList, otherButtonTitles); 68 | { 69 | for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { 70 | [mutableOtherTitles addObject:otherButtonTitle]; 71 | } 72 | } 73 | va_end(otherButtonTitleList); 74 | 75 | __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 76 | NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey]; 77 | if (error) { 78 | NSString *title, *message; 79 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 80 | 81 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; 82 | for (NSString *otherButtonTitle in mutableOtherTitles) { 83 | [alertView addButtonWithTitle:otherButtonTitle]; 84 | } 85 | [alertView setTitle:title]; 86 | [alertView setMessage:message]; 87 | [alertView show]; 88 | } 89 | 90 | [[NSNotificationCenter defaultCenter] removeObserver:observer]; 91 | }]; 92 | } 93 | #endif 94 | 95 | #pragma mark - 96 | 97 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 98 | delegate:(id)delegate 99 | { 100 | [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 101 | } 102 | 103 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 104 | delegate:(id)delegate 105 | cancelButtonTitle:(NSString *)cancelButtonTitle 106 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 107 | { 108 | NSMutableArray *mutableOtherTitles = [NSMutableArray array]; 109 | va_list otherButtonTitleList; 110 | va_start(otherButtonTitleList, otherButtonTitles); 111 | { 112 | for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { 113 | [mutableOtherTitles addObject:otherButtonTitle]; 114 | } 115 | } 116 | va_end(otherButtonTitleList); 117 | 118 | __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 119 | 120 | if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) { 121 | NSError *error = [(AFURLConnectionOperation *)notification.object error]; 122 | if (error) { 123 | NSString *title, *message; 124 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 125 | 126 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; 127 | for (NSString *otherButtonTitle in mutableOtherTitles) { 128 | [alertView addButtonWithTitle:otherButtonTitle]; 129 | } 130 | [alertView setTitle:title]; 131 | [alertView setMessage:message]; 132 | [alertView show]; 133 | } 134 | } 135 | 136 | [[NSNotificationCenter defaultCenter] removeObserver:observer]; 137 | }]; 138 | } 139 | 140 | @end 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIButton+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 | 29 | #import 30 | 31 | @protocol AFURLResponseSerialization, AFImageCache; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL. 35 | 36 | @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported. 37 | */ 38 | @interface UIButton (AFNetworking) 39 | 40 | ///---------------------------- 41 | /// @name Accessing Image Cache 42 | ///---------------------------- 43 | 44 | /** 45 | The image cache used to improve image loadiing performance on scroll views. By default, `UIButton` will use the `sharedImageCache` of `UIImageView`. 46 | */ 47 | + (id )sharedImageCache; 48 | 49 | /** 50 | Set the cache used for image loading. 51 | 52 | @param imageCache The image cache. 53 | */ 54 | + (void)setSharedImageCache:(id )imageCache; 55 | 56 | ///------------------------------------ 57 | /// @name Accessing Response Serializer 58 | ///------------------------------------ 59 | 60 | /** 61 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. 62 | 63 | @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer 64 | */ 65 | @property (nonatomic, strong) id imageResponseSerializer; 66 | 67 | ///-------------------- 68 | /// @name Setting Image 69 | ///-------------------- 70 | 71 | /** 72 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 73 | 74 | 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. 75 | 76 | @param state The control state. 77 | @param url The URL used for the image request. 78 | */ 79 | - (void)setImageForState:(UIControlState)state 80 | withURL:(NSURL *)url; 81 | 82 | /** 83 | Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 84 | 85 | 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. 86 | 87 | @param state The control state. 88 | @param url The URL used for the image request. 89 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. 90 | */ 91 | - (void)setImageForState:(UIControlState)state 92 | withURL:(NSURL *)url 93 | placeholderImage:(UIImage *)placeholderImage; 94 | 95 | /** 96 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 97 | 98 | 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. 99 | 100 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied. 101 | 102 | @param state The control state. 103 | @param urlRequest The URL request used for the image request. 104 | @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. 105 | @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the request and response parameters will be `nil`. 106 | @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 a single argument: the error that occurred. 107 | */ 108 | - (void)setImageForState:(UIControlState)state 109 | withURLRequest:(NSURLRequest *)urlRequest 110 | placeholderImage:(UIImage *)placeholderImage 111 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 112 | failure:(void (^)(NSError *error))failure; 113 | 114 | 115 | ///------------------------------- 116 | /// @name Setting Background Image 117 | ///------------------------------- 118 | 119 | /** 120 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled. 121 | 122 | If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished. 123 | 124 | @param state The control state. 125 | @param url The URL used for the background image request. 126 | */ 127 | - (void)setBackgroundImageForState:(UIControlState)state 128 | withURL:(NSURL *)url; 129 | 130 | /** 131 | Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 132 | 133 | 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. 134 | 135 | @param state The control state. 136 | @param url The URL used for the background image request. 137 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. 138 | */ 139 | - (void)setBackgroundImageForState:(UIControlState)state 140 | withURL:(NSURL *)url 141 | placeholderImage:(UIImage *)placeholderImage; 142 | 143 | /** 144 | Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. 145 | 146 | 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. 147 | 148 | If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied. 149 | 150 | @param state The control state. 151 | @param urlRequest The URL request used for the image request. 152 | @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. 153 | */ 154 | - (void)setBackgroundImageForState:(UIControlState)state 155 | withURLRequest:(NSURLRequest *)urlRequest 156 | placeholderImage:(UIImage *)placeholderImage 157 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 158 | failure:(void (^)(NSError *error))failure; 159 | 160 | 161 | ///------------------------------ 162 | /// @name Canceling Image Loading 163 | ///------------------------------ 164 | 165 | /** 166 | Cancels any executing image operation for the specified control state of the receiver, if one exists. 167 | 168 | @param state The control state. 169 | */ 170 | - (void)cancelImageRequestOperationForState:(UIControlState)state; 171 | 172 | /** 173 | Cancels any executing background image operation for the specified control state of the receiver, if one exists. 174 | 175 | @param state The control state. 176 | */ 177 | - (void)cancelBackgroundImageRequestOperationForState:(UIControlState)state; 178 | 179 | @end 180 | 181 | #endif 182 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 | 29 | #import 30 | 31 | @protocol AFURLResponseSerialization, AFImageCache; 32 | 33 | /** 34 | 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. 35 | */ 36 | @interface UIImageView (AFNetworking) 37 | 38 | ///---------------------------- 39 | /// @name Accessing Image Cache 40 | ///---------------------------- 41 | 42 | /** 43 | The image cache used to improve image loading performance on scroll views. By default, this is an `NSCache` subclass conforming to the `AFImageCache` protocol, which listens for notification warnings and evicts objects accordingly. 44 | */ 45 | + (id )sharedImageCache; 46 | 47 | /** 48 | Set the cache used for image loading. 49 | 50 | @param imageCache The image cache. 51 | */ 52 | + (void)setSharedImageCache:(id )imageCache; 53 | 54 | ///------------------------------------ 55 | /// @name Accessing Response Serializer 56 | ///------------------------------------ 57 | 58 | /** 59 | The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. 60 | 61 | @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer 62 | */ 63 | @property (nonatomic, strong) id imageResponseSerializer; 64 | 65 | ///-------------------- 66 | /// @name Setting Image 67 | ///-------------------- 68 | 69 | /** 70 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 71 | 72 | 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. 73 | 74 | By default, URL requests have a `Accept` header field value of "image / *", 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:` 75 | 76 | @param url The URL used for the image request. 77 | */ 78 | - (void)setImageWithURL:(NSURL *)url; 79 | 80 | /** 81 | Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 82 | 83 | 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. 84 | 85 | By default, URL requests have a `Accept` header field value of "image / *", 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:` 86 | 87 | @param url The URL used for the image request. 88 | @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. 89 | */ 90 | - (void)setImageWithURL:(NSURL *)url 91 | placeholderImage:(UIImage *)placeholderImage; 92 | 93 | /** 94 | Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. 95 | 96 | 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. 97 | 98 | 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 applied. 99 | 100 | @param urlRequest The URL request used for the image request. 101 | @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. 102 | @param success A block to be executed when the image request 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 image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`. 103 | @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. 104 | */ 105 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 106 | placeholderImage:(UIImage *)placeholderImage 107 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 108 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; 109 | 110 | /** 111 | Cancels any executing image operation for the receiver, if one exists. 112 | */ 113 | - (void)cancelImageRequestOperation; 114 | 115 | @end 116 | 117 | #pragma mark - 118 | 119 | /** 120 | The `AFImageCache` protocol is adopted by an object used to cache images loaded by the AFNetworking category on `UIImageView`. 121 | */ 122 | @protocol AFImageCache 123 | 124 | /** 125 | Returns a cached image for the specififed request, if available. 126 | 127 | @param request The image request. 128 | 129 | @return The cached image. 130 | */ 131 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request; 132 | 133 | /** 134 | Caches a particular image for the specified request. 135 | 136 | @param image The image to cache. 137 | @param request The request to be used as a cache key. 138 | */ 139 | - (void)cacheImage:(UIImage *)image 140 | forRequest:(NSURLRequest *)request; 141 | @end 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIImageView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "UIImageView+AFNetworking.h" 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import "AFHTTPRequestOperation.h" 30 | 31 | @interface AFImageCache : NSCache 32 | @end 33 | 34 | #pragma mark - 35 | 36 | @interface UIImageView (_AFNetworking) 37 | @property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation; 38 | @end 39 | 40 | @implementation UIImageView (_AFNetworking) 41 | 42 | + (NSOperationQueue *)af_sharedImageRequestOperationQueue { 43 | static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil; 44 | static dispatch_once_t onceToken; 45 | dispatch_once(&onceToken, ^{ 46 | _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init]; 47 | _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; 48 | }); 49 | 50 | return _af_sharedImageRequestOperationQueue; 51 | } 52 | 53 | - (AFHTTPRequestOperation *)af_imageRequestOperation { 54 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_imageRequestOperation)); 55 | } 56 | 57 | - (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation { 58 | objc_setAssociatedObject(self, @selector(af_imageRequestOperation), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 59 | } 60 | 61 | @end 62 | 63 | #pragma mark - 64 | 65 | @implementation UIImageView (AFNetworking) 66 | @dynamic imageResponseSerializer; 67 | 68 | + (id )sharedImageCache { 69 | static AFImageCache *_af_defaultImageCache = nil; 70 | static dispatch_once_t oncePredicate; 71 | dispatch_once(&oncePredicate, ^{ 72 | _af_defaultImageCache = [[AFImageCache alloc] init]; 73 | 74 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * __unused notification) { 75 | [_af_defaultImageCache removeAllObjects]; 76 | }]; 77 | }); 78 | 79 | #pragma clang diagnostic push 80 | #pragma clang diagnostic ignored "-Wgnu" 81 | return objc_getAssociatedObject(self, @selector(sharedImageCache)) ?: _af_defaultImageCache; 82 | #pragma clang diagnostic pop 83 | } 84 | 85 | + (void)setSharedImageCache:(id )imageCache { 86 | objc_setAssociatedObject(self, @selector(sharedImageCache), imageCache, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 87 | } 88 | 89 | #pragma mark - 90 | 91 | - (id )imageResponseSerializer { 92 | static id _af_defaultImageResponseSerializer = nil; 93 | static dispatch_once_t onceToken; 94 | dispatch_once(&onceToken, ^{ 95 | _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer]; 96 | }); 97 | 98 | #pragma clang diagnostic push 99 | #pragma clang diagnostic ignored "-Wgnu" 100 | return objc_getAssociatedObject(self, @selector(imageResponseSerializer)) ?: _af_defaultImageResponseSerializer; 101 | #pragma clang diagnostic pop 102 | } 103 | 104 | - (void)setImageResponseSerializer:(id )serializer { 105 | objc_setAssociatedObject(self, @selector(imageResponseSerializer), serializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 106 | } 107 | 108 | #pragma mark - 109 | 110 | - (void)setImageWithURL:(NSURL *)url { 111 | [self setImageWithURL:url placeholderImage:nil]; 112 | } 113 | 114 | - (void)setImageWithURL:(NSURL *)url 115 | placeholderImage:(UIImage *)placeholderImage 116 | { 117 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 118 | [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; 119 | 120 | [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; 121 | } 122 | 123 | - (void)setImageWithURLRequest:(NSURLRequest *)urlRequest 124 | placeholderImage:(UIImage *)placeholderImage 125 | success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success 126 | failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure 127 | { 128 | [self cancelImageRequestOperation]; 129 | 130 | UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; 131 | if (cachedImage) { 132 | if (success) { 133 | success(nil, nil, cachedImage); 134 | } else { 135 | self.image = cachedImage; 136 | } 137 | 138 | self.af_imageRequestOperation = nil; 139 | } else { 140 | if (placeholderImage) { 141 | self.image = placeholderImage; 142 | } 143 | 144 | __weak __typeof(self)weakSelf = self; 145 | self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; 146 | self.af_imageRequestOperation.responseSerializer = self.imageResponseSerializer; 147 | [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 148 | __strong __typeof(weakSelf)strongSelf = weakSelf; 149 | if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { 150 | if (success) { 151 | success(urlRequest, operation.response, responseObject); 152 | } else if (responseObject) { 153 | strongSelf.image = responseObject; 154 | } 155 | 156 | if (operation == strongSelf.af_imageRequestOperation){ 157 | strongSelf.af_imageRequestOperation = nil; 158 | } 159 | } 160 | 161 | [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; 162 | } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 163 | __strong __typeof(weakSelf)strongSelf = weakSelf; 164 | if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { 165 | if (failure) { 166 | failure(urlRequest, operation.response, error); 167 | } 168 | 169 | if (operation == strongSelf.af_imageRequestOperation){ 170 | strongSelf.af_imageRequestOperation = nil; 171 | } 172 | } 173 | }]; 174 | 175 | [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation]; 176 | } 177 | } 178 | 179 | - (void)cancelImageRequestOperation { 180 | [self.af_imageRequestOperation cancel]; 181 | self.af_imageRequestOperation = nil; 182 | } 183 | 184 | @end 185 | 186 | #pragma mark - 187 | 188 | static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) { 189 | return [[request URL] absoluteString]; 190 | } 191 | 192 | @implementation AFImageCache 193 | 194 | - (UIImage *)cachedImageForRequest:(NSURLRequest *)request { 195 | switch ([request cachePolicy]) { 196 | case NSURLRequestReloadIgnoringCacheData: 197 | case NSURLRequestReloadIgnoringLocalAndRemoteCacheData: 198 | return nil; 199 | default: 200 | break; 201 | } 202 | 203 | return [self objectForKey:AFImageCacheKeyFromURLRequest(request)]; 204 | } 205 | 206 | - (void)cacheImage:(UIImage *)image 207 | forRequest:(NSURLRequest *)request 208 | { 209 | if (image && request) { 210 | [self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)]; 211 | } 212 | } 213 | 214 | @end 215 | 216 | #endif 217 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIKit+AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.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 | #ifndef _UIKIT_AFNETWORKING_ 26 | #define _UIKIT_AFNETWORKING_ 27 | 28 | #import "AFNetworkActivityIndicatorManager.h" 29 | 30 | #import "UIActivityIndicatorView+AFNetworking.h" 31 | #import "UIAlertView+AFNetworking.h" 32 | #import "UIButton+AFNetworking.h" 33 | #import "UIImageView+AFNetworking.h" 34 | #import "UIKit+AFNetworking.h" 35 | #import "UIProgressView+AFNetworking.h" 36 | #import "UIRefreshControl+AFNetworking.h" 37 | #import "UIWebView+AFNetworking.h" 38 | #endif /* _UIKIT_AFNETWORKING_ */ 39 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 | 29 | #import 30 | 31 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task or request operation. 35 | */ 36 | @interface UIProgressView (AFNetworking) 37 | 38 | ///------------------------------------ 39 | /// @name Setting Session Task Progress 40 | ///------------------------------------ 41 | 42 | /** 43 | Binds the progress to the upload progress of the specified session task. 44 | 45 | @param task The session task. 46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 47 | */ 48 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 49 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 50 | animated:(BOOL)animated; 51 | #endif 52 | 53 | /** 54 | Binds the progress to the download progress of the specified session task. 55 | 56 | @param task The session task. 57 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 58 | */ 59 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 60 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 61 | animated:(BOOL)animated; 62 | #endif 63 | 64 | ///------------------------------------ 65 | /// @name Setting Session Task Progress 66 | ///------------------------------------ 67 | 68 | /** 69 | Binds the progress to the upload progress of the specified request operation. 70 | 71 | @param operation The request operation. 72 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 73 | */ 74 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation 75 | animated:(BOOL)animated; 76 | 77 | /** 78 | Binds the progress to the download progress of the specified request operation. 79 | 80 | @param operation The request operation. 81 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 82 | */ 83 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation 84 | animated:(BOOL)animated; 85 | 86 | @end 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "UIProgressView+AFNetworking.h" 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import "AFURLConnectionOperation.h" 30 | 31 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 32 | #import "AFURLSessionManager.h" 33 | #endif 34 | 35 | static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; 36 | static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; 37 | 38 | @interface AFURLConnectionOperation (_UIProgressView) 39 | @property (readwrite, nonatomic, copy) void (^uploadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); 40 | @property (readwrite, nonatomic, assign, setter = af_setUploadProgressAnimated:) BOOL af_uploadProgressAnimated; 41 | 42 | @property (readwrite, nonatomic, copy) void (^downloadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); 43 | @property (readwrite, nonatomic, assign, setter = af_setDownloadProgressAnimated:) BOOL af_downloadProgressAnimated; 44 | @end 45 | 46 | @implementation AFURLConnectionOperation (_UIProgressView) 47 | @dynamic uploadProgress; // Implemented in AFURLConnectionOperation 48 | @dynamic af_uploadProgressAnimated; 49 | 50 | @dynamic downloadProgress; // Implemented in AFURLConnectionOperation 51 | @dynamic af_downloadProgressAnimated; 52 | @end 53 | 54 | #pragma mark - 55 | 56 | @implementation UIProgressView (AFNetworking) 57 | 58 | - (BOOL)af_uploadProgressAnimated { 59 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; 60 | } 61 | 62 | - (void)af_setUploadProgressAnimated:(BOOL)animated { 63 | objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 64 | } 65 | 66 | - (BOOL)af_downloadProgressAnimated { 67 | return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; 68 | } 69 | 70 | - (void)af_setDownloadProgressAnimated:(BOOL)animated { 71 | objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); 72 | } 73 | 74 | #pragma mark - 75 | 76 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 77 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 78 | animated:(BOOL)animated 79 | { 80 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 81 | [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; 82 | 83 | [self af_setUploadProgressAnimated:animated]; 84 | } 85 | 86 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 87 | animated:(BOOL)animated 88 | { 89 | [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 90 | [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; 91 | 92 | [self af_setDownloadProgressAnimated:animated]; 93 | } 94 | #endif 95 | 96 | #pragma mark - 97 | 98 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation 99 | animated:(BOOL)animated 100 | { 101 | __weak __typeof(self)weakSelf = self; 102 | void (^original)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) = [operation.uploadProgress copy]; 103 | [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { 104 | if (original) { 105 | original(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); 106 | } 107 | 108 | dispatch_async(dispatch_get_main_queue(), ^{ 109 | if (totalBytesExpectedToWrite > 0) { 110 | __strong __typeof(weakSelf)strongSelf = weakSelf; 111 | [strongSelf setProgress:(totalBytesWritten / (totalBytesExpectedToWrite * 1.0f)) animated:animated]; 112 | } 113 | }); 114 | }]; 115 | } 116 | 117 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation 118 | animated:(BOOL)animated 119 | { 120 | __weak __typeof(self)weakSelf = self; 121 | void (^original)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) = [operation.downloadProgress copy]; 122 | [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { 123 | if (original) { 124 | original(bytesRead, totalBytesRead, totalBytesExpectedToRead); 125 | } 126 | 127 | dispatch_async(dispatch_get_main_queue(), ^{ 128 | if (totalBytesExpectedToRead > 0) { 129 | __strong __typeof(weakSelf)strongSelf = weakSelf; 130 | [strongSelf setProgress:(totalBytesRead / (totalBytesExpectedToRead * 1.0f)) animated:animated]; 131 | } 132 | }); 133 | }]; 134 | } 135 | 136 | #pragma mark - NSKeyValueObserving 137 | 138 | - (void)observeValueForKeyPath:(NSString *)keyPath 139 | ofObject:(id)object 140 | change:(__unused NSDictionary *)change 141 | context:(void *)context 142 | { 143 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 144 | if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { 145 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { 146 | if ([object countOfBytesExpectedToSend] > 0) { 147 | dispatch_async(dispatch_get_main_queue(), ^{ 148 | [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; 149 | }); 150 | } 151 | } 152 | 153 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { 154 | if ([object countOfBytesExpectedToReceive] > 0) { 155 | dispatch_async(dispatch_get_main_queue(), ^{ 156 | [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; 157 | }); 158 | } 159 | } 160 | 161 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { 162 | if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { 163 | @try { 164 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; 165 | 166 | if (context == AFTaskCountOfBytesSentContext) { 167 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; 168 | } 169 | 170 | if (context == AFTaskCountOfBytesReceivedContext) { 171 | [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; 172 | } 173 | } 174 | @catch (NSException * __unused exception) {} 175 | } 176 | } 177 | } 178 | #endif 179 | } 180 | 181 | @end 182 | 183 | #endif 184 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.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 | 29 | #import 30 | 31 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically begining and ending refreshing depending on the loading state of a request operation or session task. 35 | */ 36 | @interface UIRefreshControl (AFNetworking) 37 | 38 | ///----------------------------------- 39 | /// @name Refreshing for Session Tasks 40 | ///----------------------------------- 41 | 42 | /** 43 | Binds the refreshing state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 48 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 49 | #endif 50 | 51 | ///---------------------------------------- 52 | /// @name Refreshing for Request Operations 53 | ///---------------------------------------- 54 | 55 | /** 56 | Binds the refreshing state to the execution state of the specified operation. 57 | 58 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 59 | */ 60 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; 61 | 62 | @end 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.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 "UIRefreshControl+AFNetworking.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | @implementation UIRefreshControl (AFNetworking) 34 | 35 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 36 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 37 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 38 | 39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 41 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 42 | 43 | if (task) { 44 | if (task.state == NSURLSessionTaskStateRunning) { 45 | [self beginRefreshing]; 46 | 47 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 48 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 49 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 50 | } else { 51 | [self endRefreshing]; 52 | } 53 | } 54 | } 55 | #endif 56 | 57 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { 58 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 59 | 60 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 61 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 62 | 63 | if (operation) { 64 | if (![operation isFinished]) { 65 | if ([operation isExecuting]) { 66 | [self beginRefreshing]; 67 | } else { 68 | [self endRefreshing]; 69 | } 70 | 71 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation]; 72 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation]; 73 | } 74 | } 75 | } 76 | 77 | #pragma mark - 78 | 79 | - (void)af_beginRefreshing { 80 | dispatch_async(dispatch_get_main_queue(), ^{ 81 | [self beginRefreshing]; 82 | }); 83 | } 84 | 85 | - (void)af_endRefreshing { 86 | dispatch_async(dispatch_get_main_queue(), ^{ 87 | [self endRefreshing]; 88 | }); 89 | } 90 | 91 | @end 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 | 29 | #import 30 | 31 | @class AFHTTPRequestSerializer, AFHTTPResponseSerializer; 32 | @protocol AFURLRequestSerialization, AFURLResponseSerialization; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. 36 | 37 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. 38 | */ 39 | @interface UIWebView (AFNetworking) 40 | 41 | /** 42 | The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`. 43 | */ 44 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; 45 | 46 | /** 47 | The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`. 48 | */ 49 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 50 | 51 | /** 52 | Asynchronously loads the specified request. 53 | 54 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 55 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. 56 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. 57 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 58 | */ 59 | - (void)loadRequest:(NSURLRequest *)request 60 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 61 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 62 | failure:(void (^)(NSError *error))failure; 63 | 64 | /** 65 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 66 | 67 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 68 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 69 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 70 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. 71 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. 72 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 73 | */ 74 | - (void)loadRequest:(NSURLRequest *)request 75 | MIMEType:(NSString *)MIMEType 76 | textEncodingName:(NSString *)textEncodingName 77 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 78 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 79 | failure:(void (^)(NSError *error))failure; 80 | 81 | @end 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /client/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.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 "UIWebView+AFNetworking.h" 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import "AFHTTPRequestOperation.h" 30 | #import "AFURLResponseSerialization.h" 31 | #import "AFURLRequestSerialization.h" 32 | 33 | @interface UIWebView (_AFNetworking) 34 | @property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation; 35 | @end 36 | 37 | @implementation UIWebView (_AFNetworking) 38 | 39 | - (AFHTTPRequestOperation *)af_HTTPRequestOperation { 40 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation)); 41 | } 42 | 43 | - (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation { 44 | objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | } 46 | 47 | @end 48 | 49 | #pragma mark - 50 | 51 | @implementation UIWebView (AFNetworking) 52 | 53 | - (AFHTTPRequestSerializer *)requestSerializer { 54 | static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil; 55 | static dispatch_once_t onceToken; 56 | dispatch_once(&onceToken, ^{ 57 | _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer]; 58 | }); 59 | 60 | #pragma clang diagnostic push 61 | #pragma clang diagnostic ignored "-Wgnu" 62 | return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer; 63 | #pragma clang diagnostic pop 64 | } 65 | 66 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { 67 | objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 68 | } 69 | 70 | - (AFHTTPResponseSerializer *)responseSerializer { 71 | static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; 72 | static dispatch_once_t onceToken; 73 | dispatch_once(&onceToken, ^{ 74 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; 75 | }); 76 | 77 | #pragma clang diagnostic push 78 | #pragma clang diagnostic ignored "-Wgnu" 79 | return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; 80 | #pragma clang diagnostic pop 81 | } 82 | 83 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 84 | objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 85 | } 86 | 87 | #pragma mark - 88 | 89 | - (void)loadRequest:(NSURLRequest *)request 90 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 91 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 92 | failure:(void (^)(NSError *error))failure 93 | { 94 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { 95 | NSStringEncoding stringEncoding = NSUTF8StringEncoding; 96 | if (response.textEncodingName) { 97 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); 98 | if (encoding != kCFStringEncodingInvalidId) { 99 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); 100 | } 101 | } 102 | 103 | NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; 104 | if (success) { 105 | string = success(response, string); 106 | } 107 | 108 | return [string dataUsingEncoding:stringEncoding]; 109 | } failure:failure]; 110 | } 111 | 112 | - (void)loadRequest:(NSURLRequest *)request 113 | MIMEType:(NSString *)MIMEType 114 | textEncodingName:(NSString *)textEncodingName 115 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 116 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 117 | failure:(void (^)(NSError *error))failure 118 | { 119 | NSParameterAssert(request); 120 | 121 | if (self.af_HTTPRequestOperation) { 122 | [self.af_HTTPRequestOperation cancel]; 123 | } 124 | 125 | request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil]; 126 | 127 | self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 128 | self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer; 129 | 130 | __weak __typeof(self)weakSelf = self; 131 | [self.af_HTTPRequestOperation setDownloadProgressBlock:progress]; 132 | [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) { 133 | NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData; 134 | 135 | #pragma clang diagnostic push 136 | #pragma clang diagnostic ignored "-Wgnu" 137 | __strong __typeof(weakSelf) strongSelf = weakSelf; 138 | [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]]; 139 | 140 | if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { 141 | [strongSelf.delegate webViewDidFinishLoad:strongSelf]; 142 | } 143 | 144 | #pragma clang diagnostic pop 145 | } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) { 146 | if (failure) { 147 | failure(error); 148 | } 149 | }]; 150 | 151 | [self.af_HTTPRequestOperation start]; 152 | 153 | if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 154 | [self.delegate webViewDidStartLoad:self]; 155 | } 156 | } 157 | 158 | @end 159 | 160 | #endif 161 | -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFHTTPRequestOperationManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Build/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFSecurityPolicy.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/AFNetworking/AFURLSessionManager.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | ../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h -------------------------------------------------------------------------------- /client/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (2.5.3): 3 | - AFNetworking/NSURLConnection (= 2.5.3) 4 | - AFNetworking/NSURLSession (= 2.5.3) 5 | - AFNetworking/Reachability (= 2.5.3) 6 | - AFNetworking/Security (= 2.5.3) 7 | - AFNetworking/Serialization (= 2.5.3) 8 | - AFNetworking/UIKit (= 2.5.3) 9 | - AFNetworking/NSURLConnection (2.5.3): 10 | - AFNetworking/Reachability 11 | - AFNetworking/Security 12 | - AFNetworking/Serialization 13 | - AFNetworking/NSURLSession (2.5.3): 14 | - AFNetworking/Reachability 15 | - AFNetworking/Security 16 | - AFNetworking/Serialization 17 | - AFNetworking/Reachability (2.5.3) 18 | - AFNetworking/Security (2.5.3) 19 | - AFNetworking/Serialization (2.5.3) 20 | - AFNetworking/UIKit (2.5.3): 21 | - AFNetworking/NSURLConnection 22 | - AFNetworking/NSURLSession 23 | 24 | DEPENDENCIES: 25 | - AFNetworking (~> 2.0) 26 | 27 | SPEC CHECKSUMS: 28 | AFNetworking: e1d86c2a96bb5d2e7408da36149806706ee122fe 29 | 30 | COCOAPODS: 0.35.0 31 | -------------------------------------------------------------------------------- /client/Pods/Pods.xcodeproj/xcuserdata/kristjanmik.xcuserdatad/xcschemes/Pods-s3streamer-AFNetworking.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /client/Pods/Pods.xcodeproj/xcuserdata/kristjanmik.xcuserdatad/xcschemes/Pods-s3streamer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 42 | 43 | 44 | 45 | 51 | 52 | 54 | 55 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /client/Pods/Pods.xcodeproj/xcuserdata/kristjanmik.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Pods-s3streamer-AFNetworking.xcscheme 8 | 9 | isShown 10 | 11 | 12 | Pods-s3streamer.xcscheme 13 | 14 | isShown 15 | 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 553E678B947DC04ED55F7288 21 | 22 | primary 23 | 24 | 25 | 9A077B16E8EC9B270F7B2A76 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer-AFNetworking/Pods-s3streamer-AFNetworking-Private.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods-s3streamer-AFNetworking.xcconfig" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Build" "${PODS_ROOT}/Headers/Build/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | OTHER_LDFLAGS = ${PODS_S_STREAMER_AFNETWORKING_OTHER_LDFLAGS} -ObjC 5 | PODS_ROOT = ${SRCROOT} -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer-AFNetworking/Pods-s3streamer-AFNetworking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_s3streamer_AFNetworking : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_s3streamer_AFNetworking 5 | @end 6 | -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer-AFNetworking/Pods-s3streamer-AFNetworking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "Pods-s3streamer-environment.h" 6 | -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer-AFNetworking/Pods-s3streamer-AFNetworking.xcconfig: -------------------------------------------------------------------------------- 1 | PODS_S_STREAMER_AFNETWORKING_OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer/Pods-s3streamer-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## AFNetworking 5 | 6 | Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com/) 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | Generated by CocoaPods - http://cocoapods.org 27 | -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer/Pods-s3streamer-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com/) 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | Title 38 | AFNetworking 39 | Type 40 | PSGroupSpecifier 41 | 42 | 43 | FooterText 44 | Generated by CocoaPods - http://cocoapods.org 45 | Title 46 | 47 | Type 48 | PSGroupSpecifier 49 | 50 | 51 | StringsTable 52 | Acknowledgements 53 | Title 54 | Acknowledgements 55 | 56 | 57 | -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer/Pods-s3streamer-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_s3streamer : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_s3streamer 5 | @end 6 | -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer/Pods-s3streamer-environment.h: -------------------------------------------------------------------------------- 1 | 2 | // To check if a library is compiled with CocoaPods you 3 | // can use the `COCOAPODS` macro definition which is 4 | // defined in the xcconfigs so it is available in 5 | // headers also when they are imported in the client 6 | // project. 7 | 8 | 9 | // AFNetworking 10 | #define COCOAPODS_POD_AVAILABLE_AFNetworking 11 | #define COCOAPODS_VERSION_MAJOR_AFNetworking 2 12 | #define COCOAPODS_VERSION_MINOR_AFNetworking 5 13 | #define COCOAPODS_VERSION_PATCH_AFNetworking 3 14 | 15 | // AFNetworking/NSURLConnection 16 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_NSURLConnection 17 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_NSURLConnection 2 18 | #define COCOAPODS_VERSION_MINOR_AFNetworking_NSURLConnection 5 19 | #define COCOAPODS_VERSION_PATCH_AFNetworking_NSURLConnection 3 20 | 21 | // AFNetworking/NSURLSession 22 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_NSURLSession 23 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_NSURLSession 2 24 | #define COCOAPODS_VERSION_MINOR_AFNetworking_NSURLSession 5 25 | #define COCOAPODS_VERSION_PATCH_AFNetworking_NSURLSession 3 26 | 27 | // AFNetworking/Reachability 28 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Reachability 29 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Reachability 2 30 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Reachability 5 31 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Reachability 3 32 | 33 | // AFNetworking/Security 34 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Security 35 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Security 2 36 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Security 5 37 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Security 3 38 | 39 | // AFNetworking/Serialization 40 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_Serialization 41 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_Serialization 2 42 | #define COCOAPODS_VERSION_MINOR_AFNetworking_Serialization 5 43 | #define COCOAPODS_VERSION_PATCH_AFNetworking_Serialization 3 44 | 45 | // AFNetworking/UIKit 46 | #define COCOAPODS_POD_AVAILABLE_AFNetworking_UIKit 47 | #define COCOAPODS_VERSION_MAJOR_AFNetworking_UIKit 2 48 | #define COCOAPODS_VERSION_MINOR_AFNetworking_UIKit 5 49 | #define COCOAPODS_VERSION_PATCH_AFNetworking_UIKit 3 50 | 51 | -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer/Pods-s3streamer-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | install_resource() 10 | { 11 | case $1 in 12 | *.storyboard) 13 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 14 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 15 | ;; 16 | *.xib) 17 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}" 18 | ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}" 19 | ;; 20 | *.framework) 21 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 22 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 23 | echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 24 | rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 25 | ;; 26 | *.xcdatamodel) 27 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" 28 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" 29 | ;; 30 | *.xcdatamodeld) 31 | echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" 32 | xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" 33 | ;; 34 | *.xcmappingmodel) 35 | echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" 36 | xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" 37 | ;; 38 | *.xcassets) 39 | ;; 40 | /*) 41 | echo "$1" 42 | echo "$1" >> "$RESOURCES_TO_COPY" 43 | ;; 44 | *) 45 | echo "${PODS_ROOT}/$1" 46 | echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" 47 | ;; 48 | esac 49 | } 50 | 51 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 52 | if [[ "${ACTION}" == "install" ]]; then 53 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 54 | fi 55 | rm -f "$RESOURCES_TO_COPY" 56 | 57 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ `find . -name '*.xcassets' | wc -l` -ne 0 ] 58 | then 59 | case "${TARGETED_DEVICE_FAMILY}" in 60 | 1,2) 61 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 62 | ;; 63 | 1) 64 | TARGET_DEVICE_ARGS="--target-device iphone" 65 | ;; 66 | 2) 67 | TARGET_DEVICE_ARGS="--target-device ipad" 68 | ;; 69 | *) 70 | TARGET_DEVICE_ARGS="--target-device mac" 71 | ;; 72 | esac 73 | find "${PWD}" -name "*.xcassets" -print0 | xargs -0 actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 74 | fi 75 | -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer/Pods-s3streamer.debug.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | OTHER_LDFLAGS = -ObjC -l"Pods-s3streamer-AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /client/Pods/Target Support Files/Pods-s3streamer/Pods-s3streamer.release.xcconfig: -------------------------------------------------------------------------------- 1 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 2 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" 3 | OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" 4 | OTHER_LDFLAGS = -ObjC -l"Pods-s3streamer-AFNetworking" -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" 5 | OTHER_LIBTOOLFLAGS = $(OTHER_LDFLAGS) 6 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | # s3-streamer client 2 | 3 | ## Usage 4 | 5 | Getting started is done in a few steps. 6 | 7 | ### 1. Install dependencies if needed: 8 | 9 | ```sh 10 | $ pod install 11 | ``` 12 | 13 | --- 14 | 15 | ### 2. Run the project 16 | 17 | 18 | The test application will make a request to http://localhost:3200/upload -------------------------------------------------------------------------------- /client/s3streamer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /client/s3streamer.xcodeproj/project.xcworkspace/xcuserdata/kristjanmik.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kristjanmik/ios-nodejs-s3-streamer/bf9e3faf082b039f068c904430f476b4b96b77e5/client/s3streamer.xcodeproj/project.xcworkspace/xcuserdata/kristjanmik.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /client/s3streamer.xcodeproj/xcuserdata/kristjanmik.xcuserdatad/xcschemes/s3streamer.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /client/s3streamer.xcodeproj/xcuserdata/kristjanmik.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | s3streamer.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 6F827F0E1AECFCFC0039E941 16 | 17 | primary 18 | 19 | 20 | 6F827F271AECFCFC0039E941 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /client/s3streamer.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /client/s3streamer.xcworkspace/xcuserdata/kristjanmik.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kristjanmik/ios-nodejs-s3-streamer/bf9e3faf082b039f068c904430f476b4b96b77e5/client/s3streamer.xcworkspace/xcuserdata/kristjanmik.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /client/s3streamer/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // s3streamer 4 | // 5 | // Created by Kristján Ingi Mikaelsson on 26/04/2015. 6 | // Copyright (c) 2015 Appollo x. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /client/s3streamer/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // s3streamer 4 | // 5 | // Created by Kristján Ingi Mikaelsson on 26/04/2015. 6 | // Copyright (c) 2015 Appollo x. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /client/s3streamer/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /client/s3streamer/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /client/s3streamer/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /client/s3streamer/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.appollox.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /client/s3streamer/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // s3streamer 4 | // 5 | // Created by Kristján Ingi Mikaelsson on 26/04/2015. 6 | // Copyright (c) 2015 Appollo x. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /client/s3streamer/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // s3streamer 4 | // 5 | // Created by Kristján Ingi Mikaelsson on 26/04/2015. 6 | // Copyright (c) 2015 Appollo x. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "AFNetworking.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | [self upload:[[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"]]; 22 | } 23 | 24 | -(NSString *) url{ 25 | return @"http://localhost:3200"; 26 | } 27 | 28 | -(NSString *) apiKey{ 29 | return @"abcdefg"; 30 | } 31 | 32 | -(void) upload: (NSString *)assetPath{ 33 | 34 | //Create the request with the final url 35 | NSMutableURLRequest * request = [NSMutableURLRequest 36 | requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/upload",[self url]]] 37 | cachePolicy:NSURLRequestUseProtocolCachePolicy 38 | timeoutInterval:30.0]; 39 | 40 | //Do a POST request 41 | [request setHTTPMethod:@"POST"]; 42 | 43 | [request setValue:@"image/png" forHTTPHeaderField:@"Content-Type"]; 44 | [request setValue:[self apiKey] forHTTPHeaderField:@"App-Apikey"]; 45 | 46 | //Make the entire file as the body of the request via stream 47 | [request setHTTPBodyStream:[NSInputStream 48 | inputStreamWithFileAtPath:assetPath]]; 49 | 50 | AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 51 | 52 | [operation setUploadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead){ 53 | CGFloat uploadPercentage = (float)totalBytesRead / totalBytesExpectedToRead; 54 | NSLog(@"PROGRESS %f",uploadPercentage); 55 | }]; 56 | 57 | operation.responseSerializer = [AFJSONResponseSerializer serializer]; 58 | [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){ 59 | 60 | NSLog(@"Success in uploading: %@ %@", operation.responseString,operation.responseObject); 61 | 62 | }failure:^(AFHTTPRequestOperation *operation, NSError *error){ 63 | 64 | NSLog(@"Error in uploading: %@,%@,%ld", error,operation.responseString,(long)operation.response.statusCode); 65 | }]; 66 | 67 | [operation start]; 68 | 69 | } 70 | @end 71 | -------------------------------------------------------------------------------- /client/s3streamer/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kristjanmik/ios-nodejs-s3-streamer/bf9e3faf082b039f068c904430f476b4b96b77e5/client/s3streamer/image.png -------------------------------------------------------------------------------- /client/s3streamer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // s3streamer 4 | // 5 | // Created by Kristján Ingi Mikaelsson on 26/04/2015. 6 | // Copyright (c) 2015 Appollo x. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /client/s3streamerTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.appollox.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /client/s3streamerTests/s3streamerTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // s3streamerTests.m 3 | // s3streamerTests 4 | // 5 | // Created by Kristján Ingi Mikaelsson on 26/04/2015. 6 | // Copyright (c) 2015 Appollo x. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface s3streamerTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation s3streamerTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /server/README.md: -------------------------------------------------------------------------------- 1 | # s3-streamer server 2 | 3 | ## Usage 4 | 5 | Getting started is done in a few steps. 6 | 7 | ### 1. Install dependencies: 8 | 9 | ```sh 10 | $ npm i 11 | ``` 12 | 13 | --- 14 | 15 | ### 2. Run the project 16 | 17 | ```sh 18 | $ node . 19 | ``` 20 | 21 | --- 22 | 23 | 24 | The application will run at port 3200 -------------------------------------------------------------------------------- /server/index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var uuid = require('uuid'); 3 | var express = require('express'); 4 | var app = express(); 5 | var AWS = require('aws-sdk'); 6 | var compress = require('compression'); 7 | 8 | app.use(compress()); //GZip 9 | app.enable('trust proxy'); 10 | app.disable('x-powered-by'); //For security 11 | app.set('json spaces', 0); 12 | 13 | AWS.config.accessKeyId = process.env.ACCESSKEY || 'YOURACCESSKEY'; 14 | AWS.config.secretAccessKey = process.env.SECRETKEY || 'YOURSECRET'; 15 | var bucket = process.env.BUCKET || 'YOURBUCKETNAME'; 16 | 17 | var s3 = new AWS.S3({params: {Bucket: bucket}}); 18 | 19 | app.post('/upload',function(req,res){ 20 | var apiKey = req.headers['app-apikey']; 21 | 22 | console.log('Got apiKey',apiKey); 23 | 24 | //Pause the upload and validate 25 | req.pause(); 26 | 27 | //Do some validation with your datastore 28 | if(apiKey !== 'abcdefg'){ 29 | return res.status(401).json({ 30 | error: 'Not authenticated' 31 | }); 32 | } 33 | 34 | var uniqueId = uuid.v4(); //Random seed 35 | 36 | if(req.headers['content-type'] !== 'image/png'){ 37 | return res.status(400).json({ 38 | error: 'Wrong content-type' 39 | }); 40 | } 41 | 42 | if(parseInt(req.headers['content-length']) === 0){ 43 | console.error('No content given'); 44 | return res.status(500).json({ 45 | error: 'No content given' 46 | }); 47 | } 48 | 49 | var s3Path = 'somefolder/' + uniqueId + '.png'; 50 | s3.upload({ 51 | Body: req, //This is the actual pipe 52 | ContentType: 'image/png', 53 | Key: s3Path 54 | }).on('httpUploadProgress', function(evt) { 55 | console.log('PROCESS',evt); 56 | }).send(function(error, data) { 57 | if(error){ 58 | return res.status(500).json({ 59 | error: 'Unable to upload media' 60 | }); 61 | } 62 | //All is done! 63 | //Store the uniqueId somewhere 64 | 65 | console.log('Done!','File stored at',s3Path); 66 | 67 | return res.json({ 68 | message: 'upload was succesful' 69 | }); 70 | }); 71 | }); 72 | 73 | app.listen(3200,function(){ 74 | console.log('Listening on port',3200); 75 | }); -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "s3-streamer", 3 | "version": "0.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "BSD-2-Clause", 11 | "dependencies": { 12 | "uuid": "~2.0.1", 13 | "express": "~4.12.3", 14 | "aws-sdk": "~2.1.25", 15 | "compression": "~1.4.3" 16 | } 17 | } 18 | --------------------------------------------------------------------------------