Statistics
| Branch: | Revision:

root / asi-http-request-with-pithos / Classes / ASINetworkQueue.h @ be116d22

History | View | Annotate | Download (4.5 kB)

1
//
2
//  ASINetworkQueue.h
3
//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
4
//
5
//  Created by Ben Copsey on 07/11/2008.
6
//  Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
7
//
8

    
9
#import <Foundation/Foundation.h>
10
#import "ASIHTTPRequestDelegate.h"
11
#import "ASIProgressDelegate.h"
12

    
13
@interface ASINetworkQueue : NSOperationQueue <ASIProgressDelegate, ASIHTTPRequestDelegate, NSCopying> {
14
        
15
        // Delegate will get didFail + didFinish messages (if set)
16
        id delegate;
17

    
18
        // Will be called when a request starts with the request as the argument
19
        SEL requestDidStartSelector;
20
        
21
        // Will be called when a request receives response headers
22
        // Should take the form request:didRecieveResponseHeaders:, where the first argument is the request, and the second the headers dictionary
23
        SEL requestDidReceiveResponseHeadersSelector;
24
        
25
        // Will be called when a request is about to redirect
26
        // Should take the form request:willRedirectToURL:, where the first argument is the request, and the second the new url
27
        SEL requestWillRedirectSelector;
28

    
29
        // Will be called when a request completes with the request as the argument
30
        SEL requestDidFinishSelector;
31
        
32
        // Will be called when a request fails with the request as the argument
33
        SEL requestDidFailSelector;
34
        
35
        // Will be called when the queue finishes with the queue as the argument
36
        SEL queueDidFinishSelector;
37
        
38
        // Upload progress indicator, probably an NSProgressIndicator or UIProgressView
39
        id uploadProgressDelegate;
40
        
41
        // Total amount uploaded so far for all requests in this queue
42
        unsigned long long bytesUploadedSoFar;
43
        
44
        // 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
45
        unsigned long long totalBytesToUpload;
46

    
47
        // Download progress indicator, probably an NSProgressIndicator or UIProgressView
48
        id downloadProgressDelegate;
49
        
50
        // Total amount downloaded so far for all requests in this queue
51
        unsigned long long bytesDownloadedSoFar;
52
        
53
        // Total amount to be downloaded for all requests in this queue - requests add to this figure as they receive Content-Length headers
54
        unsigned long long totalBytesToDownload;
55
        
56
        // When YES, the queue will cancel all requests when a request fails. Default is YES
57
        BOOL shouldCancelAllRequestsOnFailure;
58
        
59
        //Number of real requests (excludes HEAD requests created to manage showAccurateProgress)
60
        int requestsCount;
61
        
62
        // When NO, this request will only update the progress indicator when it completes
63
        // When YES, this request will update the progress indicator according to how much data it has received so far
64
        // 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
65
        // 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 
66
        // Set to YES if the size of a requests in the queue varies greatly for much more accurate results
67
        // Default for requests in the queue is NO
68
        BOOL showAccurateProgress;
69

    
70
        // Storage container for additional queue information.
71
        NSDictionary *userInfo;
72
        
73
}
74

    
75
// Convenience constructor
76
+ (id)queue;
77

    
78
// Call this to reset a queue - it will cancel all operations, clear delegates, and suspend operation
79
- (void)reset;
80

    
81
// Used internally to manage HEAD requests when showAccurateProgress is YES, do not use!
82
- (void)addHEADOperation:(NSOperation *)operation;
83

    
84
// All ASINetworkQueues are paused when created so that total size can be calculated before the queue starts
85
// This method will start the queue
86
- (void)go;
87

    
88
@property (assign, nonatomic, setter=setUploadProgressDelegate:) id uploadProgressDelegate;
89
@property (assign, nonatomic, setter=setDownloadProgressDelegate:) id downloadProgressDelegate;
90

    
91
@property (assign) SEL requestDidStartSelector;
92
@property (assign) SEL requestDidReceiveResponseHeadersSelector;
93
@property (assign) SEL requestWillRedirectSelector;
94
@property (assign) SEL requestDidFinishSelector;
95
@property (assign) SEL requestDidFailSelector;
96
@property (assign) SEL queueDidFinishSelector;
97
@property (assign) BOOL shouldCancelAllRequestsOnFailure;
98
@property (assign) id delegate;
99
@property (assign) BOOL showAccurateProgress;
100
@property (assign, readonly) int requestsCount;
101
@property (retain) NSDictionary *userInfo;
102

    
103
@property (assign) unsigned long long bytesUploadedSoFar;
104
@property (assign) unsigned long long totalBytesToUpload;
105
@property (assign) unsigned long long bytesDownloadedSoFar;
106
@property (assign) unsigned long long totalBytesToDownload;
107

    
108
@end