mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-05 21:53:28 +01:00
Rename the DeviceEngines to DeviceListers
This commit is contained in:
parent
2b17a8ee1f
commit
b750df38ce
@ -53,9 +53,9 @@ set(SOURCES
|
|||||||
core/utilities.cpp
|
core/utilities.cpp
|
||||||
|
|
||||||
devices/device.cpp
|
devices/device.cpp
|
||||||
devices/deviceengine.cpp
|
devices/devicekitlister.cpp
|
||||||
|
devices/devicelister.cpp
|
||||||
devices/devicetest.cpp
|
devices/devicetest.cpp
|
||||||
devices/filesystemdeviceengine.cpp
|
|
||||||
|
|
||||||
engines/enginebase.cpp
|
engines/enginebase.cpp
|
||||||
|
|
||||||
@ -174,9 +174,9 @@ set(HEADERS
|
|||||||
core/taskmanager.h
|
core/taskmanager.h
|
||||||
|
|
||||||
devices/device.h
|
devices/device.h
|
||||||
devices/deviceengine.h
|
devices/devicekitlister.h
|
||||||
|
devices/devicelister.h
|
||||||
devices/devicetest.h
|
devices/devicetest.h
|
||||||
devices/filesystemdeviceengine.h
|
|
||||||
|
|
||||||
engines/enginebase.h
|
engines/enginebase.h
|
||||||
|
|
||||||
|
@ -14,25 +14,25 @@
|
|||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "filesystemdeviceengine.h"
|
#include "devicekitlister.h"
|
||||||
#include "dbus/udisks.h"
|
#include "dbus/udisks.h"
|
||||||
#include "dbus/udisksdevice.h"
|
#include "dbus/udisksdevice.h"
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
FilesystemDeviceEngine::FilesystemDeviceEngine()
|
DeviceKitLister::DeviceKitLister()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FilesystemDeviceEngine::~FilesystemDeviceEngine() {
|
DeviceKitLister::~DeviceKitLister() {
|
||||||
qDebug() << __PRETTY_FUNCTION__;
|
qDebug() << __PRETTY_FUNCTION__;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FilesystemDeviceEngine::DeviceData::unique_id() const {
|
QString DeviceKitLister::DeviceData::unique_id() const {
|
||||||
return QString("%1 %2 %3 %4").arg(drive_serial, drive_vendor, drive_model).arg(device_size);
|
return QString("%1 %2 %3 %4").arg(drive_serial, drive_vendor, drive_model).arg(device_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemDeviceEngine::Init() {
|
void DeviceKitLister::Init() {
|
||||||
interface_.reset(new OrgFreedesktopUDisksInterface(
|
interface_.reset(new OrgFreedesktopUDisksInterface(
|
||||||
OrgFreedesktopUDisksInterface::staticInterfaceName(),
|
OrgFreedesktopUDisksInterface::staticInterfaceName(),
|
||||||
"/org/freedesktop/UDisks", QDBusConnection::systemBus()));
|
"/org/freedesktop/UDisks", QDBusConnection::systemBus()));
|
||||||
@ -77,12 +77,12 @@ void FilesystemDeviceEngine::Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList FilesystemDeviceEngine::DeviceUniqueIDs() {
|
QStringList DeviceKitLister::DeviceUniqueIDs() {
|
||||||
QMutexLocker l(&mutex_);
|
QMutexLocker l(&mutex_);
|
||||||
return device_data_.keys();
|
return device_data_.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant FilesystemDeviceEngine::DeviceInfo(const QString& id, int field) {
|
QVariant DeviceKitLister::DeviceInfo(const QString& id, int field) {
|
||||||
DeviceData data;
|
DeviceData data;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ QVariant FilesystemDeviceEngine::DeviceInfo(const QString& id, int field) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FilesystemDeviceEngine::DeviceData FilesystemDeviceEngine::ReadDeviceData(
|
DeviceKitLister::DeviceData DeviceKitLister::ReadDeviceData(
|
||||||
const QDBusObjectPath &path) const {
|
const QDBusObjectPath &path) const {
|
||||||
DeviceData ret;
|
DeviceData ret;
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ FilesystemDeviceEngine::DeviceData FilesystemDeviceEngine::ReadDeviceData(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemDeviceEngine::DBusDeviceAdded(const QDBusObjectPath &path) {
|
void DeviceKitLister::DBusDeviceAdded(const QDBusObjectPath &path) {
|
||||||
DeviceData data = ReadDeviceData(path);
|
DeviceData data = ReadDeviceData(path);
|
||||||
if (!data.suitable)
|
if (!data.suitable)
|
||||||
return;
|
return;
|
||||||
@ -171,7 +171,7 @@ void FilesystemDeviceEngine::DBusDeviceAdded(const QDBusObjectPath &path) {
|
|||||||
emit DeviceAdded(data.unique_id());
|
emit DeviceAdded(data.unique_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemDeviceEngine::DBusDeviceRemoved(const QDBusObjectPath &path) {
|
void DeviceKitLister::DBusDeviceRemoved(const QDBusObjectPath &path) {
|
||||||
QString id;
|
QString id;
|
||||||
{
|
{
|
||||||
QMutexLocker l(&mutex_);
|
QMutexLocker l(&mutex_);
|
||||||
@ -185,7 +185,7 @@ void FilesystemDeviceEngine::DBusDeviceRemoved(const QDBusObjectPath &path) {
|
|||||||
emit DeviceRemoved(id);
|
emit DeviceRemoved(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesystemDeviceEngine::DBusDeviceChanged(const QDBusObjectPath &path) {
|
void DeviceKitLister::DBusDeviceChanged(const QDBusObjectPath &path) {
|
||||||
bool already_known = false;
|
bool already_known = false;
|
||||||
{
|
{
|
||||||
QMutexLocker l(&mutex_);
|
QMutexLocker l(&mutex_);
|
||||||
@ -207,7 +207,7 @@ void FilesystemDeviceEngine::DBusDeviceChanged(const QDBusObjectPath &path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FilesystemDeviceEngine::FindUniqueIdByPath(const QDBusObjectPath &path) const {
|
QString DeviceKitLister::FindUniqueIdByPath(const QDBusObjectPath &path) const {
|
||||||
foreach (const DeviceData& data, device_data_) {
|
foreach (const DeviceData& data, device_data_) {
|
||||||
if (data.dbus_path == path.path())
|
if (data.dbus_path == path.path())
|
||||||
return data.unique_id();
|
return data.unique_id();
|
@ -14,10 +14,10 @@
|
|||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FILESYSTEMDEVICEENGINE_H
|
#ifndef DEVICEKITLISTER_H
|
||||||
#define FILESYSTEMDEVICEENGINE_H
|
#define DEVICEKITLISTER_H
|
||||||
|
|
||||||
#include "deviceengine.h"
|
#include "devicelister.h"
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -28,18 +28,18 @@ class OrgFreedesktopUDisksInterface;
|
|||||||
|
|
||||||
class QDBusObjectPath;
|
class QDBusObjectPath;
|
||||||
|
|
||||||
class FilesystemDeviceEngine : public DeviceEngine {
|
class DeviceKitLister : public DeviceLister {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FilesystemDeviceEngine();
|
DeviceKitLister();
|
||||||
~FilesystemDeviceEngine();
|
~DeviceKitLister();
|
||||||
|
|
||||||
enum Field {
|
enum Field {
|
||||||
Field_MountPath = LastDeviceEngineField,
|
Field_MountPath = DeviceLister::LastField,
|
||||||
Field_DbusPath,
|
Field_DbusPath,
|
||||||
|
|
||||||
LastFilesystemDeviceEngineField
|
LastField
|
||||||
};
|
};
|
||||||
|
|
||||||
QStringList DeviceUniqueIDs();
|
QStringList DeviceUniqueIDs();
|
||||||
@ -82,4 +82,4 @@ private:
|
|||||||
QMap<QString, DeviceData> device_data_;
|
QMap<QString, DeviceData> device_data_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILESYSTEMDEVICEENGINE_H
|
#endif // DEVICEKITLISTER_H
|
@ -14,17 +14,17 @@
|
|||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "deviceengine.h"
|
#include "devicelister.h"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
DeviceEngine::DeviceEngine()
|
DeviceLister::DeviceLister()
|
||||||
: thread_(NULL)
|
: thread_(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceEngine::~DeviceEngine() {
|
DeviceLister::~DeviceLister() {
|
||||||
qDebug() << __PRETTY_FUNCTION__;
|
qDebug() << __PRETTY_FUNCTION__;
|
||||||
if (thread_) {
|
if (thread_) {
|
||||||
thread_->quit();
|
thread_->quit();
|
||||||
@ -32,7 +32,7 @@ DeviceEngine::~DeviceEngine() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceEngine::Start() {
|
void DeviceLister::Start() {
|
||||||
thread_ = new QThread;
|
thread_ = new QThread;
|
||||||
connect(thread_, SIGNAL(started()), SLOT(ThreadStarted()));
|
connect(thread_, SIGNAL(started()), SLOT(ThreadStarted()));
|
||||||
|
|
||||||
@ -40,6 +40,6 @@ void DeviceEngine::Start() {
|
|||||||
thread_->start();
|
thread_->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceEngine::ThreadStarted() {
|
void DeviceLister::ThreadStarted() {
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
@ -14,17 +14,17 @@
|
|||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DEVICEENGINE_H
|
#ifndef DEVICELISTER_H
|
||||||
#define DEVICEENGINE_H
|
#define DEVICELISTER_H
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
class DeviceEngine : public QObject {
|
class DeviceLister : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeviceEngine();
|
DeviceLister();
|
||||||
~DeviceEngine();
|
~DeviceLister();
|
||||||
|
|
||||||
enum Field {
|
enum Field {
|
||||||
Field_UniqueID = 0,
|
Field_UniqueID = 0,
|
||||||
@ -34,7 +34,7 @@ public:
|
|||||||
Field_Capacity,
|
Field_Capacity,
|
||||||
Field_FreeSpace,
|
Field_FreeSpace,
|
||||||
|
|
||||||
LastDeviceEngineField
|
LastField
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tries to start the thread and initialise the engine. This object will be
|
// Tries to start the thread and initialise the engine. This object will be
|
||||||
@ -60,4 +60,4 @@ private slots:
|
|||||||
void ThreadStarted();
|
void ThreadStarted();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICEENGINE_H
|
#endif // DEVICELISTER_H
|
@ -15,31 +15,31 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "devicetest.h"
|
#include "devicetest.h"
|
||||||
#include "filesystemdeviceengine.h"
|
#include "devicekitlister.h"
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
DeviceTest::DeviceTest(QObject *parent)
|
DeviceTest::DeviceTest(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
DeviceEngine* engine = new FilesystemDeviceEngine;
|
DeviceLister* lister = new DeviceKitLister;
|
||||||
engines_ << engine;
|
listers_ << lister;
|
||||||
connect(engine, SIGNAL(DeviceAdded(QString)), SLOT(DeviceAdded(QString)));
|
connect(lister, SIGNAL(DeviceAdded(QString)), SLOT(DeviceAdded(QString)));
|
||||||
connect(engine, SIGNAL(DeviceRemoved(QString)), SLOT(DeviceRemoved(QString)));
|
connect(lister, SIGNAL(DeviceRemoved(QString)), SLOT(DeviceRemoved(QString)));
|
||||||
connect(engine, SIGNAL(DeviceChanged(QString)), SLOT(DeviceChanged(QString)));
|
connect(lister, SIGNAL(DeviceChanged(QString)), SLOT(DeviceChanged(QString)));
|
||||||
|
|
||||||
engine->Start();
|
lister->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceTest::~DeviceTest() {
|
DeviceTest::~DeviceTest() {
|
||||||
qDeleteAll(engines_);
|
qDeleteAll(listers_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceTest::DeviceAdded(const QString &id) {
|
void DeviceTest::DeviceAdded(const QString &id) {
|
||||||
DeviceEngine* engine = qobject_cast<DeviceEngine*>(sender());
|
DeviceLister* engine = qobject_cast<DeviceLister*>(sender());
|
||||||
|
|
||||||
qDebug() << "Device added:" << id;
|
qDebug() << "Device added:" << id;
|
||||||
for (int i=0 ; i<FilesystemDeviceEngine::LastFilesystemDeviceEngineField ; ++i) {
|
for (int i=0 ; i<DeviceKitLister::LastField ; ++i) {
|
||||||
qDebug() << i << engine->DeviceInfo(id, i);
|
qDebug() << i << engine->DeviceInfo(id, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,10 +49,10 @@ void DeviceTest::DeviceRemoved(const QString &id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceTest::DeviceChanged(const QString &id) {
|
void DeviceTest::DeviceChanged(const QString &id) {
|
||||||
DeviceEngine* engine = qobject_cast<DeviceEngine*>(sender());
|
DeviceLister* engine = qobject_cast<DeviceLister*>(sender());
|
||||||
|
|
||||||
qDebug() << "Device changed:" << id;
|
qDebug() << "Device changed:" << id;
|
||||||
for (int i=0 ; i<FilesystemDeviceEngine::LastFilesystemDeviceEngineField ; ++i) {
|
for (int i=0 ; i<DeviceKitLister::LastField ; ++i) {
|
||||||
qDebug() << i << engine->DeviceInfo(id, i);
|
qDebug() << i << engine->DeviceInfo(id, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class DeviceEngine;
|
class DeviceLister;
|
||||||
|
|
||||||
class DeviceTest : public QObject {
|
class DeviceTest : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -34,7 +34,7 @@ public slots:
|
|||||||
void DeviceChanged(const QString& id);
|
void DeviceChanged(const QString& id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<DeviceEngine*> engines_;
|
QList<DeviceLister*> listers_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICETEST_H
|
#endif // DEVICETEST_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user