KWaylandServer

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

KDE's Doxygen guidelines are available online.