From 736e2fe4e482942f9c1c8ad7c66799996a0d1fb3 Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 17 Feb 2015 10:54:09 +0100 Subject: [PATCH] SYIOS-40: Any HTTP request can fail due to rate-limiting on the server, and need to be retried. SDK: Introduced MXHTTPOperation. It replaces NSOperation objects returned by all MXRestClient methods. MXHTTPOperation will help to manage request retries. --- matrixConsole/matrixConsole/API/MediaLoader.h | 4 +++- matrixConsole/matrixConsole/API/MediaLoader.m | 3 +-- matrixConsole/matrixConsole/Model/RecentRoom.m | 2 +- .../ViewController/AuthenticationViewController.m | 2 +- .../matrixConsole/ViewController/RoomViewController.m | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/matrixConsole/matrixConsole/API/MediaLoader.h b/matrixConsole/matrixConsole/API/MediaLoader.h index 06d754c8e..753109f77 100644 --- a/matrixConsole/matrixConsole/API/MediaLoader.h +++ b/matrixConsole/matrixConsole/API/MediaLoader.h @@ -16,6 +16,8 @@ #import +#import "MatrixSDKHandler.h" + // Provide the download progress // object: URL // userInfo: kMediaLoaderProgressRateKey : progress value nested in a NSNumber (range 0->1) @@ -66,7 +68,7 @@ typedef void (^blockMediaLoader_onError)(NSError *error); NSString *uploadId; CGFloat initialRange; CGFloat range; - NSOperation* operation; + MXHTTPOperation* operation; } @property (strong, readonly) NSMutableDictionary* statisticsDict; diff --git a/matrixConsole/matrixConsole/API/MediaLoader.m b/matrixConsole/matrixConsole/API/MediaLoader.m index a82d71759..c40f07b1d 100644 --- a/matrixConsole/matrixConsole/API/MediaLoader.m +++ b/matrixConsole/matrixConsole/API/MediaLoader.m @@ -15,7 +15,6 @@ */ #import "MediaManager.h" -#import "MatrixSDKHandler.h" #import "MXCTools.h" NSString *const kMediaDownloadProgressNotification = @"kMediaDownloadProgressNotification"; @@ -45,7 +44,7 @@ NSString *const kMediaLoaderProgressDownloadRateKey = @"kMediaLoaderProgressDown downloadData = nil; } else { - if (operation.executing) { + if (operation.operation.executing) { NSLog(@"media upload has been cancelled (%@)", mediaURL); [operation cancel]; operation = nil; diff --git a/matrixConsole/matrixConsole/Model/RecentRoom.m b/matrixConsole/matrixConsole/Model/RecentRoom.m index 67c7f0ff1..f9bcf87c6 100644 --- a/matrixConsole/matrixConsole/Model/RecentRoom.m +++ b/matrixConsole/matrixConsole/Model/RecentRoom.m @@ -22,7 +22,7 @@ NSString *const kRecentRoomUpdatedByBackPagination = @"kRecentRoomUpdatedByBackP @interface RecentRoom() { MXRoom *mxRoom; id backPaginationListener; - NSOperation *backPaginationOperation; + MXHTTPOperation *backPaginationOperation; // Keep reference on last event (used in case of redaction) MXEvent *lastEvent; diff --git a/matrixConsole/matrixConsole/ViewController/AuthenticationViewController.m b/matrixConsole/matrixConsole/ViewController/AuthenticationViewController.m index c4f2088ea..83de7d694 100644 --- a/matrixConsole/matrixConsole/ViewController/AuthenticationViewController.m +++ b/matrixConsole/matrixConsole/ViewController/AuthenticationViewController.m @@ -22,7 +22,7 @@ @interface AuthenticationViewController () { // Current request in progress - NSOperation *mxAuthFlowRequest; + MXHTTPOperation *mxAuthFlowRequest; // Array of flows supported by the home server and implemented by the app (for the current auth type) NSMutableArray *supportedFlows; diff --git a/matrixConsole/matrixConsole/ViewController/RoomViewController.m b/matrixConsole/matrixConsole/ViewController/RoomViewController.m index a614f591e..3d7fab038 100644 --- a/matrixConsole/matrixConsole/ViewController/RoomViewController.m +++ b/matrixConsole/matrixConsole/ViewController/RoomViewController.m @@ -80,7 +80,7 @@ NSString *const kCmdResetUserPowerLevel = @"/deop"; BOOL isFirstPagination; NSUInteger backPaginationAddedMsgNb; NSUInteger backPaginationHandledEventsNb; - NSOperation *backPaginationOperation; + MXHTTPOperation *backPaginationOperation; CGFloat backPaginationSavedFirstMsgHeight; // Members list