aboutsummaryrefslogtreecommitdiff
path: root/installer/process
diff options
context:
space:
mode:
Diffstat (limited to 'installer/process')
-rw-r--r--installer/process/installworker.cpp42
-rw-r--r--installer/process/installworker.h4
-rw-r--r--installer/process/removeworker.cpp24
-rw-r--r--installer/process/removeworker.h1
4 files changed, 68 insertions, 3 deletions
diff --git a/installer/process/installworker.cpp b/installer/process/installworker.cpp
index 5b44ad1..e7708ad 100644
--- a/installer/process/installworker.cpp
+++ b/installer/process/installworker.cpp
@@ -102,6 +102,48 @@ bool InstallWorker::startWork() {
dataRoot.insert("global", isGlobalInstall);
dataRoot.insert("appurl", url);
+ //Write uninstall information to registry
+ QUuid uuid = QUuid::createUuid();
+ dataRoot.insert("registryUuid", uuid.toString());
+ /*HKEY SoftwareEntry;
+ HKEY hive;
+ LPCWSTR keyPath = (LPCWSTR) QString("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + uuid.toString()).utf16();
+
+ if (isGlobalInstall) {
+ hive = HKEY_LOCAL_MACHINE;
+ } else {
+ hive = HKEY_CURRENT_USER;
+ }
+
+ LSTATUS createReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, keyPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &SoftwareEntry, NULL);
+ if (createReturn == ERROR_SUCCESS) {
+ RegSetValueEx(SoftwareEntry, TEXT("DisplayName"), 0, REG_SZ, (const BYTE*) vendor.toStdString().data(), vendor.count() + 1);
+
+ RegCloseKey(SoftwareEntry);
+
+ sock->write(QString("DEBUG Uninstall GUID: " + uuid.toString()).toUtf8());
+ } else {
+ sock->write(QString("ALERT " + tr("Error writing uninstall information to the registry: Error 0x%1").arg(QString::number(createReturn, 16)) + "\n").toUtf8());
+ }*/
+
+ QSettings* settings;
+ if (isGlobalInstall) {
+ settings = new QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + uuid.toString(), QSettings::NativeFormat);
+ } else {
+ settings = new QSettings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + uuid.toString(), QSettings::NativeFormat);
+ }
+
+ settings->setValue("DisplayName", name);
+ settings->setValue("Publisher", vendor);
+ settings->setValue("Contact", vendor);
+ settings->setValue("ModifyPath", dest.absoluteFilePath("uninstall.exe"));
+ settings->setValue("UninstallString", dest.absoluteFilePath("uninstall.exe"));
+ settings->setValue("InstallDate", QDateTime::currentDateTime().toString("yyyymmdd"));
+ settings->setValue("InstallLocation", dest.path());
+ settings->setValue("DisplayIcon", executableFile.absoluteFilePath() + ",0");
+ settings->sync();
+ settings->deleteLater();
+
QFile uninstallDataFile(dest.absoluteFilePath("uninstall.json"));
uninstallDataFile.open(QFile::WriteOnly);
uninstallDataFile.write(QJsonDocument(dataRoot).toJson());
diff --git a/installer/process/installworker.h b/installer/process/installworker.h
index c98763b..ea0db48 100644
--- a/installer/process/installworker.h
+++ b/installer/process/installworker.h
@@ -15,10 +15,12 @@
#include <QStandardPaths>
#include <QJsonDocument>
#include <QJsonObject>
+#include <QUuid>
+#include <QSettings>
#include <quazip/JlCompress.h>
-#include <iostream>
+#include <winreg.h>
class InstallWorker : public QObject
{
diff --git a/installer/process/removeworker.cpp b/installer/process/removeworker.cpp
index bdc1f64..2bca275 100644
--- a/installer/process/removeworker.cpp
+++ b/installer/process/removeworker.cpp
@@ -7,16 +7,19 @@ RemoveWorker::RemoveWorker(QObject *parent) : QObject(parent)
bool RemoveWorker::startWork() {
QLocalSocket* sock = new QLocalSocket();
+ QString metadataFilePath;
QString previousToken;
for (QString arg : QApplication::arguments()) {
if (previousToken != "") {
if (previousToken == "--socket") {
sock->setServerName(arg);
+ } else if (previousToken == "--uninstallmetadata") {
+ metadataFilePath = arg;
}
previousToken = "";
} else {
- if (arg == "--socket") {
+ if (arg == "--socket" || arg == "--uninstallmetadata") {
previousToken = arg;
}
}
@@ -27,6 +30,11 @@ bool RemoveWorker::startWork() {
return false;
}
+ if (metadataFilePath == "") {
+ qDebug() << "Required argument --uninstallmetadata missing";
+ return false;
+ }
+
qDebug() << "Connecting to socket server...";
sock->connectToServer();
if (!sock->waitForConnected()) {
@@ -38,9 +46,10 @@ bool RemoveWorker::startWork() {
QApplication::exit(1);
});
- QFile metadataFile(QApplication::applicationDirPath() + "/uninstall.json");
+ QFile metadataFile(metadataFilePath);
metadataFile.open(QFile::ReadOnly);
QJsonObject metadata = QJsonDocument::fromJson(metadataFile.readAll()).object();
+ metadataFile.close();
QString name = metadata.value("name").toString();
QString vendor = metadata.value("vendor").toString();
@@ -65,6 +74,17 @@ bool RemoveWorker::startWork() {
QDir dest(metadata.value("installPath").toString());
dest.removeRecursively();
+ //Remove registry entry
+
+ QSettings* settings;
+ if (metadata.value("global").toBool()) {
+ settings = new QSettings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", QSettings::NativeFormat);
+ } else {
+ settings = new QSettings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", QSettings::NativeFormat);
+ }
+ settings->remove(metadata.value("registryUuid").toString());
+ settings->sync();
+
sock->write("COMPLETE\n");
sock->flush();
sock->waitForBytesWritten();
diff --git a/installer/process/removeworker.h b/installer/process/removeworker.h
index aaa344a..9a73316 100644
--- a/installer/process/removeworker.h
+++ b/installer/process/removeworker.h
@@ -10,6 +10,7 @@
#include <QDir>
#include <QTimer>
#include <QStandardPaths>
+#include <QSettings>
class RemoveWorker : public QObject
{