diff --git a/src/dc_chat.rs b/src/dc_chat.rs index 715e77fc2..3f5323c38 100644 --- a/src/dc_chat.rs +++ b/src/dc_chat.rs @@ -164,7 +164,7 @@ pub fn dc_chat_load_from_db(chat: *mut Chat, chat_id: u32) -> bool { (*chat).name = dc_stock_str((*chat).context, 41); }, _ => { - if 0 != unsafe { dc_param_exists((*chat).param, 'K' as i32) } { + if 0 != unsafe { dc_param_exists((*chat).param, DC_PARAM_SELFTALK as i32) } { unsafe { free((*chat).name as *mut libc::c_void); (*chat).name = dc_stock_str((*chat).context, 2); @@ -379,7 +379,7 @@ unsafe fn prepare_msg_common<'a>( || (*msg).type_0 == 50i32 || (*msg).type_0 == 60i32 { - pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); + pathNfilename = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); if pathNfilename.is_null() { error!( context, @@ -394,24 +394,24 @@ unsafe fn prepare_msg_common<'a>( } else if 0 == dc_make_rel_and_copy(context, &mut pathNfilename) { current_block = 2171833246886114521; } else { - dc_param_set((*msg).param, 'f' as i32, pathNfilename); + dc_param_set((*msg).param, DC_PARAM_FILE as i32, pathNfilename); if (*msg).type_0 == 60i32 || (*msg).type_0 == 20i32 { let mut better_type: libc::c_int = 0i32; let mut better_mime: *mut libc::c_char = 0 as *mut libc::c_char; dc_msg_guess_msgtype_from_suffix(pathNfilename, &mut better_type, &mut better_mime); if 0 != better_type { (*msg).type_0 = better_type; - dc_param_set((*msg).param, 'm' as i32, better_mime); + dc_param_set((*msg).param, DC_PARAM_MIMETYPE as i32, better_mime); } free(better_mime as *mut libc::c_void); - } else if 0 == dc_param_exists((*msg).param, 'm' as i32) { + } else if 0 == dc_param_exists((*msg).param, DC_PARAM_MIMETYPE as i32) { let mut better_mime_0: *mut libc::c_char = 0 as *mut libc::c_char; dc_msg_guess_msgtype_from_suffix( pathNfilename, 0 as *mut libc::c_int, &mut better_mime_0, ); - dc_param_set((*msg).param, 'm' as i32, better_mime_0); + dc_param_set((*msg).param, DC_PARAM_MIMETYPE as i32, better_mime_0); free(better_mime_0 as *mut libc::c_void); } info!( @@ -519,8 +519,12 @@ unsafe fn prepare_msg_raw( } } else { if (*chat).type_0 == 120 || (*chat).type_0 == 130 { - if dc_param_get_int((*chat).param, 'U' as i32, 0) == 1 { - dc_param_set((*chat).param, 'U' as i32, 0 as *const libc::c_char); + if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 1 { + dc_param_set( + (*chat).param, + DC_PARAM_UNPROMOTED as i32, + 0 as *const libc::c_char, + ); dc_chat_update_param(chat); } } @@ -538,7 +542,9 @@ unsafe fn prepare_msg_raw( .sql .get_config_int(context, "e2ee_enabled") .unwrap_or_else(|| 1); - if 0 != e2ee_enabled && dc_param_get_int((*msg).param, 'u' as i32, 0) == 0 { + if 0 != e2ee_enabled + && dc_param_get_int((*msg).param, DC_PARAM_FORCE_PLAINTEXT as i32, 0) == 0 + { let mut can_encrypt = 1; let mut all_mutual = 1; @@ -593,9 +599,13 @@ unsafe fn prepare_msg_raw( } } if 0 != do_guarantee_e2ee { - dc_param_set_int((*msg).param, 'c' as i32, 1); + dc_param_set_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1); } - dc_param_set((*msg).param, 'e' as i32, 0 as *const libc::c_char); + dc_param_set( + (*msg).param, + DC_PARAM_ERRONEOUS_E2EE as i32, + 0 as *const libc::c_char, + ); if 0 == dc_chat_is_self_talk(chat) && 0 != get_parent_mime_headers( chat, @@ -798,7 +808,7 @@ pub unsafe fn dc_chat_is_self_talk(chat: *const Chat) -> libc::c_int { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32; } - dc_param_exists((*chat).param, 'K' as i32) + dc_param_exists((*chat).param, DC_PARAM_SELFTALK as i32) } /******************************************************************************* @@ -825,7 +835,7 @@ unsafe fn last_msg_in_chat_encrypted( let packed_c = to_cstring(packed); dc_param_set_packed(msg_param, packed_c.as_ptr()); - if 0 != dc_param_exists(msg_param, 'c' as i32) { + if 0 != dc_param_exists(msg_param, DC_PARAM_GUARANTEE_E2EE as i32) { last_is_encrypted = 1; } dc_param_unref(msg_param); @@ -903,7 +913,11 @@ pub unsafe fn dc_send_msg<'a>( } if 0 == chat_id { - let forwards = dc_param_get((*msg).param, 'P' as i32, 0 as *const libc::c_char); + let forwards = dc_param_get( + (*msg).param, + DC_PARAM_PREP_FORWARDS as i32, + 0 as *const libc::c_char, + ); if !forwards.is_null() { let mut p = forwards; while 0 != *p { @@ -919,7 +933,11 @@ pub unsafe fn dc_send_msg<'a>( dc_msg_unref(copy); } } - dc_param_set((*msg).param, 'P' as i32, 0 as *const libc::c_char); + dc_param_set( + (*msg).param, + DC_PARAM_PREP_FORWARDS as i32, + 0 as *const libc::c_char, + ); dc_msg_save_param_to_disk(msg); } free(forwards as *mut libc::c_void); @@ -979,7 +997,8 @@ unsafe fn set_draft_raw(context: &Context, chat_id: uint32_t, msg: *mut dc_msg_t || (*msg).type_0 == 50i32 || (*msg).type_0 == 60i32 { - pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); + pathNfilename = + dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); if pathNfilename.is_null() { current_block = 14513523936503887211; } else if 0 != dc_msg_is_increation(msg) @@ -989,7 +1008,7 @@ unsafe fn set_draft_raw(context: &Context, chat_id: uint32_t, msg: *mut dc_msg_t } else if 0 == dc_make_rel_and_copy(context, &mut pathNfilename) { current_block = 14513523936503887211; } else { - dc_param_set((*msg).param, 'f' as i32, pathNfilename); + dc_param_set((*msg).param, DC_PARAM_FILE as i32, pathNfilename); current_block = 4495394744059808450; } } else { @@ -1551,8 +1570,14 @@ pub unsafe fn dc_add_contact_to_chat_ex( ); } else { /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ - if 0 != flags & 0x1 && dc_param_get_int((*chat).param, 'U' as i32, 0) == 1 { - dc_param_set((*chat).param, 'U' as i32, 0 as *const libc::c_char); + if 0 != flags & 0x1 + && dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 1 + { + dc_param_set( + (*chat).param, + DC_PARAM_UNPROMOTED as i32, + 0 as *const libc::c_char, + ); dc_chat_update_param(chat); } let self_addr = context @@ -1600,7 +1625,7 @@ pub unsafe fn dc_add_contact_to_chat_ex( match current_block { 12326129973959287090 => {} _ => { - if dc_param_get_int((*chat).param, 'U' as i32, 0) == 0 { + if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 0 { (*msg).type_0 = 10; (*msg).text = dc_stock_system_msg( context, @@ -1609,9 +1634,13 @@ pub unsafe fn dc_add_contact_to_chat_ex( 0 as *const libc::c_char, 1 as uint32_t, ); - dc_param_set_int((*msg).param, 'S' as i32, 4); - dc_param_set((*msg).param, 'E' as i32, (*contact).addr); - dc_param_set_int((*msg).param, 'F' as i32, flags); + dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 4); + dc_param_set( + (*msg).param, + DC_PARAM_CMD_ARG as i32, + (*contact).addr, + ); + dc_param_set_int((*msg).param, DC_PARAM_CMD_ARG2 as i32, flags); (*msg).id = dc_send_msg(context, chat_id, msg); context.call_cb( Event::MSGS_CHANGED, @@ -1712,7 +1741,7 @@ pub unsafe fn dc_remove_contact_from_chat( } else { /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ if !contact.is_null() { - if dc_param_get_int((*chat).param, 'U' as i32, 0) == 0 { + if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0) == 0 { (*msg).type_0 = 10; if (*contact).id == 1 as libc::c_uint { dc_set_group_explicitly_left(context, (*chat).grpid); @@ -1732,8 +1761,8 @@ pub unsafe fn dc_remove_contact_from_chat( 1 as uint32_t, ) } - dc_param_set_int((*msg).param, 'S' as i32, 5); - dc_param_set((*msg).param, 'E' as i32, (*contact).addr); + dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 5); + dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, (*contact).addr); (*msg).id = dc_send_msg(context, chat_id, msg); context.call_cb( Event::MSGS_CHANGED, @@ -1825,7 +1854,7 @@ pub unsafe fn dc_set_chat_name( ) .is_ok() { - if dc_param_get_int((*chat).param, 'U' as i32, 0i32) == 0i32 { + if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0i32) == 0i32 { (*msg).type_0 = 10i32; (*msg).text = dc_stock_system_msg( context, @@ -1834,8 +1863,8 @@ pub unsafe fn dc_set_chat_name( new_name, 1i32 as uint32_t, ); - dc_param_set_int((*msg).param, 'S' as i32, 2i32); - dc_param_set((*msg).param, 'E' as i32, (*chat).name); + dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 2i32); + dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, (*chat).name); (*msg).id = dc_send_msg(context, chat_id, msg); context.call_cb( Event::MSGS_CHANGED, @@ -1895,11 +1924,13 @@ pub unsafe fn dc_set_chat_profile_image( match current_block { 14766584022300871387 => {} _ => { - dc_param_set((*chat).param, 'i' as i32, new_image_rel); + dc_param_set((*chat).param, DC_PARAM_PROFILE_IMAGE as i32, new_image_rel); if !(0 == dc_chat_update_param(chat)) { - if dc_param_get_int((*chat).param, 'U' as i32, 0i32) == 0i32 { - dc_param_set_int((*msg).param, 'S' as i32, 3i32); - dc_param_set((*msg).param, 'E' as i32, new_image_rel); + if dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0i32) + == 0i32 + { + dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 3i32); + dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, new_image_rel); (*msg).type_0 = 10i32; (*msg).text = dc_stock_system_msg( context, @@ -1979,11 +2010,19 @@ pub unsafe fn dc_forward_msgs( } dc_param_set_packed(original_param, (*(*msg).param).packed); if (*msg).from_id != 1i32 as libc::c_uint { - dc_param_set_int((*msg).param, 'a' as i32, 1i32); + dc_param_set_int((*msg).param, DC_PARAM_FORWARDED as i32, 1i32); } - dc_param_set((*msg).param, 'c' as i32, 0 as *const libc::c_char); - dc_param_set((*msg).param, 'u' as i32, 0 as *const libc::c_char); - dc_param_set((*msg).param, 'S' as i32, 0 as *const libc::c_char); + dc_param_set( + (*msg).param, + DC_PARAM_GUARANTEE_E2EE as i32, + 0 as *const libc::c_char, + ); + dc_param_set( + (*msg).param, + DC_PARAM_FORCE_PLAINTEXT as i32, + 0 as *const libc::c_char, + ); + dc_param_set((*msg).param, DC_PARAM_CMD as i32, 0 as *const libc::c_char); let new_msg_id: uint32_t; if (*msg).state == 18i32 { let fresh9 = curr_timestamp; @@ -1994,7 +2033,7 @@ pub unsafe fn dc_forward_msgs( (*msg).id = src_msg_id as uint32_t; let old_fwd: *mut libc::c_char = dc_param_get( (*msg).param, - 'P' as i32, + DC_PARAM_PREP_FORWARDS as i32, b"\x00" as *const u8 as *const libc::c_char, ); let new_fwd: *mut libc::c_char = dc_mprintf( @@ -2002,7 +2041,7 @@ pub unsafe fn dc_forward_msgs( old_fwd, new_msg_id, ); - dc_param_set((*msg).param, 'P' as i32, new_fwd); + dc_param_set((*msg).param, DC_PARAM_PREP_FORWARDS as i32, new_fwd); dc_msg_save_param_to_disk(msg); free(new_fwd as *mut libc::c_void); free(old_fwd as *mut libc::c_void); @@ -2079,7 +2118,7 @@ pub unsafe fn dc_chat_get_subtitle(chat: *const Chat) -> *mut libc::c_char { } let mut ret: *mut libc::c_char = std::ptr::null_mut(); - if (*chat).type_0 == 100 && 0 != dc_param_exists((*chat).param, 'K' as i32) { + if (*chat).type_0 == 100 && 0 != dc_param_exists((*chat).param, DC_PARAM_SELFTALK as i32) { ret = dc_stock_str((*chat).context, 50) } else if (*chat).type_0 == 100 { let ret_raw: String = (*chat) @@ -2128,7 +2167,11 @@ pub unsafe fn dc_chat_get_profile_image(chat: *const Chat) -> *mut libc::c_char let mut contacts: *mut dc_array_t = 0 as *mut dc_array_t; let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t; if !(chat.is_null() || (*chat).magic != 0xc4a7c4a7u32) { - image_rel = dc_param_get((*chat).param, 'i' as i32, 0 as *const libc::c_char); + image_rel = dc_param_get( + (*chat).param, + DC_PARAM_PROFILE_IMAGE as i32, + 0 as *const libc::c_char, + ); if !image_rel.is_null() && 0 != *image_rel.offset(0isize) as libc::c_int { image_abs = dc_get_abs_path((*chat).context, image_rel) } else if (*chat).type_0 == 100i32 { @@ -2188,7 +2231,7 @@ pub unsafe fn dc_chat_is_unpromoted(chat: *const Chat) -> libc::c_int { if chat.is_null() || (*chat).magic != 0xc4a7c4a7u32 { return 0i32; } - dc_param_get_int((*chat).param, 'U' as i32, 0i32) + dc_param_get_int((*chat).param, DC_PARAM_UNPROMOTED as i32, 0i32) } // TODO should return bool /rtn diff --git a/src/dc_imex.rs b/src/dc_imex.rs index f55bcdfc1..2c5e7c510 100644 --- a/src/dc_imex.rs +++ b/src/dc_imex.rs @@ -34,9 +34,9 @@ pub unsafe fn dc_imex( param2: *const libc::c_char, ) { let param: *mut dc_param_t = dc_param_new(); - dc_param_set_int(param, 'S' as i32, what); - dc_param_set(param, 'E' as i32, param1); - dc_param_set(param, 'F' as i32, param2); + dc_param_set_int(param, DC_PARAM_CMD as i32, what); + dc_param_set(param, DC_PARAM_CMD_ARG as i32, param1); + dc_param_set(param, DC_PARAM_CMD_ARG2 as i32, param2); dc_job_kill_action(context, 910i32); dc_job_add(context, 910i32, 0i32, (*param).packed, 0i32); dc_param_unref(param); @@ -143,15 +143,15 @@ pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char { if !(chat_id == 0i32 as libc::c_uint) { msg = dc_msg_new_untyped(context); (*msg).type_0 = 60i32; - dc_param_set((*msg).param, 'f' as i32, setup_file_name); + dc_param_set((*msg).param, DC_PARAM_FILE as i32, setup_file_name); dc_param_set( (*msg).param, - 'm' as i32, + DC_PARAM_MIMETYPE as i32, b"application/autocrypt-setup\x00" as *const u8 as *const libc::c_char, ); - dc_param_set_int((*msg).param, 'S' as i32, 6i32); - dc_param_set_int((*msg).param, 'u' as i32, 2i32); + dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 6); + dc_param_set_int((*msg).param, DC_PARAM_FORCE_PLAINTEXT as i32, 2); if !context .running_state .clone() @@ -551,9 +551,17 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t) let mut param2: *mut libc::c_char = 0 as *mut libc::c_char; if !(0 == dc_alloc_ongoing(context)) { ongoing_allocated_here = 1i32; - what = dc_param_get_int((*job).param, 'S' as i32, 0i32); - param1 = dc_param_get((*job).param, 'E' as i32, 0 as *const libc::c_char); - param2 = dc_param_get((*job).param, 'F' as i32, 0 as *const libc::c_char); + what = dc_param_get_int((*job).param, DC_PARAM_CMD as i32, 0); + param1 = dc_param_get( + (*job).param, + DC_PARAM_CMD_ARG as i32, + 0 as *const libc::c_char, + ); + param2 = dc_param_get( + (*job).param, + DC_PARAM_CMD_ARG2 as i32, + 0 as *const libc::c_char, + ); if param1.is_null() { error!(context, 0, "No Import/export dir/file given.",); } else { diff --git a/src/dc_job.rs b/src/dc_job.rs index b65d31595..db6d11fd4 100644 --- a/src/dc_job.rs +++ b/src/dc_job.rs @@ -296,11 +296,15 @@ unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) { } match current_block { 13109137661213826276 => { - filename = dc_param_get(job.param, 'f' as i32, 0 as *const libc::c_char); + filename = dc_param_get(job.param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); if filename.is_null() { warn!(context, 0, "Missing file name for job {}", job.job_id,); } else if !(0 == dc_read_file(context, filename, &mut buf, &mut buf_bytes)) { - recipients = dc_param_get(job.param, 'R' as i32, 0 as *const libc::c_char); + recipients = dc_param_get( + job.param, + DC_PARAM_RECIPIENTS as i32, + 0 as *const libc::c_char, + ); if recipients.is_null() { warn!(context, 0, "Missing recipients for job {}", job.job_id,); } else { @@ -493,8 +497,12 @@ fn connect_to_inbox(context: &Context, inbox: &Imap) -> libc::c_int { unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_job_t) { let current_block: u64; - let folder: *mut libc::c_char = dc_param_get(job.param, 'Z' as i32, 0 as *const libc::c_char); - let uid: uint32_t = dc_param_get_int(job.param, 'z' as i32, 0i32) as uint32_t; + let folder: *mut libc::c_char = dc_param_get( + job.param, + DC_PARAM_SERVER_FOLDER as i32, + 0 as *const libc::c_char, + ); + let uid: uint32_t = dc_param_get_int(job.param, DC_PARAM_SERVER_UID as i32, 0) as uint32_t; let mut dest_uid: uint32_t = 0i32 as uint32_t; let inbox = context.inbox.read().unwrap(); @@ -515,7 +523,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_ if inbox.set_seen(context, folder, uid) as libc::c_uint == 0i32 as libc::c_uint { dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char); } - if 0 != dc_param_get_int(job.param, 'M' as i32, 0i32) { + if 0 != dc_param_get_int(job.param, DC_PARAM_ALSO_MOVE as i32, 0i32) { if context .sql .get_config_int(context, "folders_configured") @@ -568,8 +576,12 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_ dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char); } _ => { - if 0 != dc_param_get_int((*msg).param, 'r' as i32, 0i32) - && 0 != context + if 0 != dc_param_get_int( + (*msg).param, + DC_PARAM_WANTS_MDN as i32, + 0i32, + ) && 0 + != context .sql .get_config_int(context, "mdns_enabled") .unwrap_or_else(|| 1) @@ -622,7 +634,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_ dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char); } _ => { - if 0 != dc_param_get_int((*msg).param, 'r' as i32, 0i32) + if 0 != dc_param_get_int((*msg).param, DC_PARAM_WANTS_MDN as i32, 0) && 0 != context .sql .get_config_int(context, "mdns_enabled") @@ -760,8 +772,8 @@ unsafe fn dc_add_smtp_job( (*mimefactory).recipients_addr, b"\x1e\x00" as *const u8 as *const libc::c_char, ); - dc_param_set(param, 'f' as i32, pathNfilename); - dc_param_set(param, 'R' as i32, recipients); + dc_param_set(param, DC_PARAM_FILE as i32, pathNfilename); + dc_param_set(param, DC_PARAM_RECIPIENTS as i32, recipients); dc_job_add( context, action, @@ -1161,19 +1173,19 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in { let pathNfilename = dc_param_get( (*mimefactory.msg).param, - 'f' as i32, + DC_PARAM_FILE as i32, 0 as *const libc::c_char, ); if !pathNfilename.is_null() { if ((*mimefactory.msg).type_0 == 20i32 || (*mimefactory.msg).type_0 == 21i32) - && 0 == dc_param_exists((*mimefactory.msg).param, 'w' as i32) + && 0 == dc_param_exists((*mimefactory.msg).param, DC_PARAM_WIDTH as i32) { let mut buf: *mut libc::c_uchar = 0 as *mut libc::c_uchar; let mut buf_bytes: size_t = 0; let mut w: uint32_t = 0; let mut h: uint32_t = 0; - dc_param_set_int((*mimefactory.msg).param, 'w' as i32, 0i32); - dc_param_set_int((*mimefactory.msg).param, 'h' as i32, 0i32); + dc_param_set_int((*mimefactory.msg).param, DC_PARAM_WIDTH as i32, 0); + dc_param_set_int((*mimefactory.msg).param, DC_PARAM_HEIGHT as i32, 0); if 0 != dc_read_file( context, pathNfilename, @@ -1186,8 +1198,16 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in &mut w, &mut h, ) { - dc_param_set_int((*mimefactory.msg).param, 'w' as i32, w as int32_t); - dc_param_set_int((*mimefactory.msg).param, 'h' as i32, h as int32_t); + dc_param_set_int( + (*mimefactory.msg).param, + DC_PARAM_WIDTH as i32, + w as int32_t, + ); + dc_param_set_int( + (*mimefactory.msg).param, + DC_PARAM_HEIGHT as i32, + h as int32_t, + ); } } free(buf as *mut libc::c_void); @@ -1199,7 +1219,7 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in /* create message */ if 0 == dc_mimefactory_render(&mut mimefactory) { dc_set_msg_failed(context, msg_id, mimefactory.error); - } else if 0 != dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0) + } else if 0 != dc_param_get_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) && 0 == mimefactory.out_encrypted { warn!( @@ -1207,7 +1227,7 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in 0, "e2e encryption unavailable {} - {}", msg_id, - dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0), + dc_param_get_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0), ); dc_set_msg_failed( context, @@ -1245,9 +1265,10 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in } } if 0 != mimefactory.out_encrypted - && dc_param_get_int((*mimefactory.msg).param, 'c' as i32, 0i32) == 0i32 + && dc_param_get_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) + == 0 { - dc_param_set_int((*mimefactory.msg).param, 'c' as i32, 1i32); + dc_param_set_int((*mimefactory.msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1); dc_msg_save_param_to_disk(mimefactory.msg); } dc_add_to_keyhistory( diff --git a/src/dc_location.rs b/src/dc_location.rs index e9924ae45..00c99d762 100644 --- a/src/dc_location.rs +++ b/src/dc_location.rs @@ -76,7 +76,7 @@ pub unsafe fn dc_send_locations_to_chat( 0 as *const libc::c_char, 0, ); - dc_param_set_int((*msg).param, 'S' as i32, 8i32); + dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 8); dc_send_msg(context, chat_id, msg); } else if 0 == seconds && is_sending_locations_before { stock_str = dc_stock_system_msg( @@ -688,7 +688,7 @@ pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: *mu // and dc_set_location() is typically called periodically, this is ok) let mut msg = dc_msg_new(context, 10); (*msg).hidden = 1; - dc_param_set_int((*msg).param, 'S' as i32, 9); + dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 9); dc_send_msg(context, chat_id as u32, msg); dc_msg_unref(msg); } diff --git a/src/dc_mimefactory.rs b/src/dc_mimefactory.rs index 53b0f48cf..ec02713ea 100644 --- a/src/dc_mimefactory.rs +++ b/src/dc_mimefactory.rs @@ -187,11 +187,11 @@ pub unsafe fn dc_mimefactory_load_msg( ) .unwrap(); - let command = dc_param_get_int((*(*factory).msg).param, 'S' as i32, 0); + let command = dc_param_get_int((*(*factory).msg).param, DC_PARAM_CMD as i32, 0); if command == 5 { let email_to_remove_c = dc_param_get( (*(*factory).msg).param, - 'E' as i32, + DC_PARAM_CMD_ARG as i32, 0 as *const libc::c_char, ); let email_to_remove = to_string(email_to_remove_c); @@ -551,9 +551,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: e2ee_guaranteed = 1; min_verified = 2 } else { - force_plaintext = dc_param_get_int((*(*factory).msg).param, 'u' as i32, 0); + force_plaintext = + dc_param_get_int((*(*factory).msg).param, DC_PARAM_FORCE_PLAINTEXT as i32, 0); if force_plaintext == 0 { - e2ee_guaranteed = dc_param_get_int((*(*factory).msg).param, 'c' as i32, 0) + e2ee_guaranteed = + dc_param_get_int((*(*factory).msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) } } if (*chat).gossiped_timestamp == 0 @@ -562,7 +564,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: do_gossip = 1 } /* build header etc. */ - let command: libc::c_int = dc_param_get_int((*msg).param, 'S' as i32, 0); + let command: libc::c_int = dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0); if (*chat).type_0 == DC_CHAT_TYPE_GROUP as libc::c_int || (*chat).type_0 == DC_CHAT_TYPE_VERIFIED_GROUP as libc::c_int { @@ -581,8 +583,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: ), ); if command == 5 { - let email_to_remove: *mut libc::c_char = - dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char); + let email_to_remove: *mut libc::c_char = dc_param_get( + (*msg).param, + DC_PARAM_CMD_ARG as i32, + 0 as *const libc::c_char, + ); if !email_to_remove.is_null() { mailimf_fields_add( imf_fields, @@ -597,8 +602,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: } } else if command == 4 { do_gossip = 1; - let email_to_add: *mut libc::c_char = - dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char); + let email_to_add: *mut libc::c_char = dc_param_get( + (*msg).param, + DC_PARAM_CMD_ARG as i32, + 0 as *const libc::c_char, + ); if !email_to_add.is_null() { mailimf_fields_add( imf_fields, @@ -610,9 +618,13 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: email_to_add, ), ); - grpimage = dc_param_get((*chat).param, 'i' as i32, 0 as *const libc::c_char) + grpimage = dc_param_get( + (*chat).param, + DC_PARAM_PROFILE_IMAGE as i32, + 0 as *const libc::c_char, + ) } - if 0 != dc_param_get_int((*msg).param, 'F' as i32, 0) & 0x1 { + if 0 != dc_param_get_int((*msg).param, DC_PARAM_CMD_ARG2 as i32, 0) & 0x1 { info!( (*msg).context, 0, @@ -636,13 +648,17 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: ), dc_param_get( (*msg).param, - 'E' as i32, + DC_PARAM_CMD_ARG as i32, b"\x00" as *const u8 as *const libc::c_char, ), ), ); } else if command == 3 { - grpimage = dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char); + grpimage = dc_param_get( + (*msg).param, + DC_PARAM_CMD_ARG as i32, + 0 as *const libc::c_char, + ); if grpimage.is_null() { mailimf_fields_add( imf_fields, @@ -676,8 +692,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: placeholdertext = dc_stock_str((*factory).context, 43) } if command == 7 { - let step: *mut libc::c_char = - dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char); + let step: *mut libc::c_char = dc_param_get( + (*msg).param, + DC_PARAM_CMD_ARG as i32, + 0 as *const libc::c_char, + ); if !step.is_null() { info!( (*msg).context, @@ -692,8 +711,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: step, ), ); - let param2: *mut libc::c_char = - dc_param_get((*msg).param, 'F' as i32, 0 as *const libc::c_char); + let param2: *mut libc::c_char = dc_param_get( + (*msg).param, + DC_PARAM_CMD_ARG2 as i32, + 0 as *const libc::c_char, + ); if !param2.is_null() { mailimf_fields_add( imf_fields, @@ -721,8 +743,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: ), ); } - let fingerprint: *mut libc::c_char = - dc_param_get((*msg).param, 'G' as i32, 0 as *const libc::c_char); + let fingerprint: *mut libc::c_char = dc_param_get( + (*msg).param, + DC_PARAM_CMD_ARG3 as i32, + 0 as *const libc::c_char, + ); if !fingerprint.is_null() { mailimf_fields_add( imf_fields, @@ -735,8 +760,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: ), ); } - let grpid: *mut libc::c_char = - dc_param_get((*msg).param, 'H' as i32, 0 as *const libc::c_char); + let grpid: *mut libc::c_char = dc_param_get( + (*msg).param, + DC_PARAM_CMD_ARG4 as i32, + 0 as *const libc::c_char, + ); if !grpid.is_null() { mailimf_fields_add( imf_fields, @@ -753,7 +781,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: if !grpimage.is_null() { let mut meta: *mut dc_msg_t = dc_msg_new_untyped((*factory).context); (*meta).type_0 = DC_MSG_IMAGE as libc::c_int; - dc_param_set((*meta).param, 'f' as i32, grpimage); + dc_param_set((*meta).param, DC_PARAM_FILE as i32, grpimage); let mut filename_as_sent: *mut libc::c_char = 0 as *mut libc::c_char; meta_part = build_body_file( meta, @@ -784,7 +812,8 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: ), ); } - let duration_ms: libc::c_int = dc_param_get_int((*msg).param, 'd' as i32, 0); + let duration_ms: libc::c_int = + dc_param_get_int((*msg).param, DC_PARAM_DURATION as i32, 0); if duration_ms > 0 { mailimf_fields_add( imf_fields, @@ -798,7 +827,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: ); } } - afwd_email = dc_param_exists((*msg).param, 'a' as i32); + afwd_email = dc_param_exists((*msg).param, DC_PARAM_FORWARDED as i32); let mut fwdhint: *mut libc::c_char = 0 as *mut libc::c_char; if 0 != afwd_email { fwdhint = dc_strdup( @@ -980,7 +1009,7 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc: mailmime_add_part(message, multipart); let p1: *mut libc::c_char; let p2: *mut libc::c_char; - if 0 != dc_param_get_int((*(*factory).msg).param, 'c' as i32, 0) { + if 0 != dc_param_get_int((*(*factory).msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) { p1 = dc_stock_str((*factory).context, 24) } else { p1 = dc_msg_get_summarytext((*factory).msg, 32) @@ -1106,7 +1135,7 @@ unsafe fn get_subject( } else { b"\x00" as *const u8 as *const libc::c_char }; - if dc_param_get_int((*msg).param, 'S' as i32, 0) == 6 { + if dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0) == 6 { ret = dc_stock_str(context, 42) } else if (*chat).type_0 == DC_CHAT_TYPE_GROUP as libc::c_int || (*chat).type_0 == DC_CHAT_TYPE_VERIFIED_GROUP as libc::c_int @@ -1167,9 +1196,12 @@ unsafe fn build_body_file( let mut mime_sub: *mut mailmime = 0 as *mut mailmime; let content: *mut mailmime_content; let pathNfilename: *mut libc::c_char = - dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); - let mut mimetype: *mut libc::c_char = - dc_param_get((*msg).param, 'm' as i32, 0 as *const libc::c_char); + dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); + let mut mimetype: *mut libc::c_char = dc_param_get( + (*msg).param, + DC_PARAM_MIMETYPE as i32, + 0 as *const libc::c_char, + ); let suffix: *mut libc::c_char = dc_get_filesuffix_lc(pathNfilename); let mut filename_to_send: *mut libc::c_char = 0 as *mut libc::c_char; let mut filename_encoded: *mut libc::c_char = 0 as *mut libc::c_char; @@ -1328,7 +1360,7 @@ unsafe fn build_body_file( unsafe fn is_file_size_okay(msg: *const dc_msg_t) -> libc::c_int { let mut file_size_okay: libc::c_int = 1; let pathNfilename: *mut libc::c_char = - dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); + dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); let bytes: uint64_t = dc_get_filebytes((*msg).context, pathNfilename); if bytes > (49 * 1024 * 1024 / 4 * 3) as libc::c_ulonglong { file_size_okay = 0; diff --git a/src/dc_mimeparser.rs b/src/dc_mimeparser.rs index d6d57afb5..b6c56e2af 100644 --- a/src/dc_mimeparser.rs +++ b/src/dc_mimeparser.rs @@ -323,7 +323,7 @@ pub unsafe fn dc_mimeparser_parse( while i_1 < icnt_0 { let part_2: *mut dc_mimepart_t = carray_get((*mimeparser).parts, i_1 as libc::c_uint) as *mut dc_mimepart_t; - dc_param_set_int((*part_2).param, 'a' as i32, 1i32); + dc_param_set_int((*part_2).param, DC_PARAM_FORWARDED as i32, 1); i_1 += 1 } } @@ -348,7 +348,7 @@ pub unsafe fn dc_mimeparser_parse( if !field_0.is_null() { let duration_ms: libc::c_int = dc_atoi_null_is_0((*field_0).fld_value); if duration_ms > 0i32 && duration_ms < 24i32 * 60i32 * 60i32 * 1000i32 { - dc_param_set_int((*part_3).param, 'd' as i32, duration_ms); + dc_param_set_int((*part_3).param, DC_PARAM_DURATION as i32, duration_ms); } } } @@ -385,7 +385,11 @@ pub unsafe fn dc_mimeparser_parse( let part_4: *mut dc_mimepart_t = dc_mimeparser_get_last_nonmeta(mimeparser); if !part_4.is_null() { - dc_param_set_int((*part_4).param, 'r' as i32, 1i32); + dc_param_set_int( + (*part_4).param, + DC_PARAM_WANTS_MDN as i32, + 1, + ); } } free(from_addr as *mut libc::c_void); @@ -1486,8 +1490,8 @@ unsafe fn do_add_single_file_part( (*part).type_0 = msg_type; (*part).int_mimetype = mime_type; (*part).bytes = decoded_data_bytes as libc::c_int; - dc_param_set((*part).param, 'f' as i32, pathNfilename); - dc_param_set((*part).param, 'm' as i32, raw_mime); + dc_param_set((*part).param, DC_PARAM_FILE as i32, pathNfilename); + dc_param_set((*part).param, DC_PARAM_MIMETYPE as i32, raw_mime); if mime_type == 80i32 { let mut w: uint32_t = 0i32 as uint32_t; let mut h: uint32_t = 0i32 as uint32_t; @@ -1497,8 +1501,8 @@ unsafe fn do_add_single_file_part( &mut w, &mut h, ) { - dc_param_set_int((*part).param, 'w' as i32, w as int32_t); - dc_param_set_int((*part).param, 'h' as i32, h as int32_t); + dc_param_set_int((*part).param, DC_PARAM_WIDTH as i32, w as int32_t); + dc_param_set_int((*part).param, DC_PARAM_HEIGHT as i32, h as int32_t); } } do_add_single_part(parser, part); @@ -1511,9 +1515,9 @@ unsafe fn do_add_single_file_part( unsafe fn do_add_single_part(parser: &dc_mimeparser_t, part: *mut dc_mimepart_t) { if 0 != (*parser).e2ee_helper.encrypted && (*parser).e2ee_helper.signatures.len() > 0 { - dc_param_set_int((*part).param, 'c' as i32, 1i32); + dc_param_set_int((*part).param, DC_PARAM_GUARANTEE_E2EE as i32, 1); } else if 0 != (*parser).e2ee_helper.encrypted { - dc_param_set_int((*part).param, 'e' as i32, 0x2i32); + dc_param_set_int((*part).param, DC_PARAM_ERRONEOUS_E2EE as i32, 0x2); } carray_add( (*parser).parts, diff --git a/src/dc_msg.rs b/src/dc_msg.rs index 66e6ccd52..217d7f201 100644 --- a/src/dc_msg.rs +++ b/src/dc_msg.rs @@ -142,18 +142,22 @@ pub unsafe fn dc_get_msg_info(context: &Context, msg_id: u32) -> *mut libc::c_ch ret += ", Location sent"; } - let e2ee_errors = dc_param_get_int((*msg).param, 'e' as i32, 0); + let e2ee_errors = dc_param_get_int((*msg).param, DC_PARAM_ERRONEOUS_E2EE as i32, 0); if 0 != e2ee_errors { if 0 != e2ee_errors & 0x2 { ret += ", Encrypted, no valid signature"; } - } else if 0 != dc_param_get_int((*msg).param, 'c' as i32, 0) { + } else if 0 != dc_param_get_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) { ret += ", Encrypted"; } ret += "\n"; - p = dc_param_get((*msg).param, 'L' as i32, 0 as *const libc::c_char); + p = dc_param_get( + (*msg).param, + DC_PARAM_ERROR as i32, + 0 as *const libc::c_char, + ); if !p.is_null() { ret += &format!("Error: {}", as_str(p)); free(p as *mut libc::c_void); @@ -184,12 +188,12 @@ pub unsafe fn dc_get_msg_info(context: &Context, msg_id: u32) -> *mut libc::c_ch ret += &format!("Mimetype: {}\n", as_str(p)); free(p as *mut libc::c_void); } - let w = dc_param_get_int((*msg).param, 'w' as i32, 0); - let h = dc_param_get_int((*msg).param, 'h' as i32, 0); + let w = dc_param_get_int((*msg).param, DC_PARAM_WIDTH as i32, 0); + let h = dc_param_get_int((*msg).param, DC_PARAM_HEIGHT as i32, 0); if w != 0 || h != 0 { ret += &format!("Dimension: {} x {}\n", w, h,); } - let duration = dc_param_get_int((*msg).param, 'd' as i32, 0); + let duration = dc_param_get_int((*msg).param, DC_PARAM_DURATION as i32, 0); if duration != 0 { ret += &format!("Duration: {} ms\n", duration,); } @@ -269,9 +273,13 @@ pub unsafe fn dc_msg_get_filemime(msg: *const dc_msg_t) -> *mut libc::c_char { let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; let mut file: *mut libc::c_char = 0 as *mut libc::c_char; if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { - ret = dc_param_get((*msg).param, 'm' as i32, 0 as *const libc::c_char); + ret = dc_param_get( + (*msg).param, + DC_PARAM_MIMETYPE as i32, + 0 as *const libc::c_char, + ); if ret.is_null() { - file = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); + file = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); if !file.is_null() { dc_msg_guess_msgtype_from_suffix(file, 0 as *mut libc::c_int, &mut ret); if ret.is_null() { @@ -348,7 +356,7 @@ pub unsafe fn dc_msg_get_file(msg: *const dc_msg_t) -> *mut libc::c_char { let mut file_rel: *mut libc::c_char = 0 as *mut libc::c_char; let mut file_abs: *mut libc::c_char = 0 as *mut libc::c_char; if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { - file_rel = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); + file_rel = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); if !file_rel.is_null() { file_abs = dc_get_abs_path((*msg).context, file_rel) } @@ -696,7 +704,7 @@ pub unsafe fn dc_msg_get_filename(msg: *const dc_msg_t) -> *mut libc::c_char { let mut ret: *mut libc::c_char = 0 as *mut libc::c_char; let mut pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char; if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { - pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); + pathNfilename = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); if !pathNfilename.is_null() { ret = dc_get_filename(pathNfilename) } @@ -713,7 +721,7 @@ pub unsafe fn dc_msg_get_filebytes(msg: *const dc_msg_t) -> uint64_t { let mut ret: uint64_t = 0i32 as uint64_t; let mut file: *mut libc::c_char = 0 as *mut libc::c_char; if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { - file = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); + file = dc_param_get((*msg).param, DC_PARAM_FILE as i32, 0 as *const libc::c_char); if !file.is_null() { ret = dc_get_filebytes((*msg).context, file) } @@ -728,7 +736,7 @@ pub unsafe fn dc_msg_get_width(msg: *const dc_msg_t) -> libc::c_int { return 0i32; } - dc_param_get_int((*msg).param, 'w' as i32, 0i32) + dc_param_get_int((*msg).param, DC_PARAM_WIDTH as i32, 0) } pub unsafe fn dc_msg_get_height(msg: *const dc_msg_t) -> libc::c_int { @@ -736,7 +744,7 @@ pub unsafe fn dc_msg_get_height(msg: *const dc_msg_t) -> libc::c_int { return 0i32; } - dc_param_get_int((*msg).param, 'h' as i32, 0i32) + dc_param_get_int((*msg).param, DC_PARAM_HEIGHT as i32, 0) } pub unsafe fn dc_msg_get_duration(msg: *const dc_msg_t) -> libc::c_int { @@ -744,7 +752,7 @@ pub unsafe fn dc_msg_get_duration(msg: *const dc_msg_t) -> libc::c_int { return 0; } - dc_param_get_int((*msg).param, 'd' as i32, 0i32) + dc_param_get_int((*msg).param, DC_PARAM_DURATION as i32, 0) } // TODO should return bool /rtn @@ -752,7 +760,7 @@ pub unsafe fn dc_msg_get_showpadlock(msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } - if dc_param_get_int((*msg).param, 'c' as i32, 0i32) != 0i32 { + if dc_param_get_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 0) != 0i32 { return 1i32; } @@ -835,13 +843,13 @@ pub unsafe fn dc_msg_get_summarytext_by_raw( 50 => prefix = dc_stock_str(context, 10i32), 41 => prefix = dc_stock_str(context, 7i32), 40 | 60 => { - if dc_param_get_int(param, 'S' as i32, 0i32) == 6i32 { + if dc_param_get_int(param, DC_PARAM_CMD as i32, 0) == 6i32 { prefix = dc_stock_str(context, 42i32); append_text = 0i32 } else { pathNfilename = dc_param_get( param, - 'f' as i32, + DC_PARAM_FILE as i32, b"ErrFilename\x00" as *const u8 as *const libc::c_char, ); value = dc_get_filename(pathNfilename); @@ -861,7 +869,7 @@ pub unsafe fn dc_msg_get_summarytext_by_raw( } } _ => { - if dc_param_get_int(param, 'S' as i32, 0i32) == 9i32 { + if dc_param_get_int(param, DC_PARAM_CMD as i32, 0) == 9i32 { prefix = dc_stock_str(context, 66i32); append_text = 0i32 } @@ -925,7 +933,7 @@ pub unsafe fn dc_msg_is_forwarded(msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } - return if 0 != dc_param_get_int((*msg).param, 'a' as i32, 0i32) { + return if 0 != dc_param_get_int((*msg).param, DC_PARAM_FORWARDED as i32, 0) { 1i32 } else { 0i32 @@ -937,7 +945,7 @@ pub unsafe fn dc_msg_is_info(msg: *const dc_msg_t) -> libc::c_int { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return 0i32; } - let cmd: libc::c_int = dc_param_get_int((*msg).param, 'S' as i32, 0i32); + let cmd: libc::c_int = dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0); if (*msg).from_id == 2i32 as libc::c_uint || (*msg).to_id == 2i32 as libc::c_uint || 0 != cmd && cmd != 6i32 @@ -971,7 +979,7 @@ pub unsafe fn dc_msg_is_setupmessage(msg: *const dc_msg_t) -> bool { return false; } - if dc_param_get_int((*msg).param, 'S' as i32, 0) == 6 { + if dc_param_get_int((*msg).param, DC_PARAM_CMD as i32, 0) == 6 { true } else { true @@ -1045,23 +1053,23 @@ pub unsafe fn dc_msg_set_file( if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return; } - dc_param_set((*msg).param, 'f' as i32, file); - dc_param_set((*msg).param, 'm' as i32, filemime); + dc_param_set((*msg).param, DC_PARAM_FILE as i32, file); + dc_param_set((*msg).param, DC_PARAM_MIMETYPE as i32, filemime); } pub unsafe fn dc_msg_set_dimension(msg: *mut dc_msg_t, width: libc::c_int, height: libc::c_int) { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return; } - dc_param_set_int((*msg).param, 'w' as i32, width); - dc_param_set_int((*msg).param, 'h' as i32, height); + dc_param_set_int((*msg).param, DC_PARAM_WIDTH as i32, width); + dc_param_set_int((*msg).param, DC_PARAM_HEIGHT as i32, height); } pub unsafe fn dc_msg_set_duration(msg: *mut dc_msg_t, duration: libc::c_int) { if msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint { return; } - dc_param_set_int((*msg).param, 'd' as i32, duration); + dc_param_set_int((*msg).param, DC_PARAM_DURATION as i32, duration); } pub unsafe fn dc_msg_latefiling_mediasize( @@ -1072,11 +1080,11 @@ pub unsafe fn dc_msg_latefiling_mediasize( ) { if !(msg.is_null() || (*msg).magic != 0x11561156i32 as libc::c_uint) { if width > 0i32 && height > 0i32 { - dc_param_set_int((*msg).param, 'w' as i32, width); - dc_param_set_int((*msg).param, 'h' as i32, height); + dc_param_set_int((*msg).param, DC_PARAM_WIDTH as i32, width); + dc_param_set_int((*msg).param, DC_PARAM_HEIGHT as i32, height); } if duration > 0i32 { - dc_param_set_int((*msg).param, 'd' as i32, duration); + dc_param_set_int((*msg).param, DC_PARAM_DURATION as i32, duration); } dc_msg_save_param_to_disk(msg); }; @@ -1173,7 +1181,7 @@ pub unsafe fn dc_set_msg_failed(context: &Context, msg_id: uint32_t, error: *con (*msg).state = 24 } if !error.is_null() { - dc_param_set((*msg).param, 'L' as i32, error); + dc_param_set((*msg).param, DC_PARAM_ERROR as i32, error); error!(context, 0, "{}", as_str(error),); } diff --git a/src/dc_param.rs b/src/dc_param.rs index f6591771a..fa412db9b 100644 --- a/src/dc_param.rs +++ b/src/dc_param.rs @@ -3,59 +3,61 @@ use crate::types::*; use crate::x::*; /// for msgs and jobs -pub const DC_PARAM_FILE: char = 'f'; +pub const DC_PARAM_FILE: char = 'f'; // string /// for msgs -pub const DC_PARAM_WIDTH: char = 'w'; +pub const DC_PARAM_WIDTH: char = 'w'; // int /// for msgs -pub const DC_PARAM_HEIGHT: char = 'h'; +pub const DC_PARAM_HEIGHT: char = 'h'; // int /// for msgs -pub const DC_PARAM_DURATION: char = 'd'; +pub const DC_PARAM_DURATION: char = 'd'; // int /// for msgs -pub const DC_PARAM_MIMETYPE: char = 'm'; +pub const DC_PARAM_MIMETYPE: char = 'm'; // string /// for msgs: incoming: message is encryoted, outgoing: guarantee E2EE or the message is not send -pub const DC_PARAM_GUARANTEE_E2EE: char = 'c'; +pub const DC_PARAM_GUARANTEE_E2EE: char = 'c'; // int (bool?) /// for msgs: decrypted with validation errors or without mutual set, if neither 'c' nor 'e' are preset, the messages is only transport encrypted -pub const DC_PARAM_ERRONEOUS_E2EE: char = 'e'; +pub const DC_PARAM_ERRONEOUS_E2EE: char = 'e'; // int /// for msgs: force unencrypted message, either DC_FP_ADD_AUTOCRYPT_HEADER (1), DC_FP_NO_AUTOCRYPT_HEADER (2) or 0 -pub const DC_PARAM_FORCE_PLAINTEXT: char = 'u'; +pub const DC_PARAM_FORCE_PLAINTEXT: char = 'u'; // int (bool?) /// for msgs: an incoming message which requestes a MDN (aka read receipt) -pub const DC_PARAM_WANTS_MDN: char = 'r'; +pub const DC_PARAM_WANTS_MDN: char = 'r'; // int (bool?) /// for msgs -pub const DC_PARAM_FORWARDED: char = 'a'; +pub const DC_PARAM_FORWARDED: char = 'a'; // int (bool?) /// for msgs -pub const DC_PARAM_CMD: char = 'S'; +pub const DC_PARAM_CMD: char = 'S'; // int /// for msgs -pub const DC_PARAM_CMD_ARG: char = 'E'; +pub const DC_PARAM_CMD_ARG: char = 'E'; // string /// for msgs -pub const DC_PARAM_CMD_ARG2: char = 'F'; +pub const DC_PARAM_CMD_ARG2: char = 'F'; // string /// for msgs -pub const DC_PARAM_CMD_ARG3: char = 'G'; +pub const DC_PARAM_CMD_ARG3: char = 'G'; // string /// for msgs -pub const DC_PARAM_CMD_ARG4: char = 'H'; +pub const DC_PARAM_CMD_ARG4: char = 'H'; // string /// for msgs -pub const DC_PARAM_ERROR: char = 'L'; +pub const DC_PARAM_ERROR: char = 'L'; // string /// for msgs in PREPARING: space-separated list of message IDs of forwarded copies -pub const DC_PARAM_PREP_FORWARDS: char = 'P'; +pub const DC_PARAM_PREP_FORWARDS: char = 'P'; // string /// for msgs -pub const DC_PARAM_SET_LATITUDE: char = 'l'; +pub const DC_PARAM_SET_LATITUDE: char = 'l'; // float /// for msgs -pub const DC_PARAM_SET_LONGITUDE: char = 'n'; +pub const DC_PARAM_SET_LONGITUDE: char = 'n'; // float /// for jobs -pub const DC_PARAM_SERVER_FOLDER: char = 'Z'; +pub const DC_PARAM_SERVER_FOLDER: char = 'Z'; // string /// for jobs -pub const DC_PARAM_SERVER_UID: char = 'z'; +pub const DC_PARAM_SERVER_UID: char = 'z'; // int /// for jobs -pub const DC_PARAM_ALSO_MOVE: char = 'M'; +pub const DC_PARAM_ALSO_MOVE: char = 'M'; // int (bool?) /// for jobs: space-separated list of message recipients -pub const DC_PARAM_RECIPIENTS: char = 'R'; +pub const DC_PARAM_RECIPIENTS: char = 'R'; // stringap /// for groups -pub const DC_PARAM_UNPROMOTED: char = 'U'; +pub const DC_PARAM_UNPROMOTED: char = 'U'; // int (bool?) /// for groups and contacts -pub const DC_PARAM_PROFILE_IMAGE: char = 'i'; +pub const DC_PARAM_PROFILE_IMAGE: char = 'i'; // string (bytes?) /// for chats pub const DC_PARAM_SELFTALK: char = 'K'; +// missing: 's', 'x', 'g' + // values for DC_PARAM_FORCE_PLAINTEXT pub const DC_FP_ADD_AUTOCRYPT_HEADER: u8 = 1; pub const DC_FP_NO_AUTOCRYPT_HEADER: u8 = 2; diff --git a/src/dc_qr.rs b/src/dc_qr.rs index 1b72ab2d6..337ebd14f 100644 --- a/src/dc_qr.rs +++ b/src/dc_qr.rs @@ -56,16 +56,23 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc fragment = fragment.offset(1isize); let param: *mut dc_param_t = dc_param_new(); dc_param_set_urlencoded(param, fragment); - addr = dc_param_get(param, 'a' as i32, 0 as *const libc::c_char); + addr = dc_param_get(param, DC_PARAM_FORWARDED as i32, 0 as *const libc::c_char); if !addr.is_null() { - let mut urlencoded: *mut libc::c_char = - dc_param_get(param, 'n' as i32, 0 as *const libc::c_char); + let mut urlencoded: *mut libc::c_char = dc_param_get( + param, + DC_PARAM_SET_LONGITUDE as i32, + 0 as *const libc::c_char, + ); if !urlencoded.is_null() { name = dc_urldecode(urlencoded); dc_normalize_name(name); free(urlencoded as *mut libc::c_void); } - invitenumber = dc_param_get(param, 'i' as i32, 0 as *const libc::c_char); + invitenumber = dc_param_get( + param, + DC_PARAM_PROFILE_IMAGE as i32, + 0 as *const libc::c_char, + ); auth = dc_param_get(param, 's' as i32, 0 as *const libc::c_char); grpid = dc_param_get(param, 'x' as i32, 0 as *const libc::c_char); if !grpid.is_null() { diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index 1483e74d6..1798ea29d 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -741,17 +741,21 @@ pub unsafe fn dc_receive_imf( let param = dc_param_new(); dc_param_set( param, - 'Z' as i32, + DC_PARAM_SERVER_FOLDER as i32, to_cstring(server_folder.as_ref()).as_ptr(), ); - dc_param_set_int(param, 'z' as i32, server_uid as i32); + dc_param_set_int( + param, + DC_PARAM_SERVER_UID as i32, + 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, 'M' as i32, 1); + dc_param_set_int(param, DC_PARAM_ALSO_MOVE as i32, 1); } dc_job_add(context, 120, 0, (*param).packed, 0); dc_param_unref(param); @@ -1210,7 +1214,7 @@ unsafe fn create_or_lookup_group( if (*part).type_0 == 20 { grpimage = dc_param_get( (*part).param, - 'f' as i32, + DC_PARAM_FILE as i32, 0 as *const libc::c_char, ); ok = 1 @@ -1231,7 +1235,11 @@ unsafe fn create_or_lookup_group( }, ); dc_chat_load_from_db(chat, chat_id); - dc_param_set((*chat).param, 'i' as i32, grpimage); + dc_param_set( + (*chat).param, + DC_PARAM_PROFILE_IMAGE as i32, + grpimage, + ); dc_chat_update_param(chat); dc_chat_unref(chat); free(grpimage as *mut libc::c_void); diff --git a/src/dc_securejoin.rs b/src/dc_securejoin.rs index 07d34637d..25487151b 100644 --- a/src/dc_securejoin.rs +++ b/src/dc_securejoin.rs @@ -267,23 +267,23 @@ unsafe fn send_handshake_msg( step, ); (*msg).hidden = 1i32; - dc_param_set_int((*msg).param, 'S' as i32, 7i32); - dc_param_set((*msg).param, 'E' as i32, step); + dc_param_set_int((*msg).param, DC_PARAM_CMD as i32, 7); + dc_param_set((*msg).param, DC_PARAM_CMD_ARG as i32, step); if !param2.is_null() { - dc_param_set((*msg).param, 'F' as i32, param2); + dc_param_set((*msg).param, DC_PARAM_CMD_ARG2 as i32, param2); } if !fingerprint.is_null() { - dc_param_set((*msg).param, 'G' as i32, fingerprint); + dc_param_set((*msg).param, DC_PARAM_CMD_ARG3 as i32, fingerprint); } if !grpid.is_null() { - dc_param_set((*msg).param, 'H' as i32, grpid); + dc_param_set((*msg).param, DC_PARAM_CMD_ARG4 as i32, grpid); } 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 { - dc_param_set_int((*msg).param, 'u' as i32, 1i32); + dc_param_set_int((*msg).param, DC_PARAM_FORCE_PLAINTEXT as i32, 1); } else { - dc_param_set_int((*msg).param, 'c' as i32, 1i32); + dc_param_set_int((*msg).param, DC_PARAM_GUARANTEE_E2EE as i32, 1); } dc_send_msg(context, contact_chat_id, msg); dc_msg_unref(msg); diff --git a/src/sql.rs b/src/sql.rs index 4863d8ecd..ceca9016f 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -131,6 +131,7 @@ impl Sql { }) } + /// Execute a query which is expected to return one row. pub fn query_row(&self, sql: impl AsRef, params: P, f: F) -> Result where P: IntoIterator,