From 73020237773b0c5dd4165988a9ae1f285d4dd675 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 17 Feb 2015 03:12:26 +0100 Subject: [PATCH 02/53] CMsgBoxDisplayer should not present a dialog now, but write the report to a file then attempt to launch the error reporter application. Which ofc doesn't exist yet in this commit. --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/report.cpp | 293 ++------------------------------- code/ryzom/client/src/init.cpp | 2 + 3 files changed, 19 insertions(+), 278 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index c7667acc2..2d09f5ef8 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -83,7 +83,7 @@ using namespace std; #define LOG_IN_FILE NEL_LOG_IN_FILE // If true, debug system will trap crash even if the application is in debugger -static const bool TrapCrashInDebugger = false; +static const bool TrapCrashInDebugger = true; #ifdef DEBUG_NEW #define new DEBUG_NEW diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 20b2b1c11..39f27de5f 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -42,25 +42,14 @@ using namespace std; namespace NLMISC { -#ifdef NL_OS_WINDOWS -static HWND sendReport=NULL; -#endif - //old doesn't work on visual c++ 7.1 due to default parameter typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile = "", bool onlyCheck = false); typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile, bool onlyCheck); -#define DELETE_OBJECT(a) if((a)!=NULL) { DeleteObject (a); a = NULL; } - static TEmailFunction EmailFunction = NULL; void setReportEmailFunction (void *emailFunction) { EmailFunction = (TEmailFunction)emailFunction; - -#ifdef NL_OS_WINDOWS - if (sendReport) - EnableWindow(sendReport, FALSE); -#endif } #ifndef NL_OS_WINDOWS @@ -73,91 +62,26 @@ void report () #else -// Windows specific version - -static string Body; -static string Subject; -static string AttachedFile; - -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 sendEmail() +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) { - if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED) + std::string fname; + + time_t s = time( NULL ); + fname = std::string( "log_" ) + toString( s ) + ".txt"; + + std::ofstream f; + f.open( fname.c_str() ); + if( f.good() ) { - bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); - if (res) - { - // EnableWindow(sendReport, FALSE); - // MessageBox (dialog, "The email was successfully sent", "email", MB_OK); -#ifndef NL_NO_DEBUG_FILES - CFile::createEmptyFile(getLogDirectory() + "report_sent"); -#endif - } - else - { -#ifndef NL_NO_DEBUG_FILES - CFile::createEmptyFile(getLogDirectory() + "report_failed"); -#endif - // MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); - } + f << body; + f.close(); + + NLMISC::launchProgram( "rcerror", fname ); } - else - { -#ifndef NL_NO_DEBUG_FILES - CFile::createEmptyFile(getLogDirectory() + "report_refused"); -#endif - } -} -static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //MSGFILTER *pmf; + NLMISC::CFile::deleteFile( fname ); + - if (message == WM_COMMAND && HIWORD(wParam) == BN_CLICKED) - { - if ((HWND) lParam == checkIgnore) - { - IgnoreNextTime = !IgnoreNextTime; - } - else if ((HWND) lParam == debug) - { - sendEmail(); - NeedExit = true; - Result = ReportDebug; - if (DebugDefaultBehavior) - { - NLMISC_BREAKPOINT; - } - } - else if ((HWND) lParam == ignore) - { - sendEmail(); - NeedExit = true; - Result = ReportIgnore; - } - else if ((HWND) lParam == quit) - { - sendEmail(); - 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. @@ -166,193 +90,8 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM #endif // quit without calling atexit or static object dtors. abort(); - } - } - /*else if ((HWND) lParam == sendReport) - { - if (EmailFunction != NULL) - { - bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); - if (res) - { - EnableWindow(sendReport, FALSE); - MessageBox (dialog, "The email was successfully sent", "email", MB_OK); - CFile::createEmptyFile(getLogDirectory() + "report_sent"); - } - else - { - MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); - } - } - }*/ - } - else if (message == WM_CHAR) - { - if (wParam == 27) - { - // ESC -> ignore - sendEmail(); - 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; - } - - ucstring formatedTitle = title.empty() ? ucstring("NeL report") : ucstring(title); - - - // 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"); - - Subject = subject; - AttachedFile = attachedFile; - - // 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); - - Body = addSlashR (body); - - // set the message in the edit text - SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)Body.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 && EmailFunction != NULL && EmailFunction("", "", "", "", "", true); - CanSendMailReport = sendReportButton && EmailFunction != NULL; - - 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; + return ReportQuit; } #endif diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 6958fe790..c7fdc97f8 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -539,6 +539,8 @@ void checkDriverVersion() void checkDriverDepth () { + nlassert( false ); + // Check desktop is in 32 bit else no window mode allowed. if (ClientCfg.Windowed) { From ee0b630f95bcee30e8678104de553b388e13bd3f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 19 Feb 2015 00:20:18 +0100 Subject: [PATCH 03/53] Added the Ryzom Core Error Reporter's skeleton. --HG-- branch : feature-crashreport --- code/nel/CMakeLists.txt | 3 ++ code/nel/rcerror/CMakeLists.txt | 37 +++++++++++++ code/nel/rcerror/rcerror.cpp | 50 ++++++++++++++++++ code/nel/rcerror/rcerror_socket.cpp | 20 +++++++ code/nel/rcerror/rcerror_socket.h | 23 ++++++++ code/nel/rcerror/rcerror_widget.cpp | 70 ++++++++++++++++++++++++ code/nel/rcerror/rcerror_widget.h | 47 +++++++++++++++++ code/nel/rcerror/rcerror_widget.ui | 82 +++++++++++++++++++++++++++++ 8 files changed, 332 insertions(+) create mode 100644 code/nel/rcerror/CMakeLists.txt create mode 100644 code/nel/rcerror/rcerror.cpp create mode 100644 code/nel/rcerror/rcerror_socket.cpp create mode 100644 code/nel/rcerror/rcerror_socket.h create mode 100644 code/nel/rcerror/rcerror_widget.cpp create mode 100644 code/nel/rcerror/rcerror_widget.h create mode 100644 code/nel/rcerror/rcerror_widget.ui diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 53bf071e3..00290d097 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -84,3 +84,6 @@ IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) ADD_SUBDIRECTORY(tools) ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) +IF(WITH_QT) + ADD_SUBDIRECTORY(rcerror) +ENDIF(WITH_QT) diff --git a/code/nel/rcerror/CMakeLists.txt b/code/nel/rcerror/CMakeLists.txt new file mode 100644 index 000000000..412da9b6c --- /dev/null +++ b/code/nel/rcerror/CMakeLists.txt @@ -0,0 +1,37 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SRC_DIR} ${QT_INCLUDES}) +FILE(GLOB RCERROR_SRC *.cpp) +FILE(GLOB RCERROR_HDR *h) + +SET(RCERROR_MOC_HDR +rcerror_socket.h +rcerror_widget.h +) + +SET(RCERROR_UI +rcerror_widget.ui +) + +SET(QT_USE_QTGUI TRUE) +SET(QT_USE_QTNETWORK TRUE) +SET(QT_USE_QTMAIN TRUE) +SET(QT_USE_QTOPENGL FALSE) +SET(QT_USE_QTXML FALSE) + +INCLUDE(${QT_USE_FILE}) +ADD_DEFINITIONS(${QT_DEFINITIONS}) + +QT4_WRAP_CPP(RCERROR_MOC_SRC ${RCERROR_MOC_HDR}) +QT4_WRAP_UI(RCERROR_UI_HDR ${RCERROR_UI}) + +SOURCE_GROUP(QtResources FILES ${RCERROR_UI}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${RCERROR_UI_HDR}) +SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${RCERROR_MOC_SRC}) +SOURCE_GROUP("source files" FILES ${RCERROR_SRC}) +SOURCE_GROUP("header files" FILES ${RCERROR_HDR}) + +ADD_EXECUTABLE(rcerror WIN32 MACOSX_BUNDLE ${RCERROR_SRC} ${RCERROR_MOC_HDR} ${RCERROR_MOC_SRC} ${RCERROR_UI_HDR}) +TARGET_LINK_LIBRARIES(rcerror ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) + +NL_DEFAULT_PROPS(rcerror "Ryzom Core Error Reporter") +NL_ADD_RUNTIME_FLAGS(rcerror) + diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/rcerror/rcerror.cpp new file mode 100644 index 000000000..6fa876e81 --- /dev/null +++ b/code/nel/rcerror/rcerror.cpp @@ -0,0 +1,50 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "rcerror_widget.h" +#include +#include + +int main( int argc, char **argv ) +{ + QApplication app( argc, argv ); + +#if 0 + + if( argc < 2 ) + { + QMessageBox::information( NULL, + QObject::tr( "Error" ), + QObject::tr( "Need to specify a path to the error report." ) ); + return 1; + } +#endif + + RCErrorWidget w; + +#if 0 + w.setFileName( argv[ 1 ] ); +#else + w.setFileName( "log.log" ); +#endif + + w.show(); + + return app.exec(); +} \ No newline at end of file diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp new file mode 100644 index 000000000..f39946423 --- /dev/null +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -0,0 +1,20 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "rcerror_socket.h" + diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h new file mode 100644 index 000000000..8cd9f54ad --- /dev/null +++ b/code/nel/rcerror/rcerror_socket.h @@ -0,0 +1,23 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef RCERROR_SOCKET +#define RCERROR_SOCKET +#endif + diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp new file mode 100644 index 000000000..a50b273d3 --- /dev/null +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -0,0 +1,70 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#include "rcerror_widget.h" +#include +#include +#include + +RCErrorWidget::RCErrorWidget( QWidget *parent ) : +QWidget( parent ) +{ + m_ui.setupUi( this ); + QTimer::singleShot( 1, this, SLOT( onLoad() ) ); + + connect( m_ui.sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); + connect( m_ui.canceButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); +} + +RCErrorWidget::~RCErrorWidget() +{ +} + +void RCErrorWidget::onLoad() +{ + QFile f( m_fileName ); + bool b = f.open( QFile::ReadOnly | QFile::Text ); + if( !b ) + { + return; + } + + QTextStream ss( &f ); + m_ui.reportEdit->setPlainText( ss.readAll() ); + f.close(); +} + +void RCErrorWidget::onSendClicked() +{ + close(); +} + +void RCErrorWidget::onCancelClicked() +{ + close(); +} + +void RCErrorWidget::onCBClicked() +{ + m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); +} + + + diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h new file mode 100644 index 000000000..ae5629e55 --- /dev/null +++ b/code/nel/rcerror/rcerror_widget.h @@ -0,0 +1,47 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef RCERROR_WIDGET +#define RCERROR_SOCKET + + +#include "ui_rcerror_widget.h" + +class RCErrorWidget : public QWidget +{ + Q_OBJECT +public: + RCErrorWidget( QWidget *parent = NULL ); + ~RCErrorWidget(); + + void setFileName( const char *fn ){ m_fileName = fn; } + +private Q_SLOTS: + void onLoad(); + void onSendClicked(); + void onCancelClicked(); + void onCBClicked(); + +private: + Ui::RCErrorWidget m_ui; + QString m_fileName; +}; + +#endif + diff --git a/code/nel/rcerror/rcerror_widget.ui b/code/nel/rcerror/rcerror_widget.ui new file mode 100644 index 000000000..72e5f92f5 --- /dev/null +++ b/code/nel/rcerror/rcerror_widget.ui @@ -0,0 +1,82 @@ + + + RCErrorWidget + + + Qt::ApplicationModal + + + + 0 + 0 + 400 + 407 + + + + Ryzom Core error report + + + + + + What were you doing when the crash occured? + + + + + + + + + + Contents of the report ( automatically generated ) + + + + + + + true + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Email me if you have further questions, or updates on this issue + + + + + + + false + + + Enter your email address here + + + + + + + Send + + + + + + + Cancel + + + + + + + + From 03ce683e4960d5f8606b05ca12083e10c6599e86 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 01:59:04 +0100 Subject: [PATCH 04/53] Implemented the bug report Qt app and an example web app that takes the report. --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror_data.h | 33 ++++++++ code/nel/rcerror/rcerror_socket.cpp | 46 +++++++++++ code/nel/rcerror/rcerror_socket.h | 26 ++++++ code/nel/rcerror/rcerror_widget.cpp | 25 +++++- code/nel/rcerror/rcerror_widget.h | 7 +- code/web/rcerror_web/config.inc.php | 30 +++++++ code/web/rcerror_web/log.inc.php | 45 +++++++++++ code/web/rcerror_web/rcerror.php | 112 ++++++++++++++++++++++++++ code/web/rcerror_web/rcerror_test.htm | 19 +++++ 9 files changed, 341 insertions(+), 2 deletions(-) create mode 100644 code/nel/rcerror/rcerror_data.h create mode 100644 code/web/rcerror_web/config.inc.php create mode 100644 code/web/rcerror_web/log.inc.php create mode 100644 code/web/rcerror_web/rcerror.php create mode 100644 code/web/rcerror_web/rcerror_test.htm diff --git a/code/nel/rcerror/rcerror_data.h b/code/nel/rcerror/rcerror_data.h new file mode 100644 index 000000000..146102038 --- /dev/null +++ b/code/nel/rcerror/rcerror_data.h @@ -0,0 +1,33 @@ +// Ryzom Core MMORPG framework - Error Reporter +// +// Copyright (C) 2015 Laszlo Kis-Adam +// Copyright (C) 2010 Ryzom Core +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef RCERROR_DATA +#define RCERROR_DATA + +#include + + +struct RCErrorData +{ + QString description; + QString report; + QString email; +}; + +#endif diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index f39946423..d84f69ec8 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -17,4 +17,50 @@ // along with this program. If not, see . #include "rcerror_socket.h" +#include +#include +#include + +namespace +{ + static const char *BUG_URL = "http://192.168.2.67/dfighter/r.php"; +} + +class RCErrorSocketPvt +{ +public: + QNetworkAccessManager mgr; +}; + +RCErrorSocket::RCErrorSocket( QObject *parent ) : +QObject( parent ) +{ + m_pvt = new RCErrorSocketPvt(); + + connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished() ) ); +} + +RCErrorSocket::~RCErrorSocket() +{ + delete m_pvt; +} + +void RCErrorSocket::sendReport( const RCErrorData &data ) +{ + QUrl params; + params.addQueryItem( "report", data.report ); + params.addQueryItem( "descr", data.description ); + params.addQueryItem( "email", data.email ); + + QUrl url( BUG_URL ); + QNetworkRequest request( url ); + request.setRawHeader( "Connection", "close" ); + + m_pvt->mgr.post( request, params.encodedQuery() ); +} + +void RCErrorSocket::onFinished() +{ + Q_EMIT reportSent(); +} diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h index 8cd9f54ad..ee0f510b1 100644 --- a/code/nel/rcerror/rcerror_socket.h +++ b/code/nel/rcerror/rcerror_socket.h @@ -19,5 +19,31 @@ #ifndef RCERROR_SOCKET #define RCERROR_SOCKET + +#include +#include "rcerror_data.h" + +class RCErrorSocketPvt; + +class RCErrorSocket : public QObject +{ + Q_OBJECT + +public: + RCErrorSocket( QObject *parent ); + ~RCErrorSocket(); + + void sendReport( const RCErrorData &data ); + +Q_SIGNALS: + void reportSent(); + +private Q_SLOTS: + void onFinished(); + +private: + RCErrorSocketPvt *m_pvt; +}; + #endif diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index a50b273d3..faded0afa 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -18,23 +18,32 @@ #include "rcerror_widget.h" +#include "rcerror_socket.h" +#include "rcerror_data.h" #include #include #include +#include RCErrorWidget::RCErrorWidget( QWidget *parent ) : QWidget( parent ) { m_ui.setupUi( this ); + + m_socket = new RCErrorSocket( this ); + QTimer::singleShot( 1, this, SLOT( onLoad() ) ); connect( m_ui.sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); connect( m_ui.canceButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); + + connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) ); } RCErrorWidget::~RCErrorWidget() { + m_socket = NULL; } void RCErrorWidget::onLoad() @@ -53,7 +62,14 @@ void RCErrorWidget::onLoad() void RCErrorWidget::onSendClicked() { - close(); + m_ui.sendButton->setEnabled( false ); + + RCErrorData data; + data.description = m_ui.descriptionEdit->toPlainText(); + data.report = m_ui.reportEdit->toPlainText(); + data.email = m_ui.emailEdit->text(); + + m_socket->sendReport( data ); } void RCErrorWidget::onCancelClicked() @@ -66,5 +82,12 @@ void RCErrorWidget::onCBClicked() m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } +void RCErrorWidget::onReportSent() +{ + QMessageBox::information( this, + tr( "Report sent" ), + tr( "The report has been sent." ) ); + close(); +} diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h index ae5629e55..869838e41 100644 --- a/code/nel/rcerror/rcerror_widget.h +++ b/code/nel/rcerror/rcerror_widget.h @@ -18,11 +18,13 @@ #ifndef RCERROR_WIDGET -#define RCERROR_SOCKET +#define RCERROR_WIDGET #include "ui_rcerror_widget.h" +class RCErrorSocket; + class RCErrorWidget : public QWidget { Q_OBJECT @@ -37,10 +39,13 @@ private Q_SLOTS: void onSendClicked(); void onCancelClicked(); void onCBClicked(); + + void onReportSent(); private: Ui::RCErrorWidget m_ui; QString m_fileName; + RCErrorSocket *m_socket; }; #endif diff --git a/code/web/rcerror_web/config.inc.php b/code/web/rcerror_web/config.inc.php new file mode 100644 index 000000000..fe4b3e928 --- /dev/null +++ b/code/web/rcerror_web/config.inc.php @@ -0,0 +1,30 @@ + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +class BugReportConfig +{ + static public $dbhost = "localhost"; + static public $dbport = "3306"; + static public $dbdb = "bugs"; + static public $dbuser = "bugs"; + static public $dbpw = "bugs"; +} + +?> diff --git a/code/web/rcerror_web/log.inc.php b/code/web/rcerror_web/log.inc.php new file mode 100644 index 000000000..71deee24f --- /dev/null +++ b/code/web/rcerror_web/log.inc.php @@ -0,0 +1,45 @@ + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +/// Simple file logger class +class Logger +{ + private $lf = NULL; + + function __construct() + { + $this->lf = fopen( 'log.txt', 'a' ); + if( $this->lf === FALSE ) + exit( 1 ); + } + + function __destruct() + { + fclose( $this->lf ); + } + + public function log( $msg ) + { + $date = date( "[M d, Y H:i:s] " ); + fwrite( $this->lf, $date . $msg . "\n" ); + } +} + +?> diff --git a/code/web/rcerror_web/rcerror.php b/code/web/rcerror_web/rcerror.php new file mode 100644 index 000000000..d20214d11 --- /dev/null +++ b/code/web/rcerror_web/rcerror.php @@ -0,0 +1,112 @@ + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +require_once( 'config.inc.php' ); +require_once( 'log.inc.php' ); + +/// Example web application that takes bug reports from the bug reporter Qt app +class BugReportGatherApp +{ + private $db = NULL; + private $logger = NULL; + + function __construct() + { + $this->logger = new Logger(); + } + + private function logPOSTVars() + { + $report = ""; + $descr = ""; + $email = ""; + + if( isset( $_POST[ 'report' ] ) ) + $report = $_POST[ 'report' ]; + + if( isset( $_POST[ 'descr' ] ) ) + $descr = $_POST[ 'descr' ]; + + if( isset( $_POST[ 'email' ] ) ) + $email = $_POST[ 'email' ]; + + $this->logger->log( 'report: ' . "\n" . $report ); + $this->logger->log( 'description: ' . "\n" . $descr ); + $this->logger->log( 'email: ' . "\n" . $email ); + } + + private function buildQuery() + { + $report = ""; + $descr = ""; + $email = ""; + + if( isset( $_POST[ 'report' ] ) ) + $report = $_POST[ 'report' ]; + + if( isset( $_POST[ 'descr' ] ) ) + $descr = $_POST[ 'descr' ]; + + if( isset( $_POST[ 'email' ] ) ) + $email = $_POST[ 'email' ]; + + $report = $this->db->real_escape_string( $report ); + $descr = $this->db->real_escape_string( $descr ); + $email = $this->db->real_escape_string( $email ); + + + $q = "INSERT INTO `bugs` (`report`,`description`,`email`) VALUES ("; + $q .= "'$report',"; + $q .= "'$descr',"; + $q .= "'$email')"; + + return $q; + } + + public function exec() + { + //$this->logPOSTVars(); + + $this->db = new mysqli( BugReportConfig::$dbhost, BugReportConfig::$dbuser, BugReportConfig::$dbpw, BugReportConfig::$dbdb, BugReportConfig::$dbport ); + if( mysqli_connect_error() ) + { + $this->logger->log( "Connection error :(" ); + $this->logger->log( mysqli_connect_error() ); + return; + } + + $q = $this->buildQuery(); + $result = $this->db->query( $q ); + if( $result !== TRUE ) + { + $this->logger->log( "Query failed :(" ); + $this->logger->log( 'Query: ' . $q ); + $this->logPOSTVars(); + } + + $this->db->close(); + } +} + + +$app = new BugReportGatherApp(); +$app->exec(); + +?> diff --git a/code/web/rcerror_web/rcerror_test.htm b/code/web/rcerror_web/rcerror_test.htm new file mode 100644 index 000000000..eb314d3f7 --- /dev/null +++ b/code/web/rcerror_web/rcerror_test.htm @@ -0,0 +1,19 @@ + +Ryzom Core Error Report Web application test harness + +
+ + + + + + + + + +
Description
Report
Email
+ +
+
+ + From 9518a80c99da94ed0e9d4ca46d63da686f9d6966 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:03:33 +0100 Subject: [PATCH 05/53] Probably a good idea to look for rcerror as rcerror.exe on Windows. --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 39f27de5f..1a94e17a6 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -76,7 +76,11 @@ TReportResult report (const std::string &title, const std::string &header, const f << body; f.close(); +#ifdef NL_OS_WINDOWS + NLMISC::launchProgram( "rcerror.exe", fname ); +#else NLMISC::launchProgram( "rcerror", fname ); +#endif } NLMISC::CFile::deleteFile( fname ); From f0869aa65961ce24fea94e44358df57c0b964a06 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:35:11 +0100 Subject: [PATCH 06/53] Unfortunately on Windows argc and argv parameters are unreliable inside a Qt application, so I had to hardcode the report file name. :( --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror.cpp | 19 +------------------ code/nel/rcerror/rcerror_widget.cpp | 5 ++++- code/nel/src/misc/report.cpp | 8 +------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/rcerror/rcerror.cpp index 6fa876e81..0d5088167 100644 --- a/code/nel/rcerror/rcerror.cpp +++ b/code/nel/rcerror/rcerror.cpp @@ -25,25 +25,8 @@ int main( int argc, char **argv ) { QApplication app( argc, argv ); -#if 0 - - if( argc < 2 ) - { - QMessageBox::information( NULL, - QObject::tr( "Error" ), - QObject::tr( "Need to specify a path to the error report." ) ); - return 1; - } -#endif - RCErrorWidget w; - -#if 0 - w.setFileName( argv[ 1 ] ); -#else - w.setFileName( "log.log" ); -#endif - + w.setFileName( "rcerrorlog.txt" ); w.show(); return app.exec(); diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index faded0afa..6c31533ad 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -52,7 +52,10 @@ void RCErrorWidget::onLoad() bool b = f.open( QFile::ReadOnly | QFile::Text ); if( !b ) { - return; + QMessageBox::information( this, + tr( "No log file found" ), + tr( "There was no log file found, therefore nothing to report. Exiting..." ) ); + close(); } QTextStream ss( &f ); diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 1a94e17a6..88c707aaa 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -64,10 +64,7 @@ void report () 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) { - std::string fname; - - time_t s = time( NULL ); - fname = std::string( "log_" ) + toString( s ) + ".txt"; + std::string fname = "rcerrorlog.txt"; std::ofstream f; f.open( fname.c_str() ); @@ -83,9 +80,6 @@ TReportResult report (const std::string &title, const std::string &header, const #endif } - NLMISC::CFile::deleteFile( fname ); - - #ifdef NL_OS_WINDOWS #ifndef NL_COMP_MINGW // disable the Windows popup telling that the application aborted and disable the dr watson report. From 14a709449a4b6271a4762ba8c758b54bdb0745f1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:44:22 +0100 Subject: [PATCH 07/53] Override the cursor while sending the report. --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror_socket.cpp | 2 +- code/nel/rcerror/rcerror_widget.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index d84f69ec8..6b1fd932d 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -23,7 +23,7 @@ namespace { - static const char *BUG_URL = "http://192.168.2.67/dfighter/r.php"; + static const char *BUG_URL = "http://192.168.2.66/dfighter/r.php"; } class RCErrorSocketPvt diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index 6c31533ad..e02090e0d 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -66,6 +66,7 @@ void RCErrorWidget::onLoad() void RCErrorWidget::onSendClicked() { m_ui.sendButton->setEnabled( false ); + QApplication::setOverrideCursor( Qt::WaitCursor ); RCErrorData data; data.description = m_ui.descriptionEdit->toPlainText(); @@ -87,6 +88,8 @@ void RCErrorWidget::onCBClicked() void RCErrorWidget::onReportSent() { + QApplication::setOverrideCursor( Qt::ArrowCursor ); + QMessageBox::information( this, tr( "Report sent" ), tr( "The report has been sent." ) ); From 72566f1a71ae580ad3a61e4376f24c111b750a04 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:54:05 +0100 Subject: [PATCH 08/53] Tell the user if the report couldn't be sent. --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror_socket.cpp | 10 +++++++--- code/nel/rcerror/rcerror_socket.h | 4 +++- code/nel/rcerror/rcerror_widget.cpp | 11 +++++++++++ code/nel/rcerror/rcerror_widget.h | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index 6b1fd932d..8a011c046 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace { @@ -37,7 +38,7 @@ QObject( parent ) { m_pvt = new RCErrorSocketPvt(); - connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished() ) ); + connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply* ) ) ); } RCErrorSocket::~RCErrorSocket() @@ -59,8 +60,11 @@ void RCErrorSocket::sendReport( const RCErrorData &data ) m_pvt->mgr.post( request, params.encodedQuery() ); } -void RCErrorSocket::onFinished() +void RCErrorSocket::onFinished( QNetworkReply *reply ) { - Q_EMIT reportSent(); + if( reply->error() != QNetworkReply::NoError ) + Q_EMIT reportFailed(); + else + Q_EMIT reportSent(); } diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h index ee0f510b1..a37fa32d0 100644 --- a/code/nel/rcerror/rcerror_socket.h +++ b/code/nel/rcerror/rcerror_socket.h @@ -24,6 +24,7 @@ #include "rcerror_data.h" class RCErrorSocketPvt; +class QNetworkReply; class RCErrorSocket : public QObject { @@ -37,9 +38,10 @@ public: Q_SIGNALS: void reportSent(); + void reportFailed(); private Q_SLOTS: - void onFinished(); + void onFinished( QNetworkReply *reply ); private: RCErrorSocketPvt *m_pvt; diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index e02090e0d..a28afbca6 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -39,6 +39,7 @@ QWidget( parent ) connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) ); + connect( m_socket, SIGNAL( reportFailed() ), this, SLOT( onReportFailed() ) ); } RCErrorWidget::~RCErrorWidget() @@ -97,3 +98,13 @@ void RCErrorWidget::onReportSent() close(); } +void RCErrorWidget::onReportFailed() +{ + QApplication::setOverrideCursor( Qt::ArrowCursor ); + + QMessageBox::information( this, + tr( "Report failed" ), + tr( "Failed to send the report..." ) ); + + close(); +} \ No newline at end of file diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h index 869838e41..1dd51c2af 100644 --- a/code/nel/rcerror/rcerror_widget.h +++ b/code/nel/rcerror/rcerror_widget.h @@ -41,6 +41,7 @@ private Q_SLOTS: void onCBClicked(); void onReportSent(); + void onReportFailed(); private: Ui::RCErrorWidget m_ui; From ef56d28542c2f4f840eebbf0c52965158dfd5b79 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 02:56:22 +0100 Subject: [PATCH 09/53] Oups --HG-- branch : feature-crashreport --- code/ryzom/client/src/init.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index c7fdc97f8..6958fe790 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -539,8 +539,6 @@ void checkDriverVersion() void checkDriverDepth () { - nlassert( false ); - // Check desktop is in 32 bit else no window mode allowed. if (ClientCfg.Windowed) { From 9b29695635c22349a848b05b188ec258d2a4c20c Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Fri, 20 Feb 2015 03:22:02 +0100 Subject: [PATCH 10/53] Typo... --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror_data.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/rcerror/rcerror_data.h b/code/nel/rcerror/rcerror_data.h index 146102038..9f12b12fd 100644 --- a/code/nel/rcerror/rcerror_data.h +++ b/code/nel/rcerror/rcerror_data.h @@ -20,7 +20,7 @@ #ifndef RCERROR_DATA #define RCERROR_DATA -#include +#include struct RCErrorData From 7efb3334fc6b47ea4659ea48e11af5d7ddfb46a7 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Feb 2015 20:01:44 +0100 Subject: [PATCH 11/53] Install rcerror --HG-- branch : feature-crashreport --- code/nel/rcerror/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/nel/rcerror/CMakeLists.txt b/code/nel/rcerror/CMakeLists.txt index 412da9b6c..51522cf0c 100644 --- a/code/nel/rcerror/CMakeLists.txt +++ b/code/nel/rcerror/CMakeLists.txt @@ -35,3 +35,5 @@ TARGET_LINK_LIBRARIES(rcerror ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) NL_DEFAULT_PROPS(rcerror "Ryzom Core Error Reporter") NL_ADD_RUNTIME_FLAGS(rcerror) +INSTALL(TARGETS rcerror RUNTIME DESTINATION ${NL_BIN_PREFIX}) + From 1476bfe648a1b88213453592ba9587b206ba5dbc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Feb 2015 21:28:56 +0100 Subject: [PATCH 12/53] Use CMsgBoxDisplayer on platforms other than Windows as well. --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 8 +------- code/nel/src/misc/displayer.cpp | 2 -- code/nel/src/misc/report.cpp | 12 ------------ 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 2d09f5ef8..aaa551f1f 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -1193,13 +1193,7 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) INelContext::getInstance().setAssertLog(new CLog (CLog::LOG_ASSERT)); sd = new CStdDisplayer ("DEFAULT_SD"); - -#ifdef NL_OS_WINDOWS - if (TrapCrashInDebugger || !IsDebuggerPresent ()) - { - DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); - } -#endif + DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); #if LOG_IN_FILE if (logInFile) diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index d48c44d02..35ae27964 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,7 +529,6 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { -#ifdef NL_OS_WINDOWS bool needSpace = false; // stringstream ss; @@ -720,7 +719,6 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m } */ } -#endif } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 88c707aaa..b165e29f5 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -52,16 +52,6 @@ void setReportEmailFunction (void *emailFunction) EmailFunction = (TEmailFunction)emailFunction; } -#ifndef NL_OS_WINDOWS - -// GNU/Linux, do nothing - -void report () -{ -} - -#else - 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) { std::string fname = "rcerrorlog.txt"; @@ -92,7 +82,5 @@ TReportResult report (const std::string &title, const std::string &header, const return ReportQuit; } -#endif - } // NLMISC From e130625ccab79190121cc76247cc634f26c6d3d8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Feb 2015 22:32:11 +0100 Subject: [PATCH 13/53] A little cleanup of CMsgBoxDisplayer. --HG-- branch : feature-crashreport --- code/nel/include/nel/misc/report.h | 17 +-- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/displayer.cpp | 174 +---------------------------- code/nel/src/misc/report.cpp | 19 +--- 4 files changed, 7 insertions(+), 205 deletions(-) diff --git a/code/nel/include/nel/misc/report.h b/code/nel/include/nel/misc/report.h index 11745b6e3..6bf3df959 100644 --- a/code/nel/include/nel/misc/report.h +++ b/code/nel/include/nel/misc/report.h @@ -21,21 +21,8 @@ namespace NLMISC { -/** Display a custom message box. - * - * \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 body message displayed in the edit text box. This string will be sent by email. - * \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior - * - * - * - * \return the button clicked or error - */ - -enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError }; - -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 = ""); +/// Prepares the error report, writes it to disk and launches the error reporter +void report ( const std::string &body ); /** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail); */ diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index aaa551f1f..67c8cb0f3 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -553,7 +553,7 @@ public: // 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). bool i = false; - report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE); + report ( _Reason ); // no more sent mail for crash setCrashAlreadyReported(true); diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 35ae27964..8296d1c0b 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,114 +529,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { - - bool needSpace = false; -// stringstream ss; - string str; - - // create the string for the clipboard - - if (args.Date != 0) - { - str += dateToHumanString(args.Date); - needSpace = true; - } - - if (args.LogType != CLog::LOG_NO) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += logTypeToString(args.LogType); - needSpace = true; - } - - if (!args.ProcessName.empty()) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += args.ProcessName; - needSpace = true; - } - - if (args.FileName != NULL) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += CFile::getFilename(args.FileName); - needSpace = true; - } - - if (args.Line != -1) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += NLMISC::toString(args.Line); - needSpace = true; - } - - if (args.FuncName != NULL) - { - //if (needSpace) { ss << " "; needSpace = false; } - if (needSpace) { str += " "; needSpace = false; } - str += args.FuncName; - needSpace = true; - } - - if (needSpace) { str += ": "; needSpace = false; } - - str += message; - - CSystemUtils::copyTextToClipboard(str); - - // create the string on the screen - needSpace = false; -// stringstream ss2; - string str2; - -#ifdef NL_DEBUG - if (!args.ProcessName.empty()) - { - if (needSpace) { str2 += " "; needSpace = false; } - str2 += args.ProcessName; - needSpace = true; - } - - if (args.FileName != NULL) - { - if (needSpace) { str2 += " "; needSpace = false; } - str2 += CFile::getFilename(args.FileName); - needSpace = true; - } - - if (args.Line != -1) - { - if (needSpace) { str2 += " "; needSpace = false; } - str2 += NLMISC::toString(args.Line); - needSpace = true; - } - - if (args.FuncName != NULL) - { - if (needSpace) { str2 += " "; needSpace = false; } - str2 += args.FuncName; - needSpace = true; - } - - if (needSpace) { str2 += ": "; needSpace = false; } - -#endif // NL_DEBUG - - str2 += message; - str2 += "\n\n(this message was copied in the clipboard)"; - -/* if (IsDebuggerPresent ()) - { - // Must break in assert call - DebugNeedAssert = true; - } - else -*/ { - + // Display the report string body; @@ -656,69 +549,8 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m body += "Reason: " + toString(message); body += args.CallstackAndLog; - - string subject; - - // procname is host/service_name-sid we only want the service_name to avoid redondant mail - string procname; - string::size_type pos = args.ProcessName.find ("/"); - if (pos == string::npos) - { - procname = args.ProcessName; - } - else - { - string::size_type pos2 = args.ProcessName.find ("-", pos+1); - if (pos2 == string::npos) - { - procname = args.ProcessName.substr (pos+1); - } - else - { - procname = args.ProcessName.substr (pos+1, pos2-pos-1); - } - } - - subject += procname + " NeL " + toString(LogTypeToString[0][args.LogType]) + " " + (args.FileName?string(args.FileName):"") + " " + toString(args.Line) + " " + (args.FuncName?string(args.FuncName):""); - - // Check the envvar NEL_IGNORE_ASSERT - if (getenv ("NEL_IGNORE_ASSERT") == NULL) - { - // 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). - 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())) - { - INelContext::getInstance().setDebugNeedAssert(true); - } - - // no more sent mail for crash - 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 - } - } -*/ } - + + report( body ); } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index b165e29f5..54c456ade 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -22,23 +22,8 @@ #include "nel/misc/report.h" #include "nel/misc/path.h" -#ifdef NL_OS_WINDOWS -# ifndef NL_COMP_MINGW -# define NOMINMAX -# endif -# include -# include -# include -#endif // NL_OS_WINDOWS - -#define NL_NO_DEBUG_FILES 1 - using namespace std; -#ifdef DEBUG_NEW - #define new DEBUG_NEW -#endif - namespace NLMISC { @@ -52,7 +37,7 @@ void setReportEmailFunction (void *emailFunction) EmailFunction = (TEmailFunction)emailFunction; } -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) +void report ( const std::string &body ) { std::string fname = "rcerrorlog.txt"; @@ -78,8 +63,6 @@ TReportResult report (const std::string &title, const std::string &header, const #endif // quit without calling atexit or static object dtors. abort(); - - return ReportQuit; } From d2194cda05e647151b522e6d2014480726bd0b69 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 21 Feb 2015 22:34:02 +0100 Subject: [PATCH 14/53] Removed unused references to CMsgBoxDisplayer. --HG-- branch : feature-crashreport --- code/ryzom/client/src/connection.cpp | 1 - code/ryzom/client/src/init.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 8b07cc7f2..22354e436 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -103,7 +103,6 @@ extern uint32 Version; // Client Version. extern UDriver *Driver; extern UTextContext *TextContext; extern bool game_exit; -extern CMsgBoxDisplayer MsgBoxError; extern CSoundManager *SoundMngr; diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 6958fe790..f0fd40dae 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -142,7 +142,6 @@ using namespace std; // Ligo primitive class CLigoConfig LigoConfig; -CMsgBoxDisplayer MsgBoxError; CClientChatManager ChatMngr; bool LastScreenSaverEnabled = false; From 4e00903dccfdacf1dce6fbd9d75879dd245299e4 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 17:15:41 +0100 Subject: [PATCH 15/53] Back out from 5bb3dad --HG-- branch : feature-crashreport --- code/nel/include/nel/misc/report.h | 17 ++- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/displayer.cpp | 174 ++++++++++++++++++++++++++++- code/nel/src/misc/report.cpp | 19 +++- 4 files changed, 205 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/misc/report.h b/code/nel/include/nel/misc/report.h index 6bf3df959..11745b6e3 100644 --- a/code/nel/include/nel/misc/report.h +++ b/code/nel/include/nel/misc/report.h @@ -21,8 +21,21 @@ namespace NLMISC { -/// Prepares the error report, writes it to disk and launches the error reporter -void report ( const std::string &body ); +/** Display a custom message box. + * + * \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 body message displayed in the edit text box. This string will be sent by email. + * \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior + * + * + * + * \return the button clicked or error + */ + +enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError }; + +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 = ""); /** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail); */ diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 67c8cb0f3..aaa551f1f 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -553,7 +553,7 @@ public: // 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). bool i = false; - report ( _Reason ); + report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE); // no more sent mail for crash setCrashAlreadyReported(true); diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 8296d1c0b..35ae27964 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,7 +529,114 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { - + + bool needSpace = false; +// stringstream ss; + string str; + + // create the string for the clipboard + + if (args.Date != 0) + { + str += dateToHumanString(args.Date); + needSpace = true; + } + + if (args.LogType != CLog::LOG_NO) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += logTypeToString(args.LogType); + needSpace = true; + } + + if (!args.ProcessName.empty()) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += args.ProcessName; + needSpace = true; + } + + if (args.FileName != NULL) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += CFile::getFilename(args.FileName); + needSpace = true; + } + + if (args.Line != -1) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += NLMISC::toString(args.Line); + needSpace = true; + } + + if (args.FuncName != NULL) + { + //if (needSpace) { ss << " "; needSpace = false; } + if (needSpace) { str += " "; needSpace = false; } + str += args.FuncName; + needSpace = true; + } + + if (needSpace) { str += ": "; needSpace = false; } + + str += message; + + CSystemUtils::copyTextToClipboard(str); + + // create the string on the screen + needSpace = false; +// stringstream ss2; + string str2; + +#ifdef NL_DEBUG + if (!args.ProcessName.empty()) + { + if (needSpace) { str2 += " "; needSpace = false; } + str2 += args.ProcessName; + needSpace = true; + } + + if (args.FileName != NULL) + { + if (needSpace) { str2 += " "; needSpace = false; } + str2 += CFile::getFilename(args.FileName); + needSpace = true; + } + + if (args.Line != -1) + { + if (needSpace) { str2 += " "; needSpace = false; } + str2 += NLMISC::toString(args.Line); + needSpace = true; + } + + if (args.FuncName != NULL) + { + if (needSpace) { str2 += " "; needSpace = false; } + str2 += args.FuncName; + needSpace = true; + } + + if (needSpace) { str2 += ": "; needSpace = false; } + +#endif // NL_DEBUG + + str2 += message; + str2 += "\n\n(this message was copied in the clipboard)"; + +/* if (IsDebuggerPresent ()) + { + // Must break in assert call + DebugNeedAssert = true; + } + else +*/ { + // Display the report string body; @@ -549,8 +656,69 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m body += "Reason: " + toString(message); body += args.CallstackAndLog; - - report( body ); + + string subject; + + // procname is host/service_name-sid we only want the service_name to avoid redondant mail + string procname; + string::size_type pos = args.ProcessName.find ("/"); + if (pos == string::npos) + { + procname = args.ProcessName; + } + else + { + string::size_type pos2 = args.ProcessName.find ("-", pos+1); + if (pos2 == string::npos) + { + procname = args.ProcessName.substr (pos+1); + } + else + { + procname = args.ProcessName.substr (pos+1, pos2-pos-1); + } + } + + subject += procname + " NeL " + toString(LogTypeToString[0][args.LogType]) + " " + (args.FileName?string(args.FileName):"") + " " + toString(args.Line) + " " + (args.FuncName?string(args.FuncName):""); + + // Check the envvar NEL_IGNORE_ASSERT + if (getenv ("NEL_IGNORE_ASSERT") == NULL) + { + // 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). + 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())) + { + INelContext::getInstance().setDebugNeedAssert(true); + } + + // no more sent mail for crash + 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 + } + } +*/ } + } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 54c456ade..b165e29f5 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -22,8 +22,23 @@ #include "nel/misc/report.h" #include "nel/misc/path.h" +#ifdef NL_OS_WINDOWS +# ifndef NL_COMP_MINGW +# define NOMINMAX +# endif +# include +# include +# include +#endif // NL_OS_WINDOWS + +#define NL_NO_DEBUG_FILES 1 + using namespace std; +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { @@ -37,7 +52,7 @@ void setReportEmailFunction (void *emailFunction) EmailFunction = (TEmailFunction)emailFunction; } -void report ( const std::string &body ) +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) { std::string fname = "rcerrorlog.txt"; @@ -63,6 +78,8 @@ void report ( const std::string &body ) #endif // quit without calling atexit or static object dtors. abort(); + + return ReportQuit; } From 7efbee6d0a67030281c823a91f5c0c6ba5c40cdd Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 17:20:24 +0100 Subject: [PATCH 16/53] Backed out from 5942903 --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 8 +++++++- code/nel/src/misc/displayer.cpp | 2 ++ code/nel/src/misc/report.cpp | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index aaa551f1f..2d09f5ef8 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -1193,7 +1193,13 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) INelContext::getInstance().setAssertLog(new CLog (CLog::LOG_ASSERT)); sd = new CStdDisplayer ("DEFAULT_SD"); - DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); + +#ifdef NL_OS_WINDOWS + if (TrapCrashInDebugger || !IsDebuggerPresent ()) + { + DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); + } +#endif #if LOG_IN_FILE if (logInFile) diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 35ae27964..d48c44d02 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,6 +529,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { +#ifdef NL_OS_WINDOWS bool needSpace = false; // stringstream ss; @@ -719,6 +720,7 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m } */ } +#endif } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index b165e29f5..88c707aaa 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -52,6 +52,16 @@ void setReportEmailFunction (void *emailFunction) EmailFunction = (TEmailFunction)emailFunction; } +#ifndef NL_OS_WINDOWS + +// GNU/Linux, do nothing + +void report () +{ +} + +#else + 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) { std::string fname = "rcerrorlog.txt"; @@ -82,5 +92,7 @@ TReportResult report (const std::string &title, const std::string &header, const return ReportQuit; } +#endif + } // NLMISC From 3d9357637b6d48d806ab5f0d76a33325d0b96770 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 17:38:06 +0100 Subject: [PATCH 17/53] Backed out from fdc0d40 --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/report.cpp | 291 +++++++++++++++++++++++++++++++++-- 2 files changed, 278 insertions(+), 15 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 2d09f5ef8..c7667acc2 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -83,7 +83,7 @@ using namespace std; #define LOG_IN_FILE NEL_LOG_IN_FILE // If true, debug system will trap crash even if the application is in debugger -static const bool TrapCrashInDebugger = true; +static const bool TrapCrashInDebugger = false; #ifdef DEBUG_NEW #define new DEBUG_NEW diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 88c707aaa..20b2b1c11 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -42,14 +42,25 @@ using namespace std; namespace NLMISC { +#ifdef NL_OS_WINDOWS +static HWND sendReport=NULL; +#endif + //old doesn't work on visual c++ 7.1 due to default parameter typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile = "", bool onlyCheck = false); typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile, bool onlyCheck); +#define DELETE_OBJECT(a) if((a)!=NULL) { DeleteObject (a); a = NULL; } + static TEmailFunction EmailFunction = NULL; void setReportEmailFunction (void *emailFunction) { EmailFunction = (TEmailFunction)emailFunction; + +#ifdef NL_OS_WINDOWS + if (sendReport) + EnableWindow(sendReport, FALSE); +#endif } #ifndef NL_OS_WINDOWS @@ -62,24 +73,91 @@ void report () #else -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) +// Windows specific version + +static string Body; +static string Subject; +static string AttachedFile; + +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 sendEmail() { - std::string fname = "rcerrorlog.txt"; - - std::ofstream f; - f.open( fname.c_str() ); - if( f.good() ) + if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED) { - f << body; - f.close(); - -#ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "rcerror.exe", fname ); -#else - NLMISC::launchProgram( "rcerror", fname ); + bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); + if (res) + { + // EnableWindow(sendReport, FALSE); + // MessageBox (dialog, "The email was successfully sent", "email", MB_OK); +#ifndef NL_NO_DEBUG_FILES + CFile::createEmptyFile(getLogDirectory() + "report_sent"); +#endif + } + else + { +#ifndef NL_NO_DEBUG_FILES + CFile::createEmptyFile(getLogDirectory() + "report_failed"); +#endif + // MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); + } + } + else + { +#ifndef NL_NO_DEBUG_FILES + 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) + { + sendEmail(); + NeedExit = true; + Result = ReportDebug; + if (DebugDefaultBehavior) + { + NLMISC_BREAKPOINT; + } + } + else if ((HWND) lParam == ignore) + { + sendEmail(); + NeedExit = true; + Result = ReportIgnore; + } + else if ((HWND) lParam == quit) + { + sendEmail(); + 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. @@ -88,8 +166,193 @@ TReportResult report (const std::string &title, const std::string &header, const #endif // quit without calling atexit or static object dtors. abort(); + } + } + /*else if ((HWND) lParam == sendReport) + { + if (EmailFunction != NULL) + { + bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); + if (res) + { + EnableWindow(sendReport, FALSE); + MessageBox (dialog, "The email was successfully sent", "email", MB_OK); + CFile::createEmptyFile(getLogDirectory() + "report_sent"); + } + else + { + MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); + } + } + }*/ + } + else if (message == WM_CHAR) + { + if (wParam == 27) + { + // ESC -> ignore + sendEmail(); + NeedExit = true; + Result = ReportIgnore; + } + } - return ReportQuit; + 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; + } + + ucstring formatedTitle = title.empty() ? ucstring("NeL report") : ucstring(title); + + + // 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"); + + Subject = subject; + AttachedFile = attachedFile; + + // 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); + + Body = addSlashR (body); + + // set the message in the edit text + SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)Body.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 && EmailFunction != NULL && EmailFunction("", "", "", "", "", true); + CanSendMailReport = sendReportButton && EmailFunction != NULL; + + 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 From 24aa500d0b1c2fccf1e2a547a77bb54c1002092a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 18:45:41 +0100 Subject: [PATCH 18/53] Launch the error report application instead of sending an email. --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 3 ++- code/nel/src/misc/report.cpp | 38 ++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index c7667acc2..3f0c26f69 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -83,7 +83,8 @@ using namespace std; #define LOG_IN_FILE NEL_LOG_IN_FILE // If true, debug system will trap crash even if the application is in debugger -static const bool TrapCrashInDebugger = false; +//static const bool TrapCrashInDebugger = false; +static const bool TrapCrashInDebugger = true; #ifdef DEBUG_NEW #define new DEBUG_NEW diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 20b2b1c11..d761373fd 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -92,6 +92,36 @@ static bool CanSendMailReport= false; static bool DebugDefaultBehavior, QuitDefaultBehavior; +static void doSendReport() +{ + std::string filename; + + // Unfortunately Qt 4.8.5 on Windows messes up arguments. + // As a workaround the report filename is hardcoded for now. + // + //filename = "report_"; + //filename += NLMISC::toString( time( NULL ) ); + //filename += ".txt"; + + filename = "rcerrorlog.txt"; + + std::ofstream f; + f.open( filename.c_str() ); + if( !f.good() ) + return; + + f << Body; + + f.close(); + +#ifdef NL_OS_WINDOWS + NLMISC::launchProgram( "rcerror.exe", filename ); +#else + NLMISC::launchProgram( "rcerror", filename ); +#endif + +} + static void sendEmail() { if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED) @@ -133,7 +163,7 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM } else if ((HWND) lParam == debug) { - sendEmail(); + doSendReport(); NeedExit = true; Result = ReportDebug; if (DebugDefaultBehavior) @@ -143,13 +173,13 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM } else if ((HWND) lParam == ignore) { - sendEmail(); + doSendReport(); NeedExit = true; Result = ReportIgnore; } else if ((HWND) lParam == quit) { - sendEmail(); + doSendReport(); NeedExit = true; Result = ReportQuit; @@ -191,7 +221,7 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM if (wParam == 27) { // ESC -> ignore - sendEmail(); + doSendReport(); NeedExit = true; Result = ReportIgnore; } From bdb20d32dd37be4e7b513e2be9a52c1a20896cdc Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 18:59:35 +0100 Subject: [PATCH 19/53] Copyright header changed to Nel... --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror.cpp | 2 +- code/nel/rcerror/rcerror_socket.cpp | 2 +- code/nel/rcerror/rcerror_socket.h | 2 +- code/nel/rcerror/rcerror_widget.cpp | 2 +- code/nel/rcerror/rcerror_widget.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/rcerror/rcerror.cpp index 0d5088167..4f9174f78 100644 --- a/code/nel/rcerror/rcerror.cpp +++ b/code/nel/rcerror/rcerror.cpp @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index 8a011c046..721265d1e 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h index a37fa32d0..f64b8a708 100644 --- a/code/nel/rcerror/rcerror_socket.h +++ b/code/nel/rcerror/rcerror_socket.h @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index a28afbca6..86c68504e 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h index 1dd51c2af..7393793e9 100644 --- a/code/nel/rcerror/rcerror_widget.h +++ b/code/nel/rcerror/rcerror_widget.h @@ -1,4 +1,4 @@ -// Ryzom Core MMORPG framework - Error Reporter +// Nel MMORPG framework - Error Reporter // // Copyright (C) 2015 Laszlo Kis-Adam // Copyright (C) 2010 Ryzom Core From b5c72182edfb8b26b74efaa2f7bb0474ff2ada0a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:04:11 +0100 Subject: [PATCH 20/53] Class names in Nel start with a C... --HG-- branch : feature-crashreport --- code/nel/rcerror/rcerror.cpp | 2 +- code/nel/rcerror/rcerror_data.h | 2 +- code/nel/rcerror/rcerror_socket.cpp | 12 ++++++------ code/nel/rcerror/rcerror_socket.h | 12 ++++++------ code/nel/rcerror/rcerror_widget.cpp | 20 ++++++++++---------- code/nel/rcerror/rcerror_widget.h | 10 +++++----- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/rcerror/rcerror.cpp index 4f9174f78..f26886735 100644 --- a/code/nel/rcerror/rcerror.cpp +++ b/code/nel/rcerror/rcerror.cpp @@ -25,7 +25,7 @@ int main( int argc, char **argv ) { QApplication app( argc, argv ); - RCErrorWidget w; + CRCErrorWidget w; w.setFileName( "rcerrorlog.txt" ); w.show(); diff --git a/code/nel/rcerror/rcerror_data.h b/code/nel/rcerror/rcerror_data.h index 9f12b12fd..8accc75a3 100644 --- a/code/nel/rcerror/rcerror_data.h +++ b/code/nel/rcerror/rcerror_data.h @@ -23,7 +23,7 @@ #include -struct RCErrorData +struct SRCErrorData { QString description; QString report; diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/rcerror/rcerror_socket.cpp index 721265d1e..720cb792b 100644 --- a/code/nel/rcerror/rcerror_socket.cpp +++ b/code/nel/rcerror/rcerror_socket.cpp @@ -27,26 +27,26 @@ namespace static const char *BUG_URL = "http://192.168.2.66/dfighter/r.php"; } -class RCErrorSocketPvt +class CRCErrorSocketPvt { public: QNetworkAccessManager mgr; }; -RCErrorSocket::RCErrorSocket( QObject *parent ) : +CRCErrorSocket::CRCErrorSocket( QObject *parent ) : QObject( parent ) { - m_pvt = new RCErrorSocketPvt(); + m_pvt = new CRCErrorSocketPvt(); connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply* ) ) ); } -RCErrorSocket::~RCErrorSocket() +CRCErrorSocket::~CRCErrorSocket() { delete m_pvt; } -void RCErrorSocket::sendReport( const RCErrorData &data ) +void CRCErrorSocket::sendReport( const SRCErrorData &data ) { QUrl params; params.addQueryItem( "report", data.report ); @@ -60,7 +60,7 @@ void RCErrorSocket::sendReport( const RCErrorData &data ) m_pvt->mgr.post( request, params.encodedQuery() ); } -void RCErrorSocket::onFinished( QNetworkReply *reply ) +void CRCErrorSocket::onFinished( QNetworkReply *reply ) { if( reply->error() != QNetworkReply::NoError ) Q_EMIT reportFailed(); diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/rcerror/rcerror_socket.h index f64b8a708..95092a250 100644 --- a/code/nel/rcerror/rcerror_socket.h +++ b/code/nel/rcerror/rcerror_socket.h @@ -23,18 +23,18 @@ #include #include "rcerror_data.h" -class RCErrorSocketPvt; +class CRCErrorSocketPvt; class QNetworkReply; -class RCErrorSocket : public QObject +class CRCErrorSocket : public QObject { Q_OBJECT public: - RCErrorSocket( QObject *parent ); - ~RCErrorSocket(); + CRCErrorSocket( QObject *parent ); + ~CRCErrorSocket(); - void sendReport( const RCErrorData &data ); + void sendReport( const SRCErrorData &data ); Q_SIGNALS: void reportSent(); @@ -44,7 +44,7 @@ private Q_SLOTS: void onFinished( QNetworkReply *reply ); private: - RCErrorSocketPvt *m_pvt; + CRCErrorSocketPvt *m_pvt; }; #endif diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/rcerror/rcerror_widget.cpp index 86c68504e..04d06ff94 100644 --- a/code/nel/rcerror/rcerror_widget.cpp +++ b/code/nel/rcerror/rcerror_widget.cpp @@ -25,12 +25,12 @@ #include #include -RCErrorWidget::RCErrorWidget( QWidget *parent ) : +CRCErrorWidget::CRCErrorWidget( QWidget *parent ) : QWidget( parent ) { m_ui.setupUi( this ); - m_socket = new RCErrorSocket( this ); + m_socket = new CRCErrorSocket( this ); QTimer::singleShot( 1, this, SLOT( onLoad() ) ); @@ -42,12 +42,12 @@ QWidget( parent ) connect( m_socket, SIGNAL( reportFailed() ), this, SLOT( onReportFailed() ) ); } -RCErrorWidget::~RCErrorWidget() +CRCErrorWidget::~CRCErrorWidget() { m_socket = NULL; } -void RCErrorWidget::onLoad() +void CRCErrorWidget::onLoad() { QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); @@ -64,12 +64,12 @@ void RCErrorWidget::onLoad() f.close(); } -void RCErrorWidget::onSendClicked() +void CRCErrorWidget::onSendClicked() { m_ui.sendButton->setEnabled( false ); QApplication::setOverrideCursor( Qt::WaitCursor ); - RCErrorData data; + SRCErrorData data; data.description = m_ui.descriptionEdit->toPlainText(); data.report = m_ui.reportEdit->toPlainText(); data.email = m_ui.emailEdit->text(); @@ -77,17 +77,17 @@ void RCErrorWidget::onSendClicked() m_socket->sendReport( data ); } -void RCErrorWidget::onCancelClicked() +void CRCErrorWidget::onCancelClicked() { close(); } -void RCErrorWidget::onCBClicked() +void CRCErrorWidget::onCBClicked() { m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } -void RCErrorWidget::onReportSent() +void CRCErrorWidget::onReportSent() { QApplication::setOverrideCursor( Qt::ArrowCursor ); @@ -98,7 +98,7 @@ void RCErrorWidget::onReportSent() close(); } -void RCErrorWidget::onReportFailed() +void CRCErrorWidget::onReportFailed() { QApplication::setOverrideCursor( Qt::ArrowCursor ); diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/rcerror/rcerror_widget.h index 7393793e9..1d016fa52 100644 --- a/code/nel/rcerror/rcerror_widget.h +++ b/code/nel/rcerror/rcerror_widget.h @@ -23,14 +23,14 @@ #include "ui_rcerror_widget.h" -class RCErrorSocket; +class CRCErrorSocket; -class RCErrorWidget : public QWidget +class CRCErrorWidget : public QWidget { Q_OBJECT public: - RCErrorWidget( QWidget *parent = NULL ); - ~RCErrorWidget(); + CRCErrorWidget( QWidget *parent = NULL ); + ~CRCErrorWidget(); void setFileName( const char *fn ){ m_fileName = fn; } @@ -46,7 +46,7 @@ private Q_SLOTS: private: Ui::RCErrorWidget m_ui; QString m_fileName; - RCErrorSocket *m_socket; + CRCErrorSocket *m_socket; }; #endif From 4ec87b3d6ddaa2a02e0e884364c92b42cab93066 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:24:38 +0100 Subject: [PATCH 21/53] Moved to nel\tools\misc --HG-- branch : feature-crashreport --- code/nel/CMakeLists.txt | 4 ---- code/nel/tools/misc/CMakeLists.txt | 1 + code/nel/{ => tools/misc}/rcerror/CMakeLists.txt | 0 code/nel/{ => tools/misc}/rcerror/rcerror.cpp | 0 code/nel/{ => tools/misc}/rcerror/rcerror_data.h | 0 code/nel/{ => tools/misc}/rcerror/rcerror_socket.cpp | 0 code/nel/{ => tools/misc}/rcerror/rcerror_socket.h | 0 code/nel/{ => tools/misc}/rcerror/rcerror_widget.cpp | 0 code/nel/{ => tools/misc}/rcerror/rcerror_widget.h | 0 code/nel/{ => tools/misc}/rcerror/rcerror_widget.ui | 0 10 files changed, 1 insertion(+), 4 deletions(-) rename code/nel/{ => tools/misc}/rcerror/CMakeLists.txt (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror.cpp (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_data.h (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_socket.cpp (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_socket.h (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_widget.cpp (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_widget.h (100%) rename code/nel/{ => tools/misc}/rcerror/rcerror_widget.ui (100%) diff --git a/code/nel/CMakeLists.txt b/code/nel/CMakeLists.txt index 00290d097..16a8166fe 100644 --- a/code/nel/CMakeLists.txt +++ b/code/nel/CMakeLists.txt @@ -83,7 +83,3 @@ IF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) ENDIF(WITH_NEL_TOOLS) ADD_SUBDIRECTORY(tools) ENDIF(WITH_NEL_TOOLS OR WITH_NEL_MAXPLUGIN) - -IF(WITH_QT) - ADD_SUBDIRECTORY(rcerror) -ENDIF(WITH_QT) diff --git a/code/nel/tools/misc/CMakeLists.txt b/code/nel/tools/misc/CMakeLists.txt index 5386cbbc6..1cda7e8e6 100644 --- a/code/nel/tools/misc/CMakeLists.txt +++ b/code/nel/tools/misc/CMakeLists.txt @@ -3,6 +3,7 @@ SUBDIRS(bnp_make disp_sheet_id extract_filename lock make_sheet_id xml_packer) IF(WITH_QT) ADD_SUBDIRECTORY(words_dic_qt) ADD_SUBDIRECTORY(message_box_qt) + ADD_SUBDIRECTORY(rcerror) ENDIF(WITH_QT) IF(WIN32) diff --git a/code/nel/rcerror/CMakeLists.txt b/code/nel/tools/misc/rcerror/CMakeLists.txt similarity index 100% rename from code/nel/rcerror/CMakeLists.txt rename to code/nel/tools/misc/rcerror/CMakeLists.txt diff --git a/code/nel/rcerror/rcerror.cpp b/code/nel/tools/misc/rcerror/rcerror.cpp similarity index 100% rename from code/nel/rcerror/rcerror.cpp rename to code/nel/tools/misc/rcerror/rcerror.cpp diff --git a/code/nel/rcerror/rcerror_data.h b/code/nel/tools/misc/rcerror/rcerror_data.h similarity index 100% rename from code/nel/rcerror/rcerror_data.h rename to code/nel/tools/misc/rcerror/rcerror_data.h diff --git a/code/nel/rcerror/rcerror_socket.cpp b/code/nel/tools/misc/rcerror/rcerror_socket.cpp similarity index 100% rename from code/nel/rcerror/rcerror_socket.cpp rename to code/nel/tools/misc/rcerror/rcerror_socket.cpp diff --git a/code/nel/rcerror/rcerror_socket.h b/code/nel/tools/misc/rcerror/rcerror_socket.h similarity index 100% rename from code/nel/rcerror/rcerror_socket.h rename to code/nel/tools/misc/rcerror/rcerror_socket.h diff --git a/code/nel/rcerror/rcerror_widget.cpp b/code/nel/tools/misc/rcerror/rcerror_widget.cpp similarity index 100% rename from code/nel/rcerror/rcerror_widget.cpp rename to code/nel/tools/misc/rcerror/rcerror_widget.cpp diff --git a/code/nel/rcerror/rcerror_widget.h b/code/nel/tools/misc/rcerror/rcerror_widget.h similarity index 100% rename from code/nel/rcerror/rcerror_widget.h rename to code/nel/tools/misc/rcerror/rcerror_widget.h diff --git a/code/nel/rcerror/rcerror_widget.ui b/code/nel/tools/misc/rcerror/rcerror_widget.ui similarity index 100% rename from code/nel/rcerror/rcerror_widget.ui rename to code/nel/tools/misc/rcerror/rcerror_widget.ui From 195dfcc3f3061d714c4a9ae7ba0557a33a031072 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:26:03 +0100 Subject: [PATCH 22/53] Changed default title to NeL Error Report. --HG-- branch : feature-crashreport --- code/nel/tools/misc/rcerror/rcerror_widget.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/tools/misc/rcerror/rcerror_widget.ui b/code/nel/tools/misc/rcerror/rcerror_widget.ui index 72e5f92f5..b92ac65a6 100644 --- a/code/nel/tools/misc/rcerror/rcerror_widget.ui +++ b/code/nel/tools/misc/rcerror/rcerror_widget.ui @@ -14,7 +14,7 @@ - Ryzom Core error report + NeL Error Report From 97de06bff27a607df229b3eb4131d2573a5cff99 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:28:02 +0100 Subject: [PATCH 23/53] renamed directory. --HG-- branch : feature-crashreport --- code/nel/tools/misc/CMakeLists.txt | 2 +- code/nel/tools/misc/{rcerror => crash_report}/CMakeLists.txt | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror.cpp | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror_data.h | 0 .../nel/tools/misc/{rcerror => crash_report}/rcerror_socket.cpp | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror_socket.h | 0 .../nel/tools/misc/{rcerror => crash_report}/rcerror_widget.cpp | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.h | 0 code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.ui | 0 9 files changed, 1 insertion(+), 1 deletion(-) rename code/nel/tools/misc/{rcerror => crash_report}/CMakeLists.txt (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror.cpp (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_data.h (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_socket.cpp (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_socket.h (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.cpp (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.h (100%) rename code/nel/tools/misc/{rcerror => crash_report}/rcerror_widget.ui (100%) diff --git a/code/nel/tools/misc/CMakeLists.txt b/code/nel/tools/misc/CMakeLists.txt index 1cda7e8e6..c9bbcd058 100644 --- a/code/nel/tools/misc/CMakeLists.txt +++ b/code/nel/tools/misc/CMakeLists.txt @@ -3,7 +3,7 @@ SUBDIRS(bnp_make disp_sheet_id extract_filename lock make_sheet_id xml_packer) IF(WITH_QT) ADD_SUBDIRECTORY(words_dic_qt) ADD_SUBDIRECTORY(message_box_qt) - ADD_SUBDIRECTORY(rcerror) + ADD_SUBDIRECTORY(crash_report) ENDIF(WITH_QT) IF(WIN32) diff --git a/code/nel/tools/misc/rcerror/CMakeLists.txt b/code/nel/tools/misc/crash_report/CMakeLists.txt similarity index 100% rename from code/nel/tools/misc/rcerror/CMakeLists.txt rename to code/nel/tools/misc/crash_report/CMakeLists.txt diff --git a/code/nel/tools/misc/rcerror/rcerror.cpp b/code/nel/tools/misc/crash_report/rcerror.cpp similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror.cpp rename to code/nel/tools/misc/crash_report/rcerror.cpp diff --git a/code/nel/tools/misc/rcerror/rcerror_data.h b/code/nel/tools/misc/crash_report/rcerror_data.h similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_data.h rename to code/nel/tools/misc/crash_report/rcerror_data.h diff --git a/code/nel/tools/misc/rcerror/rcerror_socket.cpp b/code/nel/tools/misc/crash_report/rcerror_socket.cpp similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_socket.cpp rename to code/nel/tools/misc/crash_report/rcerror_socket.cpp diff --git a/code/nel/tools/misc/rcerror/rcerror_socket.h b/code/nel/tools/misc/crash_report/rcerror_socket.h similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_socket.h rename to code/nel/tools/misc/crash_report/rcerror_socket.h diff --git a/code/nel/tools/misc/rcerror/rcerror_widget.cpp b/code/nel/tools/misc/crash_report/rcerror_widget.cpp similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_widget.cpp rename to code/nel/tools/misc/crash_report/rcerror_widget.cpp diff --git a/code/nel/tools/misc/rcerror/rcerror_widget.h b/code/nel/tools/misc/crash_report/rcerror_widget.h similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_widget.h rename to code/nel/tools/misc/crash_report/rcerror_widget.h diff --git a/code/nel/tools/misc/rcerror/rcerror_widget.ui b/code/nel/tools/misc/crash_report/rcerror_widget.ui similarity index 100% rename from code/nel/tools/misc/rcerror/rcerror_widget.ui rename to code/nel/tools/misc/crash_report/rcerror_widget.ui From 6be70dd39c090d1d80ff80d08695f51cd726fce8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:33:12 +0100 Subject: [PATCH 24/53] Renames. --HG-- branch : feature-crashreport --- .../tools/misc/crash_report/CMakeLists.txt | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/code/nel/tools/misc/crash_report/CMakeLists.txt b/code/nel/tools/misc/crash_report/CMakeLists.txt index 51522cf0c..0e2d2a9bc 100644 --- a/code/nel/tools/misc/crash_report/CMakeLists.txt +++ b/code/nel/tools/misc/crash_report/CMakeLists.txt @@ -1,14 +1,14 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SRC_DIR} ${QT_INCLUDES}) -FILE(GLOB RCERROR_SRC *.cpp) -FILE(GLOB RCERROR_HDR *h) +FILE(GLOB CRASHREPORT_SRC *.cpp) +FILE(GLOB CRASHREPORT_HDR *h) -SET(RCERROR_MOC_HDR -rcerror_socket.h -rcerror_widget.h +SET(CRASHREPORT_MOC_HDR +crash_report_socket.h +crash_report_widget.h ) -SET(RCERROR_UI -rcerror_widget.ui +SET(CRASHREPORT_UI +crash_report_widget.ui ) SET(QT_USE_QTGUI TRUE) @@ -20,20 +20,20 @@ SET(QT_USE_QTXML FALSE) INCLUDE(${QT_USE_FILE}) ADD_DEFINITIONS(${QT_DEFINITIONS}) -QT4_WRAP_CPP(RCERROR_MOC_SRC ${RCERROR_MOC_HDR}) -QT4_WRAP_UI(RCERROR_UI_HDR ${RCERROR_UI}) +QT4_WRAP_CPP(CRASHREPORT_MOC_SRC ${CRASHREPORT_MOC_HDR}) +QT4_WRAP_UI(CRASHREPORT_UI_HDR ${CRASHREPORT_UI}) -SOURCE_GROUP(QtResources FILES ${RCERROR_UI}) -SOURCE_GROUP(QtGeneratedUiHdr FILES ${RCERROR_UI_HDR}) -SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${RCERROR_MOC_SRC}) -SOURCE_GROUP("source files" FILES ${RCERROR_SRC}) -SOURCE_GROUP("header files" FILES ${RCERROR_HDR}) +SOURCE_GROUP(QtResources FILES ${CRASHREPORT_UI}) +SOURCE_GROUP(QtGeneratedUiHdr FILES ${CRASHREPORT_UI_HDR}) +SOURCE_GROUP(QtGeneratedMocQrcSrc FILES ${CRASHREPORT_MOC_SRC}) +SOURCE_GROUP("source files" FILES ${CRASHREPORT_SRC}) +SOURCE_GROUP("header files" FILES ${CRASHREPORT_HDR}) -ADD_EXECUTABLE(rcerror WIN32 MACOSX_BUNDLE ${RCERROR_SRC} ${RCERROR_MOC_HDR} ${RCERROR_MOC_SRC} ${RCERROR_UI_HDR}) -TARGET_LINK_LIBRARIES(rcerror ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) +ADD_EXECUTABLE(crash_report WIN32 MACOSX_BUNDLE ${CRASHREPORT_SRC} ${CRASHREPORT_MOC_HDR} ${CRASHREPORT_MOC_SRC} ${CRASHREPORT_UI_HDR}) +TARGET_LINK_LIBRARIES(crash_report ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) -NL_DEFAULT_PROPS(rcerror "Ryzom Core Error Reporter") -NL_ADD_RUNTIME_FLAGS(rcerror) +NL_DEFAULT_PROPS(crash_report "NeL, Tools, Misc: Crash Report") +NL_ADD_RUNTIME_FLAGS(crash_report) -INSTALL(TARGETS rcerror RUNTIME DESTINATION ${NL_BIN_PREFIX}) +INSTALL(TARGETS crash_report RUNTIME DESTINATION ${NL_BIN_PREFIX}) From 39879717926f8bfdc06fefe1f0158bad1cf31165 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:33:38 +0100 Subject: [PATCH 25/53] Renames. --HG-- branch : feature-crashreport --- .../nel/tools/misc/crash_report/{rcerror.cpp => crash_report.cpp} | 0 .../misc/crash_report/{rcerror_data.h => crash_report_data.h} | 0 .../crash_report/{rcerror_socket.cpp => crash_report_socket.cpp} | 0 .../misc/crash_report/{rcerror_socket.h => crash_report_socket.h} | 0 .../crash_report/{rcerror_widget.cpp => crash_report_widget.cpp} | 0 .../misc/crash_report/{rcerror_widget.h => crash_report_widget.h} | 0 .../crash_report/{rcerror_widget.ui => crash_report_widget.ui} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename code/nel/tools/misc/crash_report/{rcerror.cpp => crash_report.cpp} (100%) rename code/nel/tools/misc/crash_report/{rcerror_data.h => crash_report_data.h} (100%) rename code/nel/tools/misc/crash_report/{rcerror_socket.cpp => crash_report_socket.cpp} (100%) rename code/nel/tools/misc/crash_report/{rcerror_socket.h => crash_report_socket.h} (100%) rename code/nel/tools/misc/crash_report/{rcerror_widget.cpp => crash_report_widget.cpp} (100%) rename code/nel/tools/misc/crash_report/{rcerror_widget.h => crash_report_widget.h} (100%) rename code/nel/tools/misc/crash_report/{rcerror_widget.ui => crash_report_widget.ui} (100%) diff --git a/code/nel/tools/misc/crash_report/rcerror.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror.cpp rename to code/nel/tools/misc/crash_report/crash_report.cpp diff --git a/code/nel/tools/misc/crash_report/rcerror_data.h b/code/nel/tools/misc/crash_report/crash_report_data.h similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_data.h rename to code/nel/tools/misc/crash_report/crash_report_data.h diff --git a/code/nel/tools/misc/crash_report/rcerror_socket.cpp b/code/nel/tools/misc/crash_report/crash_report_socket.cpp similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_socket.cpp rename to code/nel/tools/misc/crash_report/crash_report_socket.cpp diff --git a/code/nel/tools/misc/crash_report/rcerror_socket.h b/code/nel/tools/misc/crash_report/crash_report_socket.h similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_socket.h rename to code/nel/tools/misc/crash_report/crash_report_socket.h diff --git a/code/nel/tools/misc/crash_report/rcerror_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_widget.cpp rename to code/nel/tools/misc/crash_report/crash_report_widget.cpp diff --git a/code/nel/tools/misc/crash_report/rcerror_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_widget.h rename to code/nel/tools/misc/crash_report/crash_report_widget.h diff --git a/code/nel/tools/misc/crash_report/rcerror_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui similarity index 100% rename from code/nel/tools/misc/crash_report/rcerror_widget.ui rename to code/nel/tools/misc/crash_report/crash_report_widget.ui From cfe2d603503d7da01e87dc8e14a90942e7544843 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 19:52:01 +0100 Subject: [PATCH 26/53] More renames... --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 4 +-- .../tools/misc/crash_report/crash_report.cpp | 4 +-- .../misc/crash_report/crash_report_data.h | 2 +- .../misc/crash_report/crash_report_socket.cpp | 14 +++++----- .../misc/crash_report/crash_report_socket.h | 14 +++++----- .../misc/crash_report/crash_report_widget.cpp | 26 +++++++++---------- .../misc/crash_report/crash_report_widget.h | 14 +++++----- .../misc/crash_report/crash_report_widget.ui | 4 +-- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index d761373fd..09cfc1178 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -115,9 +115,9 @@ static void doSendReport() f.close(); #ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "rcerror.exe", filename ); + NLMISC::launchProgram( "crash_report.exe", filename ); #else - NLMISC::launchProgram( "rcerror", filename ); + NLMISC::launchProgram( "crash_report", filename ); #endif } diff --git a/code/nel/tools/misc/crash_report/crash_report.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp index f26886735..d04928d21 100644 --- a/code/nel/tools/misc/crash_report/crash_report.cpp +++ b/code/nel/tools/misc/crash_report/crash_report.cpp @@ -17,7 +17,7 @@ // along with this program. If not, see . -#include "rcerror_widget.h" +#include "crash_report_widget.h" #include #include @@ -25,7 +25,7 @@ int main( int argc, char **argv ) { QApplication app( argc, argv ); - CRCErrorWidget w; + CCrashReportWidget w; w.setFileName( "rcerrorlog.txt" ); w.show(); diff --git a/code/nel/tools/misc/crash_report/crash_report_data.h b/code/nel/tools/misc/crash_report/crash_report_data.h index 8accc75a3..5884e7eb4 100644 --- a/code/nel/tools/misc/crash_report/crash_report_data.h +++ b/code/nel/tools/misc/crash_report/crash_report_data.h @@ -23,7 +23,7 @@ #include -struct SRCErrorData +struct SCrashReportData { QString description; QString report; diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.cpp b/code/nel/tools/misc/crash_report/crash_report_socket.cpp index 720cb792b..209ea89e8 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_socket.cpp @@ -16,7 +16,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "rcerror_socket.h" +#include "crash_report_socket.h" #include #include #include @@ -27,26 +27,26 @@ namespace static const char *BUG_URL = "http://192.168.2.66/dfighter/r.php"; } -class CRCErrorSocketPvt +class CCrashReportSocketPvt { public: QNetworkAccessManager mgr; }; -CRCErrorSocket::CRCErrorSocket( QObject *parent ) : +CCrashReportSocket::CCrashReportSocket( QObject *parent ) : QObject( parent ) { - m_pvt = new CRCErrorSocketPvt(); + m_pvt = new CCrashReportSocketPvt(); connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply* ) ) ); } -CRCErrorSocket::~CRCErrorSocket() +CCrashReportSocket::~CCrashReportSocket() { delete m_pvt; } -void CRCErrorSocket::sendReport( const SRCErrorData &data ) +void CCrashReportSocket::sendReport( const SCrashReportData &data ) { QUrl params; params.addQueryItem( "report", data.report ); @@ -60,7 +60,7 @@ void CRCErrorSocket::sendReport( const SRCErrorData &data ) m_pvt->mgr.post( request, params.encodedQuery() ); } -void CRCErrorSocket::onFinished( QNetworkReply *reply ) +void CCrashReportSocket::onFinished( QNetworkReply *reply ) { if( reply->error() != QNetworkReply::NoError ) Q_EMIT reportFailed(); diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.h b/code/nel/tools/misc/crash_report/crash_report_socket.h index 95092a250..24bf6c451 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.h +++ b/code/nel/tools/misc/crash_report/crash_report_socket.h @@ -21,20 +21,20 @@ #define RCERROR_SOCKET #include -#include "rcerror_data.h" +#include "crash_report_data.h" -class CRCErrorSocketPvt; +class CCrashReportSocketPvt; class QNetworkReply; -class CRCErrorSocket : public QObject +class CCrashReportSocket : public QObject { Q_OBJECT public: - CRCErrorSocket( QObject *parent ); - ~CRCErrorSocket(); + CCrashReportSocket( QObject *parent ); + ~CCrashReportSocket(); - void sendReport( const SRCErrorData &data ); + void sendReport( const SCrashReportData &data ); Q_SIGNALS: void reportSent(); @@ -44,7 +44,7 @@ private Q_SLOTS: void onFinished( QNetworkReply *reply ); private: - CRCErrorSocketPvt *m_pvt; + CCrashReportSocketPvt *m_pvt; }; #endif diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 04d06ff94..49925765d 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -17,20 +17,20 @@ // along with this program. If not, see . -#include "rcerror_widget.h" -#include "rcerror_socket.h" -#include "rcerror_data.h" +#include "crash_report_widget.h" +#include "crash_report_socket.h" +#include "crash_report_data.h" #include #include #include #include -CRCErrorWidget::CRCErrorWidget( QWidget *parent ) : +CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : QWidget( parent ) { m_ui.setupUi( this ); - m_socket = new CRCErrorSocket( this ); + m_socket = new CCrashReportSocket( this ); QTimer::singleShot( 1, this, SLOT( onLoad() ) ); @@ -42,12 +42,12 @@ QWidget( parent ) connect( m_socket, SIGNAL( reportFailed() ), this, SLOT( onReportFailed() ) ); } -CRCErrorWidget::~CRCErrorWidget() +CCrashReportWidget::~CCrashReportWidget() { m_socket = NULL; } -void CRCErrorWidget::onLoad() +void CCrashReportWidget::onLoad() { QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); @@ -64,12 +64,12 @@ void CRCErrorWidget::onLoad() f.close(); } -void CRCErrorWidget::onSendClicked() +void CCrashReportWidget::onSendClicked() { m_ui.sendButton->setEnabled( false ); QApplication::setOverrideCursor( Qt::WaitCursor ); - SRCErrorData data; + SCrashReportData data; data.description = m_ui.descriptionEdit->toPlainText(); data.report = m_ui.reportEdit->toPlainText(); data.email = m_ui.emailEdit->text(); @@ -77,17 +77,17 @@ void CRCErrorWidget::onSendClicked() m_socket->sendReport( data ); } -void CRCErrorWidget::onCancelClicked() +void CCrashReportWidget::onCancelClicked() { close(); } -void CRCErrorWidget::onCBClicked() +void CCrashReportWidget::onCBClicked() { m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } -void CRCErrorWidget::onReportSent() +void CCrashReportWidget::onReportSent() { QApplication::setOverrideCursor( Qt::ArrowCursor ); @@ -98,7 +98,7 @@ void CRCErrorWidget::onReportSent() close(); } -void CRCErrorWidget::onReportFailed() +void CCrashReportWidget::onReportFailed() { QApplication::setOverrideCursor( Qt::ArrowCursor ); diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index 1d016fa52..47d16ad77 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -21,16 +21,16 @@ #define RCERROR_WIDGET -#include "ui_rcerror_widget.h" +#include "ui_crash_report_widget.h" -class CRCErrorSocket; +class CCrashReportSocket; -class CRCErrorWidget : public QWidget +class CCrashReportWidget : public QWidget { Q_OBJECT public: - CRCErrorWidget( QWidget *parent = NULL ); - ~CRCErrorWidget(); + CCrashReportWidget( QWidget *parent = NULL ); + ~CCrashReportWidget(); void setFileName( const char *fn ){ m_fileName = fn; } @@ -44,9 +44,9 @@ private Q_SLOTS: void onReportFailed(); private: - Ui::RCErrorWidget m_ui; + Ui::CrashReportWidget m_ui; QString m_fileName; - CRCErrorSocket *m_socket; + CCrashReportSocket *m_socket; }; #endif diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui index b92ac65a6..589810578 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -1,7 +1,7 @@ - RCErrorWidget - + CrashReportWidget + Qt::ApplicationModal From 955ef484608242126953099a8c5935f263143e96 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 21:51:17 +0100 Subject: [PATCH 27/53] Parametrize crash reporter. --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 21 ++++--- .../tools/misc/crash_report/crash_report.cpp | 61 ++++++++++++++++++- .../misc/crash_report/crash_report_socket.cpp | 7 +-- .../misc/crash_report/crash_report_socket.h | 4 ++ .../misc/crash_report/crash_report_widget.cpp | 56 ++++++++++++++++- .../misc/crash_report/crash_report_widget.h | 7 +++ 6 files changed, 139 insertions(+), 17 deletions(-) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 09cfc1178..58740ce28 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -92,18 +92,21 @@ static bool CanSendMailReport= false; static bool DebugDefaultBehavior, QuitDefaultBehavior; +static std::string URL = "FILL_IN_CRASH_REPORT_HOSTNAME_HERE"; + static void doSendReport() { std::string filename; - // Unfortunately Qt 4.8.5 on Windows messes up arguments. - // As a workaround the report filename is hardcoded for now. - // - //filename = "report_"; - //filename += NLMISC::toString( time( NULL ) ); - //filename += ".txt"; + filename = "report_"; + filename += NLMISC::toString( time( NULL ) ); + filename += ".txt"; - filename = "rcerrorlog.txt"; + std::string params; + params = "-log "; + params += filename; + params += " -host "; + params += URL; std::ofstream f; f.open( filename.c_str() ); @@ -115,9 +118,9 @@ static void doSendReport() f.close(); #ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "crash_report.exe", filename ); + NLMISC::launchProgram( "crash_report.exe", params ); #else - NLMISC::launchProgram( "crash_report", filename ); + NLMISC::launchProgram( "crash_report", params ); #endif } diff --git a/code/nel/tools/misc/crash_report/crash_report.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp index d04928d21..e083de126 100644 --- a/code/nel/tools/misc/crash_report/crash_report.cpp +++ b/code/nel/tools/misc/crash_report/crash_report.cpp @@ -21,12 +21,71 @@ #include #include +#include +#include +#include + +class CCmdLineParser +{ +public: + static void parse( int argc, char **argv, std::vector< std::pair< std::string, std::string > > &v ) + { + std::stack< std::string > stack; + std::string key; + std::string value; + + for( int i = argc - 1 ; i >= 0; i-- ) + { + stack.push( std::string( argv[ i ] ) ); + } + + while( !stack.empty() ) + { + key = stack.top(); + stack.pop(); + + // If not a real parameter ( they start with '-' ), discard. + if( key[ 0 ] != '-' ) + continue; + + // Remove the '-' + key = key.substr( 1 ); + + // No more parameters + if( stack.empty() ) + { + v.push_back( std::make_pair( key, "" ) ); + break; + } + + value = stack.top(); + + // If next parameter is a key, process it in the next iteration + if( value[ 0 ] == '-' ) + { + v.push_back( std::make_pair( key, "" ) ); + continue; + } + // Otherwise store the pair + else + { + v.push_back( std::make_pair( key, value ) ); + stack.pop(); + } + } + } +}; + int main( int argc, char **argv ) { QApplication app( argc, argv ); + std::vector< std::pair< std::string, std::string > > params; + + CCmdLineParser::parse( argc, argv, params ); + CCrashReportWidget w; - w.setFileName( "rcerrorlog.txt" ); + w.setup( params ); w.show(); return app.exec(); diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.cpp b/code/nel/tools/misc/crash_report/crash_report_socket.cpp index 209ea89e8..5f8720e05 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_socket.cpp @@ -22,11 +22,6 @@ #include #include -namespace -{ - static const char *BUG_URL = "http://192.168.2.66/dfighter/r.php"; -} - class CCrashReportSocketPvt { public: @@ -53,7 +48,7 @@ void CCrashReportSocket::sendReport( const SCrashReportData &data ) params.addQueryItem( "descr", data.description ); params.addQueryItem( "email", data.email ); - QUrl url( BUG_URL ); + QUrl url( m_url ); QNetworkRequest request( url ); request.setRawHeader( "Connection", "close" ); diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.h b/code/nel/tools/misc/crash_report/crash_report_socket.h index 24bf6c451..32ccc5da0 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.h +++ b/code/nel/tools/misc/crash_report/crash_report_socket.h @@ -34,6 +34,9 @@ public: CCrashReportSocket( QObject *parent ); ~CCrashReportSocket(); + void setURL( const char *URL ){ m_url = URL; } + QString url() const{ return m_url; } + void sendReport( const SCrashReportData &data ); Q_SIGNALS: @@ -45,6 +48,7 @@ private Q_SLOTS: private: CCrashReportSocketPvt *m_pvt; + QString m_url; }; #endif diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 49925765d..ff0028223 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -47,8 +47,39 @@ CCrashReportWidget::~CCrashReportWidget() m_socket = NULL; } +void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::string > > ¶ms ) +{ + for( int i = 0; i < params.size(); i++ ) + { + const std::pair< std::string, std::string > &p = params[ i ]; + const std::string &k = p.first; + const std::string &v = p.second; + + if( k == "log" ) + { + m_fileName = v.c_str(); + } + else + if( k == "host" ) + { + m_socket->setURL( v.c_str() ); + } + else + if( k == "title" ) + { + setWindowTitle( v.c_str() ); + } + } +} + void CCrashReportWidget::onLoad() { + if( !checkSettings() ) + { + close(); + return; + } + QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); if( !b ) @@ -57,6 +88,7 @@ void CCrashReportWidget::onLoad() tr( "No log file found" ), tr( "There was no log file found, therefore nothing to report. Exiting..." ) ); close(); + return; } QTextStream ss( &f ); @@ -107,4 +139,26 @@ void CCrashReportWidget::onReportFailed() tr( "Failed to send the report..." ) ); close(); -} \ No newline at end of file +} + +bool CCrashReportWidget::checkSettings() +{ + if( m_fileName.isEmpty() ) + { + QMessageBox::information( this, + tr( "No log file specified." ), + tr( "No log file specified. Exiting..." ) ); + return false; + } + + if( m_socket->url().isEmpty() ) + { + QMessageBox::information( this, + tr( "No host specified." ), + tr( "No host specified. Exiting..." ) ); + return false; + } + + return true; +} + diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index 47d16ad77..0baf2521d 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -22,6 +22,8 @@ #include "ui_crash_report_widget.h" +#include +#include class CCrashReportSocket; @@ -34,6 +36,8 @@ public: void setFileName( const char *fn ){ m_fileName = fn; } + void setup( const std::vector< std::pair< std::string, std::string > > ¶ms ); + private Q_SLOTS: void onLoad(); void onSendClicked(); @@ -44,6 +48,9 @@ private Q_SLOTS: void onReportFailed(); private: + bool checkSettings(); + + Ui::CrashReportWidget m_ui; QString m_fileName; CCrashReportSocket *m_socket; From 2bb5e8e9ba6be80184635505cc570176b1a153b7 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 22 Feb 2015 22:34:07 +0100 Subject: [PATCH 28/53] Remove generated log file when quitting the reporter. --HG-- branch : feature-crashreport --- .../tools/misc/crash_report/crash_report_widget.cpp | 13 ++++++++++--- .../tools/misc/crash_report/crash_report_widget.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index ff0028223..968978f94 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -24,6 +24,7 @@ #include #include #include +#include CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : QWidget( parent ) @@ -111,7 +112,7 @@ void CCrashReportWidget::onSendClicked() void CCrashReportWidget::onCancelClicked() { - close(); + removeAndQuit(); } void CCrashReportWidget::onCBClicked() @@ -127,7 +128,7 @@ void CCrashReportWidget::onReportSent() tr( "Report sent" ), tr( "The report has been sent." ) ); - close(); + removeAndQuit(); } void CCrashReportWidget::onReportFailed() @@ -138,7 +139,7 @@ void CCrashReportWidget::onReportFailed() tr( "Report failed" ), tr( "Failed to send the report..." ) ); - close(); + removeAndQuit(); } bool CCrashReportWidget::checkSettings() @@ -162,3 +163,9 @@ bool CCrashReportWidget::checkSettings() return true; } +void CCrashReportWidget::removeAndQuit() +{ + QFile::remove( m_fileName ); + close(); +} + diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index 0baf2521d..61b56e340 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -49,7 +49,7 @@ private Q_SLOTS: private: bool checkSettings(); - + void removeAndQuit(); Ui::CrashReportWidget m_ui; QString m_fileName; From 8bf372056f1290301b75e38eac367eb74306383d Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 23 Feb 2015 01:36:50 +0100 Subject: [PATCH 29/53] Use CMsgBoxDisplayer on non-windows platforms as well. --HG-- branch : feature-crashreport --- code/nel/src/misc/debug.cpp | 2 +- code/nel/src/misc/displayer.cpp | 4 +- code/nel/src/misc/report.cpp | 79 ++++++++++++++++++--------------- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 3f0c26f69..86752a412 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -1197,10 +1197,10 @@ void createDebug (const char *logPath, bool logInFile, bool eraseLastLog) #ifdef NL_OS_WINDOWS if (TrapCrashInDebugger || !IsDebuggerPresent ()) +#endif { DefaultMsgBoxDisplayer = new CMsgBoxDisplayer ("DEFAULT_MBD"); } -#endif #if LOG_IN_FILE if (logInFile) diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index d48c44d02..86fc1d726 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -529,7 +529,7 @@ void CFileDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *mes // in release "" void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *message) { -#ifdef NL_OS_WINDOWS +//#ifdef NL_OS_WINDOWS bool needSpace = false; // stringstream ss; @@ -720,7 +720,7 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m } */ } -#endif +//#endif } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 58740ce28..784f49a9a 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -63,19 +63,61 @@ void setReportEmailFunction (void *emailFunction) #endif } +static string Body; +static std::string URL = "FILL_IN_CRASH_REPORT_HOSTNAME_HERE"; + + +static void doSendReport() +{ + std::string filename; + + filename = "report_"; + filename += NLMISC::toString( int( time( NULL ) ) ); + filename += ".txt"; + + std::string params; + params = "-log "; + params += filename; + params += " -host "; + params += URL; + + std::ofstream f; + f.open( filename.c_str() ); + if( !f.good() ) + return; + + f << Body; + + f.close(); + +#ifdef NL_OS_WINDOWS + NLMISC::launchProgram( "crash_report.exe", params ); +#else + NLMISC::launchProgram( "crash_report", params ); +#endif + + // Added because NLSMIC::launcProgram needs time to launch + nlSleep( 2 * 1000 ); + +} + #ifndef NL_OS_WINDOWS // GNU/Linux, do nothing -void report () +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) { + Body = addSlashR( body ); + + doSendReport(); + + return ReportQuit; } #else // Windows specific version -static string Body; static string Subject; static string AttachedFile; @@ -92,39 +134,6 @@ static bool CanSendMailReport= false; static bool DebugDefaultBehavior, QuitDefaultBehavior; -static std::string URL = "FILL_IN_CRASH_REPORT_HOSTNAME_HERE"; - -static void doSendReport() -{ - std::string filename; - - filename = "report_"; - filename += NLMISC::toString( time( NULL ) ); - filename += ".txt"; - - std::string params; - params = "-log "; - params += filename; - params += " -host "; - params += URL; - - std::ofstream f; - f.open( filename.c_str() ); - if( !f.good() ) - return; - - f << Body; - - f.close(); - -#ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "crash_report.exe", params ); -#else - NLMISC::launchProgram( "crash_report", params ); -#endif - -} - static void sendEmail() { if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED) From 6ae954326d761cc0b176ec83212afcd6c534095c Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 23 Feb 2015 19:23:15 +0100 Subject: [PATCH 30/53] GCC/Linux version of NLMISC_BREAKPOINT --HG-- branch : feature-crashreport --- code/nel/include/nel/misc/debug.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/misc/debug.h b/code/nel/include/nel/misc/debug.h index 690d340a3..8d2483e4e 100644 --- a/code/nel/include/nel/misc/debug.h +++ b/code/nel/include/nel/misc/debug.h @@ -350,8 +350,10 @@ void setCrashAlreadyReported(bool state); */ // removed because we always check assert (even in release mode) #if defined (NL_OS_WINDOWS) && defined (NL_DEBUG) -#if defined (NL_OS_WINDOWS) -#define NLMISC_BREAKPOINT __debugbreak(); +#if defined(NL_OS_WINDOWS) +#define NLMISC_BREAKPOINT __debugbreak() +#elif defined(NL_OS_UNIX) && defined(NL_COMP_GCC) +#define NLMISC_BREAKPOINT __builtin_trap() #else #define NLMISC_BREAKPOINT abort() #endif From e4e3f2019b427f862d34a5dce39746a889a7b7e2 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 23 Feb 2015 20:01:20 +0100 Subject: [PATCH 31/53] Add function to set custom host url. Deprecate email callback function. Add some comments --HG-- branch : feature-crashreport --- code/nel/include/nel/misc/report.h | 13 ++- code/nel/src/misc/report.cpp | 172 +++++++++++++---------------- 2 files changed, 85 insertions(+), 100 deletions(-) diff --git a/code/nel/include/nel/misc/report.h b/code/nel/include/nel/misc/report.h index 11745b6e3..c492f4aa2 100644 --- a/code/nel/include/nel/misc/report.h +++ b/code/nel/include/nel/misc/report.h @@ -21,9 +21,11 @@ namespace NLMISC { +enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError }; + /** Display a custom message box. * - * \param title set the title of the report. If empty, it'll display "NeL 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 header message displayed before the edit text box. If empty, it displays the default message. * \param body message displayed in the edit text box. This string will be sent by email. * \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior @@ -32,14 +34,15 @@ namespace NLMISC { * * \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 = ""); -enum TReportResult { ReportDebug, ReportIgnore, ReportQuit, ReportError }; - -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 = ""); +/// Set the Url of the web service used to post crash reports to +void setReportPostUrl(const std::string &postUrl); +/// DEPRECATED /** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail); */ -void setReportEmailFunction (void *emailFunction); +void setReportEmailFunction(void *emailFunction); } // NLMISC diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 784f49a9a..69ce40544 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -16,6 +16,8 @@ #include "stdmisc.h" +#include + #include "nel/misc/common.h" #include "nel/misc/ucstring.h" @@ -42,125 +44,126 @@ using namespace std; namespace NLMISC { -#ifdef NL_OS_WINDOWS -static HWND sendReport=NULL; -#endif - -//old doesn't work on visual c++ 7.1 due to default parameter typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile = "", bool onlyCheck = false); -typedef bool (*TEmailFunction) (const std::string &smtpServer, const std::string &from, const std::string &to, const std::string &subject, const std::string &body, const std::string &attachedFile, bool onlyCheck); - -#define DELETE_OBJECT(a) if((a)!=NULL) { DeleteObject (a); a = NULL; } - -static TEmailFunction EmailFunction = NULL; - -void setReportEmailFunction (void *emailFunction) +void setReportEmailFunction(void *emailFunction) { - EmailFunction = (TEmailFunction)emailFunction; - -#ifdef NL_OS_WINDOWS - if (sendReport) - EnableWindow(sendReport, FALSE); -#endif + // DEPRECATED + // no-op } -static string Body; -static std::string URL = "FILL_IN_CRASH_REPORT_HOSTNAME_HERE"; +// Contents of crash report +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; +} +// Launch the crash report application static void doSendReport() { std::string filename; - filename = "report_"; + filename = /*getLogDirectory() + */ "report_"; // FIXME: Should use log directory filename += NLMISC::toString( int( time( NULL ) ) ); filename += ".txt"; - std::string params; - params = "-log "; - params += filename; - params += " -host "; - params += URL; + std::stringstream params; + params << "-log "; + params << filename; // FIXME: Escape the filepath with quotes + if (!ReportPostUrl.empty()) + { + params << " -host "; + params << ReportPostUrl; + } + if (!ReportWindowTitle.empty()) + { + params << " -title "; + params << ReportWindowTitle; // FIXME: Escape the title with quotes and test + } std::ofstream f; f.open( filename.c_str() ); if( !f.good() ) return; - f << Body; + f << ReportBody; f.close(); #ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "crash_report.exe", params ); + NLMISC::launchProgram( "crash_report.exe", params.str() ); #else - NLMISC::launchProgram( "crash_report", params ); + NLMISC::launchProgram( "crash_report", params.str() ); #endif // Added because NLSMIC::launcProgram needs time to launch nlSleep( 2 * 1000 ); - + } -#ifndef NL_OS_WINDOWS +#if defined(FINAL_VERSION) || !defined(NL_OS_WINDOWS) -// GNU/Linux, do nothing - -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) +// 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) { - Body = addSlashR( body ); + ReportWindowTitle = title; + ReportBody = addSlashR(body); - doSendReport(); + doSendReport(); - return ReportQuit; +# if 1 // 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 +// Windows specific version for DEV builds, first shows a dialog box for debugging -static string Subject; -static string AttachedFile; +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 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 CanSendMailReport = false; static bool DebugDefaultBehavior, QuitDefaultBehavior; -static void sendEmail() +static void maybeSendReport() { if (CanSendMailReport && SendMessage(sendReport, BM_GETCHECK, 0, 0) != BST_CHECKED) { - bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); - if (res) - { - // EnableWindow(sendReport, FALSE); - // MessageBox (dialog, "The email was successfully sent", "email", MB_OK); + doSendReport(); #ifndef NL_NO_DEBUG_FILES - CFile::createEmptyFile(getLogDirectory() + "report_sent"); + CFile::createEmptyFile(getLogDirectory() + "report_sent"); #endif - } - else - { -#ifndef NL_NO_DEBUG_FILES - CFile::createEmptyFile(getLogDirectory() + "report_failed"); -#endif - // MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); - } } else { #ifndef NL_NO_DEBUG_FILES CFile::createEmptyFile(getLogDirectory() + "report_refused"); #endif - } +- } } static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -175,7 +178,7 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM } else if ((HWND) lParam == debug) { - doSendReport(); + maybeSendReport(); NeedExit = true; Result = ReportDebug; if (DebugDefaultBehavior) @@ -185,13 +188,13 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM } else if ((HWND) lParam == ignore) { - doSendReport(); + maybeSendReport(); NeedExit = true; Result = ReportIgnore; } else if ((HWND) lParam == quit) { - doSendReport(); + maybeSendReport(); NeedExit = true; Result = ReportQuit; @@ -210,43 +213,26 @@ static LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM abort(); } } - /*else if ((HWND) lParam == sendReport) - { - if (EmailFunction != NULL) - { - bool res = EmailFunction ("", "", "", Subject, Body, AttachedFile, false); - if (res) - { - EnableWindow(sendReport, FALSE); - MessageBox (dialog, "The email was successfully sent", "email", MB_OK); - CFile::createEmptyFile(getLogDirectory() + "report_sent"); - } - else - { - MessageBox (dialog, "Failed to send the email", "email", MB_OK | MB_ICONERROR); - } - } - }*/ } else if (message == WM_CHAR) { if (wParam == 27) { // ESC -> ignore - doSendReport(); + maybeSendReport(); NeedExit = true; Result = ReportIgnore; } } - return DefWindowProc (hWnd, message, wParam, lParam); + 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) +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) + if (!AlreadyRegister) { WNDCLASSW wc; memset (&wc,0,sizeof(wc)); @@ -264,8 +250,8 @@ TReportResult report (const std::string &title, const std::string &header, const AlreadyRegister = true; } - ucstring formatedTitle = title.empty() ? ucstring("NeL report") : ucstring(title); - + 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); @@ -273,9 +259,6 @@ TReportResult report (const std::string &title, const std::string &header, const // 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"); - Subject = subject; - AttachedFile = attachedFile; - // 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); @@ -283,10 +266,10 @@ TReportResult report (const std::string &title, const std::string &header, const // set the edit text limit to lot of :) SendMessage (edit, EM_LIMITTEXT, ~0U, 0); - Body = addSlashR (body); + ReportBody = addSlashR(body); // set the message in the edit text - SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)Body.c_str()); + SendMessage (edit, WM_SETTEXT, (WPARAM)0, (LPARAM)ReportBody.c_str()); if (enableCheckIgnore) { @@ -336,8 +319,7 @@ TReportResult report (const std::string &title, const std::string &header, const } // ace don't do that because it s slow to try to send a mail - //CanSendMailReport = sendReportButton && EmailFunction != NULL && EmailFunction("", "", "", "", "", true); - CanSendMailReport = sendReportButton && EmailFunction != NULL; + 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)."; From fc950e08e020ae7f3fa993f793ff34a38bde9c60 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 23 Feb 2015 20:07:29 +0100 Subject: [PATCH 32/53] Move crash report web application to appropriate directory --HG-- branch : feature-crashreport --- .../crash_report}/config.inc.php | 0 .../crash_report}/log.inc.php | 0 .../crash_report/submit.php} | 0 code/web/rcerror_web/rcerror_test.htm | 19 ------------------- 4 files changed, 19 deletions(-) rename code/web/{rcerror_web => public_php/crash_report}/config.inc.php (100%) rename code/web/{rcerror_web => public_php/crash_report}/log.inc.php (100%) rename code/web/{rcerror_web/rcerror.php => public_php/crash_report/submit.php} (100%) delete mode 100644 code/web/rcerror_web/rcerror_test.htm diff --git a/code/web/rcerror_web/config.inc.php b/code/web/public_php/crash_report/config.inc.php similarity index 100% rename from code/web/rcerror_web/config.inc.php rename to code/web/public_php/crash_report/config.inc.php diff --git a/code/web/rcerror_web/log.inc.php b/code/web/public_php/crash_report/log.inc.php similarity index 100% rename from code/web/rcerror_web/log.inc.php rename to code/web/public_php/crash_report/log.inc.php diff --git a/code/web/rcerror_web/rcerror.php b/code/web/public_php/crash_report/submit.php similarity index 100% rename from code/web/rcerror_web/rcerror.php rename to code/web/public_php/crash_report/submit.php diff --git a/code/web/rcerror_web/rcerror_test.htm b/code/web/rcerror_web/rcerror_test.htm deleted file mode 100644 index eb314d3f7..000000000 --- a/code/web/rcerror_web/rcerror_test.htm +++ /dev/null @@ -1,19 +0,0 @@ - -Ryzom Core Error Report Web application test harness - -
- - - - - - - - - -
Description
Report
Email
- -
-
- - From a548940b8c30276a0066581b279936798c46e5bf Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 23 Feb 2015 20:09:51 +0100 Subject: [PATCH 33/53] Default window title --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 69ce40544..ca06d1077 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -110,7 +110,7 @@ static void doSendReport() // 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; + ReportWindowTitle = title.empty() ? "Nel Crash Report" : title; ReportBody = addSlashR(body); doSendReport(); From 68120a53e7c6a6fcbcaeb997a6ef820f81265e2b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 23 Feb 2015 20:33:31 +0100 Subject: [PATCH 34/53] Only in FINAL_VERSION --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index ca06d1077..7323716e3 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -115,7 +115,7 @@ TReportResult report(const std::string &title, const std::string &header, const doSendReport(); -# if 1 // TODO: This behaviour is used in the old report code when Quitting the application is the default crash report behaviour. Needs testing. +# 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. From 02e8100ea4b77dea376d36f1ca21696f1288bfb6 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 24 Feb 2015 12:47:32 +0100 Subject: [PATCH 36/53] Fix sstream include --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 7323716e3..8c58234cf 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -16,7 +16,7 @@ #include "stdmisc.h" -#include +#include #include "nel/misc/common.h" #include "nel/misc/ucstring.h" From 826907c8ddae52451398c4daff421f673e93d419 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 24 Feb 2015 17:18:48 +0100 Subject: [PATCH 37/53] Qt5 compile fix for crash report tool --HG-- branch : feature-crashreport --- .../misc/crash_report/crash_report_socket.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_socket.cpp b/code/nel/tools/misc/crash_report/crash_report_socket.cpp index 5f8720e05..f2a14e84b 100644 --- a/code/nel/tools/misc/crash_report/crash_report_socket.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_socket.cpp @@ -21,6 +21,9 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +# include +#endif class CCrashReportSocketPvt { @@ -43,16 +46,26 @@ CCrashReportSocket::~CCrashReportSocket() void CCrashReportSocket::sendReport( const SCrashReportData &data ) { +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + QUrlQuery params; +#else QUrl params; +#endif params.addQueryItem( "report", data.report ); params.addQueryItem( "descr", data.description ); - params.addQueryItem( "email", data.email ); + params.addQueryItem("email", data.email); QUrl url( m_url ); QNetworkRequest request( url ); request.setRawHeader( "Connection", "close" ); - m_pvt->mgr.post( request, params.encodedQuery() ); +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + QByteArray postData = params.query(QUrl::FullyEncoded).toUtf8(); +#else + QByteArray postData = params.encodedQuery(); +#endif + + m_pvt->mgr.post(request, postData); } void CCrashReportSocket::onFinished( QNetworkReply *reply ) From 9d92e2d0d3ae191bcc9431a86dd8c002ea9a1f9b Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 2 Mar 2015 19:52:39 +0100 Subject: [PATCH 38/53] GUI changes as per requested by Kaetemi. --HG-- branch : feature-crashreport --- .../misc/crash_report/crash_report_widget.cpp | 74 ++++++++++++++++++- .../misc/crash_report/crash_report_widget.h | 8 ++ .../misc/crash_report/crash_report_widget.ui | 38 +++------- 3 files changed, 91 insertions(+), 29 deletions(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 968978f94..889606d99 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -25,18 +25,21 @@ #include #include #include +#include +#include CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : QWidget( parent ) { + m_developerMode = false; + m_forceSend = false; + m_ui.setupUi( this ); m_socket = new CCrashReportSocket( this ); QTimer::singleShot( 1, this, SLOT( onLoad() ) ); - connect( m_ui.sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); - connect( m_ui.canceButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) ); @@ -70,11 +73,60 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: { setWindowTitle( v.c_str() ); } + else + if( k == "dev" ) + { + m_developerMode = true; + } + else + if( k == "sendreport" ) + { + m_forceSend = true; + } + } + + QHBoxLayout *hbl = new QHBoxLayout( this ); + + if( m_developerMode ) + { + QPushButton *alwaysIgnoreButton = new QPushButton( tr( "Always Ignore" ), this ); + QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), this ); + QPushButton *abortButton = new QPushButton( tr( "Abort" ), this ); + QPushButton *breakButton = new QPushButton( tr( "Break" ), this ); + + hbl->addWidget( alwaysIgnoreButton ); + hbl->addWidget( ignoreButton ); + hbl->addWidget( abortButton ); + hbl->addWidget( breakButton ); + + m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 ); + + connect( alwaysIgnoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onAlwaysIgnoreClicked() ) ); + connect( ignoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onIgnoreClicked() ) ); + connect( abortButton, SIGNAL( clicked( bool ) ), this, SLOT( onAbortClicked() ) ); + connect( breakButton, SIGNAL( clicked( bool ) ), this, SLOT( onBreakClicked() ) ); + } + else + { + QPushButton *sendButton = new QPushButton( tr( "Send report" ), this ); + connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); + hbl->addWidget( sendButton ); + + if( !m_forceSend ) + { + QPushButton *cancelButton = new QPushButton( tr( "Don't send report" ), this ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + hbl->addWidget( cancelButton ); + } + + m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 ); } } void CCrashReportWidget::onLoad() { + return; + if( !checkSettings() ) { close(); @@ -99,7 +151,6 @@ void CCrashReportWidget::onLoad() void CCrashReportWidget::onSendClicked() { - m_ui.sendButton->setEnabled( false ); QApplication::setOverrideCursor( Qt::WaitCursor ); SCrashReportData data; @@ -120,6 +171,23 @@ void CCrashReportWidget::onCBClicked() m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } +void CCrashReportWidget::onAlwaysIgnoreClicked() +{ +} + +void CCrashReportWidget::onIgnoreClicked() +{ +} + +void CCrashReportWidget::onAbortClicked() +{ +} + +void CCrashReportWidget::onBreakClicked() +{ +} + + void CCrashReportWidget::onReportSent() { QApplication::setOverrideCursor( Qt::ArrowCursor ); diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index 61b56e340..b0039e0e2 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -43,6 +43,11 @@ private Q_SLOTS: void onSendClicked(); void onCancelClicked(); void onCBClicked(); + + void onAlwaysIgnoreClicked(); + void onIgnoreClicked(); + void onAbortClicked(); + void onBreakClicked(); void onReportSent(); void onReportFailed(); @@ -54,6 +59,9 @@ private: Ui::CrashReportWidget m_ui; QString m_fileName; CCrashReportSocket *m_socket; + bool m_developerMode; + bool m_forceSend; + }; #endif diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui index 589810578..ed252eb07 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -9,8 +9,8 @@ 0 0 - 400 - 407 + 406 + 430 @@ -24,9 +24,6 @@
- - - @@ -34,24 +31,17 @@ - - - - true - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - + + - + Email me if you have further questions, or updates on this issue - + false @@ -61,17 +51,13 @@ - - - - Send + + + + true - - - - - - Cancel + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse From d6662403438d22b79cfdd8ae6fb4f4fada172d1f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 2 Mar 2015 20:12:09 +0100 Subject: [PATCH 39/53] Added return codes as requested. --HG-- branch : feature-crashreport --- code/nel/tools/misc/crash_report/crash_report.cpp | 8 +++++++- .../tools/misc/crash_report/crash_report_widget.cpp | 8 ++++++++ .../tools/misc/crash_report/crash_report_widget.h | 13 +++++++++++++ code/ryzom/client/src/init.cpp | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/misc/crash_report/crash_report.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp index e083de126..0c9e4fc93 100644 --- a/code/nel/tools/misc/crash_report/crash_report.cpp +++ b/code/nel/tools/misc/crash_report/crash_report.cpp @@ -88,5 +88,11 @@ int main( int argc, char **argv ) w.setup( params ); w.show(); - return app.exec(); + int ret = app.exec(); + + if( ret != EXIT_SUCCESS ) + return ret; + else + return w.getReturnValue(); + } \ No newline at end of file diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 889606d99..609c58562 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -173,18 +173,26 @@ void CCrashReportWidget::onCBClicked() void CCrashReportWidget::onAlwaysIgnoreClicked() { + m_returnValue = ERET_ALWAYS_IGNORE; + close(); } void CCrashReportWidget::onIgnoreClicked() { + m_returnValue = ERET_IGNORE; + close(); } void CCrashReportWidget::onAbortClicked() { + m_returnValue = ERET_ABORT; + close(); } void CCrashReportWidget::onBreakClicked() { + m_returnValue = ERET_BREAK; + close(); } diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index b0039e0e2..db3d85b47 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -31,12 +31,24 @@ class CCrashReportWidget : public QWidget { Q_OBJECT public: + + enum EReturnValue + { + ERET_NULL = 0, + ERET_ALWAYS_IGNORE = 21, + ERET_IGNORE = 22, + ERET_ABORT = 23, + ERET_BREAK = 24 + }; + CCrashReportWidget( QWidget *parent = NULL ); ~CCrashReportWidget(); void setFileName( const char *fn ){ m_fileName = fn; } void setup( const std::vector< std::pair< std::string, std::string > > ¶ms ); + + EReturnValue getReturnValue() const{ return m_returnValue; } private Q_SLOTS: void onLoad(); @@ -62,6 +74,7 @@ private: bool m_developerMode; bool m_forceSend; + EReturnValue m_returnValue; }; #endif diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index f0fd40dae..2ffc6e8e0 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -538,6 +538,8 @@ void checkDriverVersion() void checkDriverDepth () { + nlassert( false ); + // Check desktop is in 32 bit else no window mode allowed. if (ClientCfg.Windowed) { From 374d966069911a3daf60f551937aed308aac9173 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 2 Mar 2015 21:06:01 +0100 Subject: [PATCH 40/53] Some more GUI changes. --HG-- branch : feature-crashreport --- .../misc/crash_report/crash_report_widget.cpp | 98 ++++++++++++------- .../misc/crash_report/crash_report_widget.h | 4 +- .../misc/crash_report/crash_report_widget.ui | 4 +- 3 files changed, 66 insertions(+), 40 deletions(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 609c58562..350a35ff8 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -27,6 +27,7 @@ #include #include #include +#include CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : QWidget( parent ) @@ -85,10 +86,38 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: } } + if( m_fileName.isEmpty() ) + { + m_ui.reportLabel->hide(); + m_ui.reportEdit->hide(); + } + + // When no -host specified no custom entry and email fields + if( m_socket->url().isEmpty() ) + { + m_ui.descriptionEdit->hide(); + m_ui.emailCB->hide(); + m_ui.emailEdit->hide(); + m_ui.descrLabel->hide(); + } + QHBoxLayout *hbl = new QHBoxLayout( this ); if( m_developerMode ) { + if( !m_socket->url().isEmpty() ) + { + m_ui.emailCB->setEnabled( false ); + + QCheckBox *cb = new QCheckBox( tr( "Send report" ), this ); + m_ui.gridLayout->addWidget( cb, 4, 0, 1, 1 ); + + m_ui.gridLayout->addWidget( m_ui.emailCB, 5, 0, 1, 1 ); + m_ui.gridLayout->addWidget( m_ui.emailEdit, 6, 0, 1, 1 ); + + connect( cb, SIGNAL( stateChanged( int ) ), this, SLOT( onSendCBClicked() ) ); + } + QPushButton *alwaysIgnoreButton = new QPushButton( tr( "Always Ignore" ), this ); QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), this ); QPushButton *abortButton = new QPushButton( tr( "Abort" ), this ); @@ -99,7 +128,7 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: hbl->addWidget( abortButton ); hbl->addWidget( breakButton ); - m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 ); + m_ui.gridLayout->addLayout( hbl, 7, 0, 1, 3 ); connect( alwaysIgnoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onAlwaysIgnoreClicked() ) ); connect( ignoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onIgnoreClicked() ) ); @@ -108,15 +137,26 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: } else { - QPushButton *sendButton = new QPushButton( tr( "Send report" ), this ); - connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); - hbl->addWidget( sendButton ); - - if( !m_forceSend ) + // If -host is specified, offer the send function + if( !m_socket->url().isEmpty() ) { - QPushButton *cancelButton = new QPushButton( tr( "Don't send report" ), this ); - connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); - hbl->addWidget( cancelButton ); + QPushButton *sendButton = new QPushButton( tr( "Send report" ), this ); + connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); + hbl->addWidget( sendButton ); + + if( !m_forceSend ) + { + QPushButton *cancelButton = new QPushButton( tr( "Don't send report" ), this ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + hbl->addWidget( cancelButton ); + } + } + // Otherwise only offer exit + else + { + QPushButton *exitButton = new QPushButton( tr( "Exit" ), this ); + connect( exitButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + hbl->addWidget( exitButton ); } m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 ); @@ -125,13 +165,8 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: void CCrashReportWidget::onLoad() { - return; - - if( !checkSettings() ) - { - close(); + if( m_fileName.isEmpty() ) return; - } QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); @@ -171,6 +206,18 @@ void CCrashReportWidget::onCBClicked() m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } +void CCrashReportWidget::onSendCBClicked() +{ + bool b = m_ui.emailCB->isEnabled(); + + if( b ) + { + m_ui.emailCB->setChecked( false ); + } + + m_ui.emailCB->setEnabled( !b ); +} + void CCrashReportWidget::onAlwaysIgnoreClicked() { m_returnValue = ERET_ALWAYS_IGNORE; @@ -218,27 +265,6 @@ void CCrashReportWidget::onReportFailed() removeAndQuit(); } -bool CCrashReportWidget::checkSettings() -{ - if( m_fileName.isEmpty() ) - { - QMessageBox::information( this, - tr( "No log file specified." ), - tr( "No log file specified. Exiting..." ) ); - return false; - } - - if( m_socket->url().isEmpty() ) - { - QMessageBox::information( this, - tr( "No host specified." ), - tr( "No host specified. Exiting..." ) ); - return false; - } - - return true; -} - void CCrashReportWidget::removeAndQuit() { QFile::remove( m_fileName ); diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index db3d85b47..a0468a565 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -49,12 +49,13 @@ public: void setup( const std::vector< std::pair< std::string, std::string > > ¶ms ); EReturnValue getReturnValue() const{ return m_returnValue; } - + private Q_SLOTS: void onLoad(); void onSendClicked(); void onCancelClicked(); void onCBClicked(); + void onSendCBClicked(); void onAlwaysIgnoreClicked(); void onIgnoreClicked(); @@ -65,7 +66,6 @@ private Q_SLOTS: void onReportFailed(); private: - bool checkSettings(); void removeAndQuit(); Ui::CrashReportWidget m_ui; diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui index ed252eb07..dec7e74ca 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -18,14 +18,14 @@ - + What were you doing when the crash occured? - + Contents of the report ( automatically generated ) From 3108e5e013c1d3ceee91234409e22bfe799f010f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 3 Mar 2015 02:30:39 +0100 Subject: [PATCH 41/53] Send report in dev mode if the CB is checked. --HG-- branch : feature-crashreport --- .../misc/crash_report/crash_report_widget.cpp | 40 +++++++++++++------ .../misc/crash_report/crash_report_widget.h | 1 + 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 350a35ff8..e176bb2be 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -34,6 +34,7 @@ QWidget( parent ) { m_developerMode = false; m_forceSend = false; + m_devSendReport = false; m_ui.setupUi( this ); @@ -63,6 +64,8 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: if( k == "log" ) { m_fileName = v.c_str(); + if( !QFile::exists( m_fileName ) ) + m_fileName.clear(); } else if( k == "host" ) @@ -92,8 +95,8 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: m_ui.reportEdit->hide(); } - // When no -host specified no custom entry and email fields - if( m_socket->url().isEmpty() ) + + if( m_socket->url().isEmpty() || m_fileName.isEmpty() ) { m_ui.descriptionEdit->hide(); m_ui.emailCB->hide(); @@ -105,7 +108,7 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: if( m_developerMode ) { - if( !m_socket->url().isEmpty() ) + if( !m_socket->url().isEmpty() && !m_fileName.isEmpty() ) { m_ui.emailCB->setEnabled( false ); @@ -172,10 +175,7 @@ void CCrashReportWidget::onLoad() bool b = f.open( QFile::ReadOnly | QFile::Text ); if( !b ) { - QMessageBox::information( this, - tr( "No log file found" ), - tr( "There was no log file found, therefore nothing to report. Exiting..." ) ); - close(); + m_fileName.clear(); return; } @@ -186,6 +186,18 @@ void CCrashReportWidget::onLoad() void CCrashReportWidget::onSendClicked() { + if( m_developerMode && !m_devSendReport ) + { + close(); + return; + } + + if( m_socket->url().isEmpty() || m_fileName.isEmpty() ) + { + close(); + return; + } + QApplication::setOverrideCursor( Qt::WaitCursor ); SCrashReportData data; @@ -216,30 +228,32 @@ void CCrashReportWidget::onSendCBClicked() } m_ui.emailCB->setEnabled( !b ); + + m_devSendReport = !m_devSendReport; } void CCrashReportWidget::onAlwaysIgnoreClicked() { m_returnValue = ERET_ALWAYS_IGNORE; - close(); + onSendClicked(); } void CCrashReportWidget::onIgnoreClicked() { m_returnValue = ERET_IGNORE; - close(); + onSendClicked(); } void CCrashReportWidget::onAbortClicked() { m_returnValue = ERET_ABORT; - close(); + onSendClicked(); } void CCrashReportWidget::onBreakClicked() { m_returnValue = ERET_BREAK; - close(); + onSendClicked(); } @@ -267,7 +281,9 @@ void CCrashReportWidget::onReportFailed() void CCrashReportWidget::removeAndQuit() { - QFile::remove( m_fileName ); + if( !m_fileName.isEmpty() ) + QFile::remove( m_fileName ); + close(); } diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index a0468a565..f40e40854 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -73,6 +73,7 @@ private: CCrashReportSocket *m_socket; bool m_developerMode; bool m_forceSend; + bool m_devSendReport; EReturnValue m_returnValue; }; From d561a7078c35898f936ca0c34606016a151f91c3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 3 Mar 2015 02:33:04 +0100 Subject: [PATCH 42/53] Only send email if the email CB is checked. --HG-- branch : feature-crashreport --- code/nel/tools/misc/crash_report/crash_report_widget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index e176bb2be..9c23b793a 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -203,7 +203,9 @@ void CCrashReportWidget::onSendClicked() SCrashReportData data; data.description = m_ui.descriptionEdit->toPlainText(); data.report = m_ui.reportEdit->toPlainText(); - data.email = m_ui.emailEdit->text(); + + if( m_ui.emailCB->isChecked() ) + data.email = m_ui.emailEdit->text(); m_socket->sendReport( data ); } From 7ca008ba86ef29c9479de4b3a27af6ec147f54c3 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 3 Mar 2015 02:37:51 +0100 Subject: [PATCH 43/53] Don't offer send in non-dev mode when there's no log file specified. --HG-- branch : feature-crashreport --- code/nel/tools/misc/crash_report/crash_report_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 9c23b793a..07ec7cd6f 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -141,7 +141,7 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: else { // If -host is specified, offer the send function - if( !m_socket->url().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() ) ); From baa5273eaa9ff939f22c6c33590775b2da245f04 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 3 Mar 2015 03:10:28 +0100 Subject: [PATCH 44/53] Default return value. --HG-- branch : feature-crashreport --- code/nel/tools/misc/crash_report/crash_report_widget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 07ec7cd6f..00b4c33bf 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -35,6 +35,7 @@ QWidget( parent ) m_developerMode = false; m_forceSend = false; m_devSendReport = false; + m_returnValue = ERET_NULL; m_ui.setupUi( this ); From 74cb91d460bbd8e7ae6afe3e5808b02144299a4a Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Tue, 3 Mar 2015 03:10:59 +0100 Subject: [PATCH 45/53] This was left here unintentionally. --HG-- branch : feature-crashreport --- code/ryzom/client/src/init.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 2ffc6e8e0..f0fd40dae 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -538,8 +538,6 @@ void checkDriverVersion() void checkDriverDepth () { - nlassert( false ); - // Check desktop is in 32 bit else no window mode allowed. if (ClientCfg.Windowed) { From 9d50210e6ba9ae10199122308b100af652e54409 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 6 Mar 2015 19:06:10 +0100 Subject: [PATCH 46/53] Enable crash report tool in debugging sample application --HG-- branch : feature-crashreport --- code/nel/samples/misc/debug/main.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/code/nel/samples/misc/debug/main.cpp b/code/nel/samples/misc/debug/main.cpp index 6ee31754f..85cd4edc9 100644 --- a/code/nel/samples/misc/debug/main.cpp +++ b/code/nel/samples/misc/debug/main.cpp @@ -18,11 +18,9 @@ #include // contains all debug features -#include "nel/misc/debug.h" +#include -using namespace NLMISC; - -int main (int /* argc */, char ** /* argv */) +int main(int /* argc */, char ** /* argv */) { // all debug functions have different behaviors in debug and in release mode. // in general, in debug mode, all debug functions are active, they display @@ -36,20 +34,23 @@ int main (int /* argc */, char ** /* argv */) // 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 // add the default displayers - createDebug (); + NLMISC::createDebug(); + + // enable the crash report tool + NLMISC::INelContext::getInstance().setWindowedApplication(true); // display debug information, that will be skipped in release mode. - nldebug ("nldebug() %d", 1); + nldebug("nldebug() %d", 1); // display the string - nlinfo ("nlinfo() %d", 2); + nlinfo("nlinfo() %d", 2); // when something not normal, but that the program can manage, occurs, call nlwarning() - nlwarning ("nlwarning() %d", 3); + nlwarning("nlwarning() %d", 3); // nlassert() is like assert but do more powerful things. in release mode, the test is // not executed and nothing will happen. (Press F5 in Visual C++ to continue the execution) - nlassert (true == false); + nlassert(true == false); // in a switch case or when you want that the program never executes a part of code, use stop. // in release, nlstop does nothing. in debug mode, @@ -61,16 +62,16 @@ int main (int /* argc */, char ** /* argv */) // occurs. (In Visual C++ press F5 to continue) try { - nlerror ("nlerror() %d", 4); + nlerror("nlerror() %d", 4); } - catch(const EFatalError &) + catch (const NLMISC::EFatalError &) { // just continue... - nlinfo ("nlerror() generated an EFatalError exception, just ignore it"); + nlinfo("nlerror() generated an EFatalError exception, just ignore it"); } printf("\nPress to exit\n"); - getchar (); + getchar(); return EXIT_SUCCESS; } From 699e1644e71ddd760313ba9b12985abec541f7af Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 6 Mar 2015 19:06:10 +0100 Subject: [PATCH 47/53] Use proper style sheet for crash report under Cinnamon --HG-- branch : feature-crashreport --- code/nel/tools/misc/crash_report/crash_report.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/nel/tools/misc/crash_report/crash_report.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp index 0c9e4fc93..c42f1ae6f 100644 --- a/code/nel/tools/misc/crash_report/crash_report.cpp +++ b/code/nel/tools/misc/crash_report/crash_report.cpp @@ -78,6 +78,19 @@ public: 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 ); std::vector< std::pair< std::string, std::string > > params; From b896405b3dd13c83c746e097aad0dee917cc7479 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 6 Mar 2015 19:06:10 +0100 Subject: [PATCH 48/53] Adjust layout --HG-- branch : feature-crashreport --- .../misc/crash_report/crash_report_widget.cpp | 25 ++++++++++++------- .../misc/crash_report/crash_report_widget.ui | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 00b4c33bf..7ca723f44 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -122,10 +122,13 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: connect( cb, SIGNAL( stateChanged( int ) ), this, SLOT( onSendCBClicked() ) ); } + hbl->addStretch(); + QPushButton *alwaysIgnoreButton = new QPushButton( tr( "Always Ignore" ), this ); QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), 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( ignoreButton ); @@ -141,26 +144,30 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: } else { + hbl->addStretch(); + // If -host is specified, offer the send function if( !m_socket->url().isEmpty() && !m_fileName.isEmpty() ) { + if (!m_forceSend) + { + QPushButton *cancelButton = new QPushButton(tr("Don't send report"), this); + connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(onCancelClicked())); + 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 ); - - if( !m_forceSend ) - { - QPushButton *cancelButton = new QPushButton( tr( "Don't send report" ), this ); - connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); - hbl->addWidget( cancelButton ); - } } // Otherwise only offer exit else { QPushButton *exitButton = new QPushButton( tr( "Exit" ), this ); 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 ); diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui index dec7e74ca..da1e38618 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -14,7 +14,7 @@ - NeL Error Report + NeL report From 230be4d64b6d3a86c4443a7185877626bb6c065f Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 6 Mar 2015 19:06:10 +0100 Subject: [PATCH 49/53] Extend debugging sample --HG-- branch : feature-crashreport --- code/nel/samples/misc/debug/main.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/code/nel/samples/misc/debug/main.cpp b/code/nel/samples/misc/debug/main.cpp index 85cd4edc9..66217ac1d 100644 --- a/code/nel/samples/misc/debug/main.cpp +++ b/code/nel/samples/misc/debug/main.cpp @@ -20,6 +20,11 @@ // contains all debug features #include +void repeatederror() +{ + nlassert(false && "hit always ignore"); +} + int main(int /* argc */, char ** /* argv */) { // all debug functions have different behaviors in debug and in release mode. @@ -70,6 +75,9 @@ int main(int /* argc */, char ** /* argv */) nlinfo("nlerror() generated an EFatalError exception, just ignore it"); } + for (int i = 0; i < 32; ++i) + repeatederror(); + printf("\nPress to exit\n"); getchar(); From a9dc1a4c6800b22fcdece31f5f42db5b8de206a7 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 6 Mar 2015 19:06:10 +0100 Subject: [PATCH 50/53] Fix checkbox behaviour --HG-- branch : feature-crashreport --- code/nel/tools/misc/crash_report/crash_report_widget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 7ca723f44..218b3545c 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -119,7 +119,9 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: m_ui.gridLayout->addWidget( m_ui.emailCB, 5, 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(); From bbfc15c07af812f91d384d5065709b17ea4b5fda Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 6 Mar 2015 19:06:10 +0100 Subject: [PATCH 51/53] Extend debugging sample --HG-- branch : feature-crashreport --- code/nel/samples/misc/debug/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/nel/samples/misc/debug/main.cpp b/code/nel/samples/misc/debug/main.cpp index 66217ac1d..5850cb2b3 100644 --- a/code/nel/samples/misc/debug/main.cpp +++ b/code/nel/samples/misc/debug/main.cpp @@ -19,9 +19,11 @@ // contains all debug features #include +#include void repeatederror() { + // hit always ignore to surpress this error for the duration of the program nlassert(false && "hit always ignore"); } @@ -43,6 +45,7 @@ int main(int /* argc */, char ** /* argv */) // 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. nldebug("nldebug() %d", 1); @@ -75,6 +78,7 @@ int main(int /* argc */, char ** /* argv */) nlinfo("nlerror() generated an EFatalError exception, just ignore it"); } + // keep repeating the same error for (int i = 0; i < 32; ++i) repeatederror(); From 5a307cfa206a9a362ebb8faa6432a1cb36ef0f53 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 6 Mar 2015 19:06:11 +0100 Subject: [PATCH 52/53] Replace report functionality --HG-- branch : feature-crashreport --- code/nel/include/nel/misc/report.h | 44 ++++++++++++++++++------------ code/nel/src/misc/debug.cpp | 4 +-- code/nel/src/misc/displayer.cpp | 42 +++++++++++++--------------- code/nel/src/misc/report.cpp | 1 + code/nel/src/net/service.cpp | 2 +- 5 files changed, 50 insertions(+), 43 deletions(-) diff --git a/code/nel/include/nel/misc/report.h b/code/nel/include/nel/misc/report.h index c492f4aa2..55a1c2dbf 100644 --- a/code/nel/include/nel/misc/report.h +++ b/code/nel/include/nel/misc/report.h @@ -21,28 +21,38 @@ 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 header message displayed before the edit text box. If empty, it displays the default message. - * \param body message displayed in the edit text box. This string will be sent by email. - * \param debugButton 0 for disabling it, 1 for enable with default behaviors (generate a breakpoint), 2 for enable with no behavior + * \param title set the title of the report. If empty, it'll display "NeL report" + * \param subject extended title of the report + * \param body message displayed in the edit text box. This string will be sent to the crash report tool + * \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 error + * \return the button clicked or defaultResult */ -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 -void setReportPostUrl(const std::string &postUrl); - -/// DEPRECATED -/** call this in the main of your appli to enable email: setReportEmailFunction (sendEmail); - */ -void setReportEmailFunction(void *emailFunction); +/// Set the Url of the web service used to post crash reports to. String is copied +void setReportPostUrl(const char *postUrl); } // NLMISC diff --git a/code/nel/src/misc/debug.cpp b/code/nel/src/misc/debug.cpp index 86752a412..96372d124 100644 --- a/code/nel/src/misc/debug.cpp +++ b/code/nel/src/misc/debug.cpp @@ -553,8 +553,8 @@ public: { // 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). - bool i = false; - report (progname+shortExc, "", subject, _Reason, true, 1, true, 1, !isCrashAlreadyReported(), i, NL_CRASH_DUMP_FILE); + report(progname + shortExc, subject, _Reason, NL_CRASH_DUMP_FILE, true, !isCrashAlreadyReported(), ReportAbort); + // TODO: Does this need to be synchronous? Why does this not handle the report result? // no more sent mail for crash setCrashAlreadyReported(true); diff --git a/code/nel/src/misc/displayer.cpp b/code/nel/src/misc/displayer.cpp index 86fc1d726..273ebf111 100644 --- a/code/nel/src/misc/displayer.cpp +++ b/code/nel/src/misc/displayer.cpp @@ -688,37 +688,33 @@ void CMsgBoxDisplayer::doDisplay ( const CLog::TDisplayInfo& args, const char *m // 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). std::string filename = getLogDirectory() + NL_CRASH_DUMP_FILE; + + TReportResult reportResult = report(args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), + subject, body, filename, NL_REPORT_SYNCHRONOUS, !isCrashAlreadyReported(), NL_REPORT_DEFAULT); - if (ReportDebug == report (args.ProcessName + " NeL " + toString(logTypeToString(args.LogType, true)), "", subject, body, true, 2, true, 1, !isCrashAlreadyReported(), IgnoreNextTime, filename.c_str())) + switch (reportResult) { + case ReportAlwaysIgnore: + IgnoreNextTime = true; + break; + case ReportBreak: 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 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 } diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 8c58234cf..96ad2fac9 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -16,6 +16,7 @@ #include "stdmisc.h" +#include #include #include "nel/misc/common.h" diff --git a/code/nel/src/net/service.cpp b/code/nel/src/net/service.cpp index f42806245..a37370b17 100644 --- a/code/nel/src/net/service.cpp +++ b/code/nel/src/net/service.cpp @@ -606,7 +606,7 @@ sint IService::main (const char *serviceShortName, const char *serviceLongName, ListeningPort = servicePort; - setReportEmailFunction ((void*)sendEmail); + // setReportEmailFunction ((void*)sendEmail); // setDefaultEmailParams ("gw.nevrax.com", "", "cado@nevrax.com"); From ee32b56d8704d59f5622a1d9012f08c841f6c239 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 6 Mar 2015 19:07:25 +0100 Subject: [PATCH 53/53] Replace report functionality --HG-- branch : feature-crashreport --- code/nel/src/misc/report.cpp | 503 ++++++++++++----------------------- 1 file changed, 169 insertions(+), 334 deletions(-) diff --git a/code/nel/src/misc/report.cpp b/code/nel/src/misc/report.cpp index 96ad2fac9..b388dfb31 100644 --- a/code/nel/src/misc/report.cpp +++ b/code/nel/src/misc/report.cpp @@ -24,363 +24,198 @@ #include "nel/misc/report.h" #include "nel/misc/path.h" - -#ifdef NL_OS_WINDOWS -# ifndef NL_COMP_MINGW -# define NOMINMAX -# endif -# include -# include -# include -#endif // NL_OS_WINDOWS - -#define NL_NO_DEBUG_FILES 1 - -using namespace std; +#include "nel/misc/file.h" #ifdef DEBUG_NEW #define new DEBUG_NEW #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 { -void setReportEmailFunction(void *emailFunction) +void setReportPostUrl(const char *postUrl) { - // DEPRECATED - // no-op -} - -// Contents of crash report -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; -} - -// Launch the crash report application -static void doSendReport() -{ - std::string filename; - - 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 "; - params << ReportPostUrl; - } - if (!ReportWindowTitle.empty()) - { - params << " -title "; - params << ReportWindowTitle; // FIXME: Escape the title with quotes and test - } - - std::ofstream f; - f.open( filename.c_str() ); - if( !f.good() ) - return; - - f << ReportBody; - - f.close(); - +#if NL_DEBUG_REPORT + if (INelContext::isContextInitialised()) + nldebug("Set report post url to '%s'", postUrl); +#endif #ifdef NL_OS_WINDOWS - NLMISC::launchProgram( "crash_report.exe", params.str() ); + SetEnvironmentVariableA(NL_REPORT_POST_URL_ENVVAR, postUrl); #else - NLMISC::launchProgram( "crash_report", params.str() ); + setenv(NL_REPORT_POST_URL_ENVVAR, postUrl, 1); #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) +inline const char *getReportPostURL() { - 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 - } - else - { -#ifndef NL_NO_DEBUG_FILES - 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); + 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 -#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) +TReportResult report(const std::string &title, const std::string &subject, const std::string &body, const std::string &attachment, bool synchronous, bool sendReport, TReportResult defaultResult) { - // register the window - static bool AlreadyRegister = false; - if (!AlreadyRegister) + std::string reportPath; + if (!body.empty()) { - 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) + std::stringstream reportFile; + reportFile << getLogDirectory(); + reportFile << "nel_report_"; + reportFile << (int)time(NULL); + reportFile << ".log"; + reportPath = CFile::findNewFile(reportFile.str()); + std::ofstream f; + f.open(reportPath.c_str()); + if (!f.good()) { - 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; -} - +#if NL_DEBUG_REPORT + if (INelContext::isContextInitialised()) + nldebug("Failed to write report log to '%s'", reportPath.c_str()); #endif + reportPath.clear(); + } + else + { + f << body; + f.close(); + } + } + if (INelContext::isContextInitialised() + && 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 + return defaultResult; +#endif + } + else + { + return defaultResult; + } + } +} } // NLMISC