Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add uninstaller checkbox #710

Draft
wants to merge 11 commits into
base: dev
Choose a base branch
from
8 changes: 7 additions & 1 deletion client/secure_qsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

using namespace QKeychain;

namespace {
constexpr auto settingsKeyTag{"settingsKeyTag"};
constexpr auto settingsIvTag{"settingsIvTag"};
constexpr auto keyChainName{"AmneziaVPN-Keychain"};
}

SecureQSettings::SecureQSettings(const QString &organization, const QString &application, QObject *parent)
: QObject { parent }, m_settings(organization, application, parent), encryptedKeys({ "Servers/serversList" })
{
Expand Down Expand Up @@ -50,7 +56,7 @@ QVariant SecureQSettings::value(const QString &key, const QVariant &defaultValue
// check if value is not encrypted, v. < 2.0.x
retVal = m_settings.value(key);
if (retVal.isValid()) {
if (retVal.userType() == QVariant::ByteArray && retVal.toByteArray().mid(0, magicString.size()) == magicString) {
if (retVal.userType() == QMetaType::QByteArray && retVal.toByteArray().mid(0, magicString.size()) == magicString) {

if (getEncKey().isEmpty() || getEncIv().isEmpty()) {
qCritical() << "SecureQSettings::setValue Decryption requested, but key is empty";
Expand Down
6 changes: 1 addition & 5 deletions client/secure_qsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

#include "keychain.h"

constexpr const char *settingsKeyTag = "settingsKeyTag";
constexpr const char *settingsIvTag = "settingsIvTag";
constexpr const char *keyChainName = "AmneziaVPN-Keychain";

class SecureQSettings : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -44,7 +40,7 @@ class SecureQSettings : public QObject
private:
QSettings m_settings;

mutable QMap<QString, QVariant> m_cache;
mutable QHash<QString, QVariant> m_cache;

QStringList encryptedKeys; // encode only key listed here

Expand Down
33 changes: 28 additions & 5 deletions deploy/installer/config/controlscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ Controller.prototype.FinishedPageCallback = function ()
installer.autoAcceptMessageBoxes();
gui.clickButton(buttons.FinishButton);
}

if (installer.isUninstaller()) {
var widget = gui.pageById(QInstaller.InstallationFinished);
if (widget) {
widget["RunItCheckBox"].visible = true;
widget["RunItCheckBox"].text = "Remove all settings and data";
gui.finishButtonClicked.connect(onFinishButtonClicked);
}
}
}

Controller.prototype.RestartPageCallback = function ()
Expand Down Expand Up @@ -215,11 +224,25 @@ onBrowseButtonClicked = function()
}
}

onNextButtonClicked = function()
{
var widget = gui.pageById(QInstaller.TargetDirectory);
if (widget !== null) {
installer.setValue("APP_BUNDLE_TARGET_DIR", widget.TargetDirectoryLineEdit.text);
onFinishButtonClicked = function() {
let widget = gui.pageById(QInstaller.InstallationFinished);
if (widget) {
let isChecked = widget["RunItCheckBox"].checked;

if (isChecked) {
if (runningOnWindows()) {
let cmdArgs = ["/C", "reg", "delete", "HKEY_CURRENT_USER\\Software\\AmneziaVPN.ORG", "/f"];
installer.execute("cmd", cmdArgs);
}
else if (runningOnMacOS()) {
let plistPath = QDesktopServices.storageLocation(QDesktopServices.HomeLocation) + "/Library/Preferences/org.amneziavpn.AmneziaVPN.plist";
installer.performOperation("Delete", [plistPath]);
}
else if (runningOnLinux()) {
let cmdArgs = ["-c", "rm -rf ~/.config/AmneziaVPN.ORG"];
installer.execute("/bin/bash", cmdArgs);
}
}
}
}

Expand Down