2015-02-25 17:19:33 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
2024-07-26 22:53:52 +00:00
|
|
|
* Copyright (C) 2015 Symless Ltd.
|
2015-02-25 17:19:33 +00:00
|
|
|
*
|
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2015-05-03 02:33:52 +00:00
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
2015-02-25 17:19:33 +00:00
|
|
|
*
|
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2024-08-07 14:05:18 +00:00
|
|
|
#include "gui/core/CoreTool.h"
|
2015-02-25 17:19:33 +00:00
|
|
|
|
2015-10-29 18:42:16 +00:00
|
|
|
#include "CommandProcess.h"
|
|
|
|
|
|
2015-02-25 17:19:33 +00:00
|
|
|
#include <QCoreApplication>
|
2024-07-02 19:07:06 +00:00
|
|
|
#include <QDir>
|
2015-02-25 17:19:33 +00:00
|
|
|
#include <QProcess>
|
2016-10-13 13:49:53 +00:00
|
|
|
#include <QtGlobal>
|
2015-02-25 17:19:33 +00:00
|
|
|
|
|
|
|
|
static const char kCoreBinary[] = "syntool";
|
|
|
|
|
|
2016-10-13 13:49:53 +00:00
|
|
|
#ifdef Q_WS_WIN
|
|
|
|
|
static const char kSerialKeyFilename[] = "Synergy.subkey";
|
|
|
|
|
#else
|
|
|
|
|
static const char kSerialKeyFilename[] = ".synergy.subkey";
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-08-07 14:05:18 +00:00
|
|
|
QString CoreTool::getProfileDir() const {
|
2024-07-02 19:07:06 +00:00
|
|
|
QStringList args("--get-profile-dir");
|
2024-07-22 16:48:02 +00:00
|
|
|
return QDir::cleanPath(run(args));
|
2015-02-25 17:19:33 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-07 14:05:18 +00:00
|
|
|
QString CoreTool::getInstalledDir() const {
|
2024-07-02 19:07:06 +00:00
|
|
|
QStringList args("--get-installed-dir");
|
2024-07-22 16:48:02 +00:00
|
|
|
return QDir::cleanPath(run(args));
|
2015-06-01 23:43:57 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-07 14:05:18 +00:00
|
|
|
QString CoreTool::getArch() const {
|
2024-07-02 19:07:06 +00:00
|
|
|
QStringList args("--get-arch");
|
|
|
|
|
return run(args);
|
2015-02-25 17:19:33 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-07 14:05:18 +00:00
|
|
|
QString CoreTool::getSerialKeyFilePath() const {
|
2024-07-22 16:48:02 +00:00
|
|
|
auto filename = getProfileDir() + QDir::separator() + kSerialKeyFilename;
|
|
|
|
|
return QDir::cleanPath(filename);
|
2015-10-23 22:37:16 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-07 14:05:18 +00:00
|
|
|
QString CoreTool::run(const QStringList &args, const QString &input) const {
|
2024-07-02 19:07:06 +00:00
|
|
|
QString program(QCoreApplication::applicationDirPath() + "/" + kCoreBinary);
|
2015-02-25 17:19:33 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
CommandProcess commandProcess(program, args, input);
|
|
|
|
|
return commandProcess.run();
|
2015-02-25 17:19:33 +00:00
|
|
|
}
|