Bug 452317 - FeedConverter.js: QueryInterface should throw NS_ERROR_NO_INTERFACE...
[wine-gecko.git] / toolkit / crashreporter / client / crashreporter.h
blobc3a436dad427520ed19e44b217136998c51d7854
1 #ifndef CRASHREPORTER_H__
2 #define CRASHREPORTER_H__
4 #ifdef _MSC_VER
5 # pragma warning( push )
6 // Disable exception handler warnings.
7 # pragma warning( disable : 4530 )
8 #endif
10 #include <string>
11 #include <map>
12 #include <vector>
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <iostream>
16 #include <fstream>
18 #define MAX_COMMENT_LENGTH 500
20 #if defined(XP_WIN32)
22 #include <windows.h>
24 #define UI_SNPRINTF _snprintf
25 #define UI_DIR_SEPARATOR "\\"
27 std::string WideToUTF8(const std::wstring& wide, bool* success = 0);
29 #else
31 #define UI_SNPRINTF snprintf
32 #define UI_DIR_SEPARATOR "/"
34 #endif
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"
59 #define ST_OK "Ok"
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;
81 extern int gArgc;
82 extern char** gArgv;
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,
90 StringTable& strings,
91 bool unescape);
92 bool ReadStringsFromFile(const std::string& path,
93 StringTable& strings,
94 bool unescape);
95 bool WriteStrings(std::ostream& out,
96 const std::string& header,
97 StringTable& strings,
98 bool escape);
99 bool WriteStringsToFile(const std::string& path,
100 const std::string& header,
101 StringTable& strings,
102 bool escape);
103 void LogMessage(const std::string& message);
104 void DeleteDump();
105 bool ShouldEnableSending();
108 //=============================================================================
109 // implemented in the platform-specific files
110 //=============================================================================
112 bool UIInit();
113 void UIShutdown();
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);
139 #ifdef _MSC_VER
140 # pragma warning( pop )
141 #endif
143 #endif