1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-27 09:41:32 +01:00

Rename the DeviceEngines to DeviceListers

This commit is contained in:
David Sansome 2010-06-25 22:36:21 +00:00
parent 2b17a8ee1f
commit b750df38ce
7 changed files with 51 additions and 51 deletions

View File

@ -53,9 +53,9 @@ set(SOURCES
core/utilities.cpp
devices/device.cpp
devices/deviceengine.cpp
devices/devicekitlister.cpp
devices/devicelister.cpp
devices/devicetest.cpp
devices/filesystemdeviceengine.cpp
engines/enginebase.cpp
@ -174,9 +174,9 @@ set(HEADERS
core/taskmanager.h
devices/device.h
devices/deviceengine.h
devices/devicekitlister.h
devices/devicelister.h
devices/devicetest.h
devices/filesystemdeviceengine.h
engines/enginebase.h

View File

@ -14,25 +14,25 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "filesystemdeviceengine.h"
#include "devicekitlister.h"
#include "dbus/udisks.h"
#include "dbus/udisksdevice.h"
#include <QtDebug>
FilesystemDeviceEngine::FilesystemDeviceEngine()
DeviceKitLister::DeviceKitLister()
{
}
FilesystemDeviceEngine::~FilesystemDeviceEngine() {
DeviceKitLister::~DeviceKitLister() {
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);
}
void FilesystemDeviceEngine::Init() {
void DeviceKitLister::Init() {
interface_.reset(new OrgFreedesktopUDisksInterface(
OrgFreedesktopUDisksInterface::staticInterfaceName(),
"/org/freedesktop/UDisks", QDBusConnection::systemBus()));
@ -77,12 +77,12 @@ void FilesystemDeviceEngine::Init() {
}
}
QStringList FilesystemDeviceEngine::DeviceUniqueIDs() {
QStringList DeviceKitLister::DeviceUniqueIDs() {
QMutexLocker l(&mutex_);
return device_data_.keys();
}
QVariant FilesystemDeviceEngine::DeviceInfo(const QString& id, int field) {
QVariant DeviceKitLister::DeviceInfo(const QString& id, int field) {
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 {
DeviceData ret;
@ -158,7 +158,7 @@ FilesystemDeviceEngine::DeviceData FilesystemDeviceEngine::ReadDeviceData(
return ret;
}
void FilesystemDeviceEngine::DBusDeviceAdded(const QDBusObjectPath &path) {
void DeviceKitLister::DBusDeviceAdded(const QDBusObjectPath &path) {
DeviceData data = ReadDeviceData(path);
if (!data.suitable)
return;
@ -171,7 +171,7 @@ void FilesystemDeviceEngine::DBusDeviceAdded(const QDBusObjectPath &path) {
emit DeviceAdded(data.unique_id());
}
void FilesystemDeviceEngine::DBusDeviceRemoved(const QDBusObjectPath &path) {
void DeviceKitLister::DBusDeviceRemoved(const QDBusObjectPath &path) {
QString id;
{
QMutexLocker l(&mutex_);
@ -185,7 +185,7 @@ void FilesystemDeviceEngine::DBusDeviceRemoved(const QDBusObjectPath &path) {
emit DeviceRemoved(id);
}
void FilesystemDeviceEngine::DBusDeviceChanged(const QDBusObjectPath &path) {
void DeviceKitLister::DBusDeviceChanged(const QDBusObjectPath &path) {
bool already_known = false;
{
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_) {
if (data.dbus_path == path.path())
return data.unique_id();

View File

@ -14,10 +14,10 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FILESYSTEMDEVICEENGINE_H
#define FILESYSTEMDEVICEENGINE_H
#ifndef DEVICEKITLISTER_H
#define DEVICEKITLISTER_H
#include "deviceengine.h"
#include "devicelister.h"
#include <QMutex>
#include <QStringList>
@ -28,18 +28,18 @@ class OrgFreedesktopUDisksInterface;
class QDBusObjectPath;
class FilesystemDeviceEngine : public DeviceEngine {
class DeviceKitLister : public DeviceLister {
Q_OBJECT
public:
FilesystemDeviceEngine();
~FilesystemDeviceEngine();
DeviceKitLister();
~DeviceKitLister();
enum Field {
Field_MountPath = LastDeviceEngineField,
Field_MountPath = DeviceLister::LastField,
Field_DbusPath,
LastFilesystemDeviceEngineField
LastField
};
QStringList DeviceUniqueIDs();
@ -82,4 +82,4 @@ private:
QMap<QString, DeviceData> device_data_;
};
#endif // FILESYSTEMDEVICEENGINE_H
#endif // DEVICEKITLISTER_H

View File

@ -14,17 +14,17 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "deviceengine.h"
#include "devicelister.h"
#include <QThread>
#include <QtDebug>
DeviceEngine::DeviceEngine()
DeviceLister::DeviceLister()
: thread_(NULL)
{
}
DeviceEngine::~DeviceEngine() {
DeviceLister::~DeviceLister() {
qDebug() << __PRETTY_FUNCTION__;
if (thread_) {
thread_->quit();
@ -32,7 +32,7 @@ DeviceEngine::~DeviceEngine() {
}
}
void DeviceEngine::Start() {
void DeviceLister::Start() {
thread_ = new QThread;
connect(thread_, SIGNAL(started()), SLOT(ThreadStarted()));
@ -40,6 +40,6 @@ void DeviceEngine::Start() {
thread_->start();
}
void DeviceEngine::ThreadStarted() {
void DeviceLister::ThreadStarted() {
Init();
}

View File

@ -14,17 +14,17 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEVICEENGINE_H
#define DEVICEENGINE_H
#ifndef DEVICELISTER_H
#define DEVICELISTER_H
#include <QAbstractItemModel>
class DeviceEngine : public QObject {
class DeviceLister : public QObject {
Q_OBJECT
public:
DeviceEngine();
~DeviceEngine();
DeviceLister();
~DeviceLister();
enum Field {
Field_UniqueID = 0,
@ -34,7 +34,7 @@ public:
Field_Capacity,
Field_FreeSpace,
LastDeviceEngineField
LastField
};
// Tries to start the thread and initialise the engine. This object will be
@ -60,4 +60,4 @@ private slots:
void ThreadStarted();
};
#endif // DEVICEENGINE_H
#endif // DEVICELISTER_H

View File

@ -15,31 +15,31 @@
*/
#include "devicetest.h"
#include "filesystemdeviceengine.h"
#include "devicekitlister.h"
#include <QtDebug>
DeviceTest::DeviceTest(QObject *parent)
: QObject(parent)
{
DeviceEngine* engine = new FilesystemDeviceEngine;
engines_ << engine;
connect(engine, SIGNAL(DeviceAdded(QString)), SLOT(DeviceAdded(QString)));
connect(engine, SIGNAL(DeviceRemoved(QString)), SLOT(DeviceRemoved(QString)));
connect(engine, SIGNAL(DeviceChanged(QString)), SLOT(DeviceChanged(QString)));
DeviceLister* lister = new DeviceKitLister;
listers_ << lister;
connect(lister, SIGNAL(DeviceAdded(QString)), SLOT(DeviceAdded(QString)));
connect(lister, SIGNAL(DeviceRemoved(QString)), SLOT(DeviceRemoved(QString)));
connect(lister, SIGNAL(DeviceChanged(QString)), SLOT(DeviceChanged(QString)));
engine->Start();
lister->Start();
}
DeviceTest::~DeviceTest() {
qDeleteAll(engines_);
qDeleteAll(listers_);
}
void DeviceTest::DeviceAdded(const QString &id) {
DeviceEngine* engine = qobject_cast<DeviceEngine*>(sender());
DeviceLister* engine = qobject_cast<DeviceLister*>(sender());
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);
}
}
@ -49,10 +49,10 @@ void DeviceTest::DeviceRemoved(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;
for (int i=0 ; i<FilesystemDeviceEngine::LastFilesystemDeviceEngineField ; ++i) {
for (int i=0 ; i<DeviceKitLister::LastField ; ++i) {
qDebug() << i << engine->DeviceInfo(id, i);
}
}

View File

@ -19,7 +19,7 @@
#include <QObject>
class DeviceEngine;
class DeviceLister;
class DeviceTest : public QObject {
Q_OBJECT
@ -34,7 +34,7 @@ public slots:
void DeviceChanged(const QString& id);
private:
QList<DeviceEngine*> engines_;
QList<DeviceLister*> listers_;
};
#endif // DEVICETEST_H