| 1 |
/* |
| 2 |
* BluezQt - Asynchronous BlueZ wrapper library |
| 3 |
* |
| 4 |
* SPDX-FileCopyrightText: 2014-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 |
#ifndef BLUEZQT_OBEXTRANSFER_H |
| 10 |
#define BLUEZQT_OBEXTRANSFER_H |
| 11 |
|
| 12 |
#include <QObject> |
| 13 |
|
| 14 |
#include "bluezqt_export.h" |
| 15 |
#include "types.h" |
| 16 |
|
| 17 |
#include <memory> |
| 18 |
|
| 19 |
class QDBusObjectPath; |
| 20 |
|
| 21 |
namespace BluezQt |
| 22 |
{ |
| 23 |
class PendingCall; |
| 24 |
|
| 25 |
/*! |
| 26 |
* \inmodule BluezQt |
| 27 |
* \class BluezQt::ObexTransfer |
| 28 |
* \inheaderfile BluezQt/ObexTransfer |
| 29 |
* \brief OBEX transfer. |
| 30 |
* |
| 31 |
* This class represents transfer of one file. |
| 32 |
*/ |
| 33 |
class BLUEZQT_EXPORT ObexTransfer : public QObject |
| 34 |
{ |
| 35 |
Q_OBJECT |
| 36 |
|
| 37 |
/*! \property BluezQt::ObexTransfer::status */ |
| 38 |
Q_PROPERTY(Status status READ status NOTIFY statusChanged) |
| 39 |
/*! \property BluezQt::ObexTransfer::name */ |
| 40 |
Q_PROPERTY(QString name READ name) |
| 41 |
/*! \property BluezQt::ObexTransfer::type */ |
| 42 |
Q_PROPERTY(QString type READ type) |
| 43 |
/*! \property BluezQt::ObexTransfer::time */ |
| 44 |
Q_PROPERTY(quint64 time READ time) |
| 45 |
/*! \property BluezQt::ObexTransfer::size */ |
| 46 |
Q_PROPERTY(quint64 size READ size) |
| 47 |
/*! \property BluezQt::ObexTransfer::transferred */ |
| 48 |
Q_PROPERTY(quint64 transferred READ transferred NOTIFY transferredChanged) |
| 49 |
/*! \property BluezQt::ObexTransfer::fileName */ |
| 50 |
Q_PROPERTY(QString fileName READ fileName NOTIFY fileNameChanged) |
| 51 |
/*! \property BluezQt::ObexTransfer::suspendable */ |
| 52 |
Q_PROPERTY(bool suspendable READ isSuspendable) |
| 53 |
|
| 54 |
public: |
| 55 |
/*! |
| 56 |
* \enum BluezQt::ObexTransfer::Status |
| 57 |
* \brief Transfer status. |
| 58 |
* \value Queued |
| 59 |
* Indicates that the transfer is queued. |
| 60 |
* \value Active |
| 61 |
* Indicates that the transfer is active. |
| 62 |
* \value Suspended |
| 63 |
* Indicates that the transfer is suspended. |
| 64 |
* \value Complete |
| 65 |
* Indicates that the transfer have completed successfully. |
| 66 |
* \value Error |
| 67 |
* Indicates that the transfer have failed with error. |
| 68 |
* \value Unknown |
| 69 |
* Indicates that the transfer status is unknown. |
| 70 |
*/ |
| 71 |
enum Status { |
| 72 |
Queued, |
| 73 |
Active, |
| 74 |
Suspended, |
| 75 |
Complete, |
| 76 |
Error, |
| 77 |
Unknown, |
| 78 |
}; |
| 79 |
Q_ENUM(Status) |
| 80 |
|
| 81 |
~ObexTransfer() override; |
| 82 |
|
| 83 |
/*! |
| 84 |
* Returns a shared pointer from this. |
| 85 |
*/ |
| 86 |
ObexTransferPtr toSharedPtr() const; |
| 87 |
|
| 88 |
/*! |
| 89 |
* Returns the D-Bus object path of the transfer. |
| 90 |
*/ |
| 91 |
QDBusObjectPath objectPath() const; |
| 92 |
|
| 93 |
/*! |
| 94 |
* Returns the status of the transfer. |
| 95 |
*/ |
| 96 |
Status status() const; |
| 97 |
|
| 98 |
/*! |
| 99 |
* Returns the name of the transferred object. |
| 100 |
*/ |
| 101 |
QString name() const; |
| 102 |
|
| 103 |
/*! |
| 104 |
* Returns the type of the transferred object. |
| 105 |
*/ |
| 106 |
QString type() const; |
| 107 |
|
| 108 |
/*! |
| 109 |
* Returns the time of the transferred object. |
| 110 |
*/ |
| 111 |
quint64 time() const; |
| 112 |
|
| 113 |
/*! |
| 114 |
* Returns the total size of the transferred object. |
| 115 |
*/ |
| 116 |
quint64 size() const; |
| 117 |
|
| 118 |
/*! |
| 119 |
* Returns the number of bytes transferred. |
| 120 |
*/ |
| 121 |
quint64 transferred() const; |
| 122 |
|
| 123 |
/*! |
| 124 |
* Returns the full name of the transferred file. |
| 125 |
*/ |
| 126 |
QString fileName() const; |
| 127 |
|
| 128 |
/*! |
| 129 |
* Returns whether the transfer is suspendable. |
| 130 |
*/ |
| 131 |
bool isSuspendable() const; |
| 132 |
|
| 133 |
/*! |
| 134 |
* Stops the current transfer. |
| 135 |
* |
| 136 |
* Possible errors: |
| 137 |
* |
| 138 |
* \list |
| 139 |
* \li PendingCall::NotAuthorized |
| 140 |
* \li PendingCall::InProgress |
| 141 |
* \li PendingCall::Failed |
| 142 |
* \endlist |
| 143 |
* |
| 144 |
* Returns void pending call. |
| 145 |
*/ |
| 146 |
PendingCall *cancel(); |
| 147 |
|
| 148 |
/*! |
| 149 |
* Suspends the current transfer. |
| 150 |
* |
| 151 |
* Only suspendable transfers can be suspended. |
| 152 |
* |
| 153 |
* Possible errors: |
| 154 |
* |
| 155 |
* \list |
| 156 |
* \li PendingCall::NotAuthorized |
| 157 |
* \li PendingCall::NotInProgress |
| 158 |
* \endlist |
| 159 |
* |
| 160 |
* \sa isSuspendable() |
| 161 |
* |
| 162 |
* Returns void pending call. |
| 163 |
*/ |
| 164 |
PendingCall *suspend(); |
| 165 |
|
| 166 |
/*! |
| 167 |
* Resumes the current transfer. |
| 168 |
* |
| 169 |
* Possible errors: |
| 170 |
* |
| 171 |
* \list |
| 172 |
* \li PendingCall::NotAuthorized |
| 173 |
* \li PendingCall::NotInProgress |
| 174 |
* \endlist |
| 175 |
* |
| 176 |
* Returns void pending call. |
| 177 |
*/ |
| 178 |
PendingCall *resume(); |
| 179 |
|
| 180 |
Q_SIGNALS: |
| 181 |
/*! |
| 182 |
* Indicates that the \a status of transfer has changed. |
| 183 |
*/ |
| 184 |
void statusChanged(Status status); |
| 185 |
|
| 186 |
/*! |
| 187 |
* Indicates that the number of \a transferred bytes has changed. |
| 188 |
*/ |
| 189 |
void transferredChanged(quint64 transferred); |
| 190 |
|
| 191 |
/*! |
| 192 |
* Indicates that the transferred \a fileName has changed. |
| 193 |
*/ |
| 194 |
void fileNameChanged(const QString &fileName); |
| 195 |
|
| 196 |
private: |
| 197 |
BLUEZQT_NO_EXPORT explicit ObexTransfer(const QString &path, const QVariantMap &properties); |
| 198 |
|
| 199 |
std::unique_ptr<class ObexTransferPrivate> const d; |
| 200 |
|
| 201 |
friend class ObexTransferPrivate; |
| 202 |
friend class ObexAgentAdaptor; |
| 203 |
friend class PendingCallPrivate; |
| 204 |
}; |
| 205 |
|
| 206 |
} // namespace BluezQt |
| 207 |
|
| 208 |
#endif // BLUEZQT_OBEXTRANSFER_H |