GODT-2179: added handler for exceptions in QML backend methods.

GODT-2179: added custom QApplication class to handle exceptions.
GODT-2179: wired sentry report in AppController error handler.
This commit is contained in:
Xavier Michelon
2023-01-09 15:40:24 +01:00
parent f876ffab52
commit e3a43e4ca8
8 changed files with 450 additions and 187 deletions

View File

@ -18,10 +18,12 @@
#include "AppController.h" #include "AppController.h"
#include "QMLBackend.h" #include "QMLBackend.h"
#include "SentryUtils.h"
#include <bridgepp/GRPC/GRPCClient.h> #include <bridgepp/GRPC/GRPCClient.h>
#include <bridgepp/Exception/Exception.h> #include <bridgepp/Exception/Exception.h>
#include <bridgepp/ProcessMonitor.h> #include <bridgepp/ProcessMonitor.h>
#include <bridgepp/Log/Log.h> #include <bridgepp/Log/Log.h>
#include <sentry.h>
using namespace bridgepp; using namespace bridgepp;
@ -54,7 +56,7 @@ ProcessMonitor *AppController::bridgeMonitor() const {
return nullptr; return nullptr;
} }
// null bridgeOverseer is OK, it means we run in 'attached' mode (app attached to an already runnning instance of Bridge). // null bridgeOverseer is OK, it means we run in 'attached' mode (app attached to an already running instance of Bridge).
// but if bridgeOverseer is not null, its attached worker must be a valid ProcessMonitor instance. // but if bridgeOverseer is not null, its attached worker must be a valid ProcessMonitor instance.
auto *monitor = dynamic_cast<ProcessMonitor *>(bridgeOverseer_->worker()); auto *monitor = dynamic_cast<ProcessMonitor *>(bridgeOverseer_->worker());
if (!monitor) { if (!monitor) {
@ -65,3 +67,14 @@ ProcessMonitor *AppController::bridgeMonitor() const {
} }
//****************************************************************************************************************************************************
/// \param[in] function The function that caught the exception.
/// \param[in] message The error message.
//****************************************************************************************************************************************************
void AppController::onFatalError(QString const &function, QString const &message) {
QString const fullMessage = QString("%1(): %2").arg(function, message);
reportSentryException(SENTRY_LEVEL_ERROR, "AppController got notified of a fatal error", "Exception", fullMessage.toLocal8Bit());
QMessageBox::critical(nullptr, tr("Error"), message);
log().fatal(fullMessage);
qApp->exit(EXIT_FAILURE);
}

View File

@ -56,6 +56,9 @@ public: // member functions.
std::unique_ptr<bridgepp::Overseer> &bridgeOverseer() { return bridgeOverseer_; }; ///< Returns a reference the bridge overseer std::unique_ptr<bridgepp::Overseer> &bridgeOverseer() { return bridgeOverseer_; }; ///< Returns a reference the bridge overseer
bridgepp::ProcessMonitor *bridgeMonitor() const; ///< Return the bridge worker. bridgepp::ProcessMonitor *bridgeMonitor() const; ///< Return the bridge worker.
public slots:
void onFatalError(QString const &function, QString const &message); ///< Handle fatal errors.
private: // member functions private: // member functions
AppController(); ///< Default constructor. AppController(); ///< Default constructor.

View File

@ -0,0 +1,49 @@
// Copyright (c) 2023 Proton AG
//
// This file is part of Proton Mail Bridge.
//
// Proton Mail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Proton Mail Bridge 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
#include "BridgeApp.h"
#include <bridgepp/Exception/Exception.h>
using namespace bridgepp;
//****************************************************************************************************************************************************
/// \param[in] argc The number of command-line arguments.
/// \param[in] argv The list of command-line arguments.
//****************************************************************************************************************************************************
BridgeApp::BridgeApp(int &argc, char **argv)
: QApplication(argc, argv) {
}
//****************************************************************************************************************************************************
/// \param[in] object The object.
/// \param[in] event The event.
//****************************************************************************************************************************************************
bool BridgeApp::notify(QObject *object, QEvent *event) {
try {
return QApplication::notify(object, event);
} catch (Exception const &e) {
emit fatalError(__func__, e.qwhat());
} catch (...) {
emit fatalError(__func__, QString("An unknown exception occurred"));
}
return false;
}

View File

@ -0,0 +1,43 @@
// Copyright (c) 2023 Proton AG
//
// This file is part of Proton Mail Bridge.
//
// Proton Mail Bridge is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Proton Mail Bridge 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Proton Mail Bridge. If not, see <https://www.gnu.org/licenses/>.
#ifndef BRIDGE_GUI_APP_H
#define BRIDGE_GUI_APP_H
//**********************************************************************************************************************
/// \brief Bridge application class
//**********************************************************************************************************************
class BridgeApp : public QApplication {
Q_OBJECT
public: // member functions.
BridgeApp(int &argc, char **argv);
bool notify(QObject *object, QEvent *event) override;
///< Constructor.
BridgeApp(BridgeApp const &) = delete; ///< Disabled copy-constructor.
BridgeApp(BridgeApp &&) = delete; ///< Disabled assignment copy-constructor.
~BridgeApp() = default; ///< Destructor.
BridgeApp &operator=(BridgeApp const &) = delete; ///< Disabled assignment operator.
BridgeApp &operator=(BridgeApp &&) = delete; ///< Disabled move assignment operator.
signals:
void fatalError(QString const &function, QString const &message); ///< Signal emitted when an fatal error occurs.
};
#endif //BRIDGE_GUI_APP_H

View File

@ -117,6 +117,7 @@ endif(UNIX)
add_executable(bridge-gui add_executable(bridge-gui
Resources.qrc Resources.qrc
AppController.cpp AppController.h AppController.cpp AppController.h
BridgeApp.cpp BridgeApp.h
CommandLine.cpp CommandLine.h CommandLine.cpp CommandLine.h
EventStreamWorker.cpp EventStreamWorker.h EventStreamWorker.cpp EventStreamWorker.h
main.cpp main.cpp

View File

@ -24,6 +24,14 @@
#include <bridgepp/Worker/Overseer.h> #include <bridgepp/Worker/Overseer.h>
#define HANDLE_EXCEPTION(x) try { x } \
catch (Exception const &e) { emit fatalError(__func__, e.qwhat()); } \
catch (...) { emit fatalError(__func__, QString("An unknown exception occurred")); }
#define HANDLE_EXCEPTION_RETURN_BOOL(x) HANDLE_EXCEPTION(x) return false;
#define HANDLE_EXCEPTION_RETURN_QSTRING(x) HANDLE_EXCEPTION(x) return QString();
#define HANDLE_EXCEPTION_RETURN_ZERO(x) HANDLE_EXCEPTION(x) return 0;
using namespace bridgepp; using namespace bridgepp;
@ -39,6 +47,8 @@ QMLBackend::QMLBackend()
/// \param[in] serviceConfig /// \param[in] serviceConfig
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::init(GRPCConfig const &serviceConfig) { void QMLBackend::init(GRPCConfig const &serviceConfig) {
connect(this, &QMLBackend::fatalError, &app(), &AppController::onFatalError);
users_ = new UserList(this); users_ = new UserList(this);
Log &log = app().log(); Log &log = app().log();
@ -95,18 +105,23 @@ bool QMLBackend::waitForEventStreamReaderToFinish(qint32 timeoutMs) {
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
/// \return The position of the cursor. /// \return The position of the cursor.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QPoint QMLBackend::getCursorPos() { QPoint QMLBackend::getCursorPos() const {
return QCursor::pos(); HANDLE_EXCEPTION(
return QCursor::pos();
)
return QPoint();
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
/// \return true iff port is available (i.e. not bound). /// \return true iff port is available (i.e. not bound).
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::isPortFree(int port) { bool QMLBackend::isPortFree(int port) const {
bool isFree = false; HANDLE_EXCEPTION_RETURN_BOOL(
app().grpc().isPortFree(port, isFree); bool isFree = false;
return isFree; app().grpc().isPortFree(port, isFree);
return isFree;
)
} }
@ -114,8 +129,10 @@ bool QMLBackend::isPortFree(int port) {
/// \param[in] url The local file URL. /// \param[in] url The local file URL.
/// \return true the native local file path of the given URL. /// \return true the native local file path of the given URL.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::nativePath(QUrl const &url) { QString QMLBackend::nativePath(QUrl const &url) const {
return QDir::toNativeSeparators(url.toLocalFile()); HANDLE_EXCEPTION_RETURN_QSTRING(
return QDir::toNativeSeparators(url.toLocalFile());
)
} }
@ -124,8 +141,10 @@ QString QMLBackend::nativePath(QUrl const &url) {
/// \param[in] rhs THe second file. /// \param[in] rhs THe second file.
/// \return true iff the two URL point to the same local file or folder. /// \return true iff the two URL point to the same local file or folder.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::areSameFileOrFolder(QUrl const &lhs, QUrl const &rhs) { bool QMLBackend::areSameFileOrFolder(QUrl const &lhs, QUrl const &rhs) const {
return QFileInfo(lhs.toLocalFile()) == QFileInfo(rhs.toLocalFile()); HANDLE_EXCEPTION_RETURN_BOOL(
return QFileInfo(lhs.toLocalFile()) == QFileInfo(rhs.toLocalFile());
)
} }
@ -133,9 +152,11 @@ bool QMLBackend::areSameFileOrFolder(QUrl const &lhs, QUrl const &rhs) {
/// \return The value for the 'showOnStartup' property. /// \return The value for the 'showOnStartup' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::showOnStartup() const { bool QMLBackend::showOnStartup() const {
bool v = false; HANDLE_EXCEPTION_RETURN_BOOL(
app().grpc().showOnStartup(v); bool v = false;
return v; app().grpc().showOnStartup(v);
return v;
)
} }
@ -143,9 +164,12 @@ bool QMLBackend::showOnStartup() const {
/// \[param[in] show The value for the 'showSplashScreen' property. /// \[param[in] show The value for the 'showSplashScreen' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::setShowSplashScreen(bool show) { void QMLBackend::setShowSplashScreen(bool show) {
if (show != showSplashScreen_) { HANDLE_EXCEPTION(
showSplashScreen_ = show; emit showSplashScreenChanged(show); if (show != showSplashScreen_) {
} showSplashScreen_ = show;
emit showSplashScreenChanged(show);
}
)
} }
@ -153,15 +177,19 @@ void QMLBackend::setShowSplashScreen(bool show) {
/// \return The value for the 'showSplashScreen' property. /// \return The value for the 'showSplashScreen' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::showSplashScreen() const { bool QMLBackend::showSplashScreen() const {
return showSplashScreen_; HANDLE_EXCEPTION_RETURN_BOOL(
return showSplashScreen_;
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
/// \return The value for the 'GOOS' property. /// \return The value for the 'GOOS' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::goos() { QString QMLBackend::goos() const {
return goos_; HANDLE_EXCEPTION_RETURN_QSTRING(
return goos_;
)
} }
@ -169,7 +197,9 @@ QString QMLBackend::goos() {
/// \return The value for the 'logsPath' property. /// \return The value for the 'logsPath' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QUrl QMLBackend::logsPath() const { QUrl QMLBackend::logsPath() const {
return logsPath_; HANDLE_EXCEPTION_RETURN_QSTRING(
return logsPath_;
)
} }
@ -177,7 +207,9 @@ QUrl QMLBackend::logsPath() const {
/// \return The value for the 'licensePath' property. /// \return The value for the 'licensePath' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QUrl QMLBackend::licensePath() const { QUrl QMLBackend::licensePath() const {
return licensePath_; HANDLE_EXCEPTION_RETURN_QSTRING(
return licensePath_;
)
} }
@ -185,9 +217,11 @@ QUrl QMLBackend::licensePath() const {
/// \return The value for the 'releaseNotesLink' property. /// \return The value for the 'releaseNotesLink' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QUrl QMLBackend::releaseNotesLink() const { QUrl QMLBackend::releaseNotesLink() const {
QUrl link; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().releaseNotesPageLink(link); QUrl link;
return link; app().grpc().releaseNotesPageLink(link);
return link;
)
} }
@ -195,9 +229,11 @@ QUrl QMLBackend::releaseNotesLink() const {
/// \return The value for the 'dependencyLicensesLink' property. /// \return The value for the 'dependencyLicensesLink' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QUrl QMLBackend::dependencyLicensesLink() const { QUrl QMLBackend::dependencyLicensesLink() const {
QUrl link; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().dependencyLicensesLink(link); QUrl link;
return link; app().grpc().dependencyLicensesLink(link);
return link;
)
} }
@ -205,9 +241,11 @@ QUrl QMLBackend::dependencyLicensesLink() const {
/// \return The value for the 'landingPageLink' property. /// \return The value for the 'landingPageLink' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QUrl QMLBackend::landingPageLink() const { QUrl QMLBackend::landingPageLink() const {
QUrl link; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().landingPageLink(link); QUrl link;
return link; app().grpc().landingPageLink(link);
return link;
)
} }
@ -215,7 +253,9 @@ QUrl QMLBackend::landingPageLink() const {
/// \return The value for the 'appname' property. /// \return The value for the 'appname' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::appname() const { QString QMLBackend::appname() const {
return QString(PROJECT_FULL_NAME); HANDLE_EXCEPTION_RETURN_QSTRING(
return QString(PROJECT_FULL_NAME);
)
} }
@ -223,7 +263,9 @@ QString QMLBackend::appname() const {
/// \return The value for the 'vendor' property. /// \return The value for the 'vendor' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::vendor() const { QString QMLBackend::vendor() const {
return QString(PROJECT_VENDOR); HANDLE_EXCEPTION_RETURN_QSTRING(
return QString(PROJECT_VENDOR);
)
} }
@ -231,9 +273,11 @@ QString QMLBackend::vendor() const {
/// \return The value for the 'vendor' property. /// \return The value for the 'vendor' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::version() const { QString QMLBackend::version() const {
QString version; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().version(version); QString version;
return version; app().grpc().version(version);
return version;
)
} }
@ -241,9 +285,11 @@ QString QMLBackend::version() const {
/// \return The value for the 'hostname' property. /// \return The value for the 'hostname' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::hostname() const { QString QMLBackend::hostname() const {
QString hostname; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().hostname(hostname); QString hostname;
return hostname; app().grpc().hostname(hostname);
return hostname;
)
} }
@ -251,9 +297,11 @@ QString QMLBackend::hostname() const {
/// \return The value for the 'isAutostartOn' property. /// \return The value for the 'isAutostartOn' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::isAutostartOn() const { bool QMLBackend::isAutostartOn() const {
bool v; HANDLE_EXCEPTION_RETURN_BOOL(
app().grpc().isAutostartOn(v); bool v;
return v; app().grpc().isAutostartOn(v);
return v;
)
} }
@ -261,9 +309,11 @@ bool QMLBackend::isAutostartOn() const {
/// \return The value for the 'isBetaEnabled' property. /// \return The value for the 'isBetaEnabled' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::isBetaEnabled() const { bool QMLBackend::isBetaEnabled() const {
bool v; HANDLE_EXCEPTION_RETURN_BOOL(
app().grpc().isBetaEnabled(v); bool v;
return v; app().grpc().isBetaEnabled(v);
return v;
)
} }
@ -271,9 +321,11 @@ bool QMLBackend::isBetaEnabled() const {
/// \return The value for the 'isAllMailVisible' property. /// \return The value for the 'isAllMailVisible' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::isAllMailVisible() const { bool QMLBackend::isAllMailVisible() const {
bool v; HANDLE_EXCEPTION_RETURN_BOOL(
app().grpc().isAllMailVisible(v); bool v;
return v; app().grpc().isAllMailVisible(v);
return v;
)
} }
@ -281,9 +333,11 @@ bool QMLBackend::isAllMailVisible() const {
/// \return The value for the 'colorSchemeName' property. /// \return The value for the 'colorSchemeName' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::colorSchemeName() const { QString QMLBackend::colorSchemeName() const {
QString name; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().colorSchemeName(name); QString name;
return name; app().grpc().colorSchemeName(name);
return name;
)
} }
@ -291,9 +345,11 @@ QString QMLBackend::colorSchemeName() const {
/// \return The value for the 'diskCachePath' property. /// \return The value for the 'diskCachePath' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QUrl QMLBackend::diskCachePath() const { QUrl QMLBackend::diskCachePath() const {
QUrl path; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().diskCachePath(path); QUrl path;
return path; app().grpc().diskCachePath(path);
return path;
)
} }
@ -301,11 +357,13 @@ QUrl QMLBackend::diskCachePath() const {
/// \param[in] value The value for the 'UseSSLForIMAP' property. /// \param[in] value The value for the 'UseSSLForIMAP' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::setUseSSLForIMAP(bool value) { void QMLBackend::setUseSSLForIMAP(bool value) {
if (value == useSSLForIMAP_) { HANDLE_EXCEPTION(
return; if (value == useSSLForIMAP_) {
} return;
useSSLForIMAP_ = value; }
emit useSSLForIMAPChanged(value); useSSLForIMAP_ = value;
emit useSSLForIMAPChanged(value);
)
} }
@ -313,7 +371,9 @@ void QMLBackend::setUseSSLForIMAP(bool value) {
/// \return The value for the 'UseSSLForIMAP' property. /// \return The value for the 'UseSSLForIMAP' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::useSSLForIMAP() const { bool QMLBackend::useSSLForIMAP() const {
return useSSLForIMAP_; HANDLE_EXCEPTION_RETURN_BOOL(
return useSSLForIMAP_;
)
} }
@ -321,11 +381,13 @@ bool QMLBackend::useSSLForIMAP() const {
/// \param[in] value The value for the 'UseSSLForSMTP' property. /// \param[in] value The value for the 'UseSSLForSMTP' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::setUseSSLForSMTP(bool value) { void QMLBackend::setUseSSLForSMTP(bool value) {
if (value == useSSLForSMTP_) { HANDLE_EXCEPTION(
return; if (value == useSSLForSMTP_) {
} return;
useSSLForSMTP_ = value; }
emit useSSLForSMTPChanged(value); useSSLForSMTP_ = value;
emit useSSLForSMTPChanged(value);
)
} }
@ -333,7 +395,9 @@ void QMLBackend::setUseSSLForSMTP(bool value) {
/// \return The value for the 'UseSSLForSMTP' property. /// \return The value for the 'UseSSLForSMTP' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::useSSLForSMTP() const { bool QMLBackend::useSSLForSMTP() const {
return useSSLForSMTP_; HANDLE_EXCEPTION_RETURN_BOOL(
return useSSLForSMTP_;
)
} }
@ -341,11 +405,13 @@ bool QMLBackend::useSSLForSMTP() const {
/// \param[in] port The value for the 'imapPort' property. /// \param[in] port The value for the 'imapPort' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::setIMAPPort(int port) { void QMLBackend::setIMAPPort(int port) {
if (port == imapPort_) { HANDLE_EXCEPTION(
return; if (port == imapPort_) {
} return;
imapPort_ = port; }
emit imapPortChanged(port); imapPort_ = port;
emit imapPortChanged(port);
)
} }
@ -353,7 +419,9 @@ void QMLBackend::setIMAPPort(int port) {
/// \return The value for the 'imapPort' property. /// \return The value for the 'imapPort' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
int QMLBackend::imapPort() const { int QMLBackend::imapPort() const {
return imapPort_; HANDLE_EXCEPTION_RETURN_ZERO(
return imapPort_;
)
} }
@ -361,11 +429,13 @@ int QMLBackend::imapPort() const {
/// \param[in] port The value for the 'smtpPort' property. /// \param[in] port The value for the 'smtpPort' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::setSMTPPort(int port) { void QMLBackend::setSMTPPort(int port) {
if (port == smtpPort_) { HANDLE_EXCEPTION(
return; if (port == smtpPort_) {
} return;
smtpPort_ = port; }
emit smtpPortChanged(port); smtpPort_ = port;
emit smtpPortChanged(port);
)
} }
@ -373,7 +443,9 @@ void QMLBackend::setSMTPPort(int port) {
/// \return The value for the 'smtpPort' property. /// \return The value for the 'smtpPort' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
int QMLBackend::smtpPort() const { int QMLBackend::smtpPort() const {
return smtpPort_; HANDLE_EXCEPTION_RETURN_ZERO(
return smtpPort_;
)
} }
@ -381,9 +453,11 @@ int QMLBackend::smtpPort() const {
/// \return The value for the 'isDoHEnabled' property. /// \return The value for the 'isDoHEnabled' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::isDoHEnabled() const { bool QMLBackend::isDoHEnabled() const {
bool isEnabled; HANDLE_EXCEPTION_RETURN_BOOL(
app().grpc().isDoHEnabled(isEnabled); bool isEnabled;
return isEnabled; app().grpc().isDoHEnabled(isEnabled);
return isEnabled;
)
} }
@ -391,9 +465,11 @@ bool QMLBackend::isDoHEnabled() const {
/// \return The value for the 'isFirstGUIStart' property. /// \return The value for the 'isFirstGUIStart' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::isFirstGUIStart() const { bool QMLBackend::isFirstGUIStart() const {
bool v; HANDLE_EXCEPTION_RETURN_BOOL(
app().grpc().isFirstGUIStart(v); bool v;
return v; app().grpc().isFirstGUIStart(v);
return v;
)
} }
@ -401,19 +477,23 @@ bool QMLBackend::isFirstGUIStart() const {
/// \return The value for the 'isAutomaticUpdateOn' property. /// \return The value for the 'isAutomaticUpdateOn' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::isAutomaticUpdateOn() const { bool QMLBackend::isAutomaticUpdateOn() const {
bool isOn = false; HANDLE_EXCEPTION_RETURN_BOOL(
app().grpc().isAutomaticUpdateOn(isOn); bool isOn = false;
return isOn; app().grpc().isAutomaticUpdateOn(isOn);
return isOn;
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
/// \return The value for the 'currentEmailClient' property. /// \return The value for the 'currentEmailClient' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::currentEmailClient() { QString QMLBackend::currentEmailClient() const {
QString client; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().currentEmailClient(client); QString client;
return client; app().grpc().currentEmailClient(client);
return client;
)
} }
@ -421,9 +501,12 @@ QString QMLBackend::currentEmailClient() {
/// \return The value for the 'availableKeychain' property. /// \return The value for the 'availableKeychain' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QStringList QMLBackend::availableKeychain() const { QStringList QMLBackend::availableKeychain() const {
QStringList keychains; HANDLE_EXCEPTION(
app().grpc().availableKeychains(keychains); QStringList keychains;
return keychains; app().grpc().availableKeychains(keychains);
return keychains;
)
return QStringList();
} }
@ -431,9 +514,11 @@ QStringList QMLBackend::availableKeychain() const {
/// \return The value for the 'currentKeychain' property. /// \return The value for the 'currentKeychain' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
QString QMLBackend::currentKeychain() const { QString QMLBackend::currentKeychain() const {
QString keychain; HANDLE_EXCEPTION_RETURN_QSTRING(
app().grpc().currentKeychain(keychain); QString keychain;
return keychain; app().grpc().currentKeychain(keychain);
return keychain;
)
} }
@ -441,7 +526,9 @@ QString QMLBackend::currentKeychain() const {
/// \return The value for the 'dockIconVisible' property. /// \return The value for the 'dockIconVisible' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
bool QMLBackend::dockIconVisible() const { bool QMLBackend::dockIconVisible() const {
return getDockIconVisibleState(); HANDLE_EXCEPTION_RETURN_BOOL(
return getDockIconVisibleState();
)
} }
@ -449,7 +536,9 @@ bool QMLBackend::dockIconVisible() const {
/// \[param[in] visible The value for the 'dockIconVisible' property. /// \[param[in] visible The value for the 'dockIconVisible' property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::setDockIconVisible(bool visible) { void QMLBackend::setDockIconVisible(bool visible) {
setDockIconVisibleState(visible); emit dockIconVisibleChanged(visible); HANDLE_EXCEPTION(
setDockIconVisibleState(visible); emit dockIconVisibleChanged(visible);
)
} }
@ -457,8 +546,10 @@ void QMLBackend::setDockIconVisible(bool visible) {
/// \param[in] active Should we activate autostart. /// \param[in] active Should we activate autostart.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::toggleAutostart(bool active) { void QMLBackend::toggleAutostart(bool active) {
app().grpc().setIsAutostartOn(active); HANDLE_EXCEPTION(
emit isAutostartOnChanged(this->isAutostartOn()); app().grpc().setIsAutostartOn(active);
emit isAutostartOnChanged(this->isAutostartOn());
)
} }
@ -466,8 +557,10 @@ void QMLBackend::toggleAutostart(bool active) {
/// \param[in] active The new state for the beta enabled property. /// \param[in] active The new state for the beta enabled property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::toggleBeta(bool active) { void QMLBackend::toggleBeta(bool active) {
app().grpc().setIsBetaEnabled(active); HANDLE_EXCEPTION(
emit isBetaEnabledChanged(this->isBetaEnabled()); app().grpc().setIsBetaEnabled(active);
emit isBetaEnabledChanged(this->isBetaEnabled());
)
} }
@ -475,8 +568,10 @@ void QMLBackend::toggleBeta(bool active) {
/// \param[in] isVisible The new state for the All Mail visibility property. /// \param[in] isVisible The new state for the All Mail visibility property.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::changeIsAllMailVisible(bool isVisible) { void QMLBackend::changeIsAllMailVisible(bool isVisible) {
app().grpc().setIsAllMailVisible(isVisible); HANDLE_EXCEPTION(
emit isAllMailVisibleChanged(this->isAllMailVisible()); app().grpc().setIsAllMailVisible(isVisible);
emit isAllMailVisibleChanged(this->isAllMailVisible());
)
} }
@ -484,8 +579,10 @@ void QMLBackend::changeIsAllMailVisible(bool isVisible) {
/// \param[in] scheme the scheme name /// \param[in] scheme the scheme name
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::changeColorScheme(QString const &scheme) { void QMLBackend::changeColorScheme(QString const &scheme) {
app().grpc().setColorSchemeName(scheme); HANDLE_EXCEPTION(
emit colorSchemeNameChanged(this->colorSchemeName()); app().grpc().setColorSchemeName(scheme);
emit colorSchemeNameChanged(this->colorSchemeName());
)
} }
@ -493,7 +590,9 @@ void QMLBackend::changeColorScheme(QString const &scheme) {
/// \param[in] path The path of the disk cache. /// \param[in] path The path of the disk cache.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::setDiskCachePath(QUrl const &path) const { void QMLBackend::setDiskCachePath(QUrl const &path) const {
app().grpc().setDiskCachePath(path); HANDLE_EXCEPTION(
app().grpc().setDiskCachePath(path);
)
} }
@ -501,8 +600,13 @@ void QMLBackend::setDiskCachePath(QUrl const &path) const {
/// \param[in] username The username. /// \param[in] username The username.
/// \param[in] password The account password. /// \param[in] password The account password.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::login(QString const &username, QString const &password) { void QMLBackend::login(QString const &username, QString const &password) const {
app().grpc().login(username, password); HANDLE_EXCEPTION(
if (username.compare("coco@bandicoot", Qt::CaseInsensitive) == 0) {
throw Exception("User requested bridge-gui to crash by trying to log as coco@bandicoot");
}
app().grpc().login(username, password);
)
} }
@ -510,8 +614,10 @@ void QMLBackend::login(QString const &username, QString const &password) {
/// \param[in] username The username. /// \param[in] username The username.
/// \param[in] code The 2FA code. /// \param[in] code The 2FA code.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::login2FA(QString const &username, QString const &code) { void QMLBackend::login2FA(QString const &username, QString const &code) const {
app().grpc().login2FA(username, code); HANDLE_EXCEPTION(
app().grpc().login2FA(username, code);
)
} }
@ -519,16 +625,20 @@ void QMLBackend::login2FA(QString const &username, QString const &code) {
/// \param[in] username The username. /// \param[in] username The username.
/// \param[in] password The mailbox password. /// \param[in] password The mailbox password.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::login2Password(QString const &username, QString const &password) { void QMLBackend::login2Password(QString const &username, QString const &password) const {
app().grpc().login2Passwords(username, password); HANDLE_EXCEPTION(
app().grpc().login2Passwords(username, password);
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
/// \param[in] username The username. /// \param[in] username The username.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::loginAbort(QString const &username) { void QMLBackend::loginAbort(QString const &username) const {
app().grpc().loginAbort(username); HANDLE_EXCEPTION(
app().grpc().loginAbort(username);
)
} }
@ -536,9 +646,11 @@ void QMLBackend::loginAbort(QString const &username) {
/// \param[in] active Should DoH be active. /// \param[in] active Should DoH be active.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::toggleDoH(bool active) { void QMLBackend::toggleDoH(bool active) {
if (app().grpc().setIsDoHEnabled(active).ok()) { HANDLE_EXCEPTION(
emit isDoHEnabledChanged(active); if (app().grpc().setIsDoHEnabled(active).ok()) {
} emit isDoHEnabledChanged(active);
}
)
} }
@ -546,9 +658,11 @@ void QMLBackend::toggleDoH(bool active) {
/// \param[in] active Should automatic update be turned on. /// \param[in] active Should automatic update be turned on.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::toggleAutomaticUpdate(bool active) { void QMLBackend::toggleAutomaticUpdate(bool active) {
if (app().grpc().setIsAutomaticUpdateOn(active).ok()) { HANDLE_EXCEPTION(
emit isAutomaticUpdateOnChanged(active); if (app().grpc().setIsAutomaticUpdateOn(active).ok()) {
} emit isAutomaticUpdateOnChanged(active);
}
)
} }
@ -556,7 +670,9 @@ void QMLBackend::toggleAutomaticUpdate(bool active) {
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::updateCurrentMailClient() { void QMLBackend::updateCurrentMailClient() {
emit currentEmailClientChanged(currentEmailClient()); HANDLE_EXCEPTION(
emit currentEmailClientChanged(currentEmailClient());
)
} }
@ -564,66 +680,82 @@ void QMLBackend::updateCurrentMailClient() {
/// \param[in] keychain The new keychain. /// \param[in] keychain The new keychain.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::changeKeychain(QString const &keychain) { void QMLBackend::changeKeychain(QString const &keychain) {
if (app().grpc().setCurrentKeychain(keychain).ok()) { HANDLE_EXCEPTION(
emit currentKeychainChanged(keychain); if (app().grpc().setCurrentKeychain(keychain).ok()) {
} emit currentKeychainChanged(keychain);
}
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::guiReady() { void QMLBackend::guiReady() const {
app().grpc().guiReady(); HANDLE_EXCEPTION(
app().grpc().guiReady();
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::quit() { void QMLBackend::quit() const {
app().grpc().quit(); HANDLE_EXCEPTION(
qApp->exit(0); app().grpc().quit();
qApp->exit(0);
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::restart() { void QMLBackend::restart() const {
app().grpc().restart(); HANDLE_EXCEPTION(
app().grpc().restart();
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
/// \param[in] launcher The path to the launcher. /// \param[in] launcher The path to the launcher.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::forceLauncher(QString launcher) { void QMLBackend::forceLauncher(QString launcher) const {
app().grpc().forceLauncher(launcher); HANDLE_EXCEPTION(
app().grpc().forceLauncher(launcher);
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::checkUpdates() { void QMLBackend::checkUpdates() const {
app().grpc().checkUpdate(); HANDLE_EXCEPTION(
app().grpc().checkUpdate();
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::installUpdate() { void QMLBackend::installUpdate() const {
app().grpc().installUpdate(); HANDLE_EXCEPTION(
app().grpc().installUpdate();
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::triggerReset() { void QMLBackend::triggerReset() const {
app().grpc().triggerReset(); HANDLE_EXCEPTION(
app().grpc().triggerReset();
)
} }
@ -633,20 +765,24 @@ void QMLBackend::triggerReset() {
/// \param[in] emailClient The email client. /// \param[in] emailClient The email client.
/// \param[in] includeLogs Should the logs be included in the report. /// \param[in] includeLogs Should the logs be included in the report.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::reportBug(QString const &description, QString const &address, QString const &emailClient, bool includeLogs) { void QMLBackend::reportBug(QString const &description, QString const &address, QString const &emailClient, bool includeLogs) const {
app().grpc().reportBug(description, address, emailClient, includeLogs); HANDLE_EXCEPTION(
app().grpc().reportBug(description, address, emailClient, includeLogs);
)
} }
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::exportTLSCertificates() { void QMLBackend::exportTLSCertificates() const {
QString const folderPath = QFileDialog::getExistingDirectory(nullptr, QObject::tr("Select directory"), HANDLE_EXCEPTION(
QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); QString const folderPath = QFileDialog::getExistingDirectory(nullptr, QObject::tr("Select directory"),
if (!folderPath.isEmpty()) { QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
app().grpc().exportTLSCertificates(folderPath); if (!folderPath.isEmpty()) {
} app().grpc().exportTLSCertificates(folderPath);
}
)
} }
@ -654,8 +790,10 @@ void QMLBackend::exportTLSCertificates() {
// //
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::onResetFinished() { void QMLBackend::onResetFinished() {
emit resetFinished(); HANDLE_EXCEPTION(
this->restart(); emit resetFinished();
this->restart();
)
} }
@ -663,8 +801,10 @@ void QMLBackend::onResetFinished() {
// onVersionChanged update dynamic link related to version // onVersionChanged update dynamic link related to version
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::onVersionChanged() { void QMLBackend::onVersionChanged() {
emit releaseNotesLinkChanged(releaseNotesLink()); HANDLE_EXCEPTION(
emit landingPageLinkChanged(landingPageLink()); emit releaseNotesLinkChanged(releaseNotesLink());
emit landingPageLinkChanged(landingPageLink());
)
} }
@ -674,8 +814,10 @@ void QMLBackend::onVersionChanged() {
/// \param[in] useSSLForIMAP The value for the 'Use SSL for IMAP' property /// \param[in] useSSLForIMAP The value for the 'Use SSL for IMAP' property
/// \param[in] useSSLForSMTP The value for the 'Use SSL for SMTP' property /// \param[in] useSSLForSMTP The value for the 'Use SSL for SMTP' property
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::setMailServerSettings(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP) { void QMLBackend::setMailServerSettings(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP) const {
app().grpc().setMailServerSettings(imapPort, smtpPort, useSSLForIMAP, useSSLForSMTP); HANDLE_EXCEPTION(
app().grpc().setMailServerSettings(imapPort, smtpPort, useSSLForIMAP, useSSLForSMTP);
)
} }
@ -686,10 +828,12 @@ void QMLBackend::setMailServerSettings(int imapPort, int smtpPort, bool useSSLFo
/// \param[in] useSSLForSMTP The value for the 'Use SSL for SMTP' property /// \param[in] useSSLForSMTP The value for the 'Use SSL for SMTP' property
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::onMailServerSettingsChanged(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP) { void QMLBackend::onMailServerSettingsChanged(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP) {
this->setIMAPPort(imapPort); HANDLE_EXCEPTION(
this->setSMTPPort(smtpPort); this->setIMAPPort(imapPort);
this->setUseSSLForIMAP(useSSLForIMAP); this->setSMTPPort(smtpPort);
this->setUseSSLForSMTP(useSSLForSMTP); this->setUseSSLForIMAP(useSSLForIMAP);
this->setUseSSLForSMTP(useSSLForSMTP);
)
} }
@ -697,7 +841,9 @@ void QMLBackend::onMailServerSettingsChanged(int imapPort, int smtpPort, bool us
/// param[in] info The error information. /// param[in] info The error information.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::onGenericError(ErrorInfo const &info) { void QMLBackend::onGenericError(ErrorInfo const &info) {
emit genericError(info.title, info.description); HANDLE_EXCEPTION(
emit genericError(info.title, info.description);
)
} }
@ -706,9 +852,11 @@ void QMLBackend::onGenericError(ErrorInfo const &info) {
/// \param[in] wasSignedOut Was the user signed-out. /// \param[in] wasSignedOut Was the user signed-out.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::onLoginFinished(QString const &userID, bool wasSignedOut) { void QMLBackend::onLoginFinished(QString const &userID, bool wasSignedOut) {
this->retrieveUserList(); HANDLE_EXCEPTION(
qint32 const index = users_->rowOfUserID(userID); this->retrieveUserList();
emit loginFinished(index, wasSignedOut); qint32 const index = users_->rowOfUserID(userID);
emit loginFinished(index, wasSignedOut);
)
} }
@ -716,9 +864,11 @@ void QMLBackend::onLoginFinished(QString const &userID, bool wasSignedOut) {
/// \param[in] userID the userID. /// \param[in] userID the userID.
//**************************************************************************************************************************************************** //****************************************************************************************************************************************************
void QMLBackend::onLoginAlreadyLoggedIn(QString const &userID) { void QMLBackend::onLoginAlreadyLoggedIn(QString const &userID) {
this->retrieveUserList(); HANDLE_EXCEPTION(
qint32 const index = users_->rowOfUserID(userID); this->retrieveUserList();
emit loginAlreadyLoggedIn(index); qint32 const index = users_->rowOfUserID(userID);
emit loginAlreadyLoggedIn(index);
)
} }

View File

@ -45,10 +45,10 @@ public: // member functions.
bool waitForEventStreamReaderToFinish(qint32 timeoutMs); ///< Wait for the event stream reader to finish. bool waitForEventStreamReaderToFinish(qint32 timeoutMs); ///< Wait for the event stream reader to finish.
// invokable methods can be called from QML. They generally return a value, which slots cannot do. // invokable methods can be called from QML. They generally return a value, which slots cannot do.
Q_INVOKABLE static QPoint getCursorPos(); ///< Retrieve the cursor position. Q_INVOKABLE QPoint getCursorPos() const; ///< Retrieve the cursor position.
Q_INVOKABLE static bool isPortFree(int port); ///< Check if a given network port is available. Q_INVOKABLE bool isPortFree(int port) const; ///< Check if a given network port is available.
Q_INVOKABLE static QString nativePath(QUrl const &url); ///< Retrieve the native path of a local URL. Q_INVOKABLE QString nativePath(QUrl const &url) const; ///< Retrieve the native path of a local URL.
Q_INVOKABLE static bool areSameFileOrFolder(QUrl const &lhs, QUrl const &rhs); ///< Check if two local URL point to the same file. Q_INVOKABLE bool areSameFileOrFolder(QUrl const &lhs, QUrl const &rhs) const; ///< Check if two local URL point to the same file.
public: // Qt/QML properties. Note that the NOTIFY-er signal is required even for read-only properties (QML warning otherwise) public: // Qt/QML properties. Note that the NOTIFY-er signal is required even for read-only properties (QML warning otherwise)
Q_PROPERTY(bool showOnStartup READ showOnStartup NOTIFY showOnStartupChanged) Q_PROPERTY(bool showOnStartup READ showOnStartup NOTIFY showOnStartupChanged)
@ -86,7 +86,7 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
bool showOnStartup() const; ///< Getter for the 'showOnStartup' property. bool showOnStartup() const; ///< Getter for the 'showOnStartup' property.
void setShowSplashScreen(bool show); ///< Setter for the 'showSplashScreen' property. void setShowSplashScreen(bool show); ///< Setter for the 'showSplashScreen' property.
bool showSplashScreen() const; ///< Getter for the 'showSplashScreen' property. bool showSplashScreen() const; ///< Getter for the 'showSplashScreen' property.
QString goos(); ///< Getter for the 'GOOS' property. QString goos() const; ///< Getter for the 'GOOS' property.
QUrl logsPath() const; ///< Getter for the 'logsPath' property. QUrl logsPath() const; ///< Getter for the 'logsPath' property.
QUrl licensePath() const; ///< Getter for the 'licensePath' property. QUrl licensePath() const; ///< Getter for the 'licensePath' property.
QUrl releaseNotesLink() const;///< Getter for the 'releaseNotesLink' property. QUrl releaseNotesLink() const;///< Getter for the 'releaseNotesLink' property.
@ -112,7 +112,7 @@ public: // Qt/QML properties. Note that the NOTIFY-er signal is required even fo
bool isDoHEnabled() const; ///< Getter for the 'isDoHEnabled' property. bool isDoHEnabled() const; ///< Getter for the 'isDoHEnabled' property.
bool isFirstGUIStart() const; ///< Getter for the 'isFirstGUIStart' property. bool isFirstGUIStart() const; ///< Getter for the 'isFirstGUIStart' property.
bool isAutomaticUpdateOn() const; ///< Getter for the 'isAutomaticUpdateOn' property. bool isAutomaticUpdateOn() const; ///< Getter for the 'isAutomaticUpdateOn' property.
QString currentEmailClient(); ///< Getter for the 'currentEmail' property. QString currentEmailClient() const; ///< Getter for the 'currentEmail' property.
QStringList availableKeychain() const; ///< Getter for the 'availableKeychain' property. QStringList availableKeychain() const; ///< Getter for the 'availableKeychain' property.
QString currentKeychain() const; ///< Getter for the 'currentKeychain' property. QString currentKeychain() const; ///< Getter for the 'currentKeychain' property.
void setDockIconVisible(bool visible); ///< Setter for the 'dockIconVisible' property. void setDockIconVisible(bool visible); ///< Setter for the 'dockIconVisible' property.
@ -154,26 +154,26 @@ public slots: // slot for signals received from QML -> To be forwarded to Bridge
void changeIsAllMailVisible(bool isVisible); ///< Slot for the changing of 'All Mail' visibility. void changeIsAllMailVisible(bool isVisible); ///< Slot for the changing of 'All Mail' visibility.
void changeColorScheme(QString const &scheme); ///< Slot for the change of the theme. void changeColorScheme(QString const &scheme); ///< Slot for the change of the theme.
void setDiskCachePath(QUrl const &path) const; ///< Slot for the change of the disk cache path. void setDiskCachePath(QUrl const &path) const; ///< Slot for the change of the disk cache path.
void login(QString const &username, QString const &password); ///< Slot for the login button (initial login). void login(QString const &username, QString const &password) const; ///< Slot for the login button (initial login).
void login2FA(QString const &username, QString const &code); ///< Slot for the login button (2FA login). void login2FA(QString const &username, QString const &code) const; ///< Slot for the login button (2FA login).
void login2Password(QString const &username, QString const &password); ///< Slot for the login button (mailbox password login). void login2Password(QString const &username, QString const &password) const; ///< Slot for the login button (mailbox password login).
void loginAbort(QString const &username); ///< Slot for the login abort procedure. void loginAbort(QString const &username) const; ///< Slot for the login abort procedure.
void toggleDoH(bool active); ///, Slot for the DoH toggle. void toggleDoH(bool active); ///, Slot for the DoH toggle.
void toggleAutomaticUpdate(bool makeItActive); ///< Slot for the automatic update toggle void toggleAutomaticUpdate(bool makeItActive); ///< Slot for the automatic update toggle
void updateCurrentMailClient(); ///< Slot for the change of the current mail client. void updateCurrentMailClient(); ///< Slot for the change of the current mail client.
void changeKeychain(QString const &keychain); ///< Slot for the change of keychain. void changeKeychain(QString const &keychain); ///< Slot for the change of keychain.
void guiReady(); ///< Slot for the GUI ready signal. void guiReady() const; ///< Slot for the GUI ready signal.
void quit(); ///< Slot for the quit signal. void quit() const; ///< Slot for the quit signal.
void restart(); ///< Slot for the restart signal. void restart() const; ///< Slot for the restart signal.
void forceLauncher(QString launcher); ///< Slot for the change of the launcher. void forceLauncher(QString launcher) const; ///< Slot for the change of the launcher.
void checkUpdates(); ///< Slot for the update check. void checkUpdates() const; ///< Slot for the update check.
void installUpdate(); ///< Slot for the update install. void installUpdate() const; ///< Slot for the update install.
void triggerReset(); ///< Slot for the triggering of reset. void triggerReset() const; ///< Slot for the triggering of reset.
void reportBug(QString const &description, QString const &address, QString const &emailClient, bool includeLogs); ///< Slot for the bug report. void reportBug(QString const &description, QString const &address, QString const &emailClient, bool includeLogs) const; ///< Slot for the bug report.
void exportTLSCertificates(); ///< Slot for the export of the TLS certificates. void exportTLSCertificates() const; ///< Slot for the export of the TLS certificates.
void onResetFinished(); ///< Slot for the reset finish signal. void onResetFinished(); ///< Slot for the reset finish signal.
void onVersionChanged(); ///< Slot for the version change signal. void onVersionChanged(); ///< Slot for the version change signal.
void setMailServerSettings(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP); ///< Forwards a connection mode change request from QML to gRPC void setMailServerSettings(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP) const; ///< Forwards a connection mode change request from QML to gRPC
public slots: // slot for signals received from gRPC that need transformation instead of simple forwarding public slots: // slot for signals received from gRPC that need transformation instead of simple forwarding
void onMailServerSettingsChanged(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP); ///< Slot for the ConnectionModeChanged gRPC event. void onMailServerSettingsChanged(int imapPort, int smtpPort, bool useSSLForIMAP, bool useSSLForSMTP); ///< Slot for the ConnectionModeChanged gRPC event.
@ -232,6 +232,9 @@ signals: // Signals received from the Go backend, to be forwarded to QML
void hideMainWindow(); ///< Signal for the 'hideMainWindow' gRPC stream event. void hideMainWindow(); ///< Signal for the 'hideMainWindow' gRPC stream event.
void genericError(QString const &title, QString const &description); ///< Signal for the 'genericError' gRPC stream event. void genericError(QString const &title, QString const &description); ///< Signal for the 'genericError' gRPC stream event.
// This signal is emitted when an exception is intercepted is calls triggered by QML. QML engine would intercept the exception otherwise.
void fatalError(QString const &function, QString const &message) const; ///< Signal emitted when an fatal error occurs.
private: // member functions private: // member functions
void retrieveUserList(); ///< Retrieve the list of users via gRPC. void retrieveUserList(); ///< Retrieve the list of users via gRPC.
void connectGrpcEvents(); ///< Connect gRPC that need to be forwarded to QML via backend signals void connectGrpcEvents(); ///< Connect gRPC that need to be forwarded to QML via backend signals

View File

@ -17,6 +17,7 @@
#include "Pch.h" #include "Pch.h"
#include "BridgeApp.h"
#include "CommandLine.h" #include "CommandLine.h"
#include "QMLBackend.h" #include "QMLBackend.h"
#include "SentryUtils.h" #include "SentryUtils.h"
@ -311,7 +312,7 @@ int main(int argc, char *argv[]) {
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL); QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
} }
QApplication guiApp(argc, argv); BridgeApp guiApp(argc, argv);
try { try {
initQtApplication(); initQtApplication();