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)
13
14// Struct used in [func@Gio.DBusError.register_error_domain].
15type DBusErrorEntry struct {
16 _ structs.HostLayout
17
18 ErrorCode int32
19
20 DbusErrorName uintptr
21}
22
23func (x *DBusErrorEntry) GoPointer() uintptr {
24 return uintptr(unsafe.Pointer(x))
25}
26
27var xDbusErrorEncodeGerror func(*glib.Error) string
28
29// Creates a D-Bus error name to use for @error.
30//
31// If @error matches a registered error (see
32// [func@Gio.DBusError.register_error]), the corresponding D-Bus error name
33// will be returned.
34//
35// Otherwise the a name of the form
36// `org.gtk.GDBus.UnmappedGError.Quark._ESCAPED_QUARK_NAME.Code_ERROR_CODE`
37// will be used. This allows other GDBus applications to map the error
38// on the wire back to a [type@GLib.Error] using
39// [func@Gio.DBusError.new_for_dbus_error].
40//
41// This function is typically only used in object mappings to put a
42// [type@GLib.Error] on the wire. Regular applications should not use it.
43func DbusErrorEncodeGerror(ErrorVar *glib.Error) string {
44
45 cret := xDbusErrorEncodeGerror(ErrorVar)
46 return cret
47}
48
49var xDbusErrorGetRemoteError func(*glib.Error) string
50
51// Gets the D-Bus error name used for @error, if any.
52//
53// This function is guaranteed to return a D-Bus error name for all
54// [type@GLib.Error]s returned from functions handling remote method calls
55// (for example, [method@Gio.DBusConnection.call_finish]) unless
56// [func@Gio.DBusError.strip_remote_error] has already been used on @error.
57func DbusErrorGetRemoteError(ErrorVar *glib.Error) string {
58
59 cret := xDbusErrorGetRemoteError(ErrorVar)
60 return cret
61}
62
63var xDbusErrorIsRemoteError func(*glib.Error) bool
64
65// Checks if @error represents an error received via D-Bus from a remote peer.
66//
67// If so, use [func@Gio.DBusError.get_remote_error] to get the name of the error.
68func DbusErrorIsRemoteError(ErrorVar *glib.Error) bool {
69
70 cret := xDbusErrorIsRemoteError(ErrorVar)
71 return cret
72}
73
74var xDbusErrorNewForDbusError func(string, string) *glib.Error
75
76// Creates a [type@GLib.Error] based on the contents of @dbus_error_name and
77// @dbus_error_message.
78//
79// Errors registered with [func@Gio.DBusError.register_error] will be looked
80// up using @dbus_error_name and if a match is found, the error domain
81// and code is used. Applications can use [func@Gio.DBusError.get_remote_error]
82// to recover @dbus_error_name.
83//
84// If a match against a registered error is not found and the D-Bus
85// error name is in a form as returned by [func@Gio.DBusError.encode_gerror]
86// the error domain and code encoded in the name is used to
87// create the [type@GLib.Error]. Also, @dbus_error_name is added to the error
88// message such that it can be recovered with
89// [func@Gio.DBusError.get_remote_error].
90//
91// Otherwise, a [type@GLib.Error] with the error code
92// [error@Gio.IOErrorEnum.DBUS_ERROR]
93// in the [error@Gio.IOErrorEnum] error domain is returned. Also, @dbus_error_name is
94// added to the error message such that it can be recovered with
95// [func@Gio.DBusError.get_remote_error].
96//
97// In all three cases, @dbus_error_name can always be recovered from the
98// returned [type@GLib.Error] using the [func@Gio.DBusError.get_remote_error]
99// function (unless [func@Gio.DBusError.strip_remote_error] hasn’t been used on
100// the returned error).
101//
102// This function is typically only used in object mappings to prepare
103// [type@GLib.Error] instances for applications. Regular applications should not
104// use it.
105func DbusErrorNewForDbusError(DbusErrorNameVar string, DbusErrorMessageVar string) *glib.Error {
106
107 cret := xDbusErrorNewForDbusError(DbusErrorNameVar, DbusErrorMessageVar)
108 return cret
109}
110
111var xDbusErrorRegisterError func(glib.Quark, int, string) bool
112
113// Creates an association mapping between @dbus_error_name and
114// [type@GLib.Error]s specified by @error_domain and @error_code.
115//
116// This is typically done in the function that returns the [type@GLib.Quark] for
117// an error domain.
118func DbusErrorRegisterError(ErrorDomainVar glib.Quark, ErrorCodeVar int, DbusErrorNameVar string) bool {
119
120 cret := xDbusErrorRegisterError(ErrorDomainVar, ErrorCodeVar, DbusErrorNameVar)
121 return cret
122}
123
124var xDbusErrorRegisterErrorDomain func(string, uint, []DBusErrorEntry, uint)
125
126// Helper function for associating a [type@GLib.Error] error domain with D-Bus
127// error names.
128//
129// While @quark_volatile has a `volatile` qualifier, this is a historical
130// artifact and the argument passed to it should not be `volatile`.
131func DbusErrorRegisterErrorDomain(ErrorDomainQuarkNameVar string, QuarkVolatileVar uint, EntriesVar []DBusErrorEntry, NumEntriesVar uint) {
132
133 xDbusErrorRegisterErrorDomain(ErrorDomainQuarkNameVar, QuarkVolatileVar, EntriesVar, NumEntriesVar)
134
135}
136
137var xDbusErrorStripRemoteError func(*glib.Error) bool
138
139// Looks for extra information in the error message used to recover
140// the D-Bus error name and strips it if found.
141//
142// If stripped, the
143// message field in @error will correspond exactly to what was
144// received on the wire.
145//
146// This is typically used when presenting errors to the end user.
147func DbusErrorStripRemoteError(ErrorVar *glib.Error) bool {
148
149 cret := xDbusErrorStripRemoteError(ErrorVar)
150 return cret
151}
152
153var xDbusErrorUnregisterError func(glib.Quark, int, string) bool
154
155// Destroys an association previously set up with
156// [func@Gio.DBusError.register_error].
157func DbusErrorUnregisterError(ErrorDomainVar glib.Quark, ErrorCodeVar int, DbusErrorNameVar string) bool {
158
159 cret := xDbusErrorUnregisterError(ErrorDomainVar, ErrorCodeVar, DbusErrorNameVar)
160 return cret
161}
162
163func init() {
164 core.SetPackageName("GIO", "gio-2.0")
165 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
166 var libs []uintptr
167 for _, libPath := range core.GetPaths("GIO") {
168 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
169 if err != nil {
170 panic(err)
171 }
172 libs = append(libs, lib)
173 }
174
175 core.PuregoSafeRegister(&xDbusErrorEncodeGerror, libs, "g_dbus_error_encode_gerror")
176 core.PuregoSafeRegister(&xDbusErrorGetRemoteError, libs, "g_dbus_error_get_remote_error")
177 core.PuregoSafeRegister(&xDbusErrorIsRemoteError, libs, "g_dbus_error_is_remote_error")
178 core.PuregoSafeRegister(&xDbusErrorNewForDbusError, libs, "g_dbus_error_new_for_dbus_error")
179 core.PuregoSafeRegister(&xDbusErrorRegisterError, libs, "g_dbus_error_register_error")
180 core.PuregoSafeRegister(&xDbusErrorRegisterErrorDomain, libs, "g_dbus_error_register_error_domain")
181 core.PuregoSafeRegister(&xDbusErrorStripRemoteError, libs, "g_dbus_error_strip_remote_error")
182 core.PuregoSafeRegister(&xDbusErrorUnregisterError, libs, "g_dbus_error_unregister_error")
183
184}