1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef WLDATASOURCE_H
5#define WLDATASOURCE_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWaylandCompositor/private/qwayland-server-wayland.h>
19#include <QtWaylandCompositor/private/qtwaylandcompositorglobal_p.h>
20#include <QObject>
21#include <QtCore/QList>
22
23QT_REQUIRE_CONFIG(wayland_datadevice);
24
25QT_BEGIN_NAMESPACE
26
27namespace QtWayland {
28
29class DataOffer;
30class DataDevice;
31class DataDeviceManager;
32
33class DataSource : public QObject, public QtWaylandServer::wl_data_source
34{
35public:
36 DataSource(struct wl_client *client, uint32_t id, uint32_t time);
37 ~DataSource() override;
38 uint32_t time() const;
39 QList<QString> mimeTypes() const;
40
41 void accept(const QString &mimeType);
42 void send(const QString &mimeType,int fd);
43 void cancel();
44
45 void setManager(DataDeviceManager *mgr);
46 void setDevice(DataDevice *device);
47
48 static DataSource *fromResource(struct ::wl_resource *resource);
49
50protected:
51 void data_source_offer(Resource *resource, const QString &mime_type) override;
52 void data_source_destroy(Resource *resource) override;
53 void data_source_destroy_resource(Resource *resource) override;
54
55private:
56 uint32_t m_time;
57 QList<QString> m_mimeTypes;
58
59 DataDevice *m_device = nullptr;
60 DataDeviceManager *m_manager = nullptr;
61};
62
63}
64
65QT_END_NAMESPACE
66
67#endif // WLDATASOURCE_H
68

source code of qtwayland/src/compositor/wayland_wrapper/qwldatasource_p.h