2010-06-25 21:04:10 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-06-25 21:04:10 +02:00
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
2010-06-26 00:36:21 +02:00
|
|
|
#ifndef DEVICELISTER_H
|
|
|
|
#define DEVICELISTER_H
|
2010-06-25 21:04:10 +02:00
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
2010-07-17 16:22:07 +02:00
|
|
|
#include <QUrl>
|
2010-06-25 21:04:10 +02:00
|
|
|
|
2010-06-26 01:38:21 +02:00
|
|
|
class ConnectedDevice;
|
2010-06-26 14:41:18 +02:00
|
|
|
class DeviceManager;
|
2010-06-26 01:38:21 +02:00
|
|
|
|
2010-06-26 00:36:21 +02:00
|
|
|
class DeviceLister : public QObject {
|
2010-06-25 21:04:10 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2010-06-26 00:36:21 +02:00
|
|
|
DeviceLister();
|
2010-07-23 15:46:30 +02:00
|
|
|
virtual ~DeviceLister();
|
2010-06-26 00:01:47 +02:00
|
|
|
|
|
|
|
// Tries to start the thread and initialise the engine. This object will be
|
|
|
|
// moved to the new thread.
|
|
|
|
void Start();
|
2010-06-25 21:04:10 +02:00
|
|
|
|
2010-07-17 19:18:02 +02:00
|
|
|
// If two listers know about the same device, then the metadata will get
|
|
|
|
// taken from the one with the highest priority.
|
|
|
|
virtual int priority() const { return 100; }
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
// Query information about the devices that are available. Must be
|
|
|
|
// thread-safe.
|
2010-06-26 00:01:47 +02:00
|
|
|
virtual QStringList DeviceUniqueIDs() = 0;
|
2010-08-16 01:26:04 +02:00
|
|
|
virtual QVariantList DeviceIcons(const QString& id) = 0;
|
2010-07-04 17:01:24 +02:00
|
|
|
virtual QString DeviceManufacturer(const QString& id) = 0;
|
|
|
|
virtual QString DeviceModel(const QString& id) = 0;
|
|
|
|
virtual quint64 DeviceCapacity(const QString& id) = 0;
|
|
|
|
virtual quint64 DeviceFreeSpace(const QString& id) = 0;
|
|
|
|
virtual QVariantMap DeviceHardwareInfo(const QString& id) = 0;
|
2010-09-11 14:29:44 +02:00
|
|
|
virtual bool DeviceNeedsMount(const QString& id) { return false; }
|
2010-07-04 17:01:24 +02:00
|
|
|
|
2011-08-11 00:59:34 +02:00
|
|
|
// When connecting to a device for the first time, do we want an user's
|
|
|
|
// confirmation for scanning it? (by default yes)
|
2011-08-11 22:10:14 +02:00
|
|
|
virtual bool AskForScan(const QString&) const { return true; }
|
2011-08-11 00:59:34 +02:00
|
|
|
|
2010-07-04 17:01:24 +02:00
|
|
|
virtual QString MakeFriendlyName(const QString& id) = 0;
|
2010-08-01 13:55:01 +02:00
|
|
|
virtual QList<QUrl> MakeDeviceUrls(const QString& id) = 0;
|
2010-06-26 01:38:21 +02:00
|
|
|
|
2010-09-11 14:29:44 +02:00
|
|
|
// Ensure the device is mounted. This should run asynchronously and emit
|
|
|
|
// DeviceMounted when it's done.
|
|
|
|
virtual int MountDevice(const QString& id);
|
|
|
|
|
2010-07-25 03:07:51 +02:00
|
|
|
// Do whatever needs to be done to safely remove the device.
|
|
|
|
virtual void UnmountDevice(const QString& id) = 0;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public slots:
|
2010-08-11 20:47:53 +02:00
|
|
|
virtual void UpdateDeviceFreeSpace(const QString& id) = 0;
|
2010-08-22 17:42:21 +02:00
|
|
|
virtual void ShutDown() {}
|
2010-08-11 20:47:53 +02:00
|
|
|
|
2010-06-26 00:01:47 +02:00
|
|
|
signals:
|
|
|
|
void DeviceAdded(const QString& id);
|
|
|
|
void DeviceRemoved(const QString& id);
|
|
|
|
void DeviceChanged(const QString& id);
|
2010-09-11 14:29:44 +02:00
|
|
|
void DeviceMounted(const QString& id, int request_id, bool success);
|
2010-06-26 00:01:47 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2010-06-26 00:01:47 +02:00
|
|
|
virtual void Init() = 0;
|
2011-04-12 19:27:01 +02:00
|
|
|
QUrl MakeUrlFromLocalPath(const QString& path) const;
|
|
|
|
bool IsIpod(const QString& path) const;
|
2010-06-26 00:01:47 +02:00
|
|
|
|
2010-07-25 02:20:18 +02:00
|
|
|
QStringList GuessIconForPath(const QString& path);
|
2010-07-25 15:32:47 +02:00
|
|
|
QStringList GuessIconForModel(const QString& vendor, const QString& model);
|
2010-07-25 02:20:18 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2010-06-26 00:01:47 +02:00
|
|
|
QThread* thread_;
|
2010-09-11 14:29:44 +02:00
|
|
|
int next_mount_request_id_;
|
2010-06-25 21:04:10 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2010-06-26 00:01:47 +02:00
|
|
|
void ThreadStarted();
|
2010-06-25 21:04:10 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // DEVICELISTER_H
|