mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
Return bool from add_contact_to_chat_ex
This commit is contained in:
@@ -848,7 +848,7 @@ pub unsafe extern "C" fn dc_add_contact_to_chat(
|
|||||||
|
|
||||||
let context = &*context;
|
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]
|
#[no_mangle]
|
||||||
|
|||||||
@@ -705,7 +705,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
|
|||||||
ensure!(!arg1.is_empty(), "Argument <contact-id> missing.");
|
ensure!(!arg1.is_empty(), "Argument <contact-id> missing.");
|
||||||
|
|
||||||
let contact_id_0: libc::c_int = arg1.parse()?;
|
let contact_id_0: libc::c_int = arg1.parse()?;
|
||||||
if 0 != chat::add_contact_to_chat(
|
if chat::add_contact_to_chat(
|
||||||
context,
|
context,
|
||||||
sel_chat.as_ref().unwrap().get_id(),
|
sel_chat.as_ref().unwrap().get_id(),
|
||||||
contact_id_0 as uint32_t,
|
contact_id_0 as uint32_t,
|
||||||
|
|||||||
13
src/chat.rs
13
src/chat.rs
@@ -1297,24 +1297,23 @@ pub fn add_to_chat_contacts_table(context: &Context, chat_id: u32, contact_id: u
|
|||||||
.is_ok()
|
.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)
|
add_contact_to_chat_ex(context, chat_id, contact_id, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO should return bool /rtn
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub fn add_contact_to_chat_ex(
|
pub fn add_contact_to_chat_ex(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
chat_id: u32,
|
chat_id: u32,
|
||||||
contact_id: u32,
|
contact_id: u32,
|
||||||
flags: libc::c_int,
|
flags: libc::c_int,
|
||||||
) -> libc::c_int {
|
) -> bool {
|
||||||
let mut OK_TO_CONTINUE = true;
|
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);
|
let contact = Contact::get_by_id(context, contact_id);
|
||||||
|
|
||||||
if contact.is_err() || chat_id <= DC_CHAT_ID_LAST_SPECIAL {
|
if contact.is_err() || chat_id <= DC_CHAT_ID_LAST_SPECIAL {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
let mut msg = dc_msg_new_untyped();
|
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 != is_contact_in_chat(context, chat_id, contact_id) {
|
||||||
if 0 == flags & 0x1 {
|
if 0 == flags & 0x1 {
|
||||||
success = 1;
|
success = true;
|
||||||
OK_TO_CONTINUE = false;
|
OK_TO_CONTINUE = false;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
context.call_cb(Event::MSGS_CHANGED, chat_id as uintptr_t, 0 as uintptr_t);
|
||||||
success = 1;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user