1 #ifndef CRASHREPORTER_H__
2 #define CRASHREPORTER_H__
5 # pragma warning( push )
6 // Disable exception handler warnings.
7 # pragma warning( disable : 4530 )
18 #define MAX_COMMENT_LENGTH 500
24 #define UI_SNPRINTF _snprintf
25 #define UI_DIR_SEPARATOR "\\"
27 std::string
WideToUTF8(const std::wstring
& wide
, bool* success
= 0);
31 #define UI_SNPRINTF snprintf
32 #define UI_DIR_SEPARATOR "/"
36 typedef std::map
<std::string
, std::string
> StringTable
;
38 #define ST_CRASHREPORTERTITLE "CrashReporterTitle"
39 #define ST_CRASHREPORTERVENDORTITLE "CrashReporterVendorTitle"
40 #define ST_CRASHREPORTERERROR "CrashReporterErrorText"
41 #define ST_CRASHREPORTERPRODUCTERROR "CrashReporterProductErrorText2"
42 #define ST_CRASHREPORTERHEADER "CrashReporterSorry"
43 #define ST_CRASHREPORTERDESCRIPTION "CrashReporterDescriptionText2"
44 #define ST_CRASHREPORTERDEFAULT "CrashReporterDefault"
45 #define ST_VIEWREPORT "Details"
46 #define ST_VIEWREPORTTITLE "ViewReportTitle"
47 #define ST_COMMENTGRAYTEXT "CommentGrayText"
48 #define ST_EXTRAREPORTINFO "ExtraReportInfo"
49 #define ST_CHECKSUBMIT "CheckSendReport"
50 #define ST_CHECKURL "CheckIncludeURL"
51 #define ST_CHECKEMAIL "CheckSendEmail"
52 #define ST_EMAILGRAYTEXT "EmailGrayText"
53 #define ST_REPORTPRESUBMIT "ReportPreSubmit2"
54 #define ST_REPORTDURINGSUBMIT "ReportDuringSubmit2"
55 #define ST_REPORTSUBMITSUCCESS "ReportSubmitSuccess"
56 #define ST_SUBMITFAILED "ReportSubmitFailed"
57 #define ST_QUIT "Quit2"
58 #define ST_RESTART "Restart"
60 #define ST_CLOSE "Close"
62 #define ST_ERROR_BADARGUMENTS "ErrorBadArguments"
63 #define ST_ERROR_EXTRAFILEEXISTS "ErrorExtraFileExists"
64 #define ST_ERROR_EXTRAFILEREAD "ErrorExtraFileRead"
65 #define ST_ERROR_EXTRAFILEMOVE "ErrorExtraFileMove"
66 #define ST_ERROR_DUMPFILEEXISTS "ErrorDumpFileExists"
67 #define ST_ERROR_DUMPFILEMOVE "ErrorDumpFileMove"
68 #define ST_ERROR_NOPRODUCTNAME "ErrorNoProductName"
69 #define ST_ERROR_NOSERVERURL "ErrorNoServerURL"
70 #define ST_ERROR_NOSETTINGSPATH "ErrorNoSettingsPath"
71 #define ST_ERROR_CREATEDUMPDIR "ErrorCreateDumpDir"
72 #define ST_ERROR_ENDOFLIFE "ErrorEndOfLife"
74 //=============================================================================
75 // implemented in crashreporter.cpp
76 //=============================================================================
78 namespace CrashReporter
{
79 extern StringTable gStrings
;
80 extern std::string gSettingsPath
;
84 void UIError(const std::string
& message
);
86 // The UI finished sending the report
87 bool SendCompleted(bool success
, const std::string
& serverResponse
);
89 bool ReadStrings(std::istream
& in
,
92 bool ReadStringsFromFile(const std::string
& path
,
95 bool WriteStrings(std::ostream
& out
,
96 const std::string
& header
,
99 bool WriteStringsToFile(const std::string
& path
,
100 const std::string
& header
,
101 StringTable
& strings
,
103 void LogMessage(const std::string
& message
);
105 bool ShouldEnableSending();
108 //=============================================================================
109 // implemented in the platform-specific files
110 //=============================================================================
115 // Run the UI for when the app was launched without a dump file
116 void UIShowDefaultUI();
118 // Run the UI for when the app was launched with a dump file
119 // Return true if the user sent (or tried to send) the crash report,
120 // false if they chose not to, and it should be deleted.
121 bool UIShowCrashUI(const std::string
& dumpfile
,
122 const StringTable
& queryParameters
,
123 const std::string
& sendURL
,
124 const std::vector
<std::string
>& restartArgs
);
126 void UIError_impl(const std::string
& message
);
128 bool UIGetIniPath(std::string
& path
);
129 bool UIGetSettingsPath(const std::string
& vendor
,
130 const std::string
& product
,
131 std::string
& settingsPath
);
132 bool UIEnsurePathExists(const std::string
& path
);
133 bool UIFileExists(const std::string
& path
);
134 bool UIMoveFile(const std::string
& oldfile
, const std::string
& newfile
);
135 bool UIDeleteFile(const std::string
& oldfile
);
136 std::ifstream
* UIOpenRead(const std::string
& filename
);
137 std::ofstream
* UIOpenWrite(const std::string
& filename
, bool append
=false);
140 # pragma warning( pop )