merging dan gomobile with erinn ui
This commit is contained in:
parent
9c7a22d472
commit
240c4d36e0
25
lib.go
25
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 {
|
||||
|
|
Loading…
Reference in New Issue