Content Hub  1.1.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_LOMIRI_CONTENT_HUB_H_
19 #define COM_LOMIRI_CONTENT_HUB_H_
20 
24 
25 #include <QObject>
26 #include <QMimeData>
27 
28 class QStringList;
29 class QDBusPendingCall;
30 
31 namespace com
32 {
33 namespace lomiri
34 {
35 namespace content
36 {
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_DECL_DEPRECATED_X("Set store by scope and content type on transfer directly instead")
58  Q_INVOKABLE virtual const Store* store_for_scope_and_type(Scope scope, Type type);
59  Q_INVOKABLE virtual Peer default_source_for_type(Type type);
60  Q_INVOKABLE virtual QVector<Peer> known_sources_for_type(Type type);
61  Q_INVOKABLE virtual QVector<Peer> known_destinations_for_type(Type type);
62  Q_INVOKABLE virtual QVector<Peer> known_shares_for_type(Type type);
63  Q_INVOKABLE virtual Transfer* create_import_from_peer(Peer peer);
64  Q_INVOKABLE virtual Transfer* create_export_to_peer(Peer peer);
65  Q_INVOKABLE virtual Transfer* create_share_to_peer(Peer peer);
66 
67  Q_INVOKABLE virtual void quit();
68 
69  Q_INVOKABLE virtual Transfer* create_import_from_peer_for_type(Peer peer, Type type);
70  Q_INVOKABLE virtual Transfer* create_export_to_peer_for_type(Peer peer, Type type);
71  Q_INVOKABLE virtual Transfer* create_share_to_peer_for_type(Peer peer, Type type);
72  Q_INVOKABLE virtual bool has_pending(QString peer_id);
73  Q_INVOKABLE virtual Peer peer_for_app_id(QString app_id);
74 
76  // Copy & Paste
77 
78  QDBusPendingCall createPaste(const QString &surfaceId, const QMimeData& data);
79 
80  QDBusPendingCall requestLatestPaste(const QString &surfaceId);
81  QDBusPendingCall requestPasteById(const QString &surfaceId, int pasteId);
82  QMimeData* paste(QDBusPendingCall requestPeply);
83 
84  // synchronous versions
85  bool createPasteSync(const QString &surfaceId, const QMimeData& data);
86  QMimeData* latestPaste(const QString &surfaceId);
87  QMimeData* pasteById(const QString &surfaceId, int id);
88 
89  QStringList pasteFormats();
90 
91  Q_SIGNALS:
92  void pasteFormatsChanged();
93  void pasteboardChanged();
94 
95  private Q_SLOTS:
96  void onPasteFormatsChanged(const QStringList &);
97  protected:
98  Hub(QObject* = nullptr);
99 
100  private:
101  void requestPasteFormats();
102  struct Private;
103  QScopedPointer<Private> d;
104  bool eventFilter(QObject *obj, QEvent *event);
105 };
106 }
107 }
108 }
109 
110 #endif // COM_LOMIRI_CONTENT_HUB_H_
QObject
com::lomiri::content::Type
Definition: type.h:37
com::lomiri::content::Hub
Definition: hub.h:41
com::lomiri::content::Hub::operator=
Hub & operator=(const Hub &)=delete
com::lomiri::content::Hub::store_for_scope_and_type
virtual const Q_INVOKABLE Store * store_for_scope_and_type(Scope scope, Type type)
com::lomiri::content::Hub::latestPaste
QMimeData * latestPaste(const QString &surfaceId)
com::lomiri::content::Hub::~Hub
virtual ~Hub()
com::lomiri::content::Hub::pasteboardChanged
void pasteboardChanged()
com::lomiri::content::Hub::known_shares_for_type
virtual Q_INVOKABLE QVector< Peer > known_shares_for_type(Type type)
com::lomiri::content::Peer
Definition: peer.h:31
type.h
com::lomiri::content::Scope
Scope
Definition: scope.h:29
com::lomiri::content::Hub::default_source_for_type
virtual Q_INVOKABLE Peer default_source_for_type(Type type)
com::lomiri::content::Hub::requestLatestPaste
QDBusPendingCall requestLatestPaste(const QString &surfaceId)
com::lomiri::content::Store
Definition: store.h:33
com::lomiri::content::Hub::quit
virtual Q_INVOKABLE void quit()
com::lomiri::content::Hub::pasteFormatsChanged
void pasteFormatsChanged()
com::lomiri::content::Hub::known_destinations_for_type
virtual Q_INVOKABLE QVector< Peer > known_destinations_for_type(Type type)
com::lomiri::content::Hub::create_share_to_peer
virtual Q_INVOKABLE Transfer * create_share_to_peer(Peer peer)
com::lomiri::content::Hub::paste
QMimeData * paste(QDBusPendingCall requestPeply)
com::lomiri::content::Hub::pasteById
QMimeData * pasteById(const QString &surfaceId, int id)
com::lomiri::content::Hub::create_export_to_peer
virtual Q_INVOKABLE Transfer * create_export_to_peer(Peer peer)
com::lomiri::content::Hub::Hub
Hub(const Hub &)=delete
com::lomiri::content::Hub::create_import_from_peer
virtual Q_INVOKABLE Transfer * create_import_from_peer(Peer peer)
add_custom_target
add_custom_target(doc ALL) find_package(Doxygen) if(DOXYGEN_FOUND) configure_file($
Definition: CMakeLists.txt:17
scope.h
com::lomiri::content::Hub::Client
Definition: hub.h:47
com::lomiri::content::ImportExportHandler
Definition: import_export_handler.h:31
peer.h
com::lomiri::content::Hub::Client::instance
static Hub * instance()
com::lomiri::content::Hub::create_import_from_peer_for_type
virtual Q_INVOKABLE Transfer * create_import_from_peer_for_type(Peer peer, Type type)
com::lomiri::content::Hub::create_share_to_peer_for_type
virtual Q_INVOKABLE Transfer * create_share_to_peer_for_type(Peer peer, Type type)
com::lomiri::content::Hub::requestPasteById
QDBusPendingCall requestPasteById(const QString &surfaceId, int pasteId)
com
Definition: hub.h:31
com::lomiri::content::Hub::register_import_export_handler
virtual Q_INVOKABLE void register_import_export_handler(ImportExportHandler *handler)
com::lomiri::content::Transfer
Definition: transfer.h:53
com::lomiri::content::Hub::createPasteSync
bool createPasteSync(const QString &surfaceId, const QMimeData &data)
com::lomiri::content::Hub::createPaste
QDBusPendingCall createPaste(const QString &surfaceId, const QMimeData &data)
com::lomiri::content::Hub::known_sources_for_type
virtual Q_INVOKABLE QVector< Peer > known_sources_for_type(Type type)
com::lomiri::content::Hub::create_export_to_peer_for_type
virtual Q_INVOKABLE Transfer * create_export_to_peer_for_type(Peer peer, Type type)
com::lomiri::content::Hub::peer_for_app_id
virtual Q_INVOKABLE Peer peer_for_app_id(QString app_id)
com::lomiri::content::Hub::has_pending
virtual Q_INVOKABLE bool has_pending(QString peer_id)
com::lomiri::content::Hub::pasteFormats
QStringList pasteFormats
Definition: hub.h:44