Permalink
Browse files

Implemented crash reporting view and handling.

  • Loading branch information...
1 parent 14dd55e commit 7128a0e9fceb24aeea33ec426f75a5af73e1a58c @tomaz tomaz committed with Jul 21, 2010
Showing with 559 additions and 14 deletions.
  1. +8 −0 OFController.h
  2. +33 −6 OFController.m
  3. +5 −3 OpenFeedback.m
  4. +513 −5 OpenFeedback.xib
View
@@ -17,6 +17,7 @@
IBOutlet NSView *viewSupport;
IBOutlet NSView *viewFeature;
IBOutlet NSView *viewBug;
+ IBOutlet NSView *viewCrash;
// Support Tab
IBOutlet NSTextView *txtQuestion;
@@ -30,16 +31,23 @@
IBOutlet NSTextView *txtStepsToReproduce;
IBOutlet NSButton *btnIsCritical;
+ // Crash Report Tab
+ IBOutlet NSTextField *txtCrashTitle;
+ IBOutlet NSTextView *txtCrashDescription;
+ IBOutlet NSTextView *txtCrashStepsToReproduce;
+
// All Tabs
IBOutlet NSButton *btnIncludeMyEmail;
IBOutlet NSComboBox *cboEmailAddress;
IBOutlet NSProgressIndicator *piStatus;
IBOutlet NSButton *btnSend;
+ BOOL _crashReportMode;
}
- (IBAction)presentFeedbackPanelForSupport:(id)sender;
- (IBAction)presentFeedbackPanelForFeature:(id)sender;
- (IBAction)presentFeedbackPanelForBug:(id)sender;
+- (void)presentFeedbackPanelForCrash:(NSString *)report;
- (void)showFeedbackWindow;
- (void) populateEmailAddresses;
View
@@ -8,13 +8,21 @@
#import "OFController.h"
+@interface OFController ()
+
+- (void)presentFeedbackPanelForBugOrCrash;
+
+@end
+
+#pragma mark -
@implementation OFController
- (void)awakeFromNib
{
[self populateEmailAddresses];
[[self window] setTitle:[NSString stringWithFormat:@"%@ Feedback", OFHostAppDisplayName()]];
+ [txtCrashTitle setStringValue:[NSString stringWithFormat:[txtCrashTitle stringValue], OFHostAppDisplayName()]];
}
- (IBAction)presentFeedbackPanelForSupport:(id)sender
@@ -37,11 +45,24 @@ - (IBAction)presentFeedbackPanelForFeature:(id)sender
- (IBAction)presentFeedbackPanelForBug:(id)sender
{
+ _crashReportMode = NO;
+ [self presentFeedbackPanelForBugOrCrash];
+}
+
+- (void)presentFeedbackPanelForCrash:(NSString *)report {
+ _crashReportMode = YES;
+ [self loadWindow]; // need to load otherwise IB links are not initalized
+ NSString *crashDescription = NSLocalizedString(@"\n\n\n\nThe text below is application's crash log, please leave it unchanged to help us determine possible cause!\n\n%@", nil);
+ [txtCrashDescription setString:[NSString stringWithFormat:crashDescription, report]];
+ [self presentFeedbackPanelForBugOrCrash];
+}
+
+- (void)presentFeedbackPanelForBugOrCrash {
[self showFeedbackWindow];
[tabs selectSegmentWithTag:2];
- [tabView setContentView:viewBug];
+ [tabView setContentView:_crashReportMode ? viewCrash : viewBug];
[btnSend setEnabled:[self sendButtonIsEnabled]];
- [[self window] makeFirstResponder:txtWhatHappened];
+ [[self window] makeFirstResponder:_crashReportMode ? txtCrashDescription : txtWhatHappened];
}
- (void)showFeedbackWindow
@@ -56,7 +77,7 @@ - (IBAction)selectedTabDidChange:(id)sender
else if([tabs selectedSegment]== 1)
[self presentFeedbackPanelForFeature:self];
else if([tabs selectedSegment] == 2)
- [self presentFeedbackPanelForBug:self];
+ [self presentFeedbackPanelForBugOrCrash];
}
- (IBAction)chkIncludeEmail:(id)sender
@@ -94,11 +115,17 @@ - (BOOL)sendButtonIsEnabled
}
- // Bug Report
+ // Bug or Crash Report
if([tabs selectedSegment] == 2)
{
- if([[txtWhatHappened string] length] == 0)
- isEnabled = NO;
+ if (_crashReportMode) {
+ if ([[txtCrashDescription string] length] == 0)
+ isEnabled = NO;
+ }
+ else {
+ if([[txtWhatHappened string] length] == 0)
+ isEnabled = NO;
+ }
}
if([btnIncludeMyEmail state] == YES)
View
@@ -58,8 +58,10 @@ - (void)presentFeedbackPanelIfCrashed {
NSArray *logs = [self crashLogsSince:self.lastCrashCheckTime];
if ([logs count] > 0) {
NSString *report = [self latestCrashLogContents:logs];
+ [windowController presentFeedbackPanelForCrash:report];
}
- self.lastCrashCheckTime = [NSDate date];
+// self.lastCrashCheckTime = [NSDate date];
+ self.lastCrashCheckTime = [NSDate distantPast];
}
@end
@@ -80,7 +82,7 @@ - (NSString *)latestCrashLogContents:(NSArray *)logs {
}
}
- if (latestFile) return [NSString stringWithContentsOfURL:latestFile encoding:NSUTF8StringEncoding error:nil];
+ if (latestFile) return [NSString stringWithContentsOfFile:latestFile encoding:NSUTF8StringEncoding error:nil];
return nil;
}
@@ -98,7 +100,7 @@ - (NSArray *)crashLogsSince:(NSDate *)time {
NSDirectoryEnumerator *enumerator = [manager enumeratorAtPath:crashPath];
NSString *prefix = [NSString stringWithFormat:@"%@_", appName];
while ((filename = [enumerator nextObject])) {
- if (![filename hasPrefix:prefix]) continue;
+// if (![filename hasPrefix:prefix]) continue;
if (![[filename pathExtension] isEqualToString:@"crash"]) continue;
filename = [crashPath stringByAppendingPathComponent:filename];
Oops, something went wrong.

0 comments on commit 7128a0e

Please sign in to comment.