DeviceManagerUnix::DeviceManagerUnix(QObject *parent) : DeviceManager(parent) { qDBusRegisterMetaType<QVariantMapMap>(); qDBusRegisterMetaType<DBusManagedObjects>(); qDBusRegisterMetaType<ByteArrayList>(); //qDBusRegisterMetaType<ByteArray>(); // Check for presence of udisks2 auto system = QDBusConnection::systemBus(); serviceConnected = system.isConnected() && system.interface()->isServiceRegistered(DBUS_SERVICE_NAME); if (!serviceConnected) return; // Listen to interface changes system.connect(DBUS_SERVICE_NAME, DBUS_OBJECT_ROOT, DBUS_IFACE_MANAGER, DBUS_IFACE_ADDED, this, SLOT(dbus_interfaceAdded(QDBusObjectPath,QMap<QString,QVariant>))); system.connect(DBUS_SERVICE_NAME, DBUS_OBJECT_ROOT, DBUS_IFACE_MANAGER, DBUS_IFACE_REMOVED, this, SLOT(dbus_interfaceRemoved(QDBusObjectPath,QStringList))); // Populate our data fields foreach (QString drive, drives()) { addDrive(drive); }
UDisks2::UDisks2(QObject *parent) : QObject(parent) { auto system = QDBusConnection::systemBus(); system.connect("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", "org.freedesktop.DBus.ObjectManager", "InterfacesAdded", this, SLOT(dbus_interfaceAdded(QDBusObjectPath,QMap<QString,QVariant>))); system.connect("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved", this, SLOT(dbus_interfaceRemoved(QDBusObjectPath,QStringList))); foreach (QString block, blockDevices()) { addBlock(block); }