From 5ccdc9e7ef68e389a71d0e783326445486dda46e Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Thu, 16 Feb 2023 14:52:32 +0100 Subject: [PATCH] feat: update to ooni/probe-cli@v3.17 See https://github.com/ooni/probe/issues/2273 --- Podfile | 4 +- Podfile.lock | 10 +- ooniprobe.xcodeproj/project.pbxproj | 12 -- ooniprobe/Engine/OONICheckInConfig.m | 2 +- ooniprobe/Engine/OONISession.h | 8 -- ooniprobe/Engine/OONIURLListConfig.h | 18 --- ooniprobe/Engine/OONIURLListConfig.m | 15 --- ooniprobe/Engine/OONIURLListResult.h | 12 -- ooniprobe/Engine/OONIURLListResult.m | 16 --- ooniprobe/Engine/PESession.m | 9 -- ooniprobe/Model/Database/Measurement.h | 1 - ooniprobe/Model/Database/Measurement.m | 11 -- ooniprobe/Test/Test/WebConnectivity.m | 3 +- ooniprobe/Utility/OONIApi.h | 19 ++- ooniprobe/Utility/OONIApi.m | 110 +----------------- ooniprobe/Utility/TestUtility.m | 7 +- .../Details/TestDetailsViewController.m | 10 +- .../Footer/UploadFooterViewController.m | 8 -- 18 files changed, 23 insertions(+), 252 deletions(-) delete mode 100644 ooniprobe/Engine/OONIURLListConfig.h delete mode 100644 ooniprobe/Engine/OONIURLListConfig.m delete mode 100644 ooniprobe/Engine/OONIURLListResult.h delete mode 100644 ooniprobe/Engine/OONIURLListResult.m diff --git a/Podfile b/Podfile index 85b112efd..c417041eb 100644 --- a/Podfile +++ b/Podfile @@ -3,7 +3,7 @@ use_frameworks! inhibit_all_warnings! target 'ooniprobe' do - pod "oonimkall", :podspec => "https://github.com/ooni/probe-cli/releases/download/v3.16.7/oonimkall.podspec" + pod "oonimkall", :podspec => "https://github.com/ooni/probe-cli/releases/download/v3.17.0-beta.1/oonimkall.podspec" pod 'Toast', '~> 4.0.0' pod 'MBProgressHUD' pod 'DZNEmptyDataSet' @@ -19,7 +19,7 @@ target 'ooniprobe' do end target 'OONIProbeUnitTests' do - pod "oonimkall", :podspec => "https://github.com/ooni/probe-cli/releases/download/v3.16.7/oonimkall.podspec" + pod "oonimkall", :podspec => "https://github.com/ooni/probe-cli/releases/download/v3.17.0-beta.1/oonimkall.podspec" pod 'SharkORM', :git => 'https://github.com/sharksync/sharkorm', :tag => 'v2.3.67' pod 'OCMapper', '2.0' end diff --git a/Podfile.lock b/Podfile.lock index 5df960494..5db59c2c5 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -9,7 +9,7 @@ PODS: - MBProgressHUD (1.2.0) - MKDropdownMenu (1.4) - OCMapper (2.0) - - oonimkall (2022.12.08-093516) + - oonimkall (2023.02.16-061929) - RHMarkdownLabel (0.0.1): - TTTAttributedLabel - XNGMarkdownParser @@ -30,7 +30,7 @@ DEPENDENCIES: - MBProgressHUD - MKDropdownMenu - OCMapper (= 2.0) - - oonimkall (from `https://github.com/ooni/probe-cli/releases/download/v3.16.7/oonimkall.podspec`) + - oonimkall (from `https://github.com/ooni/probe-cli/releases/download/v3.17.0-beta.1/oonimkall.podspec`) - RHMarkdownLabel - Sentry (from `https://github.com/getsentry/sentry-cocoa.git`, tag `6.1.4`) - SharkORM (from `https://github.com/sharksync/sharkorm`, tag `v2.3.67`) @@ -53,7 +53,7 @@ SPEC REPOS: EXTERNAL SOURCES: oonimkall: - :podspec: https://github.com/ooni/probe-cli/releases/download/v3.16.7/oonimkall.podspec + :podspec: https://github.com/ooni/probe-cli/releases/download/v3.17.0-beta.1/oonimkall.podspec Sentry: :git: https://github.com/getsentry/sentry-cocoa.git :tag: 6.1.4 @@ -78,7 +78,7 @@ SPEC CHECKSUMS: MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406 MKDropdownMenu: 269df4a41d21a1db684ce8bc709befe419fc5bae OCMapper: 9b4d542543794c42adc01f1493d894f53e193cb0 - oonimkall: e8fc753f58a2fc6ddf0d96c7833638ac688feeb7 + oonimkall: a3647b51b9a41ce2626e8f1789ec33c9f2cfe933 RHMarkdownLabel: 81d6772768e621be57302b7fd5212ad4f78fb0bd Sentry: 9d055e2de30a77685e86b219acf02e59b82091fc SharkORM: 252e4411923110ac1b524a993ee2b3fa13eed7c4 @@ -86,6 +86,6 @@ SPEC CHECKSUMS: TTTAttributedLabel: 8cffe8e127e4e82ff3af1e5386d4cd0ad000b656 XNGMarkdownParser: aed98c14f0c0eb20064184ddf9bac26c482722b2 -PODFILE CHECKSUM: 522efea553d0ccb9bd0df809fa3ecee99e5dc0c0 +PODFILE CHECKSUM: 8d090f92bbeceeddfb618975bb3ad870846b8080 COCOAPODS: 1.11.3 diff --git a/ooniprobe.xcodeproj/project.pbxproj b/ooniprobe.xcodeproj/project.pbxproj index 63d97573e..daab61e4e 100644 --- a/ooniprobe.xcodeproj/project.pbxproj +++ b/ooniprobe.xcodeproj/project.pbxproj @@ -137,8 +137,6 @@ EDC5A07225EFEA4400F86720 /* OONICheckInResults.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC5A07125EFEA4400F86720 /* OONICheckInResults.m */; }; EDC5A07B25EFEBAD00F86720 /* OONICheckInConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC5A07A25EFEBAD00F86720 /* OONICheckInConfig.m */; }; EDC5A0C525F00C4B00F86720 /* OONIURLInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC5A0C425F00C4B00F86720 /* OONIURLInfo.m */; }; - EDC5A0CE25F00C9C00F86720 /* OONIURLListConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC5A0CD25F00C9C00F86720 /* OONIURLListConfig.m */; }; - EDC5A0D425F00CB600F86720 /* OONIURLListResult.m in Sources */ = {isa = PBXBuildFile; fileRef = EDC5A0D325F00CB600F86720 /* OONIURLListResult.m */; }; EDCB9D911CB3F9ED00BBA3BC /* DefaultPreferences.plist in Resources */ = {isa = PBXBuildFile; fileRef = EDCB9D901CB3F9ED00BBA3BC /* DefaultPreferences.plist */; }; EDCD73D22180F014003B56D9 /* Header3ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EDCD73D12180F014003B56D9 /* Header3ViewController.m */; }; EDD771FD268116B300184C06 /* RunningTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EDD771FC268116B300184C06 /* RunningTest.m */; }; @@ -472,10 +470,6 @@ EDC5A07A25EFEBAD00F86720 /* OONICheckInConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = OONICheckInConfig.m; path = Engine/OONICheckInConfig.m; sourceTree = ""; }; EDC5A0C325F00C4B00F86720 /* OONIURLInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OONIURLInfo.h; path = Engine/OONIURLInfo.h; sourceTree = ""; }; EDC5A0C425F00C4B00F86720 /* OONIURLInfo.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = OONIURLInfo.m; path = Engine/OONIURLInfo.m; sourceTree = ""; }; - EDC5A0CC25F00C9C00F86720 /* OONIURLListConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OONIURLListConfig.h; path = Engine/OONIURLListConfig.h; sourceTree = ""; }; - EDC5A0CD25F00C9C00F86720 /* OONIURLListConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = OONIURLListConfig.m; path = Engine/OONIURLListConfig.m; sourceTree = ""; }; - EDC5A0D225F00CB600F86720 /* OONIURLListResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OONIURLListResult.h; path = Engine/OONIURLListResult.h; sourceTree = ""; }; - EDC5A0D325F00CB600F86720 /* OONIURLListResult.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = OONIURLListResult.m; path = Engine/OONIURLListResult.m; sourceTree = ""; }; EDCB9D901CB3F9ED00BBA3BC /* DefaultPreferences.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = DefaultPreferences.plist; sourceTree = ""; }; EDCD73D02180F014003B56D9 /* Header3ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Header3ViewController.h; sourceTree = ""; }; EDCD73D12180F014003B56D9 /* Header3ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Header3ViewController.m; sourceTree = ""; }; @@ -1142,10 +1136,6 @@ ED9CCF02252B356D004F8420 /* PESession.m */, EDC5A0C325F00C4B00F86720 /* OONIURLInfo.h */, EDC5A0C425F00C4B00F86720 /* OONIURLInfo.m */, - EDC5A0CC25F00C9C00F86720 /* OONIURLListConfig.h */, - EDC5A0CD25F00C9C00F86720 /* OONIURLListConfig.m */, - EDC5A0D225F00CB600F86720 /* OONIURLListResult.h */, - EDC5A0D325F00CB600F86720 /* OONIURLListResult.m */, ); name = Engine; sourceTree = ""; @@ -1573,7 +1563,6 @@ EDB252AA20FA4D4F00B4EDE4 /* Tampering.m in Sources */, ED0D35BE1DD72825005C863F /* RunButton.m in Sources */, ED49509D1F951F1E00344E42 /* MessageUtility.m in Sources */, - EDC5A0D425F00CB600F86720 /* OONIURLListResult.m in Sources */, ED62AB9D1ED5B70500778249 /* Reachability.m in Sources */, ED2E067821D487D600E9B9EE /* InstantMessagingSuite.m in Sources */, ED9CCEEE252B3190004F8420 /* OONIGeolocateResults.m in Sources */, @@ -1605,7 +1594,6 @@ ED2E067B21D487DD00E9B9EE /* MiddleBoxesSuite.m in Sources */, EDE47C41241FC6BC0013A1CB /* NetworkSession.m in Sources */, EDF4ED26248A9A64001A5406 /* Advanced.m in Sources */, - EDC5A0CE25F00C9C00F86720 /* OONIURLListConfig.m in Sources */, EDA17AFB208A30E100D46D0F /* MiddleBoxesDetailsViewController.m in Sources */, ED1CC7FF20158D630041089A /* ConfigureButton.m in Sources */, ED3932C41E3114740064CD11 /* AboutViewController.m in Sources */, diff --git a/ooniprobe/Engine/OONICheckInConfig.m b/ooniprobe/Engine/OONICheckInConfig.m index 8245a747c..6de7630f0 100644 --- a/ooniprobe/Engine/OONICheckInConfig.m +++ b/ooniprobe/Engine/OONICheckInConfig.m @@ -15,7 +15,7 @@ - (id) initWithSoftwareName:(NSString*)softwareName self.softwareVersion = softwareVersion; self.webConnectivity = [[OonimkallCheckInConfigWebConnectivity alloc] init]; for (NSString* category in categories) { - [self.webConnectivity add:category]; + [self.webConnectivity addCategory:category]; } } return self; diff --git a/ooniprobe/Engine/OONISession.h b/ooniprobe/Engine/OONISession.h index e0d1c9083..72af7e425 100644 --- a/ooniprobe/Engine/OONISession.h +++ b/ooniprobe/Engine/OONISession.h @@ -4,8 +4,6 @@ #import "OONISubmitResults.h" #import "OONICheckInResults.h" #import "OONICheckInConfig.h" -#import "OONIURLListConfig.h" -#import "OONIURLListResult.h" /** * OONISession contains shared state for running experiments and/or other @@ -17,9 +15,6 @@ /** geolocate returns the probe geolocation. */ - (OONIGeolocateResults*) geolocate:(OONIContext*) ctx error:(NSError **)error; -/** maybeUpdateResources updates resources if needed. */ -- (void) maybeUpdateResources:(OONIContext*) ctx error:(NSError **)error; - /** newContext creates a new OONIContext instance. */ - (OONIContext*) newContext; @@ -39,7 +34,4 @@ */ - (OONICheckInResults*) checkIn:(OONIContext*) ctx config:(OONICheckInConfig*) config error:(NSError **)error; -/** fetchURLList fetches the list of URLs to test */ -- (OONIURLListResult*) fetchURLList:(OONIContext*) ctx config:(OONIURLListConfig*) config error:(NSError **)error; - @end diff --git a/ooniprobe/Engine/OONIURLListConfig.h b/ooniprobe/Engine/OONIURLListConfig.h deleted file mode 100644 index 1c510c524..000000000 --- a/ooniprobe/Engine/OONIURLListConfig.h +++ /dev/null @@ -1,18 +0,0 @@ -#import -#import - -/** URLListConfig contains configuration for fetching the URL list. */ -@interface OONIURLListConfig : NSObject - -/** Categories to query for (empty means all) */ -@property (nonatomic, strong) NSArray *categories; - -/** CountryCode is the optional country code */ -@property (nonatomic, strong) NSString *countryCode; - -/** Max number of URLs (<= 0 means no limit) */ -@property (nonatomic) long limit; - -- (OonimkallURLListConfig*) toOonimkallURLListConfig; - -@end diff --git a/ooniprobe/Engine/OONIURLListConfig.m b/ooniprobe/Engine/OONIURLListConfig.m deleted file mode 100644 index 32bf46d2f..000000000 --- a/ooniprobe/Engine/OONIURLListConfig.m +++ /dev/null @@ -1,15 +0,0 @@ -#import "OONIURLListConfig.h" - -@implementation OONIURLListConfig - -- (OonimkallURLListConfig*) toOonimkallURLListConfig { - OonimkallURLListConfig* c = [[OonimkallURLListConfig alloc] init]; - c.limit = self.limit; - c.countryCode = self.countryCode; - for (NSString* category in self.categories) { - [c addCategory:category]; - } - return c; -} - -@end diff --git a/ooniprobe/Engine/OONIURLListResult.h b/ooniprobe/Engine/OONIURLListResult.h deleted file mode 100644 index 2f07527b0..000000000 --- a/ooniprobe/Engine/OONIURLListResult.h +++ /dev/null @@ -1,12 +0,0 @@ -#import -#import -#import "OONIURLInfo.h" - -/** URLListResult contains the URLs returned from the FetchURL API. */ -@interface OONIURLListResult : NSObject - -@property (nonatomic, strong) NSMutableArray *urls; - -- (id) initWithResults:(OonimkallURLListResult*)r; - -@end diff --git a/ooniprobe/Engine/OONIURLListResult.m b/ooniprobe/Engine/OONIURLListResult.m deleted file mode 100644 index 501443487..000000000 --- a/ooniprobe/Engine/OONIURLListResult.m +++ /dev/null @@ -1,16 +0,0 @@ -#import "OONIURLListResult.h" - -@implementation OONIURLListResult - -- (id) initWithResults:(OonimkallURLListResult*)r { - self = [super init]; - if (self) { - self.urls = [NSMutableArray new]; - for (int i = 0; i < r.size; i++) { - [self.urls addObject:[[OONIURLInfo alloc] initWithURLInfo:[r at:i]]]; - } - } - return self; -} - -@end diff --git a/ooniprobe/Engine/PESession.m b/ooniprobe/Engine/PESession.m index c702581f6..9afe2061b 100644 --- a/ooniprobe/Engine/PESession.m +++ b/ooniprobe/Engine/PESession.m @@ -15,10 +15,6 @@ - (OONIGeolocateResults*) geolocate:(OONIContext*) ctx error:(NSError **)error{ return (r != nil) ? ([[OONIGeolocateResults alloc] initWithResults:r]) : nil; } -- (void) maybeUpdateResources:(OONIContext*) ctx error:(NSError **)error{ - [self.session maybeUpdateResources:ctx.ctx error:error]; -} - - (OONIContext*) newContext{ return [self newContextWithTimeout:-1]; } @@ -39,9 +35,4 @@ - (OONICheckInResults*) checkIn:(OONIContext*) ctx config:(OONICheckInConfig*) c return (r != nil) ? ([[OONICheckInResults alloc] initWithResults:r]) : nil; } -- (OONIURLListResult*) fetchURLList:(OONIContext*) ctx config:(OONIURLListConfig*) config error:(NSError **)error { - OonimkallURLListResult *r = [self.session fetchURLList:ctx.ctx config:[config toOonimkallURLListConfig] error:(NSError * _Nullable __autoreleasing * _Nullable)error]; - return (r != nil) ? ([[OONIURLListResult alloc] initWithResults:r]) : nil; -} - @end diff --git a/ooniprobe/Model/Database/Measurement.h b/ooniprobe/Model/Database/Measurement.h index dd6766ace..26bd33006 100644 --- a/ooniprobe/Model/Database/Measurement.h +++ b/ooniprobe/Model/Database/Measurement.h @@ -43,5 +43,4 @@ -(void)setReRun; -(void)deleteObject; -(void)getExplorerUrl:(void (^)(NSDictionary*))successcb onError:(void (^)(NSError*))errorcb; --(void)checkPublished:(void (^)(BOOL))successcb onError:(void (^)(NSError*))errorcb; @end diff --git a/ooniprobe/Model/Database/Measurement.m b/ooniprobe/Model/Database/Measurement.m index fb76ac2a3..1b443a028 100644 --- a/ooniprobe/Model/Database/Measurement.m +++ b/ooniprobe/Model/Database/Measurement.m @@ -99,11 +99,6 @@ -(NSString*)getLocalizedStartTime{ -(void)save{ [self commit]; - /* - NSLog(@"---- START LOGGING MEASUREMENT OBJECT----"); - NSLog(@"%@", self); - NSLog(@"---- END LOGGING MEASUREMENT OBJECT----"); - */ } -(void)setReRun{ @@ -126,10 +121,4 @@ -(void)getExplorerUrl:(void (^)(NSDictionary*))successcb onError:(void (^)(NSErr onError:errorcb]; } --(void)checkPublished:(void (^)(BOOL))successcb onError:(void (^)(NSError*))errorcb{ - [OONIApi checkReportId:self.report_id - onSuccess:successcb - onError:errorcb]; -} - @end diff --git a/ooniprobe/Test/Test/WebConnectivity.m b/ooniprobe/Test/Test/WebConnectivity.m index c3b2a1ea6..6e7e1698d 100644 --- a/ooniprobe/Test/Test/WebConnectivity.m +++ b/ooniprobe/Test/Test/WebConnectivity.m @@ -21,7 +21,8 @@ -(void) runTest { if (self.inputs == nil || [self.inputs count] == 0){ [super testStarted]; //Download urls and then alloc class - [OONIApi downloadUrls:^(NSArray *urls) { + // TODO(aanorbel): please double check how I adapted this code + [OONIApi checkIn:^(NSArray *urls) { [self setUrls:urls]; [self setDefaultMaxRuntime]; self.isPreparing = false; diff --git a/ooniprobe/Utility/OONIApi.h b/ooniprobe/Utility/OONIApi.h index 625931209..e163505a2 100644 --- a/ooniprobe/Utility/OONIApi.h +++ b/ooniprobe/Utility/OONIApi.h @@ -2,20 +2,15 @@ @interface OONIApi : NSObject -+ (void)downloadUrls:(void (^)(NSArray*))successcb onError:(void (^)(NSError*))errorcb; -+ (void)checkIn:(void (^)(NSArray*))successcb onError:(void (^)(NSError*))errorcb; ++(void)checkIn:(void (^)(NSArray*))successcb onError:(void (^)(NSError*))errorcb; + +(void)getExplorerUrl:(NSString*)report_id withUrl:(NSString*)measurement_url onSuccess:(void (^)(NSDictionary*))successcb onError:(void (^)(NSError*))errorcb; -+ (void)getExplorerUrl:(NSString*)baseURl - report_id:(NSString*)report_id - withUrl:(NSString*)measurement_url - onSuccess:(void (^)(NSDictionary*))successcb - onError:(void (^)(NSError*))errorcb; -+ (void)checkReportId:(NSString*)baseUrl - reportId:(NSString*)report_id - onSuccess:(void (^)(BOOL))successcb + ++(void)getExplorerUrl:(NSString*)baseURl + report_id:(NSString*)report_id + withUrl:(NSString*)measurement_url + onSuccess:(void (^)(NSDictionary*))successcb onError:(void (^)(NSError*))errorcb; -+(void)checkReportId:(NSString*)report_id - onSuccess:(void (^)(BOOL))successcb onError:(void (^)(NSError*))errorcb; @end diff --git a/ooniprobe/Utility/OONIApi.m b/ooniprobe/Utility/OONIApi.m index 959c47c9f..0fc7a9523 100644 --- a/ooniprobe/Utility/OONIApi.m +++ b/ooniprobe/Utility/OONIApi.m @@ -8,28 +8,6 @@ @implementation OONIApi -+ (void)downloadUrls:(void (^)(NSArray*))successcb onError:(void (^)(NSError*))errorcb { - NSError *error; - PESession* session = [[PESession alloc] initWithConfig: - [Engine getDefaultSessionConfigWithSoftwareName:SOFTWARE_NAME - softwareVersion:[VersionUtility get_software_version] - logger:[LoggerArray new]] - error:&error]; - if (error != nil) { - return; - } - [session maybeUpdateResources:[session newContext] error:&error]; - if (error != nil) { - return; - } - OONIContext *ooniContext = [session newContextWithTimeout:30]; - OONIURLListConfig *config = [OONIURLListConfig new]; - [config setCategories:[SettingsUtility getSitesCategoriesEnabled]]; - OONIURLListResult *result = [session fetchURLList:ooniContext config:config error:&error]; - [self downloadUrlsCallback:result error:error - onSuccess:successcb onError:errorcb]; -} - + (void)checkIn:(void (^)(NSArray*))successcb onError:(void (^)(NSError*))errorcb { //Download urls and then alloc class NSError *error; @@ -41,52 +19,17 @@ + (void)checkIn:(void (^)(NSArray*))successcb onError:(void (^)(NSError*))errorc if (error != nil) { return; } - // Updating resources with no timeout because we don't know for sure how much - // it will take to download them and choosing a timeout may prevent the operation - // to ever complete. (Ideally the user should be able to interrupt the process - // and there should be no timeout here.) - [session maybeUpdateResources:[session newContext] error:&error]; - if (error != nil) { - return; - } OONIContext *ooniContext = [session newContextWithTimeout:30]; OONICheckInConfig *config = [[OONICheckInConfig alloc] initWithSoftwareName:SOFTWARE_NAME softwareVersion:[VersionUtility get_software_version] categories:[SettingsUtility getSitesCategoriesEnabled]]; + // TODO(aanorbel): here we need to configure whether we're running + // using battery power and whether we're on WiFi. OONICheckInResults *result = [session checkIn:ooniContext config:config error:&error]; [self checkInCallback:result error:error onSuccess:successcb onError:errorcb]; } -+ (void)downloadUrlsCallback:(OONIURLListResult *)result - error:(NSError *)error - onSuccess:(void (^)(NSArray*))successcb - onError:(void (^)(NSError*))errorcb { - if (error != nil) { - errorcb(error); - return; - } - NSMutableArray *urls = [[NSMutableArray alloc] init]; - for (OONIURLInfo* current in result.urls){ - //List for database - Url *url = [Url - checkExistingUrl:current.url - categoryCode:current.category_code - countryCode:current.country_code]; - //List for mk - if (url != nil) - [urls addObject:url.url]; - } - if ([urls count] == 0){ - errorcb([NSError errorWithDomain:@"io.ooni.orchestrate" - code:ERR_NO_VALID_URLS - userInfo:@{NSLocalizedDescriptionKey:@"Modal.Error.NoValidUrls" - }]); - return; - } - successcb(urls); -} - + (void)checkInCallback:(OONICheckInResults *)result error:(NSError *)error onSuccess:(void (^)(NSArray*))successcb @@ -170,53 +113,4 @@ + (void)getExplorerUrlCallback:(NSData *)data successcb(dic); } -+ (void)checkReportId:(NSString*)baseUrl - reportId:(NSString*)report_id - onSuccess:(void (^)(BOOL))successcb - onError:(void (^)(NSError*))errorcb{ - NSURLComponents *components = [[NSURLComponents alloc] init]; - components.scheme = @"https"; - components.host = baseUrl; - components.path = @"/api/_/check_report_id"; - NSURLQueryItem *reportIdItem = [NSURLQueryItem - queryItemWithName:@"report_id" - value:report_id]; - components.queryItems = @[ reportIdItem ]; - NSURL *url = components.URL; - NSURLSessionDataTask *downloadTask = [[NetworkSession getSession] - dataTaskWithURL:url - completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { - [self checkReportIdCallback:data response:response error:error - onSuccess:successcb onError:errorcb]; - }]; - [downloadTask resume]; -} - -+ (void)checkReportId:(NSString*)report_id - onSuccess:(void (^)(BOOL))successcb - onError:(void (^)(NSError*))errorcb{ - [self checkReportId:OONI_API_BASE_URL - reportId:report_id - onSuccess:successcb - onError:errorcb]; -} - -+ (void)checkReportIdCallback:(NSData *)data - response:(NSURLResponse *)response - error:(NSError *)error - onSuccess:(void (^)(BOOL))successcb - onError:(void (^)(NSError*))errorcb { - if (error != nil) { - errorcb(error); - return; - } - NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; - if (error != nil) { - errorcb(error); - return; - } - BOOL found = [[dic objectForKey:@"found"] boolValue]; - successcb(found); -} - @end diff --git a/ooniprobe/Utility/TestUtility.m b/ooniprobe/Utility/TestUtility.m index 905488032..f9431b24d 100644 --- a/ooniprobe/Utility/TestUtility.m +++ b/ooniprobe/Utility/TestUtility.m @@ -149,12 +149,7 @@ +(void)deleteMeasurementWithReportId:(NSString*)report_id{ + (void)deleteUploadedJsons{ for (NSString *report_id in [Measurement getReportsUploaded]) { - [OONIApi checkReportId:report_id onSuccess:^(BOOL found){ - if (found) - [self deleteMeasurementWithReportId:report_id]; - } onError:^(NSError *error) { - /* NOTHING */ - }]; + [self deleteMeasurementWithReportId:report_id]; } [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:delete_json_key]; [[NSUserDefaults standardUserDefaults] synchronize]; diff --git a/ooniprobe/View/TestResults/Details/TestDetailsViewController.m b/ooniprobe/View/TestResults/Details/TestDetailsViewController.m index 694f6d457..f809ae7b0 100644 --- a/ooniprobe/View/TestResults/Details/TestDetailsViewController.m +++ b/ooniprobe/View/TestResults/Details/TestDetailsViewController.m @@ -25,13 +25,9 @@ - (void)viewDidLoad { [self reloadFooter]; isInExplorer = ![self.measurement hasReportFile]; if ([self.measurement hasReportFile]){ - [self.measurement checkPublished:^(BOOL found){ - isInExplorer = found; - if (found && self.measurement.report_id != NULL) - [TestUtility deleteMeasurementWithReportId:self.measurement.report_id]; - } onError:^(NSError *error) { - isInExplorer = FALSE; - }]; + isInExplorer = YES; + if (self.measurement.report_id != NULL) + [TestUtility deleteMeasurementWithReportId:self.measurement.report_id]; } [self addShareButton]; } diff --git a/ooniprobe/View/TestResults/Footer/UploadFooterViewController.m b/ooniprobe/View/TestResults/Footer/UploadFooterViewController.m index 566388fca..0a5884f5d 100644 --- a/ooniprobe/View/TestResults/Footer/UploadFooterViewController.m +++ b/ooniprobe/View/TestResults/Footer/UploadFooterViewController.m @@ -104,14 +104,6 @@ -(void)uploadMeasurements:(NSArray *)notUploaded{ if (error != nil) { return; } - // Updating resources with no timeout because we don't know for sure how much - // it will take to download them and choosing a timeout may prevent the operation - // to ever complete. (Ideally the user should be able to interrupt the process - // and there should be no timeout here.) - [session maybeUpdateResources:[session newContext] error:&error]; - if (error != nil) { - return; - } while (i < [notUploaded count]){ if (_canceled){ break;