diff --git a/CHANGELOG.md b/CHANGELOG.md index a2e7b16d5c..784785f4c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1764,7 +1764,7 @@ This reverts commit 6f22ce2722b51773d7fbb0d89e4764f963cafd91.. ### Fixes - Reset quota on configured address change ([#5908](https://github.com/chatmail/core/pull/5908)). -- Do not emit progress 1000 when configuration is cancelled. +- Do not emit progress 1000 when configuration is canceled. - Assume file extensions are 32 chars max and don't contain whitespace ([#5338](https://github.com/chatmail/core/pull/5338)). - Re-add tokens.foreign_id column ([#6038](https://github.com/chatmail/core/pull/6038)). @@ -4212,7 +4212,7 @@ Bugfix release attempting to fix the [iOS build error](https://github.com/chatma - Recreate `smtp` table with AUTOINCREMENT `id` ([#4390](https://github.com/chatmail/core/pull/4390)). - Do not return an error from `send_msg_to_smtp` if retry limit is exceeded. - Make the bots automatically accept group chat contact requests ([#4377](https://github.com/chatmail/core/pull/4377)). -- Delete `smtp` rows when message sending is cancelled ([#4391](https://github.com/chatmail/core/pull/4391)). +- Delete `smtp` rows when message sending is canceled ([#4391](https://github.com/chatmail/core/pull/4391)). ### Refactor @@ -4223,7 +4223,7 @@ Bugfix release attempting to fix the [iOS build error](https://github.com/chatma ### Fixes - Fetch at most 100 existing messages even if EXISTS was not received. -- Delete `smtp` rows when message sending is cancelled. +- Delete `smtp` rows when message sending is canceled. ### Changes @@ -4310,14 +4310,14 @@ Bugfix release attempting to fix the [iOS build error](https://github.com/chatma ## [1.112.3] - 2023-03-30 ### Fixes -- `transfer::get_backup` now frees ongoing process when cancelled. #4249 +- `transfer::get_backup` now frees ongoing process when canceled. #4249 ## [1.112.2] - 2023-03-30 ### Changes - Update iroh, remove `default-net` from `[patch.crates-io]` section. - transfer backup: Connect to multiple provider addresses concurrently. This should speed up connection time significantly on the getter side. #4240 -- Make sure BackupProvider is cancelled on drop (or `dc_backup_provider_unref`). The BackupProvider will now always finish with an IMEX event of 1000 or 0, previously it would sometimes finished with 1000 (success) when it really was 0 (failure). #4242 +- Make sure BackupProvider is canceled on drop (or `dc_backup_provider_unref`). The BackupProvider will now always finish with an IMEX event of 1000 or 0, previously it would sometimes finished with 1000 (success) when it really was 0 (failure). #4242 ### Fixes - Do not return media from trashed messages in the "All media" view. #4247 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4385f06429..00b4b52005 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ If you want to contribute a code, follow this guide. The following prefix types are used: - `feat`: Features, e.g. "feat: Pause IO for BackupProvider". If you are unsure what's the category of your commit, you can often just use `feat`. - - `fix`: Bug fixes, e.g. "fix: delete `smtp` rows when message sending is cancelled" + - `fix`: Bug fixes, e.g. "fix: delete `smtp` rows when message sending is canceled" - `api`: API changes, e.g. "api(rust): add `get_msg_read_receipts(context, msg_id)`" - `refactor`: Refactorings, e.g. "refactor: iterate over `msg_ids` without `.iter()`" - `perf`: Performance improvements, e.g. "perf: improve SQLite performance with `PRAGMA synchronous=normal`" diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 1eddf6b663..a443c6ff93 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -1230,7 +1230,7 @@ uint32_t dc_init_webxdc_integration (dc_context_t* context, uint32_t c * * - callee declines using dc_end_call(): * caller receives #DC_EVENT_CALL_ENDED and has a "Declinced Call". - * callee's other devices receive #DC_EVENT_CALL_ENDED and have a "Cancelled Call", + * callee's other devices receive #DC_EVENT_CALL_ENDED and have a "Canceled Call", * * - callee is already in a call: * in this case, UI may decide to show a notification instead of ringing. @@ -1241,7 +1241,7 @@ uint32_t dc_init_webxdc_integration (dc_context_t* context, uint32_t c * caller and callee receive #DC_EVENT_CALL_ENDED * to prevent endless ringing of callee * in case caller got offline without being able to send cancellation message. - * for caller, this is a "Cancelled Call"; + * for caller, this is a "Canceled Call"; * for callee, this is a "Missed Call" * * Actions during the call: @@ -7820,6 +7820,21 @@ void dc_event_unref(dc_event_t* event); /// "❤️ Seems you're enjoying Delta Chat!"… (donation request device message) #define DC_STR_DONATION_REQUEST 193 +/// "Outgoing Call" +#define DC_STR_OUTGOING_CALL 194 + +/// "Incoming Call" +#define DC_STR_INCOMING_CALL 195 + +/// "Declined Call" +#define DC_STR_DECLINED_CALL 196 + +/// "Canceled Call" +#define DC_STR_CANCELED_CALL 197 + +/// "Missed Call" +#define DC_STR_MISSED_CALL 198 + /// "Contact". Deprecated, currently unused. #define DC_STR_CONTACT 200 diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index aa68b7a1a9..0773016fb7 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -1809,13 +1809,13 @@ impl CommandApi { /// Offers a backup for remote devices to retrieve. /// - /// Can be cancelled by stopping the ongoing process. Success or failure can be tracked + /// Can be canceled by stopping the ongoing process. Success or failure can be tracked /// via the `ImexProgress` event which should either reach `1000` for success or `0` for /// failure. /// /// This **stops IO** while it is running. /// - /// Returns once a remote device has retrieved the backup, or is cancelled. + /// Returns once a remote device has retrieved the backup, or is canceled. async fn provide_backup(&self, account_id: u32) -> Result<()> { let ctx = self.get_context(account_id).await?; @@ -1881,7 +1881,7 @@ impl CommandApi { /// This retrieves the backup from a remote device over the network and imports it into /// the current device. /// - /// Can be cancelled by stopping the ongoing process. + /// Can be canceled by stopping the ongoing process. /// /// Do not forget to call start_io on the account after a successful import, /// otherwise it will not connect to the email server. diff --git a/deltachat-jsonrpc/src/api/types/calls.rs b/deltachat-jsonrpc/src/api/types/calls.rs index 7122c03a64..0c555dc2ef 100644 --- a/deltachat-jsonrpc/src/api/types/calls.rs +++ b/deltachat-jsonrpc/src/api/types/calls.rs @@ -20,7 +20,7 @@ pub struct JsonrpcCallInfo { /// Call state. /// - /// For example, if the call is accepted, active, cancelled, declined etc. + /// For example, if the call is accepted, active, canceled, declined etc. pub state: JsonrpcCallState, } @@ -68,13 +68,13 @@ pub enum JsonrpcCallState { /// that was declined before the timeout. Declined, - /// Outgoing call that has been cancelled on our side + /// Outgoing call that has been canceled on our side /// before receiving a response. /// - /// Incoming calls cannot be cancelled, - /// on the receiver side cancelled calls + /// Incoming calls cannot be canceled, + /// on the receiver side canceled calls /// usually result in missed calls. - Cancelled, + Canceled, } impl JsonrpcCallState { @@ -87,7 +87,7 @@ impl JsonrpcCallState { CallState::Completed { duration } => JsonrpcCallState::Completed { duration }, CallState::Missed => JsonrpcCallState::Missed, CallState::Declined => JsonrpcCallState::Declined, - CallState::Cancelled => JsonrpcCallState::Cancelled, + CallState::Canceled => JsonrpcCallState::Canceled, }; Ok(jsonrpc_call_state) diff --git a/src/calls.rs b/src/calls.rs index 6d22b34723..95b2f7d7c2 100644 --- a/src/calls.rs +++ b/src/calls.rs @@ -46,9 +46,9 @@ const STUN_PORT: u16 = 3478; /// /// It is used to distinguish "ended" calls /// that are rejected by us from the calls -/// cancelled by the other side +/// canceled by the other side /// immediately after ringing started. -const CALL_CANCELLED_TIMESTAMP: Param = Param::Arg2; +const CALL_CANCELED_TIMESTAMP: Param = Param::Arg2; /// Information about the status of a call. #[derive(Debug, Default)] @@ -123,14 +123,14 @@ impl CallInfo { } /// Returns true if the call is missed - /// because the caller cancelled it + /// because the caller canceled it /// explicitly before ringing stopped. /// /// For outgoing calls this means /// the receiver has rejected the call /// explicitly. - pub fn is_cancelled(&self) -> bool { - self.msg.param.exists(CALL_CANCELLED_TIMESTAMP) + pub fn is_canceled(&self) -> bool { + self.msg.param.exists(CALL_CANCELED_TIMESTAMP) } async fn mark_as_ended(&mut self, context: &Context) -> Result<()> { @@ -139,17 +139,17 @@ impl CallInfo { Ok(()) } - /// Explicitly mark the call as cancelled. + /// Explicitly mark the call as canceled. /// /// For incoming calls this should be called /// when "call ended" message is received /// from the caller before we picked up the call. /// In this case the call becomes "missed" early /// before the ringing timeout. - async fn mark_as_cancelled(&mut self, context: &Context) -> Result<()> { + async fn mark_as_canceled(&mut self, context: &Context) -> Result<()> { let now = time(); self.msg.param.set_i64(CALL_ENDED_TIMESTAMP, now); - self.msg.param.set_i64(CALL_CANCELLED_TIMESTAMP, now); + self.msg.param.set_i64(CALL_CANCELED_TIMESTAMP, now); self.msg.update_param(context).await?; Ok(()) } @@ -255,8 +255,8 @@ impl Context { call.mark_as_ended(self).await?; call.update_text(self, "Declined call").await?; } else { - call.mark_as_cancelled(self).await?; - call.update_text(self, "Cancelled call").await?; + call.mark_as_canceled(self).await?; + call.update_text(self, "Canceled call").await?; } } else { call.mark_as_ended(self).await?; @@ -290,11 +290,11 @@ impl Context { let mut call = context.load_call_by_id(call_id).await?; if !call.is_accepted() && !call.is_ended() { if call.is_incoming() { - call.mark_as_cancelled(&context).await?; + call.mark_as_canceled(&context).await?; call.update_text(&context, "Missed call").await?; } else { call.mark_as_ended(&context).await?; - call.update_text(&context, "Cancelled call").await?; + call.update_text(&context, "Canceled call").await?; } context.emit_msgs_changed(call.msg.chat_id, call_id); context.emit_event(EventType::CallEnded { @@ -386,14 +386,14 @@ impl Context { call.mark_as_ended(self).await?; call.update_text(self, "Declined call").await?; } else { - call.mark_as_cancelled(self).await?; + call.mark_as_canceled(self).await?; call.update_text(self, "Missed call").await?; } } else { // outgoing if from_id == ContactId::SELF { - call.mark_as_cancelled(self).await?; - call.update_text(self, "Cancelled call").await?; + call.mark_as_canceled(self).await?; + call.update_text(self, "Canceled call").await?; } else { call.mark_as_ended(self).await?; call.update_text(self, "Declined call").await?; @@ -483,13 +483,13 @@ pub enum CallState { /// that was declined before the timeout. Declined, - /// Outgoing call that has been cancelled on our side + /// Outgoing call that has been canceled on our side /// before receiving a response. /// - /// Incoming calls cannot be cancelled, - /// on the receiver side cancelled calls + /// Incoming calls cannot be canceled, + /// on the receiver side canceled calls /// usually result in missed calls. - Cancelled, + Canceled, } /// Returns call state given the message ID. @@ -504,8 +504,8 @@ pub async fn call_state(context: &Context, msg_id: MsgId) -> Result { } else { CallState::Active } - } else if call.is_cancelled() { - // Call was explicitly cancelled + } else if call.is_canceled() { + // Call was explicitly canceled // by the caller before we picked it up. CallState::Missed } else if call.is_ended() { @@ -523,8 +523,8 @@ pub async fn call_state(context: &Context, msg_id: MsgId) -> Result { } else { CallState::Active } - } else if call.is_cancelled() { - CallState::Cancelled + } else if call.is_canceled() { + CallState::Canceled } else if call.is_ended() || call.is_stale() { CallState::Declined } else { diff --git a/src/calls/calls_tests.rs b/src/calls/calls_tests.rs index 24cb189d84..d32a2eaed6 100644 --- a/src/calls/calls_tests.rs +++ b/src/calls/calls_tests.rs @@ -368,7 +368,7 @@ async fn test_caller_cancels_call() -> Result<()> { // Alice changes their mind before Bob picks up alice.end_call(alice_call.id).await?; - assert_text(&alice, alice_call.id, "Cancelled call").await?; + assert_text(&alice, alice_call.id, "Canceled call").await?; alice .evtracker .get_matching(|evt| matches!(evt, EventType::CallEnded { .. })) @@ -376,18 +376,18 @@ async fn test_caller_cancels_call() -> Result<()> { let sent3 = alice.pop_sent_msg().await; assert_eq!( call_state(&alice, alice_call.id).await?, - CallState::Cancelled + CallState::Canceled ); alice2.recv_msg_trash(&sent3).await; - assert_text(&alice2, alice2_call.id, "Cancelled call").await?; + assert_text(&alice2, alice2_call.id, "Canceled call").await?; alice2 .evtracker .get_matching(|evt| matches!(evt, EventType::CallEnded { .. })) .await; assert_eq!( call_state(&alice2, alice2_call.id).await?, - CallState::Cancelled + CallState::Canceled ); // Bob receives the ending message @@ -398,6 +398,11 @@ async fn test_caller_cancels_call() -> Result<()> { .await; assert_eq!(call_state(&bob, bob_call.id).await?, CallState::Missed); + // Test that message summary says it is a missed call. + let bob_call_msg = Message::load_from_db(&bob, bob_call.id).await?; + let summary = bob_call_msg.get_summary(&bob, None).await?; + assert_eq!(summary.text, "📞 Missed Call"); + bob2.recv_msg_trash(&sent3).await; assert_text(&bob2, bob2_call.id, "Missed call").await?; bob2.evtracker diff --git a/src/configure.rs b/src/configure.rs index a4fcf4062b..31d81200b9 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -137,7 +137,7 @@ impl Context { let res = self .inner_configure(param) - .race(cancel_channel.recv().map(|_| Err(format_err!("Cancelled")))) + .race(cancel_channel.recv().map(|_| Err(format_err!("Canceled")))) .await; self.free_ongoing().await; diff --git a/src/imex/transfer.rs b/src/imex/transfer.rs index bbc4b1de05..16f2f6dc5f 100644 --- a/src/imex/transfer.rs +++ b/src/imex/transfer.rs @@ -242,7 +242,7 @@ impl BackupProvider { if let Err(err) = Self::handle_connection(context.clone(), conn, auth_token, dbfile).race( async { cancel_token.recv().await.ok(); - Err(format_err!("Backup transfer cancelled")) + Err(format_err!("Backup transfer canceled")) } ).race( async { @@ -262,12 +262,12 @@ impl BackupProvider { } }, _ = cancel_token.recv() => { - info!(context, "Backup transfer cancelled by the user, stopping accept loop."); + info!(context, "Backup transfer canceled by the user, stopping accept loop."); context.emit_event(EventType::ImexProgress(0)); break; } _ = drop_token.cancelled() => { - info!(context, "Backup transfer cancelled by dropping the provider, stopping accept loop."); + info!(context, "Backup transfer canceled by dropping the provider, stopping accept loop."); context.emit_event(EventType::ImexProgress(0)); break; } @@ -364,7 +364,7 @@ pub async fn get_backup(context: &Context, qr: Qr) -> Result<()> { let res = get_backup2(context, node_addr, auth_token) .race(async { cancel_token.recv().await.ok(); - Err(format_err!("Backup reception cancelled")) + Err(format_err!("Backup reception canceled")) }) .await; if let Err(ref res) = res { diff --git a/src/stock_str.rs b/src/stock_str.rs index 3a95caeaf8..0ff247332c 100644 --- a/src/stock_str.rs +++ b/src/stock_str.rs @@ -424,6 +424,21 @@ Help keeping us to keep Delta Chat independent and make it more awesome in the f https://delta.chat/donate"))] DonationRequest = 193, + + #[strum(props(fallback = "Outgoing Call"))] + OutgoingCall = 194, + + #[strum(props(fallback = "Incoming Call"))] + IncomingCall = 195, + + #[strum(props(fallback = "Declined Call"))] + DeclinedCall = 196, + + #[strum(props(fallback = "Canceled Call"))] + CanceledCall = 197, + + #[strum(props(fallback = "Missed Call"))] + MissedCall = 198, } impl StockMessage { @@ -801,6 +816,31 @@ pub(crate) async fn donation_request(context: &Context) -> String { translated(context, StockMessage::DonationRequest).await } +/// Stock string: `Outgoing Call`. +pub(crate) async fn outgoing_call(context: &Context) -> String { + translated(context, StockMessage::OutgoingCall).await +} + +/// Stock string: `Incoming Call`. +pub(crate) async fn incoming_call(context: &Context) -> String { + translated(context, StockMessage::IncomingCall).await +} + +/// Stock string: `Declined Call`. +pub(crate) async fn declined_call(context: &Context) -> String { + translated(context, StockMessage::DeclinedCall).await +} + +/// Stock string: `Canceled Call`. +pub(crate) async fn canceled_call(context: &Context) -> String { + translated(context, StockMessage::CanceledCall).await +} + +/// Stock string: `Missed Call`. +pub(crate) async fn missed_call(context: &Context) -> String { + translated(context, StockMessage::MissedCall).await +} + /// Stock string: `Scan to chat with %1$s`. pub(crate) async fn setup_contact_qr_description( context: &Context, diff --git a/src/summary.rs b/src/summary.rs index 7392b395ed..b7ae5cb4c0 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -4,6 +4,7 @@ use std::borrow::Cow; use std::fmt; use std::str; +use crate::calls::{CallState, call_state}; use crate::chat::Chat; use crate::constants::Chattype; use crate::contact::{Contact, ContactId}; @@ -234,11 +235,21 @@ impl Message { append_text = true; } Viewtype::Call => { + let call_state = call_state(context, self.id) + .await + .unwrap_or(CallState::Alerting); emoji = Some("📞"); - type_name = Some(if self.from_id == ContactId::SELF { - "Outgoing call".to_string() - } else { - "Incoming call".to_string() + type_name = Some(match call_state { + CallState::Alerting | CallState::Active | CallState::Completed { .. } => { + if self.from_id == ContactId::SELF { + stock_str::outgoing_call(context).await + } else { + stock_str::incoming_call(context).await + } + } + CallState::Missed => stock_str::missed_call(context).await, + CallState::Declined => stock_str::declined_call(context).await, + CallState::Canceled => stock_str::canceled_call(context).await, }); type_file = None; append_text = false