diff --git a/Monal/Classes/MLCrashReporter.h b/Monal/Classes/MLCrashReporter.h index f756cc0b74..172fb80e92 100644 --- a/Monal/Classes/MLCrashReporter.h +++ b/Monal/Classes/MLCrashReporter.h @@ -12,7 +12,7 @@ @class UIViewController; @interface MLCrashReporter : NSObject -+(void) reportPendingCrashesWithViewController:(UIViewController*) viewController; ++(void) reportPendingCrashes; @end #endif /* MLCrashReporter_h */ diff --git a/Monal/Classes/MLCrashReporter.m b/Monal/Classes/MLCrashReporter.m index e2036c32c9..e6f888784f 100644 --- a/Monal/Classes/MLCrashReporter.m +++ b/Monal/Classes/MLCrashReporter.m @@ -13,30 +13,33 @@ #import #import #import -#import #import #import #import "MLConstants.h" #import "HelperTools.h" +#import "MonalAppDelegate.h" #import "MLCrashReporter.h" #define PART_SEPARATOR_FORMAT "\n\n-------- d049d576-9bf0-47dd-839f-dee6b07c1df9 -------- %@ -------- d049d576-9bf0-47dd-839f-dee6b07c1df9 --------\n\n" +@interface KSCrashReportFilterAlert: NSObject ++(instancetype) filter; +@end + @interface KSCrashReportFilterEmpty: NSObject -+(KSCrashReportFilterEmpty*) filter; ++(instancetype) filter; @end @interface KSCrashReportFilterAddAuxInfo : NSObject -+(KSCrashReportFilterAddAuxInfo*) filter; ++(instancetype) filter; @end @interface KSCrashReportFilterAddMLLogfile : NSObject -+(KSCrashReportFilterAddMLLogfile*) filter; ++(instancetype) filter; @end @interface MLCrashReporter() -@property (atomic, strong) UIViewController* viewController; @property (atomic, strong) NSArray* _Nullable kscrashReports; @property (atomic, strong) KSCrashReportFilterCompletion _Nullable kscrashCompletion; @end @@ -44,7 +47,7 @@ @interface MLCrashReporter() logfileFilter = [KSCrashReportFilterAddMLLogfile filter]; NSString* logfileName = @"Logfile (*.rawlog.gz)"; handler.sink = [KSCrashReportFilterPipeline filterWithFilters: - [KSCrashReportFilterAlert - filterWithTitle:NSLocalizedString(@"Crash Detected", @"Crash reporting") - message:NSLocalizedString(@"The app crashed last time it was launched. Send a crash report? This crash report will contain privacy related data. We will only use it to debug your crash and delete it afterwards!", @"Crash reporting") - yesAnswer:NSLocalizedString(@"Sure, send it!", @"Crash reporting") - noAnswer:NSLocalizedString(@"No, thanks", @"Crash reporting") - ], + [KSCrashReportFilterAlert filter], [KSCrashReportFilterCombine filterWithFiltersAndKeys: dummyFilter, dummyFilterName, //this dummy is needed to make the filter framework print the title of our aux data auxInfoFilter, auxInfoName, @@ -84,7 +82,7 @@ +(void) reportPendingCrashesWithViewController:(UIViewController*) viewControlle ], [KSCrashReportFilterStringToData filter], [KSCrashReportFilterGZipCompress filterWithCompressionLevel:-1], - [[self alloc] initWithViewController:viewController], //this is the last filter sending out all stuff via mail + [[self alloc] init], //this is the last filter sending out all stuff via mail nil ]; DDLogVerbose(@"Trying to send crash reports..."); @@ -96,13 +94,6 @@ +(void) reportPendingCrashesWithViewController:(UIViewController*) viewControlle }]; } --(id) initWithViewController:(UIViewController*) viewController -{ - self = [super init]; - self.viewController = viewController; - return self; -} - -(void) filterReports:(NSArray*) reports onCompletion:(KSCrashReportFilterCompletion) onCompletion { if(![MFMailComposeViewController canSendMail]) @@ -133,7 +124,7 @@ -(void) filterReports:(NSArray*) reports onCompletion:(KSCrashReportFilterComple style:UIAlertActionStyleDefault handler:nil]; [alertController addAction:okAction]; - [self.viewController presentViewController:alertController animated:YES completion:NULL]; + [[(MonalAppDelegate*)[[UIApplication sharedApplication] delegate] getTopViewController] presentViewController:alertController animated:YES completion:NULL]; kscrash_callCompletion(onCompletion, reports, NO, [NSError errorWithDomain:[[self class] description] @@ -164,14 +155,14 @@ -(void) filterReports:(NSArray*) reports onCompletion:(KSCrashReportFilterComple dispatch_async(dispatch_get_main_queue(), ^{ DDLogVerbose(@"Presenting MFMailComposeViewController..."); - [self.viewController presentViewController:mailController animated:YES completion:nil]; + [[(MonalAppDelegate*)[[UIApplication sharedApplication] delegate] getTopViewController] presentViewController:mailController animated:YES completion:nil]; }); } -(void) mailComposeController:(__unused MFMailComposeViewController*) mailController didFinishWithResult:(MFMailComposeResult) result error:(NSError*) error { dispatch_async(dispatch_get_main_queue(), ^{ - [self.viewController dismissViewControllerAnimated:YES completion:nil]; + [[(MonalAppDelegate*)[[UIApplication sharedApplication] delegate] getTopViewController] dismissViewControllerAnimated:YES completion:nil]; if(self.kscrashCompletion == nil) { @@ -217,9 +208,41 @@ -(void) mailComposeController:(__unused MFMailComposeViewController*) mailContro @end +@implementation KSCrashReportFilterAlert + ++(instancetype) filter +{ + return [[self alloc] init]; +} + +-(void) filterReports:(NSArray*) reports onCompletion:(KSCrashReportFilterCompletion) onCompletion +{ + NSString* title = NSLocalizedString(@"Crash Detected", @"Crash reporting"); + NSString* message = NSLocalizedString(@"The app crashed last time it was launched. Send a crash report? This crash report will contain privacy related data. We will only use it to debug your crash and delete it afterwards!", @"Crash reporting"); + NSString* yesAnswer = NSLocalizedString(@"Sure, send it!", @"Crash reporting"); + NSString* noAnswer = NSLocalizedString(@"No, thanks", @"Crash reporting"); + + DDLogVerbose(@"KSCrashReportFilterAlert started..."); + dispatch_async(dispatch_get_main_queue(), ^{ + UIAlertController* alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* yesAction = [UIAlertAction actionWithTitle:yesAnswer style:UIAlertActionStyleDefault handler:^(__unused UIAlertAction* _Nonnull action) { + kscrash_callCompletion(onCompletion, reports, YES, nil); + }]; + UIAlertAction* noAction = [UIAlertAction actionWithTitle:noAnswer style:UIAlertActionStyleCancel handler:^(__unused UIAlertAction* _Nonnull action) { + kscrash_callCompletion(onCompletion, reports, NO, nil); + }]; + [alertController addAction:yesAction]; + [alertController addAction:noAction]; + [[(MonalAppDelegate*)[[UIApplication sharedApplication] delegate] getTopViewController] presentViewController:alertController animated:YES completion:NULL]; + }); + DDLogVerbose(@"KSCrashReportFilterAlert finished..."); +} + +@end + @implementation KSCrashReportFilterEmpty -+(KSCrashReportFilterEmpty*) filter ++(instancetype) filter { return [[self alloc] init]; } @@ -238,7 +261,7 @@ -(void) filterReports:(NSArray*) reports onCompletion:(KSCrashReportFilterComple @implementation KSCrashReportFilterAddAuxInfo -+(KSCrashReportFilterAddAuxInfo*) filter ++(instancetype) filter { return [[self alloc] init]; } @@ -281,7 +304,7 @@ -(void) filterReports:(NSArray*) reports onCompletion:(KSCrashReportFilterComple @implementation KSCrashReportFilterAddMLLogfile -+(KSCrashReportFilterAddMLLogfile*) filter ++(instancetype) filter { return [[self alloc] init]; } diff --git a/Monal/Classes/MonalAppDelegate.m b/Monal/Classes/MonalAppDelegate.m index 4d5045f45f..c1214f9297 100644 --- a/Monal/Classes/MonalAppDelegate.m +++ b/Monal/Classes/MonalAppDelegate.m @@ -676,7 +676,7 @@ -(void) applicationDidBecomeActive:(UIApplication*) application } //report pending crashes - [MLCrashReporter reportPendingCrashesWithViewController:[self getTopViewController]]; + [MLCrashReporter reportPendingCrashes]; } -(void) setActiveChats:(UIViewController*) activeChats diff --git a/Monal/Podfile b/Monal/Podfile index c2b2840066..7c601fd65c 100644 --- a/Monal/Podfile +++ b/Monal/Podfile @@ -32,7 +32,7 @@ def monalxmpp pod 'ASN1Decoder' #pod 'GoogleWebRTC' pod 'WebRTC-lib' - pod 'KSCrash', git: 'https://github.com/monal-im/KSCrash', branch: 'master' + pod 'KSCrash', subspecs:['Recording', 'Reporting/Filters/Sets', 'Reporting/Filters/Tools', 'Reporting/Tools', 'Core'] signalDeps end diff --git a/Monal/Podfile.lock b/Monal/Podfile.lock index 19f6bd1aa7..eb5b567618 100644 --- a/Monal/Podfile.lock +++ b/Monal/Podfile.lock @@ -2,34 +2,11 @@ PODS: - ASN1Decoder (1.9.0) - DZNEmptyDataSet (1.8.1) - FLAnimatedImage (1.0.17) - - KSCrash (1.16.2): - - KSCrash/Installations (= 1.16.2) - - KSCrash/Installations (1.16.2): - - KSCrash/Recording - - KSCrash/Reporting + - KSCrash/Core (1.16.2): + - KSCrash/Reporting/Filters/Basic - KSCrash/Recording (1.16.2): - KSCrash/Recording/Tools (= 1.16.2) - KSCrash/Recording/Tools (1.16.2) - - KSCrash/Reporting (1.16.2): - - KSCrash/Recording - - KSCrash/Reporting/Filters (= 1.16.2) - - KSCrash/Reporting/MessageUI (= 1.16.2) - - KSCrash/Reporting/Sinks (= 1.16.2) - - KSCrash/Reporting/Tools (= 1.16.2) - - KSCrash/Reporting/Filters (1.16.2): - - KSCrash/Recording - - KSCrash/Reporting/Filters/Alert (= 1.16.2) - - KSCrash/Reporting/Filters/AppleFmt (= 1.16.2) - - KSCrash/Reporting/Filters/Base (= 1.16.2) - - KSCrash/Reporting/Filters/Basic (= 1.16.2) - - KSCrash/Reporting/Filters/GZip (= 1.16.2) - - KSCrash/Reporting/Filters/JSON (= 1.16.2) - - KSCrash/Reporting/Filters/Sets (= 1.16.2) - - KSCrash/Reporting/Filters/Stringify (= 1.16.2) - - KSCrash/Reporting/Filters/Tools (= 1.16.2) - - KSCrash/Reporting/Filters/Alert (1.16.2): - - KSCrash/Recording - - KSCrash/Reporting/Filters/Base - KSCrash/Reporting/Filters/AppleFmt (1.16.2): - KSCrash/Recording - KSCrash/Reporting/Filters/Base @@ -57,12 +34,6 @@ PODS: - KSCrash/Reporting/Filters/Base - KSCrash/Reporting/Filters/Tools (1.16.2): - KSCrash/Recording - - KSCrash/Reporting/MessageUI (1.16.2): - - KSCrash/Recording - - KSCrash/Reporting/Sinks (1.16.2): - - KSCrash/Recording - - KSCrash/Reporting/Filters - - KSCrash/Reporting/Tools - KSCrash/Reporting/Tools (1.16.2): - KSCrash/Recording - MarqueeLabel (4.3.2) @@ -71,9 +42,9 @@ PODS: - MarqueeLabel (~> 4.3.0) - SnapKit (~> 5.6.0) - SAMKeychain (1.5.3) - - SDWebImage (5.18.6): - - SDWebImage/Core (= 5.18.6) - - SDWebImage/Core (5.18.6) + - SDWebImage (5.18.7): + - SDWebImage/Core (= 5.18.7) + - SDWebImage/Core (5.18.7) - SignalProtocolC (2.3.3) - SignalProtocolObjC (1.1.1): - SignalProtocolC (~> 2.3.3) @@ -88,7 +59,11 @@ DEPENDENCIES: - ASN1Decoder - DZNEmptyDataSet - FLAnimatedImage (~> 1.0) - - KSCrash (from `https://github.com/monal-im/KSCrash`, branch `master`) + - KSCrash/Core + - KSCrash/Recording + - KSCrash/Reporting/Filters/Sets + - KSCrash/Reporting/Filters/Tools + - KSCrash/Reporting/Tools - MBProgressHUD (~> 1.2.0) - NotificationBannerSwift (~> 3.2.0) - SAMKeychain @@ -104,6 +79,7 @@ SPEC REPOS: - ASN1Decoder - DZNEmptyDataSet - FLAnimatedImage + - KSCrash - MarqueeLabel - MBProgressHUD - NotificationBannerSwift @@ -115,9 +91,6 @@ SPEC REPOS: - WebRTC-lib EXTERNAL SOURCES: - KSCrash: - :branch: master - :git: https://github.com/monal-im/KSCrash SignalProtocolC: :branch: master :git: https://github.com/monal-im/libsignal-protocol-c @@ -126,9 +99,6 @@ EXTERNAL SOURCES: :git: https://github.com/monal-im/SignalProtocol-ObjC.git CHECKOUT OPTIONS: - KSCrash: - :commit: c7ba6e1cb2a548cb108d3536027e36a6e12670cb - :git: https://github.com/monal-im/KSCrash SignalProtocolC: :commit: 560504888d9c0ba4be860275d206dcef07e0761e :git: https://github.com/monal-im/libsignal-protocol-c @@ -140,12 +110,12 @@ SPEC CHECKSUMS: ASN1Decoder: 4f4bbcaf1d1b8be56daa3280e82863a607f5bda9 DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7 FLAnimatedImage: bbf914596368867157cc71b38a8ec834b3eeb32b - KSCrash: 95066f51c72849faaa7d8d57f300416ee4e5df52 + KSCrash: 469b9f982b97309acb719baaecbf9182f62ddf85 MarqueeLabel: 15e524a6762552bb279cb17438b8a94990269fb9 MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406 NotificationBannerSwift: dce54ded532b26e30cd8e7f4d80e124a0f2ba7d1 SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c - SDWebImage: 3d8caa2430f3d674dbb3e515df4a100a2105af5f + SDWebImage: f9258c58221ed854cfa0e2b80ee4033710b1c6d3 SignalProtocolC: 8092866e45b663a6bc3e45a8d13bad2571dbf236 SignalProtocolObjC: 1beb46b1d35733e7ab96a919f88bac20ec771c73 SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25 @@ -153,6 +123,6 @@ SPEC CHECKSUMS: TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863 WebRTC-lib: bd0d4b76aab1492415216715bd02f4329a33cd10 -PODFILE CHECKSUM: 99af97fbdbc651c2f1c5558cb9ba7107ef30aa28 +PODFILE CHECKSUM: f415f317e34fd11a687374f84ee8dfb14ebb29a6 COCOAPODS: 1.14.3