From bf02785a3607b95ff19b185bab69adae1cd7b180 Mon Sep 17 00:00:00 2001 From: WofWca Date: Tue, 10 Mar 2026 22:27:46 +0400 Subject: [PATCH] feat: add `IncomingCallAccepted.from_this_device` --- deltachat-ffi/deltachat.h | 1 + deltachat-ffi/src/lib.rs | 4 +++- deltachat-jsonrpc/src/api/types/events.rs | 9 ++++++++- src/calls.rs | 2 ++ src/calls/calls_tests.rs | 20 ++++++++++++++++++-- src/events/payload.rs | 2 ++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 5e1d9d28e..abc3f0ef0 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -6755,6 +6755,7 @@ void dc_event_unref(dc_event_t* event); * UI usually only takes action in case call UI was opened before, otherwise the event should be ignored. * * @param data1 (int) msg_id ID of the message referring to the call + * @param data2 (int) 1 if the call was accepted from this device (process). */ #define DC_EVENT_INCOMING_CALL_ACCEPTED 2560 diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 20be73db1..c0b128dae 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -680,7 +680,6 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc: | EventType::ChatModified(_) | EventType::ChatDeleted { .. } | EventType::WebxdcRealtimeAdvertisementReceived { .. } - | EventType::IncomingCallAccepted { .. } | EventType::OutgoingCallAccepted { .. } | EventType::CallEnded { .. } | EventType::EventChannelOverflow { .. } @@ -703,6 +702,9 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc: } => status_update_serial.to_u32() as libc::c_int, EventType::WebxdcRealtimeData { data, .. } => data.len() as libc::c_int, EventType::IncomingCall { has_video, .. } => *has_video as libc::c_int, + EventType::IncomingCallAccepted { + from_this_device, .. + } => *from_this_device as libc::c_int, #[allow(unreachable_patterns)] #[cfg(test)] diff --git a/deltachat-jsonrpc/src/api/types/events.rs b/deltachat-jsonrpc/src/api/types/events.rs index 73862631b..85751c363 100644 --- a/deltachat-jsonrpc/src/api/types/events.rs +++ b/deltachat-jsonrpc/src/api/types/events.rs @@ -441,6 +441,8 @@ pub enum EventType { msg_id: u32, /// ID of the chat which the message belongs to. chat_id: u32, + /// The call was accepted from this device (process). + from_this_device: bool, }, /// Outgoing call accepted. @@ -634,9 +636,14 @@ impl From for EventType { place_call_info, has_video, }, - CoreEventType::IncomingCallAccepted { msg_id, chat_id } => IncomingCallAccepted { + CoreEventType::IncomingCallAccepted { + msg_id, + chat_id, + from_this_device, + } => IncomingCallAccepted { msg_id: msg_id.to_u32(), chat_id: chat_id.to_u32(), + from_this_device, }, CoreEventType::OutgoingCallAccepted { msg_id, diff --git a/src/calls.rs b/src/calls.rs index 213b6036d..f6a04d714 100644 --- a/src/calls.rs +++ b/src/calls.rs @@ -266,6 +266,7 @@ impl Context { self.emit_event(EventType::IncomingCallAccepted { msg_id: call.msg.id, chat_id: call.msg.chat_id, + from_this_device: true, }); self.emit_msgs_changed(call.msg.chat_id, call_id); Ok(()) @@ -432,6 +433,7 @@ impl Context { self.emit_event(EventType::IncomingCallAccepted { msg_id: call.msg.id, chat_id: call.msg.chat_id, + from_this_device: false, }); } else { let accept_call_info = mime_message diff --git a/src/calls/calls_tests.rs b/src/calls/calls_tests.rs index b4d3d6e52..946cd6aeb 100644 --- a/src/calls/calls_tests.rs +++ b/src/calls/calls_tests.rs @@ -129,7 +129,15 @@ async fn accept_call() -> Result { ); assert_text(&bob, bob_call.id, "Incoming video call").await?; bob.evtracker - .get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. })) + .get_matching(|evt| { + matches!( + evt, + EventType::IncomingCallAccepted { + from_this_device: true, + .. + } + ) + }) .await; let sent2 = bob.pop_sent_msg().await; let info = bob @@ -143,7 +151,15 @@ async fn accept_call() -> Result { bob2.recv_msg_trash(&sent2).await; assert_text(&bob, bob_call.id, "Incoming video call").await?; bob2.evtracker - .get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. })) + .get_matching(|evt| { + matches!( + evt, + EventType::IncomingCallAccepted { + from_this_device: false, + .. + } + ) + }) .await; let info = bob2 .load_call_by_id(bob2_call.id) diff --git a/src/events/payload.rs b/src/events/payload.rs index 82bf70517..0b3552603 100644 --- a/src/events/payload.rs +++ b/src/events/payload.rs @@ -397,6 +397,8 @@ pub enum EventType { msg_id: MsgId, /// ID of the chat which the message belongs to. chat_id: ChatId, + /// The call was accepted from this device (process). + from_this_device: bool, }, /// Outgoing call accepted.