refactor(params): rustify

This commit is contained in:
Friedel Ziegelmayer
2019-07-29 01:49:53 +02:00
committed by GitHub
parent 669ed0e0df
commit 188da2a020
23 changed files with 912 additions and 1191 deletions

View File

@@ -17,10 +17,10 @@ use crate::dc_location::*;
use crate::dc_mimeparser::*;
use crate::dc_move::*;
use crate::dc_msg::*;
use crate::dc_param::*;
use crate::dc_securejoin::*;
use crate::dc_strencode::*;
use crate::dc_tools::*;
use crate::param::*;
use crate::peerstate::*;
use crate::sql;
use crate::stock::StockMessage;
@@ -480,9 +480,8 @@ pub unsafe fn dc_receive_imf(
)
}
if 0 != mime_parser.is_system_message {
dc_param_set_int(
(*part).param,
'S' as i32,
(*part).param.set_int( Param::Cmd,
mime_parser.is_system_message,
);
}
@@ -511,7 +510,7 @@ pub unsafe fn dc_receive_imf(
} else {
String::new()
},
as_str((*(*part).param).packed),
(*part).param.to_string(),
(*part).bytes,
hidden,
if 0 != save_mime_headers {
@@ -743,29 +742,18 @@ pub unsafe fn dc_receive_imf(
}
}
if 0 != mime_parser.is_send_by_messenger || 0 != mdn_consumed {
let param = dc_param_new();
let server_folder_c = to_cstring(server_folder.as_ref());
dc_param_set(
param,
DC_PARAM_SERVER_FOLDER as i32,
server_folder_c,
);
free(server_folder_c as *mut _);
dc_param_set_int(
param,
DC_PARAM_SERVER_UID as i32,
server_uid as i32,
);
let mut param = Params::new();
param.set(Param::ServerFolder, server_folder.as_ref());
param.set_int(Param::ServerUid, server_uid as i32);
if 0 != mime_parser.is_send_by_messenger
&& 0 != context
.sql
.get_config_int(context, "mvbox_move")
.unwrap_or_else(|| 1)
{
dc_param_set_int(param, DC_PARAM_ALSO_MOVE as i32, 1);
param.set_int(Param::AlsoMove, 1);
}
dc_job_add(context, 120, 0, (*param).packed, 0);
dc_param_unref(param);
dc_job_add(context, 120, 0, param, 0);
}
}
}
@@ -833,7 +821,7 @@ pub unsafe fn dc_receive_imf(
context,
DC_JOB_DELETE_MSG_ON_IMAP,
created_db_entries[0].1 as i32,
0 as *const libc::c_char,
Params::new(),
0,
);
}
@@ -1226,18 +1214,18 @@ unsafe fn create_or_lookup_group(
carray_get(mime_parser.parts, i_0 as libc::c_uint)
as *mut dc_mimepart_t;
if (*part).type_0 == 20 {
grpimage = dc_param_get(
(*part).param,
DC_PARAM_FILE as i32,
0 as *const libc::c_char,
);
grpimage = (*part)
.param
.get(Param::File)
.map(|s| to_cstring(s))
.unwrap_or_else(|| std::ptr::null_mut());
ok = 1
}
i_0 += 1
}
}
if 0 != ok {
let chat: *mut Chat = dc_chat_new(context);
let chat = dc_chat_new(context);
info!(
context,
0,
@@ -1249,11 +1237,11 @@ unsafe fn create_or_lookup_group(
},
);
dc_chat_load_from_db(chat, chat_id);
dc_param_set(
(*chat).param,
DC_PARAM_PROFILE_IMAGE as i32,
grpimage,
);
if grpimage.is_null() {
(*chat).param.remove(Param::ProfileImage);
} else {
(*chat).param.set(Param::ProfileImage, as_str(grpimage));
}
dc_chat_update_param(chat);
dc_chat_unref(chat);
free(grpimage as *mut libc::c_void);