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

KDE's Doxygen guidelines are available online.