// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gio import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/gobject/types" ) // Provides an interface for returning a #GSocketAddressEnumerator // and #GProxyAddressEnumerator type SocketConnectableIface struct { _ structs.HostLayout GIface uintptr xEnumerate uintptr xProxyEnumerate uintptr xToString uintptr } func (x *SocketConnectableIface) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideEnumerate sets the "enumerate" callback function. // Creates a #GSocketAddressEnumerator func (x *SocketConnectableIface) OverrideEnumerate(cb func(SocketConnectable) *SocketAddressEnumerator) { if cb == nil { x.xEnumerate = 0 } else { x.xEnumerate = purego.NewCallback(func(ConnectableVarp uintptr) uintptr { ret := cb(&SocketConnectableBase{Ptr: ConnectableVarp}) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetEnumerate gets the "enumerate" callback function. // Creates a #GSocketAddressEnumerator func (x *SocketConnectableIface) GetEnumerate() func(SocketConnectable) *SocketAddressEnumerator { if x.xEnumerate == 0 { return nil } var rawCallback func(ConnectableVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xEnumerate) return func(ConnectableVar SocketConnectable) *SocketAddressEnumerator { rawRet := rawCallback(ConnectableVar.GoPointer()) if rawRet == 0 { return nil } ret := &SocketAddressEnumerator{} ret.Ptr = rawRet return ret } } // OverrideProxyEnumerate sets the "proxy_enumerate" callback function. // Creates a #GProxyAddressEnumerator func (x *SocketConnectableIface) OverrideProxyEnumerate(cb func(SocketConnectable) *SocketAddressEnumerator) { if cb == nil { x.xProxyEnumerate = 0 } else { x.xProxyEnumerate = purego.NewCallback(func(ConnectableVarp uintptr) uintptr { ret := cb(&SocketConnectableBase{Ptr: ConnectableVarp}) if ret == nil { return 0 } return ret.GoPointer() }) } } // GetProxyEnumerate gets the "proxy_enumerate" callback function. // Creates a #GProxyAddressEnumerator func (x *SocketConnectableIface) GetProxyEnumerate() func(SocketConnectable) *SocketAddressEnumerator { if x.xProxyEnumerate == 0 { return nil } var rawCallback func(ConnectableVarp uintptr) uintptr purego.RegisterFunc(&rawCallback, x.xProxyEnumerate) return func(ConnectableVar SocketConnectable) *SocketAddressEnumerator { rawRet := rawCallback(ConnectableVar.GoPointer()) if rawRet == 0 { return nil } ret := &SocketAddressEnumerator{} ret.Ptr = rawRet return ret } } // OverrideToString sets the "to_string" callback function. // Format the connectable’s address as a string for debugging. // // Implementing this is optional. (Since: 2.48) func (x *SocketConnectableIface) OverrideToString(cb func(SocketConnectable) string) { if cb == nil { x.xToString = 0 } else { x.xToString = purego.NewCallback(func(ConnectableVarp uintptr) string { return cb(&SocketConnectableBase{Ptr: ConnectableVarp}) }) } } // GetToString gets the "to_string" callback function. // Format the connectable’s address as a string for debugging. // // Implementing this is optional. (Since: 2.48) func (x *SocketConnectableIface) GetToString() func(SocketConnectable) string { if x.xToString == 0 { return nil } var rawCallback func(ConnectableVarp uintptr) string purego.RegisterFunc(&rawCallback, x.xToString) return func(ConnectableVar SocketConnectable) string { return rawCallback(ConnectableVar.GoPointer()) } } // Objects that describe one or more potential socket endpoints // implement `GSocketConnectable`. Callers can then use // [method@Gio.SocketConnectable.enumerate] to get a // [class@Gio.SocketAddressEnumerator] to try out each socket address in turn // until one succeeds, as shown in the sample code below. // // ```c // MyConnectionType * // connect_to_host (const char *hostname, // // guint16 port, // GCancellable *cancellable, // GError **error) // // { // MyConnection *conn = NULL; // GSocketConnectable *addr; // GSocketAddressEnumerator *enumerator; // GSocketAddress *sockaddr; // GError *conn_error = NULL; // // addr = g_network_address_new (hostname, port); // enumerator = g_socket_connectable_enumerate (addr); // g_object_unref (addr); // // // Try each sockaddr until we succeed. Record the first connection error, // // but not any further ones (since they'll probably be basically the same // // as the first). // while (!conn && (sockaddr = g_socket_address_enumerator_next (enumerator, cancellable, error)) // { // conn = connect_to_sockaddr (sockaddr, conn_error ? NULL : &conn_error); // g_object_unref (sockaddr); // } // g_object_unref (enumerator); // // if (conn) // { // if (conn_error) // { // // We couldn't connect to the first address, but we succeeded // // in connecting to a later address. // g_error_free (conn_error); // } // return conn; // } // else if (error) // { // /// Either initial lookup failed, or else the caller cancelled us. // if (conn_error) // g_error_free (conn_error); // return NULL; // } // else // { // g_error_propagate (error, conn_error); // return NULL; // } // } // // ``` type SocketConnectable interface { GoPointer() uintptr SetGoPointer(uintptr) Enumerate() *SocketAddressEnumerator ProxyEnumerate() *SocketAddressEnumerator ToString() string } var xSocketConnectableGLibType func() types.GType func SocketConnectableGLibType() types.GType { return xSocketConnectableGLibType() } type SocketConnectableBase struct { Ptr uintptr } func (x *SocketConnectableBase) GoPointer() uintptr { if x == nil { return 0 } return x.Ptr } func (x *SocketConnectableBase) SetGoPointer(ptr uintptr) { x.Ptr = ptr } // Creates a #GSocketAddressEnumerator for @connectable. func (x *SocketConnectableBase) Enumerate() *SocketAddressEnumerator { var cls *SocketAddressEnumerator cret := XGSocketConnectableEnumerate(x.GoPointer()) if cret == 0 { return nil } cls = &SocketAddressEnumerator{} cls.Ptr = cret return cls } // Creates a #GSocketAddressEnumerator for @connectable that will // return a #GProxyAddress for each of its addresses that you must connect // to via a proxy. // // If @connectable does not implement // g_socket_connectable_proxy_enumerate(), this will fall back to // calling g_socket_connectable_enumerate(). func (x *SocketConnectableBase) ProxyEnumerate() *SocketAddressEnumerator { var cls *SocketAddressEnumerator cret := XGSocketConnectableProxyEnumerate(x.GoPointer()) if cret == 0 { return nil } cls = &SocketAddressEnumerator{} cls.Ptr = cret return cls } // Format a #GSocketConnectable as a string. This is a human-readable format for // use in debugging output, and is not a stable serialization format. It is not // suitable for use in user interfaces as it exposes too much information for a // user. // // If the #GSocketConnectable implementation does not support string formatting, // the implementation’s type name will be returned as a fallback. func (x *SocketConnectableBase) ToString() string { cret := XGSocketConnectableToString(x.GoPointer()) return cret } var XGSocketConnectableEnumerate func(uintptr) uintptr var XGSocketConnectableProxyEnumerate func(uintptr) uintptr var XGSocketConnectableToString func(uintptr) string 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(&xSocketConnectableGLibType, libs, "g_socket_connectable_get_type") core.PuregoSafeRegister(&XGSocketConnectableEnumerate, libs, "g_socket_connectable_enumerate") core.PuregoSafeRegister(&XGSocketConnectableProxyEnumerate, libs, "g_socket_connectable_proxy_enumerate") core.PuregoSafeRegister(&XGSocketConnectableToString, libs, "g_socket_connectable_to_string") }