Skip to content

Commit

Permalink
Progress API cleanup
Browse files Browse the repository at this point in the history
Use slightly stricter build config, fix 64bit issues
  • Loading branch information
pokeb committed Apr 14, 2010
1 parent 7ff7761 commit ffe54e9
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 145 deletions.
4 changes: 2 additions & 2 deletions Classes/ASIFormDataRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ - (void)buildURLEncodedPostBody

NSEnumerator *e = [[self postData] keyEnumerator];
NSString *key;
int i=0;
int count = [[self postData] count]-1;
NSUInteger i=0;
NSUInteger count = [[self postData] count]-1;
while (key = [e nextObject]) {
NSString *data = [NSString stringWithFormat:@"%@=%@%@", [self encodeURL:key], [self encodeURL:[[self postData] objectForKey:key]],(i<count ? @"&" : @"")];
[self appendPostString:data];
Expand Down
23 changes: 19 additions & 4 deletions Classes/ASIHTTPRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
// Called on the delegate (if implemented) when the request starts. Default is requestStarted:
SEL didStartSelector;

// Called on the delegate (if implemented) when the request receives response headers. Default is requestDidReceiveResponseHeaders:
SEL didReceiveResponseHeadersSelector;

// Called on the delegate (if implemented) when the request completes successfully. Default is requestFinished:
SEL didFinishSelector;

Expand Down Expand Up @@ -446,25 +449,37 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;

#pragma mark upload/download progress

// Called approximately every 0.25 seconds to update the progress delegates
- (void)updateProgressIndicators;

// Updates upload progress (notifies the queue and/or uploadProgressDelegate of this request)
- (void)updateUploadProgress;

// Updates download progress (notifies the queue and/or uploadProgressDelegate of this request)
- (void)updateDownloadProgress;

// Called when authorisation is needed, as we only find out we don't have permission to something when the upload is complete
- (void)removeUploadProgressSoFar;

// Called when we get a content-length header and shouldResetProgressIndicators is true
- (void)incrementDownloadSizeBy:(long long)length;

// Called when a request starts and shouldResetProgressIndicators is true
// Also called (with a negative length) to remove the size of the underlying buffer used for uploading
- (void)incrementUploadSizeBy:(long long)length;

// Helper method for interacting with progress indicators to abstract the details of different APIS (NSProgressIndicator and UIProgressView)
+ (void)updateProgressIndicator:(id)indicator withProgress:(unsigned long long)progress ofTotal:(unsigned long long)total;


- (void)resetDownloadProgressWithNewLength:(unsigned long long)length;
- (void)resetUploadProgressWithNewLength:(unsigned long long)value;

#pragma mark handling request complete / failure

// Called when a request starts, lets the delegate know via didStartSelector
- (void)requestStarted;

// Called when a request receives response headers, lets the delegate know via didReceiveResponseHeadersSelector
- (void)requestReceivedResponseHeaders;

// Called when a request completes successfully, lets the delegate know via didFinishSelector
- (void)requestFinished;

Expand Down Expand Up @@ -678,6 +693,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
@property (retain) NSString *downloadDestinationPath;
@property (retain) NSString *temporaryFileDownloadPath;
@property (assign) SEL didStartSelector;
@property (assign) SEL didReceiveResponseHeadersSelector;
@property (assign) SEL didFinishSelector;
@property (assign) SEL didFailSelector;
@property (retain,readonly) NSString *authenticationRealm;
Expand Down Expand Up @@ -728,7 +744,6 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
@property (assign, readonly) int proxyAuthenticationRetryCount;
@property (assign) BOOL haveBuiltRequestHeaders;
@property (assign, nonatomic) BOOL haveBuiltPostBody;

@property (assign, readonly) BOOL isSynchronous;
@property (assign, readonly) BOOL inProgress;
@property (assign) int numberOfTimesToRetryOnTimeout;
Expand Down
Loading

0 comments on commit ffe54e9

Please sign in to comment.