2007-07-24 18:06:03 -07:00
|
|
|
#ifndef CRASHREPORTER_H__
|
|
|
|
#define CRASHREPORTER_H__
|
|
|
|
|
2007-07-24 18:06:05 -07:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma warning( push )
|
2007-07-24 18:06:03 -07:00
|
|
|
// Disable exception handler warnings.
|
2007-07-24 18:06:05 -07:00
|
|
|
# pragma warning( disable : 4530 )
|
|
|
|
#endif
|
|
|
|
|
2007-07-24 18:06:03 -07:00
|
|
|
#include <string>
|
|
|
|
#include <map>
|
2007-07-24 18:06:05 -07:00
|
|
|
#include <vector>
|
2007-07-24 18:06:03 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2007-07-24 18:06:08 -07:00
|
|
|
#include <iostream>
|
2007-07-24 18:06:10 -07:00
|
|
|
#include <fstream>
|
2007-07-24 18:06:03 -07:00
|
|
|
|
2008-01-21 17:07:20 -08:00
|
|
|
#define MAX_COMMENT_LENGTH 500
|
|
|
|
|
2007-07-24 18:06:03 -07:00
|
|
|
#if defined(XP_WIN32)
|
|
|
|
|
|
|
|
#include <windows.h>
|
2007-07-24 18:06:10 -07:00
|
|
|
|
2007-07-24 18:06:03 -07:00
|
|
|
#define UI_SNPRINTF _snprintf
|
|
|
|
#define UI_DIR_SEPARATOR "\\"
|
|
|
|
|
2007-07-24 18:06:10 -07:00
|
|
|
std::string WideToUTF8(const std::wstring& wide, bool* success = 0);
|
|
|
|
|
2007-07-24 18:06:03 -07:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define UI_SNPRINTF snprintf
|
|
|
|
#define UI_DIR_SEPARATOR "/"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef std::map<std::string, std::string> StringTable;
|
|
|
|
|
2007-07-24 18:06:09 -07:00
|
|
|
#define ST_CRASHREPORTERTITLE "CrashReporterTitle"
|
|
|
|
#define ST_CRASHREPORTERVENDORTITLE "CrashReporterVendorTitle"
|
2008-01-21 17:07:20 -08:00
|
|
|
#define ST_CRASHREPORTERERROR "CrashReporterErrorText"
|
2008-01-22 16:03:58 -08:00
|
|
|
#define ST_CRASHREPORTERPRODUCTERROR "CrashReporterProductErrorText2"
|
2008-01-21 17:07:20 -08:00
|
|
|
#define ST_CRASHREPORTERHEADER "CrashReporterSorry"
|
2008-01-22 16:03:58 -08:00
|
|
|
#define ST_CRASHREPORTERDESCRIPTION "CrashReporterDescriptionText2"
|
2007-07-24 18:06:09 -07:00
|
|
|
#define ST_CRASHREPORTERDEFAULT "CrashReporterDefault"
|
2008-01-21 17:07:20 -08:00
|
|
|
#define ST_VIEWREPORT "Details"
|
|
|
|
#define ST_VIEWREPORTTITLE "ViewReportTitle"
|
|
|
|
#define ST_COMMENTGRAYTEXT "CommentGrayText"
|
2007-07-24 18:06:09 -07:00
|
|
|
#define ST_EXTRAREPORTINFO "ExtraReportInfo"
|
2008-01-21 17:07:20 -08:00
|
|
|
#define ST_CHECKSUBMIT "CheckSendReport"
|
|
|
|
#define ST_CHECKURL "CheckIncludeURL"
|
|
|
|
#define ST_CHECKEMAIL "CheckSendEmail"
|
|
|
|
#define ST_EMAILGRAYTEXT "EmailGrayText"
|
2008-03-07 14:17:17 -08:00
|
|
|
#define ST_REPORTPRESUBMIT "ReportPreSubmit2"
|
|
|
|
#define ST_REPORTDURINGSUBMIT "ReportDuringSubmit2"
|
2008-01-21 17:07:20 -08:00
|
|
|
#define ST_REPORTSUBMITSUCCESS "ReportSubmitSuccess"
|
|
|
|
#define ST_SUBMITFAILED "ReportSubmitFailed"
|
2008-03-07 14:17:17 -08:00
|
|
|
#define ST_QUIT "Quit2"
|
2007-07-24 18:06:09 -07:00
|
|
|
#define ST_RESTART "Restart"
|
2008-01-21 17:07:20 -08:00
|
|
|
#define ST_OK "Ok"
|
|
|
|
#define ST_CLOSE "Close"
|
2007-07-24 18:06:09 -07:00
|
|
|
|
|
|
|
#define ST_ERROR_BADARGUMENTS "ErrorBadArguments"
|
|
|
|
#define ST_ERROR_EXTRAFILEEXISTS "ErrorExtraFileExists"
|
|
|
|
#define ST_ERROR_EXTRAFILEREAD "ErrorExtraFileRead"
|
|
|
|
#define ST_ERROR_EXTRAFILEMOVE "ErrorExtraFileMove"
|
|
|
|
#define ST_ERROR_DUMPFILEEXISTS "ErrorDumpFileExists"
|
|
|
|
#define ST_ERROR_DUMPFILEMOVE "ErrorDumpFileMove"
|
|
|
|
#define ST_ERROR_NOPRODUCTNAME "ErrorNoProductName"
|
|
|
|
#define ST_ERROR_NOSERVERURL "ErrorNoServerURL"
|
|
|
|
#define ST_ERROR_NOSETTINGSPATH "ErrorNoSettingsPath"
|
|
|
|
#define ST_ERROR_CREATEDUMPDIR "ErrorCreateDumpDir"
|
2008-01-25 12:51:05 -08:00
|
|
|
#define ST_ERROR_ENDOFLIFE "ErrorEndOfLife"
|
2007-07-24 18:06:03 -07:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// implemented in crashreporter.cpp
|
|
|
|
//=============================================================================
|
|
|
|
|
2007-07-24 18:06:08 -07:00
|
|
|
namespace CrashReporter {
|
|
|
|
extern StringTable gStrings;
|
|
|
|
extern std::string gSettingsPath;
|
|
|
|
extern int gArgc;
|
|
|
|
extern char** gArgv;
|
2007-07-24 18:06:03 -07:00
|
|
|
|
2007-07-24 18:06:09 -07:00
|
|
|
void UIError(const std::string& message);
|
|
|
|
|
2007-07-24 18:06:08 -07:00
|
|
|
// The UI finished sending the report
|
|
|
|
bool SendCompleted(bool success, const std::string& serverResponse);
|
|
|
|
|
|
|
|
bool ReadStrings(std::istream& in,
|
|
|
|
StringTable& strings,
|
|
|
|
bool unescape);
|
|
|
|
bool ReadStringsFromFile(const std::string& path,
|
|
|
|
StringTable& strings,
|
|
|
|
bool unescape);
|
|
|
|
bool WriteStrings(std::ostream& out,
|
|
|
|
const std::string& header,
|
|
|
|
StringTable& strings,
|
|
|
|
bool escape);
|
|
|
|
bool WriteStringsToFile(const std::string& path,
|
|
|
|
const std::string& header,
|
|
|
|
StringTable& strings,
|
|
|
|
bool escape);
|
2007-11-09 08:46:34 -08:00
|
|
|
void LogMessage(const std::string& message);
|
2008-01-25 03:24:02 -08:00
|
|
|
void DeleteDump();
|
2007-07-24 18:06:08 -07:00
|
|
|
}
|
2007-07-24 18:06:03 -07:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
// implemented in the platform-specific files
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
bool UIInit();
|
|
|
|
void UIShutdown();
|
|
|
|
|
|
|
|
// Run the UI for when the app was launched without a dump file
|
|
|
|
void UIShowDefaultUI();
|
|
|
|
|
|
|
|
// Run the UI for when the app was launched with a dump file
|
2008-01-25 03:24:02 -08:00
|
|
|
// Return true if the user sent (or tried to send) the crash report,
|
|
|
|
// false if they chose not to, and it should be deleted.
|
|
|
|
bool UIShowCrashUI(const std::string& dumpfile,
|
2007-07-24 18:06:03 -07:00
|
|
|
const StringTable& queryParameters,
|
2007-07-24 18:06:05 -07:00
|
|
|
const std::string& sendURL,
|
|
|
|
const std::vector<std::string>& restartArgs);
|
2007-07-24 18:06:03 -07:00
|
|
|
|
2007-07-24 18:06:09 -07:00
|
|
|
void UIError_impl(const std::string& message);
|
2007-07-24 18:06:03 -07:00
|
|
|
|
|
|
|
bool UIGetIniPath(std::string& path);
|
|
|
|
bool UIGetSettingsPath(const std::string& vendor,
|
|
|
|
const std::string& product,
|
|
|
|
std::string& settingsPath);
|
|
|
|
bool UIEnsurePathExists(const std::string& path);
|
2007-07-24 18:06:09 -07:00
|
|
|
bool UIFileExists(const std::string& path);
|
2007-07-24 18:06:03 -07:00
|
|
|
bool UIMoveFile(const std::string& oldfile, const std::string& newfile);
|
|
|
|
bool UIDeleteFile(const std::string& oldfile);
|
2007-07-24 18:06:10 -07:00
|
|
|
std::ifstream* UIOpenRead(const std::string& filename);
|
2007-11-09 08:46:34 -08:00
|
|
|
std::ofstream* UIOpenWrite(const std::string& filename, bool append=false);
|
2007-07-24 18:06:03 -07:00
|
|
|
|
2007-07-24 18:06:05 -07:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma warning( pop )
|
|
|
|
#endif
|
|
|
|
|
2007-07-24 18:06:03 -07:00
|
|
|
#endif
|