From 68b553e0c855e59962530eb02d24ab05cfb9d4e4 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Mon, 27 Dec 2021 09:06:54 -0500 Subject: [PATCH] upgrade build refs, .h and buildgen bindings to lcg 1.5.2 -- now the fun begins --- build.rs | 4 +- libCwtch.h | 40 ++++++--- src/cwtchlib_go/bindings.rs | 168 ++++++++++++++++++++++++++---------- 3 files changed, 154 insertions(+), 58 deletions(-) diff --git a/build.rs b/build.rs index f57d188..d7379d4 100644 --- a/build.rs +++ b/build.rs @@ -11,6 +11,6 @@ fn main() { println!("cargo:rerun-if-changed=libCwtch.h"); let lib_cwtch_path = Path::new(&out_dir).join("libCwtch.so"); - // https://git.openprivacy.ca/cwtch.im/libcwtch-go/releases v1.2.0 - Command::new("wget").arg("https://git.openprivacy.ca/attachments/e77c69f0-9487-4808-bc23-092d943bc4a6").arg("-O").arg(lib_cwtch_path).output().expect("failed to download libCwtch.so"); + // https://git.openprivacy.ca/cwtch.im/libcwtch-go/releases v1.5.2 + Command::new("wget").arg("https://git.openprivacy.ca/attachments/3e563341-c206-4e69-98e3-e0dca449f947").arg("-O").arg(lib_cwtch_path).output().expect("failed to download libCwtch.so"); } \ No newline at end of file diff --git a/libCwtch.h b/libCwtch.h index 429db59..70c2395 100644 --- a/libCwtch.h +++ b/libCwtch.h @@ -16,6 +16,7 @@ typedef struct { const char *p; ptrdiff_t n; } _GoString_; #endif + /* Start of boilerplate cgo prologue. */ #line 1 "cgo-gcc-export-header-prolog" @@ -73,31 +74,46 @@ extern void c_SendProfileEvent(char* onion_ptr, int onion_len, char* json_ptr, i extern char* c_GetAppBusEvent(); extern void c_CreateProfile(char* nick_ptr, int nick_len, char* pass_ptr, int pass_len); extern void c_LoadProfiles(char* passwordPtr, int passwordLen); -extern void c_AcceptContact(char* profilePtr, int profileLen, char* handlePtr, int handleLen); -extern void c_RejectInvite(char* profilePtr, int profileLen, char* handlePtr, int handleLen); -extern void c_BlockContact(char* profilePtr, int profileLen, char* handlePtr, int handleLen); -extern void c_UpdateMessageFlags(char* profile_ptr, int profile_len, char* handle_ptr, int handle_len, int mIdx, long unsigned int message_flags); +extern void c_AcceptConversation(char* profilePtr, int profileLen, int conversation_id); +extern void c_BlockContact(char* profilePtr, int profileLen, int conversation_id); // the pointer returned from this function **must** be Freed by c_Free -extern char* c_GetMessage(char* profile_ptr, int profile_len, char* handle_ptr, int handle_len, int message_index); +extern char* c_GetMessage(char* profile_ptr, int profile_len, int conversation_id, int message_index); + +// the pointer returned from this function **must** be Freed by c_Free +extern char* c_GetMessageByID(char* profile_ptr, int profile_len, int conversation_id, int message_index); // the pointer returned from this function **must** be freed by calling c_Free -extern char* c_GetMessagesByContentHash(char* profile_ptr, int profile_len, char* handle_ptr, int handle_len, char* contenthash_ptr, int contenthash_len); +extern char* c_GetMessagesByContentHash(char* profile_ptr, int profile_len, int conversation_id, char* contenthash_ptr, int contenthash_len); // Dangerous function. Should only be used as documented in `MEMORY.md` extern void c_FreePointer(char* ptr); -extern void c_SendMessage(char* profile_ptr, int profile_len, char* handle_ptr, int handle_len, char* msg_ptr, int msg_len); -extern void c_SendInvitation(char* profile_ptr, int profile_len, char* handle_ptr, int handle_len, char* target_ptr, int target_len); +extern void c_SendMessage(char* profile_ptr, int profile_len, int conversation_id, char* msg_ptr, int msg_len); +extern void c_SendInvitation(char* profile_ptr, int profile_len, int conversation_id, int target_id); +extern void c_ShareFile(char* profile_ptr, int profile_len, int conversation_id, char* filepath_ptr, int filepath_len); +extern void c_DownloadFile(char* profile_ptr, int profile_len, int conversation_id, char* filepath_ptr, int filepath_len, char* manifestpath_ptr, int manifestpath_len, char* filekey_ptr, int filekey_len); +extern void c_CheckDownloadStatus(char* profilePtr, int profileLen, char* fileKeyPtr, int fileKeyLen); +extern void c_VerifyOrResumeDownload(char* profile_ptr, int profile_len, int conversation_id, char* filekey_ptr, int filekey_len); extern void c_ResetTor(); extern void c_CreateGroup(char* profile_ptr, int profile_len, char* server_ptr, int server_len, char* name_ptr, int name_len); extern void c_DeleteProfile(char* profile_ptr, int profile_len, char* password_ptr, int password_len); -extern void c_ArchiveConversation(char* profile_ptr, int profile_len, char* contact_ptr, int contact_len); -extern void c_DeleteContact(char* profile_ptr, int profile_len, char* hanlde_ptr, int handle_len); +extern void c_ArchiveConversation(char* profile_ptr, int profile_len, int conversation_id); +extern void c_DeleteContact(char* profile_ptr, int profile_len, int conversation_id); extern void c_ImportBundle(char* profile_ptr, int profile_len, char* bundle_ptr, int bundle_len); extern void c_SetProfileAttribute(char* profile_ptr, int profile_len, char* key_ptr, int key_len, char* val_ptr, int val_len); -extern void c_SetContactAttribute(char* profile_ptr, int profile_len, char* contact_ptr, int contact_len, char* key_ptr, int key_len, char* val_ptr, int val_len); -extern void c_SetGroupAttribute(char* profile_ptr, int profile_len, char* group_ptr, int group_len, char* key_ptr, int key_len, char* val_ptr, int val_len); +extern void c_SetConversationAttribute(char* profile_ptr, int profile_len, int conversation_id, char* key_ptr, int key_len, char* val_ptr, int val_len); +extern void c_SetMessageAttribute(char* profile_ptr, int profile_len, int conversation_id, int channel_id, int message_id, char* key_ptr, int key_len, char* val_ptr, int val_len); +extern void c_ChangePassword(char* profile_ptr, int profile_len, char* oldpassword_ptr, int oldpassword_len, char* newpassword_ptr, int newpassword_len, char* newpassword_again_ptr, int newpassword_again_len); extern void c_ShutdownCwtch(); +extern void c_LoadServers(char* passwordPtr, int passwordLen); +extern void c_CreateServer(char* passwordPtr, int passwordLen, char* descPtr, int descLen, char autostart); +extern void c_DeleteServer(char* onionPtr, int onionLen, char* currentPasswordPtr, int currentPasswordLen); +extern void c_LaunchServers(); +extern void c_LaunchServer(char* onionPtr, int onionLen); +extern void c_StopServer(char* onionPtr, int onionLen); +extern void c_StopServers(); +extern void c_DestroyServers(); +extern void c_SetServerAttribute(char* onionPtr, int onionLen, char* keyPtr, int keyLen, char* valPtr, int valLen); #ifdef __cplusplus } diff --git a/src/cwtchlib_go/bindings.rs b/src/cwtchlib_go/bindings.rs index aa967a6..5bbd780 100644 --- a/src/cwtchlib_go/bindings.rs +++ b/src/cwtchlib_go/bindings.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.58.1 */ +/* automatically generated by rust-bindgen 0.59.2 */ #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] #[repr(C)] @@ -240,45 +240,32 @@ extern "C" { ); } extern "C" { - pub fn c_AcceptContact( + pub fn c_AcceptConversation( profilePtr: *mut ::std::os::raw::c_char, profileLen: ::std::os::raw::c_int, - handlePtr: *mut ::std::os::raw::c_char, - handleLen: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn c_RejectInvite( - profilePtr: *mut ::std::os::raw::c_char, - profileLen: ::std::os::raw::c_int, - handlePtr: *mut ::std::os::raw::c_char, - handleLen: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, ); } extern "C" { pub fn c_BlockContact( profilePtr: *mut ::std::os::raw::c_char, profileLen: ::std::os::raw::c_int, - handlePtr: *mut ::std::os::raw::c_char, - handleLen: ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn c_UpdateMessageFlags( - profile_ptr: *mut ::std::os::raw::c_char, - profile_len: ::std::os::raw::c_int, - handle_ptr: *mut ::std::os::raw::c_char, - handle_len: ::std::os::raw::c_int, - mIdx: ::std::os::raw::c_int, - message_flags: ::std::os::raw::c_ulong, + conversation_id: ::std::os::raw::c_int, ); } extern "C" { pub fn c_GetMessage( profile_ptr: *mut ::std::os::raw::c_char, profile_len: ::std::os::raw::c_int, - handle_ptr: *mut ::std::os::raw::c_char, - handle_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, + message_index: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn c_GetMessageByID( + profile_ptr: *mut ::std::os::raw::c_char, + profile_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, message_index: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_char; } @@ -286,8 +273,7 @@ extern "C" { pub fn c_GetMessagesByContentHash( profile_ptr: *mut ::std::os::raw::c_char, profile_len: ::std::os::raw::c_int, - handle_ptr: *mut ::std::os::raw::c_char, - handle_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, contenthash_ptr: *mut ::std::os::raw::c_char, contenthash_len: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_char; @@ -299,8 +285,7 @@ extern "C" { pub fn c_SendMessage( profile_ptr: *mut ::std::os::raw::c_char, profile_len: ::std::os::raw::c_int, - handle_ptr: *mut ::std::os::raw::c_char, - handle_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, msg_ptr: *mut ::std::os::raw::c_char, msg_len: ::std::os::raw::c_int, ); @@ -309,10 +294,47 @@ extern "C" { pub fn c_SendInvitation( profile_ptr: *mut ::std::os::raw::c_char, profile_len: ::std::os::raw::c_int, - handle_ptr: *mut ::std::os::raw::c_char, - handle_len: ::std::os::raw::c_int, - target_ptr: *mut ::std::os::raw::c_char, - target_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, + target_id: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_ShareFile( + profile_ptr: *mut ::std::os::raw::c_char, + profile_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, + filepath_ptr: *mut ::std::os::raw::c_char, + filepath_len: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_DownloadFile( + profile_ptr: *mut ::std::os::raw::c_char, + profile_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, + filepath_ptr: *mut ::std::os::raw::c_char, + filepath_len: ::std::os::raw::c_int, + manifestpath_ptr: *mut ::std::os::raw::c_char, + manifestpath_len: ::std::os::raw::c_int, + filekey_ptr: *mut ::std::os::raw::c_char, + filekey_len: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_CheckDownloadStatus( + profilePtr: *mut ::std::os::raw::c_char, + profileLen: ::std::os::raw::c_int, + fileKeyPtr: *mut ::std::os::raw::c_char, + fileKeyLen: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_VerifyOrResumeDownload( + profile_ptr: *mut ::std::os::raw::c_char, + profile_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, + filekey_ptr: *mut ::std::os::raw::c_char, + filekey_len: ::std::os::raw::c_int, ); } extern "C" { @@ -340,16 +362,14 @@ extern "C" { pub fn c_ArchiveConversation( profile_ptr: *mut ::std::os::raw::c_char, profile_len: ::std::os::raw::c_int, - contact_ptr: *mut ::std::os::raw::c_char, - contact_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, ); } extern "C" { pub fn c_DeleteContact( profile_ptr: *mut ::std::os::raw::c_char, profile_len: ::std::os::raw::c_int, - hanlde_ptr: *mut ::std::os::raw::c_char, - handle_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, ); } extern "C" { @@ -371,11 +391,10 @@ extern "C" { ); } extern "C" { - pub fn c_SetContactAttribute( + pub fn c_SetConversationAttribute( profile_ptr: *mut ::std::os::raw::c_char, profile_len: ::std::os::raw::c_int, - contact_ptr: *mut ::std::os::raw::c_char, - contact_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, key_ptr: *mut ::std::os::raw::c_char, key_len: ::std::os::raw::c_int, val_ptr: *mut ::std::os::raw::c_char, @@ -383,17 +402,78 @@ extern "C" { ); } extern "C" { - pub fn c_SetGroupAttribute( + pub fn c_SetMessageAttribute( profile_ptr: *mut ::std::os::raw::c_char, profile_len: ::std::os::raw::c_int, - group_ptr: *mut ::std::os::raw::c_char, - group_len: ::std::os::raw::c_int, + conversation_id: ::std::os::raw::c_int, + channel_id: ::std::os::raw::c_int, + message_id: ::std::os::raw::c_int, key_ptr: *mut ::std::os::raw::c_char, key_len: ::std::os::raw::c_int, val_ptr: *mut ::std::os::raw::c_char, val_len: ::std::os::raw::c_int, ); } +extern "C" { + pub fn c_ChangePassword( + profile_ptr: *mut ::std::os::raw::c_char, + profile_len: ::std::os::raw::c_int, + oldpassword_ptr: *mut ::std::os::raw::c_char, + oldpassword_len: ::std::os::raw::c_int, + newpassword_ptr: *mut ::std::os::raw::c_char, + newpassword_len: ::std::os::raw::c_int, + newpassword_again_ptr: *mut ::std::os::raw::c_char, + newpassword_again_len: ::std::os::raw::c_int, + ); +} extern "C" { pub fn c_ShutdownCwtch(); } +extern "C" { + pub fn c_LoadServers( + passwordPtr: *mut ::std::os::raw::c_char, + passwordLen: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_CreateServer( + passwordPtr: *mut ::std::os::raw::c_char, + passwordLen: ::std::os::raw::c_int, + descPtr: *mut ::std::os::raw::c_char, + descLen: ::std::os::raw::c_int, + autostart: ::std::os::raw::c_char, + ); +} +extern "C" { + pub fn c_DeleteServer( + onionPtr: *mut ::std::os::raw::c_char, + onionLen: ::std::os::raw::c_int, + currentPasswordPtr: *mut ::std::os::raw::c_char, + currentPasswordLen: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_LaunchServers(); +} +extern "C" { + pub fn c_LaunchServer(onionPtr: *mut ::std::os::raw::c_char, onionLen: ::std::os::raw::c_int); +} +extern "C" { + pub fn c_StopServer(onionPtr: *mut ::std::os::raw::c_char, onionLen: ::std::os::raw::c_int); +} +extern "C" { + pub fn c_StopServers(); +} +extern "C" { + pub fn c_DestroyServers(); +} +extern "C" { + pub fn c_SetServerAttribute( + onionPtr: *mut ::std::os::raw::c_char, + onionLen: ::std::os::raw::c_int, + keyPtr: *mut ::std::os::raw::c_char, + keyLen: ::std::os::raw::c_int, + valPtr: *mut ::std::os::raw::c_char, + valLen: ::std::os::raw::c_int, + ); +}