]> git.saurik.com Git - wxWidgets.git/blame - interface/debugrpt.h
GetSocketManager() has no GUI-specific version under Darwin finally
[wxWidgets.git] / interface / debugrpt.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: debugrpt.h
e54c96f1 3// Purpose: interface of wxDebugReportPreview
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxDebugReportPreview
11 @wxheader{debugrpt.h}
7c913512 12
23324ae1
FM
13 This class presents the debug report to the user and allows him to veto report
14 entirely or remove some parts of it. Although not mandatory, using this class
15 is strongly recommended as data included in the debug report might contain
16 sensitive private information and the user should be notified about it as well
17 as having a possibility to examine the data which had been gathered to check
18 whether this is effectively the case and discard the debug report if it is.
7c913512 19
23324ae1 20 wxDebugReportPreview is an abstract base class, currently the only concrete
7c913512 21 class deriving from it is
23324ae1 22 wxDebugReportPreviewStd.
7c913512 23
23324ae1
FM
24 @library{wxqa}
25 @category{debugging}
26*/
7c913512 27class wxDebugReportPreview
23324ae1
FM
28{
29public:
30 /**
31 Trivial default constructor.
32 */
33 wxDebugReportPreview();
34
35 /**
36 dtor is trivial as well but should be virtual for a base class
37 */
38 ~wxDebugReportPreview();
39
40 /**
41 Present the report to the user and allow him to modify it by removing some or
42 all of the files and, potentially, adding some notes. Return @true if the
43 report should be processed or @false if the user chose to cancel report
44 generation or removed all files from it.
45 */
328f5751 46 bool Show(wxDebugReport& dbgrpt) const;
23324ae1
FM
47};
48
49
e54c96f1 50
23324ae1
FM
51/**
52 @class wxDebugReportCompress
53 @wxheader{debugrpt.h}
7c913512 54
23324ae1
FM
55 wxDebugReportCompress is a wxDebugReport which
56 compresses all the files in this debug report into a single .ZIP file in its
57 @c @e Process() function.
7c913512 58
23324ae1
FM
59 @library{wxqa}
60 @category{debugging}
61*/
62class wxDebugReportCompress : public wxDebugReport
63{
64public:
65 /**
66 Default constructor does nothing special.
67 */
68 wxDebugReportCompress();
69
70 /**
71 Returns the full path of the compressed file (empty if creation failed).
72 */
328f5751 73 const wxString GetCompressedFileName() const;
23324ae1
FM
74};
75
76
e54c96f1 77
23324ae1
FM
78/**
79 @class wxDebugReport
80 @wxheader{debugrpt.h}
7c913512 81
23324ae1 82 wxDebugReport is used to generate a debug report, containing information about
7c913512
FM
83 the program current state. It is usually used from
84 wxApp::OnFatalException as shown in the
e54c96f1 85 sample().
7c913512 86
23324ae1
FM
87 A wxDebugReport object contains one or more files. A few of them can be created
88 by the
89 class itself but more can be created from the outside and then added to the
90 report. Also note that several virtual functions may be overridden to further
91 customize the class behaviour.
7c913512 92
23324ae1
FM
93 Once a report is fully assembled, it can simply be left in the temporary
94 directory so that the user can email it to the developers (in which case you
95 should still use wxDebugReportCompress to
7c913512 96 compress it in a single file) or uploaded to a Web server using
23324ae1
FM
97 wxDebugReportUpload (setting up the Web server
98 to accept uploads is your responsibility, of course). Other handlers, for
99 example for
100 automatically emailing the report, can be defined as well but are not currently
101 included in wxWidgets.
7c913512 102
23324ae1
FM
103 @library{wxqa}
104 @category{debugging}
105*/
7c913512 106class wxDebugReport
23324ae1
FM
107{
108public:
109 /**
110 The constructor creates a temporary directory where the files that will
7c913512 111 be included in the report are created. Use
23324ae1
FM
112 IsOk() to check for errors.
113 */
114 wxDebugReport();
115
116 /**
117 The destructor normally destroys the temporary directory created in the
118 constructor
119 with all the files it contains. Call Reset() to
120 prevent this from happening.
121 */
122 ~wxDebugReport();
123
124 /**
125 Adds all available information to the report. Currently this includes a
126 text (XML) file describing the process context and, under Win32, a minidump
127 file.
128 */
129 void AddAll(Context context = Context_Exception);
130
131 /**
132 Add an XML file containing the current or exception context and the
133 stack trace.
134 */
135 bool AddContext(Context ctx);
136
137 /**
138 The same as @ref addcontext() AddContext(Context_Current).
139 */
140 bool AddCurrentContext();
141
142 /**
143 The same as @ref adddump() AddDump(Context_Current).
144 */
145 bool AddCurrentDump();
146
147 /**
148 Adds the minidump file to the debug report.
7c913512 149 Minidumps are only available under recent Win32 versions (@c dbghlp32.dll
23324ae1
FM
150 can be installed under older systems to make minidumps available).
151 */
152 bool AddDump(Context ctx);
153
154 /**
155 The same as @ref addcontext() AddContext(Context_Exception).
156 */
157 bool AddExceptionContext();
158
159 /**
160 The same as @ref adddump() AddDump(Context_Exception).
161 */
162 bool AddExceptionDump();
163
164 /**
4cc4bfaf 165 Add another file to the report. If @a filename is an absolute path, it is
23324ae1
FM
166 copied to a file in the debug report directory with the same name. Otherwise
167 the file should already exist in this directory
4cc4bfaf 168 @a description only exists to be displayed to the user in the report summary
23324ae1
FM
169 shown by wxDebugReportPreview.
170 */
171 void AddFile(const wxString& filename,
172 const wxString& description);
173
174 /**
175 This is a convenient wrapper around AddFile(). It
4cc4bfaf
FM
176 creates the file with the given @e name and writes @a text to it, then
177 adds the file to the report. The @a filename shouldn't contain the path.
23324ae1
FM
178 Returns @true if file could be added successfully, @false if an IO error
179 occurred.
180 */
181 bool AddText(const wxString& filename, const wxString& text,
182 const wxString& description);
183
184 /**
185 This function may be overridden to add arbitrary custom context to the XML
186 context file created by AddContext(). By
187 default, it does nothing.
188 */
4cc4bfaf 189 void DoAddCustomContext(wxXmlNode* nodeRoot);
23324ae1
FM
190
191 /**
192 This function may be overridden to modify the contents of the exception tag in
193 the XML context file.
194 */
195 bool DoAddExceptionInfo(wxXmlNode* nodeContext);
196
197 /**
198 This function may be overridden to modify the contents of the modules tag in
199 the XML context file.
200 */
201 bool DoAddLoadedModules(wxXmlNode* nodeModules);
202
203 /**
204 This function may be overridden to modify the contents of the system tag in
205 the XML context file.
206 */
207 bool DoAddSystemInfo(wxXmlNode* nodeSystemInfo);
208
209 /**
210 Returns the name of the temporary directory used for the files in this report.
23324ae1
FM
211 This method should be used to construct the full name of the files which you
212 wish to add to the report using AddFile().
213 */
328f5751 214 const wxString GetDirectory() const;
23324ae1
FM
215
216 /**
7c913512 217 Retrieves the name (relative to
23324ae1 218 wxDebugReport::GetDirectory) and the description of the
4cc4bfaf 219 file with the given index. If @a n is greater than or equal to the number of
23324ae1
FM
220 filse, @false is returned.
221 */
328f5751 222 bool GetFile(size_t n, wxString* name, wxString* desc) const;
23324ae1
FM
223
224 /**
225 Gets the current number files in this report.
226 */
328f5751 227 size_t GetFilesCount() const;
23324ae1
FM
228
229 /**
7c913512 230 Gets the name used as a base name for various files, by default
23324ae1
FM
231 wxApp::GetAppName is used.
232 */
328f5751 233 wxString GetReportName() const;
23324ae1
FM
234
235 /**
236 Returns @true if the object was successfully initialized. If this method
7c913512 237 returns
23324ae1
FM
238 @false the report can't be used.
239 */
328f5751 240 bool IsOk() const;
23324ae1
FM
241
242 /**
243 Processes this report: the base class simply notifies the user that the
244 report has been generated. This is usually not enough -- instead you
245 should override this method to do something more useful to you.
246 */
247 bool Process();
248
249 /**
7c913512 250 Removes the file from report: this is used by
23324ae1
FM
251 wxDebugReportPreview to allow the user to
252 remove files potentially containing private information from the report.
253 */
254 void RemoveFile(const wxString& name);
255
256 /**
257 Resets the directory name we use. The object can't be used any more after
258 this as it becomes uninitialized and invalid.
259 */
260 void Reset();
261};
262
263
e54c96f1 264
23324ae1
FM
265/**
266 @class wxDebugReportPreviewStd
267 @wxheader{debugrpt.h}
7c913512 268
23324ae1
FM
269 wxDebugReportPreviewStd is a standard debug report preview window. It displays
270 a GUIdialog allowing the user to examine the contents of a debug report, remove
271 files from and add notes to it.
7c913512 272
23324ae1
FM
273 @library{wxqa}
274 @category{debugging}
275*/
276class wxDebugReportPreviewStd : public wxDebugReportPreview
277{
278public:
279 /**
280 Trivial default constructor.
281 */
282 wxDebugReportPreviewStd();
283
284 /**
7c913512 285 Show the dialog, see
23324ae1
FM
286 wxDebugReportPreview::Show for more
287 information.
288 */
328f5751 289 bool Show(wxDebugReport& dbgrpt) const;
23324ae1
FM
290};
291
292
e54c96f1 293
23324ae1
FM
294/**
295 @class wxDebugReportUpload
296 @wxheader{debugrpt.h}
7c913512 297
23324ae1
FM
298 This class is used to upload a compressed file using HTTP POST request. As this
299 class derives from wxDebugReportCompress, before upload the report is
300 compressed in a single .ZIP file.
7c913512 301
23324ae1
FM
302 @library{wxqa}
303 @category{debugging}
304*/
305class wxDebugReportUpload : public wxDebugReportCompress
306{
307public:
308 /**
309 )
23324ae1 310 This class will upload the compressed file created by its base class to an HTML
4cc4bfaf
FM
311 multipart/form-data form at the specified address. The @a url is the upload
312 page address, @a input is the name of the @c "type=file" control on
313 the form used for the file name and @a action is the value of the form
23324ae1
FM
314 action field. The report is uploaded using @c @e curl program which
315 should be available, the @e curl parameter may be used to specify the full
316 path to it.
317 */
318 wxDebugReportUpload(const wxString& url, const wxString& input,
319 const wxString& action);
320
321 /**
322 )
23324ae1
FM
323 This function may be overridden in a derived class to show the output from
324 curl: this may be an HTML page or anything else that the server returned.
7c913512 325 Value returned by this function becomes the return value of
23324ae1
FM
326 wxDebugReport::Process.
327 */
328 bool OnServerReply();
329};
e54c96f1 330