diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 283a7601d..ffa06ea6a 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -3834,7 +3834,7 @@ dc_msg_t* dc_msg_get_quoted_msg (const dc_msg_t* msg); * By default, these names are equal, * but functions working with contact names * (e.g. dc_contact_get_name(), dc_contact_get_display_name(), - * dc_contact_get_name_n_addr(), dc_contact_get_first_name(), + * dc_contact_get_name_n_addr(), * dc_create_contact() or dc_add_address_book()) * only affect the given-name. */ @@ -3924,19 +3924,6 @@ char* dc_contact_get_display_name (const dc_contact_t* contact); char* dc_contact_get_name_n_addr (const dc_contact_t* contact); -/** - * Get the part of the name before the first space. In most languages, this seems to be - * the prename. If there is no space, the full display name is returned. - * If the display name is not set, the e-mail address is returned. - * - * @memberof dc_contact_t - * @param contact The contact object. - * @return String with the name to display, must be released using dc_str_unref(). - * Never returns NULL. - */ -char* dc_contact_get_first_name (const dc_contact_t* contact); - - /** * Get the contact's profile image. * This is the image set by each remote user on their own diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 577de039f..f54539f4a 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -3151,18 +3151,6 @@ pub unsafe extern "C" fn dc_contact_get_name_n_addr( ffi_contact.contact.get_name_n_addr().strdup() } -#[no_mangle] -pub unsafe extern "C" fn dc_contact_get_first_name( - contact: *mut dc_contact_t, -) -> *mut libc::c_char { - if contact.is_null() { - eprintln!("ignoring careless call to dc_contact_get_first_name()"); - return "".strdup(); - } - let ffi_contact = &*contact; - ffi_contact.contact.get_first_name().strdup() -} - #[no_mangle] pub unsafe extern "C" fn dc_contact_get_profile_image( contact: *mut dc_contact_t, diff --git a/src/contact.rs b/src/contact.rs index 6a3e74452..d85a01d51 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -888,16 +888,6 @@ impl Contact { (&self.addr).into() } - /// Get the part of the name before the first space. In most languages, this seems to be - /// the prename. If there is no space, the full display name is returned. - /// If the display name is not set, the e-mail address is returned. - pub fn get_first_name(&self) -> &str { - if !self.name.is_empty() { - return get_first_name(&self.name); - } - &self.addr - } - /// Get the contact's profile image. /// This is the image set by each remote user on their own /// using dc_set_config(context, "selfavatar", image). @@ -1035,11 +1025,6 @@ impl Contact { } } -/// Extracts first name from full name. -fn get_first_name(full_name: &str) -> &str { - full_name.splitn(2, ' ').next().unwrap_or_default() -} - /// Returns false if addr is an invalid address, otherwise true. pub fn may_be_valid_addr(addr: &str) -> bool { let res = addr.parse::(); @@ -1283,11 +1268,6 @@ mod tests { assert_ne!(addr_normalize("John@Doe.com"), "john@doe.com"); } - #[test] - fn test_get_first_name() { - assert_eq!(get_first_name("John Doe"), "John"); - } - #[test] fn test_split_address_book() { let book = "Name one\nAddress one\nName two\nAddress two\nrest name"; diff --git a/src/message.rs b/src/message.rs index 2b5da1270..185edc8dd 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1032,7 +1032,7 @@ impl Lot { self.text1 = None; } } else if let Some(contact) = contact { - self.text1 = Some(contact.get_first_name().into()); + self.text1 = Some(contact.get_display_name().into()); } else { self.text1 = None; }