File: kmtpfile.h

package info (click to toggle)
kio-extras 4%3A25.04.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 31,928 kB
  • sloc: cpp: 28,852; ansic: 3,084; perl: 1,048; xml: 116; sh: 92; python: 28; makefile: 9
file content (75 lines) | stat: -rw-r--r-- 2,462 bytes parent folder | download
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
75
/*
    This file is part of the KMTP framework, part of the KDE project.

    SPDX-FileCopyrightText: 2018 Andreas Krutzler <andreas.krutzler@gmx.net>

    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/

#ifndef KMTPFILE_H
#define KMTPFILE_H

#include <QDBusArgument>

/**
 * @brief A wrapper class for LIBMTP_file_t which provides streaming operators for D-Bus marshalling
 *
 * LIBMTP_file_t definitions with some exceptions:
 *  item_id: unchanged
 *  parent_id: unchanged
 *  storage_id: unchanged
 *  filename: represented as string
 *  filesize: unchanged
 *  modificationsdate: represented as an int64
 *  filetype: converted to a mime-string
 *  next: omitted as it is not necessary in a list
 */
class KMTPFile
{
public:
    KMTPFile();
    KMTPFile(const KMTPFile &other) = default;
    explicit KMTPFile(quint32 itemId,
                      quint32 parentId,
                      quint32 storageId,
                      const char *filename,
                      quint64 filesize,
                      qint64 modificationdate,
                      const QString &filetype);

    bool isValid() const;
    bool isFolder() const;

    quint32 itemId() const;
    quint32 parentId() const;
    quint32 storageId() const;
    QString filename() const;
    quint64 filesize() const;
    qint64 modificationdate() const;
    QString filetype() const;

private:
    quint32 m_itemId; /**< Unique item ID */
    quint32 m_parentId; /**< ID of parent folder */
    quint32 m_storageId; /**< ID of storage holding this file */
    QString m_filename; /**< Filename of this file */
    quint64 m_filesize; /**< Size of file in bytes */
    qint64 m_modificationdate; /**< Date of last alteration of the file */
    QString m_filetype; /**< Filetype used for the current file */

    friend QDBusArgument &operator<<(QDBusArgument &argument, const KMTPFile &mtpFile);
    friend const QDBusArgument &operator>>(const QDBusArgument &argument, KMTPFile &mtpFile);
};

typedef QList<KMTPFile> KMTPFileList;

Q_DECLARE_METATYPE(KMTPFile)
Q_DECLARE_METATYPE(KMTPFileList)

QDBusArgument &operator<<(QDBusArgument &argument, const KMTPFile &mtpFile);
const QDBusArgument &operator>>(const QDBusArgument &argument, KMTPFile &mtpFile);

QDBusArgument &operator<<(QDBusArgument &argument, const KMTPFileList &list);
const QDBusArgument &operator>>(const QDBusArgument &argument, KMTPFileList &list);

#endif // KMTPFILE_H