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 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16// The virtual function table for #GProxyResolver.
17type ProxyResolverInterface struct {
18 _ structs.HostLayout
19
20 GIface uintptr
21
22 xIsSupported uintptr
23
24 xLookup uintptr
25
26 xLookupAsync uintptr
27
28 xLookupFinish uintptr
29}
30
31func (x *ProxyResolverInterface) GoPointer() uintptr {
32 return uintptr(unsafe.Pointer(x))
33}
34
35// OverrideIsSupported sets the "is_supported" callback function.
36// the virtual function pointer for g_proxy_resolver_is_supported()
37func (x *ProxyResolverInterface) OverrideIsSupported(cb func(ProxyResolver) bool) {
38 if cb == nil {
39 x.xIsSupported = 0
40 } else {
41 x.xIsSupported = purego.NewCallback(func(ResolverVarp uintptr) bool {
42 return cb(&ProxyResolverBase{Ptr: ResolverVarp})
43 })
44 }
45}
46
47// GetIsSupported gets the "is_supported" callback function.
48// the virtual function pointer for g_proxy_resolver_is_supported()
49func (x *ProxyResolverInterface) GetIsSupported() func(ProxyResolver) bool {
50 if x.xIsSupported == 0 {
51 return nil
52 }
53 var rawCallback func(ResolverVarp uintptr) bool
54 purego.RegisterFunc(&rawCallback, x.xIsSupported)
55 return func(ResolverVar ProxyResolver) bool {
56 return rawCallback(ResolverVar.GoPointer())
57 }
58}
59
60// OverrideLookup sets the "lookup" callback function.
61// the virtual function pointer for g_proxy_resolver_lookup()
62func (x *ProxyResolverInterface) OverrideLookup(cb func(ProxyResolver, string, *Cancellable) []string) {
63 if cb == nil {
64 x.xLookup = 0
65 } else {
66 x.xLookup = purego.NewCallback(func(ResolverVarp uintptr, UriVarp string, CancellableVarp uintptr) []string {
67 return cb(&ProxyResolverBase{Ptr: ResolverVarp}, UriVarp, CancellableNewFromInternalPtr(CancellableVarp))
68 })
69 }
70}
71
72// GetLookup gets the "lookup" callback function.
73// the virtual function pointer for g_proxy_resolver_lookup()
74func (x *ProxyResolverInterface) GetLookup() func(ProxyResolver, string, *Cancellable) []string {
75 if x.xLookup == 0 {
76 return nil
77 }
78 var rawCallback func(ResolverVarp uintptr, UriVarp string, CancellableVarp uintptr) []string
79 purego.RegisterFunc(&rawCallback, x.xLookup)
80 return func(ResolverVar ProxyResolver, UriVar string, CancellableVar *Cancellable) []string {
81 return rawCallback(ResolverVar.GoPointer(), UriVar, CancellableVar.GoPointer())
82 }
83}
84
85// OverrideLookupAsync sets the "lookup_async" callback function.
86// the virtual function pointer for
87//
88// g_proxy_resolver_lookup_async()
89func (x *ProxyResolverInterface) OverrideLookupAsync(cb func(ProxyResolver, string, *Cancellable, *AsyncReadyCallback, uintptr)) {
90 if cb == nil {
91 x.xLookupAsync = 0
92 } else {
93 x.xLookupAsync = purego.NewCallback(func(ResolverVarp uintptr, UriVarp string, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
94 cb(&ProxyResolverBase{Ptr: ResolverVarp}, UriVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
95 })
96 }
97}
98
99// GetLookupAsync gets the "lookup_async" callback function.
100// the virtual function pointer for
101//
102// g_proxy_resolver_lookup_async()
103func (x *ProxyResolverInterface) GetLookupAsync() func(ProxyResolver, string, *Cancellable, *AsyncReadyCallback, uintptr) {
104 if x.xLookupAsync == 0 {
105 return nil
106 }
107 var rawCallback func(ResolverVarp uintptr, UriVarp string, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
108 purego.RegisterFunc(&rawCallback, x.xLookupAsync)
109 return func(ResolverVar ProxyResolver, UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
110 rawCallback(ResolverVar.GoPointer(), UriVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
111 }
112}
113
114// OverrideLookupFinish sets the "lookup_finish" callback function.
115// the virtual function pointer for
116//
117// g_proxy_resolver_lookup_finish()
118func (x *ProxyResolverInterface) OverrideLookupFinish(cb func(ProxyResolver, AsyncResult) []string) {
119 if cb == nil {
120 x.xLookupFinish = 0
121 } else {
122 x.xLookupFinish = purego.NewCallback(func(ResolverVarp uintptr, ResultVarp uintptr) []string {
123 return cb(&ProxyResolverBase{Ptr: ResolverVarp}, &AsyncResultBase{Ptr: ResultVarp})
124 })
125 }
126}
127
128// GetLookupFinish gets the "lookup_finish" callback function.
129// the virtual function pointer for
130//
131// g_proxy_resolver_lookup_finish()
132func (x *ProxyResolverInterface) GetLookupFinish() func(ProxyResolver, AsyncResult) []string {
133 if x.xLookupFinish == 0 {
134 return nil
135 }
136 var rawCallback func(ResolverVarp uintptr, ResultVarp uintptr) []string
137 purego.RegisterFunc(&rawCallback, x.xLookupFinish)
138 return func(ResolverVar ProxyResolver, ResultVar AsyncResult) []string {
139 return rawCallback(ResolverVar.GoPointer(), ResultVar.GoPointer())
140 }
141}
142
143// `GProxyResolver` provides synchronous and asynchronous network proxy
144// resolution. `GProxyResolver` is used within [class@Gio.SocketClient] through
145// the method [method@Gio.SocketConnectable.proxy_enumerate].
146//
147// Implementations of `GProxyResolver` based on
148// [libproxy](https://github.com/libproxy/libproxy) and GNOME settings can be
149// found in [glib-networking](https://gitlab.gnome.org/GNOME/glib-networking).
150// GIO comes with an implementation for use inside Flatpak portals.
151type ProxyResolver interface {
152 GoPointer() uintptr
153 SetGoPointer(uintptr)
154 IsSupported() bool
155 Lookup(UriVar string, CancellableVar *Cancellable) ([]string, error)
156 LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr)
157 LookupFinish(ResultVar AsyncResult) ([]string, error)
158}
159
160var xProxyResolverGLibType func() types.GType
161
162func ProxyResolverGLibType() types.GType {
163 return xProxyResolverGLibType()
164}
165
166type ProxyResolverBase struct {
167 Ptr uintptr
168}
169
170func (x *ProxyResolverBase) GoPointer() uintptr {
171 if x == nil {
172 return 0
173 }
174 return x.Ptr
175}
176
177func (x *ProxyResolverBase) SetGoPointer(ptr uintptr) {
178 x.Ptr = ptr
179}
180
181// Checks if @resolver can be used on this system. (This is used
182// internally; g_proxy_resolver_get_default() will only return a proxy
183// resolver that returns %TRUE for this method.)
184func (x *ProxyResolverBase) IsSupported() bool {
185
186 cret := XGProxyResolverIsSupported(x.GoPointer())
187 return cret
188}
189
190// Looks into the system proxy configuration to determine what proxy,
191// if any, to use to connect to @uri. The returned proxy URIs are of
192// the form `<protocol>://[user[:password]@]host[:port]` or
193// `direct://`, where `<protocol>` could be http, rtsp, socks
194// or other proxying protocol.
195//
196// If you don't know what network protocol is being used on the
197// socket, you should use `none` as the URI protocol.
198// In this case, the resolver might still return a generic proxy type
199// (such as SOCKS), but would not return protocol-specific proxy types
200// (such as http).
201//
202// `direct://` is used when no proxy is needed.
203// Direct connection should not be attempted unless it is part of the
204// returned array of proxies.
205func (x *ProxyResolverBase) Lookup(UriVar string, CancellableVar *Cancellable) ([]string, error) {
206 var cerr *glib.Error
207
208 cret := XGProxyResolverLookup(x.GoPointer(), UriVar, CancellableVar.GoPointer(), &cerr)
209 if cerr == nil {
210 return cret, nil
211 }
212 return cret, cerr
213
214}
215
216// Asynchronous lookup of proxy. See g_proxy_resolver_lookup() for more
217// details.
218func (x *ProxyResolverBase) LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
219
220 XGProxyResolverLookupAsync(x.GoPointer(), UriVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
221
222}
223
224// Call this function to obtain the array of proxy URIs when
225// g_proxy_resolver_lookup_async() is complete. See
226// g_proxy_resolver_lookup() for more details.
227func (x *ProxyResolverBase) LookupFinish(ResultVar AsyncResult) ([]string, error) {
228 var cerr *glib.Error
229
230 cret := XGProxyResolverLookupFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
231 if cerr == nil {
232 return cret, nil
233 }
234 return cret, cerr
235
236}
237
238var XGProxyResolverIsSupported func(uintptr) bool
239var XGProxyResolverLookup func(uintptr, string, uintptr, **glib.Error) []string
240var XGProxyResolverLookupAsync func(uintptr, string, uintptr, uintptr, uintptr)
241var XGProxyResolverLookupFinish func(uintptr, uintptr, **glib.Error) []string
242
243const (
244 // Extension point for proxy resolving functionality.
245 // See [Extending GIO](overview.html#extending-gio).
246 PROXY_RESOLVER_EXTENSION_POINT_NAME string = "gio-proxy-resolver"
247)
248
249var xProxyResolverGetDefault func() uintptr
250
251// Gets the default #GProxyResolver for the system.
252func ProxyResolverGetDefault() *ProxyResolverBase {
253 var cls *ProxyResolverBase
254
255 cret := xProxyResolverGetDefault()
256
257 if cret == 0 {
258 return nil
259 }
260 gobject.IncreaseRef(cret)
261 cls = &ProxyResolverBase{}
262 cls.Ptr = cret
263 return cls
264}
265
266func init() {
267 core.SetPackageName("GIO", "gio-2.0")
268 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
269 var libs []uintptr
270 for _, libPath := range core.GetPaths("GIO") {
271 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
272 if err != nil {
273 panic(err)
274 }
275 libs = append(libs, lib)
276 }
277
278 core.PuregoSafeRegister(&xProxyResolverGetDefault, libs, "g_proxy_resolver_get_default")
279
280 core.PuregoSafeRegister(&xProxyResolverGLibType, libs, "g_proxy_resolver_get_type")
281
282 core.PuregoSafeRegister(&XGProxyResolverIsSupported, libs, "g_proxy_resolver_is_supported")
283 core.PuregoSafeRegister(&XGProxyResolverLookup, libs, "g_proxy_resolver_lookup")
284 core.PuregoSafeRegister(&XGProxyResolverLookupAsync, libs, "g_proxy_resolver_lookup_async")
285 core.PuregoSafeRegister(&XGProxyResolverLookupFinish, libs, "g_proxy_resolver_lookup_finish")
286
287}