diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 598aa4ed6a..aaaac883f4 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 20be73db15..c0b128daeb 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 73862631bd..85751c363c 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 f75b9116cc..9f32331784 100644 --- a/src/calls.rs +++ b/src/calls.rs @@ -265,6 +265,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(()) @@ -430,6 +431,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 4328bcc4a3..cac88f40bb 100644 --- a/src/calls/calls_tests.rs +++ b/src/calls/calls_tests.rs @@ -117,7 +117,15 @@ async fn accept_call() -> Result { .await?; 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 @@ -131,7 +139,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 82bf70517c..0b35526032 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.