mirror of
https://github.com/chatmail/core.git
synced 2026-04-24 17:06:28 +03:00
feat: use different strings for audio and video calls
This commit is contained in:
@@ -7544,12 +7544,6 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
/// "❤️ Seems you're enjoying Delta Chat!"… (donation request device message)
|
/// "❤️ Seems you're enjoying Delta Chat!"… (donation request device message)
|
||||||
#define DC_STR_DONATION_REQUEST 193
|
#define DC_STR_DONATION_REQUEST 193
|
||||||
|
|
||||||
/// "Outgoing call"
|
|
||||||
#define DC_STR_OUTGOING_CALL 194
|
|
||||||
|
|
||||||
/// "Incoming call"
|
|
||||||
#define DC_STR_INCOMING_CALL 195
|
|
||||||
|
|
||||||
/// "Declined call"
|
/// "Declined call"
|
||||||
#define DC_STR_DECLINED_CALL 196
|
#define DC_STR_DECLINED_CALL 196
|
||||||
|
|
||||||
@@ -7601,6 +7595,18 @@ void dc_event_unref(dc_event_t* event);
|
|||||||
/// Used as the first info messages in newly created classic email threads.
|
/// Used as the first info messages in newly created classic email threads.
|
||||||
#define DC_STR_CHAT_UNENCRYPTED_EXPLANATON 230
|
#define DC_STR_CHAT_UNENCRYPTED_EXPLANATON 230
|
||||||
|
|
||||||
|
/// "Outgoing audio call"
|
||||||
|
#define DC_STR_OUTGOING_AUDIO_CALL 232
|
||||||
|
|
||||||
|
/// "Outgoing video call"
|
||||||
|
#define DC_STR_OUTGOING_VIDEO_CALL 233
|
||||||
|
|
||||||
|
/// "Incoming audio call"
|
||||||
|
#define DC_STR_INCOMING_AUDIO_CALL 234
|
||||||
|
|
||||||
|
/// "Incoming video call"
|
||||||
|
#define DC_STR_INCOMING_VIDEO_CALL 235
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|||||||
16
src/calls.rs
16
src/calls.rs
@@ -103,10 +103,14 @@ impl CallInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if self.is_incoming() {
|
if self.is_incoming() {
|
||||||
self.update_text(context, &format!("Incoming call\n{duration}"))
|
let incoming_call_str =
|
||||||
|
stock_str::incoming_call(context, self.has_video_initially()).await;
|
||||||
|
self.update_text(context, &format!("{incoming_call_str}\n{duration}"))
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
self.update_text(context, &format!("Outgoing call\n{duration}"))
|
let outgoing_call_str =
|
||||||
|
stock_str::outgoing_call(context, self.has_video_initially()).await;
|
||||||
|
self.update_text(context, &format!("{outgoing_call_str}\n{duration}"))
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -201,7 +205,7 @@ impl Context {
|
|||||||
);
|
);
|
||||||
ensure!(!chat.is_self_talk(), "Cannot call self");
|
ensure!(!chat.is_self_talk(), "Cannot call self");
|
||||||
|
|
||||||
let outgoing_call_str = stock_str::outgoing_call(self).await;
|
let outgoing_call_str = stock_str::outgoing_call(self, has_video_initially).await;
|
||||||
let mut call = Message {
|
let mut call = Message {
|
||||||
viewtype: Viewtype::Call,
|
viewtype: Viewtype::Call,
|
||||||
text: outgoing_call_str,
|
text: outgoing_call_str,
|
||||||
@@ -358,7 +362,8 @@ impl Context {
|
|||||||
call.update_text(self, &missed_call_str).await?;
|
call.update_text(self, &missed_call_str).await?;
|
||||||
self.emit_incoming_msg(call.msg.chat_id, call_id); // notify missed call
|
self.emit_incoming_msg(call.msg.chat_id, call_id); // notify missed call
|
||||||
} else {
|
} else {
|
||||||
let incoming_call_str = stock_str::incoming_call(self).await;
|
let incoming_call_str =
|
||||||
|
stock_str::incoming_call(self, call.has_video_initially()).await;
|
||||||
call.update_text(self, &incoming_call_str).await?;
|
call.update_text(self, &incoming_call_str).await?;
|
||||||
self.emit_msgs_changed(call.msg.chat_id, call_id); // ringing calls are not additionally notified
|
self.emit_msgs_changed(call.msg.chat_id, call_id); // ringing calls are not additionally notified
|
||||||
let can_call_me = match who_can_call_me(self).await? {
|
let can_call_me = match who_can_call_me(self).await? {
|
||||||
@@ -399,7 +404,8 @@ impl Context {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let outgoing_call_str = stock_str::outgoing_call(self).await;
|
let outgoing_call_str =
|
||||||
|
stock_str::outgoing_call(self, call.has_video_initially()).await;
|
||||||
call.update_text(self, &outgoing_call_str).await?;
|
call.update_text(self, &outgoing_call_str).await?;
|
||||||
self.emit_msgs_changed(call.msg.chat_id, call_id);
|
self.emit_msgs_changed(call.msg.chat_id, call_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ async fn setup_call() -> Result<CallSetup> {
|
|||||||
assert!(!info.is_accepted());
|
assert!(!info.is_accepted());
|
||||||
assert_eq!(info.place_call_info, PLACE_INFO);
|
assert_eq!(info.place_call_info, PLACE_INFO);
|
||||||
assert_eq!(info.has_video_initially(), true);
|
assert_eq!(info.has_video_initially(), true);
|
||||||
assert_text(t, m.id, "Outgoing call").await?;
|
assert_text(t, m.id, "Outgoing video call").await?;
|
||||||
assert_eq!(call_state(t, m.id).await?, CallState::Alerting);
|
assert_eq!(call_state(t, m.id).await?, CallState::Alerting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ async fn setup_call() -> Result<CallSetup> {
|
|||||||
assert!(!info.is_accepted());
|
assert!(!info.is_accepted());
|
||||||
assert_eq!(info.place_call_info, PLACE_INFO);
|
assert_eq!(info.place_call_info, PLACE_INFO);
|
||||||
assert_eq!(info.has_video_initially(), true);
|
assert_eq!(info.has_video_initially(), true);
|
||||||
assert_text(t, m.id, "Incoming call").await?;
|
assert_text(t, m.id, "Incoming video call").await?;
|
||||||
assert_eq!(call_state(t, m.id).await?, CallState::Alerting);
|
assert_eq!(call_state(t, m.id).await?, CallState::Alerting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ async fn accept_call() -> Result<CallSetup> {
|
|||||||
// Bob accepts the incoming call
|
// Bob accepts the incoming call
|
||||||
bob.accept_incoming_call(bob_call.id, ACCEPT_INFO.to_string())
|
bob.accept_incoming_call(bob_call.id, ACCEPT_INFO.to_string())
|
||||||
.await?;
|
.await?;
|
||||||
assert_text(&bob, bob_call.id, "Incoming call").await?;
|
assert_text(&bob, bob_call.id, "Incoming video call").await?;
|
||||||
bob.evtracker
|
bob.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. }))
|
.get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. }))
|
||||||
.await;
|
.await;
|
||||||
@@ -129,7 +129,7 @@ async fn accept_call() -> Result<CallSetup> {
|
|||||||
assert_eq!(call_state(&bob, bob_call.id).await?, CallState::Active);
|
assert_eq!(call_state(&bob, bob_call.id).await?, CallState::Active);
|
||||||
|
|
||||||
bob2.recv_msg_trash(&sent2).await;
|
bob2.recv_msg_trash(&sent2).await;
|
||||||
assert_text(&bob, bob_call.id, "Incoming call").await?;
|
assert_text(&bob, bob_call.id, "Incoming video call").await?;
|
||||||
bob2.evtracker
|
bob2.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. }))
|
.get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. }))
|
||||||
.await;
|
.await;
|
||||||
@@ -142,7 +142,7 @@ async fn accept_call() -> Result<CallSetup> {
|
|||||||
|
|
||||||
// Alice receives the acceptance message
|
// Alice receives the acceptance message
|
||||||
alice.recv_msg_trash(&sent2).await;
|
alice.recv_msg_trash(&sent2).await;
|
||||||
assert_text(&alice, alice_call.id, "Outgoing call").await?;
|
assert_text(&alice, alice_call.id, "Outgoing video call").await?;
|
||||||
let ev = alice
|
let ev = alice
|
||||||
.evtracker
|
.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::OutgoingCallAccepted { .. }))
|
.get_matching(|evt| matches!(evt, EventType::OutgoingCallAccepted { .. }))
|
||||||
@@ -164,7 +164,7 @@ async fn accept_call() -> Result<CallSetup> {
|
|||||||
assert_eq!(call_state(&alice, alice_call.id).await?, CallState::Active);
|
assert_eq!(call_state(&alice, alice_call.id).await?, CallState::Active);
|
||||||
|
|
||||||
alice2.recv_msg_trash(&sent2).await;
|
alice2.recv_msg_trash(&sent2).await;
|
||||||
assert_text(&alice2, alice2_call.id, "Outgoing call").await?;
|
assert_text(&alice2, alice2_call.id, "Outgoing video call").await?;
|
||||||
alice2
|
alice2
|
||||||
.evtracker
|
.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::OutgoingCallAccepted { .. }))
|
.get_matching(|evt| matches!(evt, EventType::OutgoingCallAccepted { .. }))
|
||||||
@@ -203,7 +203,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
|
|||||||
|
|
||||||
// Bob has accepted the call and also ends it
|
// Bob has accepted the call and also ends it
|
||||||
bob.end_call(bob_call.id).await?;
|
bob.end_call(bob_call.id).await?;
|
||||||
assert_text(&bob, bob_call.id, "Incoming call\n<1 minute").await?;
|
assert_text(&bob, bob_call.id, "Incoming video call\n<1 minute").await?;
|
||||||
bob.evtracker
|
bob.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||||
.await;
|
.await;
|
||||||
@@ -214,7 +214,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
|
|||||||
));
|
));
|
||||||
|
|
||||||
bob2.recv_msg_trash(&sent3).await;
|
bob2.recv_msg_trash(&sent3).await;
|
||||||
assert_text(&bob2, bob2_call.id, "Incoming call\n<1 minute").await?;
|
assert_text(&bob2, bob2_call.id, "Incoming video call\n<1 minute").await?;
|
||||||
bob2.evtracker
|
bob2.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||||
.await;
|
.await;
|
||||||
@@ -225,7 +225,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
|
|||||||
|
|
||||||
// Alice receives the ending message
|
// Alice receives the ending message
|
||||||
alice.recv_msg_trash(&sent3).await;
|
alice.recv_msg_trash(&sent3).await;
|
||||||
assert_text(&alice, alice_call.id, "Outgoing call\n<1 minute").await?;
|
assert_text(&alice, alice_call.id, "Outgoing video call\n<1 minute").await?;
|
||||||
alice
|
alice
|
||||||
.evtracker
|
.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||||
@@ -236,7 +236,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
|
|||||||
));
|
));
|
||||||
|
|
||||||
alice2.recv_msg_trash(&sent3).await;
|
alice2.recv_msg_trash(&sent3).await;
|
||||||
assert_text(&alice2, alice2_call.id, "Outgoing call\n<1 minute").await?;
|
assert_text(&alice2, alice2_call.id, "Outgoing video call\n<1 minute").await?;
|
||||||
alice2
|
alice2
|
||||||
.evtracker
|
.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||||
@@ -266,7 +266,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
|
|||||||
|
|
||||||
// Bob has accepted the call but Alice ends it
|
// Bob has accepted the call but Alice ends it
|
||||||
alice.end_call(alice_call.id).await?;
|
alice.end_call(alice_call.id).await?;
|
||||||
assert_text(&alice, alice_call.id, "Outgoing call\n<1 minute").await?;
|
assert_text(&alice, alice_call.id, "Outgoing video call\n<1 minute").await?;
|
||||||
alice
|
alice
|
||||||
.evtracker
|
.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||||
@@ -278,7 +278,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
|
|||||||
));
|
));
|
||||||
|
|
||||||
alice2.recv_msg_trash(&sent3).await;
|
alice2.recv_msg_trash(&sent3).await;
|
||||||
assert_text(&alice2, alice2_call.id, "Outgoing call\n<1 minute").await?;
|
assert_text(&alice2, alice2_call.id, "Outgoing video call\n<1 minute").await?;
|
||||||
alice2
|
alice2
|
||||||
.evtracker
|
.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||||
@@ -290,7 +290,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
|
|||||||
|
|
||||||
// Bob receives the ending message
|
// Bob receives the ending message
|
||||||
bob.recv_msg_trash(&sent3).await;
|
bob.recv_msg_trash(&sent3).await;
|
||||||
assert_text(&bob, bob_call.id, "Incoming call\n<1 minute").await?;
|
assert_text(&bob, bob_call.id, "Incoming video call\n<1 minute").await?;
|
||||||
bob.evtracker
|
bob.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||||
.await;
|
.await;
|
||||||
@@ -300,7 +300,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
|
|||||||
));
|
));
|
||||||
|
|
||||||
bob2.recv_msg_trash(&sent3).await;
|
bob2.recv_msg_trash(&sent3).await;
|
||||||
assert_text(&bob2, bob2_call.id, "Incoming call\n<1 minute").await?;
|
assert_text(&bob2, bob2_call.id, "Incoming video call\n<1 minute").await?;
|
||||||
bob2.evtracker
|
bob2.evtracker
|
||||||
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
|
||||||
.await;
|
.await;
|
||||||
@@ -420,7 +420,7 @@ async fn test_caller_cancels_call() -> Result<()> {
|
|||||||
// Test that message summary says it is a missed call.
|
// Test that message summary says it is a missed call.
|
||||||
let bob_call_msg = Message::load_from_db(&bob, bob_call.id).await?;
|
let bob_call_msg = Message::load_from_db(&bob, bob_call.id).await?;
|
||||||
let summary = bob_call_msg.get_summary(&bob, None).await?;
|
let summary = bob_call_msg.get_summary(&bob, None).await?;
|
||||||
assert_eq!(summary.text, "📞 Missed call");
|
assert_eq!(summary.text, "🎥 Missed call");
|
||||||
|
|
||||||
bob2.recv_msg_trash(&sent3).await;
|
bob2.recv_msg_trash(&sent3).await;
|
||||||
assert_text(&bob2, bob2_call.id, "Missed call").await?;
|
assert_text(&bob2, bob2_call.id, "Missed call").await?;
|
||||||
|
|||||||
@@ -369,12 +369,6 @@ Help keeping us to keep Delta Chat independent and make it more awesome in the f
|
|||||||
https://delta.chat/donate"))]
|
https://delta.chat/donate"))]
|
||||||
DonationRequest = 193,
|
DonationRequest = 193,
|
||||||
|
|
||||||
#[strum(props(fallback = "Outgoing call"))]
|
|
||||||
OutgoingCall = 194,
|
|
||||||
|
|
||||||
#[strum(props(fallback = "Incoming call"))]
|
|
||||||
IncomingCall = 195,
|
|
||||||
|
|
||||||
#[strum(props(fallback = "Declined call"))]
|
#[strum(props(fallback = "Declined call"))]
|
||||||
DeclinedCall = 196,
|
DeclinedCall = 196,
|
||||||
|
|
||||||
@@ -417,6 +411,18 @@ https://delta.chat/donate"))]
|
|||||||
fallback = "You are using the legacy option \"Settings → Advanced → Move automatically to DeltaChat Folder\".\n\nThis option will be removed in a few weeks and you should disable it already today.\n\nIf having chat messages mixed into your inbox is a problem, see https://delta.chat/legacy-move"
|
fallback = "You are using the legacy option \"Settings → Advanced → Move automatically to DeltaChat Folder\".\n\nThis option will be removed in a few weeks and you should disable it already today.\n\nIf having chat messages mixed into your inbox is a problem, see https://delta.chat/legacy-move"
|
||||||
))]
|
))]
|
||||||
MvboxMoveDeprecation = 231,
|
MvboxMoveDeprecation = 231,
|
||||||
|
|
||||||
|
#[strum(props(fallback = "Outgoing audio call"))]
|
||||||
|
OutgoingAudioCall = 232,
|
||||||
|
|
||||||
|
#[strum(props(fallback = "Outgoing video call"))]
|
||||||
|
OutgoingVideoCall = 233,
|
||||||
|
|
||||||
|
#[strum(props(fallback = "Incoming audio call"))]
|
||||||
|
IncomingAudioCall = 234,
|
||||||
|
|
||||||
|
#[strum(props(fallback = "Incoming video call"))]
|
||||||
|
IncomingVideoCall = 235,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StockMessage {
|
impl StockMessage {
|
||||||
@@ -762,14 +768,30 @@ pub(crate) async fn donation_request(context: &Context) -> String {
|
|||||||
translated(context, StockMessage::DonationRequest).await
|
translated(context, StockMessage::DonationRequest).await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stock string: `Outgoing call`.
|
/// Stock string: `Outgoing video call` or `Outgoing audio call`.
|
||||||
pub(crate) async fn outgoing_call(context: &Context) -> String {
|
pub(crate) async fn outgoing_call(context: &Context, has_video: bool) -> String {
|
||||||
translated(context, StockMessage::OutgoingCall).await
|
translated(
|
||||||
|
context,
|
||||||
|
if has_video {
|
||||||
|
StockMessage::OutgoingVideoCall
|
||||||
|
} else {
|
||||||
|
StockMessage::OutgoingAudioCall
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stock string: `Incoming call`.
|
/// Stock string: `Incoming video call` or `Incoming audio call`.
|
||||||
pub(crate) async fn incoming_call(context: &Context) -> String {
|
pub(crate) async fn incoming_call(context: &Context, has_video: bool) -> String {
|
||||||
translated(context, StockMessage::IncomingCall).await
|
translated(
|
||||||
|
context,
|
||||||
|
if has_video {
|
||||||
|
StockMessage::IncomingVideoCall
|
||||||
|
} else {
|
||||||
|
StockMessage::IncomingAudioCall
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stock string: `Declined call`.
|
/// Stock string: `Declined call`.
|
||||||
|
|||||||
@@ -247,16 +247,18 @@ impl Message {
|
|||||||
append_text = true;
|
append_text = true;
|
||||||
}
|
}
|
||||||
Viewtype::Call => {
|
Viewtype::Call => {
|
||||||
|
let call_info = context.load_call_by_id(self.id).await.unwrap_or(None);
|
||||||
|
let has_video = call_info.is_some_and(|c| c.has_video_initially());
|
||||||
let call_state = call_state(context, self.id)
|
let call_state = call_state(context, self.id)
|
||||||
.await
|
.await
|
||||||
.unwrap_or(CallState::Alerting);
|
.unwrap_or(CallState::Alerting);
|
||||||
emoji = Some("📞");
|
emoji = Some(if has_video { "🎥" } else { "📞" });
|
||||||
type_name = Some(match call_state {
|
type_name = Some(match call_state {
|
||||||
CallState::Alerting | CallState::Active | CallState::Completed { .. } => {
|
CallState::Alerting | CallState::Active | CallState::Completed { .. } => {
|
||||||
if self.from_id == ContactId::SELF {
|
if self.from_id == ContactId::SELF {
|
||||||
stock_str::outgoing_call(context).await
|
stock_str::outgoing_call(context, has_video).await
|
||||||
} else {
|
} else {
|
||||||
stock_str::incoming_call(context).await
|
stock_str::incoming_call(context, has_video).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CallState::Missed => stock_str::missed_call(context).await,
|
CallState::Missed => stock_str::missed_call(context).await,
|
||||||
|
|||||||
Reference in New Issue
Block a user