File indexing completed on 2024-12-01 12:29:50
0001 /* 0002 * BluezQt - Asynchronous Bluez wrapper library 0003 * 0004 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #include "obexfiletransferentry.h" 0010 0011 #include <QDateTime> 0012 #include <QVariant> 0013 0014 namespace BluezQt 0015 { 0016 class ObexFileTransferEntryPrivate 0017 { 0018 public: 0019 QString m_name; 0020 QString m_label; 0021 ObexFileTransferEntry::Type m_type; 0022 quint64 m_size; 0023 QString m_permissions; 0024 QString m_memoryType; 0025 QDateTime m_modified; 0026 }; 0027 0028 static QDateTime dateTimeFromTransfer(const QString &value) 0029 { 0030 return QDateTime::fromString(value, QStringLiteral("yyyyMMddThhmmssZ")); 0031 } 0032 0033 ObexFileTransferEntry::ObexFileTransferEntry() 0034 : d(new ObexFileTransferEntryPrivate) 0035 { 0036 d->m_type = Invalid; 0037 d->m_size = 0; 0038 } 0039 0040 ObexFileTransferEntry::ObexFileTransferEntry(const QVariantMap &properties) 0041 : d(new ObexFileTransferEntryPrivate) 0042 { 0043 d->m_name = properties.value(QStringLiteral("Name")).toString(); 0044 d->m_label = properties.value(QStringLiteral("Label")).toString(); 0045 d->m_size = properties.value(QStringLiteral("Size")).toUInt(); 0046 d->m_permissions = properties.value(QStringLiteral("User-perm")).toString(); 0047 d->m_memoryType = properties.value(QStringLiteral("Mem-type")).toString(); 0048 d->m_modified = dateTimeFromTransfer(properties.value(QStringLiteral("Modified")).toString()); 0049 0050 const QString &type = properties.value(QStringLiteral("Type")).toString(); 0051 if (type == QLatin1String("folder")) { 0052 d->m_type = ObexFileTransferEntry::Folder; 0053 } else if (type == QLatin1String("file")) { 0054 d->m_type = ObexFileTransferEntry::File; 0055 } else { 0056 d->m_type = ObexFileTransferEntry::Invalid; 0057 } 0058 } 0059 0060 ObexFileTransferEntry::~ObexFileTransferEntry() 0061 { 0062 } 0063 0064 ObexFileTransferEntry::ObexFileTransferEntry(const ObexFileTransferEntry &other) 0065 : d(other.d) 0066 { 0067 } 0068 0069 ObexFileTransferEntry &ObexFileTransferEntry::operator=(const ObexFileTransferEntry &other) 0070 { 0071 if (d != other.d) { 0072 d = other.d; 0073 } 0074 return *this; 0075 } 0076 0077 bool ObexFileTransferEntry::isValid() const 0078 { 0079 return d->m_type != Invalid; 0080 } 0081 0082 QString ObexFileTransferEntry::name() const 0083 { 0084 return d->m_name; 0085 } 0086 0087 QString ObexFileTransferEntry::label() const 0088 { 0089 return d->m_label; 0090 } 0091 0092 ObexFileTransferEntry::Type ObexFileTransferEntry::type() const 0093 { 0094 return d->m_type; 0095 } 0096 0097 quint64 ObexFileTransferEntry::size() const 0098 { 0099 return d->m_size; 0100 } 0101 0102 QString ObexFileTransferEntry::permissions() const 0103 { 0104 return d->m_permissions; 0105 } 0106 0107 QString ObexFileTransferEntry::memoryType() const 0108 { 0109 return d->m_memoryType; 0110 } 0111 0112 QDateTime ObexFileTransferEntry::modificationTime() const 0113 { 0114 return d->m_modified; 0115 } 0116 0117 } // namespace BluezQt