1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Toolkit Crash Reporter
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2006
20 * the Initial Developer. All Rights Reserved.
23 * Dave Camp <dcamp@mozilla.com>
24 * Ted Mielczarek <ted.mielczarek@gmail.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef CRASHREPORTER_OSX_H__
41 #define CRASHREPORTER_OSX_H__
43 #include <Cocoa/Cocoa.h>
44 #include "HTTPMultipartUpload.h"
45 #include "crashreporter.h"
48 @
class TextViewWithPlaceHolder
;
50 @interface CrashReporterUI
: NSObject
52 IBOutlet NSWindow
* mWindow
;
54 /* Crash reporter view */
55 IBOutlet NSTextField
* mHeaderLabel
;
56 IBOutlet NSTextField
* mDescriptionLabel
;
57 IBOutlet NSButton
* mViewReportButton
;
58 IBOutlet NSScrollView
* mCommentScrollView
;
59 IBOutlet TextViewWithPlaceHolder
* mCommentText
;
60 IBOutlet NSButton
* mSubmitReportButton
;
61 IBOutlet NSButton
* mIncludeURLButton
;
62 IBOutlet NSButton
* mEmailMeButton
;
63 IBOutlet NSTextField
* mEmailText
;
64 IBOutlet NSButton
* mCloseButton
;
65 IBOutlet NSButton
* mRestartButton
;
66 IBOutlet NSProgressIndicator
* mProgressIndicator
;
67 IBOutlet NSTextField
* mProgressText
;
70 IBOutlet NSView
* mErrorView
;
71 IBOutlet NSTextField
* mErrorHeaderLabel
;
72 IBOutlet NSTextField
* mErrorLabel
;
73 IBOutlet NSButton
* mErrorCloseButton
;
75 /* For "show info" alert */
76 IBOutlet NSWindow
* mViewReportWindow
;
77 IBOutlet NSTextView
* mViewReportTextView
;
78 IBOutlet NSButton
* mViewReportOkButton
;
80 HTTPMultipartUpload
* mPost
;
83 - (void)showCrashUI
:(const std::string
&)dumpfile
84 queryParameters
:(const StringTable
&)queryParameters
85 sendURL
:(const std::string
&)sendURL
;
86 - (void)showErrorUI
:(const std::string
&)dumpfile
;
87 - (void)showReportInfo
;
88 - (void)maybeSubmitReport
;
89 - (void)closeMeDown
:(id
)unused
;
91 - (IBAction
)submitReportClicked
:(id
)sender
;
92 - (IBAction
)viewReportClicked
:(id
)sender
;
93 - (IBAction
)viewReportOkClicked
:(id
)sender
;
94 - (IBAction
)closeClicked
:(id
)sender
;
95 - (IBAction
)restartClicked
:(id
)sender
;
96 - (IBAction
)includeURLClicked
:(id
)sender
;
97 - (IBAction
)emailMeClicked
:(id
)sender
;
99 - (void)controlTextDidChange
:(NSNotification
*)note
;
100 - (void)textDidChange
:(NSNotification
*)aNotification
;
101 - (BOOL
)textView
:(NSTextView
*)aTextView shouldChangeTextInRange
:(NSRange
)affectedCharRange replacementString
:(NSString
*)replacementString
;
103 - (void)doInitialResizing
;
104 - (float)setStringFitVertically
:(NSControl
*)control
105 string
:(NSString
*)str
106 resizeWindow
:(BOOL
)resizeWindow
;
107 - (void)setView
:(NSView
*)v animate
: (BOOL
) animate
;
108 - (void)enableControls
:(BOOL
)enabled
;
109 - (void)updateSubmit
;
114 - (void)uploadThread
:(HTTPMultipartUpload
*)post
;
115 - (void)uploadComplete
:(NSData
*)data
;
117 -(BOOL
)applicationShouldTerminateAfterLastWindowClosed
:(NSApplication
*)theApplication
;
118 -(void)applicationWillTerminate
:(NSNotification
*)aNotification
;
123 * Subclass NSTextView to provide a text view with placeholder text.
124 * Also provide a setEnabled implementation.
126 @interface TextViewWithPlaceHolder
: NSTextView
{
127 NSMutableAttributedString
*mPlaceHolderString
;
130 - (BOOL
)becomeFirstResponder
;
131 - (void)drawRect
:(NSRect
)rect
;
132 - (BOOL
)resignFirstResponder
;
133 - (void)setPlaceholder
:(NSString
*)placeholder
;
134 - (void)insertTab
:(id
)sender
;
135 - (void)insertBacktab
:(id
)sender
;
136 - (void)setEnabled
:(BOOL
)enabled
;