Commit dea4f7eb authored by Leander Schulten's avatar Leander Schulten
Browse files

Added DrMinGW to create crash reports when using MinGW 64-Bit. The Reports...

Added DrMinGW to create crash reports when using MinGW 64-Bit. The Reports gets send to the orga symposion server who forward the request slightly modified to the GitLab API (create issue)
parent 85063772
Pipeline #152232 passed with stage
in 3 minutes and 35 seconds
QT += qml quick networkauth
QT += qml quick networkauth network
CONFIG += c++1z
CONFIG += c++1z force_debug_info
TARGET = Lichtsteuerung
......@@ -237,6 +237,16 @@ win32-g++{
INCLUDEPATH += $$PWD/'lib/AudioFFT/include'
}
win32-g++{
#DrMinGW
#LIBS += -L$$PWD/'lib/AudioFFT/dll' -lAudioFFT
!contains(QT_ARCH, i386){ # 64 bit
LIBS += -L$$PWD/'lib/DrMinGW/bin/' -lexchndl
INCLUDEPATH += $$PWD/'lib/DrMinGW/include'
DEFINES += DrMinGW
}
}
win32-msvc{
#AudioFFT
LIBS += -L$$PWD/'lib/AudioFFT/dll/AudioFFT.dll'
......
\ No newline at end of file
/*
* Copyright 2002-2015 Jose Fonseca
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#include <windows.h>
// Set the unhandled exception handler.
// Must be called when exchndll.dll is statically loaded (as opposed to loaded
// dynamically via LoadLibrary)
EXTERN_C VOID APIENTRY
ExcHndlInit(void);
// Override the report file name.
//
// Default is prog_name.RPT, in the same directory as the main executable.
//
// You can also pass "-" for stderr.
EXTERN_C BOOL APIENTRY
ExcHndlSetLogFileNameA(const char *szLogFileName);
......@@ -46,13 +46,69 @@
#include "modules/dmxconsumer.h"
#include "sortedmodelview.h"
#include "updater.h"
#include "exchndl.h"
#include <QNetworkReply>
int main(int argc, char *argv[])
{
#ifdef DrMinGW
ExcHndlInit();
auto path = QStandardPaths::writableLocation(QStandardPaths::QStandardPaths::AppDataLocation);
path += QLatin1String("/Lichtsteuerung");
QDir dir(path);
if(!dir.mkpath(path)){
qWarning() << "Error creating dirs : " << path;
}
path += QLatin1String("/crash_dump_");
path += QDateTime::currentDateTime().toString(QStringLiteral("dd.MM.yyyy HH.mm.ss"));
path += QLatin1String(".txt");
qDebug() << "The crash report file is : " << path;
ExcHndlSetLogFileNameA(path.toStdString().c_str());
#endif
Updater updater;
QObject::connect(&updater,&Updater::needUpdate,[&](){
updater.update();
});
#ifdef DrMinGW
// send crash reports
auto files = dir.entryInfoList(QDir::Filter::Files);
for(auto & file : files){
if(file.fileName().startsWith(QLatin1String("crash_dump"))){
auto newFileName = file.absolutePath() + "/sended_" +file.fileName();
if(!QFile::rename(file.absoluteFilePath(),newFileName)){
qWarning() << "Failed to rename file from " << file.absoluteFilePath() << " to " << newFileName;
continue;
}
auto upload = [newFileName,&updater](){
// we only want to report Bugs for new versions
if(updater.getState() == Updater::UpdaterState::NoUpdateAvailible){
QFile file(newFileName);
if(!file.open(QIODevice::ReadOnly)){
qWarning() << "Failed to open file " << newFileName;
return;
}
auto request = QNetworkRequest(QUrl(QStringLiteral("https://orga.symposion.hilton.rwth-aachen.de/send_crash_report")));
request.setHeader(QNetworkRequest::KnownHeaders::ContentTypeHeader,"text/plain");
auto response = updater.getQNetworkAccessManager()->post(request,file.readAll());
QObject::connect(response,&QNetworkReply::finished,[=](){
if(response->error() == QNetworkReply::NoError){
qDebug() << "crash report erfolgreich hochlgeladen";
}else{
qWarning() << "Fehler beim hochladen des crash reports : " << response->errorString();
}
response->deleteLater();
});
}
};
if(updater.getState() == Updater::UpdaterState::NotChecked){
QObject::connect(&updater,&Updater::stateChanged,upload);
}else{
upload();
}
}
}
#endif
/*Test::TestModulSystem testModulSystem;
testModulSystem.runTest();
return 0;*/
......
......@@ -20,6 +20,7 @@ QByteArray getFileContent(const QString & filename){
Updater::Updater(){
if(!QFile::exists(QDir::currentPath() + "/Lichtsteuerung.exe")){
state = UpdaterState::IDE_ENV;
emit stateChanged();
}
}
......@@ -30,6 +31,7 @@ void Updater::checkForUpdate(){
if(!QFile::exists(VERSION_FILE_NAME)){
qDebug() << "version file does not exists in application folder";
state = UpdaterState::UpdateAvailible;
emit stateChanged();
emit needUpdate();
return;
}
......@@ -52,18 +54,22 @@ void Updater::checkForUpdate(){
if(!success){
qDebug() << "not successful when unzipping version.zip";
state = UpdaterState::NoUpdateAvailible;
emit stateChanged();
return;
}
if(!QFile::exists(version.absolutePath() + "/" + VERSION_FILE_NAME)){
qDebug() << "version file does not exists in version.zip";
state = UpdaterState::NoUpdateAvailible;
emit stateChanged();
return;
}
if(getFileContent(VERSION_FILE_NAME) != getFileContent(version.absolutePath() + "/" + VERSION_FILE_NAME)){
state = UpdaterState::UpdateAvailible;
emit stateChanged();
emit needUpdate();
}else{
state = UpdaterState::NoUpdateAvailible;
emit stateChanged();
}
});
});
......@@ -76,11 +82,13 @@ void Updater::update(){
return;
}
state = UpdaterState::DownloadingUpdate;
emit stateChanged();
auto redirect = http->get(QNetworkRequest(QUrl(deployDownloadURL)));
QObject::connect(redirect,static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),[this,redirect](auto error){
qWarning() << "Error while redirecting to deploy.zip! " << error << redirect->errorString();
redirect->deleteLater();
state = UpdaterState::DownloadUpdateFailed;
emit stateChanged();
});
QObject::connect(redirect,&QNetworkReply::finished,[this,redirect](){
redirect->deleteLater();
......@@ -98,6 +106,7 @@ void Updater::update(){
deploy->deleteLater();
response->deleteLater();
state = UpdaterState::DownloadUpdateFailed;
emit stateChanged();
});
QObject::connect(response,&QNetworkReply::readyRead,[response,deploy](){
deploy->write(response->readAll());
......@@ -116,6 +125,7 @@ void Updater::update(){
if(!success){
qDebug() << "not successful when unzipping deploy.zip";
state = UpdaterState::DownloadUpdateFailed;
emit stateChanged();
return;
}
deployPath = QFileInfo(*deploy).absolutePath() + "/" + NAME_OF_DEPLOY_FOLDER;
......@@ -125,12 +135,14 @@ void Updater::update(){
if(!QFile::remove(targetInstallerPath)){
qWarning() << "Failed to remove old Windows Installer";
state = UpdaterState::DownloadUpdateFailed;
emit stateChanged();
return;
}
}
if(!QFile::rename(deployPath + "/" + WINDOWS_INSTALLER_NAME,targetInstallerPath)){
qWarning() << "Failed to rename Windows Installer";
state = UpdaterState::DownloadUpdateFailed;
emit stateChanged();
return;
}
// all important files like QTJSONFile.json
......@@ -139,6 +151,7 @@ void Updater::update(){
QFile::copy(e.absoluteFilePath() , deployPath + "/" + e.fileName());
}
state = UpdaterState::UpdateDownloaded;
emit stateChanged();
});
});
});
......
......@@ -15,7 +15,10 @@ class Updater : public QObject{
QString versionDownloadURL = QStringLiteral("https://git.rwth-aachen.de/leander.schulten/Lichtsteuerung/-/jobs/artifacts/windows-release/download?job=version");
QString deployDownloadURL = QStringLiteral("https://git.rwth-aachen.de/leander.schulten/Lichtsteuerung/-/jobs/artifacts/windows-release/download?job=deploy");
std::unique_ptr<QNetworkAccessManager> http = std::make_unique<QNetworkAccessManager>();
enum class UpdaterState {IDE_ENV, NotChecked, NoUpdateAvailible, UpdateAvailible, DownloadingUpdate, UpdateDownloaded, DownloadUpdateFailed} state = UpdaterState::NotChecked;
public:
enum class UpdaterState {IDE_ENV, NotChecked, NoUpdateAvailible, UpdateAvailible, DownloadingUpdate, UpdateDownloaded, DownloadUpdateFailed};
private:
UpdaterState state = UpdaterState::NotChecked;
int progress = -1;
QString deployPath;
public:
......@@ -28,9 +31,11 @@ public:
*/
void runUpdateInstaller();
int getUpdateProgress()const{return progress;}
QNetworkAccessManager * getQNetworkAccessManager(){return http.get();}
signals:
void needUpdate();
void updateProgressChanged();
void stateChanged();
};
#endif // UPDATER_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment