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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
/*
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
*/
#include "kmtpstorageinterface.h"
#include <chrono>
#include "kmtpdeviceinterface.h"
using namespace std::chrono_literals;
KMTPStorageInterface::KMTPStorageInterface(const QString &dbusObjectPath, KMTPDeviceInterface *parent)
: QObject(parent)
{
m_dbusInterface = new org::kde::kmtp::Storage(QStringLiteral("org.kde.kmtpd5"), dbusObjectPath, QDBusConnection::sessionBus(), this);
// Arbitrarily large number to prevent timeouts on file listing.
// https://bugs.kde.org/show_bug.cgi?id=462059
// https://github.com/libmtp/libmtp/issues/144
m_dbusInterface->setTimeout(std::chrono::milliseconds(60min).count());
qDBusRegisterMetaType<KMTPFile>();
qDBusRegisterMetaType<KMTPFileList>();
connect(m_dbusInterface, &org::kde::kmtp::Storage::dataReady, this, &KMTPStorageInterface::dataReady);
connect(m_dbusInterface, &org::kde::kmtp::Storage::copyProgress, this, &KMTPStorageInterface::copyProgress);
connect(m_dbusInterface, &org::kde::kmtp::Storage::copyFinished, this, &KMTPStorageInterface::copyFinished);
}
QString KMTPStorageInterface::description() const
{
return m_dbusInterface->description();
}
quint64 KMTPStorageInterface::maxCapacity() const
{
return m_dbusInterface->maxCapacity();
}
quint64 KMTPStorageInterface::freeSpaceInBytes() const
{
return m_dbusInterface->freeSpaceInBytes();
}
KMTPFileList KMTPStorageInterface::getFilesAndFolders(const QString &path, int &result) const
{
return m_dbusInterface->getFilesAndFolders(path, result);
}
std::variant<QDBusObjectPath, QDBusError> KMTPStorageInterface::getFilesAndFolders2(const QString &path) const
{
auto reply = m_dbusInterface->getFilesAndFolders2(path);
reply.waitForFinished();
if (reply.error().isValid()) {
return reply.error();
}
return reply;
}
KMTPFile KMTPStorageInterface::getFileMetadata(const QString &path) const
{
return m_dbusInterface->getFileMetadata(path);
}
int KMTPStorageInterface::getFileToHandler(const QString &path) const
{
return m_dbusInterface->getFileToHandler(path);
}
int KMTPStorageInterface::getFileToFileDescriptor(const QDBusUnixFileDescriptor &descriptor, const QString &sourcePath) const
{
return m_dbusInterface->getFileToFileDescriptor(descriptor, sourcePath).value();
}
int KMTPStorageInterface::sendFileFromFileDescriptor(const QDBusUnixFileDescriptor &descriptor, const QString &destinationPath) const
{
return m_dbusInterface->sendFileFromFileDescriptor(descriptor, destinationPath);
}
int KMTPStorageInterface::setFileName(const QString &path, const QString &newName) const
{
return m_dbusInterface->setFileName(path, newName);
}
quint32 KMTPStorageInterface::createFolder(const QString &path) const
{
return m_dbusInterface->createFolder(path);
}
int KMTPStorageInterface::deleteObject(const QString &path) const
{
return m_dbusInterface->deleteObject(path);
}
#include "moc_kmtpstorageinterface.cpp"
|