Content Hub: /build/content-hub-git/src/content-hub/include/com/ubuntu/content/transfer.h Source File

Content Hub 0.2.0 A session-wide content-exchange service |

transfer.h
Go to the documentation of this file.
1 /*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18 #ifndef COM_UBUNTU_CONTENT_TRANSFER_H_
19 #define COM_UBUNTU_CONTENT_TRANSFER_H_
20
21 #include <com/ubuntu/content/item.h>
22 #include <com/ubuntu/content/store.h>
23
24 #include <QObject>
25 #include <QSharedPointer>
26 #include <QVector>
27 #include <QString>
28
29 namespace com
30 {
31 namespace ubuntu
32 {
33 namespace content
34 {
35 namespace detail
36 {
37 class Handler;
38 }
39 }
40 }
41 }
42
43 namespace com
44 {
45 namespace ubuntu
46 {
47 namespace content
48 {
49 class Item;
50
51 class Transfer : public QObject
52 {
53 Q_OBJECT
54 Q_ENUMS(State)
55 Q_ENUMS(SelectionType)
56 Q_ENUMS(Direction)
57 Q_PROPERTY(int id READ id)
58 Q_PROPERTY(State state READ state NOTIFY stateChanged)
59 Q_PROPERTY(QVector<Item> items READ collect WRITE charge)
60 Q_PROPERTY(Store store READ store NOTIFY storeChanged)
61 Q_PROPERTY(SelectionType selectionType READ selectionType WRITE setSelectionType NOTIFY selectionTypeChanged)
62 Q_PROPERTY(Direction direction READ direction)
63 Q_PROPERTY(QString downloadId READ downloadId WRITE setDownloadId NOTIFY downloadIdChanged)
64 Q_PROPERTY(QString contentType READ contentType)
65 Q_PROPERTY(QString source READ source)
66 Q_PROPERTY(QString destination READ destination)
67
68 public:
69 enum State
70 {
71 created,
72 initiated,
73 in_progress,
74 charged,
75 collected,
76 aborted,
77 finalized,
78 downloading,
79 downloaded
80 };
81
82 enum SelectionType
83 {
84 single,
85 multiple
86 };
87
88 enum Direction
89 {
90 Import,
91 Export,
92 Share
93 };
94
95 Transfer(const Transfer&) = delete;
96 virtual ~Transfer();
97
98 Transfer& operator=(const Transfer&) = delete;
99
100 Q_INVOKABLE virtual int id() const;
101 Q_INVOKABLE virtual State state() const;
102 Q_INVOKABLE virtual SelectionType selectionType() const;
103 Q_INVOKABLE virtual Direction direction() const;
104 Q_INVOKABLE virtual bool start();
105 Q_INVOKABLE virtual bool abort();
106 Q_INVOKABLE virtual bool finalize();
107 Q_INVOKABLE virtual bool charge(const QVector<Item>& items);
108 Q_INVOKABLE virtual QVector<Item> collect();
109 Q_INVOKABLE virtual Store store() const;
110 Q_INVOKABLE virtual bool setStore(const Store*);
111 Q_INVOKABLE virtual bool setSelectionType(const SelectionType&);
112 Q_INVOKABLE virtual QString downloadId() const;
113 Q_INVOKABLE virtual bool setDownloadId(const QString);
114 Q_INVOKABLE virtual bool download();
115 Q_INVOKABLE virtual QString contentType() const;
116 Q_INVOKABLE virtual QString source() const;
117 Q_INVOKABLE virtual QString destination() const;
118
119 Q_SIGNAL void stateChanged();
120 Q_SIGNAL void storeChanged();
121 Q_SIGNAL void selectionTypeChanged();
122 Q_SIGNAL void downloadIdChanged();
123
124 private:
125 struct Private;
126 friend struct Private;
127 friend class Hub;
128 friend class com::ubuntu::content::detail::Handler;
129 QSharedPointer<Private> d;
130
131 Transfer(const QSharedPointer<Private>&, QObject* parent = nullptr);
132 };
133 }
134 }
135 }
136
137 #endif // COM_UBUNTU_CONTENT_TRANSFER_H_
com::ubuntu::content::Transfer::created
@ created
Definition: transfer.h:71
com::ubuntu::content::Transfer
Definition: transfer.h:52
com::ubuntu::content::Transfer::SelectionType
SelectionType
Definition: transfer.h:83
com::ubuntu::content::Transfer::contentType
virtual Q_INVOKABLE QString contentType() const
com::ubuntu::content::Transfer::setStore
virtual Q_INVOKABLE bool setStore(const Store *)
QObject
com::ubuntu::content::Transfer::source
QString source
Definition: transfer.h:65
com::ubuntu::content::Transfer::contentType
QString contentType
Definition: transfer.h:64
com::ubuntu::content::Transfer::state
State state
Definition: transfer.h:58
com::ubuntu::content::Transfer::store
virtual Q_INVOKABLE Store store() const
com::ubuntu::content::Store
Definition: store.h:31
com::ubuntu::content::Transfer::single
@ single
Definition: transfer.h:84
com::ubuntu::content::Transfer::setSelectionType
virtual Q_INVOKABLE bool setSelectionType(const SelectionType &)
com::ubuntu::content::Transfer::selectionType
virtual Q_INVOKABLE SelectionType selectionType() const
com::ubuntu::content::Transfer::direction
Direction direction
Definition: transfer.h:62
com::ubuntu::content::Transfer::store
Store store
Definition: transfer.h:60
com::ubuntu::content::Transfer::multiple
@ multiple
Definition: transfer.h:85
com::ubuntu::content::Transfer::Handler
friend class com::ubuntu::content::detail::Handler
Definition: transfer.h:128
com::ubuntu::content::Transfer::~Transfer
virtual ~Transfer()
com::ubuntu::content::Transfer::direction
virtual Q_INVOKABLE Direction direction() const
com::ubuntu::content::Transfer::in_progress
@ in_progress
Definition: transfer.h:73
com::ubuntu::content::Transfer::Direction
Direction
Definition: transfer.h:89
com::ubuntu::content::Transfer::downloading
@ downloading
Definition: transfer.h:78
store.h
com::ubuntu::content::Transfer::source
virtual Q_INVOKABLE QString source() const
com::ubuntu::content::Transfer::collected
@ collected
Definition: transfer.h:75
com::ubuntu::content::Transfer::selectionType
SelectionType selectionType
Definition: transfer.h:61
com::ubuntu::content::Transfer::start
virtual Q_INVOKABLE bool start()
com::ubuntu::content::Hub
Definition: hub.h:42
com::ubuntu::content::Transfer::stateChanged
Q_SIGNAL void stateChanged()
com::ubuntu::content::Transfer::download
virtual Q_INVOKABLE bool download()
com::ubuntu::content::Transfer::items
QVector< Item > items
Definition: transfer.h:59
com::ubuntu::content::Transfer::storeChanged
Q_SIGNAL void storeChanged()
com::ubuntu::content::Transfer::charged
@ charged
Definition: transfer.h:74
com::ubuntu::content::Transfer::downloadIdChanged
Q_SIGNAL void downloadIdChanged()
com::ubuntu::content::Transfer::Export
@ Export
Definition: transfer.h:91
com::ubuntu::content::Transfer::Transfer
Transfer(const Transfer &)=delete
com::ubuntu::content::Transfer::downloadId
virtual Q_INVOKABLE QString downloadId() const
com::ubuntu::content::Transfer::downloaded
@ downloaded
Definition: transfer.h:79
com::ubuntu::content::Transfer::downloadId
QString downloadId
Definition: transfer.h:63
com::ubuntu::content::Transfer::operator=
Transfer & operator=(const Transfer &)=delete
com::ubuntu::content::Transfer::id
virtual Q_INVOKABLE int id() const
com::ubuntu::content::Transfer::initiated
@ initiated
Definition: transfer.h:72
com::ubuntu::content::Transfer::Share
@ Share
Definition: transfer.h:92
com::ubuntu::content::Transfer::aborted
@ aborted
Definition: transfer.h:76
com::ubuntu::content::Transfer::Private
friend struct Private
Definition: transfer.h:125
com::ubuntu::content::Transfer::charge
virtual Q_INVOKABLE bool charge(const QVector< Item > &items)
com::ubuntu::content::Transfer::Import
@ Import
Definition: transfer.h:90
com
Definition: hub.h:32
com::ubuntu::content::Transfer::abort
virtual Q_INVOKABLE bool abort()
com::ubuntu::content::Transfer::State
State
Definition: transfer.h:70
com::ubuntu::content::Transfer::finalize
virtual Q_INVOKABLE bool finalize()
com::ubuntu::content::Transfer::destination
virtual Q_INVOKABLE QString destination() const
com::ubuntu::content::Transfer::selectionTypeChanged
Q_SIGNAL void selectionTypeChanged()
com::ubuntu::content::Transfer::finalized
@ finalized
Definition: transfer.h:77
com::ubuntu::content::Transfer::setDownloadId
virtual Q_INVOKABLE bool setDownloadId(const QString)
com::ubuntu::content::Transfer::collect
virtual Q_INVOKABLE QVector< Item > collect()
com::ubuntu::content::Transfer::destination
QString destination
Definition: transfer.h:66
com::ubuntu::content::Transfer::state
virtual Q_INVOKABLE State state() const
item.h