File indexing completed on 2024-10-13 10:44:54

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 #ifndef SENDFILESJOB_H
0011 #define SENDFILESJOB_H
0012 
0013 #include <QList>
0014 #include <QStringList>
0015 #include <QTime>
0016 
0017 #include <KJob>
0018 
0019 #include <BluezQt/ObexTransfer>
0020 
0021 namespace BluezQt
0022 {
0023 class ObexObjectPush;
0024 }
0025 
0026 class SendFilesJob : public KJob
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     explicit SendFilesJob(const QStringList &files, BluezQt::DevicePtr device, const QDBusObjectPath &session, QObject *parent = nullptr);
0032 
0033     void start() override;
0034     bool doKill() override;
0035 
0036 private Q_SLOTS:
0037     void doStart();
0038     void nextJob();
0039     void sendFileFinished(BluezQt::PendingCall *call);
0040     void jobDone();
0041     void transferredChanged(quint64 transferred);
0042     void statusChanged(BluezQt::ObexTransfer::Status status);
0043 
0044 private:
0045     void progress(quint64 transferBytes);
0046 
0047     QTime m_time;
0048     QStringList m_files;
0049     QList<quint64> m_filesSizes;
0050     QString m_currentFile;
0051     quint64 m_progress;
0052     quint64 m_totalSize;
0053     qulonglong m_speedBytes;
0054     quint64 m_currentFileSize;
0055     quint64 m_currentFileProgress;
0056 
0057     BluezQt::DevicePtr m_device;
0058     BluezQt::ObexTransferPtr m_transfer;
0059     BluezQt::ObexObjectPush *m_objectPush;
0060 };
0061 
0062 #endif // SENDFILESJOB_H