-
Notifications
You must be signed in to change notification settings - Fork 0
/
currentdevicemanager.h
74 lines (60 loc) · 2.01 KB
/
currentdevicemanager.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
#ifndef CURRENTDEVICEMANAGER_H
#define CURRENTDEVICEMANAGER_H
#include <QFileInfoList>
#include <QObject>
#include <QThread>
#include "tools/deviceprovider.h"
#include "tools/mtptool.h"
#include "tools/findmmfiles.h"
class CurrentDeviceManager : public QObject
{
Q_OBJECT
public:
static CurrentDeviceManager *getInstance();
Device *getCurrentDevice();
MtpTool *getMtpTool();
signals:
void currentDeviceChanged(Device *m_currentDevice);
void allDevicePlugOuted();
void startFindFiles(QString path);
void startFindFilesSD(QString path);
// 转发DeviceProvider的信号
void newDeviceStateInvalid();
void detectDeviceFailed();
// 转发MtpTool的信号
void deviceMounted();
void deviceMountFailed(QString why);
void deviceUnMounted();
void mountProcessExecFailed();
void unmountProcessExecFailed();
public slots:
void cancelFindFiles();
private:
explicit CurrentDeviceManager(QObject *parent = nullptr);
explicit CurrentDeviceManager(const CurrentDeviceManager &other);
CurrentDeviceManager &operator=(const CurrentDeviceManager &other);
DeviceProvider m_deviceProvider;
Device m_currentDevice;
MtpTool m_mtpTool;
QThread m_findFilesThread;
QThread m_findFilesSDThread;
FindMMFiles *m_findFiles;
FindMMFiles *m_findFilesSD;
int m_findFilesThreadCount;
private:
void tryToEmitCurrentDeviceChanged();
private slots:
void onCDMDeviceCountChanged(QList<Device> devices);
void onNewDeviceStateInvalid();
void onDetectDeviceFailed();
void onFindFilesFinished(int allMMFilesCount, QFileInfoList musicFiles);
void onFindFilesCanceled();
void onFindFilesSDFinished(int allMMFilesCount, QFileInfoList musicFiles);
void onFindFilesSDCanceled();
void onDeviceMounted(QString storagePath, QString sdcardPath, bool hasSDCard);
void onDeviceMountFailed(QString why);
void onDeviceUnmounted();
void onMountProcessExecFailed();
void onUnMountProcessExecFailed();
};
#endif // CURRENTDEVICEMANAGER_H