refactor: remove unused arch profileDir
This commit is contained in:
parent
b051c5ae60
commit
377272e917
12 changed files with 2 additions and 103 deletions
|
|
@ -46,14 +46,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual std::string getInstalledDirectory() = 0;
|
virtual std::string getInstalledDirectory() = 0;
|
||||||
|
|
||||||
//! Get user's profile directory
|
|
||||||
/*!
|
|
||||||
Returns the user's profile directory. If no profile directory is set,
|
|
||||||
this will return the user's profile according to the operating system,
|
|
||||||
which will depend on which user launched the program.
|
|
||||||
*/
|
|
||||||
virtual std::string getProfileDirectory() = 0;
|
|
||||||
|
|
||||||
//! Concatenate path components
|
//! Concatenate path components
|
||||||
/*!
|
/*!
|
||||||
Concatenate pathname components with a directory separator
|
Concatenate pathname components with a directory separator
|
||||||
|
|
@ -62,11 +54,4 @@ public:
|
||||||
system calls to tell us that.
|
system calls to tell us that.
|
||||||
*/
|
*/
|
||||||
virtual std::string concatPath(const std::string &prefix, const std::string &suffix) = 0;
|
virtual std::string concatPath(const std::string &prefix, const std::string &suffix) = 0;
|
||||||
|
|
||||||
//@}
|
|
||||||
//! Set the user's profile directory
|
|
||||||
/*
|
|
||||||
Returns the user's profile directory.
|
|
||||||
*/
|
|
||||||
virtual void setProfileDirectory(const std::string &s) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -86,25 +86,6 @@ std::string ArchFileUnix::getInstalledDirectory()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ArchFileUnix::getProfileDirectory()
|
|
||||||
{
|
|
||||||
if (!m_profileDirectory.empty()) {
|
|
||||||
return m_profileDirectory;
|
|
||||||
} else {
|
|
||||||
const std::filesystem::path homeDir = getUserDirectory();
|
|
||||||
#if WINAPI_XWINDOWS
|
|
||||||
const auto xdgDir = std::getenv("XDG_CONFIG_HOME");
|
|
||||||
if (xdgDir != nullptr) {
|
|
||||||
return std::filesystem::path(xdgDir) / kAppName;
|
|
||||||
} else {
|
|
||||||
return homeDir / ".config" / kAppName;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return homeDir / "Library" / kAppName;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ArchFileUnix::concatPath(const std::string &prefix, const std::string &suffix)
|
std::string ArchFileUnix::concatPath(const std::string &prefix, const std::string &suffix)
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
|
|
@ -116,8 +97,3 @@ std::string ArchFileUnix::concatPath(const std::string &prefix, const std::strin
|
||||||
path += suffix;
|
path += suffix;
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchFileUnix::setProfileDirectory(const std::string &s)
|
|
||||||
{
|
|
||||||
m_profileDirectory = s;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,5 @@ public:
|
||||||
virtual std::string getUserDirectory();
|
virtual std::string getUserDirectory();
|
||||||
virtual std::string getSystemDirectory();
|
virtual std::string getSystemDirectory();
|
||||||
virtual std::string getInstalledDirectory();
|
virtual std::string getInstalledDirectory();
|
||||||
virtual std::string getProfileDirectory();
|
|
||||||
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
|
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
|
||||||
virtual void setProfileDirectory(const std::string &s);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_profileDirectory;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -114,22 +114,6 @@ std::string ArchFileWindows::getInstalledDirectory()
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ArchFileWindows::getProfileDirectory()
|
|
||||||
{
|
|
||||||
std::string dir;
|
|
||||||
if (!m_profileDirectory.empty()) {
|
|
||||||
dir = m_profileDirectory;
|
|
||||||
} else {
|
|
||||||
TCHAR result[MAX_PATH];
|
|
||||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, result))) {
|
|
||||||
dir = result;
|
|
||||||
} else {
|
|
||||||
dir = getUserDirectory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ArchFileWindows::concatPath(const std::string &prefix, const std::string &suffix)
|
std::string ArchFileWindows::concatPath(const std::string &prefix, const std::string &suffix)
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
|
|
@ -141,8 +125,3 @@ std::string ArchFileWindows::concatPath(const std::string &prefix, const std::st
|
||||||
path += suffix;
|
path += suffix;
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchFileWindows::setProfileDirectory(const std::string &s)
|
|
||||||
{
|
|
||||||
m_profileDirectory = s;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,5 @@ public:
|
||||||
virtual std::string getUserDirectory();
|
virtual std::string getUserDirectory();
|
||||||
virtual std::string getSystemDirectory();
|
virtual std::string getSystemDirectory();
|
||||||
virtual std::string getInstalledDirectory();
|
virtual std::string getInstalledDirectory();
|
||||||
virtual std::string getProfileDirectory();
|
|
||||||
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
|
virtual std::string concatPath(const std::string &prefix, const std::string &suffix);
|
||||||
virtual void setProfileDirectory(const std::string &s);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_profileDirectory;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -175,8 +175,6 @@ void App::initApp(int argc, const char **argv)
|
||||||
parseArgs(argc, argv);
|
parseArgs(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
ARCH->setProfileDirectory(argsBase().m_profileDirectory);
|
|
||||||
|
|
||||||
// set log filter
|
// set log filter
|
||||||
if (!CLOG->setFilter(argsBase().m_logFilter)) {
|
if (!CLOG->setFilter(argsBase().m_logFilter)) {
|
||||||
LOG((
|
LOG((
|
||||||
|
|
|
||||||
|
|
@ -215,10 +215,6 @@ bool ArgParser::parseGenericArgs(int argc, const char *const *argv, int &i)
|
||||||
}
|
}
|
||||||
} else if (isArg(i, argc, argv, nullptr, "--enable-crypto")) {
|
} else if (isArg(i, argc, argv, nullptr, "--enable-crypto")) {
|
||||||
argsBase().m_enableCrypto = true;
|
argsBase().m_enableCrypto = true;
|
||||||
} else if (isArg(i, argc, argv, nullptr, "--profile-dir", 1)) {
|
|
||||||
argsBase().m_profileDirectory = argv[++i];
|
|
||||||
} else if (isArg(i, argc, argv, nullptr, "--plugin-dir", 1)) {
|
|
||||||
argsBase().m_pluginDirectory = argv[++i];
|
|
||||||
} else if (isArg(i, argc, argv, nullptr, "--tls-cert", 1)) {
|
} else if (isArg(i, argc, argv, nullptr, "--tls-cert", 1)) {
|
||||||
argsBase().m_tlsCertFile = argv[++i];
|
argsBase().m_tlsCertFile = argv[++i];
|
||||||
} else if (isArg(i, argc, argv, nullptr, "--prevent-sleep")) {
|
} else if (isArg(i, argc, argv, nullptr, "--prevent-sleep")) {
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,6 @@ public:
|
||||||
/// @brief Should the connections be TLS encrypted
|
/// @brief Should the connections be TLS encrypted
|
||||||
bool m_enableCrypto = false;
|
bool m_enableCrypto = false;
|
||||||
|
|
||||||
/// @brief The dir to load settings from
|
|
||||||
std::string m_profileDirectory;
|
|
||||||
|
|
||||||
/// @brief The dir to load plugins from
|
|
||||||
std::string m_pluginDirectory;
|
|
||||||
|
|
||||||
/// @brief Contains the location of the TLS certificate file
|
/// @brief Contains the location of the TLS certificate file
|
||||||
std::string m_tlsCertFile;
|
std::string m_tlsCertFile;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,11 +130,6 @@ bool CoreProcess::Deps::fileExists(const QString &path) const
|
||||||
return QFile::exists(path);
|
return QFile::exists(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CoreProcess::Deps::getProfileRoot() const
|
|
||||||
{
|
|
||||||
return Settings::settingsPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// CoreProcess
|
// CoreProcess
|
||||||
//
|
//
|
||||||
|
|
@ -494,14 +489,6 @@ bool CoreProcess::addGenericArgs(QStringList &args, const ProcessMode processMod
|
||||||
args << "--enable-crypto";
|
args << "--enable-crypto";
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
// on windows, the profile directory changes depending on the user that
|
|
||||||
// launched the process (e.g. when launched with elevation). setting the
|
|
||||||
// profile dir on launch ensures it uses the same profile dir is used
|
|
||||||
// no matter how its relaunched.
|
|
||||||
args << "--profile-dir" << m_pDeps->getProfileRoot();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (Settings::value(Settings::Core::PreventSleep).toBool()) {
|
if (Settings::value(Settings::Core::PreventSleep).toBool()) {
|
||||||
args << "--prevent-sleep";
|
args << "--prevent-sleep";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ public:
|
||||||
}
|
}
|
||||||
virtual QString appPath(const QString &name) const;
|
virtual QString appPath(const QString &name) const;
|
||||||
virtual bool fileExists(const QString &path) const;
|
virtual bool fileExists(const QString &path) const;
|
||||||
virtual QString getProfileRoot() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QProcessProxy m_process;
|
QProcessProxy m_process;
|
||||||
|
|
|
||||||
|
|
@ -73,14 +73,11 @@ TEST(ClientArgsParsingTests, parseClientArgs_setCommonArgs)
|
||||||
ON_CALL(argParser, checkUnexpectedArgs()).WillByDefault(Invoke(client_stubCheckUnexpectedArgs));
|
ON_CALL(argParser, checkUnexpectedArgs()).WillByDefault(Invoke(client_stubCheckUnexpectedArgs));
|
||||||
deskflow::ClientArgs clientArgs;
|
deskflow::ClientArgs clientArgs;
|
||||||
clientArgs.m_enableLangSync = false;
|
clientArgs.m_enableLangSync = false;
|
||||||
const int argc = 7;
|
const int argc = 5;
|
||||||
std::array<const char *, argc> kLangCmd = {"stub", "--enable-crypto", "--profile-dir", "profileDir",
|
std::array<const char *, argc> kLangCmd = {"stub", "--enable-crypto", "--tls-cert", "tlsCertPath", "--prevent-sleep"};
|
||||||
"--tls-cert", "tlsCertPath", "--prevent-sleep"};
|
|
||||||
|
|
||||||
argParser.parseClientArgs(clientArgs, argc, kLangCmd.data());
|
argParser.parseClientArgs(clientArgs, argc, kLangCmd.data());
|
||||||
|
|
||||||
EXPECT_TRUE(clientArgs.m_enableCrypto);
|
EXPECT_TRUE(clientArgs.m_enableCrypto);
|
||||||
EXPECT_EQ(clientArgs.m_profileDirectory, "profileDir");
|
|
||||||
EXPECT_EQ(clientArgs.m_tlsCertFile, "tlsCertPath");
|
EXPECT_EQ(clientArgs.m_tlsCertFile, "tlsCertPath");
|
||||||
EXPECT_TRUE(clientArgs.m_preventSleep);
|
EXPECT_TRUE(clientArgs.m_preventSleep);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,13 +51,11 @@ public:
|
||||||
ON_CALL(*this, process()).WillByDefault(ReturnRef(m_process));
|
ON_CALL(*this, process()).WillByDefault(ReturnRef(m_process));
|
||||||
ON_CALL(*this, appPath(_)).WillByDefault(Return("stub app path"));
|
ON_CALL(*this, appPath(_)).WillByDefault(Return("stub app path"));
|
||||||
ON_CALL(*this, fileExists(_)).WillByDefault(Return(true));
|
ON_CALL(*this, fileExists(_)).WillByDefault(Return(true));
|
||||||
ON_CALL(*this, getProfileRoot()).WillByDefault(Return("stub profile"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MOCK_METHOD(proxy::QProcessProxy &, process, (), (override));
|
MOCK_METHOD(proxy::QProcessProxy &, process, (), (override));
|
||||||
MOCK_METHOD(QString, appPath, (const QString &name), (const, override));
|
MOCK_METHOD(QString, appPath, (const QString &name), (const, override));
|
||||||
MOCK_METHOD(bool, fileExists, (const QString &path), (const, override));
|
MOCK_METHOD(bool, fileExists, (const QString &path), (const, override));
|
||||||
MOCK_METHOD(QString, getProfileRoot, (), (const, override));
|
|
||||||
|
|
||||||
NiceMock<QProcessProxyMock> m_process;
|
NiceMock<QProcessProxyMock> m_process;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue