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

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

hub.h
Go to the documentation of this file.
1 /*
2 * Copyright © 2013,2016 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_HUB_H_
19 #define COM_UBUNTU_CONTENT_HUB_H_
20
21 #include <com/ubuntu/content/peer.h>
22 #include <com/ubuntu/content/scope.h>
23 #include <com/ubuntu/content/type.h>
24
25 #include <QObject>
26 #include <QMimeData>
27
28 class QStringList;
29 class QDBusPendingCall;
30
31 namespace com
32 {
33 namespace ubuntu
34 {
35 namespace content
36 {
37 class ImportExportHandler;
38 class Store;
39 class Transfer;
40
41 class Hub : public QObject
42 {
43 Q_OBJECT
44 Q_PROPERTY(QStringList pasteFormats READ pasteFormats NOTIFY pasteFormatsChanged)
45
46 public:
47 struct Client
48 {
49 static Hub* instance();
50 };
51
52 Hub(const Hub&) = delete;
53 virtual ~Hub();
54 Hub& operator=(const Hub&) = delete;
55
56 Q_INVOKABLE virtual void register_import_export_handler(ImportExportHandler* handler);
57 Q_INVOKABLE virtual const Store* store_for_scope_and_type(Scope scope, Type type);
58 Q_INVOKABLE virtual Peer default_source_for_type(Type type);
59 Q_INVOKABLE virtual QVector<Peer> known_sources_for_type(Type type);
60 Q_INVOKABLE virtual QVector<Peer> known_destinations_for_type(Type type);
61 Q_INVOKABLE virtual QVector<Peer> known_shares_for_type(Type type);
62 Q_INVOKABLE virtual Transfer* create_import_from_peer(Peer peer);
63 Q_INVOKABLE virtual Transfer* create_export_to_peer(Peer peer);
64 Q_INVOKABLE virtual Transfer* create_share_to_peer(Peer peer);
65
66 Q_INVOKABLE virtual void quit();
67
68 Q_INVOKABLE virtual Transfer* create_import_from_peer_for_type(Peer peer, Type type);
69 Q_INVOKABLE virtual Transfer* create_export_to_peer_for_type(Peer peer, Type type);
70 Q_INVOKABLE virtual Transfer* create_share_to_peer_for_type(Peer peer, Type type);
71 Q_INVOKABLE virtual bool has_pending(QString peer_id);
72 Q_INVOKABLE virtual Peer peer_for_app_id(QString app_id);
73
75 // Copy & Paste
76
77 QDBusPendingCall createPaste(const QString &surfaceId, const QMimeData& data);
78
79 QDBusPendingCall requestLatestPaste(const QString &surfaceId);
80 QDBusPendingCall requestPasteById(const QString &surfaceId, int pasteId);
81 QMimeData* paste(QDBusPendingCall requestPeply);
82
83 // synchronous versions
84 bool createPasteSync(const QString &surfaceId, const QMimeData& data);
85 QMimeData* latestPaste(const QString &surfaceId);
86 QMimeData* pasteById(const QString &surfaceId, int id);
87
88 QStringList pasteFormats();
89
90 Q_SIGNALS:
91 void pasteFormatsChanged();
92 void pasteboardChanged();
93
94 private Q_SLOTS:
95 void onPasteFormatsChanged(const QStringList &);
96 protected:
97 Hub(QObject* = nullptr);
98
99 private:
100 void requestPasteFormats();
101 struct Private;
102 QScopedPointer<Private> d;
103 bool eventFilter(QObject *obj, QEvent *event);
104 };
105 }
106 }
107 }
108
109 #endif // COM_UBUNTU_CONTENT_HUB_H_
com::ubuntu::content::Hub::requestLatestPaste
QDBusPendingCall requestLatestPaste(const QString &surfaceId)
com::ubuntu::content::Transfer
Definition: transfer.h:52
QObject
com::ubuntu::content::Hub::Client::instance
static Hub * instance()
com::ubuntu::content::Hub::known_shares_for_type
virtual Q_INVOKABLE QVector< Peer > known_shares_for_type(Type type)
com::ubuntu::content::Store
Definition: store.h:31
com::ubuntu::content::Hub::known_destinations_for_type
virtual Q_INVOKABLE QVector< Peer > known_destinations_for_type(Type type)
com::ubuntu::content::ImportExportHandler
Definition: import_export_handler.h:32
com::ubuntu::content::Hub::create_export_to_peer_for_type
virtual Q_INVOKABLE Transfer * create_export_to_peer_for_type(Peer peer, Type type)
com::ubuntu::content::Hub::peer_for_app_id
virtual Q_INVOKABLE Peer peer_for_app_id(QString app_id)
com::ubuntu::content::Hub::create_import_from_peer
virtual Q_INVOKABLE Transfer * create_import_from_peer(Peer peer)
type.h
com::ubuntu::content::Hub::~Hub
virtual ~Hub()
com::ubuntu::content::Hub::known_sources_for_type
virtual Q_INVOKABLE QVector< Peer > known_sources_for_type(Type type)
com::ubuntu::content::Peer
Definition: peer.h:32
com::ubuntu::content::Hub::latestPaste
QMimeData * latestPaste(const QString &surfaceId)
com::ubuntu::content::Hub::register_import_export_handler
virtual Q_INVOKABLE void register_import_export_handler(ImportExportHandler *handler)
com::ubuntu::content::Hub::requestPasteById
QDBusPendingCall requestPasteById(const QString &surfaceId, int pasteId)
com::ubuntu::content::Scope
Scope
Definition: scope.h:30
com::ubuntu::content::Hub
Definition: hub.h:42
com::ubuntu::content::Hub::store_for_scope_and_type
virtual Q_INVOKABLE const Store * store_for_scope_and_type(Scope scope, Type type)
com::ubuntu::content::Hub::pasteboardChanged
void pasteboardChanged()
com::ubuntu::content::Hub::default_source_for_type
virtual Q_INVOKABLE Peer default_source_for_type(Type type)
com::ubuntu::content::Hub::pasteFormats
QStringList pasteFormats
Definition: hub.h:44
com::ubuntu::content::Hub::Hub
Hub(const Hub &)=delete
com::ubuntu::content::Hub::create_export_to_peer
virtual Q_INVOKABLE Transfer * create_export_to_peer(Peer peer)
com::ubuntu::content::Type
Definition: type.h:36
com::ubuntu::content::Hub::createPasteSync
bool createPasteSync(const QString &surfaceId, const QMimeData &data)
add_custom_target
add_custom_target(doc ALL) find_package(Doxygen) if(DOXYGEN_FOUND) configure_file($
Definition: CMakeLists.txt:17
com::ubuntu::content::Hub::create_share_to_peer_for_type
virtual Q_INVOKABLE Transfer * create_share_to_peer_for_type(Peer peer, Type type)
scope.h
com::ubuntu::content::Hub::paste
QMimeData * paste(QDBusPendingCall requestPeply)
peer.h
com::ubuntu::content::Hub::create_share_to_peer
virtual Q_INVOKABLE Transfer * create_share_to_peer(Peer peer)
if
if(QDOC_EXECUTABLE) configure_file($
Definition: CMakeLists.txt:3
com::ubuntu::content::Hub::pasteFormatsChanged
void pasteFormatsChanged()
com
Definition: hub.h:32
com::ubuntu::content::Hub::has_pending
virtual Q_INVOKABLE bool has_pending(QString peer_id)
com::ubuntu::content::Hub::create_import_from_peer_for_type
virtual Q_INVOKABLE Transfer * create_import_from_peer_for_type(Peer peer, Type type)
com::ubuntu::content::Hub::Hub
Hub(QObject *=nullptr)
com::ubuntu::content::Hub::Client
Definition: hub.h:48
com::ubuntu::content::Hub::quit
virtual Q_INVOKABLE void quit()
com::ubuntu::content::Hub::pasteFormats
QStringList pasteFormats()
com::ubuntu::content::Hub::pasteById
QMimeData * pasteById(const QString &surfaceId, int id)
com::ubuntu::content::Hub::operator=
Hub & operator=(const Hub &)=delete
com::ubuntu::content::Hub::createPaste
QDBusPendingCall createPaste(const QString &surfaceId, const QMimeData &data)