mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
add networking helpers to BITAuthenticator
* NSOperation-based networking * helpers for URLRequest, operation, getPath:error:
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#import "BITAuthenticator.h"
|
||||
#import "BITHockeyBaseManagerPrivate.h"
|
||||
#import "BITAuthenticationViewController.h"
|
||||
#import "BITHTTPOperation.h" //needed for typedef
|
||||
|
||||
@interface BITAuthenticator ()<BITAuthenticationViewControllerDelegate>
|
||||
|
||||
@@ -46,4 +47,57 @@
|
||||
- (void) validationSucceeded;
|
||||
- (void) validationFailedWithError:(NSError *) validationError;
|
||||
|
||||
|
||||
#pragma mark - Networking helpers (TODO: move to base-class / networking component)
|
||||
@property (nonatomic, strong) NSOperationQueue *operationQueue;
|
||||
|
||||
/**
|
||||
* creates an NRURLRequest for the given method and path by using
|
||||
* the internally stored baseURL.
|
||||
*
|
||||
* @param method the HTTPMethod to check, must not be nil
|
||||
* @param path path to append to baseURL. can be nil in which case "/" is appended
|
||||
*
|
||||
* @return an NSMutableURLRequest for further configuration
|
||||
*/
|
||||
- (NSMutableURLRequest *) requestWithMethod:(NSString*) method
|
||||
path:(NSString *) path;
|
||||
/**
|
||||
* Creates an operation for the given NSURLRequest
|
||||
*
|
||||
* @param request the request that should be handled
|
||||
* @param completion completionBlock that is called once the operation finished
|
||||
*
|
||||
* @return operation, which can be queued via enqueueHTTPOperation:
|
||||
*/
|
||||
- (BITHTTPOperation*) operationWithURLRequest:(NSURLRequest*) request
|
||||
completion:(BITNetworkCompletionBlock) completion;
|
||||
|
||||
/**
|
||||
* Creates an operation for the given path, and enqueues it
|
||||
*
|
||||
* @param path the request path to check
|
||||
* @param completion completionBlock that is called once the operation finished
|
||||
*
|
||||
*/
|
||||
- (void) getPath:(NSString*) path
|
||||
completion:(BITNetworkCompletionBlock) completion;
|
||||
|
||||
/**
|
||||
* adds the given operation to the internal queue
|
||||
*
|
||||
* @param operation operation to add
|
||||
*/
|
||||
- (void) enqeueHTTPOperation:(BITHTTPOperation *) operation;
|
||||
|
||||
/**
|
||||
* cancels the specified operations
|
||||
*
|
||||
* @param path the path which operation should be cancelled. Can be nil to match all
|
||||
* @param method the method which operations to cancel. Can be nil to match all
|
||||
* @return number of operations cancelled
|
||||
*/
|
||||
- (NSUInteger) cancelOperationsWithPath:(NSString*) path
|
||||
method:(NSString*) method;
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user