mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-15 22:56:48 +00:00
Other: C++ Code reformat.
This commit is contained in:
@ -30,8 +30,7 @@ using namespace bridgepp;
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return A reference to the application controller.
|
||||
//****************************************************************************************************************************************************
|
||||
AppController &app()
|
||||
{
|
||||
AppController &app() {
|
||||
static AppController app;
|
||||
return app;
|
||||
}
|
||||
@ -43,8 +42,7 @@ AppController &app()
|
||||
AppController::AppController()
|
||||
: log_(std::make_unique<Log>())
|
||||
, bridgeGUILog_(std::make_unique<Log>())
|
||||
, grpc_(std::make_unique<GRPCService>())
|
||||
{
|
||||
, grpc_(std::make_unique<GRPCService>()) {
|
||||
|
||||
}
|
||||
|
||||
@ -61,8 +59,7 @@ AppController::~AppController() // NOLINT(modernize-use-equals-default): impleme
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] mainWindow The main window.
|
||||
//****************************************************************************************************************************************************
|
||||
void AppController::setMainWindow(MainWindow *mainWindow)
|
||||
{
|
||||
void AppController::setMainWindow(MainWindow *mainWindow) {
|
||||
mainWindow_ = mainWindow;
|
||||
grpc_->connectProxySignals();
|
||||
}
|
||||
@ -71,10 +68,10 @@ void AppController::setMainWindow(MainWindow *mainWindow)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The main window.
|
||||
//****************************************************************************************************************************************************
|
||||
MainWindow &AppController::mainWindow()
|
||||
{
|
||||
if (!mainWindow_)
|
||||
MainWindow &AppController::mainWindow() {
|
||||
if (!mainWindow_) {
|
||||
throw Exception("mainWindow has not yet been registered.");
|
||||
}
|
||||
return *mainWindow_;
|
||||
}
|
||||
|
||||
@ -82,8 +79,7 @@ MainWindow &AppController::mainWindow()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return A reference to the log.
|
||||
//****************************************************************************************************************************************************
|
||||
bridgepp::Log &AppController::log()
|
||||
{
|
||||
bridgepp::Log &AppController::log() {
|
||||
return *log_;
|
||||
}
|
||||
|
||||
@ -91,8 +87,7 @@ bridgepp::Log &AppController::log()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return A reference to the bridge-gui log.
|
||||
//****************************************************************************************************************************************************
|
||||
bridgepp::Log &AppController::bridgeGUILog()
|
||||
{
|
||||
bridgepp::Log &AppController::bridgeGUILog() {
|
||||
return *bridgeGUILog_;
|
||||
}
|
||||
|
||||
@ -100,7 +95,6 @@ bridgepp::Log &AppController::bridgeGUILog()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return A reference to the gRPC service.
|
||||
//****************************************************************************************************************************************************
|
||||
GRPCService &AppController::grpc()
|
||||
{
|
||||
GRPCService &AppController::grpc() {
|
||||
return *grpc_;
|
||||
}
|
||||
|
||||
@ -21,6 +21,8 @@
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
|
||||
class GRPCService;
|
||||
namespace grpc { class StreamEvent; }
|
||||
namespace bridgepp { class Log; }
|
||||
@ -29,8 +31,7 @@ namespace bridgepp { class Log; }
|
||||
//**********************************************************************************************************************
|
||||
/// \brief Application controller class
|
||||
//**********************************************************************************************************************
|
||||
class AppController : public QObject
|
||||
{
|
||||
class AppController : public QObject {
|
||||
Q_OBJECT
|
||||
public: // member functions.
|
||||
friend AppController &app();
|
||||
|
||||
@ -29,8 +29,7 @@ using namespace grpc;
|
||||
/// \param[in] The server token expected from gRPC calls
|
||||
//****************************************************************************************************************************************************
|
||||
GRPCMetadataProcessor::GRPCMetadataProcessor(QString const &serverToken)
|
||||
: serverToken_(serverToken.toStdString())
|
||||
{
|
||||
: serverToken_(serverToken.toStdString()) {
|
||||
|
||||
}
|
||||
|
||||
@ -38,8 +37,7 @@ GRPCMetadataProcessor::GRPCMetadataProcessor(QString const &serverToken)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return false.
|
||||
//****************************************************************************************************************************************************
|
||||
bool GRPCMetadataProcessor::IsBlocking() const
|
||||
{
|
||||
bool GRPCMetadataProcessor::IsBlocking() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -49,28 +47,28 @@ bool GRPCMetadataProcessor::IsBlocking() const
|
||||
/// \return the result of the metadata processing.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCMetadataProcessor::Process(AuthMetadataProcessor::InputMetadata const &auth_metadata, AuthContext *,
|
||||
AuthMetadataProcessor::OutputMetadata *, AuthMetadataProcessor::OutputMetadata *)
|
||||
{
|
||||
try
|
||||
{
|
||||
AuthMetadataProcessor::OutputMetadata *, AuthMetadataProcessor::OutputMetadata *) {
|
||||
try {
|
||||
AuthMetadataProcessor::InputMetadata::const_iterator pathIt = auth_metadata.find(":path");
|
||||
QString const callName = (pathIt == auth_metadata.end()) ? ("unkown gRPC call") : QString::fromLocal8Bit(pathIt->second);
|
||||
|
||||
AuthMetadataProcessor::InputMetadata::size_type const count = auth_metadata.count(grpcMetadataServerTokenKey);
|
||||
if (count == 0)
|
||||
if (count == 0) {
|
||||
throw Exception(QString("Missing server token in gRPC client call '%1'.").arg(callName));
|
||||
}
|
||||
|
||||
if (count > 1)
|
||||
if (count > 1) {
|
||||
throw Exception(QString("Several server tokens were provided in gRPC client call '%1'.").arg(callName));
|
||||
}
|
||||
|
||||
if (auth_metadata.find(grpcMetadataServerTokenKey)->second != serverToken_)
|
||||
if (auth_metadata.find(grpcMetadataServerTokenKey)->second != serverToken_) {
|
||||
throw Exception(QString("Invalid server token provided by gRPC client call '%1'.").arg(callName));
|
||||
}
|
||||
|
||||
app().log().trace(QString("Server token for gRPC call '%1' was validated.").arg(callName));
|
||||
return Status::OK;
|
||||
}
|
||||
catch (Exception const &e)
|
||||
{
|
||||
catch (Exception const &e) {
|
||||
app().log().error(e.qwhat());
|
||||
return Status(StatusCode::UNAUTHENTICATED, e.qwhat().toStdString());
|
||||
}
|
||||
|
||||
@ -26,15 +26,14 @@
|
||||
//****************************************************************************************************************************************************
|
||||
/// \brief Metadata processor class in charge of checking the server token provided by client calls and stream requests.
|
||||
//****************************************************************************************************************************************************
|
||||
class GRPCMetadataProcessor: public grpc::AuthMetadataProcessor
|
||||
{
|
||||
class GRPCMetadataProcessor : public grpc::AuthMetadataProcessor {
|
||||
public: // member functions.
|
||||
GRPCMetadataProcessor(QString const &serverToken); ///< Default constructor.
|
||||
GRPCMetadataProcessor(GRPCMetadataProcessor const&) = delete; ///< Disabled copy-constructor.
|
||||
GRPCMetadataProcessor(GRPCMetadataProcessor&&) = delete; ///< Disabled assignment copy-constructor.
|
||||
GRPCMetadataProcessor(GRPCMetadataProcessor const &) = delete; ///< Disabled copy-constructor.
|
||||
GRPCMetadataProcessor(GRPCMetadataProcessor &&) = delete; ///< Disabled assignment copy-constructor.
|
||||
~GRPCMetadataProcessor() = default; ///< Destructor.
|
||||
GRPCMetadataProcessor& operator=(GRPCMetadataProcessor const&) = delete; ///< Disabled assignment operator.
|
||||
GRPCMetadataProcessor& operator=(GRPCMetadataProcessor&&) = delete; ///< Disabled move assignment operator.
|
||||
GRPCMetadataProcessor &operator=(GRPCMetadataProcessor const &) = delete; ///< Disabled assignment operator.
|
||||
GRPCMetadataProcessor &operator=(GRPCMetadataProcessor &&) = delete; ///< Disabled move assignment operator.
|
||||
bool IsBlocking() const override; ///< Is the processor blocking?
|
||||
grpc::Status Process(InputMetadata const &auth_metadata, grpc::AuthContext *context, OutputMetadata *consumed_auth_metadata,
|
||||
OutputMetadata *response_metadata) override; ///< Process the metadata
|
||||
|
||||
@ -24,15 +24,14 @@
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
GRPCQtProxy::GRPCQtProxy()
|
||||
: QObject(nullptr)
|
||||
{
|
||||
: QObject(nullptr) {
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::connectSignals()
|
||||
{
|
||||
void GRPCQtProxy::connectSignals() {
|
||||
MainWindow &mainWindow = app().mainWindow();
|
||||
SettingsTab &settingsTab = mainWindow.settingsTab();
|
||||
UsersTab &usersTab = mainWindow.usersTab();
|
||||
@ -60,8 +59,7 @@ void GRPCQtProxy::connectSignals()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] event The event.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::sendDelayedEvent(bridgepp::SPStreamEvent const &event)
|
||||
{
|
||||
void GRPCQtProxy::sendDelayedEvent(bridgepp::SPStreamEvent const &event) {
|
||||
emit delayedEventRequested(event);
|
||||
}
|
||||
|
||||
@ -69,8 +67,7 @@ void GRPCQtProxy::sendDelayedEvent(bridgepp::SPStreamEvent const &event)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] on The value.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setIsAutostartOn(bool on)
|
||||
{
|
||||
void GRPCQtProxy::setIsAutostartOn(bool on) {
|
||||
emit setIsAutostartOnReceived(on);
|
||||
}
|
||||
|
||||
@ -78,8 +75,7 @@ void GRPCQtProxy::setIsAutostartOn(bool on)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] enabled The value.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setIsBetaEnabled(bool enabled)
|
||||
{
|
||||
void GRPCQtProxy::setIsBetaEnabled(bool enabled) {
|
||||
emit setIsBetaEnabledReceived(enabled);
|
||||
}
|
||||
|
||||
@ -87,8 +83,7 @@ void GRPCQtProxy::setIsBetaEnabled(bool enabled)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] visible The value.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setIsAllMailVisible(bool visible)
|
||||
{
|
||||
void GRPCQtProxy::setIsAllMailVisible(bool visible) {
|
||||
emit setIsAllMailVisibleReceived(visible);
|
||||
}
|
||||
|
||||
@ -96,8 +91,7 @@ void GRPCQtProxy::setIsAllMailVisible(bool visible)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] name The color scheme.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setColorSchemeName(QString const &name)
|
||||
{
|
||||
void GRPCQtProxy::setColorSchemeName(QString const &name) {
|
||||
emit setColorSchemeNameReceived(name);
|
||||
}
|
||||
|
||||
@ -111,8 +105,7 @@ void GRPCQtProxy::setColorSchemeName(QString const &name)
|
||||
/// \param[in] includeLogs Should the logs be included.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::reportBug(QString const &osType, QString const &osVersion, QString const &emailClient, QString const &address,
|
||||
QString const &description, bool includeLogs)
|
||||
{
|
||||
QString const &description, bool includeLogs) {
|
||||
emit reportBugReceived(osType, osVersion, emailClient, address, description, includeLogs);
|
||||
}
|
||||
|
||||
@ -120,8 +113,7 @@ void GRPCQtProxy::reportBug(QString const &osType, QString const &osVersion, QSt
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] folderPath The folder path.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::exportTLSCertificates(QString const &folderPath)
|
||||
{
|
||||
void GRPCQtProxy::exportTLSCertificates(QString const &folderPath) {
|
||||
emit exportTLSCertificatesReceived(folderPath);
|
||||
}
|
||||
|
||||
@ -129,8 +121,7 @@ void GRPCQtProxy::exportTLSCertificates(QString const &folderPath)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] isStreaming Is the gRPC server streaming.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setIsStreaming(bool isStreaming)
|
||||
{
|
||||
void GRPCQtProxy::setIsStreaming(bool isStreaming) {
|
||||
emit setIsStreamingReceived(isStreaming);
|
||||
}
|
||||
|
||||
@ -138,8 +129,7 @@ void GRPCQtProxy::setIsStreaming(bool isStreaming)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] clientPlatform The client platform.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setClientPlatform(QString const &clientPlatform)
|
||||
{
|
||||
void GRPCQtProxy::setClientPlatform(QString const &clientPlatform) {
|
||||
emit setClientPlatformReceived(clientPlatform);
|
||||
}
|
||||
|
||||
@ -150,8 +140,7 @@ void GRPCQtProxy::setClientPlatform(QString const &clientPlatform)
|
||||
/// \param[in] useSSLForIMAP The IMAP connexion mode.
|
||||
/// \param[in] useSSLForSMTP The IMAP connexion mode.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setMailServerSettings(qint32 imapPort, qint32 smtpPort, bool useSSLForIMAP, bool userSSLForSMTP)
|
||||
{
|
||||
void GRPCQtProxy::setMailServerSettings(qint32 imapPort, qint32 smtpPort, bool useSSLForIMAP, bool userSSLForSMTP) {
|
||||
emit setMailServerSettingsReceived(imapPort, smtpPort, useSSLForIMAP, userSSLForSMTP);
|
||||
}
|
||||
|
||||
@ -159,8 +148,7 @@ void GRPCQtProxy::setMailServerSettings(qint32 imapPort, qint32 smtpPort, bool u
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] enabled Is DoH enabled?
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setIsDoHEnabled(bool enabled)
|
||||
{
|
||||
void GRPCQtProxy::setIsDoHEnabled(bool enabled) {
|
||||
emit setIsDoHEnabledReceived(enabled);
|
||||
}
|
||||
|
||||
@ -168,8 +156,7 @@ void GRPCQtProxy::setIsDoHEnabled(bool enabled)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] path The disk cache path.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setDiskCachePath(QString const &path)
|
||||
{
|
||||
void GRPCQtProxy::setDiskCachePath(QString const &path) {
|
||||
emit setDiskCachePathReceived(path);
|
||||
}
|
||||
|
||||
@ -177,8 +164,7 @@ void GRPCQtProxy::setDiskCachePath(QString const &path)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] on Is automatic update on?
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setIsAutomaticUpdateOn(bool on)
|
||||
{
|
||||
void GRPCQtProxy::setIsAutomaticUpdateOn(bool on) {
|
||||
emit setIsAutomaticUpdateOnReceived(on);
|
||||
}
|
||||
|
||||
@ -187,8 +173,7 @@ void GRPCQtProxy::setIsAutomaticUpdateOn(bool on)
|
||||
/// \param[in] userID The userID.
|
||||
/// \param[in] makeItActive Should split mode be active.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::setUserSplitMode(QString const &userID, bool makeItActive)
|
||||
{
|
||||
void GRPCQtProxy::setUserSplitMode(QString const &userID, bool makeItActive) {
|
||||
emit setUserSplitModeReceived(userID, makeItActive);
|
||||
}
|
||||
|
||||
@ -196,8 +181,7 @@ void GRPCQtProxy::setUserSplitMode(QString const &userID, bool makeItActive)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] userID The userID.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::logoutUser(QString const &userID)
|
||||
{
|
||||
void GRPCQtProxy::logoutUser(QString const &userID) {
|
||||
emit logoutUserReceived(userID);
|
||||
}
|
||||
|
||||
@ -205,8 +189,7 @@ void GRPCQtProxy::logoutUser(QString const &userID)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] userID The userID.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::removeUser(QString const &userID)
|
||||
{
|
||||
void GRPCQtProxy::removeUser(QString const &userID) {
|
||||
emit removeUserReceived(userID);
|
||||
}
|
||||
|
||||
@ -215,7 +198,6 @@ void GRPCQtProxy::removeUser(QString const &userID)
|
||||
/// \param[in] userID The userID.
|
||||
/// \param[in] address The address.
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCQtProxy::configureUserAppleMail(QString const &userID, QString const &address)
|
||||
{
|
||||
void GRPCQtProxy::configureUserAppleMail(QString const &userID, QString const &address) {
|
||||
emit configureUserAppleMailReceived(userID, address);
|
||||
}
|
||||
|
||||
@ -26,8 +26,7 @@
|
||||
//****************************************************************************************************************************************************
|
||||
/// \brief Proxy object used by the gRPC service (which does not inherit QObject) to use the Qt Signal/Slot system.
|
||||
//****************************************************************************************************************************************************
|
||||
class GRPCQtProxy : public QObject
|
||||
{
|
||||
class GRPCQtProxy : public QObject {
|
||||
Q_OBJECT
|
||||
public: // member functions.
|
||||
GRPCQtProxy(); ///< Default constructor.
|
||||
|
||||
@ -32,8 +32,7 @@ using namespace grpc;
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
GRPCServerWorker::GRPCServerWorker(QObject *parent)
|
||||
: Worker(parent)
|
||||
{
|
||||
: Worker(parent) {
|
||||
|
||||
}
|
||||
|
||||
@ -41,19 +40,17 @@ GRPCServerWorker::GRPCServerWorker(QObject *parent)
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCServerWorker::run()
|
||||
{
|
||||
try
|
||||
{
|
||||
void GRPCServerWorker::run() {
|
||||
try {
|
||||
emit started();
|
||||
|
||||
SslServerCredentialsOptions::PemKeyCertPair pair;
|
||||
pair.private_key = testTLSKey.toStdString();
|
||||
pair.cert_chain = testTLSCert.toStdString();
|
||||
SslServerCredentialsOptions ssl_opts;
|
||||
ssl_opts.pem_root_certs="";
|
||||
ssl_opts.pem_root_certs = "";
|
||||
ssl_opts.pem_key_cert_pairs.push_back(pair);
|
||||
std::shared_ptr<ServerCredentials> credentials = grpc::SslServerCredentials(ssl_opts);
|
||||
std::shared_ptr<ServerCredentials> credentials = grpc::SslServerCredentials(ssl_opts);
|
||||
|
||||
GRPCConfig config;
|
||||
config.cert = testTLSCert;
|
||||
@ -65,8 +62,9 @@ void GRPCServerWorker::run()
|
||||
bool const useFileSocket = useFileSocketForGRPC();
|
||||
if (useFileSocket) {
|
||||
QString const fileSocketPath = getAvailableFileSocketPath();
|
||||
if (fileSocketPath.isEmpty())
|
||||
if (fileSocketPath.isEmpty()) {
|
||||
throw Exception("Could not get an available file socket.");
|
||||
}
|
||||
builder.AddListeningPort(QString("unix://%1").arg(fileSocketPath).toStdString(), credentials);
|
||||
config.fileSocketPath = fileSocketPath;
|
||||
} else {
|
||||
@ -76,23 +74,25 @@ void GRPCServerWorker::run()
|
||||
builder.RegisterService(&app().grpc());
|
||||
server_ = builder.BuildAndStart();
|
||||
|
||||
if (!server_)
|
||||
if (!server_) {
|
||||
throw Exception("Could not create gRPC server.");
|
||||
}
|
||||
app().log().debug("gRPC Server started.");
|
||||
|
||||
config.port = port;
|
||||
QString err;
|
||||
if (!config.save(grpcServerConfigPath(), &err))
|
||||
if (!config.save(grpcServerConfigPath(), &err)) {
|
||||
throw Exception(QString("Could not save gRPC server config. %1").arg(err));
|
||||
}
|
||||
|
||||
server_->Wait();
|
||||
emit finished();
|
||||
app().log().debug("gRPC Server exited.");
|
||||
}
|
||||
catch (Exception const &e)
|
||||
{
|
||||
if (server_)
|
||||
catch (Exception const &e) {
|
||||
if (server_) {
|
||||
server_->Shutdown();
|
||||
}
|
||||
|
||||
emit error(e.qwhat());
|
||||
}
|
||||
@ -102,10 +102,10 @@ void GRPCServerWorker::run()
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCServerWorker::stop()
|
||||
{
|
||||
if (server_)
|
||||
void GRPCServerWorker::stop() {
|
||||
if (server_) {
|
||||
server_->Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -29,8 +29,7 @@
|
||||
//**********************************************************************************************************************
|
||||
/// \brief gRPC server worker
|
||||
//**********************************************************************************************************************
|
||||
class GRPCServerWorker : public bridgepp::Worker
|
||||
{
|
||||
class GRPCServerWorker : public bridgepp::Worker {
|
||||
Q_OBJECT
|
||||
public: // member functions.
|
||||
explicit GRPCServerWorker(QObject *parent); ///< Default constructor.
|
||||
|
||||
@ -27,8 +27,7 @@ using namespace grpc;
|
||||
using namespace google::protobuf;
|
||||
using namespace bridgepp;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
|
||||
QString const defaultKeychain = "defaultKeychain"; ///< The default keychain.
|
||||
@ -40,8 +39,7 @@ QString const defaultKeychain = "defaultKeychain"; ///< The default keychain.
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void GRPCService::connectProxySignals()
|
||||
{
|
||||
void GRPCService::connectProxySignals() {
|
||||
qtProxy_.connectSignals();
|
||||
}
|
||||
|
||||
@ -49,8 +47,7 @@ void GRPCService::connectProxySignals()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the service is streaming events.
|
||||
//****************************************************************************************************************************************************
|
||||
bool GRPCService::isStreaming() const
|
||||
{
|
||||
bool GRPCService::isStreaming() const {
|
||||
QMutexLocker locker(&eventStreamMutex_);
|
||||
return isStreaming_;
|
||||
}
|
||||
@ -60,14 +57,12 @@ bool GRPCService::isStreaming() const
|
||||
/// \param[in] request The request.
|
||||
/// \param[out] response The response.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::CheckTokens(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::StringValue *response)
|
||||
{
|
||||
Log& log = app().log();
|
||||
Status GRPCService::CheckTokens(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::StringValue *response) {
|
||||
Log &log = app().log();
|
||||
log.debug(__FUNCTION__);
|
||||
GRPCConfig config;
|
||||
QString error;
|
||||
if (!config.load(QString::fromStdString(request->value()), &error))
|
||||
{
|
||||
if (!config.load(QString::fromStdString(request->value()), &error)) {
|
||||
QString const err = "Could not load gRPC client config";
|
||||
log.error(err);
|
||||
return grpc::Status(StatusCode::UNAUTHENTICATED, err.toStdString());
|
||||
@ -82,8 +77,7 @@ Status GRPCService::CheckTokens(::grpc::ServerContext *, ::google::protobuf::Str
|
||||
/// \param[in] request the request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::AddLogEntry(ServerContext *, AddLogEntryRequest const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::AddLogEntry(ServerContext *, AddLogEntryRequest const *request, Empty *) {
|
||||
app().bridgeGUILog().addEntry(logLevelFromGRPC(request->level()), QString::fromStdString(request->message()));
|
||||
return Status::OK;
|
||||
}
|
||||
@ -92,8 +86,7 @@ Status GRPCService::AddLogEntry(ServerContext *, AddLogEntryRequest const *reque
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::GuiReady(ServerContext *, Empty const *, Empty *)
|
||||
{
|
||||
Status GRPCService::GuiReady(ServerContext *, Empty const *, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
app().mainWindow().settingsTab().setGUIReady(true);
|
||||
return Status::OK;
|
||||
@ -103,8 +96,7 @@ Status GRPCService::GuiReady(ServerContext *, Empty const *, Empty *)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::Quit(ServerContext *, Empty const *, Empty *)
|
||||
{
|
||||
Status GRPCService::Quit(ServerContext *, Empty const *, Empty *) {
|
||||
// We do not actually quit.
|
||||
app().log().debug(__FUNCTION__);
|
||||
return Status::OK;
|
||||
@ -114,8 +106,7 @@ Status GRPCService::Quit(ServerContext *, Empty const *, Empty *)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::Restart(ServerContext *, Empty const *, Empty *)
|
||||
{
|
||||
Status GRPCService::Restart(ServerContext *, Empty const *, Empty *) {
|
||||
// we do not actually restart.
|
||||
app().log().debug(__FUNCTION__);
|
||||
return Status::OK;
|
||||
@ -126,8 +117,7 @@ Status GRPCService::Restart(ServerContext *, Empty const *, Empty *)
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::ShowOnStartup(ServerContext *, Empty const *, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::ShowOnStartup(ServerContext *, Empty const *, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().showOnStartup());
|
||||
return Status::OK;
|
||||
@ -138,8 +128,7 @@ Status GRPCService::ShowOnStartup(ServerContext *, Empty const *, BoolValue *res
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::ShowSplashScreen(ServerContext *, Empty const *, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::ShowSplashScreen(ServerContext *, Empty const *, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().showSplashScreen());
|
||||
return Status::OK;
|
||||
@ -150,8 +139,7 @@ Status GRPCService::ShowSplashScreen(ServerContext *, Empty const *, BoolValue *
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::IsFirstGuiStart(ServerContext *, Empty const *, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::IsFirstGuiStart(ServerContext *, Empty const *, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().isFirstGUIStart());
|
||||
return Status::OK;
|
||||
@ -162,8 +150,7 @@ Status GRPCService::IsFirstGuiStart(ServerContext *, Empty const *, BoolValue *r
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetIsAutostartOn(ServerContext *, BoolValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetIsAutostartOn(ServerContext *, BoolValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
app().mainWindow().settingsTab().setIsAutostartOn(request->value());
|
||||
qtProxy_.sendDelayedEvent(newToggleAutostartFinishedEvent());
|
||||
@ -175,8 +162,7 @@ Status GRPCService::SetIsAutostartOn(ServerContext *, BoolValue const *request,
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::IsAutostartOn(ServerContext *, Empty const *, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::IsAutostartOn(ServerContext *, Empty const *, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().isAutostartOn());
|
||||
return Status::OK;
|
||||
@ -187,8 +173,7 @@ Status GRPCService::IsAutostartOn(ServerContext *, Empty const *, BoolValue *res
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetIsBetaEnabled(ServerContext *, BoolValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetIsBetaEnabled(ServerContext *, BoolValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.setIsBetaEnabled(request->value());
|
||||
return Status::OK;
|
||||
@ -199,8 +184,7 @@ Status GRPCService::SetIsBetaEnabled(ServerContext *, BoolValue const *request,
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::IsBetaEnabled(ServerContext *, Empty const *, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::IsBetaEnabled(ServerContext *, Empty const *, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().isBetaEnabled());
|
||||
return Status::OK;
|
||||
@ -211,8 +195,7 @@ Status GRPCService::IsBetaEnabled(ServerContext *, Empty const *, BoolValue *res
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetIsAllMailVisible(ServerContext *, BoolValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetIsAllMailVisible(ServerContext *, BoolValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.setIsAllMailVisible(request->value());
|
||||
return Status::OK;
|
||||
@ -223,8 +206,7 @@ Status GRPCService::SetIsAllMailVisible(ServerContext *, BoolValue const *reques
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::IsAllMailVisible(ServerContext *, Empty const *request, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::IsAllMailVisible(ServerContext *, Empty const *request, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().isAllMailVisible());
|
||||
return Status::OK;
|
||||
@ -235,8 +217,7 @@ Status GRPCService::IsAllMailVisible(ServerContext *, Empty const *request, Bool
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::GoOs(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::GoOs(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().os().toStdString());
|
||||
return Status::OK;
|
||||
@ -246,8 +227,7 @@ Status GRPCService::GoOs(ServerContext *, Empty const *, StringValue *response)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::TriggerReset(ServerContext *, Empty const *, Empty *)
|
||||
{
|
||||
Status GRPCService::TriggerReset(ServerContext *, Empty const *, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
app().log().info("Bridge GUI requested a reset");
|
||||
return Status::OK;
|
||||
@ -258,8 +238,7 @@ Status GRPCService::TriggerReset(ServerContext *, Empty const *, Empty *)
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
grpc::Status GRPCService::Version(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
grpc::Status GRPCService::Version(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().bridgeVersion().toStdString());
|
||||
return Status::OK;
|
||||
@ -270,8 +249,7 @@ grpc::Status GRPCService::Version(ServerContext *, Empty const *, StringValue *r
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::LogsPath(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::LogsPath(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().logsPath().toStdString());
|
||||
return Status::OK;
|
||||
@ -282,8 +260,7 @@ Status GRPCService::LogsPath(ServerContext *, Empty const *, StringValue *respon
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::LicensePath(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::LicensePath(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().licensePath().toStdString());
|
||||
return Status::OK;
|
||||
@ -294,8 +271,7 @@ Status GRPCService::LicensePath(ServerContext *, Empty const *, StringValue *res
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::ReleaseNotesPageLink(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::ReleaseNotesPageLink(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().releaseNotesPageLink().toStdString());
|
||||
return Status::OK;
|
||||
@ -306,8 +282,7 @@ Status GRPCService::ReleaseNotesPageLink(ServerContext *, Empty const *, StringV
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::DependencyLicensesLink(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::DependencyLicensesLink(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().dependencyLicenseLink().toStdString());
|
||||
return Status::OK;
|
||||
@ -318,8 +293,7 @@ Status GRPCService::DependencyLicensesLink(ServerContext *, Empty const *, Strin
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::LandingPageLink(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::LandingPageLink(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().landingPageLink().toStdString());
|
||||
return Status::OK;
|
||||
@ -330,8 +304,7 @@ Status GRPCService::LandingPageLink(ServerContext *, Empty const *, StringValue
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetColorSchemeName(ServerContext *, StringValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetColorSchemeName(ServerContext *, StringValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.setColorSchemeName(QString::fromStdString(request->value()));
|
||||
return Status::OK;
|
||||
@ -342,8 +315,7 @@ Status GRPCService::SetColorSchemeName(ServerContext *, StringValue const *reque
|
||||
/// \param[in] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::ColorSchemeName(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::ColorSchemeName(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().colorSchemeName().toStdString());
|
||||
return Status::OK;
|
||||
@ -354,8 +326,7 @@ Status GRPCService::ColorSchemeName(ServerContext *, Empty const *, StringValue
|
||||
/// \param[in] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::CurrentEmailClient(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::CurrentEmailClient(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().currentEmailClient().toStdString());
|
||||
return Status::OK;
|
||||
@ -366,8 +337,7 @@ Status GRPCService::CurrentEmailClient(ServerContext *, Empty const *, StringVal
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::ForceLauncher(ServerContext *, StringValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::ForceLauncher(ServerContext *, StringValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
app().log().info(QString("ForceLauncher: %1").arg(QString::fromStdString(request->value())));
|
||||
return Status::OK;
|
||||
@ -378,20 +348,17 @@ Status GRPCService::ForceLauncher(ServerContext *, StringValue const *request, E
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetMainExecutable(ServerContext *, StringValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetMainExecutable(ServerContext *, StringValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
app().log().info(QString("SetMainExecutable: %1").arg(QString::fromStdString(request->value())));
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] request The request
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::ReportBug(ServerContext *, ReportBugRequest const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::ReportBug(ServerContext *, ReportBugRequest const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
SettingsTab &tab = app().mainWindow().settingsTab();
|
||||
qtProxy_.reportBug(QString::fromStdString(request->ostype()), QString::fromStdString(request->osversion()),
|
||||
@ -407,13 +374,14 @@ Status GRPCService::ReportBug(ServerContext *, ReportBugRequest const *request,
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] request The request
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::ExportTLSCertificates(ServerContext *, StringValue const *request, Empty *response)
|
||||
{
|
||||
Status GRPCService::ExportTLSCertificates(ServerContext *, StringValue const *request, Empty *response) {
|
||||
SettingsTab &tab = app().mainWindow().settingsTab();
|
||||
if (!tab.nextTLSCertExportWillSucceed())
|
||||
if (!tab.nextTLSCertExportWillSucceed()) {
|
||||
qtProxy_.sendDelayedEvent(newGenericErrorEvent(grpc::TLS_CERT_EXPORT_ERROR));
|
||||
if (!tab.nextTLSKeyExportWillSucceed())
|
||||
}
|
||||
if (!tab.nextTLSKeyExportWillSucceed()) {
|
||||
qtProxy_.sendDelayedEvent(newGenericErrorEvent(grpc::TLS_KEY_EXPORT_ERROR));
|
||||
}
|
||||
qtProxy_.exportTLSCertificates(QString::fromStdString(request->value()));
|
||||
return Status::OK;
|
||||
}
|
||||
@ -423,28 +391,23 @@ Status GRPCService::ExportTLSCertificates(ServerContext *, StringValue const *re
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::Login(ServerContext *, LoginRequest const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::Login(ServerContext *, LoginRequest const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
UsersTab &usersTab = app().mainWindow().usersTab();
|
||||
loginUsername_ = QString::fromStdString(request->username());
|
||||
if (usersTab.nextUserUsernamePasswordError())
|
||||
{
|
||||
if (usersTab.nextUserUsernamePasswordError()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::USERNAME_PASSWORD_ERROR, usersTab.usernamePasswordErrorMessage()));
|
||||
return Status::OK;
|
||||
}
|
||||
if (usersTab.nextUserFreeUserError())
|
||||
{
|
||||
if (usersTab.nextUserFreeUserError()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::FREE_USER, "Free user error."));
|
||||
return Status::OK;
|
||||
}
|
||||
if (usersTab.nextUserTFARequired())
|
||||
{
|
||||
if (usersTab.nextUserTFARequired()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginTfaRequestedEvent(loginUsername_));
|
||||
return Status::OK;
|
||||
}
|
||||
if (usersTab.nextUserTwoPasswordsRequired())
|
||||
{
|
||||
if (usersTab.nextUserTwoPasswordsRequired()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginTwoPasswordsRequestedEvent());
|
||||
return Status::OK;
|
||||
}
|
||||
@ -454,8 +417,9 @@ Status GRPCService::Login(ServerContext *, LoginRequest const *request, Empty *)
|
||||
user->setUsername(QString::fromStdString(request->username()));
|
||||
usersTab.userTable().append(user);
|
||||
|
||||
if (usersTab.nextUserAlreadyLoggedIn())
|
||||
if (usersTab.nextUserAlreadyLoggedIn()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginAlreadyLoggedInEvent(userID));
|
||||
}
|
||||
qtProxy_.sendDelayedEvent(newLoginFinishedEvent(userID));
|
||||
return Status::OK;
|
||||
}
|
||||
@ -465,22 +429,18 @@ Status GRPCService::Login(ServerContext *, LoginRequest const *request, Empty *)
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::Login2FA(ServerContext *, LoginRequest const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::Login2FA(ServerContext *, LoginRequest const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
UsersTab &usersTab = app().mainWindow().usersTab();
|
||||
if (usersTab.nextUserTFAError())
|
||||
{
|
||||
if (usersTab.nextUserTFAError()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::TFA_ERROR, "2FA Error."));
|
||||
return Status::OK;
|
||||
}
|
||||
if (usersTab.nextUserTFAAbort())
|
||||
{
|
||||
if (usersTab.nextUserTFAAbort()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::TFA_ABORT, "2FA Abort."));
|
||||
return Status::OK;
|
||||
}
|
||||
if (usersTab.nextUserTwoPasswordsRequired())
|
||||
{
|
||||
if (usersTab.nextUserTwoPasswordsRequired()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginTwoPasswordsRequestedEvent());
|
||||
return Status::OK;
|
||||
}
|
||||
@ -490,8 +450,9 @@ Status GRPCService::Login2FA(ServerContext *, LoginRequest const *request, Empty
|
||||
user->setUsername(QString::fromStdString(request->username()));
|
||||
usersTab.userTable().append(user);
|
||||
|
||||
if (usersTab.nextUserAlreadyLoggedIn())
|
||||
if (usersTab.nextUserAlreadyLoggedIn()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginAlreadyLoggedInEvent(userID));
|
||||
}
|
||||
qtProxy_.sendDelayedEvent(newLoginFinishedEvent(userID));
|
||||
return Status::OK;
|
||||
}
|
||||
@ -501,19 +462,16 @@ Status GRPCService::Login2FA(ServerContext *, LoginRequest const *request, Empty
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::Login2Passwords(ServerContext *, LoginRequest const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::Login2Passwords(ServerContext *, LoginRequest const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
UsersTab &usersTab = app().mainWindow().usersTab();
|
||||
|
||||
if (usersTab.nextUserTwoPasswordsError())
|
||||
{
|
||||
if (usersTab.nextUserTwoPasswordsError()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::TWO_PASSWORDS_ERROR, "Two Passwords error."));
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
if (usersTab.nextUserTwoPasswordsAbort())
|
||||
{
|
||||
if (usersTab.nextUserTwoPasswordsAbort()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::TWO_PASSWORDS_ABORT, "Two Passwords abort."));
|
||||
return Status::OK;
|
||||
}
|
||||
@ -523,8 +481,9 @@ Status GRPCService::Login2Passwords(ServerContext *, LoginRequest const *request
|
||||
user->setUsername(QString::fromStdString(request->username()));
|
||||
usersTab.userTable().append(user);
|
||||
|
||||
if (usersTab.nextUserAlreadyLoggedIn())
|
||||
if (usersTab.nextUserAlreadyLoggedIn()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginAlreadyLoggedInEvent(userID));
|
||||
}
|
||||
qtProxy_.sendDelayedEvent(newLoginFinishedEvent(userID));
|
||||
return Status::OK;
|
||||
}
|
||||
@ -534,8 +493,7 @@ Status GRPCService::Login2Passwords(ServerContext *, LoginRequest const *request
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::LoginAbort(ServerContext *, LoginAbortRequest const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::LoginAbort(ServerContext *, LoginAbortRequest const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
loginUsername_ = QString();
|
||||
return Status::OK;
|
||||
@ -545,8 +503,7 @@ Status GRPCService::LoginAbort(ServerContext *, LoginAbortRequest const *request
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::CheckUpdate(ServerContext *, Empty const *, Empty *)
|
||||
{
|
||||
Status GRPCService::CheckUpdate(ServerContext *, Empty const *, Empty *) {
|
||||
/// \todo simulate update availability.
|
||||
app().log().debug(__FUNCTION__);
|
||||
app().log().info("Check for updates");
|
||||
@ -557,8 +514,7 @@ Status GRPCService::CheckUpdate(ServerContext *, Empty const *, Empty *)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::InstallUpdate(ServerContext *, Empty const *, Empty *)
|
||||
{
|
||||
Status GRPCService::InstallUpdate(ServerContext *, Empty const *, Empty *) {
|
||||
/// Simulate update availability.
|
||||
app().log().debug(__FUNCTION__);
|
||||
app().log().info("Install update");
|
||||
@ -570,30 +526,29 @@ Status GRPCService::InstallUpdate(ServerContext *, Empty const *, Empty *)
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetIsAutomaticUpdateOn(ServerContext *, BoolValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetIsAutomaticUpdateOn(ServerContext *, BoolValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.setIsAutomaticUpdateOn(request->value());
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::IsAutomaticUpdateOn(ServerContext *, Empty const *, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::IsAutomaticUpdateOn(ServerContext *, Empty const *, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().isAutomaticUpdateOn());
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] response The response.
|
||||
/// \return The status for the call
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::DiskCachePath(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::DiskCachePath(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().diskCachePath().toStdString());
|
||||
return Status::OK;
|
||||
@ -604,18 +559,16 @@ Status GRPCService::DiskCachePath(ServerContext *, Empty const *, StringValue *r
|
||||
/// \param[in] path The path.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetDiskCachePath(ServerContext *, StringValue const *path, Empty *)
|
||||
{
|
||||
Status GRPCService::SetDiskCachePath(ServerContext *, StringValue const *path, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
|
||||
SettingsTab &tab = app().mainWindow().settingsTab();
|
||||
QString const qPath = QString::fromStdString(path->value());
|
||||
|
||||
// we mimic the behaviour of Bridge
|
||||
if (!tab.nextCacheChangeWillSucceed())
|
||||
if (!tab.nextCacheChangeWillSucceed()) {
|
||||
qtProxy_.sendDelayedEvent(newDiskCacheErrorEvent(grpc::DiskCacheErrorType(tab.cacheError())));
|
||||
else
|
||||
{
|
||||
} else {
|
||||
qtProxy_.setDiskCachePath(qPath);
|
||||
qtProxy_.sendDelayedEvent(newDiskCachePathChangedEvent(qPath));
|
||||
}
|
||||
@ -629,8 +582,7 @@ Status GRPCService::SetDiskCachePath(ServerContext *, StringValue const *path, E
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetIsDoHEnabled(ServerContext *, BoolValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetIsDoHEnabled(ServerContext *, BoolValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.setIsDoHEnabled(request->value());
|
||||
return Status::OK;
|
||||
@ -641,8 +593,7 @@ Status GRPCService::SetIsDoHEnabled(ServerContext *, BoolValue const *request, E
|
||||
/// \param[out] response The response
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::IsDoHEnabled(ServerContext *, Empty const *, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::IsDoHEnabled(ServerContext *, Empty const *, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().isDoHEnabled());
|
||||
return Status::OK;
|
||||
@ -653,8 +604,7 @@ Status GRPCService::IsDoHEnabled(ServerContext *, Empty const *, BoolValue *resp
|
||||
/// \param[in] settings The IMAP/SMTP settings.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetMailServerSettings(::grpc::ServerContext *context, ImapSmtpSettings const *settings, Empty *)
|
||||
{
|
||||
Status GRPCService::SetMailServerSettings(::grpc::ServerContext *context, ImapSmtpSettings const *settings, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.setMailServerSettings(settings->imapport(), settings->smtpport(), settings->usesslforimap(), settings->usesslforsmtp());
|
||||
qtProxy_.sendDelayedEvent(newMailServerSettingsChanged(*settings));
|
||||
@ -667,10 +617,9 @@ Status GRPCService::SetMailServerSettings(::grpc::ServerContext *context, ImapSm
|
||||
/// \param[out] outSettings The settings
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::MailServerSettings(::grpc::ServerContext *, Empty const *, ImapSmtpSettings *outSettings)
|
||||
{
|
||||
Status GRPCService::MailServerSettings(::grpc::ServerContext *, Empty const *, ImapSmtpSettings *outSettings) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
SettingsTab& tab = app().mainWindow().settingsTab();
|
||||
SettingsTab &tab = app().mainWindow().settingsTab();
|
||||
outSettings->set_imapport(tab.imapPort());
|
||||
outSettings->set_smtpport(tab.smtpPort());
|
||||
outSettings->set_usesslforimap(tab.useSSLForIMAP());
|
||||
@ -683,8 +632,7 @@ Status GRPCService::MailServerSettings(::grpc::ServerContext *, Empty const *, I
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::Hostname(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::Hostname(ServerContext *, Empty const *, StringValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().hostname().toStdString());
|
||||
return Status::OK;
|
||||
@ -696,8 +644,7 @@ Status GRPCService::Hostname(ServerContext *, Empty const *, StringValue *respon
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::IsPortFree(ServerContext *, Int32Value const *request, BoolValue *response)
|
||||
{
|
||||
Status GRPCService::IsPortFree(ServerContext *, Int32Value const *request, BoolValue *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(app().mainWindow().settingsTab().isPortFree());
|
||||
return Status::OK;
|
||||
@ -708,8 +655,7 @@ Status GRPCService::IsPortFree(ServerContext *, Int32Value const *request, BoolV
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::AvailableKeychains(ServerContext *, Empty const *, AvailableKeychainsResponse *response)
|
||||
{
|
||||
Status GRPCService::AvailableKeychains(ServerContext *, Empty const *, AvailableKeychainsResponse *response) {
|
||||
/// \todo Implement keychains configuration.
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->clear_keychains();
|
||||
@ -722,8 +668,7 @@ Status GRPCService::AvailableKeychains(ServerContext *, Empty const *, Available
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetCurrentKeychain(ServerContext *, StringValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetCurrentKeychain(ServerContext *, StringValue const *request, Empty *) {
|
||||
/// \todo Implement keychains configuration.
|
||||
app().log().debug(__FUNCTION__);
|
||||
return Status::OK;
|
||||
@ -734,8 +679,7 @@ Status GRPCService::SetCurrentKeychain(ServerContext *, StringValue const *reque
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::CurrentKeychain(ServerContext *, Empty const *, StringValue *response)
|
||||
{
|
||||
Status GRPCService::CurrentKeychain(ServerContext *, Empty const *, StringValue *response) {
|
||||
/// \todo Implement keychains configuration.
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->set_value(defaultKeychain.toStdString());
|
||||
@ -747,17 +691,16 @@ Status GRPCService::CurrentKeychain(ServerContext *, Empty const *, StringValue
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::GetUserList(ServerContext *, Empty const *, UserListResponse *response)
|
||||
{
|
||||
Status GRPCService::GetUserList(ServerContext *, Empty const *, UserListResponse *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
response->clear_users();
|
||||
|
||||
QList<SPUser> userList = app().mainWindow().usersTab().userTable().users();
|
||||
RepeatedPtrField<grpc::User> *users = response->mutable_users();
|
||||
for (SPUser const &user: userList)
|
||||
{
|
||||
if (!user)
|
||||
for (SPUser const &user: userList) {
|
||||
if (!user) {
|
||||
continue;
|
||||
}
|
||||
users->Add();
|
||||
grpc::User &grpcUser = (*users)[users->size() - 1];
|
||||
userToGRPC(*user, grpcUser);
|
||||
@ -772,13 +715,13 @@ Status GRPCService::GetUserList(ServerContext *, Empty const *, UserListResponse
|
||||
/// \param[out] response The response.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::GetUser(ServerContext *, StringValue const *request, grpc::User *response)
|
||||
{
|
||||
Status GRPCService::GetUser(ServerContext *, StringValue const *request, grpc::User *response) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
QString userID = QString::fromStdString(request->value());
|
||||
SPUser user = app().mainWindow().usersTab().userWithID(userID);
|
||||
if (!user)
|
||||
if (!user) {
|
||||
return Status(NOT_FOUND, QString("user not found %1").arg(userID).toStdString());
|
||||
}
|
||||
|
||||
userToGRPC(*user, *response);
|
||||
return Status::OK;
|
||||
@ -789,8 +732,7 @@ Status GRPCService::GetUser(ServerContext *, StringValue const *request, grpc::U
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::SetUserSplitMode(ServerContext *, UserSplitModeRequest const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::SetUserSplitMode(ServerContext *, UserSplitModeRequest const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.setUserSplitMode(QString::fromStdString(request->userid()), request->active());
|
||||
return Status::OK;
|
||||
@ -801,8 +743,7 @@ Status GRPCService::SetUserSplitMode(ServerContext *, UserSplitModeRequest const
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::LogoutUser(ServerContext *, StringValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::LogoutUser(ServerContext *, StringValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.logoutUser(QString::fromStdString(request->value()));
|
||||
return Status::OK;
|
||||
@ -813,8 +754,7 @@ Status GRPCService::LogoutUser(ServerContext *, StringValue const *request, Empt
|
||||
/// \param[in] request The request.
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::RemoveUser(ServerContext *, StringValue const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::RemoveUser(ServerContext *, StringValue const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.removeUser(QString::fromStdString(request->value()));
|
||||
return Status::OK;
|
||||
@ -824,8 +764,7 @@ Status GRPCService::RemoveUser(ServerContext *, StringValue const *request, Empt
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] request The request.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::ConfigureUserAppleMail(ServerContext *, ConfigureAppleMailRequest const *request, Empty *)
|
||||
{
|
||||
Status GRPCService::ConfigureUserAppleMail(ServerContext *, ConfigureAppleMailRequest const *request, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
qtProxy_.configureUserAppleMail(QString::fromStdString(request->userid()), QString::fromStdString(request->address()));
|
||||
return Status::OK;
|
||||
@ -837,24 +776,22 @@ Status GRPCService::ConfigureUserAppleMail(ServerContext *, ConfigureAppleMailRe
|
||||
/// \param[in] writer The writer
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::RunEventStream(ServerContext *, EventStreamRequest const *request, ServerWriter<StreamEvent> *writer)
|
||||
{
|
||||
Status GRPCService::RunEventStream(ServerContext *, EventStreamRequest const *request, ServerWriter<StreamEvent> *writer) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
{
|
||||
QMutexLocker locker(&eventStreamMutex_);
|
||||
if (isStreaming_)
|
||||
if (isStreaming_) {
|
||||
return { grpc::ALREADY_EXISTS, "the service is already streaming" };
|
||||
}
|
||||
isStreaming_ = true;
|
||||
qtProxy_.setIsStreaming(true);
|
||||
qtProxy_.setClientPlatform(QString::fromStdString(request->clientplatform()));
|
||||
eventStreamShouldStop_ = false;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (true) {
|
||||
QMutexLocker locker(&eventStreamMutex_);
|
||||
if (eventStreamShouldStop_)
|
||||
{
|
||||
if (eventStreamShouldStop_) {
|
||||
qtProxy_.setIsStreaming(false);
|
||||
qtProxy_.setClientPlatform(QString());
|
||||
isStreaming_ = false;
|
||||
@ -862,8 +799,7 @@ Status GRPCService::RunEventStream(ServerContext *, EventStreamRequest const *re
|
||||
}
|
||||
|
||||
|
||||
if (eventQueue_.isEmpty())
|
||||
{
|
||||
if (eventQueue_.isEmpty()) {
|
||||
locker.unlock();
|
||||
QThread::msleep(100);
|
||||
continue;
|
||||
@ -872,10 +808,11 @@ Status GRPCService::RunEventStream(ServerContext *, EventStreamRequest const *re
|
||||
eventQueue_.pop_front();
|
||||
locker.unlock();
|
||||
|
||||
if (writer->Write(*event))
|
||||
if (writer->Write(*event)) {
|
||||
app().log().debug(QString("event sent: %1").arg(QString::fromStdString(event->ShortDebugString())));
|
||||
else
|
||||
} else {
|
||||
app().log().error(QString("Could not send event: %1").arg(QString::fromStdString(event->ShortDebugString())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -883,12 +820,12 @@ Status GRPCService::RunEventStream(ServerContext *, EventStreamRequest const *re
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The status for the call.
|
||||
//****************************************************************************************************************************************************
|
||||
Status GRPCService::StopEventStream(ServerContext *, Empty const *, Empty *)
|
||||
{
|
||||
Status GRPCService::StopEventStream(ServerContext *, Empty const *, Empty *) {
|
||||
app().log().debug(__FUNCTION__);
|
||||
QMutexLocker mutex(&eventStreamMutex_);
|
||||
if (!isStreaming_)
|
||||
if (!isStreaming_) {
|
||||
return Status(NOT_FOUND, "The service is not streaming");
|
||||
}
|
||||
eventStreamShouldStop_ = true;
|
||||
return Status::OK;
|
||||
}
|
||||
@ -898,10 +835,10 @@ Status GRPCService::StopEventStream(ServerContext *, Empty const *, Empty *)
|
||||
/// \param[in] event The event
|
||||
/// \return true if the event was queued, and false if the server in not streaming.
|
||||
//****************************************************************************************************************************************************
|
||||
bool GRPCService::sendEvent(SPStreamEvent const &event)
|
||||
{
|
||||
bool GRPCService::sendEvent(SPStreamEvent const &event) {
|
||||
QMutexLocker mutexLocker(&eventStreamMutex_);
|
||||
if (isStreaming_)
|
||||
if (isStreaming_) {
|
||||
eventQueue_.push_back(event);
|
||||
}
|
||||
return isStreaming_;
|
||||
}
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
//**********************************************************************************************************************
|
||||
/// \brief gRPC server implementation.
|
||||
//**********************************************************************************************************************
|
||||
class GRPCService : public grpc::Bridge::Service
|
||||
{
|
||||
class GRPCService : public grpc::Bridge::Service {
|
||||
|
||||
public: // member functions.
|
||||
GRPCService() = default; ///< Default constructor.
|
||||
@ -42,29 +41,29 @@ public: // member functions.
|
||||
bool isStreaming() const; ///< Check if the service is currently streaming events.
|
||||
grpc::Status CheckTokens(::grpc::ServerContext *context, ::google::protobuf::StringValue const *request, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status AddLogEntry(::grpc::ServerContext *, ::grpc::AddLogEntryRequest const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status GuiReady(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::Empty *) override;
|
||||
grpc::Status Quit(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::Empty *) override;
|
||||
grpc::Status Restart(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::Empty *) override;
|
||||
grpc::Status ShowOnStartup(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status ShowSplashScreen(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status IsFirstGuiStart(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status GuiReady(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::Empty *) override;
|
||||
grpc::Status Quit(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::Empty *) override;
|
||||
grpc::Status Restart(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::Empty *) override;
|
||||
grpc::Status ShowOnStartup(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status ShowSplashScreen(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status IsFirstGuiStart(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status SetIsAutostartOn(::grpc::ServerContext *, ::google::protobuf::BoolValue const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status IsAutostartOn(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status IsAutostartOn(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status SetIsBetaEnabled(::grpc::ServerContext *, ::google::protobuf::BoolValue const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status IsBetaEnabled(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status IsBetaEnabled(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status SetIsAllMailVisible(::grpc::ServerContext *context, ::google::protobuf::BoolValue const *request, ::google::protobuf::Empty *response) override;
|
||||
grpc::Status IsAllMailVisible(::grpc::ServerContext *context, ::google::protobuf::Empty const *request, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status GoOs(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status TriggerReset(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::Empty *) override;
|
||||
grpc::Status Version(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status LogsPath(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status LicensePath(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status ReleaseNotesPageLink(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status DependencyLicensesLink(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status LandingPageLink(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status GoOs(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status TriggerReset(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::Empty *) override;
|
||||
grpc::Status Version(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status LogsPath(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status LicensePath(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status ReleaseNotesPageLink(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status DependencyLicensesLink(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status LandingPageLink(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status SetColorSchemeName(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status ColorSchemeName(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status CurrentEmailClient(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status ColorSchemeName(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status CurrentEmailClient(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status ReportBug(::grpc::ServerContext *, ::grpc::ReportBugRequest const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status ExportTLSCertificates(::grpc::ServerContext *context, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *response) override;
|
||||
grpc::Status ForceLauncher(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *) override;
|
||||
@ -73,29 +72,29 @@ public: // member functions.
|
||||
grpc::Status Login2FA(::grpc::ServerContext *, ::grpc::LoginRequest const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status Login2Passwords(::grpc::ServerContext *, ::grpc::LoginRequest const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status LoginAbort(::grpc::ServerContext *, ::grpc::LoginAbortRequest const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status CheckUpdate(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::Empty *) override;
|
||||
grpc::Status InstallUpdate(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::Empty *) override;
|
||||
grpc::Status CheckUpdate(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::Empty *) override;
|
||||
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 DiskCachePath(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status SetDiskCachePath(::grpc::ServerContext *, ::google::protobuf::StringValue const*, ::google::protobuf::Empty *r) override;
|
||||
grpc::Status IsAutomaticUpdateOn(::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 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 IsDoHEnabled(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status SetMailServerSettings(::grpc::ServerContext *context, ::grpc::ImapSmtpSettings const *request, ::google::protobuf::Empty *response) override;
|
||||
grpc::Status MailServerSettings(::grpc::ServerContext *context, ::google::protobuf::Empty const *request, ::grpc::ImapSmtpSettings *response) override;
|
||||
grpc::Status Hostname(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status Hostname(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status IsPortFree(::grpc::ServerContext *, ::google::protobuf::Int32Value const *request, ::google::protobuf::BoolValue *response) override;
|
||||
grpc::Status AvailableKeychains(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::grpc::AvailableKeychainsResponse *response) override;
|
||||
grpc::Status AvailableKeychains(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::grpc::AvailableKeychainsResponse *response) override;
|
||||
grpc::Status SetCurrentKeychain(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status CurrentKeychain(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status GetUserList(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::grpc::UserListResponse *response) override;
|
||||
grpc::Status CurrentKeychain(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::StringValue *response) override;
|
||||
grpc::Status GetUserList(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::grpc::UserListResponse *response) override;
|
||||
grpc::Status GetUser(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::grpc::User *response) override;
|
||||
grpc::Status SetUserSplitMode(::grpc::ServerContext *, ::grpc::UserSplitModeRequest const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status LogoutUser(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status RemoveUser(::grpc::ServerContext *, ::google::protobuf::StringValue const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status ConfigureUserAppleMail(::grpc::ServerContext *, ::grpc::ConfigureAppleMailRequest const *request, ::google::protobuf::Empty *) override;
|
||||
grpc::Status RunEventStream(::grpc::ServerContext *, ::grpc::EventStreamRequest const *request, ::grpc::ServerWriter<::grpc::StreamEvent> *writer) override;
|
||||
grpc::Status StopEventStream(::grpc::ServerContext *, ::google::protobuf::Empty const*, ::google::protobuf::Empty *) override;
|
||||
grpc::Status StopEventStream(::grpc::ServerContext *, ::google::protobuf::Empty const *, ::google::protobuf::Empty *) override;
|
||||
|
||||
bool sendEvent(bridgepp::SPStreamEvent const &event); ///< Queue an event for sending through the event stream.
|
||||
|
||||
|
||||
@ -23,8 +23,7 @@
|
||||
using namespace bridgepp;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
@ -32,12 +31,12 @@ namespace
|
||||
/// \param[in] message The log message.
|
||||
/// \param[in] logEdit The plain text edit widget that displays the log.
|
||||
//****************************************************************************************************************************************************
|
||||
void addEntryToLogEdit(bridgepp::Log::Level level, const QString &message, QPlainTextEdit &logEdit)
|
||||
{
|
||||
void addEntryToLogEdit(bridgepp::Log::Level level, const QString &message, QPlainTextEdit &logEdit) {
|
||||
/// \todo This may cause performance issue when log grows big. A better alternative should be implemented.
|
||||
QString log = logEdit.toPlainText().trimmed();
|
||||
if (!log.isEmpty())
|
||||
if (!log.isEmpty()) {
|
||||
log += "\n";
|
||||
}
|
||||
logEdit.setPlainText(log + Log::logEntryToString(level, QDateTime::currentDateTime(), message));
|
||||
}
|
||||
|
||||
@ -49,14 +48,13 @@ void addEntryToLogEdit(bridgepp::Log::Level level, const QString &message, QPlai
|
||||
/// \param[in] parent The parent widget of the window.
|
||||
//****************************************************************************************************************************************************
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
{
|
||||
: QMainWindow(parent) {
|
||||
ui_.setupUi(this);
|
||||
ui_.tabTop->setCurrentIndex(0);
|
||||
ui_.tabBottom->setCurrentIndex(0);
|
||||
ui_.splitter->setStretchFactor(0, 0);
|
||||
ui_.splitter->setStretchFactor(1, 1);
|
||||
ui_.splitter->setSizes({100, 10000});
|
||||
ui_.splitter->setSizes({ 100, 10000 });
|
||||
connect(&app().log(), &Log::entryAdded, this, &MainWindow::addLogEntry);
|
||||
connect(&app().bridgeGUILog(), &Log::entryAdded, this, &MainWindow::addBridgeGUILogEntry);
|
||||
}
|
||||
@ -65,8 +63,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return A reference to the 'General' tab.
|
||||
//****************************************************************************************************************************************************
|
||||
SettingsTab &MainWindow::settingsTab()
|
||||
{
|
||||
SettingsTab &MainWindow::settingsTab() {
|
||||
return *ui_.settingsTab;
|
||||
}
|
||||
|
||||
@ -74,8 +71,7 @@ SettingsTab &MainWindow::settingsTab()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return A reference to the users tab.
|
||||
//****************************************************************************************************************************************************
|
||||
UsersTab &MainWindow::usersTab()
|
||||
{
|
||||
UsersTab &MainWindow::usersTab() {
|
||||
return *ui_.usersTab;
|
||||
}
|
||||
|
||||
@ -84,8 +80,7 @@ UsersTab &MainWindow::usersTab()
|
||||
/// \param[in] level The log level.
|
||||
/// \param[in] message The log message
|
||||
//****************************************************************************************************************************************************
|
||||
void MainWindow::addLogEntry(bridgepp::Log::Level level, const QString &message)
|
||||
{
|
||||
void MainWindow::addLogEntry(bridgepp::Log::Level level, const QString &message) {
|
||||
addEntryToLogEdit(level, message, *ui_.editLog);
|
||||
}
|
||||
|
||||
@ -94,8 +89,7 @@ void MainWindow::addLogEntry(bridgepp::Log::Level level, const QString &message)
|
||||
/// \param[in] level The log level.
|
||||
/// \param[in] message The log message
|
||||
//****************************************************************************************************************************************************
|
||||
void MainWindow::addBridgeGUILogEntry(bridgepp::Log::Level level, const QString &message)
|
||||
{
|
||||
void MainWindow::addBridgeGUILogEntry(bridgepp::Log::Level level, const QString &message) {
|
||||
addEntryToLogEdit(level, message, *ui_.editBridgeGUILog);
|
||||
}
|
||||
|
||||
@ -103,8 +97,7 @@ void MainWindow::addBridgeGUILogEntry(bridgepp::Log::Level level, const QString
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] event The event.
|
||||
//****************************************************************************************************************************************************
|
||||
void MainWindow::sendDelayedEvent(SPStreamEvent const &event)
|
||||
{
|
||||
void MainWindow::sendDelayedEvent(SPStreamEvent const &event) {
|
||||
QTimer::singleShot(this->settingsTab().eventDelayMs(), [event] { app().grpc().sendEvent(event); });
|
||||
}
|
||||
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
//**********************************************************************************************************************
|
||||
/// \brief Main window class
|
||||
//**********************************************************************************************************************
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public: // member functions.
|
||||
explicit MainWindow(QWidget *parent); ///< Default constructor.
|
||||
@ -43,7 +42,7 @@ public: // member functions.
|
||||
UsersTab &usersTab(); ///< Returns a reference to the 'Users' tab.
|
||||
|
||||
public slots:
|
||||
void sendDelayedEvent(bridgepp::SPStreamEvent const& event); ///< Sends a gRPC event after the delay specified in the UI. The call is non blocking.
|
||||
void sendDelayedEvent(bridgepp::SPStreamEvent const &event); ///< Sends a gRPC event after the delay specified in the UI. The call is non blocking.
|
||||
|
||||
private slots:
|
||||
void addLogEntry(bridgepp::Log::Level level, QString const &message); ///< Add an entry to the log.
|
||||
|
||||
@ -25,8 +25,7 @@
|
||||
using namespace bridgepp;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
QString const colorSchemeDark = "dark"; ///< The dark color scheme name.
|
||||
QString const colorSchemeLight = "light"; ///< THe light color scheme name.
|
||||
}
|
||||
@ -36,44 +35,47 @@ QString const colorSchemeLight = "light"; ///< THe light color scheme name.
|
||||
/// \param[in] parent The parent widget of the tab.
|
||||
//****************************************************************************************************************************************************
|
||||
SettingsTab::SettingsTab(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
: QWidget(parent) {
|
||||
ui_.setupUi(this);
|
||||
|
||||
connect(ui_.buttonInternetOn, &QPushButton::clicked, []() { app().grpc().sendEvent(newInternetStatusEvent(true)); });
|
||||
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_.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);
|
||||
this->resetUI();
|
||||
this->updateGUIState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::updateGUIState()
|
||||
{
|
||||
void SettingsTab::updateGUIState() {
|
||||
bool connected = app().grpc().isStreaming();
|
||||
for (QWidget *widget: { ui_.groupVersion, ui_.groupGeneral, ui_.groupMail, ui_.groupPaths, ui_.groupCache })
|
||||
for (QWidget *widget: { ui_.groupVersion, ui_.groupGeneral, ui_.groupMail, ui_.groupPaths, ui_.groupCache }) {
|
||||
widget->setEnabled(!connected);
|
||||
ui_.comboCacheError -> setEnabled(!ui_.checkNextCacheChangeWillSucceed->isChecked());
|
||||
}
|
||||
ui_.comboCacheError->setEnabled(!ui_.checkNextCacheChangeWillSucceed->isChecked());
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] isStreaming Is the event stream on?
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setIsStreaming(bool isStreaming)
|
||||
{
|
||||
void SettingsTab::setIsStreaming(bool isStreaming) {
|
||||
ui_.labelStreamingValue->setText(isStreaming ? "Yes" : "No");
|
||||
this->updateGUIState();
|
||||
}
|
||||
@ -82,8 +84,7 @@ void SettingsTab::setIsStreaming(bool isStreaming)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] clientPlatform The client platform.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setClientPlatform(QString const &clientPlatform)
|
||||
{
|
||||
void SettingsTab::setClientPlatform(QString const &clientPlatform) {
|
||||
ui_.labelClientPlatformValue->setText(clientPlatform);
|
||||
}
|
||||
|
||||
@ -91,8 +92,7 @@ void SettingsTab::setClientPlatform(QString const &clientPlatform)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The version of Bridge
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::bridgeVersion() const
|
||||
{
|
||||
QString SettingsTab::bridgeVersion() const {
|
||||
return ui_.editVersion->text();
|
||||
}
|
||||
|
||||
@ -100,8 +100,7 @@ QString SettingsTab::bridgeVersion() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The OS as a Go GOOS compatible value ("darwin", "linux" or "windows").
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::os() const
|
||||
{
|
||||
QString SettingsTab::os() const {
|
||||
return ui_.comboOS->currentText();
|
||||
}
|
||||
|
||||
@ -109,8 +108,7 @@ QString SettingsTab::os() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'Current Email Client' edit.
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::currentEmailClient() const
|
||||
{
|
||||
QString SettingsTab::currentEmailClient() const {
|
||||
return ui_.editCurrentEmailClient->text();
|
||||
}
|
||||
|
||||
@ -118,8 +116,7 @@ QString SettingsTab::currentEmailClient() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] ready Is the GUI ready?
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setGUIReady(bool ready)
|
||||
{
|
||||
void SettingsTab::setGUIReady(bool ready) {
|
||||
this->updateGUIState();
|
||||
ui_.labelGUIReadyValue->setText(ready ? "Yes" : "No");
|
||||
}
|
||||
@ -128,8 +125,7 @@ void SettingsTab::setGUIReady(bool ready)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the 'Show On Startup' check box is checked.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::showOnStartup() const
|
||||
{
|
||||
bool SettingsTab::showOnStartup() const {
|
||||
return ui_.checkShowOnStartup->isChecked();
|
||||
}
|
||||
|
||||
@ -137,8 +133,7 @@ bool SettingsTab::showOnStartup() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the 'Show Splash Screen' check box is checked.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::showSplashScreen() const
|
||||
{
|
||||
bool SettingsTab::showSplashScreen() const {
|
||||
return ui_.checkShowSplashScreen->isChecked();
|
||||
}
|
||||
|
||||
@ -146,8 +141,7 @@ bool SettingsTab::showSplashScreen() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the 'Show Splash Screen' check box is checked.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::isFirstGUIStart() const
|
||||
{
|
||||
bool SettingsTab::isFirstGUIStart() const {
|
||||
return ui_.checkIsFirstGUIStart->isChecked();
|
||||
}
|
||||
|
||||
@ -155,8 +149,7 @@ bool SettingsTab::isFirstGUIStart() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff autosart is on.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::isAutostartOn() const
|
||||
{
|
||||
bool SettingsTab::isAutostartOn() const {
|
||||
return ui_.checkAutostart->isChecked();
|
||||
}
|
||||
|
||||
@ -164,8 +157,7 @@ bool SettingsTab::isAutostartOn() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] on Should autostart be turned on?
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setIsAutostartOn(bool on)
|
||||
{
|
||||
void SettingsTab::setIsAutostartOn(bool on) {
|
||||
ui_.checkAutostart->setChecked(on);
|
||||
}
|
||||
|
||||
@ -173,8 +165,7 @@ void SettingsTab::setIsAutostartOn(bool on)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true if the 'Use Dark Theme' check box is checked.
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::colorSchemeName() const
|
||||
{
|
||||
QString SettingsTab::colorSchemeName() const {
|
||||
return ui_.checkDarkTheme->isChecked() ? colorSchemeDark : colorSchemeLight;
|
||||
}
|
||||
|
||||
@ -182,8 +173,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) {
|
||||
ui_.checkDarkTheme->setChecked(name == colorSchemeDark);
|
||||
}
|
||||
|
||||
@ -191,8 +181,7 @@ void SettingsTab::setColorSchemeName(QString const &name)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true if the 'Beta Enabled' check box is checked.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::isBetaEnabled() const
|
||||
{
|
||||
bool SettingsTab::isBetaEnabled() const {
|
||||
return ui_.checkBetaEnabled->isChecked();
|
||||
}
|
||||
|
||||
@ -200,8 +189,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) {
|
||||
ui_.checkBetaEnabled->setChecked(enabled);
|
||||
}
|
||||
|
||||
@ -209,8 +197,7 @@ void SettingsTab::setIsBetaEnabled(bool enabled)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true if the 'All Mail Visible' check box is checked.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::isAllMailVisible() const
|
||||
{
|
||||
bool SettingsTab::isAllMailVisible() const {
|
||||
return ui_.checkAllMailVisible->isChecked();
|
||||
}
|
||||
|
||||
@ -218,8 +205,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) {
|
||||
ui_.checkAllMailVisible->setChecked(visible);
|
||||
}
|
||||
|
||||
@ -227,8 +213,7 @@ void SettingsTab::setIsAllMailVisible(bool visible)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The delay to apply before sending automatically generated events.
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 SettingsTab::eventDelayMs() const
|
||||
{
|
||||
qint32 SettingsTab::eventDelayMs() const {
|
||||
return ui_.spinEventDelay->value();
|
||||
}
|
||||
|
||||
@ -236,8 +221,7 @@ qint32 SettingsTab::eventDelayMs() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The path
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::logsPath() const
|
||||
{
|
||||
QString SettingsTab::logsPath() const {
|
||||
return ui_.editLogsPath->text();
|
||||
}
|
||||
|
||||
@ -245,8 +229,7 @@ QString SettingsTab::logsPath() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The path
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::licensePath() const
|
||||
{
|
||||
QString SettingsTab::licensePath() const {
|
||||
return ui_.editLicensePath->text();
|
||||
}
|
||||
|
||||
@ -254,8 +237,7 @@ QString SettingsTab::licensePath() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The link.
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::releaseNotesPageLink() const
|
||||
{
|
||||
QString SettingsTab::releaseNotesPageLink() const {
|
||||
return ui_.editReleaseNotesLink->text();
|
||||
}
|
||||
|
||||
@ -263,8 +245,7 @@ QString SettingsTab::releaseNotesPageLink() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The link.
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::dependencyLicenseLink() const
|
||||
{
|
||||
QString SettingsTab::dependencyLicenseLink() const {
|
||||
return ui_.editDependencyLicenseLink->text();
|
||||
}
|
||||
|
||||
@ -272,8 +253,7 @@ QString SettingsTab::dependencyLicenseLink() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The link.
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::landingPageLink() const
|
||||
{
|
||||
QString SettingsTab::landingPageLink() const {
|
||||
return ui_.editLandingPageLink->text();
|
||||
}
|
||||
|
||||
@ -287,8 +267,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) {
|
||||
ui_.editOSType->setText(osType);
|
||||
ui_.editOSVersion->setText(osVersion);
|
||||
ui_.editEmailClient->setText(emailClient);
|
||||
@ -301,8 +280,7 @@ void SettingsTab::setBugReport(QString const &osType, QString const &osVersion,
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] folderPath The folder path.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::exportTLSCertificates(QString const &folderPath)
|
||||
{
|
||||
void SettingsTab::exportTLSCertificates(QString const &folderPath) {
|
||||
ui_.labeLastTLSCertsExport->setText(QString("%1 Export to %2")
|
||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODateWithMs))
|
||||
.arg(folderPath));
|
||||
@ -312,8 +290,7 @@ void SettingsTab::exportTLSCertificates(QString const &folderPath)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The state of the check box.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::nextBugReportWillSucceed() const
|
||||
{
|
||||
bool SettingsTab::nextBugReportWillSucceed() const {
|
||||
return ui_.checkNextBugReportWillSucceed->isChecked();
|
||||
}
|
||||
|
||||
@ -321,8 +298,7 @@ bool SettingsTab::nextBugReportWillSucceed() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true if the 'Next TLS key export will succeed' check box is checked
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::nextTLSCertExportWillSucceed() const
|
||||
{
|
||||
bool SettingsTab::nextTLSCertExportWillSucceed() const {
|
||||
return ui_.checkTLSCertExportWillSucceed->isChecked();
|
||||
}
|
||||
|
||||
@ -330,8 +306,7 @@ bool SettingsTab::nextTLSCertExportWillSucceed() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true if the 'Next TLS key export will succeed' check box is checked
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::nextTLSKeyExportWillSucceed() const
|
||||
{
|
||||
bool SettingsTab::nextTLSKeyExportWillSucceed() const {
|
||||
return ui_.checkTLSKeyExportWillSucceed->isChecked();
|
||||
}
|
||||
|
||||
@ -339,8 +314,7 @@ bool SettingsTab::nextTLSKeyExportWillSucceed() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value of the 'Hostname' edit.
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::hostname() const
|
||||
{
|
||||
QString SettingsTab::hostname() const {
|
||||
return ui_.editHostname->text();
|
||||
}
|
||||
|
||||
@ -348,8 +322,7 @@ QString SettingsTab::hostname() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value of the IMAP port spin box.
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 SettingsTab::imapPort()
|
||||
{
|
||||
qint32 SettingsTab::imapPort() {
|
||||
return ui_.spinPortIMAP->value();
|
||||
}
|
||||
|
||||
@ -357,8 +330,7 @@ qint32 SettingsTab::imapPort()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value of the SMTP port spin box.
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 SettingsTab::smtpPort()
|
||||
{
|
||||
qint32 SettingsTab::smtpPort() {
|
||||
return ui_.spinPortSMTP->value();
|
||||
}
|
||||
|
||||
@ -369,27 +341,26 @@ 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) {
|
||||
ui_.spinPortIMAP->setValue(imapPort);
|
||||
ui_.spinPortSMTP->setValue(smtpPort);
|
||||
ui_.checkUseSSLForIMAP->setChecked(useSSLForIMAP);
|
||||
ui_.checkUseSSLForSMTP->setChecked(useSSLForSMTP);
|
||||
}
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The state of the 'Use SSL for SMTP' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::useSSLForSMTP() const
|
||||
{
|
||||
return ui_.checkUseSSLForSMTP->isChecked();
|
||||
}
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The state of the 'Use SSL for SMTP' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::useSSLForIMAP() const
|
||||
{
|
||||
bool SettingsTab::useSSLForSMTP() const {
|
||||
return ui_.checkUseSSLForSMTP->isChecked();
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The state of the 'Use SSL for SMTP' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::useSSLForIMAP() const {
|
||||
return ui_.checkUseSSLForIMAP->isChecked();
|
||||
}
|
||||
|
||||
@ -397,8 +368,7 @@ bool SettingsTab::useSSLForIMAP() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The state of the the 'DoH enabled' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::isDoHEnabled() const
|
||||
{
|
||||
bool SettingsTab::isDoHEnabled() const {
|
||||
return ui_.checkDoHEnabled->isChecked();
|
||||
}
|
||||
|
||||
@ -406,8 +376,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) {
|
||||
ui_.checkDoHEnabled->setChecked(enabled);
|
||||
}
|
||||
|
||||
@ -415,8 +384,7 @@ void SettingsTab::setIsDoHEnabled(bool enabled)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The reply for the next IsPortFree gRPC call.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::isPortFree() const
|
||||
{
|
||||
bool SettingsTab::isPortFree() const {
|
||||
return ui_.checkIsPortFree->isChecked();
|
||||
}
|
||||
|
||||
@ -424,8 +392,7 @@ bool SettingsTab::isPortFree() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] path The path of the local cache.
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::setDiskCachePath(const QString &path)
|
||||
{
|
||||
void SettingsTab::setDiskCachePath(const QString &path) {
|
||||
ui_.editDiskCachePath->setText(path);
|
||||
}
|
||||
|
||||
@ -433,8 +400,7 @@ void SettingsTab::setDiskCachePath(const QString &path)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The disk cache path.
|
||||
//****************************************************************************************************************************************************
|
||||
QString SettingsTab::diskCachePath() const
|
||||
{
|
||||
QString SettingsTab::diskCachePath() const {
|
||||
return ui_.editDiskCachePath->text();
|
||||
}
|
||||
|
||||
@ -442,8 +408,7 @@ QString SettingsTab::diskCachePath() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'Next Cache Change Will Succeed' check box.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::nextCacheChangeWillSucceed() const
|
||||
{
|
||||
bool SettingsTab::nextCacheChangeWillSucceed() const {
|
||||
return ui_.checkNextCacheChangeWillSucceed->isChecked();
|
||||
}
|
||||
|
||||
@ -451,8 +416,7 @@ bool SettingsTab::nextCacheChangeWillSucceed() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The index of the selected cache error.
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 SettingsTab::cacheError() const
|
||||
{
|
||||
qint32 SettingsTab::cacheError() const {
|
||||
return ui_.comboCacheError->currentIndex();
|
||||
}
|
||||
|
||||
@ -460,8 +424,7 @@ qint32 SettingsTab::cacheError() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return the value for the 'Automatic Update' check.
|
||||
//****************************************************************************************************************************************************
|
||||
bool SettingsTab::isAutomaticUpdateOn() const
|
||||
{
|
||||
bool SettingsTab::isAutomaticUpdateOn() const {
|
||||
return ui_.checkAutomaticUpdate->isChecked();
|
||||
}
|
||||
|
||||
@ -469,8 +432,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) {
|
||||
ui_.checkAutomaticUpdate->setChecked(on);
|
||||
}
|
||||
|
||||
@ -478,8 +440,7 @@ void SettingsTab::setIsAutomaticUpdateOn(bool on)
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void SettingsTab::resetUI()
|
||||
{
|
||||
void SettingsTab::resetUI() {
|
||||
this->setGUIReady(false);
|
||||
this->setIsStreaming(false);
|
||||
this->setClientPlatform("Unknown");
|
||||
@ -503,8 +464,7 @@ void SettingsTab::resetUI()
|
||||
|
||||
QString const filePath = QDir(tmpDir).absoluteFilePath("LICENSE.txt");
|
||||
QFile file(filePath);
|
||||
if (!file.exists())
|
||||
{
|
||||
if (!file.exists()) {
|
||||
// we don't really care if it fails.
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
file.write(QString("This is were the license should be.").toLocal8Bit());
|
||||
|
||||
@ -26,8 +26,7 @@
|
||||
//****************************************************************************************************************************************************
|
||||
/// \brief The 'General' tab of the main window.
|
||||
//****************************************************************************************************************************************************
|
||||
class SettingsTab : public QWidget
|
||||
{
|
||||
class SettingsTab : public QWidget {
|
||||
Q_OBJECT
|
||||
public: // member functions.
|
||||
explicit SettingsTab(QWidget *parent = nullptr); ///< Default constructor.
|
||||
@ -79,7 +78,7 @@ public slots:
|
||||
void setColorSchemeName(QString const &name); ///< 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 exportTLSCertificates(QString const& folderPath); ///< Export the TLS certificates.
|
||||
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.
|
||||
|
||||
@ -32,15 +32,15 @@ using namespace bridgepp;
|
||||
//****************************************************************************************************************************************************
|
||||
UsersTab::UsersTab(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, users_(nullptr)
|
||||
{
|
||||
, users_(nullptr) {
|
||||
ui_.setupUi(this);
|
||||
|
||||
ui_.tableUserList->setModel(&users_);
|
||||
|
||||
QItemSelectionModel *model = ui_.tableUserList->selectionModel();
|
||||
if (!model)
|
||||
if (!model) {
|
||||
throw Exception("Could not get user table selection model.");
|
||||
}
|
||||
connect(model, &QItemSelectionModel::selectionChanged, this, &UsersTab::onSelectionChanged);
|
||||
|
||||
ui_.tableUserList->setColumnWidth(0, 150);
|
||||
@ -62,62 +62,65 @@ UsersTab::UsersTab(QWidget *parent)
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onAddUserButton()
|
||||
{
|
||||
void UsersTab::onAddUserButton() {
|
||||
SPUser user = randomUser();
|
||||
UserDialog dialog(user, this);
|
||||
if (QDialog::Accepted != dialog.exec())
|
||||
if (QDialog::Accepted != dialog.exec()) {
|
||||
return;
|
||||
}
|
||||
users_.append(user);
|
||||
GRPCService &grpc = app().grpc();
|
||||
if (grpc.isStreaming())
|
||||
if (grpc.isStreaming()) {
|
||||
grpc.sendEvent(newLoginFinishedEvent(user->id()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onEditUserButton()
|
||||
{
|
||||
void UsersTab::onEditUserButton() {
|
||||
int index = selectedIndex();
|
||||
if ((index < 0) || (index >= users_.userCount()))
|
||||
if ((index < 0) || (index >= users_.userCount())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SPUser user = this->selectedUser();
|
||||
UserDialog dialog(user, this);
|
||||
if (QDialog::Accepted != dialog.exec())
|
||||
if (QDialog::Accepted != dialog.exec()) {
|
||||
return;
|
||||
}
|
||||
|
||||
users_.touch(index);
|
||||
GRPCService &grpc = app().grpc();
|
||||
if (grpc.isStreaming())
|
||||
if (grpc.isStreaming()) {
|
||||
grpc.sendEvent(newUserChangedEvent(user->id()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onRemoveUserButton()
|
||||
{
|
||||
void UsersTab::onRemoveUserButton() {
|
||||
int index = selectedIndex();
|
||||
if ((index < 0) || (index >= users_.userCount()))
|
||||
if ((index < 0) || (index >= users_.userCount())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SPUser const user = users_.userAtIndex(index);
|
||||
users_.remove(index);
|
||||
GRPCService &grpc = app().grpc();
|
||||
if (grpc.isStreaming())
|
||||
if (grpc.isStreaming()) {
|
||||
grpc.sendEvent(newUserChangedEvent(user->id()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::onSelectionChanged(QItemSelection, QItemSelection)
|
||||
{
|
||||
void UsersTab::onSelectionChanged(QItemSelection, QItemSelection) {
|
||||
this->updateGUIState();
|
||||
}
|
||||
|
||||
@ -125,8 +128,7 @@ void UsersTab::onSelectionChanged(QItemSelection, QItemSelection)
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::updateGUIState()
|
||||
{
|
||||
void UsersTab::updateGUIState() {
|
||||
bool const hasSelectedUser = ui_.tableUserList->selectionModel()->hasSelection();
|
||||
ui_.buttonEditUser->setEnabled(hasSelectedUser);
|
||||
ui_.buttonRemoveUser->setEnabled(hasSelectedUser);
|
||||
@ -137,8 +139,7 @@ void UsersTab::updateGUIState()
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 UsersTab::selectedIndex() const
|
||||
{
|
||||
qint32 UsersTab::selectedIndex() const {
|
||||
return ui_.tableUserList->selectionModel()->hasSelection() ? ui_.tableUserList->currentIndex().row() : -1;
|
||||
}
|
||||
|
||||
@ -147,8 +148,7 @@ qint32 UsersTab::selectedIndex() const
|
||||
/// \return The selected user.
|
||||
/// \return A null pointer if no user is selected.
|
||||
//****************************************************************************************************************************************************
|
||||
bridgepp::SPUser UsersTab::selectedUser()
|
||||
{
|
||||
bridgepp::SPUser UsersTab::selectedUser() {
|
||||
return users_.userAtIndex(this->selectedIndex());
|
||||
}
|
||||
|
||||
@ -156,8 +156,7 @@ bridgepp::SPUser UsersTab::selectedUser()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The list of users.
|
||||
//****************************************************************************************************************************************************
|
||||
UserTable &UsersTab::userTable()
|
||||
{
|
||||
UserTable &UsersTab::userTable() {
|
||||
return users_;
|
||||
}
|
||||
|
||||
@ -167,8 +166,7 @@ UserTable &UsersTab::userTable()
|
||||
/// \return The user with the given userID.
|
||||
/// \return A null pointer if the user is not in the list.
|
||||
//****************************************************************************************************************************************************
|
||||
bridgepp::SPUser UsersTab::userWithID(QString const &userID)
|
||||
{
|
||||
bridgepp::SPUser UsersTab::userWithID(QString const &userID) {
|
||||
return users_.userWithID(userID);
|
||||
}
|
||||
|
||||
@ -176,8 +174,7 @@ bridgepp::SPUser UsersTab::userWithID(QString const &userID)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt should trigger a username/password error.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserUsernamePasswordError() const
|
||||
{
|
||||
bool UsersTab::nextUserUsernamePasswordError() const {
|
||||
return ui_.checkUsernamePasswordError->isChecked();
|
||||
}
|
||||
|
||||
@ -185,8 +182,7 @@ bool UsersTab::nextUserUsernamePasswordError() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt should trigger a free user error.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserFreeUserError() const
|
||||
{
|
||||
bool UsersTab::nextUserFreeUserError() const {
|
||||
return ui_.checkFreeUserError->isChecked();
|
||||
}
|
||||
|
||||
@ -194,8 +190,7 @@ bool UsersTab::nextUserFreeUserError() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt will require 2FA.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserTFARequired() const
|
||||
{
|
||||
bool UsersTab::nextUserTFARequired() const {
|
||||
return ui_.checkTFARequired->isChecked();
|
||||
}
|
||||
|
||||
@ -203,8 +198,7 @@ bool UsersTab::nextUserTFARequired() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt should trigger a 2FA error.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserTFAError() const
|
||||
{
|
||||
bool UsersTab::nextUserTFAError() const {
|
||||
return ui_.checkTFAError->isChecked();
|
||||
}
|
||||
|
||||
@ -212,8 +206,7 @@ bool UsersTab::nextUserTFAError() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt should trigger a 2FA error with abort.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserTFAAbort() const
|
||||
{
|
||||
bool UsersTab::nextUserTFAAbort() const {
|
||||
return ui_.checkTFAAbort->isChecked();
|
||||
}
|
||||
|
||||
@ -221,8 +214,7 @@ bool UsersTab::nextUserTFAAbort() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt will require a 2nd password.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserTwoPasswordsRequired() const
|
||||
{
|
||||
bool UsersTab::nextUserTwoPasswordsRequired() const {
|
||||
return ui_.checkTwoPasswordsRequired->isChecked();
|
||||
}
|
||||
|
||||
@ -230,8 +222,7 @@ bool UsersTab::nextUserTwoPasswordsRequired() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt should trigger a 2nd password error.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserTwoPasswordsError() const
|
||||
{
|
||||
bool UsersTab::nextUserTwoPasswordsError() const {
|
||||
return ui_.checkTwoPasswordsError->isChecked();
|
||||
}
|
||||
|
||||
@ -239,8 +230,7 @@ bool UsersTab::nextUserTwoPasswordsError() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt should trigger a 2nd password error with abort.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserTwoPasswordsAbort() const
|
||||
{
|
||||
bool UsersTab::nextUserTwoPasswordsAbort() const {
|
||||
return ui_.checkTwoPasswordsAbort->isChecked();
|
||||
}
|
||||
|
||||
@ -248,8 +238,7 @@ bool UsersTab::nextUserTwoPasswordsAbort() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the next login attempt should trigger a 2nd password error with abort.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UsersTab::nextUserAlreadyLoggedIn() const
|
||||
{
|
||||
bool UsersTab::nextUserAlreadyLoggedIn() const {
|
||||
return ui_.checkAlreadyLoggedIn->isChecked();
|
||||
}
|
||||
|
||||
@ -257,8 +246,7 @@ bool UsersTab::nextUserAlreadyLoggedIn() const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return the message for the username/password error.
|
||||
//****************************************************************************************************************************************************
|
||||
QString UsersTab::usernamePasswordErrorMessage() const
|
||||
{
|
||||
QString UsersTab::usernamePasswordErrorMessage() const {
|
||||
return ui_.editUsernamePasswordError->text();
|
||||
}
|
||||
|
||||
@ -267,12 +255,10 @@ QString UsersTab::usernamePasswordErrorMessage() const
|
||||
/// \param[in] userID The userID.
|
||||
/// \param[in] makeItActive Should split mode be activated.
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::setUserSplitMode(QString const &userID, bool makeItActive)
|
||||
{
|
||||
void UsersTab::setUserSplitMode(QString const &userID, bool makeItActive) {
|
||||
qint32 const index = users_.indexOfUser(userID);
|
||||
SPUser const user = users_.userAtIndex(index);
|
||||
if (!user)
|
||||
{
|
||||
if (!user) {
|
||||
app().log().error(QString("%1 failed. unknown user %1").arg(__FUNCTION__, userID));
|
||||
return;
|
||||
}
|
||||
@ -283,15 +269,14 @@ void UsersTab::setUserSplitMode(QString const &userID, bool makeItActive)
|
||||
mainWindow.sendDelayedEvent(newToggleSplitModeFinishedEvent(userID));
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] userID The userID.
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::logoutUser(QString const &userID)
|
||||
{
|
||||
void UsersTab::logoutUser(QString const &userID) {
|
||||
qint32 const index = users_.indexOfUser(userID);
|
||||
SPUser const user = users_.userAtIndex(index);
|
||||
if (!user)
|
||||
{
|
||||
if (!user) {
|
||||
app().log().error(QString("%1 failed. unknown user %1").arg(__FUNCTION__, userID));
|
||||
return;
|
||||
}
|
||||
@ -304,12 +289,10 @@ void UsersTab::logoutUser(QString const &userID)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] userID The userID.
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::removeUser(QString const &userID)
|
||||
{
|
||||
void UsersTab::removeUser(QString const &userID) {
|
||||
qint32 const index = users_.indexOfUser(userID);
|
||||
SPUser const user = users_.userAtIndex(index);
|
||||
if (!user)
|
||||
{
|
||||
if (!user) {
|
||||
app().log().error(QString("%1 failed. unknown user %1").arg(__FUNCTION__, userID));
|
||||
return;
|
||||
}
|
||||
@ -322,8 +305,7 @@ void UsersTab::removeUser(QString const &userID)
|
||||
/// \param[in] userID The userID.
|
||||
/// \param[in] address The address.
|
||||
//****************************************************************************************************************************************************
|
||||
void UsersTab::configureUserAppleMail(QString const &userID, QString const &address)
|
||||
{
|
||||
void UsersTab::configureUserAppleMail(QString const &userID, QString const &address) {
|
||||
app().log().info(QString("Apple mail configuration was requested for user %1, address %2").arg(userID, address));
|
||||
|
||||
}
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
//****************************************************************************************************************************************************
|
||||
/// \brief The 'Users' tab of the main window.
|
||||
//****************************************************************************************************************************************************
|
||||
class UsersTab : public QWidget
|
||||
{
|
||||
class UsersTab : public QWidget {
|
||||
Q_OBJECT
|
||||
public: // member functions.
|
||||
explicit UsersTab(QWidget *parent = nullptr); ///< Default constructor.
|
||||
|
||||
@ -28,8 +28,7 @@ using namespace bridgepp;
|
||||
//****************************************************************************************************************************************************
|
||||
UserDialog::UserDialog(bridgepp::SPUser &user, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, user_(user)
|
||||
{
|
||||
, user_(user) {
|
||||
ui_.setupUi(this);
|
||||
|
||||
connect(ui_.buttonOK, &QPushButton::clicked, this, &UserDialog::onOK);
|
||||
@ -51,8 +50,7 @@ UserDialog::UserDialog(bridgepp::SPUser &user, QWidget *parent)
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
void UserDialog::onOK()
|
||||
{
|
||||
void UserDialog::onOK() {
|
||||
user_->setID(ui_.editUserID->text());
|
||||
user_->setUsername(ui_.editUsername->text());
|
||||
user_->setPassword(ui_.editPassword->text());
|
||||
@ -71,8 +69,7 @@ void UserDialog::onOK()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The user state that is currently selected in the dialog.
|
||||
//****************************************************************************************************************************************************
|
||||
UserState UserDialog::state()
|
||||
{
|
||||
UserState UserDialog::state() {
|
||||
return UserState(ui_.comboState->currentIndex());
|
||||
}
|
||||
|
||||
@ -80,7 +77,6 @@ UserState UserDialog::state()
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] state The user state to select in the dialog.
|
||||
//****************************************************************************************************************************************************
|
||||
void UserDialog::setState(UserState state)
|
||||
{
|
||||
void UserDialog::setState(UserState state) {
|
||||
ui_.comboState->setCurrentIndex(qint32(state));
|
||||
}
|
||||
|
||||
@ -23,11 +23,11 @@
|
||||
#include "ui_UserDialog.h"
|
||||
#include <bridgepp/User/User.h>
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \brief User dialog class.
|
||||
//****************************************************************************************************************************************************
|
||||
class UserDialog : public QDialog
|
||||
{
|
||||
class UserDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public: // member functions.
|
||||
UserDialog(bridgepp::SPUser &user, QWidget *parent); ///< Default constructor.
|
||||
|
||||
@ -26,8 +26,7 @@ using namespace bridgepp;
|
||||
/// \param[in] parent The parent object of the class
|
||||
//****************************************************************************************************************************************************
|
||||
UserTable::UserTable(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
: QAbstractTableModel(parent) {
|
||||
|
||||
}
|
||||
|
||||
@ -35,8 +34,7 @@ UserTable::UserTable(QObject *parent)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The number of rows in the table.
|
||||
//****************************************************************************************************************************************************
|
||||
int UserTable::rowCount(QModelIndex const &) const
|
||||
{
|
||||
int UserTable::rowCount(QModelIndex const &) const {
|
||||
return users_.size();
|
||||
}
|
||||
|
||||
@ -44,8 +42,7 @@ int UserTable::rowCount(QModelIndex const &) const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The number of columns in the table.
|
||||
//****************************************************************************************************************************************************
|
||||
int UserTable::columnCount(QModelIndex const &) const
|
||||
{
|
||||
int UserTable::columnCount(QModelIndex const &) const {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@ -55,18 +52,18 @@ int UserTable::columnCount(QModelIndex const &) const
|
||||
/// \param[in] role The role to retrieve data for.
|
||||
/// \return The data for the role at the given index.
|
||||
//****************************************************************************************************************************************************
|
||||
QVariant UserTable::data(QModelIndex const &index, int role) const
|
||||
{
|
||||
QVariant UserTable::data(QModelIndex const &index, int role) const {
|
||||
int const row = index.row();
|
||||
if ((row < 0) || (row >= users_.size()) || (Qt::DisplayRole != role))
|
||||
if ((row < 0) || (row >= users_.size()) || (Qt::DisplayRole != role)) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
SPUser const user = users_[row];
|
||||
if (!user)
|
||||
if (!user) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
return user->property("username");
|
||||
case 1:
|
||||
@ -86,16 +83,16 @@ QVariant UserTable::data(QModelIndex const &index, int role) const
|
||||
/// \param[in] orientation The orientation.
|
||||
/// \param[in] role The role to retrieve data
|
||||
//****************************************************************************************************************************************************
|
||||
QVariant UserTable::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (Qt::DisplayRole != role)
|
||||
QVariant UserTable::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if (Qt::DisplayRole != role) {
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
if (Qt::Horizontal != orientation)
|
||||
if (Qt::Horizontal != orientation) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
switch (section)
|
||||
{
|
||||
switch (section) {
|
||||
case 0:
|
||||
return "UserName";
|
||||
case 1:
|
||||
@ -113,8 +110,7 @@ QVariant UserTable::headerData(int section, Qt::Orientation orientation, int rol
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] user The user to add.
|
||||
//****************************************************************************************************************************************************
|
||||
void UserTable::append(SPUser const &user)
|
||||
{
|
||||
void UserTable::append(SPUser const &user) {
|
||||
qint32 const count = users_.size();
|
||||
this->beginInsertRows(QModelIndex(), count, count);
|
||||
users_.append(user);
|
||||
@ -125,8 +121,7 @@ void UserTable::append(SPUser const &user)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The number of users in the table.
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 UserTable::userCount() const
|
||||
{
|
||||
qint32 UserTable::userCount() const {
|
||||
return users_.count();
|
||||
}
|
||||
|
||||
@ -136,8 +131,7 @@ qint32 UserTable::userCount() const
|
||||
/// \return the user at the given index.
|
||||
/// \return null if the index is out of bounds.
|
||||
//****************************************************************************************************************************************************
|
||||
bridgepp::SPUser UserTable::userAtIndex(qint32 index)
|
||||
{
|
||||
bridgepp::SPUser UserTable::userAtIndex(qint32 index) {
|
||||
return isIndexValid(index) ? users_[index] : nullptr;
|
||||
}
|
||||
|
||||
@ -146,9 +140,8 @@ bridgepp::SPUser UserTable::userAtIndex(qint32 index)
|
||||
/// \return The user with the given userID.
|
||||
/// \return A null pointer if the user is not in the list.
|
||||
//****************************************************************************************************************************************************
|
||||
bridgepp::SPUser UserTable::userWithID(QString const &userID)
|
||||
{
|
||||
QList<SPUser>::const_iterator it = std::find_if(users_.constBegin(), users_.constEnd(), [&userID](SPUser const& user) -> bool {
|
||||
bridgepp::SPUser UserTable::userWithID(QString const &userID) {
|
||||
QList<SPUser>::const_iterator it = std::find_if(users_.constBegin(), users_.constEnd(), [&userID](SPUser const &user) -> bool {
|
||||
return user->id() == userID;
|
||||
});
|
||||
|
||||
@ -161,9 +154,8 @@ bridgepp::SPUser UserTable::userWithID(QString const &userID)
|
||||
/// \return the index of the user.
|
||||
/// \return -1 if the user could not be found.
|
||||
//****************************************************************************************************************************************************
|
||||
qint32 UserTable::indexOfUser(QString const &userID)
|
||||
{
|
||||
QList<SPUser>::const_iterator it = std::find_if(users_.constBegin(), users_.constEnd(), [&userID](SPUser const& user) -> bool {
|
||||
qint32 UserTable::indexOfUser(QString const &userID) {
|
||||
QList<SPUser>::const_iterator it = std::find_if(users_.constBegin(), users_.constEnd(), [&userID](SPUser const &user) -> bool {
|
||||
return user->id() == userID;
|
||||
});
|
||||
|
||||
@ -174,20 +166,19 @@ qint32 UserTable::indexOfUser(QString const &userID)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] index The index of the user in the list.
|
||||
//****************************************************************************************************************************************************
|
||||
void UserTable::touch(qint32 index)
|
||||
{
|
||||
void UserTable::touch(qint32 index) {
|
||||
if (isIndexValid(index))
|
||||
emit dataChanged(this->index(index, 0), this->index(index, this->columnCount(QModelIndex()) - 1));
|
||||
emit { dataChanged(this->index(index, 0), this->index(index, this->columnCount(QModelIndex()) - 1)); }
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] index The index of the user in the list.
|
||||
//****************************************************************************************************************************************************
|
||||
void UserTable::remove(qint32 index)
|
||||
{
|
||||
if (!isIndexValid(index))
|
||||
void UserTable::remove(qint32 index) {
|
||||
if (!isIndexValid(index)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->beginRemoveRows(QModelIndex(), index, index);
|
||||
users_.removeAt(index);
|
||||
@ -198,8 +189,7 @@ void UserTable::remove(qint32 index)
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return true iff the index is valid.
|
||||
//****************************************************************************************************************************************************
|
||||
bool UserTable::isIndexValid(qint32 index) const
|
||||
{
|
||||
bool UserTable::isIndexValid(qint32 index) const {
|
||||
return (index >= 0) && (index < users_.count());
|
||||
}
|
||||
|
||||
@ -207,7 +197,6 @@ bool UserTable::isIndexValid(qint32 index) const
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The user list.
|
||||
//****************************************************************************************************************************************************
|
||||
QList<bridgepp::SPUser> UserTable::users() const
|
||||
{
|
||||
QList<bridgepp::SPUser> UserTable::users() const {
|
||||
return users_;
|
||||
}
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
/// \brief User table model class
|
||||
//****************************************************************************************************************************************************
|
||||
|
||||
class UserTable : public QAbstractTableModel
|
||||
{
|
||||
class UserTable : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public: // member functions.
|
||||
explicit UserTable(QObject *parent); ///< Default constructor.
|
||||
@ -38,10 +37,10 @@ public: // member functions.
|
||||
UserTable &operator=(UserTable const &) = delete; ///< Disabled assignment operator.
|
||||
UserTable &operator=(UserTable &&) = delete; ///< Disabled move assignment operator.
|
||||
qint32 userCount() const; ///< Return the number of users in the table.
|
||||
void append(bridgepp::SPUser const& user); ///< Append a user.
|
||||
void append(bridgepp::SPUser const &user); ///< Append a user.
|
||||
bridgepp::SPUser userAtIndex(qint32 index); ///< Return the user at the given index.
|
||||
bridgepp::SPUser userWithID(QString const &userID); ///< Return the user with a given id.
|
||||
qint32 indexOfUser(QString const& userID); ///< Return the index of a given User.
|
||||
qint32 indexOfUser(QString const &userID); ///< Return the index of a given User.
|
||||
void touch(qint32 index); ///< touch the user at a given index (indicates it has been modified).
|
||||
void remove(qint32 index); ///< Remove the user at a given index.
|
||||
QList<bridgepp::SPUser> users() const; ///< Return a copy of the user list.
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
|
||||
|
||||
QString const applicationName = "Proton Mail Bridge GUI Tester"; ///< The name of the application.
|
||||
@ -46,18 +45,16 @@ using namespace bridgepp;
|
||||
/// \param[in] argv The list of command-line arguments.
|
||||
/// \return The exit code for the application.
|
||||
//****************************************************************************************************************************************************
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setApplicationName(applicationName);
|
||||
QApplication::setOrganizationName("Proton AG");
|
||||
QApplication::setOrganizationDomain("proton.ch");
|
||||
QApplication::setQuitOnLastWindowClosed(true);
|
||||
|
||||
Log& log = app().log();
|
||||
Log &log = app().log();
|
||||
log.setEchoInConsole(true);
|
||||
log.setLevel(Log::Level::Debug);
|
||||
log.info(QString("%1 started.").arg(applicationName));
|
||||
@ -70,21 +67,24 @@ int main(int argc, char **argv)
|
||||
auto *serverWorker = new GRPCServerWorker(nullptr);
|
||||
QObject::connect(serverWorker, &Worker::started, []() { app().log().info("Server worker started."); });
|
||||
QObject::connect(serverWorker, &Worker::finished, []() { app().log().info("Server worker finished."); });
|
||||
QObject::connect(serverWorker, &Worker::error, [&](QString const &message) { app().log().error(message); qApp->exit(EXIT_FAILURE); });
|
||||
QObject::connect(serverWorker, &Worker::error, [&](QString const &message) {
|
||||
app().log().error(message);
|
||||
qApp->exit(EXIT_FAILURE);
|
||||
});
|
||||
UPOverseer overseer = std::make_unique<Overseer>(serverWorker, nullptr);
|
||||
overseer->startWorker(true);
|
||||
|
||||
qint32 const exitCode = QApplication::exec();
|
||||
|
||||
serverWorker->stop();
|
||||
if (!overseer->wait(5000))
|
||||
if (!overseer->wait(5000)) {
|
||||
log.warn("gRPC server took too long to finish.");
|
||||
}
|
||||
|
||||
app().log().info(QString("%1 exiting with code %2.").arg(applicationName).arg(exitCode));
|
||||
return exitCode;
|
||||
}
|
||||
catch (Exception const &e)
|
||||
{
|
||||
catch (Exception const &e) {
|
||||
QTextStream(stderr) << QString("A fatal error occurred: %1\n").arg(e.qwhat());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user