/
connecteddevice.h
96 lines (73 loc) · 2.68 KB
/
connecteddevice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
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 CONNECTEDDEVICE_H
#define CONNECTEDDEVICE_H
#include <memory>
#include <QObject>
#include <QStringList>
#include <QUrl>
#include "core/musicstorage.h"
#include "core/song.h"
class Application;
class Database;
class DeviceLister;
class DeviceManager;
class LibraryBackend;
class LibraryModel;
class ConnectedDevice : public QObject,
public virtual MusicStorage,
public std::enable_shared_from_this<ConnectedDevice> {
Q_OBJECT
public:
ConnectedDevice(const QUrl& url, DeviceLister* lister,
const QString& unique_id, DeviceManager* manager,
Application* app, int database_id, bool first_time);
~ConnectedDevice();
virtual void Init() = 0;
virtual void ConnectAsync();
// For some devices (e.g. CD devices) we don't have callbacks to be notified
// when something change: we can call this method to refresh device's state
virtual void Refresh() {}
virtual TranscodeMode GetTranscodeMode() const;
virtual Song::FileType GetTranscodeFormat() const;
DeviceLister* lister() const { return lister_; }
QString unique_id() const { return unique_id_; }
LibraryModel* model() const { return model_; }
QUrl url() const { return url_; }
int song_count() const { return song_count_; }
virtual void FinishCopy(bool success);
virtual void FinishDelete(bool success);
virtual void Eject();
signals:
void TaskStarted(int id);
void SongCountUpdated(int count);
void ConnectFinished(const QString& id, bool success);
protected:
void InitBackendDirectory(const QString& mount_point, bool first_time,
bool rewrite_path = true);
protected:
Application* app_;
QUrl url_;
bool first_time_;
DeviceLister* lister_;
QString unique_id_;
int database_id_;
DeviceManager* manager_;
LibraryBackend* backend_;
LibraryModel* model_;
int song_count_;
private slots:
void BackendTotalSongCountUpdated(int count);
};
#endif // CONNECTEDDEVICE_H