Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwldatasource.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:critical reason:network-protocol
4
9#include <QtWaylandCompositor/private/qwaylandutils_p.h>
10
11#include <unistd.h>
12#include <QtWaylandCompositor/private/wayland-wayland-server-protocol.h>
13
14QT_BEGIN_NAMESPACE
15
16namespace QtWayland {
17
18DataSource::DataSource(struct wl_client *client, uint32_t id, uint32_t time)
19 : QtWaylandServer::wl_data_source(client, id, 1)
20 , m_time(time)
21{
22}
23
25{
26 if (m_manager)
27 m_manager->sourceDestroyed(this);
28 if (m_device)
29 m_device->sourceDestroyed(this);
30}
31
33{
34 return m_time;
35}
36
38{
39 return m_mimeTypes;
40}
41
42void DataSource::accept(const QString &mimeType)
43{
44 send_target(mimeType);
45}
46
47void DataSource::send(const QString &mimeType, int fd)
48{
49 send_send(mimeType, fd);
50 close(fd);
51}
52
54{
55 send_cancelled();
56}
57
59{
60 m_manager = mgr;
61}
62
64{
65 m_device = device;
66}
67
68DataSource *DataSource::fromResource(struct ::wl_resource *resource)
69{
70 return QtWayland::fromResource<DataSource *>(resource);
71}
72
73void DataSource::data_source_offer(Resource *, const QString &mime_type)
74{
75 m_mimeTypes.append(mime_type);
76}
77
78void DataSource::data_source_destroy(Resource *resource)
79{
80 wl_resource_destroy(resource->handle);
81}
82
83void DataSource::data_source_destroy_resource(QtWaylandServer::wl_data_source::Resource *resource)
84{
85 Q_UNUSED(resource);
86 delete this;
87}
88
89}
90
91QT_END_NAMESPACE
void sourceDestroyed(DataSource *source)
void sourceDestroyed(DataSource *source)
void send(const QString &mimeType, int fd)
uint32_t time() const
void setManager(DataDeviceManager *mgr)
void data_source_destroy_resource(Resource *resource) override
void data_source_offer(Resource *resource, const QString &mime_type) override
void setDevice(DataDevice *device)
void accept(const QString &mimeType)
void data_source_destroy(Resource *resource) override
QList< QString > mimeTypes() const