v0.2.1 c0399be

gdebugcontrollerdbus.go RawHistoryFolder

1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5	"structs"
6	"unsafe"
7
8	"github.com/ebitengine/purego"
9
10	"github.com/bnema/puregotk/pkg/core"
11	"github.com/bnema/puregotk/v4/glib"
12	"github.com/bnema/puregotk/v4/gobject"
13	"github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// The virtual function table for #GDebugControllerDBus.
17type DebugControllerDBusClass struct {
18	_ structs.HostLayout
19
20	ParentClass gobject.ObjectClass
21
22	xAuthorize uintptr
23
24	Padding [12]uintptr
25}
26
27func (x *DebugControllerDBusClass) GoPointer() uintptr {
28	return uintptr(unsafe.Pointer(x))
29}
30
31// OverrideAuthorize sets the "authorize" callback function.
32// Default handler for the #GDebugControllerDBus::authorize signal.
33func (x *DebugControllerDBusClass) OverrideAuthorize(cb func(*DebugControllerDBus, *DBusMethodInvocation) bool) {
34	if cb == nil {
35		x.xAuthorize = 0
36	} else {
37		x.xAuthorize = purego.NewCallback(func(ControllerVarp uintptr, InvocationVarp uintptr) bool {
38			return cb(DebugControllerDBusNewFromInternalPtr(ControllerVarp), DBusMethodInvocationNewFromInternalPtr(InvocationVarp))
39		})
40	}
41}
42
43// GetAuthorize gets the "authorize" callback function.
44// Default handler for the #GDebugControllerDBus::authorize signal.
45func (x *DebugControllerDBusClass) GetAuthorize() func(*DebugControllerDBus, *DBusMethodInvocation) bool {
46	if x.xAuthorize == 0 {
47		return nil
48	}
49	var rawCallback func(ControllerVarp uintptr, InvocationVarp uintptr) bool
50	purego.RegisterFunc(&rawCallback, x.xAuthorize)
51	return func(ControllerVar *DebugControllerDBus, InvocationVar *DBusMethodInvocation) bool {
52		return rawCallback(ControllerVar.GoPointer(), InvocationVar.GoPointer())
53	}
54}
55
56// `GDebugControllerDBus` is an implementation of [iface@Gio.DebugController]
57// which exposes debug settings as a D-Bus object.
58//
59// It is a [iface@Gio.Initable] object, and will register an object at
60// `/org/gtk/Debugging` on the bus given as
61// [property@Gio.DebugControllerDBus:connection] once it’s initialized. The
62// object will be unregistered when the last reference to the
63// `GDebugControllerDBus` is dropped.
64//
65// This D-Bus object can be used by remote processes to enable or disable debug
66// output in this process. Remote processes calling
67// `org.gtk.Debugging.SetDebugEnabled()` will affect the value of
68// [property@Gio.DebugController:debug-enabled] and, by default,
69// [func@GLib.log_get_debug_enabled].
70//
71// By default, no processes are allowed to call `SetDebugEnabled()` unless a
72// [signal@Gio.DebugControllerDBus::authorize] signal handler is installed. This
73// is because the process may be privileged, or might expose sensitive
74// information in its debug output. You may want to restrict the ability to
75// enable debug output to privileged users or processes.
76//
77// One option is to install a D-Bus security policy which restricts access to
78// `SetDebugEnabled()`, installing something like the following in
79// `$datadir/dbus-1/system.d/`:
80//
81// ```xml
82// <?xml version="1.0"?> <!--*-nxml-*-->
83// <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
84//
85//	"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
86//
87// <busconfig>
88//
89//	<policy user="root">
90//	  <allow send_destination="com.example.MyService" send_interface="org.gtk.Debugging"/>
91//	</policy>
92//	<policy context="default">
93//	  <deny send_destination="com.example.MyService" send_interface="org.gtk.Debugging"/>
94//	</policy>
95//
96// </busconfig>
97// ```
98//
99// This will prevent the `SetDebugEnabled()` method from being called by all
100// except root. It will not prevent the `DebugEnabled` property from being read,
101// as it’s accessed through the `org.freedesktop.DBus.Properties` interface.
102//
103// Another option is to use polkit to allow or deny requests on a case-by-case
104// basis, allowing for the possibility of dynamic authorisation. To do this,
105// connect to the [signal@Gio.DebugControllerDBus::authorize] signal and query
106// polkit in it:
107//
108// ```c
109//
110//	g_autoptr(GError) child_error = NULL;
111//	g_autoptr(GDBusConnection) connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
112//	gulong debug_controller_authorize_id = 0;
113//
114//	// Set up the debug controller.
115//	debug_controller = G_DEBUG_CONTROLLER (g_debug_controller_dbus_new (priv->connection, NULL, &child_error));
116//	if (debug_controller == NULL)
117//	  {
118//	    g_error ("Could not register debug controller on bus: %s",
119//	             child_error->message);
120//	  }
121//
122//	debug_controller_authorize_id = g_signal_connect (debug_controller,
123//	                                                  "authorize",
124//	                                                  G_CALLBACK (debug_controller_authorize_cb),
125//	                                                  self);
126//
127//	static gboolean
128//	debug_controller_authorize_cb (GDebugControllerDBus  *debug_controller,
129//	                               GDBusMethodInvocation *invocation,
130//	                               gpointer               user_data)
131//	{
132//	  g_autoptr(PolkitAuthority) authority = NULL;
133//	  g_autoptr(PolkitSubject) subject = NULL;
134//	  g_autoptr(PolkitAuthorizationResult) auth_result = NULL;
135//	  g_autoptr(GError) local_error = NULL;
136//	  GDBusMessage *message;
137//	  GDBusMessageFlags message_flags;
138//	  PolkitCheckAuthorizationFlags flags = POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE;
139//
140//	  message = g_dbus_method_invocation_get_message (invocation);
141//	  message_flags = g_dbus_message_get_flags (message);
142//
143//	  authority = polkit_authority_get_sync (NULL, &local_error);
144//	  if (authority == NULL)
145//	    {
146//	      g_warning ("Failed to get polkit authority: %s", local_error->message);
147//	      return FALSE;
148//	    }
149//
150//	  if (message_flags & G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION)
151//	    flags |= POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION;
152//
153//	  subject = polkit_system_bus_name_new (g_dbus_method_invocation_get_sender (invocation));
154//
155//	  auth_result = polkit_authority_check_authorization_sync (authority,
156//	                                                           subject,
157//	                                                           "com.example.MyService.set-debug-enabled",
158//	                                                           NULL,
159//	                                                           flags,
160//	                                                           NULL,
161//	                                                           &local_error);
162//	  if (auth_result == NULL)
163//	    {
164//	      g_warning ("Failed to get check polkit authorization: %s", local_error->message);
165//	      return FALSE;
166//	    }
167//
168//	  return polkit_authorization_result_get_is_authorized (auth_result);
169//	}
170//
171// ```
172type DebugControllerDBus struct {
173	gobject.Object
174}
175
176var xDebugControllerDBusGLibType func() types.GType
177
178func DebugControllerDBusGLibType() types.GType {
179	return xDebugControllerDBusGLibType()
180}
181
182func DebugControllerDBusNewFromInternalPtr(ptr uintptr) *DebugControllerDBus {
183	cls := &DebugControllerDBus{}
184	cls.Ptr = ptr
185	return cls
186}
187
188var xNewDebugControllerDBus func(uintptr, uintptr, **glib.Error) uintptr
189
190// Create a new #GDebugControllerDBus and synchronously initialize it.
191//
192// Initializing the object will export the debug object on @connection. The
193// object will remain registered until the last reference to the
194// #GDebugControllerDBus is dropped.
195//
196// Initialization may fail if registering the object on @connection fails.
197func NewDebugControllerDBus(ConnectionVar *DBusConnection, CancellableVar *Cancellable) (*DebugControllerDBus, error) {
198	var cls *DebugControllerDBus
199	var cerr *glib.Error
200
201	cret := xNewDebugControllerDBus(ConnectionVar.GoPointer(), CancellableVar.GoPointer(), &cerr)
202
203	if cret == 0 {
204		return nil, cerr
205	}
206	cls = &DebugControllerDBus{}
207	cls.Ptr = cret
208	if cerr == nil {
209		return cls, nil
210	}
211	return cls, cerr
212
213}
214
215var xDebugControllerDBusStop func(uintptr)
216
217// Stop the debug controller, unregistering its object from the bus.
218//
219// Any pending method calls to the object will complete successfully, but new
220// ones will return an error. This method will block until all pending
221// #GDebugControllerDBus::authorize signals have been handled. This is expected
222// to not take long, as it will just be waiting for threads to join. If any
223// #GDebugControllerDBus::authorize signal handlers are still executing in other
224// threads, this will block until after they have returned.
225//
226// This method will be called automatically when the final reference to the
227// #GDebugControllerDBus is dropped. You may want to call it explicitly to know
228// when the controller has been fully removed from the bus, or to break
229// reference count cycles.
230//
231// Calling this method from within a #GDebugControllerDBus::authorize signal
232// handler will cause a deadlock and must not be done.
233func (x *DebugControllerDBus) Stop() {
234
235	xDebugControllerDBusStop(x.GoPointer())
236
237}
238
239func (c *DebugControllerDBus) GoPointer() uintptr {
240	if c == nil {
241		return 0
242	}
243	return c.Ptr
244}
245
246func (c *DebugControllerDBus) SetGoPointer(ptr uintptr) {
247	c.Ptr = ptr
248}
249
250// Emitted when a D-Bus peer is trying to change the debug settings and used
251// to determine if that is authorized.
252//
253// This signal is emitted in a dedicated worker thread, so handlers are
254// allowed to perform blocking I/O. This means that, for example, it is
255// appropriate to call `polkit_authority_check_authorization_sync()` to check
256// authorization using polkit.
257//
258// If %FALSE is returned then no further handlers are run and the request to
259// change the debug settings is rejected.
260//
261// Otherwise, if %TRUE is returned, signal emission continues. If no handlers
262// return %FALSE, then the debug settings are allowed to be changed.
263//
264// Signal handlers must not modify @invocation, or cause it to return a value.
265//
266// The default class handler just returns %TRUE.
267func (x *DebugControllerDBus) ConnectAuthorize(cb *func(DebugControllerDBus, uintptr) bool) uint {
268	cbPtr := uintptr(unsafe.Pointer(cb))
269	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
270		handlerID := gobject.SignalConnect(x.GoPointer(), "authorize", cbRefPtr)
271		glib.SaveHandlerMapping(handlerID, cbPtr)
272		return handlerID
273	}
274
275	fcb := func(clsPtr uintptr, InvocationVarp uintptr) bool {
276		fa := DebugControllerDBus{}
277		fa.Ptr = clsPtr
278		cbFn := *cb
279
280		return cbFn(fa, InvocationVarp)
281
282	}
283	cbRefPtr := purego.NewCallback(fcb)
284	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
285	handlerID := gobject.SignalConnect(x.GoPointer(), "authorize", cbRefPtr)
286	glib.SaveHandlerMapping(handlerID, cbPtr)
287	return handlerID
288}
289
290// Get the value of #GDebugController:debug-enabled.
291func (x *DebugControllerDBus) GetDebugEnabled() bool {
292
293	cret := XGDebugControllerGetDebugEnabled(x.GoPointer())
294	return cret
295}
296
297// Set the value of #GDebugController:debug-enabled.
298func (x *DebugControllerDBus) SetDebugEnabled(DebugEnabledVar bool) {
299
300	XGDebugControllerSetDebugEnabled(x.GoPointer(), DebugEnabledVar)
301
302}
303
304// Initializes the object implementing the interface.
305//
306// This method is intended for language bindings. If writing in C,
307// g_initable_new() should typically be used instead.
308//
309// The object must be initialized before any real use after initial
310// construction, either with this function or g_async_initable_init_async().
311//
312// Implementations may also support cancellation. If @cancellable is not %NULL,
313// then initialization can be cancelled by triggering the cancellable object
314// from another thread. If the operation was cancelled, the error
315// %G_IO_ERROR_CANCELLED will be returned. If @cancellable is not %NULL and
316// the object doesn't support cancellable initialization the error
317// %G_IO_ERROR_NOT_SUPPORTED will be returned.
318//
319// If the object is not initialized, or initialization returns with an
320// error, then all operations on the object except g_object_ref() and
321// g_object_unref() are considered to be invalid, and have undefined
322// behaviour. See the [description][iface@Gio.Initable#description] for more details.
323//
324// Callers should not assume that a class which implements #GInitable can be
325// initialized multiple times, unless the class explicitly documents itself as
326// supporting this. Generally, a class’ implementation of init() can assume
327// (and assert) that it will only be called once. Previously, this documentation
328// recommended all #GInitable implementations should be idempotent; that
329// recommendation was relaxed in GLib 2.54.
330//
331// If a class explicitly supports being initialized multiple times, it is
332// recommended that the method is idempotent: multiple calls with the same
333// arguments should return the same results. Only the first call initializes
334// the object; further calls return the result of the first call.
335//
336// One reason why a class might need to support idempotent initialization is if
337// it is designed to be used via the singleton pattern, with a
338// #GObjectClass.constructor that sometimes returns an existing instance.
339// In this pattern, a caller would expect to be able to call g_initable_init()
340// on the result of g_object_new(), regardless of whether it is in fact a new
341// instance.
342func (x *DebugControllerDBus) Init(CancellableVar *Cancellable) (bool, error) {
343	var cerr *glib.Error
344
345	cret := XGInitableInit(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
346	if cerr == nil {
347		return cret, nil
348	}
349	return cret, cerr
350
351}
352
353func init() {
354	core.SetPackageName("GIO", "gio-2.0")
355	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
356	var libs []uintptr
357	for _, libPath := range core.GetPaths("GIO") {
358		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
359		if err != nil {
360			panic(err)
361		}
362		libs = append(libs, lib)
363	}
364
365	core.PuregoSafeRegister(&xDebugControllerDBusGLibType, libs, "g_debug_controller_dbus_get_type")
366
367	core.PuregoSafeRegister(&xNewDebugControllerDBus, libs, "g_debug_controller_dbus_new")
368
369	core.PuregoSafeRegister(&xDebugControllerDBusStop, libs, "g_debug_controller_dbus_stop")
370
371}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close