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
16type SimpleProxyResolverClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20
21 xGReserved1 uintptr
22
23 xGReserved2 uintptr
24
25 xGReserved3 uintptr
26
27 xGReserved4 uintptr
28
29 xGReserved5 uintptr
30}
31
32func (x *SimpleProxyResolverClass) GoPointer() uintptr {
33 return uintptr(unsafe.Pointer(x))
34}
35
36// OverrideGReserved1 sets the "_g_reserved1" callback function.
37func (x *SimpleProxyResolverClass) OverrideGReserved1(cb func()) {
38 if cb == nil {
39 x.xGReserved1 = 0
40 } else {
41 x.xGReserved1 = purego.NewCallback(func() {
42 cb()
43 })
44 }
45}
46
47// GetGReserved1 gets the "_g_reserved1" callback function.
48func (x *SimpleProxyResolverClass) GetGReserved1() func() {
49 if x.xGReserved1 == 0 {
50 return nil
51 }
52 var rawCallback func()
53 purego.RegisterFunc(&rawCallback, x.xGReserved1)
54 return func() {
55 rawCallback()
56 }
57}
58
59// OverrideGReserved2 sets the "_g_reserved2" callback function.
60func (x *SimpleProxyResolverClass) OverrideGReserved2(cb func()) {
61 if cb == nil {
62 x.xGReserved2 = 0
63 } else {
64 x.xGReserved2 = purego.NewCallback(func() {
65 cb()
66 })
67 }
68}
69
70// GetGReserved2 gets the "_g_reserved2" callback function.
71func (x *SimpleProxyResolverClass) GetGReserved2() func() {
72 if x.xGReserved2 == 0 {
73 return nil
74 }
75 var rawCallback func()
76 purego.RegisterFunc(&rawCallback, x.xGReserved2)
77 return func() {
78 rawCallback()
79 }
80}
81
82// OverrideGReserved3 sets the "_g_reserved3" callback function.
83func (x *SimpleProxyResolverClass) OverrideGReserved3(cb func()) {
84 if cb == nil {
85 x.xGReserved3 = 0
86 } else {
87 x.xGReserved3 = purego.NewCallback(func() {
88 cb()
89 })
90 }
91}
92
93// GetGReserved3 gets the "_g_reserved3" callback function.
94func (x *SimpleProxyResolverClass) GetGReserved3() func() {
95 if x.xGReserved3 == 0 {
96 return nil
97 }
98 var rawCallback func()
99 purego.RegisterFunc(&rawCallback, x.xGReserved3)
100 return func() {
101 rawCallback()
102 }
103}
104
105// OverrideGReserved4 sets the "_g_reserved4" callback function.
106func (x *SimpleProxyResolverClass) OverrideGReserved4(cb func()) {
107 if cb == nil {
108 x.xGReserved4 = 0
109 } else {
110 x.xGReserved4 = purego.NewCallback(func() {
111 cb()
112 })
113 }
114}
115
116// GetGReserved4 gets the "_g_reserved4" callback function.
117func (x *SimpleProxyResolverClass) GetGReserved4() func() {
118 if x.xGReserved4 == 0 {
119 return nil
120 }
121 var rawCallback func()
122 purego.RegisterFunc(&rawCallback, x.xGReserved4)
123 return func() {
124 rawCallback()
125 }
126}
127
128// OverrideGReserved5 sets the "_g_reserved5" callback function.
129func (x *SimpleProxyResolverClass) OverrideGReserved5(cb func()) {
130 if cb == nil {
131 x.xGReserved5 = 0
132 } else {
133 x.xGReserved5 = purego.NewCallback(func() {
134 cb()
135 })
136 }
137}
138
139// GetGReserved5 gets the "_g_reserved5" callback function.
140func (x *SimpleProxyResolverClass) GetGReserved5() func() {
141 if x.xGReserved5 == 0 {
142 return nil
143 }
144 var rawCallback func()
145 purego.RegisterFunc(&rawCallback, x.xGReserved5)
146 return func() {
147 rawCallback()
148 }
149}
150
151type SimpleProxyResolverPrivate struct {
152 _ structs.HostLayout
153}
154
155func (x *SimpleProxyResolverPrivate) GoPointer() uintptr {
156 return uintptr(unsafe.Pointer(x))
157}
158
159// `GSimpleProxyResolver` is a simple [iface@Gio.ProxyResolver] implementation
160// that handles a single default proxy, multiple URI-scheme-specific
161// proxies, and a list of hosts that proxies should not be used for.
162//
163// `GSimpleProxyResolver` is never the default proxy resolver, but it
164// can be used as the base class for another proxy resolver
165// implementation, or it can be created and used manually, such as
166// with [method@Gio.SocketClient.set_proxy_resolver].
167type SimpleProxyResolver struct {
168 gobject.Object
169}
170
171var xSimpleProxyResolverGLibType func() types.GType
172
173func SimpleProxyResolverGLibType() types.GType {
174 return xSimpleProxyResolverGLibType()
175}
176
177func SimpleProxyResolverNewFromInternalPtr(ptr uintptr) *SimpleProxyResolver {
178 cls := &SimpleProxyResolver{}
179 cls.Ptr = ptr
180 return cls
181}
182
183var xSimpleProxyResolverSetDefaultProxy func(uintptr, uintptr)
184
185// Sets the default proxy on @resolver, to be used for any URIs that
186// don't match #GSimpleProxyResolver:ignore-hosts or a proxy set
187// via g_simple_proxy_resolver_set_uri_proxy().
188//
189// If @default_proxy starts with "socks://",
190// #GSimpleProxyResolver will treat it as referring to all three of
191// the socks5, socks4a, and socks4 proxy types.
192func (x *SimpleProxyResolver) SetDefaultProxy(DefaultProxyVar *string) {
193
194 DefaultProxyVarPtr := core.GStrdupNullable(DefaultProxyVar)
195 defer core.GFreeNullable(DefaultProxyVarPtr)
196
197 xSimpleProxyResolverSetDefaultProxy(x.GoPointer(), DefaultProxyVarPtr)
198
199}
200
201var xSimpleProxyResolverSetIgnoreHosts func(uintptr, []string)
202
203// Sets the list of ignored hosts.
204//
205// See #GSimpleProxyResolver:ignore-hosts for more details on how the
206// @ignore_hosts argument is interpreted.
207func (x *SimpleProxyResolver) SetIgnoreHosts(IgnoreHostsVar []string) {
208
209 xSimpleProxyResolverSetIgnoreHosts(x.GoPointer(), IgnoreHostsVar)
210
211}
212
213var xSimpleProxyResolverSetUriProxy func(uintptr, string, string)
214
215// Adds a URI-scheme-specific proxy to @resolver; URIs whose scheme
216// matches @uri_scheme (and which don't match
217// #GSimpleProxyResolver:ignore-hosts) will be proxied via @proxy.
218//
219// As with #GSimpleProxyResolver:default-proxy, if @proxy starts with
220// "socks://", #GSimpleProxyResolver will treat it
221// as referring to all three of the socks5, socks4a, and socks4 proxy
222// types.
223func (x *SimpleProxyResolver) SetUriProxy(UriSchemeVar string, ProxyVar string) {
224
225 xSimpleProxyResolverSetUriProxy(x.GoPointer(), UriSchemeVar, ProxyVar)
226
227}
228
229func (c *SimpleProxyResolver) GoPointer() uintptr {
230 if c == nil {
231 return 0
232 }
233 return c.Ptr
234}
235
236func (c *SimpleProxyResolver) SetGoPointer(ptr uintptr) {
237 c.Ptr = ptr
238}
239
240// SetPropertyDefaultProxy sets the "default-proxy" property.
241// The default proxy URI that will be used for any URI that doesn't
242// match #GSimpleProxyResolver:ignore-hosts, and doesn't match any
243// of the schemes set with g_simple_proxy_resolver_set_uri_proxy().
244//
245// Note that as a special case, if this URI starts with
246// "socks://", #GSimpleProxyResolver will treat it as referring
247// to all three of the socks5, socks4a, and socks4 proxy types.
248func (x *SimpleProxyResolver) SetPropertyDefaultProxy(value string) {
249 var v gobject.Value
250 v.Init(gobject.TypeStringVal)
251 v.SetString(&value)
252 x.SetProperty("default-proxy", &v)
253}
254
255// GetPropertyDefaultProxy gets the "default-proxy" property.
256// The default proxy URI that will be used for any URI that doesn't
257// match #GSimpleProxyResolver:ignore-hosts, and doesn't match any
258// of the schemes set with g_simple_proxy_resolver_set_uri_proxy().
259//
260// Note that as a special case, if this URI starts with
261// "socks://", #GSimpleProxyResolver will treat it as referring
262// to all three of the socks5, socks4a, and socks4 proxy types.
263func (x *SimpleProxyResolver) GetPropertyDefaultProxy() string {
264 var v gobject.Value
265 x.GetProperty("default-proxy", &v)
266 return v.GetString()
267}
268
269// SetPropertyIgnoreHosts sets the "ignore-hosts" property.
270// A list of hostnames and IP addresses that the resolver should
271// allow direct connections to.
272//
273// Entries can be in one of 4 formats:
274//
275// - A hostname, such as "example.com", ".example.com", or
276// "*.example.com", any of which match "example.com" or
277// any subdomain of it.
278//
279// - An IPv4 or IPv6 address, such as "192.168.1.1",
280// which matches only that address.
281//
282// - A hostname or IP address followed by a port, such as
283// "example.com:80", which matches whatever the hostname or IP
284// address would match, but only for URLs with the (explicitly)
285// indicated port. In the case of an IPv6 address, the address
286// part must appear in brackets: "[::1]:443"
287//
288// - An IP address range, given by a base address and prefix length,
289// such as "fe80::/10", which matches any address in that range.
290//
291// Note that when dealing with Unicode hostnames, the matching is
292// done against the ASCII form of the name.
293//
294// Also note that hostname exclusions apply only to connections made
295// to hosts identified by name, and IP address exclusions apply only
296// to connections made to hosts identified by address. That is, if
297// example.com has an address of 192.168.1.1, and the :ignore-hosts list
298// contains only "192.168.1.1", then a connection to "example.com"
299// (eg, via a #GNetworkAddress) will use the proxy, and a connection to
300// "192.168.1.1" (eg, via a #GInetSocketAddress) will not.
301//
302// These rules match the "ignore-hosts"/"noproxy" rules most
303// commonly used by other applications.
304func (x *SimpleProxyResolver) SetPropertyIgnoreHosts(value []string) {
305 var v gobject.Value
306 v.Init(glib.StrvGetType())
307 v.SetBoxed(uintptr(unsafe.Pointer(core.ByteSlice(value))))
308 x.SetProperty("ignore-hosts", &v)
309}
310
311// GetPropertyIgnoreHosts gets the "ignore-hosts" property.
312// A list of hostnames and IP addresses that the resolver should
313// allow direct connections to.
314//
315// Entries can be in one of 4 formats:
316//
317// - A hostname, such as "example.com", ".example.com", or
318// "*.example.com", any of which match "example.com" or
319// any subdomain of it.
320//
321// - An IPv4 or IPv6 address, such as "192.168.1.1",
322// which matches only that address.
323//
324// - A hostname or IP address followed by a port, such as
325// "example.com:80", which matches whatever the hostname or IP
326// address would match, but only for URLs with the (explicitly)
327// indicated port. In the case of an IPv6 address, the address
328// part must appear in brackets: "[::1]:443"
329//
330// - An IP address range, given by a base address and prefix length,
331// such as "fe80::/10", which matches any address in that range.
332//
333// Note that when dealing with Unicode hostnames, the matching is
334// done against the ASCII form of the name.
335//
336// Also note that hostname exclusions apply only to connections made
337// to hosts identified by name, and IP address exclusions apply only
338// to connections made to hosts identified by address. That is, if
339// example.com has an address of 192.168.1.1, and the :ignore-hosts list
340// contains only "192.168.1.1", then a connection to "example.com"
341// (eg, via a #GNetworkAddress) will use the proxy, and a connection to
342// "192.168.1.1" (eg, via a #GInetSocketAddress) will not.
343//
344// These rules match the "ignore-hosts"/"noproxy" rules most
345// commonly used by other applications.
346func (x *SimpleProxyResolver) GetPropertyIgnoreHosts() []string {
347 var v gobject.Value
348 x.GetProperty("ignore-hosts", &v)
349 return core.GoStringSlice(v.GetBoxed())
350}
351
352// Checks if @resolver can be used on this system. (This is used
353// internally; g_proxy_resolver_get_default() will only return a proxy
354// resolver that returns %TRUE for this method.)
355func (x *SimpleProxyResolver) IsSupported() bool {
356
357 cret := XGProxyResolverIsSupported(x.GoPointer())
358 return cret
359}
360
361// Looks into the system proxy configuration to determine what proxy,
362// if any, to use to connect to @uri. The returned proxy URIs are of
363// the form `<protocol>://[user[:password]@]host[:port]` or
364// `direct://`, where `<protocol>` could be http, rtsp, socks
365// or other proxying protocol.
366//
367// If you don't know what network protocol is being used on the
368// socket, you should use `none` as the URI protocol.
369// In this case, the resolver might still return a generic proxy type
370// (such as SOCKS), but would not return protocol-specific proxy types
371// (such as http).
372//
373// `direct://` is used when no proxy is needed.
374// Direct connection should not be attempted unless it is part of the
375// returned array of proxies.
376func (x *SimpleProxyResolver) Lookup(UriVar string, CancellableVar *Cancellable) ([]string, error) {
377 var cerr *glib.Error
378
379 cret := XGProxyResolverLookup(x.GoPointer(), UriVar, CancellableVar.GoPointer(), &cerr)
380 if cerr == nil {
381 return cret, nil
382 }
383 return cret, cerr
384
385}
386
387// Asynchronous lookup of proxy. See g_proxy_resolver_lookup() for more
388// details.
389func (x *SimpleProxyResolver) LookupAsync(UriVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
390
391 XGProxyResolverLookupAsync(x.GoPointer(), UriVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
392
393}
394
395// Call this function to obtain the array of proxy URIs when
396// g_proxy_resolver_lookup_async() is complete. See
397// g_proxy_resolver_lookup() for more details.
398func (x *SimpleProxyResolver) LookupFinish(ResultVar AsyncResult) ([]string, error) {
399 var cerr *glib.Error
400
401 cret := XGProxyResolverLookupFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
402 if cerr == nil {
403 return cret, nil
404 }
405 return cret, cerr
406
407}
408
409var xSimpleProxyResolverNew func(uintptr, []string) uintptr
410
411// Creates a new #GSimpleProxyResolver. See
412// #GSimpleProxyResolver:default-proxy and
413// #GSimpleProxyResolver:ignore-hosts for more details on how the
414// arguments are interpreted.
415func SimpleProxyResolverNew(DefaultProxyVar *string, IgnoreHostsVar []string) *ProxyResolverBase {
416 var cls *ProxyResolverBase
417
418 DefaultProxyVarPtr := core.GStrdupNullable(DefaultProxyVar)
419 defer core.GFreeNullable(DefaultProxyVarPtr)
420
421 cret := xSimpleProxyResolverNew(DefaultProxyVarPtr, IgnoreHostsVar)
422
423 if cret == 0 {
424 return nil
425 }
426 cls = &ProxyResolverBase{}
427 cls.Ptr = cret
428 return cls
429}
430
431func init() {
432 core.SetPackageName("GIO", "gio-2.0")
433 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
434 var libs []uintptr
435 for _, libPath := range core.GetPaths("GIO") {
436 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
437 if err != nil {
438 panic(err)
439 }
440 libs = append(libs, lib)
441 }
442
443 core.PuregoSafeRegister(&xSimpleProxyResolverGLibType, libs, "g_simple_proxy_resolver_get_type")
444
445 core.PuregoSafeRegister(&xSimpleProxyResolverSetDefaultProxy, libs, "g_simple_proxy_resolver_set_default_proxy")
446 core.PuregoSafeRegister(&xSimpleProxyResolverSetIgnoreHosts, libs, "g_simple_proxy_resolver_set_ignore_hosts")
447 core.PuregoSafeRegister(&xSimpleProxyResolverSetUriProxy, libs, "g_simple_proxy_resolver_set_uri_proxy")
448
449 core.PuregoSafeRegister(&xSimpleProxyResolverNew, libs, "g_simple_proxy_resolver_new")
450
451}