Skip to content

Commit 65d6cfc

Browse files
committed
relay place_call_info and accept_call_info
1 parent c1016d4 commit 65d6cfc

File tree

10 files changed

+176
-61
lines changed

10 files changed

+176
-61
lines changed

deltachat-ffi/deltachat.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,6 @@ uint32_t dc_init_webxdc_integration (dc_context_t* context, uint32_t c
12371237
* - callee ends the call using dc_end_call(), caller receives #DC_EVENT_CALL_ENDED
12381238
* - caller ends the call using dc_end_call(), callee receives #DC_EVENT_CALL_ENDED
12391239
*
1240-
* The call URL is avauilable at dc_msg_get_videochat_url().
1241-
*
12421240
* Note, that the events are for updating the call screen,
12431241
* possible status messages are added and updated as usual, including the known events.
12441242
* In the UI, the sorted chatlist is used as an overview about calls as well as messages.
@@ -1251,9 +1249,11 @@ uint32_t dc_init_webxdc_integration (dc_context_t* context, uint32_t c
12511249
* @param context The context object.
12521250
* @param chat_id The chat to place a call for.
12531251
* This needs to be a one-to-one chat.
1252+
* @param place_call_info any data that other devices receives
1253+
* in #DC_EVENT_INCOMING_CALL.
12541254
* @return ID of the system message announcing the call.
12551255
*/
1256-
uint32_t dc_place_outgoing_call (dc_context_t* context, uint32_t chat_id);
1256+
uint32_t dc_place_outgoing_call (dc_context_t* context, uint32_t chat_id, const char* place_call_info);
12571257

12581258

12591259
/**
@@ -1268,9 +1268,11 @@ uint32_t dc_place_outgoing_call (dc_context_t* context, uint32_t ch
12681268
* @param msg_id The ID of the call to accept.
12691269
* This is the ID reported by #DC_EVENT_INCOMING_CALL
12701270
* and equal to the ID of the corresponding info message.
1271+
* @param accept_call_info any data that other devices receives
1272+
* in #DC_EVENT_OUTGOING_CALL_ACCEPTED or #DC_EVENT_INCOMING_CALL_ACCEPTED.
12711273
* @return 1=success, 0=error
12721274
*/
1273-
int dc_accept_incoming_call (dc_context_t* context, uint32_t msg_id);
1275+
int dc_accept_incoming_call (dc_context_t* context, uint32_t msg_id, const char* accept_call_info);
12741276

12751277

12761278
/**
@@ -6739,7 +6741,7 @@ void dc_event_unref(dc_event_t* event);
67396741
* or #DC_EVENT_INCOMING_CALL_ACCEPTED
67406742
*
67416743
* @param data1 (int) msg_id ID of the info-message referring to the call.
6742-
* The call URL is avauilable at dc_msg_get_videochat_url().
6744+
* @param data2 (char*) place_call_info, text passed to dc_place_outgoing_call()
67436745
*/
67446746
#define DC_EVENT_INCOMING_CALL 2550
67456747

@@ -6751,6 +6753,7 @@ void dc_event_unref(dc_event_t* event);
67516753
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
67526754
*
67536755
* @param data1 (int) msg_id ID of the info-message referring to the call
6756+
* @param data2 (char*) accept_call_info, text passed to dc_place_outgoing_call()
67546757
*/
67556758
#define DC_EVENT_INCOMING_CALL_ACCEPTED 2560
67566759

@@ -6761,6 +6764,7 @@ void dc_event_unref(dc_event_t* event);
67616764
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
67626765
*
67636766
* @param data1 (int) msg_id ID of the info-message referring to the call
6767+
* @param data2 (char*) accept_call_info, text passed to dc_accept_incoming_call()
67646768
*/
67656769
#define DC_EVENT_OUTGOING_CALL_ACCEPTED 2570
67666770

deltachat-ffi/src/lib.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -780,11 +780,22 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut
780780
| EventType::AccountsChanged
781781
| EventType::AccountsItemChanged
782782
| EventType::WebxdcRealtimeAdvertisementReceived { .. }
783-
| EventType::IncomingCall { .. }
784-
| EventType::IncomingCallAccepted { .. }
785-
| EventType::OutgoingCallAccepted { .. }
786-
| EventType::CallEnded { .. }
787-
| EventType::EventChannelOverflow { .. } => ptr::null_mut(),
783+
| EventType::IncomingCall {
784+
place_call_info, ..
785+
} => {
786+
let data2 = place_call_info.to_c_string().unwrap_or_default();
787+
data2.into_raw()
788+
}
789+
EventType::IncomingCallAccepted {
790+
accept_call_info, ..
791+
}
792+
| EventType::OutgoingCallAccepted {
793+
accept_call_info, ..
794+
} => {
795+
let data2 = accept_call_info.to_c_string().unwrap_or_default();
796+
data2.into_raw()
797+
}
798+
EventType::CallEnded { .. } | EventType::EventChannelOverflow { .. } => ptr::null_mut(),
788799
EventType::ConfigureProgress { comment, .. } => {
789800
if let Some(comment) = comment {
790801
comment.to_c_string().unwrap_or_default().into_raw()
@@ -1184,15 +1195,20 @@ pub unsafe extern "C" fn dc_init_webxdc_integration(
11841195
}
11851196

11861197
#[no_mangle]
1187-
pub unsafe extern "C" fn dc_place_outgoing_call(context: *mut dc_context_t, chat_id: u32) -> u32 {
1198+
pub unsafe extern "C" fn dc_place_outgoing_call(
1199+
context: *mut dc_context_t,
1200+
chat_id: u32,
1201+
place_call_info: *const libc::c_char,
1202+
) -> u32 {
11881203
if context.is_null() || chat_id == 0 {
11891204
eprintln!("ignoring careless call to dc_place_outgoing_call()");
11901205
return 0;
11911206
}
11921207
let ctx = &*context;
11931208
let chat_id = ChatId::new(chat_id);
1209+
let place_call_info = to_string_lossy(place_call_info);
11941210

1195-
block_on(ctx.place_outgoing_call(chat_id))
1211+
block_on(ctx.place_outgoing_call(chat_id, place_call_info))
11961212
.map(|msg_id| msg_id.to_u32())
11971213
.unwrap_or_log_default(ctx, "Failed to place call")
11981214
}
@@ -1201,15 +1217,17 @@ pub unsafe extern "C" fn dc_place_outgoing_call(context: *mut dc_context_t, chat
12011217
pub unsafe extern "C" fn dc_accept_incoming_call(
12021218
context: *mut dc_context_t,
12031219
msg_id: u32,
1220+
accept_call_info: *const libc::c_char,
12041221
) -> libc::c_int {
12051222
if context.is_null() || msg_id == 0 {
12061223
eprintln!("ignoring careless call to dc_accept_incoming_call()");
12071224
return 0;
12081225
}
12091226
let ctx = &*context;
12101227
let msg_id = MsgId::new(msg_id);
1228+
let accept_call_info = to_string_lossy(accept_call_info);
12111229

1212-
block_on(ctx.accept_incoming_call(msg_id)).is_ok() as libc::c_int
1230+
block_on(ctx.accept_incoming_call(msg_id, accept_call_info)).is_ok() as libc::c_int
12131231
}
12141232

12151233
#[no_mangle]

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

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,23 @@ pub enum EventType {
418418
},
419419

420420
/// Incoming call.
421-
IncomingCall { msg_id: u32 },
421+
IncomingCall {
422+
msg_id: u32,
423+
place_call_info: String,
424+
},
422425

423426
/// Incoming call accepted.
424427
/// This is esp. interesting to stop ringing on other devices.
425-
IncomingCallAccepted { msg_id: u32 },
428+
IncomingCallAccepted {
429+
msg_id: u32,
430+
accept_call_info: String,
431+
},
426432

427433
/// Outgoing call accepted.
428-
OutgoingCallAccepted { msg_id: u32 },
434+
OutgoingCallAccepted {
435+
msg_id: u32,
436+
accept_call_info: String,
437+
},
429438

430439
/// Call ended.
431440
CallEnded { msg_id: u32 },
@@ -579,14 +588,26 @@ impl From<CoreEventType> for EventType {
579588
CoreEventType::EventChannelOverflow { n } => EventChannelOverflow { n },
580589
CoreEventType::AccountsChanged => AccountsChanged,
581590
CoreEventType::AccountsItemChanged => AccountsItemChanged,
582-
CoreEventType::IncomingCall { msg_id } => IncomingCall {
591+
CoreEventType::IncomingCall {
592+
msg_id,
593+
place_call_info,
594+
} => IncomingCall {
583595
msg_id: msg_id.to_u32(),
596+
place_call_info,
584597
},
585-
CoreEventType::IncomingCallAccepted { msg_id } => IncomingCallAccepted {
598+
CoreEventType::IncomingCallAccepted {
599+
msg_id,
600+
accept_call_info,
601+
} => IncomingCallAccepted {
586602
msg_id: msg_id.to_u32(),
603+
accept_call_info,
587604
},
588-
CoreEventType::OutgoingCallAccepted { msg_id } => OutgoingCallAccepted {
605+
CoreEventType::OutgoingCallAccepted {
606+
msg_id,
607+
accept_call_info,
608+
} => OutgoingCallAccepted {
589609
msg_id: msg_id.to_u32(),
610+
accept_call_info,
590611
},
591612
CoreEventType::CallEnded { msg_id } => CallEnded {
592613
msg_id: msg_id.to_u32(),

0 commit comments

Comments
 (0)