// 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 SocketConnectionClass struct { _ structs.HostLayout ParentClass IOStreamClass xGReserved1 uintptr xGReserved2 uintptr xGReserved3 uintptr xGReserved4 uintptr xGReserved5 uintptr xGReserved6 uintptr } func (x *SocketConnectionClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideGReserved1 sets the "_g_reserved1" callback function. func (x *SocketConnectionClass) 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 *SocketConnectionClass) 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 *SocketConnectionClass) 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 *SocketConnectionClass) 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 *SocketConnectionClass) 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 *SocketConnectionClass) 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 *SocketConnectionClass) 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 *SocketConnectionClass) GetGReserved4() func() { if x.xGReserved4 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved4) return func() { rawCallback() } } // OverrideGReserved5 sets the "_g_reserved5" callback function. func (x *SocketConnectionClass) OverrideGReserved5(cb func()) { if cb == nil { x.xGReserved5 = 0 } else { x.xGReserved5 = purego.NewCallback(func() { cb() }) } } // GetGReserved5 gets the "_g_reserved5" callback function. func (x *SocketConnectionClass) GetGReserved5() func() { if x.xGReserved5 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved5) return func() { rawCallback() } } // OverrideGReserved6 sets the "_g_reserved6" callback function. func (x *SocketConnectionClass) OverrideGReserved6(cb func()) { if cb == nil { x.xGReserved6 = 0 } else { x.xGReserved6 = purego.NewCallback(func() { cb() }) } } // GetGReserved6 gets the "_g_reserved6" callback function. func (x *SocketConnectionClass) GetGReserved6() func() { if x.xGReserved6 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved6) return func() { rawCallback() } } type SocketConnectionPrivate struct { _ structs.HostLayout } func (x *SocketConnectionPrivate) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // `GSocketConnection` is a [class@Gio.IOStream] for a connected socket. They // can be created either by [class@Gio.SocketClient] when connecting to a host, // or by [class@Gio.SocketListener] when accepting a new client. // // The type of the `GSocketConnection` object returned from these calls // 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]. // // Choosing what type of object to construct is done with the socket // connection factory, and it is possible for third parties to register // custom socket connection types for specific combination of socket // family/type/protocol using [func@Gio.SocketConnection.factory_register_type]. // // To close a `GSocketConnection`, use [method@Gio.IOStream.close]. Closing both // substreams of the [class@Gio.IOStream] separately will not close the // underlying [class@Gio.Socket]. type SocketConnection struct { IOStream } var xSocketConnectionGLibType func() types.GType func SocketConnectionGLibType() types.GType { return xSocketConnectionGLibType() } func SocketConnectionNewFromInternalPtr(ptr uintptr) *SocketConnection { cls := &SocketConnection{} cls.Ptr = ptr return cls } var xSocketConnectionConnect func(uintptr, uintptr, uintptr, **glib.Error) bool // Connect @connection to the specified remote address. func (x *SocketConnection) Connect(AddressVar *SocketAddress, CancellableVar *Cancellable) (bool, error) { var cerr *glib.Error cret := xSocketConnectionConnect(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } var xSocketConnectionConnectAsync func(uintptr, uintptr, uintptr, uintptr, uintptr) // Asynchronously connect @connection to the specified remote address. // // This clears the #GSocket:blocking flag on @connection's underlying // socket if it is currently set. // // If #GSocket:timeout is set, the operation will time out and return // %G_IO_ERROR_TIMED_OUT after that period. Otherwise, it will continue // indefinitely until operating system timeouts (if any) are hit. // // Use g_socket_connection_connect_finish() to retrieve the result. func (x *SocketConnection) ConnectAsync(AddressVar *SocketAddress, 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) } } xSocketConnectionConnectAsync(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xSocketConnectionConnectFinish func(uintptr, uintptr, **glib.Error) bool // Gets the result of a g_socket_connection_connect_async() call. func (x *SocketConnection) ConnectFinish(ResultVar AsyncResult) (bool, error) { var cerr *glib.Error cret := xSocketConnectionConnectFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } var xSocketConnectionGetLocalAddress func(uintptr) uintptr // Try to get the local address of a socket connection. func (x *SocketConnection) GetLocalAddress() (*SocketAddress, error) { var cls *SocketAddress var cerr *glib.Error cret := xSocketConnectionGetLocalAddress(x.GoPointer()) if cret == 0 { return nil, cerr } cls = &SocketAddress{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketConnectionGetRemoteAddress func(uintptr) uintptr // Try to get the remote address of a socket connection. // // Since GLib 2.40, when used with g_socket_client_connect() or // g_socket_client_connect_async(), during emission of // %G_SOCKET_CLIENT_CONNECTING, this function will return the remote // address that will be used for the connection. This allows // applications to print e.g. "Connecting to example.com // (10.42.77.3)...". func (x *SocketConnection) GetRemoteAddress() (*SocketAddress, error) { var cls *SocketAddress var cerr *glib.Error cret := xSocketConnectionGetRemoteAddress(x.GoPointer()) if cret == 0 { return nil, cerr } cls = &SocketAddress{} cls.Ptr = cret if cerr == nil { return cls, nil } return cls, cerr } var xSocketConnectionGetSocket func(uintptr) uintptr // Gets the underlying #GSocket object of the connection. // This can be useful if you want to do something unusual on it // not supported by the #GSocketConnection APIs. func (x *SocketConnection) GetSocket() *Socket { var cls *Socket cret := xSocketConnectionGetSocket(x.GoPointer()) if cret == 0 { return nil } gobject.IncreaseRef(cret) cls = &Socket{} cls.Ptr = cret return cls } var xSocketConnectionIsConnected func(uintptr) bool // Checks if @connection is connected. This is equivalent to calling // g_socket_is_connected() on @connection's underlying #GSocket. func (x *SocketConnection) IsConnected() bool { cret := xSocketConnectionIsConnected(x.GoPointer()) return cret } func (c *SocketConnection) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *SocketConnection) SetGoPointer(ptr uintptr) { c.Ptr = ptr } var xSocketConnectionFactoryLookupType func(SocketFamily, SocketType, int) types.GType // Looks up the #GType to be used when creating socket connections on // sockets with the specified @family, @type and @protocol_id. // // If no type is registered, the #GSocketConnection base type is returned. func SocketConnectionFactoryLookupType(FamilyVar SocketFamily, TypeVar SocketType, ProtocolIdVar int) types.GType { cret := xSocketConnectionFactoryLookupType(FamilyVar, TypeVar, ProtocolIdVar) return cret } var xSocketConnectionFactoryRegisterType func(types.GType, SocketFamily, SocketType, int) // Looks up the #GType to be used when creating socket connections on // sockets with the specified @family, @type and @protocol. // // If no type is registered, the #GSocketConnection base type is returned. func SocketConnectionFactoryRegisterType(GTypeVar types.GType, FamilyVar SocketFamily, TypeVar SocketType, ProtocolVar int) { xSocketConnectionFactoryRegisterType(GTypeVar, FamilyVar, TypeVar, ProtocolVar) } 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(&xSocketConnectionGLibType, libs, "g_socket_connection_get_type") core.PuregoSafeRegister(&xSocketConnectionConnect, libs, "g_socket_connection_connect") core.PuregoSafeRegister(&xSocketConnectionConnectAsync, libs, "g_socket_connection_connect_async") core.PuregoSafeRegister(&xSocketConnectionConnectFinish, libs, "g_socket_connection_connect_finish") core.PuregoSafeRegister(&xSocketConnectionGetLocalAddress, libs, "g_socket_connection_get_local_address") core.PuregoSafeRegister(&xSocketConnectionGetRemoteAddress, libs, "g_socket_connection_get_remote_address") core.PuregoSafeRegister(&xSocketConnectionGetSocket, libs, "g_socket_connection_get_socket") core.PuregoSafeRegister(&xSocketConnectionIsConnected, libs, "g_socket_connection_is_connected") core.PuregoSafeRegister(&xSocketConnectionFactoryLookupType, libs, "g_socket_connection_factory_lookup_type") core.PuregoSafeRegister(&xSocketConnectionFactoryRegisterType, libs, "g_socket_connection_factory_register_type") }