remove syntool, CoreInterface, and WebClient

This commit is contained in:
walker0643
2018-03-29 17:14:57 -04:00
parent ea025f5958
commit 1be86a9248
13 changed files with 0 additions and 671 deletions

View File

@@ -1,96 +0,0 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* 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/>.
*/
#include "CoreInterface.h"
#include "CommandProcess.h"
#include "QUtility.h"
#include <QCoreApplication>
#include <QProcess>
#include <QtGlobal>
#include <QDir>
#include <stdexcept>
static const char kCoreBinary[] = "syntool";
#ifdef Q_WS_WIN
static const char kSerialKeyFilename[] = "Barrier.subkey";
#else
static const char kSerialKeyFilename[] = ".barrier.subkey";
#endif
CoreInterface::CoreInterface()
{
}
QString CoreInterface::getProfileDir()
{
QStringList args("--get-profile-dir");
return run(args);
}
QString CoreInterface::getInstalledDir()
{
QStringList args("--get-installed-dir");
return run(args);
}
QString CoreInterface::getArch()
{
QStringList args("--get-arch");
return run(args);
}
QString CoreInterface::getSerialKeyFilePath()
{
QString filename = getProfileDir() + QDir::separator() + kSerialKeyFilename;
return filename;
}
QString CoreInterface::notifyUpdate (QString const& fromVersion,
QString const& toVersion,
QString const& serialKey) {
QStringList args("--notify-update");
QString input(fromVersion + ":" + toVersion + ":" + serialKey);
input.append("\n");
return run(args, input);
}
QString CoreInterface::notifyActivation(const QString& identity)
{
QStringList args("--notify-activation");
QString input(identity + ":" + hash(getFirstMacAddress()));
QString os= getOSInformation();
if (!os.isEmpty()) {
input.append(":").append(os);
}
input.append("\n");
return run(args, input);
}
QString CoreInterface::run(const QStringList& args, const QString& input)
{
QString program(
QCoreApplication::applicationDirPath()
+ "/" + kCoreBinary);
CommandProcess commandProcess(program, args, input);
return commandProcess.run();
}

View File

@@ -1,36 +0,0 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* 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/>.
*/
#pragma once
#include <QString>
class CoreInterface
{
public:
CoreInterface();
QString getProfileDir();
QString getInstalledDir();
QString getArch();
QString getSerialKeyFilePath();
QString notifyActivation(const QString& identity);
QString notifyUpdate (QString const& fromVersion,
QString const& toVersion,
QString const& serialKey);
QString run(const QStringList& args, const QString& input = "");
};

View File

@@ -1,83 +0,0 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* 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/>.
*/
#include "WebClient.h"
#include "QUtility.h"
#include <QProcess>
#include <QMessageBox>
#include <QCoreApplication>
#include <stdexcept>
bool
WebClient::getEdition (int& edition, QString& errorOut) {
QString responseJson = request();
/* TODO: This is horrible and should be ripped out as soon as we move
* to Qt 5. See issue #5630
*/
QRegExp resultRegex(".*\"result\".*:.*(true|false).*");
if (resultRegex.exactMatch (responseJson)) {
QString boolString = resultRegex.cap(1);
if (boolString == "true") {
QRegExp editionRegex(".*\"edition\".*:.*\"([^\"]+)\".*");
if (editionRegex.exactMatch(responseJson)) {
QString e = editionRegex.cap(1);
edition = e.toInt();
return true;
} else {
throw std::runtime_error ("Unrecognised server response.");
}
} else {
errorOut = tr("Login failed. Invalid email address or password.");
return false;
}
} else {
QRegExp errorRegex(".*\"error\".*:.*\"([^\"]+)\".*");
if (errorRegex.exactMatch (responseJson)) {
errorOut = errorRegex.cap(1).replace("\\n", "\n");
return false;
} else {
throw std::runtime_error ("Unrecognised server response.");
}
}
}
bool
WebClient::setEmail (QString email, QString& errorOut) {
if (email.isEmpty()) {
errorOut = tr("Your email address cannot be left blank.");
return false;
}
m_Email = email;
return true;
}
bool
WebClient::setPassword (QString password, QString&) {
m_Password = password;
return true;
}
QString
WebClient::request() {
QStringList args("--login-auth");
QString credentials (m_Email + ":" + hash(m_Password) + "\n");
return m_CoreInterface.run (args, credentials);
}

View File

@@ -1,49 +0,0 @@
/*
* barrier -- mouse and keyboard sharing utility
* Copyright (C) 2015-2016 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* 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/>.
*/
#ifndef WEBCLIENT_H
#define WEBCLIENT_H
#include <QString>
#include <QObject>
#include "CoreInterface.h"
class QMessageBox;
class QWidget;
class QStringList;
class WebClient : public QObject
{
Q_OBJECT
public:
bool getEdition (int& edition, QString& errorOut);
bool setEmail (QString email, QString& errorOut);
bool setPassword (QString password, QString& errorOut);
signals:
void error(QString e);
private:
QString request();
QString m_Email;
QString m_Password;
CoreInterface m_CoreInterface;
};
#endif // WEBCLIENT_H