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