File indexing completed on 2024-10-13 07:52:44

0001 /*
0002  * This file is part of the KDE project
0003  *
0004  * SPDX-FileCopyrightText: 2010-2011 Alejandro Fiestas Olivares <afiestas@kde.org>
0005  * SPDX-FileCopyrightText: 2010-2011 UFO Coders <info@ufocoders.com>
0006  *
0007  * SPDX-License-Identifier: LGPL-2.0-or-later
0008  */
0009 
0010 #pragma once
0011 
0012 #include <QList>
0013 #include <QStringList>
0014 #include <QTime>
0015 
0016 #include <KJob>
0017 
0018 #include <BluezQt/ObexTransfer>
0019 
0020 namespace BluezQt
0021 {
0022 class ObexObjectPush;
0023 }
0024 
0025 class SendFilesJob : public KJob
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     explicit SendFilesJob(const QStringList &files, BluezQt::DevicePtr device, const QDBusObjectPath &session, QObject *parent = nullptr);
0031 
0032     void start() override;
0033     bool doKill() override;
0034 
0035 private Q_SLOTS:
0036     void doStart();
0037     void nextJob();
0038     void sendFileFinished(BluezQt::PendingCall *call);
0039     void jobDone();
0040     void transferredChanged(quint64 transferred);
0041     void statusChanged(BluezQt::ObexTransfer::Status status);
0042 
0043 private:
0044     void progress(quint64 transferBytes);
0045 
0046     QTime m_time;
0047     QStringList m_files;
0048     QList<quint64> m_filesSizes;
0049     QString m_currentFile;
0050     quint64 m_progress;
0051     quint64 m_totalSize;
0052     qulonglong m_speedBytes;
0053     quint64 m_currentFileSize;
0054     quint64 m_currentFileProgress;
0055 
0056     BluezQt::DevicePtr m_device;
0057     BluezQt::ObexTransferPtr m_transfer;
0058     BluezQt::ObexObjectPush *m_objectPush;
0059 };