Merge with feature-crashreport
This commit is contained in:
commit
ac7dcc4ed0
9 changed files with 277 additions and 396 deletions
|
@ -21,28 +21,38 @@
|
||||||
|
|
||||||
namespace NLMISC {
|
namespace NLMISC {
|
||||||
|
|
||||||
enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError };
|
#if FINAL_VERSION
|
||||||
|
#define NL_REPORT_SYNCHRONOUS false
|
||||||
|
#define NL_REPORT_DEFAULT NLMISC::ReportAbort
|
||||||
|
#else
|
||||||
|
#define NL_REPORT_SYNCHRONOUS true
|
||||||
|
#define NL_REPORT_DEFAULT NLMISC::ReportBreak
|
||||||
|
#endif
|
||||||
|
|
||||||
/** Display a custom message box.
|
enum TReportResult
|
||||||
|
{
|
||||||
|
// See also crash_report_widget.h EReturnValue
|
||||||
|
ReportAlwaysIgnore = 21,
|
||||||
|
ReportIgnore = 22,
|
||||||
|
ReportAbort = 23,
|
||||||
|
ReportBreak = 24
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Display a crash report
|
||||||
*
|
*
|
||||||
* \param title set the title of the report. If empty, it'll display "NeL Crash Report" or the default title set by setReportWindowTitle.
|
* \param title set the title of the report. If empty, it'll display "NeL report"
|
||||||
* \param header message displayed before the edit text box. If empty, it displays the default message.
|
* \param subject extended title of the report
|
||||||
* \param body message displayed in the edit text box. This string will be sent by email.
|
* \param body message displayed in the edit text box. This string will be sent to the crash report tool
|
||||||
* \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior
|
* \param attachment binary file to attach. This is a filename
|
||||||
|
* \param synchronous use system() and wait for the crash tool exit code, passes -dev flag; otherwise return defaultResult immediately
|
||||||
|
* \param sendReport hide 'dont send' button, or auto enable 'send report' checkbox
|
||||||
*
|
*
|
||||||
*
|
* \return the button clicked or defaultResult
|
||||||
*
|
|
||||||
* \return the button clicked or error
|
|
||||||
*/
|
*/
|
||||||
TReportResult report(const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const std::string &attachedFile = "");
|
TReportResult report(const std::string &title, const std::string &subject, const std::string &body, const std::string &attachment, bool synchronous, bool sendReport, TReportResult defaultResult);
|
||||||
|
|
||||||
/// Set the Url of the web service used to post crash reports to
|
/// Set the Url of the web service used to post crash reports to. String is copied
|
||||||
void setReportPostUrl(const std::string &postUrl);
|
void setReportPostUrl(const char *postUrl);
|
||||||
|
|
||||||
/// DEPRECATED
|
|
||||||
/** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail);
|
|
||||||
*/
|
|
||||||
void setReportEmailFunction(void *emailFunction);
|
|
||||||
|
|
||||||
} // NLMISC
|
} // NLMISC
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,14 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// contains all debug features
|
// contains all debug features
|
||||||
#include "nel/misc/debug.h"
|
#include <nel/misc/debug.h>
|
||||||
|
#include <nel/misc/report.h>
|
||||||
|
|
||||||
using namespace NLMISC;
|
void repeatederror()
|
||||||
|
{
|
||||||
|
// hit always ignore to surpress this error for the duration of the program
|
||||||
|
nlassert(false && "hit always ignore");
|
||||||
|
}
|
||||||
|
|
||||||
int main(int /* argc */, char ** /* argv */)
|
int main(int /* argc */, char ** /* argv */)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +41,11 @@ int main (int /* argc */, char ** /* argv */)
|
||||||
// in release mode, this function does nothing by default. you have to add a displayer
|
// in release mode, this function does nothing by default. you have to add a displayer
|
||||||
// manually, or put true in the parameter to say to the function that you want it to
|
// manually, or put true in the parameter to say to the function that you want it to
|
||||||
// add the default displayers
|
// add the default displayers
|
||||||
createDebug ();
|
NLMISC::createDebug();
|
||||||
|
|
||||||
|
// enable the crash report tool
|
||||||
|
NLMISC::INelContext::getInstance().setWindowedApplication(true);
|
||||||
|
NLMISC::setReportPostUrl("http://ryzomcore.org/crash_report/");
|
||||||
|
|
||||||
// display debug information, that will be skipped in release mode.
|
// display debug information, that will be skipped in release mode.
|
||||||
nldebug("nldebug() %d", 1);
|
nldebug("nldebug() %d", 1);
|
||||||
|
@ -63,12 +72,16 @@ int main (int /* argc */, char ** /* argv */)
|
||||||
{
|
{
|
||||||
nlerror("nlerror() %d", 4);
|
nlerror("nlerror() %d", 4);
|
||||||
}
|
}
|
||||||
catch(const EFatalError &)
|
catch (const NLMISC::EFatalError &)
|
||||||
{
|
{
|
||||||
// just continue...
|
// just continue...
|
||||||
nlinfo("nlerror() generated an EFatalError exception, just ignore it");
|
nlinfo("nlerror() generated an EFatalError exception, just ignore it");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// keep repeating the same error
|
||||||
|
for (int i = 0; i < 32; ++i)
|
||||||
|
repeatederror();
|
||||||
|
|
||||||
printf("\nPress <return> to exit\n");
|
printf("\nPress <return> to exit\n");
|
||||||
getchar();
|
getchar();
|
||||||
|
|
||||||
|
|
|
@ -548,8 +548,8 @@ public:
|
||||||
{
|
{
|
||||||
// yoyo: allow only to send the crash report once. Because users usually click ignore,
|
// yoyo: allow only to send the crash report once. Because users usually click ignore,
|
||||||
// which create noise into list of bugs (once a player crash, it will surely continues to do it).
|
// which create noise into list of bugs (once a player crash, it will surely continues to do it).
|
||||||
bool i = false;
|
report(progname + shortExc, subject, _Reason, NL_CRASH_DUMP_FILE, true, !isCrashAlreadyReported(), ReportAbort);
|
||||||
report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE);
|
// TODO: Does this need to be synchronous? Why does this not handle the report result?
|
||||||
|
|
||||||
// no more sent mail for crash
|
// no more sent mail for crash
|
||||||
setCrashAlreadyReported(true);
|
setCrashAlreadyReported(true);
|
||||||
|
|
|
@ -680,36 +680,32 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m
|
||||||
// which create noise into list of bugs (once a player crash, it will surely continues to do it).
|
// which create noise into list of bugs (once a player crash, it will surely continues to do it).
|
||||||
std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE;
|
std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE;
|
||||||
|
|
||||||
if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, filename.c_str()))
|
TReportResult reportResult = report(args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)),
|
||||||
|
subject, body, filename, NL_REPORT_SYNCHRONOUS, !isCrashAlreadyReported(), NL_REPORT_DEFAULT);
|
||||||
|
|
||||||
|
switch (reportResult)
|
||||||
{
|
{
|
||||||
|
case ReportAlwaysIgnore:
|
||||||
|
IgnoreNextTime = true;
|
||||||
|
break;
|
||||||
|
case ReportBreak:
|
||||||
INelContext::getInstance().setDebugNeedAssert(true);
|
INelContext::getInstance().setDebugNeedAssert(true);
|
||||||
|
break;
|
||||||
|
case ReportAbort:
|
||||||
|
# ifdef NL_OS_WINDOWS
|
||||||
|
# ifndef NL_COMP_MINGW
|
||||||
|
// disable the Windows popup telling that the application aborted and disable the dr watson report.
|
||||||
|
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// no more sent mail for crash
|
// no more sent mail for crash
|
||||||
setCrashAlreadyReported(true);
|
setCrashAlreadyReported(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* // Check the envvar NEL_IGNORE_ASSERT
|
|
||||||
if (getenv ("NEL_IGNORE_ASSERT") == NULL)
|
|
||||||
{
|
|
||||||
// Ask the user to continue, debug or ignore
|
|
||||||
int result = MessageBox (NULL, ss2.str().c_str (), logTypeToString(args.LogType, true), MB_ABORTRETRYIGNORE | MB_ICONSTOP);
|
|
||||||
if (result == IDABORT)
|
|
||||||
{
|
|
||||||
// Exit the program now
|
|
||||||
exit (EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
else if (result == IDRETRY)
|
|
||||||
{
|
|
||||||
// Give the debugger a try
|
|
||||||
DebugNeedAssert = true;
|
|
||||||
}
|
|
||||||
else if (result == IDIGNORE)
|
|
||||||
{
|
|
||||||
// Continue, do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/ }
|
|
||||||
|
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "stdmisc.h"
|
#include "stdmisc.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "nel/misc/common.h"
|
#include "nel/misc/common.h"
|
||||||
|
@ -23,359 +24,198 @@
|
||||||
|
|
||||||
#include "nel/misc/report.h"
|
#include "nel/misc/report.h"
|
||||||
#include "nel/misc/path.h"
|
#include "nel/misc/path.h"
|
||||||
|
#include "nel/misc/file.h"
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
# include <windowsx.h>
|
|
||||||
# include <winuser.h>
|
|
||||||
#endif // NL_OS_WINDOWS
|
|
||||||
|
|
||||||
#define NL_NO_DEBUG_FILES 1
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#ifdef DEBUG_NEW
|
#ifdef DEBUG_NEW
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NL_REPORT_POST_URL_ENVVAR "NL_REPORT_POST_URL"
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
#define NL_CRASH_REPORT_TOOL "crash_report.exe"
|
||||||
|
#else
|
||||||
|
#define NL_CRASH_REPORT_TOOL "crash_report"
|
||||||
|
#endif
|
||||||
|
#define NL_DEBUG_REPORT 0
|
||||||
|
// Set to 1 if you want command line report tool
|
||||||
|
#define NL_REPORT_CONSOLE 0
|
||||||
|
// Set to 1 if you want command line report tool even when the debugger is present
|
||||||
|
#define NL_REPORT_CONSOLE_DEBUGGER 1
|
||||||
|
|
||||||
namespace NLMISC
|
namespace NLMISC
|
||||||
{
|
{
|
||||||
|
|
||||||
void setReportEmailFunction(void *emailFunction)
|
void setReportPostUrl(const char *postUrl)
|
||||||
{
|
{
|
||||||
// DEPRECATED
|
#if NL_DEBUG_REPORT
|
||||||
// no-op
|
if (INelContext::isContextInitialised())
|
||||||
|
nldebug("Set report post url to '%s'", postUrl);
|
||||||
|
#endif
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
SetEnvironmentVariableA(NL_REPORT_POST_URL_ENVVAR, postUrl);
|
||||||
|
#else
|
||||||
|
setenv(NL_REPORT_POST_URL_ENVVAR, postUrl, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contents of crash report
|
inline const char *getReportPostURL()
|
||||||
static string ReportBody;
|
|
||||||
// Host url for crash report
|
|
||||||
static std::string ReportPostUrl = "";
|
|
||||||
// Title for the crash report window
|
|
||||||
static std::string ReportWindowTitle = "";
|
|
||||||
|
|
||||||
void setReportPostUrl(const std::string &postUrl)
|
|
||||||
{
|
{
|
||||||
ReportPostUrl = postUrl;
|
#ifdef NL_OS_WINDOWS
|
||||||
|
static char buf[512];
|
||||||
|
buf[0] = '\0';
|
||||||
|
int res = GetEnvironmentVariableA(NL_REPORT_POST_URL_ENVVAR, buf, sizeof(buf));
|
||||||
|
if (res <= 0 || res > 511) return NULL;
|
||||||
|
if (buf[0] == '\0') return NULL;
|
||||||
|
return buf;
|
||||||
|
#else
|
||||||
|
char *res = getenv(NL_REPORT_POST_URL_ENVVAR);
|
||||||
|
if (res == NULL || res[0] == '\0') return NULL;
|
||||||
|
return res;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Launch the crash report application
|
TReportResult report(const std::string &title, const std::string &subject, const std::string &body, const std::string &attachment, bool synchronous, bool sendReport, TReportResult defaultResult)
|
||||||
static void doSendReport()
|
|
||||||
{
|
{
|
||||||
std::string filename;
|
std::string reportPath;
|
||||||
|
if (!body.empty())
|
||||||
filename = /*getLogDirectory() + */ "report_"; // FIXME: Should use log directory
|
|
||||||
filename += NLMISC::toString( int( time( NULL ) ) );
|
|
||||||
filename += ".txt";
|
|
||||||
|
|
||||||
std::stringstream params;
|
|
||||||
params << "-log ";
|
|
||||||
params << filename; // FIXME: Escape the filepath with quotes
|
|
||||||
if (!ReportPostUrl.empty())
|
|
||||||
{
|
{
|
||||||
params << " -host ";
|
std::stringstream reportFile;
|
||||||
params << ReportPostUrl;
|
reportFile << getLogDirectory();
|
||||||
}
|
reportFile << "nel_report_";
|
||||||
if (!ReportWindowTitle.empty())
|
reportFile << (int)time(NULL);
|
||||||
{
|
reportFile << ".log";
|
||||||
params << " -title ";
|
reportPath = CFile::findNewFile(reportFile.str());
|
||||||
params << ReportWindowTitle; // FIXME: Escape the title with quotes and test
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ofstream f;
|
std::ofstream f;
|
||||||
f.open( filename.c_str() );
|
f.open(reportPath.c_str());
|
||||||
if (!f.good())
|
if (!f.good())
|
||||||
return;
|
{
|
||||||
|
#if NL_DEBUG_REPORT
|
||||||
f << ReportBody;
|
if (INelContext::isContextInitialised())
|
||||||
|
nldebug("Failed to write report log to '%s'", reportPath.c_str());
|
||||||
|
#endif
|
||||||
|
reportPath.clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
f << body;
|
||||||
f.close();
|
f.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
if (INelContext::isContextInitialised()
|
||||||
NLMISC::launchProgram( "crash_report.exe", params.str() );
|
&& INelContext::getInstance().isWindowedApplication()
|
||||||
|
&& CFile::isExists(NL_CRASH_REPORT_TOOL))
|
||||||
|
{
|
||||||
|
std::stringstream params;
|
||||||
|
params << NL_CRASH_REPORT_TOOL;
|
||||||
|
|
||||||
|
if (!reportPath.empty())
|
||||||
|
params << " -log \"" << reportPath << "\"";
|
||||||
|
|
||||||
|
if (!subject.empty())
|
||||||
|
params << " -attachment \"" << attachment << "\"";
|
||||||
|
|
||||||
|
if (!title.empty())
|
||||||
|
params << " -title \"" << title << "\"";
|
||||||
|
|
||||||
|
if (!subject.empty())
|
||||||
|
params << " -subject \"" << subject << "\"";
|
||||||
|
|
||||||
|
const char *reportPostUrl = getReportPostURL();
|
||||||
|
if (reportPostUrl)
|
||||||
|
params << " -host \"" << reportPostUrl << "\"";
|
||||||
|
|
||||||
|
if (synchronous)
|
||||||
|
params << " -dev";
|
||||||
|
|
||||||
|
if (sendReport)
|
||||||
|
params << " -sendreport";
|
||||||
|
|
||||||
|
std::string paramsStr = params.str();
|
||||||
|
|
||||||
|
if (synchronous)
|
||||||
|
{
|
||||||
|
TReportResult result = (TReportResult)::system(paramsStr.c_str());
|
||||||
|
if (result != ReportAlwaysIgnore
|
||||||
|
&& result != ReportIgnore
|
||||||
|
&& result != ReportAbort
|
||||||
|
&& result != ReportBreak)
|
||||||
|
{
|
||||||
|
#if NL_DEBUG_REPORT
|
||||||
|
if (INelContext::isContextInitialised())
|
||||||
|
nldebug("Return default result, invalid return code %i", (int)result);
|
||||||
|
#endif
|
||||||
|
return defaultResult;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NLMISC::launchProgram(NL_CRASH_REPORT_TOOL, paramsStr); // FIXME: Don't use this function, it uses logging, etc, so may loop infinitely!
|
||||||
|
return defaultResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if NL_DEBUG_REPORT
|
||||||
|
if (INelContext::isContextInitialised() && !CFile::isExists(NL_CRASH_REPORT_TOOL))
|
||||||
|
nldebug("Crash report tool '%s' does not exist", NL_CRASH_REPORT_TOOL);
|
||||||
|
#endif
|
||||||
|
#if defined(NL_OS_WINDOWS) && !FINAL_VERSION && !NL_REPORT_CONSOLE_DEBUGGER
|
||||||
|
if (IsDebuggerPresent())
|
||||||
|
{
|
||||||
|
return defaultResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if (synchronous)
|
||||||
|
{
|
||||||
|
#if NL_REPORT_CONSOLE
|
||||||
|
// An interactive console based report
|
||||||
|
printf("\n");
|
||||||
|
if (!title.empty())
|
||||||
|
printf("%s\n", title.c_str());
|
||||||
|
else
|
||||||
|
printf("NeL report\n");
|
||||||
|
printf("\n");
|
||||||
|
if (!subject.empty())
|
||||||
|
printf("\tsubject: '%s'\n", subject.c_str());
|
||||||
|
if (!body.empty())
|
||||||
|
printf("\tbody: '%s'\n", reportPath.c_str());
|
||||||
|
if (!attachment.empty())
|
||||||
|
printf("\tattachment: '%s'\n", attachment.c_str());
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
printf("\n");
|
||||||
|
printf("Always Ignore (S), Ignore (I), Abort (A), Break (B)?\n"); // S for Surpress
|
||||||
|
printf("> ");
|
||||||
|
int c = getchar();
|
||||||
|
getchar();
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'S':
|
||||||
|
case 's':
|
||||||
|
return ReportAlwaysIgnore;
|
||||||
|
case 'I':
|
||||||
|
case 'i':
|
||||||
|
return ReportIgnore;
|
||||||
|
case 'A':
|
||||||
|
case 'a':
|
||||||
|
return ReportAbort;
|
||||||
|
case 'B':
|
||||||
|
case 'b':
|
||||||
|
return ReportBreak;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
NLMISC::launchProgram( "crash_report", params.str() );
|
return defaultResult;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Added because NLSMIC::launcProgram needs time to launch
|
|
||||||
nlSleep( 2 * 1000 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(FINAL_VERSION) || !defined(NL_OS_WINDOWS)
|
|
||||||
|
|
||||||
// For FINAL_VERSION, simply launch the crash report and exit the application
|
|
||||||
TReportResult report(const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile)
|
|
||||||
{
|
|
||||||
ReportWindowTitle = title.empty() ? "Nel Crash Report" : title;
|
|
||||||
ReportBody = addSlashR(body);
|
|
||||||
|
|
||||||
doSendReport();
|
|
||||||
|
|
||||||
# if defined(FINAL_VERSION) // TODO: This behaviour is used in the old report code when Quitting the application is the default crash report behaviour. Needs testing.
|
|
||||||
# ifdef NL_OS_WINDOWS
|
|
||||||
# ifndef NL_COMP_MINGW
|
|
||||||
// disable the Windows popup telling that the application aborted and disable the dr watson report.
|
|
||||||
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
// quit without calling atexit or static object dtors.
|
|
||||||
abort();
|
|
||||||
# endif
|
|
||||||
|
|
||||||
return ReportQuit;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Windows specific version for DEV builds, first shows a dialog box for debugging
|
|
||||||
|
|
||||||
static HWND sendReport=NULL;
|
|
||||||
#define DELETE_OBJECT(a) if((a)!=NULL) { DeleteObject (a); a = NULL; }
|
|
||||||
|
|
||||||
static HWND checkIgnore = NULL;
|
|
||||||
static HWND debug = NULL;
|
|
||||||
static HWND ignore = NULL;
|
|
||||||
static HWND quit = NULL;
|
|
||||||
static HWND dialog = NULL;
|
|
||||||
|
|
||||||
static bool NeedExit;
|
|
||||||
static TReportResult Result;
|
|
||||||
static bool IgnoreNextTime;
|
|
||||||
static bool CanSendMailReport = false;
|
|
||||||
|
|
||||||
static bool DebugDefaultBehavior, QuitDefaultBehavior;
|
|
||||||
|
|
||||||
static void maybeSendReport()
|
|
||||||
{
|
|
||||||
if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED)
|
|
||||||
{
|
|
||||||
doSendReport();
|
|
||||||
#ifndef NL_NO_DEBUG_FILES
|
|
||||||
CFile::createEmptyFile(getLogDirectory() + "report_sent");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifndef NL_NO_DEBUG_FILES
|
return defaultResult;
|
||||||
CFile::createEmptyFile(getLogDirectory() + "report_refused");
|
|
||||||
#endif
|
|
||||||
- }
|
|
||||||
}
|
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
//MSGFILTER *pmf;
|
|
||||||
|
|
||||||
if (message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED)
|
|
||||||
{
|
|
||||||
if ((HWND) lParam == checkIgnore)
|
|
||||||
{
|
|
||||||
IgnoreNextTime = !IgnoreNextTime;
|
|
||||||
}
|
|
||||||
else if ((HWND) lParam == debug)
|
|
||||||
{
|
|
||||||
maybeSendReport();
|
|
||||||
NeedExit = true;
|
|
||||||
Result = ReportDebug;
|
|
||||||
if (DebugDefaultBehavior)
|
|
||||||
{
|
|
||||||
NLMISC_BREAKPOINT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((HWND) lParam == ignore)
|
|
||||||
{
|
|
||||||
maybeSendReport();
|
|
||||||
NeedExit = true;
|
|
||||||
Result = ReportIgnore;
|
|
||||||
}
|
|
||||||
else if ((HWND) lParam == quit)
|
|
||||||
{
|
|
||||||
maybeSendReport();
|
|
||||||
NeedExit = true;
|
|
||||||
Result = ReportQuit;
|
|
||||||
|
|
||||||
if (QuitDefaultBehavior)
|
|
||||||
{
|
|
||||||
// ace: we cannot call exit() because it's call the static object dtor and can crash the application
|
|
||||||
// if the dtor call order is not good.
|
|
||||||
//exit(EXIT_SUCCESS);
|
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
#ifndef NL_COMP_MINGW
|
|
||||||
// disable the Windows popup telling that the application aborted and disable the dr watson report.
|
|
||||||
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
// quit without calling atexit or static object dtors.
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (message == WM_CHAR)
|
|
||||||
{
|
|
||||||
if (wParam == 27)
|
|
||||||
{
|
|
||||||
// ESC -> ignore
|
|
||||||
maybeSendReport();
|
|
||||||
NeedExit = true;
|
|
||||||
Result = ReportIgnore;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
TReportResult report(const std::string &title, const std::string &header, const std::string &subject, const std::string &body, bool enableCheckIgnore, uint debugButton, bool ignoreButton, sint quitButton, bool sendReportButton, bool &ignoreNextTime, const string &attachedFile)
|
|
||||||
{
|
|
||||||
// register the window
|
|
||||||
static bool AlreadyRegister = false;
|
|
||||||
if (!AlreadyRegister)
|
|
||||||
{
|
|
||||||
WNDCLASSW wc;
|
|
||||||
memset (&wc,0,sizeof(wc));
|
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
||||||
wc.lpfnWndProc = (WNDPROC)WndProc;
|
|
||||||
wc.cbClsExtra = 0;
|
|
||||||
wc.cbWndExtra = 0;
|
|
||||||
wc.hInstance = GetModuleHandle(NULL);
|
|
||||||
wc.hIcon = NULL;
|
|
||||||
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
|
||||||
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
|
|
||||||
wc.lpszClassName = L"NLReportWindow";
|
|
||||||
wc.lpszMenuName = NULL;
|
|
||||||
if (!RegisterClassW(&wc)) return ReportError;
|
|
||||||
AlreadyRegister = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReportWindowTitle = title.empty() ? "Nel Crash Report" : title;
|
|
||||||
ucstring formatedTitle = ucstring::makeFromUtf8(ReportWindowTitle);
|
|
||||||
|
|
||||||
// create the window
|
|
||||||
dialog = CreateWindowW (L"NLReportWindow", (LPCWSTR)formatedTitle.c_str(), WS_DLGFRAME | WS_CAPTION /*| WS_THICKFRAME*/, CW_USEDEFAULT, CW_USEDEFAULT, 456, 400, NULL, NULL, GetModuleHandle(NULL), NULL);
|
|
||||||
|
|
||||||
// create the font
|
|
||||||
HFONT font = CreateFont (-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
|
|
||||||
|
|
||||||
// create the edit control
|
|
||||||
HWND edit = CreateWindowW (L"EDIT", NULL, WS_BORDER | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_READONLY | ES_LEFT | ES_MULTILINE, 7, 70, 429, 212, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
|
|
||||||
SendMessage (edit, WM_SETFONT, (WPARAM) font, TRUE);
|
|
||||||
|
|
||||||
// set the edit text limit to lot of :)
|
|
||||||
SendMessage (edit, EM_LIMITTEXT, ~0U, 0);
|
|
||||||
|
|
||||||
ReportBody = addSlashR(body);
|
|
||||||
|
|
||||||
// set the message in the edit text
|
|
||||||
SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)ReportBody.c_str());
|
|
||||||
|
|
||||||
if (enableCheckIgnore)
|
|
||||||
{
|
|
||||||
// create the combo box control
|
|
||||||
checkIgnore = CreateWindowW (L"BUTTON", L"Don't display this report again", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_CHECKBOX, 7, 290, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
|
|
||||||
SendMessage (checkIgnore, WM_SETFONT, (WPARAM) font, TRUE);
|
|
||||||
|
|
||||||
if(ignoreNextTime)
|
|
||||||
{
|
|
||||||
SendMessage (checkIgnore, BM_SETCHECK, BST_CHECKED, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the debug button control
|
|
||||||
debug = CreateWindowW (L"BUTTON", L"Debug", WS_CHILD | WS_VISIBLE, 7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
|
|
||||||
SendMessage (debug, WM_SETFONT, (WPARAM) font, TRUE);
|
|
||||||
|
|
||||||
if (debugButton == 0)
|
|
||||||
EnableWindow(debug, FALSE);
|
|
||||||
|
|
||||||
// create the ignore button control
|
|
||||||
ignore = CreateWindowW (L"BUTTON", L"Ignore", WS_CHILD | WS_VISIBLE, 75+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
|
|
||||||
SendMessage (ignore, WM_SETFONT, (WPARAM) font, TRUE);
|
|
||||||
|
|
||||||
if (ignoreButton == 0)
|
|
||||||
EnableWindow(ignore, FALSE);
|
|
||||||
|
|
||||||
// create the quit button control
|
|
||||||
quit = CreateWindowW (L"BUTTON", L"Quit", WS_CHILD | WS_VISIBLE, 75+75+7+7+7, 315, 75, 25, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
|
|
||||||
SendMessage (quit, WM_SETFONT, (WPARAM) font, TRUE);
|
|
||||||
|
|
||||||
if (quitButton == 0)
|
|
||||||
EnableWindow(quit, FALSE);
|
|
||||||
|
|
||||||
// create the debug button control
|
|
||||||
sendReport = CreateWindowW (L"BUTTON", L"Don't send the report", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 7, 315+32, 429, 18, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
|
|
||||||
SendMessage (sendReport, WM_SETFONT, (WPARAM) font, TRUE);
|
|
||||||
|
|
||||||
string formatedHeader;
|
|
||||||
if (header.empty())
|
|
||||||
{
|
|
||||||
formatedHeader = "This application stopped to display this report.";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
formatedHeader = header;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ace don't do that because it s slow to try to send a mail
|
|
||||||
CanSendMailReport = sendReportButton && !ReportPostUrl.empty();
|
|
||||||
|
|
||||||
if (CanSendMailReport)
|
|
||||||
formatedHeader += " Send report will only email the contents of the box below. Please, send it to help us (it could take few minutes to send the email, be patient).";
|
|
||||||
else
|
|
||||||
EnableWindow(sendReport, FALSE);
|
|
||||||
|
|
||||||
ucstring uc = ucstring::makeFromUtf8(formatedHeader);
|
|
||||||
|
|
||||||
// create the label control
|
|
||||||
HWND label = CreateWindowW (L"STATIC", (LPCWSTR)uc.c_str(), WS_CHILD | WS_VISIBLE /*| SS_WHITERECT*/, 7, 7, 429, 51, dialog, (HMENU) NULL, (HINSTANCE) GetWindowLongPtr(dialog, GWLP_HINSTANCE), NULL);
|
|
||||||
SendMessage (label, WM_SETFONT, (WPARAM) font, TRUE);
|
|
||||||
|
|
||||||
|
|
||||||
DebugDefaultBehavior = debugButton==1;
|
|
||||||
QuitDefaultBehavior = quitButton==1;
|
|
||||||
|
|
||||||
IgnoreNextTime = ignoreNextTime;
|
|
||||||
|
|
||||||
// show until the cursor really show :)
|
|
||||||
while (ShowCursor(TRUE) < 0)
|
|
||||||
;
|
|
||||||
|
|
||||||
SetWindowPos (dialog, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
|
||||||
|
|
||||||
SetFocus(dialog);
|
|
||||||
SetForegroundWindow(dialog);
|
|
||||||
|
|
||||||
NeedExit = false;
|
|
||||||
|
|
||||||
while(!NeedExit)
|
|
||||||
{
|
|
||||||
MSG msg;
|
|
||||||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
|
||||||
{
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessageW(&msg);
|
|
||||||
}
|
|
||||||
nlSleep (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the user result
|
|
||||||
ignoreNextTime = IgnoreNextTime;
|
|
||||||
|
|
||||||
ShowWindow(dialog, SW_HIDE);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DELETE_OBJECT(sendReport)
|
|
||||||
DELETE_OBJECT(quit)
|
|
||||||
DELETE_OBJECT(ignore)
|
|
||||||
DELETE_OBJECT(debug)
|
|
||||||
DELETE_OBJECT(checkIgnore)
|
|
||||||
DELETE_OBJECT(edit)
|
|
||||||
DELETE_OBJECT(label)
|
|
||||||
DELETE_OBJECT(dialog)
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
} // NLMISC
|
} // NLMISC
|
||||||
|
|
|
@ -600,7 +600,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName,
|
||||||
|
|
||||||
ListeningPort = servicePort;
|
ListeningPort = servicePort;
|
||||||
|
|
||||||
setReportEmailFunction ((void*)sendEmail);
|
// setReportEmailFunction ((void*)sendEmail);
|
||||||
// setDefaultEmailParams ("gw.nevrax.com", "", "cado@nevrax.com");
|
// setDefaultEmailParams ("gw.nevrax.com", "", "cado@nevrax.com");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,19 @@ public:
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
|
#ifndef WIN32
|
||||||
|
// Workaround to default -style=gtk+ on recent Cinnamon versions
|
||||||
|
char *currentDesktop = getenv("XDG_CURRENT_DESKTOP");
|
||||||
|
if (currentDesktop)
|
||||||
|
{
|
||||||
|
printf("XDG_CURRENT_DESKTOP: %s\n", currentDesktop);
|
||||||
|
if (!strcmp(currentDesktop, "X-Cinnamon"))
|
||||||
|
{
|
||||||
|
setenv("XDG_CURRENT_DESKTOP", "gnome", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QApplication app( argc, argv );
|
QApplication app( argc, argv );
|
||||||
|
|
||||||
std::vector< std::pair< std::string, std::string > > params;
|
std::vector< std::pair< std::string, std::string > > params;
|
||||||
|
|
|
@ -120,12 +120,17 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::
|
||||||
m_ui.gridLayout->addWidget( m_ui.emailEdit, 6, 0, 1, 1 );
|
m_ui.gridLayout->addWidget( m_ui.emailEdit, 6, 0, 1, 1 );
|
||||||
|
|
||||||
connect(cb, SIGNAL(stateChanged(int)), this, SLOT(onSendCBClicked()));
|
connect(cb, SIGNAL(stateChanged(int)), this, SLOT(onSendCBClicked()));
|
||||||
|
if (m_forceSend)
|
||||||
|
cb->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hbl->addStretch();
|
||||||
|
|
||||||
QPushButton *alwaysIgnoreButton = new QPushButton( tr( "Always Ignore" ), this );
|
QPushButton *alwaysIgnoreButton = new QPushButton( tr( "Always Ignore" ), this );
|
||||||
QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), this );
|
QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), this );
|
||||||
QPushButton *abortButton = new QPushButton( tr( "Abort" ), this );
|
QPushButton *abortButton = new QPushButton( tr( "Abort" ), this );
|
||||||
QPushButton *breakButton = new QPushButton(tr("Break"), this);
|
QPushButton *breakButton = new QPushButton(tr("Break"), this);
|
||||||
|
breakButton->setAutoDefault(true);
|
||||||
|
|
||||||
hbl->addWidget( alwaysIgnoreButton );
|
hbl->addWidget( alwaysIgnoreButton );
|
||||||
hbl->addWidget( ignoreButton );
|
hbl->addWidget( ignoreButton );
|
||||||
|
@ -141,19 +146,22 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
hbl->addStretch();
|
||||||
|
|
||||||
// If -host is specified, offer the send function
|
// If -host is specified, offer the send function
|
||||||
if( !m_socket->url().isEmpty() && !m_fileName.isEmpty() )
|
if( !m_socket->url().isEmpty() && !m_fileName.isEmpty() )
|
||||||
{
|
{
|
||||||
QPushButton *sendButton = new QPushButton( tr( "Send report" ), this );
|
|
||||||
connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) );
|
|
||||||
hbl->addWidget( sendButton );
|
|
||||||
|
|
||||||
if (!m_forceSend)
|
if (!m_forceSend)
|
||||||
{
|
{
|
||||||
QPushButton *cancelButton = new QPushButton(tr("Don't send report"), this);
|
QPushButton *cancelButton = new QPushButton(tr("Don't send report"), this);
|
||||||
connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(onCancelClicked()));
|
connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(onCancelClicked()));
|
||||||
hbl->addWidget(cancelButton);
|
hbl->addWidget(cancelButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPushButton *sendButton = new QPushButton( tr( "Send report" ), this );
|
||||||
|
sendButton->setAutoDefault(true);
|
||||||
|
connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) );
|
||||||
|
hbl->addWidget( sendButton );
|
||||||
}
|
}
|
||||||
// Otherwise only offer exit
|
// Otherwise only offer exit
|
||||||
else
|
else
|
||||||
|
@ -161,6 +169,7 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::
|
||||||
QPushButton *exitButton = new QPushButton( tr( "Exit" ), this );
|
QPushButton *exitButton = new QPushButton( tr( "Exit" ), this );
|
||||||
connect( exitButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
connect( exitButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
||||||
hbl->addWidget(exitButton);
|
hbl->addWidget(exitButton);
|
||||||
|
exitButton->setAutoDefault(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 );
|
m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 );
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>NeL Error Report</string>
|
<string>NeL report</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
|
|
Loading…
Reference in a new issue