v0.2.1 c0399be

gsocketservice.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
16// Class structure for #GSocketService.
17type SocketServiceClass struct {
18	_ structs.HostLayout
19
20	ParentClass SocketListenerClass
21
22	xIncoming uintptr
23
24	xGReserved1 uintptr
25
26	xGReserved2 uintptr
27
28	xGReserved3 uintptr
29
30	xGReserved4 uintptr
31
32	xGReserved5 uintptr
33
34	xGReserved6 uintptr
35}
36
37func (x *SocketServiceClass) GoPointer() uintptr {
38	return uintptr(unsafe.Pointer(x))
39}
40
41// OverrideIncoming sets the "incoming" callback function.
42// signal emitted when new connections are accepted
43func (x *SocketServiceClass) OverrideIncoming(cb func(*SocketService, *SocketConnection, *gobject.Object) bool) {
44	if cb == nil {
45		x.xIncoming = 0
46	} else {
47		x.xIncoming = purego.NewCallback(func(ServiceVarp uintptr, ConnectionVarp uintptr, SourceObjectVarp uintptr) bool {
48			return cb(SocketServiceNewFromInternalPtr(ServiceVarp), SocketConnectionNewFromInternalPtr(ConnectionVarp), gobject.ObjectNewFromInternalPtr(SourceObjectVarp))
49		})
50	}
51}
52
53// GetIncoming gets the "incoming" callback function.
54// signal emitted when new connections are accepted
55func (x *SocketServiceClass) GetIncoming() func(*SocketService, *SocketConnection, *gobject.Object) bool {
56	if x.xIncoming == 0 {
57		return nil
58	}
59	var rawCallback func(ServiceVarp uintptr, ConnectionVarp uintptr, SourceObjectVarp uintptr) bool
60	purego.RegisterFunc(&rawCallback, x.xIncoming)
61	return func(ServiceVar *SocketService, ConnectionVar *SocketConnection, SourceObjectVar *gobject.Object) bool {
62		return rawCallback(ServiceVar.GoPointer(), ConnectionVar.GoPointer(), SourceObjectVar.GoPointer())
63	}
64}
65
66// OverrideGReserved1 sets the "_g_reserved1" callback function.
67func (x *SocketServiceClass) OverrideGReserved1(cb func()) {
68	if cb == nil {
69		x.xGReserved1 = 0
70	} else {
71		x.xGReserved1 = purego.NewCallback(func() {
72			cb()
73		})
74	}
75}
76
77// GetGReserved1 gets the "_g_reserved1" callback function.
78func (x *SocketServiceClass) GetGReserved1() func() {
79	if x.xGReserved1 == 0 {
80		return nil
81	}
82	var rawCallback func()
83	purego.RegisterFunc(&rawCallback, x.xGReserved1)
84	return func() {
85		rawCallback()
86	}
87}
88
89// OverrideGReserved2 sets the "_g_reserved2" callback function.
90func (x *SocketServiceClass) OverrideGReserved2(cb func()) {
91	if cb == nil {
92		x.xGReserved2 = 0
93	} else {
94		x.xGReserved2 = purego.NewCallback(func() {
95			cb()
96		})
97	}
98}
99
100// GetGReserved2 gets the "_g_reserved2" callback function.
101func (x *SocketServiceClass) GetGReserved2() func() {
102	if x.xGReserved2 == 0 {
103		return nil
104	}
105	var rawCallback func()
106	purego.RegisterFunc(&rawCallback, x.xGReserved2)
107	return func() {
108		rawCallback()
109	}
110}
111
112// OverrideGReserved3 sets the "_g_reserved3" callback function.
113func (x *SocketServiceClass) OverrideGReserved3(cb func()) {
114	if cb == nil {
115		x.xGReserved3 = 0
116	} else {
117		x.xGReserved3 = purego.NewCallback(func() {
118			cb()
119		})
120	}
121}
122
123// GetGReserved3 gets the "_g_reserved3" callback function.
124func (x *SocketServiceClass) GetGReserved3() func() {
125	if x.xGReserved3 == 0 {
126		return nil
127	}
128	var rawCallback func()
129	purego.RegisterFunc(&rawCallback, x.xGReserved3)
130	return func() {
131		rawCallback()
132	}
133}
134
135// OverrideGReserved4 sets the "_g_reserved4" callback function.
136func (x *SocketServiceClass) OverrideGReserved4(cb func()) {
137	if cb == nil {
138		x.xGReserved4 = 0
139	} else {
140		x.xGReserved4 = purego.NewCallback(func() {
141			cb()
142		})
143	}
144}
145
146// GetGReserved4 gets the "_g_reserved4" callback function.
147func (x *SocketServiceClass) GetGReserved4() func() {
148	if x.xGReserved4 == 0 {
149		return nil
150	}
151	var rawCallback func()
152	purego.RegisterFunc(&rawCallback, x.xGReserved4)
153	return func() {
154		rawCallback()
155	}
156}
157
158// OverrideGReserved5 sets the "_g_reserved5" callback function.
159func (x *SocketServiceClass) OverrideGReserved5(cb func()) {
160	if cb == nil {
161		x.xGReserved5 = 0
162	} else {
163		x.xGReserved5 = purego.NewCallback(func() {
164			cb()
165		})
166	}
167}
168
169// GetGReserved5 gets the "_g_reserved5" callback function.
170func (x *SocketServiceClass) GetGReserved5() func() {
171	if x.xGReserved5 == 0 {
172		return nil
173	}
174	var rawCallback func()
175	purego.RegisterFunc(&rawCallback, x.xGReserved5)
176	return func() {
177		rawCallback()
178	}
179}
180
181// OverrideGReserved6 sets the "_g_reserved6" callback function.
182func (x *SocketServiceClass) OverrideGReserved6(cb func()) {
183	if cb == nil {
184		x.xGReserved6 = 0
185	} else {
186		x.xGReserved6 = purego.NewCallback(func() {
187			cb()
188		})
189	}
190}
191
192// GetGReserved6 gets the "_g_reserved6" callback function.
193func (x *SocketServiceClass) GetGReserved6() func() {
194	if x.xGReserved6 == 0 {
195		return nil
196	}
197	var rawCallback func()
198	purego.RegisterFunc(&rawCallback, x.xGReserved6)
199	return func() {
200		rawCallback()
201	}
202}
203
204type SocketServicePrivate struct {
205	_ structs.HostLayout
206}
207
208func (x *SocketServicePrivate) GoPointer() uintptr {
209	return uintptr(unsafe.Pointer(x))
210}
211
212// A `GSocketService` is an object that represents a service that
213// is provided to the network or over local sockets.  When a new
214// connection is made to the service the [signal@Gio.SocketService::incoming]
215// signal is emitted.
216//
217// A `GSocketService` is a subclass of [class@Gio.SocketListener] and you need
218// to add the addresses you want to accept connections on with the
219// [class@Gio.SocketListener] APIs.
220//
221// There are two options for implementing a network service based on
222// `GSocketService`. The first is to create the service using
223// [ctor@Gio.SocketService.new] and to connect to the
224// [signal@Gio.SocketService::incoming] signal. The second is to subclass
225// `GSocketService` and override the default signal handler implementation.
226//
227// In either case, the handler must immediately return, or else it
228// will block additional incoming connections from being serviced.
229// If you are interested in writing connection handlers that contain
230// blocking code then see [class@Gio.ThreadedSocketService].
231//
232// The socket service runs on the main loop of the
233// thread-default context (see
234// [method@GLib.MainContext.push_thread_default]) of the thread it is
235// created in, and is not threadsafe in general. However, the calls to start and
236// stop the service are thread-safe so these can be used from threads that
237// handle incoming clients.
238type SocketService struct {
239	SocketListener
240}
241
242var xSocketServiceGLibType func() types.GType
243
244func SocketServiceGLibType() types.GType {
245	return xSocketServiceGLibType()
246}
247
248func SocketServiceNewFromInternalPtr(ptr uintptr) *SocketService {
249	cls := &SocketService{}
250	cls.Ptr = ptr
251	return cls
252}
253
254var xNewSocketService func() uintptr
255
256// Creates a new #GSocketService with no sockets to listen for.
257// New listeners can be added with e.g. g_socket_listener_add_address()
258// or g_socket_listener_add_inet_port().
259//
260// New services are created active, there is no need to call
261// g_socket_service_start(), unless g_socket_service_stop() has been
262// called before.
263func NewSocketService() *SocketService {
264	var cls *SocketService
265
266	cret := xNewSocketService()
267
268	if cret == 0 {
269		return nil
270	}
271	cls = &SocketService{}
272	cls.Ptr = cret
273	return cls
274}
275
276var xSocketServiceIsActive func(uintptr) bool
277
278// Check whether the service is active or not. An active
279// service will accept new clients that connect, while
280// a non-active service will let connecting clients queue
281// up until the service is started.
282func (x *SocketService) IsActive() bool {
283
284	cret := xSocketServiceIsActive(x.GoPointer())
285	return cret
286}
287
288var xSocketServiceStart func(uintptr)
289
290// Restarts the service, i.e. start accepting connections
291// from the added sockets when the mainloop runs. This only needs
292// to be called after the service has been stopped from
293// g_socket_service_stop().
294//
295// This call is thread-safe, so it may be called from a thread
296// handling an incoming client request.
297func (x *SocketService) Start() {
298
299	xSocketServiceStart(x.GoPointer())
300
301}
302
303var xSocketServiceStop func(uintptr)
304
305// Stops the service, i.e. stops accepting connections
306// from the added sockets when the mainloop runs.
307//
308// This call is thread-safe, so it may be called from a thread
309// handling an incoming client request.
310//
311// Note that this only stops accepting new connections; it does not
312// close the listening sockets, and you can call
313// g_socket_service_start() again later to begin listening again. To
314// close the listening sockets, call g_socket_listener_close(). (This
315// will happen automatically when the #GSocketService is finalized.)
316//
317// This must be called before calling g_socket_listener_close() as
318// the socket service will start accepting connections immediately
319// when a new socket is added.
320func (x *SocketService) Stop() {
321
322	xSocketServiceStop(x.GoPointer())
323
324}
325
326func (c *SocketService) GoPointer() uintptr {
327	if c == nil {
328		return 0
329	}
330	return c.Ptr
331}
332
333func (c *SocketService) SetGoPointer(ptr uintptr) {
334	c.Ptr = ptr
335}
336
337// SetPropertyActive sets the "active" property.
338// Whether the service is currently accepting connections.
339func (x *SocketService) SetPropertyActive(value bool) {
340	var v gobject.Value
341	v.Init(gobject.TypeBooleanVal)
342	v.SetBoolean(value)
343	x.SetProperty("active", &v)
344}
345
346// GetPropertyActive gets the "active" property.
347// Whether the service is currently accepting connections.
348func (x *SocketService) GetPropertyActive() bool {
349	var v gobject.Value
350	x.GetProperty("active", &v)
351	return v.GetBoolean()
352}
353
354// The ::incoming signal is emitted when a new incoming connection
355// to @service needs to be handled. The handler must initiate the
356// handling of @connection, but may not block; in essence,
357// asynchronous operations must be used.
358//
359// @connection will be unreffed once the signal handler returns,
360// so you need to ref it yourself if you are planning to use it.
361func (x *SocketService) ConnectIncoming(cb *func(SocketService, uintptr, uintptr) bool) uint {
362	cbPtr := uintptr(unsafe.Pointer(cb))
363	if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
364		handlerID := gobject.SignalConnect(x.GoPointer(), "incoming", cbRefPtr)
365		glib.SaveHandlerMapping(handlerID, cbPtr)
366		return handlerID
367	}
368
369	fcb := func(clsPtr uintptr, ConnectionVarp uintptr, SourceObjectVarp uintptr) bool {
370		fa := SocketService{}
371		fa.Ptr = clsPtr
372		cbFn := *cb
373
374		return cbFn(fa, ConnectionVarp, SourceObjectVarp)
375
376	}
377	cbRefPtr := purego.NewCallback(fcb)
378	glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
379	handlerID := gobject.SignalConnect(x.GoPointer(), "incoming", cbRefPtr)
380	glib.SaveHandlerMapping(handlerID, cbPtr)
381	return handlerID
382}
383
384func init() {
385	core.SetPackageName("GIO", "gio-2.0")
386	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
387	var libs []uintptr
388	for _, libPath := range core.GetPaths("GIO") {
389		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
390		if err != nil {
391			panic(err)
392		}
393		libs = append(libs, lib)
394	}
395
396	core.PuregoSafeRegister(&xSocketServiceGLibType, libs, "g_socket_service_get_type")
397
398	core.PuregoSafeRegister(&xNewSocketService, libs, "g_socket_service_new")
399
400	core.PuregoSafeRegister(&xSocketServiceIsActive, libs, "g_socket_service_is_active")
401	core.PuregoSafeRegister(&xSocketServiceStart, libs, "g_socket_service_start")
402	core.PuregoSafeRegister(&xSocketServiceStop, libs, "g_socket_service_stop")
403
404}

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