diff --git a/Cargo.lock b/Cargo.lock index 0a75f46..86b88a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -215,7 +215,7 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libcwtch" -version = "0.6.1" +version = "0.7.0" dependencies = [ "bindgen", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 73717c1..c2f163b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libcwtch" -version = "0.6.1" +version = "0.7.0" authors = ["Dan Ballard "] edition = "2018" license = "MIT" diff --git a/build.rs b/build.rs index 9069a46..0f8c10d 100644 --- a/build.rs +++ b/build.rs @@ -44,18 +44,18 @@ fn main() { if std::env::var("LCG_DIR").is_err() { // https://git.openprivacy.ca/cwtch.im/libcwtch-go/releases v1.7.1 Command::new("wget") - .arg("https://git.openprivacy.ca/attachments/cacefb43-8292-4350-a1d6-b416847854aa") + .arg("https://git.openprivacy.ca/attachments/888a3255-0b9e-430d-b164-84322fa96ae0") .arg("-O") .arg(lib_cwtch_path.clone()) .output() - .expect("failed to download libCwtch.so"); + .expect("failed to download libCwtch.x64.so"); let mut hasher = Sha512::new(); let mut file = fs::File::open(&lib_cwtch_path).expect("could not open lib to hash"); io::copy(&mut file, &mut hasher).expect("failed to copy file into hasher"); let hash_bytes = hasher.finalize(); - assert_eq!(hash_bytes[..], hex!("1b05a0e6a7ced043aa441dfecb0a3c7d0412955de57946299bb80a763a54620f56cc3b08dde82913a0cd626668a26a0609d44015f7eb6f738789f3100c99ec14")[..]); + assert_eq!(hash_bytes[..], hex!("98b34082987cc293b42de2e92f990d84c1c7978222ce4e343dd135b46a014f0d5f2e8f8e3de1ebe41354bf9e221edb57f4e252ce9542cbb865fe699dd606f102")[..]); } else { let local_lcg = Path::new(std::env::var("LCG_DIR").unwrap().as_str()).join("libCwtch.so"); fs::copy(local_lcg, lib_cwtch_path).expect("could not find local lcg"); diff --git a/libCwtch.h b/libCwtch.h index 14f1f9d..88f6e9e 100644 --- a/libCwtch.h +++ b/libCwtch.h @@ -16,7 +16,6 @@ typedef struct { const char *p; ptrdiff_t n; } _GoString_; #endif - /* Start of boilerplate cgo prologue. */ #line 1 "cgo-gcc-export-header-prolog" @@ -88,42 +87,50 @@ extern void c_UpdateSettings(char* json_ptr, int json_len); extern char* c_GetDebugInfo(); extern void c_ActivatePeerEngine(char* onion_ptr, int onion_len); extern void c_DeactivatePeerEngine(char* onion_ptr, int onion_len); -extern void c_CreateProfile(char* name_ptr, int name_len, char* password_ptr, int password_len, char autostart1); +extern void c_ConfigureConnections(char* onion_ptr, int onion_len, char listen1, char peers2, char servers3); +extern void c_CreateProfile(char* name_ptr, int name_len, char* password_ptr, int password_len, char autostart4); extern void c_LoadProfiles(char* password_ptr, int password_len); extern void c_DeleteProfile(char* onion_ptr, int onion_len, char* password_ptr, int password_len); -extern char* c_ImportProfile(char* file2_ptr, int file2_len, char* password_ptr, int password_len); -extern void c_ChangePassword(char* onion_ptr, int onion_len, char* current3_ptr, int current3_len, char* newPassword4_ptr, int newPassword4_len, char* newPasswordAgain5_ptr, int newPasswordAgain5_len); -extern void c_ExportProfile(char* onion_ptr, int onion_len, char* file6_ptr, int file6_len); -extern char* c_ImportBundle(char* onion_ptr, int onion_len, char* bundle7_ptr, int bundle7_len); +extern char* c_ImportProfile(char* file5_ptr, int file5_len, char* password_ptr, int password_len); +extern void c_ChangePassword(char* onion_ptr, int onion_len, char* current6_ptr, int current6_len, char* newPassword7_ptr, int newPassword7_len, char* newPasswordAgain8_ptr, int newPasswordAgain8_len); +extern void c_ExportProfile(char* onion_ptr, int onion_len, char* file9_ptr, int file9_len); +extern char* c_ImportBundle(char* onion_ptr, int onion_len, char* bundle10_ptr, int bundle10_len); extern void c_ArchiveConversation(char* onion_ptr, int onion_len, int conversation); extern void c_AcceptConversation(char* onion_ptr, int onion_len, int conversation); extern void c_BlockConversation(char* onion_ptr, int onion_len, int conversation); extern void c_UnblockConversation(char* onion_ptr, int onion_len, int conversation); extern void c_DeleteConversation(char* onion_ptr, int onion_len, int conversation); -extern void c_PeerWithOnion(char* onion_ptr, int onion_len, char* handle8_ptr, int handle8_len); -extern char* c_SendMessage(char* onion_ptr, int onion_len, int conversation, char* msg9_ptr, int msg9_len); +extern void c_PeerWithOnion(char* onion_ptr, int onion_len, char* handle11_ptr, int handle11_len); +extern void c_DisconnectFromPeer(char* onion_ptr, int onion_len, char* handle12_ptr, int handle12_len); +extern char* c_SearchConversations(char* onion_ptr, int onion_len, char* pattern13_ptr, int pattern13_len); +extern char* c_SendMessage(char* onion_ptr, int onion_len, int conversation, char* msg14_ptr, int msg14_len); extern char* c_GetMessageById(char* onion_ptr, int onion_len, int conversation, int message_id); -extern char* c_GetMessageByContentHash(char* onion_ptr, int onion_len, int conversation, char* contentHash10_ptr, int contentHash10_len); +extern char* c_GetMessageByContentHash(char* onion_ptr, int onion_len, int conversation, char* contentHash15_ptr, int contentHash15_len); extern char* c_GetMessages(char* onion_ptr, int onion_len, int conversation, int index, int count); extern char* c_SendInviteMessage(char* onion_ptr, int onion_len, int conversation, int target); -extern void c_UpdateMessageAttribute(char* onion_ptr, int onion_len, int conversation, int channel_id, int message_id, char* attributeKey11_ptr, int attributeKey11_len, char* attributeValue12_ptr, int attributeValue12_len); -extern void c_StartGroup(char* onion_ptr, int onion_len, char* name13_ptr, int name13_len, char* server14_ptr, int server14_len); -extern void c_DownloadFileDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filepath15_ptr, int filepath15_len, char* manifest16_ptr, int manifest16_len, char* filekey17_ptr, int filekey17_len); -extern void c_RestartFileShare(char* onion_ptr, int onion_len, char* filekey18_ptr, int filekey18_len); -extern void c_StopFileShare(char* onion_ptr, int onion_len, char* filekey19_ptr, int filekey19_len); -extern void c_CheckDownloadStatus(char* onion_ptr, int onion_len, char* filekey20_ptr, int filekey20_len); -extern void c_VerifyOrResumeDownloadDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filekey21_ptr, int filekey21_len); -extern char* c_ShareFile(char* onion_ptr, int onion_len, int conversation, char* filepath22_ptr, int filepath22_len); +extern void c_UpdateMessageAttribute(char* onion_ptr, int onion_len, int conversation, int channel_id, int message_id, char* attributeKey16_ptr, int attributeKey16_len, char* attributeValue17_ptr, int attributeValue17_len); +extern void c_StartGroup(char* onion_ptr, int onion_len, char* name18_ptr, int name18_len, char* server19_ptr, int server19_len); +extern void c_QueueJoinServer(char* onion_ptr, int onion_len, char* handle20_ptr, int handle20_len); +extern void c_DisconnectFromServer(char* onion_ptr, int onion_len, char* handle21_ptr, int handle21_len); +extern void c_PublishServerUpdate(char* onion_ptr, int onion_len); +extern void c_GetServerInfoList(char* onion_ptr, int onion_len); +extern void c_DeleteServerInfo(char* onion_ptr, int onion_len, char* serverOnion22_ptr, int serverOnion22_len); +extern void c_DownloadFileDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filepath23_ptr, int filepath23_len, char* manifest24_ptr, int manifest24_len, char* filekey25_ptr, int filekey25_len); +extern void c_RestartFileShare(char* onion_ptr, int onion_len, char* filekey26_ptr, int filekey26_len); +extern void c_StopFileShare(char* onion_ptr, int onion_len, char* filekey27_ptr, int filekey27_len); +extern void c_CheckDownloadStatus(char* onion_ptr, int onion_len, char* filekey28_ptr, int filekey28_len); +extern void c_VerifyOrResumeDownloadDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filekey29_ptr, int filekey29_len); +extern char* c_ShareFile(char* onion_ptr, int onion_len, int conversation, char* filepath30_ptr, int filepath30_len); extern char* c_GetSharedFiles(char* onion_ptr, int onion_len, int conversation); -extern void c_CreateServer(char* password_ptr, int password_len, char* description23_ptr, int description23_len, char autostart24); -extern void c_SetServerAttribute(char* handle25_ptr, int handle25_len, char* key26_ptr, int key26_len, char* val27_ptr, int val27_len); +extern void c_CreateServer(char* password_ptr, int password_len, char* description31_ptr, int description31_len, char autostart32); +extern void c_SetServerAttribute(char* handle33_ptr, int handle33_len, char* key34_ptr, int key34_len, char* val35_ptr, int val35_len); extern void c_LoadServers(char* password_ptr, int password_len); extern void c_LaunchServers(); -extern void c_LaunchServer(char* handle28_ptr, int handle28_len); -extern void c_StopServer(char* handle29_ptr, int handle29_len); +extern void c_LaunchServer(char* handle36_ptr, int handle36_len); +extern void c_StopServer(char* handle37_ptr, int handle37_len); extern void c_StopServers(); extern void c_DestroyServers(); -extern void c_DeleteServer(char* handle30_ptr, int handle30_len, char* password_ptr, int password_len); +extern void c_DeleteServer(char* handle38_ptr, int handle38_len, char* password_ptr, int password_len); #ifdef __cplusplus } diff --git a/src/bindings_go.rs b/src/bindings_go.rs index d2d9921..16489eb 100644 --- a/src/bindings_go.rs +++ b/src/bindings_go.rs @@ -100,12 +100,15 @@ impl CwtchLibGo { c_bind!(_get_profile_attribute(profile: &str, key: &str;;) c_GetProfileAttribute -> String); c_bind!(_get_conversation_attribute(profile: &str; conversation_id: i32; key: &str) c_GetConversationAttribute -> String); c_bind!(_get_appbus_event(;;) c_GetAppBusEvent -> String); + c_bind!(_configure_connections(profile: &str; listen: c_bool, peers: c_bool, servers: c_bool;) c_ConfigureConnections); c_bind!(_create_profile(nick: &str, pass: &str; autostart: c_bool;) c_CreateProfile); c_bind!(_activate_peer_engine(profile: &str;;) c_ActivatePeerEngine); c_bind!(_deactivate_peer_engine(profile: &str;;) c_DeactivatePeerEngine); c_bind!(_accept_conversation(profile: &str ; conversation_id: i32; ) c_AcceptConversation); c_bind!(_block_conversation(profile: &str ; conversation_id: i32; ) c_BlockConversation); c_bind!(_unblock_conversation(profile: &str ; conversation_id: i32; ) c_UnblockConversation); + c_bind!(_disconnect_from_peer(profile: &str, peer_address: &str;;) c_DisconnectFromPeer); + c_bind!(_search_conversations(profile: &str, pattern: &str;;) c_SearchConversations -> String); c_bind!(_get_message_by_id(profile: &str ; conversation_id: i32, message_id: i32 ;) c_GetMessageById -> String); c_bind!(_get_message_by_content_hash(profile: &str ; conversation_id: i32 ; hash: &str) c_GetMessageByContentHash -> String); c_bind!(_get_messages(profile: &str; conversation_id: i32, message_index: i32, count: i32 ;) c_GetMessages -> String); @@ -119,6 +122,11 @@ impl CwtchLibGo { c_bind!(_check_download_status(profile: &str, file_key: &str;;) c_CheckDownloadStatus); c_bind!(_verify_or_resume_download(profile: &str; conversation_id: i32; file_key: &str) c_VerifyOrResumeDownloadDefaultLimit); c_bind!(_start_group(profile: &str, name: &str, server: &str;;) c_StartGroup); + c_bind!(_queue_join_server(profile: &str, server: &str;;) c_QueueJoinServer); + c_bind!(_disconnect_from_server(profile: &str, server: &str;;) c_DisconnectFromServer); + c_bind!(_publish_server_update(profile: &str;;) c_PublishServerUpdate); + c_bind!(_get_server_info_list(profile: &str;;) c_GetServerInfoList); + c_bind!(_delete_server_info(profile: &str, server: &str;;) c_DeleteServerInfo); c_bind!(_delete_profile(profile: &str, pass: &str;;) c_DeleteProfile); c_bind!(_archive_conversation(profile: &str; conversation_id: i32;) c_ArchiveConversation); c_bind!(_delete_conversation(profile: &str; conversation_id: i32;) c_DeleteConversation); @@ -156,6 +164,12 @@ impl CwtchLib for CwtchLibGo { fn deactivate_peer_engine(&self, profile: &ProfileIdentity) { self._deactivate_peer_engine(profile.as_str()) } + fn configure_connections(&self, profile: &ProfileIdentity, listen: bool, peers: bool, servers: bool) { + self._configure_connections(profile.as_str(), to_c_bool(listen), to_c_bool(peers), to_c_bool(servers)) + } + fn search_conversations(&self, profile: &ProfileIdentity, pattern: &str) -> String { + self._search_conversations(profile.as_str(), pattern) + } c_bind!(load_profiles(pass: &str;;) c_LoadProfiles); fn accept_conversation(&self, profile: &ProfileIdentity, conversation_id: ConversationID) { @@ -172,6 +186,10 @@ impl CwtchLib for CwtchLibGo { fn unblock_conversation(&self, profile: &ProfileIdentity, conversation_id: ConversationID) { self._unblock_conversation(String::from(profile).as_str(), conversation_id.into()) } + fn disconnect_from_peer(&self, profile: &ProfileIdentity, peer_id: &str) { + self._disconnect_from_peer(profile.as_str(), peer_id) + } + fn get_message_by_id(&self, profile: &ProfileIdentity, conversation_id: ConversationID, message_id: i32) -> String { self._get_message_by_id(String::from(profile).as_str(), conversation_id.into(), message_id) } @@ -228,6 +246,21 @@ impl CwtchLib for CwtchLibGo { fn start_group(&self, profile: &ProfileIdentity, server: &str, name: &str) { self._start_group(String::from(profile).as_str(), server, name) } + fn queue_join_server(&self, profile: &ProfileIdentity, server: &ServerIdentity) { + self._queue_join_server(profile.as_str(), server.as_str()) + } + fn disconnect_from_server(&self, profile: &ProfileIdentity, server: &ServerIdentity) { + self._disconnect_from_server(profile.as_str(), server.as_str()) + } + fn publish_server_update(&self, profile: &ProfileIdentity) { + self._publish_server_update(profile.as_str()) + } + fn get_server_info_list(&self, profile: &ProfileIdentity) { + self._get_server_info_list(profile.as_str()) + } + fn delete_server_info(&self, profile: &ProfileIdentity, server: &ServerIdentity) { + self._delete_server_info(profile.as_str(), server.as_str()) + } fn delete_profile(&self, profile: &ProfileIdentity, pass: &str) { self._delete_profile(String::from(profile).as_str(), pass) } diff --git a/src/cwtchlib_go/bindings.rs b/src/cwtchlib_go/bindings.rs index becea9e..46be707 100644 --- a/src/cwtchlib_go/bindings.rs +++ b/src/cwtchlib_go/bindings.rs @@ -285,13 +285,22 @@ extern "C" { onion_len: ::std::os::raw::c_int, ); } +extern "C" { + pub fn c_ConfigureConnections( + onion_ptr: *mut ::std::os::raw::c_char, + onion_len: ::std::os::raw::c_int, + listen1: ::std::os::raw::c_char, + peers2: ::std::os::raw::c_char, + servers3: ::std::os::raw::c_char, + ); +} extern "C" { pub fn c_CreateProfile( name_ptr: *mut ::std::os::raw::c_char, name_len: ::std::os::raw::c_int, password_ptr: *mut ::std::os::raw::c_char, password_len: ::std::os::raw::c_int, - autostart1: ::std::os::raw::c_char, + autostart4: ::std::os::raw::c_char, ); } extern "C" { @@ -310,8 +319,8 @@ extern "C" { } extern "C" { pub fn c_ImportProfile( - file2_ptr: *mut ::std::os::raw::c_char, - file2_len: ::std::os::raw::c_int, + file5_ptr: *mut ::std::os::raw::c_char, + file5_len: ::std::os::raw::c_int, password_ptr: *mut ::std::os::raw::c_char, password_len: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_char; @@ -320,28 +329,28 @@ extern "C" { pub fn c_ChangePassword( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, - current3_ptr: *mut ::std::os::raw::c_char, - current3_len: ::std::os::raw::c_int, - newPassword4_ptr: *mut ::std::os::raw::c_char, - newPassword4_len: ::std::os::raw::c_int, - newPasswordAgain5_ptr: *mut ::std::os::raw::c_char, - newPasswordAgain5_len: ::std::os::raw::c_int, + current6_ptr: *mut ::std::os::raw::c_char, + current6_len: ::std::os::raw::c_int, + newPassword7_ptr: *mut ::std::os::raw::c_char, + newPassword7_len: ::std::os::raw::c_int, + newPasswordAgain8_ptr: *mut ::std::os::raw::c_char, + newPasswordAgain8_len: ::std::os::raw::c_int, ); } extern "C" { pub fn c_ExportProfile( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, - file6_ptr: *mut ::std::os::raw::c_char, - file6_len: ::std::os::raw::c_int, + file9_ptr: *mut ::std::os::raw::c_char, + file9_len: ::std::os::raw::c_int, ); } extern "C" { pub fn c_ImportBundle( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, - bundle7_ptr: *mut ::std::os::raw::c_char, - bundle7_len: ::std::os::raw::c_int, + bundle10_ptr: *mut ::std::os::raw::c_char, + bundle10_len: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_char; } extern "C" { @@ -383,17 +392,33 @@ extern "C" { pub fn c_PeerWithOnion( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, - handle8_ptr: *mut ::std::os::raw::c_char, - handle8_len: ::std::os::raw::c_int, + handle11_ptr: *mut ::std::os::raw::c_char, + handle11_len: ::std::os::raw::c_int, ); } +extern "C" { + pub fn c_DisconnectFromPeer( + onion_ptr: *mut ::std::os::raw::c_char, + onion_len: ::std::os::raw::c_int, + handle12_ptr: *mut ::std::os::raw::c_char, + handle12_len: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_SearchConversations( + onion_ptr: *mut ::std::os::raw::c_char, + onion_len: ::std::os::raw::c_int, + pattern13_ptr: *mut ::std::os::raw::c_char, + pattern13_len: ::std::os::raw::c_int, + ) -> *mut ::std::os::raw::c_char; +} extern "C" { pub fn c_SendMessage( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, conversation: ::std::os::raw::c_int, - msg9_ptr: *mut ::std::os::raw::c_char, - msg9_len: ::std::os::raw::c_int, + msg14_ptr: *mut ::std::os::raw::c_char, + msg14_len: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_char; } extern "C" { @@ -409,8 +434,8 @@ extern "C" { onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, conversation: ::std::os::raw::c_int, - contentHash10_ptr: *mut ::std::os::raw::c_char, - contentHash10_len: ::std::os::raw::c_int, + contentHash15_ptr: *mut ::std::os::raw::c_char, + contentHash15_len: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_char; } extern "C" { @@ -437,20 +462,56 @@ extern "C" { conversation: ::std::os::raw::c_int, channel_id: ::std::os::raw::c_int, message_id: ::std::os::raw::c_int, - attributeKey11_ptr: *mut ::std::os::raw::c_char, - attributeKey11_len: ::std::os::raw::c_int, - attributeValue12_ptr: *mut ::std::os::raw::c_char, - attributeValue12_len: ::std::os::raw::c_int, + attributeKey16_ptr: *mut ::std::os::raw::c_char, + attributeKey16_len: ::std::os::raw::c_int, + attributeValue17_ptr: *mut ::std::os::raw::c_char, + attributeValue17_len: ::std::os::raw::c_int, ); } extern "C" { pub fn c_StartGroup( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, - name13_ptr: *mut ::std::os::raw::c_char, - name13_len: ::std::os::raw::c_int, - server14_ptr: *mut ::std::os::raw::c_char, - server14_len: ::std::os::raw::c_int, + name18_ptr: *mut ::std::os::raw::c_char, + name18_len: ::std::os::raw::c_int, + server19_ptr: *mut ::std::os::raw::c_char, + server19_len: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_QueueJoinServer( + onion_ptr: *mut ::std::os::raw::c_char, + onion_len: ::std::os::raw::c_int, + handle20_ptr: *mut ::std::os::raw::c_char, + handle20_len: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_DisconnectFromServer( + onion_ptr: *mut ::std::os::raw::c_char, + onion_len: ::std::os::raw::c_int, + handle21_ptr: *mut ::std::os::raw::c_char, + handle21_len: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_PublishServerUpdate( + onion_ptr: *mut ::std::os::raw::c_char, + onion_len: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_GetServerInfoList( + onion_ptr: *mut ::std::os::raw::c_char, + onion_len: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn c_DeleteServerInfo( + onion_ptr: *mut ::std::os::raw::c_char, + onion_len: ::std::os::raw::c_int, + serverOnion22_ptr: *mut ::std::os::raw::c_char, + serverOnion22_len: ::std::os::raw::c_int, ); } extern "C" { @@ -458,36 +519,36 @@ extern "C" { onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, conversation: ::std::os::raw::c_int, - filepath15_ptr: *mut ::std::os::raw::c_char, - filepath15_len: ::std::os::raw::c_int, - manifest16_ptr: *mut ::std::os::raw::c_char, - manifest16_len: ::std::os::raw::c_int, - filekey17_ptr: *mut ::std::os::raw::c_char, - filekey17_len: ::std::os::raw::c_int, + filepath23_ptr: *mut ::std::os::raw::c_char, + filepath23_len: ::std::os::raw::c_int, + manifest24_ptr: *mut ::std::os::raw::c_char, + manifest24_len: ::std::os::raw::c_int, + filekey25_ptr: *mut ::std::os::raw::c_char, + filekey25_len: ::std::os::raw::c_int, ); } extern "C" { pub fn c_RestartFileShare( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, - filekey18_ptr: *mut ::std::os::raw::c_char, - filekey18_len: ::std::os::raw::c_int, + filekey26_ptr: *mut ::std::os::raw::c_char, + filekey26_len: ::std::os::raw::c_int, ); } extern "C" { pub fn c_StopFileShare( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, - filekey19_ptr: *mut ::std::os::raw::c_char, - filekey19_len: ::std::os::raw::c_int, + filekey27_ptr: *mut ::std::os::raw::c_char, + filekey27_len: ::std::os::raw::c_int, ); } extern "C" { pub fn c_CheckDownloadStatus( onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, - filekey20_ptr: *mut ::std::os::raw::c_char, - filekey20_len: ::std::os::raw::c_int, + filekey28_ptr: *mut ::std::os::raw::c_char, + filekey28_len: ::std::os::raw::c_int, ); } extern "C" { @@ -495,8 +556,8 @@ extern "C" { onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, conversation: ::std::os::raw::c_int, - filekey21_ptr: *mut ::std::os::raw::c_char, - filekey21_len: ::std::os::raw::c_int, + filekey29_ptr: *mut ::std::os::raw::c_char, + filekey29_len: ::std::os::raw::c_int, ); } extern "C" { @@ -504,8 +565,8 @@ extern "C" { onion_ptr: *mut ::std::os::raw::c_char, onion_len: ::std::os::raw::c_int, conversation: ::std::os::raw::c_int, - filepath22_ptr: *mut ::std::os::raw::c_char, - filepath22_len: ::std::os::raw::c_int, + filepath30_ptr: *mut ::std::os::raw::c_char, + filepath30_len: ::std::os::raw::c_int, ) -> *mut ::std::os::raw::c_char; } extern "C" { @@ -519,19 +580,19 @@ extern "C" { pub fn c_CreateServer( password_ptr: *mut ::std::os::raw::c_char, password_len: ::std::os::raw::c_int, - description23_ptr: *mut ::std::os::raw::c_char, - description23_len: ::std::os::raw::c_int, - autostart24: ::std::os::raw::c_char, + description31_ptr: *mut ::std::os::raw::c_char, + description31_len: ::std::os::raw::c_int, + autostart32: ::std::os::raw::c_char, ); } extern "C" { pub fn c_SetServerAttribute( - handle25_ptr: *mut ::std::os::raw::c_char, - handle25_len: ::std::os::raw::c_int, - key26_ptr: *mut ::std::os::raw::c_char, - key26_len: ::std::os::raw::c_int, - val27_ptr: *mut ::std::os::raw::c_char, - val27_len: ::std::os::raw::c_int, + handle33_ptr: *mut ::std::os::raw::c_char, + handle33_len: ::std::os::raw::c_int, + key34_ptr: *mut ::std::os::raw::c_char, + key34_len: ::std::os::raw::c_int, + val35_ptr: *mut ::std::os::raw::c_char, + val35_len: ::std::os::raw::c_int, ); } extern "C" { @@ -545,14 +606,14 @@ extern "C" { } extern "C" { pub fn c_LaunchServer( - handle28_ptr: *mut ::std::os::raw::c_char, - handle28_len: ::std::os::raw::c_int, + handle36_ptr: *mut ::std::os::raw::c_char, + handle36_len: ::std::os::raw::c_int, ); } extern "C" { pub fn c_StopServer( - handle29_ptr: *mut ::std::os::raw::c_char, - handle29_len: ::std::os::raw::c_int, + handle37_ptr: *mut ::std::os::raw::c_char, + handle37_len: ::std::os::raw::c_int, ); } extern "C" { @@ -563,8 +624,8 @@ extern "C" { } extern "C" { pub fn c_DeleteServer( - handle30_ptr: *mut ::std::os::raw::c_char, - handle30_len: ::std::os::raw::c_int, + handle38_ptr: *mut ::std::os::raw::c_char, + handle38_len: ::std::os::raw::c_int, password_ptr: *mut ::std::os::raw::c_char, password_len: ::std::os::raw::c_int, ); diff --git a/src/event.rs b/src/event.rs index 5f08917..71592f7 100644 --- a/src/event.rs +++ b/src/event.rs @@ -88,6 +88,12 @@ impl From for GroupID { } } +impl GroupID { + /// Get &str of GroupID String + pub fn as_str(&self) -> &str { + self.0.as_str() + } +} #[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq)] /// Server ID user to refer to a server in Cwtch @@ -111,6 +117,13 @@ impl From for String { } } +impl ServerIdentity { + /// Get &str of ServerIdentity String + pub fn as_str(&self) -> &str { + self.0.as_str() + } +} + #[derive(Debug, Clone, Serialize, Deserialize, Hash, Eq, PartialEq)] /// FileKey ID user to refer to a file share in Cwtch pub struct FileKey(String); diff --git a/src/lib.rs b/src/lib.rs index 8a96365..1a10b98 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,9 @@ pub trait CwtchLib { /// Pull json of a structs::CwtchEvent off the appbus for responding to fn get_appbus_event(&self) -> Event; + /// configure a peer's connection settings, listen for incoming connections, connect to peers and connect to servers. + fn configure_connections(&self, profile: &ProfileIdentity, listen: bool, peers: bool, servers: bool); + /// Create a new profile encrypted with pass fn create_profile(&self, nick: &str, pass: &str, autostart: bool); @@ -59,6 +62,12 @@ pub trait CwtchLib { /// Attempt to peer with a a new peer fn peer_with(&self, profile: &ProfileIdentity, new_peer_address: &str); + /// manually disconnect from a conversation + fn disconnect_from_peer(&self, profile: &ProfileIdentity, peer_id: &str); + + /// starts a search process on a profile for pattern. returns a searchID that resulting SearchResult messages will have + fn search_conversations(&self, profile: &ProfileIdentity, pattern: &str) -> String; + /// Get a specific message for a conversation by its id fn get_message_by_id(&self, profile: &ProfileIdentity, conversation_id: ConversationID, message_id: i32) -> String; @@ -116,6 +125,21 @@ pub trait CwtchLib { /// Cause profile to create a group on server with name fn start_group(&self, profile: &ProfileIdentity, name: &str, server: &str); + /// Queue joining a server in the out going connections queue + fn queue_join_server(&self, profile: &ProfileIdentity, server: &ServerIdentity); + + /// Disconnect from a specific server + fn disconnect_from_server(&self, profile: &ProfileIdentity, server: &ServerIdentity); + + /// Publish server status updates for a profile + fn publish_server_update(&self, profile: &ProfileIdentity); + + /// Get list of known servers for a profile + fn get_server_info_list(&self, profile: &ProfileIdentity); + + /// Delete server information from a profile, preventing future connections for all groups hosted on it + fn delete_server_info(&self, profile: &ProfileIdentity, server: &ServerIdentity); + /// Delete profile with encryption/password check of pass fn delete_profile(&self, profile: &ProfileIdentity, pass: &str);