From be08bcb22b904735ed10ddd85c78c2afc4cae527 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 4 Nov 2019 12:36:41 +0100 Subject: [PATCH] rename DC_CONTACT_ID_DEVICE to DC_CONTACT_ID_INFO to be in-line with dc_msg_is_info() --- deltachat-ffi/deltachat.h | 2 +- python/src/deltachat/const.py | 2 +- src/chat.rs | 8 ++++---- src/constants.rs | 2 +- src/location.rs | 4 ++-- src/message.rs | 6 +++--- src/qr.rs | 2 +- src/securejoin.rs | 6 +++--- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 56ceefad0..47b511cde 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -3370,7 +3370,7 @@ void dc_msg_latefiling_mediasize (dc_msg_t* msg, int width, int hei #define DC_CONTACT_ID_SELF 1 -#define DC_CONTACT_ID_DEVICE 2 +#define DC_CONTACT_ID_INFO 2 #define DC_CONTACT_ID_LAST_SPECIAL 9 diff --git a/python/src/deltachat/const.py b/python/src/deltachat/const.py index ecfd5a86b..e3e2bfc7e 100644 --- a/python/src/deltachat/const.py +++ b/python/src/deltachat/const.py @@ -47,7 +47,7 @@ DC_STATE_OUT_FAILED = 24 DC_STATE_OUT_DELIVERED = 26 DC_STATE_OUT_MDN_RCVD = 28 DC_CONTACT_ID_SELF = 1 -DC_CONTACT_ID_DEVICE = 2 +DC_CONTACT_ID_INFO = 2 DC_CONTACT_ID_LAST_SPECIAL = 9 DC_MSG_TEXT = 10 DC_MSG_IMAGE = 20 diff --git a/src/chat.rs b/src/chat.rs index 977b7249c..b1c6f777b 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -994,7 +994,7 @@ pub fn get_chat_msgs( " LEFT JOIN contacts", " ON m.from_id=contacts.id", " WHERE m.from_id!=1", // 1=DC_CONTACT_ID_SELF - " AND m.from_id!=2", // 2=DC_CONTACT_ID_DEVICE + " AND m.from_id!=2", // 2=DC_CONTACT_ID_INFO " AND m.hidden=0", " AND chats.blocked=2", " AND contacts.blocked=0", @@ -1898,15 +1898,15 @@ pub fn get_chat_id_by_grpid(context: &Context, grpid: impl AsRef) -> (u32, .unwrap_or((0, false, Blocked::Not)) } -pub fn add_device_msg(context: &Context, chat_id: u32, text: impl AsRef) { +pub fn add_info_msg(context: &Context, chat_id: u32, text: impl AsRef) { let rfc724_mid = dc_create_outgoing_rfc724_mid(None, "@device"); if context.sql.execute( "INSERT INTO msgs (chat_id,from_id,to_id, timestamp,type,state, txt,rfc724_mid) VALUES (?,?,?, ?,?,?, ?,?);", params![ chat_id as i32, - DC_CONTACT_ID_DEVICE, - DC_CONTACT_ID_DEVICE, + DC_CONTACT_ID_INFO, + DC_CONTACT_ID_INFO, dc_create_smeared_timestamp(context), Viewtype::Text, MessageState::InNoticed, diff --git a/src/constants.rs b/src/constants.rs index f6d752ff3..23ce20c1b 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -130,7 +130,7 @@ const DC_MAX_GET_INFO_LEN: usize = 100000; pub const DC_CONTACT_ID_UNDEFINED: u32 = 0; pub const DC_CONTACT_ID_SELF: u32 = 1; -pub const DC_CONTACT_ID_DEVICE: u32 = 2; +pub const DC_CONTACT_ID_INFO: u32 = 2; pub const DC_CONTACT_ID_LAST_SPECIAL: u32 = 9; pub const DC_CREATE_MVBOX: usize = 1; diff --git a/src/location.rs b/src/location.rs index 7b658f92d..38f969a33 100644 --- a/src/location.rs +++ b/src/location.rs @@ -219,7 +219,7 @@ pub fn send_locations_to_chat(context: &Context, chat_id: u32, seconds: i64) { } else if 0 == seconds && is_sending_locations_before { let stock_str = context.stock_system_msg(StockMessage::MsgLocationDisabled, "", "", 0); - chat::add_device_msg(context, chat_id, stock_str); + chat::add_info_msg(context, chat_id, stock_str); } context.call_cb(Event::ChatModified(chat_id)); if 0 != seconds { @@ -651,7 +651,7 @@ pub fn job_do_DC_JOB_MAYBE_SEND_LOC_ENDED(context: &Context, job: &mut Job) { params![chat_id as i32], ).is_ok() { let stock_str = context.stock_system_msg(StockMessage::MsgLocationDisabled, "", "", 0); - chat::add_device_msg(context, chat_id, stock_str); + chat::add_info_msg(context, chat_id, stock_str); context.call_cb(Event::ChatModified(chat_id)); } } diff --git a/src/message.rs b/src/message.rs index b2988d910..bf4cdfecd 100644 --- a/src/message.rs +++ b/src/message.rs @@ -476,8 +476,8 @@ impl Message { pub fn is_info(&self) -> bool { let cmd = self.param.get_cmd(); - self.from_id == DC_CONTACT_ID_DEVICE as libc::c_uint - || self.to_id == DC_CONTACT_ID_DEVICE as libc::c_uint + self.from_id == DC_CONTACT_ID_INFO as libc::c_uint + || self.to_id == DC_CONTACT_ID_INFO as libc::c_uint || cmd != SystemMessage::Unknown && cmd != SystemMessage::AutocryptSetupMessage } @@ -714,7 +714,7 @@ pub fn get_msg_info(context: &Context, msg_id: MsgId) -> String { ret += "\n"; } - if msg.from_id == DC_CONTACT_ID_DEVICE || msg.to_id == DC_CONTACT_ID_DEVICE { + if msg.from_id == DC_CONTACT_ID_INFO || msg.to_id == DC_CONTACT_ID_INFO { // device-internal message, no further details needed return ret; } diff --git a/src/qr.rs b/src/qr.rs index e53c71bf4..72f2b2d65 100644 --- a/src/qr.rs +++ b/src/qr.rs @@ -150,7 +150,7 @@ fn decode_openpgp(context: &Context, qr: &str) -> Lot { let (id, _) = chat::create_or_lookup_by_contact_id(context, lot.id, Blocked::Deaddrop) .unwrap_or_default(); - chat::add_device_msg( + chat::add_info_msg( context, id, format!("{} verified.", peerstate.addr.unwrap_or_default()), diff --git a/src/securejoin.rs b/src/securejoin.rs index f8f8dc74d..783f6f3d1 100644 --- a/src/securejoin.rs +++ b/src/securejoin.rs @@ -638,7 +638,7 @@ fn secure_connection_established(context: &Context, contact_chat_id: u32) { "?" }; let msg = context.stock_string_repl_str(StockMessage::ContactVerified, addr); - chat::add_device_msg(context, contact_chat_id, msg); + chat::add_info_msg(context, contact_chat_id, msg); emit_event!(context, Event::ChatModified(contact_chat_id)); } @@ -654,7 +654,7 @@ fn could_not_establish_secure_connection(context: &Context, contact_chat_id: u32 }, ); - chat::add_device_msg(context, contact_chat_id, &msg); + chat::add_info_msg(context, contact_chat_id, &msg); error!(context, "{} ({})", &msg, details); } @@ -735,7 +735,7 @@ pub fn handle_degrade_event(context: &Context, peerstate: &Peerstate) -> Result< }; let msg = context.stock_string_repl_str(StockMessage::ContactSetupChanged, peeraddr); - chat::add_device_msg(context, contact_chat_id, msg); + chat::add_info_msg(context, contact_chat_id, msg); emit_event!(context, Event::ChatModified(contact_chat_id)); } }