diff --git a/solid/solid/CMakeLists.txt b/solid/solid/CMakeLists.txt index a7f1f075..c9d6cc6f 100644 --- a/solid/solid/CMakeLists.txt +++ b/solid/solid/CMakeLists.txt @@ -46,7 +46,6 @@ configure_file(config-processor.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-proce file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/backends/fakehw - ${CMAKE_CURRENT_BINARY_DIR}/backends/hal ${CMAKE_CURRENT_BINARY_DIR}/backends/udev ${CMAKE_CURRENT_BINARY_DIR}/backends/wmi ${CMAKE_CURRENT_BINARY_DIR}/backends/win @@ -250,33 +249,6 @@ if(NOT WIN32 AND NOT APPLE) endif( UDEV_FOUND ) - message(STATUS "Building Solid HAL backend." ) - set(solid_LIB_SRCS ${solid_LIB_SRCS} - backends/hal/halacadapter.cpp - backends/hal/halaudiointerface.cpp - backends/hal/halbattery.cpp - backends/hal/halblock.cpp - backends/hal/halbutton.cpp - backends/hal/halcamera.cpp - backends/hal/halcdrom.cpp - backends/hal/haldeviceinterface.cpp - backends/hal/haldvbinterface.cpp - backends/hal/halfstabhandling.cpp - backends/hal/halgenericinterface.cpp - backends/hal/haldevice.cpp - backends/hal/halmanager.cpp - backends/hal/halnetworkinterface.cpp - backends/hal/halserialinterface.cpp - backends/hal/halopticaldisc.cpp - backends/hal/halportablemediaplayer.cpp - backends/hal/halprocessor.cpp - backends/hal/halstorageaccess.cpp - backends/hal/halstorage.cpp - backends/hal/halvideo.cpp - backends/hal/halvolume.cpp - backends/hal/halsmartcardreader.cpp - ) - message(STATUS "Building Solid UPower backend." ) set(solid_LIB_SRCS ${solid_LIB_SRCS} backends/upower/upowermanager.cpp diff --git a/solid/solid/backends/hal/halacadapter.cpp b/solid/solid/backends/hal/halacadapter.cpp deleted file mode 100644 index f4b9451c..00000000 --- a/solid/solid/backends/hal/halacadapter.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halacadapter.h" - -using namespace Solid::Backends::Hal; - -AcAdapter::AcAdapter(HalDevice *device) - : DeviceInterface(device) -{ - connect(device, SIGNAL(propertyChanged(QMap)), - this, SLOT(slotPropertyChanged(QMap))); -} - -AcAdapter::~AcAdapter() -{ - -} - -bool AcAdapter::isPlugged() const -{ - return m_device->prop("ac_adapter.present").toBool(); -} - -void AcAdapter::slotPropertyChanged(const QMap &changes) -{ - if (changes.contains("ac_adapter.present")) - { - emit plugStateChanged(isPlugged(), m_device->udi()); - } -} - -#include "backends/hal/halacadapter.moc" diff --git a/solid/solid/backends/hal/halacadapter.h b/solid/solid/backends/hal/halacadapter.h deleted file mode 100644 index b5f1d578..00000000 --- a/solid/solid/backends/hal/halacadapter.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_ACADAPTER_H -#define SOLID_BACKENDS_HAL_ACADAPTER_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class AcAdapter : public DeviceInterface, virtual public Solid::Ifaces::AcAdapter -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::AcAdapter) - -public: - AcAdapter(HalDevice *device); - virtual ~AcAdapter(); - - virtual bool isPlugged() const; - -Q_SIGNALS: - void plugStateChanged(bool newState, const QString &udi); - -private Q_SLOTS: - void slotPropertyChanged(const QMap &changes); -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_ACADAPTER_H diff --git a/solid/solid/backends/hal/halaudiointerface.cpp b/solid/solid/backends/hal/halaudiointerface.cpp deleted file mode 100644 index 5b3b3096..00000000 --- a/solid/solid/backends/hal/halaudiointerface.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halaudiointerface.h" - -#include "haldevice.h" -#include - -using namespace Solid::Backends::Hal; - -AudioInterface::AudioInterface(HalDevice *device) - : DeviceInterface(device), - m_soundcardType(Solid::AudioInterface::InternalSoundcard), - m_soundcardTypeValid(false) -{ - -} - -AudioInterface::~AudioInterface() -{ - -} - - -Solid::AudioInterface::AudioDriver AudioInterface::driver() const -{ - QString capacity = m_device->prop("info.category").toString(); - - if (capacity == "alsa") - { - return Solid::AudioInterface::Alsa; - } - else if (capacity == "oss") - { - return Solid::AudioInterface::OpenSoundSystem; - } - else - { - return Solid::AudioInterface::UnknownAudioDriver; - } -} - -QVariant AudioInterface::driverHandle() const -{ - Solid::AudioInterface::AudioDriver d = driver(); - - if (d == Solid::AudioInterface::Alsa) - { - QVariant card_id = m_device->prop("alsa.card"); - QVariant dev_id = m_device->prop("alsa.device"); - QVariant subdev_id; - //TODO alsa.subdevice - - return QList() << card_id << dev_id << subdev_id; - } - else if (d == Solid::AudioInterface::OpenSoundSystem) - { - return m_device->prop("oss.device_file"); - } - else - { - return QVariant(); - } -} - -QString AudioInterface::name() const -{ - Solid::AudioInterface::AudioDriver d = driver(); - - if (d == Solid::AudioInterface::Alsa) - { - QVariant card_id = m_device->prop("alsa.card_id"); - if (card_id.isValid()) - { - return card_id.toString().trimmed() + QLatin1String(" (") + m_device->prop("alsa.device_id").toString().trimmed() + ')'; - } - return m_device->prop("alsa.device_id").toString(); - } - else if (d == Solid::AudioInterface::OpenSoundSystem) - { - QVariant card_id = m_device->prop("oss.card_id"); - if (card_id.isValid()) - { - return card_id.toString().trimmed() + QLatin1String(" (") + m_device->prop("oss.device_id").toString().trimmed() + ')'; - } - return m_device->prop("oss.device_id").toString(); - } - else - { - return QString(); - } -} - -Solid::AudioInterface::AudioInterfaceTypes AudioInterface::deviceType() const -{ - Solid::AudioInterface::AudioDriver d = driver(); - - if (d == Solid::AudioInterface::Alsa) - { - QString type = m_device->prop("alsa.type").toString(); - - if (type == "control") - { - return Solid::AudioInterface::AudioControl; - } - else if (type == "capture") - { - return Solid::AudioInterface::AudioInput; - } - else if (type == "playback") - { - return Solid::AudioInterface::AudioOutput; - } - else - { - return Solid::AudioInterface::UnknownAudioInterfaceType; - } - } - else if (d == Solid::AudioInterface::OpenSoundSystem) - { - QString type = m_device->prop("oss.type").toString(); - - if (type == "mixer") - { - return Solid::AudioInterface::AudioControl; - } - else if (type == "pcm") - { - return Solid::AudioInterface::AudioInput|Solid::AudioInterface::AudioOutput; - } - else - { - return Solid::AudioInterface::UnknownAudioInterfaceType; - } - } - else - { - return Solid::AudioInterface::UnknownAudioInterfaceType; - } -} - -Solid::AudioInterface::SoundcardType AudioInterface::soundcardType() const -{ - if (m_soundcardTypeValid) - { - return m_soundcardType; - } - - QString parentUdi = m_device->parentUdi(); - if (!parentUdi.isEmpty()) { - QDBusInterface parentIface(QLatin1String("org.freedesktop.Hal"), m_device->parentUdi(), "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); - const QDBusMessage &reply = parentIface.call("GetProperty", QLatin1String("info.subsystem")); - if ((reply.type() != QDBusMessage::ReplyMessage && reply.errorName() == "org.freedesktop.Hal.NoSuchProperty") || - (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().at(0) == "sound")) { - const QDBusMessage &reply2 = parentIface.call("GetProperty", QLatin1String("info.parent")); - if (reply2.type() == QDBusMessage::ReplyMessage) { - parentUdi = reply2.arguments().at(0).toString(); - } - } - - HalDevice parentDevice(parentUdi); - QString productName = parentDevice.product(); - QString deviceName = name(); - if (productName.contains("headset", Qt::CaseInsensitive) || - productName.contains("headphone", Qt::CaseInsensitive) || - deviceName.contains("headset", Qt::CaseInsensitive) || - deviceName.contains("headphone", Qt::CaseInsensitive)) - { - m_soundcardType = Solid::AudioInterface::Headset; - } - else if (productName.contains("modem", Qt::CaseInsensitive) || - deviceName.contains("modem", Qt::CaseInsensitive)) - { - m_soundcardType = Solid::AudioInterface::Modem; - } - else - { - QString busName = parentDevice.prop("info.subsystem").toString(); - QString driverName = parentDevice.prop("info.linux.driver").toString(); - if (busName == "ieee1394") - { - m_soundcardType = Solid::AudioInterface::FirewireSoundcard; - } - else if (busName == "usb" || busName == "usb_device" || driverName.contains("usb", Qt::CaseInsensitive)) - { - m_soundcardType = Solid::AudioInterface::UsbSoundcard; - } - else - { - m_soundcardType = Solid::AudioInterface::InternalSoundcard; - } - } - m_soundcardTypeValid = true; - } - return m_soundcardType; -} - -#include "backends/hal/halaudiointerface.moc" diff --git a/solid/solid/backends/hal/halaudiointerface.h b/solid/solid/backends/hal/halaudiointerface.h deleted file mode 100644 index 4003f457..00000000 --- a/solid/solid/backends/hal/halaudiointerface.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_HALAUDIOINTERFACE_H -#define SOLID_BACKENDS_HAL_HALAUDIOINTERFACE_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalDevice; - -class AudioInterface : public DeviceInterface, virtual public Solid::Ifaces::AudioInterface -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::AudioInterface) - -public: - AudioInterface(HalDevice *device); - virtual ~AudioInterface(); - - virtual Solid::AudioInterface::AudioDriver driver() const; - virtual QVariant driverHandle() const; - - virtual QString name() const; - virtual Solid::AudioInterface::AudioInterfaceTypes deviceType() const; - virtual Solid::AudioInterface::SoundcardType soundcardType() const; - -private: - mutable Solid::AudioInterface::SoundcardType m_soundcardType; - mutable bool m_soundcardTypeValid; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_HALAUDIOINTERFACE_H diff --git a/solid/solid/backends/hal/halbattery.cpp b/solid/solid/backends/hal/halbattery.cpp deleted file mode 100644 index 958ecae8..00000000 --- a/solid/solid/backends/hal/halbattery.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halbattery.h" - -using namespace Solid::Backends::Hal; - -Battery::Battery(HalDevice *device) - : DeviceInterface(device) -{ - connect(device, SIGNAL(propertyChanged(QMap)), - this, SLOT(slotPropertyChanged(QMap))); -} - -Battery::~Battery() -{ - -} - - -bool Battery::isPlugged() const -{ - return m_device->prop("battery.present").toBool(); -} - -Solid::Battery::BatteryType Battery::type() const -{ - QString name = m_device->prop("battery.type").toString(); - - if (name == "pda") - { - return Solid::Battery::PdaBattery; - } - else if (name == "ups") - { - return Solid::Battery::UpsBattery; - } - else if (name == "primary") - { - return Solid::Battery::PrimaryBattery; - } - else if (name == "mouse") - { - return Solid::Battery::MouseBattery; - } - else if (name == "keyboard") - { - return Solid::Battery::KeyboardBattery; - } - else if (name == "keyboard_mouse") - { - return Solid::Battery::KeyboardMouseBattery; - } - else if (name == "camera") - { - return Solid::Battery::CameraBattery; - } - else - { - return Solid::Battery::UnknownBattery; - } -} - -int Battery::chargePercent() const -{ - return m_device->prop("battery.charge_level.percentage").toInt(); -} - -int Battery::capacity() const -{ - const qreal lastFull = m_device->prop("battery.charge_level.last_full").toDouble(); - const qreal designFull = m_device->prop("battery.charge_level.design").toDouble(); - - return lastFull / designFull * 100; -} - -bool Battery::isRechargeable() const -{ - return m_device->prop("battery.is_rechargeable").toBool(); -} - -bool Battery::isPowerSupply() const -{ - // NOTE Hal doesn't support the is power supply property, so we're assuming that primary - // and UPS batteries are power supply and all the others are not - if (type() == Solid::Battery::PrimaryBattery || type() == Solid::Battery::UpsBattery) { - return true; - } - - return false; -} - -Solid::Battery::ChargeState Battery::chargeState() const -{ - bool charging = m_device->prop("battery.rechargeable.is_charging").toBool(); - bool discharging = m_device->prop("battery.rechargeable.is_discharging").toBool(); - - if (!charging && !discharging) - { - return Solid::Battery::NoCharge; - } - else if (charging) - { - return Solid::Battery::Charging; - } - else - { - return Solid::Battery::Discharging; - } -} - -void Battery::slotPropertyChanged(const QMap &changes) -{ - if (changes.contains("battery.charge_level.percentage")) - { - emit chargePercentChanged(chargePercent(), m_device->udi()); - } - - if (changes.contains("battery.charge_level.last_full") - || changes.contains("battery.charge_level.design")) - { - emit capacityChanged(capacity(), m_device->udi()); - } - - if (changes.contains("battery.rechargeable.is_charging") - || changes.contains("battery.rechargeable.is_discharging")) - { - emit chargeStateChanged(chargeState(), m_device->udi()); - } - - if ( changes.contains( "battery.present" ) ) - { - emit plugStateChanged(isPlugged(), m_device->udi()); - } - -} - -#include "backends/hal/halbattery.moc" diff --git a/solid/solid/backends/hal/halbattery.h b/solid/solid/backends/hal/halbattery.h deleted file mode 100644 index 7160e3a5..00000000 --- a/solid/solid/backends/hal/halbattery.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_BATTERY_H -#define SOLID_BACKENDS_HAL_BATTERY_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class Battery : public DeviceInterface, virtual public Solid::Ifaces::Battery -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::Battery) - -public: - Battery(HalDevice *device); - virtual ~Battery(); - - virtual bool isPlugged() const; - virtual Solid::Battery::BatteryType type() const; - - virtual int chargePercent() const; - virtual int capacity() const; - - virtual bool isRechargeable() const; - virtual bool isPowerSupply() const; - virtual Solid::Battery::ChargeState chargeState() const; - -Q_SIGNALS: - void chargePercentChanged(int value, const QString &udi); - void capacityChanged(int value, const QString &udi); - void chargeStateChanged(int newState, const QString &udi); - void plugStateChanged(bool newState, const QString &udi); - void powerSupplyStateChanged(bool newState, const QString &udi); // dummy - -private Q_SLOTS: - void slotPropertyChanged(const QMap &changes); -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_BATTERY_H diff --git a/solid/solid/backends/hal/halblock.cpp b/solid/solid/backends/hal/halblock.cpp deleted file mode 100644 index 990b9f95..00000000 --- a/solid/solid/backends/hal/halblock.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halblock.h" - -#include "haldevice.h" - -using namespace Solid::Backends::Hal; - -Block::Block(HalDevice *device) - : DeviceInterface(device) -{ - -} - -Block::~Block() -{ - -} - -int Block::deviceMajor() const -{ - return m_device->prop("block.major").toInt(); -} - -int Block::deviceMinor() const -{ - return m_device->prop("block.minor").toInt(); -} - -QString Block::device() const -{ - return m_device->prop("block.device").toString(); -} - -#include "backends/hal/halblock.moc" diff --git a/solid/solid/backends/hal/halblock.h b/solid/solid/backends/hal/halblock.h deleted file mode 100644 index f0310f1d..00000000 --- a/solid/solid/backends/hal/halblock.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_BLOCK_H -#define SOLID_BACKENDS_HAL_BLOCK_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class Block : public DeviceInterface, virtual public Solid::Ifaces::Block -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::Block) - -public: - Block(HalDevice *device); - virtual ~Block(); - - virtual int deviceMajor() const; - virtual int deviceMinor() const; - virtual QString device() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_BLOCK_H diff --git a/solid/solid/backends/hal/halbutton.cpp b/solid/solid/backends/hal/halbutton.cpp deleted file mode 100644 index 4c8722fd..00000000 --- a/solid/solid/backends/hal/halbutton.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright 2006 Davide Bettio - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halbutton.h" - -using namespace Solid::Backends::Hal; - -Button::Button(HalDevice *device) - : DeviceInterface(device) -{ - connect(device, SIGNAL(conditionRaised(QString,QString)), - this, SLOT(slotConditionRaised(QString,QString))); -} - -Button::~Button() -{ - -} - -Solid::Button::ButtonType Button::type() const -{ - QString buttontype = m_device->prop("button.type").toString(); - - if (buttontype=="lid") - { - return Solid::Button::LidButton; - } - else if (buttontype=="power") - { - return Solid::Button::PowerButton; - } - else if (buttontype=="sleep") - { - return Solid::Button::SleepButton; - } - else if (buttontype=="tablet_mode") - { - return Solid::Button::TabletButton; - } - else - { - return Solid::Button::UnknownButtonType; - } -} - -bool Button::hasState() const -{ - return m_device->prop("button.has_state").toBool(); -} - -bool Button::stateValue() const -{ - return m_device->prop("button.state.value").toBool(); -} - -void Button::slotConditionRaised(const QString &name, const QString &/*reason */) -{ - if (name == "ButtonPressed") - { - emit pressed(type(), m_device->udi()); - } -} - -#include "backends/hal/halbutton.moc" diff --git a/solid/solid/backends/hal/halbutton.h b/solid/solid/backends/hal/halbutton.h deleted file mode 100644 index 8641adfb..00000000 --- a/solid/solid/backends/hal/halbutton.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright 2006 Davide Bettio - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_BUTTON_H -#define SOLID_BACKENDS_HAL_BUTTON_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalDevice; - -class Button : public DeviceInterface, virtual public Solid::Ifaces::Button -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::Button) - -public: - Button(HalDevice *device); - virtual ~Button(); - - virtual Solid::Button::ButtonType type() const; - virtual bool hasState() const; - virtual bool stateValue() const; - -Q_SIGNALS: - void pressed(Solid::Button::ButtonType type, const QString &udi); - -private Q_SLOTS: - void slotConditionRaised(const QString &condition, const QString &reason); -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_BUTTON_H diff --git a/solid/solid/backends/hal/halcamera.cpp b/solid/solid/backends/hal/halcamera.cpp deleted file mode 100644 index f640830c..00000000 --- a/solid/solid/backends/hal/halcamera.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halcamera.h" - -using namespace Solid::Backends::Hal; - -Camera::Camera(HalDevice *device) - : DeviceInterface(device) -{ - -} - -Camera::~Camera() -{ - -} - -QStringList Camera::supportedProtocols() const -{ - QStringList protocols; - - QString method = m_device->prop("camera.access_method").toString(); - - protocols << method; - - return protocols; -} - -QStringList Camera::supportedDrivers(QString /*protocol*/) const -{ - QStringList res; - - if (m_device->prop("camera.libgphoto2.support").toBool()) { - res << "gphoto"; - } - - return res; -} - -QVariant Solid::Backends::Hal::Camera::driverHandle(const QString &driver) const -{ - if (driver=="gphoto" - && m_device->prop("info.subsystem").toString()=="usb") { - QVariantList list; - - list << "usb" - << m_device->prop("usb.vendor_id") - << m_device->prop("usb.product_id"); - - return list; - } - - return QVariant(); -} - -#include "backends/hal/halcamera.moc" diff --git a/solid/solid/backends/hal/halcamera.h b/solid/solid/backends/hal/halcamera.h deleted file mode 100644 index c7c339e5..00000000 --- a/solid/solid/backends/hal/halcamera.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_CAMERA_H -#define SOLID_BACKENDS_HAL_CAMERA_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class Camera : public DeviceInterface, virtual public Solid::Ifaces::Camera -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::Camera) - -public: - Camera(HalDevice *device); - virtual ~Camera(); - - virtual QStringList supportedProtocols() const; - virtual QStringList supportedDrivers(QString protocol = QString()) const; - virtual QVariant driverHandle(const QString &driver) const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_CAMERA_H diff --git a/solid/solid/backends/hal/halcdrom.cpp b/solid/solid/backends/hal/halcdrom.cpp deleted file mode 100644 index 24e0f3fd..00000000 --- a/solid/solid/backends/hal/halcdrom.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halcdrom.h" - -#include -#include -#include -#include -#include - -#include "halfstabhandling.h" - -using namespace Solid::Backends::Hal; - -Cdrom::Cdrom(HalDevice *device) - : Storage(device), m_ejectInProgress(false) -{ - connect(device, SIGNAL(conditionRaised(QString,QString)), - this, SLOT(slotCondition(QString,QString))); - m_device->registerAction("eject", this, - SLOT(slotEjectRequested()), - SLOT(slotEjectDone(int,QString))); -} - -Cdrom::~Cdrom() -{ - -} - - -Solid::OpticalDrive::MediumTypes Cdrom::supportedMedia() const -{ - Solid::OpticalDrive::MediumTypes supported; - - QMap map; - map[Solid::OpticalDrive::Cdr] = "storage.cdrom.cdr"; - map[Solid::OpticalDrive::Cdrw] = "storage.cdrom.cdrw"; - map[Solid::OpticalDrive::Dvd] = "storage.cdrom.dvd"; - map[Solid::OpticalDrive::Dvdr] = "storage.cdrom.dvdr"; - map[Solid::OpticalDrive::Dvdrw] ="storage.cdrom.dvdrw"; - map[Solid::OpticalDrive::Dvdram] ="storage.cdrom.dvdram"; - map[Solid::OpticalDrive::Dvdplusr] ="storage.cdrom.dvdplusr"; - map[Solid::OpticalDrive::Dvdplusrw] ="storage.cdrom.dvdplusrw"; - map[Solid::OpticalDrive::Dvdplusdl] ="storage.cdrom.dvdplusrdl"; - map[Solid::OpticalDrive::Dvdplusdlrw] ="storage.cdrom.dvdplusrwdl"; - map[Solid::OpticalDrive::Bd] ="storage.cdrom.bd"; - map[Solid::OpticalDrive::Bdr] ="storage.cdrom.bdr"; - map[Solid::OpticalDrive::Bdre] ="storage.cdrom.bdre"; - map[Solid::OpticalDrive::HdDvd] ="storage.cdrom.hddvd"; - map[Solid::OpticalDrive::HdDvdr] ="storage.cdrom.hddvdr"; - map[Solid::OpticalDrive::HdDvdrw] ="storage.cdrom.hddvdrw"; - - foreach (const Solid::OpticalDrive::MediumType type, map.keys()) - { - if (m_device->prop(map[type]).toBool()) - { - supported|= type; - } - } - - return supported; -} - -int Cdrom::readSpeed() const -{ - return m_device->prop("storage.cdrom.read_speed").toInt(); -} - -int Cdrom::writeSpeed() const -{ - return m_device->prop("storage.cdrom.write_speed").toInt(); -} - -QList Cdrom::writeSpeeds() const -{ - QList speeds; - QStringList speed_strlist = m_device->prop("storage.cdrom.write_speeds").toStringList(); - - foreach (const QString &speed_str, speed_strlist) - { - speeds << speed_str.toInt(); - } - - return speeds; -} - -void Cdrom::slotCondition(const QString &name, const QString &/*reason */) -{ - if (name == "EjectPressed") - { - emit ejectPressed(m_device->udi()); - } -} - -bool Cdrom::eject() -{ - if (m_ejectInProgress) { - return false; - } - m_ejectInProgress = true; - m_device->broadcastActionRequested("eject"); - - if (FstabHandling::isInFstab(m_device->prop("block.device").toString())) { - return callSystemEject(); - } else { - return callHalDriveEject(); - } -} - -void Cdrom::slotEjectRequested() -{ - m_ejectInProgress = true; - emit ejectRequested(m_device->udi()); -} - -bool Cdrom::callHalDriveEject() -{ - QString udi = m_device->udi(); - QString interface = "org.freedesktop.Hal.Device.Storage"; - - // HACK: Eject doesn't work on cdrom drives when there's a mounted disc, - // let's try to workaround this by calling a child volume... - if (m_device->prop("storage.removable.media_available").toBool()) { - QDBusInterface manager("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - QDBusConnection::systemBus()); - - QDBusReply reply = manager.call("FindDeviceStringMatch", "info.parent", udi); - - if (reply.isValid()) - { - const QStringList udis = reply; - if (!udis.isEmpty()) { - udi = udis[0]; - interface = "org.freedesktop.Hal.Device.Volume"; - } - } - } - - QDBusConnection c = QDBusConnection::systemBus(); - QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi, - interface, "Eject"); - - msg << QStringList(); - - - return c.callWithCallback(msg, this, - SLOT(slotDBusReply(QDBusMessage)), - SLOT(slotDBusError(QDBusError))); -} - -bool Solid::Backends::Hal::Cdrom::callSystemEject() -{ - const QString device = m_device->prop("block.device").toString(); - m_process = FstabHandling::callSystemCommand("eject", device, - this, SLOT(slotProcessFinished(int,QProcess::ExitStatus))); - - return m_process!=0; -} - -void Cdrom::slotDBusReply(const QDBusMessage &/*reply*/) -{ - m_ejectInProgress = false; - m_device->broadcastActionDone("eject"); -} - -void Cdrom::slotDBusError(const QDBusError &error) -{ - m_ejectInProgress = false; - - // TODO: Better error reporting here - m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation, - QString(error.name()+": "+error.message())); -} - -void Solid::Backends::Hal::Cdrom::slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - Q_UNUSED(exitStatus); - if (m_ejectInProgress) { - m_ejectInProgress = false; - - if (exitCode==0) { - m_device->broadcastActionDone("eject"); - } else { - m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation, - m_process->readAllStandardError()); - } - } - - delete m_process; -} - -void Cdrom::slotEjectDone(int error, const QString &errorString) -{ - m_ejectInProgress = false; - emit ejectDone(static_cast(error), errorString, m_device->udi()); -} - -#include "backends/hal/halcdrom.moc" diff --git a/solid/solid/backends/hal/halcdrom.h b/solid/solid/backends/hal/halcdrom.h deleted file mode 100644 index 35c01d28..00000000 --- a/solid/solid/backends/hal/halcdrom.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_CDROM_H -#define SOLID_BACKENDS_HAL_CDROM_H - -#include -#include "halstorage.h" - -#include -#include -#include -#include - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class Cdrom : public Storage, virtual public Solid::Ifaces::OpticalDrive -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::OpticalDrive) - -public: - Cdrom(HalDevice *device); - virtual ~Cdrom(); - - virtual Solid::OpticalDrive::MediumTypes supportedMedia() const; - virtual int readSpeed() const; - virtual int writeSpeed() const; - virtual QList writeSpeeds() const; - virtual bool eject(); - -Q_SIGNALS: - void ejectPressed(const QString &udi); - void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - void ejectRequested(const QString &udi); - -private Q_SLOTS: - void slotCondition(const QString &name, const QString &reason); - void slotDBusReply(const QDBusMessage &reply); - void slotDBusError(const QDBusError &error); - void slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - void slotEjectRequested(); - void slotEjectDone(int error, const QString &errorString); - -private: - bool callHalDriveEject(); - bool callSystemEject(); - - bool m_ejectInProgress; - QProcess *m_process; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_CDROM_H diff --git a/solid/solid/backends/hal/haldevice.cpp b/solid/solid/backends/hal/haldevice.cpp deleted file mode 100644 index 56e203ae..00000000 --- a/solid/solid/backends/hal/haldevice.cpp +++ /dev/null @@ -1,850 +0,0 @@ -/* - Copyright 2005-2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "haldevice.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "haldeviceinterface.h" -#include "halgenericinterface.h" -#include "halprocessor.h" -#include "halblock.h" -#include "halstorageaccess.h" -#include "halstorage.h" -#include "halcdrom.h" -#include "halvolume.h" -#include "halopticaldisc.h" -#include "halcamera.h" -#include "halportablemediaplayer.h" -#include "halnetworkinterface.h" -#include "halacadapter.h" -#include "halbattery.h" -#include "halbutton.h" -#include "halaudiointerface.h" -#include "haldvbinterface.h" -#include "halvideo.h" -#include "halserialinterface.h" -#include "halsmartcardreader.h" - -using namespace Solid::Backends::Hal; - -// Adapted from KLocale as Solid needs to be Qt-only -static QString formatByteSize(double size) -{ - // Per IEC 60027-2 - - // Binary prefixes - //Tebi-byte TiB 2^40 1,099,511,627,776 bytes - //Gibi-byte GiB 2^30 1,073,741,824 bytes - //Mebi-byte MiB 2^20 1,048,576 bytes - //Kibi-byte KiB 2^10 1,024 bytes - - QString s; - // Gibi-byte - if ( size >= 1073741824.0 ) - { - size /= 1073741824.0; - if ( size > 1024 ) // Tebi-byte - s = QObject::tr("%1 TiB").arg(QLocale().toString(size / 1024.0, 'f', 1)); - else - s = QObject::tr("%1 GiB").arg(QLocale().toString(size, 'f', 1)); - } - // Mebi-byte - else if ( size >= 1048576.0 ) - { - size /= 1048576.0; - s = QObject::tr("%1 MiB").arg(QLocale().toString(size, 'f', 1)); - } - // Kibi-byte - else if ( size >= 1024.0 ) - { - size /= 1024.0; - s = QObject::tr("%1 KiB").arg(QLocale().toString(size, 'f', 1)); - } - // Just byte - else if ( size > 0 ) - { - s = QObject::tr("%1 B").arg(QLocale().toString(size, 'f', 1)); - } - // Nothing - else - { - s = QObject::tr("0 B"); - } - return s; -} - -class Solid::Backends::Hal::HalDevicePrivate -{ -public: - HalDevicePrivate(const QString &udi) - : device("org.freedesktop.Hal", - udi, - "org.freedesktop.Hal.Device", - QDBusConnection::systemBus()), - cacheSynced(false), parent(0) { } - void checkCache(const QString &key = QString()); - - QDBusInterface device; - QMap cache; - QMap capListCache; - QSet invalidKeys; - - bool cacheSynced; - HalDevice *parent; -}; - -Q_DECLARE_METATYPE(ChangeDescription) -Q_DECLARE_METATYPE(QList) - -const QDBusArgument &operator<<(QDBusArgument &arg, const ChangeDescription &change) -{ - arg.beginStructure(); - arg << change.key << change.added << change.removed; - arg.endStructure(); - return arg; -} - -const QDBusArgument &operator>>(const QDBusArgument &arg, ChangeDescription &change) -{ - arg.beginStructure(); - arg >> change.key >> change.added >> change.removed; - arg.endStructure(); - return arg; -} - -HalDevice::HalDevice(const QString &udi) - : Device(), d(new HalDevicePrivate(udi)) -{ - qDBusRegisterMetaType(); - qDBusRegisterMetaType< QList >(); - - d->device.connection().connect("org.freedesktop.Hal", - udi, "org.freedesktop.Hal.Device", - "PropertyModified", - this, SLOT(slotPropertyModified(int,QList))); - d->device.connection().connect("org.freedesktop.Hal", - udi, "org.freedesktop.Hal.Device", - "Condition", - this, SLOT(slotCondition(QString,QString))); -} - -HalDevice::~HalDevice() -{ - delete d->parent; - delete d; -} - -QString HalDevice::udi() const -{ - return prop("info.udi").toString(); -} - -QString HalDevice::parentUdi() const -{ - return prop("info.parent").toString(); -} - -QString HalDevice::vendor() const -{ - const QString category = prop("info.category").toString(); - - if (category == QLatin1String("battery")) { - return prop("battery.vendor").toString(); - } else { - return prop("info.vendor").toString(); - } -} - -QString HalDevice::product() const -{ - return prop("info.product").toString(); -} - -QString HalDevice::icon() const -{ - QString category = prop("info.category").toString(); - - if(parentUdi().isEmpty()) { - - QString formfactor = prop("system.formfactor").toString(); - if (formfactor=="laptop") { - return "computer-laptop"; - } else { - return "computer"; - } - - } else if (category=="storage" || category=="storage.cdrom") { - - if (prop("storage.drive_type").toString()=="floppy") { - return "media-floppy"; - } else if (prop("storage.drive_type").toString()=="cdrom") { - return "drive-optical"; - } else if (prop("storage.drive_type").toString()=="sd_mmc") { - return "media-flash-sd-mmc"; - } else if (prop("storage.hotpluggable").toBool()) { - if (prop("storage.bus").toString()=="usb") { - if (prop("storage.no_partitions_hint").toBool() - || prop("storage.removable.media_size").toLongLong()<4000000000LL) { - return "drive-removable-media-usb-pendrive"; - } else { - return "drive-removable-media-usb"; - } - } - - return "drive-removable-media"; - } - - return "drive-harddisk"; - - } else if (category=="volume" || category=="volume.disc") { - - QStringList capabilities = prop("info.capabilities").toStringList(); - - if (capabilities.contains("volume.disc")) { - bool has_video = prop("volume.disc.is_vcd").toBool() - || prop("volume.disc.is_svcd").toBool() - || prop("volume.disc.is_videodvd").toBool(); - bool has_audio = prop("volume.disc.has_audio").toBool(); - bool recordable = prop("volume.disc.is_blank").toBool() - || prop("volume.disc.is_appendable").toBool() - || prop("volume.disc.is_rewritable").toBool(); - - if (has_video) { - return "media-optical-video"; - } else if (has_audio) { - return "media-optical-audio"; - } else if (recordable) { - return "media-optical-recordable"; - } else { - return "media-optical"; - } - - } else { - if (!d->parent) { - d->parent = new HalDevice(parentUdi()); - } - QString iconName = d->parent->icon(); - - if (!iconName.isEmpty()) { - return iconName; - } - - return "drive-harddisk"; - } - - } else if (category=="camera") { - return "camera-photo"; - - } else if (category=="input") { - QStringList capabilities = prop("info.capabilities").toStringList(); - - if (capabilities.contains("input.mouse")) { - return "input-mouse"; - } else if (capabilities.contains("input.keyboard")) { - return "input-keyboard"; - } else if (capabilities.contains("input.joystick")) { - return "input-gaming"; - } else if (capabilities.contains("input.tablet")) { - return "input-tablet"; - } - - } else if (category=="portable_audio_player") { - QStringList protocols = prop("portable_audio_player.access_method.protocols").toStringList(); - - if (protocols.contains("ipod")) { - return "multimedia-player-apple-ipod"; - } else { - return "multimedia-player"; - } - } else if (category=="battery") { - return "battery"; - } else if (category=="processor") { - return "cpu"; // FIXME: Doesn't follow icon spec - } else if (category=="video4linux") { - return "camera-web"; - } else if (category == "alsa" || category == "oss") { - // Sorry about this const_cast, but it's the best way to not copy the code from - // AudioInterface. - const Hal::AudioInterface audioIface(const_cast(this)); - switch (audioIface.soundcardType()) { - case Solid::AudioInterface::InternalSoundcard: - return QLatin1String("audio-card"); - case Solid::AudioInterface::UsbSoundcard: - return QLatin1String("audio-card-usb"); - case Solid::AudioInterface::FirewireSoundcard: - return QLatin1String("audio-card-firewire"); - case Solid::AudioInterface::Headset: - if (udi().contains("usb", Qt::CaseInsensitive) || - audioIface.name().contains("usb", Qt::CaseInsensitive)) { - return QLatin1String("audio-headset-usb"); - } else { - return QLatin1String("audio-headset"); - } - case Solid::AudioInterface::Modem: - return QLatin1String("modem"); - } - } else if (category == "serial") { - // TODO - a serial device can be a modem, or just - // a COM port - need a new icon? - return QLatin1String("modem"); - } else if (category == "smart_card_reader") { - return QLatin1String("smart-card-reader"); - } - - return QString(); -} - -QStringList HalDevice::emblems() const -{ - QStringList res; - - if (queryDeviceInterface(Solid::DeviceInterface::StorageAccess)) { - bool isEncrypted = prop("volume.fsusage").toString()=="crypto"; - - const Hal::StorageAccess accessIface(const_cast(this)); - if (accessIface.isAccessible()) { - if (isEncrypted) { - res << "emblem-encrypted-unlocked"; - } else { - res << "emblem-mounted"; - } - } else { - if (isEncrypted) { - res << "emblem-encrypted-locked"; - } else { - res << "emblem-unmounted"; - } - } - } - - return res; -} - -QString HalDevice::description() const -{ - QString category = prop("info.category").toString(); - - if (category=="storage" || category=="storage.cdrom") { - return storageDescription(); - } else if (category=="volume" || category=="volume.disc") { - return volumeDescription(); - } else if (category=="net.80211") { - return QObject::tr("WLAN Interface"); - } else if (category=="net.80203") { - return QObject::tr("Networking Interface"); - } else { - return product(); - } -} - -QVariant HalDevice::prop(const QString &key) const -{ - d->checkCache(key); - return d->cache.value(key); -} - -void HalDevicePrivate::checkCache(const QString &key) -{ - if (cacheSynced) { - if (key.isEmpty()) { - if (invalidKeys.isEmpty()) { - return; - } - } else if (!invalidKeys.contains(key)) { - return; - } - } - - QDBusReply reply = device.call("GetAllProperties"); - - if (reply.isValid()) { - cache = reply; - } else { - qWarning() << Q_FUNC_INFO << " error: " << reply.error().name() - << ", " << reply.error().message() << endl; - cache = QVariantMap(); - } - - invalidKeys.clear(); - cacheSynced = true; - //qDebug( )<< q << udi() << "failure"; -} - -QMap HalDevice::allProperties() const -{ - d->checkCache(); - return d->cache; -} - -bool HalDevice::propertyExists(const QString &key) const -{ - d->checkCache(key); - return d->cache.value(key).isValid(); -} - -bool HalDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type) const -{ - // Special cases not matching with HAL capabilities - if (type==Solid::DeviceInterface::GenericInterface) { - return true; - } else if (type==Solid::DeviceInterface::StorageAccess) { - return prop("org.freedesktop.Hal.Device.Volume.method_names").toStringList().contains("Mount") - || prop("info.interfaces").toStringList().contains("org.freedesktop.Hal.Device.Volume.Crypto"); - } - else if (type==Solid::DeviceInterface::Video) { - if (!prop("video4linux.device").toString().contains("video" ) ) - return false; - } else if (d->capListCache.contains(type)) { - return d->capListCache.value(type); - } - - QStringList cap_list = DeviceInterface::toStringList(type); - - foreach (const QString &cap, cap_list) { - QDBusReply reply = d->device.call("QueryCapability", cap); - - if (!reply.isValid()) { - qWarning() << Q_FUNC_INFO << " error: " << reply.error().name() << endl; - return false; - } - - if (reply) { - d->capListCache.insert(type, true); - return true; - } - } - - d->capListCache.insert(type, false); - return false; -} - -QObject *HalDevice::createDeviceInterface(const Solid::DeviceInterface::Type &type) -{ - if (!queryDeviceInterface(type)) { - return 0; - } - - DeviceInterface *iface = 0; - - switch (type) - { - case Solid::DeviceInterface::GenericInterface: - iface = new GenericInterface(this); - break; - case Solid::DeviceInterface::Processor: - iface = new Processor(this); - break; - case Solid::DeviceInterface::Block: - iface = new Block(this); - break; - case Solid::DeviceInterface::StorageAccess: - iface = new StorageAccess(this); - break; - case Solid::DeviceInterface::StorageDrive: - iface = new Storage(this); - break; - case Solid::DeviceInterface::OpticalDrive: - iface = new Cdrom(this); - break; - case Solid::DeviceInterface::StorageVolume: - iface = new Volume(this); - break; - case Solid::DeviceInterface::OpticalDisc: - iface = new OpticalDisc(this); - break; - case Solid::DeviceInterface::Camera: - iface = new Camera(this); - break; - case Solid::DeviceInterface::PortableMediaPlayer: - iface = new PortableMediaPlayer(this); - break; - case Solid::DeviceInterface::NetworkInterface: - iface = new NetworkInterface(this); - break; - case Solid::DeviceInterface::AcAdapter: - iface = new AcAdapter(this); - break; - case Solid::DeviceInterface::Battery: - iface = new Battery(this); - break; - case Solid::DeviceInterface::Button: - iface = new Button(this); - break; - case Solid::DeviceInterface::AudioInterface: - iface = new AudioInterface(this); - break; - case Solid::DeviceInterface::DvbInterface: - iface = new DvbInterface(this); - break; - case Solid::DeviceInterface::Video: - iface = new Video(this); - break; - case Solid::DeviceInterface::SerialInterface: - iface = new SerialInterface(this); - break; - case Solid::DeviceInterface::SmartCardReader: - iface = new SmartCardReader(this); - break; - case Solid::DeviceInterface::InternetGateway: - break; - case Solid::DeviceInterface::NetworkShare: - break; - case Solid::DeviceInterface::Unknown: - case Solid::DeviceInterface::Last: - break; - } - - return iface; -} - -void HalDevice::slotPropertyModified(int /*count */, const QList &changes) -{ - QMap result; - - foreach (const ChangeDescription &change, changes) { - QString key = change.key; - bool added = change.added; - bool removed = change.removed; - - Solid::GenericInterface::PropertyChange type = Solid::GenericInterface::PropertyModified; - - if (added) { - type = Solid::GenericInterface::PropertyAdded; - } else if (removed) { - type = Solid::GenericInterface::PropertyRemoved; - } - - result[key] = type; - d->cache.remove(key); - - if (d->cache.isEmpty()) { - d->cacheSynced = false; - d->invalidKeys.clear(); - } else { - d->invalidKeys.insert(key); - } - } - - //qDebug() << this << "unsyncing the cache"; - emit propertyChanged(result); -} - -void HalDevice::slotCondition(const QString &condition, const QString &reason) -{ - emit conditionRaised(condition, reason); -} - -QString HalDevice::storageDescription() const -{ - QString description; - const Storage storageDrive(const_cast(this)); - Solid::StorageDrive::DriveType drive_type = storageDrive.driveType(); - bool drive_is_hotpluggable = storageDrive.isHotpluggable(); - - if (drive_type == Solid::StorageDrive::CdromDrive) { - const Cdrom opticalDrive(const_cast(this)); - Solid::OpticalDrive::MediumTypes mediumTypes = opticalDrive.supportedMedia(); - QString first; - QString second; - - first = QObject::tr("CD-ROM", "First item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Cdr) - first = QObject::tr("CD-R", "First item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Cdrw) - first = QObject::tr("CD-RW", "First item of %1%2 Drive sentence"); - - if (mediumTypes & Solid::OpticalDrive::Dvd) - second = QObject::tr("/DVD-ROM", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Dvdplusr) - second = QObject::tr("/DVD+R", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Dvdplusrw) - second = QObject::tr("/DVD+RW", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Dvdr) - second = QObject::tr("/DVD-R", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Dvdrw) - second = QObject::tr("/DVD-RW", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Dvdram) - second = QObject::tr("/DVD-RAM", "Second item of %1%2 Drive sentence"); - if ((mediumTypes & Solid::OpticalDrive::Dvdr) && (mediumTypes & Solid::OpticalDrive::Dvdplusr)) { - if(mediumTypes & Solid::OpticalDrive::Dvdplusdl) - second = QObject::tr("/DVD±R DL", "Second item of %1%2 Drive sentence"); - else - second = QObject::tr("/DVD±R", "Second item of %1%2 Drive sentence"); - } - if ((mediumTypes & Solid::OpticalDrive::Dvdrw) && (mediumTypes & Solid::OpticalDrive::Dvdplusrw)) { - if((mediumTypes & Solid::OpticalDrive::Dvdplusdl) || (mediumTypes & Solid::OpticalDrive::Dvdplusdlrw)) - second = QObject::tr("/DVD±RW DL", "Second item of %1%2 Drive sentence"); - else - second = QObject::tr("/DVD±RW", "Second item of %1%2 Drive sentence"); - } - if (mediumTypes & Solid::OpticalDrive::Bd) - second = QObject::tr("/BD-ROM", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Bdr) - second = QObject::tr("/BD-R", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::Bdre) - second = QObject::tr("/BD-RE", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::HdDvd) - second = QObject::tr("/HD DVD-ROM", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::HdDvdr) - second = QObject::tr("/HD DVD-R", "Second item of %1%2 Drive sentence"); - if (mediumTypes & Solid::OpticalDrive::HdDvdrw) - second = QObject::tr("/HD DVD-RW", "Second item of %1%2 Drive sentence"); - - if (drive_is_hotpluggable) { - description = QObject::tr("External %1%2 Drive", "%1 is CD-ROM/CD-R/etc; %2 is '/DVD-ROM'/'/DVD-R'/etc (with leading slash)").arg(first).arg(second); - } else { - description = QObject::tr("%1%2 Drive", "%1 is CD-ROM/CD-R/etc; %2 is '/DVD-ROM'/'/DVD-R'/etc (with leading slash)").arg(first).arg(second); - } - - return description; - } - - if (drive_type == Solid::StorageDrive::Floppy) { - if (drive_is_hotpluggable) - description = QObject::tr("External Floppy Drive"); - else - description = QObject::tr("Floppy Drive"); - - return description; - } - - bool drive_is_removable = storageDrive.isRemovable(); - - if (drive_type == Solid::StorageDrive::HardDisk && !drive_is_removable) { - QString size_str = formatByteSize(prop("storage.size").toInt()); - if (!size_str.isEmpty()) { - if (drive_is_hotpluggable) { - description = QObject::tr("%1 External Hard Drive", "%1 is the size").arg(size_str); - } else { - description = QObject::tr("%1 Hard Drive", "%1 is the size").arg(size_str); - } - } else { - if (drive_is_hotpluggable) - description = QObject::tr("External Hard Drive"); - else - description = QObject::tr("Hard Drive"); - } - - return description; - } - - QString vendormodel_str; - QString model = prop("storage.model").toString(); - QString vendor = prop("storage.vendor").toString(); - - if (vendor.isEmpty()) { - if (!model.isEmpty()) - vendormodel_str = model; - } else { - if (model.isEmpty()) - vendormodel_str = vendor; - else - vendormodel_str = QObject::tr("%1 %2", "%1 is the vendor, %2 is the model of the device").arg(vendor).arg(model); - } - - if (vendormodel_str.isEmpty()) - description = QObject::tr("Drive"); - else - description = vendormodel_str; - - return description; -} - -QString HalDevice::volumeDescription() const -{ - QString description; - QString volume_label = prop("volume.label").toString(); - - if (!volume_label.isEmpty()) { - return volume_label; - } - - if (!d->parent) { - d->parent = new HalDevice(parentUdi()); - } - const Storage storageDrive(const_cast(d->parent)); - Solid::StorageDrive::DriveType drive_type = storageDrive.driveType(); - - /* Handle media in optical drives */ - if (drive_type == Solid::StorageDrive::CdromDrive) { - const OpticalDisc disc(const_cast(this)); - switch (disc.discType()) { - case Solid::OpticalDisc::UnknownDiscType: - case Solid::OpticalDisc::CdRom: - description = QObject::tr("CD-ROM"); - break; - - case Solid::OpticalDisc::CdRecordable: - if (disc.isBlank()) - description = QObject::tr("Blank CD-R"); - else - description = QObject::tr("CD-R"); - break; - - case Solid::OpticalDisc::CdRewritable: - if (disc.isBlank()) - description = QObject::tr("Blank CD-RW"); - else - description = QObject::tr("CD-RW"); - break; - - case Solid::OpticalDisc::DvdRom: - description = QObject::tr("DVD-ROM"); - break; - - case Solid::OpticalDisc::DvdRam: - if (disc.isBlank()) - description = QObject::tr("Blank DVD-RAM"); - else - description = QObject::tr("DVD-RAM"); - break; - - case Solid::OpticalDisc::DvdRecordable: - if (disc.isBlank()) - description = QObject::tr("Blank DVD-R"); - else - description = QObject::tr("DVD-R"); - break; - - case Solid::OpticalDisc::DvdPlusRecordableDuallayer: - if (disc.isBlank()) - description = QObject::tr("Blank DVD+R Dual-Layer"); - else - description = QObject::tr("DVD+R Dual-Layer"); - break; - - case Solid::OpticalDisc::DvdRewritable: - if (disc.isBlank()) - description = QObject::tr("Blank DVD-RW"); - else - description = QObject::tr("DVD-RW"); - break; - - case Solid::OpticalDisc::DvdPlusRecordable: - if (disc.isBlank()) - description = QObject::tr("Blank DVD+R"); - else - description = QObject::tr("DVD+R"); - break; - - case Solid::OpticalDisc::DvdPlusRewritable: - if (disc.isBlank()) - description = QObject::tr("Blank DVD+RW"); - else - description = QObject::tr("DVD+RW"); - break; - - case Solid::OpticalDisc::DvdPlusRewritableDuallayer: - if (disc.isBlank()) - description = QObject::tr("Blank DVD+RW Dual-Layer"); - else - description = QObject::tr("DVD+RW Dual-Layer"); - break; - - case Solid::OpticalDisc::BluRayRom: - description = QObject::tr("BD-ROM"); - break; - - case Solid::OpticalDisc::BluRayRecordable: - if (disc.isBlank()) - description = QObject::tr("Blank BD-R"); - else - description = QObject::tr("BD-R"); - break; - - case Solid::OpticalDisc::BluRayRewritable: - if (disc.isBlank()) - description = QObject::tr("Blank BD-RE"); - else - description = QObject::tr("BD-RE"); - break; - - case Solid::OpticalDisc::HdDvdRom: - description = QObject::tr("HD DVD-ROM"); - break; - - case Solid::OpticalDisc::HdDvdRecordable: - if (disc.isBlank()) - description = QObject::tr("Blank HD DVD-R"); - else - description = QObject::tr("HD DVD-R"); - break; - - case Solid::OpticalDisc::HdDvdRewritable: - if (disc.isBlank()) - description = QObject::tr("Blank HD DVD-RW"); - else - description = QObject::tr("HD DVD-RW"); - break; - } - - /* Special case for pure audio disc */ - if (disc.availableContent() == Solid::OpticalDisc::Audio) { - description = QObject::tr("Audio CD"); - } - - return description; - } - - bool drive_is_removable = storageDrive.isRemovable(); - bool drive_is_hotpluggable = storageDrive.isHotpluggable(); - bool drive_is_encrypted_container = prop("volume.fsusage").toString()=="crypto"; - - QString size_str = formatByteSize(prop("volume.size").toULongLong()); - if (drive_is_encrypted_container) { - if (!size_str.isEmpty()) { - description = QObject::tr("%1 Encrypted Container", "%1 is the size").arg(size_str); - } else { - description = QObject::tr("Encrypted Container"); - } - } else if (drive_type == Solid::StorageDrive::HardDisk && !drive_is_removable) { - if (!size_str.isEmpty()) { - if (drive_is_hotpluggable) { - description = QObject::tr("%1 External Hard Drive", "%1 is the size").arg(size_str); - } else { - description = QObject::tr("%1 Hard Drive", "%1 is the size").arg(size_str); - } - } else { - if (drive_is_hotpluggable) - description = QObject::tr("External Hard Drive"); - else - description = QObject::tr("Hard Drive"); - } - } else { - if (drive_is_removable) { - description = QObject::tr("%1 Removable Media", "%1 is the size").arg(size_str); - } else { - description = QObject::tr("%1 Media", "%1 is the size").arg(size_str); - } - } - - return description; -} - -#include "backends/hal/haldevice.moc" diff --git a/solid/solid/backends/hal/haldevice.h b/solid/solid/backends/hal/haldevice.h deleted file mode 100644 index fc7dfd0b..00000000 --- a/solid/solid/backends/hal/haldevice.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright 2005,2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_HALDEVICE_H -#define SOLID_BACKENDS_HAL_HALDEVICE_H - -#include - -class QDBusVariant; - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalManager; -class HalDevicePrivate; - -struct ChangeDescription -{ - QString key; - bool added; - bool removed; -}; - -class HalDevice : public Solid::Ifaces::Device -{ - Q_OBJECT - -public: - HalDevice(const QString &udi); - virtual ~HalDevice(); - - virtual QString udi() const; - virtual QString parentUdi() const; - - virtual QString vendor() const; - virtual QString product() const; - virtual QString icon() const; - virtual QStringList emblems() const; - virtual QString description() const; - - virtual bool queryDeviceInterface(const Solid::DeviceInterface::Type &type) const; - virtual QObject *createDeviceInterface(const Solid::DeviceInterface::Type &type); - -public: - QVariant prop(const QString &key) const; - QMap allProperties() const; - bool propertyExists(const QString &key) const; - -Q_SIGNALS: - void propertyChanged(const QMap &changes); - void conditionRaised(const QString &condition, const QString &reason); - -private Q_SLOTS: - void slotPropertyModified(int count, const QList &changes); - void slotCondition(const QString &condition, const QString &reason); - -private: - QString storageDescription() const; - QString volumeDescription() const; - - HalDevicePrivate *d; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_HALDEVICE_H diff --git a/solid/solid/backends/hal/haldeviceinterface.cpp b/solid/solid/backends/hal/haldeviceinterface.cpp deleted file mode 100644 index 60aacdfb..00000000 --- a/solid/solid/backends/hal/haldeviceinterface.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "haldeviceinterface.h" - -using namespace Solid::Backends::Hal; - -DeviceInterface::DeviceInterface(HalDevice *device) - : QObject(device), m_device(device) -{ -} - -DeviceInterface::~DeviceInterface() -{ -} - -#include "backends/hal/haldeviceinterface.moc" diff --git a/solid/solid/backends/hal/haldeviceinterface.h b/solid/solid/backends/hal/haldeviceinterface.h deleted file mode 100644 index 1d701871..00000000 --- a/solid/solid/backends/hal/haldeviceinterface.h +++ /dev/null @@ -1,171 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_DEVICEINTERFACE_H -#define SOLID_BACKENDS_HAL_DEVICEINTERFACE_H - -#include -#include "haldevice.h" - -#include -#include - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class DeviceInterface : public QObject, virtual public Solid::Ifaces::DeviceInterface -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::DeviceInterface) -public: - DeviceInterface(HalDevice *device); - virtual ~DeviceInterface(); - -protected: - HalDevice *m_device; - -public: - inline static QStringList toStringList(Solid::DeviceInterface::Type type) - { - QStringList list; - - switch(type) - { - case Solid::DeviceInterface::GenericInterface: - // Doesn't exist with HAL - break; - case Solid::DeviceInterface::Processor: - list << "processor"; - break; - case Solid::DeviceInterface::Block: - list << "block"; - break; - case Solid::DeviceInterface::StorageAccess: - // Doesn't exist with HAL, but let's assume volume always cover this type - list << "volume"; - break; - case Solid::DeviceInterface::StorageDrive: - list << "storage"; - break; - case Solid::DeviceInterface::OpticalDrive: - list << "storage.cdrom"; - break; - case Solid::DeviceInterface::StorageVolume: - list << "volume"; - break; - case Solid::DeviceInterface::OpticalDisc: - list << "volume.disc"; - break; - case Solid::DeviceInterface::Camera: - list << "camera"; - break; - case Solid::DeviceInterface::PortableMediaPlayer: - list << "portable_audio_player"; - break; - case Solid::DeviceInterface::NetworkInterface: - list << "net"; - break; - case Solid::DeviceInterface::AcAdapter: - list << "ac_adapter"; - break; - case Solid::DeviceInterface::Battery: - list << "battery"; - break; - case Solid::DeviceInterface::Button: - list << "button"; - break; - case Solid::DeviceInterface::AudioInterface: - list << "alsa" << "oss"; - break; - case Solid::DeviceInterface::DvbInterface: - list << "dvb"; - break; - case Solid::DeviceInterface::Video: - list << "video4linux"; - break; - case Solid::DeviceInterface::SerialInterface: - list << "serial"; - break; - case Solid::DeviceInterface::SmartCardReader: - list << "smart_card_reader"; - case Solid::DeviceInterface::InternetGateway: - list << "internet_gateway"; - case Solid::DeviceInterface::NetworkShare: - list << "networkshare"; - break; - case Solid::DeviceInterface::Unknown: - break; - case Solid::DeviceInterface::Last: - break; - } - - return list; - } - - inline static Solid::DeviceInterface::Type fromString(const QString &capability) - { - if (capability == "processor") - return Solid::DeviceInterface::Processor; - else if (capability == "block") - return Solid::DeviceInterface::Block; - else if (capability == "storage") - return Solid::DeviceInterface::StorageDrive; - else if (capability == "storage.cdrom") - return Solid::DeviceInterface::OpticalDrive; - else if (capability == "volume") - return Solid::DeviceInterface::StorageVolume; - else if (capability == "volume.disc") - return Solid::DeviceInterface::OpticalDisc; - else if (capability == "camera") - return Solid::DeviceInterface::Camera; - else if (capability == "portable_audio_player") - return Solid::DeviceInterface::PortableMediaPlayer; - else if (capability == "net") - return Solid::DeviceInterface::NetworkInterface; - else if (capability == "ac_adapter") - return Solid::DeviceInterface::AcAdapter; - else if (capability == "battery") - return Solid::DeviceInterface::Battery; - else if (capability == "button") - return Solid::DeviceInterface::Button; - else if (capability == "alsa" || capability == "oss") - return Solid::DeviceInterface::AudioInterface; - else if (capability == "dvb") - return Solid::DeviceInterface::DvbInterface; - else if (capability == "video4linux") - return Solid::DeviceInterface::Video; - else if (capability == "serial") - return Solid::DeviceInterface::SerialInterface; - else if (capability == "smart_card_reader") - return Solid::DeviceInterface::SmartCardReader; - else if (capability == "networkshare") - return Solid::DeviceInterface::NetworkShare; - else - return Solid::DeviceInterface::Unknown; - } -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_DEVICEINTERFACE_H diff --git a/solid/solid/backends/hal/haldvbinterface.cpp b/solid/solid/backends/hal/haldvbinterface.cpp deleted file mode 100644 index b745dfa4..00000000 --- a/solid/solid/backends/hal/haldvbinterface.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - Copyright 2007 Kevin Ottens - Copyright 2007 Christoph Pfister - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "haldvbinterface.h" - -#include "haldevice.h" - -using namespace Solid::Backends::Hal; - -DvbInterface::DvbInterface(HalDevice *device) - : DeviceInterface(device) -{ - -} - -DvbInterface::~DvbInterface() -{ - -} - -QString DvbInterface::device() const -{ - return m_device->prop("dvb.device").toString(); -} - -int DvbInterface::deviceAdapter() const -{ - QString string = device(); - int pos = string.lastIndexOf('/'); - if (pos < 0) - return -1; - string = string.left(pos); - - pos = string.lastIndexOf('/'); - if (pos < 0) - return -1; - string = string.mid(pos + 1); - - if (!string.startsWith(QLatin1String("adapter"))) - return -1; - string = string.mid(7); - - bool ok; - int adapter = string.toInt(&ok, 10); - if (ok) - return adapter; - else - return -1; -} - -Solid::DvbInterface::DeviceType DvbInterface::deviceType() const -{ - Solid::DvbInterface::DeviceType type; - int index; - - if (parseTypeIndex(&type, &index)) - return type; - else - return Solid::DvbInterface::DvbUnknown; -} - -int DvbInterface::deviceIndex() const -{ - Solid::DvbInterface::DeviceType type; - int index; - - if (parseTypeIndex(&type, &index)) - return index; - else - return -1; -} - -bool DvbInterface::parseTypeIndex(Solid::DvbInterface::DeviceType *type, int *index) const -{ - QString string = device(); - int pos = string.lastIndexOf('/'); - if (pos < 0) - return false; - string = string.mid(pos + 1); - - if (string.startsWith(QLatin1String("audio"))) { - *type = Solid::DvbInterface::DvbAudio; - string = string.mid(5); - } else if (string.startsWith(QLatin1String("ca"))) { - *type = Solid::DvbInterface::DvbCa; - string = string.mid(2); - } else if (string.startsWith(QLatin1String("demux"))) { - *type = Solid::DvbInterface::DvbDemux; - string = string.mid(5); - } else if (string.startsWith(QLatin1String("dvr"))) { - *type = Solid::DvbInterface::DvbDvr; - string = string.mid(3); - } else if (string.startsWith(QLatin1String("frontend"))) { - *type = Solid::DvbInterface::DvbFrontend; - string = string.mid(8); - } else if (string.startsWith(QLatin1String("net"))) { - *type = Solid::DvbInterface::DvbNet; - string = string.mid(3); - } else if (string.startsWith(QLatin1String("osd"))) { - *type = Solid::DvbInterface::DvbOsd; - string = string.mid(3); - } else if (string.startsWith(QLatin1String("sec"))) { - *type = Solid::DvbInterface::DvbSec; - string = string.mid(3); - } else if (string.startsWith(QLatin1String("video"))) { - *type = Solid::DvbInterface::DvbVideo; - string = string.mid(5); - } else - return false; - - bool ok; - *index = string.toInt(&ok, 10); - - return ok; -} - -#include "backends/hal/haldvbinterface.moc" diff --git a/solid/solid/backends/hal/haldvbinterface.h b/solid/solid/backends/hal/haldvbinterface.h deleted file mode 100644 index 67a90013..00000000 --- a/solid/solid/backends/hal/haldvbinterface.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright 2007 Kevin Ottens - Copyright 2007 Christoph Pfister - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_HALDVBINTERFACE_H -#define SOLID_BACKENDS_HAL_HALDVBINTERFACE_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class DvbInterface : public DeviceInterface, virtual public Solid::Ifaces::DvbInterface -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::DvbInterface) - -public: - DvbInterface(HalDevice *device); - virtual ~DvbInterface(); - - virtual QString device() const; - virtual int deviceAdapter() const; - virtual Solid::DvbInterface::DeviceType deviceType() const; - virtual int deviceIndex() const; - -private: - bool parseTypeIndex(Solid::DvbInterface::DeviceType *type, int *index) const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_HALDVBINTERFACE_H diff --git a/solid/solid/backends/hal/halfstabhandling.cpp b/solid/solid/backends/hal/halfstabhandling.cpp deleted file mode 100644 index 2fcbe43e..00000000 --- a/solid/solid/backends/hal/halfstabhandling.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright 2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halfstabhandling.h" - -#include -#include -#include -#include -#include -#include - -#include - -#ifdef HAVE_MNTENT_H -#include -#elif defined(HAVE_SYS_MNTENT_H) -#include -#endif - -#ifdef Q_OS_SOLARIS -#define FSTAB "/etc/vfstab" -#else -#define FSTAB "/etc/fstab" -#endif - -typedef QMultiHash QStringMultiHash; -SOLID_GLOBAL_STATIC(QStringMultiHash, globalMountPointsCache) - -QString _k_resolveSymLink(const QString &filename) -{ - QString resolved = filename; - QString tmp = QFile::symLinkTarget(filename); - - while (!tmp.isEmpty()) { - resolved = tmp; - tmp = QFile::symLinkTarget(resolved); - } - - return resolved; -} - -bool _k_isNetworkFileSystem(const QString &fstype, const QString &devName) -{ - if (fstype == "nfs" - || fstype == "nfs4" - || fstype == "smbfs" - || fstype == "cifs" - || devName.startsWith(QLatin1String("//"))) { - return true; - } - return false; -} - - -void _k_updateMountPointsCache() -{ - static bool firstCall = true; - static QTime elapsedTime; - - if (firstCall) { - firstCall = false; - elapsedTime.start(); - } else if (elapsedTime.elapsed()>10000) { - elapsedTime.restart(); - } else { - return; - } - - globalMountPointsCache->clear(); - -#ifdef HAVE_SETMNTENT - - struct mntent *fstab; - if ((fstab = setmntent(FSTAB, "r")) == 0) { - return; - } - - struct mntent *fe; - while ((fe = getmntent(fstab)) != 0) { - if (!_k_isNetworkFileSystem(fe->mnt_type, fe->mnt_fsname)) { - const QString device = _k_resolveSymLink(QFile::decodeName(fe->mnt_fsname)); - const QString mountpoint = _k_resolveSymLink(QFile::decodeName(fe->mnt_dir)); - - globalMountPointsCache->insert(device, mountpoint); - } - } - - endmntent(fstab); - -#else - - QFile fstab(FSTAB); - if (!fstab.open(QIODevice::ReadOnly)) { - return; - } - - QTextStream stream(&fstab); - QString line; - - while (!stream.atEnd()) { - line = stream.readLine().simplified(); - if (line.isEmpty() || line.startsWith('#')) { - continue; - } - - // not empty or commented out by '#' - const QStringList items = line.split(' '); - -#ifdef Q_OS_SOLARIS - if (items.count() < 5) { - continue; - } -#else - if (items.count() < 4) { - continue; - } -#endif - //prevent accessing a blocking directory - if (!_k_isNetworkFileSystem(items.at(2), items.at(0))) { - const QString device = _k_resolveSymLink(items.at(0)); - const QString mountpoint = _k_resolveSymLink(items.at(1)); - - globalMountPointsCache->insert(device, mountpoint); - } - } - - fstab.close(); -#endif -} - -bool Solid::Backends::Hal::FstabHandling::isInFstab(const QString &device) -{ - _k_updateMountPointsCache(); - const QString deviceToFind = _k_resolveSymLink(device); - - return globalMountPointsCache->contains(deviceToFind); -} - -QStringList Solid::Backends::Hal::FstabHandling::possibleMountPoints(const QString &device) -{ - _k_updateMountPointsCache(); - const QString deviceToFind = _k_resolveSymLink(device); - - return globalMountPointsCache->values(deviceToFind); -} - -QProcess *Solid::Backends::Hal::FstabHandling::callSystemCommand(const QString &commandName, - const QStringList &args, - QObject *obj, const char *slot) -{ - QStringList env = QProcess::systemEnvironment(); - env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=/sbin:/bin:/usr/sbin/:/usr/bin"); - - QProcess *process = new QProcess(obj); - - QObject::connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), - obj, slot); - - process->setEnvironment(env); - process->start(commandName, args); - - if (process->waitForStarted()) { - return process; - } else { - delete process; - return 0; - } -} - -QProcess *Solid::Backends::Hal::FstabHandling::callSystemCommand(const QString &commandName, - const QString &device, - QObject *obj, const char *slot) -{ - return callSystemCommand(commandName, QStringList() << device, obj, slot); -} - diff --git a/solid/solid/backends/hal/halfstabhandling.h b/solid/solid/backends/hal/halfstabhandling.h deleted file mode 100644 index bd20729a..00000000 --- a/solid/solid/backends/hal/halfstabhandling.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_FSTABHANDLING_H -#define SOLID_BACKENDS_HAL_FSTABHANDLING_H - -#include - -class QProcess; -class QObject; - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class FstabHandling -{ -public: - static bool isInFstab(const QString &device); - static QStringList possibleMountPoints(const QString &device); - static QProcess *callSystemCommand(const QString &commandName, - const QStringList &args, - QObject *obj, const char *slot); - static QProcess *callSystemCommand(const QString &commandName, - const QString &device, - QObject *obj, const char *slot); -}; -} -} -} - -#endif - - diff --git a/solid/solid/backends/hal/halgenericinterface.cpp b/solid/solid/backends/hal/halgenericinterface.cpp deleted file mode 100644 index f8cc6130..00000000 --- a/solid/solid/backends/hal/halgenericinterface.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halgenericinterface.h" - -#include "haldevice.h" - -using namespace Solid::Backends::Hal; - -GenericInterface::GenericInterface(HalDevice *device) - : DeviceInterface(device) -{ - connect(device, SIGNAL(propertyChanged(QMap)), - this, SIGNAL(propertyChanged(QMap))); - connect(device, SIGNAL(conditionRaised(QString,QString)), - this, SIGNAL(conditionRaised(QString,QString))); -} - -GenericInterface::~GenericInterface() -{ - -} - -QVariant GenericInterface::property(const QString &key) const -{ - return m_device->prop(key); -} - -QMap GenericInterface::allProperties() const -{ - return m_device->allProperties(); -} - -bool GenericInterface::propertyExists(const QString &key) const -{ - return m_device->propertyExists(key); -} - -#include "backends/hal/halgenericinterface.moc" diff --git a/solid/solid/backends/hal/halgenericinterface.h b/solid/solid/backends/hal/halgenericinterface.h deleted file mode 100644 index eb6bc555..00000000 --- a/solid/solid/backends/hal/halgenericinterface.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright 2007 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_GENERICINTERFACE_H -#define SOLID_BACKENDS_HAL_GENERICINTERFACE_H - -#include -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalDevice; - -class GenericInterface : public DeviceInterface, virtual public Solid::Ifaces::GenericInterface -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::GenericInterface) - -public: - GenericInterface(HalDevice *device); - virtual ~GenericInterface(); - - virtual QVariant property(const QString &key) const; - virtual QMap allProperties() const; - virtual bool propertyExists(const QString &key) const; - -Q_SIGNALS: - void propertyChanged(const QMap &changes); - void conditionRaised(const QString &condition, const QString &reason); -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_GENERICINTERFACE_H diff --git a/solid/solid/backends/hal/halmanager.cpp b/solid/solid/backends/hal/halmanager.cpp deleted file mode 100644 index 7238b6a9..00000000 --- a/solid/solid/backends/hal/halmanager.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright 2005,2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halmanager.h" -#include "haldevice.h" -#include "haldeviceinterface.h" - -#include -#include -#include -#include - -using namespace Solid::Backends::Hal; - -class Solid::Backends::Hal::HalManagerPrivate -{ -public: - HalManagerPrivate() : manager("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - QDBusConnection::systemBus()), - cacheSynced(false) { } - - QDBusInterface manager; - QList devicesCache; - bool cacheSynced; - QSet supportedInterfaces; -}; - - -HalManager::HalManager(QObject *parent) - : DeviceManager(parent), d(new HalManagerPrivate()) -{ - d->manager.connection().connect("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - "DeviceAdded", - this, SLOT(slotDeviceAdded(QString))); - - d->manager.connection().connect("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - "DeviceRemoved", - this, SLOT(slotDeviceRemoved(QString))); - - d->supportedInterfaces << Solid::DeviceInterface::GenericInterface - << Solid::DeviceInterface::Processor - << Solid::DeviceInterface::Block - << Solid::DeviceInterface::StorageAccess - << Solid::DeviceInterface::StorageDrive - << Solid::DeviceInterface::OpticalDrive - << Solid::DeviceInterface::StorageVolume - << Solid::DeviceInterface::OpticalDisc - << Solid::DeviceInterface::Camera - << Solid::DeviceInterface::PortableMediaPlayer - << Solid::DeviceInterface::NetworkInterface - << Solid::DeviceInterface::AcAdapter - << Solid::DeviceInterface::Battery - << Solid::DeviceInterface::Button - << Solid::DeviceInterface::AudioInterface - << Solid::DeviceInterface::DvbInterface - << Solid::DeviceInterface::Video - << Solid::DeviceInterface::SerialInterface - << Solid::DeviceInterface::SmartCardReader; -} - -HalManager::~HalManager() -{ - delete d; -} - -QString HalManager::udiPrefix() const -{ - return "/org/freedesktop/Hal"; -} - -QSet HalManager::supportedInterfaces() const -{ - return d->supportedInterfaces; -} - -QStringList HalManager::allDevices() -{ - if (d->cacheSynced) - { - return d->devicesCache; - } - - QDBusReply reply = d->manager.call("GetAllDevices"); - - if (!reply.isValid()) - { - qWarning() << Q_FUNC_INFO << " error: " << reply.error().name() << endl; - return QStringList(); - } - - d->devicesCache = reply; - d->cacheSynced = true; - - return reply; -} - -bool HalManager::deviceExists(const QString &udi) -{ - if (d->devicesCache.contains(udi)) - { - return true; - } - else if (d->cacheSynced) - { - return false; - } - - QDBusReply reply = d->manager.call("DeviceExists", udi); - - if (!reply.isValid()) - { - qWarning() << Q_FUNC_INFO << " error: " << reply.error().name() << endl; - return false; - } - - if (reply) - { - d->devicesCache.append(udi); - } - - return reply; -} - -QStringList HalManager::devicesFromQuery(const QString &parentUdi, - Solid::DeviceInterface::Type type) -{ - if ((parentUdi.isEmpty()) && (type == Solid::DeviceInterface::Unknown)) { - return allDevices(); - } - - QStringList result; - - foreach (const QString &udi, allDevices()) { - HalDevice device(udi); - - if ((!parentUdi.isEmpty()) && (parentUdi != device.parentUdi())) { - continue; - } - - if ((type != Solid::DeviceInterface::Unknown) && (!device.queryDeviceInterface(type))) { - continue; - } - - result << udi; - } - - return result; -} - -QObject *HalManager::createDevice(const QString &udi) -{ - if (deviceExists(udi)) { - return new HalDevice(udi); - } else { - return 0; - } -} - -void HalManager::slotDeviceAdded(const QString &udi) -{ - d->devicesCache.append(udi); - emit deviceAdded(udi); -} - -void HalManager::slotDeviceRemoved(const QString &udi) -{ - d->devicesCache.removeAll(udi); - emit deviceRemoved(udi); -} - -#include "backends/hal/halmanager.moc" diff --git a/solid/solid/backends/hal/halmanager.h b/solid/solid/backends/hal/halmanager.h deleted file mode 100644 index 377b15d5..00000000 --- a/solid/solid/backends/hal/halmanager.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright 2005,2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_HALMANAGER_H -#define SOLID_BACKENDS_HAL_HALMANAGER_H - -#include -#include - -#include -#include - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalManagerPrivate; - -class HalManager : public Solid::Ifaces::DeviceManager -{ - Q_OBJECT - -public: - HalManager(QObject *parent); - virtual ~HalManager(); - - virtual QString udiPrefix() const ; - virtual QSet supportedInterfaces() const; - - bool deviceExists(const QString &udi); - virtual QStringList allDevices(); - - virtual QStringList devicesFromQuery(const QString &parentUdi, - Solid::DeviceInterface::Type type); - - virtual QObject *createDevice(const QString &udi); - -private Q_SLOTS: - void slotDeviceAdded(const QString &udi); - void slotDeviceRemoved(const QString &udi); - -private: - HalManagerPrivate *d; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_HALMANAGER_H diff --git a/solid/solid/backends/hal/halnetworkinterface.cpp b/solid/solid/backends/hal/halnetworkinterface.cpp deleted file mode 100644 index e7f7b3fe..00000000 --- a/solid/solid/backends/hal/halnetworkinterface.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halnetworkinterface.h" - -#include "haldevice.h" - -#include - -using namespace Solid::Backends::Hal; - -NetworkInterface::NetworkInterface(HalDevice *device) - : DeviceInterface(device) -{ - -} - -NetworkInterface::~NetworkInterface() -{ - -} - -QString NetworkInterface::ifaceName() const -{ - return m_device->prop("net.interface").toString(); -} - -bool NetworkInterface::isWireless() const -{ - QStringList capabilities = m_device->prop("info.capabilities").toStringList(); - - return capabilities.contains("net.80211"); -} - -QString NetworkInterface::hwAddress() const -{ - return m_device->prop("net.address").toString(); -} - -qulonglong NetworkInterface::macAddress() const -{ - if (m_device->propertyExists("net.80211.mac_address")) - { - return m_device->prop("net.80211.mac_address").toULongLong(); - } - else - { - return m_device->prop("net.80203.mac_address").toULongLong(); - } -} - -#include "backends/hal/halnetworkinterface.moc" diff --git a/solid/solid/backends/hal/halnetworkinterface.h b/solid/solid/backends/hal/halnetworkinterface.h deleted file mode 100644 index 7466e7f8..00000000 --- a/solid/solid/backends/hal/halnetworkinterface.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_HALNETWORKINTERFACE_H -#define SOLID_BACKENDS_HAL_HALNETWORKINTERFACE_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalDevice; - -class NetworkInterface : public DeviceInterface, virtual public Solid::Ifaces::NetworkInterface -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::NetworkInterface) - -public: - NetworkInterface(HalDevice *device); - virtual ~NetworkInterface(); - - virtual QString ifaceName() const; - virtual bool isWireless() const; - virtual QString hwAddress() const; - virtual qulonglong macAddress() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_HALNETWORKINTERFACE_H diff --git a/solid/solid/backends/hal/halopticaldisc.cpp b/solid/solid/backends/hal/halopticaldisc.cpp deleted file mode 100644 index a6d3d6d7..00000000 --- a/solid/solid/backends/hal/halopticaldisc.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halopticaldisc.h" - -using namespace Solid::Backends::Hal; - -OpticalDisc::OpticalDisc(HalDevice *device) - : Volume(device) -{ - -} - -OpticalDisc::~OpticalDisc() -{ - -} - - -Solid::OpticalDisc::ContentTypes OpticalDisc::availableContent() const -{ - Solid::OpticalDisc::ContentTypes content; - - QMap map; - map[Solid::OpticalDisc::Audio] = "volume.disc.has_audio"; - map[Solid::OpticalDisc::Data] = "volume.disc.has_data"; - map[Solid::OpticalDisc::VideoCd] = "volume.disc.is_vcd"; - map[Solid::OpticalDisc::SuperVideoCd] = "volume.disc.is_svcd"; - map[Solid::OpticalDisc::VideoDvd] ="volume.disc.is_videodvd"; - map[Solid::OpticalDisc::VideoBluRay] ="volume.disc.is_blurayvideo"; - - foreach (const Solid::OpticalDisc::ContentType type, map.keys()) - { - if (m_device->prop(map[type]).toBool()) - { - content|= type; - } - } - - return content; -} - -Solid::OpticalDisc::DiscType OpticalDisc::discType() const -{ - QString type = m_device->prop("volume.disc.type").toString(); - - if (type == "cd_rom") - { - return Solid::OpticalDisc::CdRom; - } - else if (type == "cd_r") - { - return Solid::OpticalDisc::CdRecordable; - } - else if (type == "cd_rw") - { - return Solid::OpticalDisc::CdRewritable; - } - else if (type == "dvd_rom") - { - return Solid::OpticalDisc::DvdRom; - } - else if (type == "dvd_ram") - { - return Solid::OpticalDisc::DvdRam; - } - else if (type == "dvd_r") - { - return Solid::OpticalDisc::DvdRecordable; - } - else if (type == "dvd_rw") - { - return Solid::OpticalDisc::DvdRewritable; - } - else if (type == "dvd_plus_r") - { - return Solid::OpticalDisc::DvdPlusRecordable; - } - else if (type == "dvd_plus_rw") - { - return Solid::OpticalDisc::DvdPlusRewritable; - } - else if (type == "dvd_plus_r_dl") - { - return Solid::OpticalDisc::DvdPlusRecordableDuallayer; - } - else if (type == "dvd_plus_rw_dl") - { - return Solid::OpticalDisc::DvdPlusRewritableDuallayer; - } - else if (type == "bd_rom") - { - return Solid::OpticalDisc::BluRayRom; - } - else if (type == "bd_r") - { - return Solid::OpticalDisc::BluRayRecordable; - } - else if (type == "bd_re") - { - return Solid::OpticalDisc::BluRayRewritable; - } - else if (type == "hddvd_rom") - { - return Solid::OpticalDisc::HdDvdRom; - } - else if (type == "hddvd_r") - { - return Solid::OpticalDisc::HdDvdRecordable; - } - else if (type == "hddvd_rw") - { - return Solid::OpticalDisc::HdDvdRewritable; - } - else - { - return Solid::OpticalDisc::UnknownDiscType; - } -} - -bool OpticalDisc::isAppendable() const -{ - return m_device->prop("volume.disc.is_appendable").toBool(); -} - -bool OpticalDisc::isBlank() const -{ - return m_device->prop("volume.disc.is_blank").toBool(); -} - -bool OpticalDisc::isRewritable() const -{ - return m_device->prop("volume.disc.is_rewritable").toBool(); -} - -qulonglong OpticalDisc::capacity() const -{ - return m_device->prop("volume.disc.capacity").toULongLong(); -} - -#include "backends/hal/halopticaldisc.moc" diff --git a/solid/solid/backends/hal/halopticaldisc.h b/solid/solid/backends/hal/halopticaldisc.h deleted file mode 100644 index 71af0e56..00000000 --- a/solid/solid/backends/hal/halopticaldisc.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_OPTICALDISC_H -#define SOLID_BACKENDS_HAL_OPTICALDISC_H - -#include -#include "halvolume.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class OpticalDisc : public Volume, virtual public Solid::Ifaces::OpticalDisc -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::OpticalDisc) - -public: - OpticalDisc(HalDevice *device); - virtual ~OpticalDisc(); - - virtual Solid::OpticalDisc::ContentTypes availableContent() const; - virtual Solid::OpticalDisc::DiscType discType() const; - virtual bool isAppendable() const; - virtual bool isBlank() const; - virtual bool isRewritable() const; - virtual qulonglong capacity() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_OPTICALDISC_H diff --git a/solid/solid/backends/hal/halportablemediaplayer.cpp b/solid/solid/backends/hal/halportablemediaplayer.cpp deleted file mode 100644 index ce64478c..00000000 --- a/solid/solid/backends/hal/halportablemediaplayer.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright 2006 Davide Bettio - Copyright 2007 Jeff Mitchell - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halportablemediaplayer.h" - -using namespace Solid::Backends::Hal; - -PortableMediaPlayer::PortableMediaPlayer(HalDevice *device) - : DeviceInterface(device) -{ - -} - -PortableMediaPlayer::~PortableMediaPlayer() -{ - -} - -QStringList PortableMediaPlayer::supportedProtocols() const -{ - return m_device->prop("portable_audio_player.access_method.protocols").toStringList(); -} - -QStringList PortableMediaPlayer::supportedDrivers(QString protocol) const -{ - QStringList drivers = m_device->prop("portable_audio_player.access_method.drivers").toStringList(); - if(protocol.isNull()) - return drivers; - QStringList returnedDrivers; - QString temp; - for(int i = 0; i < drivers.size(); i++) - { - temp = drivers.at(i); - if(m_device->prop("portable_audio_player." + temp + ".protocol") == protocol) - returnedDrivers << temp; - } - return returnedDrivers; -} - -QVariant PortableMediaPlayer::driverHandle(const QString &driver) const -{ - if (driver=="mtp") { - return m_device->prop("usb.serial"); - } - // TODO: Fill in the blank for other drivers - - return QVariant(); -} - -#include "backends/hal/halportablemediaplayer.moc" diff --git a/solid/solid/backends/hal/halportablemediaplayer.h b/solid/solid/backends/hal/halportablemediaplayer.h deleted file mode 100644 index e82e8252..00000000 --- a/solid/solid/backends/hal/halportablemediaplayer.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright 2006 Davide Bettio - Copyright 2007 Jeff Mitchell - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_PORTABLEMEDIAPLAYER_H -#define SOLID_BACKENDS_HAL_PORTABLEMEDIAPLAYER_H - -#include -#include "haldeviceinterface.h" - -#include - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalDevice; - -class PortableMediaPlayer : public DeviceInterface, virtual public Solid::Ifaces::PortableMediaPlayer -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::PortableMediaPlayer) - -public: - PortableMediaPlayer(HalDevice *device); - virtual ~PortableMediaPlayer(); - - virtual QStringList supportedProtocols() const; - virtual QStringList supportedDrivers(QString protocol = QString()) const; - virtual QVariant driverHandle(const QString &driver) const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_PORTABLEMEDIAPLAYER_H diff --git a/solid/solid/backends/hal/halprocessor.cpp b/solid/solid/backends/hal/halprocessor.cpp deleted file mode 100644 index 3202ed67..00000000 --- a/solid/solid/backends/hal/halprocessor.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halprocessor.h" - -#include "haldevice.h" -#include "../shared/cpufeatures.h" - -using namespace Solid::Backends::Hal; - -Processor::Processor(HalDevice *device) - : DeviceInterface(device) -{ - -} - -Processor::~Processor() -{ - -} - -int Processor::number() const -{ - return m_device->prop("processor.number").toInt(); -} - -int Processor::maxSpeed() const -{ - // the property is not mandatory in HAL - return m_device->prop("processor.maximum_speed").toInt(); -} - -bool Processor::canChangeFrequency() const -{ - return m_device->prop("processor.can_throttle").toBool(); -} - -Solid::Processor::InstructionSets Processor::instructionSets() const -{ - static Solid::Processor::InstructionSets cpuextensions = Solid::Backends::Shared::cpuFeatures(); - - return cpuextensions; -} - -#include "backends/hal/halprocessor.moc" diff --git a/solid/solid/backends/hal/halprocessor.h b/solid/solid/backends/hal/halprocessor.h deleted file mode 100644 index 4f751366..00000000 --- a/solid/solid/backends/hal/halprocessor.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_PROCESSOR_H -#define SOLID_BACKENDS_HAL_PROCESSOR_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalDevice; - -class Processor : public DeviceInterface, virtual public Solid::Ifaces::Processor -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::Processor) - -public: - Processor(HalDevice *device); - virtual ~Processor(); - - virtual int number() const; - virtual int maxSpeed() const; - virtual bool canChangeFrequency() const; - virtual Solid::Processor::InstructionSets instructionSets() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_PROCESSOR_H diff --git a/solid/solid/backends/hal/halserialinterface.cpp b/solid/solid/backends/hal/halserialinterface.cpp deleted file mode 100644 index 4d804ec7..00000000 --- a/solid/solid/backends/hal/halserialinterface.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright 2009 Harald Fernengel - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halserialinterface.h" - -#include "haldevice.h" - -#include - -using namespace Solid::Backends::Hal; - -SerialInterface::SerialInterface(HalDevice *device) - : DeviceInterface(device) -{ - -} - -SerialInterface::~SerialInterface() -{ - -} - -QVariant SerialInterface::driverHandle() const -{ - return m_device->prop("serial.device"); -} - -Solid::SerialInterface::SerialType SerialInterface::serialType() const -{ - QString type = m_device->prop("serial.type").toString(); - if (type == QLatin1String("platform")) - return Solid::SerialInterface::Platform; - if (type == QLatin1String("usb")) - return Solid::SerialInterface::Usb; - return Solid::SerialInterface::Unknown; -} - -int SerialInterface::port() const -{ - return m_device->prop("serial.port").toInt(); -} - -#include "backends/hal/halserialinterface.moc" diff --git a/solid/solid/backends/hal/halserialinterface.h b/solid/solid/backends/hal/halserialinterface.h deleted file mode 100644 index 1c23093d..00000000 --- a/solid/solid/backends/hal/halserialinterface.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright 2009 Harald Fernengel - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_HALSERIALINTERFACE_H -#define SOLID_BACKENDS_HAL_HALSERIALINTERFACE_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalDevice; - -class SerialInterface : public DeviceInterface, virtual public Solid::Ifaces::SerialInterface -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::SerialInterface) - -public: - SerialInterface(HalDevice *device); - virtual ~SerialInterface(); - - virtual QVariant driverHandle() const; - virtual Solid::SerialInterface::SerialType serialType() const; - virtual int port() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_HALSERIALINTERFACE_H diff --git a/solid/solid/backends/hal/halsmartcardreader.cpp b/solid/solid/backends/hal/halsmartcardreader.cpp deleted file mode 100644 index 97d9bf30..00000000 --- a/solid/solid/backends/hal/halsmartcardreader.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright 2009 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halsmartcardreader.h" - -#include "haldevice.h" - -#include - -using namespace Solid::Backends::Hal; - -SmartCardReader::SmartCardReader(HalDevice *device) - : DeviceInterface(device) -{ - -} - -SmartCardReader::~SmartCardReader() -{ - -} - -Solid::SmartCardReader::ReaderType SmartCardReader::readerType() const -{ - Solid::SmartCardReader::ReaderType type; - QStringList capabilities = m_device->prop("info.capabilities").toStringList(); - - if (capabilities.contains("card_reader")) { - type = Solid::SmartCardReader::CardReader; - } - if (capabilities.contains("crypto_token")) { - type = Solid::SmartCardReader::CryptoToken; - } - - return type; -} - -#include "backends/hal/halsmartcardreader.moc" diff --git a/solid/solid/backends/hal/halsmartcardreader.h b/solid/solid/backends/hal/halsmartcardreader.h deleted file mode 100644 index a1188006..00000000 --- a/solid/solid/backends/hal/halsmartcardreader.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2009 Christopher Blauvelt - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_HALSMARTCARDREADER_H -#define SOLID_BACKENDS_HAL_HALSMARTCARDREADER_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class HalDevice; - -class SmartCardReader : public DeviceInterface, virtual public Solid::Ifaces::SmartCardReader -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::SmartCardReader) - -public: - SmartCardReader(HalDevice *device); - virtual ~SmartCardReader(); - - virtual Solid::SmartCardReader::ReaderType readerType() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_HALSMARTCARDREADER_H diff --git a/solid/solid/backends/hal/halstorage.cpp b/solid/solid/backends/hal/halstorage.cpp deleted file mode 100644 index 5f018dc5..00000000 --- a/solid/solid/backends/hal/halstorage.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halstorage.h" - -using namespace Solid::Backends::Hal; - -Storage::Storage(HalDevice *device) - : Block(device) -{ - -} - -Storage::~Storage() -{ - -} - -Solid::StorageDrive::Bus Storage::bus() const -{ - QString bus = m_device->prop("storage.bus").toString(); - - if (bus=="ide") - { - return Solid::StorageDrive::Ide; - } - else if (bus=="usb") - { - return Solid::StorageDrive::Usb; - } - else if (bus=="ieee1394") - { - return Solid::StorageDrive::Ieee1394; - } - else if (bus=="scsi") - { - return Solid::StorageDrive::Scsi; - } - else if (bus=="sata") - { - return Solid::StorageDrive::Sata; - } - else - { - return Solid::StorageDrive::Platform; - } -} - -Solid::StorageDrive::DriveType Storage::driveType() const -{ - QString type = m_device->prop("storage.drive_type").toString(); - - if (type=="disk") - { - return Solid::StorageDrive::HardDisk; - } - else if (type=="cdrom") - { - return Solid::StorageDrive::CdromDrive; - } - else if (type=="floppy") - { - return Solid::StorageDrive::Floppy; - } - else if (type=="tape") - { - return Solid::StorageDrive::Tape; - } - else if (type=="compact_flash") - { - return Solid::StorageDrive::CompactFlash; - } - else if (type=="memory_stick") - { - return Solid::StorageDrive::MemoryStick; - } - else if (type=="smart_media") - { - return Solid::StorageDrive::SmartMedia; - } - else if (type=="sd_mmc") - { - return Solid::StorageDrive::SdMmc; - } - else - { - return Solid::StorageDrive::HardDisk; - } -} - -bool Storage::isRemovable() const -{ - return m_device->prop("storage.removable").toBool(); -} - -bool Storage::isHotpluggable() const -{ - return m_device->prop("storage.hotpluggable").toBool(); -} - -qulonglong Storage::size() const -{ - return m_device->prop("storage.size").toULongLong(); -} - -#include "backends/hal/halstorage.moc" diff --git a/solid/solid/backends/hal/halstorage.h b/solid/solid/backends/hal/halstorage.h deleted file mode 100644 index 85e0ba37..00000000 --- a/solid/solid/backends/hal/halstorage.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_STORAGE_H -#define SOLID_BACKENDS_HAL_STORAGE_H - -#include -#include "halblock.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class Storage : public Block, virtual public Solid::Ifaces::StorageDrive -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::StorageDrive) - -public: - Storage(HalDevice *device); - virtual ~Storage(); - - virtual Solid::StorageDrive::Bus bus() const; - virtual Solid::StorageDrive::DriveType driveType() const; - - virtual bool isRemovable() const; - virtual bool isHotpluggable() const; - virtual qulonglong size() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_STORAGE_H diff --git a/solid/solid/backends/hal/halstorageaccess.cpp b/solid/solid/backends/hal/halstorageaccess.cpp deleted file mode 100644 index c92358db..00000000 --- a/solid/solid/backends/hal/halstorageaccess.cpp +++ /dev/null @@ -1,516 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halstorageaccess.h" - -#include "halfstabhandling.h" -#include "../../genericinterface.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifdef Q_OS_FREEBSD -#include -#endif - -using namespace Solid::Backends::Hal; - -StorageAccess::StorageAccess(HalDevice *device) - : DeviceInterface(device), m_setupInProgress(false), m_teardownInProgress(false), m_ejectInProgress(false), - m_passphraseRequested(false) -{ - connect(device, SIGNAL(propertyChanged(QMap)), - this, SLOT(slotPropertyChanged(QMap))); - // Delay connecting to DBus signals to avoid the related time penalty - // in hot paths such as predicate matching - QTimer::singleShot(0, this, SLOT(connectDBusSignals())); -} - -StorageAccess::~StorageAccess() -{ - -} - -void StorageAccess::connectDBusSignals() -{ - m_device->registerAction("setup", this, - SLOT(slotSetupRequested()), - SLOT(slotSetupDone(int,QString))); - - m_device->registerAction("teardown", this, - SLOT(slotTeardownRequested()), - SLOT(slotTeardownDone(int,QString))); - - m_device->registerAction("eject", this, - SLOT(slotEjectRequested()), - SLOT(slotEjectDone(int,QString))); -} - -void StorageAccess::slotSetupDone(int error, const QString &errorString) -{ - m_setupInProgress = false; - emit setupDone(static_cast(error), errorString, m_device->udi()); -} - -void StorageAccess::slotTeardownDone(int error, const QString &errorString) -{ - m_teardownInProgress = false; - emit teardownDone(static_cast(error), errorString, m_device->udi()); -} - -void StorageAccess::slotEjectDone(int error, const QString &errorString) -{ - m_ejectInProgress = false; - emit ejectDone(static_cast(error), errorString, m_device->udi()); -} - -bool StorageAccess::isAccessible() const -{ - if (m_device->prop("info.interfaces").toStringList().contains("org.freedesktop.Hal.Device.Volume.Crypto")) { - - // Might be a bit slow, but I see no cleaner way to do this with HAL... - QDBusInterface manager("org.freedesktop.Hal", - "/org/freedesktop/Hal/Manager", - "org.freedesktop.Hal.Manager", - QDBusConnection::systemBus()); - - QDBusReply reply = manager.call("FindDeviceStringMatch", - "volume.crypto_luks.clear.backing_volume", - m_device->udi()); - - QStringList list = reply; - - return reply.isValid() && !list.isEmpty(); - - } else { - return m_device->prop("volume.is_mounted").toBool(); - } -} - -QString StorageAccess::filePath() const -{ - QString result = m_device->prop("volume.mount_point").toString(); - - if (result.isEmpty()) { - QStringList mountpoints - = FstabHandling::possibleMountPoints(m_device->prop("block.device").toString()); - if (mountpoints.size()==1) { - result = mountpoints.first(); - } - } - - return result; -} - -bool StorageAccess::isIgnored() const -{ - HalDevice lock("/org/freedesktop/Hal/devices/computer"); - bool isLocked = lock.prop("info.named_locks.Global.org.freedesktop.Hal.Device.Storage.locked").toBool(); - - if (m_device->prop("volume.ignore").toBool() || isLocked ){ - return true; - } - - const QString mount_point = StorageAccess(m_device).filePath(); - const bool mounted = m_device->prop("volume.is_mounted").toBool(); - if (!mounted) { - return false; - } else if (mount_point.startsWith(QLatin1String("/media/")) || mount_point.startsWith(QLatin1String("/mnt/"))) { - return false; - } - - /* Now be a bit more aggressive on what we want to ignore, - * the user generally need to check only what's removable or in /media - * the volumes mounted to make the system (/, /boot, /var, etc.) - * are useless to him. - */ - Solid::Device drive(m_device->prop("block.storage_device").toString()); - - const bool removable = drive.as()->property("storage.removable").toBool(); - const bool hotpluggable = drive.as()->property("storage.hotpluggable").toBool(); - - return !removable && !hotpluggable; -} - -bool StorageAccess::setup() -{ - if (m_teardownInProgress || m_setupInProgress || isAccessible()) { - return false; - } - m_setupInProgress = true; - m_device->broadcastActionRequested("setup"); - - if (m_device->prop("info.interfaces").toStringList().contains("org.freedesktop.Hal.Device.Volume.Crypto")) { - return requestPassphrase(); - } else if (FstabHandling::isInFstab(m_device->prop("block.device").toString())) { - return callSystemMount(); - } else { - return callHalVolumeMount(); - } -} - -bool StorageAccess::teardown() -{ - if (m_teardownInProgress || m_setupInProgress || !isAccessible()) { - return false; - } - m_teardownInProgress = true; - m_device->broadcastActionRequested("teardown"); - - if (m_device->prop("info.interfaces").toStringList().contains("org.freedesktop.Hal.Device.Volume.Crypto")) { - return callCryptoTeardown(); - } else if (FstabHandling::isInFstab(m_device->prop("block.device").toString())) { - return callSystemUnmount(); - } else { - return callHalVolumeUnmount(); - } -} - -void StorageAccess::slotPropertyChanged(const QMap &changes) -{ - if (changes.contains("volume.is_mounted")) - { - emit accessibilityChanged(isAccessible(), m_device->udi()); - } -} - -void StorageAccess::slotDBusReply(const QDBusMessage &/*reply*/) -{ - if (m_setupInProgress) { - m_setupInProgress = false; - m_device->broadcastActionDone("setup"); - } else if (m_teardownInProgress) { - m_teardownInProgress = false; - m_device->broadcastActionDone("teardown"); - - HalDevice drive(m_device->prop("block.storage_device").toString()); - if (drive.prop("storage.drive_type").toString()!="cdrom" - && drive.prop("storage.requires_eject").toBool()) { - - QString devnode = m_device->prop("block.device").toString(); - -#if defined(Q_OS_OPENBSD) - QString program = "cdio"; - QStringList args; - args << "-f" << devnode << "eject"; -#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) - devnode.remove("/dev/").replace("([0-9]).", "\\1"); - QString program = "cdcontrol"; - QStringList args; - args << "-f" << devnode << "eject"; -#else - QString program = "eject"; - QStringList args; - args << devnode; -#endif - - m_ejectInProgress = true; - m_device->broadcastActionRequested("eject"); - m_process = FstabHandling::callSystemCommand("eject", args, - this, SLOT(slotProcessFinished(int,QProcess::ExitStatus))); - } - } else if (m_ejectInProgress) { - m_ejectInProgress = false; - m_device->broadcastActionDone("eject"); - } -} - -void StorageAccess::slotDBusError(const QDBusError &error) -{ - // TODO: Better error reporting here - if (m_setupInProgress) { - m_setupInProgress = false; - m_device->broadcastActionDone("setup", Solid::UnauthorizedOperation, - QString(error.name()+": "+error.message())); - } else if (m_teardownInProgress) { - m_teardownInProgress = false; - m_device->broadcastActionDone("teardown", Solid::UnauthorizedOperation, - QString(error.name()+": "+error.message())); - } else if (m_ejectInProgress) { - m_ejectInProgress = false; - m_device->broadcastActionDone("eject", Solid::UnauthorizedOperation, - QString(error.name()+": "+error.message())); - } -} - -void Solid::Backends::Hal::StorageAccess::slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - Q_UNUSED(exitStatus); - if (m_setupInProgress) { - m_setupInProgress = false; - - if (exitCode==0) { - m_device->broadcastActionDone("setup"); - } else { - m_device->broadcastActionDone("setup", Solid::UnauthorizedOperation, - m_process->readAllStandardError()); - } - } else if (m_teardownInProgress) { - m_teardownInProgress = false; - if (exitCode==0) { - m_device->broadcastActionDone("teardown"); - } else { - m_device->broadcastActionDone("teardown", Solid::UnauthorizedOperation, - m_process->readAllStandardError()); - } - } else if (m_ejectInProgress) { - if (exitCode==0) { - m_ejectInProgress = false; - m_device->broadcastActionDone("eject"); - } else { - callHalVolumeEject(); - } - } - - delete m_process; -} - -void StorageAccess::slotSetupRequested() -{ - m_setupInProgress = true; - emit setupRequested(m_device->udi()); -} - -void StorageAccess::slotTeardownRequested() -{ - m_teardownInProgress = true; - emit teardownRequested(m_device->udi()); -} - -void StorageAccess::slotEjectRequested() -{ - m_ejectInProgress = true; -} - -QString generateReturnObjectPath() -{ - static int number = 1; - - return "/org/kde/solid/HalStorageAccess_"+QString::number(number++); -} - -bool StorageAccess::requestPassphrase() -{ - QString udi = m_device->udi(); - QString returnService = QDBusConnection::sessionBus().baseService(); - m_lastReturnObject = generateReturnObjectPath(); - - QDBusConnection::sessionBus().registerObject(m_lastReturnObject, this, - QDBusConnection::ExportScriptableSlots); - - - QWidget *activeWindow = QApplication::activeWindow(); - uint wId = 0; - if (activeWindow!=0) { - wId = (uint)activeWindow->winId(); - } - - QString appId = QCoreApplication::applicationName(); - - QDBusInterface soliduiserver("org.kde.kded", "/modules/soliduiserver", "org.kde.SolidUiServer"); - QDBusReply reply = soliduiserver.call("showPassphraseDialog", udi, - returnService, m_lastReturnObject, - wId, appId); - m_passphraseRequested = reply.isValid(); - if (!m_passphraseRequested) { - qWarning() << "Failed to call the SolidUiServer, D-Bus said:" << reply.error(); - } - return m_passphraseRequested; -} - -void StorageAccess::passphraseReply(const QString &passphrase) -{ - if (m_passphraseRequested) { - QDBusConnection::sessionBus().unregisterObject(m_lastReturnObject); - m_passphraseRequested = false; - if (!passphrase.isEmpty()) { - callCryptoSetup(passphrase); - } else { - m_setupInProgress = false; - m_device->broadcastActionDone("setup"); - } - } -} - -bool StorageAccess::callHalVolumeMount() -{ - QDBusConnection c = QDBusConnection::systemBus(); - QString udi = m_device->udi(); - QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi, - "org.freedesktop.Hal.Device.Volume", - "Mount"); - - // HAL 0.5.12 supports using alternative drivers for the same filesystem. - // This is mainly used to integrate the ntfs-3g driver. - // Unfortunately, the primary driver gets used unless we - // specify some other driver (fstype) to the Mount method. - // TODO: Allow the user to choose the driver. - - QString fstype = m_device->prop("volume.fstype").toString(); - QStringList halOptions = m_device->prop("volume.mount.valid_options").toStringList(); - - QString alternativePreferred = m_device->prop("volume.fstype.alternative.preferred").toString(); - if (!alternativePreferred.isEmpty()) { - QStringList alternativeFstypes = m_device->prop("volume.fstype.alternative").toStringList(); - if (alternativeFstypes.contains(alternativePreferred)) { - fstype = alternativePreferred; - halOptions = m_device->prop("volume.mount."+fstype+".valid_options").toStringList(); - } - } - - QStringList options; - -#ifdef Q_OS_FREEBSD - QString uid="-u="; -#else - QString uid="uid="; -#endif - if (halOptions.contains(uid)) { - options << uid+QString::number(::getuid()); - } - -#ifdef Q_OS_FREEBSD - char *cType; - if ( fstype=="vfat" && halOptions.contains("-L=")) { - if ( (cType = getenv("LC_ALL")) || (cType = getenv("LC_CTYPE")) || (cType = getenv("LANG")) ) - options << "-L="+QString(cType); - } - else if ( (fstype.startsWith(QLatin1String("ntfs")) || fstype=="iso9660" || fstype=="udf") && halOptions.contains("-C=") ) { - if ((cType = getenv("LC_ALL")) || (cType = getenv("LC_CTYPE")) || (cType = getenv("LANG")) ) - options << "-C="+QString(nl_langinfo(CODESET)); - } -#else - if (fstype=="vfat" || fstype=="ntfs" || fstype=="iso9660" || fstype=="udf" ) { - if (halOptions.contains("utf8")) - options<<"utf8"; - else if (halOptions.contains("iocharset=")) - options<<"iocharset=utf8"; - if (halOptions.contains("shortname=")) - options<<"shortname=mixed"; - if (halOptions.contains("flush")) - options<<"flush"; - } - // pass our locale to the ntfs-3g driver so it can translate local characters - else if ( halOptions.contains("locale=") ) { - // have to obtain LC_CTYPE as returned by the `locale` command - // check in the same order as `locale` does - char *cType; - if ( (cType = getenv("LC_ALL")) || (cType = getenv("LC_CTYPE")) || (cType = getenv("LANG")) ) { - options << "locale="+QString(cType); - } - } -#endif - - msg << "" << fstype << options; - - return c.callWithCallback(msg, this, - SLOT(slotDBusReply(QDBusMessage)), - SLOT(slotDBusError(QDBusError))); -} - -bool StorageAccess::callHalVolumeUnmount() -{ - QDBusConnection c = QDBusConnection::systemBus(); - QString udi = m_device->udi(); - QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi, - "org.freedesktop.Hal.Device.Volume", - "Unmount"); - - msg << QStringList(); - - return c.callWithCallback(msg, this, - SLOT(slotDBusReply(QDBusMessage)), - SLOT(slotDBusError(QDBusError))); -} - -bool StorageAccess::callHalVolumeEject() -{ - QString udi = m_device->udi(); - QString interface = "org.freedesktop.Hal.Device.Volume"; - - QDBusConnection c = QDBusConnection::systemBus(); - QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi, - interface, "Eject"); - - msg << QStringList(); - - return c.callWithCallback(msg, this, - SLOT(slotDBusReply(QDBusMessage)), - SLOT(slotDBusError(QDBusError))); -} - -bool Solid::Backends::Hal::StorageAccess::callSystemMount() -{ - const QString device = m_device->prop("block.device").toString(); - m_process = FstabHandling::callSystemCommand("mount", device, - this, SLOT(slotProcessFinished(int,QProcess::ExitStatus))); - - return m_process!=0; -} - -bool Solid::Backends::Hal::StorageAccess::callSystemUnmount() -{ - const QString device = m_device->prop("block.device").toString(); - m_process = FstabHandling::callSystemCommand("umount", device, - this, SLOT(slotProcessFinished(int,QProcess::ExitStatus))); - - return m_process!=0; -} - -void StorageAccess::callCryptoSetup(const QString &passphrase) -{ - QDBusConnection c = QDBusConnection::systemBus(); - QString udi = m_device->udi(); - QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi, - "org.freedesktop.Hal.Device.Volume.Crypto", - "Setup"); - - msg << passphrase; - - c.callWithCallback(msg, this, - SLOT(slotDBusReply(QDBusMessage)), - SLOT(slotDBusError(QDBusError))); -} - -bool StorageAccess::callCryptoTeardown() -{ - QDBusConnection c = QDBusConnection::systemBus(); - QString udi = m_device->udi(); - QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Hal", udi, - "org.freedesktop.Hal.Device.Volume.Crypto", - "Teardown"); - - return c.callWithCallback(msg, this, - SLOT(slotDBusReply(QDBusMessage)), - SLOT(slotDBusError(QDBusError))); -} - -#include "backends/hal/halstorageaccess.moc" diff --git a/solid/solid/backends/hal/halstorageaccess.h b/solid/solid/backends/hal/halstorageaccess.h deleted file mode 100644 index f45a3e55..00000000 --- a/solid/solid/backends/hal/halstorageaccess.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_STORAGEACCESS_H -#define SOLID_BACKENDS_HAL_STORAGEACCESS_H - -#include -#include "haldeviceinterface.h" - -#include -#include -#include -#include - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class StorageAccess : public DeviceInterface, virtual public Solid::Ifaces::StorageAccess -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::StorageAccess) - -public: - StorageAccess(HalDevice *device); - virtual ~StorageAccess(); - - virtual bool isAccessible() const; - virtual QString filePath() const; - virtual bool isIgnored() const; - virtual bool setup(); - virtual bool teardown(); - -Q_SIGNALS: - void accessibilityChanged(bool accessible, const QString &udi); - void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi); - void setupRequested(const QString &udi); - void teardownRequested(const QString &udi); - -private Q_SLOTS: - void connectDBusSignals(); - void slotPropertyChanged(const QMap &changes); - void slotDBusReply(const QDBusMessage &reply); - void slotDBusError(const QDBusError &error); - void slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - void slotSetupRequested(); - void slotTeardownRequested(); - void slotEjectRequested(); - void slotSetupDone(int error, const QString &errorString); - void slotTeardownDone(int error, const QString &errorString); - void slotEjectDone(int error, const QString &errorString); - -public Q_SLOTS: - Q_SCRIPTABLE Q_NOREPLY void passphraseReply(const QString &passphrase); - -private: - bool callHalVolumeMount(); - bool callHalVolumeUnmount(); - bool callHalVolumeEject(); - - bool callSystemMount(); - bool callSystemUnmount(); - - bool requestPassphrase(); - void callCryptoSetup(const QString &passphrase); - bool callCryptoTeardown(); - -private: - bool m_setupInProgress; - bool m_teardownInProgress; - bool m_ejectInProgress; - bool m_passphraseRequested; - QString m_lastReturnObject; - QProcess *m_process; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_STORAGEACCESS_H diff --git a/solid/solid/backends/hal/halvideo.cpp b/solid/solid/backends/hal/halvideo.cpp deleted file mode 100644 index 3f6ac108..00000000 --- a/solid/solid/backends/hal/halvideo.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - Copyright 2007 Will Stephenson - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halvideo.h" - -using namespace Solid::Backends::Hal; - -Video::Video(HalDevice *device) - : DeviceInterface(device) -{ - -} - -Video::~Video() -{ - -} - -QStringList Video::supportedProtocols() const -{ - QStringList protocols; - protocols << QLatin1String( "video4linux" ); - return protocols; -} - -QStringList Video::supportedDrivers(QString protocol) const -{ - QStringList drivers; - if ( protocol == "video4linux" ) { - drivers << QLatin1String( "video4linux" ); //Retrocompatibility with KDE < 4.3 - if ( m_device->prop("video4linux.version") == "2" ) { - drivers << QLatin1String( "video4linux2" ); - } else { - drivers << QLatin1String( "video4linux1" ); - } - } - return drivers; -} - -QVariant Solid::Backends::Hal::Video::driverHandle(const QString &driver) const -{ - if ( driver==QLatin1String("video4linux") || driver==QLatin1String("video4linux1") || driver==QLatin1String("video4linux2") ) { - return m_device->prop("video4linux.device"); - } - // TODO: Fill in the blank for other drivers - - return QVariant(); -} - -#include "backends/hal/halvideo.moc" diff --git a/solid/solid/backends/hal/halvideo.h b/solid/solid/backends/hal/halvideo.h deleted file mode 100644 index d429835e..00000000 --- a/solid/solid/backends/hal/halvideo.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - Copyright 2007 Will Stephenson - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_VIDEO_H -#define SOLID_BACKENDS_HAL_VIDEO_H - -#include -#include "haldeviceinterface.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class Video : public DeviceInterface, virtual public Solid::Ifaces::Video -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::Video) - -public: - Video(HalDevice *device); - virtual ~Video(); - virtual QStringList supportedProtocols() const; - virtual QStringList supportedDrivers(QString protocol = QString()) const; - virtual QVariant driverHandle(const QString &driver) const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_VIDEO_H diff --git a/solid/solid/backends/hal/halvolume.cpp b/solid/solid/backends/hal/halvolume.cpp deleted file mode 100644 index 6cdc9d32..00000000 --- a/solid/solid/backends/hal/halvolume.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halvolume.h" -#include "halstorageaccess.h" -#include "../../genericinterface.h" - -using namespace Solid::Backends::Hal; - -Volume::Volume(HalDevice *device) - : Block(device) -{ -} - -Volume::~Volume() -{ - -} - - -bool Volume::isIgnored() const -{ - static HalDevice lock("/org/freedesktop/Hal/devices/computer"); - bool isLocked = lock.prop("info.named_locks.Global.org.freedesktop.Hal.Device.Storage.locked").toBool(); - - if (m_device->prop("volume.ignore").toBool() || isLocked ){ - return true; - } - - const QString mount_point = StorageAccess(m_device).filePath(); - const bool mounted = m_device->prop("volume.is_mounted").toBool(); - if (!mounted) { - return false; - } else if (mount_point.startsWith(QLatin1String("/media/")) || mount_point.startsWith(QLatin1String("/mnt/"))) { - return false; - } - - /* Now be a bit more aggressive on what we want to ignore, - * the user generally need to check only what's removable or in /media - * the volumes mounted to make the system (/, /boot, /var, etc.) - * are useless to him. - */ - Solid::Device drive(m_device->prop("block.storage_device").toString()); - - const bool removable = drive.as()->property("storage.removable").toBool(); - const bool hotpluggable = drive.as()->property("storage.hotpluggable").toBool(); - - return !removable && !hotpluggable; -} - -Solid::StorageVolume::UsageType Volume::usage() const -{ - QString usage = m_device->prop("volume.fsusage").toString(); - - if (usage == "filesystem") - { - return Solid::StorageVolume::FileSystem; - } - else if (usage == "partitiontable") - { - return Solid::StorageVolume::PartitionTable; - } - else if (usage == "raid") - { - return Solid::StorageVolume::Raid; - } - else if (usage == "crypto") - { - return Solid::StorageVolume::Encrypted; - } - else if (usage == "unused") - { - return Solid::StorageVolume::Unused; - } - else - { - return Solid::StorageVolume::Other; - } -} - -QString Volume::fsType() const -{ - return m_device->prop("volume.fstype").toString(); -} - -QString Volume::label() const -{ - return m_device->prop("volume.label").toString(); -} - -QString Volume::uuid() const -{ - return m_device->prop("volume.uuid").toString(); -} - -qulonglong Volume::size() const -{ - return m_device->prop("volume.size").toULongLong(); -} - -QString Solid::Backends::Hal::Volume::encryptedContainerUdi() const -{ - return m_device->prop("volume.crypto_luks.clear.backing_volume").toString(); -} - -#include "backends/hal/halvolume.moc" diff --git a/solid/solid/backends/hal/halvolume.h b/solid/solid/backends/hal/halvolume.h deleted file mode 100644 index c85de269..00000000 --- a/solid/solid/backends/hal/halvolume.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright 2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef SOLID_BACKENDS_HAL_VOLUME_H -#define SOLID_BACKENDS_HAL_VOLUME_H - -#include -#include "halblock.h" - -namespace Solid -{ -namespace Backends -{ -namespace Hal -{ -class Volume : public Block, virtual public Solid::Ifaces::StorageVolume -{ - Q_OBJECT - Q_INTERFACES(Solid::Ifaces::StorageVolume) - -public: - Volume(HalDevice *device); - virtual ~Volume(); - - virtual bool isIgnored() const; - virtual Solid::StorageVolume::UsageType usage() const; - virtual QString fsType() const; - virtual QString label() const; - virtual QString uuid() const; - virtual qulonglong size() const; - virtual QString encryptedContainerUdi() const; -}; -} -} -} - -#endif // SOLID_BACKENDS_HAL_VOLUME_H diff --git a/solid/tests/CMakeLists.txt b/solid/tests/CMakeLists.txt index ef507d1c..d1272afb 100644 --- a/solid/tests/CMakeLists.txt +++ b/solid/tests/CMakeLists.txt @@ -15,21 +15,6 @@ endif(WIN32) target_link_libraries(fakehardwaretest solid_static ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTTEST_LIBRARY} ) add_definitions(-DTEST_DATA="\\"${CMAKE_CURRENT_SOURCE_DIR}/../solid/backends/fakehw/fakecomputer.xml\\"") - -########### halbasictest ############### - -if(NOT WIN32 AND NOT APPLE) -set(halbasictest_SRCS halbasictest.cpp ) - -kde4_add_executable(halbasictest ${halbasictest_SRCS}) - -if(WIN32) - set_target_properties(halbasictest PROPERTIES COMPILE_FLAGS -DSOLID_EXPORT=) -endif(WIN32) - -target_link_libraries(halbasictest solid_static ${KDEWIN_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTTEST_LIBRARY} ) -endif(NOT WIN32 AND NOT APPLE) - ########### solidhwtest ############### set(solidhwtest_SRCS @@ -48,24 +33,6 @@ endif(WIN32) target_link_libraries(solidhwtest ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBS} solid_static) -########### solidmttest ############### - -set(solidmttest_SRCS - solidmttest.cpp ) - - -kde4_add_unit_test(solidmttest ${solidmttest_SRCS}) -add_definitions(-DFAKE_COMPUTER_XML="\\"${CMAKE_CURRENT_SOURCE_DIR}/../solid/backends/fakehw/fakecomputer.xml\\"") - -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../solid/backends/fakehw ) - -if(WIN32) - set_target_properties(solidmttest PROPERTIES COMPILE_FLAGS -DSOLID_EXPORT=) - set (LIBS ${KDEWIN_LIBRARIES}) -endif(WIN32) - -target_link_libraries(solidmttest ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTTEST_LIBRARY} ${LIBS} solid_static) - ########### solidnettestdbusservice ############### #set(solidnettestdbusservice_SRCS diff --git a/solid/tests/halbasictest.cpp b/solid/tests/halbasictest.cpp deleted file mode 100644 index d90130c8..00000000 --- a/solid/tests/halbasictest.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright 2005,2006 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include "halbasictest.h" - -#include - -#include "solid/backends/hal/halmanager.h" - -#include -#include -#include -#include -#include "solid/backends/hal/halprocessor.h" - -QTEST_MAIN(HalBasicTest) - -HalBasicTest::HalBasicTest(QObject *parent) - : QObject(parent) -{ - setenv("SOLID_HAL_LEGACY", "1", 1); -} - -void HalBasicTest::testBasic() -{ - Solid::Backends::Hal::HalManager *manager = new Solid::Backends::Hal::HalManager(0); - - QVERIFY(manager->deviceExists("/org/freedesktop/Hal/devices/computer")); - QVERIFY(!manager->allDevices().isEmpty()); - - QVERIFY(!manager->devicesFromQuery(QString(), Solid::DeviceInterface::Processor).isEmpty()); - - QString proc_udi = manager->devicesFromQuery(QString(), Solid::DeviceInterface::Processor).at(0); - - Solid::Backends::Hal::HalDevice *processor = qobject_cast(manager->createDevice(proc_udi)); - - QCOMPARE(processor->udi(), proc_udi); - QCOMPARE(processor->parentUdi(), QString("/org/freedesktop/Hal/devices/computer")); - QVERIFY(!processor->allProperties().isEmpty()); - QVERIFY(processor->propertyExists("info.product")); - QVERIFY(!processor->propertyExists("the.meaning.of.life")); - QVERIFY(processor->queryDeviceInterface(Solid::DeviceInterface::Processor)); - QVERIFY(!processor->queryDeviceInterface(Solid::DeviceInterface::OpticalDisc)); - - QObject *interface = processor->createDeviceInterface(Solid::DeviceInterface::Processor); - Solid::Ifaces::Processor *proc_iface = qobject_cast(interface); - - QVERIFY(proc_iface!=0); - -#if 0 - // HAL locking support being broken anyway... - QVERIFY(!processor->isLocked()); - QVERIFY(processor->lock("No reason...")); - QVERIFY(processor->isLocked()); - QCOMPARE(processor->lockReason(), QString("No reason...")); - QVERIFY(!processor->lock("Need a reason?")); - QVERIFY(processor->unlock()); -#endif - - QObject *object = processor; - QCOMPARE(interface->parent(), object); - - delete processor; - delete manager; -} - -void HalBasicTest::testProcessorList() -{ - QList list = Solid::Device::listFromType(Solid::DeviceInterface::Processor, QString()); - qDebug() << "Number of processors:" << list.size(); - if (list.size() > 0) - { - Solid::Processor* p = list[0].as(); - QVERIFY(p); - Solid::Processor::InstructionSets features = p->instructionSets(); - qDebug() << "features:" << features; - } -} - -void HalBasicTest::testDeviceCreation() -{ - // Uncomment to check if the "still reachable" number grows in - // valgrind, which probably indicates a memory leak. - //for (int i=0; i<1000; i++) - { - Solid::Device dev("/org/freedesktop/Hal/devices/computer"); - QVERIFY(dev.isValid()); - dev = Solid::Device("ddd/ff"); - QVERIFY(!dev.isValid()); - } -} - -void HalBasicTest::testSignalHandling() -{ - Solid::Backends::Hal::HalManager *manager = new Solid::Backends::Hal::HalManager(0); - m_device = qobject_cast(manager->createDevice("/org/freedesktop/Hal/devices/computer")); - -#if 0 - connect(m_device, SIGNAL(propertyChanged(QMap)), - this, SLOT(slotPropertyChanged(QMap))); - - // HAL locking support being broken anyway... - QVERIFY(!m_device->isLocked()); - m_signalProcessed = false; - m_device->lock("Still no reason... really"); - QVERIFY(m_device->isLocked()); - QVERIFY(m_signalProcessed); -#endif - - delete m_device; - delete manager; -} - -void HalBasicTest::slotPropertyChanged(const QMap &changes) -{ - Q_UNUSED(changes) -#if 0 - QVERIFY(m_device->isLocked()); - m_signalProcessed = true; -#endif -} - -#include "halbasictest.moc" - diff --git a/solid/tests/halbasictest.h b/solid/tests/halbasictest.h deleted file mode 100644 index 82dd2c85..00000000 --- a/solid/tests/halbasictest.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright 2005 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#ifndef HALBASICTEST_H -#define HALBASICTEST_H - -#include -#include -#include - -#include "solid/backends/hal/haldevice.h" - -class HalBasicTest : public QObject -{ - Q_OBJECT -public: - HalBasicTest(QObject *parent = 0); -private slots: - void testBasic(); - void testProcessorList(); - void testDeviceCreation(); - void testSignalHandling(); - - void slotPropertyChanged(const QMap &changes); - -private: - Solid::Backends::Hal::HalDevice *m_device; - bool m_signalProcessed; -}; - -#endif diff --git a/solid/tests/solidmttest.cpp b/solid/tests/solidmttest.cpp deleted file mode 100644 index 7aa319b9..00000000 --- a/solid/tests/solidmttest.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright 2008 Kevin Ottens - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) version 3, or any - later version accepted by the membership of KDE e.V. (or its - successor approved by the membership of KDE e.V.), which shall - act as a proxy defined in Section 6 of version 3 of the license. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library. If not, see . -*/ - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - - -class SolidMtTest : public QObject -{ - Q_OBJECT -private slots: - void testWorkerThread(); - void testThreadedPredicate(); -}; - -class WorkerThread : public QThread -{ - Q_OBJECT -protected: - virtual void run() - { - Solid::Device dev("/org/freedesktop/Hal/devices/computer"); - - QList driveList = Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive); - foreach (const Solid::Device &solidDevice, driveList) { - const Solid::StorageDrive* solidDrive = solidDevice.as(); - } - } -}; - -static void doPredicates() -{ - Solid::Predicate p5 = Solid::Predicate::fromString("[[Processor.maxSpeed == 3201 AND Processor.canChangeFrequency == false] OR StorageVolume.mountPoint == '/media/blup']"); - - Solid::Predicate p6 = Solid::Predicate::fromString("StorageVolume.usage == 'Other'"); - Solid::Predicate p7 = Solid::Predicate::fromString(QString("StorageVolume.usage == %1").arg((int)Solid::StorageVolume::Other)); - - Solid::Predicate p8 = Solid::Predicate::fromString("AudioInterface.deviceType == 'AudioInput|AudioOutput'"); - Solid::Predicate p9 = Solid::Predicate::fromString("AudioInterface.deviceType == 'AudioInput'"); - Solid::Predicate p10 = Solid::Predicate::fromString("AudioInterface.deviceType & 'AudioInput'"); - Solid::Predicate p11 = Solid::Predicate::fromString("AudioInterface.deviceType & 'foobar'"); -} - -QTEST_MAIN(SolidMtTest) - -void SolidMtTest::testWorkerThread() -{ - Solid::Device dev("/org/freedesktop/Hal/devices/acpi_ADP1"); - - WorkerThread *wt = new WorkerThread; - wt->start(); - wt->wait(); - - const QList driveList = Solid::Device::listFromType(Solid::DeviceInterface::StorageDrive); - foreach (const Solid::Device &solidDevice, driveList) { - const Solid::GenericInterface* solidDrive = solidDevice.as(); - } - - delete wt; -} - -void SolidMtTest::testThreadedPredicate() -{ - QThreadPool::globalInstance()->setMaxThreadCount(10); - QList > futures; - futures << QtConcurrent::run(&doPredicates); - futures << QtConcurrent::run(&doPredicates); - futures << QtConcurrent::run(&doPredicates); - futures << QtConcurrent::run(&doPredicates); - futures << QtConcurrent::run(&doPredicates); - futures << QtConcurrent::run(&doPredicates); - futures << QtConcurrent::run(&doPredicates); - futures << QtConcurrent::run(&doPredicates); - Q_FOREACH(QFuture f, futures) - f.waitForFinished(); - QThreadPool::globalInstance()->setMaxThreadCount(1); // delete those threads -} - -#include "solidmttest.moc" -