// 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" ) type SocketClientClass struct { _ structs.HostLayout ParentClass gobject.ObjectClass xEvent uintptr xGReserved1 uintptr xGReserved2 uintptr xGReserved3 uintptr xGReserved4 uintptr } func (x *SocketClientClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideEvent sets the "event" callback function. func (x *SocketClientClass) OverrideEvent(cb func(*SocketClient, SocketClientEvent, SocketConnectable, *IOStream)) { if cb == nil { x.xEvent = 0 } else { x.xEvent = purego.NewCallback(func(ClientVarp uintptr, EventVarp SocketClientEvent, ConnectableVarp uintptr, ConnectionVarp uintptr) { cb(SocketClientNewFromInternalPtr(ClientVarp), EventVarp, &SocketConnectableBase{Ptr: ConnectableVarp}, IOStreamNewFromInternalPtr(ConnectionVarp)) }) } } // GetEvent gets the "event" callback function. func (x *SocketClientClass) GetEvent() func(*SocketClient, SocketClientEvent, SocketConnectable, *IOStream) { if x.xEvent == 0 { return nil } var rawCallback func(ClientVarp uintptr, EventVarp SocketClientEvent, ConnectableVarp uintptr, ConnectionVarp uintptr) purego.RegisterFunc(&rawCallback, x.xEvent) return func(ClientVar *SocketClient, EventVar SocketClientEvent, ConnectableVar SocketConnectable, ConnectionVar *IOStream) { rawCallback(ClientVar.GoPointer(), EventVar, ConnectableVar.GoPointer(), ConnectionVar.GoPointer()) } } // OverrideGReserved1 sets the "_g_reserved1" callback function. func (x *SocketClientClass) OverrideGReserved1(cb func()) { if cb == nil { x.xGReserved1 = 0 } else { x.xGReserved1 = purego.NewCallback(func() { cb() }) } } // GetGReserved1 gets the "_g_reserved1" callback function. func (x *SocketClientClass) GetGReserved1() func() { if x.xGReserved1 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved1) return func() { rawCallback() } } // OverrideGReserved2 sets the "_g_reserved2" callback function. func (x *SocketClientClass) OverrideGReserved2(cb func()) { if cb == nil { x.xGReserved2 = 0 } else { x.xGReserved2 = purego.NewCallback(func() { cb() }) } } // GetGReserved2 gets the "_g_reserved2" callback function. func (x *SocketClientClass) GetGReserved2() func() { if x.xGReserved2 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved2) return func() { rawCallback() } } // OverrideGReserved3 sets the "_g_reserved3" callback function. func (x *SocketClientClass) OverrideGReserved3(cb func()) { if cb == nil { x.xGReserved3 = 0 } else { x.xGReserved3 = purego.NewCallback(func() { cb() }) } } // GetGReserved3 gets the "_g_reserved3" callback function. func (x *SocketClientClass) GetGReserved3() func() { if x.xGReserved3 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved3) return func() { rawCallback() } } // OverrideGReserved4 sets the "_g_reserved4" callback function. func (x *SocketClientClass) OverrideGReserved4(cb func()) { if cb == nil { x.xGReserved4 = 0 } else { x.xGReserved4 = purego.NewCallback(func() { cb() }) } } // GetGReserved4 gets the "_g_reserved4" callback function. func (x *SocketClientClass) GetGReserved4() func() { if x.xGReserved4 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved4) return func() { rawCallback() } } type SocketClientPrivate struct { _ structs.HostLayout } func (x *SocketClientPrivate) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // `GSocketClient` is a lightweight high-level utility class for connecting to // a network host using a connection oriented socket type. // // You create a `GSocketClient` object, set any options you want, and then // call a sync or async connect operation, which returns a // [class@Gio.SocketConnection] subclass on success. // // The type of the [class@Gio.SocketConnection] object returned depends on the // type of the underlying socket that is in use. For instance, for a TCP/IP // connection it will be a [class@Gio.TcpConnection]. // // As `GSocketClient` is a lightweight object, you don't need to cache it. You // can just create a new one any time you need one. type SocketClient struct { gobject.Object } var xSocketClientGLibType func() types.GType func SocketClientGLibType() types.GType { return xSocketClientGLibType() } func SocketClientNewFromInternalPtr(ptr uintptr) *SocketClient { cls := &SocketClient{} cls.Ptr = ptr return cls } var xNewSocketClient func() uintptr // Creates a new #GSocketClient with the default options. func NewSocketClient() *SocketClient { var cls *SocketClient cret := xNewSocketClient() if cret == 0 { return nil } cls = &SocketClient{} cls.Ptr = cret return cls } var xSocketClientAddApplicationProxy func(uintptr, string) // Enable proxy protocols to be handled by the application. When the // indicated proxy protocol is returned by the #GProxyResolver, // #GSocketClient will consider this protocol as supported but will // not try to find a #GProxy instance to handle handshaking. The // application must check for this case by calling // g_socket_connection_get_remote_address() on the returned // #GSocketConnection, and seeing if it's a #GProxyAddress of the // appropriate type, to determine whether or not it needs to handle // the proxy handshaking itself. // // This should be used for proxy protocols that are dialects of // another protocol such as HTTP proxy. It also allows cohabitation of // proxy protocols that are reused between protocols. A good example // is HTTP. It can be used to proxy HTTP, FTP and Gopher and can also // be use as generic socket proxy through the HTTP CONNECT method. // // When the proxy is detected as being an application proxy, TLS handshake // will be skipped. This is required to let the application do the proxy // specific handshake. func (x *SocketClient) AddApplicationProxy(ProtocolVar string) { xSocketClientAddApplicationProxy(x.GoPointer(), ProtocolVar) } var xSocketClientConnect func(uintptr, uintptr, uintptr, **glib.Error) uintptr // Tries to resolve the @connectable and make a network connection to it. // // Upon a successful connection, a new #GSocketConnection is constructed // and returned. The caller owns this new object and must drop their // reference to it when finished with it. // // The type of the #GSocketConnection object returned depends on the type of // the underlying socket that is used. For instance, for a TCP/IP connection // it will be a #GTcpConnection. // // The socket created will be the same family as the address that the // @connectable resolves to, unless family is set with g_socket_client_set_family() // or indirectly via g_socket_client_set_local_address(). The socket type // defaults to %G_SOCKET_TYPE_STREAM but can be set with // g_socket_client_set_socket_type(). // // If a local address is specified with g_socket_client_set_local_address() the // socket will be bound to this address before connecting. func (x *SocketClient) Connect(ConnectableVar SocketConnectable, CancellableVar *Cancellable) (*SocketConnection, error) { var cls *SocketConnection var cerr *glib.Error cret := xSocketClientConnect(x.GoPointer(), ConnectableVar.GoPointer(), CancellableVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &SocketConnection{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketClientConnectAsync func(uintptr, uintptr, uintptr, uintptr, uintptr) // This is the asynchronous version of g_socket_client_connect(). // // You may wish to prefer the asynchronous version even in synchronous // command line programs because, since 2.60, it implements // [RFC 8305](https://tools.ietf.org/html/rfc8305) "Happy Eyeballs" // recommendations to work around long connection timeouts in networks // where IPv6 is broken by performing an IPv4 connection simultaneously // without waiting for IPv6 to time out, which is not supported by the // synchronous call. (This is not an API guarantee, and may change in // the future.) // // When the operation is finished @callback will be // called. You can then call g_socket_client_connect_finish() to get // the result of the operation. func (x *SocketClient) ConnectAsync(ConnectableVar SocketConnectable, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xSocketClientConnectAsync(x.GoPointer(), ConnectableVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xSocketClientConnectFinish func(uintptr, uintptr, **glib.Error) uintptr // Finishes an async connect operation. See g_socket_client_connect_async() func (x *SocketClient) ConnectFinish(ResultVar AsyncResult) (*SocketConnection, error) { var cls *SocketConnection var cerr *glib.Error cret := xSocketClientConnectFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &SocketConnection{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketClientConnectToHost func(uintptr, string, uint16, uintptr, **glib.Error) uintptr // This is a helper function for g_socket_client_connect(). // // Attempts to create a TCP connection to the named host. // // @host_and_port may be in any of a number of recognized formats; an IPv6 // address, an IPv4 address, or a domain name (in which case a DNS // lookup is performed). Quoting with [] is supported for all address // types. A port override may be specified in the usual way with a // colon. Ports may be given as decimal numbers or symbolic names (in // which case an /etc/services lookup is performed). // // If no port override is given in @host_and_port then @default_port will be // used as the port number to connect to. // // In general, @host_and_port is expected to be provided by the user (allowing // them to give the hostname, and a port override if necessary) and // @default_port is expected to be provided by the application. // // In the case that an IP address is given, a single connection // attempt is made. In the case that a name is given, multiple // connection attempts may be made, in turn and according to the // number of address records in DNS, until a connection succeeds. // // Upon a successful connection, a new #GSocketConnection is constructed // and returned. The caller owns this new object and must drop their // reference to it when finished with it. // // In the event of any failure (DNS error, service not found, no hosts // connectable) %NULL is returned and @error (if non-%NULL) is set // accordingly. func (x *SocketClient) ConnectToHost(HostAndPortVar string, DefaultPortVar uint16, CancellableVar *Cancellable) (*SocketConnection, error) { var cls *SocketConnection var cerr *glib.Error cret := xSocketClientConnectToHost(x.GoPointer(), HostAndPortVar, DefaultPortVar, CancellableVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &SocketConnection{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketClientConnectToHostAsync func(uintptr, string, uint16, uintptr, uintptr, uintptr) // This is the asynchronous version of g_socket_client_connect_to_host(). // // When the operation is finished @callback will be // called. You can then call g_socket_client_connect_to_host_finish() to get // the result of the operation. func (x *SocketClient) ConnectToHostAsync(HostAndPortVar string, DefaultPortVar uint16, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xSocketClientConnectToHostAsync(x.GoPointer(), HostAndPortVar, DefaultPortVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xSocketClientConnectToHostFinish func(uintptr, uintptr, **glib.Error) uintptr // Finishes an async connect operation. See g_socket_client_connect_to_host_async() func (x *SocketClient) ConnectToHostFinish(ResultVar AsyncResult) (*SocketConnection, error) { var cls *SocketConnection var cerr *glib.Error cret := xSocketClientConnectToHostFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &SocketConnection{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketClientConnectToService func(uintptr, string, string, uintptr, **glib.Error) uintptr // Attempts to create a TCP connection to a service. // // This call looks up the SRV record for @service at @domain for the // "tcp" protocol. It then attempts to connect, in turn, to each of // the hosts providing the service until either a connection succeeds // or there are no hosts remaining. // // Upon a successful connection, a new #GSocketConnection is constructed // and returned. The caller owns this new object and must drop their // reference to it when finished with it. // // In the event of any failure (DNS error, service not found, no hosts // connectable) %NULL is returned and @error (if non-%NULL) is set // accordingly. func (x *SocketClient) ConnectToService(DomainVar string, ServiceVar string, CancellableVar *Cancellable) (*SocketConnection, error) { var cls *SocketConnection var cerr *glib.Error cret := xSocketClientConnectToService(x.GoPointer(), DomainVar, ServiceVar, CancellableVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &SocketConnection{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketClientConnectToServiceAsync func(uintptr, string, string, uintptr, uintptr, uintptr) // This is the asynchronous version of // g_socket_client_connect_to_service(). func (x *SocketClient) ConnectToServiceAsync(DomainVar string, ServiceVar string, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xSocketClientConnectToServiceAsync(x.GoPointer(), DomainVar, ServiceVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xSocketClientConnectToServiceFinish func(uintptr, uintptr, **glib.Error) uintptr // Finishes an async connect operation. See g_socket_client_connect_to_service_async() func (x *SocketClient) ConnectToServiceFinish(ResultVar AsyncResult) (*SocketConnection, error) { var cls *SocketConnection var cerr *glib.Error cret := xSocketClientConnectToServiceFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &SocketConnection{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketClientConnectToUri func(uintptr, string, uint16, uintptr, **glib.Error) uintptr // This is a helper function for g_socket_client_connect(). // // Attempts to create a TCP connection with a network URI. // // @uri may be any valid URI containing an "authority" (hostname/port) // component. If a port is not specified in the URI, @default_port // will be used. TLS will be negotiated if #GSocketClient:tls is %TRUE. // (#GSocketClient does not know to automatically assume TLS for // certain URI schemes.) // // Using this rather than g_socket_client_connect() or // g_socket_client_connect_to_host() allows #GSocketClient to // determine when to use application-specific proxy protocols. // // Upon a successful connection, a new #GSocketConnection is constructed // and returned. The caller owns this new object and must drop their // reference to it when finished with it. // // In the event of any failure (DNS error, service not found, no hosts // connectable) %NULL is returned and @error (if non-%NULL) is set // accordingly. func (x *SocketClient) ConnectToUri(UriVar string, DefaultPortVar uint16, CancellableVar *Cancellable) (*SocketConnection, error) { var cls *SocketConnection var cerr *glib.Error cret := xSocketClientConnectToUri(x.GoPointer(), UriVar, DefaultPortVar, CancellableVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &SocketConnection{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketClientConnectToUriAsync func(uintptr, string, uint16, uintptr, uintptr, uintptr) // This is the asynchronous version of g_socket_client_connect_to_uri(). // // When the operation is finished @callback will be // called. You can then call g_socket_client_connect_to_uri_finish() to get // the result of the operation. func (x *SocketClient) ConnectToUriAsync(UriVar string, DefaultPortVar uint16, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xSocketClientConnectToUriAsync(x.GoPointer(), UriVar, DefaultPortVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xSocketClientConnectToUriFinish func(uintptr, uintptr, **glib.Error) uintptr // Finishes an async connect operation. See g_socket_client_connect_to_uri_async() func (x *SocketClient) ConnectToUriFinish(ResultVar AsyncResult) (*SocketConnection, error) { var cls *SocketConnection var cerr *glib.Error cret := xSocketClientConnectToUriFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cret == 0 { return nil, cerr } cls = &SocketConnection{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketClientGetEnableProxy func(uintptr) bool // Gets the proxy enable state; see g_socket_client_set_enable_proxy() func (x *SocketClient) GetEnableProxy() bool { cret := xSocketClientGetEnableProxy(x.GoPointer()) return cret } var xSocketClientGetFamily func(uintptr) SocketFamily // Gets the socket family of the socket client. // // See g_socket_client_set_family() for details. func (x *SocketClient) GetFamily() SocketFamily { cret := xSocketClientGetFamily(x.GoPointer()) return cret } var xSocketClientGetLocalAddress func(uintptr) uintptr // Gets the local address of the socket client. // // See g_socket_client_set_local_address() for details. func (x *SocketClient) GetLocalAddress() *SocketAddress { var cls *SocketAddress cret := xSocketClientGetLocalAddress(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &SocketAddress{} cls.Ptr = cret return cls } var xSocketClientGetProtocol func(uintptr) SocketProtocol // Gets the protocol name type of the socket client. // // See g_socket_client_set_protocol() for details. func (x *SocketClient) GetProtocol() SocketProtocol { cret := xSocketClientGetProtocol(x.GoPointer()) return cret } var xSocketClientGetProxyResolver func(uintptr) uintptr // Gets the #GProxyResolver being used by @client. Normally, this will // be the resolver returned by g_proxy_resolver_get_default(), but you // can override it with g_socket_client_set_proxy_resolver(). func (x *SocketClient) GetProxyResolver() *ProxyResolverBase { var cls *ProxyResolverBase cret := xSocketClientGetProxyResolver(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &ProxyResolverBase{} cls.Ptr = cret return cls } var xSocketClientGetSocketType func(uintptr) SocketType // Gets the socket type of the socket client. // // See g_socket_client_set_socket_type() for details. func (x *SocketClient) GetSocketType() SocketType { cret := xSocketClientGetSocketType(x.GoPointer()) return cret } var xSocketClientGetTimeout func(uintptr) uint // Gets the I/O timeout time for sockets created by @client. // // See g_socket_client_set_timeout() for details. func (x *SocketClient) GetTimeout() uint { cret := xSocketClientGetTimeout(x.GoPointer()) return cret } var xSocketClientGetTls func(uintptr) bool // Gets whether @client creates TLS connections. See // g_socket_client_set_tls() for details. func (x *SocketClient) GetTls() bool { cret := xSocketClientGetTls(x.GoPointer()) return cret } var xSocketClientGetTlsValidationFlags func(uintptr) TlsCertificateFlags // Gets the TLS validation flags used creating TLS connections via // @client. // // This function does not work as originally designed and is impossible // to use correctly. See #GSocketClient:tls-validation-flags for more // information. func (x *SocketClient) GetTlsValidationFlags() TlsCertificateFlags { cret := xSocketClientGetTlsValidationFlags(x.GoPointer()) return cret } var xSocketClientSetEnableProxy func(uintptr, bool) // Sets whether or not @client attempts to make connections via a // proxy server. When enabled (the default), #GSocketClient will use a // #GProxyResolver to determine if a proxy protocol such as SOCKS is // needed, and automatically do the necessary proxy negotiation. // // See also g_socket_client_set_proxy_resolver(). func (x *SocketClient) SetEnableProxy(EnableVar bool) { xSocketClientSetEnableProxy(x.GoPointer(), EnableVar) } var xSocketClientSetFamily func(uintptr, SocketFamily) // Sets the socket family of the socket client. // If this is set to something other than %G_SOCKET_FAMILY_INVALID // then the sockets created by this object will be of the specified // family. // // This might be useful for instance if you want to force the local // connection to be an ipv4 socket, even though the address might // be an ipv6 mapped to ipv4 address. func (x *SocketClient) SetFamily(FamilyVar SocketFamily) { xSocketClientSetFamily(x.GoPointer(), FamilyVar) } var xSocketClientSetLocalAddress func(uintptr, uintptr) // Sets the local address of the socket client. // The sockets created by this object will bound to the // specified address (if not %NULL) before connecting. // // This is useful if you want to ensure that the local // side of the connection is on a specific port, or on // a specific interface. func (x *SocketClient) SetLocalAddress(AddressVar *SocketAddress) { xSocketClientSetLocalAddress(x.GoPointer(), AddressVar.GoPointer()) } var xSocketClientSetProtocol func(uintptr, SocketProtocol) // Sets the protocol of the socket client. // The sockets created by this object will use of the specified // protocol. // // If @protocol is %G_SOCKET_PROTOCOL_DEFAULT that means to use the default // protocol for the socket family and type. func (x *SocketClient) SetProtocol(ProtocolVar SocketProtocol) { xSocketClientSetProtocol(x.GoPointer(), ProtocolVar) } var xSocketClientSetProxyResolver func(uintptr, uintptr) // Overrides the #GProxyResolver used by @client. You can call this if // you want to use specific proxies, rather than using the system // default proxy settings. // // Note that whether or not the proxy resolver is actually used // depends on the setting of #GSocketClient:enable-proxy, which is not // changed by this function (but which is %TRUE by default) func (x *SocketClient) SetProxyResolver(ProxyResolverVar ProxyResolver) { xSocketClientSetProxyResolver(x.GoPointer(), ProxyResolverVar.GoPointer()) } var xSocketClientSetSocketType func(uintptr, SocketType) // Sets the socket type of the socket client. // The sockets created by this object will be of the specified // type. // // It doesn't make sense to specify a type of %G_SOCKET_TYPE_DATAGRAM, // as GSocketClient is used for connection oriented services. func (x *SocketClient) SetSocketType(TypeVar SocketType) { xSocketClientSetSocketType(x.GoPointer(), TypeVar) } var xSocketClientSetTimeout func(uintptr, uint) // Sets the I/O timeout for sockets created by @client. @timeout is a // time in seconds, or 0 for no timeout (the default). // // The timeout value affects the initial connection attempt as well, // so setting this may cause calls to g_socket_client_connect(), etc, // to fail with %G_IO_ERROR_TIMED_OUT. func (x *SocketClient) SetTimeout(TimeoutVar uint) { xSocketClientSetTimeout(x.GoPointer(), TimeoutVar) } var xSocketClientSetTls func(uintptr, bool) // Sets whether @client creates TLS (aka SSL) connections. If @tls is // %TRUE, @client will wrap its connections in a #GTlsClientConnection // and perform a TLS handshake when connecting. // // Note that since #GSocketClient must return a #GSocketConnection, // but #GTlsClientConnection is not a #GSocketConnection, this // actually wraps the resulting #GTlsClientConnection in a // #GTcpWrapperConnection when returning it. You can use // g_tcp_wrapper_connection_get_base_io_stream() on the return value // to extract the #GTlsClientConnection. // // If you need to modify the behavior of the TLS handshake (eg, by // setting a client-side certificate to use, or connecting to the // #GTlsConnection::accept-certificate signal), you can connect to // @client's #GSocketClient::event signal and wait for it to be // emitted with %G_SOCKET_CLIENT_TLS_HANDSHAKING, which will give you // a chance to see the #GTlsClientConnection before the handshake // starts. func (x *SocketClient) SetTls(TlsVar bool) { xSocketClientSetTls(x.GoPointer(), TlsVar) } var xSocketClientSetTlsValidationFlags func(uintptr, TlsCertificateFlags) // Sets the TLS validation flags used when creating TLS connections // via @client. The default value is %G_TLS_CERTIFICATE_VALIDATE_ALL. // // This function does not work as originally designed and is impossible // to use correctly. See #GSocketClient:tls-validation-flags for more // information. func (x *SocketClient) SetTlsValidationFlags(FlagsVar TlsCertificateFlags) { xSocketClientSetTlsValidationFlags(x.GoPointer(), FlagsVar) } func (c *SocketClient) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *SocketClient) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyEnableProxy sets the "enable-proxy" property. // Enable proxy support. func (x *SocketClient) SetPropertyEnableProxy(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("enable-proxy", &v) } // GetPropertyEnableProxy gets the "enable-proxy" property. // Enable proxy support. func (x *SocketClient) GetPropertyEnableProxy() bool { var v gobject.Value x.GetProperty("enable-proxy", &v) return v.GetBoolean() } // SetPropertyTimeout sets the "timeout" property. // The I/O timeout for sockets, in seconds, or `0` for none. func (x *SocketClient) SetPropertyTimeout(value uint) { var v gobject.Value v.Init(gobject.TypeUintVal) v.SetUint(value) x.SetProperty("timeout", &v) } // GetPropertyTimeout gets the "timeout" property. // The I/O timeout for sockets, in seconds, or `0` for none. func (x *SocketClient) GetPropertyTimeout() uint { var v gobject.Value x.GetProperty("timeout", &v) return v.GetUint() } // SetPropertyTls sets the "tls" property. // Whether to create TLS connections. func (x *SocketClient) SetPropertyTls(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("tls", &v) } // GetPropertyTls gets the "tls" property. // Whether to create TLS connections. func (x *SocketClient) GetPropertyTls() bool { var v gobject.Value x.GetProperty("tls", &v) return v.GetBoolean() } // Emitted when @client's activity on @connectable changes state. // Among other things, this can be used to provide progress // information about a network connection in the UI. The meanings of // the different @event values are as follows: // // - %G_SOCKET_CLIENT_RESOLVING: @client is about to look up @connectable // in DNS. @connection will be %NULL. // // - %G_SOCKET_CLIENT_RESOLVED: @client has successfully resolved // @connectable in DNS. @connection will be %NULL. // // - %G_SOCKET_CLIENT_CONNECTING: @client is about to make a connection // to a remote host; either a proxy server or the destination server // itself. @connection is the #GSocketConnection, which is not yet // connected. Since GLib 2.40, you can access the remote // address via g_socket_connection_get_remote_address(). // // - %G_SOCKET_CLIENT_CONNECTED: @client has successfully connected // to a remote host. @connection is the connected #GSocketConnection. // // - %G_SOCKET_CLIENT_PROXY_NEGOTIATING: @client is about to negotiate // with a proxy to get it to connect to @connectable. @connection is // the #GSocketConnection to the proxy server. // // - %G_SOCKET_CLIENT_PROXY_NEGOTIATED: @client has negotiated a // connection to @connectable through a proxy server. @connection is // the stream returned from g_proxy_connect(), which may or may not // be a #GSocketConnection. // // - %G_SOCKET_CLIENT_TLS_HANDSHAKING: @client is about to begin a TLS // handshake. @connection is a #GTlsClientConnection. // // - %G_SOCKET_CLIENT_TLS_HANDSHAKED: @client has successfully completed // the TLS handshake. @connection is a #GTlsClientConnection. // // - %G_SOCKET_CLIENT_COMPLETE: @client has either successfully connected // to @connectable (in which case @connection is the #GSocketConnection // that it will be returning to the caller) or has failed (in which // case @connection is %NULL and the client is about to return an error). // // Each event except %G_SOCKET_CLIENT_COMPLETE may be emitted // multiple times (or not at all) for a given connectable (in // particular, if @client ends up attempting to connect to more than // one address). However, if @client emits the #GSocketClient::event // signal at all for a given connectable, then it will always emit // it with %G_SOCKET_CLIENT_COMPLETE when it is done. // // Note that there may be additional #GSocketClientEvent values in // the future; unrecognized @event values should be ignored. func (x *SocketClient) ConnectEvent(cb *func(SocketClient, SocketClientEvent, uintptr, uintptr)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, EventVarp SocketClientEvent, ConnectableVarp uintptr, ConnectionVarp uintptr) { fa := SocketClient{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, EventVarp, ConnectableVarp, ConnectionVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "event", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } 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(&xSocketClientGLibType, libs, "g_socket_client_get_type") core.PuregoSafeRegister(&xNewSocketClient, libs, "g_socket_client_new") core.PuregoSafeRegister(&xSocketClientAddApplicationProxy, libs, "g_socket_client_add_application_proxy") core.PuregoSafeRegister(&xSocketClientConnect, libs, "g_socket_client_connect") core.PuregoSafeRegister(&xSocketClientConnectAsync, libs, "g_socket_client_connect_async") core.PuregoSafeRegister(&xSocketClientConnectFinish, libs, "g_socket_client_connect_finish") core.PuregoSafeRegister(&xSocketClientConnectToHost, libs, "g_socket_client_connect_to_host") core.PuregoSafeRegister(&xSocketClientConnectToHostAsync, libs, "g_socket_client_connect_to_host_async") core.PuregoSafeRegister(&xSocketClientConnectToHostFinish, libs, "g_socket_client_connect_to_host_finish") core.PuregoSafeRegister(&xSocketClientConnectToService, libs, "g_socket_client_connect_to_service") core.PuregoSafeRegister(&xSocketClientConnectToServiceAsync, libs, "g_socket_client_connect_to_service_async") core.PuregoSafeRegister(&xSocketClientConnectToServiceFinish, libs, "g_socket_client_connect_to_service_finish") core.PuregoSafeRegister(&xSocketClientConnectToUri, libs, "g_socket_client_connect_to_uri") core.PuregoSafeRegister(&xSocketClientConnectToUriAsync, libs, "g_socket_client_connect_to_uri_async") core.PuregoSafeRegister(&xSocketClientConnectToUriFinish, libs, "g_socket_client_connect_to_uri_finish") core.PuregoSafeRegister(&xSocketClientGetEnableProxy, libs, "g_socket_client_get_enable_proxy") core.PuregoSafeRegister(&xSocketClientGetFamily, libs, "g_socket_client_get_family") core.PuregoSafeRegister(&xSocketClientGetLocalAddress, libs, "g_socket_client_get_local_address") core.PuregoSafeRegister(&xSocketClientGetProtocol, libs, "g_socket_client_get_protocol") core.PuregoSafeRegister(&xSocketClientGetProxyResolver, libs, "g_socket_client_get_proxy_resolver") core.PuregoSafeRegister(&xSocketClientGetSocketType, libs, "g_socket_client_get_socket_type") core.PuregoSafeRegister(&xSocketClientGetTimeout, libs, "g_socket_client_get_timeout") core.PuregoSafeRegister(&xSocketClientGetTls, libs, "g_socket_client_get_tls") core.PuregoSafeRegister(&xSocketClientGetTlsValidationFlags, libs, "g_socket_client_get_tls_validation_flags") core.PuregoSafeRegister(&xSocketClientSetEnableProxy, libs, "g_socket_client_set_enable_proxy") core.PuregoSafeRegister(&xSocketClientSetFamily, libs, "g_socket_client_set_family") core.PuregoSafeRegister(&xSocketClientSetLocalAddress, libs, "g_socket_client_set_local_address") core.PuregoSafeRegister(&xSocketClientSetProtocol, libs, "g_socket_client_set_protocol") core.PuregoSafeRegister(&xSocketClientSetProxyResolver, libs, "g_socket_client_set_proxy_resolver") core.PuregoSafeRegister(&xSocketClientSetSocketType, libs, "g_socket_client_set_socket_type") core.PuregoSafeRegister(&xSocketClientSetTimeout, libs, "g_socket_client_set_timeout") core.PuregoSafeRegister(&xSocketClientSetTls, libs, "g_socket_client_set_tls") core.PuregoSafeRegister(&xSocketClientSetTlsValidationFlags, libs, "g_socket_client_set_tls_validation_flags") }