toolkit/crashreporter/client/crashreporter.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/crashreporter/client/crashreporter.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,150 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef CRASHREPORTER_H__
     1.9 +#define CRASHREPORTER_H__
    1.10 +
    1.11 +#ifdef _MSC_VER
    1.12 +# pragma warning( push )
    1.13 +// Disable exception handler warnings.
    1.14 +# pragma warning( disable : 4530 )
    1.15 +#endif
    1.16 +
    1.17 +#include <string>
    1.18 +#include <map>
    1.19 +#include <vector>
    1.20 +#include <stdlib.h>
    1.21 +#include <stdio.h>
    1.22 +#include <iostream>
    1.23 +#include <fstream>
    1.24 +
    1.25 +#define MAX_COMMENT_LENGTH   500
    1.26 +
    1.27 +#if defined(XP_WIN32)
    1.28 +
    1.29 +#include <windows.h>
    1.30 +
    1.31 +#define UI_SNPRINTF _snprintf
    1.32 +#define UI_DIR_SEPARATOR "\\"
    1.33 +
    1.34 +std::string WideToUTF8(const std::wstring& wide, bool* success = 0);
    1.35 +
    1.36 +#else
    1.37 +
    1.38 +#define UI_SNPRINTF snprintf
    1.39 +#define UI_DIR_SEPARATOR "/"
    1.40 +
    1.41 +#endif
    1.42 +
    1.43 +typedef std::map<std::string, std::string> StringTable;
    1.44 +
    1.45 +#define ST_CRASHREPORTERTITLE        "CrashReporterTitle"
    1.46 +#define ST_CRASHREPORTERVENDORTITLE  "CrashReporterVendorTitle"
    1.47 +#define ST_CRASHREPORTERERROR        "CrashReporterErrorText"
    1.48 +#define ST_CRASHREPORTERPRODUCTERROR "CrashReporterProductErrorText2"
    1.49 +#define ST_CRASHREPORTERHEADER       "CrashReporterSorry"
    1.50 +#define ST_CRASHREPORTERDESCRIPTION  "CrashReporterDescriptionText2"
    1.51 +#define ST_CRASHREPORTERDEFAULT      "CrashReporterDefault"
    1.52 +#define ST_VIEWREPORT                "Details"
    1.53 +#define ST_VIEWREPORTTITLE           "ViewReportTitle"
    1.54 +#define ST_COMMENTGRAYTEXT           "CommentGrayText"
    1.55 +#define ST_EXTRAREPORTINFO           "ExtraReportInfo"
    1.56 +#define ST_CHECKSUBMIT               "CheckSendReport"
    1.57 +#define ST_CHECKURL                  "CheckIncludeURL"
    1.58 +#define ST_CHECKEMAIL                "CheckAllowEmail"
    1.59 +#define ST_EMAILGRAYTEXT             "EmailGrayText"
    1.60 +#define ST_REPORTPRESUBMIT           "ReportPreSubmit2"
    1.61 +#define ST_REPORTDURINGSUBMIT        "ReportDuringSubmit2"
    1.62 +#define ST_REPORTSUBMITSUCCESS       "ReportSubmitSuccess"
    1.63 +#define ST_SUBMITFAILED              "ReportSubmitFailed"
    1.64 +#define ST_QUIT                      "Quit2"
    1.65 +#define ST_RESTART                   "Restart"
    1.66 +#define ST_OK                        "Ok"
    1.67 +#define ST_CLOSE                     "Close"
    1.68 +
    1.69 +#define ST_ERROR_BADARGUMENTS        "ErrorBadArguments"
    1.70 +#define ST_ERROR_EXTRAFILEEXISTS     "ErrorExtraFileExists"
    1.71 +#define ST_ERROR_EXTRAFILEREAD       "ErrorExtraFileRead"
    1.72 +#define ST_ERROR_EXTRAFILEMOVE       "ErrorExtraFileMove"
    1.73 +#define ST_ERROR_DUMPFILEEXISTS      "ErrorDumpFileExists"
    1.74 +#define ST_ERROR_DUMPFILEMOVE        "ErrorDumpFileMove"
    1.75 +#define ST_ERROR_NOPRODUCTNAME       "ErrorNoProductName"
    1.76 +#define ST_ERROR_NOSERVERURL         "ErrorNoServerURL"
    1.77 +#define ST_ERROR_NOSETTINGSPATH      "ErrorNoSettingsPath"
    1.78 +#define ST_ERROR_CREATEDUMPDIR       "ErrorCreateDumpDir"
    1.79 +#define ST_ERROR_ENDOFLIFE           "ErrorEndOfLife"
    1.80 +
    1.81 +//=============================================================================
    1.82 +// implemented in crashreporter.cpp
    1.83 +//=============================================================================
    1.84 +
    1.85 +namespace CrashReporter {
    1.86 +  extern StringTable  gStrings;
    1.87 +  extern std::string  gSettingsPath;
    1.88 +  extern int          gArgc;
    1.89 +  extern char**       gArgv;
    1.90 +
    1.91 +  void UIError(const std::string& message);
    1.92 +
    1.93 +  // The UI finished sending the report
    1.94 +  void SendCompleted(bool success, const std::string& serverResponse);
    1.95 +
    1.96 +  bool ReadStrings(std::istream& in,
    1.97 +                   StringTable& strings,
    1.98 +                   bool unescape);
    1.99 +  bool ReadStringsFromFile(const std::string& path,
   1.100 +                           StringTable& strings,
   1.101 +                           bool unescape);
   1.102 +  bool WriteStrings(std::ostream& out,
   1.103 +                    const std::string& header,
   1.104 +                    StringTable& strings,
   1.105 +                    bool escape);
   1.106 +  bool WriteStringsToFile(const std::string& path,
   1.107 +                          const std::string& header,
   1.108 +                          StringTable& strings,
   1.109 +                          bool escape);
   1.110 +  void LogMessage(const std::string& message);
   1.111 +  void DeleteDump();
   1.112 +  bool ShouldEnableSending();
   1.113 +
   1.114 +  static const unsigned int kSaveCount = 10;
   1.115 +}
   1.116 +
   1.117 +//=============================================================================
   1.118 +// implemented in the platform-specific files
   1.119 +//=============================================================================
   1.120 +
   1.121 +bool UIInit();
   1.122 +void UIShutdown();
   1.123 +
   1.124 +// Run the UI for when the app was launched without a dump file
   1.125 +void UIShowDefaultUI();
   1.126 +
   1.127 +// Run the UI for when the app was launched with a dump file
   1.128 +// Return true if the user sent (or tried to send) the crash report,
   1.129 +// false if they chose not to, and it should be deleted.
   1.130 +bool UIShowCrashUI(const std::string& dumpfile,
   1.131 +                   const StringTable& queryParameters,
   1.132 +                   const std::string& sendURL,
   1.133 +                   const std::vector<std::string>& restartArgs);
   1.134 +
   1.135 +void UIError_impl(const std::string& message);
   1.136 +
   1.137 +bool UIGetIniPath(std::string& path);
   1.138 +bool UIGetSettingsPath(const std::string& vendor,
   1.139 +                       const std::string& product,
   1.140 +                       std::string& settingsPath);
   1.141 +bool UIEnsurePathExists(const std::string& path);
   1.142 +bool UIFileExists(const std::string& path);
   1.143 +bool UIMoveFile(const std::string& oldfile, const std::string& newfile);
   1.144 +bool UIDeleteFile(const std::string& oldfile);
   1.145 +std::ifstream* UIOpenRead(const std::string& filename);
   1.146 +std::ofstream* UIOpenWrite(const std::string& filename, bool append=false);
   1.147 +void UIPruneSavedDumps(const std::string& directory);
   1.148 +
   1.149 +#ifdef _MSC_VER
   1.150 +# pragma warning( pop )
   1.151 +#endif
   1.152 +
   1.153 +#endif

mercurial