2010-06-25 21:04:10 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FILESYSTEMDEVICEENGINE_H
|
|
|
|
#define FILESYSTEMDEVICEENGINE_H
|
|
|
|
|
|
|
|
#include "deviceengine.h"
|
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
#include <QMutex>
|
2010-06-25 21:04:10 +02:00
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
#include <boost/scoped_ptr.hpp>
|
|
|
|
|
|
|
|
class OrgFreedesktopUDisksInterface;
|
|
|
|
|
|
|
|
class QDBusObjectPath;
|
|
|
|
|
|
|
|
class FilesystemDeviceEngine : public DeviceEngine {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2010-06-26 00:01:47 +02:00
|
|
|
FilesystemDeviceEngine();
|
2010-06-25 21:04:10 +02:00
|
|
|
~FilesystemDeviceEngine();
|
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
enum Field {
|
|
|
|
Field_MountPath = LastDeviceEngineField,
|
|
|
|
Field_DbusPath,
|
2010-06-25 21:04:10 +02:00
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
LastFilesystemDeviceEngineField
|
2010-06-25 21:04:10 +02:00
|
|
|
};
|
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
QStringList DeviceUniqueIDs();
|
|
|
|
QVariant DeviceInfo(const QString& id, int field);
|
2010-06-25 21:04:10 +02:00
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
protected:
|
|
|
|
void Init();
|
2010-06-25 21:04:10 +02:00
|
|
|
|
|
|
|
private slots:
|
2010-06-26 00:01:47 +02:00
|
|
|
void DBusDeviceAdded(const QDBusObjectPath& path);
|
|
|
|
void DBusDeviceRemoved(const QDBusObjectPath& path);
|
|
|
|
void DBusDeviceChanged(const QDBusObjectPath& path);
|
2010-06-25 21:04:10 +02:00
|
|
|
|
|
|
|
private:
|
2010-06-26 00:01:47 +02:00
|
|
|
struct DeviceData {
|
|
|
|
DeviceData() : suitable(false), device_size(0) {}
|
|
|
|
|
|
|
|
QString unique_id() const;
|
2010-06-25 21:04:10 +02:00
|
|
|
|
|
|
|
bool suitable;
|
|
|
|
QString dbus_path;
|
|
|
|
QString drive_serial;
|
|
|
|
QString drive_model;
|
|
|
|
QString drive_vendor;
|
|
|
|
QString device_presentation_name;
|
|
|
|
QString device_presentation_icon_name;
|
|
|
|
QStringList device_mount_paths;
|
|
|
|
quint64 device_size;
|
|
|
|
};
|
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
DeviceData ReadDeviceData(const QDBusObjectPath& path) const;
|
2010-06-25 21:04:10 +02:00
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
// You MUST hold the mutex while calling this function
|
|
|
|
QString FindUniqueIdByPath(const QDBusObjectPath& path) const;
|
2010-06-25 21:04:10 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
boost::scoped_ptr<OrgFreedesktopUDisksInterface> interface_;
|
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
QMutex mutex_;
|
|
|
|
QMap<QString, DeviceData> device_data_;
|
2010-06-25 21:04:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FILESYSTEMDEVICEENGINE_H
|