Ignite Tools
Shared/Airship/External/UA_asi-http-request/UA_ASINetworkQueue.h
00001 //
00002 //  UA_ASINetworkQueue.h
00003 //  Part of UA_ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
00004 //
00005 //  Created by Ben Copsey on 07/11/2008.
00006 //  Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
00007 //
00008 
00009 #import <Foundation/Foundation.h>
00010 #import "UA_ASIHTTPRequestDelegate.h"
00011 #import "UA_ASIProgressDelegate.h"
00012 
00013 @interface UA_ASINetworkQueue : NSOperationQueue <UA_ASIProgressDelegate, UA_ASIHTTPRequestDelegate, NSCopying> {
00014         
00015         // Delegate will get didFail + didFinish messages (if set)
00016         id delegate;
00017 
00018         // Will be called when a request starts with the request as the argument
00019         SEL requestDidStartSelector;
00020         
00021         // Will be called when a request receives response headers
00022         // Should take the form request:didRecieveResponseHeaders:, where the first argument is the request, and the second the headers dictionary
00023         SEL requestDidReceiveResponseHeadersSelector;
00024         
00025         // Will be called when a request is about to redirect
00026         // Should take the form request:willRedirectToURL:, where the first argument is the request, and the second the new url
00027         SEL requestWillRedirectSelector;
00028 
00029         // Will be called when a request completes with the request as the argument
00030         SEL requestDidFinishSelector;
00031         
00032         // Will be called when a request fails with the request as the argument
00033         SEL requestDidFailSelector;
00034         
00035         // Will be called when the queue finishes with the queue as the argument
00036         SEL queueDidFinishSelector;
00037         
00038         // Upload progress indicator, probably an NSProgressIndicator or UIProgressView
00039         id uploadProgressDelegate;
00040         
00041         // Total amount uploaded so far for all requests in this queue
00042         unsigned long long bytesUploadedSoFar;
00043         
00044         // Total amount to be uploaded for all requests in this queue - requests add to this figure as they work out how much data they have to transmit
00045         unsigned long long totalBytesToUpload;
00046 
00047         // Download progress indicator, probably an NSProgressIndicator or UIProgressView
00048         id downloadProgressDelegate;
00049         
00050         // Total amount downloaded so far for all requests in this queue
00051         unsigned long long bytesDownloadedSoFar;
00052         
00053         // Total amount to be downloaded for all requests in this queue - requests add to this figure as they receive Content-Length headers
00054         unsigned long long totalBytesToDownload;
00055         
00056         // When YES, the queue will cancel all requests when a request fails. Default is YES
00057         BOOL shouldCancelAllRequestsOnFailure;
00058         
00059         //Number of real requests (excludes HEAD requests created to manage showAccurateProgress)
00060         int requestsCount;
00061         
00062         // When NO, this request will only update the progress indicator when it completes
00063         // When YES, this request will update the progress indicator according to how much data it has received so far
00064         // When YES, the queue will first perform HEAD requests for all GET requests in the queue, so it can calculate the total download size before it starts
00065         // NO means better performance, because it skips this step for GET requests, and it won't waste time updating the progress indicator until a request completes 
00066         // Set to YES if the size of a requests in the queue varies greatly for much more accurate results
00067         // Default for requests in the queue is NO
00068         BOOL showAccurateProgress;
00069 
00070         // Storage container for additional queue information.
00071         NSDictionary *userInfo;
00072         
00073 }
00074 
00075 // Convenience constructor
00076 + (id)queue;
00077 
00078 // Call this to reset a queue - it will cancel all operations, clear delegates, and suspend operation
00079 - (void)reset;
00080 
00081 // Used internally to manage HEAD requests when showAccurateProgress is YES, do not use!
00082 - (void)addHEADOperation:(NSOperation *)operation;
00083 
00084 // All ASINetworkQueues are paused when created so that total size can be calculated before the queue starts
00085 // This method will start the queue
00086 - (void)go;
00087 
00088 @property (assign, nonatomic, setter=setUploadProgressDelegate:) id uploadProgressDelegate;
00089 @property (assign, nonatomic, setter=setDownloadProgressDelegate:) id downloadProgressDelegate;
00090 
00091 @property (assign) SEL requestDidStartSelector;
00092 @property (assign) SEL requestDidReceiveResponseHeadersSelector;
00093 @property (assign) SEL requestWillRedirectSelector;
00094 @property (assign) SEL requestDidFinishSelector;
00095 @property (assign) SEL requestDidFailSelector;
00096 @property (assign) SEL queueDidFinishSelector;
00097 @property (assign) BOOL shouldCancelAllRequestsOnFailure;
00098 @property (assign) id delegate;
00099 @property (assign) BOOL showAccurateProgress;
00100 @property (assign, readonly) int requestsCount;
00101 @property (retain) NSDictionary *userInfo;
00102 
00103 @property (assign) unsigned long long bytesUploadedSoFar;
00104 @property (assign) unsigned long long totalBytesToUpload;
00105 @property (assign) unsigned long long bytesDownloadedSoFar;
00106 @property (assign) unsigned long long totalBytesToDownload;
00107 
00108 @end
 All Classes Functions Variables Properties