1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8 "github.com/bnema/puregotk/v4/glib"
9 "github.com/bnema/puregotk/v4/gobject"
10 "github.com/bnema/puregotk/v4/gobject/types"
11)
12
13const (
14 // The value returned by handlers of the signals generated by
15 // the `gdbus-codegen` tool to indicate that a method call has been
16 // handled by an implementation. It is equal to %TRUE, but using
17 // this macro is sometimes more readable.
18 //
19 // In code that needs to be backwards-compatible with older GLib,
20 // use %TRUE instead, often written like this:
21 //
22 // |[
23 // g_dbus_method_invocation_return_error (invocation, ...);
24 // return TRUE; // handled
25 // ]|
26 DBUS_METHOD_INVOCATION_HANDLED bool = true
27 // The value returned by handlers of the signals generated by
28 // the `gdbus-codegen` tool to indicate that a method call has not been
29 // handled by an implementation. It is equal to %FALSE, but using
30 // this macro is sometimes more readable.
31 //
32 // In code that needs to be backwards-compatible with older GLib,
33 // use %FALSE instead.
34 DBUS_METHOD_INVOCATION_UNHANDLED bool = false
35)
36
37// Instances of the `GDBusMethodInvocation` class are used when
38// handling D-Bus method calls. It provides a way to asynchronously
39// return results and errors.
40//
41// The normal way to obtain a `GDBusMethodInvocation` object is to receive
42// it as an argument to the `handle_method_call()` function in a
43// [type@Gio.DBusInterfaceVTable] that was passed to
44// [method@Gio.DBusConnection.register_object].
45type DBusMethodInvocation struct {
46 gobject.Object
47}
48
49var xDBusMethodInvocationGLibType func() types.GType
50
51func DBusMethodInvocationGLibType() types.GType {
52 return xDBusMethodInvocationGLibType()
53}
54
55func DBusMethodInvocationNewFromInternalPtr(ptr uintptr) *DBusMethodInvocation {
56 cls := &DBusMethodInvocation{}
57 cls.Ptr = ptr
58 return cls
59}
60
61var xDBusMethodInvocationGetConnection func(uintptr) uintptr
62
63// Gets the #GDBusConnection the method was invoked on.
64func (x *DBusMethodInvocation) GetConnection() *DBusConnection {
65 var cls *DBusConnection
66
67 cret := xDBusMethodInvocationGetConnection(x.GoPointer())
68
69 if cret == 0 {
70 return nil
71 }
72 gobject.IncreaseRef(cret)
73 cls = &DBusConnection{}
74 cls.Ptr = cret
75 return cls
76}
77
78var xDBusMethodInvocationGetInterfaceName func(uintptr) string
79
80// Gets the name of the D-Bus interface the method was invoked on.
81//
82// This can be `NULL` if it was not specified by the sender. See
83// [callback@Gio.DBusInterfaceMethodCallFunc] or the
84// [D-Bus Specification](https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-types-method)
85// for details on when this can happen and how it should be handled.
86//
87// If this method call is a property Get, Set or GetAll call that has
88// been redirected to the method call handler then
89// "org.freedesktop.DBus.Properties" will be returned. See
90// #GDBusInterfaceVTable for more information.
91func (x *DBusMethodInvocation) GetInterfaceName() string {
92
93 cret := xDBusMethodInvocationGetInterfaceName(x.GoPointer())
94 return cret
95}
96
97var xDBusMethodInvocationGetMessage func(uintptr) uintptr
98
99// Gets the #GDBusMessage for the method invocation. This is useful if
100// you need to use low-level protocol features, such as UNIX file
101// descriptor passing, that cannot be properly expressed in the
102// #GVariant API.
103//
104// See this [server][class@Gio.DBusConnection#an-example-d-bus-server]
105// and [client][class@Gio.DBusConnection#an-example-for-file-descriptor-passing]
106// for an example of how to use this low-level API to send and receive
107// UNIX file descriptors.
108func (x *DBusMethodInvocation) GetMessage() *DBusMessage {
109 var cls *DBusMessage
110
111 cret := xDBusMethodInvocationGetMessage(x.GoPointer())
112
113 if cret == 0 {
114 return nil
115 }
116 gobject.IncreaseRef(cret)
117 cls = &DBusMessage{}
118 cls.Ptr = cret
119 return cls
120}
121
122var xDBusMethodInvocationGetMethodInfo func(uintptr) *DBusMethodInfo
123
124// Gets information about the method call, if any.
125//
126// If this method invocation is a property Get, Set or GetAll call that
127// has been redirected to the method call handler then %NULL will be
128// returned. See g_dbus_method_invocation_get_property_info() and
129// #GDBusInterfaceVTable for more information.
130func (x *DBusMethodInvocation) GetMethodInfo() *DBusMethodInfo {
131
132 cret := xDBusMethodInvocationGetMethodInfo(x.GoPointer())
133 return cret
134}
135
136var xDBusMethodInvocationGetMethodName func(uintptr) string
137
138// Gets the name of the method that was invoked.
139func (x *DBusMethodInvocation) GetMethodName() string {
140
141 cret := xDBusMethodInvocationGetMethodName(x.GoPointer())
142 return cret
143}
144
145var xDBusMethodInvocationGetObjectPath func(uintptr) string
146
147// Gets the object path the method was invoked on.
148func (x *DBusMethodInvocation) GetObjectPath() string {
149
150 cret := xDBusMethodInvocationGetObjectPath(x.GoPointer())
151 return cret
152}
153
154var xDBusMethodInvocationGetParameters func(uintptr) *glib.Variant
155
156// Gets the parameters of the method invocation. If there are no input
157// parameters then this will return a GVariant with 0 children rather than NULL.
158func (x *DBusMethodInvocation) GetParameters() *glib.Variant {
159
160 cret := xDBusMethodInvocationGetParameters(x.GoPointer())
161 return cret
162}
163
164var xDBusMethodInvocationGetPropertyInfo func(uintptr) *DBusPropertyInfo
165
166// Gets information about the property that this method call is for, if
167// any.
168//
169// This will only be set in the case of an invocation in response to a
170// property Get or Set call that has been directed to the method call
171// handler for an object on account of its property_get() or
172// property_set() vtable pointers being unset.
173//
174// See #GDBusInterfaceVTable for more information.
175//
176// If the call was GetAll, %NULL will be returned.
177func (x *DBusMethodInvocation) GetPropertyInfo() *DBusPropertyInfo {
178
179 cret := xDBusMethodInvocationGetPropertyInfo(x.GoPointer())
180 return cret
181}
182
183var xDBusMethodInvocationGetSender func(uintptr) string
184
185// Gets the bus name that invoked the method.
186//
187// This can return %NULL if not specified by the caller, e.g. on peer-to-peer
188// connections.
189func (x *DBusMethodInvocation) GetSender() string {
190
191 cret := xDBusMethodInvocationGetSender(x.GoPointer())
192 return cret
193}
194
195var xDBusMethodInvocationGetUserData func(uintptr) uintptr
196
197// Gets the @user_data #gpointer passed to g_dbus_connection_register_object().
198func (x *DBusMethodInvocation) GetUserData() uintptr {
199
200 cret := xDBusMethodInvocationGetUserData(x.GoPointer())
201 return cret
202}
203
204var xDBusMethodInvocationReturnDbusError func(uintptr, string, string)
205
206// Finishes handling a D-Bus method call by returning an error.
207//
208// This method will take ownership of @invocation. See
209// #GDBusInterfaceVTable for more information about the ownership of
210// @invocation.
211func (x *DBusMethodInvocation) ReturnDbusError(ErrorNameVar string, ErrorMessageVar string) {
212
213 xDBusMethodInvocationReturnDbusError(x.GoPointer(), ErrorNameVar, ErrorMessageVar)
214
215}
216
217var xDBusMethodInvocationReturnError func(uintptr, glib.Quark, int, string, ...interface{})
218
219// Finishes handling a D-Bus method call by returning an error.
220//
221// See g_dbus_error_encode_gerror() for details about what error name
222// will be returned on the wire. In a nutshell, if the given error is
223// registered using g_dbus_error_register_error() the name given
224// during registration is used. Otherwise, a name of the form
225// `org.gtk.GDBus.UnmappedGError.Quark...` is used. This provides
226// transparent mapping of #GError between applications using GDBus.
227//
228// If you are writing an application intended to be portable,
229// always register errors with g_dbus_error_register_error()
230// or use g_dbus_method_invocation_return_dbus_error().
231//
232// This method will take ownership of @invocation. See
233// #GDBusInterfaceVTable for more information about the ownership of
234// @invocation.
235//
236// Since 2.48, if the method call requested for a reply not to be sent
237// then this call will free @invocation but otherwise do nothing (as per
238// the recommendations of the D-Bus specification).
239func (x *DBusMethodInvocation) ReturnError(DomainVar glib.Quark, CodeVar int, FormatVar string, varArgs ...interface{}) {
240
241 xDBusMethodInvocationReturnError(x.GoPointer(), DomainVar, CodeVar, FormatVar, varArgs...)
242
243}
244
245var xDBusMethodInvocationReturnErrorLiteral func(uintptr, glib.Quark, int, string)
246
247// Like g_dbus_method_invocation_return_error() but without printf()-style formatting.
248//
249// This method will take ownership of @invocation. See
250// #GDBusInterfaceVTable for more information about the ownership of
251// @invocation.
252func (x *DBusMethodInvocation) ReturnErrorLiteral(DomainVar glib.Quark, CodeVar int, MessageVar string) {
253
254 xDBusMethodInvocationReturnErrorLiteral(x.GoPointer(), DomainVar, CodeVar, MessageVar)
255
256}
257
258var xDBusMethodInvocationReturnErrorValist func(uintptr, glib.Quark, int, string, []interface{})
259
260// Like g_dbus_method_invocation_return_error() but intended for
261// language bindings.
262//
263// This method will take ownership of @invocation. See
264// #GDBusInterfaceVTable for more information about the ownership of
265// @invocation.
266func (x *DBusMethodInvocation) ReturnErrorValist(DomainVar glib.Quark, CodeVar int, FormatVar string, VarArgsVar []interface{}) {
267
268 xDBusMethodInvocationReturnErrorValist(x.GoPointer(), DomainVar, CodeVar, FormatVar, VarArgsVar)
269
270}
271
272var xDBusMethodInvocationReturnGerror func(uintptr, *glib.Error)
273
274// Like g_dbus_method_invocation_return_error() but takes a #GError
275// instead of the error domain, error code and message.
276//
277// This method will take ownership of @invocation. See
278// #GDBusInterfaceVTable for more information about the ownership of
279// @invocation.
280func (x *DBusMethodInvocation) ReturnGerror(ErrorVar *glib.Error) {
281
282 xDBusMethodInvocationReturnGerror(x.GoPointer(), ErrorVar)
283
284}
285
286var xDBusMethodInvocationReturnValue func(uintptr, *glib.Variant)
287
288// Finishes handling a D-Bus method call by returning @parameters.
289// If the @parameters GVariant is floating, it is consumed.
290//
291// It is an error if @parameters is not of the right format: it must be a tuple
292// containing the out-parameters of the D-Bus method. Even if the method has a
293// single out-parameter, it must be contained in a tuple. If the method has no
294// out-parameters, @parameters may be %NULL or an empty tuple.
295//
296// |[<!-- language="C" -->
297// GDBusMethodInvocation *invocation = some_invocation;
298// g_autofree gchar *result_string = NULL;
299// g_autoptr (GError) error = NULL;
300//
301// result_string = calculate_result (&error);
302//
303// if (error != NULL)
304//
305// g_dbus_method_invocation_return_gerror (invocation, error);
306//
307// else
308//
309// g_dbus_method_invocation_return_value (invocation,
310// g_variant_new ("(s)", result_string));
311//
312// // Do not free @invocation here; returning a value does that
313// ]|
314//
315// This method will take ownership of @invocation. See
316// #GDBusInterfaceVTable for more information about the ownership of
317// @invocation.
318//
319// Since 2.48, if the method call requested for a reply not to be sent
320// then this call will sink @parameters and free @invocation, but
321// otherwise do nothing (as per the recommendations of the D-Bus
322// specification).
323func (x *DBusMethodInvocation) ReturnValue(ParametersVar *glib.Variant) {
324
325 xDBusMethodInvocationReturnValue(x.GoPointer(), ParametersVar)
326
327}
328
329var xDBusMethodInvocationReturnValueWithUnixFdList func(uintptr, *glib.Variant, uintptr)
330
331// Like g_dbus_method_invocation_return_value() but also takes a #GUnixFDList.
332//
333// This method is only available on UNIX.
334//
335// This method will take ownership of @invocation. See
336// #GDBusInterfaceVTable for more information about the ownership of
337// @invocation.
338func (x *DBusMethodInvocation) ReturnValueWithUnixFdList(ParametersVar *glib.Variant, FdListVar *UnixFDList) {
339
340 xDBusMethodInvocationReturnValueWithUnixFdList(x.GoPointer(), ParametersVar, FdListVar.GoPointer())
341
342}
343
344var xDBusMethodInvocationTakeError func(uintptr, *glib.Error)
345
346// Like g_dbus_method_invocation_return_gerror() but takes ownership
347// of @error so the caller does not need to free it.
348//
349// This method will take ownership of @invocation. See
350// #GDBusInterfaceVTable for more information about the ownership of
351// @invocation.
352func (x *DBusMethodInvocation) TakeError(ErrorVar *glib.Error) {
353
354 xDBusMethodInvocationTakeError(x.GoPointer(), ErrorVar)
355
356}
357
358func (c *DBusMethodInvocation) GoPointer() uintptr {
359 if c == nil {
360 return 0
361 }
362 return c.Ptr
363}
364
365func (c *DBusMethodInvocation) SetGoPointer(ptr uintptr) {
366 c.Ptr = ptr
367}
368
369func init() {
370 core.SetPackageName("GIO", "gio-2.0")
371 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
372 var libs []uintptr
373 for _, libPath := range core.GetPaths("GIO") {
374 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
375 if err != nil {
376 panic(err)
377 }
378 libs = append(libs, lib)
379 }
380
381 core.PuregoSafeRegister(&xDBusMethodInvocationGLibType, libs, "g_dbus_method_invocation_get_type")
382
383 core.PuregoSafeRegister(&xDBusMethodInvocationGetConnection, libs, "g_dbus_method_invocation_get_connection")
384 core.PuregoSafeRegister(&xDBusMethodInvocationGetInterfaceName, libs, "g_dbus_method_invocation_get_interface_name")
385 core.PuregoSafeRegister(&xDBusMethodInvocationGetMessage, libs, "g_dbus_method_invocation_get_message")
386 core.PuregoSafeRegister(&xDBusMethodInvocationGetMethodInfo, libs, "g_dbus_method_invocation_get_method_info")
387 core.PuregoSafeRegister(&xDBusMethodInvocationGetMethodName, libs, "g_dbus_method_invocation_get_method_name")
388 core.PuregoSafeRegister(&xDBusMethodInvocationGetObjectPath, libs, "g_dbus_method_invocation_get_object_path")
389 core.PuregoSafeRegister(&xDBusMethodInvocationGetParameters, libs, "g_dbus_method_invocation_get_parameters")
390 core.PuregoSafeRegister(&xDBusMethodInvocationGetPropertyInfo, libs, "g_dbus_method_invocation_get_property_info")
391 core.PuregoSafeRegister(&xDBusMethodInvocationGetSender, libs, "g_dbus_method_invocation_get_sender")
392 core.PuregoSafeRegister(&xDBusMethodInvocationGetUserData, libs, "g_dbus_method_invocation_get_user_data")
393 core.PuregoSafeRegister(&xDBusMethodInvocationReturnDbusError, libs, "g_dbus_method_invocation_return_dbus_error")
394 core.PuregoSafeRegister(&xDBusMethodInvocationReturnError, libs, "g_dbus_method_invocation_return_error")
395 core.PuregoSafeRegister(&xDBusMethodInvocationReturnErrorLiteral, libs, "g_dbus_method_invocation_return_error_literal")
396 core.PuregoSafeRegister(&xDBusMethodInvocationReturnErrorValist, libs, "g_dbus_method_invocation_return_error_valist")
397 core.PuregoSafeRegister(&xDBusMethodInvocationReturnGerror, libs, "g_dbus_method_invocation_return_gerror")
398 core.PuregoSafeRegister(&xDBusMethodInvocationReturnValue, libs, "g_dbus_method_invocation_return_value")
399 core.PuregoSafeRegister(&xDBusMethodInvocationReturnValueWithUnixFdList, libs, "g_dbus_method_invocation_return_value_with_unix_fd_list")
400 core.PuregoSafeRegister(&xDBusMethodInvocationTakeError, libs, "g_dbus_method_invocation_take_error")
401
402}