Merge pull request #1403 from deltachat/remove-unused

remove unused api
This commit is contained in:
bjoern
2020-04-17 13:02:09 +02:00
committed by GitHub
10 changed files with 13 additions and 112 deletions

View File

@@ -1,5 +1,10 @@
# Changelog # Changelog
## UNRELEASED
- removed api: dc_chat_get_subtitle(), dc_get_version_str(), dc_array_add_id()
## 1.28.0 ## 1.28.0
- new flag DC_GCL_FOR_FORWARDING for dc_get_chatlist() - new flag DC_GCL_FOR_FORWARDING for dc_get_chatlist()

View File

@@ -2827,19 +2827,6 @@ int dc_chat_get_type (const dc_chat_t* chat);
char* dc_chat_get_name (const dc_chat_t* chat); char* dc_chat_get_name (const dc_chat_t* chat);
/*
* Get a subtitle for a chat. The subtitle is eg. the email-address or the
* number of group members.
*
* Deprecated function. Subtitles should be created in the ui
* where plural forms and other specials can be handled more gracefully.
*
* @param chat The chat object to calulate the subtitle for.
* @return Subtitle as a string. Must be released using dc_str_unref() after usage. Never NULL.
*/
char* dc_chat_get_subtitle (const dc_chat_t* chat);
/** /**
* Get the chat's profile image. * Get the chat's profile image.
* For groups, this is the image set by any group member * For groups, this is the image set by any group member
@@ -4537,8 +4524,6 @@ int64_t dc_lot_get_timestamp (const dc_lot_t* lot);
#define DC_EVENT_DATA2_IS_STRING(e) ((e)>=100 && (e)<=499) #define DC_EVENT_DATA2_IS_STRING(e) ((e)>=100 && (e)<=499)
#define DC_EVENT_RETURNS_INT(e) ((e)==DC_EVENT_IS_OFFLINE) // not used anymore #define DC_EVENT_RETURNS_INT(e) ((e)==DC_EVENT_IS_OFFLINE) // not used anymore
#define DC_EVENT_RETURNS_STRING(e) ((e)==DC_EVENT_GET_STRING) // not used anymore #define DC_EVENT_RETURNS_STRING(e) ((e)==DC_EVENT_GET_STRING) // not used anymore
char* dc_get_version_str (void); // deprecated
void dc_array_add_id (dc_array_t*, uint32_t); // deprecated
#define dc_archive_chat(a,b,c) dc_set_chat_visibility((a), (b), (c)? 1 : 0) // not used anymore #define dc_archive_chat(a,b,c) dc_set_chat_visibility((a), (b), (c)? 1 : 0) // not used anymore
#define dc_chat_get_archived(a) (dc_chat_get_visibility((a))==1? 1 : 0) // not used anymore #define dc_chat_get_archived(a) (dc_chat_get_visibility((a))==1? 1 : 0) // not used anymore
@@ -4668,8 +4653,6 @@ void dc_array_add_id (dc_array_t*, uint32_t); // depreca
#define DC_STR_NOMESSAGES 1 #define DC_STR_NOMESSAGES 1
#define DC_STR_SELF 2 #define DC_STR_SELF 2
#define DC_STR_DRAFT 3 #define DC_STR_DRAFT 3
#define DC_STR_MEMBER 4
#define DC_STR_CONTACT 6
#define DC_STR_VOICEMESSAGE 7 #define DC_STR_VOICEMESSAGE 7
#define DC_STR_DEADDROP 8 #define DC_STR_DEADDROP 8
#define DC_STR_IMAGE 9 #define DC_STR_IMAGE 9
@@ -4701,7 +4684,6 @@ void dc_array_add_id (dc_array_t*, uint32_t); // depreca
#define DC_STR_STARREDMSGS 41 #define DC_STR_STARREDMSGS 41
#define DC_STR_AC_SETUP_MSG_SUBJECT 42 #define DC_STR_AC_SETUP_MSG_SUBJECT 42
#define DC_STR_AC_SETUP_MSG_BODY 43 #define DC_STR_AC_SETUP_MSG_BODY 43
#define DC_STR_SELFTALK_SUBTITLE 50
#define DC_STR_CANNOT_LOGIN 60 #define DC_STR_CANNOT_LOGIN 60
#define DC_STR_SERVER_RESPONSE 61 #define DC_STR_SERVER_RESPONSE 61
#define DC_STR_MSGACTIONBYUSER 62 #define DC_STR_MSGACTIONBYUSER 62

View File

@@ -484,11 +484,6 @@ pub unsafe extern "C" fn dc_get_oauth2_url(
.unwrap_or_else(|_| ptr::null_mut()) .unwrap_or_else(|_| ptr::null_mut())
} }
#[no_mangle]
pub unsafe extern "C" fn dc_get_version_str() -> *mut libc::c_char {
context::get_version_str().strdup()
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn dc_configure(context: *mut dc_context_t) { pub unsafe extern "C" fn dc_configure(context: *mut dc_context_t) {
if context.is_null() { if context.is_null() {
@@ -2104,16 +2099,6 @@ pub unsafe extern "C" fn dc_array_unref(a: *mut dc_array::dc_array_t) {
Box::from_raw(a); Box::from_raw(a);
} }
#[no_mangle]
pub unsafe extern "C" fn dc_array_add_id(array: *mut dc_array_t, item: libc::c_uint) {
if array.is_null() {
eprintln!("ignoring careless call to dc_array_add_id()");
return;
}
(*array).add_id(item);
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn dc_array_get_cnt(array: *const dc_array_t) -> libc::size_t { pub unsafe extern "C" fn dc_array_get_cnt(array: *const dc_array_t) -> libc::size_t {
if array.is_null() { if array.is_null() {
@@ -2441,19 +2426,6 @@ pub unsafe extern "C" fn dc_chat_get_name(chat: *mut dc_chat_t) -> *mut libc::c_
ffi_chat.chat.get_name().strdup() ffi_chat.chat.get_name().strdup()
} }
#[no_mangle]
pub unsafe extern "C" fn dc_chat_get_subtitle(chat: *mut dc_chat_t) -> *mut libc::c_char {
if chat.is_null() {
eprintln!("ignoring careless call to dc_chat_get_subtitle()");
return "".strdup();
}
let ffi_chat = &*chat;
let ffi_context: &ContextWrapper = &*ffi_chat.context;
ffi_context
.with_inner(|ctx| ffi_chat.chat.get_subtitle(ctx).strdup())
.unwrap_or_else(|_| "".strdup())
}
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn dc_chat_get_profile_image(chat: *mut dc_chat_t) -> *mut libc::c_char { pub unsafe extern "C" fn dc_chat_get_profile_image(chat: *mut dc_chat_t) -> *mut libc::c_char {
if chat.is_null() { if chat.is_null() {

View File

@@ -415,12 +415,6 @@ class Chat(object):
""" """
return lib.dc_chat_get_color(self._dc_chat) return lib.dc_chat_get_color(self._dc_chat)
def get_subtitle(self):
"""return the subtitle of the chat
:returns: the subtitle
"""
return from_dc_charpointer(lib.dc_chat_get_subtitle(self._dc_chat))
# ------ location streaming API ------------------------------ # ------ location streaming API ------------------------------
def is_sending_locations(self): def is_sending_locations(self):

View File

@@ -117,8 +117,6 @@ DC_CHAT_VISIBILITY_PINNED = 2
DC_STR_NOMESSAGES = 1 DC_STR_NOMESSAGES = 1
DC_STR_SELF = 2 DC_STR_SELF = 2
DC_STR_DRAFT = 3 DC_STR_DRAFT = 3
DC_STR_MEMBER = 4
DC_STR_CONTACT = 6
DC_STR_VOICEMESSAGE = 7 DC_STR_VOICEMESSAGE = 7
DC_STR_DEADDROP = 8 DC_STR_DEADDROP = 8
DC_STR_IMAGE = 9 DC_STR_IMAGE = 9
@@ -150,7 +148,6 @@ DC_STR_ARCHIVEDCHATS = 40
DC_STR_STARREDMSGS = 41 DC_STR_STARREDMSGS = 41
DC_STR_AC_SETUP_MSG_SUBJECT = 42 DC_STR_AC_SETUP_MSG_SUBJECT = 42
DC_STR_AC_SETUP_MSG_BODY = 43 DC_STR_AC_SETUP_MSG_BODY = 43
DC_STR_SELFTALK_SUBTITLE = 50
DC_STR_CANNOT_LOGIN = 60 DC_STR_CANNOT_LOGIN = 60
DC_STR_SERVER_RESPONSE = 61 DC_STR_SERVER_RESPONSE = 61
DC_STR_MSGACTIONBYUSER = 62 DC_STR_MSGACTIONBYUSER = 62

View File

@@ -221,7 +221,6 @@ class TestOfflineChat:
# assert d["param"] == chat.param # assert d["param"] == chat.param
assert d["color"] == chat.get_color() assert d["color"] == chat.get_color()
assert d["profile_image"] == "" if chat.get_profile_image() is None else chat.get_profile_image() assert d["profile_image"] == "" if chat.get_profile_image() is None else chat.get_profile_image()
assert d["subtitle"] == chat.get_subtitle()
assert d["draft"] == "" if chat.get_draft() is None else chat.get_draft() assert d["draft"] == "" if chat.get_draft() is None else chat.get_draft()
def test_group_chat_creation_with_translation(self, ac1): def test_group_chat_creation_with_translation(self, ac1):

View File

@@ -604,38 +604,6 @@ impl Chat {
&self.name &self.name
} }
pub fn get_subtitle(&self, context: &Context) -> String {
// returns either the address or the number of chat members
if self.typ == Chattype::Single && self.param.exists(Param::Selftalk) {
return context.stock_str(StockMessage::SelfTalkSubTitle).into();
}
if self.typ == Chattype::Single {
return context
.sql
.query_get_value(
context,
"SELECT c.addr
FROM chats_contacts cc
LEFT JOIN contacts c ON c.id=cc.contact_id
WHERE cc.chat_id=?;",
params![self.id],
)
.unwrap_or_else(|| "Err".into());
}
if self.typ == Chattype::Group || self.typ == Chattype::VerifiedGroup {
if self.id.is_deaddrop() {
return context.stock_str(StockMessage::DeadDrop).into();
}
let cnt = get_chat_contact_cnt(context, self.id);
return context.stock_string_repl_int(StockMessage::Member, cnt as i32);
}
"Err".to_string()
}
pub fn get_profile_image(&self, context: &Context) -> Option<PathBuf> { pub fn get_profile_image(&self, context: &Context) -> Option<PathBuf> {
if let Some(image_rel) = self.param.get(Param::ProfileImage) { if let Some(image_rel) = self.param.get(Param::ProfileImage) {
if !image_rel.is_empty() { if !image_rel.is_empty() {
@@ -693,7 +661,6 @@ impl Chat {
is_sending_locations: self.is_sending_locations, is_sending_locations: self.is_sending_locations,
color: self.get_color(context), color: self.get_color(context),
profile_image: self.get_profile_image(context).unwrap_or_else(PathBuf::new), profile_image: self.get_profile_image(context).unwrap_or_else(PathBuf::new),
subtitle: self.get_subtitle(context),
draft, draft,
is_muted: self.is_muted(), is_muted: self.is_muted(),
}) })
@@ -1036,9 +1003,6 @@ pub struct ChatInfo {
/// currently. /// currently.
pub profile_image: PathBuf, pub profile_image: PathBuf,
/// Subtitle for the chat.
pub subtitle: String,
/// The draft message text. /// The draft message text.
/// ///
/// If the chat has not draft this is an empty string. /// If the chat has not draft this is an empty string.
@@ -2653,7 +2617,6 @@ mod tests {
"is_sending_locations": false, "is_sending_locations": false,
"color": 15895624, "color": 15895624,
"profile_image": "", "profile_image": "",
"subtitle": "bob@example.com",
"draft": "", "draft": "",
"is_muted": false "is_muted": false
} }

View File

@@ -314,8 +314,6 @@ const DC_STR_SELFNOTINGRP: usize = 21; // deprecated;
const DC_STR_NOMESSAGES: usize = 1; const DC_STR_NOMESSAGES: usize = 1;
const DC_STR_SELF: usize = 2; const DC_STR_SELF: usize = 2;
const DC_STR_DRAFT: usize = 3; const DC_STR_DRAFT: usize = 3;
const DC_STR_MEMBER: usize = 4;
const DC_STR_CONTACT: usize = 6;
const DC_STR_VOICEMESSAGE: usize = 7; const DC_STR_VOICEMESSAGE: usize = 7;
const DC_STR_DEADDROP: usize = 8; const DC_STR_DEADDROP: usize = 8;
const DC_STR_IMAGE: usize = 9; const DC_STR_IMAGE: usize = 9;
@@ -347,7 +345,6 @@ const DC_STR_ARCHIVEDCHATS: usize = 40;
const DC_STR_STARREDMSGS: usize = 41; const DC_STR_STARREDMSGS: usize = 41;
const DC_STR_AC_SETUP_MSG_SUBJECT: usize = 42; const DC_STR_AC_SETUP_MSG_SUBJECT: usize = 42;
const DC_STR_AC_SETUP_MSG_BODY: usize = 43; const DC_STR_AC_SETUP_MSG_BODY: usize = 43;
const DC_STR_SELFTALK_SUBTITLE: usize = 50;
const DC_STR_CANNOT_LOGIN: usize = 60; const DC_STR_CANNOT_LOGIN: usize = 60;
const DC_STR_SERVER_RESPONSE: usize = 61; const DC_STR_SERVER_RESPONSE: usize = 61;
const DC_STR_MSGACTIONBYUSER: usize = 62; const DC_STR_MSGACTIONBYUSER: usize = 62;

View File

@@ -1192,9 +1192,9 @@ fn create_or_lookup_adhoc_group(
return Ok((ChatId::new(0), Blocked::Not)); return Ok((ChatId::new(0), Blocked::Not));
} }
// use subject as initial chat name // use subject as initial chat name
let grpname = mime_parser.get_subject().unwrap_or_else(|| { let grpname = mime_parser
context.stock_string_repl_int(StockMessage::Member, member_ids.len() as i32) .get_subject()
}); .unwrap_or_else(|| "Unnamed group".to_string());
// create group record // create group record
let new_chat_id: ChatId = create_group_record( let new_chat_id: ChatId = create_group_record(

View File

@@ -35,12 +35,6 @@ pub enum StockMessage {
#[strum(props(fallback = "Draft"))] #[strum(props(fallback = "Draft"))]
Draft = 3, Draft = 3,
#[strum(props(fallback = "%1$s member(s)"))]
Member = 4,
#[strum(props(fallback = "%1$s contact(s)"))]
Contact = 6,
#[strum(props(fallback = "Voice message"))] #[strum(props(fallback = "Voice message"))]
VoiceMessage = 7, VoiceMessage = 7,
@@ -136,9 +130,6 @@ pub enum StockMessage {
))] ))]
AcSetupMsgBody = 43, AcSetupMsgBody = 43,
#[strum(props(fallback = "Messages I sent to myself"))]
SelfTalkSubTitle = 50,
#[strum(props(fallback = "Cannot login as %1$s."))] #[strum(props(fallback = "Cannot login as %1$s."))]
CannotLogin = 60, CannotLogin = 60,
@@ -430,8 +421,9 @@ mod tests {
let t = dummy_context(); let t = dummy_context();
// uses %1$s substitution // uses %1$s substitution
assert_eq!( assert_eq!(
t.ctx.stock_string_repl_str(StockMessage::Member, "42"), t.ctx
"42 member(s)" .stock_string_repl_str(StockMessage::MsgAddMember, "Foo"),
"Member Foo added."
); );
// We have no string using %1$d to test... // We have no string using %1$d to test...
} }
@@ -440,8 +432,8 @@ mod tests {
fn test_stock_string_repl_int() { fn test_stock_string_repl_int() {
let t = dummy_context(); let t = dummy_context();
assert_eq!( assert_eq!(
t.ctx.stock_string_repl_int(StockMessage::Member, 42), t.ctx.stock_string_repl_int(StockMessage::MsgAddMember, 42),
"42 member(s)" "Member 42 added."
); );
} }