|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef CRASHREPORTER_OSX_H__ |
|
7 #define CRASHREPORTER_OSX_H__ |
|
8 |
|
9 #include <Cocoa/Cocoa.h> |
|
10 #include "HTTPMultipartUpload.h" |
|
11 #include "crashreporter.h" |
|
12 |
|
13 // Defined below |
|
14 @class TextViewWithPlaceHolder; |
|
15 |
|
16 @interface CrashReporterUI : NSObject |
|
17 { |
|
18 IBOutlet NSWindow* mWindow; |
|
19 |
|
20 /* Crash reporter view */ |
|
21 IBOutlet NSTextField* mHeaderLabel; |
|
22 IBOutlet NSTextField* mDescriptionLabel; |
|
23 IBOutlet NSButton* mViewReportButton; |
|
24 IBOutlet NSScrollView* mCommentScrollView; |
|
25 IBOutlet TextViewWithPlaceHolder* mCommentText; |
|
26 IBOutlet NSButton* mSubmitReportButton; |
|
27 IBOutlet NSButton* mIncludeURLButton; |
|
28 IBOutlet NSButton* mEmailMeButton; |
|
29 IBOutlet NSTextField* mEmailText; |
|
30 IBOutlet NSButton* mCloseButton; |
|
31 IBOutlet NSButton* mRestartButton; |
|
32 IBOutlet NSProgressIndicator* mProgressIndicator; |
|
33 IBOutlet NSTextField* mProgressText; |
|
34 |
|
35 /* Error view */ |
|
36 IBOutlet NSView* mErrorView; |
|
37 IBOutlet NSTextField* mErrorHeaderLabel; |
|
38 IBOutlet NSTextField* mErrorLabel; |
|
39 IBOutlet NSButton* mErrorCloseButton; |
|
40 |
|
41 /* For "show info" alert */ |
|
42 IBOutlet NSWindow* mViewReportWindow; |
|
43 IBOutlet NSTextView* mViewReportTextView; |
|
44 IBOutlet NSButton* mViewReportOkButton; |
|
45 |
|
46 HTTPMultipartUpload* mPost; |
|
47 } |
|
48 |
|
49 - (void)showCrashUI:(const std::string&)dumpfile |
|
50 queryParameters:(const StringTable&)queryParameters |
|
51 sendURL:(const std::string&)sendURL; |
|
52 - (void)showErrorUI:(const std::string&)dumpfile; |
|
53 - (void)showReportInfo; |
|
54 - (void)maybeSubmitReport; |
|
55 - (void)closeMeDown:(id)unused; |
|
56 |
|
57 - (IBAction)submitReportClicked:(id)sender; |
|
58 - (IBAction)viewReportClicked:(id)sender; |
|
59 - (IBAction)viewReportOkClicked:(id)sender; |
|
60 - (IBAction)closeClicked:(id)sender; |
|
61 - (IBAction)restartClicked:(id)sender; |
|
62 - (IBAction)includeURLClicked:(id)sender; |
|
63 - (IBAction)emailMeClicked:(id)sender; |
|
64 |
|
65 - (void)controlTextDidChange:(NSNotification *)note; |
|
66 - (void)textDidChange:(NSNotification *)aNotification; |
|
67 - (BOOL)textView:(NSTextView *)aTextView shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString; |
|
68 |
|
69 - (void)doInitialResizing; |
|
70 - (float)setStringFitVertically:(NSControl*)control |
|
71 string:(NSString*)str |
|
72 resizeWindow:(BOOL)resizeWindow; |
|
73 - (void)setView:(NSView*)v animate: (BOOL) animate; |
|
74 - (void)enableControls:(BOOL)enabled; |
|
75 - (void)updateSubmit; |
|
76 - (void)updateURL; |
|
77 - (void)updateEmail; |
|
78 - (void)sendReport; |
|
79 - (bool)setupPost; |
|
80 - (void)uploadThread:(HTTPMultipartUpload*)post; |
|
81 - (void)uploadComplete:(NSData*)data; |
|
82 |
|
83 -(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication; |
|
84 -(void)applicationWillTerminate:(NSNotification *)aNotification; |
|
85 |
|
86 @end |
|
87 |
|
88 /* |
|
89 * Subclass NSTextView to provide a text view with placeholder text. |
|
90 * Also provide a setEnabled implementation. |
|
91 */ |
|
92 @interface TextViewWithPlaceHolder : NSTextView { |
|
93 NSMutableAttributedString *mPlaceHolderString; |
|
94 } |
|
95 |
|
96 - (BOOL)becomeFirstResponder; |
|
97 - (void)drawRect:(NSRect)rect; |
|
98 - (BOOL)resignFirstResponder; |
|
99 - (void)setPlaceholder:(NSString*)placeholder; |
|
100 - (void)insertTab:(id)sender; |
|
101 - (void)insertBacktab:(id)sender; |
|
102 - (void)setEnabled:(BOOL)enabled; |
|
103 - (void)dealloc; |
|
104 |
|
105 @end |
|
106 |
|
107 #endif |