From 24c0a833bdc6a405fcc3e2e37891d0a7facb79b9 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Wed, 9 Oct 2019 14:25:27 +0200 Subject: [PATCH] address @flub comments --- deltachat-ffi/deltachat.h | 12 +++--------- deltachat-ffi/src/lib.rs | 6 ------ examples/repl/main.rs | 1 - src/context.rs | 4 ++-- src/events.rs | 15 --------------- src/imex.rs | 2 +- 6 files changed, 6 insertions(+), 34 deletions(-) diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index bf19ba09d..b37b9e0ef 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -4201,16 +4201,10 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot); /** - * Requeste a localized string from the frontend. + * (DEPRECATED, DC_EVENT_GET_STRING is not emmitted anymore. Use + * dc_set_stock_translation() to pre-fill translations for stock + * messages. * - * @param data1 (int) ID of the string to request, one of the DC_STR_* constants. - * @param data2 (int) The count. If the requested string contains a placeholder for a numeric value, - * the ui may use this value to return different strings on different plural forms. - * @return (const char*) Null-terminated UTF-8 string. - * The string will be free()'d by the core, - * so it must be allocated using malloc() or a compatible function. - * Return 0 if the ui cannot provide the requested string - * the core will use a default string in english language then. */ #define DC_EVENT_GET_STRING 2091 diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index dc89cf167..654589735 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -167,12 +167,6 @@ impl ContextWrapper { contact_id as uintptr_t, progress as uintptr_t, ), - Event::GetString { id, count } => ffi_cb( - self, - event_id, - id.to_u32().unwrap_or_default() as uintptr_t, - count as uintptr_t, - ), } } None => 0, diff --git a/examples/repl/main.rs b/examples/repl/main.rs index 62839b321..eba162f92 100644 --- a/examples/repl/main.rs +++ b/examples/repl/main.rs @@ -43,7 +43,6 @@ use self::cmdline::*; fn receive_event(_context: &Context, event: Event) -> libc::uintptr_t { match event { - Event::GetString { .. } => {} Event::Info(msg) => { /* do not show the event as this would fill the screen */ println!("{}", msg); diff --git a/src/context.rs b/src/context.rs index 2d321e58d..e7d3fbd1f 100644 --- a/src/context.rs +++ b/src/context.rs @@ -63,7 +63,7 @@ pub struct Context { pub running_state: Arc>, /// Mutex to avoid generating the key for the user more than once. pub generating_key_mutex: Mutex<()>, - pub translated_stockstrings: Arc>>, + pub translated_stockstrings: RwLock>, } #[derive(Debug, PartialEq, Eq)] @@ -146,7 +146,7 @@ impl Context { probe_imap_network: Arc::new(RwLock::new(false)), perform_inbox_jobs_needed: Arc::new(RwLock::new(false)), generating_key_mutex: Mutex::new(()), - translated_stockstrings: Arc::new(RwLock::new(HashMap::new())), + translated_stockstrings: RwLock::new(HashMap::new()), }; ensure!( diff --git a/src/events.rs b/src/events.rs index a2cbc6512..d5c1f73f8 100644 --- a/src/events.rs +++ b/src/events.rs @@ -2,8 +2,6 @@ use std::path::PathBuf; use strum::EnumProperty; -use crate::stock::StockMessage; - impl Event { /// Returns the corresponding Event id. pub fn as_id(&self) -> i32 { @@ -237,17 +235,4 @@ pub enum Event { /// @return 0 #[strum(props(id = "2061"))] SecurejoinJoinerProgress { contact_id: u32, progress: usize }, - - // the following events are functions that should be provided by the frontends - /// Requeste a localized string from the frontend. - /// @param data1 (int) ID of the string to request, one of the DC_STR_/// constants. - /// @param data2 (int) The count. If the requested string contains a placeholder for a numeric value, - /// the ui may use this value to return different strings on different plural forms. - /// @return (const char*) Null-terminated UTF-8 string. - /// The string will be free()'d by the core, - /// so it must be allocated using malloc() or a compatible function. - /// Return 0 if the ui cannot provide the requested string - /// the core will use a default string in english language then. - #[strum(props(id = "2091"))] - GetString { id: StockMessage, count: usize }, } diff --git a/src/imex.rs b/src/imex.rs index 3d9db3b74..953d18fbd 100644 --- a/src/imex.rs +++ b/src/imex.rs @@ -806,7 +806,7 @@ mod tests { } #[test] - fn otest_render_setup_file_newline_replace() { + fn test_render_setup_file_newline_replace() { let t = dummy_context(); t.ctx .set_stock_translation(StockMessage::AcSetupMsgBody, "hello\r\nthere".to_string())