Verified Commit cc0e6b34 authored by azubieta's avatar azubieta
Browse files

Set target application name as the helper application name

parent 1cafb302
Pipeline #669 failed with stage
in 4 minutes and 27 seconds
......@@ -5,6 +5,7 @@ add_executable(
RemoveJob.cpp
InstallJob.cpp
UninstallJob.cpp
TargetDataLoader.cpp
)
target_link_libraries(plasma-appimage-integration appimageservices-interfaces KF5::KIOWidgets KF5::I18n KF5::Notifications)
......
// libraries
#include <QtWidgets/QApplication>
#include <utility>
// local
#include "InspectorInterface.h"
#include "TargetDataLoader.h"
TargetDataLoader::TargetDataLoader(QString target) : target(std::move(target)) {}
void TargetDataLoader::loadTargetDataIntoApplication() {
auto inspectorInterface = new OrgAppimageServices1InspectorInterface("org.appimage.Services1.Inspector",
"/org/appimage/Services1/Inspector",
QDBusConnection::sessionBus(), this);
auto reply = inspectorInterface->getApplicationInfo(target);
if (reply.isError())
qWarning() << "Unable to fetch AppImage information " << reply.error().message();
else {
QString response = reply.value();
QJsonDocument document = QJsonDocument::fromJson(response.toLocal8Bit());
QJsonObject root = document.object();
QString nameValue = root.value("name").toString();
if (!nameValue.isEmpty())
QApplication::setApplicationName(nameValue);
}
}
#pragma once
// libraries
#include <QtCore/QString>
#include <QtCore/QObject>
class TargetDataLoader : public QObject {
Q_OBJECT
public:
TargetDataLoader(QString target);
void loadTargetDataIntoApplication();
private:
QString target;
};
\ No newline at end of file
......@@ -13,6 +13,7 @@
#include "RemoveJob.h"
#include "InstallJob.h"
#include "UninstallJob.h"
#include "TargetDataLoader.h"
QString parseTarget(QCommandLineParser& parser) {
......@@ -90,21 +91,26 @@ int main(int argc, char** argv) {
if (command == "update") {
QString target = parseTarget(parser);
TargetDataLoader(target).loadTargetDataIntoApplication();
executeUpdateCommand(target);
}
if (command == "remove") {
QString target = parseTarget(parser);
TargetDataLoader(target).loadTargetDataIntoApplication();
executeRemoveCommand(target);
}
if (command == "install") {
QString target = parseTarget(parser);
TargetDataLoader(target).loadTargetDataIntoApplication();
executeInstallCommand(target);
}
if (command == "uninstall") {
QString target = parseTarget(parser);
TargetDataLoader(target).loadTargetDataIntoApplication();
executeUninstallCommand(target);
}
return QApplication::exec();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment