// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gio import ( "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" ) // Invoked when the name being watched is known to have to have an owner. type BusNameAppearedCallback func(uintptr, string, string, uintptr) // Invoked when the name being watched is known not to have to have an owner. // // This is also invoked when the #GDBusConnection on which the watch was // established has been closed. In that case, @connection will be // %NULL. type BusNameVanishedCallback func(uintptr, string, uintptr) var xBusUnwatchName func(uint) // Stops watching a name. // // Note that there may still be D-Bus traffic to process (relating to watching // and unwatching the name) in the current thread-default #GMainContext after // this function has returned. You should continue to iterate the #GMainContext // until the #GDestroyNotify function passed to g_bus_watch_name() is called, in // order to avoid memory leaks through callbacks queued on the #GMainContext // after it’s stopped being iterated. func BusUnwatchName(WatcherIdVar uint) { xBusUnwatchName(WatcherIdVar) } var xBusWatchName func(BusType, string, BusNameWatcherFlags, uintptr, uintptr, uintptr, uintptr) uint // Starts watching @name on the bus specified by @bus_type and calls // @name_appeared_handler and @name_vanished_handler when the name is // known to have an owner respectively known to lose its // owner. Callbacks will be invoked in the thread-default main context // (see [method@GLib.MainContext.push_thread_default]) // of the thread you are calling this function from. // // You are guaranteed that one of the handlers will be invoked after // calling this function. When you are done watching the name, just // call g_bus_unwatch_name() with the watcher id this function // returns. // // If the name vanishes or appears (for example the application owning // the name could restart), the handlers are also invoked. If the // #GDBusConnection that is used for watching the name disconnects, then // @name_vanished_handler is invoked since it is no longer // possible to access the name. // // Another guarantee is that invocations of @name_appeared_handler // and @name_vanished_handler are guaranteed to alternate; that // is, if @name_appeared_handler is invoked then you are // guaranteed that the next time one of the handlers is invoked, it // will be @name_vanished_handler. The reverse is also true. // // This behavior makes it very simple to write applications that want // to take action when a certain [name exists](dbus-name-watching.html#d-bus-name-watching). // Basically, the application should create object proxies in // @name_appeared_handler and destroy them again (if any) in // @name_vanished_handler. func BusWatchName(BusTypeVar BusType, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedHandlerVar *BusNameAppearedCallback, NameVanishedHandlerVar *BusNameVanishedCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint { var NameAppearedHandlerVarRef uintptr if NameAppearedHandlerVar != nil { NameAppearedHandlerVarPtr := uintptr(unsafe.Pointer(NameAppearedHandlerVar)) if cbRefPtr, ok := glib.GetCallback(NameAppearedHandlerVarPtr); ok { NameAppearedHandlerVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr, arg3 uintptr) { cbFn := *NameAppearedHandlerVar cbFn(arg0, core.GoString(arg1), core.GoString(arg2), arg3) } NameAppearedHandlerVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(NameAppearedHandlerVarPtr, NameAppearedHandlerVarRef, NameAppearedHandlerVar) } } var NameVanishedHandlerVarRef uintptr if NameVanishedHandlerVar != nil { NameVanishedHandlerVarPtr := uintptr(unsafe.Pointer(NameVanishedHandlerVar)) if cbRefPtr, ok := glib.GetCallback(NameVanishedHandlerVarPtr); ok { NameVanishedHandlerVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *NameVanishedHandlerVar cbFn(arg0, core.GoString(arg1), arg2) } NameVanishedHandlerVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(NameVanishedHandlerVarPtr, NameVanishedHandlerVarRef, NameVanishedHandlerVar) } } var UserDataFreeFuncVarRef uintptr if UserDataFreeFuncVar != nil { UserDataFreeFuncVarPtr := uintptr(unsafe.Pointer(UserDataFreeFuncVar)) if cbRefPtr, ok := glib.GetCallback(UserDataFreeFuncVarPtr); ok { UserDataFreeFuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *UserDataFreeFuncVar cbFn(arg0) } UserDataFreeFuncVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(UserDataFreeFuncVarPtr, UserDataFreeFuncVarRef, UserDataFreeFuncVar) } } cret := xBusWatchName(BusTypeVar, NameVar, FlagsVar, NameAppearedHandlerVarRef, NameVanishedHandlerVarRef, UserDataVar, UserDataFreeFuncVarRef) return cret } var xBusWatchNameOnConnection func(uintptr, string, BusNameWatcherFlags, uintptr, uintptr, uintptr, uintptr) uint // Like g_bus_watch_name() but takes a #GDBusConnection instead of a // #GBusType. func BusWatchNameOnConnection(ConnectionVar *DBusConnection, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedHandlerVar *BusNameAppearedCallback, NameVanishedHandlerVar *BusNameVanishedCallback, UserDataVar uintptr, UserDataFreeFuncVar *glib.DestroyNotify) uint { var NameAppearedHandlerVarRef uintptr if NameAppearedHandlerVar != nil { NameAppearedHandlerVarPtr := uintptr(unsafe.Pointer(NameAppearedHandlerVar)) if cbRefPtr, ok := glib.GetCallback(NameAppearedHandlerVarPtr); ok { NameAppearedHandlerVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr, arg3 uintptr) { cbFn := *NameAppearedHandlerVar cbFn(arg0, core.GoString(arg1), core.GoString(arg2), arg3) } NameAppearedHandlerVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(NameAppearedHandlerVarPtr, NameAppearedHandlerVarRef, NameAppearedHandlerVar) } } var NameVanishedHandlerVarRef uintptr if NameVanishedHandlerVar != nil { NameVanishedHandlerVarPtr := uintptr(unsafe.Pointer(NameVanishedHandlerVar)) if cbRefPtr, ok := glib.GetCallback(NameVanishedHandlerVarPtr); ok { NameVanishedHandlerVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *NameVanishedHandlerVar cbFn(arg0, core.GoString(arg1), arg2) } NameVanishedHandlerVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(NameVanishedHandlerVarPtr, NameVanishedHandlerVarRef, NameVanishedHandlerVar) } } var UserDataFreeFuncVarRef uintptr if UserDataFreeFuncVar != nil { UserDataFreeFuncVarPtr := uintptr(unsafe.Pointer(UserDataFreeFuncVar)) if cbRefPtr, ok := glib.GetCallback(UserDataFreeFuncVarPtr); ok { UserDataFreeFuncVarRef = cbRefPtr } else { fcb := func(arg0 uintptr) { cbFn := *UserDataFreeFuncVar cbFn(arg0) } UserDataFreeFuncVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(UserDataFreeFuncVarPtr, UserDataFreeFuncVarRef, UserDataFreeFuncVar) } } cret := xBusWatchNameOnConnection(ConnectionVar.GoPointer(), NameVar, FlagsVar, NameAppearedHandlerVarRef, NameVanishedHandlerVarRef, UserDataVar, UserDataFreeFuncVarRef) return cret } var xBusWatchNameOnConnectionWithClosures func(uintptr, string, BusNameWatcherFlags, *gobject.Closure, *gobject.Closure) uint // Version of g_bus_watch_name_on_connection() using closures instead of callbacks for // easier binding in other languages. func BusWatchNameOnConnectionWithClosures(ConnectionVar *DBusConnection, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedClosureVar *gobject.Closure, NameVanishedClosureVar *gobject.Closure) uint { cret := xBusWatchNameOnConnectionWithClosures(ConnectionVar.GoPointer(), NameVar, FlagsVar, NameAppearedClosureVar, NameVanishedClosureVar) return cret } var xBusWatchNameWithClosures func(BusType, string, BusNameWatcherFlags, *gobject.Closure, *gobject.Closure) uint // Version of g_bus_watch_name() using closures instead of callbacks for // easier binding in other languages. func BusWatchNameWithClosures(BusTypeVar BusType, NameVar string, FlagsVar BusNameWatcherFlags, NameAppearedClosureVar *gobject.Closure, NameVanishedClosureVar *gobject.Closure) uint { cret := xBusWatchNameWithClosures(BusTypeVar, NameVar, FlagsVar, NameAppearedClosureVar, NameVanishedClosureVar) return cret } func init() { core.SetPackageName("GIO", "gio-2.0") core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GIO") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xBusUnwatchName, libs, "g_bus_unwatch_name") core.PuregoSafeRegister(&xBusWatchName, libs, "g_bus_watch_name") core.PuregoSafeRegister(&xBusWatchNameOnConnection, libs, "g_bus_watch_name_on_connection") core.PuregoSafeRegister(&xBusWatchNameOnConnectionWithClosures, libs, "g_bus_watch_name_on_connection_with_closures") core.PuregoSafeRegister(&xBusWatchNameWithClosures, libs, "g_bus_watch_name_with_closures") }