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/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// Provides an interface for describing TLS-related types.
16type TlsBackendInterface struct {
17 _ structs.HostLayout
18
19 GIface uintptr
20
21 xSupportsTls uintptr
22
23 xGetCertificateType uintptr
24
25 xGetClientConnectionType uintptr
26
27 xGetServerConnectionType uintptr
28
29 xGetFileDatabaseType uintptr
30
31 xGetDefaultDatabase uintptr
32
33 xSupportsDtls uintptr
34
35 xGetDtlsClientConnectionType uintptr
36
37 xGetDtlsServerConnectionType uintptr
38}
39
40func (x *TlsBackendInterface) GoPointer() uintptr {
41 return uintptr(unsafe.Pointer(x))
42}
43
44// OverrideSupportsTls sets the "supports_tls" callback function.
45// returns whether the backend supports TLS.
46func (x *TlsBackendInterface) OverrideSupportsTls(cb func(TlsBackend) bool) {
47 if cb == nil {
48 x.xSupportsTls = 0
49 } else {
50 x.xSupportsTls = purego.NewCallback(func(BackendVarp uintptr) bool {
51 return cb(&TlsBackendBase{Ptr: BackendVarp})
52 })
53 }
54}
55
56// GetSupportsTls gets the "supports_tls" callback function.
57// returns whether the backend supports TLS.
58func (x *TlsBackendInterface) GetSupportsTls() func(TlsBackend) bool {
59 if x.xSupportsTls == 0 {
60 return nil
61 }
62 var rawCallback func(BackendVarp uintptr) bool
63 purego.RegisterFunc(&rawCallback, x.xSupportsTls)
64 return func(BackendVar TlsBackend) bool {
65 return rawCallback(BackendVar.GoPointer())
66 }
67}
68
69// OverrideGetCertificateType sets the "get_certificate_type" callback function.
70// returns the #GTlsCertificate implementation type
71func (x *TlsBackendInterface) OverrideGetCertificateType(cb func() types.GType) {
72 if cb == nil {
73 x.xGetCertificateType = 0
74 } else {
75 x.xGetCertificateType = purego.NewCallback(func() types.GType {
76 return cb()
77 })
78 }
79}
80
81// GetGetCertificateType gets the "get_certificate_type" callback function.
82// returns the #GTlsCertificate implementation type
83func (x *TlsBackendInterface) GetGetCertificateType() func() types.GType {
84 if x.xGetCertificateType == 0 {
85 return nil
86 }
87 var rawCallback func() types.GType
88 purego.RegisterFunc(&rawCallback, x.xGetCertificateType)
89 return func() types.GType {
90 return rawCallback()
91 }
92}
93
94// OverrideGetClientConnectionType sets the "get_client_connection_type" callback function.
95// returns the #GTlsClientConnection implementation type
96func (x *TlsBackendInterface) OverrideGetClientConnectionType(cb func() types.GType) {
97 if cb == nil {
98 x.xGetClientConnectionType = 0
99 } else {
100 x.xGetClientConnectionType = purego.NewCallback(func() types.GType {
101 return cb()
102 })
103 }
104}
105
106// GetGetClientConnectionType gets the "get_client_connection_type" callback function.
107// returns the #GTlsClientConnection implementation type
108func (x *TlsBackendInterface) GetGetClientConnectionType() func() types.GType {
109 if x.xGetClientConnectionType == 0 {
110 return nil
111 }
112 var rawCallback func() types.GType
113 purego.RegisterFunc(&rawCallback, x.xGetClientConnectionType)
114 return func() types.GType {
115 return rawCallback()
116 }
117}
118
119// OverrideGetServerConnectionType sets the "get_server_connection_type" callback function.
120// returns the #GTlsServerConnection implementation type
121func (x *TlsBackendInterface) OverrideGetServerConnectionType(cb func() types.GType) {
122 if cb == nil {
123 x.xGetServerConnectionType = 0
124 } else {
125 x.xGetServerConnectionType = purego.NewCallback(func() types.GType {
126 return cb()
127 })
128 }
129}
130
131// GetGetServerConnectionType gets the "get_server_connection_type" callback function.
132// returns the #GTlsServerConnection implementation type
133func (x *TlsBackendInterface) GetGetServerConnectionType() func() types.GType {
134 if x.xGetServerConnectionType == 0 {
135 return nil
136 }
137 var rawCallback func() types.GType
138 purego.RegisterFunc(&rawCallback, x.xGetServerConnectionType)
139 return func() types.GType {
140 return rawCallback()
141 }
142}
143
144// OverrideGetFileDatabaseType sets the "get_file_database_type" callback function.
145// returns the #GTlsFileDatabase implementation type.
146func (x *TlsBackendInterface) OverrideGetFileDatabaseType(cb func() types.GType) {
147 if cb == nil {
148 x.xGetFileDatabaseType = 0
149 } else {
150 x.xGetFileDatabaseType = purego.NewCallback(func() types.GType {
151 return cb()
152 })
153 }
154}
155
156// GetGetFileDatabaseType gets the "get_file_database_type" callback function.
157// returns the #GTlsFileDatabase implementation type.
158func (x *TlsBackendInterface) GetGetFileDatabaseType() func() types.GType {
159 if x.xGetFileDatabaseType == 0 {
160 return nil
161 }
162 var rawCallback func() types.GType
163 purego.RegisterFunc(&rawCallback, x.xGetFileDatabaseType)
164 return func() types.GType {
165 return rawCallback()
166 }
167}
168
169// OverrideGetDefaultDatabase sets the "get_default_database" callback function.
170// returns a default #GTlsDatabase instance.
171func (x *TlsBackendInterface) OverrideGetDefaultDatabase(cb func(TlsBackend) *TlsDatabase) {
172 if cb == nil {
173 x.xGetDefaultDatabase = 0
174 } else {
175 x.xGetDefaultDatabase = purego.NewCallback(func(BackendVarp uintptr) uintptr {
176 ret := cb(&TlsBackendBase{Ptr: BackendVarp})
177 if ret == nil {
178 return 0
179 }
180 return ret.GoPointer()
181 })
182 }
183}
184
185// GetGetDefaultDatabase gets the "get_default_database" callback function.
186// returns a default #GTlsDatabase instance.
187func (x *TlsBackendInterface) GetGetDefaultDatabase() func(TlsBackend) *TlsDatabase {
188 if x.xGetDefaultDatabase == 0 {
189 return nil
190 }
191 var rawCallback func(BackendVarp uintptr) uintptr
192 purego.RegisterFunc(&rawCallback, x.xGetDefaultDatabase)
193 return func(BackendVar TlsBackend) *TlsDatabase {
194 rawRet := rawCallback(BackendVar.GoPointer())
195 if rawRet == 0 {
196 return nil
197 }
198 ret := &TlsDatabase{}
199 ret.Ptr = rawRet
200 return ret
201 }
202}
203
204// OverrideSupportsDtls sets the "supports_dtls" callback function.
205// returns whether the backend supports DTLS
206func (x *TlsBackendInterface) OverrideSupportsDtls(cb func(TlsBackend) bool) {
207 if cb == nil {
208 x.xSupportsDtls = 0
209 } else {
210 x.xSupportsDtls = purego.NewCallback(func(BackendVarp uintptr) bool {
211 return cb(&TlsBackendBase{Ptr: BackendVarp})
212 })
213 }
214}
215
216// GetSupportsDtls gets the "supports_dtls" callback function.
217// returns whether the backend supports DTLS
218func (x *TlsBackendInterface) GetSupportsDtls() func(TlsBackend) bool {
219 if x.xSupportsDtls == 0 {
220 return nil
221 }
222 var rawCallback func(BackendVarp uintptr) bool
223 purego.RegisterFunc(&rawCallback, x.xSupportsDtls)
224 return func(BackendVar TlsBackend) bool {
225 return rawCallback(BackendVar.GoPointer())
226 }
227}
228
229// OverrideGetDtlsClientConnectionType sets the "get_dtls_client_connection_type" callback function.
230// returns the #GDtlsClientConnection implementation type
231func (x *TlsBackendInterface) OverrideGetDtlsClientConnectionType(cb func() types.GType) {
232 if cb == nil {
233 x.xGetDtlsClientConnectionType = 0
234 } else {
235 x.xGetDtlsClientConnectionType = purego.NewCallback(func() types.GType {
236 return cb()
237 })
238 }
239}
240
241// GetGetDtlsClientConnectionType gets the "get_dtls_client_connection_type" callback function.
242// returns the #GDtlsClientConnection implementation type
243func (x *TlsBackendInterface) GetGetDtlsClientConnectionType() func() types.GType {
244 if x.xGetDtlsClientConnectionType == 0 {
245 return nil
246 }
247 var rawCallback func() types.GType
248 purego.RegisterFunc(&rawCallback, x.xGetDtlsClientConnectionType)
249 return func() types.GType {
250 return rawCallback()
251 }
252}
253
254// OverrideGetDtlsServerConnectionType sets the "get_dtls_server_connection_type" callback function.
255// returns the #GDtlsServerConnection implementation type
256func (x *TlsBackendInterface) OverrideGetDtlsServerConnectionType(cb func() types.GType) {
257 if cb == nil {
258 x.xGetDtlsServerConnectionType = 0
259 } else {
260 x.xGetDtlsServerConnectionType = purego.NewCallback(func() types.GType {
261 return cb()
262 })
263 }
264}
265
266// GetGetDtlsServerConnectionType gets the "get_dtls_server_connection_type" callback function.
267// returns the #GDtlsServerConnection implementation type
268func (x *TlsBackendInterface) GetGetDtlsServerConnectionType() func() types.GType {
269 if x.xGetDtlsServerConnectionType == 0 {
270 return nil
271 }
272 var rawCallback func() types.GType
273 purego.RegisterFunc(&rawCallback, x.xGetDtlsServerConnectionType)
274 return func() types.GType {
275 return rawCallback()
276 }
277}
278
279// TLS (Transport Layer Security, aka SSL) and DTLS backend. This is an
280// internal type used to coordinate the different classes implemented
281// by a TLS backend.
282type TlsBackend interface {
283 GoPointer() uintptr
284 SetGoPointer(uintptr)
285 GetCertificateType() types.GType
286 GetClientConnectionType() types.GType
287 GetDefaultDatabase() *TlsDatabase
288 GetDtlsClientConnectionType() types.GType
289 GetDtlsServerConnectionType() types.GType
290 GetFileDatabaseType() types.GType
291 GetServerConnectionType() types.GType
292 SetDefaultDatabase(DatabaseVar *TlsDatabase)
293 SupportsDtls() bool
294 SupportsTls() bool
295}
296
297var xTlsBackendGLibType func() types.GType
298
299func TlsBackendGLibType() types.GType {
300 return xTlsBackendGLibType()
301}
302
303type TlsBackendBase struct {
304 Ptr uintptr
305}
306
307func (x *TlsBackendBase) GoPointer() uintptr {
308 if x == nil {
309 return 0
310 }
311 return x.Ptr
312}
313
314func (x *TlsBackendBase) SetGoPointer(ptr uintptr) {
315 x.Ptr = ptr
316}
317
318// Gets the #GType of @backend's #GTlsCertificate implementation.
319func (x *TlsBackendBase) GetCertificateType() types.GType {
320
321 cret := XGTlsBackendGetCertificateType(x.GoPointer())
322 return cret
323}
324
325// Gets the #GType of @backend's #GTlsClientConnection implementation.
326func (x *TlsBackendBase) GetClientConnectionType() types.GType {
327
328 cret := XGTlsBackendGetClientConnectionType(x.GoPointer())
329 return cret
330}
331
332// Gets the default #GTlsDatabase used to verify TLS connections.
333func (x *TlsBackendBase) GetDefaultDatabase() *TlsDatabase {
334 var cls *TlsDatabase
335
336 cret := XGTlsBackendGetDefaultDatabase(x.GoPointer())
337
338 if cret == 0 {
339 return nil
340 }
341 cls = &TlsDatabase{}
342 cls.Ptr = cret
343 return cls
344}
345
346// Gets the #GType of @backend’s #GDtlsClientConnection implementation.
347func (x *TlsBackendBase) GetDtlsClientConnectionType() types.GType {
348
349 cret := XGTlsBackendGetDtlsClientConnectionType(x.GoPointer())
350 return cret
351}
352
353// Gets the #GType of @backend’s #GDtlsServerConnection implementation.
354func (x *TlsBackendBase) GetDtlsServerConnectionType() types.GType {
355
356 cret := XGTlsBackendGetDtlsServerConnectionType(x.GoPointer())
357 return cret
358}
359
360// Gets the #GType of @backend's #GTlsFileDatabase implementation.
361func (x *TlsBackendBase) GetFileDatabaseType() types.GType {
362
363 cret := XGTlsBackendGetFileDatabaseType(x.GoPointer())
364 return cret
365}
366
367// Gets the #GType of @backend's #GTlsServerConnection implementation.
368func (x *TlsBackendBase) GetServerConnectionType() types.GType {
369
370 cret := XGTlsBackendGetServerConnectionType(x.GoPointer())
371 return cret
372}
373
374// Set the default #GTlsDatabase used to verify TLS connections
375//
376// Any subsequent call to g_tls_backend_get_default_database() will return
377// the database set in this call. Existing databases and connections are not
378// modified.
379//
380// Setting a %NULL default database will reset to using the system default
381// database as if g_tls_backend_set_default_database() had never been called.
382func (x *TlsBackendBase) SetDefaultDatabase(DatabaseVar *TlsDatabase) {
383
384 XGTlsBackendSetDefaultDatabase(x.GoPointer(), DatabaseVar.GoPointer())
385
386}
387
388// Checks if DTLS is supported. DTLS support may not be available even if TLS
389// support is available, and vice-versa.
390func (x *TlsBackendBase) SupportsDtls() bool {
391
392 cret := XGTlsBackendSupportsDtls(x.GoPointer())
393 return cret
394}
395
396// Checks if TLS is supported; if this returns %FALSE for the default
397// #GTlsBackend, it means no "real" TLS backend is available.
398func (x *TlsBackendBase) SupportsTls() bool {
399
400 cret := XGTlsBackendSupportsTls(x.GoPointer())
401 return cret
402}
403
404var XGTlsBackendGetCertificateType func(uintptr) types.GType
405var XGTlsBackendGetClientConnectionType func(uintptr) types.GType
406var XGTlsBackendGetDefaultDatabase func(uintptr) uintptr
407var XGTlsBackendGetDtlsClientConnectionType func(uintptr) types.GType
408var XGTlsBackendGetDtlsServerConnectionType func(uintptr) types.GType
409var XGTlsBackendGetFileDatabaseType func(uintptr) types.GType
410var XGTlsBackendGetServerConnectionType func(uintptr) types.GType
411var XGTlsBackendSetDefaultDatabase func(uintptr, uintptr)
412var XGTlsBackendSupportsDtls func(uintptr) bool
413var XGTlsBackendSupportsTls func(uintptr) bool
414
415const (
416 // Extension point for TLS functionality via #GTlsBackend.
417 // See [Extending GIO](overview.html#extending-gio).
418 TLS_BACKEND_EXTENSION_POINT_NAME string = "gio-tls-backend"
419)
420
421var xTlsBackendGetDefault func() uintptr
422
423// Gets the default #GTlsBackend for the system.
424func TlsBackendGetDefault() *TlsBackendBase {
425 var cls *TlsBackendBase
426
427 cret := xTlsBackendGetDefault()
428
429 if cret == 0 {
430 return nil
431 }
432 gobject.IncreaseRef(cret)
433 cls = &TlsBackendBase{}
434 cls.Ptr = cret
435 return cls
436}
437
438func init() {
439 core.SetPackageName("GIO", "gio-2.0")
440 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
441 var libs []uintptr
442 for _, libPath := range core.GetPaths("GIO") {
443 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
444 if err != nil {
445 panic(err)
446 }
447 libs = append(libs, lib)
448 }
449
450 core.PuregoSafeRegister(&xTlsBackendGetDefault, libs, "g_tls_backend_get_default")
451
452 core.PuregoSafeRegister(&xTlsBackendGLibType, libs, "g_tls_backend_get_type")
453
454 core.PuregoSafeRegister(&XGTlsBackendGetCertificateType, libs, "g_tls_backend_get_certificate_type")
455 core.PuregoSafeRegister(&XGTlsBackendGetClientConnectionType, libs, "g_tls_backend_get_client_connection_type")
456 core.PuregoSafeRegister(&XGTlsBackendGetDefaultDatabase, libs, "g_tls_backend_get_default_database")
457 core.PuregoSafeRegister(&XGTlsBackendGetDtlsClientConnectionType, libs, "g_tls_backend_get_dtls_client_connection_type")
458 core.PuregoSafeRegister(&XGTlsBackendGetDtlsServerConnectionType, libs, "g_tls_backend_get_dtls_server_connection_type")
459 core.PuregoSafeRegister(&XGTlsBackendGetFileDatabaseType, libs, "g_tls_backend_get_file_database_type")
460 core.PuregoSafeRegister(&XGTlsBackendGetServerConnectionType, libs, "g_tls_backend_get_server_connection_type")
461 core.PuregoSafeRegister(&XGTlsBackendSetDefaultDatabase, libs, "g_tls_backend_set_default_database")
462 core.PuregoSafeRegister(&XGTlsBackendSupportsDtls, libs, "g_tls_backend_supports_dtls")
463 core.PuregoSafeRegister(&XGTlsBackendSupportsTls, libs, "g_tls_backend_supports_tls")
464
465}