Skip to content

Commit bf02785

Browse files
committed
feat: add IncomingCallAccepted.from_this_device
1 parent 01b2aa0 commit bf02785

6 files changed

Lines changed: 34 additions & 4 deletions

File tree

deltachat-ffi/deltachat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6755,6 +6755,7 @@ void dc_event_unref(dc_event_t* event);
67556755
* UI usually only takes action in case call UI was opened before, otherwise the event should be ignored.
67566756
*
67576757
* @param data1 (int) msg_id ID of the message referring to the call
6758+
* @param data2 (int) 1 if the call was accepted from this device (process).
67586759
*/
67596760
#define DC_EVENT_INCOMING_CALL_ACCEPTED 2560
67606761

deltachat-ffi/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,6 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc:
680680
| EventType::ChatModified(_)
681681
| EventType::ChatDeleted { .. }
682682
| EventType::WebxdcRealtimeAdvertisementReceived { .. }
683-
| EventType::IncomingCallAccepted { .. }
684683
| EventType::OutgoingCallAccepted { .. }
685684
| EventType::CallEnded { .. }
686685
| EventType::EventChannelOverflow { .. }
@@ -703,6 +702,9 @@ pub unsafe extern "C" fn dc_event_get_data2_int(event: *mut dc_event_t) -> libc:
703702
} => status_update_serial.to_u32() as libc::c_int,
704703
EventType::WebxdcRealtimeData { data, .. } => data.len() as libc::c_int,
705704
EventType::IncomingCall { has_video, .. } => *has_video as libc::c_int,
705+
EventType::IncomingCallAccepted {
706+
from_this_device, ..
707+
} => *from_this_device as libc::c_int,
706708

707709
#[allow(unreachable_patterns)]
708710
#[cfg(test)]

deltachat-jsonrpc/src/api/types/events.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ pub enum EventType {
441441
msg_id: u32,
442442
/// ID of the chat which the message belongs to.
443443
chat_id: u32,
444+
/// The call was accepted from this device (process).
445+
from_this_device: bool,
444446
},
445447

446448
/// Outgoing call accepted.
@@ -634,9 +636,14 @@ impl From<CoreEventType> for EventType {
634636
place_call_info,
635637
has_video,
636638
},
637-
CoreEventType::IncomingCallAccepted { msg_id, chat_id } => IncomingCallAccepted {
639+
CoreEventType::IncomingCallAccepted {
640+
msg_id,
641+
chat_id,
642+
from_this_device,
643+
} => IncomingCallAccepted {
638644
msg_id: msg_id.to_u32(),
639645
chat_id: chat_id.to_u32(),
646+
from_this_device,
640647
},
641648
CoreEventType::OutgoingCallAccepted {
642649
msg_id,

src/calls.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ impl Context {
266266
self.emit_event(EventType::IncomingCallAccepted {
267267
msg_id: call.msg.id,
268268
chat_id: call.msg.chat_id,
269+
from_this_device: true,
269270
});
270271
self.emit_msgs_changed(call.msg.chat_id, call_id);
271272
Ok(())
@@ -432,6 +433,7 @@ impl Context {
432433
self.emit_event(EventType::IncomingCallAccepted {
433434
msg_id: call.msg.id,
434435
chat_id: call.msg.chat_id,
436+
from_this_device: false,
435437
});
436438
} else {
437439
let accept_call_info = mime_message

src/calls/calls_tests.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,15 @@ async fn accept_call() -> Result<CallSetup> {
129129
);
130130
assert_text(&bob, bob_call.id, "Incoming video call").await?;
131131
bob.evtracker
132-
.get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. }))
132+
.get_matching(|evt| {
133+
matches!(
134+
evt,
135+
EventType::IncomingCallAccepted {
136+
from_this_device: true,
137+
..
138+
}
139+
)
140+
})
133141
.await;
134142
let sent2 = bob.pop_sent_msg().await;
135143
let info = bob
@@ -143,7 +151,15 @@ async fn accept_call() -> Result<CallSetup> {
143151
bob2.recv_msg_trash(&sent2).await;
144152
assert_text(&bob, bob_call.id, "Incoming video call").await?;
145153
bob2.evtracker
146-
.get_matching(|evt| matches!(evt, EventType::IncomingCallAccepted { .. }))
154+
.get_matching(|evt| {
155+
matches!(
156+
evt,
157+
EventType::IncomingCallAccepted {
158+
from_this_device: false,
159+
..
160+
}
161+
)
162+
})
147163
.await;
148164
let info = bob2
149165
.load_call_by_id(bob2_call.id)

src/events/payload.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ pub enum EventType {
397397
msg_id: MsgId,
398398
/// ID of the chat which the message belongs to.
399399
chat_id: ChatId,
400+
/// The call was accepted from this device (process).
401+
from_this_device: bool,
400402
},
401403

402404
/// Outgoing call accepted.

0 commit comments

Comments
 (0)