Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Dan Ballard | a148e1af47 | |
Dan Ballard | 98571f5559 | |
Dan Ballard | 94a9a3448e |
|
@ -215,7 +215,7 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
|||
|
||||
[[package]]
|
||||
name = "libcwtch"
|
||||
version = "0.6.1"
|
||||
version = "0.8.0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"chrono",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "libcwtch"
|
||||
version = "0.6.1"
|
||||
version = "0.8.0"
|
||||
authors = ["Dan Ballard <dan@mindstab.net>"]
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
|
|
9
build.rs
9
build.rs
|
@ -42,20 +42,19 @@ fn main() {
|
|||
|
||||
let lib_cwtch_path = Path::new(&out_dir).join("libCwtch.so");
|
||||
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")
|
||||
Command::new("wget")
|
||||
.arg("https://git.openprivacy.ca/cwtch.im/autobindings/releases/download/v0.0.12/libCwtch.x64.so")
|
||||
.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!("a3742e0cdedc00eb3673063b100b7596b05bdc9bb68a0fba6fd2423c9a41f1653597c4d44ba3877be08cbb5bba2806435830061ab3517cdd4472a18c7557d9c7")[..]);
|
||||
} 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");
|
||||
|
|
55
libCwtch.h
55
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,52 @@ 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_GetConversationAccessControlList(char* onion_ptr, int onion_len, int conversation);
|
||||
extern void c_UpdateConversationAccessControlList(char* onion_ptr, int onion_len, int conversation, char* json13_ptr, int json13_len);
|
||||
extern char* c_SearchConversations(char* onion_ptr, int onion_len, char* pattern14_ptr, int pattern14_len);
|
||||
extern char* c_SendMessage(char* onion_ptr, int onion_len, int conversation, char* msg15_ptr, int msg15_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_GetMessages(char* onion_ptr, int onion_len, int conversation, int index, int count);
|
||||
extern char* c_GetMessageByContentHash(char* onion_ptr, int onion_len, int conversation, char* contentHash16_ptr, int contentHash16_len);
|
||||
extern char* c_GetMessages(char* onion_ptr, int onion_len, int conversation, int index, unsigned 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* attributeKey17_ptr, int attributeKey17_len, char* attributeValue18_ptr, int attributeValue18_len);
|
||||
extern void c_StartGroup(char* onion_ptr, int onion_len, char* name19_ptr, int name19_len, char* server20_ptr, int server20_len);
|
||||
extern void c_QueueJoinServer(char* onion_ptr, int onion_len, char* handle21_ptr, int handle21_len);
|
||||
extern void c_DisconnectFromServer(char* onion_ptr, int onion_len, char* handle22_ptr, int handle22_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* serverOnion23_ptr, int serverOnion23_len);
|
||||
extern void c_DownloadFileDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filepath24_ptr, int filepath24_len, char* manifest25_ptr, int manifest25_len, char* filekey26_ptr, int filekey26_len);
|
||||
extern void c_RestartFileShare(char* onion_ptr, int onion_len, char* filekey27_ptr, int filekey27_len);
|
||||
extern void c_StopFileShare(char* onion_ptr, int onion_len, char* filekey28_ptr, int filekey28_len);
|
||||
extern void c_CheckDownloadStatus(char* onion_ptr, int onion_len, char* filekey29_ptr, int filekey29_len);
|
||||
extern void c_VerifyOrResumeDownloadDefaultLimit(char* onion_ptr, int onion_len, int conversation, char* filekey30_ptr, int filekey30_len);
|
||||
extern char* c_ShareFile(char* onion_ptr, int onion_len, int conversation, char* filepath31_ptr, int filepath31_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* description32_ptr, int description32_len, char autostart33);
|
||||
extern void c_SetServerAttribute(char* handle34_ptr, int handle34_len, char* key35_ptr, int key35_len, char* val36_ptr, int val36_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* handle37_ptr, int handle37_len);
|
||||
extern void c_StopServer(char* handle38_ptr, int handle38_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* handle39_ptr, int handle39_len, char* password_ptr, int password_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -100,15 +100,20 @@ 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_conversation_access_control_list(profile: &str; conversation_id: i32;) c_GetConversationAccessControlList -> String);
|
||||
c_bind!(_update_conversation_access_control_list(profile: &str; conversation_id: i32; acl: &str) c_UpdateConversationAccessControlList);
|
||||
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);
|
||||
c_bind!(_get_messages(profile: &str; conversation_id: i32, message_index: i32, count: u32 ;) c_GetMessages -> String);
|
||||
c_bind!(_send_message(profile: &str; conversation_id: i32; msg: &str) c_SendMessage -> String);
|
||||
c_bind!(_send_invite_message(profile: &str; conversation_id: i32, target_id: i32;) c_SendInviteMessage -> String);
|
||||
c_bind!(_share_file(profile: &str; conversation_id: i32; file_path: &str) c_ShareFile -> String);
|
||||
|
@ -119,6 +124,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 +166,28 @@ 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)
|
||||
}
|
||||
|
||||
fn get_conversation_access_control_list(&self, profile: &ProfileIdentity, conversation_id: ConversationID) -> Result<ACL, CwtchError> {
|
||||
let json = self._get_conversation_access_control_list(profile.as_str(), conversation_id.into());
|
||||
|
||||
match serde_json::from_str(&json) {
|
||||
Ok(acl) => Ok(acl),
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
fn update_conversation_access_control_list(&self, profile: &ProfileIdentity, conversation_id: ConversationID, acl: ACL) {
|
||||
match serde_json::to_string(&acl) {
|
||||
Ok(acl_json) => self._update_conversation_access_control_list(profile.as_str(), conversation_id.into(), &acl_json),
|
||||
Err(_) => return,
|
||||
};
|
||||
}
|
||||
|
||||
c_bind!(load_profiles(pass: &str;;) c_LoadProfiles);
|
||||
fn accept_conversation(&self, profile: &ProfileIdentity, conversation_id: ConversationID) {
|
||||
|
@ -172,13 +204,17 @@ 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)
|
||||
}
|
||||
fn get_message_by_content_hash(&self, profile: &ProfileIdentity, conversation_id: ConversationID, hash: &str) -> String {
|
||||
self._get_message_by_content_hash(String::from(profile).as_str(), conversation_id.into(), hash)
|
||||
}
|
||||
fn get_messages(&self, profile: &ProfileIdentity, conversation_id: ConversationID, message_index: i32, count: i32) -> String {
|
||||
fn get_messages(&self, profile: &ProfileIdentity, conversation_id: ConversationID, message_index: i32, count: u32) -> String {
|
||||
self._get_messages(String::from(profile).as_str(), conversation_id.into(), message_index, count)
|
||||
}
|
||||
fn send_message_raw(&self, profile: &ProfileIdentity, conversation_id: ConversationID, msg: &str) -> String {
|
||||
|
@ -228,6 +264,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)
|
||||
}
|
||||
|
|
|
@ -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,49 @@ 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_GetConversationAccessControlList(
|
||||
onion_ptr: *mut ::std::os::raw::c_char,
|
||||
onion_len: ::std::os::raw::c_int,
|
||||
conversation: ::std::os::raw::c_int,
|
||||
) -> *mut ::std::os::raw::c_char;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn c_UpdateConversationAccessControlList(
|
||||
onion_ptr: *mut ::std::os::raw::c_char,
|
||||
onion_len: ::std::os::raw::c_int,
|
||||
conversation: ::std::os::raw::c_int,
|
||||
json13_ptr: *mut ::std::os::raw::c_char,
|
||||
json13_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,
|
||||
pattern14_ptr: *mut ::std::os::raw::c_char,
|
||||
pattern14_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,
|
||||
msg15_ptr: *mut ::std::os::raw::c_char,
|
||||
msg15_len: ::std::os::raw::c_int,
|
||||
) -> *mut ::std::os::raw::c_char;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -409,8 +450,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,
|
||||
contentHash16_ptr: *mut ::std::os::raw::c_char,
|
||||
contentHash16_len: ::std::os::raw::c_int,
|
||||
) -> *mut ::std::os::raw::c_char;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -419,7 +460,7 @@ extern "C" {
|
|||
onion_len: ::std::os::raw::c_int,
|
||||
conversation: ::std::os::raw::c_int,
|
||||
index: ::std::os::raw::c_int,
|
||||
count: ::std::os::raw::c_int,
|
||||
count: ::std::os::raw::c_uint,
|
||||
) -> *mut ::std::os::raw::c_char;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -437,20 +478,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,
|
||||
attributeKey17_ptr: *mut ::std::os::raw::c_char,
|
||||
attributeKey17_len: ::std::os::raw::c_int,
|
||||
attributeValue18_ptr: *mut ::std::os::raw::c_char,
|
||||
attributeValue18_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,
|
||||
name19_ptr: *mut ::std::os::raw::c_char,
|
||||
name19_len: ::std::os::raw::c_int,
|
||||
server20_ptr: *mut ::std::os::raw::c_char,
|
||||
server20_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,
|
||||
handle21_ptr: *mut ::std::os::raw::c_char,
|
||||
handle21_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,
|
||||
handle22_ptr: *mut ::std::os::raw::c_char,
|
||||
handle22_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,
|
||||
serverOnion23_ptr: *mut ::std::os::raw::c_char,
|
||||
serverOnion23_len: ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -458,36 +535,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,
|
||||
filepath24_ptr: *mut ::std::os::raw::c_char,
|
||||
filepath24_len: ::std::os::raw::c_int,
|
||||
manifest25_ptr: *mut ::std::os::raw::c_char,
|
||||
manifest25_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_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,
|
||||
filekey27_ptr: *mut ::std::os::raw::c_char,
|
||||
filekey27_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,
|
||||
filekey28_ptr: *mut ::std::os::raw::c_char,
|
||||
filekey28_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,
|
||||
filekey29_ptr: *mut ::std::os::raw::c_char,
|
||||
filekey29_len: ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -495,8 +572,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,
|
||||
filekey30_ptr: *mut ::std::os::raw::c_char,
|
||||
filekey30_len: ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -504,8 +581,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,
|
||||
filepath31_ptr: *mut ::std::os::raw::c_char,
|
||||
filepath31_len: ::std::os::raw::c_int,
|
||||
) -> *mut ::std::os::raw::c_char;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -519,19 +596,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,
|
||||
description32_ptr: *mut ::std::os::raw::c_char,
|
||||
description32_len: ::std::os::raw::c_int,
|
||||
autostart33: ::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,
|
||||
handle34_ptr: *mut ::std::os::raw::c_char,
|
||||
handle34_len: ::std::os::raw::c_int,
|
||||
key35_ptr: *mut ::std::os::raw::c_char,
|
||||
key35_len: ::std::os::raw::c_int,
|
||||
val36_ptr: *mut ::std::os::raw::c_char,
|
||||
val36_len: ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -545,14 +622,14 @@ extern "C" {
|
|||
}
|
||||
extern "C" {
|
||||
pub fn c_LaunchServer(
|
||||
handle28_ptr: *mut ::std::os::raw::c_char,
|
||||
handle28_len: ::std::os::raw::c_int,
|
||||
handle37_ptr: *mut ::std::os::raw::c_char,
|
||||
handle37_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,
|
||||
handle38_ptr: *mut ::std::os::raw::c_char,
|
||||
handle38_len: ::std::os::raw::c_int,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -563,8 +640,8 @@ extern "C" {
|
|||
}
|
||||
extern "C" {
|
||||
pub fn c_DeleteServer(
|
||||
handle30_ptr: *mut ::std::os::raw::c_char,
|
||||
handle30_len: ::std::os::raw::c_int,
|
||||
handle39_ptr: *mut ::std::os::raw::c_char,
|
||||
handle39_len: ::std::os::raw::c_int,
|
||||
password_ptr: *mut ::std::os::raw::c_char,
|
||||
password_len: ::std::os::raw::c_int,
|
||||
);
|
||||
|
|
27
src/event.rs
27
src/event.rs
|
@ -88,6 +88,12 @@ impl From<String> 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<ServerIdentity> 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);
|
||||
|
@ -476,8 +489,6 @@ pub enum Event {
|
|||
content_hash: String,
|
||||
/// path to picture for sender
|
||||
picture: String,
|
||||
/// name of sender
|
||||
nick: String,
|
||||
/// notification policy (based on settings)
|
||||
notification: MessageNotification,
|
||||
},
|
||||
|
@ -504,18 +515,12 @@ pub enum Event {
|
|||
profile_id: ProfileIdentity,
|
||||
/// conversation id
|
||||
conversation_id: ConversationID,
|
||||
/// group id
|
||||
group_id: GroupID,
|
||||
/// server the group is on
|
||||
group_server: String,
|
||||
/// invite string
|
||||
group_invite: String,
|
||||
/// group name
|
||||
group_name: String,
|
||||
/// path to group picture
|
||||
picture: String,
|
||||
/// Access Control List for group
|
||||
access_control_list: ACL,
|
||||
},
|
||||
/// a server connection state has changed
|
||||
ServerStateChange {
|
||||
|
@ -793,7 +798,6 @@ impl From<&CwtchEvent> for Event {
|
|||
content_hash: cwtch_event.data["ContentHash"].clone(),
|
||||
conversation_id: cwtch_event.data["ConversationID"].parse().unwrap_or(-2).into(),
|
||||
contact_id: cwtch_event.data["RemotePeer"].clone().into(),
|
||||
nick: cwtch_event.data["Nick"].clone(),
|
||||
message: MessageWrapper::from_json(&cwtch_event.data["Data"]),
|
||||
notification: MessageNotification::from(cwtch_event.data["notification"].clone()),
|
||||
picture: cwtch_event.data["picture"].clone(),
|
||||
|
@ -810,12 +814,9 @@ impl From<&CwtchEvent> for Event {
|
|||
"NewGroup" => Event::NewGroup {
|
||||
profile_id: cwtch_event.data["ProfileOnion"].clone().into(),
|
||||
conversation_id: cwtch_event.data["ConversationID"].parse().unwrap_or(-2).into(),
|
||||
group_id: cwtch_event.data["GroupID"].clone().into(),
|
||||
group_server: cwtch_event.data["GroupServer"].clone(),
|
||||
group_invite: cwtch_event.data["GroupInvite"].clone(),
|
||||
group_name: cwtch_event.data["GroupName"].clone(),
|
||||
picture: cwtch_event.data["picture"].clone(),
|
||||
access_control_list: serde_json::from_str(cwtch_event.data["accessControlList"].as_str()).unwrap_or(ACL::new()),
|
||||
group_invite: cwtch_event.data["GroupInvite"].clone(),
|
||||
},
|
||||
"ServerStateChange" => Event::ServerStateChange {
|
||||
profile_id: cwtch_event.data["ProfileOnion"].clone().into(),
|
||||
|
|
34
src/lib.rs
34
src/lib.rs
|
@ -4,7 +4,7 @@
|
|||
#![deny(missing_docs)]
|
||||
|
||||
use crate::event::{ConversationID, Event, FileKey, ProfileIdentity, ServerIdentity};
|
||||
use crate::structs::{MessageWrapper, Settings, SharedFile};
|
||||
use crate::structs::{ACL, MessageWrapper, Settings, SharedFile};
|
||||
|
||||
mod bindings_go;
|
||||
mod cwtchlib_go;
|
||||
|
@ -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,18 @@ 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 an ACL for a conversation
|
||||
fn get_conversation_access_control_list(&self, profile: &ProfileIdentity, conversation_id: ConversationID) -> Result<ACL, CwtchError>;
|
||||
|
||||
/// Update a conversation's ACL
|
||||
fn update_conversation_access_control_list(&self, profile: &ProfileIdentity, conversation_id: ConversationID, acl: ACL);
|
||||
|
||||
/// 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;
|
||||
|
||||
|
@ -71,7 +86,7 @@ pub trait CwtchLib {
|
|||
) -> String;
|
||||
|
||||
/// Bulk get messages starting at message index and of count amoung
|
||||
fn get_messages(&self, profile: &ProfileIdentity, conversation_id: ConversationID, message_index: i32, count: i32) -> String;
|
||||
fn get_messages(&self, profile: &ProfileIdentity, conversation_id: ConversationID, message_index: i32, count: u32) -> String;
|
||||
|
||||
/// Send json of a structs::Message from profile to contact. Returns computed sent message (including index and hash values)
|
||||
fn send_message_raw(&self, profile: &ProfileIdentity, conversation_id: ConversationID, msg: &str) -> String;
|
||||
|
@ -116,6 +131,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);
|
||||
|
||||
|
|
|
@ -94,6 +94,18 @@ pub struct AccessControl {
|
|||
pub read: bool,
|
||||
/// Allows a handle to append new messages to the conversation
|
||||
pub append: bool,
|
||||
|
||||
/// Profile should automatically try to connect with peer
|
||||
pub auto_connect: bool,
|
||||
|
||||
/// Profile should automatically exchange attributes like Name, Profile Image, etc.
|
||||
pub exchange_attributes: bool,
|
||||
|
||||
/// Allows a handle to share files to a conversation
|
||||
pub share_files: bool,
|
||||
|
||||
/// Indicates that certain filetypes should be autodownloaded and rendered when shared by this contact
|
||||
pub render_images: bool
|
||||
}
|
||||
|
||||
/// represents an access control list for a conversation. Mapping handles to conversation functions
|
||||
|
|
Loading…
Reference in New Issue