diff --git a/autotests/solidfreedesktoptest.cpp b/autotests/solidfreedesktoptest.cpp index 8af855e..18bc7f5 100644 --- a/autotests/solidfreedesktoptest.cpp +++ b/autotests/solidfreedesktoptest.cpp @@ -1,135 +1,135 @@ /* Copyright 2014 Alejandro Fiestas Olivares 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 "qtest_dbus.h" #include "fakeUpower.h" #include "fakelogind.h" #include #include #include #include #include #include #include #include #include #include using namespace Solid; class solidFreedesktopTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void testAcPluggedJob(); void testAcPluggedChanged(); void testAddInhibition(); void testSupportedStates(); void testRequestState(); private: FakeUpower *m_fakeUPower; FakeLogind *m_fakeLogind; }; void solidFreedesktopTest::initTestCase() { qputenv("SOLID_POWER_BACKEND", "FREE_DESKTOP"); m_fakeUPower = new FakeUpower(this); QDBusConnection::systemBus().registerService(QStringLiteral("org.freedesktop.UPower")); QDBusConnection::systemBus().registerObject(QStringLiteral("/org/freedesktop/UPower"), m_fakeUPower, QDBusConnection::ExportAllContents); m_fakeLogind = new FakeLogind(this); QDBusConnection::systemBus().registerService(QStringLiteral("org.freedesktop.login1")); QDBusConnection::systemBus().registerObject(QStringLiteral("/org/freedesktop/login1"), m_fakeLogind, QDBusConnection::ExportAllContents); } void solidFreedesktopTest::testAcPluggedJob() { m_fakeUPower->m_onBattery = true; auto job = new AcPluggedJob(this); QVERIFY(job->exec()); QCOMPARE(job->isPlugged(), false); m_fakeUPower->m_onBattery = false; job = Solid::Power::isAcPlugged(); QVERIFY(job->exec()); QCOMPARE(job->isPlugged(), true); } void solidFreedesktopTest::testAcPluggedChanged() { auto power = Solid::Power::self(); QSignalSpy spy(power, SIGNAL(acPluggedChanged(bool))); m_fakeUPower->setOnBattery(true); m_fakeUPower->setOnBattery(false); spy.wait(10000); QCOMPARE(spy.count(), 2); QCOMPARE(spy.first().first().toBool(), false); QCOMPARE(spy.at(1).first().toBool(), true); } void solidFreedesktopTest::testAddInhibition() { - QSignalSpy spy(m_fakeLogind, SIGNAL(newInhibition(QString, QString, QString, QString))); + QSignalSpy spy(m_fakeLogind, SIGNAL(newInhibition(QString,QString,QString,QString))); auto job = new InhibitionJob(this); job->setDescription(QStringLiteral("Foo! I am inhibing!")); job->setInhibitions(Power::Shutdown | Power::Sleep); job->exec(); QCOMPARE(spy.count(), 1); QSignalSpy spyRemoved(m_fakeLogind, SIGNAL(inhibitionRemoved())); auto inhibition = job->inhibition(); inhibition->stop(); spyRemoved.wait(100); QCOMPARE(spy.count(), 1); QSignalSpy spyStatusChanged(inhibition, SIGNAL(stateChanged(Inhibition::State))); inhibition->start(); spyStatusChanged.wait(100); QCOMPARE(spyStatusChanged.count(), 1); delete inhibition; spyRemoved.wait(100); QCOMPARE(spyRemoved.count(), 2); } void solidFreedesktopTest::testSupportedStates() { } void solidFreedesktopTest::testRequestState() { } QTEST_GUILESS_MAIN_SYSTEM_DBUS(solidFreedesktopTest) #include "solidfreedesktoptest.moc" diff --git a/src/solid/devices/backends/win/windevicemanager.cpp b/src/solid/devices/backends/win/windevicemanager.cpp index 022068c..9e5ba5f 100644 --- a/src/solid/devices/backends/win/windevicemanager.cpp +++ b/src/solid/devices/backends/win/windevicemanager.cpp @@ -1,245 +1,245 @@ /* Copyright 2013 Patrick von Reth 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 "windevicemanager.h" #include "windevicemanager_p.h" #include #include "windevice.h" #include "winprocessor.h" #include "winblock.h" #include "winbattery.h" #include #include #include #include #include using namespace Solid::Backends::Win; Q_GLOBAL_STATIC(SolidWinEventFilter,solidWineventFilter) SolidWinEventFilter *SolidWinEventFilter::instance() { return solidWineventFilter; } SolidWinEventFilter::SolidWinEventFilter(): QObject() { wchar_t title[] = L"KDEWinDeviceManager"; WNDCLASSEX wcex; ZeroMemory(&wcex, sizeof(wcex)); wcex.cbSize = sizeof(WNDCLASSEX); wcex.lpfnWndProc = SolidWinEventFilter::WndProc; wcex.hInstance = (HINSTANCE)::GetModuleHandle(NULL); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW); wcex.lpszClassName = title; if (RegisterClassEx(&wcex) == 0) { qWarning() << "Failed to initialize KDEWinDeviceManager we will be unable to detect device changes"; return; } m_windowID = CreateWindow(title, title, WS_ICONIC, 0, 0, CW_USEDEFAULT, 0, NULL, NULL, wcex.hInstance, NULL); if (m_windowID == NULL) { qWarning() << "Failed to initialize KDEWinDeviceManager we will be unable to detect device changes"; return; } ShowWindow(m_windowID, SW_HIDE); } SolidWinEventFilter::~SolidWinEventFilter() { PostMessage(m_windowID, WM_CLOSE, 0, 0); } void SolidWinEventFilter::promoteAddedDevice(const QSet &udi) { emit deviceAdded(udi); } void SolidWinEventFilter::promoteRemovedDevice(const QSet &udi) { emit deviceRemoved(udi); } void SolidWinEventFilter::promotePowerChange() { emit powerChanged(); } LRESULT CALLBACK SolidWinEventFilter::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { //some parts of the code are based on http://www.codeproject.com/Articles/119168/Hardware-Change-Detection switch (message) { case WM_DEVICECHANGE: { if ((wParam == DBT_DEVICEARRIVAL) || (wParam == DBT_DEVICEREMOVECOMPLETE)) { DEV_BROADCAST_HDR *header = reinterpret_cast(lParam); if (header->dbch_devicetype == DBT_DEVTYP_VOLUME) { DEV_BROADCAST_VOLUME *devNot = reinterpret_cast(lParam); switch (wParam) { case DBT_DEVICEREMOVECOMPLETE: { QSet udis = WinBlock::getFromBitMask(devNot->dbcv_unitmask); solidWineventFilter->promoteRemovedDevice(udis); } break; case DBT_DEVICEARRIVAL: { QSet udis = WinBlock::updateUdiFromBitMask(devNot->dbcv_unitmask); solidWineventFilter->promoteAddedDevice(udis); } break; } break; } } } break; case WM_POWERBROADCAST: { solidWineventFilter->promotePowerChange(); } break; case WM_DESTROY: { PostQuitMessage(0); } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } WinDeviceManager::WinDeviceManager(QObject *parent) : DeviceManager(parent) { - connect(solidWineventFilter, SIGNAL(deviceAdded(const QSet &)),this, SLOT(slotDeviceAdded(QSet))); - connect(solidWineventFilter, SIGNAL(deviceRemoved(const QSet &)),this, SLOT(slotDeviceRemoved(QSet))); + connect(solidWineventFilter, SIGNAL(deviceAdded(QSet)),this, SLOT(slotDeviceAdded(QSet))); + connect(solidWineventFilter, SIGNAL(deviceRemoved(QSet)),this, SLOT(slotDeviceRemoved(QSet))); m_supportedInterfaces << Solid::DeviceInterface::GenericInterface // << Solid::DeviceInterface::Block << Solid::DeviceInterface::StorageAccess << Solid::DeviceInterface::StorageDrive << Solid::DeviceInterface::OpticalDrive << Solid::DeviceInterface::StorageVolume << Solid::DeviceInterface::OpticalDisc << Solid::DeviceInterface::Processor << Solid::DeviceInterface::Battery; updateDeviceList(); } WinDeviceManager::~WinDeviceManager() { } QString WinDeviceManager::udiPrefix() const { return QString(); } QSet Solid::Backends::Win::WinDeviceManager::supportedInterfaces() const { return m_supportedInterfaces; } QStringList WinDeviceManager::allDevices() { return m_devicesList; } QStringList WinDeviceManager::devicesFromQuery(const QString &parentUdi, Solid::DeviceInterface::Type type) { QStringList list; if (!parentUdi.isEmpty()) { foreach (const QString &udi, allDevices()) { WinDevice device(udi); if (device.type() == type && device.parentUdi() == parentUdi) { list << udi; } } } else if (type != Solid::DeviceInterface::Unknown) { foreach (const QString &udi, allDevices()) { WinDevice device(udi); if (device.queryDeviceInterface(type)) { list << udi; } } } else { list << allDevices(); } return list; } QObject *Solid::Backends::Win::WinDeviceManager::createDevice(const QString &udi) { if (allDevices().contains(udi)) { return new WinDevice(udi); } else { return 0; } } void WinDeviceManager::slotDeviceAdded(const QSet &udi) { QSet tmp = udi - m_devices;//don't report devices that are already known(cd drive) m_devices += tmp; m_devicesList = m_devices.toList(); qSort(m_devicesList); foreach (const QString &s, tmp) { emit deviceAdded(s); } } void WinDeviceManager::slotDeviceRemoved(const QSet &udi) { m_devices -= udi; m_devicesList = m_devices.toList(); qSort(m_devicesList); foreach (const QString &s, udi) { emit deviceRemoved(s); } } void WinDeviceManager::updateDeviceList() { QSet devices = WinProcessor::getUdis(); devices += WinBlock::getUdis(); devices += WinBattery::getUdis(); m_devices = devices; m_devicesList = m_devices.toList(); qSort(m_devicesList); } diff --git a/src/solid/power/backends/freedesktop/fdpowernotifier.cpp b/src/solid/power/backends/freedesktop/fdpowernotifier.cpp index 2677b2d..8562648 100644 --- a/src/solid/power/backends/freedesktop/fdpowernotifier.cpp +++ b/src/solid/power/backends/freedesktop/fdpowernotifier.cpp @@ -1,70 +1,70 @@ /* Copyright 2014 Alejandro Fiestas Olivares Copyright 2014 Lukáš Tinkl 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 "fdpowernotifier.h" #include #include Solid::FDPowerNotifier::FDPowerNotifier(QObject* parent): PowerNotifier(parent) { auto conn = QDBusConnection::systemBus(); conn.connect(QStringLiteral("org.freedesktop.UPower"), QStringLiteral("/org/freedesktop/UPower"), QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"), this, - SLOT(upowerPropertiesChanged(QString, QVariantMap, QStringList)) + SLOT(upowerPropertiesChanged(QString,QVariantMap,QStringList)) ); conn.connect(QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"), QStringLiteral("org.freedesktop.login1.Manager"), QStringLiteral("PrepareForSleep"), this, SLOT(login1Resuming(bool)) ); } void Solid::FDPowerNotifier::upowerPropertiesChanged(const QString &interface, const QVariantMap &changedProperties, const QStringList &invalidated) { if (interface != QStringLiteral("org.freedesktop.UPower")) { return; } if (changedProperties.contains(QStringLiteral("OnBattery"))) { Q_EMIT acPluggedChanged(!changedProperties.value(QStringLiteral("OnBattery")).toBool()); } //Just for debug purposes if (!invalidated.isEmpty()) { qDebug() << "Invalidated" << invalidated; } } void Solid::FDPowerNotifier::login1Resuming(bool active) { if (active) { Q_EMIT aboutToSuspend(); } else { Q_EMIT resumeFromSuspend(); } } diff --git a/src/tools/solid-hardware/solid-hardware.cpp b/src/tools/solid-hardware/solid-hardware.cpp index e65a648..ccd49ce 100644 --- a/src/tools/solid-hardware/solid-hardware.cpp +++ b/src/tools/solid-hardware/solid-hardware.cpp @@ -1,451 +1,451 @@ /* This file is part of the KDE project Copyright (C) 2006 Kevin Ottens Copyright (C) 2014 Alejandro Fiestas Olivares This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "solid-hardware.h" #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; static const char appName[] = "solid-hardware"; static const char version[] = "0.1a"; std::ostream &operator<<(std::ostream &out, const QString &msg) { return (out << msg.toLocal8Bit().constData()); } std::ostream &operator<<(std::ostream &out, const QVariant &value) { switch (value.type()) { case QVariant::StringList: { out << "{"; const QStringList list = value.toStringList(); QStringList::ConstIterator it = list.constBegin(); QStringList::ConstIterator end = list.constEnd(); for (; it!=end; ++it) { out << "'" << *it << "'"; if (it+1!=end) { out << ", "; } } out << "} (string list)"; break; } case QVariant::Bool: out << (value.toBool()?"true":"false") << " (bool)"; break; case QVariant::Int: case QVariant::LongLong: out << value.toString() << " (0x" << QString::number(value.toLongLong(), 16) << ") (" << QVariant::typeToName(value.type()) << ")"; break; case QVariant::UInt: case QVariant::ULongLong: out << value.toString() << " (0x" << QString::number(value.toULongLong(), 16) << ") (" << QVariant::typeToName(value.type()) << ")"; break; case QVariant::Double: out << value.toString() << " (double)"; break; case QVariant::UserType: { //qDebug() << "got variant type:" << value.typeName(); if (value.canConvert >()) { QList intlist = value.value >(); QStringList tmp; foreach (int val, intlist) tmp.append(QString::number(val)); out << "{" << tmp.join(",") << "} (int list)"; } break; } default: out << "'" << value.toString() << "' (string)"; break; } return out; } std::ostream &operator<<(std::ostream &out, const Solid::Device &device) { out << " parent = " << QVariant(device.parentUdi()) << endl; out << " vendor = " << QVariant(device.vendor()) << endl; out << " product = " << QVariant(device.product()) << endl; out << " description = " << QVariant(device.description()) << endl; out << " icon = " << QVariant(device.icon()) << endl; int index = Solid::DeviceInterface::staticMetaObject.indexOfEnumerator("Type"); QMetaEnum typeEnum = Solid::DeviceInterface::staticMetaObject.enumerator(index); for (int i=0; imetaObject(); for (int i=meta->propertyOffset(); ipropertyCount(); i++) { QMetaProperty property = meta->property(i); out << " " << QString(meta->className()).mid(7) << "." << property.name() << " = "; QVariant value = property.read(interface); if (property.isEnumType()) { QMetaEnum metaEnum = property.enumerator(); if (metaEnum.isFlag()) { out << "'" << metaEnum.valueToKeys(value.toInt()).constData() << "'" << " (0x" << QString::number(value.toInt(), 16) << ") (flag)"; } else { out << "'" << metaEnum.valueToKey(value.toInt()) << "'" << " (0x" << QString::number(value.toInt(), 16) << ") (enum)"; } out << endl; } else { out << value << endl; } } } } return out; } std::ostream &operator<<(std::ostream &out, const QMap &properties) { Q_FOREACH (const QString &key, properties.keys()) { out << " " << key << " = " << properties[key] << endl; } return out; } QString getUdiFromArguments(QCoreApplication &app, QCommandLineParser &parser) { parser.addPositionalArgument("udi", QCoreApplication::translate("solid-hardware", "Device udi")); parser.process(app); if (parser.positionalArguments().count() < 2) { parser.showHelp(1); } return parser.positionalArguments().at(1); } int main(int argc, char **argv) { SolidHardware app(argc, argv); app.setApplicationName(appName); app.setApplicationVersion(version); QCommandLineParser parser; parser.setApplicationDescription(QCoreApplication::translate("solid-hardware", "KDE tool for querying your hardware from the command line")); parser.addHelpOption(); parser.addVersionOption(); parser.addPositionalArgument("command", QCoreApplication::translate("solid-hardware", "Command to execute")); QCommandLineOption commands("commands", QCoreApplication::translate("solid-hardware", "Show available commands")); parser.addOption(commands); parser.process(app); if (parser.isSet(commands)) { cout << endl << QCoreApplication::translate("solid-hardware", "Syntax:") << endl << endl; cout << " solid-hardware list [details|nonportableinfo]" << endl; cout << QCoreApplication::translate("solid-hardware", " # List the hardware available in the system.\n" " # - If the 'nonportableinfo' option is specified, the device\n" " # properties are listed (be careful, in this case property names\n" " # are backend dependent),\n" " # - If the 'details' option is specified, the device interfaces\n" " # and the corresponding properties are listed in a platform\n" " # neutral fashion,\n" " # - Otherwise only device UDIs are listed.\n") << endl; cout << " solid-hardware details 'udi'" << endl; cout << QCoreApplication::translate("solid-hardware", " # Display all the interfaces and properties of the device\n" " # corresponding to 'udi' in a platform neutral fashion.\n") << endl; cout << " solid-hardware nonportableinfo 'udi'" << endl; cout << QCoreApplication::translate("solid-hardware", " # Display all the properties of the device corresponding to 'udi'\n" " # (be careful, in this case property names are backend dependent).\n") << endl; cout << " solid-hardware query 'predicate' ['parentUdi']" << endl; cout << QCoreApplication::translate("solid-hardware", " # List the UDI of devices corresponding to 'predicate'.\n" " # - If 'parentUdi' is specified, the search is restricted to the\n" " # branch of the corresponding device,\n" " # - Otherwise the search is done on all the devices.\n") << endl; cout << " solid-hardware mount 'udi'" << endl; cout << QCoreApplication::translate("solid-hardware", " # If applicable, mount the device corresponding to 'udi'.\n") << endl; cout << " solid-hardware unmount 'udi'" << endl; cout << QCoreApplication::translate("solid-hardware", " # If applicable, unmount the device corresponding to 'udi'.\n") << endl; cout << " solid-hardware eject 'udi'" << endl; cout << QCoreApplication::translate("solid-hardware", " # If applicable, eject the device corresponding to 'udi'.\n") << endl; cout << " solid-hardware listen" << endl; cout << QCoreApplication::translate("solid-hardware", " # Listen to all add/remove events on supported hardware.") << endl; return 0; } QStringList args = parser.positionalArguments(); if (args.count() < 1) { parser.showHelp(1); } parser.clearPositionalArguments(); QString command(args.at(0)); if (command == "list") { parser.addPositionalArgument("details", QCoreApplication::translate("solid-hardware", "Show device details")); parser.addPositionalArgument("nonportableinfo", QCoreApplication::translate("solid-hardware", "Show non portable information")); parser.process(app); args = parser.positionalArguments(); QByteArray extra(args.count() == 2 ? args.at(1).toLocal8Bit() : ""); return app.hwList(extra == "details", extra == "nonportableinfo"); } else if (command == "details") { const QString udi = getUdiFromArguments(app, parser); return app.hwCapabilities(udi); } else if (command == "nonportableinfo") { const QString udi = getUdiFromArguments(app, parser); return app.hwProperties(udi); } else if (command == "query") { parser.addPositionalArgument("udi", QCoreApplication::translate("solid-hardware", "Device udi")); parser.addPositionalArgument("parent", QCoreApplication::translate("solid-hardware", "Parent device udi")); parser.process(app); if (parser.positionalArguments().count() < 2 || parser.positionalArguments().count() > 3) { parser.showHelp(1); } QString query = args.at(1); QString parent; if (args.count() == 3) { parent = args.at(2); } return app.hwQuery(parent, query); } else if (command == "mount") { const QString udi = getUdiFromArguments(app, parser); return app.hwVolumeCall(SolidHardware::Mount, udi); } else if (command == "unmount") { const QString udi = getUdiFromArguments(app, parser); return app.hwVolumeCall(SolidHardware::Unmount, udi); } else if (command == "eject") { const QString udi = getUdiFromArguments(app, parser); return app.hwVolumeCall(SolidHardware::Eject, udi); } else if (command == "listen") { return app.listen(); } cerr << QCoreApplication::translate("solid-hardware", "Syntax Error: Unknown command '%1'").arg(command) << endl; return 1; } bool SolidHardware::hwList(bool interfaces, bool system) { const QList all = Solid::Device::allDevices(); Q_FOREACH (const Solid::Device &device, all) { cout << "udi = '" << device.udi() << "'" << endl; if (interfaces) { cout << device << endl; } else if (system && device.is()) { QMap properties = device.as()->allProperties(); cout << properties << endl; } } return true; } bool SolidHardware::hwCapabilities(const QString &udi) { const Solid::Device device(udi); cout << "udi = '" << device.udi() << "'" << endl; cout << device << endl; return true; } bool SolidHardware::hwProperties(const QString &udi) { const Solid::Device device(udi); cout << "udi = '" << device.udi() << "'" << endl; if (device.is()) { QMap properties = device.as()->allProperties(); cout << properties << endl; } return true; } bool SolidHardware::hwQuery(const QString &parentUdi, const QString &query) { const QList devices = Solid::Device::listFromQuery(query, parentUdi); Q_FOREACH (const Solid::Device &device, devices) { cout << "udi = '" << device.udi() << "'" << endl; } return true; } bool SolidHardware::hwVolumeCall(SolidHardware::VolumeCallType type, const QString &udi) { Solid::Device device(udi); if (!device.is() && type!=Eject) { cerr << tr("Error: %1 does not have the interface StorageAccess.").arg(udi) << endl; return false; } else if (!device.is() && type==Eject) { cerr << tr("Error: %1 does not have the interface OpticalDrive.").arg(udi) << endl; return false; } switch(type) { case Mount: connect(device.as(), - SIGNAL(setupDone(Solid::ErrorType, QVariant, const QString &)), + SIGNAL(setupDone(Solid::ErrorType,QVariant,QString)), this, - SLOT(slotStorageResult(Solid::ErrorType, QVariant))); + SLOT(slotStorageResult(Solid::ErrorType,QVariant))); device.as()->setup(); break; case Unmount: connect(device.as(), - SIGNAL(teardownDone(Solid::ErrorType, QVariant, const QString &)), + SIGNAL(teardownDone(Solid::ErrorType,QVariant,QString)), this, - SLOT(slotStorageResult(Solid::ErrorType, QVariant))); + SLOT(slotStorageResult(Solid::ErrorType,QVariant))); device.as()->teardown(); break; case Eject: connect(device.as(), - SIGNAL(ejectDone(Solid::ErrorType, QVariant, const QString &)), + SIGNAL(ejectDone(Solid::ErrorType,QVariant,QString)), this, - SLOT(slotStorageResult(Solid::ErrorType, QVariant))); + SLOT(slotStorageResult(Solid::ErrorType,QVariant))); device.as()->eject(); break; } m_loop.exec(); if (m_error) { cerr << tr("Error: %1").arg(m_errorString) << endl; return false; } return true; } bool SolidHardware::listen() { Solid::DeviceNotifier *notifier = Solid::DeviceNotifier::instance(); bool a = connect(notifier, SIGNAL(deviceAdded(QString)), this, SLOT(deviceAdded(QString))); bool d = connect(notifier, SIGNAL(deviceRemoved(QString)), this, SLOT(deviceRemoved(QString))); if (!a || !d) { return false; } cout << "Listening to add/remove events: " << endl; m_loop.exec(); return true; } void SolidHardware::deviceAdded(const QString &udi) { cout << "Device Added:" << endl; cout << "udi = '" << udi << "'" << endl; } void SolidHardware::deviceRemoved(const QString &udi) { cout << "Device Removed:" << endl; cout << "udi = '" << udi << "'" << endl; } void SolidHardware::slotStorageResult(Solid::ErrorType error, const QVariant &errorData) { if (error) { m_error = 1; m_errorString = errorData.toString(); } m_loop.exit(); }