]> git.saurik.com Git - wxWidgets.git/blame - include/wx/debugrpt.h
applied heavily modified patch 1116702: support for specifying disabled toolbar image...
[wxWidgets.git] / include / wx / debugrpt.h
CommitLineData
ce4fd7b5
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/debugrpt.h
3// Purpose: declaration of wxDebugReport class
4// Author: Vadim Zeitlin
5// Created: 2005-01-17
6// RCS-ID: $Id$
7// Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_DEBUGRPT_H_
12#define _WX_DEBUGRPT_H_
13
14#include "wx/defs.h"
15
16#if wxUSE_DEBUGREPORT
17
18class WXDLLIMPEXP_XML wxXmlNode;
19
20// ----------------------------------------------------------------------------
21// wxDebugReport: generate a debug report, processing is done in derived class
22// ----------------------------------------------------------------------------
23
61639efb 24class WXDLLIMPEXP_QA wxDebugReport
ce4fd7b5
VZ
25{
26public:
27 // this is used for the functions which may report either the current state
28 // or the state during the last (fatal) exception
478cde32 29 enum Context { Context_Current, Context_Exception };
ce4fd7b5
VZ
30
31
32 // ctor creates a temporary directory where we create the files which will
33 // be included in the report, use IsOk() to check for errors
34 wxDebugReport();
35
36 // dtor normally destroys the temporary directory created in the ctor (with
37 // all the files it contains), call Reset() to prevent this from happening
38 virtual ~wxDebugReport();
39
40 // return the name of the directory used for this report
41 const wxString& GetDirectory() const { return m_dir; }
42
43 // return true if the object was successfully initialized
44 bool IsOk() const { return !GetDirectory().empty(); }
45
46 // reset the directory name we use, the object can't be used any more after
47 // this as it becomes invalid/uninitialized
48 void Reset() { m_dir.clear(); }
49
50
51 // add another file to the report: the file must already exist, its name is
52 // relative to GetDirectory()
53 //
54 // description is shown to the user in the report summary
55 virtual void AddFile(const wxString& name, const wxString& description);
56
707c4418 57#if wxUSE_STACKWALKER
ce4fd7b5
VZ
58 // add an XML file containing the current or exception context and the
59 // stack trace
478cde32 60 bool AddCurrentContext() { return AddContext(Context_Current); }
ce4fd7b5
VZ
61 bool AddExceptionContext() { return AddContext(Context_Exception); }
62 virtual bool AddContext(Context ctx);
707c4418 63#endif
ce4fd7b5
VZ
64
65#if wxUSE_CRASHREPORT
66 // add a file with crash report
478cde32 67 bool AddCurrentDump() { return AddDump(Context_Current); }
ce4fd7b5
VZ
68 bool AddExceptionDump() { return AddDump(Context_Exception); }
69 virtual bool AddDump(Context ctx);
70#endif // wxUSE_CRASHREPORT
71
72 // add all available information to the report
73 void AddAll(Context context = Context_Exception);
74
75
76 // process this report: the base class simply notifies the user that the
77 // report has been generated, this is usually not enough -- instead you
78 // should override this method to do something more useful to you
79 bool Process();
80
81 // get the name used as base name for various files, by default
82 // wxApp::GetName()
83 virtual wxString GetReportName() const;
84
85 // get the files in this report
86 size_t GetFilesCount() const { return m_files.GetCount(); }
87 bool GetFile(size_t n, wxString *name, wxString *desc) const;
88
89 // remove the file from report: this is used by wxDebugReportPreview to
90 // allow the user to remove files potentially containing private
91 // information from the report
92 void RemoveFile(const wxString& name);
93
94protected:
707c4418 95#if wxUSE_STACKWALKER
ce4fd7b5
VZ
96 // used by AddContext()
97 virtual bool DoAddSystemInfo(wxXmlNode *nodeSystemInfo);
98 virtual bool DoAddLoadedModules(wxXmlNode *nodeModules);
99 virtual bool DoAddExceptionInfo(wxXmlNode *nodeContext);
100 virtual void DoAddCustomContext(wxXmlNode * WXUNUSED(nodeRoot)) { }
707c4418 101#endif
ce4fd7b5
VZ
102
103 // used by Process()
104 virtual bool DoProcess();
105
106private:
107 // name of the report directory
108 wxString m_dir;
109
110 // the arrays of files in this report and their descriptions
111 wxArrayString m_files,
112 m_descriptions;
113};
114
115#if wxUSE_ZIPSTREAM
116
117// ----------------------------------------------------------------------------
118// wxDebugReportCompress: compress all files of this debug report in a .ZIP
119// ----------------------------------------------------------------------------
120
61639efb 121class WXDLLIMPEXP_QA wxDebugReportCompress : public wxDebugReport
ce4fd7b5
VZ
122{
123public:
124 wxDebugReportCompress() { }
125
126 // returns the full path of the compressed file (empty if creation failed)
127 const wxString& GetCompressedFileName() const { return m_zipfile; }
128
129protected:
130 virtual bool DoProcess();
131
132private:
133 // full path to the ZIP file we created
134 wxString m_zipfile;
135};
136
137// ----------------------------------------------------------------------------
138// wxDebugReportUploader: uploads compressed file using HTTP POST request
139// ----------------------------------------------------------------------------
140
61639efb 141class WXDLLIMPEXP_QA wxDebugReportUpload : public wxDebugReportCompress
ce4fd7b5
VZ
142{
143public:
144 // this class will upload the compressed file created by its base class to
145 // an HTML multipart/form-data form at the specified address
146 //
147 // the URL is the base address, input is the name of the "type=file"
148 // control on the form used for the file name and action is the value of
149 // the form action field
150 wxDebugReportUpload(const wxString& url,
151 const wxString& input,
152 const wxString& action,
153 const wxString& curl = _T("curl"));
154
155protected:
156 virtual bool DoProcess();
157
158 // this function may be overridden in a derived class to show the output
159 // from curl: this may be an HTML page or anything else that the server
160 // returned
161 //
162 // return value becomes the return value of Process()
163 virtual bool OnServerReply(const wxArrayString& WXUNUSED(reply))
164 {
165 return true;
166 }
167
168private:
169 // the full URL to use with HTTP POST request
170 wxString m_uploadURL;
171
172 // the name of the input field containing the file name in the form at
173 // above URL
174 wxString m_inputField;
175
176 // the curl command (by default it is just "curl" but could be full path to
177 // curl or a wrapper script with curl-compatible syntax)
178 wxString m_curlCmd;
179};
180
181#endif // wxUSE_ZIPSTREAM
182
183
184// ----------------------------------------------------------------------------
185// wxDebugReportPreview: presents the debug report to the user and allows him
186// to veto report entirely or remove some parts of it
187// ----------------------------------------------------------------------------
188
61639efb 189class WXDLLIMPEXP_QA wxDebugReportPreview
ce4fd7b5
VZ
190{
191public:
192 // ctor is trivial
193 wxDebugReportPreview() { }
194
195 // present the report to the user and allow him to modify it by removing
196 // some or all of the files and, potentially, adding some notes
197 //
198 // return true if the report should be processed or false if the user chose
199 // to cancel report generation or removed all files from it
200 virtual bool Show(wxDebugReport& dbgrpt) const = 0;
201
202 // dtor is trivial as well but should be virtual for a base class
203 virtual ~wxDebugReportPreview() { }
204};
205
206#if wxUSE_GUI
207
208// ----------------------------------------------------------------------------
209// wxDebugReportPreviewStd: standard debug report preview window
210// ----------------------------------------------------------------------------
211
61639efb 212class WXDLLIMPEXP_QA wxDebugReportPreviewStd : public wxDebugReportPreview
ce4fd7b5
VZ
213{
214public:
215 wxDebugReportPreviewStd() { }
216
217 virtual bool Show(wxDebugReport& dbgrpt) const;
218};
219
220#endif // wxUSE_GUI
221
222#endif // wxUSE_DEBUGREPORT
223
224#endif // _WX_DEBUGRPT_H_
225