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 
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 {
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_
Hub & operator=(const Hub &)=delete
virtual Q_INVOKABLE Transfer * create_share_to_peer(Peer peer)
QDBusPendingCall createPaste(const QString &surfaceId, const QMimeData &data)
virtual Q_INVOKABLE QVector< Peer > known_sources_for_type(Type type)
QMimeData * pasteById(const QString &surfaceId, int id)
virtual Q_INVOKABLE Transfer * create_import_from_peer(Peer peer)
Hub(const Hub &)=delete
Definition: hub.h:31
virtual Q_INVOKABLE void quit()
virtual Q_INVOKABLE QVector< Peer > known_shares_for_type(Type type)
virtual Q_INVOKABLE Transfer * create_export_to_peer(Peer peer)
QDBusPendingCall requestPasteById(const QString &surfaceId, int pasteId)
virtual Q_INVOKABLE Transfer * create_export_to_peer_for_type(Peer peer, Type type)
virtual Q_INVOKABLE void register_import_export_handler(ImportExportHandler *handler)
virtual Q_INVOKABLE const Store * store_for_scope_and_type(Scope scope, Type type)
virtual Q_INVOKABLE Peer default_source_for_type(Type type)
virtual Q_INVOKABLE Transfer * create_import_from_peer_for_type(Peer peer, Type type)
QDBusPendingCall requestLatestPaste(const QString &surfaceId)
virtual Q_INVOKABLE bool has_pending(QString peer_id)
bool createPasteSync(const QString &surfaceId, const QMimeData &data)
QMimeData * latestPaste(const QString &surfaceId)
QMimeData * paste(QDBusPendingCall requestPeply)
QStringList pasteFormats()
virtual Q_INVOKABLE QVector< Peer > known_destinations_for_type(Type type)
virtual Q_INVOKABLE Transfer * create_share_to_peer_for_type(Peer peer, Type type)
virtual Q_INVOKABLE Peer peer_for_app_id(QString app_id)