Merge pull request 'Unlock Profiles' (#4) from unlock into gomobile

Reviewed-on: #4
This commit is contained in:
Dan Ballard 2021-01-26 17:22:50 -08:00
commit dd9f60a9ac
1 changed files with 24 additions and 3 deletions

27
lib.go
View File

@ -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() {}
func main() {}