v0.2.1 c0399be

gsocketconnection.go RawHistoryFolder

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 SocketConnectionClass struct {
17	_ structs.HostLayout
18
19	ParentClass IOStreamClass
20
21	xGReserved1 uintptr
22
23	xGReserved2 uintptr
24
25	xGReserved3 uintptr
26
27	xGReserved4 uintptr
28
29	xGReserved5 uintptr
30
31	xGReserved6 uintptr
32}
33
34func (x *SocketConnectionClass) GoPointer() uintptr {
35	return uintptr(unsafe.Pointer(x))
36}
37
38// OverrideGReserved1 sets the "_g_reserved1" callback function.
39func (x *SocketConnectionClass) OverrideGReserved1(cb func()) {
40	if cb == nil {
41		x.xGReserved1 = 0
42	} else {
43		x.xGReserved1 = purego.NewCallback(func() {
44			cb()
45		})
46	}
47}
48
49// GetGReserved1 gets the "_g_reserved1" callback function.
50func (x *SocketConnectionClass) GetGReserved1() func() {
51	if x.xGReserved1 == 0 {
52		return nil
53	}
54	var rawCallback func()
55	purego.RegisterFunc(&rawCallback, x.xGReserved1)
56	return func() {
57		rawCallback()
58	}
59}
60
61// OverrideGReserved2 sets the "_g_reserved2" callback function.
62func (x *SocketConnectionClass) OverrideGReserved2(cb func()) {
63	if cb == nil {
64		x.xGReserved2 = 0
65	} else {
66		x.xGReserved2 = purego.NewCallback(func() {
67			cb()
68		})
69	}
70}
71
72// GetGReserved2 gets the "_g_reserved2" callback function.
73func (x *SocketConnectionClass) GetGReserved2() func() {
74	if x.xGReserved2 == 0 {
75		return nil
76	}
77	var rawCallback func()
78	purego.RegisterFunc(&rawCallback, x.xGReserved2)
79	return func() {
80		rawCallback()
81	}
82}
83
84// OverrideGReserved3 sets the "_g_reserved3" callback function.
85func (x *SocketConnectionClass) OverrideGReserved3(cb func()) {
86	if cb == nil {
87		x.xGReserved3 = 0
88	} else {
89		x.xGReserved3 = purego.NewCallback(func() {
90			cb()
91		})
92	}
93}
94
95// GetGReserved3 gets the "_g_reserved3" callback function.
96func (x *SocketConnectionClass) GetGReserved3() func() {
97	if x.xGReserved3 == 0 {
98		return nil
99	}
100	var rawCallback func()
101	purego.RegisterFunc(&rawCallback, x.xGReserved3)
102	return func() {
103		rawCallback()
104	}
105}
106
107// OverrideGReserved4 sets the "_g_reserved4" callback function.
108func (x *SocketConnectionClass) OverrideGReserved4(cb func()) {
109	if cb == nil {
110		x.xGReserved4 = 0
111	} else {
112		x.xGReserved4 = purego.NewCallback(func() {
113			cb()
114		})
115	}
116}
117
118// GetGReserved4 gets the "_g_reserved4" callback function.
119func (x *SocketConnectionClass) GetGReserved4() func() {
120	if x.xGReserved4 == 0 {
121		return nil
122	}
123	var rawCallback func()
124	purego.RegisterFunc(&rawCallback, x.xGReserved4)
125	return func() {
126		rawCallback()
127	}
128}
129
130// OverrideGReserved5 sets the "_g_reserved5" callback function.
131func (x *SocketConnectionClass) OverrideGReserved5(cb func()) {
132	if cb == nil {
133		x.xGReserved5 = 0
134	} else {
135		x.xGReserved5 = purego.NewCallback(func() {
136			cb()
137		})
138	}
139}
140
141// GetGReserved5 gets the "_g_reserved5" callback function.
142func (x *SocketConnectionClass) GetGReserved5() func() {
143	if x.xGReserved5 == 0 {
144		return nil
145	}
146	var rawCallback func()
147	purego.RegisterFunc(&rawCallback, x.xGReserved5)
148	return func() {
149		rawCallback()
150	}
151}
152
153// OverrideGReserved6 sets the "_g_reserved6" callback function.
154func (x *SocketConnectionClass) OverrideGReserved6(cb func()) {
155	if cb == nil {
156		x.xGReserved6 = 0
157	} else {
158		x.xGReserved6 = purego.NewCallback(func() {
159			cb()
160		})
161	}
162}
163
164// GetGReserved6 gets the "_g_reserved6" callback function.
165func (x *SocketConnectionClass) GetGReserved6() func() {
166	if x.xGReserved6 == 0 {
167		return nil
168	}
169	var rawCallback func()
170	purego.RegisterFunc(&rawCallback, x.xGReserved6)
171	return func() {
172		rawCallback()
173	}
174}
175
176type SocketConnectionPrivate struct {
177	_ structs.HostLayout
178}
179
180func (x *SocketConnectionPrivate) GoPointer() uintptr {
181	return uintptr(unsafe.Pointer(x))
182}
183
184// `GSocketConnection` is a [class@Gio.IOStream] for a connected socket. They
185// can be created either by [class@Gio.SocketClient] when connecting to a host,
186// or by [class@Gio.SocketListener] when accepting a new client.
187//
188// The type of the `GSocketConnection` object returned from these calls
189// depends on the type of the underlying socket that is in use. For
190// instance, for a TCP/IP connection it will be a [class@Gio.TcpConnection].
191//
192// Choosing what type of object to construct is done with the socket
193// connection factory, and it is possible for third parties to register
194// custom socket connection types for specific combination of socket
195// family/type/protocol using [func@Gio.SocketConnection.factory_register_type].
196//
197// To close a `GSocketConnection`, use [method@Gio.IOStream.close]. Closing both
198// substreams of the [class@Gio.IOStream] separately will not close the
199// underlying [class@Gio.Socket].
200type SocketConnection struct {
201	IOStream
202}
203
204var xSocketConnectionGLibType func() types.GType
205
206func SocketConnectionGLibType() types.GType {
207	return xSocketConnectionGLibType()
208}
209
210func SocketConnectionNewFromInternalPtr(ptr uintptr) *SocketConnection {
211	cls := &SocketConnection{}
212	cls.Ptr = ptr
213	return cls
214}
215
216var xSocketConnectionConnect func(uintptr, uintptr, uintptr, **glib.Error) bool
217
218// Connect @connection to the specified remote address.
219func (x *SocketConnection) Connect(AddressVar *SocketAddress, CancellableVar *Cancellable) (bool, error) {
220	var cerr *glib.Error
221
222	cret := xSocketConnectionConnect(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), &cerr)
223	if cerr == nil {
224		return cret, nil
225	}
226	return cret, cerr
227
228}
229
230var xSocketConnectionConnectAsync func(uintptr, uintptr, uintptr, uintptr, uintptr)
231
232// Asynchronously connect @connection to the specified remote address.
233//
234// This clears the #GSocket:blocking flag on @connection's underlying
235// socket if it is currently set.
236//
237// If #GSocket:timeout is set, the operation will time out and return
238// %G_IO_ERROR_TIMED_OUT after that period. Otherwise, it will continue
239// indefinitely until operating system timeouts (if any) are hit.
240//
241// Use g_socket_connection_connect_finish() to retrieve the result.
242func (x *SocketConnection) ConnectAsync(AddressVar *SocketAddress, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
243
244	var CallbackVarRef uintptr
245	if CallbackVar != nil {
246		CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
247		if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
248			CallbackVarRef = cbRefPtr
249		} else {
250			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
251				cbFn := *CallbackVar
252				cbFn(arg0, arg1, arg2)
253			}
254			CallbackVarRef = purego.NewCallback(fcb)
255			glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
256		}
257	}
258
259	xSocketConnectionConnectAsync(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
260
261}
262
263var xSocketConnectionConnectFinish func(uintptr, uintptr, **glib.Error) bool
264
265// Gets the result of a g_socket_connection_connect_async() call.
266func (x *SocketConnection) ConnectFinish(ResultVar AsyncResult) (bool, error) {
267	var cerr *glib.Error
268
269	cret := xSocketConnectionConnectFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
270	if cerr == nil {
271		return cret, nil
272	}
273	return cret, cerr
274
275}
276
277var xSocketConnectionGetLocalAddress func(uintptr) uintptr
278
279// Try to get the local address of a socket connection.
280func (x *SocketConnection) GetLocalAddress() (*SocketAddress, error) {
281	var cls *SocketAddress
282	var cerr *glib.Error
283
284	cret := xSocketConnectionGetLocalAddress(x.GoPointer())
285
286	if cret == 0 {
287		return nil, cerr
288	}
289	cls = &SocketAddress{}
290	cls.Ptr = cret
291	if cerr == nil {
292		return cls, nil
293	}
294	return cls, cerr
295
296}
297
298var xSocketConnectionGetRemoteAddress func(uintptr) uintptr
299
300// Try to get the remote address of a socket connection.
301//
302// Since GLib 2.40, when used with g_socket_client_connect() or
303// g_socket_client_connect_async(), during emission of
304// %G_SOCKET_CLIENT_CONNECTING, this function will return the remote
305// address that will be used for the connection.  This allows
306// applications to print e.g. "Connecting to example.com
307// (10.42.77.3)...".
308func (x *SocketConnection) GetRemoteAddress() (*SocketAddress, error) {
309	var cls *SocketAddress
310	var cerr *glib.Error
311
312	cret := xSocketConnectionGetRemoteAddress(x.GoPointer())
313
314	if cret == 0 {
315		return nil, cerr
316	}
317	cls = &SocketAddress{}
318	cls.Ptr = cret
319	if cerr == nil {
320		return cls, nil
321	}
322	return cls, cerr
323
324}
325
326var xSocketConnectionGetSocket func(uintptr) uintptr
327
328// Gets the underlying #GSocket object of the connection.
329// This can be useful if you want to do something unusual on it
330// not supported by the #GSocketConnection APIs.
331func (x *SocketConnection) GetSocket() *Socket {
332	var cls *Socket
333
334	cret := xSocketConnectionGetSocket(x.GoPointer())
335
336	if cret == 0 {
337		return nil
338	}
339	gobject.IncreaseRef(cret)
340	cls = &Socket{}
341	cls.Ptr = cret
342	return cls
343}
344
345var xSocketConnectionIsConnected func(uintptr) bool
346
347// Checks if @connection is connected. This is equivalent to calling
348// g_socket_is_connected() on @connection's underlying #GSocket.
349func (x *SocketConnection) IsConnected() bool {
350
351	cret := xSocketConnectionIsConnected(x.GoPointer())
352	return cret
353}
354
355func (c *SocketConnection) GoPointer() uintptr {
356	if c == nil {
357		return 0
358	}
359	return c.Ptr
360}
361
362func (c *SocketConnection) SetGoPointer(ptr uintptr) {
363	c.Ptr = ptr
364}
365
366var xSocketConnectionFactoryLookupType func(SocketFamily, SocketType, int) types.GType
367
368// Looks up the #GType to be used when creating socket connections on
369// sockets with the specified @family, @type and @protocol_id.
370//
371// If no type is registered, the #GSocketConnection base type is returned.
372func SocketConnectionFactoryLookupType(FamilyVar SocketFamily, TypeVar SocketType, ProtocolIdVar int) types.GType {
373
374	cret := xSocketConnectionFactoryLookupType(FamilyVar, TypeVar, ProtocolIdVar)
375	return cret
376}
377
378var xSocketConnectionFactoryRegisterType func(types.GType, SocketFamily, SocketType, int)
379
380// Looks up the #GType to be used when creating socket connections on
381// sockets with the specified @family, @type and @protocol.
382//
383// If no type is registered, the #GSocketConnection base type is returned.
384func SocketConnectionFactoryRegisterType(GTypeVar types.GType, FamilyVar SocketFamily, TypeVar SocketType, ProtocolVar int) {
385
386	xSocketConnectionFactoryRegisterType(GTypeVar, FamilyVar, TypeVar, ProtocolVar)
387
388}
389
390func init() {
391	core.SetPackageName("GIO", "gio-2.0")
392	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
393	var libs []uintptr
394	for _, libPath := range core.GetPaths("GIO") {
395		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
396		if err != nil {
397			panic(err)
398		}
399		libs = append(libs, lib)
400	}
401
402	core.PuregoSafeRegister(&xSocketConnectionGLibType, libs, "g_socket_connection_get_type")
403
404	core.PuregoSafeRegister(&xSocketConnectionConnect, libs, "g_socket_connection_connect")
405	core.PuregoSafeRegister(&xSocketConnectionConnectAsync, libs, "g_socket_connection_connect_async")
406	core.PuregoSafeRegister(&xSocketConnectionConnectFinish, libs, "g_socket_connection_connect_finish")
407	core.PuregoSafeRegister(&xSocketConnectionGetLocalAddress, libs, "g_socket_connection_get_local_address")
408	core.PuregoSafeRegister(&xSocketConnectionGetRemoteAddress, libs, "g_socket_connection_get_remote_address")
409	core.PuregoSafeRegister(&xSocketConnectionGetSocket, libs, "g_socket_connection_get_socket")
410	core.PuregoSafeRegister(&xSocketConnectionIsConnected, libs, "g_socket_connection_is_connected")
411
412	core.PuregoSafeRegister(&xSocketConnectionFactoryLookupType, libs, "g_socket_connection_factory_lookup_type")
413	core.PuregoSafeRegister(&xSocketConnectionFactoryRegisterType, libs, "g_socket_connection_factory_register_type")
414
415}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close