File indexing completed on 2024-05-12 04:59:44
0001 /* 0002 This file is part of the MTP KIOD module, part of the KDE project. 0003 0004 SPDX-FileCopyrightText: 2018 Andreas Krutzler <andreas.krutzler@gmx.net> 0005 SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #ifndef MTPDEVICE_H 0011 #define MTPDEVICE_H 0012 0013 #include <libmtp.h> 0014 0015 #include <QDBusObjectPath> 0016 0017 class MTPStorage; 0018 0019 /** 0020 * @brief This D-Bus interface is used to access a single MTP device. 0021 */ 0022 class MTPDevice : public QObject 0023 { 0024 Q_OBJECT 0025 Q_PROPERTY(QString udi READ udi CONSTANT) 0026 Q_PROPERTY(QString friendlyName READ friendlyName NOTIFY friendlyNameChanged) 0027 0028 public: 0029 explicit MTPDevice(const QString &dbusObjectPath, 0030 LIBMTP_mtpdevice_t *device, 0031 LIBMTP_raw_device_t *rawdevice, 0032 const QString &udi, 0033 QObject *parent = nullptr); 0034 ~MTPDevice() override; 0035 0036 LIBMTP_mtpdevice_t *getDevice(); 0037 QString dbusObjectName() const; 0038 0039 // D-Bus properties 0040 QString udi() const; 0041 QString friendlyName() const; 0042 0043 bool devicesUpdated() const; 0044 void setDevicesUpdatedStatus(bool value); 0045 0046 /// The friendly name url of this device. 0047 QUrl url() const; 0048 0049 private: 0050 const QString m_dbusObjectName; 0051 QList<MTPStorage *> m_storages; 0052 0053 LIBMTP_mtpdevice_t *m_mtpdevice; 0054 LIBMTP_raw_device_t m_rawdevice; 0055 0056 QString m_udi; 0057 QString m_friendlyName; 0058 bool m_devicesUpdated; 0059 0060 public Q_SLOTS: 0061 // D-Bus methods 0062 0063 int setFriendlyName(const QString &friendlyName); 0064 QList<QDBusObjectPath> listStorages(); 0065 0066 Q_SIGNALS: 0067 void friendlyNameChanged(const QString &friendlyName); 0068 }; 0069 0070 #endif // MTPDEVICE_H