/* SPDX-FileCopyrightText: 2011 Viranch Mehta SPDX-FileCopyrightText: 2019 Harald Sitter SPDX-License-Identifier: LGPL-2.0-only */ #include "hotplugjob.h" #include "deviceserviceaction.h" #include #include #include #include void HotplugJob::start() { if (operationName() == QLatin1String("invokeAction")) { const QString desktopFile = parameters()[QStringLiteral("predicate")].toString(); const QString filePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "solid/actions/" + desktopFile); QList services = KDesktopFileActions::userDefinedServices(KService(filePath), true); if (services.size() < 1) { qWarning() << "Failed to resolve hotplugjob action" << desktopFile << filePath; setError(KJob::UserDefinedError); setErrorText(i18nc("error; %1 is the desktop file name of the service", "Failed to resolve service action for %1.", desktopFile)); setResult(false); // calls emitResult internally. return; } // Cannot be > 1, we only have one filePath, and < 1 was handled as error. Q_ASSERT(services.size() == 1); DeviceServiceAction action; action.setService(services.takeFirst()); Solid::Device device(m_dest); action.execute(device); } emitResult(); }