Return bool from add_contact_to_chat_ex

This commit is contained in:
Alexander Krotov
2019-09-12 12:45:52 +03:00
parent 97edd23910
commit 0f67b16f29
3 changed files with 8 additions and 9 deletions

View File

@@ -848,7 +848,7 @@ pub unsafe extern "C" fn dc_add_contact_to_chat(
let context = &*context;
chat::add_contact_to_chat(context, chat_id, contact_id)
chat::add_contact_to_chat(context, chat_id, contact_id) as libc::c_int
}
#[no_mangle]

View File

@@ -705,7 +705,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
ensure!(!arg1.is_empty(), "Argument <contact-id> missing.");
let contact_id_0: libc::c_int = arg1.parse()?;
if 0 != chat::add_contact_to_chat(
if chat::add_contact_to_chat(
context,
sel_chat.as_ref().unwrap().get_id(),
contact_id_0 as uint32_t,

View File

@@ -1297,24 +1297,23 @@ pub fn add_to_chat_contacts_table(context: &Context, chat_id: u32, contact_id: u
.is_ok()
}
pub unsafe fn add_contact_to_chat(context: &Context, chat_id: u32, contact_id: u32) -> libc::c_int {
pub unsafe fn add_contact_to_chat(context: &Context, chat_id: u32, contact_id: u32) -> bool {
add_contact_to_chat_ex(context, chat_id, contact_id, 0)
}
// TODO should return bool /rtn
#[allow(non_snake_case)]
pub fn add_contact_to_chat_ex(
context: &Context,
chat_id: u32,
contact_id: u32,
flags: libc::c_int,
) -> libc::c_int {
) -> bool {
let mut OK_TO_CONTINUE = true;
let mut success: libc::c_int = 0;
let mut success = false;
let contact = Contact::get_by_id(context, contact_id);
if contact.is_err() || chat_id <= DC_CHAT_ID_LAST_SPECIAL {
return 0;
return false;
}
let mut msg = dc_msg_new_untyped();
@@ -1351,7 +1350,7 @@ pub fn add_contact_to_chat_ex(
if 0 != is_contact_in_chat(context, chat_id, contact_id) {
if 0 == flags & 0x1 {
success = 1;
success = true;
OK_TO_CONTINUE = false;
}
} else {
@@ -1391,7 +1390,7 @@ pub fn add_contact_to_chat_ex(
);
}
context.call_cb(Event::MSGS_CHANGED, chat_id as uintptr_t, 0 as uintptr_t);
success = 1;
success = true;
}
}
}