drop the solid runner

Summary:
- hasn't been installed for years and no one missed it
- not actually ported
- using tech we want to get rid of (soliduiserver)

Test Plan: workspace still builds

Reviewers: broulik

Reviewed By: broulik

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21747
wilder-5.17
Harald Sitter 7 years ago
parent 9efe2b4596
commit ec9709fdd2
  1. 1
      runners/CMakeLists.txt
  2. 13
      runners/solid/CMakeLists.txt
  3. 3
      runners/solid/Messages.sh
  4. 209
      runners/solid/devicewrapper.cpp
  5. 89
      runners/solid/devicewrapper.h
  6. 148
      runners/solid/plasma-runner-solid.desktop
  7. 285
      runners/solid/solidrunner.cpp
  8. 76
      runners/solid/solidrunner.h

@ -9,7 +9,6 @@ add_subdirectory(places)
add_subdirectory(services)
add_subdirectory(recentdocuments)
add_subdirectory(shell)
# add_subdirectory(solid)
add_subdirectory(webshortcuts)
add_subdirectory(windowedwidgets)

@ -1,13 +0,0 @@
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_solid\")
set(krunner_solid_SRCS
solidrunner.cpp
devicewrapper.cpp
)
add_library(krunner_solid MODULE ${krunner_solid_SRCS})
target_link_libraries(krunner_solid KF5::Plasma KF5::Solid KIOCore)
install(TARGETS krunner_solid DESTINATION ${KDE_INSTALL_PLUGINDIR} )
install(FILES plasma-runner-solid.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})

@ -1,3 +0,0 @@
#! /usr/bin/env bash
$XGETTEXT *.cpp -o $podir/plasma_runner_solid.pot

@ -1,209 +0,0 @@
/**************************************************************************
* Copyright 2009 by Jacopo De Simoi <wilderkde@gmail.com> *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
//own
#include "devicewrapper.h"
//Qt
#include <QAction>
#include <QTimer>
#include <QDBusInterface>
#include <QDBusReply>
//Solid
#include <Solid/Device>
#include <Solid/StorageVolume>
#include <Solid/StorageAccess>
#include <Solid/OpticalDrive>
#include <Solid/OpticalDisc>
//KDE
#include <KIcon>
#include <KMessageBox>
#include <KStandardDirs>
#include <kdesktopfileactions.h>
//Plasma
#include <Plasma/DataEngine>
DeviceWrapper::DeviceWrapper(const QString& udi)
: m_device(udi),
m_isStorageAccess(false),
m_isAccessible(false),
m_isEncryptedContainer(false)
{
m_udi = m_device.udi();
}
DeviceWrapper::~DeviceWrapper()
{
}
void DeviceWrapper::dataUpdated(const QString &source, Plasma::DataEngine::Data data)
{
Q_UNUSED(source)
if (data.isEmpty()) {
return;
}
if (data["text"].isValid()) {
m_actionIds.clear();
foreach (const QString &desktop, data["predicateFiles"].toStringList()) {
QString filePath = KStandardDirs::locate("data", "solid/actions/" + desktop);
QList<KServiceAction> services = KDesktopFileActions::userDefinedServices(filePath, true);
foreach (KServiceAction serviceAction, services) {
QString actionId = id()+'_'+desktop+'_'+serviceAction.name();
m_actionIds << actionId;
emit registerAction(actionId, serviceAction.icon(), serviceAction.text(), desktop);
}
}
m_isEncryptedContainer = data["isEncryptedContainer"].toBool();
} else {
if (data["Device Types"].toStringList().contains("Storage Access")) {
m_isStorageAccess = true;
if (data["Accessible"].toBool() == true) {
m_isAccessible = true;
} else {
m_isAccessible = false;
}
} else {
m_isStorageAccess = false;
}
if (data["Device Types"].toStringList().contains("OpticalDisc")) {
m_isOpticalDisc = true;
} else {
m_isOpticalDisc = false;
}
}
m_emblems = m_device.emblems();
m_description = m_device.description();
m_iconName = m_device.icon();
emit refreshMatch(m_udi);
}
QString DeviceWrapper::id() const {
return m_udi;
}
Solid::Device DeviceWrapper::device() const {
return m_device;
}
KIcon DeviceWrapper::icon() const {
return KIcon(m_iconName, nullptr, m_emblems);
}
bool DeviceWrapper::isStorageAccess() const {
return m_isStorageAccess;
}
bool DeviceWrapper::isAccessible() const {
return m_isAccessible;
}
bool DeviceWrapper::isEncryptedContainer() const {
return m_isEncryptedContainer;
}
bool DeviceWrapper::isOpticalDisc() const {
return m_isOpticalDisc;
}
QString DeviceWrapper::description() const {
return m_description;
}
void DeviceWrapper::setForceEject(bool force)
{
m_forceEject = force;
}
QString DeviceWrapper::defaultAction() const {
QString actionString;
if (m_isOpticalDisc && m_forceEject) {
actionString = i18n("Eject medium");
} else if (m_isStorageAccess) {
if (!m_isEncryptedContainer) {
if (!m_isAccessible) {
actionString = i18n("Mount the device");
} else {
actionString = i18n("Unmount the device");
}
} else {
if (!m_isAccessible) {
actionString = i18nc("Unlock the encrypted container; will ask for a password; partitions inside will appear as they had been plugged in","Unlock the container");
} else {
actionString = i18nc("Close the encrypted container; partitions inside will disappear as they had been unplugged", "Lock the container");
}
}
} else {
actionString = i18n("Eject medium");
}
return actionString;
}
void DeviceWrapper::runAction(QAction * action)
{
if (action) {
QString desktopAction = action->data().toString();
if (!desktopAction.isEmpty()) {
QStringList desktopFiles;
desktopFiles.append(desktopAction);
QDBusInterface soliduiserver("org.kde.kded5", "/modules/soliduiserver", "org.kde.SolidUiServer");
soliduiserver.asyncCall("showActionsDialog", id(), desktopFiles);
}
} else {
if (isOpticalDisc() && m_forceEject) {
Solid::OpticalDrive *drive = m_device.parent().as<Solid::OpticalDrive>();
if (drive) {
drive->eject();
}
return;
}
if (m_device.is<Solid::StorageVolume>()) {
Solid::StorageAccess *access = m_device.as<Solid::StorageAccess>();
if (access) {
if (access->isAccessible()) {
access->teardown();
} else {
access->setup();
}
return;
}
}
if (isOpticalDisc()) {
Solid::OpticalDrive *drive = m_device.parent().as<Solid::OpticalDrive>();
if (drive) {
drive->eject();
}
}
}
}
QStringList DeviceWrapper::actionIds() const
{
return m_actionIds;
}

@ -1,89 +0,0 @@
/**************************************************************************
* Copyright 2009 by Jacopo De Simoi <wilderkde@gmail.com> *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef DEVICEWRAPPER_H
#define DEVICEWRAPPER_H
#include <QString>
#include <KIcon>
#include <Plasma/DataEngine>
#include <Solid/Device>
#include <solid/solidnamespace.h>
class DeviceWrapper : public QObject
{
Q_OBJECT
public:
explicit DeviceWrapper(const QString& udi);
~DeviceWrapper();
QString id() const;
Solid::Device device() const;
KIcon icon() const;
bool isStorageAccess() const;
bool isAccessible() const;
bool isOpticalDisc() const;
bool isEncryptedContainer() const;
QString description() const;
QString defaultAction() const;
void runAction(QAction *) ;
QStringList actionIds() const;
void setForceEject(bool force);
Q_SIGNALS:
void registerAction(QString &id, QString icon, QString text, QString desktop);
void refreshMatch(QString &id);
protected Q_SLOTS:
/**
* slot called when a source of the hotplug engine is updated
* @param source the name of the source
* @param data the data of the source
*
* @internal
**/
void dataUpdated(const QString &source, Plasma::DataEngine::Data data);
private:
Solid::Device m_device;
QString m_iconName;
bool m_isStorageAccess;
bool m_isAccessible;
bool m_isEncryptedContainer;
bool m_isOpticalDisc;
bool m_forceEject;
QString m_description;
QStringList m_actionIds;
// Solid doesn't like multithreading that much
// We cache the information we need locally so that
// 1) nothing possibly goes wrong when processing a query
// 2) performance++
QString m_udi;
QStringList m_emblems;
};
#endif //DEVICEWRAPPER_H

@ -1,148 +0,0 @@
[Desktop Entry]
# ctxt: plasma runner
Name=Devices
Name[ar]=الأجهزة
Name[bg]=Устройства
Name[bn]=ডিইস
Name[bs]=Uređaji
Name[ca]=Dispositius
Name[ca@valencia]=Dispositius
Name[cs]=Zařízení
Name[csb]=Ùrządzenia
Name[da]=Enheder
Name[de]=Geräte
Name[el]=Συσκευές
Name[en_GB]=Devices
Name[eo]=Aparatoj
Name[es]=Dispositivos
Name[et]=Seadmed
Name[eu]=Gailuak
Name[fa]=دستگاهها
Name[fi]=Laitteet
Name[fr]=Périphériques
Name[fy]=Apparaten
Name[ga]=Gléasanna
Name[gl]=Dispositivos
Name[gu]=ઉપકરણ
Name[he]=התקנים
Name[hi]=औज
Name[hr]=Uređaji
Name[hu]=Eszközök
Name[ia]=Dispositivos
Name[id]=Perangkat
Name[is]=Tæki
Name[it]=Dispositivi
Name[ja]=デバイス
Name[kk]=Құрылғылар
Name[km]=ឧបករណ
Name[kn]=ಸಧನಗಳ
Name[ko]=장치
Name[lt]=Įrenginiai
Name[lv]=Ierīces
Name[mk]=Уреди
Name[ml]=ഉപകരണങങള
Name[mr]=सधन
Name[nb]=Enhet
Name[nds]=Reedschappen
Name[nl]=Apparaten
Name[nn]=Einingar
Name[pa]=ਜਤਰ
Name[pl]=Urządzenia
Name[pt]=Dispositivos
Name[pt_BR]=Dispositivos
Name[ro]=Dispozitive
Name[ru]=Устройства
Name[si]=මවලම
Name[sk]=Zariadenia
Name[sl]=Naprave
Name[sr]=уређаји
Name[sr@ijekavian]=уређаји
Name[sr@ijekavianlatin]=uređaji
Name[sr@latin]=uređaji
Name[sv]=Enheter
Name[tg]=Дастгоҳҳо
Name[th]=อปกรณาง ๆ
Name[tr]=Aygıtlar
Name[ug]=ئۈسكۈنىلەر
Name[uk]=Пристрої
Name[vi]=Thiết bị
Name[wa]=Éndjins
Name[x-test]=xxDevicesxx
Name[zh_CN]=设备
Name[zh_TW]=裝置
Comment=Manage removable devices
Comment[ar]=أدر الأجهزة المنفصلة
Comment[bn]=অপসরণযয ডিইস বযবসপন
Comment[bs]=Upravljanje uklonjivim uređajima
Comment[ca]=Gestiona dispositius extraïbles
Comment[ca@valencia]=Gestiona dispositius extraïbles
Comment[cs]=Spravovat odpojitelná zařízení
Comment[csb]=Sprôwiôj przenosnyma ùrządzeniama
Comment[da]=Håndtér flytbare enheder
Comment[de]=Wechselmedien verwalten
Comment[el]=Διαχείριση αφαιρούμενων συσκευών
Comment[en_GB]=Manage removable devices
Comment[es]=Gestionar dispositivos extraíbles
Comment[et]=Eemaldatavate seadmete haldamine
Comment[eu]=Kudeatu gailu eramangarriak
Comment[fi]=Hallitse irrotettavia laitteita
Comment[fr]=Gère les périphériques amovibles
Comment[fy]=Utnimbere apparaten beheare
Comment[ga]=Bainistigh gléasanna inbhainte
Comment[gl]=Xestiona os dispositivos extraíbeis
Comment[he]=משמש לניהול התקנים נשלפים
Comment[hr]=Upravlja uklonjivim uređajima
Comment[hu]=Cserélhető eszközök kezelése
Comment[ia]=Gere dispositivos removibile
Comment[id]=Kelola perangkat dapat dilepas
Comment[is]=Sýsla með fjarlægjanleg tæki
Comment[it]=Gestisce i dispositivi rimovibili
Comment[ja]=リムーバブルデバイスを管理します
Comment[kk]=Ауыстырмалы құрылғыларды басқару
Comment[km]=គរបរងឧបករណចល
Comment[kn]=ತಕಬಹದ ಸಧನಗಳನಯವಸಿಿ
Comment[ko]=이동식 장치를 관리합니다
Comment[lt]=Tvarkyti keičiamuosius įrenginius
Comment[lv]=Pārvaldīt noņemamās iekārtas
Comment[mk]=Ракувајте со подвижните уреди
Comment[ml]=നന ഉപകരണങങളി നടതതല
Comment[mr]=कढतधनयवसपन कर
Comment[nb]=Flyttbar
Comment[nds]=Tuuschbor Reedschappen plegen
Comment[nl]=Verwijderbare apparaten beheren
Comment[nn]=Handter flyttbare einingar
Comment[pa]=ਹਟਉਣਯਗ ਜਤਰ ਪਰਬ
Comment[pl]=Zarządza urządzeniami wymiennymi
Comment[pt]=Gerir os dispositivos removíveis
Comment[pt_BR]=Gerencia dispositivos removíveis
Comment[ro]=Gestionează dispozitive amovibile
Comment[ru]=Управление подключаемыми устройствами
Comment[si]=ඉවත කල හවලම කළමනකරනය කරන
Comment[sk]=Správa vymeniteľných zariadení
Comment[sl]=Upravljanje odstranljivih naprav
Comment[sr]=Управљање уклоњивим уређајима
Comment[sr@ijekavian]=Управљање уклоњивим уређајима
Comment[sr@ijekavianlatin]=Upravljanje uklonjivim uređajima
Comment[sr@latin]=Upravljanje uklonjivim uređajima
Comment[sv]=Hantera flyttbara enheter
Comment[tg]=Идоракунии дастгоҳҳои ҷудошаванда
Comment[th]=จดการอปกรณสามารถถอด/เสยบได
Comment[tr]=Çıkarılabilir aygıtları yönet
Comment[ug]=كۆچمە ئۈسكۈنىلەرنى باشقۇرۇش
Comment[uk]=Керування портативними пристроями
Comment[vi]=Quản lý thiết bị gắn ngoài
Comment[wa]=Manaedjî oiståves éndjins
Comment[x-test]=xxManage removable devicesxx
Comment[zh_CN]=管理可移动设备
Comment[zh_TW]=管理可移除裝置
X-KDE-ServiceTypes=Plasma/Runner
Type=Service
Icon=device-notifier
X-KDE-Library=krunner_solid
X-KDE-PluginInfo-Author=Jacopo De Simoi
X-KDE-PluginInfo-Email=wilderkde@gmail.com
X-KDE-PluginInfo-Name=solid
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-AdvertiseSingleRunnerQueryMode=true

@ -1,285 +0,0 @@
/***************************************************************************
* Copyright 2009 by Jacopo De Simoi <wilderkde@gmail.com> *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
//own
#include "solidrunner.h"
#include "devicewrapper.h"
//Qt
#include <QAction>
//KDE
#include <KIcon>
//Plasma
#include <Plasma/Plasma>
#include <Plasma/DataEngineManager>
//Solid
#include <Solid/Device>
using namespace Plasma;
SolidRunner::SolidRunner(QObject* parent, const QVariantList& args)
: AbstractRunner(parent, args),
m_deviceList()
{
Q_UNUSED(args)
setObjectName( QLatin1String("Solid" ));
m_engineManager = Plasma::DataEngineManager::self();
addSyntax(Plasma::RunnerSyntax(":q:", i18n("Finds devices whose name match :q:")));
setDefaultSyntax(Plasma::RunnerSyntax(i18nc("Note this is a KRunner keyword", "device"),
i18n("Lists all devices and allows them to be mounted, unmounted or ejected.")));
addSyntax(Plasma::RunnerSyntax(i18nc("Note this is a KRunner keyword", "mount"),
i18n("Lists all devices which can be mounted, and allows them to be mounted.")));
addSyntax(Plasma::RunnerSyntax(i18nc("Note this is a KRunner keyword", "unlock"),
i18n("Lists all encrypted devices which can be unlocked, and allows them to be unlocked.")));
addSyntax(Plasma::RunnerSyntax(i18nc("Note this is a KRunner keyword", "unmount"),
i18n("Lists all devices which can be unmounted, and allows them to be unmounted.")));
addSyntax(Plasma::RunnerSyntax(i18nc("Note this is a KRunner keyword", "lock"),
i18n("Lists all encrypted devices which can be locked, and allows them to be locked.")));
addSyntax(Plasma::RunnerSyntax(i18nc("Note this is a KRunner keyword", "eject"),
i18n("Lists all devices which can be ejected, and allows them to be ejected.")));
}
SolidRunner::~SolidRunner()
{
}
void SolidRunner::init()
{
m_hotplugEngine = dataEngine("hotplug");
m_solidDeviceEngine = dataEngine("soliddevice");
//connect to engine when a device is plugged
connect(m_hotplugEngine, SIGNAL(sourceAdded(QString)),
this, SLOT(onSourceAdded(QString)));
connect(m_hotplugEngine, SIGNAL(sourceRemoved(QString)),
this, SLOT(onSourceRemoved(QString)));
fillPreviousDevices();
}
void SolidRunner::cleanActionsForDevice(DeviceWrapper * dev)
{
const QStringList actionIds = dev->actionIds();
if (!actionIds.isEmpty()) {
foreach (const QString& id, actionIds) {
removeAction(id);
}
}
}
QList<QAction*> SolidRunner::actionsForMatch(const Plasma::QueryMatch &match)
{
QList<QAction*> actions;
DeviceWrapper* dev = m_deviceList.value(match.data().toString());
if (dev) {
QStringList actionIds = dev->actionIds();
if (!actionIds.isEmpty()) {
foreach (const QString& id, actionIds) {
actions << action(id);
}
}
}
return actions;
}
void SolidRunner::match(Plasma::RunnerContext& context)
{
m_currentContext = context;
createOrUpdateMatches(m_deviceList.keys());
}
void SolidRunner::createOrUpdateMatches(const QStringList &udiList)
{
const QString term = m_currentContext.query();
if (!m_currentContext.isValid()) {
return;
}
if (!m_currentContext.singleRunnerQueryMode() && (term.length() < 3)) {
return;
}
QList<Plasma::QueryMatch> matches;
// keyword match: when term starts with "device" we list all devices
QStringList keywords = term.split(" ");
QString deviceDescription;
bool onlyMounted = false;
bool onlyMountable = false;
bool onlyEncrypted = false;
bool onlyOptical = false;
bool forceEject = false;
bool showDevices = false;
if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "device") , Qt::CaseInsensitive)) {
showDevices = true;
keywords.removeFirst();
}
if (!keywords.isEmpty()) {
if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "mount") , Qt::CaseInsensitive)) {
showDevices = true;
onlyMountable = true;
keywords.removeFirst();
} else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "unmount") , Qt::CaseInsensitive)) {
showDevices = true;
onlyMounted = true;
keywords.removeFirst();
} else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "eject") , Qt::CaseInsensitive)) {
showDevices = true;
onlyOptical = true;
forceEject = true;
keywords.removeFirst();
} else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "unlock") , Qt::CaseInsensitive)) {
showDevices = true;
onlyMountable = true;
onlyEncrypted = true;
keywords.removeFirst();
} else if (keywords[0].startsWith(i18nc("Note this is a KRunner keyword", "lock") , Qt::CaseInsensitive)) {
showDevices = true;
onlyMounted = true;
onlyEncrypted = true;
keywords.removeFirst();
}
}
if (!keywords.isEmpty()) {
deviceDescription = keywords[0];
}
foreach (const QString& udi, udiList) {
DeviceWrapper * dev = m_deviceList.value(udi);
if ((deviceDescription.isEmpty() && showDevices) || dev->description().contains(deviceDescription, Qt::CaseInsensitive)) {
// This is getting quite messy indeed
if (((!onlyEncrypted) || (onlyEncrypted && dev->isEncryptedContainer())) &&
((!onlyOptical) || (onlyOptical && dev->isOpticalDisc())) &&
((onlyMounted && dev->isAccessible()) ||
(onlyMountable && dev->isStorageAccess() && !dev->isAccessible()) ||
(!onlyMounted && !onlyMountable))) {
dev->setForceEject(forceEject);
Plasma::QueryMatch match = deviceMatch(dev);
if (dev->description().compare(deviceDescription, Qt::CaseInsensitive)) {
match.setType(Plasma::QueryMatch::ExactMatch);
} else if (deviceDescription.isEmpty()) {
match.setType(Plasma::QueryMatch::PossibleMatch);
} else {
match.setType(Plasma::QueryMatch::CompletionMatch);
}
matches << match;
}
}
}
if (!matches.isEmpty()) {
m_currentContext.addMatches(term, matches);
}
}
Plasma::QueryMatch SolidRunner::deviceMatch(DeviceWrapper * device)
{
Plasma::QueryMatch match(this);
match.setId(device->id());
match.setData(device->id());
match.setIcon(device->icon());
match.setText(device->description());
match.setSubtext(device->defaultAction());
//Put them in order such that the last added device is on top.
match.setRelevance(0.5+0.1*qreal(m_udiOrderedList.indexOf(device->id()))/qreal(m_udiOrderedList.count()));
return match;
}
void SolidRunner::run(const Plasma::RunnerContext& context, const Plasma::QueryMatch& match)
{
Q_UNUSED(context)
DeviceWrapper *device = m_deviceList.value(match.data().toString());
if (device) {
device->runAction(match.selectedAction());
}
}
void SolidRunner::registerAction(QString &id, QString icon, QString text, QString desktop)
{
QAction* action = addAction(id, KIcon(icon), text);
action->setData(desktop);
}
void SolidRunner::refreshMatch(QString &id)
{
if (!m_currentContext.isValid()) {
return;
}
QueryMatch match(this);
match.setId(id);
m_currentContext.removeMatch(match.id());
QStringList deviceList;
deviceList << id;
createOrUpdateMatches(deviceList);
}
void SolidRunner::onSourceAdded(const QString &name)
{
DeviceWrapper * device = new DeviceWrapper(name);
connect(device, SIGNAL(registerAction(QString&,QString,QString,QString)),
this, SLOT(registerAction(QString&,QString,QString,QString)));
connect(device, SIGNAL(refreshMatch(QString&)), this, SLOT(refreshMatch(QString&)));
m_deviceList.insert(name, device);
m_udiOrderedList << name;
m_hotplugEngine->connectSource(name, device);
m_solidDeviceEngine->connectSource(name, device);
}
void SolidRunner::onSourceRemoved(const QString &name)
{
DeviceWrapper * device = m_deviceList.value(name);
if (device) {
m_hotplugEngine->disconnectSource(name, device);
m_solidDeviceEngine->disconnectSource(name, device);
disconnect(device, 0, this, 0);
cleanActionsForDevice(device);
m_deviceList.remove(name);
m_udiOrderedList.removeAll(name);
if (m_currentContext.isValid()) {
QueryMatch match(this);
match.setId(device->id());
m_currentContext.removeMatch(match.id());
}
delete device;
}
}
void SolidRunner::fillPreviousDevices()
{
foreach (const QString &source, m_hotplugEngine->sources()) {
onSourceAdded(source);
}
}

@ -1,76 +0,0 @@
/***************************************************************************
* Copyright 2009 by Jacopo De Simoi <wilderkde@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef SOLIDRUNNER_H
#define SOLIDRUNNER_H
#include <Plasma/AbstractRunner>
namespace Plasma {
class DataEngine;
class DataEngineManager;
class RunnerContext;
}
class DeviceWrapper;
class SolidRunner : public Plasma::AbstractRunner
{
Q_OBJECT
public:
SolidRunner(QObject* parent, const QVariantList &args);
~SolidRunner();
virtual void match(Plasma::RunnerContext& context);
virtual void run(const Plasma::RunnerContext& context, const Plasma::QueryMatch& match);
protected:
QList<QAction*> actionsForMatch(const Plasma::QueryMatch &match);
protected Q_SLOTS:
void init();
void onSourceAdded(const QString &name);
void onSourceRemoved(const QString &name);
private Q_SLOTS:
void registerAction(QString &id, QString icon, QString text, QString desktop);
void refreshMatch(QString &id);
private:
void fillPreviousDevices();
void cleanActionsForDevice(DeviceWrapper *);
void createOrUpdateMatches(const QStringList &udiList);
Plasma::QueryMatch deviceMatch(DeviceWrapper * device);
Plasma::DataEngine *m_hotplugEngine;
Plasma::DataEngine *m_solidDeviceEngine;
QHash<QString, DeviceWrapper*> m_deviceList;
QStringList m_udiOrderedList;
Plasma::DataEngineManager* m_engineManager;
Plasma::RunnerContext m_currentContext;
};
K_EXPORT_PLASMA_RUNNER(solid, SolidRunner)
#endif // SOLIDRUNNER_H
Loading…
Cancel
Save