add GetMessages
This commit is contained in:
parent
b70da91e5c
commit
120dc5f468
|
@ -1 +1,5 @@
|
|||
.idea
|
||||
cwtch-sources.jar
|
||||
cwtch.aar
|
||||
libCwtch.h
|
||||
libCwtch.so
|
||||
|
|
12
README.md
12
README.md
|
@ -1,6 +1,14 @@
|
|||
# Build Instructions...
|
||||
go build -buildmode c-shared -o libCwtch.so
|
||||
make linux
|
||||
make android
|
||||
|
||||
# Using
|
||||
|
||||
LD_LIBRARY_PATH set to point to libCwtch.so
|
||||
## Linux Desktop:
|
||||
|
||||
- `LD_LIBRARY_PATH` set to point to `libCwtch.so`
|
||||
- or drop a symlink into `/usr/lib`
|
||||
|
||||
## Android
|
||||
|
||||
- copy `cwtch.aar` into `flutter_app/android/cwtch`
|
||||
|
|
17
lib.go
17
lib.go
|
@ -32,7 +32,6 @@ func c_StartCwtch(dir_c *C.char, len C.int, tor_c *C.char, torLen C.int) {
|
|||
}
|
||||
|
||||
func StartCwtch(appDir string, torPath string) {
|
||||
//go func (appDir string, torPath string) {
|
||||
log.SetLevel(log.LevelDebug)
|
||||
|
||||
log.Infof("Loading Cwtch Directory %v and tor path: %v", appDir, torPath)
|
||||
|
@ -73,7 +72,7 @@ func StartCwtch(appDir string, torPath string) {
|
|||
newApp.LoadProfiles("be gay do crime")
|
||||
newApp.LaunchPeers()
|
||||
application = newApp
|
||||
//}(appDir, torPath)
|
||||
log.Infof("libcwtch-go application SET\n")
|
||||
}
|
||||
|
||||
//export c_ACNEvents
|
||||
|
@ -179,6 +178,7 @@ func c_GetMessage(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, ha
|
|||
return C.CString(GetMessage(profile, handle, int(message_index)))
|
||||
}
|
||||
|
||||
// Deprecate - 2021.01.14 - not used
|
||||
func GetMessage(profile, handle string, message_index int) string {
|
||||
message := application.GetPeer(profile).GetContact(handle).Timeline.Messages[message_index]
|
||||
bytes,_ := json.Marshal(message)
|
||||
|
@ -186,5 +186,18 @@ func GetMessage(profile, handle string, message_index int) string {
|
|||
return string(bytes)
|
||||
}
|
||||
|
||||
//export c_GetMessages
|
||||
func c_GetMessages(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, start C.int, end C.int) *C.char {
|
||||
profile := C.GoStringN(profile_ptr, profile_len)
|
||||
handle := C.GoStringN(handle_ptr, handle_len)
|
||||
return C.CString(GetMessages(profile, handle, int(start), int(end)))
|
||||
}
|
||||
|
||||
func GetMessages(profile, handle string, start, end int) string {
|
||||
messages := application.GetPeer(profile).GetContact(handle).Timeline.Messages[start:end]
|
||||
bytes,_ := json.Marshal(messages)
|
||||
return string(bytes)
|
||||
}
|
||||
|
||||
// Leave as is, needed by ffi
|
||||
//func main() {}
|
Loading…
Reference in New Issue