GODT-1982: updated gRPC and GUI for disk cache.

Other: modified bridge-gui-tester for new cache related gRPC interface.
Other: bridge-gui-tester has buttons for cache related errors.
This commit is contained in:
Xavier Michelon
2022-10-27 18:59:42 +02:00
committed by James Houlahan
parent 93d9ae32fc
commit d9762010fa
27 changed files with 2662 additions and 3947 deletions

View File

@ -47,7 +47,7 @@ void GRPCQtProxy::connectSignals()
connect(this, &GRPCQtProxy::changePortsReceived, &settingsTab, &SettingsTab::changePorts);
connect(this, &GRPCQtProxy::setUseSSLForSMTPReceived, &settingsTab, &SettingsTab::setUseSSLForSMTP);
connect(this, &GRPCQtProxy::setIsDoHEnabledReceived, &settingsTab, &SettingsTab::setIsDoHEnabled);
connect(this, &GRPCQtProxy::changeLocalCacheReceived, &settingsTab, &SettingsTab::changeLocalCache);
connect(this, &GRPCQtProxy::setDiskCachePathReceived, &settingsTab, &SettingsTab::setDiskCachePath);
connect(this, &GRPCQtProxy::setIsAutomaticUpdateOnReceived, &settingsTab, &SettingsTab::setIsAutomaticUpdateOn);
connect(this, &GRPCQtProxy::setUserSplitModeReceived, &usersTab, &UsersTab::setUserSplitMode);
connect(this, &GRPCQtProxy::removeUserReceived, &usersTab, &UsersTab::removeUser);
@ -164,12 +164,11 @@ void GRPCQtProxy::setIsDoHEnabled(bool enabled)
//****************************************************************************************************************************************************
/// \param[in] enabled is cache on disk enabled?
/// \param[in] path The path for the cache on disk.
/// \param[in] path The disk cache path.
//****************************************************************************************************************************************************
void GRPCQtProxy::changeLocalCache(bool enabled, QString const &path)
void GRPCQtProxy::setDiskCachePath(QString const &path)
{
emit changeLocalCacheReceived(enabled, path);
emit setDiskCachePathReceived(path);
}

View File

@ -50,7 +50,7 @@ public: // member functions.
void changePorts(qint32 imapPort, qint32 smtpPort); ///< Forwards a ChangePorts call via a Qt signal.
void setUseSSLForSMTP(bool use); ///< Forwards a SetUseSSLForSMTP call via a Qt signal.
void setIsDoHEnabled(bool enabled); ///< Forwards a setIsDoHEnabled call via a Qt signal.
void changeLocalCache(bool enabled, QString const &path); ///< Forwards a ChangeLocalPath call via a Qt signal.
void setDiskCachePath(QString const &path); ///< Forwards a setDiskCachePath call via a Qt signal.
void setIsAutomaticUpdateOn(bool on); ///< Forwards a SetIsAutomaticUpdateOn call via a Qt signal.
void setUserSplitMode(QString const &userID, bool makeItActive); ///< Forwards a setUserSplitMode call via a Qt signal.
void logoutUser(QString const &userID); ///< Forwards a logoutUser call via a Qt signal.
@ -70,7 +70,7 @@ signals:
void changePortsReceived(qint32 imapPort, qint32 smtpPort); ///< Signal for the ChangePorts gRPC call.
void setUseSSLForSMTPReceived(bool use); ///< Signal for the SetUseSSLForSMTP gRPC call.
void setIsDoHEnabledReceived(bool enabled); ///< Signal for the SetIsDoHEnabled gRPC call.
void changeLocalCacheReceived(bool enabled, QString const &path); ///< Signal for the ChangeLocalPath gRPC call.
void setDiskCachePathReceived(QString const &path); ///< Signal for the setDiskCachePath gRPC call.
void setIsAutomaticUpdateOnReceived(bool on); ///< Signal for the SetIsAutomaticUpdateOn gRPC call.
void setUserSplitModeReceived(QString const &userID, bool makeItActive); ///< Signal for the SetUserSplitModeReceived gRPC call.
void logoutUserReceived(QString const &userID); ///< Signal for the LogoutUserReceived gRPC call.

View File

@ -573,19 +573,6 @@ Status GRPCService::IsAutomaticUpdateOn(ServerContext *, Empty const *, BoolValu
return Status::OK;
}
//****************************************************************************************************************************************************
/// \param[in] response The response.
/// \return The status for the call
//****************************************************************************************************************************************************
Status GRPCService::IsCacheOnDiskEnabled(ServerContext *, Empty const *, BoolValue *response)
{
app().log().debug(__FUNCTION__);
response->set_value(app().mainWindow().settingsTab().isCacheOnDiskEnabled());
return Status::OK;
}
//****************************************************************************************************************************************************
/// \param[in] response The response.
/// \return The status for the call
@ -599,23 +586,25 @@ Status GRPCService::DiskCachePath(ServerContext *, Empty const *, StringValue *r
//****************************************************************************************************************************************************
/// \param[in] request The request.
/// \param[in] path The path.
/// \return The status for the call.
//****************************************************************************************************************************************************
Status GRPCService::ChangeLocalCache(ServerContext *, ChangeLocalCacheRequest const *request, Empty *)
Status GRPCService::SetDiskCachePath(ServerContext *, StringValue const *path, Empty *)
{
app().log().debug(__FUNCTION__);
SettingsTab &tab = app().mainWindow().settingsTab();
QString const path = QString::fromStdString(request->diskcachepath());
QString const qPath = QString::fromStdString(path->value());
// we mimic the behaviour of Bridge
if (!tab.nextCacheChangeWillSucceed())
qtProxy_.sendDelayedEvent(newCacheErrorEvent(grpc::CacheErrorType(tab.cacheError())));
qtProxy_.sendDelayedEvent(newDiskCacheErrorEvent(grpc::DiskCacheErrorType(tab.cacheError())));
else
qtProxy_.sendDelayedEvent(newCacheLocationChangeSuccessEvent());
qtProxy_.sendDelayedEvent(newDiskCachePathChanged(path));
qtProxy_.sendDelayedEvent(newIsCacheOnDiskEnabledChanged(request->enablediskcache()));
qtProxy_.sendDelayedEvent(newChangeLocalCacheFinishedEvent());
{
qtProxy_.setDiskCachePath(qPath);
qtProxy_.sendDelayedEvent(newDiskCachePathChangedEvent(qPath));
}
qtProxy_.sendDelayedEvent(newDiskCachePathChangeFinishedEvent());
return Status::OK;
}

View File

@ -76,9 +76,8 @@ public: // member functions.
grpc::Status InstallUpdate(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::Empty *) override;
grpc::Status SetIsAutomaticUpdateOn(::grpc::ServerContext *, ::google::protobuf::BoolValue const *request, ::google::protobuf::Empty *) override;
grpc::Status IsAutomaticUpdateOn(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::BoolValue *response) override;
grpc::Status IsCacheOnDiskEnabled(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::BoolValue *response) override;
grpc::Status DiskCachePath(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
grpc::Status ChangeLocalCache(::grpc::ServerContext *, ::grpc::ChangeLocalCacheRequest const *request, ::google::protobuf::Empty *) override;
grpc::Status SetDiskCachePath(::grpc::ServerContext *, ::google::protobuf::StringValue const*, ::google::protobuf::Empty *r) override;
grpc::Status SetIsDoHEnabled(::grpc::ServerContext *, ::google::protobuf::BoolValue const *request, ::google::protobuf::Empty *) override;
grpc::Status IsDoHEnabled(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::BoolValue *response) override;
grpc::Status SetUseSslForSmtp(::grpc::ServerContext *, ::google::protobuf::BoolValue const *request, ::google::protobuf::Empty *) override;

View File

@ -44,6 +44,10 @@ SettingsTab::SettingsTab(QWidget *parent)
connect(ui_.buttonInternetOff, &QPushButton::clicked, []() { app().grpc().sendEvent(newInternetStatusEvent(false)); });
connect(ui_.buttonShowMainWindow, &QPushButton::clicked, []() { app().grpc().sendEvent(newShowMainWindowEvent()); });
connect(ui_.buttonAPICertIssue, &QPushButton::clicked, []() {app().grpc().sendEvent(newApiCertIssueEvent()); });
connect(ui_.buttonDiskCacheUnavailable, &QPushButton::clicked,[]() {app().grpc().sendEvent(
newDiskCacheErrorEvent(grpc::DiskCacheErrorType::DISK_CACHE_UNAVAILABLE_ERROR)); });
connect(ui_.buttonDiskFull, &QPushButton::clicked,[]() {app().grpc().sendEvent(
newDiskCacheErrorEvent(grpc::DiskCacheErrorType::DISK_FULL_ERROR)); });
connect(ui_.buttonNoActiveKeyForRecipient, &QPushButton::clicked, [&]() {app().grpc().sendEvent(
newNoActiveKeyForRecipientEvent(ui_.editNoActiveKeyForRecipient->text())); });
connect(ui_.checkNextCacheChangeWillSucceed, &QCheckBox::toggled, this, &SettingsTab::updateGUIState);
@ -403,21 +407,10 @@ bool SettingsTab::isPortFree() const
//****************************************************************************************************************************************************
/// \return true iff cache on disk is enabled.
//****************************************************************************************************************************************************
bool SettingsTab::isCacheOnDiskEnabled() const
{
return ui_.checkCacheOnDiskEnabled->isChecked();
}
//****************************************************************************************************************************************************
/// \param[in] enabled Is the cache on disk enabled?
/// \param[in] path The path of the local cache.
//****************************************************************************************************************************************************
void SettingsTab::changeLocalCache(bool enabled, QString const &path)
void SettingsTab::setDiskCachePath(const QString &path)
{
ui_.checkCacheOnDiskEnabled->setChecked(enabled);
ui_.editDiskCachePath->setText(path);
}
@ -523,7 +516,6 @@ void SettingsTab::resetUI()
ui_.checkDoHEnabled->setChecked(true);
ui_.checkIsPortFree->setChecked(true);
ui_.checkCacheOnDiskEnabled->setChecked(true);
QString const cacheDir = QDir(tmpDir).absoluteFilePath("cache");
QDir().mkpath(cacheDir);
ui_.editDiskCachePath->setText(QDir::toNativeSeparators(cacheDir));

View File

@ -62,13 +62,12 @@ public: // member functions.
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.
bool isPortFree() const; ///< Get the value for the "Is Port Free" check box.
bool isCacheOnDiskEnabled() const; ///< get the value for the 'Cache On Disk Enabled' check box.
QString diskCachePath() const; ///< Get the value for the 'Disk Cache Path' edit.
bool nextCacheChangeWillSucceed() const; ///< Get the value for the 'Next Cache Change will succeed' edit.
qint32 cacheError() const; ///< Return the index of the selected cache error.
bool isAutomaticUpdateOn() const; ///<Get the value for the 'Automatic Update' check box.
public: // slots
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.
@ -82,7 +81,7 @@ public: // slots
void setUseSSLForSMTP(bool use); ///< Set the value for the 'Use SSL for SMTP' check box.
void setUseSSLForIMAP(bool use); ///< Set the value for the 'Use SSL for IMAP' check box.
void setIsDoHEnabled(bool enabled); ///< Set the value for the 'DoH Enabled' check box.
void changeLocalCache(bool enabled, QString const &path); ///< Set the value for the 'Cache On Disk 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.
private: // member functions.

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1066</width>
<width>1127</width>
<height>808</height>
</rect>
</property>
@ -211,7 +211,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,0,0,0,1">
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,0,0,0,1,0">
<item>
<widget class="QLabel" name="labelMAP">
<property name="text">
@ -355,13 +355,6 @@
<string>Cache</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QCheckBox" name="checkCacheOnDiskEnabled">
<property name="text">
<string>Cache On Disk Enabled</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
@ -733,6 +726,37 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QPushButton" name="buttonDiskCacheUnavailable">
<property name="text">
<string>Disk Cache Unavailable</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonDiskFull">
<property name="text">
<string>Disk Full</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>1</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
@ -796,12 +820,12 @@
<widget class="QComboBox" name="comboCacheError">
<item>
<property name="text">
<string>Cache Unavailable</string>
<string>Disk Cache Unavailable</string>
</property>
</item>
<item>
<property name="text">
<string>Can't Move Cache</string>
<string>Can't Move Disk Cache</string>
</property>
</item>
<item>
@ -851,7 +875,6 @@
<tabstop>editReleaseNotesLink</tabstop>
<tabstop>editDependencyLicenseLink</tabstop>
<tabstop>editLandingPageLink</tabstop>
<tabstop>checkCacheOnDiskEnabled</tabstop>
<tabstop>editDiskCachePath</tabstop>
<tabstop>editOSType</tabstop>
<tabstop>editOSVersion</tabstop>