Changeset View
Changeset View
Standalone View
Standalone View
mtp/kiod_module/mtpdevice.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | This file is part of the MTP KIOD module, part of the KDE project. | ||||
3 | | ||||
4 | Copyright (C) 2018 Andreas Krutzler <andreas.krutzler@gmx.net> | ||||
5 | | ||||
6 | This program is free software: you can redistribute it and/or modify | ||||
7 | it under the terms of the GNU General Public License as published by | ||||
8 | the Free Software Foundation, either version 2 of the License, or | ||||
9 | (at your option) any later version. | ||||
10 | | ||||
11 | This program is distributed in the hope that it will be useful, | ||||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
14 | GNU General Public License for more details. | ||||
15 | | ||||
16 | You should have received a copy of the GNU General Public License | ||||
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
18 | */ | ||||
19 | | ||||
20 | #ifndef MTPDEVICE_H | ||||
21 | #define MTPDEVICE_H | ||||
22 | | ||||
23 | #include <libmtp.h> | ||||
24 | | ||||
25 | #include <QDBusObjectPath> | ||||
26 | #include <QLoggingCategory> | ||||
27 | | ||||
28 | Q_DECLARE_LOGGING_CATEGORY(LOG_KIOD_KMTPD) | ||||
29 | | ||||
30 | class MTPStorage; | ||||
31 | | ||||
32 | /** | ||||
33 | * @brief This D-Bus interface is used to access a single MTP device. | ||||
34 | */ | ||||
35 | class MTPDevice : public QObject | ||||
36 | { | ||||
37 | Q_OBJECT | ||||
38 | Q_PROPERTY(QString udi READ udi CONSTANT) | ||||
39 | Q_PROPERTY(QString friendlyName READ friendlyName NOTIFY friendlyNameChanged) | ||||
40 | | ||||
41 | public: | ||||
42 | explicit MTPDevice(const QString &dbusObjectPath, | ||||
43 | LIBMTP_mtpdevice_t *device, | ||||
44 | LIBMTP_raw_device_t *rawdevice, | ||||
45 | const QString &udi, | ||||
46 | qint32 timeout, | ||||
47 | QObject *parent = nullptr); | ||||
48 | ~MTPDevice() override; | ||||
49 | | ||||
50 | LIBMTP_mtpdevice_t *getDevice(); | ||||
51 | QString dbusObjectName() const; | ||||
52 | | ||||
53 | // D-Bus properties | ||||
54 | QString udi() const; | ||||
55 | QString friendlyName() const; | ||||
56 | | ||||
57 | private: | ||||
58 | const QString m_dbusObjectName; | ||||
59 | QList<MTPStorage *> m_storages; | ||||
60 | qint32 m_timeout; | ||||
61 | | ||||
62 | LIBMTP_mtpdevice_t *m_mtpdevice; | ||||
63 | LIBMTP_raw_device_t m_rawdevice; | ||||
64 | | ||||
65 | QString m_udi; | ||||
66 | QString m_friendlyName; | ||||
67 | | ||||
68 | public slots: | ||||
69 | // D-Bus methods | ||||
70 | | ||||
71 | int setFriendlyName(const QString &friendlyName); | ||||
72 | QList<QDBusObjectPath> listStorages() const; | ||||
73 | | ||||
74 | signals: | ||||
75 | void friendlyNameChanged(const QString &friendlyName); | ||||
76 | }; | ||||
77 | | ||||
78 | #endif // MTPDEVICE_H |