forked from qt-creator/qt-creator
Axivion: Move query error handling closer to query code
Change-Id: I6c57c0578b284f20e23312bf748c5efbe0ac3c3e Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <coreplugin/editormanager/documentmodel.h>
|
#include <coreplugin/editormanager/documentmodel.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
@@ -31,7 +30,6 @@
|
|||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
constexpr char AxivionTextMarkId[] = "AxivionTextMark";
|
constexpr char AxivionTextMarkId[] = "AxivionTextMark";
|
||||||
@@ -150,24 +148,6 @@ AxivionProjectSettings *AxivionPlugin::projectSettings(ProjectExplorer::Project
|
|||||||
return dd->projectSettings(project);
|
return dd->projectSettings(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AxivionPlugin::handleCertificateIssue()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(dd, return false);
|
|
||||||
|
|
||||||
const QString serverHost = QUrl(dd->m_axivionSettings.server.dashboard).host();
|
|
||||||
if (QMessageBox::question(Core::ICore::dialogParent(), Tr::tr("Certificate Error"),
|
|
||||||
Tr::tr("Server certificate for %1 cannot be authenticated.\n"
|
|
||||||
"Do you want to disable SSL verification for this server?\n"
|
|
||||||
"Note: This can expose you to man-in-the-middle attack.")
|
|
||||||
.arg(serverHost))
|
|
||||||
!= QMessageBox::Yes) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dd->m_axivionSettings.server.validateCert = false;
|
|
||||||
emit s_instance->settingsChanged();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AxivionPlugin::fetchProjectInfo(const QString &projectName)
|
void AxivionPlugin::fetchProjectInfo(const QString &projectName)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dd, return);
|
QTC_ASSERT(dd, return);
|
||||||
|
@@ -26,7 +26,6 @@ public:
|
|||||||
static AxivionSettings *settings();
|
static AxivionSettings *settings();
|
||||||
static AxivionProjectSettings *projectSettings(ProjectExplorer::Project *project);
|
static AxivionProjectSettings *projectSettings(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
static bool handleCertificateIssue();
|
|
||||||
static void fetchProjectInfo(const QString &projectName);
|
static void fetchProjectInfo(const QString &projectName);
|
||||||
static ProjectInfo projectInfo();
|
static ProjectInfo projectInfo();
|
||||||
signals:
|
signals:
|
||||||
|
@@ -5,10 +5,14 @@
|
|||||||
|
|
||||||
#include "axivionplugin.h"
|
#include "axivionplugin.h"
|
||||||
#include "axivionsettings.h"
|
#include "axivionsettings.h"
|
||||||
|
#include "axiviontr.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/processenums.h>
|
#include <utils/processenums.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -50,6 +54,24 @@ QString AxivionQuery::toString() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool handleCertificateIssue()
|
||||||
|
{
|
||||||
|
AxivionSettings *settings = AxivionPlugin::settings();
|
||||||
|
const QString serverHost = QUrl(settings->server.dashboard).host();
|
||||||
|
if (QMessageBox::question(Core::ICore::dialogParent(), Tr::tr("Certificate Error"),
|
||||||
|
Tr::tr("Server certificate for %1 cannot be authenticated.\n"
|
||||||
|
"Do you want to disable SSL verification for this server?\n"
|
||||||
|
"Note: This can expose you to man-in-the-middle attack.")
|
||||||
|
.arg(serverHost))
|
||||||
|
!= QMessageBox::Yes) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
settings->server.validateCert = false;
|
||||||
|
settings->apply();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
AxivionQueryRunner::AxivionQueryRunner(const AxivionQuery &query, QObject *parent)
|
AxivionQueryRunner::AxivionQueryRunner(const AxivionQuery &query, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@@ -71,7 +93,7 @@ AxivionQueryRunner::AxivionQueryRunner(const AxivionQuery &query, QObject *paren
|
|||||||
const int exitCode = m_process.exitCode();
|
const int exitCode = m_process.exitCode();
|
||||||
if (m_process.exitStatus() == QProcess::NormalExit
|
if (m_process.exitStatus() == QProcess::NormalExit
|
||||||
&& (exitCode == 35 || exitCode == 60)
|
&& (exitCode == 35 || exitCode == 60)
|
||||||
&& AxivionPlugin::handleCertificateIssue()) {
|
&& handleCertificateIssue()) {
|
||||||
// prepend -k for re-requesting same query
|
// prepend -k for re-requesting same query
|
||||||
CommandLine cmdline = m_process.commandLine();
|
CommandLine cmdline = m_process.commandLine();
|
||||||
cmdline.prependArgs({"-k"});
|
cmdline.prependArgs({"-k"});
|
||||||
|
Reference in New Issue
Block a user