Skip to content

Commit 66edc88

Browse files
committed
feat: use different strings for audio and video calls
1 parent 76d8b71 commit 66edc88

File tree

5 files changed

+79
-43
lines changed

5 files changed

+79
-43
lines changed

deltachat-ffi/deltachat.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7544,12 +7544,6 @@ void dc_event_unref(dc_event_t* event);
75447544
/// "❤️ Seems you're enjoying Delta Chat!"… (donation request device message)
75457545
#define DC_STR_DONATION_REQUEST 193
75467546

7547-
/// "Outgoing call"
7548-
#define DC_STR_OUTGOING_CALL 194
7549-
7550-
/// "Incoming call"
7551-
#define DC_STR_INCOMING_CALL 195
7552-
75537547
/// "Declined call"
75547548
#define DC_STR_DECLINED_CALL 196
75557549

@@ -7601,6 +7595,18 @@ void dc_event_unref(dc_event_t* event);
76017595
/// Used as the first info messages in newly created classic email threads.
76027596
#define DC_STR_CHAT_UNENCRYPTED_EXPLANATON 230
76037597

7598+
/// "Outgoing audio call"
7599+
#define DC_STR_OUTGOING_AUDIO_CALL 232
7600+
7601+
/// "Outgoing video call"
7602+
#define DC_STR_OUTGOING_VIDEO_CALL 233
7603+
7604+
/// "Incoming audio call"
7605+
#define DC_STR_INCOMING_AUDIO_CALL 234
7606+
7607+
/// "Incoming video call"
7608+
#define DC_STR_INCOMING_VIDEO_CALL 235
7609+
76047610
/**
76057611
* @}
76067612
*/

src/calls.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,14 @@ impl CallInfo {
103103
};
104104

105105
if self.is_incoming() {
106-
self.update_text(context, &format!("Incoming call\n{duration}"))
106+
let incoming_call_str =
107+
stock_str::incoming_call(context, self.has_video_initially()).await;
108+
self.update_text(context, &format!("{incoming_call_str}\n{duration}"))
107109
.await?;
108110
} else {
109-
self.update_text(context, &format!("Outgoing call\n{duration}"))
111+
let outgoing_call_str =
112+
stock_str::outgoing_call(context, self.has_video_initially()).await;
113+
self.update_text(context, &format!("{outgoing_call_str}\n{duration}"))
110114
.await?;
111115
}
112116
Ok(())
@@ -201,7 +205,7 @@ impl Context {
201205
);
202206
ensure!(!chat.is_self_talk(), "Cannot call self");
203207

204-
let outgoing_call_str = stock_str::outgoing_call(self).await;
208+
let outgoing_call_str = stock_str::outgoing_call(self, has_video_initially).await;
205209
let mut call = Message {
206210
viewtype: Viewtype::Call,
207211
text: outgoing_call_str,
@@ -358,7 +362,8 @@ impl Context {
358362
call.update_text(self, &missed_call_str).await?;
359363
self.emit_incoming_msg(call.msg.chat_id, call_id); // notify missed call
360364
} else {
361-
let incoming_call_str = stock_str::incoming_call(self).await;
365+
let incoming_call_str =
366+
stock_str::incoming_call(self, call.has_video_initially()).await;
362367
call.update_text(self, &incoming_call_str).await?;
363368
self.emit_msgs_changed(call.msg.chat_id, call_id); // ringing calls are not additionally notified
364369
let can_call_me = match who_can_call_me(self).await? {
@@ -399,7 +404,8 @@ impl Context {
399404
));
400405
}
401406
} else {
402-
let outgoing_call_str = stock_str::outgoing_call(self).await;
407+
let outgoing_call_str =
408+
stock_str::outgoing_call(self, call.has_video_initially()).await;
403409
call.update_text(self, &outgoing_call_str).await?;
404410
self.emit_msgs_changed(call.msg.chat_id, call_id);
405411
}

src/calls/calls_tests.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async fn setup_call() -> Result<CallSetup> {
6262
assert!(!info.is_accepted());
6363
assert_eq!(info.place_call_info, PLACE_INFO);
6464
assert_eq!(info.has_video_initially(), true);
65-
assert_text(t, m.id, "Outgoing call").await?;
65+
assert_text(t, m.id, "Outgoing video call").await?;
6666
assert_eq!(call_state(t, m.id).await?, CallState::Alerting);
6767
}
6868

@@ -84,7 +84,7 @@ async fn setup_call() -> Result<CallSetup> {
8484
assert!(!info.is_accepted());
8585
assert_eq!(info.place_call_info, PLACE_INFO);
8686
assert_eq!(info.has_video_initially(), true);
87-
assert_text(t, m.id, "Incoming call").await?;
87+
assert_text(t, m.id, "Incoming video call").await?;
8888
assert_eq!(call_state(t, m.id).await?, CallState::Alerting);
8989
}
9090

@@ -115,7 +115,7 @@ async fn accept_call() -> Result<CallSetup> {
115115
// Bob accepts the incoming call
116116
bob.accept_incoming_call(bob_call.id, ACCEPT_INFO.to_string())
117117
.await?;
118-
assert_text(&bob, bob_call.id, "Incoming call").await?;
118+
assert_text(&bob, bob_call.id, "Incoming video call").await?;
119119
bob.evtracker
120120
.get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. }))
121121
.await;
@@ -129,7 +129,7 @@ async fn accept_call() -> Result<CallSetup> {
129129
assert_eq!(call_state(&bob, bob_call.id).await?, CallState::Active);
130130

131131
bob2.recv_msg_trash(&sent2).await;
132-
assert_text(&bob, bob_call.id, "Incoming call").await?;
132+
assert_text(&bob, bob_call.id, "Incoming video call").await?;
133133
bob2.evtracker
134134
.get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. }))
135135
.await;
@@ -142,7 +142,7 @@ async fn accept_call() -> Result<CallSetup> {
142142

143143
// Alice receives the acceptance message
144144
alice.recv_msg_trash(&sent2).await;
145-
assert_text(&alice, alice_call.id, "Outgoing call").await?;
145+
assert_text(&alice, alice_call.id, "Outgoing video call").await?;
146146
let ev = alice
147147
.evtracker
148148
.get_matching(|evt| matches!(evt, EventType::OutgoingCallAccepted { .. }))
@@ -164,7 +164,7 @@ async fn accept_call() -> Result<CallSetup> {
164164
assert_eq!(call_state(&alice, alice_call.id).await?, CallState::Active);
165165

166166
alice2.recv_msg_trash(&sent2).await;
167-
assert_text(&alice2, alice2_call.id, "Outgoing call").await?;
167+
assert_text(&alice2, alice2_call.id, "Outgoing video call").await?;
168168
alice2
169169
.evtracker
170170
.get_matching(|evt| matches!(evt, EventType::OutgoingCallAccepted { .. }))
@@ -203,7 +203,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
203203

204204
// Bob has accepted the call and also ends it
205205
bob.end_call(bob_call.id).await?;
206-
assert_text(&bob, bob_call.id, "Incoming call\n<1 minute").await?;
206+
assert_text(&bob, bob_call.id, "Incoming video call\n<1 minute").await?;
207207
bob.evtracker
208208
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
209209
.await;
@@ -214,7 +214,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
214214
));
215215

216216
bob2.recv_msg_trash(&sent3).await;
217-
assert_text(&bob2, bob2_call.id, "Incoming call\n<1 minute").await?;
217+
assert_text(&bob2, bob2_call.id, "Incoming video call\n<1 minute").await?;
218218
bob2.evtracker
219219
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
220220
.await;
@@ -225,7 +225,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
225225

226226
// Alice receives the ending message
227227
alice.recv_msg_trash(&sent3).await;
228-
assert_text(&alice, alice_call.id, "Outgoing call\n<1 minute").await?;
228+
assert_text(&alice, alice_call.id, "Outgoing video call\n<1 minute").await?;
229229
alice
230230
.evtracker
231231
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
@@ -236,7 +236,7 @@ async fn test_accept_call_callee_ends() -> Result<()> {
236236
));
237237

238238
alice2.recv_msg_trash(&sent3).await;
239-
assert_text(&alice2, alice2_call.id, "Outgoing call\n<1 minute").await?;
239+
assert_text(&alice2, alice2_call.id, "Outgoing video call\n<1 minute").await?;
240240
alice2
241241
.evtracker
242242
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
@@ -266,7 +266,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
266266

267267
// Bob has accepted the call but Alice ends it
268268
alice.end_call(alice_call.id).await?;
269-
assert_text(&alice, alice_call.id, "Outgoing call\n<1 minute").await?;
269+
assert_text(&alice, alice_call.id, "Outgoing video call\n<1 minute").await?;
270270
alice
271271
.evtracker
272272
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
@@ -278,7 +278,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
278278
));
279279

280280
alice2.recv_msg_trash(&sent3).await;
281-
assert_text(&alice2, alice2_call.id, "Outgoing call\n<1 minute").await?;
281+
assert_text(&alice2, alice2_call.id, "Outgoing video call\n<1 minute").await?;
282282
alice2
283283
.evtracker
284284
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
@@ -290,7 +290,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
290290

291291
// Bob receives the ending message
292292
bob.recv_msg_trash(&sent3).await;
293-
assert_text(&bob, bob_call.id, "Incoming call\n<1 minute").await?;
293+
assert_text(&bob, bob_call.id, "Incoming video call\n<1 minute").await?;
294294
bob.evtracker
295295
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
296296
.await;
@@ -300,7 +300,7 @@ async fn test_accept_call_caller_ends() -> Result<()> {
300300
));
301301

302302
bob2.recv_msg_trash(&sent3).await;
303-
assert_text(&bob2, bob2_call.id, "Incoming call\n<1 minute").await?;
303+
assert_text(&bob2, bob2_call.id, "Incoming video call\n<1 minute").await?;
304304
bob2.evtracker
305305
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
306306
.await;
@@ -420,7 +420,7 @@ async fn test_caller_cancels_call() -> Result<()> {
420420
// Test that message summary says it is a missed call.
421421
let bob_call_msg = Message::load_from_db(&bob, bob_call.id).await?;
422422
let summary = bob_call_msg.get_summary(&bob, None).await?;
423-
assert_eq!(summary.text, "📞 Missed call");
423+
assert_eq!(summary.text, "🎥 Missed call");
424424

425425
bob2.recv_msg_trash(&sent3).await;
426426
assert_text(&bob2, bob2_call.id, "Missed call").await?;

src/stock_str.rs

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,6 @@ Help keeping us to keep Delta Chat independent and make it more awesome in the f
369369
https://delta.chat/donate"))]
370370
DonationRequest = 193,
371371

372-
#[strum(props(fallback = "Outgoing call"))]
373-
OutgoingCall = 194,
374-
375-
#[strum(props(fallback = "Incoming call"))]
376-
IncomingCall = 195,
377-
378372
#[strum(props(fallback = "Declined call"))]
379373
DeclinedCall = 196,
380374

@@ -417,6 +411,18 @@ https://delta.chat/donate"))]
417411
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"
418412
))]
419413
MvboxMoveDeprecation = 231,
414+
415+
#[strum(props(fallback = "Outgoing audio call"))]
416+
OutgoingAudioCall = 232,
417+
418+
#[strum(props(fallback = "Outgoing video call"))]
419+
OutgoingVideoCall = 233,
420+
421+
#[strum(props(fallback = "Incoming audio call"))]
422+
IncomingAudioCall = 234,
423+
424+
#[strum(props(fallback = "Incoming video call"))]
425+
IncomingVideoCall = 235,
420426
}
421427

422428
impl StockMessage {
@@ -762,14 +768,30 @@ pub(crate) async fn donation_request(context: &Context) -> String {
762768
translated(context, StockMessage::DonationRequest).await
763769
}
764770

765-
/// Stock string: `Outgoing call`.
766-
pub(crate) async fn outgoing_call(context: &Context) -> String {
767-
translated(context, StockMessage::OutgoingCall).await
768-
}
769-
770-
/// Stock string: `Incoming call`.
771-
pub(crate) async fn incoming_call(context: &Context) -> String {
772-
translated(context, StockMessage::IncomingCall).await
771+
/// Stock string: `Outgoing video call` or `Outgoing audio call`.
772+
pub(crate) async fn outgoing_call(context: &Context, has_video: bool) -> String {
773+
translated(
774+
context,
775+
if has_video {
776+
StockMessage::OutgoingVideoCall
777+
} else {
778+
StockMessage::OutgoingAudioCall
779+
},
780+
)
781+
.await
782+
}
783+
784+
/// Stock string: `Incoming video call` or `Incoming audio call`.
785+
pub(crate) async fn incoming_call(context: &Context, has_video: bool) -> String {
786+
translated(
787+
context,
788+
if has_video {
789+
StockMessage::IncomingVideoCall
790+
} else {
791+
StockMessage::IncomingAudioCall
792+
},
793+
)
794+
.await
773795
}
774796

775797
/// Stock string: `Declined call`.

src/summary.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,18 @@ impl Message {
247247
append_text = true;
248248
}
249249
Viewtype::Call => {
250+
let call_info = context.load_call_by_id(self.id).await.unwrap_or(None);
251+
let has_video = call_info.is_some_and(|c| c.has_video_initially());
250252
let call_state = call_state(context, self.id)
251253
.await
252254
.unwrap_or(CallState::Alerting);
253-
emoji = Some("📞");
255+
emoji = Some(if has_video { "🎥" } else { "📞" });
254256
type_name = Some(match call_state {
255257
CallState::Alerting | CallState::Active | CallState::Completed { .. } => {
256258
if self.from_id == ContactId::SELF {
257-
stock_str::outgoing_call(context).await
259+
stock_str::outgoing_call(context, has_video).await
258260
} else {
259-
stock_str::incoming_call(context).await
261+
stock_str::incoming_call(context, has_video).await
260262
}
261263
}
262264
CallState::Missed => stock_str::missed_call(context).await,

0 commit comments

Comments
 (0)