refactor(msg): use rust based allocations

This commit is contained in:
dignifiedquire
2019-08-18 21:26:53 +02:00
parent a906faeb35
commit cb6c8ac78b
13 changed files with 982 additions and 1227 deletions

View File

@@ -293,38 +293,37 @@ unsafe fn send_handshake_msg(
fingerprint: *const libc::c_char,
grpid: impl AsRef<str>,
) {
let mut msg: *mut dc_msg_t = dc_msg_new_untyped(context);
(*msg).type_0 = Viewtype::Text;
(*msg).text = Some(format!("Secure-Join: {}", to_string(step)));
(*msg).hidden = 1;
(*msg).param.set_int(Param::Cmd, 7);
let mut msg = dc_msg_new_untyped(context);
msg.type_0 = Viewtype::Text;
msg.text = Some(format!("Secure-Join: {}", to_string(step)));
msg.hidden = true;
msg.param.set_int(Param::Cmd, 7);
if step.is_null() {
(*msg).param.remove(Param::Arg);
msg.param.remove(Param::Arg);
} else {
(*msg).param.set(Param::Arg, as_str(step));
msg.param.set(Param::Arg, as_str(step));
}
if !param2.as_ref().is_empty() {
(*msg).param.set(Param::Arg2, param2);
msg.param.set(Param::Arg2, param2);
}
if !fingerprint.is_null() {
(*msg).param.set(Param::Arg3, as_str(fingerprint));
msg.param.set(Param::Arg3, as_str(fingerprint));
}
if !grpid.as_ref().is_empty() {
(*msg).param.set(Param::Arg4, grpid.as_ref());
msg.param.set(Param::Arg4, grpid.as_ref());
}
if strcmp(step, b"vg-request\x00" as *const u8 as *const libc::c_char) == 0i32
|| strcmp(step, b"vc-request\x00" as *const u8 as *const libc::c_char) == 0i32
{
(*msg).param.set_int(
msg.param.set_int(
Param::ForcePlaintext,
ForcePlaintext::AddAutocryptHeader as i32,
);
} else {
(*msg).param.set_int(Param::GuranteeE2ee, 1);
msg.param.set_int(Param::GuranteeE2ee, 1);
}
// TODO. handle cleanup on error
chat::send_msg(context, contact_chat_id, msg).unwrap();
dc_msg_unref(msg);
chat::send_msg(context, contact_chat_id, &mut msg).unwrap();
}
unsafe fn chat_id_2_contact_id(context: &Context, contact_chat_id: uint32_t) -> uint32_t {