summaryrefslogtreecommitdiff
path: root/gui/backend.go
blob: a5cb3abe3fa4c9136cd10805d07e55ad2b50e062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main

//go:generate python3 ../branding/scripts/vendorize.py ../branding/templates/bitmaskvpn/config.go ../branding/config/vendor.conf ../pkg/config/config.go

/* a wrapper around bitmask that exposes status to a QtQml gui.
   Have a look at the pkg/backend module for further enlightment. */

import (
	"C"
	"unsafe"

	"0xacab.org/leap/bitmask-vpn/pkg/backend"
)

//export GetVersion
func GetVersion() *C.char {
	return (*C.char)(backend.GetVersion())
}

//export GetAppName
func GetAppName() *C.char {
	return (*C.char)(backend.GetAppName())
}

//export Login
func Login(username, password *C.char) {
	backend.Login(C.GoString(username), C.GoString(password))
}

//export SwitchOn
func SwitchOn() {
	backend.SwitchOn()
}

//export SwitchOff
func SwitchOff() {
	backend.SwitchOff()
}

//export Quit
func Quit() {
	backend.Quit()
}

//export DonateAccepted
func DonateAccepted() {
	backend.DonateAccepted()
}

//export SubscribeToEvent
func SubscribeToEvent(event string, f unsafe.Pointer) {
	backend.SubscribeToEvent(event, f)
}

//export InitializeBitmaskContext
func InitializeBitmaskContext() {
	opts := &backend.InitOpts{}
	backend.InitializeBitmaskContext(opts)
}

//export InitializeTestBitmaskContext
func InitializeTestBitmaskContext() {
	opts := &backend.InitOpts{}
	opts.SkipLaunch = true
	backend.InitializeBitmaskContext(opts)
	backend.EnableMockBackend()
}

//export EnableWebAPI
func EnableWebAPI(port string) {
	backend.EnableWebAPI(port)
}

//export RefreshContext
func RefreshContext() *C.char {
	return (*C.char)(backend.RefreshContext())
}

//export InstallHelpers
func InstallHelpers() {
	backend.InstallHelpers()
}

func main() {}