diff --git a/src/lib/arch/IArchFile.h b/src/lib/arch/IArchFile.h index 60bbde856..cc8776203 100644 --- a/src/lib/arch/IArchFile.h +++ b/src/lib/arch/IArchFile.h @@ -46,14 +46,6 @@ public: */ 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 pathname components with a directory separator @@ -62,11 +54,4 @@ public: system calls to tell us that. */ 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; }; diff --git a/src/lib/arch/unix/ArchFileUnix.cpp b/src/lib/arch/unix/ArchFileUnix.cpp index f4658f693..cb23c06aa 100644 --- a/src/lib/arch/unix/ArchFileUnix.cpp +++ b/src/lib/arch/unix/ArchFileUnix.cpp @@ -86,25 +86,6 @@ std::string ArchFileUnix::getInstalledDirectory() #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 path; @@ -116,8 +97,3 @@ std::string ArchFileUnix::concatPath(const std::string &prefix, const std::strin path += suffix; return path; } - -void ArchFileUnix::setProfileDirectory(const std::string &s) -{ - m_profileDirectory = s; -} diff --git a/src/lib/arch/unix/ArchFileUnix.h b/src/lib/arch/unix/ArchFileUnix.h index d5bad352d..6b3d43d0d 100644 --- a/src/lib/arch/unix/ArchFileUnix.h +++ b/src/lib/arch/unix/ArchFileUnix.h @@ -23,10 +23,5 @@ public: virtual std::string getUserDirectory(); virtual std::string getSystemDirectory(); virtual std::string getInstalledDirectory(); - virtual std::string getProfileDirectory(); virtual std::string concatPath(const std::string &prefix, const std::string &suffix); - virtual void setProfileDirectory(const std::string &s); - -private: - std::string m_profileDirectory; }; diff --git a/src/lib/arch/win32/ArchFileWindows.cpp b/src/lib/arch/win32/ArchFileWindows.cpp index 77db18bdb..33965178a 100644 --- a/src/lib/arch/win32/ArchFileWindows.cpp +++ b/src/lib/arch/win32/ArchFileWindows.cpp @@ -114,22 +114,6 @@ std::string ArchFileWindows::getInstalledDirectory() 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 path; @@ -141,8 +125,3 @@ std::string ArchFileWindows::concatPath(const std::string &prefix, const std::st path += suffix; return path; } - -void ArchFileWindows::setProfileDirectory(const std::string &s) -{ - m_profileDirectory = s; -} diff --git a/src/lib/arch/win32/ArchFileWindows.h b/src/lib/arch/win32/ArchFileWindows.h index 2d22e78b0..1e6d58d72 100644 --- a/src/lib/arch/win32/ArchFileWindows.h +++ b/src/lib/arch/win32/ArchFileWindows.h @@ -23,10 +23,5 @@ public: virtual std::string getUserDirectory(); virtual std::string getSystemDirectory(); virtual std::string getInstalledDirectory(); - virtual std::string getProfileDirectory(); virtual std::string concatPath(const std::string &prefix, const std::string &suffix); - virtual void setProfileDirectory(const std::string &s); - -private: - std::string m_profileDirectory; }; diff --git a/src/lib/deskflow/App.cpp b/src/lib/deskflow/App.cpp index 8270ffd97..5b5f5d4bf 100644 --- a/src/lib/deskflow/App.cpp +++ b/src/lib/deskflow/App.cpp @@ -175,8 +175,6 @@ void App::initApp(int argc, const char **argv) parseArgs(argc, argv); } - ARCH->setProfileDirectory(argsBase().m_profileDirectory); - // set log filter if (!CLOG->setFilter(argsBase().m_logFilter)) { LOG(( diff --git a/src/lib/deskflow/ArgParser.cpp b/src/lib/deskflow/ArgParser.cpp index c022a6808..bc0b1faf4 100644 --- a/src/lib/deskflow/ArgParser.cpp +++ b/src/lib/deskflow/ArgParser.cpp @@ -215,10 +215,6 @@ bool ArgParser::parseGenericArgs(int argc, const char *const *argv, int &i) } } else if (isArg(i, argc, argv, nullptr, "--enable-crypto")) { 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)) { argsBase().m_tlsCertFile = argv[++i]; } else if (isArg(i, argc, argv, nullptr, "--prevent-sleep")) { diff --git a/src/lib/deskflow/ArgsBase.h b/src/lib/deskflow/ArgsBase.h index 5e84a00ed..42b5ef3bd 100644 --- a/src/lib/deskflow/ArgsBase.h +++ b/src/lib/deskflow/ArgsBase.h @@ -74,12 +74,6 @@ public: /// @brief Should the connections be TLS encrypted 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 std::string m_tlsCertFile; diff --git a/src/lib/gui/core/CoreProcess.cpp b/src/lib/gui/core/CoreProcess.cpp index 8c339650e..163b9dc05 100644 --- a/src/lib/gui/core/CoreProcess.cpp +++ b/src/lib/gui/core/CoreProcess.cpp @@ -130,11 +130,6 @@ bool CoreProcess::Deps::fileExists(const QString &path) const return QFile::exists(path); } -QString CoreProcess::Deps::getProfileRoot() const -{ - return Settings::settingsPath(); -} - // // CoreProcess // @@ -494,14 +489,6 @@ bool CoreProcess::addGenericArgs(QStringList &args, const ProcessMode processMod 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()) { args << "--prevent-sleep"; } diff --git a/src/lib/gui/core/CoreProcess.h b/src/lib/gui/core/CoreProcess.h index 91ab14e7e..fba64a684 100644 --- a/src/lib/gui/core/CoreProcess.h +++ b/src/lib/gui/core/CoreProcess.h @@ -44,7 +44,6 @@ public: } virtual QString appPath(const QString &name) const; virtual bool fileExists(const QString &path) const; - virtual QString getProfileRoot() const; private: QProcessProxy m_process; diff --git a/src/test/unittests/deskflow/ClientArgsParsingTests.cpp b/src/test/unittests/deskflow/ClientArgsParsingTests.cpp index 714adac16..f9813639d 100644 --- a/src/test/unittests/deskflow/ClientArgsParsingTests.cpp +++ b/src/test/unittests/deskflow/ClientArgsParsingTests.cpp @@ -73,14 +73,11 @@ TEST(ClientArgsParsingTests, parseClientArgs_setCommonArgs) ON_CALL(argParser, checkUnexpectedArgs()).WillByDefault(Invoke(client_stubCheckUnexpectedArgs)); deskflow::ClientArgs clientArgs; clientArgs.m_enableLangSync = false; - const int argc = 7; - std::array kLangCmd = {"stub", "--enable-crypto", "--profile-dir", "profileDir", - "--tls-cert", "tlsCertPath", "--prevent-sleep"}; - + const int argc = 5; + std::array kLangCmd = {"stub", "--enable-crypto", "--tls-cert", "tlsCertPath", "--prevent-sleep"}; argParser.parseClientArgs(clientArgs, argc, kLangCmd.data()); EXPECT_TRUE(clientArgs.m_enableCrypto); - EXPECT_EQ(clientArgs.m_profileDirectory, "profileDir"); EXPECT_EQ(clientArgs.m_tlsCertFile, "tlsCertPath"); EXPECT_TRUE(clientArgs.m_preventSleep); } diff --git a/src/test/unittests/gui/core/CoreProcessTests.cpp b/src/test/unittests/gui/core/CoreProcessTests.cpp index 3575ec32d..ebcf27602 100644 --- a/src/test/unittests/gui/core/CoreProcessTests.cpp +++ b/src/test/unittests/gui/core/CoreProcessTests.cpp @@ -51,13 +51,11 @@ public: ON_CALL(*this, process()).WillByDefault(ReturnRef(m_process)); ON_CALL(*this, appPath(_)).WillByDefault(Return("stub app path")); ON_CALL(*this, fileExists(_)).WillByDefault(Return(true)); - ON_CALL(*this, getProfileRoot()).WillByDefault(Return("stub profile")); } MOCK_METHOD(proxy::QProcessProxy &, process, (), (override)); MOCK_METHOD(QString, appPath, (const QString &name), (const, override)); MOCK_METHOD(bool, fileExists, (const QString &path), (const, override)); - MOCK_METHOD(QString, getProfileRoot, (), (const, override)); NiceMock m_process; };