1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: security_context_v1
3// Source: security-context-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2021 Simon Ser
7//
8// Permission is hereby granted, free of charge, to any person obtaining a
9// copy of this software and associated documentation files (the "Software"),
10// to deal in the Software without restriction, including without limitation
11// the rights to use, copy, modify, merge, publish, distribute, sublicense,
12// and/or sell copies of the Software, and to permit persons to whom the
13// Software is furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice (including the next
16// paragraph) shall be included in all copies or substantial portions of the
17// Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25// DEALINGS IN THE SOFTWARE.
26
27package securitycontext
28
29import (
30 "github.com/bnema/wlturbo/wl"
31)
32
33// ERROR_INVALID_LISTEN_FD is the error invalid_listen_fd value.
34const ERROR_INVALID_LISTEN_FD = 1
35
36// ERROR_NESTED is the error nested value.
37const ERROR_NESTED = 2
38
39// ERROR_ALREADY_USED is the error already_used value.
40const ERROR_ALREADY_USED = 1
41
42// ERROR_ALREADY_SET is the error already_set value.
43const ERROR_ALREADY_SET = 2
44
45// ERROR_INVALID_METADATA is the error invalid_metadata value.
46const ERROR_INVALID_METADATA = 3
47
48// WpSecurityContextManagerInterface is the protocol interface name.
49const WpSecurityContextManagerInterface = "wp_security_context_manager_v1"
50
51// WpSecurityContextManager is the generated binding for wp_security_context_manager_v1 version 1.
52type WpSecurityContextManager struct {
53 wl.BaseProxy
54}
55
56// NewWpSecurityContextManager returns an unbound WpSecurityContextManager.
57func NewWpSecurityContextManager(ctx *wl.Context) *WpSecurityContextManager {
58 obj := &WpSecurityContextManager{}
59 obj.SetContext(ctx)
60 ctx.Register(obj)
61 return obj
62}
63
64// Destroy the manager. This doesn't destroy objects created with the manager.
65func (o *WpSecurityContextManager) Destroy() error {
66 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_security_context_manager_v1.destroy", Destructor: true}); err != nil {
67 return err
68 }
69 return nil
70}
71
72// Creates a new security context with a socket listening FD. The compositor will accept new client connections on listen_fd. listen_fd must be ready to accept new connections when this request is sent by the client. In other words, the client must call bind(2) and listen(2) before sending the FD. close_fd is a FD that will signal hangup when the compositor should stop accepting new connections on listen_fd. The compositor must continue to accept connections on listen_fd when the Wayland client which created the security context disconnects. After sending this request, closing listen_fd and close_fd remains the only valid operation on them.
73func (o *WpSecurityContextManager) CreateListener(listenFd int, closeFd int) (*WpSecurityContext, error) {
74 child := &WpSecurityContext{}
75 child.SetContext(o.Context())
76 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_security_context_manager_v1.create_listener", Child: child, FDs: []int{listenFd, closeFd}}, wl.ArgObject(child), wl.ArgFD(), wl.ArgFD()); err != nil {
77 return nil, err
78 }
79 return child, nil
80}
81
82// EventSignature returns the declared event argument types in wire order.
83func (o *WpSecurityContextManager) EventSignature(opcode uint16) (string, bool) {
84 switch opcode {
85 default:
86 return "", false
87 }
88}
89
90// Dispatch decodes one event on wp_security_context_manager_v1 and calls the registered handlers.
91func (o *WpSecurityContextManager) Dispatch(event *wl.Event) {
92 switch event.Opcode {
93 default:
94 }
95}
96
97// WpSecurityContextInterface is the protocol interface name.
98const WpSecurityContextInterface = "wp_security_context_v1"
99
100// WpSecurityContext is the generated binding for wp_security_context_v1 version 1.
101type WpSecurityContext struct {
102 wl.BaseProxy
103}
104
105// NewWpSecurityContext returns an unbound WpSecurityContext.
106func NewWpSecurityContext(ctx *wl.Context) *WpSecurityContext {
107 obj := &WpSecurityContext{}
108 obj.SetContext(ctx)
109 ctx.Register(obj)
110 return obj
111}
112
113// Destroy the security context object.
114func (o *WpSecurityContext) Destroy() error {
115 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_security_context_v1.destroy", Destructor: true}); err != nil {
116 return err
117 }
118 return nil
119}
120
121// Attach a unique sandbox engine name to the security context. The name should follow the reverse-DNS style (e.g. "org.flatpak"). A list of well-known engines is maintained at: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md It is a protocol error to call this request twice. The already_set error is sent in this case.
122func (o *WpSecurityContext) SetSandboxEngine(name string) error {
123 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_security_context_v1.set_sandbox_engine"}, wl.ArgString(name)); err != nil {
124 return err
125 }
126 return nil
127}
128
129// Attach an application ID to the security context. The application ID is an opaque, sandbox-specific identifier for an application. See the well-known engines document for more details: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md The compositor may use the application ID to group clients belonging to the same security context application. Whether this request is optional or not depends on the sandbox engine used. It is a protocol error to call this request twice. The already_set error is sent in this case.
130func (o *WpSecurityContext) SetAppId(appId string) error {
131 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wp_security_context_v1.set_app_id"}, wl.ArgString(appId)); err != nil {
132 return err
133 }
134 return nil
135}
136
137// Attach an instance ID to the security context. The instance ID is an opaque, sandbox-specific identifier for a running instance of an application. See the well-known engines document for more details: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md Whether this request is optional or not depends on the sandbox engine used. It is a protocol error to call this request twice. The already_set error is sent in this case.
138func (o *WpSecurityContext) SetInstanceId(instanceId string) error {
139 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "wp_security_context_v1.set_instance_id"}, wl.ArgString(instanceId)); err != nil {
140 return err
141 }
142 return nil
143}
144
145// Atomically register the new client and attach the security context metadata. If the provided metadata is inconsistent or does not match with out of band metadata (see https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/security-context/engines.md), the invalid_metadata error may be sent eventually. It's a protocol error to send any request other than "destroy" after this request. In this case, the already_used error is sent.
146func (o *WpSecurityContext) Commit() error {
147 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "wp_security_context_v1.commit"}); err != nil {
148 return err
149 }
150 return nil
151}
152
153// EventSignature returns the declared event argument types in wire order.
154func (o *WpSecurityContext) EventSignature(opcode uint16) (string, bool) {
155 switch opcode {
156 default:
157 return "", false
158 }
159}
160
161// Dispatch decodes one event on wp_security_context_v1 and calls the registered handlers.
162func (o *WpSecurityContext) Dispatch(event *wl.Event) {
163 switch event.Opcode {
164 default:
165 }
166}