1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/glib"
11 "github.com/bnema/puregotk/v4/gobject"
12)
13
14// Invoked when the name being watched is known to have to have an owner.
15type BusNameAppearedCallback func(uintptr, string, string, uintptr)
16
17// Invoked when the name being watched is known not to have to have an owner.
18//
19// This is also invoked when the #GDBusConnection on which the watch was
20// established has been closed. In that case, @connection will be
21// %NULL.
22type BusNameVanishedCallback func(uintptr, string, uintptr)
23
24var xBusUnwatchName func(uint)
25
26// Stops watching a name.
27//
28// Note that there may still be D-Bus traffic to process (relating to watching
29// and unwatching the name) in the current thread-default #GMainContext after
30// this function has returned. You should continue to iterate the #GMainContext
31// until the #GDestroyNotify function passed to g_bus_watch_name() is called, in
32// order to avoid memory leaks through callbacks queued on the #GMainContext
33// after it’s stopped being iterated.
34func BusUnwatchName(WatcherIdVar uint) {
35
36 xBusUnwatchName(WatcherIdVar)
37
38}
39
40var xBusWatchName func(BusType, string, BusNameWatcherFlags, uintptr, uintptr, uintptr, uintptr) uint
41
42// Starts watching @name on the bus specified by @bus_type and calls
43// @name_appeared_handler and @name_vanished_handler when the name is
44// known to have an owner respectively known to lose its
45// owner. Callbacks will be invoked in the thread-default main context
46// (see [method@GLib.MainContext.push_thread_default])
47// of the thread you are calling this function from.
48//
49// You are guaranteed that one of the handlers will be invoked after
50// calling this function. When you are done watching the name, just
51// call g_bus_unwatch_name() with the watcher id this function
52// returns.
53//
54// If the name vanishes or appears (for example the application owning
55// the name could restart), the handlers are also invoked. If the
56// #GDBusConnection that is used for watching the name disconnects, then
57// @name_vanished_handler is invoked since it is no longer
58// possible to access the name.
59//
60// Another guarantee is that invocations of @name_appeared_handler
61// and @name_vanished_handler are guaranteed to alternate; that
62// is, if @name_appeared_handler is invoked then you are
63// guaranteed that the next time one of the handlers is invoked, it
64// will be @name_vanished_handler. The reverse is also true.
65//
66// This behavior makes it very simple to write applications that want
67// to take action when a certain [name exists](dbus-name-watching.html#d-bus-name-watching).
68// Basically, the application should create object proxies in
69// @name_appeared_handler and destroy them again (if any) in
70// @name_vanished_handler.
71func BusWatchName(BusTypeVar BusType, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedHandlerVar *BusNameAppearedCallback, NameVanishedHandlerVar *BusNameVanishedCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint {
72
73 var NameAppearedHandlerVarRef uintptr
74 if NameAppearedHandlerVar != nil {
75 NameAppearedHandlerVarPtr := uintptr(unsafe.Pointer(NameAppearedHandlerVar))
76 if cbRefPtr, ok := glib.GetCallback(NameAppearedHandlerVarPtr); ok {
77 NameAppearedHandlerVarRef = cbRefPtr
78 } else {
79 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr, arg3 uintptr) {
80 cbFn := *NameAppearedHandlerVar
81 cbFn(arg0, core.GoString(arg1), core.GoString(arg2), arg3)
82 }
83 NameAppearedHandlerVarRef = purego.NewCallback(fcb)
84 glib.SaveCallbackWithClosure(NameAppearedHandlerVarPtr, NameAppearedHandlerVarRef, NameAppearedHandlerVar)
85 }
86 }
87
88 var NameVanishedHandlerVarRef uintptr
89 if NameVanishedHandlerVar != nil {
90 NameVanishedHandlerVarPtr := uintptr(unsafe.Pointer(NameVanishedHandlerVar))
91 if cbRefPtr, ok := glib.GetCallback(NameVanishedHandlerVarPtr); ok {
92 NameVanishedHandlerVarRef = cbRefPtr
93 } else {
94 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
95 cbFn := *NameVanishedHandlerVar
96 cbFn(arg0, core.GoString(arg1), arg2)
97 }
98 NameVanishedHandlerVarRef = purego.NewCallback(fcb)
99 glib.SaveCallbackWithClosure(NameVanishedHandlerVarPtr, NameVanishedHandlerVarRef, NameVanishedHandlerVar)
100 }
101 }
102
103 var UserDataFreeFuncVarRef uintptr
104 if UserDataFreeFuncVar != nil {
105 UserDataFreeFuncVarPtr := uintptr(unsafe.Pointer(UserDataFreeFuncVar))
106 if cbRefPtr, ok := glib.GetCallback(UserDataFreeFuncVarPtr); ok {
107 UserDataFreeFuncVarRef = cbRefPtr
108 } else {
109 fcb := func(arg0 uintptr) {
110 cbFn := *UserDataFreeFuncVar
111 cbFn(arg0)
112 }
113 UserDataFreeFuncVarRef = purego.NewCallback(fcb)
114 glib.SaveCallbackWithClosure(UserDataFreeFuncVarPtr, UserDataFreeFuncVarRef, UserDataFreeFuncVar)
115 }
116 }
117
118 cret := xBusWatchName(BusTypeVar, NameVar, FlagsVar, NameAppearedHandlerVarRef, NameVanishedHandlerVarRef, UserDataVar, UserDataFreeFuncVarRef)
119 return cret
120}
121
122var xBusWatchNameOnConnection func(uintptr, string, BusNameWatcherFlags, uintptr, uintptr, uintptr, uintptr) uint
123
124// Like g_bus_watch_name() but takes a #GDBusConnection instead of a
125// #GBusType.
126func BusWatchNameOnConnection(ConnectionVar *DBusConnection, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedHandlerVar *BusNameAppearedCallback, NameVanishedHandlerVar *BusNameVanishedCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint {
127
128 var NameAppearedHandlerVarRef uintptr
129 if NameAppearedHandlerVar != nil {
130 NameAppearedHandlerVarPtr := uintptr(unsafe.Pointer(NameAppearedHandlerVar))
131 if cbRefPtr, ok := glib.GetCallback(NameAppearedHandlerVarPtr); ok {
132 NameAppearedHandlerVarRef = cbRefPtr
133 } else {
134 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr, arg3 uintptr) {
135 cbFn := *NameAppearedHandlerVar
136 cbFn(arg0, core.GoString(arg1), core.GoString(arg2), arg3)
137 }
138 NameAppearedHandlerVarRef = purego.NewCallback(fcb)
139 glib.SaveCallbackWithClosure(NameAppearedHandlerVarPtr, NameAppearedHandlerVarRef, NameAppearedHandlerVar)
140 }
141 }
142
143 var NameVanishedHandlerVarRef uintptr
144 if NameVanishedHandlerVar != nil {
145 NameVanishedHandlerVarPtr := uintptr(unsafe.Pointer(NameVanishedHandlerVar))
146 if cbRefPtr, ok := glib.GetCallback(NameVanishedHandlerVarPtr); ok {
147 NameVanishedHandlerVarRef = cbRefPtr
148 } else {
149 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
150 cbFn := *NameVanishedHandlerVar
151 cbFn(arg0, core.GoString(arg1), arg2)
152 }
153 NameVanishedHandlerVarRef = purego.NewCallback(fcb)
154 glib.SaveCallbackWithClosure(NameVanishedHandlerVarPtr, NameVanishedHandlerVarRef, NameVanishedHandlerVar)
155 }
156 }
157
158 var UserDataFreeFuncVarRef uintptr
159 if UserDataFreeFuncVar != nil {
160 UserDataFreeFuncVarPtr := uintptr(unsafe.Pointer(UserDataFreeFuncVar))
161 if cbRefPtr, ok := glib.GetCallback(UserDataFreeFuncVarPtr); ok {
162 UserDataFreeFuncVarRef = cbRefPtr
163 } else {
164 fcb := func(arg0 uintptr) {
165 cbFn := *UserDataFreeFuncVar
166 cbFn(arg0)
167 }
168 UserDataFreeFuncVarRef = purego.NewCallback(fcb)
169 glib.SaveCallbackWithClosure(UserDataFreeFuncVarPtr, UserDataFreeFuncVarRef, UserDataFreeFuncVar)
170 }
171 }
172
173 cret := xBusWatchNameOnConnection(ConnectionVar.GoPointer(), NameVar, FlagsVar, NameAppearedHandlerVarRef, NameVanishedHandlerVarRef, UserDataVar, UserDataFreeFuncVarRef)
174 return cret
175}
176
177var xBusWatchNameOnConnectionWithClosures func(uintptr, string, BusNameWatcherFlags, *gobject.Closure, *gobject.Closure) uint
178
179// Version of g_bus_watch_name_on_connection() using closures instead of callbacks for
180// easier binding in other languages.
181func BusWatchNameOnConnectionWithClosures(ConnectionVar *DBusConnection, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedClosureVar *gobject.Closure, NameVanishedClosureVar *gobject.Closure) uint {
182
183 cret := xBusWatchNameOnConnectionWithClosures(ConnectionVar.GoPointer(), NameVar, FlagsVar, NameAppearedClosureVar, NameVanishedClosureVar)
184 return cret
185}
186
187var xBusWatchNameWithClosures func(BusType, string, BusNameWatcherFlags, *gobject.Closure, *gobject.Closure) uint
188
189// Version of g_bus_watch_name() using closures instead of callbacks for
190// easier binding in other languages.
191func BusWatchNameWithClosures(BusTypeVar BusType, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedClosureVar *gobject.Closure, NameVanishedClosureVar *gobject.Closure) uint {
192
193 cret := xBusWatchNameWithClosures(BusTypeVar, NameVar, FlagsVar, NameAppearedClosureVar, NameVanishedClosureVar)
194 return cret
195}
196
197func init() {
198 core.SetPackageName("GIO", "gio-2.0")
199 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
200 var libs []uintptr
201 for _, libPath := range core.GetPaths("GIO") {
202 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
203 if err != nil {
204 panic(err)
205 }
206 libs = append(libs, lib)
207 }
208
209 core.PuregoSafeRegister(&xBusUnwatchName, libs, "g_bus_unwatch_name")
210 core.PuregoSafeRegister(&xBusWatchName, libs, "g_bus_watch_name")
211 core.PuregoSafeRegister(&xBusWatchNameOnConnection, libs, "g_bus_watch_name_on_connection")
212 core.PuregoSafeRegister(&xBusWatchNameOnConnectionWithClosures, libs, "g_bus_watch_name_on_connection_with_closures")
213 core.PuregoSafeRegister(&xBusWatchNameWithClosures, libs, "g_bus_watch_name_with_closures")
214
215}