BluezQt

obexfiletransferentry.cpp
1 /*
2  * BluezQt - Asynchronous Bluez wrapper library
3  *
4  * SPDX-FileCopyrightText: 2015 David Rosca <[email protected]>
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 
14 namespace BluezQt
15 {
16 class ObexFileTransferEntryPrivate
17 {
18 public:
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 
28 static 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 
40 ObexFileTransferEntry::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")) {
54  d->m_type = ObexFileTransferEntry::File;
55  } else {
57  }
58 }
59 
61 {
62 }
63 
65  : d(other.d)
66 {
67 }
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
QString permissions() const
Returns a permissions of the entry.
QString memoryType() const
Returns a memory type where the entry is stored.
Type type() const
Returns a type of the entry.
@ Folder
Indicates that the entry is a folder.
QString name() const
Returns a name of the entry.
QDateTime modificationTime() const
Returns a modification time of the entry.
QString label() const
Returns a label of the entry.
QDateTime fromString(const QString &string, Qt::DateFormat format)
@ Invalid
Indicates that the entry is invalid.
ObexFileTransferEntry()
Creates a new invalid ObexFileTransferEntry object.
quint64 size() const
Returns a size of the entry.
bool isValid() const
Returns whether the entry is valid.
@ File
Indicates that the entry is a file.
virtual ~ObexFileTransferEntry()
Destroys an ObexFileTransferEntry object.
ObexFileTransferEntry & operator=(const ObexFileTransferEntry &other)
Copy assignment operator.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.