From 240c4d36e02987e0ea7893326517d0c23922e5c5 Mon Sep 17 00:00:00 2001 From: erinn Date: Fri, 22 Jan 2021 00:00:03 -0800 Subject: [PATCH] merging dan gomobile with erinn ui --- lib.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib.go b/lib.go index 77b546e..751d0cf 100644 --- a/lib.go +++ b/lib.go @@ -106,13 +106,29 @@ func GetAppBusEvent() string { return fmt.Sprintf("%v", event) } +type Profile struct { + Name string `json:"name"` + Onion string `json:"onion"` + ImagePath string `json:"imagePath"` +} + //export c_GetProfiles func c_GetProfiles() *C.char { return C.CString(GetProfiles()) } func GetProfiles() string { - profiles := application.ListPeers() + peerList := application.ListPeers() + profiles := make([]Profile, len(peerList)) + i := 0 + for onion, name := range peerList { + profiles[i] = Profile{ + Name: name, + Onion: onion, + ImagePath: "", + } + i += 1 + } jsonBytes,_ := json.Marshal(profiles) return string(jsonBytes) } @@ -147,7 +163,14 @@ func GetContacts(onion string)string { return string(bytes) } +//export c_CreateProfile +func c_CreateProfile(nick_ptr *C.char, nick_len C.int, pass_ptr *C.char, pass_len C.int) { + CreateProfile(C.GoStringN(nick_ptr, nick_len), C.GoStringN(pass_ptr, pass_len)) +} +func CreateProfile(nick, pass string) { + application.CreatePeer(nick, pass) +} //export c_SelectProfile func c_SelectProfile(onion_ptr *C.char, onion_len C.int) *C.char {