File indexing completed on 2024-05-12 04:59:45
0001 /* 0002 This file is part of the KMTP framework, part of the KDE project. 0003 0004 SPDX-FileCopyrightText: 2018 Andreas Krutzler <andreas.krutzler@gmx.net> 0005 0006 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef KMTPFILE_H 0010 #define KMTPFILE_H 0011 0012 #include <QDBusArgument> 0013 0014 /** 0015 * @brief A wrapper class for LIBMTP_file_t which provides streaming operators for D-Bus marshalling 0016 * 0017 * LIBMTP_file_t definitions with some exceptions: 0018 * item_id: unchanged 0019 * parent_id: unchanged 0020 * storage_id: unchanged 0021 * filename: represented as string 0022 * filesize: unchanged 0023 * modificationsdate: represented as an int64 0024 * filetype: converted to a mime-string 0025 * next: omitted as it is not necessary in a list 0026 */ 0027 class KMTPFile 0028 { 0029 public: 0030 KMTPFile(); 0031 KMTPFile(const KMTPFile &other) = default; 0032 explicit KMTPFile(quint32 itemId, 0033 quint32 parentId, 0034 quint32 storageId, 0035 const char *filename, 0036 quint64 filesize, 0037 qint64 modificationdate, 0038 const QString &filetype); 0039 0040 bool isValid() const; 0041 bool isFolder() const; 0042 0043 quint32 itemId() const; 0044 quint32 parentId() const; 0045 quint32 storageId() const; 0046 QString filename() const; 0047 quint64 filesize() const; 0048 qint64 modificationdate() const; 0049 QString filetype() const; 0050 0051 private: 0052 quint32 m_itemId; /**< Unique item ID */ 0053 quint32 m_parentId; /**< ID of parent folder */ 0054 quint32 m_storageId; /**< ID of storage holding this file */ 0055 QString m_filename; /**< Filename of this file */ 0056 quint64 m_filesize; /**< Size of file in bytes */ 0057 qint64 m_modificationdate; /**< Date of last alteration of the file */ 0058 QString m_filetype; /**< Filetype used for the current file */ 0059 0060 friend QDBusArgument &operator<<(QDBusArgument &argument, const KMTPFile &mtpFile); 0061 friend const QDBusArgument &operator>>(const QDBusArgument &argument, KMTPFile &mtpFile); 0062 }; 0063 0064 typedef QList<KMTPFile> KMTPFileList; 0065 0066 Q_DECLARE_METATYPE(KMTPFile) 0067 Q_DECLARE_METATYPE(KMTPFileList) 0068 0069 QDBusArgument &operator<<(QDBusArgument &argument, const KMTPFile &mtpFile); 0070 const QDBusArgument &operator>>(const QDBusArgument &argument, KMTPFile &mtpFile); 0071 0072 QDBusArgument &operator<<(QDBusArgument &argument, const KMTPFileList &list); 0073 const QDBusArgument &operator>>(const QDBusArgument &argument, KMTPFileList &list); 0074 0075 #endif // KMTPFILE_H