diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bb02cf6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,54 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md + +fastlane/report.xml +fastlane/screenshots +Pods/CocoaPodsKeys \ No newline at end of file diff --git a/README.md b/README.md index 503a8f9..938b680 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -# passion-project \ No newline at end of file +# passion-project +- \ No newline at end of file diff --git a/Strike/.DS_Store b/Strike/.DS_Store new file mode 100644 index 0000000..c18c4ad Binary files /dev/null and b/Strike/.DS_Store differ diff --git a/Strike/Podfile b/Strike/Podfile new file mode 100644 index 0000000..d63e0ab --- /dev/null +++ b/Strike/Podfile @@ -0,0 +1,10 @@ +pod "Spark-SDK" +pod "SparkSetup" + +plugin 'cocoapods-keys', { + :project => “Strike1”, + :keys => [ + "Username", + "Password" + ] +} \ No newline at end of file diff --git a/Strike/Podfile.lock b/Strike/Podfile.lock new file mode 100644 index 0000000..ee6ceec --- /dev/null +++ b/Strike/Podfile.lock @@ -0,0 +1,57 @@ +PODS: + - AFNetworking (2.6.3): + - AFNetworking/NSURLConnection (= 2.6.3) + - AFNetworking/NSURLSession (= 2.6.3) + - AFNetworking/Reachability (= 2.6.3) + - AFNetworking/Security (= 2.6.3) + - AFNetworking/Serialization (= 2.6.3) + - AFNetworking/UIKit (= 2.6.3) + - AFNetworking/NSURLConnection (2.6.3): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/NSURLSession (2.6.3): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (2.6.3) + - AFNetworking/Security (2.6.3) + - AFNetworking/Serialization (2.6.3) + - AFNetworking/UIKit (2.6.3): + - AFNetworking/NSURLConnection + - AFNetworking/NSURLSession + - Keys (1.0.0) + - Spark-SDK (0.3.4): + - Spark-SDK/Helpers (= 0.3.4) + - Spark-SDK/SDK (= 0.3.4) + - Spark-SDK/Helpers (0.3.4) + - Spark-SDK/SDK (0.3.4): + - AFNetworking (< 3.0.0) + - Spark-SDK/Helpers + - SparkSetup (0.3.3): + - SparkSetup/Comm (= 0.3.3) + - SparkSetup/Core (= 0.3.3) + - SparkSetup/Resources (= 0.3.3) + - SparkSetup/Comm (0.3.3) + - SparkSetup/Core (0.3.3): + - Spark-SDK + - SparkSetup/Comm + - SparkSetup/Resources + - SparkSetup/Resources (0.3.3) + +DEPENDENCIES: + - Keys (from `Pods/CocoaPodsKeys`) + - Spark-SDK + - SparkSetup + +EXTERNAL SOURCES: + Keys: + :path: Pods/CocoaPodsKeys + +SPEC CHECKSUMS: + AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60 + Keys: 7d2ff6ff42f6903358267ce56e9392f83c31acfe + Spark-SDK: f5dad30a5afa319f43ca570a64f241c73c693641 + SparkSetup: f9618dd24548ab8a024efdaa65a89f63ed44a7ee + +COCOAPODS: 0.39.0 diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h new file mode 100644 index 0000000..cf6def4 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1,70 @@ +// AFHTTPRequestOperation.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import "AFURLConnectionOperation.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + `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. + */ +@interface AFHTTPRequestOperation : AFURLConnectionOperation + +///------------------------------------------------ +/// @name Getting HTTP URL Connection Information +///------------------------------------------------ + +/** + The last HTTP response received by the operation's connection. + */ +@property (readonly, nonatomic, strong, nullable) NSHTTPURLResponse *response; + +/** + 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. + + @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + 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. + */ +@property (readonly, nonatomic, strong, nullable) id responseObject; + +///----------------------------------------------------------- +/// @name Setting Completion Block Success / Failure Callbacks +///----------------------------------------------------------- + +/** + 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. + + This method should be overridden in subclasses in order to specify the response object passed into the success block. + + @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. + @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. + */ +- (void)setCompletionBlockWithSuccess:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m new file mode 100644 index 0000000..b8deda8 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m @@ -0,0 +1,206 @@ +// AFHTTPRequestOperation.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPRequestOperation.h" + +static dispatch_queue_t http_request_operation_processing_queue() { + static dispatch_queue_t af_http_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_http_request_operation_processing_queue; +} + +static dispatch_group_t http_request_operation_completion_group() { + static dispatch_group_t af_http_request_operation_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_http_request_operation_completion_group = dispatch_group_create(); + }); + + return af_http_request_operation_completion_group; +} + +#pragma mark - + +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSURLResponse *response; +@end + +@interface AFHTTPRequestOperation () +@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; +@property (readwrite, nonatomic, strong) id responseObject; +@property (readwrite, nonatomic, strong) NSError *responseSerializationError; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@end + +@implementation AFHTTPRequestOperation +@dynamic response; +@dynamic lock; + +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { + self = [super initWithRequest:urlRequest]; + if (!self) { + return nil; + } + + self.responseSerializer = [AFHTTPResponseSerializer serializer]; + + return self; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [self.lock lock]; + _responseSerializer = responseSerializer; + self.responseObject = nil; + self.responseSerializationError = nil; + [self.lock unlock]; +} + +- (id)responseObject { + [self.lock lock]; + if (!_responseObject && [self isFinished] && !self.error) { + NSError *error = nil; + self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error]; + if (error) { + self.responseSerializationError = error; + } + } + [self.lock unlock]; + + return _responseObject; +} + +- (NSError *)error { + if (_responseSerializationError) { + return _responseSerializationError; + } else { + return [super error]; + } +} + +#pragma mark - AFHTTPRequestOperation + +- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + self.completionBlock = ^{ + if (self.completionGroup) { + dispatch_group_enter(self.completionGroup); + } + + dispatch_async(http_request_operation_processing_queue(), ^{ + if (self.error) { + if (failure) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + id responseObject = self.responseObject; + if (self.error) { + if (failure) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { + dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ + success(self, responseObject); + }); + } + } + } + + if (self.completionGroup) { + dispatch_group_leave(self.completionGroup); + } + }); + }; +#pragma clang diagnostic pop +} + +#pragma mark - AFURLRequestOperation + +- (void)pause { + [super pause]; + + u_int64_t offset = 0; + if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { + offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; + } else { + offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; + } + + NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; + if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { + [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; + } + [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; + self.request = mutableURLRequest; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestOperation *operation = [super copyWithZone:zone]; + + operation.responseSerializer = [self.responseSerializer copyWithZone:zone]; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +@end diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h new file mode 100644 index 0000000..8170811 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1,326 @@ +// AFHTTPRequestOperationManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +#import "AFHTTPRequestOperation.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#import "AFNetworkReachabilityManager.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all request operation construction for an `AFHTTPRequestOperationManager` subclass, override `HTTPRequestOperationWithRequest:success:failure`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSSecureCoding & NSCopying Caveats + + `AFHTTPRequestOperationManager` conforms to the `NSSecureCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however: + + - Archives and copies of HTTP clients will be initialized with an empty operation queue. + - NSSecureCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set. + */ +@interface AFHTTPRequestOperationManager : NSObject + +/** + The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong, nullable) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + 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 a JSON serializer, which serializes data from responses with a `application/json` MIME type, and falls back to the raw data 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. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + The operation queue on which request operations are scheduled and run. + */ +@property (nonatomic, strong) NSOperationQueue *operationQueue; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether request operations should consult the credential storage for authenticating the connection. `YES` by default. + + @see AFURLConnectionOperation -shouldUseCredentialStorage + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + The credential used by request operations for authentication challenges. + + @see AFURLConnectionOperation -credential + */ +@property (nonatomic, strong, nullable) NSURLCredential *credential; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created request operations to evaluate server trust for secure connections. `AFHTTPRequestOperationManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///------------------------------------ +/// @name Managing Network Reachability +///------------------------------------ + +/** + The network reachability manager. `AFHTTPRequestOperationManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for the `completionBlock` of request operations. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_USE_OBJC +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign, nullable) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for the `completionBlock` of request operations. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_USE_OBJC +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign, nullable) dispatch_group_t completionGroup; +#endif + +///--------------------------------------------- +/// @name Creating and Initializing HTTP Clients +///--------------------------------------------- + +/** + Creates and returns an `AFHTTPRequestOperationManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPRequestOperationManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url NS_DESIGNATED_INITIALIZER; + +///--------------------------------------- +/// @name Managing HTTP Request Operations +///--------------------------------------- + +/** + Creates an `AFHTTPRequestOperation`, and sets the response serializers to that of the HTTP client. + + @param request The request object to be loaded asynchronously during execution of the operation. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. + @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 two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. + */ +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `AFHTTPRequestOperation` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @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 two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)GET:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation * __nullable operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single arguments: the request operation. + @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 two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)HEAD:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation))success + failure:(nullable void (^)(AFHTTPRequestOperation * __nullable operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @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 two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation * __nullable operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @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 two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation * __nullable operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @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 two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)PUT:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation * __nullable operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @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 two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)PATCH:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation * __nullable operation, NSError *error))failure; + +/** + Creates and runs an `AFHTTPRequestOperation` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. + @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 two arguments: the request operation and the error describing the network or parsing error that occurred. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (nullable AFHTTPRequestOperation *)DELETE:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(nullable void (^)(AFHTTPRequestOperation * __nullable operation, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m new file mode 100644 index 0000000..ee682b7 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m @@ -0,0 +1,290 @@ +// AFHTTPRequestOperationManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "AFHTTPRequestOperationManager.h" +#import "AFHTTPRequestOperation.h" + +#import +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +@interface AFHTTPRequestOperationManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPRequestOperationManager + ++ (instancetype)manager { + return [[self alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + self = [super init]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; + + self.operationQueue = [[NSOperationQueue alloc] init]; + + self.shouldUseCredentialStorage = YES; + + return self; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +#endif + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - + +- (AFHTTPRequestOperation *)HTTPRequestOperationWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + return [self HTTPRequestOperationWithRequest:request success:success failure:failure]; +} + +- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + operation.responseSerializer = self.responseSerializer; + operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + operation.credential = self.credential; + operation.securityPolicy = self.securityPolicy; + + [operation setCompletionBlockWithSuccess:success failure:failure]; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +#pragma mark - + +- (AFHTTPRequestOperation *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) { + if (success) { + success(requestOperation); + } + } failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure +{ + AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; + + [self.operationQueue addOperation:operation]; + + return operation; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))]; + + self = [self initWithBaseURL:baseURL]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))]; + if (decodedPolicy) { + self.securityPolicy = decodedPolicy; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; + [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestOperationManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone]; + + return HTTPClient; +} + +@end diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h new file mode 100644 index 0000000..04b0876 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1,253 @@ +// AFHTTPSessionManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#if !TARGET_OS_WATCH +#import +#endif +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +#import "AFURLSessionManager.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths. + + ## Subclassing Notes + + Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. + + For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. + + ## Methods to Override + + To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`. + + ## Serialization + + Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. + + Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` + + ## URL Construction Using Relative Paths + + For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. + + Below are a few examples of how `baseURL` and relative paths interact: + + NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; + [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz + [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo + [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo + [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ + [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ + + Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || TARGET_OS_WATCH + +NS_ASSUME_NONNULL_BEGIN + +@interface AFHTTPSessionManager : AFURLSessionManager + +/** + The URL used to construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. + */ +@property (readonly, nonatomic, strong, nullable) NSURL *baseURL; + +/** + Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. + + @warning `requestSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + 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 instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns an `AFHTTPSessionManager` object. + */ ++ (instancetype)manager; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + @param url The base URL for the HTTP client. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url; + +/** + Initializes an `AFHTTPSessionManager` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. + @param configuration The configuration used to create the managed session. + + @return The newly-initialized HTTP client + */ +- (instancetype)initWithBaseURL:(nullable NSURL *)url + sessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates and runs an `NSURLSessionDataTask` with a `GET` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * __nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task))success + failure:(nullable void (^)(NSURLSessionDataTask * __nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * __nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(nullable id)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * __nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PUT` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * __nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * __nullable task, NSError *error))failure; + +/** + Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. + + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded according to the client request serializer. + @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. + @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. + + @see -dataTaskWithRequest:completionHandler: + */ +- (nullable NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(nullable id)parameters + success:(nullable void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(nullable void (^)(NSURLSessionDataTask * __nullable task, NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m new file mode 100644 index 0000000..ed46b26 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m @@ -0,0 +1,328 @@ +// AFHTTPSessionManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFHTTPSessionManager.h" + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || TARGET_WATCH_OS + +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" + +#import +#import + +#ifdef _SYSTEMCONFIGURATION_H +#import +#import +#import +#import +#import +#endif + +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#endif + +@interface AFHTTPSessionManager () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@end + +@implementation AFHTTPSessionManager +@dynamic responseSerializer; + ++ (instancetype)manager { + return [[[self class] alloc] initWithBaseURL:nil]; +} + +- (instancetype)init { + return [self initWithBaseURL:nil]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url { + return [self initWithBaseURL:url sessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + return [self initWithBaseURL:nil sessionConfiguration:configuration]; +} + +- (instancetype)initWithBaseURL:(NSURL *)url + sessionConfiguration:(NSURLSessionConfiguration *)configuration +{ + self = [super initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected + if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { + url = [url URLByAppendingPathComponent:@""]; + } + + self.baseURL = url; + + self.requestSerializer = [AFHTTPRequestSerializer serializer]; + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + return self; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +#endif + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + NSParameterAssert(requestSerializer); + + _requestSerializer = requestSerializer; +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + NSParameterAssert(responseSerializer); + + [super setResponseSerializer:responseSerializer]; +} + +#pragma mark - + +- (NSURLSessionDataTask *)GET:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)HEAD:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"HEAD" URLString:URLString parameters:parameters success:^(NSURLSessionDataTask *task, __unused id responseObject) { + if (success) { + success(task); + } + } failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"POST" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)POST:(NSString *)URLString + parameters:(id)parameters + constructingBodyWithBlock:(void (^)(id formData))block + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(task, error); + } + } else { + if (success) { + success(task, responseObject); + } + } + }]; + + [task resume]; + + return task; +} + +- (NSURLSessionDataTask *)PUT:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PUT" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)PATCH:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"PATCH" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)DELETE:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure +{ + NSURLSessionDataTask *dataTask = [self dataTaskWithHTTPMethod:@"DELETE" URLString:URLString parameters:parameters success:success failure:failure]; + + [dataTask resume]; + + return dataTask; +} + +- (NSURLSessionDataTask *)dataTaskWithHTTPMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + success:(void (^)(NSURLSessionDataTask *, id))success + failure:(void (^)(NSURLSessionDataTask *, NSError *))failure +{ + NSError *serializationError = nil; + NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError]; + if (serializationError) { + if (failure) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(self.completionQueue ?: dispatch_get_main_queue(), ^{ + failure(nil, serializationError); + }); +#pragma clang diagnostic pop + } + + return nil; + } + + __block NSURLSessionDataTask *dataTask = nil; + dataTask = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { + if (error) { + if (failure) { + failure(dataTask, error); + } + } else { + if (success) { + success(dataTask, responseObject); + } + } + }]; + + return dataTask; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + if (!configuration) { + NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"]; + if (configurationIdentifier) { +#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1100) + configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier]; +#else + configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier]; +#endif + } + } + + self = [self initWithBaseURL:baseURL sessionConfiguration:configuration]; + if (!self) { + return nil; + } + + self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; + self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; + AFSecurityPolicy *decodedPolicy = [decoder decodeObjectOfClass:[AFSecurityPolicy class] forKey:NSStringFromSelector(@selector(securityPolicy))]; + if (decodedPolicy) { + self.securityPolicy = decodedPolicy; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; + if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; + } else { + [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"]; + } + [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; + [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; + [coder encodeObject:self.securityPolicy forKey:NSStringFromSelector(@selector(securityPolicy))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; + + HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; + HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; + HTTPClient.securityPolicy = [self.securityPolicy copyWithZone:zone]; + return HTTPClient; +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h b/Strike/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h new file mode 100644 index 0000000..e2eb945 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1,207 @@ +// AFNetworkReachabilityManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#if !TARGET_OS_WATCH +#import + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { + AFNetworkReachabilityStatusUnknown = -1, + AFNetworkReachabilityStatusNotReachable = 0, + AFNetworkReachabilityStatusReachableViaWWAN = 1, + AFNetworkReachabilityStatusReachableViaWiFi = 2, +}; + +NS_ASSUME_NONNULL_BEGIN + +/** + `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + + 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. + + See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/) + + @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. + */ +@interface AFNetworkReachabilityManager : NSObject + +/** + The current network reachability status. + */ +@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; + +/** + Whether or not the network is currently reachable. + */ +@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; + +/** + Whether or not the network is currently reachable via WWAN. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; + +/** + Whether or not the network is currently reachable via WiFi. + */ +@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Returns the shared network reachability manager. + */ ++ (instancetype)sharedManager; + +/** + Creates and returns a network reachability manager for the specified domain. + + @param domain The domain used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified domain. + */ ++ (instancetype)managerForDomain:(NSString *)domain; + +/** + Creates and returns a network reachability manager for the socket address. + + @param address The socket address (`sockaddr_in`) used to evaluate network reachability. + + @return An initialized network reachability manager, actively monitoring the specified socket address. + */ ++ (instancetype)managerForAddress:(const void *)address; + +/** + Initializes an instance of a network reachability manager from the specified reachability object. + + @param reachability The reachability object to monitor. + + @return An initialized network reachability manager, actively monitoring the specified reachability. + */ +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; + +///-------------------------------------------------- +/// @name Starting & Stopping Reachability Monitoring +///-------------------------------------------------- + +/** + Starts monitoring for changes in network reachability status. + */ +- (void)startMonitoring; + +/** + Stops monitoring for changes in network reachability status. + */ +- (void)stopMonitoring; + +///------------------------------------------------- +/// @name Getting Localized Reachability Description +///------------------------------------------------- + +/** + Returns a localized string representation of the current network reachability status. + */ +- (NSString *)localizedNetworkReachabilityStatusString; + +///--------------------------------------------------- +/// @name Setting Network Reachability Change Callback +///--------------------------------------------------- + +/** + Sets a callback to be executed when the network availability of the `baseURL` host changes. + + @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`. + */ +- (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Network Reachability + + The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. + + enum { + AFNetworkReachabilityStatusUnknown, + AFNetworkReachabilityStatusNotReachable, + AFNetworkReachabilityStatusReachableViaWWAN, + AFNetworkReachabilityStatusReachableViaWiFi, + } + + `AFNetworkReachabilityStatusUnknown` + The `baseURL` host reachability is not known. + + `AFNetworkReachabilityStatusNotReachable` + The `baseURL` host cannot be reached. + + `AFNetworkReachabilityStatusReachableViaWWAN` + The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. + + `AFNetworkReachabilityStatusReachableViaWiFi` + The `baseURL` host can be reached via a Wi-Fi connection. + + ### Keys for Notification UserInfo Dictionary + + Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. + + `AFNetworkingReachabilityNotificationStatusItem` + A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. + The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. + */ + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when network reachability changes. + 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. + + @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`). + */ +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification; +FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem; + +///-------------------- +/// @name Functions +///-------------------- + +/** + Returns a localized string representation of an `AFNetworkReachabilityStatus` value. + */ +FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); + +NS_ASSUME_NONNULL_END +#endif diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m b/Strike/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m new file mode 100644 index 0000000..fe67781 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m @@ -0,0 +1,248 @@ +// AFNetworkReachabilityManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkReachabilityManager.h" +#if !TARGET_OS_WATCH + +#import +#import +#import +#import +#import + +NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; +NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; + +typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); + +NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusNotReachable: + return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWWAN: + return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); + case AFNetworkReachabilityStatusReachableViaWiFi: + return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); + case AFNetworkReachabilityStatusUnknown: + default: + return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); + } +} + +static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { + BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); + BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); + BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); + BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); + BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); + + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; + if (isNetworkReachable == NO) { + status = AFNetworkReachabilityStatusNotReachable; + } +#if TARGET_OS_IPHONE + else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { + status = AFNetworkReachabilityStatusReachableViaWWAN; + } +#endif + else { + status = AFNetworkReachabilityStatusReachableViaWiFi; + } + + return status; +} + +/** + * Queue a status change notification for the main thread. + * + * This is done to ensure that the notifications are received in the same order + * as they are sent. If notifications are sent directly, it is possible that + * a queued notification (for an earlier status condition) is processed after + * the later update, resulting in the listener being left in the wrong state. + */ +static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) { + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + dispatch_async(dispatch_get_main_queue(), ^{ + if (block) { + block(status); + } + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; + [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; + }); +} + +static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { + AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info); +} + +static const void * AFNetworkReachabilityRetainCallback(const void *info) { + return Block_copy(info); +} + +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + Block_release(info); + } +} + +@interface AFNetworkReachabilityManager () +@property (readwrite, nonatomic, strong) id networkReachability; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; +@end + +@implementation AFNetworkReachabilityManager + ++ (instancetype)sharedManager { + static AFNetworkReachabilityManager *_sharedManager = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + struct sockaddr_in address; + bzero(&address, sizeof(address)); + address.sin_len = sizeof(address); + address.sin_family = AF_INET; + + _sharedManager = [self managerForAddress:&address]; + }); + + return _sharedManager; +} + +#ifndef __clang_analyzer__ ++ (instancetype)managerForDomain:(NSString *)domain { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); + + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + + return manager; +} +#endif + +#ifndef __clang_analyzer__ ++ (instancetype)managerForAddress:(const void *)address { + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); + AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; + + return manager; +} +#endif + +- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { + self = [super init]; + if (!self) { + return nil; + } + + self.networkReachability = CFBridgingRelease(reachability); + self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; + + return self; +} + +- (instancetype)init NS_UNAVAILABLE +{ + return nil; +} + +- (void)dealloc { + [self stopMonitoring]; +} + +#pragma mark - + +- (BOOL)isReachable { + return [self isReachableViaWWAN] || [self isReachableViaWiFi]; +} + +- (BOOL)isReachableViaWWAN { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; +} + +- (BOOL)isReachableViaWiFi { + return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; +} + +#pragma mark - + +- (void)startMonitoring { + [self stopMonitoring]; + + if (!self.networkReachability) { + return; + } + + __weak __typeof(self)weakSelf = self; + AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + + strongSelf.networkReachabilityStatus = status; + if (strongSelf.networkReachabilityStatusBlock) { + strongSelf.networkReachabilityStatusBlock(status); + } + + }; + + id networkReachability = self.networkReachability; + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; + SCNetworkReachabilitySetCallback((__bridge SCNetworkReachabilityRef)networkReachability, AFNetworkReachabilityCallback, &context); + SCNetworkReachabilityScheduleWithRunLoop((__bridge SCNetworkReachabilityRef)networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ + SCNetworkReachabilityFlags flags; + if (SCNetworkReachabilityGetFlags((__bridge SCNetworkReachabilityRef)networkReachability, &flags)) { + AFPostReachabilityStatusChange(flags, callback); + } + }); +} + +- (void)stopMonitoring { + if (!self.networkReachability) { + return; + } + + SCNetworkReachabilityUnscheduleFromRunLoop((__bridge SCNetworkReachabilityRef)self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); +} + +#pragma mark - + +- (NSString *)localizedNetworkReachabilityStatusString { + return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); +} + +#pragma mark - + +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { + self.networkReachabilityStatusBlock = block; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { + return [NSSet setWithObject:@"networkReachabilityStatus"]; + } + + return [super keyPathsForValuesAffectingValueForKey:key]; +} + +@end +#endif diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFNetworking.h b/Strike/Pods/AFNetworking/AFNetworking/AFNetworking.h new file mode 100644 index 0000000..6d442bb --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFNetworking.h @@ -0,0 +1,46 @@ +// AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +#ifndef _AFNETWORKING_ + #define _AFNETWORKING_ + + #import "AFURLRequestSerialization.h" + #import "AFURLResponseSerialization.h" + #import "AFSecurityPolicy.h" +#if !TARGET_OS_WATCH + #import "AFNetworkReachabilityManager.h" + #import "AFURLConnectionOperation.h" + #import "AFHTTPRequestOperation.h" + #import "AFHTTPRequestOperationManager.h" +#endif + +#if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ + ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) || \ + TARGET_OS_WATCH ) + #import "AFURLSessionManager.h" + #import "AFHTTPSessionManager.h" +#endif + +#endif /* _AFNETWORKING_ */ diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h b/Strike/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h new file mode 100644 index 0000000..d968f49 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1,142 @@ +// AFSecurityPolicy.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, +}; + +/** + `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + + 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. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFSecurityPolicy : NSObject + +/** + The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. + */ +@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; + +/** + 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. Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. + */ +@property (nonatomic, strong, nullable) NSArray *pinnedCertificates; + +/** + Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowInvalidCertificates; + +/** + Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. + */ +@property (nonatomic, assign) BOOL validatesDomainName; + +///----------------------------------------- +/// @name Getting Specific Security Policies +///----------------------------------------- + +/** + Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. + + @return The default security policy. + */ ++ (instancetype)defaultPolicy; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a security policy with the specified pinning mode. + + @param pinningMode The SSL pinning mode. + + @return A new security policy. + */ ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; + +///------------------------------ +/// @name Evaluating Server Trust +///------------------------------ + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + + @return Whether or not to trust the server. + + @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; + +/** + Whether or not the specified server trust should be accepted, based on the security policy. + + This method should be used when responding to an authentication challenge from a server. + + @param serverTrust The X.509 certificate trust of the server. + @param domain The domain of serverTrust. If `nil`, the domain will not be validated. + + @return Whether or not to trust the server. + */ +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(nullable NSString *)domain; + +@end + +NS_ASSUME_NONNULL_END + +///---------------- +/// @name Constants +///---------------- + +/** + ## SSL Pinning Modes + + The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. + + enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModeNone` + Do not used pinned certificates to validate servers. + + `AFSSLPinningModePublicKey` + Validate host certificates against public keys of pinned certificates. + + `AFSSLPinningModeCertificate` + Validate host certificates against pinned certificates. +*/ diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m b/Strike/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m new file mode 100644 index 0000000..2624775 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m @@ -0,0 +1,347 @@ +// AFSecurityPolicy.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFSecurityPolicy.h" + +#import + +#if !TARGET_OS_IOS && !TARGET_OS_WATCH +static NSData * AFSecKeyGetData(SecKeyRef key) { + CFDataRef data = NULL; + + __Require_noErr_Quiet(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); + + return (__bridge_transfer NSData *)data; + +_out: + if (data) { + CFRelease(data); + } + + return nil; +} +#endif + +static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { +#if TARGET_OS_IOS || TARGET_OS_WATCH + return [(__bridge id)key1 isEqual:(__bridge id)key2]; +#else + return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; +#endif +} + +static id AFPublicKeyForCertificate(NSData *certificate) { + id allowedPublicKey = nil; + SecCertificateRef allowedCertificate; + SecCertificateRef allowedCertificates[1]; + CFArrayRef tempCertificates = nil; + SecPolicyRef policy = nil; + SecTrustRef allowedTrust = nil; + SecTrustResultType result; + + allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); + __Require_Quiet(allowedCertificate != NULL, _out); + + allowedCertificates[0] = allowedCertificate; + tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); + + policy = SecPolicyCreateBasicX509(); + __Require_noErr_Quiet(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); + __Require_noErr_Quiet(SecTrustEvaluate(allowedTrust, &result), _out); + + allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); + +_out: + if (allowedTrust) { + CFRelease(allowedTrust); + } + + if (policy) { + CFRelease(policy); + } + + if (tempCertificates) { + CFRelease(tempCertificates); + } + + if (allowedCertificate) { + CFRelease(allowedCertificate); + } + + return allowedPublicKey; +} + +static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { + BOOL isValid = NO; + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(serverTrust, &result), _out); + + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + +_out: + return isValid; +} + +static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } + + return [NSArray arrayWithArray:trustChain]; +} + +static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + + SecTrustRef trust; + __Require_noErr_Quiet(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); + + SecTrustResultType result; + __Require_noErr_Quiet(SecTrustEvaluate(trust, &result), _out); + + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + _out: + if (trust) { + CFRelease(trust); + } + + if (certificates) { + CFRelease(certificates); + } + + continue; + } + CFRelease(policy); + + return [NSArray arrayWithArray:trustChain]; +} + +#pragma mark - + +@interface AFSecurityPolicy() +@property (readwrite, nonatomic, assign) AFSSLPinningMode SSLPinningMode; +@property (readwrite, nonatomic, strong) NSArray *pinnedPublicKeys; +@end + +@implementation AFSecurityPolicy + ++ (NSArray *)defaultPinnedCertificates { + static NSArray *_defaultPinnedCertificates = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; + NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; + + NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; + for (NSString *path in paths) { + NSData *certificateData = [NSData dataWithContentsOfFile:path]; + [certificates addObject:certificateData]; + } + + _defaultPinnedCertificates = [[NSArray alloc] initWithArray:certificates]; + }); + + return _defaultPinnedCertificates; +} + ++ (instancetype)defaultPolicy { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = AFSSLPinningModeNone; + + return securityPolicy; +} + ++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { + AFSecurityPolicy *securityPolicy = [[self alloc] init]; + securityPolicy.SSLPinningMode = pinningMode; + + [securityPolicy setPinnedCertificates:[self defaultPinnedCertificates]]; + + return securityPolicy; +} + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + self.validatesDomainName = YES; + + return self; +} + +- (void)setPinnedCertificates:(NSArray *)pinnedCertificates { + _pinnedCertificates = [[NSOrderedSet orderedSetWithArray:pinnedCertificates] array]; + + if (self.pinnedCertificates) { + NSMutableArray *mutablePinnedPublicKeys = [NSMutableArray arrayWithCapacity:[self.pinnedCertificates count]]; + for (NSData *certificate in self.pinnedCertificates) { + id publicKey = AFPublicKeyForCertificate(certificate); + if (!publicKey) { + continue; + } + [mutablePinnedPublicKeys addObject:publicKey]; + } + self.pinnedPublicKeys = [NSArray arrayWithArray:mutablePinnedPublicKeys]; + } else { + self.pinnedPublicKeys = nil; + } +} + +#pragma mark - + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust { + return [self evaluateServerTrust:serverTrust forDomain:nil]; +} + +- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust + forDomain:(NSString *)domain +{ + if (domain && self.allowInvalidCertificates && self.validatesDomainName && (self.SSLPinningMode == AFSSLPinningModeNone || [self.pinnedCertificates count] == 0)) { + // https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html + // According to the docs, you should only trust your provided certs for evaluation. + // Pinned certificates are added to the trust. Without pinned certificates, + // there is nothing to evaluate against. + // + // From Apple Docs: + // "Do not implicitly trust self-signed certificates as anchors (kSecTrustOptionImplicitAnchors). + // Instead, add your own (self-signed) CA certificate to the list of trusted anchors." + NSLog(@"In order to validate a domain name for self signed certificates, you MUST use pinning."); + return NO; + } + + NSMutableArray *policies = [NSMutableArray array]; + if (self.validatesDomainName) { + [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; + } else { + [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; + } + + SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); + + if (self.SSLPinningMode == AFSSLPinningModeNone) { + return self.allowInvalidCertificates || AFServerTrustIsValid(serverTrust); + } else if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { + return NO; + } + + NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); + switch (self.SSLPinningMode) { + case AFSSLPinningModeNone: + default: + return NO; + case AFSSLPinningModeCertificate: { + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + for (NSData *certificateData in self.pinnedCertificates) { + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + } + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + + if (!AFServerTrustIsValid(serverTrust)) { + return NO; + } + + NSUInteger trustedCertificateCount = 0; + for (NSData *trustChainCertificate in serverCertificates) { + if ([self.pinnedCertificates containsObject:trustChainCertificate]) { + trustedCertificateCount++; + } + } + return trustedCertificateCount > 0; + } + case AFSSLPinningModePublicKey: { + NSUInteger trustedPublicKeyCount = 0; + NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); + + for (id trustChainPublicKey in publicKeys) { + for (id pinnedPublicKey in self.pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + trustedPublicKeyCount += 1; + } + } + } + return trustedPublicKeyCount > 0; + } + } + + return NO; +} + +#pragma mark - NSKeyValueObserving + ++ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { + return [NSSet setWithObject:@"pinnedCertificates"]; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder { + + self = [self init]; + if (!self) { + return nil; + } + + self.SSLPinningMode = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(SSLPinningMode))] unsignedIntegerValue]; + self.allowInvalidCertificates = [decoder decodeBoolForKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; + self.validatesDomainName = [decoder decodeBoolForKey:NSStringFromSelector(@selector(validatesDomainName))]; + self.pinnedCertificates = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(pinnedCertificates))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:[NSNumber numberWithUnsignedInteger:self.SSLPinningMode] forKey:NSStringFromSelector(@selector(SSLPinningMode))]; + [coder encodeBool:self.allowInvalidCertificates forKey:NSStringFromSelector(@selector(allowInvalidCertificates))]; + [coder encodeBool:self.validatesDomainName forKey:NSStringFromSelector(@selector(validatesDomainName))]; + [coder encodeObject:self.pinnedCertificates forKey:NSStringFromSelector(@selector(pinnedCertificates))]; +} + +#pragma mark - NSCopying + +- (instancetype)copyWithZone:(NSZone *)zone { + AFSecurityPolicy *securityPolicy = [[[self class] allocWithZone:zone] init]; + securityPolicy.SSLPinningMode = self.SSLPinningMode; + securityPolicy.allowInvalidCertificates = self.allowInvalidCertificates; + securityPolicy.validatesDomainName = self.validatesDomainName; + securityPolicy.pinnedCertificates = [self.pinnedCertificates copyWithZone:zone]; + + return securityPolicy; +} + +@end diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h b/Strike/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h new file mode 100644 index 0000000..c21119e --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1,344 @@ +// AFURLConnectionOperation.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import +#import "AFURLRequestSerialization.h" +#import "AFURLResponseSerialization.h" +#import "AFSecurityPolicy.h" + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods. + + ## Subclassing Notes + + This is the base class of all network request operations. You may wish to create your own subclass in order to implement additional `NSURLConnection` delegate methods (see "`NSURLConnection` Delegate Methods" below), or to provide additional properties and/or class constructors. + + If you are creating a subclass that communicates over the HTTP or HTTPS protocols, you may want to consider subclassing `AFHTTPRequestOperation` instead, as it supports specifying acceptable content types or status codes. + + ## NSURLConnection Delegate Methods + + `AFURLConnectionOperation` implements the following `NSURLConnection` delegate methods: + + - `connection:didReceiveResponse:` + - `connection:didReceiveData:` + - `connectionDidFinishLoading:` + - `connection:didFailWithError:` + - `connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:` + - `connection:willCacheResponse:` + - `connectionShouldUseCredentialStorage:` + - `connection:needNewBodyStream:` + - `connection:willSendRequestForAuthenticationChallenge:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Callbacks and Completion Blocks + + The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this. + + Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/). + + ## SSL Pinning + + Relying on the CA trust model to validate SSL certificates exposes your app to security vulnerabilities, such as man-in-the-middle attacks. For applications that connect to known servers, SSL certificate pinning provides an increased level of security, by checking server certificate validity against those specified in the app bundle. + + SSL with certificate pinning is strongly recommended for any application that transmits sensitive information to an external webservice. + + Connections will be validated on all matching certificates with a `.cer` extension in the bundle root. + + ## NSCoding & NSCopying Conformance + + `AFURLConnectionOperation` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. However, because of the intrinsic limitations of capturing the exact state of an operation at a particular moment, there are some important caveats to keep in mind: + + ### NSCoding Caveats + + - Encoded operations do not include any block or stream properties. Be sure to set `completionBlock`, `outputStream`, and any callback blocks as necessary when using `-initWithCoder:` or `NSKeyedUnarchiver`. + - Operations are paused on `encodeWithCoder:`. If the operation was encoded while paused or still executing, its archived state will return `YES` for `isReady`. Otherwise, the state of an operation when encoding will remain unchanged. + + ### NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new operation with the `NSURLRequest` of the original. So rather than an exact copy of the operation at that particular instant, the copying mechanism returns a completely new instance, which can be useful for retrying operations. + - A copy of an operation will not include the `outputStream` of the original. + - Operation copies do not include `completionBlock`, as it often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. + */ + +NS_ASSUME_NONNULL_BEGIN + +@interface AFURLConnectionOperation : NSOperation + +///------------------------------- +/// @name Accessing Run Loop Modes +///------------------------------- + +/** + The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing `NSRunLoopCommonModes`. + */ +@property (nonatomic, strong) NSSet *runLoopModes; + +///----------------------------------------- +/// @name Getting URL Connection Information +///----------------------------------------- + +/** + The request used by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSURLRequest *request; + +/** + The last response received by the operation's connection. + */ +@property (readonly, nonatomic, strong, nullable) NSURLResponse *response; + +/** + The error, if any, that occurred in the lifecycle of the request. + */ +@property (readonly, nonatomic, strong, nullable) NSError *error; + +///---------------------------- +/// @name Getting Response Data +///---------------------------- + +/** + The data received during the request. + */ +@property (readonly, nonatomic, strong, nullable) NSData *responseData; + +/** + The string representation of the response data. + */ +@property (readonly, nonatomic, copy, nullable) NSString *responseString; + +/** + The string encoding of the response. + + If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. + */ +@property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. + + This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. + */ +@property (nonatomic, assign) BOOL shouldUseCredentialStorage; + +/** + The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. + + This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. + */ +@property (nonatomic, strong, nullable) NSURLCredential *credential; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used to evaluate server trust for secure connections. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +///------------------------ +/// @name Accessing Streams +///------------------------ + +/** + The input stream used to read data to be sent during the request. + + This property acts as a proxy to the `HTTPBodyStream` property of `request`. + */ +@property (nonatomic, strong) NSInputStream *inputStream; + +/** + The output stream that is used to write data received until the request is finished. + + By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request, with the intermediary `outputStream` property set to `nil`. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. + */ +@property (nonatomic, strong, nullable) NSOutputStream *outputStream; + +///--------------------------------- +/// @name Managing Callback Queues +///--------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_USE_OBJC +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign, nullable) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_USE_OBJC +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign, nullable) dispatch_group_t completionGroup; +#endif + +///--------------------------------------------- +/// @name Managing Request Operation Information +///--------------------------------------------- + +/** + The user info dictionary for the receiver. + */ +@property (nonatomic, strong) NSDictionary *userInfo; +// FIXME: It doesn't seem that this userInfo is used anywhere in the implementation. + +///------------------------------------------------------ +/// @name Initializing an AFURLConnectionOperation Object +///------------------------------------------------------ + +/** + Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. + + This is the designated initializer. + + @param urlRequest The request object to be used by the operation connection. + */ +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest NS_DESIGNATED_INITIALIZER; + +///---------------------------------- +/// @name Pausing / Resuming Requests +///---------------------------------- + +/** + Pauses the execution of the request operation. + + A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. + */ +- (void)pause; + +/** + Whether the request operation is currently paused. + + @return `YES` if the operation is currently paused, otherwise `NO`. + */ +- (BOOL)isPaused; + +/** + Resumes the execution of the paused request operation. + + Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. + */ +- (void)resume; + +///---------------------------------------------- +/// @name Configuring Backgrounding Task Behavior +///---------------------------------------------- + +/** + Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task. + + @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. + */ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(nullable void (^)(void))handler NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); +#endif + +///--------------------------------- +/// @name Setting Progress Callbacks +///--------------------------------- + +/** + Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setUploadProgressBlock:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; + +/** + Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. + + @param block 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. + */ +- (void)setDownloadProgressBlock:(nullable void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; + +///------------------------------------------------- +/// @name Setting NSURLConnection Delegate Callbacks +///------------------------------------------------- + +/** + Sets a block to be executed when the connection will authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequestForAuthenticationChallenge:`. + + @param block A block object to be executed when the connection will authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. This block must invoke one of the challenge-responder methods (NSURLAuthenticationChallengeSender protocol). + + If `allowsInvalidSSLCertificate` is set to YES, `connection:willSendRequestForAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + */ +- (void)setWillSendRequestForAuthenticationChallengeBlock:(nullable void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; + +/** + Sets a block to be executed when the server redirects the request from one URL to another URL, or when the request URL changed by the `NSURLProtocol` subclass handling the request in order to standardize its format, as handled by the `NSURLConnectionDataDelegate` method `connection:willSendRequest:redirectResponse:`. + + @param block A block object to be executed when the request URL was changed. The block returns an `NSURLRequest` object, the URL request to redirect, and takes three arguments: the URL connection object, the the proposed redirected request, and the URL response that caused the redirect. + */ +- (void)setRedirectResponseBlock:(nullable NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block; + + +/** + Sets a block to be executed to modify the response a connection will cache, if any, as handled by the `NSURLConnectionDelegate` method `connection:willCacheResponse:`. + + @param block A block object to be executed to determine what response a connection will cache, if any. The block returns an `NSCachedURLResponse` object, the cached response to store in memory or `nil` to prevent the response from being cached, and takes two arguments: the URL connection object, and the cached response provided for the request. + */ +- (void)setCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block; + +/// + +/** + + */ ++ (NSArray *)batchOfRequestOperations:(nullable NSArray *)operations + progressBlock:(nullable void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(nullable void (^)(NSArray *operations))completionBlock; + +@end + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when an operation begins executing. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationDidStartNotification; + +/** + Posted when an operation finishes. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationDidFinishNotification; + +NS_ASSUME_NONNULL_END diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m b/Strike/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m new file mode 100644 index 0000000..2126ca6 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m @@ -0,0 +1,792 @@ +// AFURLConnectionOperation.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLConnectionOperation.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +#if !__has_feature(objc_arc) +#error AFNetworking must be built with ARC. +// You can turn on ARC for only AFNetworking files by adding -fobjc-arc to the build phase for each of its files. +#endif + +typedef NS_ENUM(NSInteger, AFOperationState) { + AFOperationPausedState = -1, + AFOperationReadyState = 1, + AFOperationExecutingState = 2, + AFOperationFinishedState = 3, +}; + +static dispatch_group_t url_request_operation_completion_group() { + static dispatch_group_t af_url_request_operation_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_request_operation_completion_group = dispatch_group_create(); + }); + + return af_url_request_operation_completion_group; +} + +static dispatch_queue_t url_request_operation_completion_queue() { + static dispatch_queue_t af_url_request_operation_completion_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_request_operation_completion_queue = dispatch_queue_create("com.alamofire.networking.operation.queue", DISPATCH_QUEUE_CONCURRENT ); + }); + + return af_url_request_operation_completion_queue; +} + +static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock"; + +NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start"; +NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish"; + +typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge); +typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse); +typedef NSURLRequest * (^AFURLConnectionOperationRedirectResponseBlock)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse); +typedef void (^AFURLConnectionOperationBackgroundTaskCleanupBlock)(); + +static inline NSString * AFKeyPathFromOperationState(AFOperationState state) { + switch (state) { + case AFOperationReadyState: + return @"isReady"; + case AFOperationExecutingState: + return @"isExecuting"; + case AFOperationFinishedState: + return @"isFinished"; + case AFOperationPausedState: + return @"isPaused"; + default: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + return @"state"; +#pragma clang diagnostic pop + } + } +} + +static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperationState toState, BOOL isCancelled) { + switch (fromState) { + case AFOperationReadyState: + switch (toState) { + case AFOperationPausedState: + case AFOperationExecutingState: + return YES; + case AFOperationFinishedState: + return isCancelled; + default: + return NO; + } + case AFOperationExecutingState: + switch (toState) { + case AFOperationPausedState: + case AFOperationFinishedState: + return YES; + default: + return NO; + } + case AFOperationFinishedState: + return NO; + case AFOperationPausedState: + return toState == AFOperationReadyState; + default: { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunreachable-code" + switch (toState) { + case AFOperationPausedState: + case AFOperationReadyState: + case AFOperationExecutingState: + case AFOperationFinishedState: + return YES; + default: + return NO; + } + } +#pragma clang diagnostic pop + } +} + +@interface AFURLConnectionOperation () +@property (readwrite, nonatomic, assign) AFOperationState state; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@property (readwrite, nonatomic, strong) NSURLConnection *connection; +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSURLResponse *response; +@property (readwrite, nonatomic, strong) NSError *error; +@property (readwrite, nonatomic, strong) NSData *responseData; +@property (readwrite, nonatomic, copy) NSString *responseString; +@property (readwrite, nonatomic, assign) NSStringEncoding responseStringEncoding; +@property (readwrite, nonatomic, assign) long long totalBytesRead; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationBackgroundTaskCleanupBlock backgroundTaskCleanup; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationChallengeBlock authenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationCacheResponseBlock cacheResponse; +@property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse; + +- (void)operationDidStart; +- (void)finish; +- (void)cancelConnection; +@end + +@implementation AFURLConnectionOperation +@synthesize outputStream = _outputStream; + ++ (void)networkRequestThreadEntryPoint:(id)__unused object { + @autoreleasepool { + [[NSThread currentThread] setName:@"AFNetworking"]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + [runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode]; + [runLoop run]; + } +} + ++ (NSThread *)networkRequestThread { + static NSThread *_networkRequestThread = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil]; + [_networkRequestThread start]; + }); + + return _networkRequestThread; +} + +- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { + NSParameterAssert(urlRequest); + + self = [super init]; + if (!self) { + return nil; + } + + _state = AFOperationReadyState; + + self.lock = [[NSRecursiveLock alloc] init]; + self.lock.name = kAFNetworkingLockName; + + self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; + + self.request = urlRequest; + + self.shouldUseCredentialStorage = YES; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + + return self; +} + +- (instancetype)init NS_UNAVAILABLE +{ + return nil; +} + +- (void)dealloc { + if (_outputStream) { + [_outputStream close]; + _outputStream = nil; + } + + if (_backgroundTaskCleanup) { + _backgroundTaskCleanup(); + } +} + +#pragma mark - + +- (void)setResponseData:(NSData *)responseData { + [self.lock lock]; + if (!responseData) { + _responseData = nil; + } else { + _responseData = [NSData dataWithBytes:responseData.bytes length:responseData.length]; + } + [self.lock unlock]; +} + +- (NSString *)responseString { + [self.lock lock]; + if (!_responseString && self.response && self.responseData) { + self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding]; + } + [self.lock unlock]; + + return _responseString; +} + +- (NSStringEncoding)responseStringEncoding { + [self.lock lock]; + if (!_responseStringEncoding && self.response) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (self.response.textEncodingName) { + CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName); + if (IANAEncoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding); + } + } + + self.responseStringEncoding = stringEncoding; + } + [self.lock unlock]; + + return _responseStringEncoding; +} + +- (NSInputStream *)inputStream { + return self.request.HTTPBodyStream; +} + +- (void)setInputStream:(NSInputStream *)inputStream { + NSMutableURLRequest *mutableRequest = [self.request mutableCopy]; + mutableRequest.HTTPBodyStream = inputStream; + self.request = mutableRequest; +} + +- (NSOutputStream *)outputStream { + if (!_outputStream) { + self.outputStream = [NSOutputStream outputStreamToMemory]; + } + + return _outputStream; +} + +- (void)setOutputStream:(NSOutputStream *)outputStream { + [self.lock lock]; + if (outputStream != _outputStream) { + if (_outputStream) { + [_outputStream close]; + } + + _outputStream = outputStream; + } + [self.lock unlock]; +} + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler { + [self.lock lock]; + if (!self.backgroundTaskCleanup) { + UIApplication *application = [UIApplication sharedApplication]; + UIBackgroundTaskIdentifier __block backgroundTaskIdentifier = UIBackgroundTaskInvalid; + __weak __typeof(self)weakSelf = self; + + self.backgroundTaskCleanup = ^(){ + if (backgroundTaskIdentifier != UIBackgroundTaskInvalid) { + [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier]; + backgroundTaskIdentifier = UIBackgroundTaskInvalid; + } + }; + + backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ + __strong __typeof(weakSelf)strongSelf = weakSelf; + + if (handler) { + handler(); + } + + if (strongSelf) { + [strongSelf cancel]; + strongSelf.backgroundTaskCleanup(); + } + }]; + } + [self.lock unlock]; +} +#endif + +#pragma mark - + +- (void)setState:(AFOperationState)state { + if (!AFStateTransitionIsValid(self.state, state, [self isCancelled])) { + return; + } + + [self.lock lock]; + NSString *oldStateKey = AFKeyPathFromOperationState(self.state); + NSString *newStateKey = AFKeyPathFromOperationState(state); + + [self willChangeValueForKey:newStateKey]; + [self willChangeValueForKey:oldStateKey]; + _state = state; + [self didChangeValueForKey:oldStateKey]; + [self didChangeValueForKey:newStateKey]; + [self.lock unlock]; +} + +- (void)pause { + if ([self isPaused] || [self isFinished] || [self isCancelled]) { + return; + } + + [self.lock lock]; + if ([self isExecuting]) { + [self performSelector:@selector(operationDidPause) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + + dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); + } + + self.state = AFOperationPausedState; + [self.lock unlock]; +} + +- (void)operationDidPause { + [self.lock lock]; + [self.connection cancel]; + [self.lock unlock]; +} + +- (BOOL)isPaused { + return self.state == AFOperationPausedState; +} + +- (void)resume { + if (![self isPaused]) { + return; + } + + [self.lock lock]; + self.state = AFOperationReadyState; + + [self start]; + [self.lock unlock]; +} + +#pragma mark - + +- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block { + self.uploadProgress = block; +} + +- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block { + self.downloadProgress = block; +} + +- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block { + self.authenticationChallenge = block; +} + +- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block { + self.cacheResponse = block; +} + +- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block { + self.redirectResponse = block; +} + +#pragma mark - NSOperation + +- (void)setCompletionBlock:(void (^)(void))block { + [self.lock lock]; + if (!block) { + [super setCompletionBlock:nil]; + } else { + __weak __typeof(self)weakSelf = self; + [super setCompletionBlock:^ { + __strong __typeof(weakSelf)strongSelf = weakSelf; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_group_t group = strongSelf.completionGroup ?: url_request_operation_completion_group(); + dispatch_queue_t queue = strongSelf.completionQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + + dispatch_group_async(group, queue, ^{ + block(); + }); + + dispatch_group_notify(group, url_request_operation_completion_queue(), ^{ + [strongSelf setCompletionBlock:nil]; + }); + }]; + } + [self.lock unlock]; +} + +- (BOOL)isReady { + return self.state == AFOperationReadyState && [super isReady]; +} + +- (BOOL)isExecuting { + return self.state == AFOperationExecutingState; +} + +- (BOOL)isFinished { + return self.state == AFOperationFinishedState; +} + +- (BOOL)isConcurrent { + return YES; +} + +- (void)start { + [self.lock lock]; + if ([self isCancelled]) { + [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } else if ([self isReady]) { + self.state = AFOperationExecutingState; + + [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } + [self.lock unlock]; +} + +- (void)operationDidStart { + [self.lock lock]; + if (![self isCancelled]) { + self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; + + NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; + for (NSString *runLoopMode in self.runLoopModes) { + [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode]; + [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; + } + + [self.outputStream open]; + [self.connection start]; + } + [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; + }); +} + +- (void)finish { + [self.lock lock]; + self.state = AFOperationFinishedState; + [self.lock unlock]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; + }); +} + +- (void)cancel { + [self.lock lock]; + if (![self isFinished] && ![self isCancelled]) { + [super cancel]; + + if ([self isExecuting]) { + [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + } + } + [self.lock unlock]; +} + +- (void)cancelConnection { + NSDictionary *userInfo = nil; + if ([self.request URL]) { + userInfo = @{NSURLErrorFailingURLErrorKey : [self.request URL]}; + } + NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + + if (![self isFinished]) { + if (self.connection) { + [self.connection cancel]; + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:error]; + } else { + // Accommodate race condition where `self.connection` has not yet been set before cancellation + self.error = error; + [self finish]; + } + } +} + +#pragma mark - + ++ (NSArray *)batchOfRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock +{ + if (!operations || [operations count] == 0) { + return @[[NSBlockOperation blockOperationWithBlock:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(@[]); + } + }); + }]]; + } + + __block dispatch_group_t group = dispatch_group_create(); + NSBlockOperation *batchedOperation = [NSBlockOperation blockOperationWithBlock:^{ + dispatch_group_notify(group, dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(operations); + } + }); + }]; + + for (AFURLConnectionOperation *operation in operations) { + operation.completionGroup = group; + void (^originalCompletionBlock)(void) = [operation.completionBlock copy]; + __weak __typeof(operation)weakOperation = operation; + operation.completionBlock = ^{ + __strong __typeof(weakOperation)strongOperation = weakOperation; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_queue_t queue = strongOperation.completionQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + dispatch_group_async(group, queue, ^{ + if (originalCompletionBlock) { + originalCompletionBlock(); + } + + NSUInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger __unused idx, BOOL __unused *stop) { + return [op isFinished]; + }] count]; + + if (progressBlock) { + progressBlock(numberOfFinishedOperations, [operations count]); + } + + dispatch_group_leave(group); + }); + }; + + dispatch_group_enter(group); + [batchedOperation addDependency:operation]; + } + + return [operations arrayByAddingObject:batchedOperation]; +} + +#pragma mark - NSObject + +- (NSString *)description { + [self.lock lock]; + NSString *description = [NSString stringWithFormat:@"<%@: %p, state: %@, cancelled: %@ request: %@, response: %@>", NSStringFromClass([self class]), self, AFKeyPathFromOperationState(self.state), ([self isCancelled] ? @"YES" : @"NO"), self.request, self.response]; + [self.lock unlock]; + return description; +} + +#pragma mark - NSURLConnectionDelegate + +- (void)connection:(NSURLConnection *)connection +willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +{ + if (self.authenticationChallenge) { + self.authenticationChallenge(connection, challenge); + return; + } + + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + } else { + if ([challenge previousFailureCount] == 0) { + if (self.credential) { + [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } else { + [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; + } + } +} + +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + +- (NSURLRequest *)connection:(NSURLConnection *)connection + willSendRequest:(NSURLRequest *)request + redirectResponse:(NSURLResponse *)redirectResponse +{ + if (self.redirectResponse) { + return self.redirectResponse(connection, request, redirectResponse); + } else { + return request; + } +} + +- (void)connection:(NSURLConnection __unused *)connection + didSendBodyData:(NSInteger)bytesWritten + totalBytesWritten:(NSInteger)totalBytesWritten +totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite +{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.uploadProgress) { + self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } + }); +} + +- (void)connection:(NSURLConnection __unused *)connection +didReceiveResponse:(NSURLResponse *)response +{ + self.response = response; +} + +- (void)connection:(NSURLConnection __unused *)connection + didReceiveData:(NSData *)data +{ + NSUInteger length = [data length]; + while (YES) { + NSInteger totalNumberOfBytesWritten = 0; + if ([self.outputStream hasSpaceAvailable]) { + const uint8_t *dataBuffer = (uint8_t *)[data bytes]; + + NSInteger numberOfBytesWritten = 0; + while (totalNumberOfBytesWritten < (NSInteger)length) { + numberOfBytesWritten = [self.outputStream write:&dataBuffer[(NSUInteger)totalNumberOfBytesWritten] maxLength:(length - (NSUInteger)totalNumberOfBytesWritten)]; + if (numberOfBytesWritten == -1) { + break; + } + + totalNumberOfBytesWritten += numberOfBytesWritten; + } + + break; + } else { + [self.connection cancel]; + if (self.outputStream.streamError) { + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError]; + } + return; + } + } + + dispatch_async(dispatch_get_main_queue(), ^{ + self.totalBytesRead += (long long)length; + + if (self.downloadProgress) { + self.downloadProgress(length, self.totalBytesRead, self.response.expectedContentLength); + } + }); +} + +- (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection { + self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey]; + + [self.outputStream close]; + if (self.responseData) { + self.outputStream = nil; + } + + self.connection = nil; + + [self finish]; +} + +- (void)connection:(NSURLConnection __unused *)connection + didFailWithError:(NSError *)error +{ + self.error = error; + + [self.outputStream close]; + if (self.responseData) { + self.outputStream = nil; + } + + self.connection = nil; + + [self finish]; +} + +- (NSCachedURLResponse *)connection:(NSURLConnection *)connection + willCacheResponse:(NSCachedURLResponse *)cachedResponse +{ + if (self.cacheResponse) { + return self.cacheResponse(connection, cachedResponse); + } else { + if ([self isCancelled]) { + return nil; + } + + return cachedResponse; + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURLRequest *request = [decoder decodeObjectOfClass:[NSURLRequest class] forKey:NSStringFromSelector(@selector(request))]; + + self = [self initWithRequest:request]; + if (!self) { + return nil; + } + + self.state = (AFOperationState)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(state))] integerValue]; + self.response = [decoder decodeObjectOfClass:[NSHTTPURLResponse class] forKey:NSStringFromSelector(@selector(response))]; + self.error = [decoder decodeObjectOfClass:[NSError class] forKey:NSStringFromSelector(@selector(error))]; + self.responseData = [decoder decodeObjectOfClass:[NSData class] forKey:NSStringFromSelector(@selector(responseData))]; + self.totalBytesRead = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(totalBytesRead))] longLongValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [self pause]; + + [coder encodeObject:self.request forKey:NSStringFromSelector(@selector(request))]; + + switch (self.state) { + case AFOperationExecutingState: + case AFOperationPausedState: + [coder encodeInteger:AFOperationReadyState forKey:NSStringFromSelector(@selector(state))]; + break; + default: + [coder encodeInteger:self.state forKey:NSStringFromSelector(@selector(state))]; + break; + } + + [coder encodeObject:self.response forKey:NSStringFromSelector(@selector(response))]; + [coder encodeObject:self.error forKey:NSStringFromSelector(@selector(error))]; + [coder encodeObject:self.responseData forKey:NSStringFromSelector(@selector(responseData))]; + [coder encodeInt64:self.totalBytesRead forKey:NSStringFromSelector(@selector(totalBytesRead))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; + + operation.uploadProgress = self.uploadProgress; + operation.downloadProgress = self.downloadProgress; + operation.authenticationChallenge = self.authenticationChallenge; + operation.cacheResponse = self.cacheResponse; + operation.redirectResponse = self.redirectResponse; + operation.completionQueue = self.completionQueue; + operation.completionGroup = self.completionGroup; + + return operation; +} + +@end diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h b/Strike/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h new file mode 100644 index 0000000..15ced1d --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1,476 @@ +// AFURLRequestSerialization.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#endif + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary. + + For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`. + */ +@protocol AFURLRequestSerialization + +/** + Returns a request with the specified parameters encoded into a copy of the original request. + + @param request The original request. + @param parameters The parameters to be encoded. + @param error The error that occurred while attempting to encode the request parameters. + + @return A serialized request. + */ +- (nullable NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(nullable id)parameters + error:(NSError * __nullable __autoreleasing *)error +#ifdef NS_SWIFT_NOTHROW +NS_SWIFT_NOTHROW +#endif +; +@end + +#pragma mark - + +/** + + */ +typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) { + AFHTTPRequestQueryStringDefaultStyle = 0, +}; + +@protocol AFMultipartFormData; + +/** + `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPRequestSerializer : NSObject + +/** + The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Whether created requests can use the device’s cellular radio (if present). `YES` by default. + + @see NSMutableURLRequest -setAllowsCellularAccess: + */ +@property (nonatomic, assign) BOOL allowsCellularAccess; + +/** + The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default. + + @see NSMutableURLRequest -setCachePolicy: + */ +@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; + +/** + Whether created requests should use the default cookie handling. `YES` by default. + + @see NSMutableURLRequest -setHTTPShouldHandleCookies: + */ +@property (nonatomic, assign) BOOL HTTPShouldHandleCookies; + +/** + Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default + + @see NSMutableURLRequest -setHTTPShouldUsePipelining: + */ +@property (nonatomic, assign) BOOL HTTPShouldUsePipelining; + +/** + The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default. + + @see NSMutableURLRequest -setNetworkServiceType: + */ +@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType; + +/** + The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds. + + @see NSMutableURLRequest -setTimeoutInterval: + */ +@property (nonatomic, assign) NSTimeInterval timeoutInterval; + +///--------------------------------------- +/// @name Configuring HTTP Request Headers +///--------------------------------------- + +/** + Default HTTP header field values to be applied to serialized requests. By default, these include the following: + + - `Accept-Language` with the contents of `NSLocale +preferredLanguages` + - `User-Agent` with the contents of various bundle identifiers and OS designations + + @discussion To add or remove default request headers, use `setValue:forHTTPHeaderField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +/** + Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header. + + @param field The HTTP header to set a default value for + @param value The value set as default for the specified header, or `nil` + */ +- (void)setValue:(nullable NSString *)value +forHTTPHeaderField:(NSString *)field; + +/** + Returns the value for the HTTP headers set in the request serializer. + + @param field The HTTP header to retrieve the default value for + + @return The value set as default for the specified header, or `nil` + */ +- (nullable NSString *)valueForHTTPHeaderField:(NSString *)field; + +/** + Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. + + @param username The HTTP basic auth username + @param password The HTTP basic auth password + */ +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password; + +/** + @deprecated This method has been deprecated. Use -setValue:forHTTPHeaderField: instead. + */ +- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token DEPRECATED_ATTRIBUTE; + + +/** + Clears any existing value for the "Authorization" HTTP header. + */ +- (void)clearAuthorizationHeader; + +///------------------------------------------------------- +/// @name Configuring Query String Parameter Serialization +///------------------------------------------------------- + +/** + HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. + */ +@property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; + +/** + Set the method of query string serialization according to one of the pre-defined styles. + + @param style The serialization style. + + @see AFHTTPRequestQueryStringSerializationStyle + */ +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style; + +/** + Set the a custom method of query string serialization according to the specified block. + + @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request. + */ +- (void)setQueryStringSerializationWithBlock:(nullable NSString * (^)(NSURLRequest *request, id parameters, NSError * __autoreleasing *error))block; + +///------------------------------- +/// @name Creating Request Objects +///------------------------------- + +/** + @deprecated This method has been deprecated. Use -requestWithMethod:URLString:parameters:error: instead. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters DEPRECATED_ATTRIBUTE; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. + + If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. + + @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object. + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable id)parameters + error:(NSError * __nullable __autoreleasing *)error; + +/** + @deprecated This method has been deprecated. Use -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error: instead. + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block DEPRECATED_ATTRIBUTE; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 + + Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. + + @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. + @param URLString The URL string used to create the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. + @param error The error that occurred while constructing the request. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(nullable NSDictionary *)parameters + constructingBodyWithBlock:(nullable void (^)(id formData))block + error:(NSError * __nullable __autoreleasing *)error; + +/** + Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished. + + @param request The multipart form request. The `HTTPBodyStream` property of `request` must not be `nil`. + @param fileURL The file URL to write multipart form contents to. + @param handler A handler block to execute. + + @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request. + + @see https://github.com/AFNetworking/AFNetworking/issues/1398 + */ +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(nullable void (^)(NSError * __nullable error))handler; + +@end + +#pragma mark - + +/** + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`. + */ +@protocol AFMultipartFormData + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended, otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __nullable __autoreleasing *)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. + + @param inputStream The input stream to be appended to the form data + @param name The name to be associated with the specified input stream. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. + @param length The length of the specified input stream in bytes. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithInputStream:(nullable NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType; + +/** + Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + */ + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name; + + +/** + Appends HTTP headers, followed by the encoded data and the multipart form boundary. + + @param headers The HTTP headers to be appended to the form data. + @param body The data to be encoded and appended to the form data. This parameter must not be `nil`. + */ +- (void)appendPartWithHeaders:(nullable NSDictionary *)headers + body:(NSData *)body; + +/** + Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. + + When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. + + @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb. + @param delay Duration of delay each time a packet is read. By default, no delay is set. + */ +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay; + +@end + +#pragma mark - + +/** + `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`. + */ +@interface AFJSONRequestSerializer : AFHTTPRequestSerializer + +/** + Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONWritingOptions writingOptions; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param writingOptions The specified JSON writing options. + */ ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions; + +@end + +#pragma mark - + +/** + `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`. + */ +@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + @warning The `writeOptions` property is currently unused. + */ +@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param writeOptions The property list write options. + + @warning The `writeOptions` property is currently unused. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions; + +@end + +#pragma mark - + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLRequestSerializationErrorDomain` + + ### Constants + + `AFURLRequestSerializationErrorDomain` + AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLRequestSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLRequestErrorKey` + The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLRequestErrorKey; + +/** + ## Throttling Bandwidth for HTTP Request Input Streams + + @see -throttleBandwidthWithPacketSize:delay: + + ### Constants + + `kAFUploadStream3GSuggestedPacketSize` + Maximum packet size, in number of bytes. Equal to 16kb. + + `kAFUploadStream3GSuggestedDelay` + Duration of delay each time a packet is read. Equal to 0.2 seconds. + */ +FOUNDATION_EXPORT NSUInteger const kAFUploadStream3GSuggestedPacketSize; +FOUNDATION_EXPORT NSTimeInterval const kAFUploadStream3GSuggestedDelay; + +NS_ASSUME_NONNULL_END diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m b/Strike/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m new file mode 100644 index 0000000..7e22454 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m @@ -0,0 +1,1428 @@ +// AFURLRequestSerialization.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLRequestSerialization.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import +#else +#import +#endif + +NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request"; +NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response"; + +typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, id parameters, NSError *__autoreleasing *error); + +static NSString * AFBase64EncodedStringFromString(NSString *string) { + NSData *data = [NSData dataWithBytes:[string UTF8String] length:[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]; + NSUInteger length = [data length]; + NSMutableData *mutableData = [NSMutableData dataWithLength:((length + 2) / 3) * 4]; + + uint8_t *input = (uint8_t *)[data bytes]; + uint8_t *output = (uint8_t *)[mutableData mutableBytes]; + + for (NSUInteger i = 0; i < length; i += 3) { + NSUInteger value = 0; + for (NSUInteger j = i; j < (i + 3); j++) { + value <<= 8; + if (j < length) { + value |= (0xFF & input[j]); + } + } + + static uint8_t const kAFBase64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + + NSUInteger idx = (i / 3) * 4; + output[idx + 0] = kAFBase64EncodingTable[(value >> 18) & 0x3F]; + output[idx + 1] = kAFBase64EncodingTable[(value >> 12) & 0x3F]; + output[idx + 2] = (i + 1) < length ? kAFBase64EncodingTable[(value >> 6) & 0x3F] : '='; + output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '='; + } + + return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding]; +} + +/** + Returns a percent-escaped string following RFC 3986 for a query string key or value. + RFC 3986 states that the following characters are "reserved" characters. + - General Delimiters: ":", "#", "[", "]", "@", "?", "/" + - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=" + + In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow + query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/" + should be percent-escaped in the query string. + - parameter string: The string to be percent-escaped. + - returns: The percent-escaped string. + */ +static NSString * AFPercentEscapedStringFromString(NSString *string) { + static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4 + static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;="; + + NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy]; + [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]]; + + // FIXME: https://github.com/AFNetworking/AFNetworking/pull/3028 + // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + + static NSUInteger const batchSize = 50; + + NSUInteger index = 0; + NSMutableString *escaped = @"".mutableCopy; + + while (index < string.length) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wgnu" + NSUInteger length = MIN(string.length - index, batchSize); +#pragma GCC diagnostic pop + NSRange range = NSMakeRange(index, length); + + // To avoid breaking up character sequences such as 👴🏻👮🏽 + range = [string rangeOfComposedCharacterSequencesForRange:range]; + + NSString *substring = [string substringWithRange:range]; + NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet]; + [escaped appendString:encoded]; + + index += range.length; + } + + return escaped; +} + +#pragma mark - + +@interface AFQueryStringPair : NSObject +@property (readwrite, nonatomic, strong) id field; +@property (readwrite, nonatomic, strong) id value; + +- (id)initWithField:(id)field value:(id)value; + +- (NSString *)URLEncodedStringValue; +@end + +@implementation AFQueryStringPair + +- (id)initWithField:(id)field value:(id)value { + self = [super init]; + if (!self) { + return nil; + } + + self.field = field; + self.value = value; + + return self; +} + +- (NSString *)URLEncodedStringValue { + if (!self.value || [self.value isEqual:[NSNull null]]) { + return AFPercentEscapedStringFromString([self.field description]); + } else { + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedStringFromString([self.field description]), AFPercentEscapedStringFromString([self.value description])]; + } +} + +@end + +#pragma mark - + +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary); +FOUNDATION_EXPORT NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value); + +static NSString * AFQueryStringFromParameters(NSDictionary *parameters) { + NSMutableArray *mutablePairs = [NSMutableArray array]; + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + [mutablePairs addObject:[pair URLEncodedStringValue]]; + } + + return [mutablePairs componentsJoinedByString:@"&"]; +} + +NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) { + return AFQueryStringPairsFromKeyAndValue(nil, dictionary); +} + +NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; + + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)]; + + if ([value isKindOfClass:[NSDictionary class]]) { + NSDictionary *dictionary = value; + // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = dictionary[nestedKey]; + if (nestedValue) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; + } + } + } else if ([value isKindOfClass:[NSArray class]]) { + NSArray *array = value; + for (id nestedValue in array) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; + } + } else { + [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; + } + + return mutableQueryStringComponents; +} + +#pragma mark - + +@interface AFStreamingMultipartFormData : NSObject +- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding; + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; +@end + +#pragma mark - + +static NSArray * AFHTTPRequestSerializerObservedKeyPaths() { + static NSArray *_AFHTTPRequestSerializerObservedKeyPaths = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _AFHTTPRequestSerializerObservedKeyPaths = @[NSStringFromSelector(@selector(allowsCellularAccess)), NSStringFromSelector(@selector(cachePolicy)), NSStringFromSelector(@selector(HTTPShouldHandleCookies)), NSStringFromSelector(@selector(HTTPShouldUsePipelining)), NSStringFromSelector(@selector(networkServiceType)), NSStringFromSelector(@selector(timeoutInterval))]; + }); + + return _AFHTTPRequestSerializerObservedKeyPaths; +} + +static void *AFHTTPRequestSerializerObserverContext = &AFHTTPRequestSerializerObserverContext; + +@interface AFHTTPRequestSerializer () +@property (readwrite, nonatomic, strong) NSMutableSet *mutableObservedChangedKeyPaths; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders; +@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle; +@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization; +@end + +@implementation AFHTTPRequestSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary]; + + // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 + NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; + [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + float q = 1.0f - (idx * 0.1f); + [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; + *stop = q <= 0.5f; + }]; + [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; + + NSString *userAgent = nil; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" +#if TARGET_OS_IOS + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; +#elif TARGET_OS_WATCH + // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 + userAgent = [NSString stringWithFormat:@"%@/%@ (%@; watchOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[WKInterfaceDevice currentDevice] model], [[WKInterfaceDevice currentDevice] systemVersion], [[WKInterfaceDevice currentDevice] screenScale]]; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; +#endif +#pragma clang diagnostic pop + if (userAgent) { + if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { + NSMutableString *mutableUserAgent = [userAgent mutableCopy]; + if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { + userAgent = mutableUserAgent; + } + } + [self setValue:userAgent forHTTPHeaderField:@"User-Agent"]; + } + + // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html + self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil]; + + self.mutableObservedChangedKeyPaths = [NSMutableSet set]; + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext]; + } + } + + return self; +} + +- (void)dealloc { + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self respondsToSelector:NSSelectorFromString(keyPath)]) { + [self removeObserver:self forKeyPath:keyPath context:AFHTTPRequestSerializerObserverContext]; + } + } +} + +#pragma mark - + +// Workarounds for crashing behavior using Key-Value Observing with XCTest +// See https://github.com/AFNetworking/AFNetworking/issues/2523 + +- (void)setAllowsCellularAccess:(BOOL)allowsCellularAccess { + [self willChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; + _allowsCellularAccess = allowsCellularAccess; + [self didChangeValueForKey:NSStringFromSelector(@selector(allowsCellularAccess))]; +} + +- (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy { + [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; + _cachePolicy = cachePolicy; + [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))]; +} + +- (void)setHTTPShouldHandleCookies:(BOOL)HTTPShouldHandleCookies { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; + _HTTPShouldHandleCookies = HTTPShouldHandleCookies; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldHandleCookies))]; +} + +- (void)setHTTPShouldUsePipelining:(BOOL)HTTPShouldUsePipelining { + [self willChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; + _HTTPShouldUsePipelining = HTTPShouldUsePipelining; + [self didChangeValueForKey:NSStringFromSelector(@selector(HTTPShouldUsePipelining))]; +} + +- (void)setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType { + [self willChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; + _networkServiceType = networkServiceType; + [self didChangeValueForKey:NSStringFromSelector(@selector(networkServiceType))]; +} + +- (void)setTimeoutInterval:(NSTimeInterval)timeoutInterval { + [self willChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; + _timeoutInterval = timeoutInterval; + [self didChangeValueForKey:NSStringFromSelector(@selector(timeoutInterval))]; +} + +#pragma mark - + +- (NSDictionary *)HTTPRequestHeaders { + return [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders]; +} + +- (void)setValue:(NSString *)value +forHTTPHeaderField:(NSString *)field +{ + [self.mutableHTTPRequestHeaders setValue:value forKey:field]; +} + +- (NSString *)valueForHTTPHeaderField:(NSString *)field { + return [self.mutableHTTPRequestHeaders valueForKey:field]; +} + +- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username + password:(NSString *)password +{ + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password]; + [self setValue:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)] forHTTPHeaderField:@"Authorization"]; +} + +- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token { + [self setValue:[NSString stringWithFormat:@"Token token=\"%@\"", token] forHTTPHeaderField:@"Authorization"]; +} + +- (void)clearAuthorizationHeader { + [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; +} + +#pragma mark - + +- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style { + self.queryStringSerializationStyle = style; + self.queryStringSerialization = nil; +} + +- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, id, NSError *__autoreleasing *))block { + self.queryStringSerialization = block; +} + +#pragma mark - + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters +{ + return [self requestWithMethod:method URLString:URLString parameters:parameters error:nil]; +} + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(URLString); + + NSURL *url = [NSURL URLWithString:URLString]; + + NSParameterAssert(url); + + NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url]; + mutableRequest.HTTPMethod = method; + + for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) { + if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) { + [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath]; + } + } + + mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy]; + + return mutableRequest; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block +{ + return [self multipartFormRequestWithMethod:method URLString:URLString parameters:parameters constructingBodyWithBlock:block error:nil]; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + URLString:(NSString *)URLString + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(method); + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); + + NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error]; + + __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding]; + + if (parameters) { + for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { + NSData *data = nil; + if ([pair.value isKindOfClass:[NSData class]]) { + data = pair.value; + } else if ([pair.value isEqual:[NSNull null]]) { + data = [NSData data]; + } else { + data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; + } + + if (data) { + [formData appendPartWithFormData:data name:[pair.field description]]; + } + } + } + + if (block) { + block(formData); + } + + return [formData requestByFinalizingMultipartFormData]; +} + +- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request + writingStreamContentsToFile:(NSURL *)fileURL + completionHandler:(void (^)(NSError *error))handler +{ + NSParameterAssert(request.HTTPBodyStream); + NSParameterAssert([fileURL isFileURL]); + + NSInputStream *inputStream = request.HTTPBodyStream; + NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO]; + __block NSError *error = nil; + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + + [inputStream open]; + [outputStream open]; + + while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) { + uint8_t buffer[1024]; + + NSInteger bytesRead = [inputStream read:buffer maxLength:1024]; + if (inputStream.streamError || bytesRead < 0) { + error = inputStream.streamError; + break; + } + + NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead]; + if (outputStream.streamError || bytesWritten < 0) { + error = outputStream.streamError; + break; + } + + if (bytesRead == 0 && bytesWritten == 0) { + break; + } + } + + [outputStream close]; + [inputStream close]; + + if (handler) { + dispatch_async(dispatch_get_main_queue(), ^{ + handler(error); + }); + } + }); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + mutableRequest.HTTPBodyStream = nil; + + return mutableRequest; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + NSString *query = nil; + if (parameters) { + if (self.queryStringSerialization) { + NSError *serializationError; + query = self.queryStringSerialization(request, parameters, &serializationError); + + if (serializationError) { + if (error) { + *error = serializationError; + } + + return nil; + } + } else { + switch (self.queryStringSerializationStyle) { + case AFHTTPRequestQueryStringDefaultStyle: + query = AFQueryStringFromParameters(parameters); + break; + } + } + } + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + if (query) { + mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]]; + } + } else { + // #2864: an empty string is a valid x-www-form-urlencoded payload + if (!query) { + query = @""; + } + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; + } + [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]]; + } + + return mutableRequest; +} + +#pragma mark - NSKeyValueObserving + ++ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key { + if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) { + return NO; + } + + return [super automaticallyNotifiesObserversForKey:key]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(__unused id)object + change:(NSDictionary *)change + context:(void *)context +{ + if (context == AFHTTPRequestSerializerObserverContext) { + if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) { + [self.mutableObservedChangedKeyPaths removeObject:keyPath]; + } else { + [self.mutableObservedChangedKeyPaths addObject:keyPath]; + } + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy]; + self.queryStringSerializationStyle = (AFHTTPRequestQueryStringSerializationStyle)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; + [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; + serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; + serializer.queryStringSerialization = self.queryStringSerialization; + + return serializer; +} + +@end + +#pragma mark - + +static NSString * AFCreateMultipartFormBoundary() { + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; +} + +static NSString * const kAFMultipartFormCRLF = @"\r\n"; + +static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFContentTypeForPathExtension(NSString *extension) { +#ifdef __UTTYPE__ + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } +#else +#pragma unused (extension) + return @"application/octet-stream"; +#endif +} + +NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16; +NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; + +@interface AFHTTPBodyPart : NSObject +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSDictionary *headers; +@property (nonatomic, copy) NSString *boundary; +@property (nonatomic, strong) id body; +@property (nonatomic, assign) unsigned long long bodyContentLength; +@property (nonatomic, strong) NSInputStream *inputStream; + +@property (nonatomic, assign) BOOL hasInitialBoundary; +@property (nonatomic, assign) BOOL hasFinalBoundary; + +@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (readonly, nonatomic, assign) unsigned long long contentLength; + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@interface AFMultipartBodyStream : NSInputStream +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (readonly, nonatomic, assign) unsigned long long contentLength; +@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; + +- (id)initWithStringEncoding:(NSStringEncoding)encoding; +- (void)setInitialAndFinalBoundaries; +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; +@end + +#pragma mark - + +@interface AFStreamingMultipartFormData () +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, copy) NSString *boundary; +@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; +@end + +@implementation AFStreamingMultipartFormData + +- (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding +{ + self = [super init]; + if (!self) { + return nil; + } + + self.request = urlRequest; + self.stringEncoding = encoding; + self.boundary = AFCreateMultipartFormBoundary(); + self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; + + return self; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + + NSString *fileName = [fileURL lastPathComponent]; + NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); + + return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType + error:(NSError * __autoreleasing *)error +{ + NSParameterAssert(fileURL); + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + if (![fileURL isFileURL]) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)}; + if (error) { + *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error]; + if (!fileAttributes) { + return NO; + } + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = fileURL; + bodyPart.bodyContentLength = [fileAttributes[NSFileSize] unsignedLongLongValue]; + [self.bodyStream appendHTTPBodyPart:bodyPart]; + + return YES; +} + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(int64_t)length + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.boundary = self.boundary; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = (unsigned long long)length; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)appendPartWithFileData:(NSData *)data + name:(NSString *)name + fileName:(NSString *)fileName + mimeType:(NSString *)mimeType +{ + NSParameterAssert(name); + NSParameterAssert(fileName); + NSParameterAssert(mimeType); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; + [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithFormData:(NSData *)data + name:(NSString *)name +{ + NSParameterAssert(name); + + NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; + [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; + + [self appendPartWithHeaders:mutableHeaders body:data]; +} + +- (void)appendPartWithHeaders:(NSDictionary *)headers + body:(NSData *)body +{ + NSParameterAssert(body); + + AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = headers; + bodyPart.boundary = self.boundary; + bodyPart.bodyContentLength = [body length]; + bodyPart.body = body; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; +} + +- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes + delay:(NSTimeInterval)delay +{ + self.bodyStream.numberOfBytesInPacket = numberOfBytes; + self.bodyStream.delay = delay; +} + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { + if ([self.bodyStream isEmpty]) { + return self.request; + } + + // Reset the initial and final boundaries to ensure correct Content-Length + [self.bodyStream setInitialAndFinalBoundaries]; + [self.request setHTTPBodyStream:self.bodyStream]; + + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; + + return self.request; +} + +@end + +#pragma mark - + +@interface NSStream () +@property (readwrite) NSStreamStatus streamStatus; +@property (readwrite, copy) NSError *streamError; +@end + +@interface AFMultipartBodyStream () +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts; +@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; +@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; +@property (readwrite, nonatomic, strong) NSOutputStream *outputStream; +@property (readwrite, nonatomic, strong) NSMutableData *buffer; +@end + +@implementation AFMultipartBodyStream +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wimplicit-atomic-properties" +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100) +@synthesize delegate; +#endif +@synthesize streamStatus; +@synthesize streamError; +#pragma clang diagnostic pop + +- (id)initWithStringEncoding:(NSStringEncoding)encoding { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = encoding; + self.HTTPBodyParts = [NSMutableArray array]; + self.numberOfBytesInPacket = NSIntegerMax; + + return self; +} + +- (void)setInitialAndFinalBoundaries { + if ([self.HTTPBodyParts count] > 0) { + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + bodyPart.hasInitialBoundary = NO; + bodyPart.hasFinalBoundary = NO; + } + + [[self.HTTPBodyParts firstObject] setHasInitialBoundary:YES]; + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; + } +} + +- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { + [self.HTTPBodyParts addObject:bodyPart]; +} + +- (BOOL)isEmpty { + return [self.HTTPBodyParts count] == 0; +} + +#pragma mark - NSInputStream + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + if ([self streamStatus] == NSStreamStatusClosed) { + return 0; + } + + NSInteger totalNumberOfBytesRead = 0; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) { + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { + break; + } + } else { + NSUInteger maxLength = length - (NSUInteger)totalNumberOfBytesRead; + NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength]; + if (numberOfBytesRead == -1) { + self.streamError = self.currentHTTPBodyPart.inputStream.streamError; + break; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } + } + } + } +#pragma clang diagnostic pop + + return totalNumberOfBytesRead; +} + +- (BOOL)getBuffer:(__unused uint8_t **)buffer + length:(__unused NSUInteger *)len +{ + return NO; +} + +- (BOOL)hasBytesAvailable { + return [self streamStatus] == NSStreamStatusOpen; +} + +#pragma mark - NSStream + +- (void)open { + if (self.streamStatus == NSStreamStatusOpen) { + return; + } + + self.streamStatus = NSStreamStatusOpen; + + [self setInitialAndFinalBoundaries]; + self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; +} + +- (void)close { + self.streamStatus = NSStreamStatusClosed; +} + +- (id)propertyForKey:(__unused NSString *)key { + return nil; +} + +- (BOOL)setProperty:(__unused id)property + forKey:(__unused NSString *)key +{ + return NO; +} + +- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop + forMode:(__unused NSString *)mode +{} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + length += [bodyPart contentLength]; + } + + return length; +} + +#pragma mark - Undocumented CFReadStream Bridged Methods + +- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop + forMode:(__unused CFStringRef)aMode +{} + +- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags + callback:(__unused CFReadStreamClientCallBack)inCallback + context:(__unused CFStreamClientContext *)inContext { + return NO; +} + +#pragma mark - NSCopying + +-(id)copyWithZone:(NSZone *)zone { + AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; + } + + [bodyStreamCopy setInitialAndFinalBoundaries]; + + return bodyStreamCopy; +} + +@end + +#pragma mark - + +typedef enum { + AFEncapsulationBoundaryPhase = 1, + AFHeaderPhase = 2, + AFBodyPhase = 3, + AFFinalBoundaryPhase = 4, +} AFHTTPBodyPartReadPhase; + +@interface AFHTTPBodyPart () { + AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; + unsigned long long _phaseReadOffset; +} + +- (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@implementation AFHTTPBodyPart + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + [self transitionToNextPhase]; + + return self; +} + +- (void)dealloc { + if (_inputStream) { + [_inputStream close]; + _inputStream = nil; + } +} + +- (NSInputStream *)inputStream { + if (!_inputStream) { + if ([self.body isKindOfClass:[NSData class]]) { + _inputStream = [NSInputStream inputStreamWithData:self.body]; + } else if ([self.body isKindOfClass:[NSURL class]]) { + _inputStream = [NSInputStream inputStreamWithURL:self.body]; + } else if ([self.body isKindOfClass:[NSInputStream class]]) { + _inputStream = self.body; + } else { + _inputStream = [NSInputStream inputStreamWithData:[NSData data]]; + } + } + + return _inputStream; +} + +- (NSString *)stringForHeaders { + NSMutableString *headerString = [NSMutableString string]; + for (NSString *field in [self.headers allKeys]) { + [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; + } + [headerString appendString:kAFMultipartFormCRLF]; + + return [NSString stringWithString:headerString]; +} + +- (unsigned long long)contentLength { + unsigned long long length = 0; + + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + length += [encapsulationBoundaryData length]; + + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + length += [headersData length]; + + length += _bodyContentLength; + + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + length += [closingBoundaryData length]; + + return length; +} + +- (BOOL)hasBytesAvailable { + // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer + if (_phase == AFFinalBoundaryPhase) { + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (self.inputStream.streamStatus) { + case NSStreamStatusNotOpen: + case NSStreamStatusOpening: + case NSStreamStatusOpen: + case NSStreamStatusReading: + case NSStreamStatusWriting: + return YES; + case NSStreamStatusAtEnd: + case NSStreamStatusClosed: + case NSStreamStatusError: + default: + return NO; + } +#pragma clang diagnostic pop +} + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ + NSInteger totalNumberOfBytesRead = 0; + + if (_phase == AFEncapsulationBoundaryPhase) { + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFHeaderPhase) { + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + if (_phase == AFBodyPhase) { + NSInteger numberOfBytesRead = 0; + + numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + if (numberOfBytesRead == -1) { + return -1; + } else { + totalNumberOfBytesRead += numberOfBytesRead; + + if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) { + [self transitionToNextPhase]; + } + } + } + + if (_phase == AFFinalBoundaryPhase) { + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); + totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; + } + + return totalNumberOfBytesRead; +} + +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); + [data getBytes:buffer range:range]; +#pragma clang diagnostic pop + + _phaseReadOffset += range.length; + + if (((NSUInteger)_phaseReadOffset) >= [data length]) { + [self transitionToNextPhase]; + } + + return (NSInteger)range.length; +} + +- (BOOL)transitionToNextPhase { + if (![[NSThread currentThread] isMainThread]) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self transitionToNextPhase]; + }); + return YES; + } + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcovered-switch-default" + switch (_phase) { + case AFEncapsulationBoundaryPhase: + _phase = AFHeaderPhase; + break; + case AFHeaderPhase: + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; + [self.inputStream open]; + _phase = AFBodyPhase; + break; + case AFBodyPhase: + [self.inputStream close]; + _phase = AFFinalBoundaryPhase; + break; + case AFFinalBoundaryPhase: + default: + _phase = AFEncapsulationBoundaryPhase; + break; + } + _phaseReadOffset = 0; +#pragma clang diagnostic pop + + return YES; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + bodyPart.boundary = self.boundary; + + return bodyPart; +} + +@end + +#pragma mark - + +@implementation AFJSONRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithWritingOptions:(NSJSONWritingOptions)0]; +} + ++ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions +{ + AFJSONRequestSerializer *serializer = [[self alloc] init]; + serializer.writingOptions = writingOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerialization + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.writingOptions = self.writingOptions; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFPropertyListRequestSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + writeOptions:(NSPropertyListWriteOptions)writeOptions +{ + AFPropertyListRequestSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.writeOptions = writeOptions; + + return serializer; +} + +#pragma mark - AFURLRequestSerializer + +- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request + withParameters:(id)parameters + error:(NSError *__autoreleasing *)error +{ + NSParameterAssert(request); + + if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { + return [super requestBySerializingRequest:request withParameters:parameters error:error]; + } + + NSMutableURLRequest *mutableRequest = [request mutableCopy]; + + [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { + if (![request valueForHTTPHeaderField:field]) { + [mutableRequest setValue:value forHTTPHeaderField:field]; + } + }]; + + if (parameters) { + if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { + [mutableRequest setValue:@"application/x-plist" forHTTPHeaderField:@"Content-Type"]; + } + + [mutableRequest setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error]]; + } + + return mutableRequest; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; + serializer.format = self.format; + serializer.writeOptions = self.writeOptions; + + return serializer; +} + +@end diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h b/Strike/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h new file mode 100644 index 0000000..1578b78 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1,315 @@ +// AFURLResponseSerialization.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. + + For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. + */ +@protocol AFURLResponseSerialization + +/** + The response object decoded from the data associated with a specified response. + + @param response The response to be processed. + @param data The response data to be decoded. + @param error The error that occurred while attempting to decode the response data. + + @return The object decoded from the specified response data. + */ +- (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response + data:(nullable NSData *)data + error:(NSError * __nullable __autoreleasing *)error +#ifdef NS_SWIFT_NOTHROW +NS_SWIFT_NOTHROW +#endif +; + +@end + +#pragma mark - + +/** + `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. + + Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. + */ +@interface AFHTTPResponseSerializer : NSObject + +- (instancetype)init; + +/** + The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + Creates and returns a serializer with default configuration. + */ ++ (instancetype)serializer; + +///----------------------------------------- +/// @name Configuring Response Serialization +///----------------------------------------- + +/** + The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. + + See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + */ +@property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes; + +/** + The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. + */ +@property (nonatomic, copy, nullable) NSSet *acceptableContentTypes; + +/** + Validates the specified response and data. + + In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. + + @param response The response to be validated. + @param data The data associated with the response. + @param error The error that occurred while attempting to validate the response. + + @return `YES` if the response is valid, otherwise `NO`. + */ +- (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response + data:(nullable NSData *)data + error:(NSError * __nullable __autoreleasing *)error; + +@end + +#pragma mark - + + +/** + `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. + + By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: + + - `application/json` + - `text/json` + - `text/javascript` + */ +@interface AFJSONResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSJSONReadingOptions readingOptions; + +/** + Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. + */ +@property (nonatomic, assign) BOOL removesKeysWithNullValues; + +/** + Creates and returns a JSON serializer with specified reading and writing options. + + @param readingOptions The specified JSON reading options. + */ ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; + +@end + +#pragma mark - + +/** + `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. + + By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +/** + `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + */ +@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. + */ +@property (nonatomic, assign) NSUInteger options; + +/** + Creates and returns an XML document serializer with the specified options. + + @param mask The XML document options. + */ ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; + +@end + +#endif + +#pragma mark - + +/** + `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. + + By default, `AFPropertyListResponseSerializer` accepts the following MIME types: + + - `application/x-plist` + */ +@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer + +- (instancetype)init; + +/** + The property list format. Possible values are described in "NSPropertyListFormat". + */ +@property (nonatomic, assign) NSPropertyListFormat format; + +/** + The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." + */ +@property (nonatomic, assign) NSPropertyListReadOptions readOptions; + +/** + Creates and returns a property list serializer with a specified format, read options, and write options. + + @param format The property list format. + @param readOptions The property list reading options. + */ ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions; + +@end + +#pragma mark - + +/** + `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. + + By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: + + - `image/tiff` + - `image/jpeg` + - `image/gif` + - `image/png` + - `image/ico` + - `image/x-icon` + - `image/bmp` + - `image/x-bmp` + - `image/x-xbitmap` + - `image/x-win-bitmap` + */ +@interface AFImageResponseSerializer : AFHTTPResponseSerializer + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +/** + The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. + */ +@property (nonatomic, assign) CGFloat imageScale; + +/** + Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. + */ +@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; +#endif + +@end + +#pragma mark - + +/** + `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. + */ +@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer + +/** + The component response serializers. + */ +@property (readonly, nonatomic, copy) NSArray *responseSerializers; + +/** + Creates and returns a compound serializer comprised of the specified response serializers. + + @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. + */ ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFURLResponseSerializationErrorDomain` + + ### Constants + + `AFURLResponseSerializationErrorDomain` + AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain; + +/** + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` + - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` + + ### Constants + + `AFNetworkingOperationFailingURLResponseErrorKey` + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + + `AFNetworkingOperationFailingURLResponseDataErrorKey` + The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey; + +FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m b/Strike/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m new file mode 100644 index 0000000..cfa8287 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m @@ -0,0 +1,825 @@ +// AFURLResponseSerialization.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLResponseSerialization.h" + +#if TARGET_OS_IOS +#import +#elif TARGET_OS_WATCH +#import +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#import +#endif + +NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response"; +NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response"; +NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data"; + +static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) { + if (!error) { + return underlyingError; + } + + if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) { + return error; + } + + NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy]; + mutableUserInfo[NSUnderlyingErrorKey] = underlyingError; + + return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo]; +} + +static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) { + if ([error.domain isEqualToString:domain] && error.code == code) { + return YES; + } else if (error.userInfo[NSUnderlyingErrorKey]) { + return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain); + } + + return NO; +} + +static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { + if ([JSONObject isKindOfClass:[NSArray class]]) { + NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; + for (id value in (NSArray *)JSONObject) { + [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; + } else if ([JSONObject isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject]; + for (id key in [(NSDictionary *)JSONObject allKeys]) { + id value = (NSDictionary *)JSONObject[key]; + if (!value || [value isEqual:[NSNull null]]) { + [mutableDictionary removeObjectForKey:key]; + } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) { + mutableDictionary[key] = AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions); + } + } + + return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary]; + } + + return JSONObject; +} + +@implementation AFHTTPResponseSerializer + ++ (instancetype)serializer { + return [[self alloc] init]; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.stringEncoding = NSUTF8StringEncoding; + + self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; + self.acceptableContentTypes = nil; + + return self; +} + +#pragma mark - + +- (BOOL)validateResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError * __autoreleasing *)error +{ + BOOL responseIsValid = YES; + NSError *validationError = nil; + + if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) { + if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) { + if ([data length] > 0 && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError); + } + + responseIsValid = NO; + } + + if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) { + NSMutableDictionary *mutableUserInfo = [@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode], + NSURLErrorFailingURLErrorKey:[response URL], + AFNetworkingOperationFailingURLResponseErrorKey: response, + } mutableCopy]; + + if (data) { + mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data; + } + + validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError); + + responseIsValid = NO; + } + } + + if (error && !responseIsValid) { + *error = validationError; + } + + return responseIsValid; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + [self validateResponse:(NSHTTPURLResponse *)response data:data error:error]; + + return data; +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + self = [self init]; + if (!self) { + return nil; + } + + self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; + [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; + serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFJSONResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithReadingOptions:(NSJSONReadingOptions)0]; +} + ++ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions { + AFJSONResponseSerializer *serializer = [[self alloc] init]; + serializer.readingOptions = readingOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. + // See https://github.com/rails/rails/issues/1742 + NSStringEncoding stringEncoding = self.stringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + id responseObject = nil; + NSError *serializationError = nil; + @autoreleasepool { + NSString *responseString = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (responseString && ![responseString isEqualToString:@" "]) { + // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character + // See http://stackoverflow.com/a/12843465/157142 + data = [responseString dataUsingEncoding:NSUTF8StringEncoding]; + + if (data) { + if ([data length] > 0) { + responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError]; + } else { + return nil; + } + } else { + NSDictionary *userInfo = @{ + NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"Data failed decoding as a UTF-8 string", @"AFNetworking", nil), + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Could not decode string: %@", @"AFNetworking", nil), responseString] + }; + + serializationError = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; + } + } + } + + if (self.removesKeysWithNullValues && responseObject) { + responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions); + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue]; + self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))]; + [coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.readingOptions = self.readingOptions; + serializer.removesKeysWithNullValues = self.removesKeysWithNullValues; + + return serializer; +} + +@end + +#pragma mark - + +@implementation AFXMLParserResponseSerializer + ++ (instancetype)serializer { + AFXMLParserResponseSerializer *serializer = [[self alloc] init]; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSHTTPURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + return [[NSXMLParser alloc] initWithData:data]; +} + +@end + +#pragma mark - + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + +@implementation AFXMLDocumentResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithXMLDocumentOptions:0]; +} + ++ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask { + AFXMLDocumentResponseSerializer *serializer = [[self alloc] init]; + serializer.options = mask; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + NSError *serializationError = nil; + NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError]; + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return document; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.options = self.options; + + return serializer; +} + +@end + +#endif + +#pragma mark - + +@implementation AFPropertyListResponseSerializer + ++ (instancetype)serializer { + return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0]; +} + ++ (instancetype)serializerWithFormat:(NSPropertyListFormat)format + readOptions:(NSPropertyListReadOptions)readOptions +{ + AFPropertyListResponseSerializer *serializer = [[self alloc] init]; + serializer.format = format; + serializer.readOptions = readOptions; + + return serializer; +} + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil]; + + return self; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + + id responseObject; + NSError *serializationError = nil; + + if (data) { + responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError]; + } + + if (error) { + *error = AFErrorWithUnderlyingError(serializationError, *error); + } + + return responseObject; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; + self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; + [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.format = self.format; + serializer.readOptions = self.readOptions; + + return serializer; +} + +@end + +#pragma mark - + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import + +@interface UIImage (AFNetworkingSafeImageLoading) ++ (UIImage *)af_safeImageWithData:(NSData *)data; +@end + +static NSLock* imageLock = nil; + +@implementation UIImage (AFNetworkingSafeImageLoading) + ++ (UIImage *)af_safeImageWithData:(NSData *)data { + UIImage* image = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + imageLock = [[NSLock alloc] init]; + }); + + [imageLock lock]; + image = [UIImage imageWithData:data]; + [imageLock unlock]; + return image; +} + +@end + +static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { + UIImage *image = [UIImage af_safeImageWithData:data]; + if (image.images) { + return image; + } + + return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; +} + +static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { + if (!data || [data length] == 0) { + return nil; + } + + CGImageRef imageRef = NULL; + CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); + + if ([response.MIMEType isEqualToString:@"image/png"]) { + imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) { + imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); + + if (imageRef) { + CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef); + CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace); + + // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale + if (imageColorSpaceModel == kCGColorSpaceModelCMYK) { + CGImageRelease(imageRef); + imageRef = NULL; + } + } + } + + CGDataProviderRelease(dataProvider); + + UIImage *image = AFImageWithDataAtScale(data, scale); + if (!imageRef) { + if (image.images || !image) { + return image; + } + + imageRef = CGImageCreateCopy([image CGImage]); + if (!imageRef) { + return nil; + } + } + + size_t width = CGImageGetWidth(imageRef); + size_t height = CGImageGetHeight(imageRef); + size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); + + if (width * height > 1024 * 1024 || bitsPerComponent > 8) { + CGImageRelease(imageRef); + + return image; + } + + // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate + size_t bytesPerRow = 0; + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); + CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); + + if (colorSpaceModel == kCGColorSpaceModelRGB) { + uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" + if (alpha == kCGImageAlphaNone) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaNoneSkipFirst; + } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { + bitmapInfo &= ~kCGBitmapAlphaInfoMask; + bitmapInfo |= kCGImageAlphaPremultipliedFirst; + } +#pragma clang diagnostic pop + } + + CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); + + CGColorSpaceRelease(colorSpace); + + if (!context) { + CGImageRelease(imageRef); + + return image; + } + + CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef); + CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); + + CGContextRelease(context); + + UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation]; + + CGImageRelease(inflatedImageRef); + CGImageRelease(imageRef); + + return inflatedImage; +} +#endif + + +@implementation AFImageResponseSerializer + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil]; + +#if TARGET_OS_IOS + self.imageScale = [[UIScreen mainScreen] scale]; + self.automaticallyInflatesResponseImage = YES; +#elif TARGET_OS_WATCH + self.imageScale = [[WKInterfaceDevice currentDevice] screenScale]; + self.automaticallyInflatesResponseImage = YES; +#endif + + return self; +} + +#pragma mark - AFURLResponseSerializer + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { + if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { + return nil; + } + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + if (self.automaticallyInflatesResponseImage) { + return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale); + } else { + return AFImageWithDataAtScale(data, self.imageScale); + } +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + // Ensure that the image is set to it's correct pixel width and height + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data]; + NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; + [image addRepresentation:bitimage]; + + return image; +#endif + + return nil; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))]; +#if CGFLOAT_IS_DOUBLE + self.imageScale = [imageScale doubleValue]; +#else + self.imageScale = [imageScale floatValue]; +#endif + + self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))]; + [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; +#endif +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + serializer.imageScale = self.imageScale; + serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage; +#endif + + return serializer; +} + +@end + +#pragma mark - + +@interface AFCompoundResponseSerializer () +@property (readwrite, nonatomic, copy) NSArray *responseSerializers; +@end + +@implementation AFCompoundResponseSerializer + ++ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers { + AFCompoundResponseSerializer *serializer = [[self alloc] init]; + serializer.responseSerializers = responseSerializers; + + return serializer; +} + +#pragma mark - AFURLResponseSerialization + +- (id)responseObjectForResponse:(NSURLResponse *)response + data:(NSData *)data + error:(NSError *__autoreleasing *)error +{ + for (id serializer in self.responseSerializers) { + if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) { + continue; + } + + NSError *serializerError = nil; + id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError]; + if (responseObject) { + if (error) { + *error = AFErrorWithUnderlyingError(serializerError, *error); + } + + return responseObject; + } + } + + return [super responseObjectForResponse:response data:data error:error]; +} + +#pragma mark - NSSecureCoding + +- (id)initWithCoder:(NSCoder *)decoder { + self = [super initWithCoder:decoder]; + if (!self) { + return nil; + } + + self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [super encodeWithCoder:coder]; + + [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; + serializer.responseSerializers = self.responseSerializers; + + return serializer; +} + +@end diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h b/Strike/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h new file mode 100644 index 0000000..4498c89 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFURLSessionManager.h @@ -0,0 +1,554 @@ +// AFURLSessionManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" +#import "AFSecurityPolicy.h" +#if !TARGET_OS_WATCH +#import "AFNetworkReachabilityManager.h" +#endif + +#ifndef NS_DESIGNATED_INITIALIZER +#if __has_attribute(objc_designated_initializer) +#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer)) +#else +#define NS_DESIGNATED_INITIALIZER +#endif +#endif + +/** + `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + + ## Subclassing Notes + + This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead. + + ## NSURLSession & NSURLSessionTask Delegate Methods + + `AFURLSessionManager` implements the following delegate methods: + + ### `NSURLSessionDelegate` + + - `URLSession:didBecomeInvalidWithError:` + - `URLSession:didReceiveChallenge:completionHandler:` + - `URLSessionDidFinishEventsForBackgroundURLSession:` + + ### `NSURLSessionTaskDelegate` + + - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:` + - `URLSession:task:didReceiveChallenge:completionHandler:` + - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` + - `URLSession:task:didCompleteWithError:` + + ### `NSURLSessionDataDelegate` + + - `URLSession:dataTask:didReceiveResponse:completionHandler:` + - `URLSession:dataTask:didBecomeDownloadTask:` + - `URLSession:dataTask:didReceiveData:` + - `URLSession:dataTask:willCacheResponse:completionHandler:` + + ### `NSURLSessionDownloadDelegate` + + - `URLSession:downloadTask:didFinishDownloadingToURL:` + - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:` + - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Network Reachability Monitoring + + Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. + + ## NSCoding Caveats + + - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`. + + ## NSCopying Caveats + + - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original. + - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied. + + @warning Managers for background sessions must be owned for the duration of their use. This can be accomplished by creating an application-wide or shared singleton instance. + */ + +NS_ASSUME_NONNULL_BEGIN + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || TARGET_OS_WATCH + +@interface AFURLSessionManager : NSObject + +/** + The managed session. + */ +@property (readonly, nonatomic, strong) NSURLSession *session; + +/** + The operation queue on which delegate callbacks are run. + */ +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; + +/** + 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 instance of `AFJSONResponseSerializer`. + + @warning `responseSerializer` must not be `nil`. + */ +@property (nonatomic, strong) id responseSerializer; + +///------------------------------- +/// @name Managing Security Policy +///------------------------------- + +/** + The security policy used by created request operations to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. + */ +@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; + +#if !TARGET_OS_WATCH +///-------------------------------------- +/// @name Monitoring Network Reachability +///-------------------------------------- + +/** + The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default. + */ +@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; +#endif + +///---------------------------- +/// @name Getting Session Tasks +///---------------------------- + +/** + The data, upload, and download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *tasks; + +/** + The data tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *dataTasks; + +/** + The upload tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *uploadTasks; + +/** + The download tasks currently run by the managed session. + */ +@property (readonly, nonatomic, strong) NSArray *downloadTasks; + +///------------------------------- +/// @name Managing Callback Queues +///------------------------------- + +/** + The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. + */ +#if OS_OBJECT_USE_OBJC +@property (nonatomic, strong, nullable) dispatch_queue_t completionQueue; +#else +@property (nonatomic, assign, nullable) dispatch_queue_t completionQueue; +#endif + +/** + The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. + */ +#if OS_OBJECT_USE_OBJC +@property (nonatomic, strong, nullable) dispatch_group_t completionGroup; +#else +@property (nonatomic, assign, nullable) dispatch_group_t completionGroup; +#endif + +///--------------------------------- +/// @name Working Around System Bugs +///--------------------------------- + +/** + Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default. + + @bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again. + + @see https://github.com/AFNetworking/AFNetworking/issues/1675 + */ +@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions; + +///--------------------- +/// @name Initialization +///--------------------- + +/** + Creates and returns a manager for a session created with the specified configuration. This is the designated initializer. + + @param configuration The configuration used to create the managed session. + + @return A manager for a newly-created session. + */ +- (instancetype)initWithSessionConfiguration:(nullable NSURLSessionConfiguration *)configuration NS_DESIGNATED_INITIALIZER; + +/** + Invalidates the managed session, optionally canceling pending tasks. + + @param cancelPendingTasks Whether or not to cancel pending tasks. + */ +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks; + +///------------------------- +/// @name Running Data Tasks +///------------------------- + +/** + Creates an `NSURLSessionDataTask` with the specified request. + + @param request The HTTP request for the request. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(nullable void (^)(NSURLResponse *response, id __nullable responseObject, NSError * __nullable error))completionHandler; + +///--------------------------- +/// @name Running Upload Tasks +///--------------------------- + +/** + Creates an `NSURLSessionUploadTask` with the specified request for a local file. + + @param request The HTTP request for the request. + @param fileURL A URL to the local file to be uploaded. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + + @see `attemptsToRecreateUploadTasksForBackgroundSessions` + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + completionHandler:(nullable void (^)(NSURLResponse *response, id __nullable responseObject, NSError * __nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body. + + @param request The HTTP request for the request. + @param bodyData A data object containing the HTTP body to be uploaded. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(nullable NSData *)bodyData + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + completionHandler:(nullable void (^)(NSURLResponse *response, id __nullable responseObject, NSError * __nullable error))completionHandler; + +/** + Creates an `NSURLSessionUploadTask` with the specified streaming request. + + @param request The HTTP request for the request. + @param progress A progress object monitoring the current upload progress. + @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. + */ +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + completionHandler:(nullable void (^)(NSURLResponse *response, id __nullable responseObject, NSError * __nullable error))completionHandler; + +///----------------------------- +/// @name Running Download Tasks +///----------------------------- + +/** + Creates an `NSURLSessionDownloadTask` with the specified request. + + @param request The HTTP request for the request. + @param progress A progress object monitoring the current download progress. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + + @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * __nullable filePath, NSError * __nullable error))completionHandler; + +/** + Creates an `NSURLSessionDownloadTask` with the specified resume data. + + @param resumeData The data used to resume downloading. + @param progress A progress object monitoring the current download progress. + @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. + @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. + */ +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(NSProgress * __nullable __autoreleasing * __nullable)progress + destination:(nullable NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(nullable void (^)(NSURLResponse *response, NSURL * __nullable filePath, NSError * __nullable error))completionHandler; + +///--------------------------------- +/// @name Getting Progress for Tasks +///--------------------------------- + +/** + Returns the upload progress of the specified task. + + @param uploadTask The session upload task. Must not be `nil`. + + @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask; + +/** + Returns the download progress of the specified task. + + @param downloadTask The session download task. Must not be `nil`. + + @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable. + */ +- (nullable NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask; + +///----------------------------------------- +/// @name Setting Session Delegate Callbacks +///----------------------------------------- + +/** + Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`. + + @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation. + */ +- (void)setSessionDidBecomeInvalidBlock:(nullable void (^)(NSURLSession *session, NSError *error))block; + +/** + Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __nullable __autoreleasing * __nullable credential))block; + +///-------------------------------------- +/// @name Setting Task Delegate Callbacks +///-------------------------------------- + +/** + Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`. + + @param block A block object to be executed when a task requires a new request body stream. + */ +- (void)setTaskNeedNewBodyStreamBlock:(nullable NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block; + +/** + Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`. + + @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response. + */ +- (void)setTaskWillPerformHTTPRedirectionBlock:(nullable NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block; + +/** + Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`. + + @param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. + */ +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __nullable __autoreleasing * __nullable credential))block; + +/** + Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. + + @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. + */ +- (void)setTaskDidSendBodyDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block; + +/** + Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`. + + @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task. + */ +- (void)setTaskDidCompleteBlock:(nullable void (^)(NSURLSession *session, NSURLSessionTask *task, NSError * __nullable error))block; + +///------------------------------------------- +/// @name Setting Data Task Delegate Callbacks +///------------------------------------------- + +/** + Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`. + + @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response. + */ +- (void)setDataTaskDidReceiveResponseBlock:(nullable NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block; + +/** + Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`. + + @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become. + */ +- (void)setDataTaskDidBecomeDownloadTaskBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block; + +/** + Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`. + + @param block 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 session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue. + */ +- (void)setDataTaskDidReceiveDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block; + +/** + Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`. + + @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response. + */ +- (void)setDataTaskWillCacheResponseBlock:(nullable NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block; + +/** + Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`. + + @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session. + */ +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(nullable void (^)(NSURLSession *session))block; + +///----------------------------------------------- +/// @name Setting Download Task Delegate Callbacks +///----------------------------------------------- + +/** + Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`. + + @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error. + */ +- (void)setDownloadTaskDidFinishDownloadingBlock:(nullable NSURL * __nullable (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block; + +/** + Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`. + + @param block 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 five arguments: the session, the download task, 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 session manager operation queue. + */ +- (void)setDownloadTaskDidWriteDataBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block; + +/** + Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. + + @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded. + */ +- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; + +@end + +#endif + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when a task begins executing. + + @deprecated Use `AFNetworkingTaskDidResumeNotification` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidStartNotification DEPRECATED_ATTRIBUTE; + +/** + Posted when a task resumes. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidResumeNotification; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + + @deprecated Use `AFNetworkingTaskDidCompleteNotification` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishNotification DEPRECATED_ATTRIBUTE; + +/** + Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteNotification; + +/** + Posted when a task suspends its execution. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidSuspendNotification; + +/** + Posted when a session is invalidated. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDidInvalidateNotification; + +/** + Posted when a session download task encountered an error when moving the temporary download file to a specified destination. + */ +FOUNDATION_EXPORT NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. + + @deprecated Use `AFNetworkingTaskDidCompleteResponseDataKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishResponseDataKey DEPRECATED_ATTRIBUTE; + +/** + The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseDataKey; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. + + @deprecated Use `AFNetworkingTaskDidCompleteSerializedResponseKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishSerializedResponseKey DEPRECATED_ATTRIBUTE; + +/** + The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. + + @deprecated Use `AFNetworkingTaskDidCompleteResponseSerializerKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishResponseSerializerKey DEPRECATED_ATTRIBUTE; + +/** + The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. + + @deprecated Use `AFNetworkingTaskDidCompleteAssetPathKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishAssetPathKey DEPRECATED_ATTRIBUTE; + +/** + The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteAssetPathKey; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. + + @deprecated Use `AFNetworkingTaskDidCompleteErrorKey` instead. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidFinishErrorKey DEPRECATED_ATTRIBUTE; + +/** + Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. + */ +FOUNDATION_EXPORT NSString * const AFNetworkingTaskDidCompleteErrorKey; + +NS_ASSUME_NONNULL_END diff --git a/Strike/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m b/Strike/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m new file mode 100644 index 0000000..8ec0f08 --- /dev/null +++ b/Strike/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m @@ -0,0 +1,1174 @@ +// AFURLSessionManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFURLSessionManager.h" +#import + +#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) + +static dispatch_queue_t url_session_manager_creation_queue() { + static dispatch_queue_t af_url_session_manager_creation_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_creation_queue = dispatch_queue_create("com.alamofire.networking.session.manager.creation", DISPATCH_QUEUE_SERIAL); + }); + + return af_url_session_manager_creation_queue; +} + +static dispatch_queue_t url_session_manager_processing_queue() { + static dispatch_queue_t af_url_session_manager_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_url_session_manager_processing_queue; +} + +static dispatch_group_t url_session_manager_completion_group() { + static dispatch_group_t af_url_session_manager_completion_group; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_url_session_manager_completion_group = dispatch_group_create(); + }); + + return af_url_session_manager_completion_group; +} + +NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume"; +NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete"; +NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend"; +NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate"; +NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error"; + +NSString * const AFNetworkingTaskDidStartNotification = @"com.alamofire.networking.task.resume"; // Deprecated +NSString * const AFNetworkingTaskDidFinishNotification = @"com.alamofire.networking.task.complete"; // Deprecated + +NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; +NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; +NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; +NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error"; +NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; + +NSString * const AFNetworkingTaskDidFinishSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; // Deprecated +NSString * const AFNetworkingTaskDidFinishResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; // Deprecated +NSString * const AFNetworkingTaskDidFinishResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; // Deprecated +NSString * const AFNetworkingTaskDidFinishErrorKey = @"com.alamofire.networking.task.complete.error"; // Deprecated +NSString * const AFNetworkingTaskDidFinishAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; // Deprecated + +static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock"; + +static NSUInteger const AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask = 3; + +static void * AFTaskStateChangedContext = &AFTaskStateChangedContext; + +typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); + +typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request); +typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); +typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session); + +typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task); +typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend); +typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error); + +typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response); +typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask); +typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data); +typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse); + +typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location); +typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); +typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes); + +typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error); + +#pragma mark - + +@interface AFURLSessionManagerTaskDelegate : NSObject +@property (nonatomic, weak) AFURLSessionManager *manager; +@property (nonatomic, strong) NSMutableData *mutableData; +@property (nonatomic, strong) NSProgress *progress; +@property (nonatomic, copy) NSURL *downloadFileURL; +@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler; +@end + +@implementation AFURLSessionManagerTaskDelegate + +- (instancetype)init { + self = [super init]; + if (!self) { + return nil; + } + + self.mutableData = [NSMutableData data]; + + self.progress = [NSProgress progressWithTotalUnitCount:0]; + + return self; +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + task:(__unused NSURLSessionTask *)task + didSendBodyData:(__unused int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + self.progress.totalUnitCount = totalBytesExpectedToSend; + self.progress.completedUnitCount = totalBytesSent; +} + +- (void)URLSession:(__unused NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + __strong AFURLSessionManager *manager = self.manager; + + __block id responseObject = nil; + + __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer; + + //Performance Improvement from #2672 + NSData *data = nil; + if (self.mutableData) { + data = [self.mutableData copy]; + //We no longer need the reference, so nil it out to gain back some memory. + self.mutableData = nil; + } + + if (self.downloadFileURL) { + userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; + } else if (data) { + userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data; + } + + if (error) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = error; + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, error); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + } else { + dispatch_async(url_session_manager_processing_queue(), ^{ + NSError *serializationError = nil; + responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:data error:&serializationError]; + + if (self.downloadFileURL) { + responseObject = self.downloadFileURL; + } + + if (responseObject) { + userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject; + } + + if (serializationError) { + userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError; + } + + dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ + if (self.completionHandler) { + self.completionHandler(task.response, responseObject, serializationError); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; + }); + }); + }); + } +#pragma clang diagnostic pop +} + +#pragma mark - NSURLSessionDataTaskDelegate + +- (void)URLSession:(__unused NSURLSession *)session + dataTask:(__unused NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + [self.mutableData appendData:data]; +} + +#pragma mark - NSURLSessionDownloadTaskDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + NSError *fileManagerError = nil; + self.downloadFileURL = nil; + + if (self.downloadTaskDidFinishDownloading) { + self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (self.downloadFileURL) { + [[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]; + + if (fileManagerError) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo]; + } + } + } +} + +- (void)URLSession:(__unused NSURLSession *)session + downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask + didWriteData:(__unused int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + self.progress.totalUnitCount = totalBytesExpectedToWrite; + self.progress.completedUnitCount = totalBytesWritten; +} + +- (void)URLSession:(__unused NSURLSession *)session + downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes { + self.progress.totalUnitCount = expectedTotalBytes; + self.progress.completedUnitCount = fileOffset; +} + +@end + +#pragma mark - + +/** + * A workaround for issues related to key-value observing the `state` of an `NSURLSessionTask`. + * + * See: + * - https://github.com/AFNetworking/AFNetworking/issues/1477 + * - https://github.com/AFNetworking/AFNetworking/issues/2638 + * - https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + +static inline void af_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) { + Method originalMethod = class_getInstanceMethod(theClass, originalSelector); + Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector); + method_exchangeImplementations(originalMethod, swizzledMethod); +} + +static inline BOOL af_addMethod(Class theClass, SEL selector, Method method) { + return class_addMethod(theClass, selector, method_getImplementation(method), method_getTypeEncoding(method)); +} + +static NSString * const AFNSURLSessionTaskDidResumeNotification = @"com.alamofire.networking.nsurlsessiontask.resume"; +static NSString * const AFNSURLSessionTaskDidSuspendNotification = @"com.alamofire.networking.nsurlsessiontask.suspend"; + +@interface _AFURLSessionTaskSwizzling : NSObject + +@end + +@implementation _AFURLSessionTaskSwizzling + ++ (void)load { + /** + WARNING: Trouble Ahead + https://github.com/AFNetworking/AFNetworking/pull/2702 + */ + + if (NSClassFromString(@"NSURLSessionTask")) { + /** + iOS 7 and iOS 8 differ in NSURLSessionTask implementation, which makes the next bit of code a bit tricky. + Many Unit Tests have been built to validate as much of this behavior has possible. + Here is what we know: + - NSURLSessionTasks are implemented with class clusters, meaning the class you request from the API isn't actually the type of class you will get back. + - Simply referencing `[NSURLSessionTask class]` will not work. You need to ask an `NSURLSession` to actually create an object, and grab the class from there. + - On iOS 7, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `__NSCFURLSessionTask`. + - On iOS 8, `localDataTask` is a `__NSCFLocalDataTask`, which inherits from `__NSCFLocalSessionTask`, which inherits from `NSURLSessionTask`. + - On iOS 7, `__NSCFLocalSessionTask` and `__NSCFURLSessionTask` are the only two classes that have their own implementations of `resume` and `suspend`, and `__NSCFLocalSessionTask` DOES NOT CALL SUPER. This means both classes need to be swizzled. + - On iOS 8, `NSURLSessionTask` is the only class that implements `resume` and `suspend`. This means this is the only class that needs to be swizzled. + - Because `NSURLSessionTask` is not involved in the class hierarchy for every version of iOS, its easier to add the swizzled methods to a dummy class and manage them there. + + Some Assumptions: + - No implementations of `resume` or `suspend` call super. If this were to change in a future version of iOS, we'd need to handle it. + - No background task classes override `resume` or `suspend` + + The current solution: + 1) Grab an instance of `__NSCFLocalDataTask` by asking an instance of `NSURLSession` for a data task. + 2) Grab a pointer to the original implementation of `af_resume` + 3) Check to see if the current class has an implementation of resume. If so, continue to step 4. + 4) Grab the super class of the current class. + 5) Grab a pointer for the current class to the current implementation of `resume`. + 6) Grab a pointer for the super class to the current implementation of `resume`. + 7) If the current class implementation of `resume` is not equal to the super class implementation of `resume` AND the current implementation of `resume` is not equal to the original implementation of `af_resume`, THEN swizzle the methods + 8) Set the current class to the super class, and repeat steps 3-8 + */ + NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration]; + NSURLSession * session = [NSURLSession sessionWithConfiguration:configuration]; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnonnull" + NSURLSessionDataTask *localDataTask = [session dataTaskWithURL:nil]; +#pragma clang diagnostic pop + IMP originalAFResumeIMP = method_getImplementation(class_getInstanceMethod([self class], @selector(af_resume))); + Class currentClass = [localDataTask class]; + + while (class_getInstanceMethod(currentClass, @selector(resume))) { + Class superClass = [currentClass superclass]; + IMP classResumeIMP = method_getImplementation(class_getInstanceMethod(currentClass, @selector(resume))); + IMP superclassResumeIMP = method_getImplementation(class_getInstanceMethod(superClass, @selector(resume))); + if (classResumeIMP != superclassResumeIMP && + originalAFResumeIMP != classResumeIMP) { + [self swizzleResumeAndSuspendMethodForClass:currentClass]; + } + currentClass = [currentClass superclass]; + } + + [localDataTask cancel]; + [session finishTasksAndInvalidate]; + } +} + ++ (void)swizzleResumeAndSuspendMethodForClass:(Class)theClass { + Method afResumeMethod = class_getInstanceMethod(self, @selector(af_resume)); + Method afSuspendMethod = class_getInstanceMethod(self, @selector(af_suspend)); + + if (af_addMethod(theClass, @selector(af_resume), afResumeMethod)) { + af_swizzleSelector(theClass, @selector(resume), @selector(af_resume)); + } + + if (af_addMethod(theClass, @selector(af_suspend), afSuspendMethod)) { + af_swizzleSelector(theClass, @selector(suspend), @selector(af_suspend)); + } +} + +- (NSURLSessionTaskState)state { + NSAssert(NO, @"State method should never be called in the actual dummy class"); + return NSURLSessionTaskStateCanceling; +} + +- (void)af_resume { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_resume]; + + if (state != NSURLSessionTaskStateRunning) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidResumeNotification object:self]; + } +} + +- (void)af_suspend { + NSAssert([self respondsToSelector:@selector(state)], @"Does not respond to state"); + NSURLSessionTaskState state = [self state]; + [self af_suspend]; + + if (state != NSURLSessionTaskStateSuspended) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFNSURLSessionTaskDidSuspendNotification object:self]; + } +} +@end + +#pragma mark - + +@interface AFURLSessionManager () +@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; +@property (readwrite, nonatomic, strong) NSURLSession *session; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier; +@property (readonly, nonatomic, copy) NSString *taskDescriptionForSessionTasks; +@property (readwrite, nonatomic, strong) NSLock *lock; +@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid; +@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession; +@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge; +@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData; +@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData; +@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData; +@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume; +@end + +@implementation AFURLSessionManager + +- (instancetype)init { + return [self initWithSessionConfiguration:nil]; +} + +- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { + self = [super init]; + if (!self) { + return nil; + } + + if (!configuration) { + configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; + } + + self.sessionConfiguration = configuration; + + self.operationQueue = [[NSOperationQueue alloc] init]; + self.operationQueue.maxConcurrentOperationCount = 1; + + self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue]; + + self.responseSerializer = [AFJSONResponseSerializer serializer]; + + self.securityPolicy = [AFSecurityPolicy defaultPolicy]; + +#if !TARGET_OS_WATCH + self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; +#endif + + self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init]; + + self.lock = [[NSLock alloc] init]; + self.lock.name = AFURLSessionManagerLockName; + + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + for (NSURLSessionDataTask *task in dataTasks) { + [self addDelegateForDataTask:task completionHandler:nil]; + } + + for (NSURLSessionUploadTask *uploadTask in uploadTasks) { + [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil]; + } + + for (NSURLSessionDownloadTask *downloadTask in downloadTasks) { + [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil]; + } + }]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidResume:) name:AFNSURLSessionTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskDidSuspend:) name:AFNSURLSessionTaskDidSuspendNotification object:nil]; + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +#pragma mark - + +- (NSString *)taskDescriptionForSessionTasks { + return [NSString stringWithFormat:@"%p", self]; +} + +- (void)taskDidResume:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidResumeNotification object:task]; + }); + } + } +} + +- (void)taskDidSuspend:(NSNotification *)notification { + NSURLSessionTask *task = notification.object; + if ([task respondsToSelector:@selector(taskDescription)]) { + if ([task.taskDescription isEqualToString:self.taskDescriptionForSessionTasks]) { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidSuspendNotification object:task]; + }); + } + } +} + +#pragma mark - + +- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + AFURLSessionManagerTaskDelegate *delegate = nil; + [self.lock lock]; + delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)]; + [self.lock unlock]; + + return delegate; +} + +- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate + forTask:(NSURLSessionTask *)task +{ + NSParameterAssert(task); + NSParameterAssert(delegate); + + [self.lock lock]; + self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate; + [self.lock unlock]; +} + +- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + dataTask.taskDescription = self.taskDescriptionForSessionTasks; + [self setDelegate:delegate forTask:dataTask]; +} + +- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + int64_t totalUnitCount = uploadTask.countOfBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [uploadTask.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t)[contentLength longLongValue]; + } + } + + if (delegate.progress) { + delegate.progress.totalUnitCount = totalUnitCount; + } else { + delegate.progress = [NSProgress progressWithTotalUnitCount:totalUnitCount]; + } + + delegate.progress.pausingHandler = ^{ + [uploadTask suspend]; + }; + delegate.progress.cancellationHandler = ^{ + [uploadTask cancel]; + }; + + if (progress) { + *progress = delegate.progress; + } + + uploadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:uploadTask]; +} + +- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; + delegate.manager = self; + delegate.completionHandler = completionHandler; + + if (destination) { + delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) { + return destination(location, task.response); + }; + } + + if (progress) { + *progress = delegate.progress; + } + + downloadTask.taskDescription = self.taskDescriptionForSessionTasks; + + [self setDelegate:delegate forTask:downloadTask]; +} + +- (void)removeDelegateForTask:(NSURLSessionTask *)task { + NSParameterAssert(task); + + [self.lock lock]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)]; + [self.lock unlock]; +} + +- (void)removeAllDelegates { + [self.lock lock]; + [self.mutableTaskDelegatesKeyedByTaskIdentifier removeAllObjects]; + [self.lock unlock]; +} + +#pragma mark - + +- (NSArray *)tasksForKeyPath:(NSString *)keyPath { + __block NSArray *tasks = nil; + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); + [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) { + tasks = dataTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) { + tasks = uploadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) { + tasks = downloadTasks; + } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) { + tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; + } + + dispatch_semaphore_signal(semaphore); + }]; + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + + return tasks; +} + +- (NSArray *)tasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)dataTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)uploadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +- (NSArray *)downloadTasks { + return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; +} + +#pragma mark - + +- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks { + dispatch_async(dispatch_get_main_queue(), ^{ + if (cancelPendingTasks) { + [self.session invalidateAndCancel]; + } else { + [self.session finishTasksAndInvalidate]; + } + }); +} + +#pragma mark - + +- (void)setResponseSerializer:(id )responseSerializer { + NSParameterAssert(responseSerializer); + + _responseSerializer = responseSerializer; +} + +#pragma mark - + +- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionDataTask *dataTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + dataTask = [self.session dataTaskWithRequest:request]; + }); + + [self addDelegateForDataTask:dataTask completionHandler:completionHandler]; + + return dataTask; +} + +#pragma mark - + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromFile:(NSURL *)fileURL + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + }); + + if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) { + for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfAttemptsToRecreateBackgroundSessionUploadTask; attempts++) { + uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; + } + } + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request + fromData:(NSData *)bodyData + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData]; + }); + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler +{ + __block NSURLSessionUploadTask *uploadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + uploadTask = [self.session uploadTaskWithStreamedRequest:request]; + }); + + [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; + + return uploadTask; +} + +#pragma mark - + +- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + downloadTask = [self.session downloadTaskWithRequest:request]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData + progress:(NSProgress * __autoreleasing *)progress + destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination + completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler +{ + __block NSURLSessionDownloadTask *downloadTask = nil; + dispatch_sync(url_session_manager_creation_queue(), ^{ + downloadTask = [self.session downloadTaskWithResumeData:resumeData]; + }); + + [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; + + return downloadTask; +} + +#pragma mark - + +- (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask { + return [[self delegateForTask:uploadTask] progress]; +} + +- (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask { + return [[self delegateForTask:downloadTask] progress]; +} + +#pragma mark - + +- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block { + self.sessionDidBecomeInvalid = block; +} + +- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.sessionDidReceiveAuthenticationChallenge = block; +} + +- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block { + self.didFinishEventsForBackgroundURLSession = block; +} + +#pragma mark - + +- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block { + self.taskNeedNewBodyStream = block; +} + +- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block { + self.taskWillPerformHTTPRedirection = block; +} + +- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { + self.taskDidReceiveAuthenticationChallenge = block; +} + +- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block { + self.taskDidSendBodyData = block; +} + +- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block { + self.taskDidComplete = block; +} + +#pragma mark - + +- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block { + self.dataTaskDidReceiveResponse = block; +} + +- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block { + self.dataTaskDidBecomeDownloadTask = block; +} + +- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block { + self.dataTaskDidReceiveData = block; +} + +- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block { + self.dataTaskWillCacheResponse = block; +} + +#pragma mark - + +- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block { + self.downloadTaskDidFinishDownloading = block; +} + +- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block { + self.downloadTaskDidWriteData = block; +} + +- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block { + self.downloadTaskDidResume = block; +} + +#pragma mark - NSObject + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue]; +} + +- (BOOL)respondsToSelector:(SEL)selector { + if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) { + return self.taskWillPerformHTTPRedirection != nil; + } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) { + return self.dataTaskDidReceiveResponse != nil; + } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) { + return self.dataTaskWillCacheResponse != nil; + } else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) { + return self.didFinishEventsForBackgroundURLSession != nil; + } + + return [[self class] instancesRespondToSelector:selector]; +} + +#pragma mark - NSURLSessionDelegate + +- (void)URLSession:(NSURLSession *)session +didBecomeInvalidWithError:(NSError *)error +{ + if (self.sessionDidBecomeInvalid) { + self.sessionDidBecomeInvalid(session, error); + } + + [self removeAllDelegates]; + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session]; +} + +- (void)URLSession:(NSURLSession *)session +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.sessionDidReceiveAuthenticationChallenge) { + disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + if (credential) { + disposition = NSURLSessionAuthChallengeUseCredential; + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +#pragma mark - NSURLSessionTaskDelegate + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +willPerformHTTPRedirection:(NSHTTPURLResponse *)response + newRequest:(NSURLRequest *)request + completionHandler:(void (^)(NSURLRequest *))completionHandler +{ + NSURLRequest *redirectRequest = request; + + if (self.taskWillPerformHTTPRedirection) { + redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request); + } + + if (completionHandler) { + completionHandler(redirectRequest); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge + completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler +{ + NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; + __block NSURLCredential *credential = nil; + + if (self.taskDidReceiveAuthenticationChallenge) { + disposition = self.taskDidReceiveAuthenticationChallenge(session, task, challenge, &credential); + } else { + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { + disposition = NSURLSessionAuthChallengeUseCredential; + credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + } else { + disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; + } + } else { + disposition = NSURLSessionAuthChallengePerformDefaultHandling; + } + } + + if (completionHandler) { + completionHandler(disposition, credential); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler +{ + NSInputStream *inputStream = nil; + + if (self.taskNeedNewBodyStream) { + inputStream = self.taskNeedNewBodyStream(session, task); + } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + inputStream = [task.originalRequest.HTTPBodyStream copy]; + } + + if (completionHandler) { + completionHandler(inputStream); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task + didSendBodyData:(int64_t)bytesSent + totalBytesSent:(int64_t)totalBytesSent +totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + + int64_t totalUnitCount = totalBytesExpectedToSend; + if(totalUnitCount == NSURLSessionTransferSizeUnknown) { + NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"]; + if(contentLength) { + totalUnitCount = (int64_t) [contentLength longLongValue]; + } + } + + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + [delegate URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalUnitCount]; + + if (self.taskDidSendBodyData) { + self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount); + } +} + +- (void)URLSession:(NSURLSession *)session + task:(NSURLSessionTask *)task +didCompleteWithError:(NSError *)error +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; + + // delegate may be nil when completing a task in the background + if (delegate) { + [delegate URLSession:session task:task didCompleteWithError:error]; + + [self removeDelegateForTask:task]; + } + + if (self.taskDidComplete) { + self.taskDidComplete(session, task, error); + } + +} + +#pragma mark - NSURLSessionDataDelegate + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didReceiveResponse:(NSURLResponse *)response + completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler +{ + NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; + + if (self.dataTaskDidReceiveResponse) { + disposition = self.dataTaskDidReceiveResponse(session, dataTask, response); + } + + if (completionHandler) { + completionHandler(disposition); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask +didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + if (delegate) { + [self removeDelegateForTask:dataTask]; + [self setDelegate:delegate forTask:downloadTask]; + } + + if (self.dataTaskDidBecomeDownloadTask) { + self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + didReceiveData:(NSData *)data +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; + [delegate URLSession:session dataTask:dataTask didReceiveData:data]; + + if (self.dataTaskDidReceiveData) { + self.dataTaskDidReceiveData(session, dataTask, data); + } +} + +- (void)URLSession:(NSURLSession *)session + dataTask:(NSURLSessionDataTask *)dataTask + willCacheResponse:(NSCachedURLResponse *)proposedResponse + completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler +{ + NSCachedURLResponse *cachedResponse = proposedResponse; + + if (self.dataTaskWillCacheResponse) { + cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse); + } + + if (completionHandler) { + completionHandler(cachedResponse); + } +} + +- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { + if (self.didFinishEventsForBackgroundURLSession) { + dispatch_async(dispatch_get_main_queue(), ^{ + self.didFinishEventsForBackgroundURLSession(session); + }); + } +} + +#pragma mark - NSURLSessionDownloadDelegate + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask +didFinishDownloadingToURL:(NSURL *)location +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + if (self.downloadTaskDidFinishDownloading) { + NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); + if (fileURL) { + delegate.downloadFileURL = fileURL; + NSError *error = nil; + [[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]; + if (error) { + [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo]; + } + + return; + } + } + + if (delegate) { + [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location]; + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didWriteData:(int64_t)bytesWritten + totalBytesWritten:(int64_t)totalBytesWritten +totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + [delegate URLSession:session downloadTask:downloadTask didWriteData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite]; + + if (self.downloadTaskDidWriteData) { + self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } +} + +- (void)URLSession:(NSURLSession *)session + downloadTask:(NSURLSessionDownloadTask *)downloadTask + didResumeAtOffset:(int64_t)fileOffset +expectedTotalBytes:(int64_t)expectedTotalBytes +{ + AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; + [delegate URLSession:session downloadTask:downloadTask didResumeAtOffset:fileOffset expectedTotalBytes:expectedTotalBytes]; + + if (self.downloadTaskDidResume) { + self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes); + } +} + +#pragma mark - NSSecureCoding + ++ (BOOL)supportsSecureCoding { + return YES; +} + +- (id)initWithCoder:(NSCoder *)decoder { + NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; + + self = [self initWithSessionConfiguration:configuration]; + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder { + [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/LICENSE b/Strike/Pods/AFNetworking/LICENSE new file mode 100644 index 0000000..91f125b --- /dev/null +++ b/Strike/Pods/AFNetworking/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Strike/Pods/AFNetworking/README.md b/Strike/Pods/AFNetworking/README.md new file mode 100644 index 0000000..87ec4b2 --- /dev/null +++ b/Strike/Pods/AFNetworking/README.md @@ -0,0 +1,394 @@ +

+ AFNetworking +

+ +[![Build Status](https://travis-ci.org/AFNetworking/AFNetworking.svg)](https://travis-ci.org/AFNetworking/AFNetworking) + +AFNetworking is a delightful networking library for iOS and Mac OS X. It's built on top of the [Foundation URL Loading System](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html), extending the powerful high-level networking abstractions built into Cocoa. It has a modular architecture with well-designed, feature-rich APIs that are a joy to use. + +Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac. + +Choose AFNetworking for your next project, or migrate over your existing projects—you'll be happy you did! + +## How To Get Started + +- [Download AFNetworking](https://github.com/AFNetworking/AFNetworking/archive/master.zip) and try out the included Mac and iPhone example apps +- Read the ["Getting Started" guide](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking), [FAQ](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-FAQ), or [other articles on the Wiki](https://github.com/AFNetworking/AFNetworking/wiki) +- Check out the [documentation](http://cocoadocs.org/docsets/AFNetworking/) for a comprehensive look at all of the APIs available in AFNetworking +- Read the [AFNetworking 2.0 Migration Guide](https://github.com/AFNetworking/AFNetworking/wiki/AFNetworking-2.0-Migration-Guide) for an overview of the architectural changes from 1.0. + +## Communication + +- If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). (Tag 'afnetworking') +- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/afnetworking). +- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + +### Installation with CocoaPods + +[CocoaPods](https://cocoapods.org/) is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like AFNetworking in your projects. See the ["Getting Started" guide for more information](https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking). + +#### Podfile + +```ruby +platform :ios, '7.0' +pod "AFNetworking", "~> 2.0" +``` + +## Requirements + +| AFNetworking Version | Minimum iOS Target | Minimum OS X Target | Notes | +|:--------------------:|:---------------------------:|:----------------------------:|:-------------------------------------------------------------------------:| +| 2.x | iOS 6 | OS X 10.8 | Xcode 5 is required. `NSURLSession` subspec requires iOS 7 or OS X 10.9. | +| [1.x](https://github.com/AFNetworking/AFNetworking/tree/1.x) | iOS 5 | Mac OS X 10.7 | | +| [0.10.x](https://github.com/AFNetworking/AFNetworking/tree/0.10.x) | iOS 4 | Mac OS X 10.6 | | + +(OS X projects must support [64-bit with modern Cocoa runtime](https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtVersionsPlatforms.html)). + +> Programming in Swift? Try [Alamofire](https://github.com/Alamofire/Alamofire) for a more conventional set of APIs. + +## Architecture + +### NSURLConnection + +- `AFURLConnectionOperation` +- `AFHTTPRequestOperation` +- `AFHTTPRequestOperationManager` + +### NSURLSession _(iOS 7 / Mac OS X 10.9)_ + +- `AFURLSessionManager` +- `AFHTTPSessionManager` + +### Serialization + +* `` + - `AFHTTPRequestSerializer` + - `AFJSONRequestSerializer` + - `AFPropertyListRequestSerializer` +* `` + - `AFHTTPResponseSerializer` + - `AFJSONResponseSerializer` + - `AFXMLParserResponseSerializer` + - `AFXMLDocumentResponseSerializer` _(Mac OS X)_ + - `AFPropertyListResponseSerializer` + - `AFImageResponseSerializer` + - `AFCompoundResponseSerializer` + +### Additional Functionality + +- `AFSecurityPolicy` +- `AFNetworkReachabilityManager` + +## Usage + +### HTTP Request Operation Manager + +`AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management. + +#### `GET` Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +[manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +#### `POST` URL-Form-Encoded Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +NSDictionary *parameters = @{@"foo": @"bar"}; +[manager POST:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +#### `POST` Multi-Part Request + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +NSDictionary *parameters = @{@"foo": @"bar"}; +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +[manager POST:@"http://example.com/resources.json" parameters:parameters constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:filePath name:@"image" error:nil]; +} success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"Success: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +``` + +--- + +### AFURLSessionManager + +`AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. + +#### Creating a Download Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/download.zip"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) { + NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; + return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]]; +} completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) { + NSLog(@"File downloaded to: %@", filePath); +}]; +[downloadTask resume]; +``` + +#### Creating an Upload Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithRequest:request fromFile:filePath progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"Success: %@ %@", response, responseObject); + } +}]; +[uploadTask resume]; +``` + +#### Creating an Upload Task for a Multi-Part Request, with Progress + +```objective-c +NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:[NSURL fileURLWithPath:@"file://path/to/image.jpg"] name:@"file" fileName:@"filename.jpg" mimeType:@"image/jpeg" error:nil]; + } error:nil]; + +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; +NSProgress *progress = nil; + +NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; + +[uploadTask resume]; +``` + +#### Creating a Data Task + +```objective-c +NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; +AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; + +NSURL *URL = [NSURL URLWithString:@"http://example.com/upload"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; + +NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) { + if (error) { + NSLog(@"Error: %@", error); + } else { + NSLog(@"%@ %@", response, responseObject); + } +}]; +[dataTask resume]; +``` + +--- + +### Request Serialization + +Request serializers create requests from URL strings, encoding parameters as either a query string or HTTP body. + +```objective-c +NSString *URLString = @"http://example.com"; +NSDictionary *parameters = @{@"foo": @"bar", @"baz": @[@1, @2, @3]}; +``` + +#### Query String Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:URLString parameters:parameters error:nil]; +``` + + GET http://example.com?foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### URL Form Parameter Encoding + +```objective-c +[[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; +``` + + POST http://example.com/ + Content-Type: application/x-www-form-urlencoded + + foo=bar&baz[]=1&baz[]=2&baz[]=3 + +#### JSON Parameter Encoding + +```objective-c +[[AFJSONRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; +``` + + POST http://example.com/ + Content-Type: application/json + + {"foo": "bar", "baz": [1,2,3]} + +--- + +### Network Reachability Manager + +`AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. + +* Do not use Reachability to determine if the original request should be sent. + * You should try to send it. +* You can use Reachability to determine when a request should be automatically retried. + * Although it may still fail, a Reachability notification that the connectivity is available is a good time to retry something. +* Network reachability is a useful tool for determining why a request might have failed. + * After a network request has failed, telling the user they're offline is better than giving them a more technical but accurate error, such as "request timed out." + +See also [WWDC 2012 session 706, "Networking Best Practices."](https://developer.apple.com/videos/play/wwdc2012-706/). + +#### Shared Network Reachability + +```objective-c +[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + NSLog(@"Reachability: %@", AFStringFromNetworkReachabilityStatus(status)); +}]; + +[[AFNetworkReachabilityManager sharedManager] startMonitoring]; +``` + +#### HTTP Manager Reachability + +```objective-c +NSURL *baseURL = [NSURL URLWithString:@"http://example.com/"]; +AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL]; + +NSOperationQueue *operationQueue = manager.operationQueue; +[manager.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + switch (status) { + case AFNetworkReachabilityStatusReachableViaWWAN: + case AFNetworkReachabilityStatusReachableViaWiFi: + [operationQueue setSuspended:NO]; + break; + case AFNetworkReachabilityStatusNotReachable: + default: + [operationQueue setSuspended:YES]; + break; + } +}]; + +[manager.reachabilityManager startMonitoring]; +``` + +--- + +### Security Policy + +`AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. + +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. + +#### Allowing Invalid SSL Certificates + +```objective-c +AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; +manager.securityPolicy.allowInvalidCertificates = YES; // not recommended for production +``` + +--- + +### AFHTTPRequestOperation + +`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. + +Although `AFHTTPRequestOperationManager` is usually the best way to go about making requests, `AFHTTPRequestOperation` can be used by itself. + +#### `GET` with `AFHTTPRequestOperation` + +```objective-c +NSURL *URL = [NSURL URLWithString:@"http://example.com/resources/123.json"]; +NSURLRequest *request = [NSURLRequest requestWithURL:URL]; +AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request]; +op.responseSerializer = [AFJSONResponseSerializer serializer]; +[op setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + NSLog(@"JSON: %@", responseObject); +} failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSLog(@"Error: %@", error); +}]; +[[NSOperationQueue mainQueue] addOperation:op]; +``` + +#### Batch of Operations + +```objective-c +NSMutableArray *mutableOperations = [NSMutableArray array]; +for (NSURL *fileURL in filesToUpload) { + NSURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:@"http://example.com/upload" parameters:nil constructingBodyWithBlock:^(id formData) { + [formData appendPartWithFileURL:fileURL name:@"images[]" error:nil]; + }]; + + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + + [mutableOperations addObject:operation]; +} + +NSArray *operations = [AFURLConnectionOperation batchOfRequestOperations:@[...] progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) { + NSLog(@"%lu of %lu complete", numberOfFinishedOperations, totalNumberOfOperations); +} completionBlock:^(NSArray *operations) { + NSLog(@"All operations in batch complete"); +}]; +[[NSOperationQueue mainQueue] addOperations:operations waitUntilFinished:NO]; +``` + +## Unit Tests + +AFNetworking includes a suite of unit tests within the Tests subdirectory. In order to run the unit tests, you must install the testing dependencies via [CocoaPods](https://cocoapods.org/): + + $ cd Tests + $ pod install + +Once testing dependencies are installed, you can execute the test suite via the 'iOS Tests' and 'OS X Tests' schemes within Xcode. + +### Running Tests from the Command Line + +Tests can also be run from the command line or within a continuous integration environment. The [`xcpretty`](https://github.com/supermarin/xcpretty) utility needs to be installed before running the tests from the command line: + + $ gem install xcpretty + +Once `xcpretty` is installed, you can execute the suite via `rake test`. + +## Credits + +AFNetworking is owned and maintained by the [Alamofire Software Foundation](http://alamofire.org). + +AFNetworking was originally created by [Scott Raymond](https://github.com/sco/) and [Mattt Thompson](https://github.com/mattt/) in the development of [Gowalla for iPhone](https://en.wikipedia.org/wiki/Gowalla). + +AFNetworking's logo was designed by [Alan Defibaugh](http://www.alandefibaugh.com/). + +And most of all, thanks to AFNetworking's [growing list of contributors](https://github.com/AFNetworking/AFNetworking/graphs/contributors). + +### Security Disclosure + +If you believe you have identified a security vulnerability with AFNetworking, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker. + +## License + +AFNetworking is released under the MIT license. See LICENSE for details. diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 100644 index 0000000..3c7649b --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1,80 @@ +// AFNetworkActivityIndicatorManager.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** + `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. + + 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: + + [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; + + 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. + + See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: + http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 + */ +NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead.") +@interface AFNetworkActivityIndicatorManager : NSObject + +/** + A Boolean value indicating whether the manager is enabled. + + If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. + */ +@property (nonatomic, assign, getter = isEnabled) BOOL enabled; + +/** + A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. + */ +@property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; + +/** + Returns the shared network activity indicator manager object for the system. + + @return The systemwide network activity indicator manager. + */ ++ (instancetype)sharedManager; + +/** + Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. + */ +- (void)incrementActivityCount; + +/** + Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. + */ +- (void)decrementActivityCount; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m b/Strike/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m new file mode 100644 index 0000000..cf13180 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m @@ -0,0 +1,170 @@ +// AFNetworkActivityIndicatorManager.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "AFNetworkActivityIndicatorManager.h" + +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) + +#import "AFHTTPRequestOperation.h" + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 +#import "AFURLSessionManager.h" +#endif + +static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; + +static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { + if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) { + return [(AFURLConnectionOperation *)[notification object] request]; + } + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 + if ([[notification object] respondsToSelector:@selector(originalRequest)]) { + return [(NSURLSessionTask *)[notification object] originalRequest]; + } +#endif + + return nil; +} + +@interface AFNetworkActivityIndicatorManager () +@property (readwrite, nonatomic, assign) NSInteger activityCount; +@property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; +@property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; + +- (void)updateNetworkActivityIndicatorVisibility; +- (void)updateNetworkActivityIndicatorVisibilityDelayed; +@end + +@implementation AFNetworkActivityIndicatorManager +@dynamic networkActivityIndicatorVisible; + ++ (instancetype)sharedManager { + static AFNetworkActivityIndicatorManager *_sharedManager = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _sharedManager = [[self alloc] init]; + }); + + return _sharedManager; +} + ++ (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { + return [NSSet setWithObject:@"activityCount"]; +} + +- (id)init { + self = [super init]; + if (!self) { + return nil; + } + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; +#endif + + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [_activityIndicatorVisibilityTimer invalidate]; +} + +- (void)updateNetworkActivityIndicatorVisibilityDelayed { + if (self.enabled) { + // Delay hiding of activity indicator for a short interval, to avoid flickering + if (![self isNetworkActivityIndicatorVisible]) { + [self.activityIndicatorVisibilityTimer invalidate]; + self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; + [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; + } else { + [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; + } + } +} + +- (BOOL)isNetworkActivityIndicatorVisible { + return self.activityCount > 0; +} + +- (void)updateNetworkActivityIndicatorVisibility { + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; +} + +- (void)setActivityCount:(NSInteger)activityCount { + @synchronized(self) { + _activityCount = activityCount; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); +} + +- (void)incrementActivityCount { + [self willChangeValueForKey:@"activityCount"]; + @synchronized(self) { + _activityCount++; + } + [self didChangeValueForKey:@"activityCount"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); +} + +- (void)decrementActivityCount { + [self willChangeValueForKey:@"activityCount"]; + @synchronized(self) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + _activityCount = MAX(_activityCount - 1, 0); +#pragma clang diagnostic pop + } + [self didChangeValueForKey:@"activityCount"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self updateNetworkActivityIndicatorVisibilityDelayed]; + }); +} + +- (void)networkRequestDidStart:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self incrementActivityCount]; + } +} + +- (void)networkRequestDidFinish:(NSNotification *)notification { + if ([AFNetworkRequestFromNotification(notification) URL]) { + [self decrementActivityCount]; + } +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 100644 index 0000000..0c8f9b5 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1,63 @@ +// UIActivityIndicatorView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +@class AFURLConnectionOperation; + +/** + 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. + */ +@interface UIActivityIndicatorView (AFNetworking) + +///---------------------------------- +/// @name Animating for Session Tasks +///---------------------------------- + +/** + Binds the animating state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setAnimatingWithStateOfTask:(nullable NSURLSessionTask *)task; +#endif + +///--------------------------------------- +/// @name Animating for Request Operations +///--------------------------------------- + +/** + Binds the animating state to the execution state of the specified operation. + + @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setAnimatingWithStateOfOperation:(nullable AFURLConnectionOperation *)operation; + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m new file mode 100644 index 0000000..dd362b0 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m @@ -0,0 +1,171 @@ +// UIActivityIndicatorView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIActivityIndicatorView+AFNetworking.h" +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFHTTPRequestOperation.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +#import "AFURLSessionManager.h" +#endif + +@interface AFActivityIndicatorViewNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIActivityIndicatorView *activityIndicatorView; +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; +#endif +- (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation; + +@end + +@implementation UIActivityIndicatorView (AFNetworking) + +- (AFActivityIndicatorViewNotificationObserver *)af_notificationObserver { + AFActivityIndicatorViewNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFActivityIndicatorViewNotificationObserver alloc] initWithActivityIndicatorView:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setAnimatingWithStateOfTask:task]; +} +#endif + +- (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { + [[self af_notificationObserver] setAnimatingWithStateOfOperation:operation]; +} + +@end + +@implementation AFActivityIndicatorViewNotificationObserver + +- (instancetype)initWithActivityIndicatorView:(UIActivityIndicatorView *)activityIndicatorView +{ + self = [super init]; + if (self) { + _activityIndicatorView = activityIndicatorView; + } + return self; +} + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { + if (task.state != NSURLSessionTaskStateCompleted) { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (task.state == NSURLSessionTaskStateRunning) { + [self.activityIndicatorView startAnimating]; + } else { + [self.activityIndicatorView stopAnimating]; + } +#pragma clang diagnostic pop + + [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; + } + } +} +#endif + +#pragma mark - + +- (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; + + if (operation) { + if (![operation isFinished]) { + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if ([operation isExecuting]) { + [self.activityIndicatorView startAnimating]; + } else { + [self.activityIndicatorView stopAnimating]; + } +#pragma clang diagnostic pop + + [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation]; + [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation]; + } + } +} + +#pragma mark - + +- (void)af_startAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.activityIndicatorView startAnimating]; +#pragma clang diagnostic pop + }); +} + +- (void)af_stopAnimating { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.activityIndicatorView stopAnimating]; +#pragma clang diagnostic pop + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +#endif + + [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h new file mode 100644 index 0000000..97f5622 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h @@ -0,0 +1,99 @@ +// UIAlertView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFURLConnectionOperation; + +/** + 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. + */ +@interface UIAlertView (AFNetworking) + +///------------------------------------- +/// @name Showing Alert for Session Task +///------------------------------------- + +/** + Shows an alert view with the error of the specified session task, if any. + + @param task The session task. + @param delegate The alert view delegate. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 ++ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task + delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); +#endif + +/** + Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. + + @param task The session task. + @param delegate The alert view delegate. + @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. + @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`. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 ++ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task + delegate:(nullable id)delegate + cancelButtonTitle:(nullable NSString *)cancelButtonTitle + otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); +#endif + +///------------------------------------------ +/// @name Showing Alert for Request Operation +///------------------------------------------ + +/** + Shows an alert view with the error of the specified request operation, if any. + + @param operation The request operation. + @param delegate The alert view delegate. + */ ++ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation + delegate:(nullable id)delegate NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); + +/** + Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. + + @param operation The request operation. + @param delegate The alert view delegate. + @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. + @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`. + */ ++ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation + delegate:(nullable id)delegate + cancelButtonTitle:(nullable NSString *)cancelButtonTitle + otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extensions."); + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m new file mode 100644 index 0000000..0d1e9e7 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.m @@ -0,0 +1,141 @@ +// UIAlertView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIAlertView+AFNetworking.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFURLConnectionOperation.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +#import "AFURLSessionManager.h" +#endif + +static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) { + if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) { + *title = error.localizedDescription; + + if (error.localizedRecoverySuggestion) { + *message = error.localizedRecoverySuggestion; + } else { + *message = error.localizedFailureReason; + } + } else if (error.localizedDescription) { + *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); + *message = error.localizedDescription; + } else { + *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); + *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code]; + } +} + +@implementation UIAlertView (AFNetworking) + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 ++ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task + delegate:(id)delegate +{ + [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; +} + ++ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task + delegate:(id)delegate + cancelButtonTitle:(NSString *)cancelButtonTitle + otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION +{ + NSMutableArray *mutableOtherTitles = [NSMutableArray array]; + va_list otherButtonTitleList; + va_start(otherButtonTitleList, otherButtonTitles); + { + for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { + [mutableOtherTitles addObject:otherButtonTitle]; + } + } + va_end(otherButtonTitleList); + + __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { + NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey]; + if (error) { + NSString *title, *message; + AFGetAlertViewTitleAndMessageFromError(error, &title, &message); + + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; + for (NSString *otherButtonTitle in mutableOtherTitles) { + [alertView addButtonWithTitle:otherButtonTitle]; + } + [alertView setTitle:title]; + [alertView setMessage:message]; + [alertView show]; + } + + [[NSNotificationCenter defaultCenter] removeObserver:observer]; + }]; +} +#endif + +#pragma mark - + ++ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation + delegate:(id)delegate +{ + [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; +} + ++ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation + delegate:(id)delegate + cancelButtonTitle:(NSString *)cancelButtonTitle + otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION +{ + NSMutableArray *mutableOtherTitles = [NSMutableArray array]; + va_list otherButtonTitleList; + va_start(otherButtonTitleList, otherButtonTitles); + { + for (NSString *otherButtonTitle = otherButtonTitles; otherButtonTitle != nil; otherButtonTitle = va_arg(otherButtonTitleList, NSString *)) { + [mutableOtherTitles addObject:otherButtonTitle]; + } + } + va_end(otherButtonTitleList); + + __block __weak id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { + + if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) { + NSError *error = [(AFURLConnectionOperation *)notification.object error]; + if (error) { + NSString *title, *message; + AFGetAlertViewTitleAndMessageFromError(error, &title, &message); + + UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; + for (NSString *otherButtonTitle in mutableOtherTitles) { + [alertView addButtonWithTitle:otherButtonTitle]; + } + [alertView setTitle:title]; + [alertView setMessage:message]; + [alertView show]; + } + } + + [[NSNotificationCenter defaultCenter] removeObserver:observer]; + }]; +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h new file mode 100644 index 0000000..7289bdb --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1,186 @@ +// UIButton+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol AFURLResponseSerialization, AFImageCache; + +/** + 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. + + @warning Compound values for control `state` (such as `UIControlStateHighlighted | UIControlStateDisabled`) are unsupported. + */ +@interface UIButton (AFNetworking) + +///---------------------------- +/// @name Accessing Image Cache +///---------------------------- + +/** + The image cache used to improve image loading performance on scroll views. By default, `UIButton` will use the `sharedImageCache` of `UIImageView`. + */ ++ (id )sharedImageCache; + +/** + Set the cache used for image loading. + + @param imageCache The image cache. + */ ++ (void)setSharedImageCache:(__nullable id )imageCache; + +///------------------------------------ +/// @name Accessing Response Serializer +///------------------------------------ + +/** + The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. + + @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 + */ +@property (nonatomic, strong) id imageResponseSerializer; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + 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. + + 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. + + @param state The control state. + @param url The URL used for the image request. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + 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. + + 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. + + @param state The control state. + @param url The URL used for the image request. + @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. + */ +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + 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. + + 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. + + 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. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @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. + @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 response parameter will be `nil`. + @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. + */ +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(nullable void (^)(NSError *error))failure; + + +///------------------------------- +/// @name Setting Background Image +///------------------------------- + +/** + 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. + + 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. + + @param state The control state. + @param url The URL used for the background image request. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url; + +/** + 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. + + 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. + + @param state The control state. + @param url The URL used for the background image request. + @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. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + 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. + + 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. + + 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. + + @param state The control state. + @param urlRequest The URL request used for the image request. + @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. + @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 response parameter will be `nil`. + @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. + */ +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(nullable void (^)(NSError *error))failure; + + +///------------------------------ +/// @name Canceling Image Loading +///------------------------------ + +/** + Cancels any executing image operation for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelImageRequestOperationForState:(UIControlState)state; + +/** + Cancels any executing background image operation for the specified control state of the receiver, if one exists. + + @param state The control state. + */ +- (void)cancelBackgroundImageRequestOperationForState:(UIControlState)state; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m new file mode 100644 index 0000000..e5c36a5 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.m @@ -0,0 +1,293 @@ +// UIButton+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIButton+AFNetworking.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFURLResponseSerialization.h" +#import "AFHTTPRequestOperation.h" + +#import "UIImageView+AFNetworking.h" + +@interface UIButton (_AFNetworking) +@end + +@implementation UIButton (_AFNetworking) + ++ (NSOperationQueue *)af_sharedImageRequestOperationQueue { + static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init]; + _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; + }); + + return _af_sharedImageRequestOperationQueue; +} + +#pragma mark - + +static char AFImageRequestOperationNormal; +static char AFImageRequestOperationHighlighted; +static char AFImageRequestOperationSelected; +static char AFImageRequestOperationDisabled; + +static const char * af_imageRequestOperationKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFImageRequestOperationHighlighted; + case UIControlStateSelected: + return &AFImageRequestOperationSelected; + case UIControlStateDisabled: + return &AFImageRequestOperationDisabled; + case UIControlStateNormal: + default: + return &AFImageRequestOperationNormal; + } +} + +- (AFHTTPRequestOperation *)af_imageRequestOperationForState:(UIControlState)state { + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, af_imageRequestOperationKeyForState(state)); +} + +- (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_imageRequestOperationKeyForState(state), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +static char AFBackgroundImageRequestOperationNormal; +static char AFBackgroundImageRequestOperationHighlighted; +static char AFBackgroundImageRequestOperationSelected; +static char AFBackgroundImageRequestOperationDisabled; + +static const char * af_backgroundImageRequestOperationKeyForState(UIControlState state) { + switch (state) { + case UIControlStateHighlighted: + return &AFBackgroundImageRequestOperationHighlighted; + case UIControlStateSelected: + return &AFBackgroundImageRequestOperationSelected; + case UIControlStateDisabled: + return &AFBackgroundImageRequestOperationDisabled; + case UIControlStateNormal: + default: + return &AFBackgroundImageRequestOperationNormal; + } +} + +- (AFHTTPRequestOperation *)af_backgroundImageRequestOperationForState:(UIControlState)state { + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, af_backgroundImageRequestOperationKeyForState(state)); +} + +- (void)af_setBackgroundImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation + forState:(UIControlState)state +{ + objc_setAssociatedObject(self, af_backgroundImageRequestOperationKeyForState(state), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIButton (AFNetworking) + ++ (id )sharedImageCache { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sharedImageCache)) ?: [UIImageView sharedImageCache]; +#pragma clang diagnostic pop +} + ++ (void)setSharedImageCache:(__nullable id )imageCache { + objc_setAssociatedObject(self, @selector(sharedImageCache), imageCache, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (id )imageResponseSerializer { + static id _af_defaultImageResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(imageResponseSerializer)) ?: _af_defaultImageResponseSerializer; +#pragma clang diagnostic pop +} + +- (void)setImageResponseSerializer:(id )serializer { + objc_setAssociatedObject(self, @selector(imageResponseSerializer), serializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(void (^)(NSError *error))failure +{ + [self cancelImageRequestOperationForState:state]; + + UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setImage:cachedImage forState:state]; + } + + [self af_setImageRequestOperation:nil forState:state]; + } else { + if (placeholderImage) { + [self setImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + AFHTTPRequestOperation *imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + imageRequestOperation.responseSerializer = self.imageResponseSerializer; + [imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[urlRequest URL] isEqual:[operation.request URL]]) { + if (success) { + success(operation.request, operation.response, responseObject); + } else if (responseObject) { + [strongSelf setImage:responseObject forState:state]; + } + } + [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if ([[urlRequest URL] isEqual:[operation.request URL]]) { + if (failure) { + failure(error); + } + } + }]; + + [self af_setImageRequestOperation:imageRequestOperation forState:state]; + [[[self class] af_sharedImageRequestOperationQueue] addOperation:imageRequestOperation]; + } +} + +#pragma mark - + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url +{ + [self setBackgroundImageForState:state withURL:url placeholderImage:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setBackgroundImageForState:(UIControlState)state + withURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(void (^)(NSError *error))failure +{ + [self cancelBackgroundImageRequestOperationForState:state]; + + UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + [self setBackgroundImage:cachedImage forState:state]; + } + + [self af_setBackgroundImageRequestOperation:nil forState:state]; + } else { + if (placeholderImage) { + [self setBackgroundImage:placeholderImage forState:state]; + } + + __weak __typeof(self)weakSelf = self; + AFHTTPRequestOperation *backgroundImageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + backgroundImageRequestOperation.responseSerializer = self.imageResponseSerializer; + [backgroundImageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[urlRequest URL] isEqual:[operation.request URL]]) { + if (success) { + success(operation.request, operation.response, responseObject); + } else if (responseObject) { + [strongSelf setBackgroundImage:responseObject forState:state]; + } + } + [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if ([[urlRequest URL] isEqual:[operation.request URL]]) { + if (failure) { + failure(error); + } + } + }]; + + [self af_setBackgroundImageRequestOperation:backgroundImageRequestOperation forState:state]; + [[[self class] af_sharedImageRequestOperationQueue] addOperation:backgroundImageRequestOperation]; + } +} + +#pragma mark - + +- (void)cancelImageRequestOperationForState:(UIControlState)state { + [[self af_imageRequestOperationForState:state] cancel]; + [self af_setImageRequestOperation:nil forState:state]; +} + +- (void)cancelBackgroundImageRequestOperationForState:(UIControlState)state { + [[self af_backgroundImageRequestOperationForState:state] cancel]; + [self af_setBackgroundImageRequestOperation:nil forState:state]; +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h new file mode 100644 index 0000000..3292920 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1,35 @@ +// +// UIImage+AFNetworking.h +// +// +// Created by Paulo Ferreira on 08/07/15. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +@interface UIImage (AFNetworking) + ++ (UIImage*) safeImageWithData:(NSData*)data; + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h new file mode 100644 index 0000000..bf61915 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1,146 @@ +// UIImageView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol AFURLResponseSerialization, AFImageCache; + +/** + 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. + */ +@interface UIImageView (AFNetworking) + +///---------------------------- +/// @name Accessing Image Cache +///---------------------------- + +/** + 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. +*/ ++ (id )sharedImageCache; + +/** + Set the cache used for image loading. + + @param imageCache The image cache. + */ ++ (void)setSharedImageCache:(__nullable id )imageCache; + +///------------------------------------ +/// @name Accessing Response Serializer +///------------------------------------ + +/** + The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. + + @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 + */ +@property (nonatomic, strong) id imageResponseSerializer; + +///-------------------- +/// @name Setting Image +///-------------------- + +/** + 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. + + 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. + + 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:` + + @param url The URL used for the image request. + */ +- (void)setImageWithURL:(NSURL *)url; + +/** + 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. + + 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. + + 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:` + + @param url The URL used for the image request. + @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. + */ +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(nullable UIImage *)placeholderImage; + +/** + 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. + + 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. + + 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. + + @param urlRequest The URL request used for the image request. + @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. + @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 response parameter will be `nil`. + @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. + */ +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(nullable UIImage *)placeholderImage + success:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(nullable void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, NSError *error))failure; + +/** + Cancels any executing image operation for the receiver, if one exists. + */ +- (void)cancelImageRequestOperation; + +@end + +#pragma mark - + +/** + The `AFImageCache` protocol is adopted by an object used to cache images loaded by the AFNetworking category on `UIImageView`. + */ +@protocol AFImageCache + +/** + Returns a cached image for the specified request, if available. + + @param request The image request. + + @return The cached image. + */ +- (nullable UIImage *)cachedImageForRequest:(NSURLRequest *)request; + +/** + Caches a particular image for the specified request. + + @param image The image to cache. + @param request The request to be used as a cache key. + */ +- (void)cacheImage:(UIImage *)image + forRequest:(NSURLRequest *)request; +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m new file mode 100644 index 0000000..2efc160 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.m @@ -0,0 +1,215 @@ +// UIImageView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIImageView+AFNetworking.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFHTTPRequestOperation.h" + +@interface AFImageCache : NSCache +@end + +#pragma mark - + +@interface UIImageView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation; +@end + +@implementation UIImageView (_AFNetworking) + ++ (NSOperationQueue *)af_sharedImageRequestOperationQueue { + static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init]; + _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; + }); + + return _af_sharedImageRequestOperationQueue; +} + +- (AFHTTPRequestOperation *)af_imageRequestOperation { + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_imageRequestOperation)); +} + +- (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation { + objc_setAssociatedObject(self, @selector(af_imageRequestOperation), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIImageView (AFNetworking) +@dynamic imageResponseSerializer; + ++ (id )sharedImageCache { + static AFImageCache *_af_defaultImageCache = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _af_defaultImageCache = [[AFImageCache alloc] init]; + + [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * __unused notification) { + [_af_defaultImageCache removeAllObjects]; + }]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(sharedImageCache)) ?: _af_defaultImageCache; +#pragma clang diagnostic pop +} + ++ (void)setSharedImageCache:(__nullable id )imageCache { + objc_setAssociatedObject(self, @selector(sharedImageCache), imageCache, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (id )imageResponseSerializer { + static id _af_defaultImageResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(imageResponseSerializer)) ?: _af_defaultImageResponseSerializer; +#pragma clang diagnostic pop +} + +- (void)setImageResponseSerializer:(id )serializer { + objc_setAssociatedObject(self, @selector(imageResponseSerializer), serializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)setImageWithURL:(NSURL *)url { + [self setImageWithURL:url placeholderImage:nil]; +} + +- (void)setImageWithURL:(NSURL *)url + placeholderImage:(UIImage *)placeholderImage +{ + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; + [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; + + [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; +} + +- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest + placeholderImage:(UIImage *)placeholderImage + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse * __nullable response, NSError *error))failure +{ + [self cancelImageRequestOperation]; + + UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; + if (cachedImage) { + if (success) { + success(urlRequest, nil, cachedImage); + } else { + self.image = cachedImage; + } + + self.af_imageRequestOperation = nil; + } else { + if (placeholderImage) { + self.image = placeholderImage; + } + + __weak __typeof(self)weakSelf = self; + self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + self.af_imageRequestOperation.responseSerializer = self.imageResponseSerializer; + [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { + if (success) { + success(urlRequest, operation.response, responseObject); + } else if (responseObject) { + strongSelf.image = responseObject; + } + + if (operation == strongSelf.af_imageRequestOperation){ + strongSelf.af_imageRequestOperation = nil; + } + } + + [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { + if (failure) { + failure(urlRequest, operation.response, error); + } + + if (operation == strongSelf.af_imageRequestOperation){ + strongSelf.af_imageRequestOperation = nil; + } + } + }]; + + [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation]; + } +} + +- (void)cancelImageRequestOperation { + [self.af_imageRequestOperation cancel]; + self.af_imageRequestOperation = nil; +} + +@end + +#pragma mark - + +static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) { + return [[request URL] absoluteString]; +} + +@implementation AFImageCache + +- (UIImage *)cachedImageForRequest:(NSURLRequest *)request { + switch ([request cachePolicy]) { + case NSURLRequestReloadIgnoringCacheData: + case NSURLRequestReloadIgnoringLocalAndRemoteCacheData: + return nil; + default: + break; + } + + return [self objectForKey:AFImageCacheKeyFromURLRequest(request)]; +} + +- (void)cacheImage:(UIImage *)image + forRequest:(NSURLRequest *)request +{ + if (image && request) { + [self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)]; + } +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h new file mode 100644 index 0000000..49850ed --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1,39 @@ +// UIKit+AFNetworking.h +// +// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if TARGET_OS_IOS +#import + +#ifndef _UIKIT_AFNETWORKING_ + #define _UIKIT_AFNETWORKING_ + + #import "AFNetworkActivityIndicatorManager.h" + + #import "UIActivityIndicatorView+AFNetworking.h" + #import "UIAlertView+AFNetworking.h" + #import "UIButton+AFNetworking.h" + #import "UIImageView+AFNetworking.h" + #import "UIProgressView+AFNetworking.h" + #import "UIRefreshControl+AFNetworking.h" + #import "UIWebView+AFNetworking.h" +#endif /* _UIKIT_AFNETWORKING_ */ +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h new file mode 100644 index 0000000..5c00d6d --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1,91 @@ +// UIProgressView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFURLConnectionOperation; + +/** + 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. + */ +@interface UIProgressView (AFNetworking) + +///------------------------------------ +/// @name Setting Session Task Progress +///------------------------------------ + +/** + Binds the progress to the upload progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated; +#endif + +/** + Binds the progress to the download progress of the specified session task. + + @param task The session task. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated; +#endif + +///------------------------------------ +/// @name Setting Session Task Progress +///------------------------------------ + +/** + Binds the progress to the upload progress of the specified request operation. + + @param operation The request operation. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation + animated:(BOOL)animated; + +/** + Binds the progress to the download progress of the specified request operation. + + @param operation The request operation. + @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. + */ +- (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation + animated:(BOOL)animated; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m new file mode 100644 index 0000000..ad2c280 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.m @@ -0,0 +1,182 @@ +// UIProgressView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIProgressView+AFNetworking.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFURLConnectionOperation.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +#import "AFURLSessionManager.h" +#endif + +static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; +static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; + +@interface AFURLConnectionOperation (_UIProgressView) +@property (readwrite, nonatomic, copy) void (^uploadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +@property (readwrite, nonatomic, assign, setter = af_setUploadProgressAnimated:) BOOL af_uploadProgressAnimated; + +@property (readwrite, nonatomic, copy) void (^downloadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +@property (readwrite, nonatomic, assign, setter = af_setDownloadProgressAnimated:) BOOL af_downloadProgressAnimated; +@end + +@implementation AFURLConnectionOperation (_UIProgressView) +@dynamic uploadProgress; // Implemented in AFURLConnectionOperation +@dynamic af_uploadProgressAnimated; + +@dynamic downloadProgress; // Implemented in AFURLConnectionOperation +@dynamic af_downloadProgressAnimated; +@end + +#pragma mark - + +@implementation UIProgressView (AFNetworking) + +- (BOOL)af_uploadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; +} + +- (void)af_setUploadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (BOOL)af_downloadProgressAnimated { + return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; +} + +- (void)af_setDownloadProgressAnimated:(BOOL)animated { + objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task + animated:(BOOL)animated +{ + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + [task addObserver:self forKeyPath:@"countOfBytesSent" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesSentContext]; + + [self af_setUploadProgressAnimated:animated]; +} + +- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task + animated:(BOOL)animated +{ + [task addObserver:self forKeyPath:@"state" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + [task addObserver:self forKeyPath:@"countOfBytesReceived" options:(NSKeyValueObservingOptions)0 context:AFTaskCountOfBytesReceivedContext]; + + [self af_setDownloadProgressAnimated:animated]; +} +#endif + +#pragma mark - + +- (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation + animated:(BOOL)animated +{ + __weak __typeof(self)weakSelf = self; + void (^original)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) = [operation.uploadProgress copy]; + [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { + if (original) { + original(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + if (totalBytesExpectedToWrite > 0) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf setProgress:(totalBytesWritten / (totalBytesExpectedToWrite * 1.0f)) animated:animated]; + } + }); + }]; +} + +- (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation + animated:(BOOL)animated +{ + __weak __typeof(self)weakSelf = self; + void (^original)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) = [operation.downloadProgress copy]; + [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { + if (original) { + original(bytesRead, totalBytesRead, totalBytesExpectedToRead); + } + + dispatch_async(dispatch_get_main_queue(), ^{ + if (totalBytesExpectedToRead > 0) { + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf setProgress:(totalBytesRead / (totalBytesExpectedToRead * 1.0f)) animated:animated]; + } + }); + }]; +} + +#pragma mark - NSKeyValueObserving + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(__unused NSDictionary *)change + context:(void *)context +{ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 + if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { + if ([object countOfBytesExpectedToSend] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { + if ([object countOfBytesExpectedToReceive] > 0) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; + }); + } + } + + if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { + if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { + @try { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; + + if (context == AFTaskCountOfBytesSentContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; + } + + if (context == AFTaskCountOfBytesReceivedContext) { + [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; + } + } + @catch (NSException * __unused exception) {} + } + } + } +#endif +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h new file mode 100644 index 0000000..a65e390 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1,68 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFURLConnectionOperation; + +/** + This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically beginning and ending refreshing depending on the loading state of a request operation or session task. + */ +@interface UIRefreshControl (AFNetworking) + +///----------------------------------- +/// @name Refreshing for Session Tasks +///----------------------------------- + +/** + Binds the refreshing state to the state of the specified task. + + @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; +#endif + +///---------------------------------------- +/// @name Refreshing for Request Operations +///---------------------------------------- + +/** + Binds the refreshing state to the execution state of the specified operation. + + @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. + */ +- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m new file mode 100644 index 0000000..4c19245 --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m @@ -0,0 +1,166 @@ +// UIRefreshControl+AFNetworking.m +// +// Copyright (c) 2014 AFNetworking (http://afnetworking.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIRefreshControl+AFNetworking.h" +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFHTTPRequestOperation.h" + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +#import "AFURLSessionManager.h" +#endif + +@interface AFRefreshControlNotificationObserver : NSObject +@property (readonly, nonatomic, weak) UIRefreshControl *refreshControl; +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; +#endif +- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; + +@end + +@implementation UIRefreshControl (AFNetworking) + +- (AFRefreshControlNotificationObserver *)af_notificationObserver { + AFRefreshControlNotificationObserver *notificationObserver = objc_getAssociatedObject(self, @selector(af_notificationObserver)); + if (notificationObserver == nil) { + notificationObserver = [[AFRefreshControlNotificationObserver alloc] initWithActivityRefreshControl:self]; + objc_setAssociatedObject(self, @selector(af_notificationObserver), notificationObserver, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + } + return notificationObserver; +} + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + [[self af_notificationObserver] setRefreshingWithStateOfTask:task]; +} +#endif + +- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { + [[self af_notificationObserver] setRefreshingWithStateOfOperation:operation]; +} + +@end + +@implementation AFRefreshControlNotificationObserver + +- (instancetype)initWithActivityRefreshControl:(UIRefreshControl *)refreshControl +{ + self = [super init]; + if (self) { + _refreshControl = refreshControl; + } + return self; +} + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 +- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + + if (task) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (task.state == NSURLSessionTaskStateRunning) { + [self.refreshControl beginRefreshing]; + + [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; + } else { + [self.refreshControl endRefreshing]; + } +#pragma clang diagnostic pop + } +} +#endif + +- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + + [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; + + if (operation) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" +#pragma clang diagnostic ignored "-Warc-repeated-use-of-weak" + if (![operation isFinished]) { + if ([operation isExecuting]) { + [self.refreshControl beginRefreshing]; + } else { + [self.refreshControl endRefreshing]; + } + + [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation]; + [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation]; + } +#pragma clang diagnostic pop + } +} + +#pragma mark - + +- (void)af_beginRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.refreshControl beginRefreshing]; +#pragma clang diagnostic pop + }); +} + +- (void)af_endRefreshing { + dispatch_async(dispatch_get_main_queue(), ^{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreceiver-is-weak" + [self.refreshControl endRefreshing]; +#pragma clang diagnostic pop + }); +} + +#pragma mark - + +- (void)dealloc { + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + +#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 + [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; +#endif + + [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; + [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; +} + +@end + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h new file mode 100644 index 0000000..5d61d6a --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1,86 @@ +// UIWebView+AFNetworking.h +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class AFHTTPRequestSerializer, AFHTTPResponseSerializer; +@protocol AFURLRequestSerialization, AFURLResponseSerialization; + +/** + 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. + + @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. + */ +@interface UIWebView (AFNetworking) + +/** + The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`. + */ +@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; + +/** + The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`. + */ +@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; + +/** + Asynchronously loads the specified request. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @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. + @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. + @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. + */ +- (void)loadRequest:(NSURLRequest *)request + progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress + success:(nullable NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(nullable void (^)(NSError *error))failure; + +/** + Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. + + @param request A URL request identifying the location of the content to load. This must not be `nil`. + @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. + @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. + @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. + @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. + @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. + */ +- (void)loadRequest:(NSURLRequest *)request + MIMEType:(nullable NSString *)MIMEType + textEncodingName:(nullable NSString *)textEncodingName + progress:(nullable void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress + success:(nullable NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(nullable void (^)(NSError *error))failure; + +@end + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m new file mode 100644 index 0000000..93eacaa --- /dev/null +++ b/Strike/Pods/AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.m @@ -0,0 +1,159 @@ +// UIWebView+AFNetworking.m +// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#import "UIWebView+AFNetworking.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + +#import "AFHTTPRequestOperation.h" +#import "AFURLResponseSerialization.h" +#import "AFURLRequestSerialization.h" + +@interface UIWebView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation; +@end + +@implementation UIWebView (_AFNetworking) + +- (AFHTTPRequestOperation *)af_HTTPRequestOperation { + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation)); +} + +- (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation { + objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +@end + +#pragma mark - + +@implementation UIWebView (AFNetworking) + +- (AFHTTPRequestSerializer *)requestSerializer { + static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer; +#pragma clang diagnostic pop +} + +- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { + objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +- (AFHTTPResponseSerializer *)responseSerializer { + static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; + }); + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; +#pragma clang diagnostic pop +} + +- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { + objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + +#pragma mark - + +- (void)loadRequest:(NSURLRequest *)request + progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress + success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success + failure:(void (^)(NSError *error))failure +{ + [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { + NSStringEncoding stringEncoding = NSUTF8StringEncoding; + if (response.textEncodingName) { + CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); + if (encoding != kCFStringEncodingInvalidId) { + stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); + } + } + + NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; + if (success) { + string = success(response, string); + } + + return [string dataUsingEncoding:stringEncoding]; + } failure:failure]; +} + +- (void)loadRequest:(NSURLRequest *)request + MIMEType:(NSString *)MIMEType + textEncodingName:(NSString *)textEncodingName + progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress + success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success + failure:(void (^)(NSError *error))failure +{ + NSParameterAssert(request); + + if (self.af_HTTPRequestOperation) { + [self.af_HTTPRequestOperation cancel]; + } + + request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil]; + + self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; + self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer; + + __weak __typeof(self)weakSelf = self; + [self.af_HTTPRequestOperation setDownloadProgressBlock:progress]; + [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) { + NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData; + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + __strong __typeof(weakSelf) strongSelf = weakSelf; + [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]]; + + if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { + [strongSelf.delegate webViewDidFinishLoad:strongSelf]; + } + +#pragma clang diagnostic pop + } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) { + if (failure) { + failure(error); + } + }]; + + [self.af_HTTPRequestOperation start]; + + if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { + [self.delegate webViewDidStartLoad:self]; + } +} + +@end + +#endif diff --git a/Strike/Pods/CocoaPodsKeys/Keys.podspec.json b/Strike/Pods/CocoaPodsKeys/Keys.podspec.json new file mode 100644 index 0000000..1b1671e --- /dev/null +++ b/Strike/Pods/CocoaPodsKeys/Keys.podspec.json @@ -0,0 +1,23 @@ +{ + "name": "Keys", + "version": "1.0.0", + "summary": "Injected podspec used by CocoaPods-Keys plugin.", + "description": "This is intended to be used as an injected podspec template \n used by the [CocoaPods-Keys plugin](https://github.com/orta/cocoapods-keys).\n\n It should *not* be referenced outside of that context. \n", + "homepage": "https://github.com/orta/cocoapods-keys", + "license": { + "type": "MIT", + "text": "MIT LICENSE Found in the repo" + }, + "authors": { + "Orta Therox": "orta.therox@gmail.com", + "Samuel Giddins": "segiddins@segiddins.me", + "Ash Furrow": "ash@ashfurrow.com" + }, + "source": { + "git": "https://github.com/orta/cocoapods-keys.git", + "tag": "23" + }, + "source_files": "*.{h,m,swift}", + "frameworks": "Foundation", + "requires_arc": true +} \ No newline at end of file diff --git a/Strike/Pods/CocoaPodsKeys/Strike1Keys.h b/Strike/Pods/CocoaPodsKeys/Strike1Keys.h new file mode 100644 index 0000000..0348f60 --- /dev/null +++ b/Strike/Pods/CocoaPodsKeys/Strike1Keys.h @@ -0,0 +1,14 @@ +// +// Generated by CocoaPods-Keys +// on 14/02/2016 +// For more information see https://github.com/orta/cocoapods-keys +// + +#import + +@interface Strike1Keys : NSObject + +- (NSString *)username; +- (NSString *)password; + +@end diff --git a/Strike/Pods/CocoaPodsKeys/Strike1Keys.m b/Strike/Pods/CocoaPodsKeys/Strike1Keys.m new file mode 100644 index 0000000..162d3b3 --- /dev/null +++ b/Strike/Pods/CocoaPodsKeys/Strike1Keys.m @@ -0,0 +1,74 @@ +// +// Generated by CocoaPods-Keys +// on 14/02/2016 +// For more information see https://github.com/orta/cocoapods-keys +// + +#import +#import +#import "Strike1Keys.h" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wincomplete-implementation" + +@implementation Strike1Keys + +#pragma clang diagnostic pop + ++ (BOOL)resolveInstanceMethod:(SEL)name +{ + NSString *key = NSStringFromSelector(name); + NSString * (*implementation)(Strike1Keys *, SEL) = NULL; + + if ([key isEqualToString:@"username"]) { + implementation = _podKeys14c4b06b824ec593239362517f538b29; + } + + if ([key isEqualToString:@"password"]) { + implementation = _podKeys5f4dcc3b5aa765d61d8327deb882cf99; + } + + if (!implementation) { + return [super resolveInstanceMethod:name]; + } + + return class_addMethod([self class], name, (IMP)implementation, "@@:"); +} + +static NSString *_podKeys14c4b06b824ec593239362517f538b29(Strike1Keys *self, SEL _cmd) +{ + + + char cString[19] = { Strike1KeysData[996], Strike1KeysData[435], Strike1KeysData[531], Strike1KeysData[150], Strike1KeysData[963], Strike1KeysData[772], Strike1KeysData[899], Strike1KeysData[470], Strike1KeysData[684], Strike1KeysData[637], Strike1KeysData[829], Strike1KeysData[12], Strike1KeysData[714], Strike1KeysData[834], Strike1KeysData[70], Strike1KeysData[434], Strike1KeysData[585], Strike1KeysData[513], '\0' }; + + return [NSString stringWithCString:cString encoding:NSUTF8StringEncoding]; + +} + +static NSString *_podKeys5f4dcc3b5aa765d61d8327deb882cf99(Strike1Keys *self, SEL _cmd) +{ + + + char cString[12] = { Strike1KeysData[674], Strike1KeysData[761], Strike1KeysData[820], Strike1KeysData[216], Strike1KeysData[239], Strike1KeysData[352], Strike1KeysData[234], Strike1KeysData[324], Strike1KeysData[353], Strike1KeysData[82], Strike1KeysData[267], '\0' }; + + return [NSString stringWithCString:cString encoding:NSUTF8StringEncoding]; + +} + + +static char Strike1KeysData[1010] = "0mmRl5Ns61ODaccR14v/o7dze7JVK9OstbzxAZtQ49ZjKnuZJoNvZBO93iKvjY1voPfFLh.lkXDuCrsL4J2ZX22goVybg6Cx5tl1JQfRzkx41QxiwbWdESMoZqmkYvUB53n/dRwBF6XwktRm5+alIqcuwesDZk+16mYwOD1en8UqR2fsdF7DgMNCZA6sF4PoK1TSKBIN2jdy1mGY7kSrij1vpN1GxOOEndYnuWem58ncdXdlQvIaMoZTcVRQZS4Y7/KXJL9SMzn3DcfTSny5o2eMTbC7EL4wyCpuYj8HRr511G2qyaMPhKcD/Pve6aYAfMvCthZmnx4w197p8BS5bEACIWXi2seYa1fpOF439JMEcJHNqyWls+ALGmFcp+6pF0L7j7t+2xcozyXkUv9l3dOGJ2KIVLaw6kZrlCyVM6fifP/IV9crIgLpvDmZZdP7OkzuCM9W+rIB2WUyYe8HDYeWtPTrn7BPgNXVpUlOEXDPzAwXWb4si90M2/nvHm9QbmGrS45fn2JxEf9cNx0iHgJhAbNl7jdr5PmLvI6K/KVvmrfcXuQxS1hko5kVju8yeu4B303OVov4bg2vOO67FFZWJ8cy4XR4oxMRGxS4u2svAep6De/VJm4uJFP8/gMJiRM10YCcb/x/iUWmZm9lueU+MMi+1cjIeZe52DRYNL+i@YYQghHAJHoK3xxENA42pTHMF4/+1ii/RTln3tTk+0GG5wybBbjhc1c/xYJR76vfLNTnuBR4cmt32gra46PHlzYOsttk/akFhZa3Tk8FKdoz/aS3sS8w9tLEXMqzlcWj3pBbkyYOg2tNg3bLSmvXlwlB7gP2ZMuoqxHiL+ogyXAghDHnTDqrQBocK5+DVl3U9zv5Lt3PwLgUBXVXdhHrCNmzQqhuy0VcWDw8XhAbat0YO/0xgW2KN/m4B+XNL3JBeRZ2V67NTR+UrwKgj2aPrXmyq97xNSjRrK9aEvfnzmqkOctpjScH7t25E4jG3ph9Wg==\\\""; + +- (NSString *)description +{ + return [@{ + @"username": self.username, + @"password": self.password, + } description]; +} + +- (id)debugQuickLookObject +{ + return [self description]; +} + +@end diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperation.h b/Strike/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperation.h new file mode 120000 index 0000000..ac762c8 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperationManager.h b/Strike/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperationManager.h new file mode 120000 index 0000000..9dcc623 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h b/Strike/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h new file mode 120000 index 0000000..56feb9f --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h b/Strike/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 120000 index 0000000..67519d9 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h b/Strike/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h new file mode 120000 index 0000000..68fc774 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/AFNetworking.h new file mode 120000 index 0000000..a5a38da --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h b/Strike/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h new file mode 120000 index 0000000..fd1322d --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFSecurityPolicy.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFURLConnectionOperation.h b/Strike/Pods/Headers/Private/AFNetworking/AFURLConnectionOperation.h new file mode 120000 index 0000000..d9b35fb --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h b/Strike/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h new file mode 120000 index 0000000..ca8209b --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h b/Strike/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h new file mode 120000 index 0000000..e36a765 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h b/Strike/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h new file mode 120000 index 0000000..835101d --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/AFURLSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLSessionManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 120000 index 0000000..c534ebf --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIAlertView+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIAlertView+AFNetworking.h new file mode 120000 index 0000000..f992813 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIAlertView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h new file mode 120000 index 0000000..8f2e221 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h new file mode 120000 index 0000000..74f6649 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h new file mode 120000 index 0000000..a95d673 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h new file mode 120000 index 0000000..95017cc --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h new file mode 120000 index 0000000..730b167 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h new file mode 120000 index 0000000..8efd826 --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h b/Strike/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h new file mode 120000 index 0000000..c8df6ef --- /dev/null +++ b/Strike/Pods/Headers/Private/AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Keys/Strike1Keys.h b/Strike/Pods/Headers/Private/Keys/Strike1Keys.h new file mode 120000 index 0000000..225fc7b --- /dev/null +++ b/Strike/Pods/Headers/Private/Keys/Strike1Keys.h @@ -0,0 +1 @@ +../../../CocoaPodsKeys/Strike1Keys.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Spark-SDK/EventSource.h b/Strike/Pods/Headers/Private/Spark-SDK/EventSource.h new file mode 120000 index 0000000..f45ef38 --- /dev/null +++ b/Strike/Pods/Headers/Private/Spark-SDK/EventSource.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/Helpers/EventSource.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Spark-SDK/KeychainItemWrapper.h b/Strike/Pods/Headers/Private/Spark-SDK/KeychainItemWrapper.h new file mode 120000 index 0000000..9903168 --- /dev/null +++ b/Strike/Pods/Headers/Private/Spark-SDK/KeychainItemWrapper.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/Helpers/KeychainItemWrapper.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Spark-SDK/Spark-SDK.h b/Strike/Pods/Headers/Private/Spark-SDK/Spark-SDK.h new file mode 120000 index 0000000..e38aabc --- /dev/null +++ b/Strike/Pods/Headers/Private/Spark-SDK/Spark-SDK.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/Spark-SDK.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Spark-SDK/SparkAccessToken.h b/Strike/Pods/Headers/Private/Spark-SDK/SparkAccessToken.h new file mode 120000 index 0000000..cb0ad32 --- /dev/null +++ b/Strike/Pods/Headers/Private/Spark-SDK/SparkAccessToken.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkAccessToken.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Spark-SDK/SparkCloud.h b/Strike/Pods/Headers/Private/Spark-SDK/SparkCloud.h new file mode 120000 index 0000000..a8589e5 --- /dev/null +++ b/Strike/Pods/Headers/Private/Spark-SDK/SparkCloud.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkCloud.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Spark-SDK/SparkDevice.h b/Strike/Pods/Headers/Private/Spark-SDK/SparkDevice.h new file mode 120000 index 0000000..5b43b58 --- /dev/null +++ b/Strike/Pods/Headers/Private/Spark-SDK/SparkDevice.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkDevice.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Spark-SDK/SparkEvent.h b/Strike/Pods/Headers/Private/Spark-SDK/SparkEvent.h new file mode 120000 index 0000000..d6dac69 --- /dev/null +++ b/Strike/Pods/Headers/Private/Spark-SDK/SparkEvent.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkEvent.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/Spark-SDK/SparkUser.h b/Strike/Pods/Headers/Private/Spark-SDK/SparkUser.h new file mode 120000 index 0000000..c98a8a5 --- /dev/null +++ b/Strike/Pods/Headers/Private/Spark-SDK/SparkUser.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkUser.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/Reachability.h b/Strike/Pods/Headers/Private/SparkSetup/Reachability.h new file mode 120000 index 0000000..7c3d3f4 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/Reachability.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/Comm/Reachability.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkConnectingProgressViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkConnectingProgressViewController.h new file mode 120000 index 0000000..2eda49e --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkConnectingProgressViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkConnectingProgressViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkDiscoverDeviceViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkDiscoverDeviceViewController.h new file mode 120000 index 0000000..12aa471 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkDiscoverDeviceViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkDiscoverDeviceViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkGetReadyViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkGetReadyViewController.h new file mode 120000 index 0000000..d6ba41a --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkGetReadyViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkGetReadyViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkManualNetworkViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkManualNetworkViewController.h new file mode 120000 index 0000000..bf5fa16 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkManualNetworkViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkManualNetworkViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSelectNetworkViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSelectNetworkViewController.h new file mode 120000 index 0000000..622fd8a --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSelectNetworkViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSelectNetworkViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetup-Bridging-Header.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetup-Bridging-Header.h new file mode 120000 index 0000000..688c9e7 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetup-Bridging-Header.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/SparkSetup-Bridging-Header.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetup.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetup.h new file mode 120000 index 0000000..31217da --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetup.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/SparkSetup.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupCommManager.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupCommManager.h new file mode 120000 index 0000000..31c8af5 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupCommManager.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/Comm/SparkSetupCommManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupConnection.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupConnection.h new file mode 120000 index 0000000..2866c9b --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupConnection.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/Comm/SparkSetupConnection.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupCustomization.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupCustomization.h new file mode 120000 index 0000000..9c2a328 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupCustomization.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/User/SparkSetupCustomization.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupMainController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupMainController.h new file mode 120000 index 0000000..463bd6e --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupMainController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/User/SparkSetupMainController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupPasswordEntryViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupPasswordEntryViewController.h new file mode 120000 index 0000000..a796d20 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupPasswordEntryViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSetupPasswordEntryViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupResultViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupResultViewController.h new file mode 120000 index 0000000..72b64f6 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupResultViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSetupResultViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupSecurityManager.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupSecurityManager.h new file mode 120000 index 0000000..adf42dd --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupSecurityManager.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/Comm/SparkSetupSecurityManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIButton.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIButton.h new file mode 120000 index 0000000..2ae1035 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIButton.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUIButton.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIElements.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIElements.h new file mode 120000 index 0000000..64e781a --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIElements.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUIElements.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUILabel.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUILabel.h new file mode 120000 index 0000000..c065bf5 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUILabel.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUILabel.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUISpinner.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUISpinner.h new file mode 120000 index 0000000..8a11ecc --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUISpinner.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUISpinner.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIViewController.h new file mode 120000 index 0000000..c43849a --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupUIViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUIViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupVideoViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupVideoViewController.h new file mode 120000 index 0000000..247e3ce --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupVideoViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSetupVideoViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupWebViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupWebViewController.h new file mode 120000 index 0000000..908774f --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupWebViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSetupWebViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkSetupWifiTableViewCell.h b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupWifiTableViewCell.h new file mode 120000 index 0000000..7387ded --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkSetupWifiTableViewCell.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupWifiTableViewCell.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkUserForgotPasswordViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkUserForgotPasswordViewController.h new file mode 120000 index 0000000..6248e90 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkUserForgotPasswordViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkUserForgotPasswordViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkUserLoginViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkUserLoginViewController.h new file mode 120000 index 0000000..29effd4 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkUserLoginViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkUserLoginViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Private/SparkSetup/SparkUserSignupViewController.h b/Strike/Pods/Headers/Private/SparkSetup/SparkUserSignupViewController.h new file mode 120000 index 0000000..3841e95 --- /dev/null +++ b/Strike/Pods/Headers/Private/SparkSetup/SparkUserSignupViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkUserSignupViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h b/Strike/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h new file mode 120000 index 0000000..ac762c8 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperation.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h b/Strike/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h new file mode 120000 index 0000000..9dcc623 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFHTTPRequestOperationManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPRequestOperationManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h b/Strike/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h new file mode 120000 index 0000000..56feb9f --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFHTTPSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h b/Strike/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h new file mode 120000 index 0000000..67519d9 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFNetworkActivityIndicatorManager.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h b/Strike/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h new file mode 120000 index 0000000..68fc774 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFNetworkReachabilityManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/AFNetworking.h new file mode 120000 index 0000000..a5a38da --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h b/Strike/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h new file mode 120000 index 0000000..fd1322d --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFSecurityPolicy.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFSecurityPolicy.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h b/Strike/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h new file mode 120000 index 0000000..d9b35fb --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFURLConnectionOperation.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLConnectionOperation.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h b/Strike/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h new file mode 120000 index 0000000..ca8209b --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFURLRequestSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h b/Strike/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h new file mode 120000 index 0000000..e36a765 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFURLResponseSerialization.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h b/Strike/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h new file mode 120000 index 0000000..835101d --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/AFURLSessionManager.h @@ -0,0 +1 @@ +../../../AFNetworking/AFNetworking/AFURLSessionManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h new file mode 120000 index 0000000..c534ebf --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIActivityIndicatorView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h new file mode 120000 index 0000000..f992813 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIAlertView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIAlertView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h new file mode 120000 index 0000000..8f2e221 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIButton+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h new file mode 120000 index 0000000..74f6649 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIImage+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h new file mode 120000 index 0000000..a95d673 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIImageView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h new file mode 120000 index 0000000..95017cc --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIKit+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h new file mode 120000 index 0000000..730b167 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIProgressView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h new file mode 120000 index 0000000..8efd826 --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIRefreshControl+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h b/Strike/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h new file mode 120000 index 0000000..c8df6ef --- /dev/null +++ b/Strike/Pods/Headers/Public/AFNetworking/UIWebView+AFNetworking.h @@ -0,0 +1 @@ +../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Keys/Strike1Keys.h b/Strike/Pods/Headers/Public/Keys/Strike1Keys.h new file mode 120000 index 0000000..225fc7b --- /dev/null +++ b/Strike/Pods/Headers/Public/Keys/Strike1Keys.h @@ -0,0 +1 @@ +../../../CocoaPodsKeys/Strike1Keys.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Spark-SDK/EventSource.h b/Strike/Pods/Headers/Public/Spark-SDK/EventSource.h new file mode 120000 index 0000000..f45ef38 --- /dev/null +++ b/Strike/Pods/Headers/Public/Spark-SDK/EventSource.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/Helpers/EventSource.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Spark-SDK/KeychainItemWrapper.h b/Strike/Pods/Headers/Public/Spark-SDK/KeychainItemWrapper.h new file mode 120000 index 0000000..9903168 --- /dev/null +++ b/Strike/Pods/Headers/Public/Spark-SDK/KeychainItemWrapper.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/Helpers/KeychainItemWrapper.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Spark-SDK/Spark-SDK.h b/Strike/Pods/Headers/Public/Spark-SDK/Spark-SDK.h new file mode 120000 index 0000000..e38aabc --- /dev/null +++ b/Strike/Pods/Headers/Public/Spark-SDK/Spark-SDK.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/Spark-SDK.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Spark-SDK/SparkAccessToken.h b/Strike/Pods/Headers/Public/Spark-SDK/SparkAccessToken.h new file mode 120000 index 0000000..cb0ad32 --- /dev/null +++ b/Strike/Pods/Headers/Public/Spark-SDK/SparkAccessToken.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkAccessToken.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Spark-SDK/SparkCloud.h b/Strike/Pods/Headers/Public/Spark-SDK/SparkCloud.h new file mode 120000 index 0000000..a8589e5 --- /dev/null +++ b/Strike/Pods/Headers/Public/Spark-SDK/SparkCloud.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkCloud.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Spark-SDK/SparkDevice.h b/Strike/Pods/Headers/Public/Spark-SDK/SparkDevice.h new file mode 120000 index 0000000..5b43b58 --- /dev/null +++ b/Strike/Pods/Headers/Public/Spark-SDK/SparkDevice.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkDevice.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Spark-SDK/SparkEvent.h b/Strike/Pods/Headers/Public/Spark-SDK/SparkEvent.h new file mode 120000 index 0000000..d6dac69 --- /dev/null +++ b/Strike/Pods/Headers/Public/Spark-SDK/SparkEvent.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkEvent.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/Spark-SDK/SparkUser.h b/Strike/Pods/Headers/Public/Spark-SDK/SparkUser.h new file mode 120000 index 0000000..c98a8a5 --- /dev/null +++ b/Strike/Pods/Headers/Public/Spark-SDK/SparkUser.h @@ -0,0 +1 @@ +../../../Spark-SDK/Pod/Classes/SDK/SparkUser.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/Reachability.h b/Strike/Pods/Headers/Public/SparkSetup/Reachability.h new file mode 120000 index 0000000..7c3d3f4 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/Reachability.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/Comm/Reachability.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkConnectingProgressViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkConnectingProgressViewController.h new file mode 120000 index 0000000..2eda49e --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkConnectingProgressViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkConnectingProgressViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkDiscoverDeviceViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkDiscoverDeviceViewController.h new file mode 120000 index 0000000..12aa471 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkDiscoverDeviceViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkDiscoverDeviceViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkGetReadyViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkGetReadyViewController.h new file mode 120000 index 0000000..d6ba41a --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkGetReadyViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkGetReadyViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkManualNetworkViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkManualNetworkViewController.h new file mode 120000 index 0000000..bf5fa16 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkManualNetworkViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkManualNetworkViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSelectNetworkViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSelectNetworkViewController.h new file mode 120000 index 0000000..622fd8a --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSelectNetworkViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSelectNetworkViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetup-Bridging-Header.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetup-Bridging-Header.h new file mode 120000 index 0000000..688c9e7 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetup-Bridging-Header.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/SparkSetup-Bridging-Header.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetup.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetup.h new file mode 120000 index 0000000..31217da --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetup.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/SparkSetup.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupCommManager.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupCommManager.h new file mode 120000 index 0000000..31c8af5 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupCommManager.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/Comm/SparkSetupCommManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupConnection.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupConnection.h new file mode 120000 index 0000000..2866c9b --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupConnection.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/Comm/SparkSetupConnection.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupCustomization.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupCustomization.h new file mode 120000 index 0000000..9c2a328 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupCustomization.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/User/SparkSetupCustomization.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupMainController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupMainController.h new file mode 120000 index 0000000..463bd6e --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupMainController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/User/SparkSetupMainController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupPasswordEntryViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupPasswordEntryViewController.h new file mode 120000 index 0000000..a796d20 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupPasswordEntryViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSetupPasswordEntryViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupResultViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupResultViewController.h new file mode 120000 index 0000000..72b64f6 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupResultViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSetupResultViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupSecurityManager.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupSecurityManager.h new file mode 120000 index 0000000..adf42dd --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupSecurityManager.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/Comm/SparkSetupSecurityManager.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIButton.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIButton.h new file mode 120000 index 0000000..2ae1035 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIButton.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUIButton.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIElements.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIElements.h new file mode 120000 index 0000000..64e781a --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIElements.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUIElements.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUILabel.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUILabel.h new file mode 120000 index 0000000..c065bf5 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUILabel.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUILabel.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUISpinner.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUISpinner.h new file mode 120000 index 0000000..8a11ecc --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUISpinner.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUISpinner.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIViewController.h new file mode 120000 index 0000000..c43849a --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupUIViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupUIViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupVideoViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupVideoViewController.h new file mode 120000 index 0000000..247e3ce --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupVideoViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSetupVideoViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupWebViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupWebViewController.h new file mode 120000 index 0000000..908774f --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupWebViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkSetupWebViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkSetupWifiTableViewCell.h b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupWifiTableViewCell.h new file mode 120000 index 0000000..7387ded --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkSetupWifiTableViewCell.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/UI Elements/SparkSetupWifiTableViewCell.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkUserForgotPasswordViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkUserForgotPasswordViewController.h new file mode 120000 index 0000000..6248e90 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkUserForgotPasswordViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkUserForgotPasswordViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkUserLoginViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkUserLoginViewController.h new file mode 120000 index 0000000..29effd4 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkUserLoginViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkUserLoginViewController.h \ No newline at end of file diff --git a/Strike/Pods/Headers/Public/SparkSetup/SparkUserSignupViewController.h b/Strike/Pods/Headers/Public/SparkSetup/SparkUserSignupViewController.h new file mode 120000 index 0000000..3841e95 --- /dev/null +++ b/Strike/Pods/Headers/Public/SparkSetup/SparkUserSignupViewController.h @@ -0,0 +1 @@ +../../../SparkSetup/Classes/UI/SparkUserSignupViewController.h \ No newline at end of file diff --git a/Strike/Pods/Local Podspecs/Keys.podspec.json b/Strike/Pods/Local Podspecs/Keys.podspec.json new file mode 100644 index 0000000..8a27953 --- /dev/null +++ b/Strike/Pods/Local Podspecs/Keys.podspec.json @@ -0,0 +1,23 @@ +{ + "name": "Keys", + "version": "1.0.0", + "summary": "Injected podspec used by CocoaPods-Keys plugin.", + "description": "This is intended to be used as an injected podspec template \n used by the [CocoaPods-Keys plugin](https://github.com/orta/cocoapods-keys).\n\n It should *not* be referenced outside of that context. \n", + "homepage": "https://github.com/orta/cocoapods-keys", + "license": { + "type": "MIT", + "text": "MIT LICENSE Found in the repo" + }, + "authors": { + "Orta Therox": "orta.therox@gmail.com", + "Samuel Giddins": "segiddins@segiddins.me", + "Ash Furrow": "ash@ashfurrow.com" + }, + "source": { + "git": "https://github.com/orta/cocoapods-keys.git", + "tag": "23" + }, + "source_files": "*.{h,m,swift}", + "frameworks": "Foundation", + "requires_arc": true +} diff --git a/Strike/Pods/Manifest.lock b/Strike/Pods/Manifest.lock new file mode 100644 index 0000000..ee6ceec --- /dev/null +++ b/Strike/Pods/Manifest.lock @@ -0,0 +1,57 @@ +PODS: + - AFNetworking (2.6.3): + - AFNetworking/NSURLConnection (= 2.6.3) + - AFNetworking/NSURLSession (= 2.6.3) + - AFNetworking/Reachability (= 2.6.3) + - AFNetworking/Security (= 2.6.3) + - AFNetworking/Serialization (= 2.6.3) + - AFNetworking/UIKit (= 2.6.3) + - AFNetworking/NSURLConnection (2.6.3): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/NSURLSession (2.6.3): + - AFNetworking/Reachability + - AFNetworking/Security + - AFNetworking/Serialization + - AFNetworking/Reachability (2.6.3) + - AFNetworking/Security (2.6.3) + - AFNetworking/Serialization (2.6.3) + - AFNetworking/UIKit (2.6.3): + - AFNetworking/NSURLConnection + - AFNetworking/NSURLSession + - Keys (1.0.0) + - Spark-SDK (0.3.4): + - Spark-SDK/Helpers (= 0.3.4) + - Spark-SDK/SDK (= 0.3.4) + - Spark-SDK/Helpers (0.3.4) + - Spark-SDK/SDK (0.3.4): + - AFNetworking (< 3.0.0) + - Spark-SDK/Helpers + - SparkSetup (0.3.3): + - SparkSetup/Comm (= 0.3.3) + - SparkSetup/Core (= 0.3.3) + - SparkSetup/Resources (= 0.3.3) + - SparkSetup/Comm (0.3.3) + - SparkSetup/Core (0.3.3): + - Spark-SDK + - SparkSetup/Comm + - SparkSetup/Resources + - SparkSetup/Resources (0.3.3) + +DEPENDENCIES: + - Keys (from `Pods/CocoaPodsKeys`) + - Spark-SDK + - SparkSetup + +EXTERNAL SOURCES: + Keys: + :path: Pods/CocoaPodsKeys + +SPEC CHECKSUMS: + AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60 + Keys: 7d2ff6ff42f6903358267ce56e9392f83c31acfe + Spark-SDK: f5dad30a5afa319f43ca570a64f241c73c693641 + SparkSetup: f9618dd24548ab8a024efdaa65a89f63ed44a7ee + +COCOAPODS: 0.39.0 diff --git a/Strike/Pods/Pods.xcodeproj/project.pbxproj b/Strike/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2d042b8 --- /dev/null +++ b/Strike/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,1633 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 037FCD8502BDC545D6A5CF181BF2DA3E /* checkmark.png in Resources */ = {isa = PBXBuildFile; fileRef = 17C3A74681C6EB6065DC3BF0F665E686 /* checkmark.png */; }; + 044ED6DBCB9FA64195D7B6F4BD2CEB8D /* SparkSetupCustomization.m in Sources */ = {isa = PBXBuildFile; fileRef = 51C4F65AC0631ADCB97AF537150A1D4E /* SparkSetupCustomization.m */; }; + 04CA911CEA4E88C6BB8C7C1825A3E427 /* spacer.png in Resources */ = {isa = PBXBuildFile; fileRef = 5D1218BCDC304634B52A531553CB4C2B /* spacer.png */; }; + 0598CEE3527028F1F957A6004677135A /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = CE506A589D9627F92405940C2DEB4D89 /* Default-667h@2x.png */; }; + 05A88E3C8E67B8BA7C7D64C9F64B52C3 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8908189965D177AD6BAB607AE614C1E /* SystemConfiguration.framework */; }; + 0832DC7DFB991B7870FA2052BDD8B254 /* 2.png in Resources */ = {isa = PBXBuildFile; fileRef = 2C751BA86E29FA09D4BC0F6BD6378669 /* 2.png */; }; + 0C9722862E565387F9FFE798307F5098 /* AppIcon29x29.png in Resources */ = {isa = PBXBuildFile; fileRef = 1E83CC83A9EA04EAC31A4C46F3F52FA0 /* AppIcon29x29.png */; }; + 0E37FCC8546A1592B5BB4BAA97B6EFA6 /* AppIcon40x40@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B044AADC2973806CDA37653633C1EB6 /* AppIcon40x40@2x.png */; }; + 0F8217A7033D4B1169408CA2DEBFA592 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8D0D0663BFEACD3F126A939DB77861F /* Foundation.framework */; }; + 15027F8F65D663383E9A8644B94079C4 /* SparkConnectingProgressViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6FE3E3EC95D69C201CE5656C3D1C3777 /* SparkConnectingProgressViewController.m */; }; + 16F0EA6274A579BD3FBA7CD76B9B09C8 /* KeychainItemWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EFB776BABC19CC83B752468707E3A69 /* KeychainItemWrapper.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 18241EB8A6862D64CBE5E8D8D0A5099B /* Pods-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 272643F56613CA0D336AE3DBF19DC404 /* Pods-dummy.m */; }; + 19049A2A2F3EB187194A5520127DB8D5 /* SparkSetup.h in Headers */ = {isa = PBXBuildFile; fileRef = 76C8214F1603AFE3461D0907859E7577 /* SparkSetup.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1905AD632AEF96E5E898D7E22CF82E96 /* Reachability.h in Headers */ = {isa = PBXBuildFile; fileRef = FC75C5EA647C041A3AC35E610F100557 /* Reachability.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 19BEBED8018E30F0D60D6CA540E974C9 /* SparkSetupMainController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8939B8678DD109AAA51F23233B5DF01C /* SparkSetupMainController.m */; }; + 1A6BF2B7930BE4B4AAAFBD674A3D687E /* Keys-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = BD897B2C65901B39D778A2AE7B66751A /* Keys-dummy.m */; }; + 1B01544912D3AA80CF9E8B3CDF157688 /* SparkSetupCommManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 08A4A0A1008527F34FC2DB6555FE6474 /* SparkSetupCommManager.m */; }; + 1B04813FE4A67FBF495624B62AB77A67 /* AppIcon29x29@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 111D868ECCD8F6CB5945D22110275DDC /* AppIcon29x29@2x.png */; }; + 1CB72A3C589B2E28E44B54D29436AA4D /* SparkGetReadyViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C86CE3CDEA978FC67C96DBD07528F5 /* SparkGetReadyViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1CBDB47B210A0C2448C14A610BC6D4D6 /* AFSecurityPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = D293BBBAD1F8B4AD0E18C5C22F2C1242 /* AFSecurityPolicy.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1E310D0CE3BE27EF253B6D822B0AEE5E /* AFURLResponseSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E89AB552E736A69BE59C374185A6035 /* AFURLResponseSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1E3FC541EAB2B1A1378E34D6B4C07006 /* wifi2.png in Resources */ = {isa = PBXBuildFile; fileRef = 8780F132E2A1C1736A32BA85099DC2BD /* wifi2.png */; }; + 1E57CA0BC26269BE5BA88A3AC2BC3326 /* SparkDiscoverDeviceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C7945F3C2131DDDD647E5EEF04CF5F6 /* SparkDiscoverDeviceViewController.m */; }; + 1F6BB0CA11C6D0D85062ED24ACCF282E /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3BA91FAAE708116C42507E22D769743 /* Security.framework */; }; + 1FAC7F3E38443BE107780A7A98B34323 /* Strike1Keys.h in Headers */ = {isa = PBXBuildFile; fileRef = F8009C6E5BE9E0FC3B584A8C768B8DBF /* Strike1Keys.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 20078A2086063338B63874BF88A91BAC /* Default-Portrait-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = E61EDEAC890205E4F429AAF201B6938B /* Default-Portrait-736h@3x.png */; }; + 20E08814B3AB2982AC84AF75DAB05E65 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3BA91FAAE708116C42507E22D769743 /* Security.framework */; }; + 211D4EA06F5920376A069ACB55DF6006 /* AFHTTPRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = C193F57DA6B6ABAACB2FBE3F9C848EE7 /* AFHTTPRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2373004DCCE6119B8D086A66BF223555 /* SparkSetupUIViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = A6C0BCC26C36FD45B3B0185584AEED79 /* SparkSetupUIViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 243A9A69C7CDBCF2D1B851FA74F7A979 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8908189965D177AD6BAB607AE614C1E /* SystemConfiguration.framework */; }; + 256EFEE5A70448273282044CA8C63BD1 /* SparkSetupWifiTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C27BF17445F746932F44818B6C83741E /* SparkSetupWifiTableViewCell.m */; }; + 2769A4E6F6829406F9438B4C4E385076 /* SparkSetupCommManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 20A92058080DEA64503E3B122AA83C34 /* SparkSetupCommManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 27E5CE82BE5DE9B15426560831EB07AC /* SparkSetupPasswordEntryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E5DC80AB542BC465525DD22801223B29 /* SparkSetupPasswordEntryViewController.m */; }; + 2894AF707D15CF7670D98A018626AA80 /* SparkSetup-Bridging-Header.h in Headers */ = {isa = PBXBuildFile; fileRef = 584D62887D24E11524ADA3228AD5FAF7 /* SparkSetup-Bridging-Header.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2B8269A87473D9F1259E9BD98E7588D3 /* AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = E474978076D8199A6CDF4A72E8C100AA /* AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2CF66E8669A348C421E93F2F67C6A61E /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D168AA93293F5533EC2F297BFBCF3730 /* AFHTTPSessionManager.m */; }; + 2DDBAD69257BE62DC3352182246DF24E /* SparkSetup-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = FCBD1055328AE9E85FFC91AC554ED34B /* SparkSetup-dummy.m */; }; + 2DEB81B3F9A6CDB629410803BD883A7D /* SparkSetupWifiTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BC678E5531DCCB9F2D759596022D6D25 /* SparkSetupWifiTableViewCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2EEF69E8AA14531A00897DE2DAFA3114 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8D0D0663BFEACD3F126A939DB77861F /* Foundation.framework */; }; + 2FA12A58911B9BBFC6E1F34B7DEE96AA /* SparkSetupConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 24417C1CA86EFDB23DA2487B433FBD67 /* SparkSetupConnection.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3033C63AC334D346E9461D0942D8FB69 /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = E8D4CD22DCC99E6C56B3218F81CB60B9 /* AFURLRequestSerialization.m */; }; + 317665CB03863B6DD2AD13ED1E49A575 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC1C7C6EA23889590C9297EB4225718A /* Default-568h@2x.png */; }; + 35A75CF792C92805B0746E2BE72C6DAD /* photon.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C8505D0DFA5B8E5AF2BB8F53D6D385A /* photon.png */; }; + 3686C90A3EB01886CA1E822CF2C13736 /* SparkSetupPasswordEntryViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = E0839124458B80721F17B67A23A99DAA /* SparkSetupPasswordEntryViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 37C0720A596A37B897445C62DCA561EE /* SparkDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = 0EA197BEB0F7AE944EEE0044F85C3025 /* SparkDevice.m */; }; + 399AC825EE10F70364CE7B0AA89F466D /* UIAlertView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 040518A36AA634B93F4DBE2300AA0E09 /* UIAlertView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3A05A5B279F9F8DDD44036F8DAC5DD4D /* 3.png in Resources */ = {isa = PBXBuildFile; fileRef = E18FD6539184A6E4E8D61687DCB692F8 /* 3.png */; }; + 3A5B54373A45916EC8DE74D060DE5503 /* UIButton+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = A08F446BB083BB0A254F944A49DC6151 /* UIButton+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 3C492535C9EB521ECCF876440847670C /* AppIcon40x40.png in Resources */ = {isa = PBXBuildFile; fileRef = 84184649E3CB6AA25D2C09E6E0A2DC2F /* AppIcon40x40.png */; }; + 3DB9E81A3AE190AE8E1A4D11578E3126 /* spark-logo.png in Resources */ = {isa = PBXBuildFile; fileRef = AD517D8A84459209B1DE67F13E63290F /* spark-logo.png */; }; + 43C1ED4F0732341280C1D1ABD60CA318 /* x.png in Resources */ = {isa = PBXBuildFile; fileRef = AD9B681E0DC6507243ADE76FC49456BC /* x.png */; }; + 4431F01AF58FD635CDC3699FFA4F12B4 /* SparkManualNetworkViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F478CC9C981AA8AE2B54556537B54D7 /* SparkManualNetworkViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 44713EF05CED2F9CAF2FCA717A3163B0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8D0D0663BFEACD3F126A939DB77861F /* Foundation.framework */; }; + 472A6BFCC6207D98F787649BDF44A1BE /* AFHTTPRequestOperationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 104818EE841FDC5A6E77E4B1028A677B /* AFHTTPRequestOperationManager.m */; }; + 48B382028C8E355861FAB93B2558F1EE /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E0241F701AE1F7A58D83409A20BAEAA /* Reachability.m */; }; + 495F717651B12E6496C72D16BCC28C29 /* AFURLRequestSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = D65E3E47BF916E7814004609E7B67DAE /* AFURLRequestSerialization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4A95C860874CE6296FB6DCBD2462C375 /* iosCheckmark.png in Resources */ = {isa = PBXBuildFile; fileRef = 43E58C3FFD2ED7C57813BEA234DD0D97 /* iosCheckmark.png */; }; + 4E12A46ADE239E9A9EF893CAC7E3EB4C /* AppIcon76x76-1.png in Resources */ = {isa = PBXBuildFile; fileRef = 8AE0BC13ADCA826EB340C142D2FA6B8E /* AppIcon76x76-1.png */; }; + 4F48278E8D5A3B5EBC7302B91DA963F9 /* SparkConnectingProgressViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = B1A9DB7A3EB9C984AF5BAD92FC27D59B /* SparkConnectingProgressViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5037735033555AEDA6C1E9CD306A02FB /* SparkUser.h in Headers */ = {isa = PBXBuildFile; fileRef = C6F5088CC992CBA9E545691DEDAA1EBA /* SparkUser.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 54DE78D4CC0AE42F36FC2F66BECB0914 /* SparkEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7F2B98C1023B504DAECFFEF542F25B80 /* SparkEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 573E8F68BFF8F0110F5A49F6C9183A3D /* EventSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 0658B3A7F5106FC3A96AC8AA72A0C231 /* EventSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 58A3B19F4674F533A94D00B4E9010C7E /* SparkSetupWebViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 32936DB39575AB90BC0A90E8316FAF4D /* SparkSetupWebViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 5CF0E043147B69E77976A2CCADFF18CA /* AFURLSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = FCC60591D9B8CB2629DF0D88930C94AA /* AFURLSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 62211E06845580D498B0110657767465 /* wifi3.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CA6B94E029542907A4A22845ADF7577 /* wifi3.png */; }; + 640B51A5EA146490A16295AE2B9FD819 /* SparkSetupResultViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E5FC2C69A27D77CF70C2310D80D2B5A /* SparkSetupResultViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 674E6704704A329C6295FDA3CE1F2ACA /* SparkSetupUIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C9C1F81D3497AC8A8C48B81E2FED3BA /* SparkSetupUIButton.m */; }; + 6AB68CEB0BBE9DFA50258A3063A1BC4E /* SparkSetupVideoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FE8D71FE2BB26DA75BEAD48641D4EE60 /* SparkSetupVideoViewController.m */; }; + 6CC4B79C1FEE1E7B3F2860ADA479D381 /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FF84ADAA9C18388173432BF2DAC75BD3 /* AFURLSessionManager.m */; }; + 6E7619F8B41208CACCDBA1A221339DFF /* SparkSetupSecurityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 61C3A9EC4F6EA34D70B34AF2C0513AFA /* SparkSetupSecurityManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 70112FDCF2E9DEAA2E409673F9974F89 /* SparkSetupConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = FA121E6420831479E9ADDA0F0ABA0661 /* SparkSetupConnection.m */; }; + 70255569D06E0E87D2E20FE88EC0D73B /* SparkUserForgotPasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C0360414907C53E2EEE6A25098A26361 /* SparkUserForgotPasswordViewController.m */; }; + 70B37761E115BD2D785F0A3D26B1B10F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8D0D0663BFEACD3F126A939DB77861F /* Foundation.framework */; }; + 71C62F6793EC2B70D81DB9A33C8074C5 /* SparkUserSignupViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F3BF00F2C7BE58B36D9175A872F91417 /* SparkUserSignupViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 749B47B0BA8650FEDD5A3D3BA76F9829 /* connect-to-wifi.png in Resources */ = {isa = PBXBuildFile; fileRef = 968E6C75C2D4469B287B36195CD8A2DD /* connect-to-wifi.png */; }; + 7665EC1EB9391236229902B2D13296E6 /* SparkSetupVideoViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CEA734A21391B82CD906564AB4F289B /* SparkSetupVideoViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 776F1C013A2EC6BAA7268B20B2EF8892 /* EventSource.m in Sources */ = {isa = PBXBuildFile; fileRef = B6DDE58F65E0125C844CD6646C226F39 /* EventSource.m */; }; + 78449FCC01114171AA3CCB45C6666206 /* AFNetworkReachabilityManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 252D72F3F883F17FE5A0890ACC27DAFB /* AFNetworkReachabilityManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7A40D8D95330BA7EFE70D4B71055015F /* SparkSetupUILabel.m in Sources */ = {isa = PBXBuildFile; fileRef = B96DC26748E3FC5B3DEEB0B052363C9D /* SparkSetupUILabel.m */; }; + 7BECEB800CE44767C142A09D7E6CC224 /* SparkSelectNetworkViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 21C15DC62792E05B785178132CD0F964 /* SparkSelectNetworkViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7CCA6777E1CA7E9B1EC60F8D50931C38 /* SparkAccessToken.h in Headers */ = {isa = PBXBuildFile; fileRef = CCF1BA6DB0507C1CA560B4181EAA266E /* SparkAccessToken.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 7FA9BA2A55556F344923DC319BB1876E /* SparkUserForgotPasswordViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = A28C0110554DE1AEC894884D07C7B354 /* SparkUserForgotPasswordViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 808C57539D9B9AB7636043AF0142EE9F /* Strike1Keys.m in Sources */ = {isa = PBXBuildFile; fileRef = 81A47DF8A8EBBE8446F0E30D3BA08743 /* Strike1Keys.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; }; + 81A982BAA277B1E641F4147A14605734 /* SparkSetupUISpinner.m in Sources */ = {isa = PBXBuildFile; fileRef = A5F7177EB5E47D784133A2EB73B9DE53 /* SparkSetupUISpinner.m */; }; + 834F18A900A57B3B1D84EB43647D0AAE /* KeychainItemWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = BE22549C5625B26EE546D7F94C09CADF /* KeychainItemWrapper.m */; }; + 83CC4DC9682FA94EBACC1E3DB3F9B792 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 241A2B7247375EE22111B162FCE4AE84 /* UIKit.framework */; }; + 83EECD2665C9C7B38E79A7E2EC4294F4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8D0D0663BFEACD3F126A939DB77861F /* Foundation.framework */; }; + 83F69AA6F6D4F2866884E475E0D16D60 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 828D5356DDCD7C4F0308813B83F45120 /* Default@2x.png */; }; + 84814680B853CA5BC2BEBFDAC9492C8D /* SparkSetupUISpinner.h in Headers */ = {isa = PBXBuildFile; fileRef = 45F45782272296C1352AE371D34544E4 /* SparkSetupUISpinner.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 854BC4449D8CAD0F2799B021D1914C3B /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 652FFBA609976DA051941E88C4397155 /* UIRefreshControl+AFNetworking.m */; }; + 876C2EF5FE318346CDCB4BFE25A9D5B2 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 053B1BBBAAD0B45E58470F0091EB49F3 /* AFHTTPRequestOperation.m */; }; + 8A5E2BA5BDB908D5EF9B284B70C59609 /* 1.png in Resources */ = {isa = PBXBuildFile; fileRef = EFCFEF23CC6390280873A23E3FB72FDB /* 1.png */; }; + 8B7DC7FCBA8BAFECEB2883BDE1C60B0D /* SparkSetupUILabel.h in Headers */ = {isa = PBXBuildFile; fileRef = A072B4122EBB6EC6315CEDB61FB8ACEE /* SparkSetupUILabel.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 8D118CB43F0F2E3F4FA8FDCEC431E5E8 /* Spark-SDK-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = F34A646429A01BBE2F5A58FA8175D255 /* Spark-SDK-dummy.m */; }; + 903A0E1F82A29D285902CBB5A0828BE9 /* UIImage+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 36E3ABFE2DC1F06D82B0B406429E3C18 /* UIImage+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 907A7728AFDADAE8703E756F44ECEF42 /* spark-logo-head.png in Resources */ = {isa = PBXBuildFile; fileRef = 74F3D4D1B78366583AFBDECF533D846F /* spark-logo-head.png */; }; + 914403435B6C25B41FEC114D69881E39 /* SparkSetupUIButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C239678430A159AF182601929241AA6 /* SparkSetupUIButton.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9642475E9B97ED95187075DFBA5E822C /* SparkEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = D93A7A79FA39F8DCD59A8A4A78477B1E /* SparkEvent.m */; }; + 96D1606ACA5FCB2FB5C48FD5F51217F9 /* leftChevron.png in Resources */ = {isa = PBXBuildFile; fileRef = F6C15E3FDC85ABFC356779E64879F7E6 /* leftChevron.png */; }; + 96FD140D0BFE410C0F86AA076AE742BB /* SparkCloud.m in Sources */ = {isa = PBXBuildFile; fileRef = 85940B04C3900B1079BF6FB5403695D3 /* SparkCloud.m */; }; + 99E82D6DC032555656E37AF2367B20D3 /* UIButton+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A5B42DD861454B7564E573B0D665734 /* UIButton+AFNetworking.m */; }; + 9A04E971065AF4281E43947994A53D07 /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 2802CCFEC73CA6916AA75B69453F67C0 /* UIWebView+AFNetworking.m */; }; + 9B47A1441B897F71505D8BE670B0940B /* UIAlertView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = F7536BAE8C1A5DD8E7DCAAF99AE84837 /* UIAlertView+AFNetworking.m */; }; + 9DD0AFDE1F4C1B775F095A2455AE641A /* success.png in Resources */ = {isa = PBXBuildFile; fileRef = 989E9F2E569396E383DD224863C3828C /* success.png */; }; + A28588D1CCB5253CF80509F30A1AF1A5 /* UIActivityIndicatorView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EA1E9424F8E70BD1F8085C8726A1196 /* UIActivityIndicatorView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A3F097BA9D814A799E77FD3B286BCA9E /* SparkUserLoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 22050C7C4BE7F51F9FE2223BE4527494 /* SparkUserLoginViewController.m */; }; + A4EE8D1BEE38B87066BAA1B09A047356 /* UIWebView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = E519163EB66C5B99B289125B8D7E5872 /* UIWebView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + AA37EE09B228D3EA729B2FECA2F76BA1 /* setup.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3A5DE13BFF53941638E7DAB7606754CB /* setup.storyboard */; }; + AB2978110F1272FE9FEF2A639A692617 /* AppIcon76x76@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 847209C429CC16B2D6ACF92DA337F8CB /* AppIcon76x76@2x.png */; }; + AE607E682415FAA160B33C7C13A8475B /* UIActivityIndicatorView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = CADB363DD2CF336E66D075513DCD2B49 /* UIActivityIndicatorView+AFNetworking.m */; }; + B12AD2EE044D6F7424F75F1506B516B2 /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CCE8DA1C46E18E6B36C9CA2234F99A3 /* AFSecurityPolicy.m */; }; + B28F8C13D3E7F828EE8BCA117AA05EB9 /* warning.png in Resources */ = {isa = PBXBuildFile; fileRef = E0BA5A4A9D449B998B840B3DEC7C612D /* warning.png */; }; + B2B5DEC33B644F946C59F656AAAA8146 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 70E691FC9DE43D850FE38203F49C684A /* AFNetworkActivityIndicatorManager.m */; }; + B55068C29FE3DBED229D5A3D279AEABB /* SparkSetupSecurityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A0CAFF45DEAD0C0F3B89BAD67B06EB30 /* SparkSetupSecurityManager.m */; }; + B6F276AFFEA701315C62BB4DDE7A20C8 /* SparkSelectNetworkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A52466161703BD32B6B478B4F301787A /* SparkSelectNetworkViewController.m */; }; + B74DDBA928B18BA9C7F4300499BC1D4D /* SparkSetupCustomization.h in Headers */ = {isa = PBXBuildFile; fileRef = A240826CC6D084724C7C99E6FD6D8503 /* SparkSetupCustomization.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B7ECC4B1AAE85B1ACA10A24B0483563B /* SparkSetupMainController.h in Headers */ = {isa = PBXBuildFile; fileRef = 95110933E0F890897C121571811F08D5 /* SparkSetupMainController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B9DAA002CF3E0E8EBE9B6E9A7778CFD4 /* AFNetworking-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = C87F1540D3EFBBA2089267EFE227EEAE /* AFNetworking-dummy.m */; }; + BA025A85A850C1E24A6C92F4C29E5531 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8908189965D177AD6BAB607AE614C1E /* SystemConfiguration.framework */; }; + BA225ACC712F6D911BFC1C25E58D5C66 /* lock.png in Resources */ = {isa = PBXBuildFile; fileRef = 6F7829AE27CC57982BBC3A090B44B0FA /* lock.png */; }; + BC7993B7436D4D7FADE6DD554DA52769 /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 624D36651D8811A65D745B494FAF2AA4 /* AFNetworkReachabilityManager.m */; }; + BD8EC5BD8B679FEBC9F46F18884DDC7A /* SparkSetupWebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 856BFAC4C93CD1BBC6A98A4CF1272547 /* SparkSetupWebViewController.m */; }; + BE516E3F1C19358A8D8B25801E40E444 /* SparkUserSignupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 85B7902C78F87E0836100B2B49B30644 /* SparkUserSignupViewController.m */; }; + C24CA16B02440C2A794CE71A154D4CF8 /* failure.png in Resources */ = {isa = PBXBuildFile; fileRef = 006C6F0A3E9E9AD52F1356B05B5F7CBF /* failure.png */; }; + C25463A21A0429F797EB2FED9C156BE5 /* spinner_big.png in Resources */ = {isa = PBXBuildFile; fileRef = DA58C7A6F06F25A1F72A9546E0513F2E /* spinner_big.png */; }; + C486E81A8911428ACC41E6A00276628B /* connect-to-power.png in Resources */ = {isa = PBXBuildFile; fileRef = 4B4631C02622069A97C0F699C1139A80 /* connect-to-power.png */; }; + C58268D5A4D2A786576E0EAA5B50FB93 /* UIRefreshControl+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DD74C86B9671633BB60CEEA58F20195 /* UIRefreshControl+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C76032137D289370D2B96386150EEBAF /* SparkSetupResultViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 06AD42CB0CD3259A0D32223D57A5C1B2 /* SparkSetupResultViewController.m */; }; + C7ACDDE36465ACAF629FEC233B1BF172 /* UIProgressView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = D629384A0807E819AF88513104DBC68A /* UIProgressView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C9B1E231816CBA9075144D28C1226FA0 /* SparkUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 9DCA8D76F05F6FBEDF28EC37F3D50322 /* SparkUser.m */; }; + CAA0F8074B35A2F73890310EC4521A0D /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 1DCC296A4EC1F44B7430283A38810119 /* AFURLResponseSerialization.m */; }; + CB4BCAF540A3B06E92BC3F101891FA85 /* SparkSetupUIElements.h in Headers */ = {isa = PBXBuildFile; fileRef = 7290D63102399F5321ACF3FA5BA42B7B /* SparkSetupUIElements.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CCF32D28A9C871B2AC04189AECE516BB /* spinner.png in Resources */ = {isa = PBXBuildFile; fileRef = D2484C990E4B8B11FE716C9ECEEA9B14 /* spinner.png */; }; + D070B784EFCA099C141EEAB69FBCC870 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 21EA1DB782D228AFA2781A058AF28176 /* UIImageView+AFNetworking.m */; }; + D2492E61B7797BB52D3C955E823C29C1 /* SparkUserLoginViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B9F690E64B1203DD7C8CCCB254ECC64 /* SparkUserLoginViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D4A65C2E29ACB340587FD41196176F8A /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = C2D445F656639E02848A46667C2BEC22 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D5C0CB0FE4FECD1B4B7C4874434FDD25 /* Spark-SDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 4415ED2543B3392EE6273F92B7A27922 /* Spark-SDK.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D7F50CAB829344D10E3921201F219BF9 /* SparkGetReadyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E094D66062E35F56FAA203EC280B324 /* SparkGetReadyViewController.m */; }; + DB12C5F4C6D8C49691F3892E556832C8 /* SparkDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 80C36D8E35C6AC1B72F34F4DD0E33E49 /* SparkDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB2E92A71137AD2E6993E8B0CE682C89 /* AFURLConnectionOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = F14C9C9F913559FAF65AE7B526E1C041 /* AFURLConnectionOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DB3654AAC36D5914E01F5B8A4079DAB7 /* SparkSetupUIViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D7C35E6ACCF3DB67742298C17967679C /* SparkSetupUIViewController.m */; }; + DB42C604EF2F39D542F805AC6A05E090 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 37864639795C4854F0231F20AE600CAD /* MobileCoreServices.framework */; }; + DB72DB4A2F6D3325F7290ACA7ACD6552 /* wifi1.png in Resources */ = {isa = PBXBuildFile; fileRef = C55555710E8166947E1EAD3155C5FA8E /* wifi1.png */; }; + DECD5915774351B8473476B041DD87D7 /* AFHTTPSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DE3F341D2A4295D67B050EC8046474 /* AFHTTPSessionManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + DF9435E7EB08458A6C00D5E3CBBE1274 /* AppIcon29x29@2x-1.png in Resources */ = {isa = PBXBuildFile; fileRef = D11C1EA4E13FABB2E9ECA22FA8AFF245 /* AppIcon29x29@2x-1.png */; }; + E18C7FDAC3E26CE7C4D5437939C8BFCA /* AppIcon40x40@2x-1.png in Resources */ = {isa = PBXBuildFile; fileRef = D49430388065C258FC8796E5416B6EB6 /* AppIcon40x40@2x-1.png */; }; + E317BA2472D193740E0FF7B862CEF19B /* SparkManualNetworkViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F89BF9FB31F554F0A3C597A7C16CBF8D /* SparkManualNetworkViewController.m */; }; + E54F1F1AD904377771A6B10248C51EF3 /* background-1-1.png in Resources */ = {isa = PBXBuildFile; fileRef = FE3BEBBD5651901872EAB8E10C848F03 /* background-1-1.png */; }; + E6DD6ABB4FC13B60FA54C950FB6B262B /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = A5CE43AA20CA228A62BC61A76D6E93F5 /* AFURLConnectionOperation.m */; }; + EC41B5CF68F617747663E8364C523BF6 /* AppIcon60x60@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 167F3E228DE7EE9F878882DFDB5C7803 /* AppIcon60x60@2x.png */; }; + F08E19D8B440D85D564273B1A501B1FC /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C3FA101C77BBB9691CE81BAE29586E8 /* CoreGraphics.framework */; }; + F14D746E64B123CFAD929EAE86366132 /* imgBackArrow.png in Resources */ = {isa = PBXBuildFile; fileRef = 29472EB761C8B4FDA94E5845FB97C1BC /* imgBackArrow.png */; }; + F2AF56F00E313B9CD0F4ADA3C5D73BDF /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3BA91FAAE708116C42507E22D769743 /* Security.framework */; }; + F4A1512E8C4D8C8194CBB276BF72A552 /* AFHTTPRequestOperationManager.h in Headers */ = {isa = PBXBuildFile; fileRef = FC4816191F806110B04ABCBDFED0BD01 /* AFHTTPRequestOperationManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F4B03681047157E5C357E584147F5A46 /* UIKit+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = E4EDAD6BB7D00CE66CBD7C609F66F704 /* UIKit+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F4DCBA2A42A38C6E7A755182DA50DEA2 /* AFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 8E9B319993ACC4BB91E86A4A01974E4E /* AFNetworkActivityIndicatorManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F601DEB28EDB1F22BC07D41D72F4CE58 /* iosSettingWifi.png in Resources */ = {isa = PBXBuildFile; fileRef = E3AD4B4957766463E6E81B5D60B346E7 /* iosSettingWifi.png */; }; + F6588E4CE1CAB1C428C6035C97987785 /* SparkDiscoverDeviceViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D84279B18B5189C43C8B5014B5488703 /* SparkDiscoverDeviceViewController.h */; settings = {ATTRIBUTES = (Public, ); }; }; + F9D3F88FB00E02B1C08D73D7CF54D053 /* SparkCloud.h in Headers */ = {isa = PBXBuildFile; fileRef = 6CD969BC227F62D266145E35E293DE20 /* SparkCloud.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FD6F966F458CEE40B07A2367BA3BC8EC /* UIProgressView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 22736E4D3C505DA078A28E52BDE3AA09 /* UIProgressView+AFNetworking.m */; }; + FD914DDDDED3DBFFD128BCFB17D80A6A /* SparkAccessToken.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A16D6753000DD755CA3C0C7F8FD26F8 /* SparkAccessToken.m */; }; + FFB83062D7E02506A5773A9B78E1B864 /* background-1.png in Resources */ = {isa = PBXBuildFile; fileRef = AE885EF01C456069CD80A6E8AF217777 /* background-1.png */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 0A30DFE2279D125160B650A41C16BA2B /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5579B1232582A96EA47C65196B85011C; + remoteInfo = "Spark-SDK"; + }; + 3BF9D3615D86200C1C7089E195544826 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = D140B65203AF3A193E404F4B98C7E839; + remoteInfo = "SparkSetup-SparkSetup"; + }; + 70CA02B062FEDBA3120AFB01CDD2C06F /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5579B1232582A96EA47C65196B85011C; + remoteInfo = "Spark-SDK"; + }; + 9D7E29C11F2DBD6CC7BCEB8B00E3DEA4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 13457F116F17C32A4D53480B68EE9E4F; + remoteInfo = Keys; + }; + AB7158E511F306CB43A97A9F21C3C415 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 410B25DF16EA5C5B3E2698F74F9625FB; + remoteInfo = AFNetworking; + }; + BD8C52530FD44305C88B7CC94715D295 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 410B25DF16EA5C5B3E2698F74F9625FB; + remoteInfo = AFNetworking; + }; + DC939E7A6A3648B592D1FBD8CCC346CA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */; + proxyType = 1; + remoteGlobalIDString = E61E5CE6662F45D382902657287BB36F; + remoteInfo = SparkSetup; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 006C6F0A3E9E9AD52F1356B05B5F7CBF /* failure.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = failure.png; path = Resources/setup.xcassets/failure.imageset/failure.png; sourceTree = ""; }; + 040518A36AA634B93F4DBE2300AA0E09 /* UIAlertView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIAlertView+AFNetworking.h"; path = "UIKit+AFNetworking/UIAlertView+AFNetworking.h"; sourceTree = ""; }; + 04DE3F341D2A4295D67B050EC8046474 /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPSessionManager.h; path = AFNetworking/AFHTTPSessionManager.h; sourceTree = ""; }; + 053B1BBBAAD0B45E58470F0091EB49F3 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPRequestOperation.m; path = AFNetworking/AFHTTPRequestOperation.m; sourceTree = ""; }; + 06248D0A29CA1015181AD173BE0BF93D /* Keys-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Keys-prefix.pch"; sourceTree = ""; }; + 0658B3A7F5106FC3A96AC8AA72A0C231 /* EventSource.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = EventSource.h; path = Pod/Classes/Helpers/EventSource.h; sourceTree = ""; }; + 06AD42CB0CD3259A0D32223D57A5C1B2 /* SparkSetupResultViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupResultViewController.m; path = Classes/UI/SparkSetupResultViewController.m; sourceTree = ""; }; + 08A4A0A1008527F34FC2DB6555FE6474 /* SparkSetupCommManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupCommManager.m; path = Classes/Comm/SparkSetupCommManager.m; sourceTree = ""; }; + 0EA197BEB0F7AE944EEE0044F85C3025 /* SparkDevice.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkDevice.m; path = Pod/Classes/SDK/SparkDevice.m; sourceTree = ""; }; + 104818EE841FDC5A6E77E4B1028A677B /* AFHTTPRequestOperationManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPRequestOperationManager.m; path = AFNetworking/AFHTTPRequestOperationManager.m; sourceTree = ""; }; + 10834806BD7B412BC24F347361FA2C8E /* Pods-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-acknowledgements.plist"; sourceTree = ""; }; + 111D868ECCD8F6CB5945D22110275DDC /* AppIcon29x29@2x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "AppIcon29x29@2x.png"; path = "Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png"; sourceTree = ""; }; + 167F3E228DE7EE9F878882DFDB5C7803 /* AppIcon60x60@2x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "AppIcon60x60@2x.png"; path = "Resources/setup.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png"; sourceTree = ""; }; + 17C3A74681C6EB6065DC3BF0F665E686 /* checkmark.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = checkmark.png; path = Resources/setup.xcassets/checkmark.imageset/checkmark.png; sourceTree = ""; }; + 1DCC296A4EC1F44B7430283A38810119 /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLResponseSerialization.m; path = AFNetworking/AFURLResponseSerialization.m; sourceTree = ""; }; + 1E83CC83A9EA04EAC31A4C46F3F52FA0 /* AppIcon29x29.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = AppIcon29x29.png; path = Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29.png; sourceTree = ""; }; + 1E89AB552E736A69BE59C374185A6035 /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLResponseSerialization.h; path = AFNetworking/AFURLResponseSerialization.h; sourceTree = ""; }; + 1F4C450070003D63D71BC9CA8F86113E /* Spark-SDK-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Spark-SDK-prefix.pch"; sourceTree = ""; }; + 20A92058080DEA64503E3B122AA83C34 /* SparkSetupCommManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupCommManager.h; path = Classes/Comm/SparkSetupCommManager.h; sourceTree = ""; }; + 21C15DC62792E05B785178132CD0F964 /* SparkSelectNetworkViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSelectNetworkViewController.h; path = Classes/UI/SparkSelectNetworkViewController.h; sourceTree = ""; }; + 21EA1DB782D228AFA2781A058AF28176 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIImageView+AFNetworking.m"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.m"; sourceTree = ""; }; + 22050C7C4BE7F51F9FE2223BE4527494 /* SparkUserLoginViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkUserLoginViewController.m; path = Classes/UI/SparkUserLoginViewController.m; sourceTree = ""; }; + 22736E4D3C505DA078A28E52BDE3AA09 /* UIProgressView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIProgressView+AFNetworking.m"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.m"; sourceTree = ""; }; + 23A85C03BBD9931572741402A4EB0098 /* libKeys.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libKeys.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 241A2B7247375EE22111B162FCE4AE84 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + 24417C1CA86EFDB23DA2487B433FBD67 /* SparkSetupConnection.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupConnection.h; path = Classes/Comm/SparkSetupConnection.h; sourceTree = ""; }; + 252D72F3F883F17FE5A0890ACC27DAFB /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkReachabilityManager.h; path = AFNetworking/AFNetworkReachabilityManager.h; sourceTree = ""; }; + 272643F56613CA0D336AE3DBF19DC404 /* Pods-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-dummy.m"; sourceTree = ""; }; + 2802CCFEC73CA6916AA75B69453F67C0 /* UIWebView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIWebView+AFNetworking.m"; path = "UIKit+AFNetworking/UIWebView+AFNetworking.m"; sourceTree = ""; }; + 29472EB761C8B4FDA94E5845FB97C1BC /* imgBackArrow.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = imgBackArrow.png; path = Resources/setup.xcassets/imgBackArrow.imageset/imgBackArrow.png; sourceTree = ""; }; + 299B3B33BEDFF91C499DA5B777EF7412 /* AFNetworking-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "AFNetworking-prefix.pch"; sourceTree = ""; }; + 2B9F690E64B1203DD7C8CCCB254ECC64 /* SparkUserLoginViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkUserLoginViewController.h; path = Classes/UI/SparkUserLoginViewController.h; sourceTree = ""; }; + 2C3FA101C77BBB9691CE81BAE29586E8 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/CoreGraphics.framework; sourceTree = DEVELOPER_DIR; }; + 2C751BA86E29FA09D4BC0F6BD6378669 /* 2.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = 2.png; path = Resources/setup.xcassets/2.imageset/2.png; sourceTree = ""; }; + 32936DB39575AB90BC0A90E8316FAF4D /* SparkSetupWebViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupWebViewController.h; path = Classes/UI/SparkSetupWebViewController.h; sourceTree = ""; }; + 36E3ABFE2DC1F06D82B0B406429E3C18 /* UIImage+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImage+AFNetworking.h"; path = "UIKit+AFNetworking/UIImage+AFNetworking.h"; sourceTree = ""; }; + 37864639795C4854F0231F20AE600CAD /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/MobileCoreServices.framework; sourceTree = DEVELOPER_DIR; }; + 37DB56D75062CC75FCB0966E1C6E8A8E /* Pods-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-acknowledgements.markdown"; sourceTree = ""; }; + 3A16D6753000DD755CA3C0C7F8FD26F8 /* SparkAccessToken.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkAccessToken.m; path = Pod/Classes/SDK/SparkAccessToken.m; sourceTree = ""; }; + 3A5B42DD861454B7564E573B0D665734 /* UIButton+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIButton+AFNetworking.m"; path = "UIKit+AFNetworking/UIButton+AFNetworking.m"; sourceTree = ""; }; + 3A5DE13BFF53941638E7DAB7606754CB /* setup.storyboard */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = file.storyboard; name = setup.storyboard; path = Resources/setup.storyboard; sourceTree = ""; }; + 42189A8351516CBA3725786C152CC4E9 /* SparkSetup.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = SparkSetup.xcconfig; sourceTree = ""; }; + 43E58C3FFD2ED7C57813BEA234DD0D97 /* iosCheckmark.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = iosCheckmark.png; path = Resources/setup.xcassets/iosCheckmark.imageset/iosCheckmark.png; sourceTree = ""; }; + 4415ED2543B3392EE6273F92B7A27922 /* Spark-SDK.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "Spark-SDK.h"; path = "Pod/Classes/Spark-SDK.h"; sourceTree = ""; }; + 454A68BCCAB8203C7EDF4B82C94075FF /* Keys.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Keys.xcconfig; sourceTree = ""; }; + 45F45782272296C1352AE371D34544E4 /* SparkSetupUISpinner.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupUISpinner.h; path = "Classes/UI/UI Elements/SparkSetupUISpinner.h"; sourceTree = ""; }; + 4B044AADC2973806CDA37653633C1EB6 /* AppIcon40x40@2x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "AppIcon40x40@2x.png"; path = "Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png"; sourceTree = ""; }; + 4B4631C02622069A97C0F699C1139A80 /* connect-to-power.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "connect-to-power.png"; path = "Resources/setup.xcassets/connect-to-power.imageset/connect-to-power.png"; sourceTree = ""; }; + 4C8505D0DFA5B8E5AF2BB8F53D6D385A /* photon.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = photon.png; path = Resources/setup.xcassets/photon.imageset/photon.png; sourceTree = ""; }; + 4DD74C86B9671633BB60CEEA58F20195 /* UIRefreshControl+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIRefreshControl+AFNetworking.h"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.h"; sourceTree = ""; }; + 4E094D66062E35F56FAA203EC280B324 /* SparkGetReadyViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkGetReadyViewController.m; path = Classes/UI/SparkGetReadyViewController.m; sourceTree = ""; }; + 4E762F23EC34ED4A6FF3312D84E33A40 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.debug.xcconfig; sourceTree = ""; }; + 4EA1E9424F8E70BD1F8085C8726A1196 /* UIActivityIndicatorView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIActivityIndicatorView+AFNetworking.h"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h"; sourceTree = ""; }; + 4F478CC9C981AA8AE2B54556537B54D7 /* SparkManualNetworkViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkManualNetworkViewController.h; path = Classes/UI/SparkManualNetworkViewController.h; sourceTree = ""; }; + 51C4F65AC0631ADCB97AF537150A1D4E /* SparkSetupCustomization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupCustomization.m; path = Classes/User/SparkSetupCustomization.m; sourceTree = ""; }; + 584D62887D24E11524ADA3228AD5FAF7 /* SparkSetup-Bridging-Header.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "SparkSetup-Bridging-Header.h"; path = "Classes/SparkSetup-Bridging-Header.h"; sourceTree = ""; }; + 5D1218BCDC304634B52A531553CB4C2B /* spacer.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = spacer.png; path = Resources/setup.xcassets/spacer.imageset/spacer.png; sourceTree = ""; }; + 5EFB776BABC19CC83B752468707E3A69 /* KeychainItemWrapper.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = KeychainItemWrapper.h; path = Pod/Classes/Helpers/KeychainItemWrapper.h; sourceTree = ""; }; + 61C3A9EC4F6EA34D70B34AF2C0513AFA /* SparkSetupSecurityManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupSecurityManager.h; path = Classes/Comm/SparkSetupSecurityManager.h; sourceTree = ""; }; + 624D36651D8811A65D745B494FAF2AA4 /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkReachabilityManager.m; path = AFNetworking/AFNetworkReachabilityManager.m; sourceTree = ""; }; + 652FFBA609976DA051941E88C4397155 /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIRefreshControl+AFNetworking.m"; path = "UIKit+AFNetworking/UIRefreshControl+AFNetworking.m"; sourceTree = ""; }; + 65C86CE3CDEA978FC67C96DBD07528F5 /* SparkGetReadyViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkGetReadyViewController.h; path = Classes/UI/SparkGetReadyViewController.h; sourceTree = ""; }; + 6911BECA35E7518D864239B7E898EEF3 /* Pods-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-frameworks.sh"; sourceTree = ""; }; + 6CA6B94E029542907A4A22845ADF7577 /* wifi3.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = wifi3.png; path = Resources/setup.xcassets/wifi3.imageset/wifi3.png; sourceTree = ""; }; + 6CD969BC227F62D266145E35E293DE20 /* SparkCloud.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkCloud.h; path = Pod/Classes/SDK/SparkCloud.h; sourceTree = ""; }; + 6E5FC2C69A27D77CF70C2310D80D2B5A /* SparkSetupResultViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupResultViewController.h; path = Classes/UI/SparkSetupResultViewController.h; sourceTree = ""; }; + 6F7829AE27CC57982BBC3A090B44B0FA /* lock.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = lock.png; path = Resources/setup.xcassets/lock.imageset/lock.png; sourceTree = ""; }; + 6FE3E3EC95D69C201CE5656C3D1C3777 /* SparkConnectingProgressViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkConnectingProgressViewController.m; path = Classes/UI/SparkConnectingProgressViewController.m; sourceTree = ""; }; + 70E691FC9DE43D850FE38203F49C684A /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFNetworkActivityIndicatorManager.m; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m"; sourceTree = ""; }; + 7290D63102399F5321ACF3FA5BA42B7B /* SparkSetupUIElements.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupUIElements.h; path = "Classes/UI/UI Elements/SparkSetupUIElements.h"; sourceTree = ""; }; + 74F3D4D1B78366583AFBDECF533D846F /* spark-logo-head.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "spark-logo-head.png"; path = "Resources/setup.xcassets/spark-logo-head.imageset/spark-logo-head.png"; sourceTree = ""; }; + 76C8214F1603AFE3461D0907859E7577 /* SparkSetup.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetup.h; path = Classes/SparkSetup.h; sourceTree = ""; }; + 7C239678430A159AF182601929241AA6 /* SparkSetupUIButton.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupUIButton.h; path = "Classes/UI/UI Elements/SparkSetupUIButton.h"; sourceTree = ""; }; + 7CCE8DA1C46E18E6B36C9CA2234F99A3 /* AFSecurityPolicy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFSecurityPolicy.m; path = AFNetworking/AFSecurityPolicy.m; sourceTree = ""; }; + 7E0241F701AE1F7A58D83409A20BAEAA /* Reachability.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = Reachability.m; path = Classes/Comm/Reachability.m; sourceTree = ""; }; + 7F2B98C1023B504DAECFFEF542F25B80 /* SparkEvent.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkEvent.h; path = Pod/Classes/SDK/SparkEvent.h; sourceTree = ""; }; + 80C36D8E35C6AC1B72F34F4DD0E33E49 /* SparkDevice.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkDevice.h; path = Pod/Classes/SDK/SparkDevice.h; sourceTree = ""; }; + 81A47DF8A8EBBE8446F0E30D3BA08743 /* Strike1Keys.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = Strike1Keys.m; sourceTree = ""; }; + 828D5356DDCD7C4F0308813B83F45120 /* Default@2x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "Default@2x.png"; path = "Resources/setup.xcassets/LaunchImage.launchimage/Default@2x.png"; sourceTree = ""; }; + 84184649E3CB6AA25D2C09E6E0A2DC2F /* AppIcon40x40.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = AppIcon40x40.png; path = Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40.png; sourceTree = ""; }; + 847209C429CC16B2D6ACF92DA337F8CB /* AppIcon76x76@2x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "AppIcon76x76@2x.png"; path = "Resources/setup.xcassets/AppIcon.appiconset/AppIcon76x76@2x.png"; sourceTree = ""; }; + 856BFAC4C93CD1BBC6A98A4CF1272547 /* SparkSetupWebViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupWebViewController.m; path = Classes/UI/SparkSetupWebViewController.m; sourceTree = ""; }; + 85940B04C3900B1079BF6FB5403695D3 /* SparkCloud.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkCloud.m; path = Pod/Classes/SDK/SparkCloud.m; sourceTree = ""; }; + 85B7902C78F87E0836100B2B49B30644 /* SparkUserSignupViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkUserSignupViewController.m; path = Classes/UI/SparkUserSignupViewController.m; sourceTree = ""; }; + 8780F132E2A1C1736A32BA85099DC2BD /* wifi2.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = wifi2.png; path = Resources/setup.xcassets/wifi2.imageset/wifi2.png; sourceTree = ""; }; + 8939B8678DD109AAA51F23233B5DF01C /* SparkSetupMainController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupMainController.m; path = Classes/User/SparkSetupMainController.m; sourceTree = ""; }; + 8AE0BC13ADCA826EB340C142D2FA6B8E /* AppIcon76x76-1.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "AppIcon76x76-1.png"; path = "Resources/setup.xcassets/AppIcon.appiconset/AppIcon76x76-1.png"; sourceTree = ""; }; + 8C7945F3C2131DDDD647E5EEF04CF5F6 /* SparkDiscoverDeviceViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkDiscoverDeviceViewController.m; path = Classes/UI/SparkDiscoverDeviceViewController.m; sourceTree = ""; }; + 8E9B319993ACC4BB91E86A4A01974E4E /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworkActivityIndicatorManager.h; path = "UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h"; sourceTree = ""; }; + 95110933E0F890897C121571811F08D5 /* SparkSetupMainController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupMainController.h; path = Classes/User/SparkSetupMainController.h; sourceTree = ""; }; + 968E6C75C2D4469B287B36195CD8A2DD /* connect-to-wifi.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "connect-to-wifi.png"; path = "Resources/setup.xcassets/connect-to-wifi.imageset/connect-to-wifi.png"; sourceTree = ""; }; + 989E9F2E569396E383DD224863C3828C /* success.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = success.png; path = Resources/setup.xcassets/success.imageset/success.png; sourceTree = ""; }; + 98C98CDFB3F20F2925F6CD1F141BB14F /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.release.xcconfig; sourceTree = ""; }; + 98D1911E279D11861E25D55AFCA9D919 /* AFNetworking.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = AFNetworking.xcconfig; sourceTree = ""; }; + 9C9C1F81D3497AC8A8C48B81E2FED3BA /* SparkSetupUIButton.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupUIButton.m; path = "Classes/UI/UI Elements/SparkSetupUIButton.m"; sourceTree = ""; }; + 9CEA734A21391B82CD906564AB4F289B /* SparkSetupVideoViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupVideoViewController.h; path = Classes/UI/SparkSetupVideoViewController.h; sourceTree = ""; }; + 9DCA8D76F05F6FBEDF28EC37F3D50322 /* SparkUser.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkUser.m; path = Pod/Classes/SDK/SparkUser.m; sourceTree = ""; }; + A072B4122EBB6EC6315CEDB61FB8ACEE /* SparkSetupUILabel.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupUILabel.h; path = "Classes/UI/UI Elements/SparkSetupUILabel.h"; sourceTree = ""; }; + A08F446BB083BB0A254F944A49DC6151 /* UIButton+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIButton+AFNetworking.h"; path = "UIKit+AFNetworking/UIButton+AFNetworking.h"; sourceTree = ""; }; + A0CAFF45DEAD0C0F3B89BAD67B06EB30 /* SparkSetupSecurityManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupSecurityManager.m; path = Classes/Comm/SparkSetupSecurityManager.m; sourceTree = ""; }; + A1A36D34413696BE466E2CA0AFF194DA /* Pods-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-resources.sh"; sourceTree = ""; }; + A240826CC6D084724C7C99E6FD6D8503 /* SparkSetupCustomization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupCustomization.h; path = Classes/User/SparkSetupCustomization.h; sourceTree = ""; }; + A28C0110554DE1AEC894884D07C7B354 /* SparkUserForgotPasswordViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkUserForgotPasswordViewController.h; path = Classes/UI/SparkUserForgotPasswordViewController.h; sourceTree = ""; }; + A52466161703BD32B6B478B4F301787A /* SparkSelectNetworkViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSelectNetworkViewController.m; path = Classes/UI/SparkSelectNetworkViewController.m; sourceTree = ""; }; + A5CE43AA20CA228A62BC61A76D6E93F5 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLConnectionOperation.m; path = AFNetworking/AFURLConnectionOperation.m; sourceTree = ""; }; + A5F7177EB5E47D784133A2EB73B9DE53 /* SparkSetupUISpinner.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupUISpinner.m; path = "Classes/UI/UI Elements/SparkSetupUISpinner.m"; sourceTree = ""; }; + A6C0BCC26C36FD45B3B0185584AEED79 /* SparkSetupUIViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupUIViewController.h; path = "Classes/UI/UI Elements/SparkSetupUIViewController.h"; sourceTree = ""; }; + AC15A39E3ABE535A96A5CC298835EEDB /* libAFNetworking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAFNetworking.a; sourceTree = BUILT_PRODUCTS_DIR; }; + AD517D8A84459209B1DE67F13E63290F /* spark-logo.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "spark-logo.png"; path = "Resources/setup.xcassets/spark-logo.imageset/spark-logo.png"; sourceTree = ""; }; + AD9B681E0DC6507243ADE76FC49456BC /* x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = x.png; path = Resources/setup.xcassets/x.imageset/x.png; sourceTree = ""; }; + AE885EF01C456069CD80A6E8AF217777 /* background-1.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "background-1.png"; path = "Resources/setup.xcassets/background.imageset/background-1.png"; sourceTree = ""; }; + AFAF3F8EB78A2547823A0759DEFE34FA /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + B1A9DB7A3EB9C984AF5BAD92FC27D59B /* SparkConnectingProgressViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkConnectingProgressViewController.h; path = Classes/UI/SparkConnectingProgressViewController.h; sourceTree = ""; }; + B5ACF9B9CD19FB2745D57F47CE53FDFF /* Spark-SDK.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Spark-SDK.xcconfig"; sourceTree = ""; }; + B6DDE58F65E0125C844CD6646C226F39 /* EventSource.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = EventSource.m; path = Pod/Classes/Helpers/EventSource.m; sourceTree = ""; }; + B96DC26748E3FC5B3DEEB0B052363C9D /* SparkSetupUILabel.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupUILabel.m; path = "Classes/UI/UI Elements/SparkSetupUILabel.m"; sourceTree = ""; }; + BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; + BC678E5531DCCB9F2D759596022D6D25 /* SparkSetupWifiTableViewCell.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupWifiTableViewCell.h; path = "Classes/UI/UI Elements/SparkSetupWifiTableViewCell.h"; sourceTree = ""; }; + BD897B2C65901B39D778A2AE7B66751A /* Keys-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Keys-dummy.m"; sourceTree = ""; }; + BE22549C5625B26EE546D7F94C09CADF /* KeychainItemWrapper.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = KeychainItemWrapper.m; path = Pod/Classes/Helpers/KeychainItemWrapper.m; sourceTree = ""; }; + C0360414907C53E2EEE6A25098A26361 /* SparkUserForgotPasswordViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkUserForgotPasswordViewController.m; path = Classes/UI/SparkUserForgotPasswordViewController.m; sourceTree = ""; }; + C193F57DA6B6ABAACB2FBE3F9C848EE7 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPRequestOperation.h; path = AFNetworking/AFHTTPRequestOperation.h; sourceTree = ""; }; + C27BF17445F746932F44818B6C83741E /* SparkSetupWifiTableViewCell.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupWifiTableViewCell.m; path = "Classes/UI/UI Elements/SparkSetupWifiTableViewCell.m"; sourceTree = ""; }; + C2D445F656639E02848A46667C2BEC22 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIImageView+AFNetworking.h"; path = "UIKit+AFNetworking/UIImageView+AFNetworking.h"; sourceTree = ""; }; + C55555710E8166947E1EAD3155C5FA8E /* wifi1.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = wifi1.png; path = Resources/setup.xcassets/wifi1.imageset/wifi1.png; sourceTree = ""; }; + C6F5088CC992CBA9E545691DEDAA1EBA /* SparkUser.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkUser.h; path = Pod/Classes/SDK/SparkUser.h; sourceTree = ""; }; + C87F1540D3EFBBA2089267EFE227EEAE /* AFNetworking-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "AFNetworking-dummy.m"; sourceTree = ""; }; + C8908189965D177AD6BAB607AE614C1E /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; }; + C8D0D0663BFEACD3F126A939DB77861F /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; + CADB363DD2CF336E66D075513DCD2B49 /* UIActivityIndicatorView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIActivityIndicatorView+AFNetworking.m"; path = "UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m"; sourceTree = ""; }; + CCF1BA6DB0507C1CA560B4181EAA266E /* SparkAccessToken.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkAccessToken.h; path = Pod/Classes/SDK/SparkAccessToken.h; sourceTree = ""; }; + CE506A589D9627F92405940C2DEB4D89 /* Default-667h@2x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "Default-667h@2x.png"; path = "Resources/setup.xcassets/LaunchImage.launchimage/Default-667h@2x.png"; sourceTree = ""; }; + D11C1EA4E13FABB2E9ECA22FA8AFF245 /* AppIcon29x29@2x-1.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "AppIcon29x29@2x-1.png"; path = "Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29@2x-1.png"; sourceTree = ""; }; + D168AA93293F5533EC2F297BFBCF3730 /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFHTTPSessionManager.m; path = AFNetworking/AFHTTPSessionManager.m; sourceTree = ""; }; + D2484C990E4B8B11FE716C9ECEEA9B14 /* spinner.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = spinner.png; path = Resources/setup.xcassets/spinner.imageset/spinner.png; sourceTree = ""; }; + D293BBBAD1F8B4AD0E18C5C22F2C1242 /* AFSecurityPolicy.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFSecurityPolicy.h; path = AFNetworking/AFSecurityPolicy.h; sourceTree = ""; }; + D31A03A119C9E22081396859E887EA4B /* SparkSetup.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SparkSetup.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; + D3BA91FAAE708116C42507E22D769743 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; + D49430388065C258FC8796E5416B6EB6 /* AppIcon40x40@2x-1.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "AppIcon40x40@2x-1.png"; path = "Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40@2x-1.png"; sourceTree = ""; }; + D629384A0807E819AF88513104DBC68A /* UIProgressView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIProgressView+AFNetworking.h"; path = "UIKit+AFNetworking/UIProgressView+AFNetworking.h"; sourceTree = ""; }; + D65E3E47BF916E7814004609E7B67DAE /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLRequestSerialization.h; path = AFNetworking/AFURLRequestSerialization.h; sourceTree = ""; }; + D7C35E6ACCF3DB67742298C17967679C /* SparkSetupUIViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupUIViewController.m; path = "Classes/UI/UI Elements/SparkSetupUIViewController.m"; sourceTree = ""; }; + D84279B18B5189C43C8B5014B5488703 /* SparkDiscoverDeviceViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkDiscoverDeviceViewController.h; path = Classes/UI/SparkDiscoverDeviceViewController.h; sourceTree = ""; }; + D93A7A79FA39F8DCD59A8A4A78477B1E /* SparkEvent.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkEvent.m; path = Pod/Classes/SDK/SparkEvent.m; sourceTree = ""; }; + DA58C7A6F06F25A1F72A9546E0513F2E /* spinner_big.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = spinner_big.png; path = Resources/setup.xcassets/spinner_big.imageset/spinner_big.png; sourceTree = ""; }; + DC1C7C6EA23889590C9297EB4225718A /* Default-568h@2x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "Resources/setup.xcassets/LaunchImage.launchimage/Default-568h@2x.png"; sourceTree = ""; }; + E0839124458B80721F17B67A23A99DAA /* SparkSetupPasswordEntryViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkSetupPasswordEntryViewController.h; path = Classes/UI/SparkSetupPasswordEntryViewController.h; sourceTree = ""; }; + E0BA5A4A9D449B998B840B3DEC7C612D /* warning.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = warning.png; path = Resources/setup.xcassets/warning.imageset/warning.png; sourceTree = ""; }; + E18FD6539184A6E4E8D61687DCB692F8 /* 3.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = 3.png; path = Resources/setup.xcassets/3.imageset/3.png; sourceTree = ""; }; + E3AD4B4957766463E6E81B5D60B346E7 /* iosSettingWifi.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = iosSettingWifi.png; path = Resources/setup.xcassets/iosSettingWifi.imageset/iosSettingWifi.png; sourceTree = ""; }; + E474978076D8199A6CDF4A72E8C100AA /* AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFNetworking.h; path = AFNetworking/AFNetworking.h; sourceTree = ""; }; + E4B674A88AB8A9732133017B29821135 /* SparkSetup-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "SparkSetup-prefix.pch"; sourceTree = ""; }; + E4EDAD6BB7D00CE66CBD7C609F66F704 /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIKit+AFNetworking.h"; path = "UIKit+AFNetworking/UIKit+AFNetworking.h"; sourceTree = ""; }; + E4F0974D51857B77CD3206A66BCFF62A /* libSpark-SDK.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libSpark-SDK.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + E519163EB66C5B99B289125B8D7E5872 /* UIWebView+AFNetworking.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "UIWebView+AFNetworking.h"; path = "UIKit+AFNetworking/UIWebView+AFNetworking.h"; sourceTree = ""; }; + E5DC80AB542BC465525DD22801223B29 /* SparkSetupPasswordEntryViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupPasswordEntryViewController.m; path = Classes/UI/SparkSetupPasswordEntryViewController.m; sourceTree = ""; }; + E61EDEAC890205E4F429AAF201B6938B /* Default-Portrait-736h@3x.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "Default-Portrait-736h@3x.png"; path = "Resources/setup.xcassets/LaunchImage.launchimage/Default-Portrait-736h@3x.png"; sourceTree = ""; }; + E8D4CD22DCC99E6C56B3218F81CB60B9 /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLRequestSerialization.m; path = AFNetworking/AFURLRequestSerialization.m; sourceTree = ""; }; + EFCFEF23CC6390280873A23E3FB72FDB /* 1.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = 1.png; path = Resources/setup.xcassets/1.imageset/1.png; sourceTree = ""; }; + F14C9C9F913559FAF65AE7B526E1C041 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLConnectionOperation.h; path = AFNetworking/AFURLConnectionOperation.h; sourceTree = ""; }; + F34A646429A01BBE2F5A58FA8175D255 /* Spark-SDK-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Spark-SDK-dummy.m"; sourceTree = ""; }; + F3BF00F2C7BE58B36D9175A872F91417 /* SparkUserSignupViewController.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = SparkUserSignupViewController.h; path = Classes/UI/SparkUserSignupViewController.h; sourceTree = ""; }; + F6C15E3FDC85ABFC356779E64879F7E6 /* leftChevron.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = leftChevron.png; path = Resources/setup.xcassets/leftChevron.imageset/leftChevron.png; sourceTree = ""; }; + F7536BAE8C1A5DD8E7DCAAF99AE84837 /* UIAlertView+AFNetworking.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "UIAlertView+AFNetworking.m"; path = "UIKit+AFNetworking/UIAlertView+AFNetworking.m"; sourceTree = ""; }; + F8009C6E5BE9E0FC3B584A8C768B8DBF /* Strike1Keys.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = Strike1Keys.h; sourceTree = ""; }; + F89BF9FB31F554F0A3C597A7C16CBF8D /* SparkManualNetworkViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkManualNetworkViewController.m; path = Classes/UI/SparkManualNetworkViewController.m; sourceTree = ""; }; + F9025CDAF76EA4301C729E51A8B7A47F /* libSparkSetup.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSparkSetup.a; sourceTree = BUILT_PRODUCTS_DIR; }; + FA121E6420831479E9ADDA0F0ABA0661 /* SparkSetupConnection.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupConnection.m; path = Classes/Comm/SparkSetupConnection.m; sourceTree = ""; }; + FC4816191F806110B04ABCBDFED0BD01 /* AFHTTPRequestOperationManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFHTTPRequestOperationManager.h; path = AFNetworking/AFHTTPRequestOperationManager.h; sourceTree = ""; }; + FC75C5EA647C041A3AC35E610F100557 /* Reachability.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = Reachability.h; path = Classes/Comm/Reachability.h; sourceTree = ""; }; + FCBD1055328AE9E85FFC91AC554ED34B /* SparkSetup-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "SparkSetup-dummy.m"; sourceTree = ""; }; + FCC60591D9B8CB2629DF0D88930C94AA /* AFURLSessionManager.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = AFURLSessionManager.h; path = AFNetworking/AFURLSessionManager.h; sourceTree = ""; }; + FE3BEBBD5651901872EAB8E10C848F03 /* background-1-1.png */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = image.png; name = "background-1-1.png"; path = "Resources/setup.xcassets/background.imageset/background-1-1.png"; sourceTree = ""; }; + FE8D71FE2BB26DA75BEAD48641D4EE60 /* SparkSetupVideoViewController.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = SparkSetupVideoViewController.m; path = Classes/UI/SparkSetupVideoViewController.m; sourceTree = ""; }; + FF84ADAA9C18388173432BF2DAC75BD3 /* AFURLSessionManager.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = AFURLSessionManager.m; path = AFNetworking/AFURLSessionManager.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0294643AC4D5684FBE11636D0A5932EF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 44713EF05CED2F9CAF2FCA717A3163B0 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 21F5B2C7D4661CB532A44CB96E30989F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 2EEF69E8AA14531A00897DE2DAFA3114 /* Foundation.framework in Frameworks */, + 20E08814B3AB2982AC84AF75DAB05E65 /* Security.framework in Frameworks */, + 243A9A69C7CDBCF2D1B851FA74F7A979 /* SystemConfiguration.framework in Frameworks */, + 83CC4DC9682FA94EBACC1E3DB3F9B792 /* UIKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4440199D17452096C06B95FD8D745409 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 70B37761E115BD2D785F0A3D26B1B10F /* Foundation.framework in Frameworks */, + 1F6BB0CA11C6D0D85062ED24ACCF282E /* Security.framework in Frameworks */, + 05A88E3C8E67B8BA7C7D64C9F64B52C3 /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 5AE427967A2D59B1D1A7098318795177 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 83EECD2665C9C7B38E79A7E2EC4294F4 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 82599AE642FB3381C29E8C7A72E2BA83 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F428C0A5C7AEF469CC7F9B7E6EC0003A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F08E19D8B440D85D564273B1A501B1FC /* CoreGraphics.framework in Frameworks */, + 0F8217A7033D4B1169408CA2DEBFA592 /* Foundation.framework in Frameworks */, + DB42C604EF2F39D542F805AC6A05E090 /* MobileCoreServices.framework in Frameworks */, + F2AF56F00E313B9CD0F4ADA3C5D73BDF /* Security.framework in Frameworks */, + BA025A85A850C1E24A6C92F4C29E5531 /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 030399288BE749194910EF3FC9659BDE /* Development Pods */ = { + isa = PBXGroup; + children = ( + 62CB749ECAA214DA641CF26971AA299F /* Keys */, + ); + name = "Development Pods"; + sourceTree = ""; + }; + 037C0CA694176A3C0915F62C9D20B3E6 /* Targets Support Files */ = { + isa = PBXGroup; + children = ( + B3D1D13E0C6553800746CB8FD61CF946 /* Pods */, + ); + name = "Targets Support Files"; + sourceTree = ""; + }; + 0897F2331A60D078855B2AB80FC556F4 /* Security */ = { + isa = PBXGroup; + children = ( + D293BBBAD1F8B4AD0E18C5C22F2C1242 /* AFSecurityPolicy.h */, + 7CCE8DA1C46E18E6B36C9CA2234F99A3 /* AFSecurityPolicy.m */, + ); + name = Security; + sourceTree = ""; + }; + 0F75DF6C7C5F002280EC53F48E80B587 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1F866C4FD622AAEA41E36EEF0EE4C9DF /* iOS */, + ); + name = Frameworks; + sourceTree = ""; + }; + 18794A5FD3BEE673283BB35688089772 /* Pods */ = { + isa = PBXGroup; + children = ( + CB0BE91CDE805323790E6E963CA742C4 /* AFNetworking */, + 600EE937B1F8BD899615F3E5DBD9C842 /* Spark-SDK */, + D4FF8806F0AB01CA069CE1871F9E84CA /* SparkSetup */, + ); + name = Pods; + sourceTree = ""; + }; + 1F866C4FD622AAEA41E36EEF0EE4C9DF /* iOS */ = { + isa = PBXGroup; + children = ( + 2C3FA101C77BBB9691CE81BAE29586E8 /* CoreGraphics.framework */, + C8D0D0663BFEACD3F126A939DB77861F /* Foundation.framework */, + 37864639795C4854F0231F20AE600CAD /* MobileCoreServices.framework */, + D3BA91FAAE708116C42507E22D769743 /* Security.framework */, + C8908189965D177AD6BAB607AE614C1E /* SystemConfiguration.framework */, + 241A2B7247375EE22111B162FCE4AE84 /* UIKit.framework */, + ); + name = iOS; + sourceTree = ""; + }; + 4537A9F73612E990915913172F4C70E5 /* UIKit */ = { + isa = PBXGroup; + children = ( + 8E9B319993ACC4BB91E86A4A01974E4E /* AFNetworkActivityIndicatorManager.h */, + 70E691FC9DE43D850FE38203F49C684A /* AFNetworkActivityIndicatorManager.m */, + 4EA1E9424F8E70BD1F8085C8726A1196 /* UIActivityIndicatorView+AFNetworking.h */, + CADB363DD2CF336E66D075513DCD2B49 /* UIActivityIndicatorView+AFNetworking.m */, + 040518A36AA634B93F4DBE2300AA0E09 /* UIAlertView+AFNetworking.h */, + F7536BAE8C1A5DD8E7DCAAF99AE84837 /* UIAlertView+AFNetworking.m */, + A08F446BB083BB0A254F944A49DC6151 /* UIButton+AFNetworking.h */, + 3A5B42DD861454B7564E573B0D665734 /* UIButton+AFNetworking.m */, + 36E3ABFE2DC1F06D82B0B406429E3C18 /* UIImage+AFNetworking.h */, + C2D445F656639E02848A46667C2BEC22 /* UIImageView+AFNetworking.h */, + 21EA1DB782D228AFA2781A058AF28176 /* UIImageView+AFNetworking.m */, + E4EDAD6BB7D00CE66CBD7C609F66F704 /* UIKit+AFNetworking.h */, + D629384A0807E819AF88513104DBC68A /* UIProgressView+AFNetworking.h */, + 22736E4D3C505DA078A28E52BDE3AA09 /* UIProgressView+AFNetworking.m */, + 4DD74C86B9671633BB60CEEA58F20195 /* UIRefreshControl+AFNetworking.h */, + 652FFBA609976DA051941E88C4397155 /* UIRefreshControl+AFNetworking.m */, + E519163EB66C5B99B289125B8D7E5872 /* UIWebView+AFNetworking.h */, + 2802CCFEC73CA6916AA75B69453F67C0 /* UIWebView+AFNetworking.m */, + ); + name = UIKit; + sourceTree = ""; + }; + 59BC0D89C4C345977B6C443662135163 /* Helpers */ = { + isa = PBXGroup; + children = ( + 0658B3A7F5106FC3A96AC8AA72A0C231 /* EventSource.h */, + B6DDE58F65E0125C844CD6646C226F39 /* EventSource.m */, + 5EFB776BABC19CC83B752468707E3A69 /* KeychainItemWrapper.h */, + BE22549C5625B26EE546D7F94C09CADF /* KeychainItemWrapper.m */, + ); + name = Helpers; + sourceTree = ""; + }; + 600EE937B1F8BD899615F3E5DBD9C842 /* Spark-SDK */ = { + isa = PBXGroup; + children = ( + 4415ED2543B3392EE6273F92B7A27922 /* Spark-SDK.h */, + 59BC0D89C4C345977B6C443662135163 /* Helpers */, + B9A2B27D867268259D2E8443A0BB7461 /* SDK */, + AA3D30F517A550BA5C38EB269025C4AE /* Support Files */, + ); + path = "Spark-SDK"; + sourceTree = ""; + }; + 62CB749ECAA214DA641CF26971AA299F /* Keys */ = { + isa = PBXGroup; + children = ( + F8009C6E5BE9E0FC3B584A8C768B8DBF /* Strike1Keys.h */, + 81A47DF8A8EBBE8446F0E30D3BA08743 /* Strike1Keys.m */, + B57A6DD48855C355706BBE33AAADAB12 /* Support Files */, + ); + name = Keys; + path = CocoaPodsKeys; + sourceTree = ""; + }; + 643DB26276179768C0951538BC23F063 /* Reachability */ = { + isa = PBXGroup; + children = ( + 252D72F3F883F17FE5A0890ACC27DAFB /* AFNetworkReachabilityManager.h */, + 624D36651D8811A65D745B494FAF2AA4 /* AFNetworkReachabilityManager.m */, + ); + name = Reachability; + sourceTree = ""; + }; + 6F950A19572554799A83652F55D08641 /* NSURLConnection */ = { + isa = PBXGroup; + children = ( + C193F57DA6B6ABAACB2FBE3F9C848EE7 /* AFHTTPRequestOperation.h */, + 053B1BBBAAD0B45E58470F0091EB49F3 /* AFHTTPRequestOperation.m */, + FC4816191F806110B04ABCBDFED0BD01 /* AFHTTPRequestOperationManager.h */, + 104818EE841FDC5A6E77E4B1028A677B /* AFHTTPRequestOperationManager.m */, + F14C9C9F913559FAF65AE7B526E1C041 /* AFURLConnectionOperation.h */, + A5CE43AA20CA228A62BC61A76D6E93F5 /* AFURLConnectionOperation.m */, + ); + name = NSURLConnection; + sourceTree = ""; + }; + 78DABF20A4181FCF3D23685BA669197C /* Resources */ = { + isa = PBXGroup; + children = ( + AA56E91ECEC3DE13184840F833602782 /* Resources */, + ); + name = Resources; + sourceTree = ""; + }; + 7DB346D0F39D3F0E887471402A8071AB = { + isa = PBXGroup; + children = ( + BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */, + 030399288BE749194910EF3FC9659BDE /* Development Pods */, + 0F75DF6C7C5F002280EC53F48E80B587 /* Frameworks */, + 18794A5FD3BEE673283BB35688089772 /* Pods */, + E9CF58D6CA3BDB348F46329A955F0317 /* Products */, + 037C0CA694176A3C0915F62C9D20B3E6 /* Targets Support Files */, + ); + sourceTree = ""; + }; + 8AE1DD03D18AE84852E013C57F3389B6 /* Serialization */ = { + isa = PBXGroup; + children = ( + D65E3E47BF916E7814004609E7B67DAE /* AFURLRequestSerialization.h */, + E8D4CD22DCC99E6C56B3218F81CB60B9 /* AFURLRequestSerialization.m */, + 1E89AB552E736A69BE59C374185A6035 /* AFURLResponseSerialization.h */, + 1DCC296A4EC1F44B7430283A38810119 /* AFURLResponseSerialization.m */, + ); + name = Serialization; + sourceTree = ""; + }; + AA3D30F517A550BA5C38EB269025C4AE /* Support Files */ = { + isa = PBXGroup; + children = ( + B5ACF9B9CD19FB2745D57F47CE53FDFF /* Spark-SDK.xcconfig */, + F34A646429A01BBE2F5A58FA8175D255 /* Spark-SDK-dummy.m */, + 1F4C450070003D63D71BC9CA8F86113E /* Spark-SDK-prefix.pch */, + ); + name = "Support Files"; + path = "../Target Support Files/Spark-SDK"; + sourceTree = ""; + }; + AA56E91ECEC3DE13184840F833602782 /* Resources */ = { + isa = PBXGroup; + children = ( + EFCFEF23CC6390280873A23E3FB72FDB /* 1.png */, + 2C751BA86E29FA09D4BC0F6BD6378669 /* 2.png */, + E18FD6539184A6E4E8D61687DCB692F8 /* 3.png */, + 1E83CC83A9EA04EAC31A4C46F3F52FA0 /* AppIcon29x29.png */, + 111D868ECCD8F6CB5945D22110275DDC /* AppIcon29x29@2x.png */, + D11C1EA4E13FABB2E9ECA22FA8AFF245 /* AppIcon29x29@2x-1.png */, + 84184649E3CB6AA25D2C09E6E0A2DC2F /* AppIcon40x40.png */, + 4B044AADC2973806CDA37653633C1EB6 /* AppIcon40x40@2x.png */, + D49430388065C258FC8796E5416B6EB6 /* AppIcon40x40@2x-1.png */, + 167F3E228DE7EE9F878882DFDB5C7803 /* AppIcon60x60@2x.png */, + 8AE0BC13ADCA826EB340C142D2FA6B8E /* AppIcon76x76-1.png */, + 847209C429CC16B2D6ACF92DA337F8CB /* AppIcon76x76@2x.png */, + AE885EF01C456069CD80A6E8AF217777 /* background-1.png */, + FE3BEBBD5651901872EAB8E10C848F03 /* background-1-1.png */, + 17C3A74681C6EB6065DC3BF0F665E686 /* checkmark.png */, + 4B4631C02622069A97C0F699C1139A80 /* connect-to-power.png */, + 968E6C75C2D4469B287B36195CD8A2DD /* connect-to-wifi.png */, + DC1C7C6EA23889590C9297EB4225718A /* Default-568h@2x.png */, + CE506A589D9627F92405940C2DEB4D89 /* Default-667h@2x.png */, + E61EDEAC890205E4F429AAF201B6938B /* Default-Portrait-736h@3x.png */, + 828D5356DDCD7C4F0308813B83F45120 /* Default@2x.png */, + 006C6F0A3E9E9AD52F1356B05B5F7CBF /* failure.png */, + 29472EB761C8B4FDA94E5845FB97C1BC /* imgBackArrow.png */, + 43E58C3FFD2ED7C57813BEA234DD0D97 /* iosCheckmark.png */, + E3AD4B4957766463E6E81B5D60B346E7 /* iosSettingWifi.png */, + F6C15E3FDC85ABFC356779E64879F7E6 /* leftChevron.png */, + 6F7829AE27CC57982BBC3A090B44B0FA /* lock.png */, + 4C8505D0DFA5B8E5AF2BB8F53D6D385A /* photon.png */, + 3A5DE13BFF53941638E7DAB7606754CB /* setup.storyboard */, + 5D1218BCDC304634B52A531553CB4C2B /* spacer.png */, + AD517D8A84459209B1DE67F13E63290F /* spark-logo.png */, + 74F3D4D1B78366583AFBDECF533D846F /* spark-logo-head.png */, + D2484C990E4B8B11FE716C9ECEEA9B14 /* spinner.png */, + DA58C7A6F06F25A1F72A9546E0513F2E /* spinner_big.png */, + 989E9F2E569396E383DD224863C3828C /* success.png */, + E0BA5A4A9D449B998B840B3DEC7C612D /* warning.png */, + C55555710E8166947E1EAD3155C5FA8E /* wifi1.png */, + 8780F132E2A1C1736A32BA85099DC2BD /* wifi2.png */, + 6CA6B94E029542907A4A22845ADF7577 /* wifi3.png */, + AD9B681E0DC6507243ADE76FC49456BC /* x.png */, + ); + name = Resources; + sourceTree = ""; + }; + B3D1D13E0C6553800746CB8FD61CF946 /* Pods */ = { + isa = PBXGroup; + children = ( + 37DB56D75062CC75FCB0966E1C6E8A8E /* Pods-acknowledgements.markdown */, + 10834806BD7B412BC24F347361FA2C8E /* Pods-acknowledgements.plist */, + 272643F56613CA0D336AE3DBF19DC404 /* Pods-dummy.m */, + 6911BECA35E7518D864239B7E898EEF3 /* Pods-frameworks.sh */, + A1A36D34413696BE466E2CA0AFF194DA /* Pods-resources.sh */, + 4E762F23EC34ED4A6FF3312D84E33A40 /* Pods.debug.xcconfig */, + 98C98CDFB3F20F2925F6CD1F141BB14F /* Pods.release.xcconfig */, + ); + name = Pods; + path = "Target Support Files/Pods"; + sourceTree = ""; + }; + B57A6DD48855C355706BBE33AAADAB12 /* Support Files */ = { + isa = PBXGroup; + children = ( + 454A68BCCAB8203C7EDF4B82C94075FF /* Keys.xcconfig */, + BD897B2C65901B39D778A2AE7B66751A /* Keys-dummy.m */, + 06248D0A29CA1015181AD173BE0BF93D /* Keys-prefix.pch */, + ); + name = "Support Files"; + path = "../Target Support Files/Keys"; + sourceTree = ""; + }; + B9A2B27D867268259D2E8443A0BB7461 /* SDK */ = { + isa = PBXGroup; + children = ( + CCF1BA6DB0507C1CA560B4181EAA266E /* SparkAccessToken.h */, + 3A16D6753000DD755CA3C0C7F8FD26F8 /* SparkAccessToken.m */, + 6CD969BC227F62D266145E35E293DE20 /* SparkCloud.h */, + 85940B04C3900B1079BF6FB5403695D3 /* SparkCloud.m */, + 80C36D8E35C6AC1B72F34F4DD0E33E49 /* SparkDevice.h */, + 0EA197BEB0F7AE944EEE0044F85C3025 /* SparkDevice.m */, + 7F2B98C1023B504DAECFFEF542F25B80 /* SparkEvent.h */, + D93A7A79FA39F8DCD59A8A4A78477B1E /* SparkEvent.m */, + C6F5088CC992CBA9E545691DEDAA1EBA /* SparkUser.h */, + 9DCA8D76F05F6FBEDF28EC37F3D50322 /* SparkUser.m */, + ); + name = SDK; + sourceTree = ""; + }; + CB0BE91CDE805323790E6E963CA742C4 /* AFNetworking */ = { + isa = PBXGroup; + children = ( + E474978076D8199A6CDF4A72E8C100AA /* AFNetworking.h */, + 6F950A19572554799A83652F55D08641 /* NSURLConnection */, + D92DBB1361F10CCBA825DC76DB656E4E /* NSURLSession */, + 643DB26276179768C0951538BC23F063 /* Reachability */, + 0897F2331A60D078855B2AB80FC556F4 /* Security */, + 8AE1DD03D18AE84852E013C57F3389B6 /* Serialization */, + F5CB69E06700DFD6C9F22C27A098949A /* Support Files */, + 4537A9F73612E990915913172F4C70E5 /* UIKit */, + ); + path = AFNetworking; + sourceTree = ""; + }; + D4FF8806F0AB01CA069CE1871F9E84CA /* SparkSetup */ = { + isa = PBXGroup; + children = ( + 76C8214F1603AFE3461D0907859E7577 /* SparkSetup.h */, + 584D62887D24E11524ADA3228AD5FAF7 /* SparkSetup-Bridging-Header.h */, + F535F86B99D260B6C09B60C6D101A4AE /* Comm */, + FF4ACD625C11C24C5099567D84701FDE /* Core */, + 78DABF20A4181FCF3D23685BA669197C /* Resources */, + DCB39868DF0415C90EA04E6CE0FAA734 /* Support Files */, + ); + path = SparkSetup; + sourceTree = ""; + }; + D92DBB1361F10CCBA825DC76DB656E4E /* NSURLSession */ = { + isa = PBXGroup; + children = ( + 04DE3F341D2A4295D67B050EC8046474 /* AFHTTPSessionManager.h */, + D168AA93293F5533EC2F297BFBCF3730 /* AFHTTPSessionManager.m */, + FCC60591D9B8CB2629DF0D88930C94AA /* AFURLSessionManager.h */, + FF84ADAA9C18388173432BF2DAC75BD3 /* AFURLSessionManager.m */, + ); + name = NSURLSession; + sourceTree = ""; + }; + DCB39868DF0415C90EA04E6CE0FAA734 /* Support Files */ = { + isa = PBXGroup; + children = ( + 42189A8351516CBA3725786C152CC4E9 /* SparkSetup.xcconfig */, + FCBD1055328AE9E85FFC91AC554ED34B /* SparkSetup-dummy.m */, + E4B674A88AB8A9732133017B29821135 /* SparkSetup-prefix.pch */, + ); + name = "Support Files"; + path = "../Target Support Files/SparkSetup"; + sourceTree = ""; + }; + E9CF58D6CA3BDB348F46329A955F0317 /* Products */ = { + isa = PBXGroup; + children = ( + AC15A39E3ABE535A96A5CC298835EEDB /* libAFNetworking.a */, + 23A85C03BBD9931572741402A4EB0098 /* libKeys.a */, + AFAF3F8EB78A2547823A0759DEFE34FA /* libPods.a */, + E4F0974D51857B77CD3206A66BCFF62A /* libSpark-SDK.a */, + F9025CDAF76EA4301C729E51A8B7A47F /* libSparkSetup.a */, + D31A03A119C9E22081396859E887EA4B /* SparkSetup.bundle */, + ); + name = Products; + sourceTree = ""; + }; + F535F86B99D260B6C09B60C6D101A4AE /* Comm */ = { + isa = PBXGroup; + children = ( + FC75C5EA647C041A3AC35E610F100557 /* Reachability.h */, + 7E0241F701AE1F7A58D83409A20BAEAA /* Reachability.m */, + 20A92058080DEA64503E3B122AA83C34 /* SparkSetupCommManager.h */, + 08A4A0A1008527F34FC2DB6555FE6474 /* SparkSetupCommManager.m */, + 24417C1CA86EFDB23DA2487B433FBD67 /* SparkSetupConnection.h */, + FA121E6420831479E9ADDA0F0ABA0661 /* SparkSetupConnection.m */, + 61C3A9EC4F6EA34D70B34AF2C0513AFA /* SparkSetupSecurityManager.h */, + A0CAFF45DEAD0C0F3B89BAD67B06EB30 /* SparkSetupSecurityManager.m */, + ); + name = Comm; + sourceTree = ""; + }; + F5CB69E06700DFD6C9F22C27A098949A /* Support Files */ = { + isa = PBXGroup; + children = ( + 98D1911E279D11861E25D55AFCA9D919 /* AFNetworking.xcconfig */, + C87F1540D3EFBBA2089267EFE227EEAE /* AFNetworking-dummy.m */, + 299B3B33BEDFF91C499DA5B777EF7412 /* AFNetworking-prefix.pch */, + ); + name = "Support Files"; + path = "../Target Support Files/AFNetworking"; + sourceTree = ""; + }; + FF4ACD625C11C24C5099567D84701FDE /* Core */ = { + isa = PBXGroup; + children = ( + B1A9DB7A3EB9C984AF5BAD92FC27D59B /* SparkConnectingProgressViewController.h */, + 6FE3E3EC95D69C201CE5656C3D1C3777 /* SparkConnectingProgressViewController.m */, + D84279B18B5189C43C8B5014B5488703 /* SparkDiscoverDeviceViewController.h */, + 8C7945F3C2131DDDD647E5EEF04CF5F6 /* SparkDiscoverDeviceViewController.m */, + 65C86CE3CDEA978FC67C96DBD07528F5 /* SparkGetReadyViewController.h */, + 4E094D66062E35F56FAA203EC280B324 /* SparkGetReadyViewController.m */, + 4F478CC9C981AA8AE2B54556537B54D7 /* SparkManualNetworkViewController.h */, + F89BF9FB31F554F0A3C597A7C16CBF8D /* SparkManualNetworkViewController.m */, + 21C15DC62792E05B785178132CD0F964 /* SparkSelectNetworkViewController.h */, + A52466161703BD32B6B478B4F301787A /* SparkSelectNetworkViewController.m */, + A240826CC6D084724C7C99E6FD6D8503 /* SparkSetupCustomization.h */, + 51C4F65AC0631ADCB97AF537150A1D4E /* SparkSetupCustomization.m */, + 95110933E0F890897C121571811F08D5 /* SparkSetupMainController.h */, + 8939B8678DD109AAA51F23233B5DF01C /* SparkSetupMainController.m */, + E0839124458B80721F17B67A23A99DAA /* SparkSetupPasswordEntryViewController.h */, + E5DC80AB542BC465525DD22801223B29 /* SparkSetupPasswordEntryViewController.m */, + 6E5FC2C69A27D77CF70C2310D80D2B5A /* SparkSetupResultViewController.h */, + 06AD42CB0CD3259A0D32223D57A5C1B2 /* SparkSetupResultViewController.m */, + 7C239678430A159AF182601929241AA6 /* SparkSetupUIButton.h */, + 9C9C1F81D3497AC8A8C48B81E2FED3BA /* SparkSetupUIButton.m */, + 7290D63102399F5321ACF3FA5BA42B7B /* SparkSetupUIElements.h */, + A072B4122EBB6EC6315CEDB61FB8ACEE /* SparkSetupUILabel.h */, + B96DC26748E3FC5B3DEEB0B052363C9D /* SparkSetupUILabel.m */, + 45F45782272296C1352AE371D34544E4 /* SparkSetupUISpinner.h */, + A5F7177EB5E47D784133A2EB73B9DE53 /* SparkSetupUISpinner.m */, + A6C0BCC26C36FD45B3B0185584AEED79 /* SparkSetupUIViewController.h */, + D7C35E6ACCF3DB67742298C17967679C /* SparkSetupUIViewController.m */, + 9CEA734A21391B82CD906564AB4F289B /* SparkSetupVideoViewController.h */, + FE8D71FE2BB26DA75BEAD48641D4EE60 /* SparkSetupVideoViewController.m */, + 32936DB39575AB90BC0A90E8316FAF4D /* SparkSetupWebViewController.h */, + 856BFAC4C93CD1BBC6A98A4CF1272547 /* SparkSetupWebViewController.m */, + BC678E5531DCCB9F2D759596022D6D25 /* SparkSetupWifiTableViewCell.h */, + C27BF17445F746932F44818B6C83741E /* SparkSetupWifiTableViewCell.m */, + A28C0110554DE1AEC894884D07C7B354 /* SparkUserForgotPasswordViewController.h */, + C0360414907C53E2EEE6A25098A26361 /* SparkUserForgotPasswordViewController.m */, + 2B9F690E64B1203DD7C8CCCB254ECC64 /* SparkUserLoginViewController.h */, + 22050C7C4BE7F51F9FE2223BE4527494 /* SparkUserLoginViewController.m */, + F3BF00F2C7BE58B36D9175A872F91417 /* SparkUserSignupViewController.h */, + 85B7902C78F87E0836100B2B49B30644 /* SparkUserSignupViewController.m */, + ); + name = Core; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 887AC5F9BD172A234FF1077C2AE624C7 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 573E8F68BFF8F0110F5A49F6C9183A3D /* EventSource.h in Headers */, + 16F0EA6274A579BD3FBA7CD76B9B09C8 /* KeychainItemWrapper.h in Headers */, + D5C0CB0FE4FECD1B4B7C4874434FDD25 /* Spark-SDK.h in Headers */, + 7CCA6777E1CA7E9B1EC60F8D50931C38 /* SparkAccessToken.h in Headers */, + F9D3F88FB00E02B1C08D73D7CF54D053 /* SparkCloud.h in Headers */, + DB12C5F4C6D8C49691F3892E556832C8 /* SparkDevice.h in Headers */, + 54DE78D4CC0AE42F36FC2F66BECB0914 /* SparkEvent.h in Headers */, + 5037735033555AEDA6C1E9CD306A02FB /* SparkUser.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 8F87EEC4B0DD1D4CE4E922BC24B19D3F /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 1905AD632AEF96E5E898D7E22CF82E96 /* Reachability.h in Headers */, + 4F48278E8D5A3B5EBC7302B91DA963F9 /* SparkConnectingProgressViewController.h in Headers */, + F6588E4CE1CAB1C428C6035C97987785 /* SparkDiscoverDeviceViewController.h in Headers */, + 1CB72A3C589B2E28E44B54D29436AA4D /* SparkGetReadyViewController.h in Headers */, + 4431F01AF58FD635CDC3699FFA4F12B4 /* SparkManualNetworkViewController.h in Headers */, + 7BECEB800CE44767C142A09D7E6CC224 /* SparkSelectNetworkViewController.h in Headers */, + 2894AF707D15CF7670D98A018626AA80 /* SparkSetup-Bridging-Header.h in Headers */, + 19049A2A2F3EB187194A5520127DB8D5 /* SparkSetup.h in Headers */, + 2769A4E6F6829406F9438B4C4E385076 /* SparkSetupCommManager.h in Headers */, + 2FA12A58911B9BBFC6E1F34B7DEE96AA /* SparkSetupConnection.h in Headers */, + B74DDBA928B18BA9C7F4300499BC1D4D /* SparkSetupCustomization.h in Headers */, + B7ECC4B1AAE85B1ACA10A24B0483563B /* SparkSetupMainController.h in Headers */, + 3686C90A3EB01886CA1E822CF2C13736 /* SparkSetupPasswordEntryViewController.h in Headers */, + 640B51A5EA146490A16295AE2B9FD819 /* SparkSetupResultViewController.h in Headers */, + 6E7619F8B41208CACCDBA1A221339DFF /* SparkSetupSecurityManager.h in Headers */, + 914403435B6C25B41FEC114D69881E39 /* SparkSetupUIButton.h in Headers */, + CB4BCAF540A3B06E92BC3F101891FA85 /* SparkSetupUIElements.h in Headers */, + 8B7DC7FCBA8BAFECEB2883BDE1C60B0D /* SparkSetupUILabel.h in Headers */, + 84814680B853CA5BC2BEBFDAC9492C8D /* SparkSetupUISpinner.h in Headers */, + 2373004DCCE6119B8D086A66BF223555 /* SparkSetupUIViewController.h in Headers */, + 7665EC1EB9391236229902B2D13296E6 /* SparkSetupVideoViewController.h in Headers */, + 58A3B19F4674F533A94D00B4E9010C7E /* SparkSetupWebViewController.h in Headers */, + 2DEB81B3F9A6CDB629410803BD883A7D /* SparkSetupWifiTableViewCell.h in Headers */, + 7FA9BA2A55556F344923DC319BB1876E /* SparkUserForgotPasswordViewController.h in Headers */, + D2492E61B7797BB52D3C955E823C29C1 /* SparkUserLoginViewController.h in Headers */, + 71C62F6793EC2B70D81DB9A33C8074C5 /* SparkUserSignupViewController.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E47C20049A928150D3BDFF99BB3A1E83 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 1FAC7F3E38443BE107780A7A98B34323 /* Strike1Keys.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E9C26A9D9761804867532D147CEA1D5A /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 211D4EA06F5920376A069ACB55DF6006 /* AFHTTPRequestOperation.h in Headers */, + F4A1512E8C4D8C8194CBB276BF72A552 /* AFHTTPRequestOperationManager.h in Headers */, + DECD5915774351B8473476B041DD87D7 /* AFHTTPSessionManager.h in Headers */, + F4DCBA2A42A38C6E7A755182DA50DEA2 /* AFNetworkActivityIndicatorManager.h in Headers */, + 2B8269A87473D9F1259E9BD98E7588D3 /* AFNetworking.h in Headers */, + 78449FCC01114171AA3CCB45C6666206 /* AFNetworkReachabilityManager.h in Headers */, + 1CBDB47B210A0C2448C14A610BC6D4D6 /* AFSecurityPolicy.h in Headers */, + DB2E92A71137AD2E6993E8B0CE682C89 /* AFURLConnectionOperation.h in Headers */, + 495F717651B12E6496C72D16BCC28C29 /* AFURLRequestSerialization.h in Headers */, + 1E310D0CE3BE27EF253B6D822B0AEE5E /* AFURLResponseSerialization.h in Headers */, + 5CF0E043147B69E77976A2CCADFF18CA /* AFURLSessionManager.h in Headers */, + A28588D1CCB5253CF80509F30A1AF1A5 /* UIActivityIndicatorView+AFNetworking.h in Headers */, + 399AC825EE10F70364CE7B0AA89F466D /* UIAlertView+AFNetworking.h in Headers */, + 3A5B54373A45916EC8DE74D060DE5503 /* UIButton+AFNetworking.h in Headers */, + 903A0E1F82A29D285902CBB5A0828BE9 /* UIImage+AFNetworking.h in Headers */, + D4A65C2E29ACB340587FD41196176F8A /* UIImageView+AFNetworking.h in Headers */, + F4B03681047157E5C357E584147F5A46 /* UIKit+AFNetworking.h in Headers */, + C7ACDDE36465ACAF629FEC233B1BF172 /* UIProgressView+AFNetworking.h in Headers */, + C58268D5A4D2A786576E0EAA5B50FB93 /* UIRefreshControl+AFNetworking.h in Headers */, + A4EE8D1BEE38B87066BAA1B09A047356 /* UIWebView+AFNetworking.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 13457F116F17C32A4D53480B68EE9E4F /* Keys */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1398D3467620CBFB8B71ADD08DD9FAF3 /* Build configuration list for PBXNativeTarget "Keys" */; + buildPhases = ( + E6214046A2C4E9760067C7D9DD7FF1E5 /* Sources */, + 5AE427967A2D59B1D1A7098318795177 /* Frameworks */, + E47C20049A928150D3BDFF99BB3A1E83 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Keys; + productName = Keys; + productReference = 23A85C03BBD9931572741402A4EB0098 /* libKeys.a */; + productType = "com.apple.product-type.library.static"; + }; + 32A55E964483F82761FEEB93B7814E9A /* Pods */ = { + isa = PBXNativeTarget; + buildConfigurationList = 8B60831436EE0F575DD32BFEB5CEC1B5 /* Build configuration list for PBXNativeTarget "Pods" */; + buildPhases = ( + A680762F3160C681EAEA6D4B400B1AAE /* Sources */, + 0294643AC4D5684FBE11636D0A5932EF /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 5F955B87CBE1286936F888B7F12F7263 /* PBXTargetDependency */, + 12A3E7ED72AF8F7DA47D9654259A15EA /* PBXTargetDependency */, + E64CA74E3CAEBB1E44514DBC663C9854 /* PBXTargetDependency */, + 988B3701EBB6EB575FCF5500DF0E8EBA /* PBXTargetDependency */, + ); + name = Pods; + productName = Pods; + productReference = AFAF3F8EB78A2547823A0759DEFE34FA /* libPods.a */; + productType = "com.apple.product-type.library.static"; + }; + 410B25DF16EA5C5B3E2698F74F9625FB /* AFNetworking */ = { + isa = PBXNativeTarget; + buildConfigurationList = 41F6B64BF089D072A394601910D14E7B /* Build configuration list for PBXNativeTarget "AFNetworking" */; + buildPhases = ( + 9D44B0AD2D97CB2AA74B614C1E92EDCF /* Sources */, + F428C0A5C7AEF469CC7F9B7E6EC0003A /* Frameworks */, + E9C26A9D9761804867532D147CEA1D5A /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = AFNetworking; + productName = AFNetworking; + productReference = AC15A39E3ABE535A96A5CC298835EEDB /* libAFNetworking.a */; + productType = "com.apple.product-type.library.static"; + }; + 5579B1232582A96EA47C65196B85011C /* Spark-SDK */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0570F46D4495A00FF3468757093C12B0 /* Build configuration list for PBXNativeTarget "Spark-SDK" */; + buildPhases = ( + 2391FED2CDDA7B146608046079FA0034 /* Sources */, + 4440199D17452096C06B95FD8D745409 /* Frameworks */, + 887AC5F9BD172A234FF1077C2AE624C7 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + C8D5D03BB11671BACAEE6B83C80B95C4 /* PBXTargetDependency */, + ); + name = "Spark-SDK"; + productName = "Spark-SDK"; + productReference = E4F0974D51857B77CD3206A66BCFF62A /* libSpark-SDK.a */; + productType = "com.apple.product-type.library.static"; + }; + D140B65203AF3A193E404F4B98C7E839 /* SparkSetup-SparkSetup */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9FA5CC99AB08A4C9161A3AAEA5416236 /* Build configuration list for PBXNativeTarget "SparkSetup-SparkSetup" */; + buildPhases = ( + BAAC0CB3781884B9171F26293BB39D5E /* Sources */, + 82599AE642FB3381C29E8C7A72E2BA83 /* Frameworks */, + 8A1658E92ED94F6FF752379184F1466C /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "SparkSetup-SparkSetup"; + productName = "SparkSetup-SparkSetup"; + productReference = D31A03A119C9E22081396859E887EA4B /* SparkSetup.bundle */; + productType = "com.apple.product-type.bundle"; + }; + E61E5CE6662F45D382902657287BB36F /* SparkSetup */ = { + isa = PBXNativeTarget; + buildConfigurationList = 531DFED76483EE2E3C93283B9ABE3C70 /* Build configuration list for PBXNativeTarget "SparkSetup" */; + buildPhases = ( + F7A9518512DF50F90848624DE3C593FF /* Sources */, + 21F5B2C7D4661CB532A44CB96E30989F /* Frameworks */, + 8F87EEC4B0DD1D4CE4E922BC24B19D3F /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + 67686508EE7ABB2680A3B15E2627BBCD /* PBXTargetDependency */, + 41B4F0C9B392ED58D93800FA00480F97 /* PBXTargetDependency */, + ); + name = SparkSetup; + productName = SparkSetup; + productReference = F9025CDAF76EA4301C729E51A8B7A47F /* libSparkSetup.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D41D8CD98F00B204E9800998ECF8427E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; + }; + buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 7DB346D0F39D3F0E887471402A8071AB; + productRefGroup = E9CF58D6CA3BDB348F46329A955F0317 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 410B25DF16EA5C5B3E2698F74F9625FB /* AFNetworking */, + 13457F116F17C32A4D53480B68EE9E4F /* Keys */, + 32A55E964483F82761FEEB93B7814E9A /* Pods */, + 5579B1232582A96EA47C65196B85011C /* Spark-SDK */, + E61E5CE6662F45D382902657287BB36F /* SparkSetup */, + D140B65203AF3A193E404F4B98C7E839 /* SparkSetup-SparkSetup */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8A1658E92ED94F6FF752379184F1466C /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8A5E2BA5BDB908D5EF9B284B70C59609 /* 1.png in Resources */, + 0832DC7DFB991B7870FA2052BDD8B254 /* 2.png in Resources */, + 3A05A5B279F9F8DDD44036F8DAC5DD4D /* 3.png in Resources */, + 0C9722862E565387F9FFE798307F5098 /* AppIcon29x29.png in Resources */, + DF9435E7EB08458A6C00D5E3CBBE1274 /* AppIcon29x29@2x-1.png in Resources */, + 1B04813FE4A67FBF495624B62AB77A67 /* AppIcon29x29@2x.png in Resources */, + 3C492535C9EB521ECCF876440847670C /* AppIcon40x40.png in Resources */, + E18C7FDAC3E26CE7C4D5437939C8BFCA /* AppIcon40x40@2x-1.png in Resources */, + 0E37FCC8546A1592B5BB4BAA97B6EFA6 /* AppIcon40x40@2x.png in Resources */, + EC41B5CF68F617747663E8364C523BF6 /* AppIcon60x60@2x.png in Resources */, + 4E12A46ADE239E9A9EF893CAC7E3EB4C /* AppIcon76x76-1.png in Resources */, + AB2978110F1272FE9FEF2A639A692617 /* AppIcon76x76@2x.png in Resources */, + E54F1F1AD904377771A6B10248C51EF3 /* background-1-1.png in Resources */, + FFB83062D7E02506A5773A9B78E1B864 /* background-1.png in Resources */, + 037FCD8502BDC545D6A5CF181BF2DA3E /* checkmark.png in Resources */, + C486E81A8911428ACC41E6A00276628B /* connect-to-power.png in Resources */, + 749B47B0BA8650FEDD5A3D3BA76F9829 /* connect-to-wifi.png in Resources */, + 317665CB03863B6DD2AD13ED1E49A575 /* Default-568h@2x.png in Resources */, + 0598CEE3527028F1F957A6004677135A /* Default-667h@2x.png in Resources */, + 20078A2086063338B63874BF88A91BAC /* Default-Portrait-736h@3x.png in Resources */, + 83F69AA6F6D4F2866884E475E0D16D60 /* Default@2x.png in Resources */, + C24CA16B02440C2A794CE71A154D4CF8 /* failure.png in Resources */, + F14D746E64B123CFAD929EAE86366132 /* imgBackArrow.png in Resources */, + 4A95C860874CE6296FB6DCBD2462C375 /* iosCheckmark.png in Resources */, + F601DEB28EDB1F22BC07D41D72F4CE58 /* iosSettingWifi.png in Resources */, + 96D1606ACA5FCB2FB5C48FD5F51217F9 /* leftChevron.png in Resources */, + BA225ACC712F6D911BFC1C25E58D5C66 /* lock.png in Resources */, + 35A75CF792C92805B0746E2BE72C6DAD /* photon.png in Resources */, + AA37EE09B228D3EA729B2FECA2F76BA1 /* setup.storyboard in Resources */, + 04CA911CEA4E88C6BB8C7C1825A3E427 /* spacer.png in Resources */, + 907A7728AFDADAE8703E756F44ECEF42 /* spark-logo-head.png in Resources */, + 3DB9E81A3AE190AE8E1A4D11578E3126 /* spark-logo.png in Resources */, + CCF32D28A9C871B2AC04189AECE516BB /* spinner.png in Resources */, + C25463A21A0429F797EB2FED9C156BE5 /* spinner_big.png in Resources */, + 9DD0AFDE1F4C1B775F095A2455AE641A /* success.png in Resources */, + B28F8C13D3E7F828EE8BCA117AA05EB9 /* warning.png in Resources */, + DB72DB4A2F6D3325F7290ACA7ACD6552 /* wifi1.png in Resources */, + 1E3FC541EAB2B1A1378E34D6B4C07006 /* wifi2.png in Resources */, + 62211E06845580D498B0110657767465 /* wifi3.png in Resources */, + 43C1ED4F0732341280C1D1ABD60CA318 /* x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2391FED2CDDA7B146608046079FA0034 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 776F1C013A2EC6BAA7268B20B2EF8892 /* EventSource.m in Sources */, + 834F18A900A57B3B1D84EB43647D0AAE /* KeychainItemWrapper.m in Sources */, + 8D118CB43F0F2E3F4FA8FDCEC431E5E8 /* Spark-SDK-dummy.m in Sources */, + FD914DDDDED3DBFFD128BCFB17D80A6A /* SparkAccessToken.m in Sources */, + 96FD140D0BFE410C0F86AA076AE742BB /* SparkCloud.m in Sources */, + 37C0720A596A37B897445C62DCA561EE /* SparkDevice.m in Sources */, + 9642475E9B97ED95187075DFBA5E822C /* SparkEvent.m in Sources */, + C9B1E231816CBA9075144D28C1226FA0 /* SparkUser.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 9D44B0AD2D97CB2AA74B614C1E92EDCF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 876C2EF5FE318346CDCB4BFE25A9D5B2 /* AFHTTPRequestOperation.m in Sources */, + 472A6BFCC6207D98F787649BDF44A1BE /* AFHTTPRequestOperationManager.m in Sources */, + 2CF66E8669A348C421E93F2F67C6A61E /* AFHTTPSessionManager.m in Sources */, + B2B5DEC33B644F946C59F656AAAA8146 /* AFNetworkActivityIndicatorManager.m in Sources */, + B9DAA002CF3E0E8EBE9B6E9A7778CFD4 /* AFNetworking-dummy.m in Sources */, + BC7993B7436D4D7FADE6DD554DA52769 /* AFNetworkReachabilityManager.m in Sources */, + B12AD2EE044D6F7424F75F1506B516B2 /* AFSecurityPolicy.m in Sources */, + E6DD6ABB4FC13B60FA54C950FB6B262B /* AFURLConnectionOperation.m in Sources */, + 3033C63AC334D346E9461D0942D8FB69 /* AFURLRequestSerialization.m in Sources */, + CAA0F8074B35A2F73890310EC4521A0D /* AFURLResponseSerialization.m in Sources */, + 6CC4B79C1FEE1E7B3F2860ADA479D381 /* AFURLSessionManager.m in Sources */, + AE607E682415FAA160B33C7C13A8475B /* UIActivityIndicatorView+AFNetworking.m in Sources */, + 9B47A1441B897F71505D8BE670B0940B /* UIAlertView+AFNetworking.m in Sources */, + 99E82D6DC032555656E37AF2367B20D3 /* UIButton+AFNetworking.m in Sources */, + D070B784EFCA099C141EEAB69FBCC870 /* UIImageView+AFNetworking.m in Sources */, + FD6F966F458CEE40B07A2367BA3BC8EC /* UIProgressView+AFNetworking.m in Sources */, + 854BC4449D8CAD0F2799B021D1914C3B /* UIRefreshControl+AFNetworking.m in Sources */, + 9A04E971065AF4281E43947994A53D07 /* UIWebView+AFNetworking.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + A680762F3160C681EAEA6D4B400B1AAE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 18241EB8A6862D64CBE5E8D8D0A5099B /* Pods-dummy.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + BAAC0CB3781884B9171F26293BB39D5E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + E6214046A2C4E9760067C7D9DD7FF1E5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1A6BF2B7930BE4B4AAAFBD674A3D687E /* Keys-dummy.m in Sources */, + 808C57539D9B9AB7636043AF0142EE9F /* Strike1Keys.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + F7A9518512DF50F90848624DE3C593FF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 48B382028C8E355861FAB93B2558F1EE /* Reachability.m in Sources */, + 15027F8F65D663383E9A8644B94079C4 /* SparkConnectingProgressViewController.m in Sources */, + 1E57CA0BC26269BE5BA88A3AC2BC3326 /* SparkDiscoverDeviceViewController.m in Sources */, + D7F50CAB829344D10E3921201F219BF9 /* SparkGetReadyViewController.m in Sources */, + E317BA2472D193740E0FF7B862CEF19B /* SparkManualNetworkViewController.m in Sources */, + B6F276AFFEA701315C62BB4DDE7A20C8 /* SparkSelectNetworkViewController.m in Sources */, + 2DDBAD69257BE62DC3352182246DF24E /* SparkSetup-dummy.m in Sources */, + 1B01544912D3AA80CF9E8B3CDF157688 /* SparkSetupCommManager.m in Sources */, + 70112FDCF2E9DEAA2E409673F9974F89 /* SparkSetupConnection.m in Sources */, + 044ED6DBCB9FA64195D7B6F4BD2CEB8D /* SparkSetupCustomization.m in Sources */, + 19BEBED8018E30F0D60D6CA540E974C9 /* SparkSetupMainController.m in Sources */, + 27E5CE82BE5DE9B15426560831EB07AC /* SparkSetupPasswordEntryViewController.m in Sources */, + C76032137D289370D2B96386150EEBAF /* SparkSetupResultViewController.m in Sources */, + B55068C29FE3DBED229D5A3D279AEABB /* SparkSetupSecurityManager.m in Sources */, + 674E6704704A329C6295FDA3CE1F2ACA /* SparkSetupUIButton.m in Sources */, + 7A40D8D95330BA7EFE70D4B71055015F /* SparkSetupUILabel.m in Sources */, + 81A982BAA277B1E641F4147A14605734 /* SparkSetupUISpinner.m in Sources */, + DB3654AAC36D5914E01F5B8A4079DAB7 /* SparkSetupUIViewController.m in Sources */, + 6AB68CEB0BBE9DFA50258A3063A1BC4E /* SparkSetupVideoViewController.m in Sources */, + BD8EC5BD8B679FEBC9F46F18884DDC7A /* SparkSetupWebViewController.m in Sources */, + 256EFEE5A70448273282044CA8C63BD1 /* SparkSetupWifiTableViewCell.m in Sources */, + 70255569D06E0E87D2E20FE88EC0D73B /* SparkUserForgotPasswordViewController.m in Sources */, + A3F097BA9D814A799E77FD3B286BCA9E /* SparkUserLoginViewController.m in Sources */, + BE516E3F1C19358A8D8B25801E40E444 /* SparkUserSignupViewController.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 12A3E7ED72AF8F7DA47D9654259A15EA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Keys; + target = 13457F116F17C32A4D53480B68EE9E4F /* Keys */; + targetProxy = 9D7E29C11F2DBD6CC7BCEB8B00E3DEA4 /* PBXContainerItemProxy */; + }; + 41B4F0C9B392ED58D93800FA00480F97 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "SparkSetup-SparkSetup"; + target = D140B65203AF3A193E404F4B98C7E839 /* SparkSetup-SparkSetup */; + targetProxy = 3BF9D3615D86200C1C7089E195544826 /* PBXContainerItemProxy */; + }; + 5F955B87CBE1286936F888B7F12F7263 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = AFNetworking; + target = 410B25DF16EA5C5B3E2698F74F9625FB /* AFNetworking */; + targetProxy = BD8C52530FD44305C88B7CC94715D295 /* PBXContainerItemProxy */; + }; + 67686508EE7ABB2680A3B15E2627BBCD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "Spark-SDK"; + target = 5579B1232582A96EA47C65196B85011C /* Spark-SDK */; + targetProxy = 70CA02B062FEDBA3120AFB01CDD2C06F /* PBXContainerItemProxy */; + }; + 988B3701EBB6EB575FCF5500DF0E8EBA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SparkSetup; + target = E61E5CE6662F45D382902657287BB36F /* SparkSetup */; + targetProxy = DC939E7A6A3648B592D1FBD8CCC346CA /* PBXContainerItemProxy */; + }; + C8D5D03BB11671BACAEE6B83C80B95C4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = AFNetworking; + target = 410B25DF16EA5C5B3E2698F74F9625FB /* AFNetworking */; + targetProxy = AB7158E511F306CB43A97A9F21C3C415 /* PBXContainerItemProxy */; + }; + E64CA74E3CAEBB1E44514DBC663C9854 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "Spark-SDK"; + target = 5579B1232582A96EA47C65196B85011C /* Spark-SDK */; + targetProxy = 0A30DFE2279D125160B650A41C16BA2B /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 13481A1443ABF7734D6D3086EA2465D5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 42189A8351516CBA3725786C152CC4E9 /* SparkSetup.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + PRODUCT_NAME = SparkSetup; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + WRAPPER_EXTENSION = bundle; + }; + name = Debug; + }; + 54970567027EDDA46A05D551E0587C4B /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 42189A8351516CBA3725786C152CC4E9 /* SparkSetup.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/SparkSetup/SparkSetup-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 76C88D168B94F380434CA46F30EBE33A /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B5ACF9B9CD19FB2745D57F47CE53FDFF /* Spark-SDK.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/Spark-SDK/Spark-SDK-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 7E1899DAAF5EC91B8E7425E53D397ECA /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 42189A8351516CBA3725786C152CC4E9 /* SparkSetup.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/SparkSetup/SparkSetup-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 81DCE0521913A86E21073FF060860E29 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 4E762F23EC34ED4A6FF3312D84E33A40 /* Pods.debug.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MACH_O_TYPE = staticlib; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 89B8DBA919676542DC16EC277C1C088A /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 98D1911E279D11861E25D55AFCA9D919 /* AFNetworking.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/AFNetworking/AFNetworking-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 921D5FC38F3C54554255B2720A507684 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 42189A8351516CBA3725786C152CC4E9 /* SparkSetup.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + PRODUCT_NAME = SparkSetup; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + WRAPPER_EXTENSION = bundle; + }; + name = Release; + }; + 936373C94C6777F75A36FCBEDB9BBFFC /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 454A68BCCAB8203C7EDF4B82C94075FF /* Keys.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/Keys/Keys-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + A70CDAD61F90AC503C7D04CC22DA2923 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + ONLY_ACTIVE_ARCH = YES; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + }; + name = Debug; + }; + BC87243035A8353EEE679A263D92E46D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 98C98CDFB3F20F2925F6CD1F141BB14F /* Pods.release.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MACH_O_TYPE = staticlib; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PODS_ROOT = "$(SRCROOT)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + D80057F3C7CAD3ACDAA16DDB6A8C0049 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 454A68BCCAB8203C7EDF4B82C94075FF /* Keys.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/Keys/Keys-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + DE2AA43792EE6A366AD6813340B56E37 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 98D1911E279D11861E25D55AFCA9D919 /* AFNetworking.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/AFNetworking/AFNetworking-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + F4980039CF12F984F43BE0D00C5DBF4B /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = B5ACF9B9CD19FB2745D57F47CE53FDFF /* Spark-SDK.xcconfig */; + buildSettings = { + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_PREFIX_HEADER = "Target Support Files/Spark-SDK/Spark-SDK-prefix.pch"; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = ""; + OTHER_LIBTOOLFLAGS = ""; + PRIVATE_HEADERS_FOLDER_PATH = ""; + PRODUCT_NAME = "$(TARGET_NAME)"; + PUBLIC_HEADERS_FOLDER_PATH = ""; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + }; + name = Release; + }; + FB45FFD90572718D82AB9092B750F0CA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = "RELEASE=1"; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + STRIP_INSTALLED_PRODUCT = NO; + SYMROOT = "${SRCROOT}/../build"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0570F46D4495A00FF3468757093C12B0 /* Build configuration list for PBXNativeTarget "Spark-SDK" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 76C88D168B94F380434CA46F30EBE33A /* Debug */, + F4980039CF12F984F43BE0D00C5DBF4B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1398D3467620CBFB8B71ADD08DD9FAF3 /* Build configuration list for PBXNativeTarget "Keys" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D80057F3C7CAD3ACDAA16DDB6A8C0049 /* Debug */, + 936373C94C6777F75A36FCBEDB9BBFFC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A70CDAD61F90AC503C7D04CC22DA2923 /* Debug */, + FB45FFD90572718D82AB9092B750F0CA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 41F6B64BF089D072A394601910D14E7B /* Build configuration list for PBXNativeTarget "AFNetworking" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DE2AA43792EE6A366AD6813340B56E37 /* Debug */, + 89B8DBA919676542DC16EC277C1C088A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 531DFED76483EE2E3C93283B9ABE3C70 /* Build configuration list for PBXNativeTarget "SparkSetup" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 54970567027EDDA46A05D551E0587C4B /* Debug */, + 7E1899DAAF5EC91B8E7425E53D397ECA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 8B60831436EE0F575DD32BFEB5CEC1B5 /* Build configuration list for PBXNativeTarget "Pods" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 81DCE0521913A86E21073FF060860E29 /* Debug */, + BC87243035A8353EEE679A263D92E46D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9FA5CC99AB08A4C9161A3AAEA5416236 /* Build configuration list for PBXNativeTarget "SparkSetup-SparkSetup" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 13481A1443ABF7734D6D3086EA2465D5 /* Debug */, + 921D5FC38F3C54554255B2720A507684 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */; +} diff --git a/Strike/Pods/Spark-SDK/LICENSE b/Strike/Pods/Spark-SDK/LICENSE new file mode 100644 index 0000000..7acc4a1 --- /dev/null +++ b/Strike/Pods/Spark-SDK/LICENSE @@ -0,0 +1,176 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/EventSource.h b/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/EventSource.h new file mode 100644 index 0000000..c1bbcd5 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/EventSource.h @@ -0,0 +1,92 @@ +// +// EventSource +// Server-Sent Events for iOS and Mac +// +// Created by Neil on 25/07/2013. +// Copyright (c) 2013 Neil Cowburn. MIT license. +// Modified by Ido Kleinman, Particle inc. 2015 +// +// Original codebase: +// https://github.com/neilco/EventSource + +#import + +typedef enum { + kEventStateConnecting = 0, + kEventStateOpen = 1, + kEventStateClosed = 2, +} EventState; + +// --------------------------------------------------------------------------------------------------------------------- + +/// Describes an Event received from an EventSource +@interface Event : NSObject + +/// The name of the Event +@property (nonatomic, strong) NSString *name; +/// The data received from the EventSource +@property (nonatomic, strong) NSData *data; + +/// The current state of the connection to the EventSource +@property (nonatomic, assign) EventState readyState; +/// Provides details of any errors with the connection to the EventSource +@property (nonatomic, strong) NSError *error; // unused + +@end + +// --------------------------------------------------------------------------------------------------------------------- + +typedef void (^EventSourceEventHandler)(Event *event); + +// --------------------------------------------------------------------------------------------------------------------- + +/// Connect to and receive Server-Sent Events (SSEs). +@interface EventSource : NSObject + +/// Returns a new instance of EventSource with the specified URL. +/// +/// @param URL The URL of the EventSource. +/// @param timeoutInterval The request timeout interval in seconds. See NSURLRequest for more details. Default: 5 minutes. ++ (instancetype)eventSourceWithURL:(NSURL *)URL timeoutInterval:(NSTimeInterval)timeoutInterval queue:(dispatch_queue_t)queue accessToken:(NSString *)accessToken; + + +/// Creates a new instance of EventSource with the specified URL. +/// +/// @param URL The URL of the EventSource. +/// @param timeoutInterval The request timeout interval in seconds. See NSURLRequest for more details. Default: 5 minutes. +- (instancetype)initWithURL:(NSURL *)URL timeoutInterval:(NSTimeInterval)timeoutInterval queue:(dispatch_queue_t)queue accessToken:(NSString *)accessToken; + + + +/// Registers an event handler for the Message event. +/// +/// @param handler The handler for the Message event. +- (void)onMessage:(EventSourceEventHandler)handler; + +/// Registers an event handler for the Error event. +/// +/// @param handler The handler for the Error event. +- (void)onError:(EventSourceEventHandler)handler; + +/// Registers an event handler for the Open event. +/// +/// @param handler The handler for the Open event. +- (void)onOpen:(EventSourceEventHandler)handler; + +/// Registers an event handler for a named event. +/// +/// @param eventName The name of the event you registered. +/// @param handler The handler for the Message event. +- (void)addEventListener:(NSString *)eventName handler:(EventSourceEventHandler)handler; +- (void)removeEventListener:(NSString *)eventName handler:(EventSourceEventHandler)handler; + +/// Closes the connection to the EventSource. +- (void)close; + +@end + +// --------------------------------------------------------------------------------------------------------------------- + +extern NSString *const MessageEvent; +extern NSString *const ErrorEvent; +extern NSString *const OpenEvent; \ No newline at end of file diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/EventSource.m b/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/EventSource.m new file mode 100644 index 0000000..bdae037 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/EventSource.m @@ -0,0 +1,289 @@ +// +// EventSource.m +// EventSource +// +// Created by Neil on 25/07/2013. +// Copyright (c) 2013 Neil Cowburn. All rights reserved, +// Heavily modified to match Spark event structure by Ido Kleinman, 2015 +// Original codebase: +// https://github.com/neilco/EventSource + + +#import "EventSource.h" + +static CGFloat const ES_RETRY_INTERVAL = 1.0; + +static NSString *const ESKeyValueDelimiter = @": "; +static NSString *const ESEventSeparatorLFLF = @"\n\n"; +static NSString *const ESEventSeparatorCRCR = @"\r\r"; +static NSString *const ESEventSeparatorCRLFCRLF = @"\r\n\r\n"; +static NSString *const ESEventKeyValuePairSeparator = @"\n"; +static NSString *const ESEventDataKey = @"data"; +static NSString *const ESEventEventKey = @"event"; + +@interface EventSource () { + BOOL wasClosed; +} + +@property (nonatomic, strong) NSURL *eventURL; +@property (nonatomic, strong) NSURLConnection *eventSource; +@property (nonatomic, strong) NSMutableDictionary *listeners; +@property (nonatomic, assign) NSTimeInterval timeoutInterval; +@property (nonatomic, assign) NSTimeInterval retryInterval; +@property (nonatomic, strong) id lastEventID; +@property (nonatomic, strong) dispatch_queue_t queue; +@property (nonatomic, strong) NSString* accessToken; +@property (atomic, strong) Event *event; + + +- (void)open; + +@end + +@implementation EventSource + + ++ (instancetype)eventSourceWithURL:(NSURL *)URL timeoutInterval:(NSTimeInterval)timeoutInterval queue:(dispatch_queue_t)queue accessToken:(NSString *)accessToken +{ + return [[EventSource alloc] initWithURL:URL timeoutInterval:timeoutInterval queue:queue accessToken:accessToken]; +} + + +- (instancetype)initWithURL:(NSURL *)URL timeoutInterval:(NSTimeInterval)timeoutInterval queue:(dispatch_queue_t)queue accessToken:(NSString *)accessToken +{ + self = [super init]; + if (self) { + _listeners = [NSMutableDictionary dictionary]; + _eventURL = URL; + _timeoutInterval = timeoutInterval; + _retryInterval = ES_RETRY_INTERVAL; + _queue = queue; + _accessToken = accessToken; + + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(_retryInterval * NSEC_PER_SEC)); + dispatch_after(popTime, queue, ^(void){ + [self open]; + }); + + self.event = [Event new]; + } + return self; +} + +- (void)addEventListener:(NSString *)eventName handler:(EventSourceEventHandler)handler +{ + if (self.listeners[eventName] == nil) { + [self.listeners setObject:[NSMutableArray array] forKey:eventName]; + } + + [self.listeners[eventName] addObject:handler]; +} + +- (void)removeEventListener:(NSString *)eventName handler:(EventSourceEventHandler)handler +{ + if (self.listeners[eventName]) + [self.listeners[eventName] removeObject:handler]; +} + + + +- (void)onMessage:(EventSourceEventHandler)handler +{ + [self addEventListener:MessageEvent handler:handler]; +} + +- (void)onError:(EventSourceEventHandler)handler +{ + [self addEventListener:ErrorEvent handler:handler]; +} + +- (void)onOpen:(EventSourceEventHandler)handler +{ + [self addEventListener:OpenEvent handler:handler]; +} + +- (void)open +{ + NSLog(@"event open"); + // TODO: add the authorization headers/parameters here + wasClosed = NO; + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:self.eventURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:self.timeoutInterval]; +// if (self.lastEventID) +// { +// [request setValue:self.lastEventID forHTTPHeaderField:@"Last-Event-ID"]; +// } + + [request addValue:[NSString stringWithFormat:@"Bearer %@",self.accessToken] forHTTPHeaderField:@"Authorization"]; + [request setHTTPMethod:@"GET"]; + + self.eventSource = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; + + if (![NSThread isMainThread]) { + CFRunLoopRun(); + } +} + +- (void)close +{ + wasClosed = YES; + [self.eventSource cancel]; + self.queue = nil; +} + +// --------------------------------------------------------------------------------------------------------------------- + +- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response +{ + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + if (httpResponse.statusCode == 200) { + // Opened + Event *e = [Event new]; + e.readyState = kEventStateOpen; + + // TODO: remove this? (open/close/etc) + NSArray *openHandlers = self.listeners[OpenEvent]; + for (EventSourceEventHandler handler in openHandlers) { + dispatch_async(self.queue, ^{ + handler(e); + }); + } + } + else + { + NSLog(@"Error opening event stream, code %ld",(long)httpResponse.statusCode); + } +} + +- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error +{ + Event *e = [Event new]; + e.readyState = kEventStateClosed; + e.error = error; + + NSArray *errorHandlers = self.listeners[ErrorEvent]; + for (EventSourceEventHandler handler in errorHandlers) { + dispatch_async(self.queue, ^{ + handler(e); + }); + } + + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(self.retryInterval * NSEC_PER_SEC)); + dispatch_after(popTime, self.queue, ^(void){ + [self open]; + }); +} + +- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data +{ + NSString *eventString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + eventString = [eventString stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; + NSArray *components = [eventString componentsSeparatedByString:ESEventKeyValuePairSeparator]; + + self.event.readyState = kEventStateOpen; + + for (NSString *component in components) { + if (component.length == 0) { + continue; + } + + NSInteger index = [component rangeOfString:ESKeyValueDelimiter].location; + if (index == NSNotFound || index == (component.length - 2)) { + continue; + } + + NSString *key = [component substringToIndex:index]; + NSString *value = [component substringFromIndex:index + ESKeyValueDelimiter.length]; + + + if ([key isEqualToString:ESEventEventKey]) + { + self.event.name = value; + } else if ([key isEqualToString:ESEventDataKey]) + { + self.event.data = [value dataUsingEncoding:NSUTF8StringEncoding]; + } + + if ((self.event.name) && (self.event.data)) + { + NSArray *messageHandlers = self.listeners[MessageEvent]; + __block Event *sendEvent = [self.event copy]; // to prevent race conditions where loop continues iterating sending duplicate events to handler callback + for (EventSourceEventHandler handler in messageHandlers) { + dispatch_async(self.queue, ^{ + handler(sendEvent); + }); + } + self.event = [Event new]; + } + } +} + + +- (void)connectionDidFinishLoading:(NSURLConnection *)connection +{ + if (wasClosed) { + return; + } + + Event *e = [Event new]; + e.readyState = kEventStateClosed; + e.error = [NSError errorWithDomain:@"" + code:e.readyState + userInfo:@{ NSLocalizedDescriptionKey: @"Connection with the event source was closed." }]; + + NSArray *errorHandlers = self.listeners[ErrorEvent]; + for (EventSourceEventHandler handler in errorHandlers) { + dispatch_async(self.queue, ^{ + handler(e); + }); + } + + [self open]; +} + +@end + +// --------------------------------------------------------------------------------------------------------------------- + +@implementation Event + +- (NSString *)description +{ + NSString *state = nil; + switch (self.readyState) { + case kEventStateConnecting: + state = @"CONNECTING"; + break; + case kEventStateOpen: + state = @"OPEN"; + break; + case kEventStateClosed: + state = @"CLOSED"; + break; + } + + return [NSString stringWithFormat:@"<%@: readyState: %@; event: %@; data: %@>", + [self class], + state, +// self.id, + self.name, + self.data]; + +} + +-(id)copyWithZone:(NSZone *)zone +{ + Event *copy = [[Event allocWithZone:zone] init]; + + copy.name = self.name; + copy.data = self.data; + copy.readyState = self.readyState; + copy.error = self.error; + + return copy; +} + +@end + +NSString *const MessageEvent = @"message"; +NSString *const ErrorEvent = @"error"; +NSString *const OpenEvent = @"open"; \ No newline at end of file diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/KeychainItemWrapper.h b/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/KeychainItemWrapper.h new file mode 100755 index 0000000..effde8b --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/KeychainItemWrapper.h @@ -0,0 +1,67 @@ +/* + File: KeychainItemWrapper.h + Abstract: + Objective-C wrapper for accessing a single keychain item. + + Version: 1.2 - ARCified + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2010 Apple Inc. All Rights Reserved. + + */ + +#import + +/* + The KeychainItemWrapper class is an abstraction layer for the iPhone Keychain communication. It is merely a + simple wrapper to provide a distinct barrier between all the idiosyncracies involved with the Keychain + CF/NS container objects. + */ +@interface KeychainItemWrapper : NSObject + +// Designated initializer. +- (id)initWithIdentifier: (NSString *)identifier accessGroup:(NSString *)accessGroup; +- (void)setObject:(id)inObject forKey:(id)key; +- (id)objectForKey:(id)key; + +// Initializes and resets the default generic keychain item data. +- (void)resetKeychainItem; + +@end \ No newline at end of file diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/KeychainItemWrapper.m b/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/KeychainItemWrapper.m new file mode 100755 index 0000000..1cd0d2c --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/Helpers/KeychainItemWrapper.m @@ -0,0 +1,334 @@ +/* + File: KeychainItemWrapper.m + Abstract: + Objective-C wrapper for accessing a single keychain item. + + Version: 1.2 - ARCified + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2010 Apple Inc. All Rights Reserved. + + */ + +#define PASSWORD_USES_DATA + +#import "KeychainItemWrapper.h" +#import + +/* + + These are the default constants and their respective types, + available for the kSecClassGenericPassword Keychain Item class: + + kSecAttrAccessGroup - CFStringRef + kSecAttrCreationDate - CFDateRef + kSecAttrModificationDate - CFDateRef + kSecAttrDescription - CFStringRef + kSecAttrComment - CFStringRef + kSecAttrCreator - CFNumberRef + kSecAttrType - CFNumberRef + kSecAttrLabel - CFStringRef + kSecAttrIsInvisible - CFBooleanRef + kSecAttrIsNegative - CFBooleanRef + kSecAttrAccount - CFStringRef + kSecAttrService - CFStringRef + kSecAttrGeneric - CFDataRef + + See the header file Security/SecItem.h for more details. + + */ + +@interface KeychainItemWrapper (PrivateMethods) +/* + The decision behind the following two methods (secItemFormatToDictionary and dictionaryToSecItemFormat) was + to encapsulate the transition between what the detail view controller was expecting (NSString *) and what the + Keychain API expects as a validly constructed container class. + */ +- (NSMutableDictionary *)secItemFormatToDictionary:(NSDictionary *)dictionaryToConvert; +- (NSMutableDictionary *)dictionaryToSecItemFormat:(NSDictionary *)dictionaryToConvert; + +// Updates the item in the keychain, or adds it if it doesn't exist. +- (void)writeToKeychain; + +@end + +@implementation KeychainItemWrapper +{ + NSMutableDictionary *keychainItemData; // The actual keychain item data backing store. + NSMutableDictionary *genericPasswordQuery; // A placeholder for the generic keychain item query used to locate the item. +} + +- (id)initWithIdentifier: (NSString *)identifier accessGroup:(NSString *) accessGroup; +{ + if (self = [super init]) + { + // Begin Keychain search setup. The genericPasswordQuery leverages the special user + // defined attribute kSecAttrGeneric to distinguish itself between other generic Keychain + // items which may be included by the same application. + genericPasswordQuery = [[NSMutableDictionary alloc] init]; + + [genericPasswordQuery setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; + [genericPasswordQuery setObject:identifier forKey:(__bridge id)kSecAttrGeneric]; + + // The keychain access group attribute determines if this item can be shared + // amongst multiple apps whose code signing entitlements contain the same keychain access group. + if (accessGroup != nil) + { +#if TARGET_IPHONE_SIMULATOR + // Ignore the access group if running on the iPhone simulator. + // + // Apps that are built for the simulator aren't signed, so there's no keychain access group + // for the simulator to check. This means that all apps can see all keychain items when run + // on the simulator. + // + // If a SecItem contains an access group attribute, SecItemAdd and SecItemUpdate on the + // simulator will return -25243 (errSecNoAccessForItem). +#else + [genericPasswordQuery setObject:accessGroup forKey:(__bridge id)kSecAttrAccessGroup]; +#endif + } + + // Use the proper search constants, return only the attributes of the first match. + [genericPasswordQuery setObject:(__bridge id)kSecMatchLimitOne forKey:(__bridge id)kSecMatchLimit]; + [genericPasswordQuery setObject:(__bridge id)kCFBooleanTrue forKey:(__bridge id)kSecReturnAttributes]; + + NSDictionary *tempQuery = [NSDictionary dictionaryWithDictionary:genericPasswordQuery]; + + CFMutableDictionaryRef outDictionary = NULL; + + if (!SecItemCopyMatching((__bridge CFDictionaryRef)tempQuery, (CFTypeRef *)&outDictionary) == noErr) + { + // Stick these default values into keychain item if nothing found. + [self resetKeychainItem]; + + // Add the generic attribute and the keychain access group. + [keychainItemData setObject:identifier forKey:(__bridge id)kSecAttrGeneric]; + if (accessGroup != nil) + { +#if TARGET_IPHONE_SIMULATOR + // Ignore the access group if running on the iPhone simulator. + // + // Apps that are built for the simulator aren't signed, so there's no keychain access group + // for the simulator to check. This means that all apps can see all keychain items when run + // on the simulator. + // + // If a SecItem contains an access group attribute, SecItemAdd and SecItemUpdate on the + // simulator will return -25243 (errSecNoAccessForItem). +#else + [keychainItemData setObject:accessGroup forKey:(__bridge id)kSecAttrAccessGroup]; +#endif + } + } + else + { + // load the saved data from Keychain. + keychainItemData = [self secItemFormatToDictionary:(__bridge NSDictionary *)outDictionary]; + } + if(outDictionary) CFRelease(outDictionary); + } + + return self; +} + +- (void)setObject:(id)inObject forKey:(id)key +{ + if (inObject == nil) return; + id currentObject = [keychainItemData objectForKey:key]; + if (![currentObject isEqual:inObject]) + { + [keychainItemData setObject:inObject forKey:key]; + [self writeToKeychain]; + } +} + +- (id)objectForKey:(id)key +{ + return [keychainItemData objectForKey:key]; +} + +- (void)resetKeychainItem +{ + if (!keychainItemData) + { + keychainItemData = [[NSMutableDictionary alloc] init]; + } + else if (keychainItemData) + { + NSMutableDictionary *tempDictionary = [self dictionaryToSecItemFormat:keychainItemData]; +#ifndef NS_BLOCK_ASSERTIONS +// OSStatus junk = +#endif + SecItemDelete((__bridge CFDictionaryRef)tempDictionary); +// NSAssert( junk == noErr || junk == errSecItemNotFound, @"Problem deleting current dictionary." ); + } + + // Default attributes for keychain item. + [keychainItemData setObject:@"" forKey:(__bridge id)kSecAttrAccount]; + [keychainItemData setObject:@"" forKey:(__bridge id)kSecAttrLabel]; + [keychainItemData setObject:@"" forKey:(__bridge id)kSecAttrDescription]; + + // Default data for keychain item. +#ifndef PASSWORD_USES_DATA + [keychainItemData setObject:@"" forKey:(__bridge id)kSecValueData]; +#else + [keychainItemData setObject:[NSData data] forKey:(__bridge id)kSecValueData]; +#endif +} + +- (NSMutableDictionary *)dictionaryToSecItemFormat:(NSDictionary *)dictionaryToConvert +{ + // The assumption is that this method will be called with a properly populated dictionary + // containing all the right key/value pairs for a SecItem. + + // Create a dictionary to return populated with the attributes and data. + NSMutableDictionary *returnDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionaryToConvert]; + + // Add the Generic Password keychain item class attribute. + [returnDictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; + + // Convert the NSString to NSData to meet the requirements for the value type kSecValueData. + // This is where to store sensitive data that should be encrypted. +#ifndef PASSWORD_USES_DATA + // orig + NSString *passwordString = [dictionaryToConvert objectForKey:(__bridge id)kSecValueData]; + [returnDictionary setObject:[passwordString dataUsingEncoding:NSUTF8StringEncoding] forKey:(__bridge id)kSecValueData]; +#else + // DFH + id val = [dictionaryToConvert objectForKey:(__bridge id)kSecValueData]; + if([val isKindOfClass:[NSString class]]) { + val = [(NSString *)val dataUsingEncoding:NSUTF8StringEncoding]; + } + [returnDictionary setObject:val forKey:(__bridge id)kSecValueData]; +#endif + + + return returnDictionary; +} + +- (NSMutableDictionary *)secItemFormatToDictionary:(NSDictionary *)dictionaryToConvert +{ + // The assumption is that this method will be called with a properly populated dictionary + // containing all the right key/value pairs for the UI element. + + // Create a dictionary to return populated with the attributes and data. + NSMutableDictionary *returnDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionaryToConvert]; + + // Add the proper search key and class attribute. + [returnDictionary setObject:(__bridge id)kCFBooleanTrue forKey:(__bridge id)kSecReturnData]; + [returnDictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; + + // Acquire the password data from the attributes. + CFDataRef passwordData = NULL; + if (SecItemCopyMatching((__bridge CFDictionaryRef)returnDictionary, (CFTypeRef *)&passwordData) == noErr) + { + // Remove the search, class, and identifier key/value, we don't need them anymore. + [returnDictionary removeObjectForKey:(__bridge id)kSecReturnData]; + +#ifndef PASSWORD_USES_DATA + // Add the password to the dictionary, converting from NSData to NSString. + NSString *password = [[NSString alloc] initWithBytes:[(__bridge NSData *)passwordData bytes] length:[(__bridge NSData *)passwordData length] + encoding:NSUTF8StringEncoding]; +#else + NSData *password = (__bridge_transfer NSData *)passwordData; + passwordData = NULL; +#endif + [returnDictionary setObject:password forKey:(__bridge id)kSecValueData]; + } + else + { + // Don't do anything if nothing is found. + NSAssert(NO, @"Serious error, no matching item found in the keychain.\n"); + } + if(passwordData) CFRelease(passwordData); + + return returnDictionary; +} + +- (void)writeToKeychain +{ + CFDictionaryRef attributes = NULL; + NSMutableDictionary *updateItem = nil; + OSStatus result; + + if (SecItemCopyMatching((__bridge CFDictionaryRef)genericPasswordQuery, (CFTypeRef *)&attributes) == noErr) + { + // First we need the attributes from the Keychain. + updateItem = [NSMutableDictionary dictionaryWithDictionary:(__bridge NSDictionary *)attributes]; + // Second we need to add the appropriate search key/values. + [updateItem setObject:[genericPasswordQuery objectForKey:(__bridge id)kSecClass] forKey:(__bridge id)kSecClass]; + + // Lastly, we need to set up the updated attribute list being careful to remove the class. + NSMutableDictionary *tempCheck = [self dictionaryToSecItemFormat:keychainItemData]; + [tempCheck removeObjectForKey:(__bridge id)kSecClass]; + +#if TARGET_IPHONE_SIMULATOR + // Remove the access group if running on the iPhone simulator. + // + // Apps that are built for the simulator aren't signed, so there's no keychain access group + // for the simulator to check. This means that all apps can see all keychain items when run + // on the simulator. + // + // If a SecItem contains an access group attribute, SecItemAdd and SecItemUpdate on the + // simulator will return -25243 (errSecNoAccessForItem). + // + // The access group attribute will be included in items returned by SecItemCopyMatching, + // which is why we need to remove it before updating the item. + [tempCheck removeObjectForKey:(__bridge id)kSecAttrAccessGroup]; +#endif + + // An implicit assumption is that you can only update a single item at a time. +#ifndef NDEBUG + result = +#endif + SecItemUpdate((__bridge CFDictionaryRef)updateItem, (__bridge CFDictionaryRef)tempCheck); + + NSAssert( result == noErr, @"Couldn't update the Keychain Item." ); + } + else + { + // No previous item found; add the new one. + result = SecItemAdd((__bridge CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL); + NSAssert( result == noErr, @"Couldn't add the Keychain Item." ); + } + + if(attributes) CFRelease(attributes); +} + +@end \ No newline at end of file diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkAccessToken.h b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkAccessToken.h new file mode 100644 index 0000000..a9433a5 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkAccessToken.h @@ -0,0 +1,61 @@ +// +// SparkAccessToken.h +// Particle iOS Cloud SDK +// +// Created by Ido Kleinman +// Copyright 2015 Particle +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +@class SparkAccessToken; + +@protocol SparkAccessTokenDelegate +-(void)SparkAccessToken:(SparkAccessToken *)accessToken didExpireAt:(NSDate *)date; +@end + +@interface SparkAccessToken : NSObject +/** + * Access token string to be used when calling cloud API + */ +@property (nonatomic, strong, readonly) NSString *accessToken; +/** + * Delegate to receive didExpireAt method call whenever a token is detected as expired + */ +@property (nonatomic, weak) id delegate; + +/** + * Initialze SparkAccessToken class with new session + * + * @param loginResponseDict response object from Spark cloud login deserialized as NSDictionary + * + * @return New SparkAccessToken instance + */ +-(instancetype)initWithNewSession:(NSDictionary *)loginResponseDict; + +/** + * Initialize SparkAccessToken from existing session stored in keychain + * + * @return A SparkAccessToken instance in case session is stored in keychain and token has not expired, nil if not + */ +-(instancetype)initWithSavedSession; + +-(instancetype)init __attribute__((unavailable("Must use initWithNewSession: or initWithSavedSession:"))); + +/** + * Remove access token session data from keychain + */ +-(void)removeSession; + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkAccessToken.m b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkAccessToken.m new file mode 100644 index 0000000..c4a8c7c --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkAccessToken.m @@ -0,0 +1,142 @@ +// +// SparkAccessToken.m +// teacup-ios-app +// +// Created by Ido Kleinman on 1/5/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkAccessToken.h" +#import "KeychainItemWrapper.h" +#import +#import "SparkCloud.h" + +NSString *const kSparkAccessTokenKeychainEntry = @"io.spark.api.Keychain.AccessToken"; +NSString *const kSparkAccessTokenExpiryDateKey = @"kSparkAccessTokenExpiryDateKey"; +NSString *const kSparkAccessTokenStringKey = @"kSparkAccessTokenStringKey"; + +// how many seconds before expiry date will a token be considered expired (0 = expire on expiry date, 24*60*60 = expire a day before) +#define ACCESS_TOKEN_EXPIRY_MARGIN 0 + +@interface SparkAccessToken() +@property (nonatomic, strong) NSDate *expiryDate; +@property (nonatomic, strong) NSTimer *expiryTimer; +@property (nonatomic, strong) NSString *accessToken; +@end + +@implementation SparkAccessToken + +-(instancetype)initWithNewSession:(NSDictionary *)loginResponseDict +{ + self = [super init]; + if (self) + { +// NSLog(@"(debug)login responseObject:\n%@",loginResponseDict.description); + NSNumber *nti = loginResponseDict[@"expires_in"]; + if (!nti) return nil; + + self.expiryDate = [[NSDate alloc] initWithTimeIntervalSinceNow:nti.doubleValue]; +// NSLog(@"(debug)access token expiry: %@",self.expiryDate.description); + self.accessToken = loginResponseDict[@"access_token"]; + if (!self.accessToken) + return nil; + + // verify response object type + if (![loginResponseDict[@"token_type"] isEqualToString:@"bearer"]) + return nil; + + self.expiryTimer = [[NSTimer alloc] initWithFireDate:self.expiryDate interval:0 target:self selector:@selector(accessTokenExpired:) userInfo:nil repeats:NO]; + [[NSRunLoop currentRunLoop] addTimer:self.expiryTimer forMode:NSDefaultRunLoopMode]; + + NSMutableDictionary *accessTokenDict = [NSMutableDictionary new]; + accessTokenDict[kSparkAccessTokenStringKey] = self.accessToken; + accessTokenDict[kSparkAccessTokenExpiryDateKey] = self.expiryDate; + + NSData *keychainData = [NSKeyedArchiver archivedDataWithRootObject:accessTokenDict]; + KeychainItemWrapper *keychainTokenItem = [[KeychainItemWrapper alloc] initWithIdentifier:kSparkAccessTokenKeychainEntry accessGroup:nil]; + [keychainTokenItem setObject:keychainData forKey:(__bridge id)(kSecValueData)]; + + return self; + } + + return nil; +} + + +-(void)accessTokenExpired:(NSTimer *)timer +{ + [self.expiryTimer invalidate]; + [self.delegate SparkAccessToken:self didExpireAt:self.expiryDate]; +} + + +-(instancetype)initWithSavedSession +{ + self = [super init]; + if (self) + { + KeychainItemWrapper *keychainTokenItem = [[KeychainItemWrapper alloc] initWithIdentifier:kSparkAccessTokenKeychainEntry accessGroup:nil]; + NSData *keychainData = [keychainTokenItem objectForKey:(__bridge id)(kSecValueData)]; + NSDictionary *accessTokenDict; + if ((keychainData) && (keychainData.length > 0)) + { + @try { + // might throw a NSInvalidArgumentException incomprehensible archive for previously incompatible saved sessions + accessTokenDict = (NSDictionary *)[NSKeyedUnarchiver unarchiveObjectWithData:keychainData]; + } + @catch (NSException *exception) { + // so remove any invalid session data + [self removeSession]; + } + + } + else + return nil; + + if (accessTokenDict) + { + self.accessToken = accessTokenDict[kSparkAccessTokenStringKey]; + self.expiryDate = accessTokenDict[kSparkAccessTokenExpiryDateKey]; + } + else + return nil; + + // this also checks if saved session access token has expired already (by getter) + if (!((self.accessToken) && (self.expiryDate))) + return nil; + + self.expiryTimer = [[NSTimer alloc] initWithFireDate:self.expiryDate interval:0 target:self selector:@selector(accessTokenExpired:) userInfo:nil repeats:NO]; + [[NSRunLoop currentRunLoop] addTimer:self.expiryTimer forMode:NSDefaultRunLoopMode]; + + return self; + } + + return nil; +} + + +-(NSString *)accessToken +{ + // always return only a non-expired access token + NSTimeInterval ti = [self.expiryDate timeIntervalSinceNow]; + if (ti < ACCESS_TOKEN_EXPIRY_MARGIN) + return nil; + else + return _accessToken; +} + + +-(void)removeSession +{ + KeychainItemWrapper *keychainTokenItem = [[KeychainItemWrapper alloc] initWithIdentifier:kSparkAccessTokenKeychainEntry accessGroup:nil]; + [keychainTokenItem resetKeychainItem]; + self.accessToken = nil; +} + + +-(void)dealloc +{ + [self.expiryTimer invalidate]; +} + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkCloud.h b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkCloud.h new file mode 100644 index 0000000..fc04aa7 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkCloud.h @@ -0,0 +1,201 @@ +// +// SparkCloud.h +// Particle iOS Cloud SDK +// +// Created by Ido Kleinman +// Copyright 2015 Particle +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import +#import "SparkDevice.h" +#import "SparkEvent.h" + +extern NSString *const kSparkAPIBaseURL; + +@interface SparkCloud : NSObject + +/** + * Currently loggeed in user name, nil if no session exists + */ +@property (nonatomic, strong, readonly) NSString* loggedInUsername; +@property (nonatomic, readonly) BOOL isLoggedIn; +/** + * Current session access token string + */ +@property (nonatomic, strong, readonly) NSString *accessToken; + +@property (nonatomic, strong) NSString *OAuthClientId; +@property (nonatomic, strong) NSString *OAuthClientSecret; +/** + * Singleton instance of SparkCloud class + * + * @return SparkCloud + */ ++ (instancetype)sharedInstance; + +#pragma mark User onboarding functions +// -------------------------------------------------------------------------------------------------------------------------------------------------------- +// User onboarding functions +// -------------------------------------------------------------------------------------------------------------------------------------------------------- + +/** + * Login with existing account credentials to Spark cloud + * + * @param user User name, must be a valid email address + * @param password Password + * @param completion Completion block will be called when login finished, NSError object will be passed in case of an error, nil if success + */ +-(void)loginWithUser:(NSString *)user password:(NSString *)password completion:(void (^)(NSError *error))completion; + +/** + * Sign up with new account credentials to Spark cloud + * + * @param user Required user name, must be a valid email address + * @param password Required password + * @param completion Completion block will be called when sign-up finished, NSError object will be passed in case of an error, nil if success + */ +-(void)signupWithUser:(NSString *)user password:(NSString *)password completion:(void (^)(NSError *error))completion; + + +/** + * Sign up with new account credentials to Spark cloud + * + * @param email Required user name, must be a valid email address + * @param password Required password + * @param orgSlug Organization string to include in cloud API endpoint URL + * @param completion Completion block will be called when sign-up finished, NSError object will be passed in case of an error, nil if success + */ +-(void)signupWithCustomer:(NSString *)email password:(NSString *)password orgSlug:(NSString *)orgSlug completion:(void (^)(NSError *))completion; + +/** + * Logout user, remove session data + */ +-(void)logout; + +/** + * Request password reset for user or customer (organization mode) + * command generates confirmation token and sends email to customer using org SMTP settings + * + * @param email user email + * @param completion Completion block with NSError object if failure, nil if success + */ +-(void)requestPasswordResetForCustomer:(NSString *)orgSlug email:(NSString *)email completion:(void(^)(NSError *))completion; +-(void)requestPasswordResetForUser:(NSString *)email completion:(void(^)(NSError *))completion; + +#pragma mark Device management functions +// -------------------------------------------------------------------------------------------------------------------------------------------------------- +// Device management functions +// -------------------------------------------------------------------------------------------------------------------------------------------------------- + +/** + * Get an array of instances of all user's claimed devices + * offline devices will contain only partial data (no info about functions/variables) + * + * @param completion Completion block with the device instances array in case of success or with NSError object if failure + */ +-(void)getDevices:(void (^)(NSArray *sparkDevices, NSError *error))completion; + +/** + * Get a specific device instance by its deviceID. If the device is offline the instance will contain only partial information the cloud has cached, + * notice that the the request might also take quite some time to complete for offline devices. + * + * @param deviceID required deviceID + * @param completion Completion block with first arguemnt as the device instance in case of success or with second argument NSError object if operation failed + */ +-(void)getDevice:(NSString *)deviceID completion:(void (^)(SparkDevice *, NSError *))completion; + +// Not available yet +//-(void)publishEvent:(NSString *)eventName data:(NSData *)data; + +/** + * Claim the specified device to the currently logged in user (without claim code mechanism) + * + * @param deviceID required deviceID + * @param completion Completion block with NSError object if failure, nil if success + */ +-(void)claimDevice:(NSString *)deviceID completion:(void(^)(NSError *))completion; + +/** + * Get a short-lived claiming token for transmitting to soon-to-be-claimed device in soft AP setup process + * + * @param completion Completion block with claimCode string returned (48 random bytes base64 encoded to 64 ASCII characters), second argument is a list of the devices currently claimed by current session user and third is NSError object for failure, nil if success + */ +-(void)generateClaimCode:(void(^)(NSString *claimCode, NSArray *userClaimedDeviceIDs, NSError *error))completion; + + +/** + * Get a short-lived claiming token for transmitting to soon-to-be-claimed device in soft AP setup process for specific product and organization (different API endpoints) + * @param orgSlug - the organization slug string in URL + * @param productSlug - the product slug string in URL + * @param activationCode - optional (can be nil) activation code string for products in private-beta mode - see Particle Dashboard for product creators + * + * @param completion Completion block with claimCode string returned (48 random bytes base64 encoded to 64 ASCII characters), second argument is a list of the devices currently claimed by current session user and third is NSError object for failure, nil if success + */ +-(void)generateClaimCodeForOrganization:(NSString *)orgSlug andProduct:(NSString *)productSlug withActivationCode:(NSString *)activationCode completion:(void(^)(NSString *claimCode, NSArray *userClaimedDeviceIDs, NSError *error))completion; + + +#pragma mark Events subsystem functions +// -------------------------------------------------------------------------------------------------------------------------------------------------------- +// Events subsystem: +// -------------------------------------------------------------------------------------------------------------------------------------------------------- + +/** + * Subscribe to the firehose of public events, plus private events published by devices one owns + * + * @param eventHandler SparkEventHandler event handler method - receiving NSDictionary argument which contains keys: event (name), data (payload), ttl (time to live), published_at (date/time emitted), coreid (device ID). Second argument is NSError object in case error occured in parsing the event payload. + * @param eventName Filter only events that match name eventName, if nil is passed any event will trigger eventHandler + * @return eventListenerID function will return an id type object as the eventListener registration unique ID - keep and pass this object to the unsubscribe method in order to remove this event listener + */ +-(id)subscribeToAllEventsWithPrefix:(NSString *)eventNamePrefix handler:(SparkEventHandler)eventHandler; +/** + * Subscribe to all events, public and private, published by devices one owns + * + * @param eventHandler Event handler function that accepts the event payload dictionary and an NSError object in case of an error + * @param eventNamePrefix Filter only events that match name eventNamePrefix, for exact match pass whole string, if nil/empty string is passed any event will trigger eventHandler + * @return eventListenerID function will return an id type object as the eventListener registration unique ID - keep and pass this object to the unsubscribe method in order to remove this event listener + */ +-(id)subscribeToMyDevicesEventsWithPrefix:(NSString *)eventNamePrefix handler:(SparkEventHandler)eventHandler; + +/** + * Subscribe to events from one specific device. If the API user has the device claimed, then she will receive all events, public and private, published by that device. + * If the API user does not own the device she will only receive public events. + * + * @param eventNamePrefix Filter only events that match name eventNamePrefix, for exact match pass whole string, if nil/empty string is passed any event will trigger eventHandler + * @param deviceID Specific device ID. If user has this device claimed the private & public events will be received, otherwise public events only are received. + * @param eventHandler Event handler function that accepts the event payload dictionary and an NSError object in case of an error + * @return eventListenerID function will return an id type object as the eventListener registration unique ID - keep and pass this object to the unsubscribe method in order to remove this event listener + */ +-(id)subscribeToDeviceEventsWithPrefix:(NSString *)eventNamePrefix deviceID:(NSString *)deviceID handler:(SparkEventHandler)eventHandler; + +/** + * Unsubscribe from event/events. + * + * @param eventListenerID The eventListener registration unique ID returned by the subscribe method which you want to cancel + */ +-(void)unsubscribeFromEventWithID:(id)eventListenerID; + +/** + * Subscribe to events from one specific device. If the API user has the device claimed, then she will receive all events, public and private, published by that device. + * If the API user does not own the device she will only receive public events. + * + * @param eventName Publish event named eventName + * @param data A string representing event data payload, you can serialize any data you need to represent into this string and events listeners will get it + * @param private A boolean flag determining if this event is private or not (only users's claimed devices will be able to listen to it) + * @param ttl TTL stands for Time To Live. It it the number of seconds that the event data is relevant and meaningful. For example, an outdoor temperature reading with a precision of integer degrees Celsius might have a TTL of somewhere between 600 (10 minutes) and 1800 (30 minutes). + * The geolocation of a large piece of farm equipment that remains stationary most of the time but may be moved to a different field once in a while might have a TTL of 86400 (24 hours). After the TTL has passed, the information can be considered stale or out of date. + */ +-(void)publishEventWithName:(NSString *)eventName data:(NSString *)data isPrivate:(BOOL)isPrivate ttl:(NSUInteger)ttl completion:(void (^)(NSError *))completion; + + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkCloud.m b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkCloud.m new file mode 100644 index 0000000..1edeb6a --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkCloud.m @@ -0,0 +1,829 @@ +// +// SparkCloud.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/7/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkCloud.h" +#import "KeychainItemWrapper.h" +#import "SparkAccessToken.h" +#import "SparkUser.h" +#import +#import +#import "SparkEvent.h" + + +#define GLOBAL_API_TIMEOUT_INTERVAL 31.0f + +NSString *const kSparkAPIBaseURL = @"https://api.particle.io"; +NSString *const kEventListenersDictEventSourceKey = @"eventSource"; +NSString *const kEventListenersDictHandlerKey = @"eventHandler"; +NSString *const kEventListenersDictIDKey = @"id"; + +@interface SparkCloud () +@property (nonatomic, strong) NSURL* baseURL; +@property (nonatomic, strong) SparkAccessToken* token; +@property (nonatomic, strong) SparkUser* user; +@property (nonatomic, strong) AFHTTPRequestOperationManager *manager; + +@property (nonatomic, strong) NSMutableDictionary *eventListenersDict; +@end + + +@implementation SparkCloud + +#pragma mark Class initialization and singleton instancing + ++ (instancetype)sharedInstance; +{ + // TODO: no singleton, initializer gets: CloudConnection, CloudEndpoint (URL) to allow private cloud, dependency injection + static SparkCloud *sharedInstance = nil; + @synchronized(self) { + if (sharedInstance == nil) + sharedInstance = [[self alloc] init]; + } + return sharedInstance; +} + +- (id)init +{ + self = [super init]; + if (self) { + self.baseURL = [NSURL URLWithString:kSparkAPIBaseURL]; +// self.loggedIn = NO; + + // try to restore session (user and access token) + self.user = [[SparkUser alloc] initWithSavedSession]; + self.token = [[SparkAccessToken alloc] initWithSavedSession]; + if (self.token) + self.token.delegate = self; + + // Init HTTP manager + self.manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:self.baseURL]; + self.manager.responseSerializer = [AFJSONResponseSerializer serializer]; + [self.manager.requestSerializer setTimeoutInterval:GLOBAL_API_TIMEOUT_INTERVAL]; + + // init event listeners internal dictionary + self.eventListenersDict = [NSMutableDictionary new]; + if (!self.manager) + return nil; + } + return self; +} + + +#pragma mark Getter functions +-(NSString *)accessToken +{ + if (self.token) + return self.token.accessToken; + else + return nil; +} + + +-(NSString *)loggedInUsername +{ + if ((self.user) && (self.token)) + return self.user.user; + else + return nil; +} + +-(BOOL)isLoggedIn +{ + return (self.loggedInUsername != nil); +} + +#pragma mark Delegate functions +-(void)SparkAccessToken:(SparkAccessToken *)accessToken didExpireAt:(NSDate *)date +{ + // handle auto-renewal of expired access tokens by internal timer event + // TODO: fix that to do it using a refresh token and not save the user password! + if (self.user) + { + [self loginWithUser:self.user.user password:self.user.password completion:nil]; + } + else + { + self.token = nil; + } +} + + +#pragma mark SDK public functions +-(void)loginWithUser:(NSString *)user password:(NSString *)password completion:(void (^)(NSError *error))completion +{ + // non default params + NSDictionary *params = @{ + @"grant_type": @"password", + @"username": user, + @"password": password, + }; + +// NSDictionary *OAuthClientCredentialsDict = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"OAuthClientCredentials" ofType:@"plist"]]; +// NSString *clientId = OAuthClientCredentialsDict[@"clientId"]; +// NSString *clientSecret = OAuthClientCredentialsDict[@"clientSecret"]; + + if (!self.OAuthClientId) + self.OAuthClientId = @"particle"; + if (!self.OAuthClientSecret) + self.OAuthClientSecret = @"particle"; + + + [self.manager.requestSerializer setAuthorizationHeaderFieldWithUsername:self.OAuthClientId password:self.OAuthClientSecret]; + // OAuth login + [self.manager POST:@"oauth/token" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) + { + NSDictionary *responseDict = responseObject; + + self.token = [[SparkAccessToken alloc] initWithNewSession:responseDict]; + if (self.token) // login was successful + { + self.token.delegate = self; + self.user = [[SparkUser alloc] initWithUser:user andPassword:password]; + } + + if (completion) + { + completion(nil); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + // check type of error? + if (completion) + completion([NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! loginWithUser %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + }]; + + [self.manager.requestSerializer clearAuthorizationHeader]; +} + + + +-(void)signupWithUser:(NSString *)user password:(NSString *)password completion:(void (^)(NSError *))completion +{ + + // non default params + NSDictionary *params = @{ + @"username": user, + @"password": password, + }; + + [self.manager POST:@"/v1/users" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) + { + NSDictionary *responseDict = responseObject; + if (completion) { + if ([responseDict[@"ok"] boolValue]) + { + completion(nil); + } + else + { + NSString *errorString; + if (responseDict[@"errors"][0]) + errorString = [NSString stringWithFormat:@"Could not sign up: %@",responseDict[@"errors"][0]]; + else + errorString = @"Error signing up"; + completion([self makeErrorWithDescription:errorString code:1004]); + } + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + // check type of error? + if (completion) + completion([NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! signupWithUser %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + }]; + + [self.manager.requestSerializer clearAuthorizationHeader]; +} + + +-(void)signupWithCustomer:(NSString *)email password:(NSString *)password orgSlug:(NSString *)orgSlug completion:(void (^)(NSError *))completion +{ + if ((!orgSlug) || ([orgSlug isEqualToString:@""])) + completion([self makeErrorWithDescription:@"Organization slug must be specified" code:1006]); + + if ((!self.OAuthClientId) || (!self.OAuthClientSecret)) + completion([self makeErrorWithDescription:@"Client OAuth credentials must be set to create a new customer" code:1010]); + + [self.manager.requestSerializer setAuthorizationHeaderFieldWithUsername:self.OAuthClientId password:self.OAuthClientSecret]; + + // non default params + NSMutableDictionary *params = [@{ + @"email": email, + @"password": password, + @"grant_type" : @"client_credentials", + } mutableCopy]; + +// if (inviteCode) +// params[@"activation_code"] = inviteCode; + + NSString *url = [NSString stringWithFormat:@"/v1/orgs/%@/customers",orgSlug]; + NSLog(@"Signing up customer..."); + + [self.manager POST:url parameters:[params copy] success:^(AFHTTPRequestOperation *operation, id responseObject) + { + NSDictionary *responseDict = responseObject; + NSLog(@"Got status code %d, and response: %@",(int)operation.response.statusCode,responseDict); + + self.token = [[SparkAccessToken alloc] initWithNewSession:responseDict]; + if (self.token) // customer login was successful + { + self.token.delegate = self; + self.user = [[SparkUser alloc] initWithUser:email andPassword:password]; // TODO: fix that to refresh token behaviour + } + + if (completion) { + if (operation.response.statusCode == 201) + { + completion(nil); + } + else + { + NSString *errorDesc = ([responseDict[@"error"] stringValue]); // check name of field + completion([self makeErrorWithDescription:errorDesc code:1004]); + } + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + // check type of error? + if (completion) + completion([NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! signupWithCustomer %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + }]; + + [self.manager.requestSerializer clearAuthorizationHeader]; +} + + + + + +-(void)logout +{ + [self.token removeSession]; + [self.user removeSession]; +} + + +-(void)claimDevice:(NSString *)deviceID completion:(void (^)(NSError *))completion +{ + NSString *authorization = [NSString stringWithFormat:@"Bearer %@",self.token.accessToken]; + [self.manager.requestSerializer setValue:authorization forHTTPHeaderField:@"Authorization"]; + + NSMutableDictionary *params = [NSMutableDictionary new]; //[self defaultParams]; + params[@"id"] = deviceID; + [self.manager POST:@"/v1/devices" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) + { + if (completion) + { + NSMutableDictionary *responseDict = responseObject; + + if ([responseDict[@"ok"] boolValue]) + completion(nil); + else + completion([self makeErrorWithDescription:@"Could not claim device" code:1002]); + + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + // check type of error? + if (completion) + completion([NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! claimDevice %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + + }]; + + +} + +-(void)getDevice:(NSString *)deviceID completion:(void (^)(SparkDevice *, NSError *))completion +{ + NSString *authorization = [NSString stringWithFormat:@"Bearer %@",self.token.accessToken]; + [self.manager.requestSerializer setValue:authorization forHTTPHeaderField:@"Authorization"]; + + NSString *urlPath = [NSString stringWithFormat:@"/v1/devices/%@",deviceID]; + [self.manager GET:urlPath parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) + { + if (completion) + { + NSMutableDictionary *responseDict = responseObject; +// responseDict[@"access_token"] = self.accessToken; // add access token + + SparkDevice *device = [[SparkDevice alloc] initWithParams:responseDict]; + if (completion) + completion(device, nil); + + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + // check type of error? + if (completion) + completion(nil, [NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! getDevice %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + + }]; + +} + + +-(void)getDevices:(void (^)(NSArray *sparkDevices, NSError *error))completion +{ + NSString *authorization = [NSString stringWithFormat:@"Bearer %@",self.token.accessToken]; + [self.manager.requestSerializer setValue:authorization forHTTPHeaderField:@"Authorization"]; + + [self.manager GET:@"/v1/devices" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) + { + if (completion) + { + + NSArray *responseList = responseObject; + NSMutableArray *queryDeviceIDList = [[NSMutableArray alloc] init]; + __block NSMutableArray *deviceList = [[NSMutableArray alloc] init]; + __block NSError *deviceError = nil; + // analyze + for (NSDictionary *deviceDict in responseList) + { + if (deviceDict[@"id"]) // ignore device listings that sometimes return from /v1/devices API call + { + if (![deviceDict[@"id"] isKindOfClass:[NSNull class]]) + { + if ([deviceDict[@"connected"] boolValue]==YES) // do inquiry only for online devices (otherwise we waste time on request timeouts and get no new info) + { + // if it's online then add it to the query list so we can get additional information about it + [queryDeviceIDList addObject:deviceDict[@"id"]]; + } + else + { + // if it's offline just make an instance for it with the limited data with have + SparkDevice *device = [[SparkDevice alloc] initWithParams:deviceDict]; + [deviceList addObject:device]; + } + } + + } + } + + // iterate thru deviceList and create SparkDevice instances through query + __block dispatch_group_t group = dispatch_group_create(); + + for (NSString *deviceID in queryDeviceIDList) + { + dispatch_group_enter(group); + [self getDevice:deviceID completion:^(SparkDevice *device, NSError *error) { + if ((!error) && (device)) + [deviceList addObject:device]; + + if ((error) && (!deviceError)) // if there wasn't an error before cache it + deviceError = error; + + dispatch_group_leave(group); + }]; + } + + // call user's completion block on main thread after all concurrent GET requests finished and SparkDevice instances created + dispatch_group_notify(group, dispatch_get_main_queue(), ^{ + if (completion) + { + if (deviceError && (deviceList.count==0)) // empty list? error? report it + completion(nil, deviceError); + else if (deviceList.count > 0) // if some devices reported error but some not, then return at least the ones that didn't report error, ditch error + completion(deviceList, nil); + else + completion(nil, nil); + } + }); + + + + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + // check type of error? + if (completion) + completion(nil, [NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! getDevices %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + }]; +} + + + +-(void)generateClaimCode:(void(^)(NSString *claimCode, NSArray *userClaimedDeviceIDs, NSError *error))completion; +{ + NSString *authorization = [NSString stringWithFormat:@"Bearer %@",self.token.accessToken]; + [self.manager.requestSerializer setValue:authorization forHTTPHeaderField:@"Authorization"]; + + NSString *urlPath = [NSString stringWithFormat:@"/v1/device_claims"]; + [self.manager POST:urlPath parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) + { + if (completion) + { + NSDictionary *responseDict = responseObject; + if (responseDict[@"claim_code"]) + { + NSArray *claimedDeviceIDs = responseDict[@"device_ids"]; + if ((claimedDeviceIDs) && (claimedDeviceIDs.count > 0)) + { + completion(responseDict[@"claim_code"], responseDict[@"device_ids"], nil); + } + else + { + completion(responseDict[@"claim_code"], nil, nil); + } + } + else + { + completion(nil, nil, [self makeErrorWithDescription:@"Could not generate a claim code" code:1005]); //TODO: collect all codes to a table + } + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (completion) + completion(nil, nil, [NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! generateClaimCode %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + }]; + +} + + + +-(void)generateClaimCodeForOrganization:(NSString *)orgSlug andProduct:(NSString *)productSlug withActivationCode:(NSString *)activationCode completion:(void(^)(NSString *claimCode, NSArray *userClaimedDeviceIDs, NSError *error))completion; +{ + NSString *authorization = [NSString stringWithFormat:@"Bearer %@",self.token.accessToken]; + [self.manager.requestSerializer setValue:authorization forHTTPHeaderField:@"Authorization"]; + + + NSDictionary *params; + if (activationCode) + params = @{@"activation_code" : activationCode}; + + + NSString *urlPath = [NSString stringWithFormat:@"/v1/orgs/%@/products/%@/device_claims",orgSlug,productSlug]; + [self.manager POST:urlPath parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) + { + if (completion) + { + NSDictionary *responseDict = responseObject; + if (responseDict[@"claim_code"]) + { + NSArray *claimedDeviceIDs = responseDict[@"device_ids"]; + if ((claimedDeviceIDs) && (claimedDeviceIDs.count > 0)) + { + completion(responseDict[@"claim_code"], responseDict[@"device_ids"], nil); + } + else + { + completion(responseDict[@"claim_code"], nil, nil); + } + } + else + { + completion(nil, nil, [self makeErrorWithDescription:@"Could not generate a claim code" code:1007]); + } + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! generateClaimCodeForOrganization %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + + if (completion) + completion(nil, nil, [NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + }]; + +} + + + + +//-(void)requestPasswordReset:(NSString *)email completion:(void (^)(NSError *))completion +-(void)requestPasswordResetForCustomer:(NSString *)orgSlug email:(NSString *)email completion:(void (^)(NSError *))completion +{ + NSDictionary *params = @{@"email": email}; + NSString *urlPath = [NSString stringWithFormat:@"/v1/orgs/%@/customers/reset_password",orgSlug]; + + [self.manager POST:urlPath parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) + { + if (completion) // TODO: check responses + { + completion(nil); + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (completion) + { + // make error have the HTTP response status code + // TODO: for all + completion([NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + } + + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! requestPasswordReset %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + }]; + +} + + +-(void)requestPasswordResetForUser:(NSString *)email completion:(void (^)(NSError *))completion +{ + NSDictionary *params = @{@"email": email}; + NSString *urlPath = [NSString stringWithFormat:@"/v1/user/password-reset"]; + + [self.manager POST:urlPath parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) + { + if (completion) // TODO: check responses + { + completion(nil); + } + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (completion) + { + // make error have the HTTP response status code + // TODO: for all + completion([NSError errorWithDomain:error.domain code:operation.response.statusCode userInfo:error.userInfo]); + } + + NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey]; + if (errorData) + { + + NSDictionary *serializedFailedBody = [NSJSONSerialization JSONObjectWithData:errorData options:kNilOptions error:nil]; + NSLog(@"! requestPasswordResetForUser %@ Failed (status code %d): %@",operation.request.URL,(int)operation.response.statusCode,serializedFailedBody); + } + }]; + +} + + + + + + +#pragma mark Internal use methods +-(void)listTokens:(NSString *)user password:(NSString *)password +{ + [self.manager.requestSerializer setAuthorizationHeaderFieldWithUsername:user password:password]; + + [self.manager GET:@"/v1/access_tokens" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSArray *responseArr = responseObject; + NSLog(@"(debug) listTokens:\n%@",[responseArr description]); + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + // + NSLog(@"listTokens %@",[error localizedDescription]); + }]; + [self.manager.requestSerializer clearAuthorizationHeader]; + +} + +/* +- (NSMutableDictionary *)defaultParams +{ + // Access token in HTTP body + if (self.token) + return [@{@"access_token": self.token.accessToken} mutableCopy]; + else + return nil; +} +*/ + +-(NSError *)makeErrorWithDescription:(NSString *)desc code:(NSInteger)errorCode +{ + + NSMutableDictionary *errorDetail = [NSMutableDictionary dictionary]; + [errorDetail setValue:desc forKey:NSLocalizedDescriptionKey]; + return [NSError errorWithDomain:@"SparkAPIError" code:errorCode userInfo:errorDetail]; +} + + + +#pragma mark Events subsystem implementation +-(id)subscribeToEventWithURL:(NSURL *)url handler:(SparkEventHandler)eventHandler +{ + if (!self.accessToken) + { + eventHandler(nil, [self makeErrorWithDescription:@"No active access token" code:1008]); + return nil; + } + + // TODO: add eventHandler + source to an internal dictionary so it will be removeable later by calling removeEventListener on saved Source + EventSource *source = [EventSource eventSourceWithURL:url timeoutInterval:30.0f queue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0) accessToken:self.accessToken]; + + // if (eventName == nil) + // eventName = @"no_name"; + + // - event example - + // event: Temp + // data: {"data":"Temp1 is 41.900002 F, Temp2 is $f F","ttl":"60","published_at":"2015-01-13T01:23:12.269Z","coreid":"53ff6e066667574824151267"} + + // [source addEventListener:@"" handler:^(Event *event) { //event name +// [source onMessage: + + EventSourceEventHandler handler = ^void(Event *event) { + if (eventHandler) + { + if (event.error) + eventHandler(nil, event.error); + else + { + // deserialize event payload into dictionary + NSError *error; + NSDictionary *jsonDict; + NSMutableDictionary *eventDict; + if (event.data) + { + jsonDict = [NSJSONSerialization JSONObjectWithData:event.data options:0 error:&error]; + eventDict = [jsonDict mutableCopy]; + } + + if ((eventDict) && (!error)) + { + if (event.name) + { + eventDict[@"event"] = event.name; // add event name to dict + } + SparkEvent *sparkEvent = [[SparkEvent alloc] initWithEventDict:eventDict]; + eventHandler(sparkEvent ,nil); // callback with parsed data + } + else if (error) + { + eventHandler(nil, error); + } + } + } + + }; + + [source onMessage:handler]; // bind the handler + + id eventListenerID = [NSUUID UUID]; // create the eventListenerID + self.eventListenersDict[eventListenerID] = @{kEventListenersDictHandlerKey : handler, + kEventListenersDictEventSourceKey : source}; // save it in the internal dictionary for future unsubscribing + + return eventListenerID; + +} + + +-(void)unsubscribeFromEventWithID:(id)eventListenerID +{ + NSDictionary *eventListenerDict = [self.eventListenersDict objectForKey:eventListenerID]; + if (eventListenerDict) + { + EventSource *source = [eventListenerDict objectForKey:kEventListenersDictEventSourceKey]; + EventSourceEventHandler handler = [eventListenerDict objectForKey:kEventListenersDictHandlerKey]; + [source removeEventListener:MessageEvent handler:handler]; + [self.eventListenersDict removeObjectForKey:eventListenerID]; + } +} + + +-(id)subscribeToAllEventsWithPrefix:(NSString *)eventNamePrefix handler:(SparkEventHandler)eventHandler +{ + // GET /v1/events[/:event_name] + NSString *endpoint; + if ((!eventNamePrefix) || [eventNamePrefix isEqualToString:@""]) + { + endpoint = [NSString stringWithFormat:@"%@/v1/events", self.baseURL]; + } + else + { + endpoint = [NSString stringWithFormat:@"%@/v1/events/%@", self.baseURL, eventNamePrefix]; + } + + return [self subscribeToEventWithURL:[NSURL URLWithString:endpoint] handler:eventHandler]; +} + + +-(id)subscribeToMyDevicesEventsWithPrefix:(NSString *)eventNamePrefix handler:(SparkEventHandler)eventHandler +{ + // GET /v1/devices/events[/:event_name] + NSString *endpoint; + if ((!eventNamePrefix) || [eventNamePrefix isEqualToString:@""]) + { + // TODO: check + endpoint = [NSString stringWithFormat:@"%@/v1/devices/events", self.baseURL]; + } + else + { + endpoint = [NSString stringWithFormat:@"%@/v1/devices/events/%@", self.baseURL, eventNamePrefix]; + } + + return [self subscribeToEventWithURL:[NSURL URLWithString:endpoint] handler:eventHandler]; + +} + +-(id)subscribeToDeviceEventsWithPrefix:(NSString *)eventNamePrefix deviceID:(NSString *)deviceID handler:(SparkEventHandler)eventHandler +{ + // GET /v1/devices/:device_id/events[/:event_name] + NSString *endpoint; + if ((!eventNamePrefix) || [eventNamePrefix isEqualToString:@""]) + { + // TODO: check + endpoint = [NSString stringWithFormat:@"%@/v1/devices/%@/events", self.baseURL,deviceID]; + } + else + { + endpoint = [NSString stringWithFormat:@"%@/v1/devices/%@/events/%@", self.baseURL, deviceID, eventNamePrefix]; + } + + return [self subscribeToEventWithURL:[NSURL URLWithString:endpoint] handler:eventHandler]; +} + + + +-(void)publishEventWithName:(NSString *)eventName data:(NSString *)data isPrivate:(BOOL)isPrivate ttl:(NSUInteger)ttl completion:(void (^)(NSError *))completion +{ + NSMutableDictionary *params = [NSMutableDictionary new]; + NSString *authorization = [NSString stringWithFormat:@"Bearer %@",self.token.accessToken]; + [self.manager.requestSerializer setValue:authorization forHTTPHeaderField:@"Authorization"]; + + params[@"name"]=eventName; + params[@"data"]=data; + if (isPrivate) + params[@"private"]=@"true"; + else + params[@"private"]=@"false"; // TODO: check if needed + + params[@"ttl"] = [NSString stringWithFormat:@"%lu", (unsigned long)ttl]; + + [self.manager POST:@"/v1/devices/events" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + if (completion) + { + // TODO: check server response for that + NSDictionary *responseDict = responseObject; + if ([responseDict[@"ok"] boolValue]==NO) + { + NSError *err = [self makeErrorWithDescription:@"Server reported error publishing event" code:1009]; + completion(err); + } + else + { + completion(nil); + } + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) + { + if (completion) + completion(error); + }]; + + + +} + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkDevice.h b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkDevice.h new file mode 100644 index 0000000..ea84cc8 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkDevice.h @@ -0,0 +1,159 @@ +// +// SparkDevice.h +// Particle iOS Cloud SDK +// +// Created by Ido Kleinman +// Copyright 2015 Particle +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import +#import "SparkEvent.h" + +typedef NS_ENUM(NSInteger, SparkDeviceType) { + SparkDeviceTypeCore=0, + SparkDeviceTypePhoton=6, + SparkDeviceTypeElectron=10, +}; + +@interface SparkDevice : NSObject + +/** + * DeviceID string + */ +@property (strong, nonatomic, readonly) NSString* id; +/** + * Device name. Device can be renamed in the cloud by setting this property. If renaming fails name will stay the same. + */ +@property (strong, nonatomic) NSString* name; +/** + * Is device connected to the cloud? + */ +@property (nonatomic, readonly) BOOL connected; +/** + * List of function names exposed by device + */ +@property (strong, nonatomic, readonly) NSArray *functions; +/** + * Dictionary of exposed variables on device with their respective types. + */ +@property (strong, nonatomic, readonly) NSDictionary *variables; // @{varName : varType, ...} + +@property (strong, nonatomic, readonly) NSString *lastApp; + +@property (strong, nonatomic, readonly) NSDate *lastHeard; + +@property (nonatomic) BOOL isFlashing; + + +/** + * Device firmware version string + */ +@property (strong, nonatomic, readonly) NSString *version; +@property (nonatomic, readonly) BOOL requiresUpdate; +@property (nonatomic, readonly) SparkDeviceType type; // inactive for now + +-(instancetype)initWithParams:(NSDictionary *)params NS_DESIGNATED_INITIALIZER; +-(instancetype)init __attribute__((unavailable("Must use initWithParams:"))); + +/** + * Retrieve a variable value from the device + * + * @param variableName Variable name + * @param completion Completion block to be called when function completes with the variable value retrieved (as id/AnyObject) or NSError object in case on an error + */ +-(void)getVariable:(NSString *)variableName completion:(void(^)(id result, NSError* error))completion; + +/** + * Call a function on the device + * + * @param functionName Function name + * @param args Array of arguments to pass to the function on the device. Arguments will be converted to string maximum length 63 chars. + * @param completion Completion block will be called when function was invoked on device. First argument of block is the integer return value of the function, second is NSError object in case of an error invoking the function + */ +-(void)callFunction:(NSString *)functionName withArguments:(NSArray *)args completion:(void (^)(NSNumber *, NSError *))completion; + +/* +-(void)addEventHandler:(NSString *)eventName handler:(void(^)(void))handler; +-(void)removeEventHandler:(NSString *)eventName; + */ + + +/** + * Request device refresh from cloud + * update online status/functions/variables/device name, etc + * + * @param completion Completion block called when function completes with NSError object in case of an error or nil if success. + * + */ +-(void)refresh:(void(^)(NSError* error))completion; + +/** + * Remove device from current logged in user account + * + * @param completion Completion block called when function completes with NSError object in case of an error or nil if success. + */ +-(void)unclaim:(void(^)(NSError* error))completion; + +/* +-(void)compileAndFlash:(NSString *)sourceCode completion:(void(^)(NSError* error))completion; +-(void)flash:(NSData *)binary completion:(void(^)(NSError* error))completion; +*/ + +/** + * Rename device + * + * @param newName New device name + * @param completion Completion block called when function completes with NSError object in case of an error or nil if success. + */ +-(void)rename:(NSString *)newName completion:(void(^)(NSError* error))completion; + +/** + * Flash files to device + * + * @param filesDict files dictionary in the following format: @{@"filename.bin" : , ...} - that is a NSString filename as key and NSData blob as value. More than one file can be flashed. Data is alway binary. + * @param completion Completion block called when function completes with NSError object in case of an error or nil if success. NSError.localized descripion will contain a detailed error report in case of a + */ +-(void)flashFiles:(NSDictionary *)filesDict completion:(void(^)(NSError* error))completion; //@{@"" : NSData, ...} + +/** + * Flash known firmware images to device + * + * @param knownAppName NSString of known app name. Currently @"tinker" is supported. + * @param completion Completion block called when function completes with NSError object in case of an error or nil if success. NSError.localized descripion will contain a detailed error report in case of a + */ +-(void)flashKnownApp:(NSString *)knownAppName completion:(void (^)(NSError *))completion; // knownAppName = @"tinker", @"blinky", ... see http://docs. + +//-(void)compileAndFlashFiles:(NSDictionary *)filesDict completion:(void(^)(NSError* error))completion; //@{@"" : @""} +//-(void)complileFiles:(NSDictionary *)filesDict completion:(void(^)(NSData *resultBinary, NSError* error))completion; //@{@"" : @""} + +// -------------------------------------------------------------------------------------------------------------------------------------------------------- +// Events subsystem: +// -------------------------------------------------------------------------------------------------------------------------------------------------------- + +/** + * Subscribe to events from this specific (claimed) device - both public and private. + * + * @param eventNamePrefix Filter only events that match name eventNamePrefix, for exact match pass whole string, if nil/empty string is passed any event will trigger eventHandler + * @param eventHandler Event handler function that accepts the event payload dictionary and an NSError object in case of an error + */ +-(id)subscribeToEventsWithPrefix:(NSString *)eventNamePrefix handler:(SparkEventHandler)eventHandler; + +/** + * Unsubscribe from event/events. + * + * @param eventListenerID The eventListener registration unique ID returned by the subscribe method which you want to cancel + */ +-(void)unsubscribeFromEventWithID:(id)eventListenerID; + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkDevice.m b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkDevice.m new file mode 100644 index 0000000..49a7eae --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkDevice.m @@ -0,0 +1,474 @@ +// +// SparkDevice.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/7/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkDevice.h" +#import "SparkCloud.h" +#import +#import + +#define MAX_SPARK_FUNCTION_ARG_LENGTH 63 + +@interface SparkDevice() +@property (strong, nonatomic) NSString* id; +@property (nonatomic) BOOL connected; // might be impossible +@property (strong, nonatomic) NSArray *functions; +@property (strong, nonatomic) NSDictionary *variables; +@property (strong, nonatomic) NSString *version; +//@property (nonatomic) SparkDeviceType type; +@property (nonatomic) BOOL requiresUpdate; +@property (nonatomic, strong) AFHTTPRequestOperationManager *manager; +@property (atomic) NSInteger flashingTimeLeft; +@property (nonatomic, strong) NSTimer *flashingTimer; +@property (nonatomic, strong) NSURL *baseURL; +@end + +@implementation SparkDevice + +-(instancetype)initWithParams:(NSDictionary *)params +{ + if (self = [super init]) + { + self.baseURL = [NSURL URLWithString:kSparkAPIBaseURL]; + + self.requiresUpdate = NO; + + if (![params[@"name"] isKindOfClass:[NSNull class]]) + if (params[@"name"]) + _name = params[@"name"]; + else _name = nil; + else _name = nil; + + if ([params[@"connected"] boolValue]==YES) + self.connected = YES; + else + self.connected = NO; + + if (params[@"functions"]) + self.functions = params[@"functions"]; + + if (params[@"variables"]) + self.variables = params[@"variables"]; + + _id = params[@"id"]; + + _type = SparkDeviceTypePhoton; + if (![params[@"product_id"] isKindOfClass:[NSNull class]]) + { + if (params[@"product_id"]) + { + if ([params[@"product_id"] intValue]==SparkDeviceTypeCore) + _type = SparkDeviceTypeCore; + if ([params[@"product_id"] intValue]==SparkDeviceTypeElectron) + _type = SparkDeviceTypeElectron; + + } + } + + + + if (![params[@"last_app"] isKindOfClass:[NSNull class]]) + if (params[@"last_app"]) + _lastApp = params[@"last_app"]; + + if (![params[@"last_heard"] isKindOfClass:[NSNull class]]) + { + if (params[@"last_heard"]) + { + // TODO: add to utils class as POSIX time to NSDate + NSString *dateString = params[@"last_heard"];// "2015-04-18T08:42:22.127Z" + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; + NSLocale *posix = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; + [formatter setLocale:posix]; + _lastHeard = [formatter dateFromString:dateString]; + } + } + + /* + // Inactive for now // TODO: re-enable when we can distinguish devices in the cloud + if (params[@"cc3000_patch_version"]) // check for other version indication strings - ask doc + { + self.type = SparkDeviceTypeCore; + self.version = (params[@"cc3000_patch_version"]); + } + */ + + if (params[@"device_needs_update"]) + { + self.requiresUpdate = YES; + } + + + + self.manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:self.baseURL]; + self.manager.responseSerializer = [AFJSONResponseSerializer serializer]; + + if (!self.manager) return nil; + + return self; + } + + return nil; +} + + +-(void)refresh:(void(^)(NSError* error))completion; +{ + [[SparkCloud sharedInstance] getDevice:self.id completion:^(SparkDevice *updatedDevice, NSError *error) { + if (!error) + { + if (updatedDevice) + { + // if we got an updated device from the cloud - overwrite ALL self's properies with the new device properties + NSMutableSet *propNames = [NSMutableSet set]; + unsigned int outCount, i; + objc_property_t *properties = class_copyPropertyList([updatedDevice class], &outCount); + for (i = 0; i < outCount; i++) { + objc_property_t property = properties[i]; + NSString *propertyName = [[NSString alloc] initWithCString:property_getName(property) encoding:NSStringEncodingConversionAllowLossy]; + [propNames addObject:propertyName]; + } + free(properties); + + for (NSString *property in propNames) + { + id value = [updatedDevice valueForKey:property]; + [self setValue:value forKey:property]; + } + } + if (completion) + completion(nil); + } + else + { + if (completion) + completion(error); + } + }]; +} + +-(void)setName:(NSString *)name +{ + [self rename:name completion:nil]; +} + +-(void)getVariable:(NSString *)variableName completion:(void(^)(id result, NSError* error))completion +{ + // TODO: check variable name exists in list + NSURL *url = [self.baseURL URLByAppendingPathComponent:[NSString stringWithFormat:@"v1/devices/%@/%@", self.id, variableName]]; + // TODO: check response of calling a non existant function + + [self setAuthHeaderWithAccessToken]; + + [self.manager GET:[url description] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + if (completion) + { + NSDictionary *responseDict = responseObject; + if ([responseDict[@"coreInfo"][@"connected"] boolValue]==NO) // check response + { + NSError *err = [self makeErrorWithDescription:@"Device is not connected" code:1001]; + completion(nil,err); + } + else + { + // check + completion(responseDict[@"result"],nil); + } + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) + { + if (completion) + completion(nil,error); + }]; + + +} + +-(void)callFunction:(NSString *)functionName withArguments:(NSArray *)args completion:(void (^)(NSNumber *, NSError *))completion +{ + // TODO: check function name exists in list + NSURL *url = [self.baseURL URLByAppendingPathComponent:[NSString stringWithFormat:@"v1/devices/%@/%@", self.id, functionName]]; + NSMutableDictionary *params = [NSMutableDictionary new]; //[self defaultParams]; + // TODO: check response of calling a non existant function + + if (args) { + NSMutableArray *argsStr = [[NSMutableArray alloc] initWithCapacity:args.count]; + for (id arg in args) + { + [argsStr addObject:[arg description]]; + } + NSString *argsValue = [argsStr componentsJoinedByString:@","]; + if (argsValue.length > MAX_SPARK_FUNCTION_ARG_LENGTH) + { + // TODO: arrange user error/codes in a list + NSError *err = [self makeErrorWithDescription:[NSString stringWithFormat:@"Maximum argument length cannot exceed %d",MAX_SPARK_FUNCTION_ARG_LENGTH] code:1000]; + if (completion) + completion(nil,err); + return; + } + + params[@"args"] = argsValue; + } + + [self setAuthHeaderWithAccessToken]; + + [self.manager POST:[url description] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + if (completion) + { + NSDictionary *responseDict = responseObject; + if ([responseDict[@"connected"] boolValue]==NO) + { + NSError *err = [self makeErrorWithDescription:@"Device is not connected" code:1001]; + completion(nil,err); + } + else + { + // check + NSNumber *result = responseDict[@"return_value"]; + completion(result,nil); + } + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) + { + if (completion) + completion(nil,error); + }]; + +} + + + +-(void)unclaim:(void (^)(NSError *))completion +{ + + NSURL *url = [self.baseURL URLByAppendingPathComponent:[NSString stringWithFormat:@"v1/devices/%@", self.id]]; + +// NSMutableDictionary *params = [self defaultParams]; +// params[@"id"] = self.id; + [self setAuthHeaderWithAccessToken]; + + [self.manager DELETE:[url description] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { + if (completion) + { + NSDictionary *responseDict = responseObject; + if ([responseDict[@"ok"] boolValue]) + completion(nil); + else + completion([self makeErrorWithDescription:@"Could not unclaim device" code:1003]); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) + { + if (completion) + completion(error); + }]; + + +} + +-(void)rename:(NSString *)newName completion:(void(^)(NSError* error))completion +{ + NSURL *url = [self.baseURL URLByAppendingPathComponent:[NSString stringWithFormat:@"v1/devices/%@", self.id]]; + + // TODO: check name validity before calling API + NSMutableDictionary *params = [NSMutableDictionary new];// [self defaultParams]; + params[@"name"] = newName; + [self setAuthHeaderWithAccessToken]; + + + [self.manager PUT:[url description] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + _name = newName; + if (completion) + { + completion(nil); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) + { + if (completion) // TODO: better erroring handling + completion(error); + }]; + + + +} + + + +#pragma mark Internal use methods +- (NSMutableDictionary *)defaultParams +{ + // TODO: change access token to be passed in header not in body + if ([SparkCloud sharedInstance].accessToken) + { + return [@{@"access_token" : [SparkCloud sharedInstance].accessToken} mutableCopy]; + } + else return nil; +} + +-(void)setAuthHeaderWithAccessToken +{ + NSString *authorization = [NSString stringWithFormat:@"Bearer %@",[SparkCloud sharedInstance].accessToken]; + [self.manager.requestSerializer setValue:authorization forHTTPHeaderField:@"Authorization"]; +} + + +-(NSError *)makeErrorWithDescription:(NSString *)desc code:(NSInteger)errorCode +{ + + NSMutableDictionary *errorDetail = [NSMutableDictionary dictionary]; + [errorDetail setValue:desc forKey:NSLocalizedDescriptionKey]; + return [NSError errorWithDomain:@"SparkAPIError" code:errorCode userInfo:errorDetail]; +} + + + +-(NSString *)description +{ + NSString *desc = [NSString stringWithFormat:@"", + (unsigned long)self, + (self.type == SparkDeviceTypeCore) ? @"Core" : @"Photon", + self.id, + self.name, + (self.connected) ? @"true" : @"false", + self.variables, + self.functions, + self.version, + (self.requiresUpdate) ? @"true" : @"false", + self.lastApp, + self.lastHeard]; + + return desc; + +} + + +-(void)flashKnownApp:(NSString *)knownAppName completion:(void (^)(NSError *))completion +{ + NSURL *url = [self.baseURL URLByAppendingPathComponent:[NSString stringWithFormat:@"v1/devices/%@", self.id]]; + + NSMutableDictionary *params = [NSMutableDictionary new]; + params[@"app"] = knownAppName; + [self setAuthHeaderWithAccessToken]; + + [self.manager PUT:[url description] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSDictionary *responseDict = responseObject; + if (responseDict[@"errors"]) + { + if (completion) completion([self makeErrorWithDescription:responseDict[@"errors"][@"error"] code:1005]); + } + else + if (completion) completion(nil); + + } failure:^(AFHTTPRequestOperation *operation, NSError *error) + { + if (completion) // TODO: better erroring handling + completion(error); + }]; + + +} + + +-(void)flashFiles:(NSDictionary *)filesDict completion:(void (^)(NSError *))completion // binary +{ + NSURL *url = [self.baseURL URLByAppendingPathComponent:[NSString stringWithFormat:@"v1/devices/%@", self.id]]; + + [self setAuthHeaderWithAccessToken]; + + NSError *reqError; + NSMutableURLRequest *request = [self.manager.requestSerializer multipartFormRequestWithMethod:@"PUT" URLString:url.description parameters:@{@"file_type" : @"binary"} constructingBodyWithBlock:^(id formData) { + // check this: + for (NSString *key in filesDict.allKeys) + { +// [formData appendPartWithFormData:filesDict[key] name:key]; + [formData appendPartWithFileData:filesDict[key] name:@"file" fileName:key mimeType:@"application/octet-stream"]; + } + } error:&reqError]; + + + + if (!reqError) + { + AFHTTPRequestOperation *operation = [self.manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { + NSDictionary *responseDict = responseObject; +// NSLog(@"flashFiles: %@",responseDict.description); + if (responseDict[@"error"]) + { + if (completion) + { + completion([self makeErrorWithDescription:responseDict[@"error"] code:1004]); + } + } + else if (completion) + { + completion(nil); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (completion) // TODO: better erroring handling + completion(error); + }]; + + [self.manager.operationQueue addOperation:operation]; + + } + else + { + if (completion) + completion(reqError); + } + + +} + + + +-(void)flashingTimeLeftTimerFunc:(NSTimer *)timer +{ + if (self.flashingTimeLeft > 0) + { + self.flashingTimeLeft -= 1; +// NSLog(@"flashingTimeLeft (0x%lx): %ld",self,(long)self.flashingTimeLeft); + } + else + { + [timer invalidate]; + } +} + +-(BOOL)isFlashing +{ +// NSLog(@"isFlashing (0x%lx): %ld",self,(long)self.flashingTimeLeft); + return (self.flashingTimeLeft > 0); +} + +-(void)setIsFlashing:(BOOL)isFlashing +{ + // TODO: convert this to be working with a subscribe to start flash/end flash event instead of a dumb timer + if (isFlashing) + { + self.flashingTimeLeft = (self.type == SparkDeviceTypePhoton) ? 15 : 30; + self.flashingTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(flashingTimeLeftTimerFunc:) userInfo:nil repeats:YES]; + } + else + { + self.flashingTimeLeft = 0; + } +} + + +-(id)subscribeToEventsWithPrefix:(NSString *)eventNamePrefix handler:(SparkEventHandler)eventHandler +{ + return [[SparkCloud sharedInstance] subscribeToDeviceEventsWithPrefix:eventNamePrefix deviceID:self.id handler:eventHandler]; +} + +-(void)unsubscribeFromEventWithID:(id)eventListenerID +{ + [[SparkCloud sharedInstance] unsubscribeFromEventWithID:eventListenerID]; +} + + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkEvent.h b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkEvent.h new file mode 100644 index 0000000..6df8ee7 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkEvent.h @@ -0,0 +1,30 @@ +// +// SparkEvent.h +// Pods +// +// Created by Ido on 7/14/15. +// +// + +#import +/** + * Spark event handler function which receives two arguements + * + * @param eventDict NSDictionary argument which contains the event payload keys: event (name), data (payload), ttl (time to live), published_at (date/time published), coreid (publishiing device ID). + * @param error NSError object in case an error occured in parsing the event payload or receiving it + */ +@class SparkEvent; + +typedef void (^SparkEventHandler)(SparkEvent *event, NSError *error); + +@interface SparkEvent : NSObject + +@property (nonatomic, strong) NSString *deviceID; // Event published by this device ID +@property (nonatomic, strong) NSString *data; // Event string payload +@property (nonatomic, strong) NSString *event; // Event name +@property (nonatomic, strong) NSDate *time; // Event "published at" time/dat +@property (nonatomic) NSInteger ttl; // Event time to live + +-(instancetype)initWithEventDict:(NSDictionary *)eventDict; + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkEvent.m b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkEvent.m new file mode 100644 index 0000000..1c307e3 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkEvent.m @@ -0,0 +1,39 @@ +// +// SparkEvent.m +// Pods +// +// Created by Ido on 7/14/15. +// +// + +#import "SparkEvent.h" + +@implementation SparkEvent +-(instancetype)initWithEventDict:(NSDictionary *)eventDict +{ + if (self = [super init]) + { + + self.deviceID = eventDict[@"coreid"]; + self.data = eventDict[@"data"]; + self.event = eventDict[@"event"]; + NSString *ttl = eventDict[@"ttl"]; + self.ttl = [ttl integerValue]; + + NSString *dateString = eventDict[@"published_at"];// "2015-04-18T08:42:22.127Z" + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; + NSLocale *posix = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; + [formatter setLocale:posix]; + self.time = [formatter dateFromString:dateString]; + } + + return self; + +} + +-(NSString *)description +{ + return [NSString stringWithFormat:@"",self.event,self.deviceID,self.data,self.time,(long)self.ttl]; +} +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkUser.h b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkUser.h new file mode 100644 index 0000000..5d303d6 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkUser.h @@ -0,0 +1,57 @@ +// +// SparkUser.h +// Particle iOS Cloud SDK +// +// Created by Ido Kleinman +// Copyright 2015 Particle +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +@interface SparkUser : NSObject +/** + * User name, should be a valid email address + */ +@property (nonatomic, strong, readonly) NSString *user; + +/** + * Password string + */ +@property (nonatomic, strong, readonly) NSString *password; + +/** + * Initialize SparkUser class with new credentials and store session in keychain + * + * @param user New username credential + * @param password New password credential + * + * @return SparkUser instance + */ +-(instancetype)initWithUser:(NSString *)user andPassword:(NSString *)password; + +/** + * Try to initialize a SparkUser class with stored keychain session + * + * @return SparkUser instance if successfully retrieved session from keychain, nil if failed + */ +-(instancetype)initWithSavedSession; + +-(instancetype)init __attribute__((unavailable("Must use -initWithUser: or -initWithSavedSession:"))); + +/** + * Remove user credentials session data from keychain + */ +-(void)removeSession; + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkUser.m b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkUser.m new file mode 100644 index 0000000..e4023b5 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/SDK/SparkUser.m @@ -0,0 +1,70 @@ +// +// SparkUser.m +// teacup-ios-app +// +// Created by Ido Kleinman on 1/9/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkUser.h" +#import "KeychainItemWrapper.h" + +NSString *const kSparkCredentialsKeychainEntry = @"io.spark.api.Keychain.Credentials"; + + +@interface SparkUser() +@property (nonatomic, strong) NSString *user; +@property (nonatomic, strong) NSString *password; +@end + +@implementation SparkUser + +-(instancetype)initWithSavedSession +{ + if (self = [super init]) + { + KeychainItemWrapper *keychainCredentialsItem = [[KeychainItemWrapper alloc] initWithIdentifier:kSparkCredentialsKeychainEntry accessGroup:nil]; + self.password = [[NSString alloc] initWithData:[keychainCredentialsItem objectForKey:(__bridge id)(kSecValueData)] encoding:NSUTF8StringEncoding]; + self.user = [keychainCredentialsItem objectForKey:(__bridge id)(kSecAttrAccount)]; + + if ((!self.user) || ([self.user isEqualToString:@""])) + return nil; + + if ((!self.password) || ([self.password isEqualToString:@""])) + return nil; + + return self; + } + return nil; +} + + + +-(instancetype)initWithUser:(NSString *)user andPassword:(NSString *)password +{ + if (self = [super init]) + { + self.user = user; + self.password = password; + + KeychainItemWrapper *keychainCredentialsItem = [[KeychainItemWrapper alloc] initWithIdentifier:kSparkCredentialsKeychainEntry accessGroup:nil]; + [keychainCredentialsItem setObject:user forKey:(__bridge id)(kSecAttrAccount)]; + [keychainCredentialsItem setObject:password forKey:(__bridge id)(kSecValueData)]; // TODO: debug why this crashes sometimes + + return self; + } + + return nil; +} + + +-(void)removeSession +{ + // remove user + KeychainItemWrapper *keychainCredentialsItem = [[KeychainItemWrapper alloc] initWithIdentifier:kSparkCredentialsKeychainEntry accessGroup:nil]; + [keychainCredentialsItem resetKeychainItem]; + self.user = nil; + self.password = nil; +} + +@end diff --git a/Strike/Pods/Spark-SDK/Pod/Classes/Spark-SDK.h b/Strike/Pods/Spark-SDK/Pod/Classes/Spark-SDK.h new file mode 100644 index 0000000..1f8bb75 --- /dev/null +++ b/Strike/Pods/Spark-SDK/Pod/Classes/Spark-SDK.h @@ -0,0 +1,30 @@ +// +// Spark-SDK.h +// Particle iOS Cloud SDK +// +// Created by Ido Kleinman +// Copyright 2015 Particle +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#import + +#ifndef Pods_Spark_SDK_h +#define Pods_Spark_SDK_h + +#import "SparkCloud.h" +#import "SparkDevice.h" + +#endif + + diff --git a/Strike/Pods/Spark-SDK/README.md b/Strike/Pods/Spark-SDK/README.md new file mode 100644 index 0000000..fc989db --- /dev/null +++ b/Strike/Pods/Spark-SDK/README.md @@ -0,0 +1,414 @@ +

+Particle +

+# Particle iOS Cloud SDK +[![Build Status](https://api.travis-ci.org/spark/spark-sdk-ios.svg)](https://travis-ci.org/spark/spark-sdk-ios) [![license](https://img.shields.io/hexpm/l/plug.svg)](https://github.com/spark/spark-sdk-ios/blob/master/LICENSE) [![version](https://img.shields.io/badge/cocoapods-0.3.0-green.svg)](https://github.com/spark/spark-sdk-ios/blob/master/CHANGELOG.md) + +Particle iOS Cloud SDK enables iOS apps to interact with Particle-powered connected products via the Particle Cloud. It’s an easy-to-use wrapper for Particle REST API. The Cloud SDK will allow you to: + +- Manage user sessions for the Particle Cloud (access tokens, encrypted session management) +- Claim/Unclaim devices for a user account +- Get a list of instances of user's Particle devices +- Read variables from devices +- Invoke functions on devices +- Publish events from the mobile app and subscribe to events coming from devices *(New!)* + +All cloud operations take place asynchronously and use the well-known completion blocks (closures for swift) design pattern for reporting results allowing you to build beautiful responsive apps for your Particle products and projects. +iOS Cloud SDK is implemented as an open-source Cocoapod library. See [Installation](#installation) section for more details. It works well for both Objective-C and [Swift](#support-for-swift-projects) projects. + +**Rebranding notice** + +Spark has been recently rebranded as Particle. +Code currently refers to `SparkCloud` and `SparkDevice`, this will soon be replaced with `ParticleCloud` and `ParticleDevice`. A new Cocoapod library will be published and current one will be deprecated and point to the new one. This should not bother or affect your code. + +**Beta notice** + +This SDK is still under development and is currently released as Beta. Although tested, bugs and issues may be present. Some code might require cleanup. In addition, until version 1.0 is released, we cannot guarantee that API calls will not break from one Cloud SDK version to the next. Be sure to consult the [Change Log](https://github.com/spark/spark-sdk-ios/blob/master/CHANGELOG.md) for any breaking changes / additions to the SDK. + +## Getting Started + +- Perform the installation step described under the **Installation** section below for integrating in your own project +- You can also [Download Particle iOS Cloud SDK](https://github.com/spark/spark-sdk-ios/archive/master.zip) and try out the included iOS example app +- Be sure to check [Usage](#usage) before you begin for some code examples + +## Usage + +Cloud SDK usage involves two basic classes: first is `SparkCloud` which is a singleton object that enables all basic cloud operations such as user authentication, device listing, claiming etc. Second class is `SparkDevice` which is an instance representing a claimed device in the current user session. Each object enables device-specific operation such as: getting its info, invoking functions and reading variables from it. + +### Common tasks + +Here are few examples for the most common use cases to get your started: + +#### Logging in to Particle cloud +You don't need to worry about access tokens, SDK takes care of that for you + +**Objective-C** +```objc +[[SparkCloud sharedInstance] loginWithUser:@"ido@particle.io" password:@"userpass" completion:^(NSError *error) { + if (!error) + NSLog(@"Logged in to cloud"); + else + NSLog(@"Wrong credentials or no internet connectivity, please try again"); +}]; +``` +**Swift** +```swift +SparkCloud.sharedInstance().loginWithUser("ido@particle.io", password: "userpass") { (error:NSError!) -> Void in + if let e=error { + println("Wrong credentials or no internet connectivity, please try again") + } + else { + println("Logged in") + } +} +``` + +#### Get a list of all devices +List the devices that belong to currently logged in user and find a specific device by name: + +**Objective-C** + +```objc +__block SparkDevice *myPhoton; +[[SparkCloud sharedInstance] getDevices:^(NSArray *sparkDevices, NSError *error) { + NSLog(@"%@",sparkDevices.description); // print all devices claimed to user + + for (SparkDevice *device in sparkDevices) + { + if ([device.name isEqualToString:@"myNewPhotonName"]) + myPhoton = device; + } +}]; +``` + +**Swift** + +```swift +var myPhoton : SparkDevice? +SparkCloud.sharedInstance().getDevices { (sparkDevices:[AnyObject]!, error:NSError!) -> Void in + if let e = error { + println("Check your internet connectivity") + } + else { + if let devices = sparkDevices as? [SparkDevice] { + for device in devices { + if device.name == "myNewPhotonName" { + myPhoton = device + } + } + } + } +} +``` + + +#### Read a variable from a Particle device (Core/Photon) +Assuming here that `myPhoton` is an active instance of `SparkDevice` class which represents a device claimed to current user: + +**Objective-C** +```objc +[myPhoton getVariable:@"temperature" completion:^(id result, NSError *error) { + if (!error) { + NSNumber *temperatureReading = (NSNumber *)result; + NSLog(@"Room temperature is %f degrees",temperatureReading.floatValue); + } + else { + NSLog(@"Failed reading temperature from Photon device"); + } +}]; +``` +**Swift** +```swift +myPhoton!.getVariable("temperature", completion: { (result:AnyObject!, error:NSError!) -> Void in + if let e=error { + println("Failed reading temperature from device") + } + else { + if let temp = result as? Float { + println("Room temperature is \(temp) degrees") + } + } +}) +``` + +#### Call a function on a Particle device (Core/Photon) +Invoke a function on the device and pass a list of parameters to it, `resultCode` on the completion block will represent the returned result code of the function on the device + +**Objective-C** +```objc +[myPhoton callFunction:@"digitalwrite" withArguments:@[@"D7",@1] completion:^(NSNumber *resultCode, NSError *error) { + if (!error) + { + NSLog(@"LED on D7 successfully turned on"); + } +}]; +``` +**Swift** +```swift +let funcArgs = ["D7",1] +myPhoton!.callFunction("digitalwrite", withArguments: funcArgs) { (resultCode : NSNumber!, error : NSError!) -> Void in + if (error == nil) { + println("LED on D7 successfully turned on") + } +} +``` + +#### List device exposed functions and variables +Functions is just a list of names, variables is a dictionary in which keys are variable names and values are variable types: + +**Objective-C** +```objc +NSDictionary *myDeviceVariables = myPhoton.variables; +NSLog(@"MyDevice first Variable is called %@ and is from type %@", myDeviceVariables.allKeys[0], myDeviceVariables.allValues[0]); + +NSArray *myDeviceFunctions = myPhoton.functions; +NSLog(@"MyDevice first Function is called %@", myDeviceFunctions[0]); +``` +**Swift** +```swift +let myDeviceVariables : Dictionary? = myPhoton.variables as? Dictionary +println("MyDevice first Variable is called \(myDeviceVariables!.keys.first) and is from type \(myDeviceVariables?.values.first)") + +let myDeviceFunction = myPhoton.functions +println("MyDevice first function is called \(myDeviceFunction!.first)") +``` + +#### Get an instance of a device +Get a device instance by its ID: + +**Objective-C** +```objc +__block SparkDevice *myOtherDevice; +NSString *deviceID = @"53fa73265066544b16208184"; +[[SparkCloud sharedInstance] getDevice:deviceID completion:^(SparkDevice *device, NSError *error) { + if (!error) + myOtherDevice = device; +}]; +``` +**Swift** +```swift +var myOtherDevice : SparkDevice? = nil + SparkCloud.sharedInstance().getDevice("53fa73265066544b16208184", completion: { (device:SparkDevice!, error:NSError!) -> Void in + if let d = device { + myOtherDevice = d + } + }) +``` + +#### Rename a device +you can simply set the `.name` property or use -rename() method if you need a completion block to be called (for example updating a UI after renaming was done): + +**Objective-C** +```objc +myPhoton.name = @"myNewDeviceName"; +``` + +_or_ +```objc +[myPhoton rename:@"myNewDeviecName" completion:^(NSError *error) { + if (!error) + NSLog(@"Device renamed successfully"); +}]; +``` +**Swift** +```swift +myPhoton!.name = "myNewDeviceName" +``` +_or_ +```swift +myPhoton!.rename("myNewDeviceName", completion: { (error:NSError!) -> Void in + if (error == nil) { + println("Device successfully renamed") + } +}) +``` + +#### Logout +Also clears user session and access token + +**Objective-C** +```objc +[[SparkCloud sharedInstance] logout]; +``` +**Swift** +```swift +SparkCloud.sharedInstance().logout() +``` + +### Events sub-system + +You can make an API call that will open a stream of [Server-Sent Events (SSEs)](http://www.w3.org/TR/eventsource/). You will make one API call that opens a connection to the Particle Cloud. That connection will stay open, unlike normal HTTP calls which end quickly. Very little data will come to you across the connection unless your Particle device publishes an event, at which point you will be immediately notified. In each case, the event name filter is `eventNamePrefix` and is optional. When specifying an event name filter, published events will be limited to those events with names that begin with the specified string. For example, specifying an event name filter of 'temp' will return events with names 'temp' and 'temperature'. + +#### Subscribe to events + +Subscribe to the firehose of public events, plus private events published by devices one owns: + +```objc +// The event handler: +SparkEventHandler handler = ^(SparkEvent *event, NSError *error) { + if (!error) + { + dispatch_async(dispatch_get_main_queue(), ^{ + NSLog(@"Got Event %@ with data: %@",event.event,event.data); + }); + } + else + { + NSLog(@"Error occured: %@",error.localizedDescription); + } + + }; + +// This line actually subscribes to the event stream: +id eventListenerID = [[SparkCloud sharedInstance] subscribeToAllEventsWithPrefix:@"temp" handler:handler]; +``` + +*Note:* specifying nil or empty string in the eventNamePrefix parameter will subscribe to ALL events (lots of data!) +You can have multiple handlers per event name and/or same handler per multiple events names. + +Subscribe to all events, public and private, published by devices the user owns: + +```objc +id eventListenerID = [[SparkCloud sharedInstance] subscribeToMyDevicesEventsWithPrefix:@"temp" handler:handler]; +``` + +Subscribe to events from one specific device (by deviceID, second parameter). If the API user owns the device, then he'll receive all events, public and private, published by that device. If the API user does not own the device he will only receive public events. + +```objc +id eventListenerID = [[SparkCloud sharedInstance] subscribeToDeviceEventsWithPrefix:@"temp" deviceID:@"53ff6c065075535119511687" handler:handler]; +``` + +other option is calling same method via the `SparkDevice` instance: + +```objc +id eventListenerID = [device subscribeToEventsWithPrefix:@"temp" handler:handler]; +``` + +this guarantees that private events will be received since having access device instance in your app signifies that the user has this device claimed. + +#### Unsubscribing from events + +Very straightforward. Keep the id object the subscribe method returned and use it as parameter to call the unsubscribe method: + +```objc +[[SparkCloud sharedInstance] unsubscribeFromEventWithID:self.eventListenerID]; +``` + +or via the `SparkDevice` instance (if applicable): + +```objc +[device unsubscribeFromEventWithID:self.eventListenerID]; +``` + +#### Publishing an event + +You can also publish an event from your app to the Particle Cloud: + +**Objective-C** + +```objc +[[SparkCloud sharedInstance] publishEventWithName:@"event_from_app" data:@"event_payload" isPrivate:NO ttl:60 completion:^(NSError *error) { + if (error) + { + NSLog(@"Error publishing event: %@",error.localizedDescription); + } +}]; +``` + +**Swift** + +```swift +SparkCloud.sharedInstance().publishEventWithName("event_from_app", data: "event_payload", isPrivate: false, ttl: 60, completion: { (error:NSError!) -> Void in + if let e = error + { + println("Error publishing event" + e.localizedDescription) + } +}) +``` + +### OAuth client configuration + +If you're creating an app you're required to provide the `SparkCloud` class with OAuth clientId and secret. +Those are used to identify users coming from your specific app to the Particle Cloud. +Please follow the procedure decribed [in our guide](https://docs.particle.io/guide/how-to-build-a-product/web-app/#creating-an-oauth-client) to create those strings, +then in your `AppDelegate` class you can supply those credentials by setting the following properties in `SparkCloud` singleton: + +```objc +@property (nonatomic, strong) NSString *OAuthClientId; +@property (nonatomic, strong) NSString *OAuthClientSecret; +``` + +**Important** +Those credentials should be kept as secret. We recommend the use of [Cocoapods-keys plugin](https://github.com/orta/cocoapods-keys) for cocoapods +(which you have to use anyways to install the SDK). It is essentially a key value store for enviroment and application keys. +It's a good security practice to keep production keys out of developer hands. CocoaPods-keys makes it easy to have per-user config settings stored securely in the developer's keychain, +and not in the application source. It is a plugin that once installed will run on every pod install or pod update. + +After adding the following additional lines your project `Podfile`: +```ruby +plugin 'cocoapods-keys', { + :project => "YourAppName", + :keys => [ + "OAuthClientId", + "OAuthSecret" + ]} +``` + +go to your project folder in shell and run `pod install` - it will now ask you for "OAuthClientId", "OAuthSecret" - you can copy/paste the generated keys there +and from that point on you can feed those keys into `SparkCloud` by adding this code to your AppDelegate `didFinishLaunchingWithOptions` function which gets called +when your app starts: + +*Swift example code* + +```swift +func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + var keys = YourappnameKeys() + SparkCloud.sharedInstance().OAuthClientId = keys.oAuthClientId() + SparkCloud.sharedInstance().OAuthClientSecret = keys.oAuthSecret() + + return true +} +``` + +Be sure to replace `YourAppName` with your project name. + +### Additional reference +For additional reference check out the [Reference in Cocoadocs website](http://cocoadocs.org/docsets/Spark-SDK/) for full coverage of `SparkDevice` and `SparkCloud` functions and member variables. In addition you can consult the javadoc style comments in `SparkCloud.h` and `SparkDevice.h` for each public method. If Particle iOS Cloud SDK is integrated in your XCode project you should be able to press `Esc` to get an auto-complete hints for each cloud and device method. + +## Installation + +Particle iOS Cloud SDK is available through [CocoaPods](http://cocoapods.org). Cocoapods is an easy to use dependacy manager for iOS. +You must have Cocoapods installed, if you don't then be sure to [Install Cocoapods](https://guides.cocoapods.org/using/getting-started.html) before you start: +To install the iOS Cloud SDK, simply add the following line to your Podfile on main project folder: + +```ruby +pod "Spark-SDK" +``` + +and then run `pod update`. A new `.xcworkspace` file will be created for you to open by Cocoapods, open that file workspace file in XCode and you can start interacting with Particle cloud and devices by +adding `#import "Spark-SDK.h"`. (that is not required for swift projects) + +## Communication + +- If you **need help**, use [Our community website](http://community.particle.io), use the `Mobile` category for dicussion/troubleshooting iOS apps using the Particle iOS Cloud SDK. +- If you are certain you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue, label it as `bug`. +- If you **have a feature request**, open an issue with an `enhancement` label on it +- If you **want to contribute**, submit a pull request, be sure to check out spark.github.io for our contribution guidelines, and please sign the [CLA](https://docs.google.com/a/particle.io/forms/d/1_2P-vRKGUFg5bmpcKLHO_qNZWGi5HKYnfrrkd-sbZoA/viewform). + + +#### Support for Swift projects +To use iOS Cloud SDK from within Swift based projects [read here](http://swiftalicio.us/2014/11/using-cocoapods-from-swift/). +For a detailed step-by-step help on integrating the Cloud SDK within a Swift project check out this [Particle community posting](https://community.particle.io/t/mobile-sdk-building-the-bridge-from-swift-to-objective-c/12020/1). + +The [Apple documentation](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html) is an important resource on mixing Objective-C and Swift code, be sure to read through that as well. + +_Notice_ that we've included the required bridging header file in the SDK, you just need to copy it to your project add it as the active bridging header file in the project settings as described in the links above. +There's also an [example app](https://github.com/spark/spark-setup-ios-example), this app also demonstrates the Particle DeviceSetup library usage, as well as several Cloud SDK calls. + +## Maintainers + +- Ido Kleinman [Github](https://www.github.com/idokleinman) | [Twitter](https://www.twitter.com/idokleinman) + +## License + +Particle iOS Cloud SDK is available under the Apache License 2.0. See the LICENSE file for more info. diff --git a/Strike/Pods/SparkSetup/Classes/Comm/Reachability.h b/Strike/Pods/SparkSetup/Classes/Comm/Reachability.h new file mode 100644 index 0000000..bbdc760 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/Comm/Reachability.h @@ -0,0 +1,100 @@ +/* + File: Reachability.h + Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs. + Version: 3.5 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2014-2015 Apple Inc. All Rights Reserved. + + */ + +#import +#import +#import + + +typedef enum : NSInteger { + NotReachable = 0, + ReachableViaWiFi, + ReachableViaWWAN +} NetworkStatus; + + +extern NSString *kReachabilityChangedNotification; + + +@interface Reachability : NSObject + +/*! + * Use to check the reachability of a given host name. + */ ++ (instancetype)reachabilityWithHostName:(NSString *)hostName; + +/*! + * Use to check the reachability of a given IP address. + */ ++ (instancetype)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress; + +/*! + * Checks whether the default route is available. Should be used by applications that do not connect to a particular host. + */ ++ (instancetype)reachabilityForInternetConnection; + +/*! + * Checks whether a local WiFi connection is available. + */ ++ (instancetype)reachabilityForLocalWiFi; + +/*! + * Start listening for reachability notifications on the current run loop. + */ +- (BOOL)startNotifier; +- (void)stopNotifier; + +- (NetworkStatus)currentReachabilityStatus; + +/*! + * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand. + */ +- (BOOL)connectionRequired; + +@end + + diff --git a/Strike/Pods/SparkSetup/Classes/Comm/Reachability.m b/Strike/Pods/SparkSetup/Classes/Comm/Reachability.m new file mode 100644 index 0000000..e71a824 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/Comm/Reachability.m @@ -0,0 +1,311 @@ +/* + File: Reachability.m + Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs. + Version: 3.5 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2014-2015 Apple Inc. All Rights Reserved. + + */ + +#import +#import +#import +#import + +#import + +#import "Reachability.h" + + +NSString *kReachabilityChangedNotification = @"kNetworkReachabilityChangedNotification"; + + +#pragma mark - Supporting functions + +#define kShouldPrintReachabilityFlags 0 + +static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment) +{ +#if kShouldPrintReachabilityFlags + + NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n", + (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', + (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', + + (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', + (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', + (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', + (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', + (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-', + comment + ); +#endif +} + + +static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) +{ +#pragma unused (target, flags) + NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback"); + NSCAssert([(__bridge NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback"); + + Reachability* noteObject = (__bridge Reachability *)info; + // Post a notification to notify the client that the network reachability changed. + [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject]; +} + + +#pragma mark - Reachability implementation + +@implementation Reachability +{ + BOOL _alwaysReturnLocalWiFiStatus; //default is NO + SCNetworkReachabilityRef _reachabilityRef; +} + ++ (instancetype)reachabilityWithHostName:(NSString *)hostName +{ + Reachability* returnValue = NULL; + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]); + if (reachability != NULL) + { + returnValue= [[self alloc] init]; + if (returnValue != NULL) + { + returnValue->_reachabilityRef = reachability; + returnValue->_alwaysReturnLocalWiFiStatus = NO; + } + } + return returnValue; +} + + ++ (instancetype)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress +{ + SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)hostAddress); + + Reachability* returnValue = NULL; + + if (reachability != NULL) + { + returnValue = [[self alloc] init]; + if (returnValue != NULL) + { + returnValue->_reachabilityRef = reachability; + returnValue->_alwaysReturnLocalWiFiStatus = NO; + } + } + return returnValue; +} + + + ++ (instancetype)reachabilityForInternetConnection +{ + struct sockaddr_in zeroAddress; + bzero(&zeroAddress, sizeof(zeroAddress)); + zeroAddress.sin_len = sizeof(zeroAddress); + zeroAddress.sin_family = AF_INET; + + return [self reachabilityWithAddress:&zeroAddress]; +} + + ++ (instancetype)reachabilityForLocalWiFi +{ + struct sockaddr_in localWifiAddress; + bzero(&localWifiAddress, sizeof(localWifiAddress)); + localWifiAddress.sin_len = sizeof(localWifiAddress); + localWifiAddress.sin_family = AF_INET; + + // IN_LINKLOCALNETNUM is defined in as 169.254.0.0. + localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); + + Reachability* returnValue = [self reachabilityWithAddress: &localWifiAddress]; + if (returnValue != NULL) + { + returnValue->_alwaysReturnLocalWiFiStatus = YES; + } + + return returnValue; +} + + +#pragma mark - Start and stop notifier + +- (BOOL)startNotifier +{ + BOOL returnValue = NO; + SCNetworkReachabilityContext context = {0, (__bridge void *)(self), NULL, NULL, NULL}; + + if (SCNetworkReachabilitySetCallback(_reachabilityRef, ReachabilityCallback, &context)) + { + if (SCNetworkReachabilityScheduleWithRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) + { + returnValue = YES; + } + } + + return returnValue; +} + + +- (void)stopNotifier +{ + if (_reachabilityRef != NULL) + { + SCNetworkReachabilityUnscheduleFromRunLoop(_reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + } +} + + +- (void)dealloc +{ + [self stopNotifier]; + if (_reachabilityRef != NULL) + { + CFRelease(_reachabilityRef); + } +} + + +#pragma mark - Network Flag Handling + +- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags +{ + PrintReachabilityFlags(flags, "localWiFiStatusForFlags"); + NetworkStatus returnValue = NotReachable; + + if ((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect)) + { + returnValue = ReachableViaWiFi; + } + + return returnValue; +} + + +- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags +{ + PrintReachabilityFlags(flags, "networkStatusForFlags"); + if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) + { + // The target host is not reachable. + return NotReachable; + } + + NetworkStatus returnValue = NotReachable; + + if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) + { + /* + If the target host is reachable and no connection is required then we'll assume (for now) that you're on Wi-Fi... + */ + returnValue = ReachableViaWiFi; + } + + if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || + (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)) + { + /* + ... and the connection is on-demand (or on-traffic) if the calling application is using the CFSocketStream or higher APIs... + */ + + if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) + { + /* + ... and no [user] intervention is needed... + */ + returnValue = ReachableViaWiFi; + } + } + + if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) + { + /* + ... but WWAN connections are OK if the calling application is using the CFNetwork APIs. + */ + returnValue = ReachableViaWWAN; + } + + return returnValue; +} + + +- (BOOL)connectionRequired +{ + NSAssert(_reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef"); + SCNetworkReachabilityFlags flags; + + if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) + { + return (flags & kSCNetworkReachabilityFlagsConnectionRequired); + } + + return NO; +} + + +- (NetworkStatus)currentReachabilityStatus +{ + NSAssert(_reachabilityRef != NULL, @"currentNetworkStatus called with NULL SCNetworkReachabilityRef"); + NetworkStatus returnValue = NotReachable; + SCNetworkReachabilityFlags flags; + + if (SCNetworkReachabilityGetFlags(_reachabilityRef, &flags)) + { + if (_alwaysReturnLocalWiFiStatus) + { + returnValue = [self localWiFiStatusForFlags:flags]; + } + else + { + returnValue = [self networkStatusForFlags:flags]; + } + } + + return returnValue; +} + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupCommManager.h b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupCommManager.h new file mode 100644 index 0000000..1bf4cb5 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupCommManager.h @@ -0,0 +1,58 @@ +// +// SparkSetupManager.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/20/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import "SparkSetupConnection.h" + + +#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) + +extern NSString *const kSparkSetupConnectionEndpointAddress; +extern int const kSparkSetupConnectionEndpointPort; + +typedef NS_ENUM(NSInteger, SparkSetupWifiSecurityType) { + SparkSetupWifiSecurityTypeOpen = 0, /**< Unsecured */ + SparkSetupWifiSecurityTypeWEP_PSK = 1, /**< WEP Security with open authentication */ + SparkSetupWifiSecurityTypeWEP_SHARED = 0x8001, /**< WEP Security with shared authentication */ + SparkSetupWifiSecurityTypeWPA_TKIP_PSK = 0x00200002, /**< WPA Security with TKIP */ + SparkSetupWifiSecurityTypeWPA_AES_PSK = 0x00200004, /**< WPA Security with AES */ + SparkSetupWifiSecurityTypeWPA2_AES_PSK = 0x00400004, /**< WPA2 Security with AES */ + SparkSetupWifiSecurityTypeWPA2_TKIP_PSK = 0x00400002, /**< WPA2 Security with TKIP */ + SparkSetupWifiSecurityTypeWPA2_MIXED_PSK = 0x00400006, /**< WPA2 Security with AES & TKIP */ +}; + + +@interface SparkSetupCommManager : NSObject + +/** + * Check if currently connected wifi is the Soft AP device wi-fi network + * + * @param networkPrefix Device Soft AP SSID prefix + * + * @return YES if connected, NO otherwise + */ ++(BOOL)checkSparkDeviceWifiConnection:(NSString *)networkPrefix; + +/** + * Use to initialize comm manager + * + * @param networkPrefix Device Soft AP SSID prefix + * + * @return Initialized comm manager or bil if error + */ +-(instancetype)initWithNetworkPrefix:(NSString *)networkPrefix; + + +-(void)version:(void(^)(id version, NSError *error))completion; +-(void)deviceID:(void(^)(id responseDict, NSError *error))completion; +-(void)scanAP:(void(^)(id scanResponse, NSError *error))completion; +-(void)configureAP:(NSString *)ssid passcode:(NSString *)passcode security:(NSNumber *)securityType channel:(NSNumber *)channel completion:(void(^)(id responseCode, NSError *error))completion; +-(void)connectAP:(void(^)(id responseCode, NSError *error))completion; +-(void)publicKey:(void(^)(id responseCode, NSError *error))completion; // retrieve the device public key and store it in keychain +-(void)setClaimCode:(NSString *)claimCode completion:(void(^)(id responseCode, NSError *error))completion; +@end diff --git a/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupCommManager.m b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupCommManager.m new file mode 100644 index 0000000..2ad033f --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupCommManager.m @@ -0,0 +1,653 @@ +// +// SparkSetupManager.m +// spark-setup-ios +// +// Created by Ido Kleinman on 11/20/14. +// Copyright (c) 2014-2015 Particle. All rights reserved. +// This class implements the Particle Soft-AP protocol specified in +// https://github.com/spark/photon-wiced/blob/master/soft-ap.md +// + +#import "SparkSetupCommManager.h" +#import "SparkSetupConnection.h" +#import +#import "SparkSetupSecurityManager.h" +#import +//#import "FastSocket.h" + +// new iOS 9 requirements: +#import "Reachability.h" +@import UIKit; + + +#define ENCRYPT_PWD 1 + +typedef NS_ENUM(NSInteger, SparkSetupCommandType) { + SparkSetupCommandTypeNone=0, + SparkSetupCommandTypeVersion=1, + SparkSetupCommandTypeDeviceID=2, + SparkSetupCommandTypeScanAP=3, + SparkSetupCommandTypeConfigureAP=4, + SparkSetupCommandTypeConnectAP=5, + SparkSetupCommandTypePublicKey, + SparkSetupCommandTypeSet, +}; + + +NSString *const kSparkSetupConnectionEndpointAddress = @"192.168.0.1"; +NSString *const kSparkSetupConnectionEndpointPortString = @"5609"; +int const kSparkSetupConnectionEndpointAddressHex = 0xC0A80001; +int const kSparkSetupConnectionEndpointPort = 5609; + + +@interface SparkSetupCommManager() + +@property (nonatomic, strong) SparkSetupConnection *connection; +@property (atomic) SparkSetupCommandType commandType; // last command type +@property (copy)void (^commandCompletionBlock)(id, NSError *); // completion block for last sent command +//@property (copy)void (^commandDeviceIDCompletionBlock)(id, BOOL, NSError *); // completion block for commandID command + +@property (copy)void (^commandSendBlock)(void); // code block for sending the command to socket +@property (nonatomic, strong) NSTimer *sendCommandTimeoutTimer; +@property (nonatomic, strong) NSString *networkNamePrefix; +@end + + +@implementation SparkSetupCommManager + + +//-(instancetype)initWithConnection:(SparkSetupConnection *)connection +-(instancetype)init +{ + self = [super init]; + if (self) + { + self.commandType = SparkSetupCommandTypeNone; + self.commandCompletionBlock = nil; + self.commandSendBlock = nil; + // self.ready = NO; +// NSLog(@"SparkSetupCommManager %@ instanciated!",self); + + return self; + + } + + return nil; +} + + +-(instancetype)initWithNetworkPrefix:(NSString *)networkPrefix +{ + SparkSetupCommManager *manager = [self init]; + if (manager) + { + manager.networkNamePrefix = networkPrefix; + return manager; + } + else + return nil; +} + +#pragma mark Spark photon device wifi connection detection methods + ++(BOOL)checkSparkDeviceWifiConnection:(NSString *)networkPrefix +{ + // starting iOS 9: just try to open socket to photon - networkPrefix is ignored + /* + if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")) + { + static BOOL bOpeningSocket = NO; + + if (bOpeningSocket) + return NO; + + + bOpeningSocket = YES; + FastSocket *socket = [[FastSocket alloc] initWithHost:kSparkSetupConnectionEndpointAddress andPort:kSparkSetupConnectionEndpointPortString]; + + if ([socket connect]) + { + [socket close]; + bOpeningSocket = NO; + return YES; + } + else + { + bOpeningSocket = NO; + return NO; + } + } + else*/ +// { + + // for iOS 8: + NSArray *ifs = (__bridge_transfer NSArray *)CNCopySupportedInterfaces(); + // NSLog(@"Supported interfaces: %@", ifs); + NSDictionary *info; + for (NSString *ifnam in ifs) { + info = (__bridge_transfer NSDictionary *)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam); + // NSLog(@"%@ => %@", ifnam, info); + if (info && [info count]) { break; } + } + + NSString *SSID = info[@"SSID"]; + // NSLog(@"currently connected SSID: %@",SSID); + // if ([SSID hasPrefix:[SparkSetupCustomization sharedInstance].networkNamePrefix]) + if ([SSID hasPrefix:networkPrefix]) + { + return YES; + // TODO: add notification or delegate method + // TODO: add reachability change detection + + } +// } + + return NO; + +} + +#pragma mark SparkSetupConnection delegate methods + +-(void)SparkSetupConnection:(SparkSetupConnection *)connection didReceiveData:(NSString *)data +{ + if (connection == self.connection) + { + NSNumber *responseCode; + NSError *e = nil; + NSDictionary *response = [NSJSONSerialization JSONObjectWithData:[data dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&e]; + if ((!e) && (self.commandCompletionBlock)) + { + switch (self.commandType) { + case SparkSetupCommandTypeVersion: + self.commandCompletionBlock(response[@"v"],nil); // the version string + // self.commandType = SparkSetupCommandTypeNone; + break; + + case SparkSetupCommandTypeDeviceID: + if (self.commandCompletionBlock) // special completion + self.commandCompletionBlock(response, nil); // the device ID string + claimed flag dictionary + // self.commandType = SparkSetupCommandTypeNone; + break; + + case SparkSetupCommandTypeScanAP: + self.commandCompletionBlock(response[@"scans"],nil); // the scan response array + // self.commandType = SparkSetupCommandTypeNone; + break; + + + case SparkSetupCommandTypeConfigureAP: + case SparkSetupCommandTypeConnectAP: + case SparkSetupCommandTypeSet: + self.commandCompletionBlock(response[@"r"],nil); // the response code number + // self.commandType = SparkSetupCommandTypeNone; + break; + + case SparkSetupCommandTypePublicKey: + // handle key storage +// NSLog(@"SparkSetupCommandTypePublicKey response is:\n%@",response); + + responseCode = (NSNumber *)response[@"r"]; + if (responseCode.intValue != 0) + { + self.commandCompletionBlock(nil,[NSError errorWithDomain:@"SparkSetupCommManagerError" code:2006 userInfo:@{NSLocalizedDescriptionKey:@"Could not retrieve public key from device"}]); + } + else + { + // decode HEX encoded key to NSData + NSString *pubKeyHexCoded = (NSString *)response[@"b"]; +// NSLog(@"Encoded key is %@", pubKeyHexCoded); + + NSData *pubKey = [SparkSetupSecurityManager decodeDataFromHexString:pubKeyHexCoded]; +// NSLog(@"Decoded key is %@", [pubKey description]); + + if ([SparkSetupSecurityManager setPublicKey:pubKey]) + { +// NSLog(@"Public key stored in keychain successfully"); + self.commandCompletionBlock(response[@"r"],nil); + } + else + { + self.commandCompletionBlock(nil,[NSError errorWithDomain:@"SparkSetupSecurityManager" code:2007 userInfo:@{NSLocalizedDescriptionKey:@"Could not store public key in device keychain"}]); + } + + } + default: // something else happened + // self.commandType = SparkSetupCommandTypeNone; + break; + } + + } + } + +} + + + + + +-(void)SparkSetupConnection:(SparkSetupConnection *)connection didUpdateState:(SparkSetupConnectionState)state error:(NSError *)error +{ + if (error) + { + [self.sendCommandTimeoutTimer invalidate]; + if (self.commandCompletionBlock) + self.commandCompletionBlock(nil, [NSError errorWithDomain:@"SparkSetupCommManagerError" code:2002 userInfo:@{NSLocalizedDescriptionKey:error.localizedDescription}]); +// self.commandCompletionBlock = nil; + return; + } + + switch (state) { + case SparkSetupConnectionStateClosed: +// NSLog(@"Connection to spark device closed"); + [self.sendCommandTimeoutTimer invalidate]; + break; + + case SparkSetupConnectionOpenTimeout: +// NSLog(@"Opening connection to spark device timed out"); + [self.sendCommandTimeoutTimer invalidate]; + if (self.commandCompletionBlock) + { + self.commandCompletionBlock(nil, [NSError errorWithDomain:@"SparkSetupCommManagerError" code:2002 userInfo:@{NSLocalizedDescriptionKey:@"Opening connection to spark device timed out"}]); + self.commandCompletionBlock = nil; + } + break; + + case SparkSetupConnectionStateOpened: +// NSLog(@"Connection to spark device opened"); + if (self.commandSendBlock) + { + self.sendCommandTimeoutTimer = [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(sendCommandTimeoutHandler:) userInfo:nil repeats:NO]; + self.commandSendBlock(); +// NSLog(@"Command %ld sent to spark device",(long)self.commandType); + } + break; + case SparkSetupConnectionStateError: + case SparkSetupConnectionStateUnknown: + self.commandType = SparkSetupCommandTypeNone; + [self.sendCommandTimeoutTimer invalidate]; +// NSLog(@"Connection to spark device failed"); + if (self.commandCompletionBlock) + { + self.commandCompletionBlock(nil, [NSError errorWithDomain:@"SparkSetupCommManagerError" code:2002 userInfo:@{NSLocalizedDescriptionKey:@"Connection to spark device failed"}]); + self.commandCompletionBlock = nil; + } + break; + + default: + break; + } +} + +/* + -(void)writeCommandTimeoutHandler:(id)sender + { + self.commandType = SparkSetupCommandTypeNone; + // self.connection = nil; + + if (self.commandCompletionBlock) + self.commandCompletionBlock(nil,[NSError errorWithDomain:@"SparkSetupCommManagerError" code:2002 userInfo:@{NSLocalizedDescriptionKey:@"Timeout occured while writing data to socket connection"}]); + + // self.commandCompletionBlock = nil; + } + */ + + + +-(void)sendCommandTimeoutHandler:(id)sender +{ + + [self.sendCommandTimeoutTimer invalidate]; + // self.commandType = SparkSetupCommandTypeNone; + + if (self.commandCompletionBlock) + self.commandCompletionBlock(nil,[NSError errorWithDomain:@"SparkSetupCommManagerError" code:2004 userInfo:@{NSLocalizedDescriptionKey:@"Timeout occured while waiting for response from socket"}]); + + self.commandCompletionBlock = nil; +} + +#pragma mark TCP Socket photon soft AP protocol implementation + + +-(void)openConnection // and then send command (+ timeout) +{ + // TODO: add command queue + self.connection = [[SparkSetupConnection alloc] initWithIPAddress:kSparkSetupConnectionEndpointAddress port:kSparkSetupConnectionEndpointPort]; + self.connection.delegate = self; +} + + +-(BOOL)canSendCommandCallCompletionForError:(void(^)(id obj, NSError *error))completion +{ + if (self.networkNamePrefix) + { + if (![SparkSetupCommManager checkSparkDeviceWifiConnection:self.networkNamePrefix]) + { + completion(nil, [NSError errorWithDomain:@"SparkSetupCommManangerError" code:2003 userInfo:@{NSLocalizedDescriptionKey:@"Not connected to Spark device"}]); + return NO; + } + } + + if (self.commandType != SparkSetupCommandTypeNone) + { + completion(nil, [NSError errorWithDomain:@"SparkSetupCommManangerError" code:2005 userInfo:@{NSLocalizedDescriptionKey:@"Use a new instance of SparkSetupCommManager per command"}]); + return NO; + } + + return YES; +} + +-(void)version:(void(^)(id version, NSError *error))completion +{ + // TODO: new prototype: + // open connection --> add semaphore to delegate + // wait on semaphore with timeout (open socket timeout call completion) + // do write command (+ handle completion) + // add semaphore to receive data with timeout + // if fails - receive data timeout + // else calls completion with data + // no need for NSTimers + + if ([self canSendCommandCallCompletionForError:completion]) + { + __weak SparkSetupCommManager *weakSelf = self; + self.commandCompletionBlock = completion; + + self.commandSendBlock = ^{ + + NSString *commandStr = @"version\n0\n\n"; + weakSelf.commandType = SparkSetupCommandTypeVersion; + [weakSelf.connection writeString:commandStr completion:^(NSError *error) { + if ((error) && (completion)) + { + completion(nil, error); + weakSelf.commandCompletionBlock = nil; + // weakSelf.commandType = SparkSetupCommandTypeNone; + } + }]; + }; + // start process + [self openConnection]; + } + + +} + + + +-(void)deviceID:(void (^)(id, NSError *))completion +{ + if ([self canSendCommandCallCompletionForError:completion]) + { + __weak SparkSetupCommManager *weakSelf = self; + self.commandCompletionBlock = completion; + + self.commandSendBlock = ^{ + + if (weakSelf.connection.state == SparkSetupConnectionStateOpened) + { + weakSelf.commandType = SparkSetupCommandTypeDeviceID; + NSString *commandStr = @"device-id\n0\n\n"; + + [weakSelf.connection writeString:commandStr completion:^(NSError *error) { + if ((error) && (completion)) + { + completion(nil, error); + weakSelf.commandCompletionBlock = nil; + // weakSelf.commandType = SparkSetupCommandTypeNone; + + } + }]; + } + + }; + + [self openConnection]; + } +} + + + +-(void)scanAP:(void(^)(id scanResponse, NSError *error))completion //NSDictionary +{ + if ([self canSendCommandCallCompletionForError:completion]) + { + __weak SparkSetupCommManager *weakSelf = self; + self.commandCompletionBlock = completion; + + self.commandSendBlock = ^{ + + weakSelf.commandType = SparkSetupCommandTypeScanAP; + NSString *commandStr = @"scan-ap\n0\n\n"; + + [weakSelf.connection writeString:commandStr completion:^(NSError *error) { + if ((error) && (completion)) + { + completion(nil, error); + weakSelf.commandCompletionBlock = nil; + // weakSelf.commandType = SparkSetupCommandTypeNone; + } + }]; + + }; + + [self openConnection]; + + } +} + + + + +-(void)configureAP:(NSString *)ssid passcode:(NSString *)passcode security:(NSNumber *)securityType channel:(NSNumber *)channel completion:(void(^)(id responseCode, NSError *error))completion +{ + if ([self canSendCommandCallCompletionForError:completion]) + { + __weak SparkSetupCommManager *weakSelf = self; + self.commandCompletionBlock = completion; + + self.commandSendBlock = ^{ + + NSDictionary* requestDataDict; + + // Truncate passcode to 64 chars maximum + NSRange stringRange = {0, MIN(passcode.length, 64)}; + // adjust the range to include dependent chars + stringRange = [passcode rangeOfComposedCharacterSequencesForRange:stringRange]; + // Now you can create the short string + NSString *passcodeTruncated = [passcode substringWithRange:stringRange]; + NSString *hexEncodedEncryptedPasscodeStr; + + if (ENCRYPT_PWD) + { + SecKeyRef pubKey = [SparkSetupSecurityManager getPublicKey]; + if (pubKey != NULL) + { + // encrypt it using the stored public key + NSData *plainTextData = [passcodeTruncated dataUsingEncoding:NSUTF8StringEncoding]; + NSData *cipherTextData = [SparkSetupSecurityManager encryptWithPublicKey:pubKey plainText:plainTextData]; + if (cipherTextData != nil) + { + // encode the encrypted data to a hex string + hexEncodedEncryptedPasscodeStr = [SparkSetupSecurityManager encodeDataToHexString:cipherTextData]; +// NSLog(@"plaintext: %@\nCiphertext:\n%@",passcodeTruncated,hexEncodedEncryptedPasscodeStr); + requestDataDict = @{@"idx":@0, @"ssid":ssid, @"pwd":hexEncodedEncryptedPasscodeStr, @"sec":securityType, @"ch":channel}; + } + else + { + completion(nil, [NSError errorWithDomain:@"SparkSetupSecurityManager" code:2007 userInfo:@{NSLocalizedDescriptionKey:@"Failed to encrypt passcode"}]); + return; //? + } + } + else + { + completion(nil, [NSError errorWithDomain:@"SparkSetupSecurityManager" code:2008 userInfo:@{NSLocalizedDescriptionKey:@"Failed to retrieve device public key from keychain"}]); + return; //? + } + } + else + { + // no passcode encryption // TODO: remove when encryption functional + requestDataDict = @{@"idx":@0, @"ssid":ssid, @"pwd":passcodeTruncated, @"sec":securityType, @"ch":channel}; + } + + NSError *error; + NSString *jsonString; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:requestDataDict + options:0 + error:&error]; + + if (jsonData) + jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + else + completion(nil, [NSError errorWithDomain:@"SparkSetupCommManangerError" code:2002 userInfo:@{NSLocalizedDescriptionKey:@"Cannot process configureAP command data to JSON"}]); + + NSString *commandStr = [NSString stringWithFormat:@"configure-ap\n%ld\n\n%@",(unsigned long)jsonString.length, jsonString]; + weakSelf.commandType = SparkSetupCommandTypeConfigureAP; + [weakSelf.connection writeString:commandStr completion:^(NSError *error) { + if ((error) && (completion)) + { + completion(nil, error); + weakSelf.commandCompletionBlock = nil; + // weakSelf.commandType = SparkSetupCommandTypeNone; + } + }]; + + }; + + [self openConnection]; + } + +} + + + + +-(void)setClaimCode:(NSString *)claimCode completion:(void (^)(id, NSError *))completion +{ + if ([self canSendCommandCallCompletionForError:completion]) + { + __weak SparkSetupCommManager *weakSelf = self; + self.commandCompletionBlock = completion; + + self.commandSendBlock = ^{ + + NSDictionary* requestDataDict; + requestDataDict = @{@"k":@"cc", + @"v": claimCode}; + + NSError *error; + NSString *jsonString; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:requestDataDict + options:0 + error:&error]; + + if (jsonData) + jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + else + completion(nil, [NSError errorWithDomain:@"SparkSetupCommManangerError" code:2002 userInfo:@{NSLocalizedDescriptionKey:@"Cannot process setClaimCode command data to JSON"}]); + + // remove backslahes that might occur from '/' in + jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\\" withString:@""]; + + NSString *commandStr = [NSString stringWithFormat:@"set\n%ld\n\n%@",(unsigned long)jsonString.length, jsonString]; + weakSelf.commandType = SparkSetupCommandTypeSet; + [weakSelf.connection writeString:commandStr completion:^(NSError *error) { + if ((error) && (completion)) + { + completion(nil, error); + weakSelf.commandCompletionBlock = nil; + } + }]; + + }; + + [self openConnection]; + } +} + +-(void)connectAP:(void(^)(id responseCode, NSError *error))completion +{ + if ([self canSendCommandCallCompletionForError:completion]) + { + __weak SparkSetupCommManager *weakSelf = self; + self.commandCompletionBlock = completion; + + self.commandSendBlock = ^{ + + NSDictionary* requestDataDict = @{@"idx":@0}; + NSError *error; + NSString *jsonString; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:requestDataDict + options:0 + error:&error]; + + if (jsonData) + { + jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + + NSString *commandStr = [NSString stringWithFormat:@"connect-ap\n%ld\n\n%@",(unsigned long)jsonString.length, jsonString]; + weakSelf.commandType = SparkSetupCommandTypeConnectAP; + [weakSelf.connection writeString:commandStr completion:^(NSError *error) { + if ((error) && (completion)) + { + completion(nil, error); + weakSelf.commandCompletionBlock = nil; + // weakSelf.commandType = SparkSetupCommandTypeNone; + } + }]; + } + else + { + completion(nil, [NSError errorWithDomain:@"SparkSetupCommManangerError" code:2002 userInfo:@{NSLocalizedDescriptionKey:@"Cannot process connectAP command data to JSON"}]); + } + + }; + + [self openConnection]; + } + +} + + +-(void)publicKey:(void (^)(id, NSError *))completion +{ + if ([self canSendCommandCallCompletionForError:completion]) + { + __weak SparkSetupCommManager *weakSelf = self; + self.commandCompletionBlock = completion; + + self.commandSendBlock = ^{ + + weakSelf.commandType = SparkSetupCommandTypePublicKey; + NSString *commandStr = @"public-key\n0\n\n"; + + [weakSelf.connection writeString:commandStr completion:^(NSError *error) { + if ((error) && (completion)) + { + completion(nil, error); + weakSelf.commandCompletionBlock = nil; + + } + }]; + + }; + + [self openConnection]; + + } + +} + +-(void)dealloc +{ +// NSLog(@"SparkSetupCommManager %@ dealloced!",self); + + self.commandSendBlock = nil; + self.commandCompletionBlock = nil; + self.connection = nil; + +} + + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupConnection.h b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupConnection.h new file mode 100644 index 0000000..961596b --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupConnection.h @@ -0,0 +1,44 @@ +// +// SparkSetupConnection.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/20/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import + +@class SparkSetupConnection; + +typedef NS_ENUM(NSInteger, SparkSetupConnectionState) { + SparkSetupConnectionStateOpened, +// SparkSetupConnectionStateSentCommand, +// SparkSetupConnectionStateReceivedResponse, + SparkSetupConnectionStateClosed, + SparkSetupConnectionOpenTimeout, + SparkSetupConnectionStateError, + SparkSetupConnectionStateUnknown +}; + + +@protocol SparkSetupConnectionDelegate + +@required +-(void)SparkSetupConnection:(SparkSetupConnection *)connection didReceiveData:(NSString *)data; + +@optional +-(void)SparkSetupConnection:(SparkSetupConnection *)connection didUpdateState:(SparkSetupConnectionState)state error:(NSError *)error; + +@end + +@interface SparkSetupConnection : NSObject +-(instancetype)initWithIPAddress:(NSString *)IPAddr port:(int)port NS_DESIGNATED_INITIALIZER; +-(id)init __attribute__((unavailable("Must use -initWithIPAddress:port:"))); +-(void)close; + +@property (nonatomic, strong) iddelegate; +@property (nonatomic, readonly) SparkSetupConnectionState state; + +-(void)writeString:(NSString *)string completion:(void(^)(NSError *error))completion; + +@end diff --git a/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupConnection.m b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupConnection.m new file mode 100644 index 0000000..baa85c5 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupConnection.m @@ -0,0 +1,261 @@ +// +// SparkSetupConnection.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/20/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkSetupConnection.h" + +float const kSparkSetupConnectionOpenTimeout = 3.0f; + + + +@interface SparkSetupConnection() +@property (strong, nonatomic) NSInputStream *inputStream; +@property (strong, nonatomic) NSOutputStream *outputStream; +@property (nonatomic) SparkSetupConnectionState state; +@property (nonatomic, strong) NSString *IPaddr; +@property (nonatomic) NSInteger port; +@property (nonatomic, strong) NSMutableString *rcvdDataBuffer; + +@property (nonatomic) BOOL outStreamOpened; +@property (nonatomic) BOOL inStreamOpened; +@property (nonatomic, strong) NSTimer *socketOpenTimeoutTimer; + + +@end + +@implementation SparkSetupConnection + + +-(void)initSocket +{ + // This is the iOS 8+ way to go: +// NSInputStream *inputStream; +// NSOutputStream *outputStream; +// [NSStream getStreamsToHostWithName:self.IPaddr port:self.port inputStream:&inputStream outputStream:&outputStream]; + + // instead of all this crap: + CFReadStreamRef readStream; + CFWriteStreamRef writeStream; + CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)self.IPaddr, (UInt32)self.port, &readStream, &writeStream); + NSInputStream *inputStream = (__bridge_transfer NSInputStream *)readStream; + NSOutputStream *outputStream = (__bridge_transfer NSOutputStream *)writeStream; + // ---- + + self.inputStream = inputStream; + self.outputStream = outputStream; + + [self.inputStream setDelegate:self]; + [self.outputStream setDelegate:self]; + + self.outStreamOpened = NO; + self.inStreamOpened = NO; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [self.outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [self.inputStream open]; + [self.outputStream open]; + + self.socketOpenTimeoutTimer = [NSTimer scheduledTimerWithTimeInterval:kSparkSetupConnectionOpenTimeout target:self selector:@selector(socketOpenTimeoutHandler:) userInfo:nil repeats:NO]; + + }); +} + + +-(instancetype)initWithIPAddress:(NSString *)IPaddr port:(int)port +{ + self = [super init]; + if (self) + { + self.IPaddr = IPaddr; + self.port = port; + [self initSocket]; + + return self; + } + + return nil; +} + + + + +-(void)socketOpenTimeoutHandler:(id)sender +{ + [self.socketOpenTimeoutTimer invalidate]; + self.state = SparkSetupConnectionOpenTimeout; + [self.delegate SparkSetupConnection:self didUpdateState:self.state error:nil]; +} + + + +-(void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode +{ + // handling a bit-wise event code (few events can happen at once) + while (eventCode != NSStreamEventNone) { + + if (eventCode & NSStreamEventOpenCompleted) + { + eventCode = eventCode &~ NSStreamEventOpenCompleted; + +// NSLog(@"NSStreamEventOpenCompleted: %@",aStream.description); + if (aStream == self.outputStream) + self.outStreamOpened = YES; + + if (aStream == self.inputStream) + self.inStreamOpened = YES; + + if ((self.outStreamOpened) && (self.inStreamOpened)) + { + [self.socketOpenTimeoutTimer invalidate]; + self.state = SparkSetupConnectionStateOpened; + [self.delegate SparkSetupConnection:self didUpdateState:self.state error:nil]; + } + } + + if ((eventCode & NSStreamEventHasSpaceAvailable) || (eventCode & NSStreamEventHasBytesAvailable)) + { + if (eventCode & NSStreamEventHasSpaceAvailable) + eventCode = eventCode &~NSStreamEventHasSpaceAvailable; + + if (eventCode & NSStreamEventHasBytesAvailable) + eventCode = eventCode &~NSStreamEventHasBytesAvailable; + + if (aStream == self.inputStream) { + + uint8_t buffer[1024]; + NSInteger len; + + while ([self.inputStream hasBytesAvailable]) { + len = [self.inputStream read:buffer maxLength:sizeof(buffer)]; + if (len > 0) { + + NSString *rcvdData = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding]; + [self.rcvdDataBuffer appendString:rcvdData]; +// NSLog(@"appended server data: %@",rcvdData); + } + } + } + } + + if (eventCode & NSStreamEventErrorOccurred) + { + if (eventCode & NSStreamEventErrorOccurred) + eventCode = eventCode &~NSStreamEventErrorOccurred; + +// NSLog(@"NSStreamEventErrorOccurred: %@",[aStream.streamError localizedDescription]); + self.state = SparkSetupConnectionStateError; + [self.delegate SparkSetupConnection:self didUpdateState:self.state error:aStream.streamError]; + } + + if (eventCode & NSStreamEventEndEncountered) + { + if (eventCode & NSStreamEventEndEncountered) + eventCode = eventCode &~NSStreamEventEndEncountered; + + if (aStream == self.outputStream) + { + self.outStreamOpened = NO; +// NSLog(@"%@ outputStream closed",self.description); + } + + if (aStream == self.inputStream) + { + self.inStreamOpened = NO; +// NSLog(@"%@ inputStream closed",self.description); + + if (self.outStreamOpened) // if input stream has closed - output stream should close too + [_outputStream close]; + + self.state = SparkSetupConnectionStateClosed; + [self.delegate SparkSetupConnection:self didUpdateState:self.state error:[aStream streamError]]; + + if (self.rcvdDataBuffer) + { + if (self.rcvdDataBuffer.length > 0) + { + [self.delegate SparkSetupConnection:self didReceiveData:self.rcvdDataBuffer]; + } + } + + + } + + } + + if (eventCode & SparkSetupConnectionStateUnknown) + { + if (eventCode & SparkSetupConnectionStateUnknown) + eventCode = eventCode &~SparkSetupConnectionStateUnknown; + + self.state = SparkSetupConnectionStateUnknown; + [self.delegate SparkSetupConnection:self didUpdateState:self.state error:aStream.streamError]; + } + } + +} + + + +-(void)writeString:(NSString *)string completion:(void(^)(NSError *error))completion; +{ + if (self.state != SparkSetupConnectionStateOpened) + { + completion([NSError errorWithDomain:@"SparkSetupConnectionError" code:3000 userInfo:@{NSLocalizedDescriptionKey:@"Socket connection is not open"}]); + return; + } + + + NSData *buffer = [string dataUsingEncoding:NSStringEncodingConversionAllowLossy]; + self.rcvdDataBuffer = [@"" mutableCopy]; // getting ready to send command - zeroing response data buffer + + + dispatch_async(dispatch_get_main_queue(), ^{ + if ([self.outputStream hasSpaceAvailable]) + { + if (![self.outputStream write:[buffer bytes] maxLength:[buffer length]] == string.length) + { + completion([NSError errorWithDomain:@"SparkSetupConnectionError" code:3002 userInfo:@{NSLocalizedDescriptionKey:@"Could not write all data to socket"}]); return; + } + } + else + { + completion([NSError errorWithDomain:@"SparkSetupConnectionError" code:3001 userInfo:@{NSLocalizedDescriptionKey:@"Output socket not ready"}]); + } + }); + + +} + + + +-(void)dealloc +{ + [self close]; +} + +-(void)close +{ + [self.socketOpenTimeoutTimer invalidate]; + + if (self.outputStream) + { + [self.outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [self.outputStream close]; + } + + if (self.inputStream) + { + [self.inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [self.inputStream close]; + } + + +} + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupSecurityManager.h b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupSecurityManager.h new file mode 100644 index 0000000..2960504 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupSecurityManager.h @@ -0,0 +1,19 @@ +// +// SparkSetupSecurity.h +// teacup-ios-app +// +// Created by Ido Kleinman on 1/8/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import + +@interface SparkSetupSecurityManager : NSObject + ++(SecKeyRef)getPublicKey; ++(BOOL)setPublicKey:(NSData *)rawASN1FormattedKey; ++(NSData *)encryptWithPublicKey:(SecKeyRef)pubKey plainText:(NSData *)plainText; ++(NSData *)decodeDataFromHexString:(NSString *)hexEncodedString; ++(NSString *)encodeDataToHexString:(NSData *)buffer; + +@end diff --git a/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupSecurityManager.m b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupSecurityManager.m new file mode 100644 index 0000000..aaef226 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/Comm/SparkSetupSecurityManager.m @@ -0,0 +1,238 @@ +// +// SparkSetupSecurity.m +// teacup-ios-app +// +// Created by Ido Kleinman on 1/8/15. +// Copyright (c) 2015 spark. All rights reserved. +// setPublicKey stripping ASN.1 headers from public key data function based on code from: +// http://blog.wingsofhermes.org/?p=75 + +#import "SparkSetupSecurityManager.h" + +char *const kSparkSetupSecurityPublicKeystore = "kSparkSetupSecurityPublicKeystore"; +#define CIPHER_BUFFER_SIZE 128 + + +@implementation SparkSetupSecurityManager + + ++(SecKeyRef)getPublicKey +{ + NSMutableDictionary * keyAttr = [[NSMutableDictionary alloc] init]; + CFTypeRef publicKeyRef = NULL; + OSStatus error = noErr; + + NSData* refTag = [[NSData alloc] initWithBytes:kSparkSetupSecurityPublicKeystore length:strlen(kSparkSetupSecurityPublicKeystore)]; + + [keyAttr setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass]; + [keyAttr setObject:refTag forKey:(__bridge id)kSecAttrApplicationTag]; + [keyAttr setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; + [keyAttr setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef]; + + // Get the persistent key reference. + error = SecItemCopyMatching((__bridge CFDictionaryRef)keyAttr, (CFTypeRef *)&publicKeyRef); + + if (publicKeyRef == nil || ( error != noErr && error != errSecDuplicateItem)) { + NSLog(@"Error retrieving public key reference from keychain"); + return NULL; + } + + return (SecKeyRef)publicKeyRef; +} + + +//-(NSData *)RSAencryptData:(NSData *)plainText withPublicKey:(SecKeyRef)pubKey +//{ +// +//} + + ++(BOOL)setPublicKey:(NSData *)rawASN1FormattedKey +{ + /* strip the uncessary ASN encoding guff at the start */ + unsigned char * bytes = (unsigned char *)[rawASN1FormattedKey bytes]; + size_t bytesLen = [rawASN1FormattedKey length]; + + /* Strip the initial stuff */ + size_t i = 0; + if (bytes[i++] != 0x30) + return FALSE; + + /* Skip size bytes */ + if (bytes[i] > 0x80) + i += bytes[i] - 0x80 + 1; + else + i++; + + if (i >= bytesLen) + return FALSE; + + if (bytes[i] != 0x30) + return FALSE; + + /* Skip OID */ + i += 15; + + if (i >= bytesLen - 2) + return FALSE; + + if (bytes[i++] != 0x03) + return FALSE; + + /* Skip length and null */ + if (bytes[i] > 0x80) + i += bytes[i] - 0x80 + 1; + else + i++; + + if (i >= bytesLen) + return FALSE; + + if (bytes[i++] != 0x00) + return FALSE; + + if (i >= bytesLen) + return FALSE; + + /* Here we go! */ + NSData * extractedKey = [NSData dataWithBytes:&bytes[i] length:bytesLen - i]; + + /* Load as a key ref */ + OSStatus error = noErr; + CFTypeRef persistPeer = NULL; + + NSData * refTag = [[NSData alloc] initWithBytes:kSparkSetupSecurityPublicKeystore length:strlen(kSparkSetupSecurityPublicKeystore)]; + NSMutableDictionary * keyAttr = [[NSMutableDictionary alloc] init]; + + [keyAttr setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass]; + [keyAttr setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; + [keyAttr setObject:refTag forKey:(__bridge id)kSecAttrApplicationTag]; + + /* First we delete any current keys */ + /*error = */ + SecItemDelete((__bridge CFDictionaryRef) keyAttr); + + [keyAttr setObject:extractedKey forKey:(__bridge id)kSecValueData]; + [keyAttr setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnPersistentRef]; + + error = SecItemAdd((__bridge CFDictionaryRef) keyAttr, (CFTypeRef *)&persistPeer); + + if (persistPeer == nil || ( error != noErr && error != errSecDuplicateItem)) { + NSLog(@"Problem adding public key to keychain"); + return FALSE; + } + + CFRelease(persistPeer); + + CFTypeRef publicKeyRef = NULL; + + // TODO: call getPublicKey here to remove code duplication + + /* Now we extract the real ref */ + [keyAttr removeAllObjects]; + /* + [keyAttr setObject:(id)persistPeer forKey:(id)kSecValuePersistentRef]; + [keyAttr setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecReturnRef]; + */ + [keyAttr setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass]; + [keyAttr setObject:refTag forKey:(__bridge id)kSecAttrApplicationTag]; + [keyAttr setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType]; + [keyAttr setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef]; + + // Get the persistent key reference. + error = SecItemCopyMatching((__bridge CFDictionaryRef)keyAttr, (CFTypeRef *)&publicKeyRef); + + if (publicKeyRef == nil || ( error != noErr && error != errSecDuplicateItem)) { + NSLog(@"Error retrieving public key reference from chain"); + return FALSE; + } + + + return TRUE; +} + + + ++(NSData *)encryptWithPublicKey:(SecKeyRef)pubKey plainText:(NSData *)plainText +{ + const uint32_t PADDING = kSecPaddingPKCS1; + size_t cipherBufferSize = CIPHER_BUFFER_SIZE; + + uint8_t *cipherBuffer; + cipherBuffer = (uint8_t *)calloc(cipherBufferSize, sizeof(uint8_t)); + + size_t keyBlockSize = SecKeyGetBlockSize(pubKey); +// NSLog(@"SecKeyGetBlockSize() public = %lu",keyBlockSize); + + if (plainText.length > keyBlockSize) + { + NSLog(@"plainText size must be less or equal to key block size"); + free(cipherBuffer); + + return nil; + } + + // Error handling + // Encrypt using the public. + OSStatus status = noErr; + status = SecKeyEncrypt(pubKey, + PADDING, + plainText.bytes, + plainText.length, + &cipherBuffer[0], //remove &,[0]? + &cipherBufferSize + ); + + NSData *cipherText; + if (status == errSecSuccess) + { + cipherText = [NSData dataWithBytes:cipherBuffer length:cipherBufferSize]; + free(cipherBuffer); + return cipherText; + + } + else + { + free(cipherBuffer); + return nil; + } + + +} + + + ++(NSData *)decodeDataFromHexString:(NSString *)hexEncodedString // TODO: move to NSString category under helpers +{ + // command = [command stringByReplacingOccurrencesOfString:@" " withString:@""]; + NSMutableData *data= [[NSMutableData alloc] init]; + unsigned char whole_byte; + char byte_chars[3] = {'\0','\0','\0'}; + for (int i = 0; i < ([hexEncodedString length] / 2); i++) { + byte_chars[0] = [hexEncodedString characterAtIndex:i*2]; + byte_chars[1] = [hexEncodedString characterAtIndex:i*2+1]; + whole_byte = strtol(byte_chars, NULL, 16); + [data appendBytes:&whole_byte length:1]; + } + return data; +} + + ++(NSString *)encodeDataToHexString:(NSData *)buffer // TODO: move to NSString category under helpers +{ + /* Returns hexadecimal string of NSData. */ + const unsigned char *dataBuffer = buffer.bytes; + + if (!dataBuffer) + return nil; + + NSUInteger dataLength = buffer.length; + NSMutableString *hexString = [NSMutableString stringWithCapacity:(dataLength * 2)]; + + for (int i = 0; i < dataLength; ++i) + [hexString appendString:[NSString stringWithFormat:@"%02lx", (unsigned long)dataBuffer[i]]]; + + return hexString; +} + +@end diff --git a/Strike/Pods/SparkSetup/Classes/SparkSetup-Bridging-Header.h b/Strike/Pods/SparkSetup/Classes/SparkSetup-Bridging-Header.h new file mode 100644 index 0000000..56d1519 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/SparkSetup-Bridging-Header.h @@ -0,0 +1,10 @@ +// +// SparkSetup-Bridging-Header.h +// + +#ifndef _SparkSetup_Bridging_Header_h +#define _SparkSetup_Bridging_Header_h + +#include "SparkSetup.h" + +#endif diff --git a/Strike/Pods/SparkSetup/Classes/SparkSetup.h b/Strike/Pods/SparkSetup/Classes/SparkSetup.h new file mode 100644 index 0000000..2d34012 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/SparkSetup.h @@ -0,0 +1,15 @@ +// +// SparkSetup.h +// SparkSetup +// +// Created by Ido on 4/8/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#ifndef SparkSetup_SparkSetup_h +#define SparkSetup_SparkSetup_h + +#import +#import + +#endif diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkConnectingProgressViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkConnectingProgressViewController.h new file mode 100644 index 0000000..38c238f --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkConnectingProgressViewController.h @@ -0,0 +1,19 @@ +// +// SparkConnectiProgressViewController.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/25/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import "SparkSetupUIViewController.h" + +@interface SparkConnectingProgressViewController : SparkSetupUIViewController +@property (nonatomic, strong) NSString *networkName; +@property (nonatomic, strong) NSString *deviceID; +@property (nonatomic, strong) NSString *password; +@property (nonatomic, strong) NSNumber *channel; +@property (nonatomic, strong) NSNumber *security; +@property (nonatomic) BOOL needToClaimDevice; +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkConnectingProgressViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkConnectingProgressViewController.m new file mode 100644 index 0000000..f09631e --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkConnectingProgressViewController.m @@ -0,0 +1,515 @@ +// +// SparkConnectiProgressViewController.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/25/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkConnectingProgressViewController.h" +#import "SparkSetupCommManager.h" +#import "SparkSetupMainController.h" +#import "SparkSetupCustomization.h" +#import "SparkSetupWebViewController.h" +#import +#import "Reachability.h" +#import "SparkCloud.h" +#import "SparkSetupUIElements.h" +#import "SparkSetupResultViewController.h" +#ifdef ANALYTICS +#import "Mixpanel.h" +#endif + +NSInteger const kMaxRetriesDisconnectFromDevice = 10; +NSInteger const kMaxRetriesClaim = 15; +NSInteger const kMaxRetriesConfigureAP = 5; +NSInteger const kMaxRetriesConnectAP = 5; +NSInteger const kMaxRetriesReachability = 5; +NSInteger const kWaitForCloudConnectionTime = 3; + +typedef NS_ENUM(NSInteger, SparkSetupConnectionProgressState) { + SparkSetupConnectionProgressStateConfigureCredentials = 0, + SparkSetupConnectionProgressStateConnectToWifi, + SparkSetupConnectionProgressStateWaitForCloudConnection, + SparkSetupConnectionProgressStateCheckInternetConnectivity, + SparkSetupConnectionProgressStateVerifyDeviceOwnership, + __SparkSetupConnectionProgressStateLast +}; + +@interface SparkConnectingProgressView : UIView +@property (nonatomic, weak) IBOutlet UILabel *label; +@property (nonatomic, weak) IBOutlet UIImageView *spinner; +@end + +@implementation SparkConnectingProgressView + +@end + + +@interface SparkConnectingProgressViewController () +@property (weak, nonatomic) IBOutlet UILabel *ssidLabel; +@property (nonatomic, strong) NSMutableArray *connectionProgressTextList; +@property (weak, nonatomic) IBOutlet UILabel *deviceIsConnectingLabel; +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; +//@property (weak, nonatomic) IBOutlet UIButton *troubleshootingButton; +@property (strong, nonatomic) SparkDevice *device; + +@property (strong, nonatomic) Reachability *hostReachability; +@property (nonatomic) BOOL hostReachable; +@property (nonatomic) BOOL apiReachable; +@property (nonatomic) NSInteger claimRetries; +@property (nonatomic) NSInteger configureRetries; +@property (nonatomic) NSInteger connectAPRetries; +@property (nonatomic) NSInteger disconnectRetries; +@property (nonatomic, strong) UIAlertView *errorAlertView; +//@property (nonatomic) BOOL connectAPsent, disconnectedFromDevice; +@property (nonatomic) SparkSetupResult setupResult; +@property (atomic) SparkSetupConnectionProgressState currentState; +@property (nonatomic, strong) SparkConnectingProgressView *currentStateView; +@property (strong, nonatomic) IBOutletCollection(SparkConnectingProgressView) NSArray *progressViews; + +@property (weak, nonatomic) IBOutlet UIImageView *wifiSymbolImageView; +@end + +@implementation SparkConnectingProgressViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.currentState = SparkSetupConnectionProgressStateConfigureCredentials; + + self.ssidLabel.text = self.networkName; + self.connectionProgressTextList = [[NSMutableArray alloc] init]; + + // set logo + self.brandImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + // force load from resource bundle + self.wifiSymbolImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"wifi3"]; + + self.hostReachable = NO; + self.apiReachable = NO; + self.hostReachability = [Reachability reachabilityWithHostName:@"api.particle.io"]; //TODO: change to https://api... + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil]; + [self.hostReachability startNotifier]; + +// self.connectAPsent = NO; +// self.disconnectedFromDevice = NO; + + if ([SparkSetupCustomization sharedInstance].tintSetupImages) + { + self.wifiSymbolImageView.image = [self.wifiSymbolImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.wifiSymbolImageView.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor;// elementBackgroundColor;; + } +} + +-(void)viewWillAppear:(BOOL)animated +{ + self.currentStateView = self.progressViews[self.currentState]; + self.currentStateView.hidden = NO; + self.currentStateView.label.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + self.currentStateView.label.textColor = [SparkSetupCustomization sharedInstance].normalTextColor; + [self startAnimatingSpinner:self.currentStateView.spinner]; + [self tintConnectionProgressStateSpinner]; +#ifdef ANALYTICS + [[Mixpanel sharedInstance] timeEvent:@"Device Setup: Connecting progress screen activity"]; +#endif + +} + + + + +- (void)reachabilityChanged:(NSNotification *)note +{ + Reachability* curReach = [note object]; + NSParameterAssert([curReach isKindOfClass:[Reachability class]]); + NetworkStatus netStatus = [curReach currentReachabilityStatus]; + + switch (netStatus) + { + case NotReachable: + { +// NSLog(@"reachabilityChanged -- NO"); + self.hostReachable = NO; + break; + } + + case ReachableViaWWAN: + { +// NSLog(@"reachabilityChanged -- YES 3G"); + self.hostReachable = YES; // we want to make sure device changed wifis + break; + } + case ReachableViaWiFi: + { +// NSLog(@"reachabilityChanged -- YES WiFi"); + self.hostReachable = YES; + break; + } + } + + +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + + +-(void)setCurrentConnectionProgressStateError:(BOOL)isError +{ + dispatch_async(dispatch_get_main_queue(), ^{ + [self stopAnimatingSpinner:self.currentStateView.spinner]; + NSString *stateImageName = (isError) ? @"x" : @"checkmark"; + self.currentStateView.spinner.image = [UIImage imageNamed:stateImageName inBundle:[SparkSetupMainController getResourcesBundle] compatibleWithTraitCollection:nil]; // TODO: make iOS7 compatible + [self tintConnectionProgressStateSpinner]; + }); +} + + +-(void)tintConnectionProgressStateSpinner +{ + self.currentStateView.spinner.image = [self.currentStateView.spinner.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + if ([SparkSetupCustomization sharedInstance].tintSetupImages) + { + self.currentStateView.spinner.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor; + } + else + { + self.currentStateView.spinner.tintColor = [SparkSetupCustomization sharedInstance].elementBackgroundColor; + } + +} + +-(void)nextConnectionProgressState +{ + NSLog(@"nextConnectionProgressState called, current state: %ld",(long)self.currentState); + + + dispatch_async(dispatch_get_main_queue(), ^{ + + [self stopAnimatingSpinner:self.currentStateView.spinner]; + self.currentStateView.spinner.image = [UIImage imageNamed:@"checkmark" inBundle:[SparkSetupMainController getResourcesBundle] compatibleWithTraitCollection:nil]; // TODO: make iOS7 compatible + [self tintConnectionProgressStateSpinner]; + self.currentState++; + if (self.currentState < __SparkSetupConnectionProgressStateLast) + { + self.currentStateView = self.progressViews[self.currentState]; + self.currentStateView.hidden = NO; + self.currentStateView.label.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + self.currentStateView.label.textColor = [SparkSetupCustomization sharedInstance].normalTextColor; + [self tintConnectionProgressStateSpinner]; + [self startAnimatingSpinner:self.currentStateView.spinner]; + } + }); +} + + + +-(void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + self.configureRetries = 0; + +// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [self configureDeviceNetworkCredentials]; + +} + + +-(void)finishSetupWithResult:(SparkSetupResult)result +{ + self.setupResult = result; + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1.5 * NSEC_PER_SEC); + dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + [self performSegueWithIdentifier:@"done" sender:self]; + }); +} + +-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + if ([segue.identifier isEqualToString:@"done"]) + { + SparkSetupResultViewController *resultVC = segue.destinationViewController; + resultVC.device = self.device; + resultVC.setupResult = self.setupResult; + } +} + +-(void)configureDeviceNetworkCredentials // step 0 +{ + + // --- Configure-AP --- + __block SparkSetupCommManager *managerForConfigure = [[SparkSetupCommManager alloc] init]; + + [managerForConfigure configureAP:self.networkName passcode:self.password security:self.security channel:self.channel completion:^(id responseCode, NSError *error) { + NSLog(@"configureAP sent"); + if ((error) || ([responseCode intValue]!=0)) + { + if (self.currentState == SparkSetupConnectionProgressStateConfigureCredentials) + { + self.configureRetries++; + if (self.configureRetries >= kMaxRetriesConfigureAP-1) + { + [self setCurrentConnectionProgressStateError:YES]; + [self finishSetupWithResult:SparkSetupResultFailureConfigure]; + } + else + { + [self configureDeviceNetworkCredentials]; + } + } + } + else + { + if (self.currentState == SparkSetupConnectionProgressStateConfigureCredentials) + { + [self nextConnectionProgressState]; + self.connectAPRetries = 0; + self.disconnectRetries = 0; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self connectDeviceToNetwork]; + + }); + } + + } + }]; +} + + + + +-(void)connectDeviceToNetwork // step 1 +{ + // --- Connect-AP --- + SparkSetupCommManager *managerForConnect = [[SparkSetupCommManager alloc] init]; +// self.connectAPsent = YES; +// if (!self.disconnectedFromDevice) + if (self.currentState == SparkSetupConnectionProgressStateConnectToWifi) + { + [managerForConnect connectAP:^(id responseCode, NSError *error) { + while (([SparkSetupCommManager checkSparkDeviceWifiConnection:[SparkSetupCustomization sharedInstance].networkNamePrefix]) && (self.disconnectRetries < kMaxRetriesDisconnectFromDevice)) + { + [NSThread sleepForTimeInterval:2.0]; + self.disconnectRetries++; + } + + // are we still connected to device? + if ([SparkSetupCommManager checkSparkDeviceWifiConnection:[SparkSetupCustomization sharedInstance].networkNamePrefix]) + { + if (self.connectAPRetries++ >= kMaxRetriesConnectAP) + { + [self setCurrentConnectionProgressStateError:YES]; + [self finishSetupWithResult:SparkSetupResultFailureCannotDisconnectFromDevice]; + } + else + { + self.disconnectRetries = 0; + [self connectDeviceToNetwork]; // recursion retry sending connect-ap + } + } + else + { + if (self.currentState == SparkSetupConnectionProgressStateConnectToWifi) + { + [self nextConnectionProgressState]; + [self waitForCloudConnection]; + } + } + }]; + } + +} + + +-(void)waitForCloudConnection // step 2 +{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kWaitForCloudConnectionTime * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [self nextConnectionProgressState]; + [self checkForInternetConnectivity]; + + }); + + +} + +-(void)checkForInternetConnectivity // step 3 +{ + + // --- reachability check --- + if (!self.hostReachable) + { + for (int i=0; i= kMaxRetriesClaim-1) + { + [self setCurrentConnectionProgressStateError:YES]; + [self finishSetupWithResult:SparkSetupResultFailureClaiming]; + } + else + { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + [self checkDeviceIsClaimed]; // recursion retry + }); + + } + } + else + { +// NSLog(@"Claim success"); + // get the claimed device to report it back to the user + [[SparkCloud sharedInstance] getDevice:self.deviceID completion:^(SparkDevice *device, NSError *error) { + // --- Done --- + if (!error) + { + self.device = device; + [self nextConnectionProgressState]; + + if (device.connected) + self.setupResult = SparkSetupResultSuccess; + else + self.setupResult = SparkSetupResultSuccessDeviceOffline; + + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC); + dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + [self performSegueWithIdentifier:@"done" sender:self]; + }); + } + else + { + [self setCurrentConnectionProgressStateError:YES]; + [self finishSetupWithResult:SparkSetupResultFailureClaiming]; + } + }]; + + + } + }]; + +} + + + + + +- (void)dealloc +{ +// NSLog(@"-- removed kReachabilityChangedNotification"); + [self.hostReachability stopNotifier]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil]; + +} + + +-(void)viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; +// NSLog(@"-- removed kReachabilityChangedNotification"); + [self.hostReachability stopNotifier]; +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Connecting progress screen activity"]; +#endif + + [[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil]; +} + + +-(void)startAnimatingSpinner:(UIImageView *)spinner +{ + spinner.hidden = NO; + CABasicAnimation *rotation; + rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; + rotation.fromValue = [NSNumber numberWithFloat:0]; + rotation.toValue = [NSNumber numberWithFloat:(2*M_PI)]; + rotation.duration = 1.1; // Speed + rotation.repeatCount = HUGE_VALF; // Repeat forever. Can be a finite number. + [spinner.layer addAnimation:rotation forKey:@"Spin"]; +} + + +-(void)stopAnimatingSpinner:(UIImageView *)spinner + +{ +// spinner.hidden = YES; + [spinner.layer removeAllAnimations]; +} + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkDiscoverDeviceViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkDiscoverDeviceViewController.h new file mode 100644 index 0000000..05653c1 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkDiscoverDeviceViewController.h @@ -0,0 +1,17 @@ +// +// SparkDiscoverDeviceViewController.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/16/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import "SparkSetupUIViewController.h" +#import "SparkSetupMainController.h" + +@interface SparkDiscoverDeviceViewController : SparkSetupUIViewController +@property (nonatomic, strong) NSString *claimCode; +@property (nonatomic, strong) NSArray *claimedDevices; + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkDiscoverDeviceViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkDiscoverDeviceViewController.m new file mode 100644 index 0000000..7c01816 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkDiscoverDeviceViewController.m @@ -0,0 +1,596 @@ +// +// SparkDiscoverDeviceViewController.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/16/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkDiscoverDeviceViewController.h" +#import "SparkSetupConnection.h" +#import "SparkSetupCommManager.h" +#import "SparkSelectNetworkViewController.h" +#import +#import "SparkCloud.h" +#import "SparkSetupSecurityManager.h" +#import "SparkSetupUILabel.h" +//#import "UIViewController+SparkSetupCommManager.h" +#import "SparkSetupUIElements.h" +#import "SparkSetupVideoViewController.h" +#import +#import "SparkSetupCustomization.h" +#import "SparkSetupConnection.h" +#import "SparkSetupCommManager.h" + +#ifdef ANALYTICS +#import +#endif + +@interface SparkDiscoverDeviceViewController () +@property (weak, nonatomic) IBOutlet UIImageView *wifiSignalImageView; + +@property (weak, nonatomic) IBOutlet UILabel *networkNameLabel; +@property (weak, nonatomic) IBOutlet UIButton *troubleShootingButton; +@property (weak, nonatomic) IBOutlet UIImageView *brandImage; +@property (strong, nonatomic) NSArray *scannedWifiList; +@property (weak, nonatomic) IBOutlet UIButton *cancelSetupButton; +@property (weak, nonatomic) IBOutlet SparkSetupUILabel *step3Label; +@property (weak, nonatomic) IBOutlet SparkSetupUIButton *readyButton; + + + +@property (weak, nonatomic) IBOutlet SparkSetupUISpinner *spinner; +@property (weak, nonatomic) IBOutlet SparkSetupUIButton *showMeHowButton; + +// new background local notification feature +@property (nonatomic) UIBackgroundTaskIdentifier backgroundTask; +@property (nonatomic, strong) NSTimer *backgroundTaskTimer; + +@property (strong, nonatomic) NSTimer *checkConnectionTimer; +@property (atomic, strong) NSString *detectedDeviceID; +@property (atomic) BOOL gotPublicKey; +@property (atomic) BOOL gotOwnershipInfo; +@property (atomic) BOOL didGoToWifiListScreen; +@property (nonatomic) BOOL isDetectedDeviceClaimed; +@property (nonatomic) BOOL needToCheckDeviceClaimed; +@property (nonatomic) BOOL userAlreadyOwnsDevice; +@property (nonatomic) BOOL deviceClaimedByUser; +@property (nonatomic, strong) UIAlertView *changeOwnershipAlertView; +@property (weak, nonatomic) IBOutlet UIView *wifiView; +@property (nonatomic, strong) SparkSetupConnection *tryConn; + + +@property (weak, nonatomic) IBOutlet UIImageView *connectToWifiImageView; +@property (weak, nonatomic) IBOutlet UIImageView *wifiInfoImageView; +@property (weak, nonatomic) IBOutlet UIImageView *checkmarkImageView; + +@end + +@implementation SparkDiscoverDeviceViewController + +-(void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self + name:UIApplicationDidBecomeActiveNotification + object:nil]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + self.didGoToWifiListScreen = NO; + + self.backgroundTask = UIBackgroundTaskInvalid; + self.showMeHowButton.hidden = [SparkSetupCustomization sharedInstance].instructionalVideoFilename ? NO : YES; + + // Do any additional setup after loading the view. + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(viewDidAppear:) + name:UIApplicationDidBecomeActiveNotification object:nil]; + + // customize logo + self.brandImage.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImage.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + // force load of images from resource bundle + self.connectToWifiImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"connect-to-wifi"]; + self.checkmarkImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"iosCheckmark"]; + self.wifiInfoImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"iosSettingWifi"]; + +// self.wifiSignalImageView.image = [UIImage imageNamed:@"iosSettingsWifi" inBundle:[SparkSetupMainController getResourcesBundle] compatibleWithTraitCollection:nil]; // TODO: make iOS7 compatible + self.wifiSignalImageView.hidden = NO; + self.needToCheckDeviceClaimed = NO; + + self.gotPublicKey = NO; + self.gotOwnershipInfo = NO; + + self.networkNameLabel.text = [NSString stringWithFormat:@"%@-XXXX",[SparkSetupCustomization sharedInstance].networkNamePrefix]; + self.wifiView.layer.borderColor = [UIColor lightGrayColor].CGColor; + self.wifiView.layer.borderWidth = 1.0f; + +// self.cancelSetupButton. // customize color too + self.cancelSetupButton.titleLabel.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].headerTextFontName size:self.self.cancelSetupButton.titleLabel.font.pointSize]; + [self.cancelSetupButton setTitleColor:[SparkSetupCustomization sharedInstance].normalTextColor forState:UIControlStateNormal]; + + +#ifdef ANALYTICS + [[Mixpanel sharedInstance] timeEvent:@"Device Setup: Device discovery screen activity"]; +#endif + + +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +-(void)resetWifiSignalIconWithDelay +{ + // TODO: this is a little bit of a hack + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ +// self.wifiSignalImageView.image = [UIImage imageNamed:@"iosSettingsWifi" inBundle:[SparkSetupMainController getResourcesBundle] compatibleWithTraitCollection:nil]; // TODO: make iOS7 compatible + [self.spinner stopAnimating]; + self.wifiSignalImageView.hidden = NO; + }); +} + +-(void)restartDeviceDetectionTimer +{ +// NSLog(@"restartDeviceDetectionTimer called"); + [self.checkConnectionTimer invalidate]; + self.checkConnectionTimer = nil; + + if (!self.didGoToWifiListScreen) + self.checkConnectionTimer = [NSTimer scheduledTimerWithTimeInterval:2.5f target:self selector:@selector(checkDeviceWifiConnection:) userInfo:nil repeats:YES]; +} + +-(void)goToWifiListScreen +{ + if (self.didGoToWifiListScreen == NO) + { + self.didGoToWifiListScreen = YES; + [self performSegueWithIdentifier:@"select_network" sender:self]; + } +} + + +-(void)willPopBackToDeviceDiscovery +{ + NSLog(@"willPopBackToDeviceDiscovery"); + self.didGoToWifiListScreen = NO; + [self restartDeviceDetectionTimer]; +} + +- (IBAction)readyButton:(id)sender +{ + +} + + + +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + // TODO: solve this via autolayout? + + + self.spinner.image = [self.spinner.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.spinner.tintColor = [UIColor blackColor]; + [self scheduleBackgroundTask]; + +} + +-(void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + [self restartDeviceDetectionTimer]; +} + +-(void)checkDeviceConnectionForNotification:(NSTimer *)timer +{ + UIApplicationState state = [[UIApplication sharedApplication] applicationState]; + if (state == UIApplicationStateBackground || state == UIApplicationStateInactive) + { +// NSLog(@"checkDeviceConnectionForNotification (background)"); + + if ([SparkSetupCommManager checkSparkDeviceWifiConnection:[SparkSetupCustomization sharedInstance].networkNamePrefix]) + { + UILocalNotification *localNotification = [[UILocalNotification alloc] init]; + localNotification.alertAction = @"Connected"; + NSString *notifText = [NSString stringWithFormat:@"Your phone has connected to %@. Tap to continue Setup.",[SparkSetupCustomization sharedInstance].deviceName]; + localNotification.alertBody = notifText; + localNotification.alertAction = @"open"; // text that is displayed after "slide to..." on the lock screen - defaults to "slide to view" + localNotification.soundName = UILocalNotificationDefaultSoundName; // play default sound + localNotification.fireDate = [[NSDate alloc] initWithTimeIntervalSinceNow:0]; + [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; + [timer invalidate]; + } + } +} + +-(void)scheduleBackgroundTask +{ + [self.backgroundTaskTimer invalidate]; + self.backgroundTaskTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 + target:self + selector:@selector(checkDeviceConnectionForNotification:) + userInfo:nil + repeats:YES]; + + + self.backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ +// NSLog(@"Background handler called. Not running background tasks anymore."); + [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask]; + self.backgroundTask = UIBackgroundTaskInvalid; + }]; + +} + + + +-(void)SparkSetupConnection:(SparkSetupConnection *)connection didUpdateState:(SparkSetupConnectionState)state error:(NSError *)error +{ + if (state == SparkSetupConnectionStateOpened) + { +// NSLog(@"Photon detected!"); + [connection close]; + [self startPhotonQuery]; + } +} + +-(void)startPhotonQuery +{ + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) + { + [self.checkConnectionTimer invalidate]; + + dispatch_async(dispatch_get_main_queue(), ^{ + + // UI activity indicator + self.wifiSignalImageView.hidden = YES; + [self.spinner startAnimating]; + }); + + // Start connection command chain process with a small delay + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self getDeviceID]; + }); + + } + +} + + +-(void)checkDeviceWifiConnection:(id)sender +{ + // printf("Detect device timer\n"); + + + UIApplicationState state = [[UIApplication sharedApplication] applicationState]; + if (state == UIApplicationStateActive) + { + // NSLog(@"SparkDiscover -> checkDeviceWifiConnection timer"); + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + if ([SparkSetupCommManager checkSparkDeviceWifiConnection:[SparkSetupCustomization sharedInstance].networkNamePrefix]) + { + [self startPhotonQuery]; + } + }); + } + +} + + + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + [[NSNotificationCenter defaultCenter] removeObserver:self + name:UIApplicationDidBecomeActiveNotification + object:nil]; + + // Make sure your segue name in storyboard is the same as this line + if ([[segue identifier] isEqualToString:@"select_network"]) + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Device discovery screen activity"]; +#endif + + [self.checkConnectionTimer invalidate]; + // Get reference to the destination view controller + SparkSelectNetworkViewController *vc = [segue destinationViewController]; + [vc setWifiList:self.scannedWifiList]; + vc.deviceID = self.detectedDeviceID; + vc.delegate = self; + vc.needToClaimDevice = self.needToCheckDeviceClaimed; + } + else if ([segue.identifier isEqualToString:@"video"]) + { + SparkSetupVideoViewController *vc = segue.destinationViewController; + vc.videoFilePath = [SparkSetupCustomization sharedInstance].instructionalVideoFilename; + } + +} + + +-(void)getDeviceID +{ + if (!self.detectedDeviceID) + { + NSLog(@"DeviceID sent"); + + SparkSetupCommManager *manager = [[SparkSetupCommManager alloc] init]; + [self.checkConnectionTimer invalidate]; + [manager deviceID:^(id deviceResponseDict, NSError *error) + { + if (error) + { + NSLog(@"Could not send device-id command: %@", error.localizedDescription); + [self restartDeviceDetectionTimer]; + [self resetWifiSignalIconWithDelay]; + + } + else + { + + self.detectedDeviceID = (NSString *)deviceResponseDict[@"id"]; //TODO: fix that dict interpretation is done in comm manager (layer completion) + self.detectedDeviceID = [self.detectedDeviceID lowercaseString]; + self.isDetectedDeviceClaimed = [deviceResponseDict[@"c"] boolValue]; + NSLog(@"DeviceID response received: %@",self.detectedDeviceID ); + + [self photonPublicKey]; +// NSLog(@"Got device ID: %@",deviceResponseDict); + } + }]; + } + else + { +// NSLog(@"getDeviceID called again"); + [self photonPublicKey]; + } +} + + + + +-(void)photonScanAP +{ + if (!self.scannedWifiList) + { + SparkSetupCommManager *manager = [[SparkSetupCommManager alloc] init]; + NSLog(@"ScanAP sent"); + [manager scanAP:^(id scanResponse, NSError *error) { + if (error) + { + NSLog(@"Could not send scan-ap command: %@",error.localizedDescription); + [self restartDeviceDetectionTimer]; + [self resetWifiSignalIconWithDelay]; + } + else + { + if (scanResponse) + { + NSLog(@"ScanAP response received"); + self.scannedWifiList = scanResponse; +// NSLog(@"Scan data:\n%@",self.scannedWifiList); + [self checkDeviceOwnershipChange]; + + } + + } + }]; + } + else + { + [self checkDeviceOwnershipChange]; + } + +} + + +-(void)checkDeviceOwnershipChange +{ + if (!self.gotOwnershipInfo) + { + [self.checkConnectionTimer invalidate]; + self.needToCheckDeviceClaimed = NO; + +// self.isDetectedDeviceClaimed = YES; // DEBUG + if (!self.isDetectedDeviceClaimed) // device was never claimed before - so we need to claim it anyways + { + self.needToCheckDeviceClaimed = YES; + [self setDeviceClaimCode]; + } + else + { + self.deviceClaimedByUser = NO; + + for (NSString *claimedDeviceID in self.claimedDevices) + { + if ([claimedDeviceID isEqualToString:self.detectedDeviceID]) + { + self.deviceClaimedByUser = YES; + } + } + + // if the user already owns the device it does not need to be set with a claim code but claiming check should be performed as last stage of setup process + if (self.deviceClaimedByUser) + self.needToCheckDeviceClaimed = YES; + + self.gotOwnershipInfo = YES; + + if ((self.isDetectedDeviceClaimed == YES) && (self.deviceClaimedByUser == NO)) + { + if (!self.didGoToWifiListScreen) + { + + if ([SparkCloud sharedInstance].isLoggedIn) + { + // that means device is claimed by somebody else - we want to check that with user (and set claimcode if user wants to change ownership) + NSString *messageStr = [NSString stringWithFormat:@"This %@ is has been setup before, do you want to override ownership to %@?",[SparkSetupCustomization sharedInstance].deviceName,[SparkCloud sharedInstance].loggedInUsername]; + self.changeOwnershipAlertView = [[UIAlertView alloc] initWithTitle:@"Product ownership" message:messageStr delegate:self cancelButtonTitle:nil otherButtonTitles:@"Yes",@"No",nil]; + [self.checkConnectionTimer invalidate]; + [self.changeOwnershipAlertView show]; + } + else // user skipped authentication so no need to claim or set claim code + { + self.needToCheckDeviceClaimed = NO; + [self goToWifiListScreen]; + + } + } + } + else + { + // no need to set claim code because the device is owned by current user + [self goToWifiListScreen]; + } + + } + + // all cases: +// (1) device not claimed c=0 — device should also not be in list from API => mobile app assumes user is claiming and sets device claimCode + check its claimed at last stage +// (2) device claimed c=1 and already in list from API => mobile app does not ask user about taking ownership because device already belongs to this user, does NOT set claimCode to device (no need) but does check ownership in last setup step +// (3) device claimed c=1 and NOT in the list from the API => mobile app asks whether user would like to take ownership. YES: set claimCode and check ownership in last step, NO: doesn't set claimCode, doesn't check ownership in last step + } + else + { + if (self.needToCheckDeviceClaimed) + { + if (!self.deviceClaimedByUser) + [self setDeviceClaimCode]; + } + else + [self goToWifiListScreen]; + + } + + +} + + +-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + if (alertView == self.changeOwnershipAlertView) + { + NSLog(@"button index %ld",(long)buttonIndex); + if (buttonIndex == 0) //YES + { + self.needToCheckDeviceClaimed = YES; + [self setDeviceClaimCode]; + } + else + { + self.needToCheckDeviceClaimed = NO; + [self goToWifiListScreen]; + } + } +} + + + + +-(void)photonPublicKey +{ + if (!self.gotPublicKey) + { + NSLog(@"PublicKey sent"); + SparkSetupCommManager *manager = [[SparkSetupCommManager alloc] init]; + [self.checkConnectionTimer invalidate]; + [manager publicKey:^(id responseCode, NSError *error) { + if (error) + { + NSLog(@"Error sending public-key command to target: %@",error.localizedDescription); + [self restartDeviceDetectionTimer]; // TODO: better error handling + [self resetWifiSignalIconWithDelay]; + + } + else + { + NSInteger code = [responseCode integerValue]; + if (code != 0) + { + NSLog(@"Public key retrival error"); + [self restartDeviceDetectionTimer]; // TODO: better error handling + [self resetWifiSignalIconWithDelay]; + + } + else + { + NSLog(@"PublicKey response received"); + self.gotPublicKey = YES; + [self photonScanAP]; + } + } + }]; + } + else + { + [self photonScanAP]; + } +} + + + + +-(void)setDeviceClaimCode +{ + SparkSetupCommManager *manager = [[SparkSetupCommManager alloc] init]; + [self.checkConnectionTimer invalidate]; + NSLog(@"Claim code - trying to set"); + [manager setClaimCode:self.claimCode completion:^(id responseCode, NSError *error) { + if (error) + { + NSLog(@"Could not send set command: %@", error.localizedDescription); + [self restartDeviceDetectionTimer]; + } + else + { + NSLog(@"Device claim code set successfully: %@",self.claimCode); + // finished - segue + [self goToWifiListScreen]; + + } + }]; + +} + + + + +-(void)getDeviceVersion +{ + SparkSetupCommManager *manager = [[SparkSetupCommManager alloc] init]; + [self.checkConnectionTimer invalidate]; + [manager version:^(id version, NSError *error) { + if (error) + { + NSLog(@"Could not send version command: %@",error.localizedDescription); + } + else + { + NSString *versionStr = version; + NSLog(@"Device version:\n%@",versionStr); + } + }]; +} + + + +- (IBAction)cancelButtonTouched:(id)sender +{ + // finish gracefully + [self.checkConnectionTimer invalidate]; + self.checkConnectionTimer = nil; + [[NSNotificationCenter defaultCenter] postNotificationName:kSparkSetupDidFinishNotification object:nil userInfo:@{kSparkSetupDidFinishStateKey:@(SparkSetupMainControllerResultUserCancel)}]; + + +} + + + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkGetReadyViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkGetReadyViewController.h new file mode 100644 index 0000000..8dd7ccb --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkGetReadyViewController.h @@ -0,0 +1,13 @@ +// +// SparkGetReadyViewController.h +// teacup-ios-app +// +// Created by Ido on 1/15/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupUIViewController.h" + +@interface SparkGetReadyViewController : SparkSetupUIViewController + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkGetReadyViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkGetReadyViewController.m new file mode 100644 index 0000000..3ea6844 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkGetReadyViewController.m @@ -0,0 +1,219 @@ +// +// SparkGetReadyViewController.m +// teacup-ios-app +// +// Created by Ido on 1/15/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkGetReadyViewController.h" +#import "SparkSetupWebViewController.h" +#import +#import "SparkCloud.h" +#import "SparkSetupMainController.h" +#import "SparkDiscoverDeviceViewController.h" +#import "SparkSetupUIElements.h" +#import "SparkSetupResultViewController.h" +#import "SparkSetupCustomization.h" +#ifdef ANALYTICS +#import +#endif + + +@interface SparkGetReadyViewController () +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; +@property (weak, nonatomic) IBOutlet UIButton *readyButton; +@property (weak, nonatomic) IBOutlet SparkSetupUISpinner *spinner; + +@property (weak, nonatomic) IBOutlet UILabel *loggedInLabel; +@property (weak, nonatomic) IBOutlet SparkSetupUILabel *instructionsLabel; +//@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollViewHeight; + +@property (weak, nonatomic) IBOutlet UIImageView *productImageView; + +// new claiming process +@property (nonatomic, strong) NSString *claimCode; +@property (nonatomic, strong) NSArray *claimedDevices; +@property (weak, nonatomic) IBOutlet SparkSetupUIButton *logoutButton; +@property (weak, nonatomic) IBOutlet UIButton *cancelSetupButton; +@property (weak, nonatomic) IBOutlet SparkSetupUILabel *loggedInUserLabel; + +@end + +@implementation SparkGetReadyViewController + + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + self.brandImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + if ([SparkSetupCustomization sharedInstance].productImage) + self.productImageView.image = [SparkSetupCustomization sharedInstance].productImage; + + if ([SparkCloud sharedInstance].loggedInUsername) + self.loggedInLabel.text = [self.loggedInLabel.text stringByAppendingString:[SparkCloud sharedInstance].loggedInUsername]; + else + self.loggedInLabel.text = @""; + self.loggedInLabel.alpha = 0.85; + self.logoutButton.titleLabel.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].headerTextFontName size:self.logoutButton.titleLabel.font.pointSize]; + [self.logoutButton setTitleColor:[SparkSetupCustomization sharedInstance].normalTextColor forState:UIControlStateNormal]; + + // self.cancelSetupButton. // customize color too + self.cancelSetupButton.titleLabel.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].headerTextFontName size:self.self.cancelSetupButton.titleLabel.font.pointSize]; + [self.cancelSetupButton setTitleColor:[SparkSetupCustomization sharedInstance].normalTextColor forState:UIControlStateNormal]; + + if ([SparkCloud sharedInstance].isLoggedIn) + { + self.loggedInLabel.text = [SparkCloud sharedInstance].loggedInUsername; + } + else + { + [self.logoutButton setTitle:@"Log in" forState:UIControlStateNormal]; + self.loggedInLabel.text = @""; + } + if ([SparkSetupCustomization sharedInstance].disableLogOutOption) { + self.logoutButton.hidden = YES; + } +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. + +} + +- (IBAction)cancelSetup:(id)sender { + [[NSNotificationCenter defaultCenter] postNotificationName:kSparkSetupDidFinishNotification object:nil userInfo:@{kSparkSetupDidFinishStateKey:@(SparkSetupMainControllerResultUserCancel)}]; + +} + + +-(void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; +// self.videoViewWidth.constant = ((self.videoView.frame.size.height * 9.0)/16.0); + + UIUserNotificationType types = UIUserNotificationTypeAlert|UIUserNotificationTypeSound; + UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; + [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; + + + if (isiPhone4) + { + self.instructionsLabel.text = [NSString stringWithFormat:@"Scroll down for more instructions:\n%@",self.instructionsLabel.text]; + [self.view setNeedsUpdateConstraints]; + + [UIView animateWithDuration:0.25f animations:^{ + [self.view layoutIfNeeded]; + }]; + } + + +} + +- (IBAction)troubleShootingButtonTapped:(id)sender +{ + SparkSetupWebViewController* webVC = [[UIStoryboard storyboardWithName:@"setup" bundle:[NSBundle bundleWithIdentifier:SPARK_SETUP_RESOURCE_BUNDLE_IDENTIFIER]] instantiateViewControllerWithIdentifier:@"webview"]; + webVC.link = [SparkSetupCustomization sharedInstance].troubleshootingLinkURL; + [self presentViewController:webVC animated:YES completion:nil]; + +} + +-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + if ([[segue identifier] isEqualToString:@"discover"]) + { + SparkDiscoverDeviceViewController *vc = [segue destinationViewController]; + vc.claimCode = self.claimCode; + vc.claimedDevices = self.claimedDevices; + } +} + + +- (IBAction)readyButtonTapped:(id)sender +{ + [self.spinner startAnimating]; + self.readyButton.userInteractionEnabled = NO; + + + + // [[SparkCloud sharedInstance] generateClaimCode + void (^claimCodeCompletionBlock)(NSString *, NSArray *, NSError *) = ^void(NSString *claimCode, NSArray *userClaimedDeviceIDs, NSError *error) { + // [[SparkCloud sharedInstance] generateClaimCode:^(NSString *claimCode, NSArray *userClaimedDeviceIDs, NSError *error) { + + self.readyButton.userInteractionEnabled = YES; + [self.spinner stopAnimating]; + + if (!error) + { + self.claimCode = claimCode; + self.claimedDevices = userClaimedDeviceIDs; + // NSLog(@"Got claim code: %@",self.claimCode); + // NSLog(@"Devices IDs owned by user: %@",self.claimedDevices); + [self performSegueWithIdentifier:@"discover" sender:self]; + + } + else + { + if (error.code == 401)// localizedDescription containsString:@"unauthorized"]) + { + NSString *errStr = [NSString stringWithFormat:@"Sorry, you must be logged in as a %@ customer.",[SparkSetupCustomization sharedInstance].brandName]; + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Access denied" message:errStr delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + [[SparkCloud sharedInstance] logout]; + // call main delegate or post notification + [[NSNotificationCenter defaultCenter] postNotificationName:kSparkSetupDidLogoutNotification object:nil userInfo:nil]; + } + else + { + NSString *errStr = [NSString stringWithFormat:@"Could not communicate with Particle cloud. Make sure your iOS device is connected to the internet and retry.\n\n(%@)",error.localizedDescription]; + UIAlertView *errorAlertView = [[UIAlertView alloc] initWithTitle:@"Error" message:errStr delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + errorAlertView.delegate = self; + [errorAlertView show]; + } + } + }; + + if ([SparkCloud sharedInstance].isLoggedIn) + { + if ([SparkSetupCustomization sharedInstance].organization) + { + [[SparkCloud sharedInstance] generateClaimCodeForOrganization:[SparkSetupCustomization sharedInstance].organizationSlug andProduct:[SparkSetupCustomization sharedInstance].productSlug withActivationCode:nil completion:claimCodeCompletionBlock]; + } + else + { + [[SparkCloud sharedInstance] generateClaimCode:claimCodeCompletionBlock]; + } + } + else + { + // authentication skipped by user + [self performSegueWithIdentifier:@"discover" sender:self]; + } + + +} + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Get ready screen"]; +#endif +} + + + +- (IBAction)logoutButtonTouched:(id)sender +{ +// [self.checkConnectionTimer invalidate]; + [[SparkCloud sharedInstance] logout]; + // call main delegate or post notification + [[NSNotificationCenter defaultCenter] postNotificationName:kSparkSetupDidLogoutNotification object:nil userInfo:nil]; + // [self.navigationController popToRootViewControllerAnimated:YES]; + +} + + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkManualNetworkViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkManualNetworkViewController.h new file mode 100644 index 0000000..a374f73 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkManualNetworkViewController.h @@ -0,0 +1,14 @@ +// +// SparkManualNetworkViewController.h +// teacup-ios-app +// +// Created by Ido on 2/22/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupUIViewController.h" + +@interface SparkManualNetworkViewController : SparkSetupUIViewController +@property (nonatomic, strong) NSString *deviceID; +@property (nonatomic) BOOL needToClaimDevice; +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkManualNetworkViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkManualNetworkViewController.m new file mode 100644 index 0000000..64c7052 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkManualNetworkViewController.m @@ -0,0 +1,156 @@ +// +// SparkManualNetworkViewController.m +// teacup-ios-app +// +// Created by Ido on 2/22/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkManualNetworkViewController.h" +#import "SparkSetupUIElements.h" +#import "SparkSetupCustomization.h" +#import "SparkConnectingProgressViewController.h" +#import "SparkSetupCommManager.h" +#import "SparkSetupPasswordEntryViewController.h" +#import "SparkSetupCustomization.h" +#ifdef ANALYTICS +#import +#endif + +@interface SparkManualNetworkViewController () +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; +@property (weak, nonatomic) IBOutlet UITextField *networkNameTextField; +@property (weak, nonatomic) IBOutlet UISwitch *networkRequiresPasswordSwitch; +@property (weak, nonatomic) IBOutlet UIImageView *wifiSymbolImageView; +@property (weak, nonatomic) IBOutlet UIButton *backButton; + +@end + +@implementation SparkManualNetworkViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + // move to super viewdidload? + self.brandImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + // Trick to add an inset from the left of the text fields + CGRect viewRect = CGRectMake(0, 0, 10, 32); + UIView* emptyView = [[UIView alloc] initWithFrame:viewRect]; + + self.networkNameTextField.leftView = emptyView; + self.networkNameTextField.leftViewMode = UITextFieldViewModeAlways; + self.networkNameTextField.delegate = self; + self.networkNameTextField.returnKeyType = UIReturnKeyJoin; + self.networkNameTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + + self.networkRequiresPasswordSwitch.onTintColor = [SparkSetupCustomization sharedInstance].elementBackgroundColor; + + self.wifiSymbolImageView.image = [self.wifiSymbolImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.wifiSymbolImageView.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor;// elementBackgroundColor;; + + self.backButton.imageView.image = [self.backButton.imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.backButton.imageView.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor;// elementBackgroundColor;; + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Manual network entry screen"]; +#endif +} + + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + + + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + if ([[segue identifier] isEqualToString:@"connect"]) + { + // Get reference to the destination view controller + SparkConnectingProgressViewController *vc = [segue destinationViewController]; + vc.networkName = self.networkNameTextField.text; + vc.channel = @0; // unknown + vc.security = @(SparkSetupWifiSecurityTypeOpen); + vc.password = @""; // non secure network + vc.deviceID = self.deviceID; // propagate device ID + vc.needToClaimDevice = self.needToClaimDevice; + } + if ([[segue identifier] isEqualToString:@"require_password"]) // prompt user for password + { + // Get reference to the destination view controller + SparkSetupPasswordEntryViewController *vc = [segue destinationViewController]; + vc.networkName = self.networkNameTextField.text; + vc.channel = @0; // unknown + vc.security = @(SparkSetupWifiSecurityTypeWPA2_AES_PSK); // default + vc.deviceID = self.deviceID; // propagate device ID + vc.needToClaimDevice = self.needToClaimDevice; + } +} + + + + +- (IBAction)connectButtonTapped:(id)sender +{ + if (![self.networkNameTextField.text isEqualToString:@""]) + { + [self.view endEditing:YES]; + if (self.networkRequiresPasswordSwitch.isOn) + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Selected secured network"]; +#endif + [self performSegueWithIdentifier:@"require_password" sender:self]; + } + else + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Selected open network"]; +#endif + [self performSegueWithIdentifier:@"connect" sender:self]; + + } + } + + + +} + + +- (IBAction)cancelButtonTapped:(id)sender +{ + [self.navigationController popViewControllerAnimated:YES]; +} + + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + if (textField == self.networkNameTextField) + { + [self connectButtonTapped:self]; + } + + return YES; +} + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSelectNetworkViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkSelectNetworkViewController.h new file mode 100644 index 0000000..49cdce0 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSelectNetworkViewController.h @@ -0,0 +1,25 @@ +// +// SparkSelectNetworkViewController.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/19/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import "SparkSetupUIViewController.h" + +@protocol SparkSelectNetworkViewControllerDelegate + +-(void)willPopBackToDeviceDiscovery; + +@end + +@interface SparkSelectNetworkViewController : SparkSetupUIViewController +@property (nonatomic, strong) NSArray *wifiList; +@property (nonatomic, strong) NSString *deviceID; +@property (nonatomic) BOOL needToClaimDevice; +@property (nonatomic, weak) id delegate; +@end + + diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSelectNetworkViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkSelectNetworkViewController.m new file mode 100644 index 0000000..3e14527 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSelectNetworkViewController.m @@ -0,0 +1,398 @@ +// +// SparkSelectNetworkViewController.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/19/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkSelectNetworkViewController.h" +#import "SparkSetupPasswordEntryViewController.h" +#import "SparkConnectingProgressViewController.h" +#import "SparkSetupCommManager.h" +#import "SparkSetupCustomization.h" +#import "SparkSetupUIElements.h" +#import "SparkManualNetworkViewController.h" +#import "SparkSetupMainController.h" +#import "SparkSetupCustomization.h" +#import "SparkSetupWifiTableViewCell.h" + +#ifdef ANALYTICS +#import +#endif + +// TODO: move it somewhere else +#define kSparkWifiRSSIThresholdStrong -56 +#define kSparkWifiRSSIThresholdWeak -71 + + + +@interface SparkSelectNetworkViewController () +@property (weak, nonatomic) IBOutlet UITableView *wifiTableView; +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; +@property (weak, nonatomic) IBOutlet UIButton *refreshButton; +@property (weak, nonatomic) IBOutlet UILabel *selectNetworkLabel; +@property (weak, nonatomic) IBOutlet SparkSetupUISpinner *spinner; + +@property (nonatomic, strong) NSIndexPath *selectedNetworkIndexPath; +@property (nonatomic, strong) NSTimer *checkConnectionTimer; +@property (nonatomic, strong) NSString *selectedNetworkSSID; +@property (nonatomic, strong) NSNumber *selectedNetworkSecurity; +@property (nonatomic, strong) NSNumber *selectedNetworkChannel; + +@end + +@implementation SparkSelectNetworkViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. + self.wifiTableView.delegate = self; + self.wifiTableView.dataSource = self; + self.wifiTableView.backgroundColor = [UIColor clearColor]; + + // move to super viewdidload? + self.brandImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + [self sortWifiList]; + +// if ([SparkSetupCustomization sharedInstance].tintSetupImages) +// { + self.wifiTableView.separatorStyle = UITableViewCellSeparatorStyleNone; +// } +// else +// { +// self.wifiTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; +// self.wifiTableView.separatorColor = [SparkSetupCustomization sharedInstance].normalTextColor; +// } + +// self.wifiTableView.layer.borderWidth = 0.5; +// self.wifiTableView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + // temporary test init + /* + self.wifiList = @[ + @{@"ssid" : @"network1", @"rssi" : @-70, @"sec" : @1}, + @{@"ssid" : @"some-wifi", @"rssi" : @-75, @"sec" : @1}, + @{@"ssid" : @"open_wifi", @"rssi" : @-80, @"sec" : @0}, + @{@"ssid" : @"anotherone", @"rssi" : @-90, @"sec" : @1}, + @{@"ssid" : @"hide_yer_kids_hide_yer_wifi", @"rssi" : @-65, @"sec" : @YES}]; + + */ + +} + + +-(void)sortWifiList +{ + + // sort by strength: + +// NSDictionary *lastNetwork; + + // sort alphabeticly + + NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"ssid" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) { + NSString *s1 = obj1; + NSString *s2 = obj2; + return [s1 caseInsensitiveCompare:s2]; + }]; + + + self.wifiList = [self.wifiList sortedArrayUsingDescriptors:[NSArray arrayWithObjects:descriptor,nil]]; + + NSMutableArray *noDupesWifiList = [NSMutableArray new]; + + // remove similar named SSIDs - choose strongest + for (NSDictionary *network in self.wifiList) + { + NSDictionary *strongestNetwork = network; + for (NSDictionary *sameNameNetwork in self.wifiList) + { + if ([sameNameNetwork[@"ssid"] isEqualToString:network[@"ssid"]]) + { + if ([sameNameNetwork[@"rssi"] integerValue] > [strongestNetwork[@"rssi"] integerValue]) + { + strongestNetwork = sameNameNetwork; + } + } + + } + + BOOL strongestNetworkAdded = NO; + for (NSDictionary *addedNetwork in noDupesWifiList) + { + if ([addedNetwork[@"ssid"] isEqualToString:strongestNetwork[@"ssid"]]) + { + strongestNetworkAdded = YES; + } + } + + if (!strongestNetworkAdded) + [noDupesWifiList addObject:strongestNetwork]; + } + + self.wifiList = [noDupesWifiList copy]; + +} + + +-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + static NSString *CellIdentifer = @"wifiCell"; + SparkSetupWifiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifer forIndexPath:indexPath]; + + // Using a cell identifier will allow your app to reuse cells as they come and go from the screen. +// if (cell == nil) +// { +// cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifer]; +// } +// + NSUInteger row = [indexPath row]; + +// UILabel *textLabel = (UILabel *)[cell.contentView viewWithTag:10]; + cell.ssidLabel.text = self.wifiList[row][@"ssid"]; +// textLabel.text + cell.ssidLabel.textColor = [SparkSetupCustomization sharedInstance].normalTextColor; + +// UIImageView *signalStrengthImageView = cell.wifiStrengthImageView; // (UIImageView *)[cell.contentView viewWithTag:30]; + + int rssi = [self.wifiList[row][@"rssi"] intValue]; + if (rssi > kSparkWifiRSSIThresholdStrong) + { + [cell.wifiStrengthImageView setImage:[SparkSetupMainController loadImageFromResourceBundle:@"wifi3"]]; + } + else if (rssi > kSparkWifiRSSIThresholdWeak) + { + [cell.wifiStrengthImageView setImage:[SparkSetupMainController loadImageFromResourceBundle:@"wifi2"]]; + } + else + { + [cell.wifiStrengthImageView setImage:[SparkSetupMainController loadImageFromResourceBundle:@"wifi1"]]; + } + + + cell.wifiStrengthImageView.image = [cell.wifiStrengthImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + cell.wifiStrengthImageView.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor;; + + +// UIImageView *secureImageView = (UIImageView *)[cell.contentView viewWithTag:20]; + SparkSetupWifiSecurityType sec = [self.wifiList[row][@"sec"] intValue]; + if (sec != SparkSetupWifiSecurityTypeOpen) + { +// [cell.contentView viewWithTag:20].hidden = NO; +// UIImageView *lock = cell.securedNetworkIconImageView; //(UIImageView *)[cell.contentView viewWithTag:20]; + cell.securedNetworkIconImageView.hidden = NO; + [cell.securedNetworkIconImageView setImage:[SparkSetupMainController loadImageFromResourceBundle:@"lock"]]; + cell.securedNetworkIconImageView.image = [cell.securedNetworkIconImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + cell.securedNetworkIconImageView.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor;; + } + else + { + cell.securedNetworkIconImageView.hidden = YES; +// [cell.contentView viewWithTag:20].hidden = YES; + } + + if ((indexPath.row % 2) == 0) + { + cell.backgroundColor = [UIColor colorWithRed: 0.1 green: 0.1 blue: 0.1 alpha: 0.25]; + } + else // clear if even + { + cell.backgroundColor = [UIColor clearColor]; + } + + +// [cell setNeedsLayout]; + return cell; +} + + +-(void)checkPhotonConnection:(id)sender +{ +// NSLog(@"checkPhotonConnection"); + if (![SparkSetupCommManager checkSparkDeviceWifiConnection:[SparkSetupCustomization sharedInstance].networkNamePrefix]) + { + [self.checkConnectionTimer invalidate]; + [self.delegate willPopBackToDeviceDiscovery]; + [self.navigationController popViewControllerAnimated:YES]; + } +} + + + + +-(void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + [self.wifiTableView reloadData]; + [self restartDeviceDetectionTimer]; + [self disableKeyboardMovesViewUp]; + +} + +-(void)restartDeviceDetectionTimer +{ + [self.checkConnectionTimer invalidate]; + self.checkConnectionTimer = [NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(checkPhotonConnection:) userInfo:nil repeats:YES]; + +} + + + +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + return [self.wifiList count]; +} + + + +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return 44.0f; +} + + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + NSLog(@"sparkSelectNetworkVC prepareForSegue : %@",segue.identifier); + [self.checkConnectionTimer invalidate]; + + if ([[segue identifier] isEqualToString:@"connect"]) + { + // Get reference to the destination view controller + SparkConnectingProgressViewController *vc = [segue destinationViewController]; + vc.networkName = self.selectedNetworkSSID; + vc.channel = self.selectedNetworkChannel; + vc.security = self.selectedNetworkSecurity; + vc.password = @""; // non secure network + vc.deviceID = self.deviceID; // propagate device ID + vc.needToClaimDevice = self.needToClaimDevice; + } + else if ([[segue identifier] isEqualToString:@"require_password"]) // prompt user for password + { + // Get reference to the destination view controller + SparkSetupPasswordEntryViewController *vc = [segue destinationViewController]; + vc.networkName = self.selectedNetworkSSID; + vc.channel = self.selectedNetworkChannel; + vc.security = self.selectedNetworkSecurity; + vc.deviceID = self.deviceID; // propagate device ID + vc.needToClaimDevice = self.needToClaimDevice; + } + else if ([[segue identifier] isEqualToString:@"manual_network"]) // prompt user for password + { + // Get reference to the destination view controller + SparkManualNetworkViewController *vc = [segue destinationViewController]; + vc.deviceID = self.deviceID; // propagate device ID + vc.needToClaimDevice = self.needToClaimDevice; + } +} + + + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +{ + [self.wifiTableView deselectRowAtIndexPath:indexPath animated:YES]; + self.selectedNetworkIndexPath = indexPath; + + SparkSetupWifiSecurityType secInt = [self.wifiList[indexPath.row][@"sec"] intValue]; + self.selectedNetworkSecurity = [NSNumber numberWithInt:secInt]; + self.selectedNetworkChannel = self.wifiList[indexPath.row][@"ch"]; + self.selectedNetworkSSID = self.wifiList[indexPath.row][@"ssid"]; + [self.checkConnectionTimer invalidate]; + + if (secInt == SparkSetupWifiSecurityTypeOpen) + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Selected open network"]; +#endif + [self performSegueWithIdentifier:@"connect" sender:self]; + + } + else + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Selected secured network"]; +#endif + [self performSegueWithIdentifier:@"require_password" sender:self]; + } + +} + + +//-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +//{ +// if (buttonIndex == 1) +// { +// NSString *password = [alertView textFieldAtIndex:0].text; +// NSLog(@"password: %@",password); +// [self connectToSelectedNetwork:self.selectedNetworkIndexPath withPassword:password]; +// } +// else // User Cancelled +// [self restartDeviceDetectionTimer]; +// +//} + + +- (IBAction)manualNetworkButtonTapped:(id)sender +{ + +} + + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Select Network Screen"]; +#endif +} + + + +-(void)photonScanAP +{ + + self.refreshButton.enabled = NO; + [self.spinner startAnimating]; + SparkSetupCommManager *manager = [[SparkSetupCommManager alloc] init]; + [manager scanAP:^(id scanResponse, NSError *error) { + [self.spinner stopAnimating]; + if (error) + { + NSLog(@"Could not send scan-ap command: %@",error.localizedDescription); + } + else + { + if (scanResponse) // check why getting two callbacks + { + self.wifiList = scanResponse; + [self sortWifiList]; + [self.wifiTableView reloadData]; + } + + } + self.refreshButton.enabled = YES; + }]; +} + +- (IBAction)refreshScanButton:(id)sender +{ + [self photonScanAP]; +} + + + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSetupPasswordEntryViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupPasswordEntryViewController.h new file mode 100644 index 0000000..bc99891 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupPasswordEntryViewController.h @@ -0,0 +1,17 @@ +// +// SparkSetupPasswordEntryViewController.h +// teacup-ios-app +// +// Created by Ido on 1/20/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupUIViewController.h" + +@interface SparkSetupPasswordEntryViewController : SparkSetupUIViewController +@property (nonatomic, strong) NSString *networkName; +@property (nonatomic, strong) NSString *deviceID; +@property (nonatomic, strong) NSNumber *channel; +@property (nonatomic, strong) NSNumber *security; +@property (nonatomic) BOOL needToClaimDevice; +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSetupPasswordEntryViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupPasswordEntryViewController.m new file mode 100644 index 0000000..e9bf820 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupPasswordEntryViewController.m @@ -0,0 +1,179 @@ +// +// SparkSetupPasswordEntryViewController.m +// teacup-ios-app +// +// Created by Ido on 1/20/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupPasswordEntryViewController.h" +#import "SparkSetupUILabel.h" +#import "SparkSetupCustomization.h" +#import "SparkConnectingProgressViewController.h" +#import "SparkSetupCommManager.h" +#import "SparkSetupCustomization.h" +#import "SparkSetupMainController.h" +#ifdef ANALYTICS +#import +#endif + +@interface SparkSetupPasswordEntryViewController () +@property (weak, nonatomic) IBOutlet UITextField *passwordTextField; +@property (weak, nonatomic) IBOutlet SparkSetupUILabel *networkNameLabel; +@property (weak, nonatomic) IBOutlet SparkSetupUILabel *securityTypeLabel; +@property (weak, nonatomic) IBOutlet UISwitch *showPasswordSwitch; +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; +@property (weak, nonatomic) IBOutlet UIImageView *wifiSymbolImageView; +@property (weak, nonatomic) IBOutlet UIButton *backButton; + +@end + +@implementation SparkSetupPasswordEntryViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + // move to super viewdidload? + self.brandImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + // force load images from resource bundle + self.wifiSymbolImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"wifi3"]; + + // Trick to add an inset from the left of the text fields + CGRect viewRect = CGRectMake(0, 0, 10, 32); + UIView* emptyView = [[UIView alloc] initWithFrame:viewRect]; + + self.passwordTextField.leftView = emptyView; + self.passwordTextField.leftViewMode = UITextFieldViewModeAlways; + self.passwordTextField.delegate = self; + self.passwordTextField.returnKeyType = UIReturnKeyJoin; + + self.passwordTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + + self.networkNameLabel.text = self.networkName; + self.securityTypeLabel.text = [self convertSecurityTypeToString:self.security]; + self.showPasswordSwitch.onTintColor = [SparkSetupCustomization sharedInstance].elementBackgroundColor; + + self.wifiSymbolImageView.image = [self.wifiSymbolImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.wifiSymbolImageView.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor;// elementBackgroundColor;; + + self.backButton.imageView.image = [self.backButton.imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.backButton.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor; + + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (IBAction)showPasswordSwitchTapped:(id)sender +{ + self.passwordTextField.secureTextEntry = self.showPasswordSwitch.isOn; + + // Hack to update cursor position to match new length of dots/chars + NSString *tmp = self.passwordTextField.text; + self.passwordTextField.text = @" "; + self.passwordTextField.text = tmp; + +} + + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Password Entry Screen"]; +#endif +} + + +- (IBAction)connectButtonTapped:(id)sender +{ + int minWifiPassChars = 8; +// if ([self.securityTypeLabel.text containsString:@"WEP"]) // iOS 8 only + if ([self.securityTypeLabel.text rangeOfString:@"WEP"].length > 0) //iOS7 way to do it (still need to do something nicer here) + minWifiPassChars = 5; + + if (self.passwordTextField.text.length < minWifiPassChars) + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid password" message:[NSString stringWithFormat:@"Password must be %d characters or longer",minWifiPassChars] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + } + else + { + [self.view endEditing:YES]; + [self performSegueWithIdentifier:@"connect" sender:self]; + } + +} + +-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + if ([[segue identifier] isEqualToString:@"connect"]) + { + // Get reference to the destination view controller + SparkConnectingProgressViewController *vc = [segue destinationViewController]; + vc.networkName = self.networkName; + vc.channel = self.channel; + vc.security = self.security; + vc.password = self.passwordTextField.text; + vc.deviceID = self.deviceID; // propagate device ID + vc.needToClaimDevice = self.needToClaimDevice; // propagate claiming + } + +} + +-(NSString *)convertSecurityTypeToString:(NSNumber *)securityType +{ + switch ([securityType intValue]) { + case SparkSetupWifiSecurityTypeOpen: + return @"Open"; + break; + case SparkSetupWifiSecurityTypeWEP_PSK: + return @"WEP-PSK"; + break; + case SparkSetupWifiSecurityTypeWEP_SHARED: + return @"WEP-Shared"; + break; + case SparkSetupWifiSecurityTypeWPA_TKIP_PSK: + return @"WPA-TKIP"; + break; + case SparkSetupWifiSecurityTypeWPA_AES_PSK: + return @"WPA-AES"; + break; + case SparkSetupWifiSecurityTypeWPA2_AES_PSK: + return @"WPA2-AES"; + break; + case SparkSetupWifiSecurityTypeWPA2_TKIP_PSK: + return @"WPA2-TKIP"; + break; + case SparkSetupWifiSecurityTypeWPA2_MIXED_PSK: + return @"WPA2-Mixed"; + break; + + default: + return @"unknown"; + break; + } +} + + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + if (textField == self.passwordTextField) + { + [self connectButtonTapped:self]; + } + + return YES; +} + + +- (IBAction)changeNetworkButtonTapped:(id)sender +{ + [self.navigationController popViewControllerAnimated:YES]; +} + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSetupResultViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupResultViewController.h new file mode 100644 index 0000000..6a81e7b --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupResultViewController.h @@ -0,0 +1,26 @@ +// +// SparkSetupSuccessFailureViewController.h +// teacup-ios-app +// +// Created by Ido on 2/3/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupUIViewController.h" +#import "Spark-SDK.h" + +typedef NS_ENUM(NSInteger, SparkSetupResult) { + SparkSetupResultSuccess=0, + SparkSetupResultSuccessUnknown, + SparkSetupResultSuccessDeviceOffline, + SparkSetupResultFailureClaiming, + SparkSetupResultFailureConfigure, + SparkSetupResultFailureCannotDisconnectFromDevice, + SparkSetupResultFailureLostConnectionToDevice +}; + +@interface SparkSetupResultViewController : SparkSetupUIViewController +@property (nonatomic, strong) SparkDevice *device; +@property (nonatomic) SparkSetupResult setupResult; + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSetupResultViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupResultViewController.m new file mode 100644 index 0000000..ee4d873 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupResultViewController.m @@ -0,0 +1,249 @@ +// +// SparkSetupSuccessFailureViewController.m +// teacup-ios-app +// +// Created by Ido on 2/3/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupResultViewController.h" +#import "SparkSetupUIElements.h" +#import "SparkSetupMainController.h" +#import "SparkSetupWebViewController.h" +#import "SparkSetupCustomization.h" +#ifdef ANALYTICS +#import +#endif + +@interface SparkSetupResultViewController () +@property (weak, nonatomic) IBOutlet SparkSetupUILabel *shortMessageLabel; +@property (weak, nonatomic) IBOutlet SparkSetupUILabel *longMessageLabel; +@property (weak, nonatomic) IBOutlet UIImageView *setupResultImageView; +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; + +@property (weak, nonatomic) IBOutlet SparkSetupUILabel *nameDeviceLabel; +@property (weak, nonatomic) IBOutlet UITextField *nameDeviceTextField; +@property (strong, nonatomic) NSArray *randomDeviceNamesArray; + +@end + +@implementation SparkSetupResultViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // set logo + self.brandImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + self.nameDeviceLabel.hidden = YES; + self.nameDeviceTextField.hidden = YES; + + // Trick to add an inset from the left of the text fields + CGRect viewRect = CGRectMake(0, 0, 10, 32); + UIView* emptyView = [[UIView alloc] initWithFrame:viewRect]; + + self.nameDeviceTextField.leftView = emptyView; + self.nameDeviceTextField.leftViewMode = UITextFieldViewModeAlways; + self.nameDeviceTextField.delegate = self; + self.nameDeviceTextField.returnKeyType = UIReturnKeyDone; + self.nameDeviceTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + + // init funny random device names + self.randomDeviceNamesArray = [NSArray arrayWithObjects:@"aardvark", @"bacon", @"badger", @"banjo", @"bobcat", @"boomer", @"captain", @"chicken", @"cowboy", @"cracker", @"cranky", @"crazy", @"dentist", @"doctor", @"dozen", @"easter", @"ferret", @"gerbil", @"hacker", @"hamster", @"hindu", @"hobo", @"hoosier", @"hunter", @"jester", @"jetpack", @"kitty", @"laser", @"lawyer", @"mighty", @"monkey", @"morphing", @"mutant", @"narwhal", @"ninja", @"normal", @"penguin", @"pirate", @"pizza", @"plumber", @"power", @"puppy", @"ranger", @"raptor", @"robot", @"scraper", @"scrapple", @"station", @"tasty", @"trochee", @"turkey", @"turtle", @"vampire", @"wombat", @"zombie", nil]; + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +-(void)viewDidAppear:(BOOL)animated +{ + if ((!isiPhone4) && (!isiPhone5)) + [self disableKeyboardMovesViewUp]; + + if (self.setupResult == SparkSetupResultSuccess) + { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [self.nameDeviceTextField becomeFirstResponder]; + }); + } +} + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Setup Result Screen"]; +#endif + + + [super viewWillAppear:animated]; + + switch (self.setupResult) { + case SparkSetupResultSuccess: + { + self.setupResultImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"success"]; + self.shortMessageLabel.text = @"Setup completed successfully"; + self.longMessageLabel.text = @"Congrats! You've successfully set up your {device}."; + + self.nameDeviceLabel.hidden = NO; + self.nameDeviceTextField.hidden = NO; + NSString *randomDeviceName1 = self.randomDeviceNamesArray[arc4random_uniform((UInt32)self.randomDeviceNamesArray.count)]; + NSString *randomDeviceName2 = self.randomDeviceNamesArray[arc4random_uniform((UInt32)self.randomDeviceNamesArray.count)]; + self.nameDeviceTextField.text = [NSString stringWithFormat:@"%@_%@",randomDeviceName1,randomDeviceName2]; +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Success"]; +#endif + + break; + } + + case SparkSetupResultSuccessDeviceOffline: + { + self.setupResultImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"warning"]; + self.shortMessageLabel.text = @"Setup completed"; + self.longMessageLabel.text = @"Your device has been successfully claimed to your account, however it is offline. If the device was already claimed before this setup, then the Wi-Fi connection may have failed, and you should try setup again."; + +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Success" properties:@{@"reason":@"device offline"}]; +#endif + break; + } + + case SparkSetupResultSuccessUnknown: + { + self.setupResultImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"success"]; + self.shortMessageLabel.text = @"Setup completed"; + self.longMessageLabel.text = @"Setup was successful, but since you do not own this device we cannot know if the {device} has connected to the Internet. If you see the LED breathing cyan this means it worked! If not, please restart the setup process."; + +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Success" properties:@{@"reason":@"not claimed"}]; +#endif + break; + + } + + case SparkSetupResultFailureClaiming: + { + self.setupResultImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"failure"]; + self.shortMessageLabel.text = @"Setup failed"; + // TODO: add customization point for custom troubleshoot texts +// self.longMessageLabel.text = @"Setup process failed at claiming your {device}, if your {device} LED is blinking in blue or green this means that you provided wrong Wi-Fi credentials. If {device} LED is breathing cyan an internal cloud issue occured - please contact product support."; + self.longMessageLabel.text = @"Setup process failed at claiming your {device}, if your {device} LED is blinking in blue or green this means that you provided wrong Wi-Fi credentials, please try setup process again."; +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Failure" properties:@{@"reason":@"claiming failed"}]; +#endif + + break; + } + + case SparkSetupResultFailureCannotDisconnectFromDevice: + { + self.setupResultImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"failure"]; + self.shortMessageLabel.text = @"Oops!"; + self.longMessageLabel.text = @"Setup process couldn't disconnect from the {device} Wi-fi network. This is an internal problem with the device, so please try running setup again after resetting your {device} and putting it back in listen mode (blinking blue LED) if needed."; +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Failure" properties:@{@"reason":@"cannot disconnect"}]; +#endif + + break; + } + + case SparkSetupResultFailureConfigure: + { + self.setupResultImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"failure"]; + self.shortMessageLabel.text = @"Uh oh!"; + self.longMessageLabel.text = @"Setup process couldn't disconnect from the {device} Wi-fi network. This is an internal problem with the device, so please try running setup again after resetting your {device} and putting it back in blinking blue listen mode if needed."; +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Failure" properties:@{@"reason":@"cannot configure"}]; +#endif + + break; + } + + case SparkSetupResultFailureLostConnectionToDevice: + { + self.setupResultImageView.image = [SparkSetupMainController loadImageFromResourceBundle:@"failure"]; + self.shortMessageLabel.text = @"Error!"; + self.longMessageLabel.text = @"Setup process couldn't configure the Wi-Fi credentials for your {device}, please try running setup again after resetting your {device} and putting it back in blinking blue listen mode if needed."; +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Failure" properties:@{@"reason":@"lost connection"}]; +#endif + break; + } + + } + + [self.longMessageLabel setType:@"normal"]; + + if ([SparkSetupCustomization sharedInstance].tintSetupImages) + { + self.setupResultImageView.image = [self.setupResultImageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.setupResultImageView.tintColor = [SparkSetupCustomization sharedInstance].normalTextColor;// elementBackgroundColor;; + } + +} + + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + if (textField == self.nameDeviceTextField) + { + [textField resignFirstResponder]; + [self.device rename:textField.text completion:^(NSError *error) { + [self doneButtonTapped:self]; + }]; + } + + return YES; +} + + + + +- (IBAction)doneButtonTapped:(id)sender +{ + NSMutableDictionary *userInfo = [NSMutableDictionary new]; + if (self.setupResult == SparkSetupResultSuccess) + { + // Update zero notice to user + // TODO: condition message only if its really getting update zero + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Firmware update" message:@"If this is the first time you are setting up this device it might blink its LED in magenta color for a while, this means the device is currently updating its firmware from the cloud to the latest version. Please be patient and do not press the reset button. Device LED will breathe cyan once update has completed and it has come online." delegate:nil cancelButtonTitle:@"Understood" otherButtonTitles:nil]; + [alert show]; + + userInfo[kSparkSetupDidFinishStateKey] = @(SparkSetupMainControllerResultSuccess); + + if (self.device) + userInfo[kSparkSetupDidFinishDeviceKey] = self.device; + } + else if (self.setupResult == SparkSetupResultSuccessUnknown) + { + userInfo[kSparkSetupDidFinishStateKey] = @(SparkSetupMainControllerResultSuccessNotClaimed); + } + else + { + userInfo[kSparkSetupDidFinishStateKey] = @(SparkSetupMainControllerResultFailure); + } + + // finish with success and provide device + [[NSNotificationCenter defaultCenter] postNotificationName:kSparkSetupDidFinishNotification + object:nil + userInfo:userInfo]; + +} + + +- (IBAction)troubleshootingButtonTouched:(id)sender +{ + + SparkSetupWebViewController* webVC = [[UIStoryboard storyboardWithName:@"setup" bundle:[NSBundle bundleWithIdentifier:SPARK_SETUP_RESOURCE_BUNDLE_IDENTIFIER]] instantiateViewControllerWithIdentifier:@"webview"]; + webVC.link = [SparkSetupCustomization sharedInstance].troubleshootingLinkURL; + [self presentViewController:webVC animated:YES completion:nil]; + +} + + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSetupVideoViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupVideoViewController.h new file mode 100644 index 0000000..4b89b3c --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupVideoViewController.h @@ -0,0 +1,15 @@ +// +// SparkSetupVideoViewController.h +// Pods +// +// Created by Ido on 6/15/15. +// +// + +#import +#import "SparkSetupUIViewController.h" + +@interface SparkSetupVideoViewController : SparkSetupUIViewController +@property (nonatomic, strong) NSString *videoFilePath; + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSetupVideoViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupVideoViewController.m new file mode 100644 index 0000000..6bcda84 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupVideoViewController.m @@ -0,0 +1,105 @@ +// +// SparkSetupVideoViewController.m +// Pods +// +// Created by Ido on 6/15/15. +// +// + +#import "SparkSetupVideoViewController.h" +#import "SparkSetupCustomization.h" +#import +#if ANALYTICS +#import +#endif + +@interface SparkSetupVideoViewController () +@property (weak, nonatomic) IBOutlet UIView *videoView; +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; +@property (strong, nonatomic) MPMoviePlayerController *videoPlayer; +@end + +@implementation SparkSetupVideoViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // move to super viewdidload? + self.brandImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] timeEvent:@"Device Setup: How-To video screen activity"]; +#endif +} + + +-(void)viewWillDisappear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: How-To video screen activity"]; +#endif + +} + +-(void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + // self.videoViewWidth.constant = ((self.videoView.frame.size.height * 9.0)/16.0); + + + if (self.videoFilePath) + { + NSArray *videoFilenameArr = [self.videoFilePath componentsSeparatedByString:@"."]; + NSString *path = [[NSBundle mainBundle] pathForResource:videoFilenameArr[0] ofType:videoFilenameArr[1]]; + + if (path) + self.videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]]; + if (self.videoPlayer) + { + self.videoPlayer.shouldAutoplay = YES; + self.videoPlayer.view.frame = self.videoView.bounds; + self.videoPlayer.repeatMode = MPMovieRepeatModeOne; + self.videoPlayer.fullscreen = NO; + self.videoPlayer.movieSourceType = MPMovieSourceTypeFile; + self.videoPlayer.scalingMode = MPMovieScalingModeAspectFit; + self.videoPlayer.controlStyle = MPMovieControlStyleNone; + [self.videoView addSubview:self.videoPlayer.view]; + [self.videoPlayer play]; +// self.videoView.layer.borderColor = [UIColor lightGrayColor].CGColor; +// self.videoView.layer.borderWidth = 0.5; + + } + } + + + +} + +- (IBAction)doneButtonTapped:(id)sender { + [self.videoPlayer stop]; + [self dismissViewControllerAnimated:YES completion:nil]; +} + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSetupWebViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupWebViewController.h new file mode 100644 index 0000000..06b8989 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupWebViewController.h @@ -0,0 +1,18 @@ +// +// SparkSetupWebViewController.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 12/12/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import "SparkSetupUIViewController.h" + +@interface SparkSetupWebViewController : SparkSetupUIViewController +@property (nonatomic, strong) NSURL *link; +@property (nonatomic, strong) NSString *htmlFilename; +@property (nonatomic, strong) NSString *htmlFileDirectory; +@end + + diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkSetupWebViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupWebViewController.m new file mode 100644 index 0000000..1bd36a1 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkSetupWebViewController.m @@ -0,0 +1,107 @@ +// +// SparkSetupWebViewController.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 12/12/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkSetupWebViewController.h" +#import "SparkSetupCustomization.h" +#import +#import "SparkSetupUIElements.h" +#ifdef ANALYTICS +#import +#endif + +//#import "UIViewController+SparkSetupMainController.h" + +@interface SparkSetupWebViewController () +@property (weak, nonatomic) IBOutlet UIWebView *webView; +@property (weak, nonatomic) IBOutlet SparkSetupUISpinner *spinner; + +@end + +@implementation SparkSetupWebViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + + if (self.link) + { + [self.webView loadRequest:[NSURLRequest requestWithURL:self.link cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:10.0f]]; + } + else + { + if (self.htmlFilename) + { + NSString *path = [[NSBundle mainBundle] pathForResource:self.htmlFilename ofType:@"html" inDirectory:self.htmlFileDirectory]; + NSURL *baseURL = [NSURL fileURLWithPath:path]; + NSString* htmlString = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; + [self.webView loadHTMLString:htmlString baseURL:baseURL]; + } + } + + + self.webView.scalesPageToFit = YES; + self.navigationController.navigationBarHidden = NO; + self.webView.delegate = self; + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (IBAction)closeButtonTouched:(id)sender +{ + [self dismissViewControllerAnimated:YES completion:nil]; +} + + + +-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error +{ + + [self.spinner stopAnimating]; + // TODO: show a nice error static HTML +} + +-(void)webViewDidStartLoad:(UIWebView *)webView +{ + [self.spinner startAnimating]; +} + +-(void)webViewDidFinishLoad:(UIWebView *)webView +{ + [self.spinner stopAnimating]; + + CGSize contentSize = self.webView.scrollView.contentSize; + CGSize viewSize = self.view.bounds.size; + + float rw = viewSize.width / contentSize.width; + + self.webView.scrollView.minimumZoomScale = rw; + self.webView.scrollView.maximumZoomScale = rw; + self.webView.scrollView.zoomScale = rw; + + + // experimenting +// NSString *injectSrc = @"var i = document.createElement('div'); i.innerHTML = '%@';document.documentElement.appendChild(i);"; +// NSString *runToInject = [NSString stringWithFormat:injectSrc, @""]; +// [self.webView stringByEvaluatingJavascriptFromString:runToInject]; + + +} + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Device Setup: Webview Screen"]; +#endif +} + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkUserForgotPasswordViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkUserForgotPasswordViewController.h new file mode 100644 index 0000000..84e5368 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkUserForgotPasswordViewController.h @@ -0,0 +1,14 @@ +// +// SparkUserForgotPasswordViewController.h +// teacup-ios-app +// +// Created by Ido on 2/13/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupUIViewController.h" +#import "SparkUserLoginViewController.h" + +@interface SparkUserForgotPasswordViewController : SparkSetupUIViewController +@property (nonatomic, strong) id delegate; +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkUserForgotPasswordViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkUserForgotPasswordViewController.m new file mode 100644 index 0000000..2ea55ac --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkUserForgotPasswordViewController.m @@ -0,0 +1,134 @@ +// +// SparkUserForgotPasswordViewController.m +// teacup-ios-app +// +// Created by Ido on 2/13/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkUserForgotPasswordViewController.h" +#import "SparkSetupCustomization.h" +#import "Spark-SDK.h" +#import "SparkSetupWebViewController.h" +#import "SparkUserLoginViewController.h" +#import "SparkSetupUIElements.h" +#ifdef ANALYTICS +#import +#endif + +@interface SparkUserForgotPasswordViewController () +@property (weak, nonatomic) IBOutlet UITextField *emailTextField; +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; +@property (weak, nonatomic) IBOutlet SparkSetupUISpinner *spinner; + +@end + +@implementation SparkUserForgotPasswordViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.brandImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + // Trick to add an inset from the left of the text fields + CGRect viewRect = CGRectMake(0, 0, 10, 32); + UIView* emptyView = [[UIView alloc] initWithFrame:viewRect]; + + self.emailTextField.leftView = emptyView; + self.emailTextField.leftViewMode = UITextFieldViewModeAlways; + self.emailTextField.delegate = self; + self.emailTextField.returnKeyType = UIReturnKeyGo; + self.emailTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +- (IBAction)resetPasswordButtonTapped:(id)sender +{ + [self.view endEditing:YES]; + [self.spinner startAnimating]; + + void (^passwordResetCallback)(NSError *) = ^void(NSError *error) { + + [self.spinner stopAnimating]; + + if (!error) + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Request password reset"]; +#endif + + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reset password" message:@"Instuctions how to reset your password will be sent to the provided email address. Please check your email and continue according to instructions." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + alert.delegate = self; + [alert show]; + } + else + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reset password" message:@"Could not find a user with supplied email address, please check the address supplied or create a new user via signup screen" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + + } + }; + + if ([self isValidEmail:self.emailTextField.text]) + { + if ([SparkSetupCustomization sharedInstance].organization) // TODO: fix that so it'll work for non-org too + { + [[SparkCloud sharedInstance] requestPasswordResetForCustomer:[SparkSetupCustomization sharedInstance].organizationName email:self.emailTextField.text completion:passwordResetCallback]; + } + else + { + [[SparkCloud sharedInstance] requestPasswordResetForUser:self.emailTextField.text completion:passwordResetCallback]; + } + } + else + { + [self.spinner stopAnimating]; + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reset password" message:@"Invalid email address" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + } + + +// SparkSetupWebViewController* webVC = [[UIStoryboard storyboardWithName:@"setup" bundle:[NSBundle bundleWithIdentifier:SPARK_SETUP_RESOURCE_BUNDLE_IDENTIFIER]] instantiateViewControllerWithIdentifier:@"webview"]; +// webVC.link = [SparkSetupCustomization sharedInstance].forgotPasswordLinkURL; +// [self presentViewController:webVC animated:YES completion:nil]; + +} + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Forgot password screen"]; +#endif +} + + + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + if (textField == self.emailTextField) + { + [self resetPasswordButtonTapped:self]; + return YES; + + } + return NO; +} + +-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + [self.delegate didRequestUserLogin:self]; +} + +- (IBAction)cancelButtonTapped:(id)sender +{ + [self.delegate didRequestUserLogin:self]; + +} +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkUserLoginViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkUserLoginViewController.h new file mode 100644 index 0000000..b4cd087 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkUserLoginViewController.h @@ -0,0 +1,15 @@ +// +// SparkUserLoginViewController.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/26/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import "SparkSetupUIViewController.h" +#import "SparkUserSignupViewController.h" + +@interface SparkUserLoginViewController : SparkSetupUIViewController +@property (nonatomic, strong) id delegate; +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkUserLoginViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkUserLoginViewController.m new file mode 100644 index 0000000..b1ac40e --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkUserLoginViewController.m @@ -0,0 +1,202 @@ +// +// SparkUserLoginViewController.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/26/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkUserLoginViewController.h" +#import "SparkSetupWebViewController.h" +#import "SparkSetupCustomization.h" +#import "SparkSetupUIElements.h" +#import "Spark-SDK.h" +#ifdef ANALYTICS +#import "Mixpanel.h" +#endif + + +@interface SparkUserLoginViewController () +@property (weak, nonatomic) IBOutlet UITextField *emailTextField; +@property (weak, nonatomic) IBOutlet UITextField *passwordTextField; +@property (weak, nonatomic) IBOutlet UIButton *forgotButton; +@property (weak, nonatomic) IBOutlet UIButton *loginButton; +@property (weak, nonatomic) IBOutlet UIImageView *brandImage; +@property (weak, nonatomic) IBOutlet UIButton *noAccountButton; +@property (weak, nonatomic) IBOutlet UILabel *loginLabel; +@property (strong, nonatomic) UIAlertView *skipAuthAlertView; +@property (weak, nonatomic) IBOutlet SparkSetupUISpinner *spinner; +@property (weak, nonatomic) IBOutlet SparkSetupUIButton *skipAuthButton; +@end + +@implementation SparkUserLoginViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + +// [self makeLinkButton:self.forgotButton withText:@"Forgot password"]; +// [self makeBoldButton:self.noAccountButton withText:nil]; + + // move to super viewdidload? + self.brandImage.image = [SparkSetupCustomization sharedInstance].brandImage; + self.brandImage.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + // Trick to add an inset from the left of the text fields + CGRect viewRect = CGRectMake(0, 0, 10, 32); + UIView* emptyView1 = [[UIView alloc] initWithFrame:viewRect]; + UIView* emptyView2 = [[UIView alloc] initWithFrame:viewRect]; + + // TODO: make a custom control from all the text fields + self.emailTextField.leftView = emptyView1; + self.emailTextField.leftViewMode = UITextFieldViewModeAlways; + self.emailTextField.delegate = self; + self.emailTextField.returnKeyType = UIReturnKeyNext; + self.emailTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + + self.passwordTextField.leftView = emptyView2; + self.passwordTextField.leftViewMode = UITextFieldViewModeAlways; + self.passwordTextField.delegate = self; + self.passwordTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + + self.skipAuthButton.hidden = !([SparkSetupCustomization sharedInstance].allowSkipAuthentication); + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + if (textField == self.emailTextField) + { + [self.passwordTextField becomeFirstResponder]; + } + if (textField == self.passwordTextField) + { + [self loginButton:self]; + } + + return YES; + +} + + +- (IBAction)forgotPasswordButton:(id)sender +{ + [self.delegate didRequestPasswordReset:self]; +} + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Login Screen"]; +#endif +} + + + +- (IBAction)loginButton:(id)sender +{ + [self.view endEditing:YES]; + if (self.passwordTextField.text.length == 0) + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot sign in" message:@"Password cannot be blank" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + return; + } + + NSString *email = self.emailTextField.text.lowercaseString; + + if ([self isValidEmail:email]) + { + [self.spinner startAnimating]; + [[SparkCloud sharedInstance] loginWithUser:email password:self.passwordTextField.text completion:^(NSError *error) { + [self.spinner stopAnimating]; + if (!error) + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Login success"]; +#endif + + // dismiss modal view and call main controller delegate to go on to setup process since login is complete +// [self dismissViewControllerAnimated:YES completion:^{ + [self.delegate didFinishUserAuthentication:self loggedIn:YES]; +// }]; + } + else + { + NSString *errorText; +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Login failure"]; +#endif + +// if ([error.localizedDescription containsString:@"(400)"]) // TODO: fix this hack to something nicer + if ([error.localizedDescription rangeOfString:@"(400)"].length > 0) //iOS7 way to do it (still need to do something nicer here) + errorText = @"Incorrect username and/or password"; + else + errorText = error.localizedDescription; + + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot sign in" message:errorText delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + } + }]; + } + else + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cannot sign in" message:@"Invalid email address" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + } + +} + + +- (IBAction)noAccountButton:(id)sender +{ + [self.view endEditing:YES]; + [self.delegate didRequestUserSignup:self]; + + /* + // go back to signup + [self dismissViewControllerAnimated:YES completion:nil]; + */ + +} + + +-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + if (alertView == self.skipAuthAlertView) + { + if (buttonIndex == 0) //YES + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Auth skipped"]; +#endif + [self.delegate didFinishUserAuthentication:self loggedIn:NO]; + } + } +} + +- (IBAction)skipAuthButtonTapped:(id)sender { + + // that means device is claimed by somebody else - we want to check that with user (and set claimcode if user wants to change ownership) + NSString *messageStr = [SparkSetupCustomization sharedInstance].skipAuthenticationMessage; + self.skipAuthAlertView = [[UIAlertView alloc] initWithTitle:@"Skip authentication" message:messageStr delegate:self cancelButtonTitle:nil otherButtonTitles:@"Yes",@"No",nil]; + [self.skipAuthAlertView show]; + +} + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkUserSignupViewController.h b/Strike/Pods/SparkSetup/Classes/UI/SparkUserSignupViewController.h new file mode 100644 index 0000000..c3b920e --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkUserSignupViewController.h @@ -0,0 +1,25 @@ +// +// SparkUserSignupViewController.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/15/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import "SparkSetupUIViewController.h" + +@protocol SparkUserLoginDelegate +@required +-(void)didFinishUserAuthentication:(id)sender loggedIn:(BOOL)loggedIn; +-(void)didRequestUserSignup:(id)sender; +-(void)didRequestUserLogin:(id)sender; +-(void)didRequestPasswordReset:(id)sender; +@end + + +@interface SparkUserSignupViewController : SparkSetupUIViewController +@property (nonatomic, strong) id delegate; +@property (nonatomic, strong) NSString *predefinedActivationCode; + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/SparkUserSignupViewController.m b/Strike/Pods/SparkSetup/Classes/UI/SparkUserSignupViewController.m new file mode 100644 index 0000000..a90a8b9 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/SparkUserSignupViewController.m @@ -0,0 +1,332 @@ +// +// SparkUserSignupViewController.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/15/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkUserSignupViewController.h" +#import "Spark-SDK.h" +#import "SparkUserLoginViewController.h" +#import "SparkSetupWebViewController.h" +#import "SparkSetupCustomization.h" +#import "SparkSetupUIElements.h" +#import "SparkSetupMainController.h" +#ifdef ANALYTICS +#import +#endif + +@interface SparkUserSignupViewController () +@property (weak, nonatomic) IBOutlet SparkSetupUISpinner *spinner; +@property (weak, nonatomic) IBOutlet UITextField *passwordTextField; +@property (weak, nonatomic) IBOutlet UITextField *passwordVerifyTextField; +@property (weak, nonatomic) IBOutlet UITextField *emailTextField; +@property (weak, nonatomic) IBOutlet UIButton *termsButton; +@property (weak, nonatomic) IBOutlet UIButton *privacyButton; +@property (weak, nonatomic) IBOutlet UIButton *signupButton; +@property (weak, nonatomic) IBOutlet UIImageView *logoImageView; +@property (weak, nonatomic) IBOutlet UIButton *haveAccountButton; +@property (weak, nonatomic) IBOutlet UILabel *createAccountLabel; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *signupButtonSpace; +@property (weak, nonatomic) IBOutlet SparkSetupUIButton *skipAuthButton; +@property (strong, nonatomic) UIAlertView *skipAuthAlertView; + +@end + +@implementation SparkUserSignupViewController + + + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Add underlines to link buttons / bold to navigation buttons +// [self makeLinkButton:self.termsButton withText:nil]; +// [self makeLinkButton:self.privacyButton withText:nil]; +// [self makeBoldButton:self.haveAccountButton withText:nil]; + + // set brand logo + self.logoImageView.image = [SparkSetupCustomization sharedInstance].brandImage; + self.logoImageView.backgroundColor = [SparkSetupCustomization sharedInstance].brandImageBackgroundColor; + + // add an inset from the left of the text fields + CGRect viewRect = CGRectMake(0, 0, 10, 32); + UIView* emptyView1 = [[UIView alloc] initWithFrame:viewRect]; + UIView* emptyView2 = [[UIView alloc] initWithFrame:viewRect]; + UIView* emptyView3 = [[UIView alloc] initWithFrame:viewRect]; +// UIView* emptyView4 = [[UIView alloc] initWithFrame:viewRect]; + + self.emailTextField.leftView = emptyView1; + self.emailTextField.leftViewMode = UITextFieldViewModeAlways; + self.emailTextField.delegate = self; + self.emailTextField.returnKeyType = UIReturnKeyNext; + self.emailTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + + self.passwordTextField.leftView = emptyView2; + self.passwordTextField.leftViewMode = UITextFieldViewModeAlways; + self.passwordTextField.delegate = self; + self.passwordTextField.returnKeyType = UIReturnKeyNext; + self.passwordTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + + self.passwordVerifyTextField.leftView = emptyView3; + self.passwordVerifyTextField.leftViewMode = UITextFieldViewModeAlways; + self.passwordVerifyTextField.delegate = self; + self.passwordVerifyTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + + /* + if ([SparkSetupCustomization sharedInstance].organization) + { + self.passwordVerifyTextField.returnKeyType = UIReturnKeyNext; + + self.activationCodeTextField.leftView = emptyView4; + self.activationCodeTextField.leftViewMode = UITextFieldViewModeAlways; + self.activationCodeTextField.delegate = self; + self.activationCodeTextField.hidden = NO; + self.activationCodeTextField.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:16.0]; + self.activationCodeTextField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters; + self.activationCodeTextField.delegate = self; + + else + {*/ + // make sign up button be closer to verify password textfield (no activation code field) + self.signupButtonSpace.constant = 16; + self.skipAuthButton.hidden = !([SparkSetupCustomization sharedInstance].allowSkipAuthentication); + + + /* + if ((self.predefinedActivationCode) && (self.predefinedActivationCode.length >= 4)) + { + // trim white space, set string max length to 4 chars and uppercase it + NSString *code = self.predefinedActivationCode; + NSString *codeWhiteSpaceTrimmed = [code stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + codeWhiteSpaceTrimmed = [codeWhiteSpaceTrimmed stringByReplacingOccurrencesOfString:@" " withString:@""]; + codeWhiteSpaceTrimmed = [codeWhiteSpaceTrimmed stringByReplacingOccurrencesOfString:@"%20" withString:@""]; + NSRange stringRange = {0, 4}; + NSString *shortActCode = [codeWhiteSpaceTrimmed substringWithRange:stringRange]; + self.activationCodeTextField.text = [shortActCode uppercaseString]; + } + + */ + + +} + + +// removed activation code +/* +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string +{ + + if (textField == self.activationCodeTextField) + { + NSRange lowercaseCharRange = [string rangeOfCharacterFromSet:[NSCharacterSet lowercaseLetterCharacterSet]]; + + // make activation code uppercase + if (lowercaseCharRange.location != NSNotFound) { + textField.text = [textField.text stringByReplacingCharactersInRange:range + withString:[string uppercaseString]]; + return NO; + } + + // limit it to 4 chars + if(range.length + range.location > textField.text.length) + { + return NO; + } + + NSUInteger newLength = [textField.text length] + [string length] - range.length; + return (newLength > 4) ? NO : YES; + } + + return YES; +} + */ + + +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + if (textField == self.emailTextField) + { + [self.passwordTextField becomeFirstResponder]; + } + if (textField == self.passwordTextField) + { + [self.passwordVerifyTextField becomeFirstResponder]; + } + if (textField == self.passwordVerifyTextField) + { +// if ([SparkSetupCustomization sharedInstance].organization) +// [self.activationCodeTextField becomeFirstResponder]; +// else + [self signupButton:self]; + } +// if (textField == self.activationCodeTextField) +// { +// [self signupButton:self]; +// } + + return YES; + +} + +-(void)viewWillAppear:(BOOL)animated +{ +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Sign Up screen"]; +#endif +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + + + +- (IBAction)signupButton:(id)sender +{ + [self.view endEditing:YES]; + __block NSString *email = [self.emailTextField.text lowercaseString]; + + if (![self.passwordTextField.text isEqualToString:self.passwordVerifyTextField.text]) + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Passwords do not match" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + } + else if ([self isValidEmail:email]) + { + BOOL orgMode = [SparkSetupCustomization sharedInstance].organization; + if (orgMode) + { + // org user sign up + [self.spinner startAnimating]; + + // Sign up and then login + [[SparkCloud sharedInstance] signupWithCustomer:email password:self.passwordTextField.text orgSlug:[SparkSetupCustomization sharedInstance].organizationSlug completion:^(NSError *error) { + if (!error) + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Signed Up New Customer"]; +#endif + + [self.delegate didFinishUserAuthentication:self loggedIn:YES]; + + } + else + { + [self.spinner stopAnimating]; + NSLog(@"Error signing up: %@",error.localizedDescription); + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Could not signup" message:@"Make sure your user email does not already exist and that you have entered the activation code correctly and that it was not already used"/*error.localizedDescription*/ delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + } + + }]; + } + else + { + // normal user sign up + [self.spinner startAnimating]; + + // Sign up and then login + [[SparkCloud sharedInstance] signupWithUser:email password:self.passwordTextField.text completion:^(NSError *error) { + if (!error) + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Signed Up New User"]; +#endif + + [[SparkCloud sharedInstance] loginWithUser:email password:self.passwordTextField.text completion:^(NSError *error) { + [self.spinner stopAnimating]; + if (!error) + { + // [self performSegueWithIdentifier:@"discover" sender:self]; + [self.delegate didFinishUserAuthentication:self loggedIn:YES]; + } + else + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + } + }]; + } + else + { + [self.spinner stopAnimating]; + NSLog(@"Error signing up: %@",error.localizedDescription); + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + + } + }]; + } + + } + else + { + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Invalid email address" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; + [alert show]; + } +} + + +- (IBAction)privacyPolicyButton:(id)sender +{ + [self.view endEditing:YES]; + SparkSetupWebViewController* webVC = [[UIStoryboard storyboardWithName:@"setup" bundle:[NSBundle bundleWithIdentifier:SPARK_SETUP_RESOURCE_BUNDLE_IDENTIFIER]] instantiateViewControllerWithIdentifier:@"webview"]; + webVC.link = [SparkSetupCustomization sharedInstance].privacyPolicyLinkURL; +// webVC.htmlFilename = @"test"; + [self presentViewController:webVC animated:YES completion:nil]; +} + + + +- (IBAction)termOfServiceButton:(id)sender +{ + [self.view endEditing:YES]; + SparkSetupWebViewController* webVC = [[UIStoryboard storyboardWithName:@"setup" bundle:[NSBundle bundleWithIdentifier:SPARK_SETUP_RESOURCE_BUNDLE_IDENTIFIER]] instantiateViewControllerWithIdentifier:@"webview"]; + webVC.link = [SparkSetupCustomization sharedInstance].termsOfServiceLinkURL; + [self presentViewController:webVC animated:YES completion:nil]; +} + + + +- (IBAction)haveAnAccountButtonTouched:(id)sender +{ + [self.view endEditing:YES]; + [self.delegate didRequestUserLogin:self]; + + /* + SparkUserLoginViewController* loginVC = [[UIStoryboard storyboardWithName:@"setup" bundle:[NSBundle bundleWithIdentifier:SPARK_SETUP_RESOURCE_BUNDLE_IDENTIFIER]] instantiateViewControllerWithIdentifier:@"login"]; + loginVC.delegate = self.delegate; + loginVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;// //UIModalPresentationPageSheet; + [self presentViewController:loginVC animated:YES completion:nil]; + */ +} + +- (IBAction)skipAuthButtonTapped:(id)sender { + // that means device is claimed by somebody else - we want to check that with user (and set claimcode if user wants to change ownership) + NSString *messageStr = [SparkSetupCustomization sharedInstance].skipAuthenticationMessage; + self.skipAuthAlertView = [[UIAlertView alloc] initWithTitle:@"Skip authentication" message:messageStr delegate:self cancelButtonTitle:nil otherButtonTitles:@"Yes",@"No",nil]; + [self.skipAuthAlertView show]; + +} + + +-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + if (alertView == self.skipAuthAlertView) + { + if (buttonIndex == 0) //YES + { +#ifdef ANALYTICS + [[Mixpanel sharedInstance] track:@"Auth: Auth skipped"]; +#endif + [self.delegate didFinishUserAuthentication:self loggedIn:NO]; + } + } +} + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIButton.h b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIButton.h new file mode 100644 index 0000000..bbfc8af --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIButton.h @@ -0,0 +1,13 @@ +// +// SparkSetupUIButton.h +// teacup-ios-app +// +// Created by Ido on 1/16/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import + +@interface SparkSetupUIButton : UIButton +@property (nonatomic, strong) NSString *type; // "action", "link" +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIButton.m b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIButton.m new file mode 100644 index 0000000..5d960d6 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIButton.m @@ -0,0 +1,173 @@ +// +// SparkSetupUIButton.m +// teacup-ios-app +// +// Created by Ido on 1/16/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import +#import "SparkSetupUIButton.h" +#import "SparkSetupCustomization.h" +#import + +@implementation SparkSetupUIButton + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { + // Drawing code +} +*/ + + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super initWithCoder:aDecoder]; + if (self) { + [self addTarget:self action:@selector(didTouchButton:) forControlEvents:UIControlEventTouchDown]; + [self addTarget:self action:@selector(didUntouchButton:) forControlEvents:UIControlEventTouchUpOutside]; + [self addTarget:self action:@selector(didUntouchButton:) forControlEvents:UIControlEventTouchUpInside]; + + + } + return self; +} + +-(void)replacePredefinedText +{ + self.titleLabel.text = [self.titleLabel.text stringByReplacingOccurrencesOfString:@"{device}" withString:[SparkSetupCustomization sharedInstance].deviceName]; + self.titleLabel.text = [self.titleLabel.text stringByReplacingOccurrencesOfString:@"{brand}" withString:[SparkSetupCustomization sharedInstance].brandName]; + NSString *orgName = [SparkSetupCustomization sharedInstance].organizationName; + if (orgName) + self.titleLabel.text = [self.titleLabel.text stringByReplacingOccurrencesOfString:@"{org name}" withString:orgName]; + self.titleLabel.text = [self.titleLabel.text stringByReplacingOccurrencesOfString:@"{color}" withString:[SparkSetupCustomization sharedInstance].listenModeLEDColorName]; + self.titleLabel.text = [self.titleLabel.text stringByReplacingOccurrencesOfString:@"{mode button}" withString:[SparkSetupCustomization sharedInstance].modeButtonName]; + self.titleLabel.text = [self.titleLabel.text stringByReplacingOccurrencesOfString:@"{network prefix}" withString:[SparkSetupCustomization sharedInstance].networkNamePrefix]; +} + + + +- (UIColor *)darkerColorForColor:(UIColor *)c // TODO: category for UIColor? +{ + CGFloat r, g, b, a; + if ([c getRed:&r green:&g blue:&b alpha:&a]) + return [UIColor colorWithRed:MAX(r - 0.1, 0.0) + green:MAX(g - 0.1, 0.0) + blue:MAX(b - 0.1, 0.0) + alpha:a]; + return nil; +} + + +- (void)didTouchButton:(id)sender +{ + if ([self.type isEqualToString:@"action"]) + { + UIColor *color = [SparkSetupCustomization sharedInstance].elementBackgroundColor; + self.backgroundColor = [self darkerColorForColor:color]; + +// self.layer.shadowOffset = CGSizeMake(0.0f, 0.0f); + self.layer.shadowOpacity = 0; + + } + [self setNeedsDisplay]; + +} + +- (void)didUntouchButton:(id)sender +{ + if ([self.type isEqualToString:@"action"]) + { + self.backgroundColor = [SparkSetupCustomization sharedInstance].elementBackgroundColor; + +// self.layer.shadowOffset = CGSizeMake(0.0f, 1.0f); + self.layer.shadowOpacity = 0.3; + + } + [self setNeedsDisplay]; + +} + + +-(void)setType:(NSString *)type +{ + _type = type; + [self replacePredefinedText]; + + + if (([type isEqualToString:@"action"]) || ([type isEqualToString:@"primary"])) + { + UIFont *boldFont = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].boldTextFontName size:self.titleLabel.font.pointSize+[SparkSetupCustomization sharedInstance].fontSizeOffset]; + self.titleLabel.font = boldFont; + self.titleLabel.backgroundColor = [UIColor clearColor]; + self.backgroundColor = [SparkSetupCustomization sharedInstance].elementBackgroundColor; + self.layer.cornerRadius = 3.0; + [self setTitleColor:[SparkSetupCustomization sharedInstance].elementTextColor forState:UIControlStateNormal]; + + self.layer.shadowColor = [UIColor blackColor].CGColor; + self.layer.shadowOpacity = 0.3; + self.layer.shadowRadius = 2; + self.layer.shadowOffset = CGSizeMake(0.0f, 1.0f); + } + + if ([type isEqualToString:@"link"]) + { + NSMutableAttributedString *s; + NSString *text = self.titleLabel.text; + + s = [[NSMutableAttributedString alloc] initWithString:text]; + [s addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [s length])]; + + [self setAttributedTitle:s forState:UIControlStateNormal]; + self.titleLabel.textColor = [SparkSetupCustomization sharedInstance].linkTextColor; + [self setTitleColor:[SparkSetupCustomization sharedInstance].linkTextColor forState:UIControlStateNormal]; + + self.titleLabel.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:self.titleLabel.font.pointSize+[SparkSetupCustomization sharedInstance].fontSizeOffset]; + self.backgroundColor = [UIColor clearColor]; + } + + + if ([type isEqualToString:@"secondary"]) + { + + UIFont *boldFont = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].boldTextFontName size:self.titleLabel.font.pointSize+[SparkSetupCustomization sharedInstance].fontSizeOffset]; + self.titleLabel.font = boldFont; +// self.titleLabel.textColor = [SparkSetupCustomization sharedInstance].normalTextColor; + [self setTitleColor:[SparkSetupCustomization sharedInstance].normalTextColor forState:UIControlStateNormal]; + + self.titleLabel.backgroundColor = [UIColor clearColor]; + self.backgroundColor = [UIColor clearColor]; + self.layer.borderColor = [SparkSetupCustomization sharedInstance].normalTextColor.CGColor; + self.layer.backgroundColor = [UIColor clearColor].CGColor; + self.layer.cornerRadius = 3.0; + self.layer.borderWidth = 2.0; + + + } + + + + [self setNeedsDisplay]; + [self layoutIfNeeded]; +} + + + +-(void)setEnabled:(BOOL)enabled +{ + [super setEnabled:enabled]; + + if (enabled) + { + self.alpha = 1; + } + else + { + self.alpha = 0.5; + } + [self setNeedsDisplay]; + +} +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIElements.h b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIElements.h new file mode 100644 index 0000000..c975c40 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIElements.h @@ -0,0 +1,11 @@ +// +// Header.h +// teacup-ios-app +// +// Created by Ido on 1/30/15. +// Copyright (c) 2015 spark. All rights reserved. +// +#import "SparkSetupUILabel.h" +#import "SparkSetupUIButton.h" +#import "SparkSetupUISpinner.h" +#import "SparkSetupUIViewController.h" diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUILabel.h b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUILabel.h new file mode 100644 index 0000000..f993399 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUILabel.h @@ -0,0 +1,13 @@ +// +// SparkSetupUILabel.h +// teacup-ios-app +// +// Created by Ido on 1/16/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import + +@interface SparkSetupUILabel : UILabel +@property (nonatomic, strong) NSString *type;// "bold" or nothing +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUILabel.m b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUILabel.m new file mode 100644 index 0000000..9bd0fcc --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUILabel.m @@ -0,0 +1,73 @@ +// +// SparkSetupUILabel.m +// teacup-ios-app +// +// Created by Ido on 1/16/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupUILabel.h" +#import "SparkSetupCustomization.h" +@implementation SparkSetupUILabel + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { + // Drawing code +} +*/ + +-(void)replacePredefinedText +{ + self.text = [self.text stringByReplacingOccurrencesOfString:@"{device}" withString:[SparkSetupCustomization sharedInstance].deviceName]; + self.text = [self.text stringByReplacingOccurrencesOfString:@"{brand}" withString:[SparkSetupCustomization sharedInstance].brandName]; + NSString *orgName = [SparkSetupCustomization sharedInstance].organizationName; + if (orgName) + self.text = [self.text stringByReplacingOccurrencesOfString:@"{org name}" withString:orgName]; + self.text = [self.text stringByReplacingOccurrencesOfString:@"{color}" withString:[SparkSetupCustomization sharedInstance].listenModeLEDColorName]; + self.text = [self.text stringByReplacingOccurrencesOfString:@"{mode button}" withString:[SparkSetupCustomization sharedInstance].modeButtonName]; + self.text = [self.text stringByReplacingOccurrencesOfString:@"{network prefix}" withString:[SparkSetupCustomization sharedInstance].networkNamePrefix]; + self.text = [self.text stringByReplacingOccurrencesOfString:@"{product}" withString:[SparkSetupCustomization sharedInstance].productName]; + + // self.text = [self.text stringByReplacingOccurrencesOfString:@"{app name}" withString:[SparkSetupCustomization sharedInstance].appName]; +} + +-(id)initWithCoder:(NSCoder *)aDecoder +{ + if (self = [super initWithCoder:aDecoder]) + { +// [self replacePredefinedText]; + [self setType:self.type]; + return self; + } + return nil; + +} + +-(void)setType:(NSString *)type +{ + if ((type) && ([type isEqualToString:@"bold"])) + { + self.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].boldTextFontName size:self.font.pointSize+[SparkSetupCustomization sharedInstance].fontSizeOffset]; + self.textColor = [SparkSetupCustomization sharedInstance].normalTextColor; + } + else if ((type) && ([type isEqualToString:@"header"])) + { + self.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].headerTextFontName size:self.font.pointSize+[SparkSetupCustomization sharedInstance].fontSizeOffset]; + self.textColor = [SparkSetupCustomization sharedInstance].normalTextColor; + } + else + { + self.font = [UIFont fontWithName:[SparkSetupCustomization sharedInstance].normalTextFontName size:self.font.pointSize+[SparkSetupCustomization sharedInstance].fontSizeOffset]; + self.textColor = [SparkSetupCustomization sharedInstance].normalTextColor; + + } + [self replacePredefinedText]; + + [self setNeedsDisplay]; + [self layoutIfNeeded]; + +} + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUISpinner.h b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUISpinner.h new file mode 100644 index 0000000..c667ff7 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUISpinner.h @@ -0,0 +1,18 @@ +// +// SparkSetupUISpinner.h +// teacup-ios-app +// +// Created by Ido on 1/27/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import + +@interface SparkSetupUISpinner : UIImageView +@property (nonatomic, strong) NSString *type; // "foreground" (colored on a view) or "background" (white on a button) + +-(void)startAnimating; +-(void)stopAnimating; +-(instancetype)initWithType:(NSString *)type; + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUISpinner.m b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUISpinner.m new file mode 100644 index 0000000..f3bcd9d --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUISpinner.m @@ -0,0 +1,77 @@ +// +// SparkSetupUISpinner.m +// teacup-ios-app +// +// Created by Ido on 1/27/15. +// Copyright (c) 2015 spark. All rights reserved. +// + +#import "SparkSetupUISpinner.h" +#import "SparkSetupCustomization.h" +#import "SparkSetupMainController.h" + +@implementation SparkSetupUISpinner + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect { + // Drawing code +} +*/ +-(void)setType:(NSString *)type +{ + if ((type) && ([type isEqualToString:@"foreground"])) + { +// self.image = [UIImage imageNamed:@"spinner_big" inBundle:[SparkSetupMainController getResourcesBundle] compatibleWithTraitCollection:nil]; // TODO: make iOS7 compatible + self.image = [SparkSetupMainController loadImageFromResourceBundle:@"spinner_big"]; + self.image = [self.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + self.tintColor = [SparkSetupCustomization sharedInstance].elementBackgroundColor; + } + else + { +// self.image = [UIImage imageNamed:@"spinner" inBundle:[SparkSetupMainController getResourcesBundle] compatibleWithTraitCollection:nil]; // TODO: make iOS7 compatible + self.image = [SparkSetupMainController loadImageFromResourceBundle:@"spinner"]; + NSLog(@"spinner: %@",self.image); + } + + [self setNeedsDisplay]; + [self layoutIfNeeded]; +} + + +-(void)startAnimating +{ + self.hidden = NO; + CABasicAnimation *rotation; + rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; + rotation.fromValue = [NSNumber numberWithFloat:0]; + rotation.toValue = [NSNumber numberWithFloat:(2*M_PI)]; + rotation.duration = 1.11; // Speed + rotation.repeatCount = HUGE_VALF; // Repeat forever. Can be a finite number. + [self.layer addAnimation:rotation forKey:@"Spin"]; +} + + + + +-(void)stopAnimating +{ + self.hidden = YES; + [self.layer removeAllAnimations]; +} + + +-(instancetype)initWithType:(NSString *)type +{ + if (self = [super init]) + { + [self setType:type]; + + return self; + } + return nil; +} + + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIViewController.h b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIViewController.h new file mode 100644 index 0000000..e9d4c78 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIViewController.h @@ -0,0 +1,22 @@ +// +// SparkSetupViewController.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 12/13/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import + +#define SPARK_SETUP_RESOURCE_BUNDLE_IDENTIFIER @"io.spark.SparkSetup" + +#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) +#define isiPhone4 ([[UIScreen mainScreen] bounds].size.height == 480) ? YES : NO +#define isiPhone5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0) + +@interface SparkSetupUIViewController : UIViewController + +-(BOOL)isValidEmail:(NSString *)checkString; // should be in NSString category +-(void)disableKeyboardMovesViewUp; // might not be needed when we remove all popups + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIViewController.m b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIViewController.m new file mode 100644 index 0000000..bb67ec5 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupUIViewController.m @@ -0,0 +1,162 @@ +// +// SparkSetupViewController.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 12/13/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkSetupUIViewController.h" +#import "SparkSetupCustomization.h" + +@interface SparkSetupUIViewController () +@property (nonatomic, assign) CGFloat kbSizeHeight; +@property (weak, nonatomic) IBOutlet UIImageView *brandImageView; +@property (nonatomic, strong) UITapGestureRecognizer *tap; +@end + +@implementation SparkSetupUIViewController + +#pragma mark view controller life cycle + +-(void)viewDidLoad { + [super viewDidLoad]; + + // self.view.backgroundColor = [SparkSetupCustomization sharedInstance].pageBackgroundColor; + if ([SparkSetupCustomization sharedInstance].pageBackgroundImage) + { + UIImageView *backgroundImage = [[UIImageView alloc] initWithImage:[SparkSetupCustomization sharedInstance].pageBackgroundImage]; + backgroundImage.frame = [UIScreen mainScreen].bounds; + backgroundImage.contentMode = UIViewContentModeScaleToFill; + [self.view addSubview:backgroundImage]; + [self.view sendSubviewToBack:backgroundImage]; + } + + + if ([SparkSetupCustomization sharedInstance].pageBackgroundColor) //TODO: check this + { + UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds]; + view.backgroundColor = [SparkSetupCustomization sharedInstance].pageBackgroundColor; + [self.view addSubview:view]; + [self.view sendSubviewToBack:view]; + } + + + // do customization +} + + + +- (void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; +} + +- (void)viewWillDisappear:(BOOL)animated +{ + [super viewWillDisappear:animated]; + + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil]; +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +-(void)disableKeyboardMovesViewUp +{ + // TODO: something less hacky + [self viewWillDisappear:NO]; + +} +#pragma mark public methods + + +- (BOOL)isValidEmail:(NSString *)checkString // TODO: move to NSString category under helpers (as well as encode/decode hex) +{ + NSString *emailRegex = //@".+@([A-Za-z0-9]+\\.)+[A-Za-z]{2}[A-Za-z]*"; + @"(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}" + @"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\" + @"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-" + @"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5" + @"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-" + @"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21" + @"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"; + NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; + return [emailTest evaluateWithObject:checkString]; +} + + + +#pragma mark - Notifications / Keyboard move handling + +- (void)keyboardWillShow:(NSNotification *)notification +{ + self.tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)]; + self.tap.cancelsTouchesInView = YES; // to enable touches to go through tableviews, etc + [self.view addGestureRecognizer:self.tap]; + + self.kbSizeHeight = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height; + self.kbSizeHeight -= [self keyboardHeightAdjust]; + + if (self.view.frame.origin.y >= 0) { + [self setViewMovedUp:YES]; + } else if (self.view.frame.origin.y < 0) { + [self setViewMovedUp:NO]; + } +} + +- (void)keyboardWillHide:(NSNotification *)notification +{ + [self.view removeGestureRecognizer:self.tap]; + + if (self.view.frame.origin.y >= 0) { + [self setViewMovedUp:YES]; + } else if (self.view.frame.origin.y < 0) { + [self setViewMovedUp:NO]; + } +} + +- (void)dismissKeyboard +{ + [self.view endEditing:YES]; +} + +- (CGFloat)keyboardHeightAdjust +{ + if (isiPhone4) return 64.0; + else if (isiPhone5) return 48.0; + else return 32.0; +} + + +//method to move the view up/down whenever the keyboard is shown/dismissed +- (void)setViewMovedUp:(BOOL)movedUp +{ + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.3]; + + CGRect rect = self.view.frame; + if (movedUp) { + // 1. move the view's origin up so that the text field that will be hidden come above the keyboard + // 2. increase the size of the view so that the area behind the keyboard is covered up. + rect.origin.y -= self.kbSizeHeight; + rect.size.height += self.kbSizeHeight; + } else { + // revert back to the normal state. + rect.origin.y += self.kbSizeHeight; + rect.size.height -= self.kbSizeHeight; + } + self.view.frame = rect; + [self.view layoutIfNeeded]; + + [UIView commitAnimations]; +} + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupWifiTableViewCell.h b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupWifiTableViewCell.h new file mode 100644 index 0000000..b54907c --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupWifiTableViewCell.h @@ -0,0 +1,16 @@ +// +// SparkSetupWifiTableViewCell.h +// +// +// Created by Ido on 9/10/15. +// +// + +#import + +@interface SparkSetupWifiTableViewCell : UITableViewCell +@property (weak, nonatomic) IBOutlet UILabel *ssidLabel; +@property (weak, nonatomic) IBOutlet UIImageView *wifiStrengthImageView; +@property (weak, nonatomic) IBOutlet UIImageView *securedNetworkIconImageView; + +@end diff --git a/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupWifiTableViewCell.m b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupWifiTableViewCell.m new file mode 100644 index 0000000..d0b1b62 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/UI/UI Elements/SparkSetupWifiTableViewCell.m @@ -0,0 +1,23 @@ +// +// SparkSetupWifiTableViewCell.m +// +// +// Created by Ido on 9/10/15. +// +// + +#import "SparkSetupWifiTableViewCell.h" + +@implementation SparkSetupWifiTableViewCell + +- (void)awakeFromNib { + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/Strike/Pods/SparkSetup/Classes/User/SparkSetupCustomization.h b/Strike/Pods/SparkSetup/Classes/User/SparkSetupCustomization.h new file mode 100644 index 0000000..bb5937c --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/User/SparkSetupCustomization.h @@ -0,0 +1,80 @@ +// +// SparkSetupCustomization.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 12/12/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import + +//#define ANALYTICS 1 + +@interface SparkSetupCustomization : NSObject + +/** + * Spark soft AP setup wizard apperance customization proxy class + * + * @return Singleton instance of the customization class + */ ++ (instancetype)sharedInstance; + +@property (nonatomic, strong) NSString *deviceName; +@property (nonatomic, strong) UIImage *productImage; + +@property (nonatomic, strong) NSString *brandName; +@property (nonatomic, strong) UIImage *brandImage; +@property (nonatomic, strong) UIColor *brandImageBackgroundColor; +@property (nonatomic, strong) NSString *instructionalVideoFilename; + +@property (nonatomic, strong) NSString *modeButtonName; +@property (nonatomic, strong) NSString *listenModeLEDColorName; +@property (nonatomic, strong) NSString *networkNamePrefix; + +// TODO: kill forgot password links +@property (nonatomic, strong) NSURL *termsOfServiceLinkURL; // URL for terms of service of the app/device usage +@property (nonatomic, strong) NSURL *privacyPolicyLinkURL; // URL for privacy policy of the app/device usage +@property (nonatomic, strong) NSURL *forgotPasswordLinkURL; // URL for user password reset (non-organization setup app only) +@property (nonatomic, strong) NSURL *troubleshootingLinkURL; // URL for troubleshooting text of the app/device usage + +@property (nonatomic, strong) NSString *termsOfServiceHTMLFile; // Static HTML for terms of service of the app/device usage +@property (nonatomic, strong) NSString *privacyPolicyHTMLFile; // Static HTML for privacy policy of the app/device usage +@property (nonatomic, strong) NSString *forgotPasswordHTMLFile; // Static HTML for user password reset (non-organization setup app only) +@property (nonatomic, strong) NSString *troubleshootingHTMLFile; // Static HTML for troubleshooting text of the app/device usage + +@property (nonatomic, strong) UIColor *pageBackgroundColor; +@property (nonatomic, strong) UIImage *pageBackgroundImage; +@property (nonatomic, strong) UIColor *normalTextColor; +@property (nonatomic, strong) UIColor *linkTextColor; + +@property (nonatomic, strong) UIColor *elementBackgroundColor; // Buttons/spinners background color +// TODO: change to: +//@property (nonatomic, strong) UIColor *buttonBackgroundColor; // new + +@property (nonatomic, strong) UIColor *elementTextColor; // Buttons text color +// TODO: change to: +//@property (nonatomic, strong) UIColor *buttonTextColor; // new +@property (nonatomic) BOOL tintSetupImages; // new // this will tint the checkmark/warning/ wifi symbols + + +@property (nonatomic, strong) NSString *normalTextFontName; // Customize setup font - include OTF/TTF file in project + +@property (nonatomic, strong) NSString *headerTextFontName; //new + +@property (nonatomic, strong) NSString *boldTextFontName; // Customize setup font - include OTF/TTF file in project + + +@property (nonatomic) CGFloat fontSizeOffset; // Set offset of font size so small/big fonts can be fine-adjusted + +@property (nonatomic, assign) BOOL organization; // enable organizational mode +@property (nonatomic, strong) NSString *organizationName; // organization display name +@property (nonatomic, strong) NSString *organizationSlug; // organizational name for API endpoint URL - must specify for orgMode +@property (nonatomic, strong) NSString *productName; // product display name +@property (nonatomic, strong) NSString *productSlug; // product string for API endpoint URL - must specify for orgMode + +@property (nonatomic, assign) BOOL allowSkipAuthentication; // allow user to skip authentication +@property (nonatomic, strong) NSString *skipAuthenticationMessage; // Prompt to display to user when he's requesting to skip authentication +@property (nonatomic) BOOL disableLogOutOption; // Do not allow the user to log out from the GetReady page. + +@end diff --git a/Strike/Pods/SparkSetup/Classes/User/SparkSetupCustomization.m b/Strike/Pods/SparkSetup/Classes/User/SparkSetupCustomization.m new file mode 100644 index 0000000..50475a3 --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/User/SparkSetupCustomization.m @@ -0,0 +1,101 @@ +// +// SparkSetupCustomization.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 12/12/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkSetupCustomization.h" +#import "SparkSetupMainController.h" + + + +@interface UIColor(withDecimalRGB) // TODO: move to category in helpers ++(UIColor *)colorWithRed:(NSInteger)r green:(NSInteger)g blue:(NSInteger)b; +@end + +@implementation UIColor(withDecimalRGB) // TODO: move to category in helpers ++(UIColor *)colorWithRed:(NSInteger)r green:(NSInteger)g blue:(NSInteger)b +{ + return [UIColor colorWithRed:((float)r/255.0f) green:((float)g/255.0f) blue:((float)b/255.0f) alpha:1.0f]; +} +@end + +@implementation SparkSetupCustomization + + ++(instancetype)sharedInstance +{ + static SparkSetupCustomization *sharedInstance = nil; + @synchronized(self) { + if (sharedInstance == nil) + { + sharedInstance = [[self alloc] init]; + } + } + return sharedInstance; + +} + + + +-(instancetype)init +{ + if (self = [super init]) + { + // Defaults + self.deviceName = @"Particle device"; +// self.deviceImage = [UIImage imageNamed:@"photon" inBundle:[SparkSetupMainController getResourcesBundle] compatibleWithTraitCollection:nil]; // TODO: make iOS7 compatible + self.brandName = @"Particle"; +// self.brandImage = [UIImage imageNamed:@"spark-logo-head" inBundle:[SparkSetupMainController getResourcesBundle] compatibleWithTraitCollection:nil]; // TODO: make iOS7 compatible + self.brandImage = [SparkSetupMainController loadImageFromResourceBundle:@"spark-logo-head"]; +// self.brandImageBackgroundColor = [UIColor colorWithRed:0.79f green:0.79f blue:0.79f alpha:1.0f]; + self.brandImageBackgroundColor = [UIColor colorWithRed:229 green:229 blue:237]; + + self.modeButtonName = @"mode button"; + self.networkNamePrefix = @"Photon"; + self.listenModeLEDColorName = @"blue"; +// self.appName = self.brandName;// @"SparkSetup"; + self.fontSizeOffset = 0; + + self.privacyPolicyLinkURL = [NSURL URLWithString:@"https://www.spark.io/privacy"]; + self.termsOfServiceLinkURL = [NSURL URLWithString:@"https://www.spark.io/tos"]; + self.forgotPasswordLinkURL = [NSURL URLWithString:@"https://www.spark.io/forgot-password"]; + self.troubleshootingLinkURL = [NSURL URLWithString:@"https://community.spark.io/t/spark-core-troubleshooting-guide-spark-team/696"]; + // TODO: add default HTMLs + +// self.normalTextColor = [UIColor blackColor]; + self.normalTextColor = [UIColor colorWithRed:28 green:26 blue:25]; + self.pageBackgroundColor = [UIColor colorWithWhite:0.94 alpha:1.0f]; +// self.pageBackgroundColor = [UIColor colorWithRed:250 green:250 blue:250]; + self.linkTextColor = [UIColor blueColor]; +// self.linkTextColor = [UIColor colorWithRed:6 green:165 blue:226]; +// self.errorTextColor = [UIColor redColor]; +// self.errorTextColor = [UIColor colorWithRed:254 green:71 blue:71]; +// self.elementBackgroundColor = [UIColor colorWithRed:0.84f green:0.32f blue:0.07f alpha:1.0f]; + self.elementBackgroundColor = [UIColor colorWithRed:0 green:165 blue:231]; + self.elementTextColor = [UIColor whiteColor]; + + self.normalTextFontName = @"HelveticaNeue"; + self.boldTextFontName = @"HelveticaNeue-Bold"; + self.headerTextFontName = @"HelveticaNeue-Light"; + + self.tintSetupImages = NO; + + self.organization = NO; + self.organizationSlug = @"particle"; + self.organizationName = @"Particle"; + self.productSlug = @"photon"; + self.productName = @"Photon"; + + self.allowSkipAuthentication = NO; + self.skipAuthenticationMessage = @"Skipping authentication will allow you to configure Wi-Fi credentials to your device but it will not be claimed to your account. Are you sure you want to skip authentication?"; + self.disableLogOutOption = NO; + return self; + } + + return nil; +} + +@end diff --git a/Strike/Pods/SparkSetup/Classes/User/SparkSetupMainController.h b/Strike/Pods/SparkSetup/Classes/User/SparkSetupMainController.h new file mode 100644 index 0000000..199ca8e --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/User/SparkSetupMainController.h @@ -0,0 +1,107 @@ +// +// SparkSetupManager.h +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/15/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import +#import +#import "SparkSetupCustomization.h" +#import "Spark-SDK.h" + +typedef NS_ENUM(NSInteger, SparkSetupMainControllerResult) { + SparkSetupMainControllerResultSuccess=1, + SparkSetupMainControllerResultFailure, + SparkSetupMainControllerResultUserCancel, + SparkSetupMainControllerResultLoggedIn, // relevant to initWithAuthenticationOnly:YES only + SparkSetupMainControllerResultSkippedAuth, // relevant to initWithAuthenticationOnly:YES only + SparkSetupMainControllerResultSuccessNotClaimed + +}; + +extern NSString *const kSparkSetupDidLogoutNotification; +extern NSString *const kSparkSetupDidFinishNotification; +extern NSString *const kSparkSetupDidFinishStateKey; +extern NSString *const kSparkSetupDidFinishDeviceKey; + +@class SparkSetupMainController; + +@protocol SparkSetupMainControllerDelegate +@required +/** + * Method will be called whenever SparkSetup wizard completes + * + * @param controller Instance of main SparkSetup viewController + * @param result Result of setup completion - can be success, failure or user-cancelled. + * @param device SparkDevice instance in case the setup completed successfully and a SparkDevice was claimed to logged in user + */ +- (void)sparkSetupViewController:(SparkSetupMainController *)controller didFinishWithResult:(SparkSetupMainControllerResult)result device:(SparkDevice *)device; +@end + + +@interface SparkSetupMainController : UIViewController + +// Viewcontroller displaying the modal setup UI control +@property (nonatomic, weak) id delegate; + +/** + * Entry point for invoking Spark Soft AP setup wizard, use by calling this on your viewController: + * SparkSetupMainController *setupController = [[SparkSetupMainController alloc] init]; // or [SparkSetupMainController new] + * [self presentViewController:setupController animated:YES completion:nil]; + * If no active user session exists than this call will also authenticate user to the Spark cloud (or allow her to sign up) before the soft AP wizard will be displayed + * + * @return An inititalized SparkSetupMainController instance ready to be presented. + */ +-(instancetype)init NS_DESIGNATED_INITIALIZER; + +/** + * Entry point for invoking Spark Cloud authentication (login/signup/password recovery screens) only, use by calling this on your viewController: + * SparkSetupMainController *setupController = [[SparkSetupMainController alloc] initWithAuthenticationOnly]; + * [self presentViewController:setupController animated:YES completion:nil]; + * After user has successfully logged in or signed up, control will be return to the calling app. If an active user session already exists control will be returned immediately + * + * @param yesOrNo YES will invoke Authentication wizard only, NO will invoke whole Device Setup process (will skip authentication if user session is active, same as calling -init) + * + * @return An inititalized SparkSetupMainController instance ready to be presented. + */ +-(instancetype)initWithAuthenticationOnly:(BOOL)yesOrNo; + + +/** + * Entry point for invoking Spark Cloud setup process only - used for configuring device Wi-Fi credentials without changing its ownership. + * If active user session exists - it'll be used and device will be claimed, otherwise no. Calling -initWithSetupOnly: method with an active user session is + * essentially the same as calling -init: + * use by calling this on your viewController: + * SparkSetupMainController *setupController = [[SparkSetupMainController alloc] initWithSetupOnly]; + * [self presentViewController:setupController animated:YES completion:nil]; + * After user has successfully logged in or signed up, control will be return to the calling app. If an active user session already exists control will be returned immediately + * + * @param yesOrNo YES will invoke Setup wizard only, NO will invoke whole Device Setup process (will skip authentication if user session is active, same as calling -init) + * + * @return An inititalized SparkSetupMainController instance ready to be presented. + */ +-(instancetype)initWithSetupOnly:(BOOL)yesOrNo; + + +/** + * Open setup wizard in Signup screen with a pre-filled activation code from a URL scheme which was used to open the app. + * Deprecated since pod v0.3.0 + * + * @param activationCode Activation code string + */ +-(void)showSignupWithPredefinedActivationCode:(NSString *)activationCode __deprecated; + +/** + * Get default resource bundle for Spark Soft AP setup wizard assets + * + * @return Default assets resource NSBundle instance + */ ++(NSBundle *)getResourcesBundle; ++(UIImage *)loadImageFromResourceBundle:(NSString *)imageName; + + +@end + + diff --git a/Strike/Pods/SparkSetup/Classes/User/SparkSetupMainController.m b/Strike/Pods/SparkSetup/Classes/User/SparkSetupMainController.m new file mode 100644 index 0000000..c2be1bf --- /dev/null +++ b/Strike/Pods/SparkSetup/Classes/User/SparkSetupMainController.m @@ -0,0 +1,257 @@ +// +// SparkSetupManager.m +// mobile-sdk-ios +// +// Created by Ido Kleinman on 11/15/14. +// Copyright (c) 2014-2015 Spark. All rights reserved. +// + +#import "SparkSetupMainController.h" +#import "SparkUserSignupViewController.h" +#import "SparkSetupCommManager.h" +#import "SparkSetupConnection.h" +#import "SparkCloud.h" +#import "SparkSetupCustomization.h" +#import "SparkUserLoginViewController.h" +#import "SparkSetupUIElements.h" + +//#define SPARK_SETUP_RESOURCE_BUNDLE_IDENTIFIER @"io.spark.SparkSetup" + +NSString *const kSparkSetupDidFinishNotification = @"kSparkSetupDidFinishNotification"; +NSString *const kSparkSetupDidFinishStateKey = @"kSparkSetupDidFinishStateKey"; +NSString *const kSparkSetupDidFinishDeviceKey = @"kSparkSetupDidFinishDeviceKey"; +NSString *const kSparkSetupDidLogoutNotification = @"kSparkSetupDidLogoutNotification"; + +@interface SparkSetupMainController() + +//@property (nonatomic, strong) UINavigationController *setupNavController; +@property (weak, nonatomic) IBOutlet UIView *containerView; +@property (nonatomic, strong) UIViewController *currentVC; +@property (nonatomic) BOOL authenticationOnly; +@property (nonatomic) BOOL setupOnly; +@end + +@implementation SparkSetupMainController + + ++(NSBundle *)getResourcesBundle +{ + NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle bundleForClass:[self class]] URLForResource:@"SparkSetup" withExtension:@"bundle"]]; + return bundle; +} + + ++(UIStoryboard *)getSetupStoryboard +{ + UIStoryboard *setupStoryboard = [UIStoryboard storyboardWithName:@"setup" bundle:[SparkSetupMainController getResourcesBundle]]; + return setupStoryboard; +} + ++(UIImage *)loadImageFromResourceBundle:(NSString *)imageName +{ + NSBundle *bundle = [SparkSetupMainController getResourcesBundle]; + NSString *imageFileName = [NSString stringWithFormat:@"%@.png",imageName]; + UIImage *image = [UIImage imageNamed:imageFileName inBundle:bundle compatibleWithTraitCollection:nil]; + return image; +} + +-(instancetype)init +{ + SparkSetupMainController* mainVC = [super initWithNibName:nil bundle:nil]; // super init is not actually required, but supress the warning + self.authenticationOnly = NO; + + @try { + mainVC = [[SparkSetupMainController getSetupStoryboard] instantiateViewControllerWithIdentifier:@"root"]; + } + @catch (NSException *exception) { + return nil; + } + + return mainVC; +} + + +-(instancetype)initWithSetupOnly:(BOOL)yesOrNo +{ + SparkSetupMainController* mainVC = [self init]; + self.setupOnly = yesOrNo; + return mainVC; +} + + +-(instancetype)initWithAuthenticationOnly:(BOOL)yesOrNo +{ + SparkSetupMainController* mainVC = [self init]; + self.authenticationOnly = yesOrNo; + return mainVC; +} + +-(void)viewDidLoad +{ + [super viewDidLoad]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupDidFinishObserver:) name:kSparkSetupDidFinishNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setupDidLogoutObserver:) name:kSparkSetupDidLogoutNotification object:nil]; + + if ([SparkCloud sharedInstance].isLoggedIn) + { + // start from discover screen if user is already logged in + if (self.authenticationOnly == NO) + { + [self runSetup]; + } + else + { + // add a small delay and perform in another thread to let viewDidload finish, otherwise we might get a deadlock black screen + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:kSparkSetupDidFinishNotification object:nil userInfo:@{kSparkSetupDidFinishStateKey:@(SparkSetupMainControllerResultLoggedIn)}]; + }); + } + } + else + { + if (self.setupOnly) + [self runSetup]; + else + [self showSignup]; + } + + +} + +-(void)runSetup +{ + UINavigationController* setupVC = [[SparkSetupMainController getSetupStoryboard] instantiateViewControllerWithIdentifier:@"setup"]; + [self showViewController:setupVC]; +} + +-(void)showSignup +{ + SparkUserSignupViewController *signupVC = [[SparkSetupMainController getSetupStoryboard] instantiateViewControllerWithIdentifier:@"signup"]; + signupVC.delegate = self; + [self showViewController:signupVC]; +} + + +-(void)showSignupWithPredefinedActivationCode:(NSString *)activationCode; +{ + // __deprecated + SparkUserSignupViewController *signupVC = [[SparkSetupMainController getSetupStoryboard] instantiateViewControllerWithIdentifier:@"signup"]; +// signupVC.predefinedActivationCode = activationCode; + signupVC.delegate = self; + [self showViewController:signupVC]; +} + + +-(void)showLogin +{ + SparkUserLoginViewController *loginVC = [[SparkSetupMainController getSetupStoryboard] instantiateViewControllerWithIdentifier:@"login"]; + loginVC.delegate = self; + [self showViewController:loginVC]; +} + +-(void)showPasswordReset +{ + SparkUserLoginViewController *pwdrstVC = [[SparkSetupMainController getSetupStoryboard] instantiateViewControllerWithIdentifier:@"password_reset"]; + pwdrstVC.delegate = self; + [self showViewController:pwdrstVC]; +} + + +-(void)setupDidLogoutObserver:(NSNotification *)note +{ + // User intentionally logged out so display the login/signup screens + [self showLogin]; +} + +#pragma mark SparkUserLoginDelegate methods +//-(void)didFinishUserLogin:(id)sender +-(void)didFinishUserAuthentication:(id)sender loggedIn:(BOOL)loggedIn; +{ + if (self.authenticationOnly) + { + // if authentication only requested than just post a notification to remove modal screen and return to calling app + // add a small delay and perform in another thread to let viewDidload finish (if we're still in it), otherwise we might get a deadlock black screen + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + if (loggedIn) + [[NSNotificationCenter defaultCenter] postNotificationName:kSparkSetupDidFinishNotification object:nil userInfo:@{kSparkSetupDidFinishStateKey:@(SparkSetupMainControllerResultLoggedIn)}]; + else + [[NSNotificationCenter defaultCenter] postNotificationName:kSparkSetupDidFinishNotification object:nil userInfo:@{kSparkSetupDidFinishStateKey:@(SparkSetupMainControllerResultSkippedAuth)}]; + + }); + } + else + { + + [self runSetup]; + } +} + + +-(void)didRequestPasswordReset:(id)sender +{ + [self showPasswordReset]; +} + +-(void)didRequestUserSignup:(id)sender +{ + [self showSignup]; +} + +-(void)didRequestUserLogin:(id)sender +{ + [self showLogin]; +} + +#pragma mark Observer for setup end notifications +-(void)setupDidFinishObserver:(NSNotification *)note +{ + // Setup finished so dismiss modal main controller and call delegate with state + + NSDictionary *finishStateDict = note.userInfo; + NSNumber* state = finishStateDict[kSparkSetupDidFinishStateKey]; + SparkDevice *device = finishStateDict[kSparkSetupDidFinishDeviceKey]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:kSparkSetupDidFinishNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:kSparkSetupDidLogoutNotification object:nil]; + + [self dismissViewControllerAnimated:YES completion:^{ + [self.delegate sparkSetupViewController:self didFinishWithResult:[state integerValue] device:device]; // TODO: add NSError reporting? + }]; +} + +// viewcontroller container behaviour code +- (void)showViewController:(UIViewController *)viewController +{ + if (self.currentVC) + { + [self addChildViewController:viewController]; + [self transitionFromViewController:self.currentVC toViewController:viewController duration:0.5f options:UIViewAnimationOptionTransitionFlipFromTop animations:nil completion:nil]; + [self hideViewController:self.currentVC]; + } + self.currentVC = viewController; + [self.containerView endEditing:YES]; + [self addChildViewController:viewController]; + viewController.view.frame = self.containerView.bounds; + [self.containerView addSubview:viewController.view]; + [viewController didMoveToParentViewController:self]; +} + +- (void)hideViewController:(UIViewController *)viewController; +{ + [self.containerView endEditing:YES]; + [viewController willMoveToParentViewController:nil]; + [viewController.view removeFromSuperview]; + [viewController removeFromParentViewController]; +} + + +-(void)dealloc +{ + // check + [[NSNotificationCenter defaultCenter] removeObserver:self name:kSparkSetupDidFinishNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:kSparkSetupDidLogoutNotification object:nil]; + +} + + +@end diff --git a/Strike/Pods/SparkSetup/LICENSE b/Strike/Pods/SparkSetup/LICENSE new file mode 100644 index 0000000..7acc4a1 --- /dev/null +++ b/Strike/Pods/SparkSetup/LICENSE @@ -0,0 +1,176 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/Strike/Pods/SparkSetup/README.md b/Strike/Pods/SparkSetup/README.md new file mode 100644 index 0000000..658ac26 --- /dev/null +++ b/Strike/Pods/SparkSetup/README.md @@ -0,0 +1,229 @@ +

+Particle +

+ +# Particle Device Setup library (beta) + +[![Platform](https://img.shields.io/badge/platform-iOS-10a4fa.svg)]() [![license](https://img.shields.io/hexpm/l/plug.svg)]() [![version](https://img.shields.io/badge/pod-0.2.1-green.svg)]() + +The Particle Device Setup library is meant for integrating the initial setup process of Particle devices in your app. +This library will enable you to easily invoke a standalone setup wizard UI for setting up internet-connected products +powered by a Particle device (Photon, P0, P1). The setup UI can be easily customized by a customization proxy class, +that includes: look & feel, colors, texts and fonts as well as custom brand logos and custom instructional video for your product. There are good defaults in place if you don’t set these properties, but you can override the look and feel as needed to suit the rest of your app. + +The wireless setup process for the Photon uses very different underlying technology from the Core. Where the Core used TI SmartConfig, the Photon uses what we call “soft AP” — i.e.: the Photon advertises a Wi-Fi network, you join that network from your mobile app to exchange credentials, and then the Photon connects using the Wi-Fi credentials you supplied. + +With the Device Setup library, you make one simple call from your app, for example when the user hits a “Setup my device” button, and a whole series of screens then guide the user through the setup process. When the process finishes, the app user is back on the screen where she hit the “setup my device” button, and your code has been passed an instance of the device she just setup and claimed. + +**Rebranding notice** + +Spark has been recently rebranded as Particle. +Code currently contains `SparkSetup` keyword as classes prefixes. this will soon be replaced with `ParticleDeviceSetup`. A new Cocoapod library will be published and current one will be depracated and point to the new one. This should not bother or affect your code in any way. + +## Usage + +Official documentation can be found in [Particle docs website](http://docs.particle.io/photon/ios/). + +### Basic + +Import `SparkSetup.h` in your view controller implementation file, and invoke the device setup wizard by: + +**Objective-C** + +```objc +SparkSetupMainController *setupController = [[SparkSetupMainController alloc] init]; +setupController.delegate = self; // why? see "Advanced" section below +[self presentViewController:setupController animated:YES completion:nil]; +``` + +**Swift** + +```swift +if let setupController = SparkSetupMainController() +{ + setupController.delegate = self + self.presentViewController(setupController, animated: true, completion: nil) +} +``` + +Alternatively if your app requires separation between the Particle cloud authentication process and the device setup process you can call: + +**Objective-C** + +```objc +SparkSetupMainController *setupController = [[SparkSetupMainController alloc] initWithAuthenticationOnly:YES]; +[self presentViewController:setupController animated:YES completion:nil]; +``` + +**Swift** +```swift +if let setupController = SparkSetupMainController(authenticationOnly: true) +{ + self.presentViewController(setupController, animated: true, completion: nil) +} +``` + +This will invoke Particle Cloud authentication (login/signup/password recovery screens) only +after user has successfully logged in or signed up, control will be returned to the calling app. +If an active user session already exists control will be returned immediately. + +####Configure device Wi-Fi credentials without claiming it + +If your app requires the ability to let users configure device Wi-Fi credentials without changing its ownership you can also do that via `initWithSetupOnly`, +and by allowing your users to skip authentication (see `allowSkipAuthentication` flag in customization section) if you present the authentication stage. +If an active user session exists - it'll be used and device will be claimed, otherwise it won't. +So invoking setup without an active user session will go thru the setup steps required for configuring device Wi-Fi credentials but not for claiming it. +However, calling `-initWithSetupOnly:` method with an active user session is essentially the same as calling `-init:`. +Usage: + +```objc +SparkSetupMainController *setupController = [[SparkSetupMainController alloc] initWithSetupOnly:YES]; +[self presentViewController:setupController animated:YES completion:nil]; +``` + +**Swift** +```swift +if let setupController = SparkSetupMainController(setupOnly: true) +{ + self.presentViewController(setupController, animated: true, completion: nil) +} +``` + + +### Customization + +Customize setup look and feel by accessing the `SparkSetupCustomization` singleton appearance proxy `[SparkSetupCustomization sharedInstance]` +and modify its default properties. Setting the properties in this class is optional. *(Replace NSString with String for Swift projects)* + +#### Product/brand info: + +```objc + NSString *deviceName; // Device/product name + UIImage *productImage; // Custom product image to display in "Get ready" screen *new* + NSString *brandName; // Your brand name + UIImage *brandImage; // Your brand logo to fit in header of setup wizard screens + UIColor *brandImageBackgroundColor; // brand logo background color + NSString *instructionalVideoFilename; // Instructional video shown when "show me how" button pressed +``` + +#### Technical data: + +```objc + NSString *modeButtonName; // The mode button name on your product + NSString *listenModeLEDColorName; // The color of the LED when product is in listen mode + NSString *networkNamePrefix; // The SSID prefix of the Soft AP Wi-Fi network of your product while in listen mode +``` + +#### Links for legal/technical info: + +```objc + NSURL *termsOfServiceLinkURL; // URL for terms of service of the app/device usage + NSURL *privacyPolicyLinkURL; // URL for privacy policy of the app/device usage + NSURL *forgotPasswordLinkURL; // URL for user password reset (non-organization setup app only) - to be disabled soon + NSURL *troubleshootingLinkURL; // URL for troubleshooting text of the app/device usage + + NSString *termsOfServiceHTMLFile; // Static HTML file for terms of service of the app/device usage + NSString *privacyPolicyHTMLFile; // Static HTML file for privacy policy of the app/device usage + NSString *forgotPasswordHTMLFile; // Static HTML file for user password reset (non-organization setup app only) - to be disabled soon + NSString *troubleshootingHTMLFile; // Static HTML file for troubleshooting text of the app/device usage +``` + +#### Look & feel: + +```objc + UIColor *pageBackgroundColor; // setup screens background color + UIImage *pageBackgroundImage; // optional background image for setup screens + UIColor *normalTextColor; // normal text color + UIColor *linkTextColor; // link text color (will be underlined) + UIColor *elementBackgroundColor; // Buttons/spinners background color + UIColor *elementTextColor; // Buttons text color + NSString *normalTextFontName; // Customize setup font - include OTF/TTF file in project + NSString *boldTextFontName; // Customize setup font - include OTF/TTF file in project + CGFloat fontSizeOffset; // Set offset of font size so small/big fonts can be fine-adjusted + BOOL tintSetupImages; // This will tint the checkmark/warning/wifi symbols in the setup process to match text color (useful for dark backgrounds) +``` + +#### Organization: + +Setting `organization=YES` will enable organization mode which uses different API endpoints and requires special permissions (See Particle Dashboard). +*New fields since v0.2.2* + +If you set `organization` to `YES` be sure to also provide the `organizationSlug` and `productSlug` your created in [Particle Dashboard](https://docs.particle.io/guide/tools-and-features/dashboard/). +Make sure you inject the `SparkCloud` class with scoped OAuth credentials for creating customers (so app users could create an account), [read here](https://docs.particle.io/reference/ios/#oauth-client-configuration) on how to do it correctly. +To learn how to create those credentials for your organization [read here](https://docs.particle.io/guide/how-to-build-a-product/authentication/#creating-an-oauth-client). + +```objc + BOOL organization; // enable organizational mode + NSString *organizationName; // organization display name + NSString *organizationSlug; // organizational name for API endpoint URL - must specify for orgMode *new* + NSString *productName; // product display name *new* + NSString *productSlug; // product string for API endpoint URL - must specify for orgMode *new* +``` + +#### Skipping authentication: + +*New since v0.3.0* + +```objc + BOOL allowSkipAuthentication; // Allow user to skip authentication (skip button will appear on signup and login screens) + NSString *skipAuthenticationMessage; // Message to display to user when she's requesting to skip authentication (Yes/No question) +``` + +### Advanced + +You can get an active instance of `SparkDevice` by making your viewcontroller conform to protocol `` when setup wizard completes: + +```objc +-(void)sparkSetupViewController:(SparkSetupMainController *)controller didFinishWithResult:(SparkSetupMainControllerResult)result device:(SparkDevice *)device; +``` + +```swift +func sparkSetupViewController(controller: SparkSetupMainController!, didFinishWithResult result: SparkSetupMainControllerResult, device: SparkDevice!); +``` + +method will be called, if `(result == SparkSetupMainControllerResultSuccess)` or (or simply `(result == .Success)` in Swift) the device parameter will contain an active `SparkDevice` instance you can interact with +using the [iOS Cloud SDK](https://cocoapods.org/pods/Spark-SDK). + +#### Support for Swift projects +To use Particle Device Setup library from within Swift based projects [read here](http://swiftalicio.us/2014/11/using-cocoapods-from-swift/), +also be sure the check out [Apple documentation](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html) on this matter. + +### Example +Usage example app (in Swift) can be found [here](https://www.github.com/spark/spark-setup-ios-example/). Example app demonstates - invoking the setup wizard, customizing its UI and using the returned SparkDevice instance once +setup wizard completes (delegate). Feel free to contribute to the example by submitting pull requests. + +### Reference + +Check out the [Reference in Cocoadocs website](http://cocoadocs.org/docsets/SparkSetup/) or consult the javadoc style comments in `SparkSetupCustomization.h` and `SparkSetupMainController.h` for each public method or property. +If the Device Setup library installation completed successfully - you should be able to press `Esc` to get an auto-complete hints from XCode for each public method or property in the library. + +## Requirements / limitations + +- iOS 8.0 and up supported +- Currently setup wizard displays on portait mode only. +- XCode 6.0 and up is required + +## Installation + +Particle Device Setup library is available through [CocoaPods](http://cocoapods.org) under the pod name `SparkSetup`. +To install it, simply add the following line to your Podfile: + +```ruby +pod "SparkSetup" +``` + +## Communication + +- If you **need help**, use [Our community website](http://community.spark.io) +- If you **found a bug**, _and can provide steps to reliably reproduce it_, open an issue. +- If you **have a feature request**, open an issue. +- If you **want to contribute**, submit a pull request. + + +## Maintainers + +- [Ido Kleinman](https://www.github.com/idokleinman) + +## License + +Particle Device Setup library is available under the Apache license 2.0. See the LICENSE file for more info. diff --git a/Strike/Pods/SparkSetup/Resources/setup.storyboard b/Strike/Pods/SparkSetup/Resources/setup.storyboard new file mode 100644 index 0000000..b0bcbd4 --- /dev/null +++ b/Strike/Pods/SparkSetup/Resources/setup.storyboard @@ -0,0 +1,5460 @@ + + + + + + + + + + + + + Gotham-Book + Gotham-Book + Gotham-Book + Gotham-Book + + + Reader + Reader + Reader + Reader + Reader + Reader + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/1.imageset/1.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/1.imageset/1.png new file mode 100644 index 0000000..1788873 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/1.imageset/1.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/2.imageset/2.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/2.imageset/2.png new file mode 100644 index 0000000..0fc775e Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/2.imageset/2.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/3.imageset/3.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/3.imageset/3.png new file mode 100644 index 0000000..3c406a5 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/3.imageset/3.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29.png new file mode 100644 index 0000000..436152d Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29@2x-1.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29@2x-1.png new file mode 100644 index 0000000..ba5bc50 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29@2x-1.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png new file mode 100644 index 0000000..ba5bc50 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon29x29@2x.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40.png new file mode 100644 index 0000000..8c01b5e Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40@2x-1.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40@2x-1.png new file mode 100644 index 0000000..cb6b95c Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40@2x-1.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png new file mode 100644 index 0000000..cb6b95c Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon40x40@2x.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png new file mode 100644 index 0000000..7753390 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon60x60@2x.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon76x76-1.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon76x76-1.png new file mode 100644 index 0000000..c935506 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon76x76-1.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon76x76@2x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon76x76@2x.png new file mode 100644 index 0000000..6c86579 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/AppIcon.appiconset/AppIcon76x76@2x.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-568h@2x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-568h@2x.png new file mode 100644 index 0000000..ef84d20 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-568h@2x.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-667h@2x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-667h@2x.png new file mode 100644 index 0000000..68d0b7e Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-667h@2x.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-Portrait-736h@3x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-Portrait-736h@3x.png new file mode 100644 index 0000000..6839f6f Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default-Portrait-736h@3x.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default@2x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default@2x.png new file mode 100644 index 0000000..6dedc53 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/LaunchImage.launchimage/Default@2x.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/background.imageset/background-1-1.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/background.imageset/background-1-1.png new file mode 100644 index 0000000..9d5d670 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/background.imageset/background-1-1.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/background.imageset/background-1.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/background.imageset/background-1.png new file mode 100644 index 0000000..9d5d670 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/background.imageset/background-1.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/checkmark.imageset/checkmark.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/checkmark.imageset/checkmark.png new file mode 100644 index 0000000..5a8b6a3 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/checkmark.imageset/checkmark.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/connect-to-power.imageset/connect-to-power.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/connect-to-power.imageset/connect-to-power.png new file mode 100644 index 0000000..981889d Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/connect-to-power.imageset/connect-to-power.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/connect-to-wifi.imageset/connect-to-wifi.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/connect-to-wifi.imageset/connect-to-wifi.png new file mode 100644 index 0000000..e566f2b Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/connect-to-wifi.imageset/connect-to-wifi.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/failure.imageset/failure.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/failure.imageset/failure.png new file mode 100644 index 0000000..b943863 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/failure.imageset/failure.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/imgBackArrow.imageset/imgBackArrow.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/imgBackArrow.imageset/imgBackArrow.png new file mode 100644 index 0000000..be8623d Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/imgBackArrow.imageset/imgBackArrow.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/iosCheckmark.imageset/iosCheckmark.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/iosCheckmark.imageset/iosCheckmark.png new file mode 100644 index 0000000..968c8f7 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/iosCheckmark.imageset/iosCheckmark.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/iosSettingWifi.imageset/iosSettingWifi.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/iosSettingWifi.imageset/iosSettingWifi.png new file mode 100644 index 0000000..814eecf Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/iosSettingWifi.imageset/iosSettingWifi.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/leftChevron.imageset/leftChevron.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/leftChevron.imageset/leftChevron.png new file mode 100644 index 0000000..3066eed Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/leftChevron.imageset/leftChevron.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/lock.imageset/lock.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/lock.imageset/lock.png new file mode 100644 index 0000000..d878426 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/lock.imageset/lock.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/photon.imageset/photon.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/photon.imageset/photon.png new file mode 100644 index 0000000..18027b5 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/photon.imageset/photon.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/spacer.imageset/spacer.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spacer.imageset/spacer.png new file mode 100644 index 0000000..a059f2d Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spacer.imageset/spacer.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/spark-logo-head.imageset/spark-logo-head.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spark-logo-head.imageset/spark-logo-head.png new file mode 100644 index 0000000..81f09c9 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spark-logo-head.imageset/spark-logo-head.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/spark-logo.imageset/spark-logo.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spark-logo.imageset/spark-logo.png new file mode 100644 index 0000000..ef34aee Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spark-logo.imageset/spark-logo.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/spinner.imageset/spinner.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spinner.imageset/spinner.png new file mode 100644 index 0000000..908fc0a Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spinner.imageset/spinner.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/spinner_big.imageset/spinner_big.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spinner_big.imageset/spinner_big.png new file mode 100644 index 0000000..f8b819f Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/spinner_big.imageset/spinner_big.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/success.imageset/success.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/success.imageset/success.png new file mode 100644 index 0000000..56df1d0 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/success.imageset/success.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/warning.imageset/warning.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/warning.imageset/warning.png new file mode 100644 index 0000000..cf53cdd Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/warning.imageset/warning.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi1.imageset/wifi1.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi1.imageset/wifi1.png new file mode 100644 index 0000000..e334d8c Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi1.imageset/wifi1.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi2.imageset/wifi2.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi2.imageset/wifi2.png new file mode 100644 index 0000000..a690ec7 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi2.imageset/wifi2.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi3.imageset/wifi3.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi3.imageset/wifi3.png new file mode 100644 index 0000000..29e2d01 Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/wifi3.imageset/wifi3.png differ diff --git a/Strike/Pods/SparkSetup/Resources/setup.xcassets/x.imageset/x.png b/Strike/Pods/SparkSetup/Resources/setup.xcassets/x.imageset/x.png new file mode 100644 index 0000000..95f963c Binary files /dev/null and b/Strike/Pods/SparkSetup/Resources/setup.xcassets/x.imageset/x.png differ diff --git a/Strike/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m b/Strike/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m new file mode 100644 index 0000000..6a29cf8 --- /dev/null +++ b/Strike/Pods/Target Support Files/AFNetworking/AFNetworking-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_AFNetworking : NSObject +@end +@implementation PodsDummy_AFNetworking +@end diff --git a/Strike/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch b/Strike/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch new file mode 100644 index 0000000..1e116a3 --- /dev/null +++ b/Strike/Pods/Target Support Files/AFNetworking/AFNetworking-prefix.pch @@ -0,0 +1,11 @@ +#ifdef __OBJC__ +#import +#endif + +#ifndef TARGET_OS_IOS + #define TARGET_OS_IOS TARGET_OS_IPHONE +#endif + +#ifndef TARGET_OS_WATCH + #define TARGET_OS_WATCH 0 +#endif diff --git a/Strike/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig b/Strike/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig new file mode 100644 index 0000000..115679d --- /dev/null +++ b/Strike/Pods/Target Support Files/AFNetworking/AFNetworking.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/AFNetworking" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/Keys" "${PODS_ROOT}/Headers/Public/Spark-SDK" "${PODS_ROOT}/Headers/Public/SparkSetup" +OTHER_LDFLAGS = -framework "CoreGraphics" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/Strike/Pods/Target Support Files/Keys/Keys-dummy.m b/Strike/Pods/Target Support Files/Keys/Keys-dummy.m new file mode 100644 index 0000000..e335a60 --- /dev/null +++ b/Strike/Pods/Target Support Files/Keys/Keys-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Keys : NSObject +@end +@implementation PodsDummy_Keys +@end diff --git a/Strike/Pods/Target Support Files/Keys/Keys-prefix.pch b/Strike/Pods/Target Support Files/Keys/Keys-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/Strike/Pods/Target Support Files/Keys/Keys-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/Strike/Pods/Target Support Files/Keys/Keys.xcconfig b/Strike/Pods/Target Support Files/Keys/Keys.xcconfig new file mode 100644 index 0000000..12f4aaa --- /dev/null +++ b/Strike/Pods/Target Support Files/Keys/Keys.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Keys" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/Keys" "${PODS_ROOT}/Headers/Public/Spark-SDK" "${PODS_ROOT}/Headers/Public/SparkSetup" +OTHER_LDFLAGS = -framework "Foundation" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/Strike/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown b/Strike/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown new file mode 100644 index 0000000..66cb645 --- /dev/null +++ b/Strike/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown @@ -0,0 +1,388 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## AFNetworking + +Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +## Keys + +MIT LICENSE Found in the repo + +## Spark-SDK + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +## SparkSetup + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS +Generated by CocoaPods - http://cocoapods.org diff --git a/Strike/Pods/Target Support Files/Pods/Pods-acknowledgements.plist b/Strike/Pods/Target Support Files/Pods/Pods-acknowledgements.plist new file mode 100644 index 0000000..ea886bf --- /dev/null +++ b/Strike/Pods/Target Support Files/Pods/Pods-acknowledgements.plist @@ -0,0 +1,430 @@ + + + + + PreferenceSpecifiers + + + FooterText + This application makes use of the following third party libraries: + Title + Acknowledgements + Type + PSGroupSpecifier + + + FooterText + Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + Title + AFNetworking + Type + PSGroupSpecifier + + + FooterText + MIT LICENSE Found in the repo + Title + Keys + Type + PSGroupSpecifier + + + FooterText + Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + Title + Spark-SDK + Type + PSGroupSpecifier + + + FooterText + Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + Title + SparkSetup + Type + PSGroupSpecifier + + + FooterText + Generated by CocoaPods - http://cocoapods.org + Title + + Type + PSGroupSpecifier + + + StringsTable + Acknowledgements + Title + Acknowledgements + + diff --git a/Strike/Pods/Target Support Files/Pods/Pods-dummy.m b/Strike/Pods/Target Support Files/Pods/Pods-dummy.m new file mode 100644 index 0000000..ade64bd --- /dev/null +++ b/Strike/Pods/Target Support Files/Pods/Pods-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods : NSObject +@end +@implementation PodsDummy_Pods +@end diff --git a/Strike/Pods/Target Support Files/Pods/Pods-frameworks.sh b/Strike/Pods/Target Support Files/Pods/Pods-frameworks.sh new file mode 100755 index 0000000..6f76344 --- /dev/null +++ b/Strike/Pods/Target Support Files/Pods/Pods-frameworks.sh @@ -0,0 +1,84 @@ +#!/bin/sh +set -e + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # use filter instead of exclude so missing patterns dont' throw errors + echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identitiy + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\"" + /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current file + archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" + stripped="" + for arch in $archs; do + if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi +} + diff --git a/Strike/Pods/Target Support Files/Pods/Pods-resources.sh b/Strike/Pods/Target Support Files/Pods/Pods-resources.sh new file mode 100755 index 0000000..53e401a --- /dev/null +++ b/Strike/Pods/Target Support Files/Pods/Pods-resources.sh @@ -0,0 +1,101 @@ +#!/bin/sh +set -e + +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + +RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt +> "$RESOURCES_TO_COPY" + +XCASSET_FILES=() + +realpath() { + DIRECTORY="$(cd "${1%/*}" && pwd)" + FILENAME="${1##*/}" + echo "$DIRECTORY/$FILENAME" +} + +install_resource() +{ + case $1 in + *.storyboard) + 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}" + 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}" + ;; + *.xib) + 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}" + 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}" + ;; + *.framework) + echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + ;; + *.xcdatamodel) + echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\"" + xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom" + ;; + *.xcdatamodeld) + echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\"" + xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd" + ;; + *.xcmappingmodel) + echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\"" + xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm" + ;; + *.xcassets) + ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1") + XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") + ;; + /*) + echo "$1" + echo "$1" >> "$RESOURCES_TO_COPY" + ;; + *) + echo "${PODS_ROOT}/$1" + echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY" + ;; + esac +} +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_resource "${BUILT_PRODUCTS_DIR}/SparkSetup.bundle" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_resource "${BUILT_PRODUCTS_DIR}/SparkSetup.bundle" +fi + +mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then + mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" + rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" +fi +rm -f "$RESOURCES_TO_COPY" + +if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] +then + case "${TARGETED_DEVICE_FAMILY}" in + 1,2) + TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" + ;; + 1) + TARGET_DEVICE_ARGS="--target-device iphone" + ;; + 2) + TARGET_DEVICE_ARGS="--target-device ipad" + ;; + *) + TARGET_DEVICE_ARGS="--target-device mac" + ;; + esac + + # Find all other xcassets (this unfortunately includes those of path pods and other targets). + OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) + while read line; do + if [[ $line != "`realpath $PODS_ROOT`*" ]]; then + XCASSET_FILES+=("$line") + fi + done <<<"$OTHER_XCASSETS" + + printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun 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}" +fi diff --git a/Strike/Pods/Target Support Files/Pods/Pods.debug.xcconfig b/Strike/Pods/Target Support Files/Pods/Pods.debug.xcconfig new file mode 100644 index 0000000..8dba4a6 --- /dev/null +++ b/Strike/Pods/Target Support Files/Pods/Pods.debug.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/Keys" "${PODS_ROOT}/Headers/Public/Spark-SDK" "${PODS_ROOT}/Headers/Public/SparkSetup" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/Keys" -isystem "${PODS_ROOT}/Headers/Public/Spark-SDK" -isystem "${PODS_ROOT}/Headers/Public/SparkSetup" +OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"Keys" -l"Spark-SDK" -l"SparkSetup" -framework "CoreGraphics" -framework "Foundation" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/Strike/Pods/Target Support Files/Pods/Pods.release.xcconfig b/Strike/Pods/Target Support Files/Pods/Pods.release.xcconfig new file mode 100644 index 0000000..8dba4a6 --- /dev/null +++ b/Strike/Pods/Target Support Files/Pods/Pods.release.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/Keys" "${PODS_ROOT}/Headers/Public/Spark-SDK" "${PODS_ROOT}/Headers/Public/SparkSetup" +OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/AFNetworking" -isystem "${PODS_ROOT}/Headers/Public/Keys" -isystem "${PODS_ROOT}/Headers/Public/Spark-SDK" -isystem "${PODS_ROOT}/Headers/Public/SparkSetup" +OTHER_LDFLAGS = $(inherited) -ObjC -l"AFNetworking" -l"Keys" -l"Spark-SDK" -l"SparkSetup" -framework "CoreGraphics" -framework "Foundation" -framework "MobileCoreServices" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" +PODS_ROOT = ${SRCROOT}/Pods \ No newline at end of file diff --git a/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK-dummy.m b/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK-dummy.m new file mode 100644 index 0000000..783b458 --- /dev/null +++ b/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Spark_SDK : NSObject +@end +@implementation PodsDummy_Spark_SDK +@end diff --git a/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK-prefix.pch b/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK.xcconfig b/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK.xcconfig new file mode 100644 index 0000000..da8e3b2 --- /dev/null +++ b/Strike/Pods/Target Support Files/Spark-SDK/Spark-SDK.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Spark-SDK" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/Keys" "${PODS_ROOT}/Headers/Public/Spark-SDK" "${PODS_ROOT}/Headers/Public/SparkSetup" +OTHER_LDFLAGS = -framework "Security" -framework "SystemConfiguration" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/Strike/Pods/Target Support Files/SparkSetup/SparkSetup-dummy.m b/Strike/Pods/Target Support Files/SparkSetup/SparkSetup-dummy.m new file mode 100644 index 0000000..2d6710b --- /dev/null +++ b/Strike/Pods/Target Support Files/SparkSetup/SparkSetup-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_SparkSetup : NSObject +@end +@implementation PodsDummy_SparkSetup +@end diff --git a/Strike/Pods/Target Support Files/SparkSetup/SparkSetup-prefix.pch b/Strike/Pods/Target Support Files/SparkSetup/SparkSetup-prefix.pch new file mode 100644 index 0000000..aa992a4 --- /dev/null +++ b/Strike/Pods/Target Support Files/SparkSetup/SparkSetup-prefix.pch @@ -0,0 +1,4 @@ +#ifdef __OBJC__ +#import +#endif + diff --git a/Strike/Pods/Target Support Files/SparkSetup/SparkSetup.xcconfig b/Strike/Pods/Target Support Files/SparkSetup/SparkSetup.xcconfig new file mode 100644 index 0000000..a98463f --- /dev/null +++ b/Strike/Pods/Target Support Files/SparkSetup/SparkSetup.xcconfig @@ -0,0 +1,5 @@ +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/SparkSetup" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/AFNetworking" "${PODS_ROOT}/Headers/Public/Keys" "${PODS_ROOT}/Headers/Public/Spark-SDK" "${PODS_ROOT}/Headers/Public/SparkSetup" +OTHER_LDFLAGS = -framework "Security" -framework "SystemConfiguration" -framework "UIKit" +PODS_ROOT = ${SRCROOT} +SKIP_INSTALL = YES \ No newline at end of file diff --git a/Strike/Strike.xcodeproj/project.pbxproj b/Strike/Strike.xcodeproj/project.pbxproj new file mode 100644 index 0000000..8450c27 --- /dev/null +++ b/Strike/Strike.xcodeproj/project.pbxproj @@ -0,0 +1,519 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 273FF9E2C0B07905D6A1DFDF /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE4E177048F0D1723A9FEE9E /* libPods.a */; }; + D45112631C710F0B00088B72 /* WelcomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D45112621C710F0B00088B72 /* WelcomeViewController.m */; }; + D475E4601C70F88500C3914D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D475E45F1C70F88500C3914D /* main.m */; }; + D475E4631C70F88500C3914D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D475E4621C70F88500C3914D /* AppDelegate.m */; }; + D475E4661C70F88500C3914D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D475E4651C70F88500C3914D /* ViewController.m */; }; + D475E4691C70F88500C3914D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D475E4671C70F88500C3914D /* Main.storyboard */; }; + D475E46C1C70F88500C3914D /* Strike.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = D475E46A1C70F88500C3914D /* Strike.xcdatamodeld */; }; + D475E46E1C70F88500C3914D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D475E46D1C70F88500C3914D /* Assets.xcassets */; }; + D475E4711C70F88500C3914D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D475E46F1C70F88500C3914D /* LaunchScreen.storyboard */; }; + D475E47C1C70F88500C3914D /* StrikeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D475E47B1C70F88500C3914D /* StrikeTests.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + D475E4781C70F88500C3914D /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D475E4531C70F88400C3914D /* Project object */; + proxyType = 1; + remoteGlobalIDString = D475E45A1C70F88400C3914D; + remoteInfo = Strike; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + AEC534D43DBE5EACE75A4C86 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + D427EC3F4560C3335138F0FD /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + D45112611C710F0B00088B72 /* WelcomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WelcomeViewController.h; sourceTree = ""; }; + D45112621C710F0B00088B72 /* WelcomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WelcomeViewController.m; sourceTree = ""; }; + D475E45B1C70F88500C3914D /* Strike.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Strike.app; sourceTree = BUILT_PRODUCTS_DIR; }; + D475E45F1C70F88500C3914D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + D475E4611C70F88500C3914D /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + D475E4621C70F88500C3914D /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + D475E4641C70F88500C3914D /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + D475E4651C70F88500C3914D /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + D475E4681C70F88500C3914D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + D475E46B1C70F88500C3914D /* Strike.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Strike.xcdatamodel; sourceTree = ""; }; + D475E46D1C70F88500C3914D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + D475E4701C70F88500C3914D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + D475E4721C70F88500C3914D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D475E4771C70F88500C3914D /* StrikeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StrikeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + D475E47B1C70F88500C3914D /* StrikeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StrikeTests.m; sourceTree = ""; }; + D475E47D1C70F88500C3914D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + EE4E177048F0D1723A9FEE9E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D475E4581C70F88400C3914D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 273FF9E2C0B07905D6A1DFDF /* libPods.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D475E4741C70F88500C3914D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 39BDF5C5655D5C79709027A8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + EE4E177048F0D1723A9FEE9E /* libPods.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + AC1CB90F102EBCD705AB0C8E /* Pods */ = { + isa = PBXGroup; + children = ( + AEC534D43DBE5EACE75A4C86 /* Pods.debug.xcconfig */, + D427EC3F4560C3335138F0FD /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + D475E4521C70F88400C3914D = { + isa = PBXGroup; + children = ( + D475E45D1C70F88500C3914D /* Strike */, + D475E47A1C70F88500C3914D /* StrikeTests */, + D475E45C1C70F88500C3914D /* Products */, + AC1CB90F102EBCD705AB0C8E /* Pods */, + 39BDF5C5655D5C79709027A8 /* Frameworks */, + ); + sourceTree = ""; + }; + D475E45C1C70F88500C3914D /* Products */ = { + isa = PBXGroup; + children = ( + D475E45B1C70F88500C3914D /* Strike.app */, + D475E4771C70F88500C3914D /* StrikeTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + D475E45D1C70F88500C3914D /* Strike */ = { + isa = PBXGroup; + children = ( + D475E4611C70F88500C3914D /* AppDelegate.h */, + D475E4621C70F88500C3914D /* AppDelegate.m */, + D475E4641C70F88500C3914D /* ViewController.h */, + D475E4651C70F88500C3914D /* ViewController.m */, + D45112611C710F0B00088B72 /* WelcomeViewController.h */, + D45112621C710F0B00088B72 /* WelcomeViewController.m */, + D475E4671C70F88500C3914D /* Main.storyboard */, + D475E46D1C70F88500C3914D /* Assets.xcassets */, + D475E46F1C70F88500C3914D /* LaunchScreen.storyboard */, + D475E4721C70F88500C3914D /* Info.plist */, + D475E46A1C70F88500C3914D /* Strike.xcdatamodeld */, + D475E45E1C70F88500C3914D /* Supporting Files */, + ); + path = Strike; + sourceTree = ""; + }; + D475E45E1C70F88500C3914D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + D475E45F1C70F88500C3914D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + D475E47A1C70F88500C3914D /* StrikeTests */ = { + isa = PBXGroup; + children = ( + D475E47B1C70F88500C3914D /* StrikeTests.m */, + D475E47D1C70F88500C3914D /* Info.plist */, + ); + path = StrikeTests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + D475E45A1C70F88400C3914D /* Strike */ = { + isa = PBXNativeTarget; + buildConfigurationList = D475E4801C70F88500C3914D /* Build configuration list for PBXNativeTarget "Strike" */; + buildPhases = ( + 83507129A00C530A5662C716 /* Check Pods Manifest.lock */, + D475E4571C70F88400C3914D /* Sources */, + D475E4581C70F88400C3914D /* Frameworks */, + D475E4591C70F88400C3914D /* Resources */, + 8378F6FE211D14BD086CF301 /* Embed Pods Frameworks */, + 79BEB225401ACA5097564064 /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Strike; + productName = Strike; + productReference = D475E45B1C70F88500C3914D /* Strike.app */; + productType = "com.apple.product-type.application"; + }; + D475E4761C70F88500C3914D /* StrikeTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = D475E4831C70F88500C3914D /* Build configuration list for PBXNativeTarget "StrikeTests" */; + buildPhases = ( + D475E4731C70F88500C3914D /* Sources */, + D475E4741C70F88500C3914D /* Frameworks */, + D475E4751C70F88500C3914D /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + D475E4791C70F88500C3914D /* PBXTargetDependency */, + ); + name = StrikeTests; + productName = StrikeTests; + productReference = D475E4771C70F88500C3914D /* StrikeTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D475E4531C70F88400C3914D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0720; + ORGANIZATIONNAME = "Jason Wang"; + TargetAttributes = { + D475E45A1C70F88400C3914D = { + CreatedOnToolsVersion = 7.2.1; + }; + D475E4761C70F88500C3914D = { + CreatedOnToolsVersion = 7.2.1; + TestTargetID = D475E45A1C70F88400C3914D; + }; + }; + }; + buildConfigurationList = D475E4561C70F88400C3914D /* Build configuration list for PBXProject "Strike" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = D475E4521C70F88400C3914D; + productRefGroup = D475E45C1C70F88500C3914D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D475E45A1C70F88400C3914D /* Strike */, + D475E4761C70F88500C3914D /* StrikeTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + D475E4591C70F88400C3914D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D475E4711C70F88500C3914D /* LaunchScreen.storyboard in Resources */, + D475E46E1C70F88500C3914D /* Assets.xcassets in Resources */, + D475E4691C70F88500C3914D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D475E4751C70F88500C3914D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 79BEB225401ACA5097564064 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 83507129A00C530A5662C716 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 8378F6FE211D14BD086CF301 /* Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + D475E4571C70F88400C3914D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D45112631C710F0B00088B72 /* WelcomeViewController.m in Sources */, + D475E4661C70F88500C3914D /* ViewController.m in Sources */, + D475E46C1C70F88500C3914D /* Strike.xcdatamodeld in Sources */, + D475E4631C70F88500C3914D /* AppDelegate.m in Sources */, + D475E4601C70F88500C3914D /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D475E4731C70F88500C3914D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D475E47C1C70F88500C3914D /* StrikeTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + D475E4791C70F88500C3914D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = D475E45A1C70F88400C3914D /* Strike */; + targetProxy = D475E4781C70F88500C3914D /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + D475E4671C70F88500C3914D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + D475E4681C70F88500C3914D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + D475E46F1C70F88500C3914D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + D475E4701C70F88500C3914D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + D475E47E1C70F88500C3914D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + D475E47F1C70F88500C3914D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + D475E4811C70F88500C3914D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AEC534D43DBE5EACE75A4C86 /* Pods.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Strike/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.jasonwang.Strike; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + D475E4821C70F88500C3914D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D427EC3F4560C3335138F0FD /* Pods.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Strike/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.jasonwang.Strike; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + D475E4841C70F88500C3914D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = StrikeTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.jasonwang.StrikeTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Strike.app/Strike"; + }; + name = Debug; + }; + D475E4851C70F88500C3914D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + INFOPLIST_FILE = StrikeTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.jasonwang.StrikeTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Strike.app/Strike"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + D475E4561C70F88400C3914D /* Build configuration list for PBXProject "Strike" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D475E47E1C70F88500C3914D /* Debug */, + D475E47F1C70F88500C3914D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D475E4801C70F88500C3914D /* Build configuration list for PBXNativeTarget "Strike" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D475E4811C70F88500C3914D /* Debug */, + D475E4821C70F88500C3914D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D475E4831C70F88500C3914D /* Build configuration list for PBXNativeTarget "StrikeTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D475E4841C70F88500C3914D /* Debug */, + D475E4851C70F88500C3914D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCVersionGroup section */ + D475E46A1C70F88500C3914D /* Strike.xcdatamodeld */ = { + isa = XCVersionGroup; + children = ( + D475E46B1C70F88500C3914D /* Strike.xcdatamodel */, + ); + currentVersion = D475E46B1C70F88500C3914D /* Strike.xcdatamodel */; + path = Strike.xcdatamodeld; + sourceTree = ""; + versionGroupType = wrapper.xcdatamodel; + }; +/* End XCVersionGroup section */ + }; + rootObject = D475E4531C70F88400C3914D /* Project object */; +} diff --git a/Strike/Strike.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Strike/Strike.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..aa66d9d --- /dev/null +++ b/Strike/Strike.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Strike/Strike.xcworkspace/contents.xcworkspacedata b/Strike/Strike.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..0405fc7 --- /dev/null +++ b/Strike/Strike.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Strike/Strike/.DS_Store b/Strike/Strike/.DS_Store new file mode 100644 index 0000000..7d09959 Binary files /dev/null and b/Strike/Strike/.DS_Store differ diff --git a/Strike/Strike/AppDelegate.h b/Strike/Strike/AppDelegate.h new file mode 100644 index 0000000..5beb489 --- /dev/null +++ b/Strike/Strike/AppDelegate.h @@ -0,0 +1,25 @@ +// +// AppDelegate.h +// Strike +// +// Created by Jason Wang on 2/14/16. +// Copyright © 2016 Jason Wang. All rights reserved. +// + +#import +#import + +@interface AppDelegate : UIResponder + +@property (strong, nonatomic) UIWindow *window; + +@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; +@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; +@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator; + +- (void)saveContext; +- (NSURL *)applicationDocumentsDirectory; + + +@end + diff --git a/Strike/Strike/AppDelegate.m b/Strike/Strike/AppDelegate.m new file mode 100644 index 0000000..6af1052 --- /dev/null +++ b/Strike/Strike/AppDelegate.m @@ -0,0 +1,140 @@ +// +// AppDelegate.m +// Strike +// +// Created by Jason Wang on 2/14/16. +// Copyright © 2016 Jason Wang. All rights reserved. +// + +#import "AppDelegate.h" +#import +#import "Strike1Keys.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + Strike1Keys *keys = [[Strike1Keys alloc]init]; + if (![SparkCloud sharedInstance].loggedInUsername) { + [[SparkCloud sharedInstance] loginWithUser:keys.username password:keys.password completion:^(NSError *error) { + if (!error) { + NSLog(@"Login Success with %@", [SparkCloud sharedInstance].loggedInUsername); + } + }]; + } else { + NSLog(@"User already Logged as %@", [SparkCloud sharedInstance].loggedInUsername); + } + + + return YES; +} + +- (void)applicationWillResignActive:(UIApplication *)application { + // 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. + // 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. +} + +- (void)applicationDidEnterBackground:(UIApplication *)application { + // 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. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. +} + +- (void)applicationWillEnterForeground:(UIApplication *)application { + // 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. +} + +- (void)applicationDidBecomeActive:(UIApplication *)application { + // 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. +} + +- (void)applicationWillTerminate:(UIApplication *)application { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + // Saves changes in the application's managed object context before the application terminates. + [self saveContext]; +} + +#pragma mark - Core Data stack + +@synthesize managedObjectContext = _managedObjectContext; +@synthesize managedObjectModel = _managedObjectModel; +@synthesize persistentStoreCoordinator = _persistentStoreCoordinator; + +- (NSURL *)applicationDocumentsDirectory { + // The directory the application uses to store the Core Data store file. This code uses a directory named "com.jasonwang.Strike" in the application's documents directory. + return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; +} + +- (NSManagedObjectModel *)managedObjectModel { + // The managed object model for the application. It is a fatal error for the application not to be able to find and load its model. + if (_managedObjectModel != nil) { + return _managedObjectModel; + } + NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Strike" withExtension:@"momd"]; + _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; + return _managedObjectModel; +} + +- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { + // The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. + if (_persistentStoreCoordinator != nil) { + return _persistentStoreCoordinator; + } + + // Create the coordinator and store + + _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; + NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Strike.sqlite"]; + NSError *error = nil; + NSString *failureReason = @"There was an error creating or loading the application's saved data."; + if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { + // Report any error we got. + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + dict[NSLocalizedDescriptionKey] = @"Failed to initialize the application's saved data"; + dict[NSLocalizedFailureReasonErrorKey] = failureReason; + dict[NSUnderlyingErrorKey] = error; + error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict]; + // Replace this with code to handle the error appropriately. + // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + NSLog(@"Unresolved error %@, %@", error, [error userInfo]); + abort(); + } + + return _persistentStoreCoordinator; +} + + +- (NSManagedObjectContext *)managedObjectContext { + // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) + if (_managedObjectContext != nil) { + return _managedObjectContext; + } + + NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; + if (!coordinator) { + return nil; + } + _managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; + [_managedObjectContext setPersistentStoreCoordinator:coordinator]; + return _managedObjectContext; +} + +#pragma mark - Core Data Saving support + +- (void)saveContext { + NSManagedObjectContext *managedObjectContext = self.managedObjectContext; + if (managedObjectContext != nil) { + NSError *error = nil; + if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { + // Replace this implementation with code to handle the error appropriately. + // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. + NSLog(@"Unresolved error %@, %@", error, [error userInfo]); + abort(); + } + } +} + +@end diff --git a/Strike/Strike/Assets.xcassets/AppIcon.appiconset/Contents.json b/Strike/Strike/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/Strike/Strike/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Strike/Strike/Base.lproj/LaunchScreen.storyboard b/Strike/Strike/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..2e721e1 --- /dev/null +++ b/Strike/Strike/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Strike/Strike/Base.lproj/Main.storyboard b/Strike/Strike/Base.lproj/Main.storyboard new file mode 100644 index 0000000..6e8cf14 --- /dev/null +++ b/Strike/Strike/Base.lproj/Main.storyboard @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Strike/Strike/Info.plist b/Strike/Strike/Info.plist new file mode 100644 index 0000000..6905cc6 --- /dev/null +++ b/Strike/Strike/Info.plist @@ -0,0 +1,40 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Strike/Strike/Strike.xcdatamodeld/.xccurrentversion b/Strike/Strike/Strike.xcdatamodeld/.xccurrentversion new file mode 100644 index 0000000..1226ac3 --- /dev/null +++ b/Strike/Strike/Strike.xcdatamodeld/.xccurrentversion @@ -0,0 +1,8 @@ + + + + + _XCCurrentVersionName + Strike.xcdatamodel + + diff --git a/Strike/Strike/Strike.xcdatamodeld/Strike.xcdatamodel/contents b/Strike/Strike/Strike.xcdatamodeld/Strike.xcdatamodel/contents new file mode 100644 index 0000000..193f33c --- /dev/null +++ b/Strike/Strike/Strike.xcdatamodeld/Strike.xcdatamodel/contents @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Strike/Strike/ViewController.h b/Strike/Strike/ViewController.h new file mode 100644 index 0000000..1f6cda2 --- /dev/null +++ b/Strike/Strike/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// Strike +// +// Created by Jason Wang on 2/14/16. +// Copyright © 2016 Jason Wang. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/Strike/Strike/ViewController.m b/Strike/Strike/ViewController.m new file mode 100644 index 0000000..d1b03eb --- /dev/null +++ b/Strike/Strike/ViewController.m @@ -0,0 +1,63 @@ +// +// ViewController.m +// Strike +// +// Created by Jason Wang on 2/14/16. +// Copyright © 2016 Jason Wang. All rights reserved. +// + +#import "ViewController.h" + +#import +#import + +@interface ViewController () +@property (weak, nonatomic) IBOutlet UITextField *emailTextField; +@property (weak, nonatomic) IBOutlet UITextField *passwordTextField; + +@property (nonatomic) __block SparkDevice *myPhoton; + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; +} + +- (IBAction)SigninButtonTapped:(UIButton *)sender { + // log out any previous account that's saved + [[SparkCloud sharedInstance] logout]; + + [[SparkCloud sharedInstance] loginWithUser:self.emailTextField.text password:self.passwordTextField.text completion:^(NSError *error) { + if (!error) { + [self presentWelcomeVC]; + } else { + NSLog(@"ViewController: Login error ==> %@", error.localizedDescription); + } + }]; +} + + + +- (void)presentWelcomeVC { + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + UIViewController *welcomeVC = [storyboard instantiateViewControllerWithIdentifier:@"WelcomeVC"]; + [self presentViewController:welcomeVC animated:YES completion:nil]; +} + +- (IBAction)savedUserInfoLoginButtonTapped:(UIButton *)sender { + if ([SparkCloud sharedInstance].accessToken) { + [self presentWelcomeVC]; + NSLog(@"call presentWelcomeVC method"); + } else { + NSLog(@"accessToken = %@", [SparkCloud sharedInstance].accessToken); + } +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/Strike/Strike/WelcomeViewController.h b/Strike/Strike/WelcomeViewController.h new file mode 100644 index 0000000..425a938 --- /dev/null +++ b/Strike/Strike/WelcomeViewController.h @@ -0,0 +1,13 @@ +// +// WelcomeViewController.h +// Strike +// +// Created by Jason Wang on 2/14/16. +// Copyright © 2016 Jason Wang. All rights reserved. +// + +#import + +@interface WelcomeViewController : UIViewController + +@end diff --git a/Strike/Strike/WelcomeViewController.m b/Strike/Strike/WelcomeViewController.m new file mode 100644 index 0000000..bdddf4e --- /dev/null +++ b/Strike/Strike/WelcomeViewController.m @@ -0,0 +1,124 @@ +// +// WelcomeViewController.m +// Strike +// +// Created by Jason Wang on 2/14/16. +// Copyright © 2016 Jason Wang. All rights reserved. +// + +#import "WelcomeViewController.h" +#import "Strike1Keys.h" +#import +#import + +@interface WelcomeViewController () +@property (weak, nonatomic) IBOutlet UILabel *welcomeLabel; +@property (nonatomic) __block SparkDevice *myPhoton; +@property (nonatomic) Strike1Keys *keys; + +@end + +@implementation WelcomeViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self grabDevice]; + self.keys = [[Strike1Keys alloc]init]; + NSLog(@"WelcomeVC: ViewDidLoad accessToken = %@",[SparkCloud sharedInstance].accessToken); +} + +-(void)grabDevice { + [[SparkCloud sharedInstance] getDevices:^(NSArray *sparkDevices, NSError *error) { + NSLog(@"Device Array == %@", sparkDevices); + for (SparkDevice *device in sparkDevices) { + if ([device.name isEqualToString:@"Strike"]) { + self.myPhoton = device; + self.welcomeLabel.text = device.name; + } + } + }]; +} + +- (IBAction)redLEDSwitchTapped:(UISwitch *)sender { + NSLog(@"led1 touched"); + if (sender.on) { + [self.myPhoton callFunction:@"led1" withArguments:@[@"ON"] completion:^(NSNumber *resultCode, NSError *error) { + + if (!error) { + NSLog(@"LED D0 should be ON"); + NSLog(@"result code for ON == %@",resultCode); + } else { + NSLog(@"erro message == %@",error.userInfo); + } + }]; + } else { + [self.myPhoton callFunction:@"led1" withArguments:@[@"OFF"] completion:^(NSNumber *resultCode, NSError *error) { + if (!error) { + NSLog(@"LED D0 should be OFF"); + NSLog(@"result code for OFF == %@",resultCode); + } + }]; + } +} + +- (IBAction)d7LEDSwitchedTapped:(UISwitch *)sender { + NSLog(@"led2 touched"); + if (sender.on) { + [self.myPhoton callFunction:@"led2" withArguments:@[@"ON"] completion:^(NSNumber *resultCode, NSError *error) { + + if (!error) { + NSLog(@"LED D7 should be ON"); + NSLog(@"result code for ON == %@",resultCode); + } else { + NSLog(@"erro message == %@",error.userInfo); + } + }]; + } else { + [self.myPhoton callFunction:@"led2" withArguments:@[@"OFF"] completion:^(NSNumber *resultCode, NSError *error) { + if (!error) { + NSLog(@"LED D7 should be OFF"); + NSLog(@"result code for OFF == %@",resultCode); + } + }]; + } +} + + +- (IBAction)logoutButtonTapped:(UIButton *)sender { + + [[SparkCloud sharedInstance] logout]; + + [[SparkCloud sharedInstance] loginWithUser:self.keys.username password:self.keys.password completion:^(NSError *error) { + NSLog(@"Logback to keysAccount"); + }]; + [self dismissViewControllerAnimated:YES completion:nil]; +} + +- (IBAction)fetchDeviceNameButtonTapped:(UIButton *)sender { + [self grabDevice]; +} +- (IBAction)setupDeviceButtonTapped:(UIButton *)sender { + [[SparkCloud sharedInstance] logout]; + + SparkSetupMainController *setupController = [[SparkSetupMainController alloc]init]; + [self presentViewController:setupController animated:YES completion:nil]; + + [self grabDevice]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/Strike/Strike/main.m b/Strike/Strike/main.m new file mode 100644 index 0000000..949d1c2 --- /dev/null +++ b/Strike/Strike/main.m @@ -0,0 +1,16 @@ +// +// main.m +// Strike +// +// Created by Jason Wang on 2/14/16. +// Copyright © 2016 Jason Wang. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/Strike/StrikeTests/Info.plist b/Strike/StrikeTests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/Strike/StrikeTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Strike/StrikeTests/StrikeTests.m b/Strike/StrikeTests/StrikeTests.m new file mode 100644 index 0000000..94069e5 --- /dev/null +++ b/Strike/StrikeTests/StrikeTests.m @@ -0,0 +1,39 @@ +// +// StrikeTests.m +// StrikeTests +// +// Created by Jason Wang on 2/14/16. +// Copyright © 2016 Jason Wang. All rights reserved. +// + +#import + +@interface StrikeTests : XCTestCase + +@end + +@implementation StrikeTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end