KWayland

clientconnection.h
1 /*
2  SPDX-FileCopyrightText: 2014 Martin Gräßlin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 #ifndef KWAYLAND_SERVER_CLIENTCONNECTION_H
7 #define KWAYLAND_SERVER_CLIENTCONNECTION_H
8 
9 #include <sys/types.h>
10 
11 #include <QObject>
12 
13 #include <KWayland/Server/kwaylandserver_export.h>
14 
15 struct wl_client;
16 struct wl_interface;
17 struct wl_resource;
18 
19 namespace KWayland
20 {
21 namespace Server
22 {
23 class Display;
24 
25 /**
26  * @brief Convenient Class which represents a wl_client.
27  *
28  * The ClientConnection gets automatically created for a wl_client when a wl_client is
29  * first used in the context of KWayland::Server. In particular the signal
30  * @link Display::clientConnected @endlink will be emitted.
31  *
32  * @see Display
33  **/
34 class KWAYLANDSERVER_EXPORT ClientConnection : public QObject
35 {
36  Q_OBJECT
37 public:
38  virtual ~ClientConnection();
39 
40  /**
41  * Flushes the connection to this client. Ensures that all events are pushed to the client.
42  **/
43  void flush();
44  /**
45  * Creates a new wl_resource for the provided @p interface.
46  *
47  * Thus a convenient wrapper around wl_resource_create
48  *
49  * @param interface
50  * @param version
51  * @param id
52  * @returns the created native wl_resource
53  **/
54  wl_resource *createResource(const wl_interface *interface, quint32 version, quint32 id);
55  /**
56  * Get the wl_resource associated with the given @p id.
57  * @since 5.3
58  **/
59  wl_resource *getResource(quint32 id);
60 
61  /**
62  * @returns the native wl_client this ClientConnection represents.
63  **/
64  wl_client *client();
65  /**
66  * @returns The Display this ClientConnection is connected to
67  **/
68  Display *display();
69 
70  /**
71  * The pid of the ClientConnection endpoint.
72  *
73  * Please note: if the ClientConnection got created with @link Display::createClient @endlink
74  * the pid will be identical to the process running the KWayland::Server::Display.
75  *
76  * @returns The pid of the connection.
77  **/
78  pid_t processId() const;
79  /**
80  * The uid of the ClientConnection endpoint.
81  *
82  * Please note: if the ClientConnection got created with @link Display::createClient @endlink
83  * the uid will be identical to the process running the KWayland::Server::Display.
84  *
85  * @returns The uid of the connection.
86  **/
87  uid_t userId() const;
88  /**
89  * The gid of the ClientConnection endpoint.
90  *
91  * Please note: if the ClientConnection got created with @link Display::createClient @endlink
92  * the gid will be identical to the process running the KWayland::Server::Display.
93  *
94  * @returns The gid of the connection.
95  **/
96  gid_t groupId() const;
97 
98  /**
99  * The absolute path to the executable.
100  *
101  * Please note: if the ClientConnection got created with @link Display::createClient @endlink
102  * the executablePath will be identical to the process running the KWayland::Server::Display.
103  *
104  * If the executable path cannot be resolved an empty QString is returned.
105  *
106  * @see processId
107  * @since 5.6
108  **/
109  QString executablePath() const;
110 
111  /**
112  * Cast operator the native wl_client this ClientConnection represents.
113  **/
114  operator wl_client *();
115  /**
116  * Cast operator the native wl_client this ClientConnection represents.
117  **/
118  operator wl_client *() const;
119 
120  /**
121  * Destroys this ClientConnection.
122  * This is a convenient wrapper around wl_client_destroy. The use case is in combination
123  * with ClientConnections created through @link Display::createClient @endlink. E.g. once
124  * the process for the ClientConnection exited, the ClientConnection needs to be destroyed, too.
125  * @since 5.5
126  **/
127  void destroy();
128 
129 Q_SIGNALS:
130  /**
131  * Signal emitted when the ClientConnection got disconnected from the server.
132  **/
133  void disconnected(KWayland::Server::ClientConnection *);
134 
135 private:
136  friend class Display;
137  explicit ClientConnection(wl_client *c, Display *parent);
138  class Private;
140 };
141 
142 }
143 }
144 
145 Q_DECLARE_METATYPE(KWayland::Server::ClientConnection *)
146 
147 #endif
Class holding the Wayland server display loop.
Definition: display.h:86
Convenient Class which represents a wl_client.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Sep 26 2021 22:51:12 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.