mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
feat(GODT-3121): fix issues reported by the resharper C++ engine.
This commit is contained in:
@ -31,7 +31,7 @@ using namespace bridgepp;
|
||||
/// \param[in] edit The edit containing the address.
|
||||
/// \param[in] eventGenerator The factory function creating the event.
|
||||
//****************************************************************************************************************************************************
|
||||
void connectAddressError(QPushButton* button, QLineEdit* edit, bridgepp::SPStreamEvent (*eventGenerator)(QString const&)) {
|
||||
void connectAddressError(QPushButton const* button, QLineEdit* edit, SPStreamEvent (*eventGenerator)(QString const&)) {
|
||||
QObject::connect(button, &QPushButton::clicked, [edit, eventGenerator]() { app().grpc().sendEvent(eventGenerator(edit->text())); });
|
||||
}
|
||||
|
||||
@ -77,13 +77,6 @@ qint32 EventsTab::eventDelayMs() const {
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void EventsTab::updateGUIState() {
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The bug report results
|
||||
//****************************************************************************************************************************************************
|
||||
|
||||
@ -45,7 +45,6 @@ public: // member functions.
|
||||
EventsTab& operator=(EventsTab&&) = delete; ///< Disabled move assignment operator.
|
||||
|
||||
qint32 eventDelayMs() const; ///< Get the delay for sending automatically generated events.
|
||||
void updateGUIState(); ///< Update the GUI state.
|
||||
BugReportResult nextBugReportResult() const; ///< Get the value of the 'Next bug report result' combo box.
|
||||
bool isPortFree() const; ///< Get the value for the "Is Port Free" check box.
|
||||
bool nextCacheChangeWillSucceed() const; ///< Get the value for the 'Next Cache Change will succeed' edit.
|
||||
@ -53,7 +52,7 @@ public: // member functions.
|
||||
void resetUI() const; ///< Resets the UI.
|
||||
|
||||
private: // data members
|
||||
Ui::EventsTab ui_; ///< The UI for the widget.
|
||||
Ui::EventsTab ui_ {}; ///< The UI for the widget.
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ KnowledgeBaseTab::KnowledgeBaseTab(QWidget* parent)
|
||||
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] checkbox The check box.
|
||||
/// \param[in] widgets The widgets to conditionally enable.
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
|
||||
#include "SettingsTab.h"
|
||||
#include "GRPCService.h"
|
||||
#include <bridgepp/GRPC/EventFactory.h>
|
||||
#include <bridgepp/BridgeUtils.h>
|
||||
|
||||
|
||||
@ -47,7 +46,7 @@ SettingsTab::SettingsTab(QWidget *parent)
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::updateGUIState() {
|
||||
bool connected = app().grpc().isStreaming();
|
||||
bool const connected = app().grpc().isStreaming();
|
||||
for (QWidget *widget: { ui_.groupVersion, ui_.groupGeneral, ui_.groupMail, ui_.groupPaths, ui_.groupCache }) {
|
||||
widget->setEnabled(!connected);
|
||||
}
|
||||
@ -66,7 +65,7 @@ void SettingsTab::setIsStreaming(bool isStreaming) {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] clientPlatform The client platform.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setClientPlatform(QString const &clientPlatform) {
|
||||
void SettingsTab::setClientPlatform(QString const &clientPlatform) const {
|
||||
ui_.labelClientPlatformValue->setText(clientPlatform);
|
||||
}
|
||||
|
||||
@ -131,7 +130,7 @@ bool SettingsTab::isAutostartOn() const {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] on Should autostart be turned on?
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setIsAutostartOn(bool on) {
|
||||
void SettingsTab::setIsAutostartOn(bool on) const {
|
||||
ui_.checkAutostart->setChecked(on);
|
||||
}
|
||||
|
||||
@ -147,7 +146,7 @@ QString SettingsTab::colorSchemeName() const {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] name True if the 'Use Dark Theme' check box should be checked.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setColorSchemeName(QString const &name) {
|
||||
void SettingsTab::setColorSchemeName(QString const &name) const {
|
||||
ui_.checkDarkTheme->setChecked(name == colorSchemeDark);
|
||||
}
|
||||
|
||||
@ -163,7 +162,7 @@ bool SettingsTab::isBetaEnabled() const {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] enabled The new state for the 'Beta Enabled' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setIsBetaEnabled(bool enabled) {
|
||||
void SettingsTab::setIsBetaEnabled(bool enabled) const {
|
||||
ui_.checkBetaEnabled->setChecked(enabled);
|
||||
}
|
||||
|
||||
@ -179,7 +178,7 @@ bool SettingsTab::isAllMailVisible() const {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] visible The new value for the 'All Mail Visible' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setIsAllMailVisible(bool visible) {
|
||||
void SettingsTab::setIsAllMailVisible(bool visible) const {
|
||||
ui_.checkAllMailVisible->setChecked(visible);
|
||||
}
|
||||
|
||||
@ -195,7 +194,7 @@ bool SettingsTab::isTelemetryDisabled() const {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] isDisabled The new value for the 'Disable Telemetry' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setIsTelemetryDisabled(bool isDisabled) {
|
||||
void SettingsTab::setIsTelemetryDisabled(bool isDisabled) const {
|
||||
ui_.checkIsTelemetryDisabled->setChecked(isDisabled);
|
||||
}
|
||||
|
||||
@ -249,7 +248,7 @@ QString SettingsTab::landingPageLink() const {
|
||||
/// \param[in] includeLogs Are the log included.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setBugReport(QString const &osType, QString const &osVersion, QString const &emailClient, QString const &address,
|
||||
QString const &description, bool includeLogs) {
|
||||
QString const &description, bool includeLogs) const {
|
||||
ui_.editOSType->setText(osType);
|
||||
ui_.editOSVersion->setText(osVersion);
|
||||
ui_.editEmailClient->setText(emailClient);
|
||||
@ -262,7 +261,7 @@ void SettingsTab::setBugReport(QString const &osType, QString const &osVersion,
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::installTLSCertificate() {
|
||||
void SettingsTab::installTLSCertificate() const {
|
||||
ui_.labelLastTLSCertInstall->setText(QString("Last install: %1").arg(QDateTime::currentDateTime().toString(Qt::ISODateWithMs)));
|
||||
ui_.checkTLSCertIsInstalled->setChecked(this->nextTLSCertInstallResult() == TLSCertInstallResult::Success);
|
||||
}
|
||||
@ -271,7 +270,7 @@ void SettingsTab::installTLSCertificate() {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] folderPath The folder path.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::exportTLSCertificates(QString const &folderPath) {
|
||||
void SettingsTab::exportTLSCertificates(QString const &folderPath) const {
|
||||
ui_.labeLastTLSCertExport->setText(QString("%1 Export to %2").arg(QDateTime::currentDateTime().toString(Qt::ISODateWithMs),folderPath));
|
||||
}
|
||||
|
||||
@ -288,7 +287,7 @@ bool SettingsTab::isTLSCertificateInstalled() const {
|
||||
/// \return The value for the 'Next TLS cert install result'.
|
||||
//****************************************************************************************************************************************************
|
||||
SettingsTab::TLSCertInstallResult SettingsTab::nextTLSCertInstallResult() const {
|
||||
return TLSCertInstallResult(ui_.comboNextTLSCertInstallResult->currentIndex());
|
||||
return static_cast<TLSCertInstallResult>(ui_.comboNextTLSCertInstallResult->currentIndex());
|
||||
}
|
||||
|
||||
|
||||
@ -319,7 +318,7 @@ QString SettingsTab::hostname() const {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value of the IMAP port spin box.
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 SettingsTab::imapPort() {
|
||||
qint32 SettingsTab::imapPort() const {
|
||||
return ui_.spinPortIMAP->value();
|
||||
}
|
||||
|
||||
@ -327,7 +326,7 @@ qint32 SettingsTab::imapPort() {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value of the SMTP port spin box.
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 SettingsTab::smtpPort() {
|
||||
qint32 SettingsTab::smtpPort() const {
|
||||
return ui_.spinPortSMTP->value();
|
||||
}
|
||||
|
||||
@ -338,7 +337,7 @@ qint32 SettingsTab::smtpPort() {
|
||||
/// \param[in] useSSLForIMAP The IMAP connexion mode.
|
||||
/// \param[in] useSSLForSMTP The IMAP connexion mode.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setMailServerSettings(qint32 imapPort, qint32 smtpPort, bool useSSLForIMAP, bool useSSLForSMTP) {
|
||||
void SettingsTab::setMailServerSettings(qint32 imapPort, qint32 smtpPort, bool useSSLForIMAP, bool useSSLForSMTP) const {
|
||||
ui_.spinPortIMAP->setValue(imapPort);
|
||||
ui_.spinPortSMTP->setValue(smtpPort);
|
||||
ui_.checkUseSSLForIMAP->setChecked(useSSLForIMAP);
|
||||
@ -373,7 +372,7 @@ bool SettingsTab::isDoHEnabled() const {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] enabled The state of the 'DoH enabled' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setIsDoHEnabled(bool enabled) {
|
||||
void SettingsTab::setIsDoHEnabled(bool enabled) const {
|
||||
ui_.checkDoHEnabled->setChecked(enabled);
|
||||
}
|
||||
|
||||
@ -381,7 +380,7 @@ void SettingsTab::setIsDoHEnabled(bool enabled) {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] path The path of the local cache.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setDiskCachePath(const QString &path) {
|
||||
void SettingsTab::setDiskCachePath(const QString &path) const {
|
||||
ui_.editDiskCachePath->setText(path);
|
||||
}
|
||||
|
||||
@ -405,7 +404,7 @@ bool SettingsTab::isAutomaticUpdateOn() const {
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] on The value for the 'Automatic Update' check.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setIsAutomaticUpdateOn(bool on) {
|
||||
void SettingsTab::setIsAutomaticUpdateOn(bool on) const {
|
||||
ui_.checkAutomaticUpdate->setChecked(on);
|
||||
}
|
||||
|
||||
|
||||
@ -64,8 +64,8 @@ public: // member functions.
|
||||
bool nextTLSCertExportWillSucceed() const; ///< Get the status of the 'Next TLS Cert export will succeed' check box.
|
||||
bool nextTLSKeyExportWillSucceed() const; ///< Get the status of the 'Next TLS Key export will succeed' check box.
|
||||
QString hostname() const; ///< Get the value of the 'Hostname' edit.
|
||||
qint32 imapPort(); ///< Get the value of the IMAP port spin.
|
||||
qint32 smtpPort(); ///< Get the value of the SMTP port spin.
|
||||
qint32 imapPort() const; ///< Get the value of the IMAP port spin.
|
||||
qint32 smtpPort() const; ///< Get the value of the SMTP port spin.
|
||||
bool useSSLForSMTP() const; ///< Get the value for the 'Use SSL for SMTP' check box.
|
||||
bool useSSLForIMAP() const; ///< Get the value for the 'Use SSL for IMAP' check box.
|
||||
bool isDoHEnabled() const; ///< Get the value for the 'DoH Enabled' check box.
|
||||
@ -75,20 +75,20 @@ public: // member functions.
|
||||
public slots:
|
||||
void updateGUIState(); ///< Update the GUI state.
|
||||
void setIsStreaming(bool isStreaming); ///< Set the isStreamingEvents value.
|
||||
void setClientPlatform(QString const &clientPlatform); ///< Set the client platform.
|
||||
void setIsAutostartOn(bool on); ///< Set the value for the 'Autostart' check box.
|
||||
void setIsBetaEnabled(bool enabled); ///< Set the value for the 'Beta Enabled' check box.
|
||||
void setIsAllMailVisible(bool visible); ///< Set the value for the 'All Mail Visible' check box.
|
||||
void setIsTelemetryDisabled(bool isDisabled); ///< Set the value for the 'Disable Telemetry' check box.
|
||||
void setColorSchemeName(QString const &name); ///< Set the value for the 'Use Dark Theme' check box.
|
||||
void setClientPlatform(QString const &clientPlatform) const; ///< Set the client platform.
|
||||
void setIsAutostartOn(bool on) const; ///< Set the value for the 'Autostart' check box.
|
||||
void setIsBetaEnabled(bool enabled) const; ///< Set the value for the 'Beta Enabled' check box.
|
||||
void setIsAllMailVisible(bool visible) const; ///< Set the value for the 'All Mail Visible' check box.
|
||||
void setIsTelemetryDisabled(bool isDisabled) const; ///< Set the value for the 'Disable Telemetry' check box.
|
||||
void setColorSchemeName(QString const &name) const; ///< Set the value for the 'Use Dark Theme' check box.
|
||||
void setBugReport(QString const &osType, QString const &osVersion, QString const &emailClient, QString const &address, QString const &description,
|
||||
bool includeLogs); ///< Set the content of the bug report box.
|
||||
void installTLSCertificate(); ///< Install the TLS certificate.
|
||||
void exportTLSCertificates(QString const &folderPath); ///< Export the TLS certificates.
|
||||
void setMailServerSettings(qint32 imapPort, qint32 smtpPort, bool useSSLForIMAP, bool useSSLForSMTP); ///< Change the mail server settings.
|
||||
void setIsDoHEnabled(bool enabled); ///< Set the value for the 'DoH Enabled' check box.
|
||||
void setDiskCachePath(QString const &path); ///< Set the value for the 'Cache On Disk Enabled' check box.
|
||||
void setIsAutomaticUpdateOn(bool on); ///< Set the value for the 'Automatic Update' check box.
|
||||
bool includeLogs) const; ///< Set the content of the bug report box.
|
||||
void installTLSCertificate() const; ///< Install the TLS certificate.
|
||||
void exportTLSCertificates(QString const &folderPath) const; ///< Export the TLS certificates.
|
||||
void setMailServerSettings(qint32 imapPort, qint32 smtpPort, bool useSSLForIMAP, bool useSSLForSMTP) const; ///< Change the mail server settings.
|
||||
void setIsDoHEnabled(bool enabled) const; ///< Set the value for the 'DoH Enabled' check box.
|
||||
void setDiskCachePath(QString const &path) const; ///< Set the value for the 'Cache On Disk Enabled' check box.
|
||||
void setIsAutomaticUpdateOn(bool on) const; ///< Set the value for the 'Automatic Update' check box.
|
||||
|
||||
private: // member functions.
|
||||
void resetUI(); ///< Reset the widget.
|
||||
|
||||
@ -85,7 +85,7 @@ void UsersTab::onAddUserButton() {
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onEditUserButton() {
|
||||
int index = selectedIndex();
|
||||
const int index = selectedIndex();
|
||||
if ((index < 0) || (index >= users_.userCount())) {
|
||||
return;
|
||||
}
|
||||
@ -110,7 +110,7 @@ void UsersTab::onEditUserButton() {
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onRemoveUserButton() {
|
||||
int index = selectedIndex();
|
||||
const int index = selectedIndex();
|
||||
if ((index < 0) || (index >= users_.userCount())) {
|
||||
return;
|
||||
}
|
||||
@ -127,7 +127,7 @@ void UsersTab::onRemoveUserButton() {
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onSelectionChanged(QItemSelection, QItemSelection) {
|
||||
void UsersTab::onSelectionChanged(QItemSelection const&, QItemSelection const&) {
|
||||
this->updateGUIState();
|
||||
}
|
||||
|
||||
@ -137,7 +137,6 @@ void UsersTab::onSelectionChanged(QItemSelection, QItemSelection) {
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onSendUserBadEvent() {
|
||||
SPUser const user = selectedUser();
|
||||
int const index = this->selectedIndex();
|
||||
|
||||
if (!user) {
|
||||
app().log().error(QString("%1 failed. Unkown user.").arg(__FUNCTION__));
|
||||
@ -175,8 +174,8 @@ void UsersTab::onSendUsedBytesChangedEvent() {
|
||||
app().log().error(QString("%1 failed. User is not connected").arg(__FUNCTION__));
|
||||
}
|
||||
|
||||
qint64 const usedBytes = qint64(ui_.spinUsedBytes->value());
|
||||
user->setUsedBytes(usedBytes);
|
||||
auto const usedBytes = static_cast<qint64>(ui_.spinUsedBytes->value());
|
||||
user->setUsedBytes(static_cast<float>(usedBytes));
|
||||
users_.touch(index);
|
||||
|
||||
GRPCService &grpc = app().grpc();
|
||||
@ -224,9 +223,10 @@ void UsersTab::updateGUIState() {
|
||||
QSignalBlocker b(ui_.checkSync);
|
||||
bool const syncing = user && user->isSyncing();
|
||||
ui_.checkSync->setChecked(syncing);
|
||||
// ReSharper disable once CppDFAUnusedValue
|
||||
b = QSignalBlocker(ui_.sliderSync);
|
||||
ui_.sliderSync->setEnabled(syncing);
|
||||
qint32 const progressPercent = syncing ? qint32(user->syncProgress() * 100.0f) : 0;
|
||||
qint32 const progressPercent = syncing ? static_cast<qint32>(user->syncProgress() * 100.0f) : 0;
|
||||
ui_.sliderSync->setValue(progressPercent);
|
||||
ui_.labelSync->setText(syncing ? QString("%1%").arg(progressPercent) : "" );
|
||||
}
|
||||
@ -418,7 +418,7 @@ void UsersTab::processBadEventUserFeedback(QString const &userID, bool doResync)
|
||||
return; // we do not do any form of emulation for resync.
|
||||
}
|
||||
|
||||
SPUser user = users_.userWithID(userID);
|
||||
SPUser const user = users_.userWithID(userID);
|
||||
if (!user) {
|
||||
app().log().error(QString("%1(): could not find user with id %1.").arg(__func__, userID));
|
||||
}
|
||||
@ -464,12 +464,12 @@ void UsersTab::onCheckSyncToggled(bool checked) {
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onSliderSyncValueChanged(int value) {
|
||||
SPUser const user = this->selectedUser();
|
||||
if ((!user) || (!user->isSyncing()) || user->syncProgress() == value) {
|
||||
if ((!user) || (!user->isSyncing()) || user->syncProgress() == static_cast<float>(value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double const progress = value / 100.0;
|
||||
user->setSyncProgress(progress);
|
||||
user->setSyncProgress(static_cast<float>(progress));
|
||||
app().grpc().sendEvent(newSyncProgressEvent(user->id(), progress, 1, 1)); // we do not simulate elapsed & remaining.
|
||||
this->updateGUIState();
|
||||
}
|
||||
|
||||
@ -53,14 +53,14 @@ public slots:
|
||||
void setUserSplitMode(QString const &userID, bool makeItActive); ///< Slot for the split mode.
|
||||
void logoutUser(QString const &userID); ///< slot for the logging out of a user.
|
||||
void removeUser(QString const &userID); ///< Slot for the removal of a user.
|
||||
void configureUserAppleMail(QString const &userID, QString const &address); ///< Slot for the configuration of Apple mail.
|
||||
static void configureUserAppleMail(QString const &userID, QString const &address); ///< Slot for the configuration of Apple mail.
|
||||
void processBadEventUserFeedback(QString const& userID, bool doResync); ///< Slot for the reception of a bad event user feedback.
|
||||
|
||||
private slots:
|
||||
void onAddUserButton(); ///< Add a user to the user list.
|
||||
void onEditUserButton(); ///< Edit the currently selected user.
|
||||
void onRemoveUserButton(); ///< Remove the currently selected user.
|
||||
void onSelectionChanged(QItemSelection, QItemSelection); ///< Slot for the change of the selection.
|
||||
void onSelectionChanged(QItemSelection const&, QItemSelection const&); ///< Slot for the change of the selection.
|
||||
void onSendUserBadEvent(); ///< Slot for the 'Send Bad Event Error' button.
|
||||
void onSendUsedBytesChangedEvent(); ///< Slot for the 'Send Used Bytes Changed Event' button.
|
||||
void onSendIMAPLoginFailedEvent(); ///< Slot for the 'Send IMAP Login failure Event' button.
|
||||
|
||||
Reference in New Issue
Block a user