Changeset View
Changeset View
Standalone View
Standalone View
mtp/shared/kmtpfile.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | This file is part of the KMTP framework, part of the KDE project. | ||||
3 | | ||||
4 | Copyright (C) 2018 Andreas Krutzler <andreas.krutzler@gmx.net> | ||||
5 | | ||||
6 | This library is free software; you can redistribute it and/or | ||||
7 | modify it under the terms of the GNU Lesser General Public | ||||
8 | License as published by the Free Software Foundation; either | ||||
9 | version 2.1 of the License, or (at your option) version 3, or any | ||||
10 | later version accepted by the membership of KDE e.V. (or its | ||||
11 | successor approved by the membership of KDE e.V.), which shall | ||||
12 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
13 | | ||||
14 | This library is distributed in the hope that it will be useful, | ||||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
17 | Lesser General Public License for more details. | ||||
18 | | ||||
19 | You should have received a copy of the GNU Lesser General Public | ||||
20 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
21 | */ | ||||
22 | | ||||
23 | #ifndef KMTPFILE_H | ||||
24 | #define KMTPFILE_H | ||||
25 | | ||||
26 | #include <QDBusArgument> | ||||
27 | | ||||
28 | /** | ||||
29 | * @brief A wrapper class for LIBMTP_file_t which provides streaming operators for D-Bus marshalling | ||||
30 | * | ||||
31 | * LIBMTP_file_t definitions with some exceptions: | ||||
32 | * item_id: unchanged | ||||
33 | * parent_id: unchanged | ||||
34 | * storage_id: unchanged | ||||
35 | * filename: represented as string | ||||
36 | * filesize: unchanged | ||||
37 | * modificationsdate: represented as an int64 | ||||
38 | * filetype: converted to a mime-string | ||||
39 | * next: omitted as it is not necessary in a list | ||||
40 | */ | ||||
41 | class KMTPFile | ||||
42 | { | ||||
43 | | ||||
44 | public: | ||||
45 | KMTPFile(); | ||||
46 | KMTPFile(const KMTPFile &other) = default; | ||||
47 | KMTPFile(quint32 itemId, | ||||
48 | quint32 parentId, | ||||
49 | quint32 storageId, | ||||
50 | const char *filename, | ||||
51 | quint64 filesize, | ||||
52 | qint64 modificationdate, | ||||
53 | const QString &filetype); | ||||
54 | | ||||
55 | bool isValid() const; | ||||
56 | bool isFolder() const; | ||||
57 | | ||||
58 | quint32 itemId() const; | ||||
59 | quint32 parentId() const; | ||||
60 | quint32 storageId() const; | ||||
61 | QString filename() const; | ||||
62 | quint64 filesize() const; | ||||
63 | qint64 modificationdate() const; | ||||
64 | QString filetype() const; | ||||
65 | | ||||
66 | private: | ||||
67 | quint32 m_itemId; /**< Unique item ID */ | ||||
68 | quint32 m_parentId; /**< ID of parent folder */ | ||||
69 | quint32 m_storageId; /**< ID of storage holding this file */ | ||||
70 | QString m_filename; /**< Filename of this file */ | ||||
71 | quint64 m_filesize; /**< Size of file in bytes */ | ||||
72 | qint64 m_modificationdate; /**< Date of last alteration of the file */ | ||||
73 | QString m_filetype; /**< Filetype used for the current file */ | ||||
74 | | ||||
75 | friend QDBusArgument& operator<<(QDBusArgument &argument, const KMTPFile &mtpFile); | ||||
76 | friend const QDBusArgument& operator>>(const QDBusArgument &argument, KMTPFile &mtpFile); | ||||
77 | }; | ||||
78 | | ||||
79 | typedef QList<KMTPFile> KMTPFileList; | ||||
80 | | ||||
81 | Q_DECLARE_METATYPE(KMTPFile) | ||||
82 | Q_DECLARE_METATYPE(KMTPFileList) | ||||
83 | | ||||
84 | QDBusArgument& operator<<(QDBusArgument &argument, const KMTPFile &mtpFile); | ||||
85 | const QDBusArgument& operator>>(const QDBusArgument &argument, KMTPFile &mtpFile); | ||||
86 | | ||||
87 | QDBusArgument& operator<<(QDBusArgument &argument, const KMTPFileList &list); | ||||
88 | const QDBusArgument& operator>>(const QDBusArgument &argument, KMTPFileList &list); | ||||
89 | | ||||
90 | #endif // KMTPFILE_H |