BluezQt

obexfiletransferentry.cpp
1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "obexfiletransferentry.h"
10
11#include <QDateTime>
12#include <QVariant>
13
14namespace BluezQt
15{
16class ObexFileTransferEntryPrivate
17{
18public:
19 QString m_name;
20 QString m_label;
22 quint64 m_size;
23 QString m_permissions;
24 QString m_memoryType;
25 QDateTime m_modified;
26};
27
28static QDateTime dateTimeFromTransfer(const QString &value)
29{
30 return QDateTime::fromString(value, QStringLiteral("yyyyMMddThhmmssZ"));
31}
32
34 : d(new ObexFileTransferEntryPrivate)
35{
36 d->m_type = Invalid;
37 d->m_size = 0;
38}
39
40ObexFileTransferEntry::ObexFileTransferEntry(const QVariantMap &properties)
41 : d(new ObexFileTransferEntryPrivate)
42{
43 d->m_name = properties.value(QStringLiteral("Name")).toString();
44 d->m_label = properties.value(QStringLiteral("Label")).toString();
45 d->m_size = properties.value(QStringLiteral("Size")).toUInt();
46 d->m_permissions = properties.value(QStringLiteral("User-perm")).toString();
47 d->m_memoryType = properties.value(QStringLiteral("Mem-type")).toString();
48 d->m_modified = dateTimeFromTransfer(properties.value(QStringLiteral("Modified")).toString());
49
50 const QString &type = properties.value(QStringLiteral("Type")).toString();
51 if (type == QLatin1String("folder")) {
53 } else if (type == QLatin1String("file")) {
55 } else {
57 }
58}
59
63
68
70{
71 if (d != other.d) {
72 d = other.d;
73 }
74 return *this;
75}
76
78{
79 return d->m_type != Invalid;
80}
81
83{
84 return d->m_name;
85}
86
88{
89 return d->m_label;
90}
91
93{
94 return d->m_type;
95}
96
98{
99 return d->m_size;
100}
101
103{
104 return d->m_permissions;
105}
106
108{
109 return d->m_memoryType;
110}
111
113{
114 return d->m_modified;
115}
116
117} // namespace BluezQt
OBEX file transfer entry.
QString label() const
Returns a label of the entry.
Type type() const
Returns a type of the entry.
ObexFileTransferEntry()
Creates a new invalid ObexFileTransferEntry object.
QString name() const
Returns a name of the entry.
ObexFileTransferEntry & operator=(const ObexFileTransferEntry &other)
Copy assignment operator.
virtual ~ObexFileTransferEntry()
Destroys an ObexFileTransferEntry object.
@ Folder
Indicates that the entry is a folder.
@ Invalid
Indicates that the entry is invalid.
@ File
Indicates that the entry is a file.
QDateTime modificationTime() const
Returns a modification time of the entry.
bool isValid() const
Returns whether the entry is valid.
quint64 size() const
Returns a size of the entry.
QString memoryType() const
Returns a memory type where the entry is stored.
QString permissions() const
Returns a permissions of the entry.
QDateTime fromString(QStringView string, QStringView format, QCalendar cal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:00:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.