diff --git a/AppDelegate.h b/AppDelegate.h index 3f8db52..b12b8e9 100755 --- a/AppDelegate.h +++ b/AppDelegate.h @@ -21,6 +21,7 @@ #import "ResultsWindowController.h" #import +#import /* GLOBALS */ diff --git a/AppDelegate.m b/AppDelegate.m index e3a681f..dff7ca9 100755 --- a/AppDelegate.m +++ b/AppDelegate.m @@ -35,6 +35,29 @@ @implementation AppDelegate @synthesize categoryTableController; @synthesize resultsWindowController; +//exception handler +// show alert and log error +void uncaughtExceptionHandler(NSException* exception) { + + //alert + NSAlert* alert = nil; + + //alloc/init alert + alert = [NSAlert alertWithMessageText:NSLocalizedString(@"ERROR:\nKnockKnock Encountered a Fatal Error", @"KnockKnock Encountered a Fatal Error") defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:NSLocalizedString(@"Exception: %@",@"Exception: %@"), exception]; + + //show it + [alert runModal]; + + //log + os_log_error(OS_LOG_DEFAULT, "KnockKnock crash: %{public}@", exception); + os_log_error(OS_LOG_DEFAULT, "KnockKnock crash (stack trace): %{public}@", [exception callStackSymbols]); + + //bye + exit(EXIT_FAILURE); + + return; +} + //center window // also make front -(void)awakeFromNib @@ -57,6 +80,9 @@ -(void)applicationDidFinishLaunching:(NSNotification *)notification //defaults NSUserDefaults* defaults = nil; + //set exception handler + NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler); + //init filter object itemFilter = [[Filter alloc] init]; diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 558bf71..b568faa 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -188,6 +188,9 @@ } } }, + "ERROR:\nKnockKnock Encountered a Fatal Error" : { + "comment" : "KnockKnock Encountered a Fatal Error" + }, "ERROR:\nVirusTotal query for '%@' failed" : { "comment" : "ERROR:\nVirusTotal query for '%@' failed", "localizations" : { @@ -221,6 +224,9 @@ } } }, + "Exception: %@" : { + "comment" : "Exception: %@" + }, "extensions hosted in the browser" : { "comment" : "extensions hosted in the browser", "localizations" : { @@ -526,6 +532,7 @@ }, "Submissions complete, though errors were encountered (HTTP response(s): %@)." : { "comment" : "Submissions complete, though errors were encountered (HTTP response(s): %@).", + "extractionState" : "stale", "localizations" : { "es" : { "stringUnit" : { @@ -535,6 +542,9 @@ } } }, + "Submissions complete, though errors were encountered.\r\n(HTTP response(s): %@)." : { + "comment" : "Submissions complete, though errors were encountered.\r\n(HTTP response(s): %@)." + }, "Submissions complete. (In subsequent scans item's VT detection ratios will now be displayed)." : { "comment" : "Submissions complete. (In subsequent scans item's VT detection ratios will now be displayed).", "localizations" : { @@ -645,6 +655,9 @@ } } }, + "VirusTotal Results: Disabled" : { + "comment" : "VirusTotal Results: Disabled" + }, "VirusTotal:\r\n %lu flagged item(s)\r\n %lu unknown item(s)" : { "comment" : "VirusTotal:\r\n %lu flagged item(s)\r\n %lu unknown item(s)", "localizations" : { diff --git a/ResultsWindowController.m b/ResultsWindowController.m index 4689ba8..29647e6 100755 --- a/ResultsWindowController.m +++ b/ResultsWindowController.m @@ -40,8 +40,25 @@ -(void)windowDidLoad //set details self.detailsLabel.stringValue = self.details; - //set unknown items - self.vtDetailsLabel.stringValue = self.vtDetails; + //set VT results + if(nil != self.vtDetails) + { + //set + self.vtDetailsLabel.stringValue = self.vtDetails; + } + //no VT results + // disabled? something else? + else + { + if(YES == ((AppDelegate*)[[NSApplication sharedApplication] delegate]).prefsWindowController.disableVTQueries) + { + self.vtDetailsLabel.stringValue = NSLocalizedString(@"VirusTotal Results: Disabled", @"VirusTotal Results: Disabled"); + } + else + { + self.vtDetailsLabel.stringValue = @"VirusTotal: ?"; + } + } //toggle 'Submit' button self.submitToVT.hidden = !(self.unknownItems.count); @@ -87,6 +104,9 @@ -(IBAction)submitToVT:(id)sender //update UI now that submission is done -(void)submissionComplete:(NSUInteger)successes httpResponses:(NSMutableArray*)httpResponses { + //unique responses + NSSet* uniqueResponses = nil; + //enable close self.closeButton.enabled = YES; @@ -101,10 +121,16 @@ -(void)submissionComplete:(NSUInteger)successes httpResponses:(NSMutableArray*)h } else { + //get just unique responses + uniqueResponses = [NSSet setWithArray:httpResponses]; + //update message - self.submissionStatus.stringValue = [NSString stringWithFormat:NSLocalizedString(@"Submissions complete, though errors were encountered (HTTP response(s): %@).", @"Submissions complete, though errors were encountered (HTTP response(s): %@)."), [httpResponses componentsJoinedByString:@","]]; + self.submissionStatus.stringValue = [NSString stringWithFormat:NSLocalizedString(@"Submissions complete, though errors were encountered.\r\n(HTTP response(s): %@)", @"Submissions complete, though errors were encountered.\r\n(HTTP response(s): %@)"), [[uniqueResponses allObjects] componentsJoinedByString:@","]]; } + //then make action button first responder + [self.window makeFirstResponder:self.closeButton]; + return; }