// 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/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) // The virtual function table for #GProxyResolver. type ProxyResolverInterface struct { _ structs.HostLayout GIface uintptr xIsSupported uintptr xLookup uintptr xLookupAsync uintptr xLookupFinish uintptr } func (x *ProxyResolverInterface) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideIsSupported sets the "is_supported" callback function. // the virtual function pointer for g_proxy_resolver_is_supported() func (x *ProxyResolverInterface) OverrideIsSupported(cb func(ProxyResolver) bool) { if cb == nil { x.xIsSupported = 0 } else { x.xIsSupported = purego.NewCallback(func(ResolverVarp uintptr) bool { return cb(&ProxyResolverBase{Ptr: ResolverVarp}) }) } } // GetIsSupported gets the "is_supported" callback function. // the virtual function pointer for g_proxy_resolver_is_supported() func (x *ProxyResolverInterface) GetIsSupported() func(ProxyResolver) bool { if x.xIsSupported == 0 { return nil } var rawCallback func(ResolverVarp uintptr) bool purego.RegisterFunc(&rawCallback, x.xIsSupported) return func(ResolverVar ProxyResolver) bool { return rawCallback(ResolverVar.GoPointer()) } } // OverrideLookup sets the "lookup" callback function. // the virtual function pointer for g_proxy_resolver_lookup() func (x *ProxyResolverInterface) OverrideLookup(cb func(ProxyResolver, string, *Cancellable) []string) { if cb == nil { x.xLookup = 0 } else { x.xLookup = purego.NewCallback(func(ResolverVarp uintptr, UriVarp string, CancellableVarp uintptr) []string { return cb(&ProxyResolverBase{Ptr: ResolverVarp}, UriVarp, CancellableNewFromInternalPtr(CancellableVarp)) }) } } // GetLookup gets the "lookup" callback function. // the virtual function pointer for g_proxy_resolver_lookup() func (x *ProxyResolverInterface) GetLookup() func(ProxyResolver, string, *Cancellable) []string { if x.xLookup == 0 { return nil } var rawCallback func(ResolverVarp uintptr, UriVarp string, CancellableVarp uintptr) []string purego.RegisterFunc(&rawCallback, x.xLookup) return func(ResolverVar ProxyResolver, UriVar string, CancellableVar *Cancellable) []string { return rawCallback(ResolverVar.GoPointer(), UriVar, CancellableVar.GoPointer()) } } // OverrideLookupAsync sets the "lookup_async" callback function. // the virtual function pointer for // // g_proxy_resolver_lookup_async() func (x *ProxyResolverInterface) OverrideLookupAsync(cb func(ProxyResolver, string, *Cancellable, *AsyncReadyCallback, uintptr)) { if cb == nil { x.xLookupAsync = 0 } else { x.xLookupAsync = purego.NewCallback(func(ResolverVarp uintptr, UriVarp string, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) { cb(&ProxyResolverBase{Ptr: ResolverVarp}, UriVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp) }) } } // GetLookupAsync gets the "lookup_async" callback function. // the virtual function pointer for // // g_proxy_resolver_lookup_async() func (x *ProxyResolverInterface) GetLookupAsync() func(ProxyResolver, string, *Cancellable, *AsyncReadyCallback, uintptr) { if x.xLookupAsync == 0 { return nil } var rawCallback func(ResolverVarp uintptr, UriVarp string, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) purego.RegisterFunc(&rawCallback, x.xLookupAsync) return func(ResolverVar ProxyResolver, UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { rawCallback(ResolverVar.GoPointer(), UriVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar) } } // OverrideLookupFinish sets the "lookup_finish" callback function. // the virtual function pointer for // // g_proxy_resolver_lookup_finish() func (x *ProxyResolverInterface) OverrideLookupFinish(cb func(ProxyResolver, AsyncResult) []string) { if cb == nil { x.xLookupFinish = 0 } else { x.xLookupFinish = purego.NewCallback(func(ResolverVarp uintptr, ResultVarp uintptr) []string { return cb(&ProxyResolverBase{Ptr: ResolverVarp}, &AsyncResultBase{Ptr: ResultVarp}) }) } } // GetLookupFinish gets the "lookup_finish" callback function. // the virtual function pointer for // // g_proxy_resolver_lookup_finish() func (x *ProxyResolverInterface) GetLookupFinish() func(ProxyResolver, AsyncResult) []string { if x.xLookupFinish == 0 { return nil } var rawCallback func(ResolverVarp uintptr, ResultVarp uintptr) []string purego.RegisterFunc(&rawCallback, x.xLookupFinish) return func(ResolverVar ProxyResolver, ResultVar AsyncResult) []string { return rawCallback(ResolverVar.GoPointer(), ResultVar.GoPointer()) } } // `GProxyResolver` provides synchronous and asynchronous network proxy // resolution. `GProxyResolver` is used within [class@Gio.SocketClient] through // the method [method@Gio.SocketConnectable.proxy_enumerate]. // // Implementations of `GProxyResolver` based on // [libproxy](https://github.com/libproxy/libproxy) and GNOME settings can be // found in [glib-networking](https://gitlab.gnome.org/GNOME/glib-networking). // GIO comes with an implementation for use inside Flatpak portals. type ProxyResolver interface { GoPointer() uintptr SetGoPointer(uintptr) IsSupported() bool Lookup(UriVar string, CancellableVar *Cancellable) ([]string, error) LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) LookupFinish(ResultVar AsyncResult) ([]string, error) } var xProxyResolverGLibType func() types.GType func ProxyResolverGLibType() types.GType { return xProxyResolverGLibType() } type ProxyResolverBase struct { Ptr uintptr } func (x *ProxyResolverBase) GoPointer() uintptr { if x == nil { return 0 } return x.Ptr } func (x *ProxyResolverBase) SetGoPointer(ptr uintptr) { x.Ptr = ptr } // Checks if @resolver can be used on this system. (This is used // internally; g_proxy_resolver_get_default() will only return a proxy // resolver that returns %TRUE for this method.) func (x *ProxyResolverBase) IsSupported() bool { cret := XGProxyResolverIsSupported(x.GoPointer()) return cret } // Looks into the system proxy configuration to determine what proxy, // if any, to use to connect to @uri. The returned proxy URIs are of // the form `<protocol>://[user[:password]@]host[:port]` or // `direct://`, where `<protocol>` could be http, rtsp, socks // or other proxying protocol. // // If you don't know what network protocol is being used on the // socket, you should use `none` as the URI protocol. // In this case, the resolver might still return a generic proxy type // (such as SOCKS), but would not return protocol-specific proxy types // (such as http). // // `direct://` is used when no proxy is needed. // Direct connection should not be attempted unless it is part of the // returned array of proxies. func (x *ProxyResolverBase) Lookup(UriVar string, CancellableVar *Cancellable) ([]string, error) { var cerr *glib.Error cret := XGProxyResolverLookup(x.GoPointer(), UriVar, CancellableVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } // Asynchronous lookup of proxy. See g_proxy_resolver_lookup() for more // details. func (x *ProxyResolverBase) LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { XGProxyResolverLookupAsync(x.GoPointer(), UriVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar) } // Call this function to obtain the array of proxy URIs when // g_proxy_resolver_lookup_async() is complete. See // g_proxy_resolver_lookup() for more details. func (x *ProxyResolverBase) LookupFinish(ResultVar AsyncResult) ([]string, error) { var cerr *glib.Error cret := XGProxyResolverLookupFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } var XGProxyResolverIsSupported func(uintptr) bool var XGProxyResolverLookup func(uintptr, string, uintptr, **glib.Error) []string var XGProxyResolverLookupAsync func(uintptr, string, uintptr, uintptr, uintptr) var XGProxyResolverLookupFinish func(uintptr, uintptr, **glib.Error) []string const ( // Extension point for proxy resolving functionality. // See [Extending GIO](overview.html#extending-gio). PROXY_RESOLVER_EXTENSION_POINT_NAME string = "gio-proxy-resolver" ) var xProxyResolverGetDefault func() uintptr // Gets the default #GProxyResolver for the system. func ProxyResolverGetDefault() *ProxyResolverBase { var cls *ProxyResolverBase cret := xProxyResolverGetDefault() if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &ProxyResolverBase{} cls.Ptr = cret return cls } 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(&xProxyResolverGetDefault, libs, "g_proxy_resolver_get_default") core.PuregoSafeRegister(&xProxyResolverGLibType, libs, "g_proxy_resolver_get_type") core.PuregoSafeRegister(&XGProxyResolverIsSupported, libs, "g_proxy_resolver_is_supported") core.PuregoSafeRegister(&XGProxyResolverLookup, libs, "g_proxy_resolver_lookup") core.PuregoSafeRegister(&XGProxyResolverLookupAsync, libs, "g_proxy_resolver_lookup_async") core.PuregoSafeRegister(&XGProxyResolverLookupFinish, libs, "g_proxy_resolver_lookup_finish") }