diff --git a/src/bindings_go.rs b/src/bindings_go.rs
index d6b584b..37c4874 100644
--- a/src/bindings_go.rs
+++ b/src/bindings_go.rs
@@ -8,7 +8,7 @@ use std::ffi::CString;
use super::CwtchLib;
use crate::cwtchlib_go::bindings;
-use crate::{CwtchError, structs::*};
+use crate::{ConversationID, CwtchError, ProfileIdentity, ServerIdentity, structs::*};
use crate::event::Event;
struct c_str_wrap {
@@ -88,41 +88,111 @@ 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!(_send_profile_event(profile: &str, event_jason: &str;;) c_SendProfileEvent);
+ c_bind!(_accept_conversation(profile: &str ; conversation_id: i32 ;) c_AcceptConversation);
+ c_bind!(_block_contact(profile: &str ; conversation_id: i32; ) c_BlockContact);
+ c_bind!(_unblock_contact(profile: &str ; conversation_id: i32; ) c_UnblockContact);
+ c_bind!(_get_message(profile: &str; conversation_id: i32, message_index: i32 ;) c_GetMessage -> 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_GetMessagesByContentHash -> String);
+ c_bind!(_get_messages(profile: &str; conversation_id: i32, message_index: i32, count: i32 ;) c_GetMessages -> String);
+ c_bind!(_send_message(profile: &str; conversation_id: i32; msg: &str) c_SendMessage -> String);
+ c_bind!(_send_invitation(profile: &str; conversation_id: i32, target_id: i32;) c_SendInvitation -> String);
+ c_bind!(_share_file(profile: &str; conversation_id: i32; file_path: &str) c_ShareFile -> String);
+ c_bind!(_download_file(profile: &str; conversation_id: i32; file_path: &str, manifest_path: &str, file_key: &str) c_DownloadFile);
+ 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_VerifyOrResumeDownload);
+ c_bind!(_create_group(profile: &str, server: &str, name: &str;;) c_CreateGroup);
+ c_bind!(_delete_profile(profile: &str, pass: &str;;) c_DeleteProfile);
+ c_bind!(_archive_conversation(profile: &str; conversation_id: i32;) c_ArchiveConversation);
+ c_bind!(_delete_contact(profile: &str; conversation_id: i32;) c_DeleteContact);
+ c_bind!(_import_bundle(profile: &str, bundle: &str;;) c_ImportBundle);
+ c_bind!(_set_profile_attribute(profile: &str, key: &str, val: &str;;) c_SetProfileAttribute);
+ c_bind!(_set_conversation_attribute(profile: &str; conversation_id: i32; key: &str, val: &str) c_SetConversationAttribute);
+ c_bind!(_set_message_attribute(profile: &str; conversation_id: i32, channel_id: i32, message_id: i32; key: &str, val: &str) c_SetMessageAttribute);
+ c_bind!(_change_password(profile: &str, old_pass: &str, new_pass: &str, new_pass_again: &str;;) c_ChangePassword);
+ c_bind!(_export_profile(profile: &str, filename: &str;;) c_ExportProfile);
+ c_bind!(_delete_server(server: &str, current_password: &str;;) c_DeleteServer);
+ c_bind!(_launch_server(server: &str;;) c_LaunchServer);
+ c_bind!(_stop_server(server: &str;;) c_StopServer);
+ c_bind!(_set_server_attribute(server: &str, key: &str, val: &str;;) c_SetServerAttribute);
}
impl CwtchLib for CwtchLibGo {
c_bind!(start_cwtch(app_dir: &str, tor_path: &str;;) c_StartCwtch -> i32);
c_bind!(started(;;) c_Started -> i32);
c_bind!(send_app_event(event_json: &str;;) c_SendAppEvent);
- c_bind!(send_profile_event(profile: &str, event_jason: &str;;) c_SendProfileEvent);
+ fn send_profile_event(&self, profile: ProfileIdentity, event_jason: &str) {
+ self._send_profile_event(profile.into(), event_jason)
+ }
c_bind!(create_profile(nick: &str, pass: &str;;) c_CreateProfile);
c_bind!(load_profiles(pass: &str;;) c_LoadProfiles);
- c_bind!(accept_conversation(profile: &str ; conversation_id: i32 ;) c_AcceptConversation);
- c_bind!(block_contact(profile: &str ; conversation_id: i32; ) c_BlockContact);
- c_bind!(unblock_contact(profile: &str ; conversation_id: i32; ) c_UnblockContact);
- c_bind!(get_message(profile: &str; conversation_id: i32, message_index: i32 ;) c_GetMessage -> 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_GetMessagesByContentHash -> String);
- c_bind!(get_messages(profile: &str; conversation_id: i32, message_index: i32, count: i32 ;) c_GetMessages -> String);
- c_bind!(send_message(profile: &str; conversation_id: i32; msg: &str) c_SendMessage -> String);
- c_bind!(send_invitation(profile: &str; conversation_id: i32, target_id: i32;) c_SendInvitation -> String);
- c_bind!(share_file(profile: &str; conversation_id: i32; file_path: &str) c_ShareFile -> String);
- c_bind!(download_file(profile: &str; conversation_id: i32; file_path: &str, manifest_path: &str, file_key: &str) c_DownloadFile);
- 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_VerifyOrResumeDownload);
+ fn accept_conversation(&self, profile: ProfileIdentity, conversation_id: ConversationID) {
+ self._accept_conversation(profile.into(), conversation_id.into())
+ }
+ fn block_contact(&self, profile: ProfileIdentity, conversation_id: ConversationID) {
+ self._block_contact(profile.into(), conversation_id.into())
+ }
+ fn unblock_contact(&self, profile: ProfileIdentity, conversation_id: ConversationID) {
+ self._unblock_contact(profile.into(), conversation_id.into())
+ }
+ fn get_message(&self, profile: ProfileIdentity, conversation_id: ConversationID, message_index: i32) -> String {
+ self._get_message(profile.into(), conversation_id.into(), message_index)
+ }
+ fn get_message_by_id(&self, profile: ProfileIdentity, conversation_id: ConversationID, message_id: i32) -> String {
+ self._get_message_by_id(profile.into(), 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(profile.into(), conversation_id.into(), hash)
+ }
+ fn get_messages(&self, profile: ProfileIdentity, conversation_id: ConversationID, message_index: i32, count: i32) -> String {
+ self.get_messages(profile.into(), conversation_id, message_index, count)
+ }
+ fn send_message(&self, profile: ProfileIdentity, conversation_id: ConversationID, msg: &str) -> String {
+ self._send_message(profile.into(), conversation_id.into(), msg)
+ }
+ fn send_invitation(&self, profile: ProfileIdentity, conversation_id: ConversationID, target_id: i32) -> String {
+ self._send_invitation(profile.into(), conversation_id.into(), target_id)
+ }
+ fn share_file(&self, profile: ProfileIdentity, conversation_id: ConversationID, file_path: &str) -> String {
+ self.share_file(profile.into(), conversation_id, file_path)
+ }
+ fn download_file(&self, profile: ProfileIdentity, conversation_id: ConversationID, file_path: &str, manifest_path: &str, file_key: &str) {
+ self._download_file(profile.into(), conversation_id.into(), file_path, manifest_path, file_key)
+ }
+ fn check_download_status(&self, profile: ProfileIdentity, file_key: &str) {
+ self._check_download_status(profile.into(), file_key)
+ }
+ fn verify_or_resume_download(&self, profile: ProfileIdentity, conversation_id: ConversationID, file_key: &str) {
+ self._verify_or_resume_download(profile.into(), conversation_id.into(), file_key)
+ }
+
fn reset_tor(&self) {
unsafe {
bindings::c_ResetTor();
}
}
- c_bind!(create_group(profile: &str, server: &str, name: &str;;) c_CreateGroup);
- c_bind!(delete_profile(profile: &str, pass: &str;;) c_DeleteProfile);
- c_bind!(archive_conversation(profile: &str; conversation_id: i32;) c_ArchiveConversation);
- c_bind!(delete_contact(profile: &str; conversation_id: i32;) c_DeleteContact);
- c_bind!(import_bundle(profile: &str, bundle: &str;;) c_ImportBundle);
- c_bind!(set_profile_attribute(profile: &str, key: &str, val: &str;;) c_SetProfileAttribute);
- fn get_profile_attribute(&self, profile: &str, key: &str) -> Result