From 92f74b2dc67d7c4123f9b165327c637567a35f0f Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 26 Jan 2021 14:38:06 -0800 Subject: [PATCH] Unlock Profiles --- lib.go | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/lib.go b/lib.go index 751d0cf..a9b71db 100644 --- a/lib.go +++ b/lib.go @@ -1,5 +1,5 @@ -package cwtch -//package main +//package cwtch +package main import "C" import ( @@ -100,8 +100,20 @@ func ACNEvents() string { } } +//export c_AppBusEvent +func c_AppBusEvent() *C.char { + return C.CString(GetAppBusEvent()) +} + + // GetAppBusEvent blocks until an event func GetAppBusEvent() string { + select { + case myevent := <- acnQueue.OutChan(): + return fmt.Sprintf("%v", myevent) + default: + return "" + } event := appBusQueue.Next() return fmt.Sprintf("%v", event) } @@ -184,6 +196,15 @@ func SelectProfile(onion string) string { return "" } +//export c_LoadProfiles +func c_LoadProfiles(passwordPtr *C.char, passwordLen C.int) { + LoadProfiles(C.GoStringN(passwordPtr, passwordLen)) +} + +func LoadProfiles(pass string) { + application.LoadProfiles(pass) +} + //export c_ContactEvents func c_ContactEvents() *C.char { return C.CString(ContactEvents()) @@ -240,4 +261,4 @@ func GetMessages(profile, handle string, start, end int) string { } // Leave as is, needed by ffi -//func main() {} \ No newline at end of file +func main() {} \ No newline at end of file