fix: Delete HKEY_LOCAL_MACHINE\SOFTWARE\Deskflow when clearing settings
This commit is contained in:
parent
9de268d293
commit
b64942e3a3
18 changed files with 73 additions and 1 deletions
|
|
@ -99,6 +99,10 @@ int main(int argc, char **argv)
|
||||||
&ipcServer, &ipc::DaemonIpcServer::stopProcessRequested, &daemon, &DaemonApp::clearWatchdogCommand, //
|
&ipcServer, &ipc::DaemonIpcServer::stopProcessRequested, &daemon, &DaemonApp::clearWatchdogCommand, //
|
||||||
Qt::DirectConnection
|
Qt::DirectConnection
|
||||||
);
|
);
|
||||||
|
QObject::connect(
|
||||||
|
&ipcServer, &ipc::DaemonIpcServer::clearSettingsRequested, &daemon, &DaemonApp::clearSettings, //
|
||||||
|
Qt::DirectConnection
|
||||||
|
);
|
||||||
|
|
||||||
daemonThread.start();
|
daemonThread.start();
|
||||||
const auto exitCode = QCoreApplication::exec();
|
const auto exitCode = QCoreApplication::exec();
|
||||||
|
|
|
||||||
|
|
@ -459,6 +459,7 @@ void MainWindow::clearSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_coreProcess.stop();
|
m_coreProcess.stop();
|
||||||
|
m_coreProcess.clearSettings();
|
||||||
|
|
||||||
m_saveOnExit = false;
|
m_saveOnExit = false;
|
||||||
diagnostic::clearSettings(m_configScopes, true);
|
diagnostic::clearSettings(m_configScopes, true);
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,11 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void setting(const std::string &valueName, const std::string &valueString) const = 0;
|
virtual void setting(const std::string &valueName, const std::string &valueString) const = 0;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
//! Delete settings
|
||||||
|
/*!
|
||||||
|
Deletes all Core settings from the system.
|
||||||
|
*/
|
||||||
|
virtual void clearSettings() const = 0;
|
||||||
|
//@}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,11 @@ void ArchSystemUnix::setting(const std::string &, const std::string &) const
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArchSystemUnix::clearSettings() const
|
||||||
|
{
|
||||||
|
// Not implemented
|
||||||
|
}
|
||||||
|
|
||||||
std::string ArchSystemUnix::getLibsUsed(void) const
|
std::string ArchSystemUnix::getLibsUsed(void) const
|
||||||
{
|
{
|
||||||
return "not implemented.\nuse lsof on shell";
|
return "not implemented.\nuse lsof on shell";
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ public:
|
||||||
virtual std::string setting(const std::string &) const;
|
virtual std::string setting(const std::string &) const;
|
||||||
virtual void setting(const std::string &, const std::string &) const;
|
virtual void setting(const std::string &, const std::string &) const;
|
||||||
virtual std::string getLibsUsed(void) const;
|
virtual std::string getLibsUsed(void) const;
|
||||||
|
virtual void clearSettings() const;
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
enum class InhibitScreenServices
|
enum class InhibitScreenServices
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,15 @@ void ArchMiscWindows::deleteValue(HKEY key, const TCHAR *name)
|
||||||
RegDeleteValue(key, name);
|
RegDeleteValue(key, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArchMiscWindows::deleteKeyTree(HKEY key, const TCHAR *name)
|
||||||
|
{
|
||||||
|
assert(key != NULL);
|
||||||
|
assert(name != NULL);
|
||||||
|
if (key == NULL || name == NULL)
|
||||||
|
return;
|
||||||
|
RegDeleteTree(key, name);
|
||||||
|
}
|
||||||
|
|
||||||
bool ArchMiscWindows::hasValue(HKEY key, const TCHAR *name)
|
bool ArchMiscWindows::hasValue(HKEY key, const TCHAR *name)
|
||||||
{
|
{
|
||||||
DWORD type;
|
DWORD type;
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,9 @@ public:
|
||||||
//! Delete a value
|
//! Delete a value
|
||||||
static void deleteValue(HKEY parent, const TCHAR *name);
|
static void deleteValue(HKEY parent, const TCHAR *name);
|
||||||
|
|
||||||
|
//! Delete a tree of keys from the registry
|
||||||
|
static void deleteKeyTree(HKEY parent, const TCHAR *name);
|
||||||
|
|
||||||
//! Test if a value exists
|
//! Test if a value exists
|
||||||
static bool hasValue(HKEY key, const TCHAR *name);
|
static bool hasValue(HKEY key, const TCHAR *name);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include "arch/win32/ArchMiscWindows.h"
|
#include "arch/win32/ArchMiscWindows.h"
|
||||||
|
|
||||||
#include "arch/XArch.h"
|
#include "arch/XArch.h"
|
||||||
|
#include "base/Log.h"
|
||||||
#include "common/constants.h"
|
#include "common/constants.h"
|
||||||
|
|
||||||
#include "tchar.h"
|
#include "tchar.h"
|
||||||
|
|
@ -17,7 +18,7 @@
|
||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
static const char *s_settingsKeyNames[] = {_T("SOFTWARE"), _T(kAppName), NULL};
|
static const TCHAR *s_settingsKeyNames[] = {_T("SOFTWARE"), _T(kAppName), NULL};
|
||||||
|
|
||||||
//
|
//
|
||||||
// ArchSystemWindows
|
// ArchSystemWindows
|
||||||
|
|
@ -86,6 +87,11 @@ void ArchSystemWindows::setting(const std::string &valueName, const std::string
|
||||||
ArchMiscWindows::setValue(key, valueName.c_str(), valueString.c_str());
|
ArchMiscWindows::setValue(key, valueName.c_str(), valueString.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ArchSystemWindows::clearSettings() const
|
||||||
|
{
|
||||||
|
ArchMiscWindows::deleteKeyTree(HKEY_LOCAL_MACHINE, kWindowsRegistryKey);
|
||||||
|
}
|
||||||
|
|
||||||
bool ArchSystemWindows::isWOW64() const
|
bool ArchSystemWindows::isWOW64() const
|
||||||
{
|
{
|
||||||
#if WINVER >= _WIN32_WINNT_WINXP
|
#if WINVER >= _WIN32_WINNT_WINXP
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ public:
|
||||||
virtual std::string getPlatformName() const;
|
virtual std::string getPlatformName() const;
|
||||||
virtual std::string setting(const std::string &valueName) const;
|
virtual std::string setting(const std::string &valueName) const;
|
||||||
virtual void setting(const std::string &valueName, const std::string &valueString) const;
|
virtual void setting(const std::string &valueName, const std::string &valueString) const;
|
||||||
|
virtual void clearSettings() const;
|
||||||
|
|
||||||
bool isWOW64() const;
|
bool isWOW64() const;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ const auto kVersionGitSha = "@GIT_SHA_SHORT@";
|
||||||
const auto kDaemonBinName = "@CMAKE_PROJECT_NAME@-daemon";
|
const auto kDaemonBinName = "@CMAKE_PROJECT_NAME@-daemon";
|
||||||
const auto kDaemonIpcName = "@CMAKE_PROJECT_NAME@-daemon";
|
const auto kDaemonIpcName = "@CMAKE_PROJECT_NAME@-daemon";
|
||||||
const auto kDaemonLogFilename = "@CMAKE_PROJECT_NAME@-daemon.log";
|
const auto kDaemonLogFilename = "@CMAKE_PROJECT_NAME@-daemon.log";
|
||||||
|
const auto kWindowsRegistryKey = "SOFTWARE\\@CMAKE_PROJECT_PROPER_NAME@";
|
||||||
|
|
||||||
const auto kCopyright = //
|
const auto kCopyright = //
|
||||||
"Copyright @CMAKE_PROJECT_COPYRIGHT@\n"
|
"Copyright @CMAKE_PROJECT_COPYRIGHT@\n"
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,12 @@ void DaemonApp::clearWatchdogCommand()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DaemonApp::clearSettings()
|
||||||
|
{
|
||||||
|
LOG_INFO("clearing daemon settings");
|
||||||
|
ARCH->clearSettings();
|
||||||
|
}
|
||||||
|
|
||||||
DaemonApp::InitResult DaemonApp::init(IEventQueue *events, int argc, char **argv) // NOSONAR - CLI args
|
DaemonApp::InitResult DaemonApp::init(IEventQueue *events, int argc, char **argv) // NOSONAR - CLI args
|
||||||
{
|
{
|
||||||
using enum InitResult;
|
using enum InitResult;
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ public:
|
||||||
void setCommand(const QString &command);
|
void setCommand(const QString &command);
|
||||||
void applyWatchdogCommand() const;
|
void applyWatchdogCommand() const;
|
||||||
void clearWatchdogCommand();
|
void clearWatchdogCommand();
|
||||||
|
void clearSettings();
|
||||||
std::string logFilename();
|
std::string logFilename();
|
||||||
|
|
||||||
static DaemonApp &instance()
|
static DaemonApp &instance()
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,10 @@ void DaemonIpcServer::processMessage(QLocalSocket *clientSocket, const QString &
|
||||||
} else if (command == "logPath") {
|
} else if (command == "logPath") {
|
||||||
LOG_DEBUG("ipc server got log path request");
|
LOG_DEBUG("ipc server got log path request");
|
||||||
clientSocket->write("logPath=" + m_logFilename.toUtf8());
|
clientSocket->write("logPath=" + m_logFilename.toUtf8());
|
||||||
|
} else if (command == "clearSettings") {
|
||||||
|
LOG_DEBUG("ipc server got clear settings message");
|
||||||
|
Q_EMIT clearSettingsRequested();
|
||||||
|
clientSocket->write(kAckMessage);
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("ipc server got unknown message: %s", message.toUtf8().constData());
|
LOG_WARN("ipc server got unknown message: %s", message.toUtf8().constData());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ signals:
|
||||||
void commandChanged(const QString &command);
|
void commandChanged(const QString &command);
|
||||||
void startProcessRequested();
|
void startProcessRequested();
|
||||||
void stopProcessRequested();
|
void stopProcessRequested();
|
||||||
|
void clearSettingsRequested();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processMessage(QLocalSocket *clientSocket, const QString &message);
|
void processMessage(QLocalSocket *clientSocket, const QString &message);
|
||||||
|
|
|
||||||
|
|
@ -746,4 +746,19 @@ QString CoreProcess::requestDaemonLogPath()
|
||||||
return logPath;
|
return logPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoreProcess::clearSettings()
|
||||||
|
{
|
||||||
|
if (m_appConfig.processMode() == ProcessMode::kDesktop) {
|
||||||
|
qDebug("no core settings to clear in desktop mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_appConfig.processMode() != ProcessMode::kService) {
|
||||||
|
qFatal("invalid process mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
qInfo("clearing core settings through daemon");
|
||||||
|
m_daemonIpcClient->sendClearSettings();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace deskflow::gui
|
} // namespace deskflow::gui
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ public:
|
||||||
void restart();
|
void restart();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
void applyLogLevel();
|
void applyLogLevel();
|
||||||
|
void clearSettings();
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
Mode mode() const
|
Mode mode() const
|
||||||
|
|
|
||||||
|
|
@ -194,4 +194,9 @@ QString DaemonIpcClient::requestLogPath()
|
||||||
return parts[1];
|
return parts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DaemonIpcClient::sendClearSettings()
|
||||||
|
{
|
||||||
|
return sendMessage("clearSettings");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace deskflow::gui::ipc
|
} // namespace deskflow::gui::ipc
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ public:
|
||||||
bool sendLogLevel(const QString &logLevel);
|
bool sendLogLevel(const QString &logLevel);
|
||||||
bool sendStartProcess(const QString &command, ElevateMode elevateMode);
|
bool sendStartProcess(const QString &command, ElevateMode elevateMode);
|
||||||
bool sendStopProcess();
|
bool sendStopProcess();
|
||||||
|
bool sendClearSettings();
|
||||||
QString requestLogPath();
|
QString requestLogPath();
|
||||||
|
|
||||||
bool isConnected() const
|
bool isConnected() const
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue