diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-20 14:28:08 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-20 14:28:08 +0200 |
| commit | 1c54936626a4a30d0c6f69576a06ba3661f39dc6 (patch) | |
| tree | 426c76b4c55cf9a9efbc7bd1aa957baec57b2892 /exports | |
| parent | 77c9f266553cbadfd5fb150a26c2162b705f151e (diff) | |
Profiles: Implement SetProfileID instead of getting generic data
Diffstat (limited to 'exports')
| -rw-r--r-- | exports/exports.go | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/exports/exports.go b/exports/exports.go index 7d2b1ce..af71eba 100644 --- a/exports/exports.go +++ b/exports/exports.go @@ -18,9 +18,9 @@ import "github.com/jwijenbergh/eduvpn-common/src" var P_StateCallback C.PythonCB -func StateCallback(old_state string, new_state string, data string) string { +func StateCallback(old_state string, new_state string, data string) { if P_StateCallback == nil { - return "" + return } oldState_c := C.CString(old_state) newState_c := C.CString(new_state) @@ -29,12 +29,6 @@ func StateCallback(old_state string, new_state string, data string) string { C.free(unsafe.Pointer(oldState_c)) C.free(unsafe.Pointer(newState_c)) C.free(unsafe.Pointer(data_c)) - - // Get state data and reset - state := eduvpn.GetVPNState() - received_data := state.StateCallbackData - state.StateCallbackData = "" - return received_data } //export Register @@ -81,9 +75,24 @@ func GetServersList() (*C.char, *C.char) { return C.CString(servers), C.CString(ErrorToString(serversErr)) } -//export SendData -func SendData(data *C.char) { - eduvpn.GetVPNState().StateCallbackData = C.GoString(data) +//export SetProfileID +func SetProfileID(data *C.char) { + state := eduvpn.GetVPNState() + + // No server + if state.Server == nil { + return + } + + // No profiles for server + if state.Server.Profiles == nil { + return + } + + // Set current profile to id + profile_id := C.GoString(data) + + state.Server.Profiles.Current = profile_id } //export FreeString |
