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 SocketClientClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20
21 xEvent uintptr
22
23 xGReserved1 uintptr
24
25 xGReserved2 uintptr
26
27 xGReserved3 uintptr
28
29 xGReserved4 uintptr
30}
31
32func (x *SocketClientClass) GoPointer() uintptr {
33 return uintptr(unsafe.Pointer(x))
34}
35
36// OverrideEvent sets the "event" callback function.
37func (x *SocketClientClass) OverrideEvent(cb func(*SocketClient, SocketClientEvent, SocketConnectable, *IOStream)) {
38 if cb == nil {
39 x.xEvent = 0
40 } else {
41 x.xEvent = purego.NewCallback(func(ClientVarp uintptr, EventVarp SocketClientEvent, ConnectableVarp uintptr, ConnectionVarp uintptr) {
42 cb(SocketClientNewFromInternalPtr(ClientVarp), EventVarp, &SocketConnectableBase{Ptr: ConnectableVarp}, IOStreamNewFromInternalPtr(ConnectionVarp))
43 })
44 }
45}
46
47// GetEvent gets the "event" callback function.
48func (x *SocketClientClass) GetEvent() func(*SocketClient, SocketClientEvent, SocketConnectable, *IOStream) {
49 if x.xEvent == 0 {
50 return nil
51 }
52 var rawCallback func(ClientVarp uintptr, EventVarp SocketClientEvent, ConnectableVarp uintptr, ConnectionVarp uintptr)
53 purego.RegisterFunc(&rawCallback, x.xEvent)
54 return func(ClientVar *SocketClient, EventVar SocketClientEvent, ConnectableVar SocketConnectable, ConnectionVar *IOStream) {
55 rawCallback(ClientVar.GoPointer(), EventVar, ConnectableVar.GoPointer(), ConnectionVar.GoPointer())
56 }
57}
58
59// OverrideGReserved1 sets the "_g_reserved1" callback function.
60func (x *SocketClientClass) OverrideGReserved1(cb func()) {
61 if cb == nil {
62 x.xGReserved1 = 0
63 } else {
64 x.xGReserved1 = purego.NewCallback(func() {
65 cb()
66 })
67 }
68}
69
70// GetGReserved1 gets the "_g_reserved1" callback function.
71func (x *SocketClientClass) GetGReserved1() func() {
72 if x.xGReserved1 == 0 {
73 return nil
74 }
75 var rawCallback func()
76 purego.RegisterFunc(&rawCallback, x.xGReserved1)
77 return func() {
78 rawCallback()
79 }
80}
81
82// OverrideGReserved2 sets the "_g_reserved2" callback function.
83func (x *SocketClientClass) OverrideGReserved2(cb func()) {
84 if cb == nil {
85 x.xGReserved2 = 0
86 } else {
87 x.xGReserved2 = purego.NewCallback(func() {
88 cb()
89 })
90 }
91}
92
93// GetGReserved2 gets the "_g_reserved2" callback function.
94func (x *SocketClientClass) GetGReserved2() func() {
95 if x.xGReserved2 == 0 {
96 return nil
97 }
98 var rawCallback func()
99 purego.RegisterFunc(&rawCallback, x.xGReserved2)
100 return func() {
101 rawCallback()
102 }
103}
104
105// OverrideGReserved3 sets the "_g_reserved3" callback function.
106func (x *SocketClientClass) OverrideGReserved3(cb func()) {
107 if cb == nil {
108 x.xGReserved3 = 0
109 } else {
110 x.xGReserved3 = purego.NewCallback(func() {
111 cb()
112 })
113 }
114}
115
116// GetGReserved3 gets the "_g_reserved3" callback function.
117func (x *SocketClientClass) GetGReserved3() func() {
118 if x.xGReserved3 == 0 {
119 return nil
120 }
121 var rawCallback func()
122 purego.RegisterFunc(&rawCallback, x.xGReserved3)
123 return func() {
124 rawCallback()
125 }
126}
127
128// OverrideGReserved4 sets the "_g_reserved4" callback function.
129func (x *SocketClientClass) OverrideGReserved4(cb func()) {
130 if cb == nil {
131 x.xGReserved4 = 0
132 } else {
133 x.xGReserved4 = purego.NewCallback(func() {
134 cb()
135 })
136 }
137}
138
139// GetGReserved4 gets the "_g_reserved4" callback function.
140func (x *SocketClientClass) GetGReserved4() func() {
141 if x.xGReserved4 == 0 {
142 return nil
143 }
144 var rawCallback func()
145 purego.RegisterFunc(&rawCallback, x.xGReserved4)
146 return func() {
147 rawCallback()
148 }
149}
150
151type SocketClientPrivate struct {
152 _ structs.HostLayout
153}
154
155func (x *SocketClientPrivate) GoPointer() uintptr {
156 return uintptr(unsafe.Pointer(x))
157}
158
159// `GSocketClient` is a lightweight high-level utility class for connecting to
160// a network host using a connection oriented socket type.
161//
162// You create a `GSocketClient` object, set any options you want, and then
163// call a sync or async connect operation, which returns a
164// [class@Gio.SocketConnection] subclass on success.
165//
166// The type of the [class@Gio.SocketConnection] object returned depends on the
167// type of the underlying socket that is in use. For instance, for a TCP/IP
168// connection it will be a [class@Gio.TcpConnection].
169//
170// As `GSocketClient` is a lightweight object, you don't need to cache it. You
171// can just create a new one any time you need one.
172type SocketClient struct {
173 gobject.Object
174}
175
176var xSocketClientGLibType func() types.GType
177
178func SocketClientGLibType() types.GType {
179 return xSocketClientGLibType()
180}
181
182func SocketClientNewFromInternalPtr(ptr uintptr) *SocketClient {
183 cls := &SocketClient{}
184 cls.Ptr = ptr
185 return cls
186}
187
188var xNewSocketClient func() uintptr
189
190// Creates a new #GSocketClient with the default options.
191func NewSocketClient() *SocketClient {
192 var cls *SocketClient
193
194 cret := xNewSocketClient()
195
196 if cret == 0 {
197 return nil
198 }
199 cls = &SocketClient{}
200 cls.Ptr = cret
201 return cls
202}
203
204var xSocketClientAddApplicationProxy func(uintptr, string)
205
206// Enable proxy protocols to be handled by the application. When the
207// indicated proxy protocol is returned by the #GProxyResolver,
208// #GSocketClient will consider this protocol as supported but will
209// not try to find a #GProxy instance to handle handshaking. The
210// application must check for this case by calling
211// g_socket_connection_get_remote_address() on the returned
212// #GSocketConnection, and seeing if it's a #GProxyAddress of the
213// appropriate type, to determine whether or not it needs to handle
214// the proxy handshaking itself.
215//
216// This should be used for proxy protocols that are dialects of
217// another protocol such as HTTP proxy. It also allows cohabitation of
218// proxy protocols that are reused between protocols. A good example
219// is HTTP. It can be used to proxy HTTP, FTP and Gopher and can also
220// be use as generic socket proxy through the HTTP CONNECT method.
221//
222// When the proxy is detected as being an application proxy, TLS handshake
223// will be skipped. This is required to let the application do the proxy
224// specific handshake.
225func (x *SocketClient) AddApplicationProxy(ProtocolVar string) {
226
227 xSocketClientAddApplicationProxy(x.GoPointer(), ProtocolVar)
228
229}
230
231var xSocketClientConnect func(uintptr, uintptr, uintptr, **glib.Error) uintptr
232
233// Tries to resolve the @connectable and make a network connection to it.
234//
235// Upon a successful connection, a new #GSocketConnection is constructed
236// and returned. The caller owns this new object and must drop their
237// reference to it when finished with it.
238//
239// The type of the #GSocketConnection object returned depends on the type of
240// the underlying socket that is used. For instance, for a TCP/IP connection
241// it will be a #GTcpConnection.
242//
243// The socket created will be the same family as the address that the
244// @connectable resolves to, unless family is set with g_socket_client_set_family()
245// or indirectly via g_socket_client_set_local_address(). The socket type
246// defaults to %G_SOCKET_TYPE_STREAM but can be set with
247// g_socket_client_set_socket_type().
248//
249// If a local address is specified with g_socket_client_set_local_address() the
250// socket will be bound to this address before connecting.
251func (x *SocketClient) Connect(ConnectableVar SocketConnectable, CancellableVar *Cancellable) (*SocketConnection, error) {
252 var cls *SocketConnection
253 var cerr *glib.Error
254
255 cret := xSocketClientConnect(x.GoPointer(), ConnectableVar.GoPointer(), CancellableVar.GoPointer(), &cerr)
256
257 if cret == 0 {
258 return nil, cerr
259 }
260 cls = &SocketConnection{}
261 cls.Ptr = cret
262 if cerr == nil {
263 return cls, nil
264 }
265 return cls, cerr
266
267}
268
269var xSocketClientConnectAsync func(uintptr, uintptr, uintptr, uintptr, uintptr)
270
271// This is the asynchronous version of g_socket_client_connect().
272//
273// You may wish to prefer the asynchronous version even in synchronous
274// command line programs because, since 2.60, it implements
275// [RFC 8305](https://tools.ietf.org/html/rfc8305) "Happy Eyeballs"
276// recommendations to work around long connection timeouts in networks
277// where IPv6 is broken by performing an IPv4 connection simultaneously
278// without waiting for IPv6 to time out, which is not supported by the
279// synchronous call. (This is not an API guarantee, and may change in
280// the future.)
281//
282// When the operation is finished @callback will be
283// called. You can then call g_socket_client_connect_finish() to get
284// the result of the operation.
285func (x *SocketClient) ConnectAsync(ConnectableVar SocketConnectable, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
286
287 var CallbackVarRef uintptr
288 if CallbackVar != nil {
289 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
290 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
291 CallbackVarRef = cbRefPtr
292 } else {
293 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
294 cbFn := *CallbackVar
295 cbFn(arg0, arg1, arg2)
296 }
297 CallbackVarRef = purego.NewCallback(fcb)
298 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
299 }
300 }
301
302 xSocketClientConnectAsync(x.GoPointer(), ConnectableVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
303
304}
305
306var xSocketClientConnectFinish func(uintptr, uintptr, **glib.Error) uintptr
307
308// Finishes an async connect operation. See g_socket_client_connect_async()
309func (x *SocketClient) ConnectFinish(ResultVar AsyncResult) (*SocketConnection, error) {
310 var cls *SocketConnection
311 var cerr *glib.Error
312
313 cret := xSocketClientConnectFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
314
315 if cret == 0 {
316 return nil, cerr
317 }
318 cls = &SocketConnection{}
319 cls.Ptr = cret
320 if cerr == nil {
321 return cls, nil
322 }
323 return cls, cerr
324
325}
326
327var xSocketClientConnectToHost func(uintptr, string, uint16, uintptr, **glib.Error) uintptr
328
329// This is a helper function for g_socket_client_connect().
330//
331// Attempts to create a TCP connection to the named host.
332//
333// @host_and_port may be in any of a number of recognized formats; an IPv6
334// address, an IPv4 address, or a domain name (in which case a DNS
335// lookup is performed). Quoting with [] is supported for all address
336// types. A port override may be specified in the usual way with a
337// colon. Ports may be given as decimal numbers or symbolic names (in
338// which case an /etc/services lookup is performed).
339//
340// If no port override is given in @host_and_port then @default_port will be
341// used as the port number to connect to.
342//
343// In general, @host_and_port is expected to be provided by the user (allowing
344// them to give the hostname, and a port override if necessary) and
345// @default_port is expected to be provided by the application.
346//
347// In the case that an IP address is given, a single connection
348// attempt is made. In the case that a name is given, multiple
349// connection attempts may be made, in turn and according to the
350// number of address records in DNS, until a connection succeeds.
351//
352// Upon a successful connection, a new #GSocketConnection is constructed
353// and returned. The caller owns this new object and must drop their
354// reference to it when finished with it.
355//
356// In the event of any failure (DNS error, service not found, no hosts
357// connectable) %NULL is returned and @error (if non-%NULL) is set
358// accordingly.
359func (x *SocketClient) ConnectToHost(HostAndPortVar string, DefaultPortVar uint16, CancellableVar *Cancellable) (*SocketConnection, error) {
360 var cls *SocketConnection
361 var cerr *glib.Error
362
363 cret := xSocketClientConnectToHost(x.GoPointer(), HostAndPortVar, DefaultPortVar, CancellableVar.GoPointer(), &cerr)
364
365 if cret == 0 {
366 return nil, cerr
367 }
368 cls = &SocketConnection{}
369 cls.Ptr = cret
370 if cerr == nil {
371 return cls, nil
372 }
373 return cls, cerr
374
375}
376
377var xSocketClientConnectToHostAsync func(uintptr, string, uint16, uintptr, uintptr, uintptr)
378
379// This is the asynchronous version of g_socket_client_connect_to_host().
380//
381// When the operation is finished @callback will be
382// called. You can then call g_socket_client_connect_to_host_finish() to get
383// the result of the operation.
384func (x *SocketClient) ConnectToHostAsync(HostAndPortVar string, DefaultPortVar uint16, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
385
386 var CallbackVarRef uintptr
387 if CallbackVar != nil {
388 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
389 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
390 CallbackVarRef = cbRefPtr
391 } else {
392 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
393 cbFn := *CallbackVar
394 cbFn(arg0, arg1, arg2)
395 }
396 CallbackVarRef = purego.NewCallback(fcb)
397 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
398 }
399 }
400
401 xSocketClientConnectToHostAsync(x.GoPointer(), HostAndPortVar, DefaultPortVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
402
403}
404
405var xSocketClientConnectToHostFinish func(uintptr, uintptr, **glib.Error) uintptr
406
407// Finishes an async connect operation. See g_socket_client_connect_to_host_async()
408func (x *SocketClient) ConnectToHostFinish(ResultVar AsyncResult) (*SocketConnection, error) {
409 var cls *SocketConnection
410 var cerr *glib.Error
411
412 cret := xSocketClientConnectToHostFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
413
414 if cret == 0 {
415 return nil, cerr
416 }
417 cls = &SocketConnection{}
418 cls.Ptr = cret
419 if cerr == nil {
420 return cls, nil
421 }
422 return cls, cerr
423
424}
425
426var xSocketClientConnectToService func(uintptr, string, string, uintptr, **glib.Error) uintptr
427
428// Attempts to create a TCP connection to a service.
429//
430// This call looks up the SRV record for @service at @domain for the
431// "tcp" protocol. It then attempts to connect, in turn, to each of
432// the hosts providing the service until either a connection succeeds
433// or there are no hosts remaining.
434//
435// Upon a successful connection, a new #GSocketConnection is constructed
436// and returned. The caller owns this new object and must drop their
437// reference to it when finished with it.
438//
439// In the event of any failure (DNS error, service not found, no hosts
440// connectable) %NULL is returned and @error (if non-%NULL) is set
441// accordingly.
442func (x *SocketClient) ConnectToService(DomainVar string, ServiceVar string, CancellableVar *Cancellable) (*SocketConnection, error) {
443 var cls *SocketConnection
444 var cerr *glib.Error
445
446 cret := xSocketClientConnectToService(x.GoPointer(), DomainVar, ServiceVar, CancellableVar.GoPointer(), &cerr)
447
448 if cret == 0 {
449 return nil, cerr
450 }
451 cls = &SocketConnection{}
452 cls.Ptr = cret
453 if cerr == nil {
454 return cls, nil
455 }
456 return cls, cerr
457
458}
459
460var xSocketClientConnectToServiceAsync func(uintptr, string, string, uintptr, uintptr, uintptr)
461
462// This is the asynchronous version of
463// g_socket_client_connect_to_service().
464func (x *SocketClient) ConnectToServiceAsync(DomainVar string, ServiceVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
465
466 var CallbackVarRef uintptr
467 if CallbackVar != nil {
468 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
469 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
470 CallbackVarRef = cbRefPtr
471 } else {
472 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
473 cbFn := *CallbackVar
474 cbFn(arg0, arg1, arg2)
475 }
476 CallbackVarRef = purego.NewCallback(fcb)
477 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
478 }
479 }
480
481 xSocketClientConnectToServiceAsync(x.GoPointer(), DomainVar, ServiceVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
482
483}
484
485var xSocketClientConnectToServiceFinish func(uintptr, uintptr, **glib.Error) uintptr
486
487// Finishes an async connect operation. See g_socket_client_connect_to_service_async()
488func (x *SocketClient) ConnectToServiceFinish(ResultVar AsyncResult) (*SocketConnection, error) {
489 var cls *SocketConnection
490 var cerr *glib.Error
491
492 cret := xSocketClientConnectToServiceFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
493
494 if cret == 0 {
495 return nil, cerr
496 }
497 cls = &SocketConnection{}
498 cls.Ptr = cret
499 if cerr == nil {
500 return cls, nil
501 }
502 return cls, cerr
503
504}
505
506var xSocketClientConnectToUri func(uintptr, string, uint16, uintptr, **glib.Error) uintptr
507
508// This is a helper function for g_socket_client_connect().
509//
510// Attempts to create a TCP connection with a network URI.
511//
512// @uri may be any valid URI containing an "authority" (hostname/port)
513// component. If a port is not specified in the URI, @default_port
514// will be used. TLS will be negotiated if #GSocketClient:tls is %TRUE.
515// (#GSocketClient does not know to automatically assume TLS for
516// certain URI schemes.)
517//
518// Using this rather than g_socket_client_connect() or
519// g_socket_client_connect_to_host() allows #GSocketClient to
520// determine when to use application-specific proxy protocols.
521//
522// Upon a successful connection, a new #GSocketConnection is constructed
523// and returned. The caller owns this new object and must drop their
524// reference to it when finished with it.
525//
526// In the event of any failure (DNS error, service not found, no hosts
527// connectable) %NULL is returned and @error (if non-%NULL) is set
528// accordingly.
529func (x *SocketClient) ConnectToUri(UriVar string, DefaultPortVar uint16, CancellableVar *Cancellable) (*SocketConnection, error) {
530 var cls *SocketConnection
531 var cerr *glib.Error
532
533 cret := xSocketClientConnectToUri(x.GoPointer(), UriVar, DefaultPortVar, CancellableVar.GoPointer(), &cerr)
534
535 if cret == 0 {
536 return nil, cerr
537 }
538 cls = &SocketConnection{}
539 cls.Ptr = cret
540 if cerr == nil {
541 return cls, nil
542 }
543 return cls, cerr
544
545}
546
547var xSocketClientConnectToUriAsync func(uintptr, string, uint16, uintptr, uintptr, uintptr)
548
549// This is the asynchronous version of g_socket_client_connect_to_uri().
550//
551// When the operation is finished @callback will be
552// called. You can then call g_socket_client_connect_to_uri_finish() to get
553// the result of the operation.
554func (x *SocketClient) ConnectToUriAsync(UriVar string, DefaultPortVar uint16, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
555
556 var CallbackVarRef uintptr
557 if CallbackVar != nil {
558 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
559 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
560 CallbackVarRef = cbRefPtr
561 } else {
562 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
563 cbFn := *CallbackVar
564 cbFn(arg0, arg1, arg2)
565 }
566 CallbackVarRef = purego.NewCallback(fcb)
567 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
568 }
569 }
570
571 xSocketClientConnectToUriAsync(x.GoPointer(), UriVar, DefaultPortVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
572
573}
574
575var xSocketClientConnectToUriFinish func(uintptr, uintptr, **glib.Error) uintptr
576
577// Finishes an async connect operation. See g_socket_client_connect_to_uri_async()
578func (x *SocketClient) ConnectToUriFinish(ResultVar AsyncResult) (*SocketConnection, error) {
579 var cls *SocketConnection
580 var cerr *glib.Error
581
582 cret := xSocketClientConnectToUriFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
583
584 if cret == 0 {
585 return nil, cerr
586 }
587 cls = &SocketConnection{}
588 cls.Ptr = cret
589 if cerr == nil {
590 return cls, nil
591 }
592 return cls, cerr
593
594}
595
596var xSocketClientGetEnableProxy func(uintptr) bool
597
598// Gets the proxy enable state; see g_socket_client_set_enable_proxy()
599func (x *SocketClient) GetEnableProxy() bool {
600
601 cret := xSocketClientGetEnableProxy(x.GoPointer())
602 return cret
603}
604
605var xSocketClientGetFamily func(uintptr) SocketFamily
606
607// Gets the socket family of the socket client.
608//
609// See g_socket_client_set_family() for details.
610func (x *SocketClient) GetFamily() SocketFamily {
611
612 cret := xSocketClientGetFamily(x.GoPointer())
613 return cret
614}
615
616var xSocketClientGetLocalAddress func(uintptr) uintptr
617
618// Gets the local address of the socket client.
619//
620// See g_socket_client_set_local_address() for details.
621func (x *SocketClient) GetLocalAddress() *SocketAddress {
622 var cls *SocketAddress
623
624 cret := xSocketClientGetLocalAddress(x.GoPointer())
625
626 if cret == 0 {
627 return nil
628 }
629 gobject.IncreaseRef(cret)
630 cls = &SocketAddress{}
631 cls.Ptr = cret
632 return cls
633}
634
635var xSocketClientGetProtocol func(uintptr) SocketProtocol
636
637// Gets the protocol name type of the socket client.
638//
639// See g_socket_client_set_protocol() for details.
640func (x *SocketClient) GetProtocol() SocketProtocol {
641
642 cret := xSocketClientGetProtocol(x.GoPointer())
643 return cret
644}
645
646var xSocketClientGetProxyResolver func(uintptr) uintptr
647
648// Gets the #GProxyResolver being used by @client. Normally, this will
649// be the resolver returned by g_proxy_resolver_get_default(), but you
650// can override it with g_socket_client_set_proxy_resolver().
651func (x *SocketClient) GetProxyResolver() *ProxyResolverBase {
652 var cls *ProxyResolverBase
653
654 cret := xSocketClientGetProxyResolver(x.GoPointer())
655
656 if cret == 0 {
657 return nil
658 }
659 gobject.IncreaseRef(cret)
660 cls = &ProxyResolverBase{}
661 cls.Ptr = cret
662 return cls
663}
664
665var xSocketClientGetSocketType func(uintptr) SocketType
666
667// Gets the socket type of the socket client.
668//
669// See g_socket_client_set_socket_type() for details.
670func (x *SocketClient) GetSocketType() SocketType {
671
672 cret := xSocketClientGetSocketType(x.GoPointer())
673 return cret
674}
675
676var xSocketClientGetTimeout func(uintptr) uint
677
678// Gets the I/O timeout time for sockets created by @client.
679//
680// See g_socket_client_set_timeout() for details.
681func (x *SocketClient) GetTimeout() uint {
682
683 cret := xSocketClientGetTimeout(x.GoPointer())
684 return cret
685}
686
687var xSocketClientGetTls func(uintptr) bool
688
689// Gets whether @client creates TLS connections. See
690// g_socket_client_set_tls() for details.
691func (x *SocketClient) GetTls() bool {
692
693 cret := xSocketClientGetTls(x.GoPointer())
694 return cret
695}
696
697var xSocketClientGetTlsValidationFlags func(uintptr) TlsCertificateFlags
698
699// Gets the TLS validation flags used creating TLS connections via
700// @client.
701//
702// This function does not work as originally designed and is impossible
703// to use correctly. See #GSocketClient:tls-validation-flags for more
704// information.
705func (x *SocketClient) GetTlsValidationFlags() TlsCertificateFlags {
706
707 cret := xSocketClientGetTlsValidationFlags(x.GoPointer())
708 return cret
709}
710
711var xSocketClientSetEnableProxy func(uintptr, bool)
712
713// Sets whether or not @client attempts to make connections via a
714// proxy server. When enabled (the default), #GSocketClient will use a
715// #GProxyResolver to determine if a proxy protocol such as SOCKS is
716// needed, and automatically do the necessary proxy negotiation.
717//
718// See also g_socket_client_set_proxy_resolver().
719func (x *SocketClient) SetEnableProxy(EnableVar bool) {
720
721 xSocketClientSetEnableProxy(x.GoPointer(), EnableVar)
722
723}
724
725var xSocketClientSetFamily func(uintptr, SocketFamily)
726
727// Sets the socket family of the socket client.
728// If this is set to something other than %G_SOCKET_FAMILY_INVALID
729// then the sockets created by this object will be of the specified
730// family.
731//
732// This might be useful for instance if you want to force the local
733// connection to be an ipv4 socket, even though the address might
734// be an ipv6 mapped to ipv4 address.
735func (x *SocketClient) SetFamily(FamilyVar SocketFamily) {
736
737 xSocketClientSetFamily(x.GoPointer(), FamilyVar)
738
739}
740
741var xSocketClientSetLocalAddress func(uintptr, uintptr)
742
743// Sets the local address of the socket client.
744// The sockets created by this object will bound to the
745// specified address (if not %NULL) before connecting.
746//
747// This is useful if you want to ensure that the local
748// side of the connection is on a specific port, or on
749// a specific interface.
750func (x *SocketClient) SetLocalAddress(AddressVar *SocketAddress) {
751
752 xSocketClientSetLocalAddress(x.GoPointer(), AddressVar.GoPointer())
753
754}
755
756var xSocketClientSetProtocol func(uintptr, SocketProtocol)
757
758// Sets the protocol of the socket client.
759// The sockets created by this object will use of the specified
760// protocol.
761//
762// If @protocol is %G_SOCKET_PROTOCOL_DEFAULT that means to use the default
763// protocol for the socket family and type.
764func (x *SocketClient) SetProtocol(ProtocolVar SocketProtocol) {
765
766 xSocketClientSetProtocol(x.GoPointer(), ProtocolVar)
767
768}
769
770var xSocketClientSetProxyResolver func(uintptr, uintptr)
771
772// Overrides the #GProxyResolver used by @client. You can call this if
773// you want to use specific proxies, rather than using the system
774// default proxy settings.
775//
776// Note that whether or not the proxy resolver is actually used
777// depends on the setting of #GSocketClient:enable-proxy, which is not
778// changed by this function (but which is %TRUE by default)
779func (x *SocketClient) SetProxyResolver(ProxyResolverVar ProxyResolver) {
780
781 xSocketClientSetProxyResolver(x.GoPointer(), ProxyResolverVar.GoPointer())
782
783}
784
785var xSocketClientSetSocketType func(uintptr, SocketType)
786
787// Sets the socket type of the socket client.
788// The sockets created by this object will be of the specified
789// type.
790//
791// It doesn't make sense to specify a type of %G_SOCKET_TYPE_DATAGRAM,
792// as GSocketClient is used for connection oriented services.
793func (x *SocketClient) SetSocketType(TypeVar SocketType) {
794
795 xSocketClientSetSocketType(x.GoPointer(), TypeVar)
796
797}
798
799var xSocketClientSetTimeout func(uintptr, uint)
800
801// Sets the I/O timeout for sockets created by @client. @timeout is a
802// time in seconds, or 0 for no timeout (the default).
803//
804// The timeout value affects the initial connection attempt as well,
805// so setting this may cause calls to g_socket_client_connect(), etc,
806// to fail with %G_IO_ERROR_TIMED_OUT.
807func (x *SocketClient) SetTimeout(TimeoutVar uint) {
808
809 xSocketClientSetTimeout(x.GoPointer(), TimeoutVar)
810
811}
812
813var xSocketClientSetTls func(uintptr, bool)
814
815// Sets whether @client creates TLS (aka SSL) connections. If @tls is
816// %TRUE, @client will wrap its connections in a #GTlsClientConnection
817// and perform a TLS handshake when connecting.
818//
819// Note that since #GSocketClient must return a #GSocketConnection,
820// but #GTlsClientConnection is not a #GSocketConnection, this
821// actually wraps the resulting #GTlsClientConnection in a
822// #GTcpWrapperConnection when returning it. You can use
823// g_tcp_wrapper_connection_get_base_io_stream() on the return value
824// to extract the #GTlsClientConnection.
825//
826// If you need to modify the behavior of the TLS handshake (eg, by
827// setting a client-side certificate to use, or connecting to the
828// #GTlsConnection::accept-certificate signal), you can connect to
829// @client's #GSocketClient::event signal and wait for it to be
830// emitted with %G_SOCKET_CLIENT_TLS_HANDSHAKING, which will give you
831// a chance to see the #GTlsClientConnection before the handshake
832// starts.
833func (x *SocketClient) SetTls(TlsVar bool) {
834
835 xSocketClientSetTls(x.GoPointer(), TlsVar)
836
837}
838
839var xSocketClientSetTlsValidationFlags func(uintptr, TlsCertificateFlags)
840
841// Sets the TLS validation flags used when creating TLS connections
842// via @client. The default value is %G_TLS_CERTIFICATE_VALIDATE_ALL.
843//
844// This function does not work as originally designed and is impossible
845// to use correctly. See #GSocketClient:tls-validation-flags for more
846// information.
847func (x *SocketClient) SetTlsValidationFlags(FlagsVar TlsCertificateFlags) {
848
849 xSocketClientSetTlsValidationFlags(x.GoPointer(), FlagsVar)
850
851}
852
853func (c *SocketClient) GoPointer() uintptr {
854 if c == nil {
855 return 0
856 }
857 return c.Ptr
858}
859
860func (c *SocketClient) SetGoPointer(ptr uintptr) {
861 c.Ptr = ptr
862}
863
864// SetPropertyEnableProxy sets the "enable-proxy" property.
865// Enable proxy support.
866func (x *SocketClient) SetPropertyEnableProxy(value bool) {
867 var v gobject.Value
868 v.Init(gobject.TypeBooleanVal)
869 v.SetBoolean(value)
870 x.SetProperty("enable-proxy", &v)
871}
872
873// GetPropertyEnableProxy gets the "enable-proxy" property.
874// Enable proxy support.
875func (x *SocketClient) GetPropertyEnableProxy() bool {
876 var v gobject.Value
877 x.GetProperty("enable-proxy", &v)
878 return v.GetBoolean()
879}
880
881// SetPropertyTimeout sets the "timeout" property.
882// The I/O timeout for sockets, in seconds, or `0` for none.
883func (x *SocketClient) SetPropertyTimeout(value uint) {
884 var v gobject.Value
885 v.Init(gobject.TypeUintVal)
886 v.SetUint(value)
887 x.SetProperty("timeout", &v)
888}
889
890// GetPropertyTimeout gets the "timeout" property.
891// The I/O timeout for sockets, in seconds, or `0` for none.
892func (x *SocketClient) GetPropertyTimeout() uint {
893 var v gobject.Value
894 x.GetProperty("timeout", &v)
895 return v.GetUint()
896}
897
898// SetPropertyTls sets the "tls" property.
899// Whether to create TLS connections.
900func (x *SocketClient) SetPropertyTls(value bool) {
901 var v gobject.Value
902 v.Init(gobject.TypeBooleanVal)
903 v.SetBoolean(value)
904 x.SetProperty("tls", &v)
905}
906
907// GetPropertyTls gets the "tls" property.
908// Whether to create TLS connections.
909func (x *SocketClient) GetPropertyTls() bool {
910 var v gobject.Value
911 x.GetProperty("tls", &v)
912 return v.GetBoolean()
913}
914
915// Emitted when @client's activity on @connectable changes state.
916// Among other things, this can be used to provide progress
917// information about a network connection in the UI. The meanings of
918// the different @event values are as follows:
919//
920// - %G_SOCKET_CLIENT_RESOLVING: @client is about to look up @connectable
921// in DNS. @connection will be %NULL.
922//
923// - %G_SOCKET_CLIENT_RESOLVED: @client has successfully resolved
924// @connectable in DNS. @connection will be %NULL.
925//
926// - %G_SOCKET_CLIENT_CONNECTING: @client is about to make a connection
927// to a remote host; either a proxy server or the destination server
928// itself. @connection is the #GSocketConnection, which is not yet
929// connected. Since GLib 2.40, you can access the remote
930// address via g_socket_connection_get_remote_address().
931//
932// - %G_SOCKET_CLIENT_CONNECTED: @client has successfully connected
933// to a remote host. @connection is the connected #GSocketConnection.
934//
935// - %G_SOCKET_CLIENT_PROXY_NEGOTIATING: @client is about to negotiate
936// with a proxy to get it to connect to @connectable. @connection is
937// the #GSocketConnection to the proxy server.
938//
939// - %G_SOCKET_CLIENT_PROXY_NEGOTIATED: @client has negotiated a
940// connection to @connectable through a proxy server. @connection is
941// the stream returned from g_proxy_connect(), which may or may not
942// be a #GSocketConnection.
943//
944// - %G_SOCKET_CLIENT_TLS_HANDSHAKING: @client is about to begin a TLS
945// handshake. @connection is a #GTlsClientConnection.
946//
947// - %G_SOCKET_CLIENT_TLS_HANDSHAKED: @client has successfully completed
948// the TLS handshake. @connection is a #GTlsClientConnection.
949//
950// - %G_SOCKET_CLIENT_COMPLETE: @client has either successfully connected
951// to @connectable (in which case @connection is the #GSocketConnection
952// that it will be returning to the caller) or has failed (in which
953// case @connection is %NULL and the client is about to return an error).
954//
955// Each event except %G_SOCKET_CLIENT_COMPLETE may be emitted
956// multiple times (or not at all) for a given connectable (in
957// particular, if @client ends up attempting to connect to more than
958// one address). However, if @client emits the #GSocketClient::event
959// signal at all for a given connectable, then it will always emit
960// it with %G_SOCKET_CLIENT_COMPLETE when it is done.
961//
962// Note that there may be additional #GSocketClientEvent values in
963// the future; unrecognized @event values should be ignored.
964func (x *SocketClient) ConnectEvent(cb *func(SocketClient, SocketClientEvent, uintptr, uintptr)) uint {
965 cbPtr := uintptr(unsafe.Pointer(cb))
966 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
967 handlerID := gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr)
968 glib.SaveHandlerMapping(handlerID, cbPtr)
969 return handlerID
970 }
971
972 fcb := func(clsPtr uintptr, EventVarp SocketClientEvent, ConnectableVarp uintptr, ConnectionVarp uintptr) {
973 fa := SocketClient{}
974 fa.Ptr = clsPtr
975 cbFn := *cb
976
977 cbFn(fa, EventVarp, ConnectableVarp, ConnectionVarp)
978
979 }
980 cbRefPtr := purego.NewCallback(fcb)
981 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
982 handlerID := gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr)
983 glib.SaveHandlerMapping(handlerID, cbPtr)
984 return handlerID
985}
986
987func init() {
988 core.SetPackageName("GIO", "gio-2.0")
989 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
990 var libs []uintptr
991 for _, libPath := range core.GetPaths("GIO") {
992 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
993 if err != nil {
994 panic(err)
995 }
996 libs = append(libs, lib)
997 }
998
999 core.PuregoSafeRegister(&xSocketClientGLibType, libs, "g_socket_client_get_type")
1000
1001 core.PuregoSafeRegister(&xNewSocketClient, libs, "g_socket_client_new")
1002
1003 core.PuregoSafeRegister(&xSocketClientAddApplicationProxy, libs, "g_socket_client_add_application_proxy")
1004 core.PuregoSafeRegister(&xSocketClientConnect, libs, "g_socket_client_connect")
1005 core.PuregoSafeRegister(&xSocketClientConnectAsync, libs, "g_socket_client_connect_async")
1006 core.PuregoSafeRegister(&xSocketClientConnectFinish, libs, "g_socket_client_connect_finish")
1007 core.PuregoSafeRegister(&xSocketClientConnectToHost, libs, "g_socket_client_connect_to_host")
1008 core.PuregoSafeRegister(&xSocketClientConnectToHostAsync, libs, "g_socket_client_connect_to_host_async")
1009 core.PuregoSafeRegister(&xSocketClientConnectToHostFinish, libs, "g_socket_client_connect_to_host_finish")
1010 core.PuregoSafeRegister(&xSocketClientConnectToService, libs, "g_socket_client_connect_to_service")
1011 core.PuregoSafeRegister(&xSocketClientConnectToServiceAsync, libs, "g_socket_client_connect_to_service_async")
1012 core.PuregoSafeRegister(&xSocketClientConnectToServiceFinish, libs, "g_socket_client_connect_to_service_finish")
1013 core.PuregoSafeRegister(&xSocketClientConnectToUri, libs, "g_socket_client_connect_to_uri")
1014 core.PuregoSafeRegister(&xSocketClientConnectToUriAsync, libs, "g_socket_client_connect_to_uri_async")
1015 core.PuregoSafeRegister(&xSocketClientConnectToUriFinish, libs, "g_socket_client_connect_to_uri_finish")
1016 core.PuregoSafeRegister(&xSocketClientGetEnableProxy, libs, "g_socket_client_get_enable_proxy")
1017 core.PuregoSafeRegister(&xSocketClientGetFamily, libs, "g_socket_client_get_family")
1018 core.PuregoSafeRegister(&xSocketClientGetLocalAddress, libs, "g_socket_client_get_local_address")
1019 core.PuregoSafeRegister(&xSocketClientGetProtocol, libs, "g_socket_client_get_protocol")
1020 core.PuregoSafeRegister(&xSocketClientGetProxyResolver, libs, "g_socket_client_get_proxy_resolver")
1021 core.PuregoSafeRegister(&xSocketClientGetSocketType, libs, "g_socket_client_get_socket_type")
1022 core.PuregoSafeRegister(&xSocketClientGetTimeout, libs, "g_socket_client_get_timeout")
1023 core.PuregoSafeRegister(&xSocketClientGetTls, libs, "g_socket_client_get_tls")
1024 core.PuregoSafeRegister(&xSocketClientGetTlsValidationFlags, libs, "g_socket_client_get_tls_validation_flags")
1025 core.PuregoSafeRegister(&xSocketClientSetEnableProxy, libs, "g_socket_client_set_enable_proxy")
1026 core.PuregoSafeRegister(&xSocketClientSetFamily, libs, "g_socket_client_set_family")
1027 core.PuregoSafeRegister(&xSocketClientSetLocalAddress, libs, "g_socket_client_set_local_address")
1028 core.PuregoSafeRegister(&xSocketClientSetProtocol, libs, "g_socket_client_set_protocol")
1029 core.PuregoSafeRegister(&xSocketClientSetProxyResolver, libs, "g_socket_client_set_proxy_resolver")
1030 core.PuregoSafeRegister(&xSocketClientSetSocketType, libs, "g_socket_client_set_socket_type")
1031 core.PuregoSafeRegister(&xSocketClientSetTimeout, libs, "g_socket_client_set_timeout")
1032 core.PuregoSafeRegister(&xSocketClientSetTls, libs, "g_socket_client_set_tls")
1033 core.PuregoSafeRegister(&xSocketClientSetTlsValidationFlags, libs, "g_socket_client_set_tls_validation_flags")
1034
1035}