added the ability to work with an online repository
* added a command line argument for the application, when called, cached profiles will be cleared
This commit is contained in:
parent
6f53abbae3
commit
03599e4da7
10 changed files with 96 additions and 36 deletions
|
|
@ -197,16 +197,27 @@ bool AmneziaApplication::parseCommands()
|
|||
m_parser.addHelpOption();
|
||||
m_parser.addVersionOption();
|
||||
|
||||
QCommandLineOption c_autostart {{"a", "autostart"}, "System autostart"};
|
||||
m_parser.addOption(c_autostart);
|
||||
|
||||
QCommandLineOption c_cleanup {{"c", "cleanup"}, "Cleanup logs"};
|
||||
m_parser.addOption(c_cleanup);
|
||||
m_parser.addOption(m_autoStartOption);
|
||||
m_parser.addOption(m_cleanUpOption);
|
||||
m_parser.addOption(m_clearProfilesOption);
|
||||
|
||||
m_parser.process(*this);
|
||||
|
||||
if (m_parser.isSet(c_cleanup)) {
|
||||
if (m_parser.isSet(m_cleanUpOption)) {
|
||||
Logger::cleanUp();
|
||||
QTimer::singleShot(100, this, [this]{
|
||||
quit();
|
||||
});
|
||||
exec();
|
||||
return false;
|
||||
} else if (m_parser.isSet(m_clearProfilesOption)) {
|
||||
for (int i = 0; i < m_settings->serversCount(); i++) {
|
||||
const auto &containers = m_settings->containers(i).keys();
|
||||
for (DockerContainer container : containers) {
|
||||
m_settings->clearLastConnectionConfig(i, container);
|
||||
}
|
||||
}
|
||||
|
||||
QTimer::singleShot(100, this, [this]{
|
||||
quit();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,7 +55,11 @@ private:
|
|||
ProtocolProps* m_protocolProps {};
|
||||
|
||||
QTranslator* m_translator;
|
||||
|
||||
QCommandLineParser m_parser;
|
||||
QCommandLineOption m_autoStartOption {{"a", "autoStart"}, tr("System autostart")};
|
||||
QCommandLineOption m_cleanUpOption {{"c", "cleanUp"}, tr("Cleanup logs")};
|
||||
QCommandLineOption m_clearProfilesOption {"clearProfiles", tr("Clear client cached profile")};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ int main(int argc, char *argv[])
|
|||
app.loadTranslator();
|
||||
app.loadFonts();
|
||||
|
||||
bool doExec = app.parseCommands();
|
||||
bool runGuiApplication = app.parseCommands();
|
||||
|
||||
if (doExec) {
|
||||
if (runGuiApplication) {
|
||||
app.init();
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
var requestToQuitFromApp = false;
|
||||
var updaterCompleted = 0;
|
||||
var desktopAppProcessRunning = false;
|
||||
var appInstalledUninstallerPath;
|
||||
var appInstalledUninstallerPath_x86;
|
||||
|
||||
function appName()
|
||||
{
|
||||
|
|
@ -18,18 +16,20 @@ function appExecutableFileName()
|
|||
}
|
||||
}
|
||||
|
||||
function appInstalled()
|
||||
function pathToMaintenanceTool()
|
||||
{
|
||||
if (runningOnWindows()) {
|
||||
appInstalledUninstallerPath = installer.value("RootDir") + "Program Files/AmneziaVPN/maintenancetool.exe";
|
||||
appInstalledUninstallerPath_x86 = installer.value("RootDir") + "Program Files (x86)/AmneziaVPN/maintenancetool.exe";
|
||||
return installer.value("TargetDir") + "/maintenancetool.exe";
|
||||
} else if (runningOnMacOS()) {
|
||||
appInstalledUninstallerPath = "/Applications/" + appName() + ".app/maintenancetool.app/Contents/MacOS/maintenancetool";
|
||||
return installer.value("TargetDir") + "/maintenancetool.app/Contents/MacOS/maintenancetool";
|
||||
} else if (runningOnLinux()) {
|
||||
appInstalledUninstallerPath = "/opt/" + appName() + "/maintenancetool";
|
||||
return installer.value("TargetDir") + "/maintenancetool";
|
||||
}
|
||||
}
|
||||
|
||||
return installer.fileExists(appInstalledUninstallerPath) || installer.fileExists(appInstalledUninstallerPath_x86);
|
||||
function appInstalled()
|
||||
{
|
||||
return installer.fileExists(pathToMaintenanceTool());
|
||||
}
|
||||
|
||||
function endsWith(str, suffix)
|
||||
|
|
@ -259,18 +259,13 @@ function Controller () {
|
|||
qsTr("We need to remove the old installation first. Do you wish to proceed?"),
|
||||
QMessageBox.Ok | QMessageBox.Cancel)) {
|
||||
|
||||
|
||||
if (appInstalled()) {
|
||||
var resultArray = [];
|
||||
|
||||
if (installer.fileExists(appInstalledUninstallerPath_x86)) {
|
||||
console.log("Starting uninstallation " + appInstalledUninstallerPath_x86);
|
||||
resultArray = installer.execute(appInstalledUninstallerPath_x86);
|
||||
}
|
||||
|
||||
if (installer.fileExists(appInstalledUninstallerPath)) {
|
||||
console.log("Starting uninstallation " + appInstalledUninstallerPath);
|
||||
resultArray = installer.execute(appInstalledUninstallerPath);
|
||||
if (installer.fileExists(pathToMaintenanceTool())) {
|
||||
console.log("Starting uninstallation " + pathToMaintenanceTool());
|
||||
var args = ["--sr"];
|
||||
resultArray = installer.execute(pathToMaintenanceTool(), args);
|
||||
}
|
||||
|
||||
console.log("Uninstaller finished with code: " + resultArray[1])
|
||||
|
|
|
|||
|
|
@ -13,13 +13,12 @@
|
|||
<AllowSpaceInPath>true</AllowSpaceInPath>
|
||||
<AllowNonAsciiCharacters>false</AllowNonAsciiCharacters>
|
||||
<ControlScript>controlscript.js</ControlScript>
|
||||
<RepositorySettingsPageVisible>false</RepositorySettingsPageVisible>
|
||||
<DependsOnLocalInstallerBinary>true</DependsOnLocalInstallerBinary>
|
||||
<SupportsModify>false</SupportsModify>
|
||||
<DisableAuthorizationFallback>true</DisableAuthorizationFallback>
|
||||
<RemoteRepositories>
|
||||
<Repository>
|
||||
<Url>https://amneziavpn.org/updates/linux</Url>
|
||||
<Url>http://localhost/repository</Url>
|
||||
<Enabled>true</Enabled>
|
||||
<DisplayName>AmneziaVPN - repository for Linux</DisplayName>
|
||||
</Repository>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
<AllowSpaceInPath>true</AllowSpaceInPath>
|
||||
<AllowNonAsciiCharacters>false</AllowNonAsciiCharacters>
|
||||
<ControlScript>controlscript.js</ControlScript>
|
||||
<RepositorySettingsPageVisible>false</RepositorySettingsPageVisible>
|
||||
<DependsOnLocalInstallerBinary>true</DependsOnLocalInstallerBinary>
|
||||
<SupportsModify>false</SupportsModify>
|
||||
<DisableAuthorizationFallback>true</DisableAuthorizationFallback>
|
||||
|
|
|
|||
|
|
@ -13,8 +13,14 @@
|
|||
<AllowSpaceInPath>true</AllowSpaceInPath>
|
||||
<AllowNonAsciiCharacters>false</AllowNonAsciiCharacters>
|
||||
<ControlScript>controlscript.js</ControlScript>
|
||||
<RepositorySettingsPageVisible>false</RepositorySettingsPageVisible>
|
||||
<DependsOnLocalInstallerBinary>true</DependsOnLocalInstallerBinary>
|
||||
<SupportsModify>false</SupportsModify>
|
||||
<DisableAuthorizationFallback>true</DisableAuthorizationFallback>
|
||||
<RemoteRepositories>
|
||||
<Repository>
|
||||
<Url>http://localhost/repository</Url>
|
||||
<Enabled>1</Enabled>
|
||||
<DisplayName>AmneziaVPN - repository for Windows</DisplayName>
|
||||
</Repository>
|
||||
</RemoteRepositories>
|
||||
</Installer>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ClearProfilesCheckboxForm</class>
|
||||
<widget class="QWidget" name="ClearProfilesCheckboxForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ClearProfilesCheckbox">
|
||||
<property name="text">
|
||||
<string>Clear client cached profiles</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -47,7 +47,11 @@ function Component()
|
|||
|
||||
Component.prototype.componentLoaded = function ()
|
||||
{
|
||||
|
||||
console.log("123");
|
||||
// if (installer.isPackageManager()) {
|
||||
installer.addWizardPageItem( component, "ClearProfilesCheckboxForm", QInstaller.ComponentSelection );
|
||||
console.log("333");
|
||||
// }
|
||||
}
|
||||
|
||||
Component.prototype.installationFinishedPageIsShown = function()
|
||||
|
|
@ -62,7 +66,6 @@ Component.prototype.createOperations = function()
|
|||
component.createOperations();
|
||||
|
||||
if (runningOnWindows()) {
|
||||
|
||||
component.addOperation("CreateShortcut", "@TargetDir@/" + appExecutableFileName(),
|
||||
QDesktopServices.storageLocation(QDesktopServices.DesktopLocation) + "/" + appName() + ".lnk",
|
||||
"workingDirectory=@TargetDir@", "iconPath=@TargetDir@\\" + appExecutableFileName(), "iconId=0");
|
||||
|
|
@ -100,7 +103,6 @@ Component.prototype.createOperations = function()
|
|||
Component.prototype.installationFinished = function()
|
||||
{
|
||||
var command = "";
|
||||
var args = [];
|
||||
|
||||
if ((installer.status === QInstaller.Success) && (installer.isInstaller() || installer.isUpdater())) {
|
||||
|
||||
|
|
@ -126,6 +128,16 @@ Component.prototype.installationFinished = function()
|
|||
|
||||
installer.dropAdminRights()
|
||||
|
||||
if (installer.isUninstaller() || installer.isUpdater()) {
|
||||
var checkboxForm = component.userInterface( "ClearProfilesCheckboxForm" );
|
||||
if (checkboxForm && checkboxForm.ClearProfilesCheckbox.checked) {
|
||||
var args = ["--clearProfiles"];
|
||||
processStatus = installer.execute(command, args, installer.value("TargetDir"));
|
||||
}
|
||||
}
|
||||
|
||||
var args = [];
|
||||
processStatus = installer.executeDetached(command, args, installer.value("TargetDir"));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,4 +8,7 @@
|
|||
<ForcedInstallation>true</ForcedInstallation>
|
||||
<RequiresAdminRights>true</RequiresAdminRights>
|
||||
<Script>componentscript.js</Script>
|
||||
<UserInterfaces>
|
||||
<UserInterface>clearProfilesCheckboxForm.ui</UserInterface>
|
||||
</UserInterfaces>
|
||||
</Package>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue