Skip to content

Commit d1bc5f4

Browse files
committed
relay place_call_info and accept_call_info
1 parent 40c9678 commit d1bc5f4

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
@@ -1244,8 +1244,6 @@ uint32_t dc_init_webxdc_integration (dc_context_t* context, uint32_t c
12441244
* - callee ends the call using dc_end_call(), caller receives #DC_EVENT_CALL_ENDED
12451245
* - caller ends the call using dc_end_call(), callee receives #DC_EVENT_CALL_ENDED
12461246
*
1247-
* The call URL is avauilable at dc_msg_get_videochat_url().
1248-
*
12491247
* Note, that the events are for updating the call screen,
12501248
* possible status messages are added and updated as usual, including the known events.
12511249
* In the UI, the sorted chatlist is used as an overview about calls as well as messages.
@@ -1258,9 +1256,11 @@ uint32_t dc_init_webxdc_integration (dc_context_t* context, uint32_t c
12581256
* @param context The context object.
12591257
* @param chat_id The chat to place a call for.
12601258
* This needs to be a one-to-one chat.
1259+
* @param place_call_info any data that other devices receives
1260+
* in #DC_EVENT_INCOMING_CALL.
12611261
* @return ID of the system message announcing the call.
12621262
*/
1263-
uint32_t dc_place_outgoing_call (dc_context_t* context, uint32_t chat_id);
1263+
uint32_t dc_place_outgoing_call (dc_context_t* context, uint32_t chat_id, const char* place_call_info);
12641264

12651265

12661266
/**
@@ -1275,9 +1275,11 @@ uint32_t dc_place_outgoing_call (dc_context_t* context, uint32_t ch
12751275
* @param msg_id The ID of the call to accept.
12761276
* This is the ID reported by #DC_EVENT_INCOMING_CALL
12771277
* and equal to the ID of the corresponding info message.
1278+
* @param accept_call_info any data that other devices receives
1279+
* in #DC_EVENT_OUTGOING_CALL_ACCEPTED or #DC_EVENT_INCOMING_CALL_ACCEPTED.
12781280
* @return 1=success, 0=error
12791281
*/
1280-
int dc_accept_incoming_call (dc_context_t* context, uint32_t msg_id);
1282+
int dc_accept_incoming_call (dc_context_t* context, uint32_t msg_id, const char* accept_call_info);
12811283

12821284

12831285
/**
@@ -6673,7 +6675,7 @@ void dc_event_unref(dc_event_t* event);
66736675
* or #DC_EVENT_INCOMING_CALL_ACCEPTED
66746676
*
66756677
* @param data1 (int) msg_id ID of the info-message referring to the call.
6676-
* The call URL is avauilable at dc_msg_get_videochat_url().
6678+
* @param data2 (char*) place_call_info, text passed to dc_place_outgoing_call()
66776679
*/
66786680
#define DC_EVENT_INCOMING_CALL 2550
66796681

@@ -6685,6 +6687,7 @@ void dc_event_unref(dc_event_t* event);
66856687
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
66866688
*
66876689
* @param data1 (int) msg_id ID of the info-message referring to the call
6690+
* @param data2 (char*) accept_call_info, text passed to dc_place_outgoing_call()
66886691
*/
66896692
#define DC_EVENT_INCOMING_CALL_ACCEPTED 2560
66906693

@@ -6695,6 +6698,7 @@ void dc_event_unref(dc_event_t* event);
66956698
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
66966699
*
66976700
* @param data1 (int) msg_id ID of the info-message referring to the call
6701+
* @param data2 (char*) accept_call_info, text passed to dc_accept_incoming_call()
66986702
*/
66996703
#define DC_EVENT_OUTGOING_CALL_ACCEPTED 2570
67006704

deltachat-ffi/src/lib.rs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -790,11 +790,22 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut
790790
| EventType::AccountsChanged
791791
| EventType::AccountsItemChanged
792792
| EventType::WebxdcRealtimeAdvertisementReceived { .. }
793-
| EventType::IncomingCall { .. }
794-
| EventType::IncomingCallAccepted { .. }
795-
| EventType::OutgoingCallAccepted { .. }
796-
| EventType::CallEnded { .. }
797-
| EventType::EventChannelOverflow { .. } => ptr::null_mut(),
793+
| EventType::IncomingCall {
794+
place_call_info, ..
795+
} => {
796+
let data2 = place_call_info.to_c_string().unwrap_or_default();
797+
data2.into_raw()
798+
}
799+
EventType::IncomingCallAccepted {
800+
accept_call_info, ..
801+
}
802+
| EventType::OutgoingCallAccepted {
803+
accept_call_info, ..
804+
} => {
805+
let data2 = accept_call_info.to_c_string().unwrap_or_default();
806+
data2.into_raw()
807+
}
808+
EventType::CallEnded { .. } | EventType::EventChannelOverflow { .. } => ptr::null_mut(),
798809
EventType::ConfigureProgress { comment, .. } => {
799810
if let Some(comment) = comment {
800811
comment.to_c_string().unwrap_or_default().into_raw()
@@ -1194,15 +1205,20 @@ pub unsafe extern "C" fn dc_init_webxdc_integration(
11941205
}
11951206

11961207
#[no_mangle]
1197-
pub unsafe extern "C" fn dc_place_outgoing_call(context: *mut dc_context_t, chat_id: u32) -> u32 {
1208+
pub unsafe extern "C" fn dc_place_outgoing_call(
1209+
context: *mut dc_context_t,
1210+
chat_id: u32,
1211+
place_call_info: *const libc::c_char,
1212+
) -> u32 {
11981213
if context.is_null() || chat_id == 0 {
11991214
eprintln!("ignoring careless call to dc_place_outgoing_call()");
12001215
return 0;
12011216
}
12021217
let ctx = &*context;
12031218
let chat_id = ChatId::new(chat_id);
1219+
let place_call_info = to_string_lossy(place_call_info);
12041220

1205-
block_on(ctx.place_outgoing_call(chat_id))
1221+
block_on(ctx.place_outgoing_call(chat_id, place_call_info))
12061222
.map(|msg_id| msg_id.to_u32())
12071223
.unwrap_or_log_default(ctx, "Failed to place call")
12081224
}
@@ -1211,15 +1227,17 @@ pub unsafe extern "C" fn dc_place_outgoing_call(context: *mut dc_context_t, chat
12111227
pub unsafe extern "C" fn dc_accept_incoming_call(
12121228
context: *mut dc_context_t,
12131229
msg_id: u32,
1230+
accept_call_info: *const libc::c_char,
12141231
) -> libc::c_int {
12151232
if context.is_null() || msg_id == 0 {
12161233
eprintln!("ignoring careless call to dc_accept_incoming_call()");
12171234
return 0;
12181235
}
12191236
let ctx = &*context;
12201237
let msg_id = MsgId::new(msg_id);
1238+
let accept_call_info = to_string_lossy(accept_call_info);
12211239

1222-
block_on(ctx.accept_incoming_call(msg_id)).is_ok() as libc::c_int
1240+
block_on(ctx.accept_incoming_call(msg_id, accept_call_info)).is_ok() as libc::c_int
12231241
}
12241242

12251243
#[no_mangle]

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

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

421421
/// Incoming call.
422-
IncomingCall { msg_id: u32 },
422+
IncomingCall {
423+
msg_id: u32,
424+
place_call_info: String,
425+
},
423426

424427
/// Incoming call accepted.
425428
/// This is esp. interesting to stop ringing on other devices.
426-
IncomingCallAccepted { msg_id: u32 },
429+
IncomingCallAccepted {
430+
msg_id: u32,
431+
accept_call_info: String,
432+
},
427433

428434
/// Outgoing call accepted.
429-
OutgoingCallAccepted { msg_id: u32 },
435+
OutgoingCallAccepted {
436+
msg_id: u32,
437+
accept_call_info: String,
438+
},
430439

431440
/// Call ended.
432441
CallEnded { msg_id: u32 },
@@ -580,14 +589,26 @@ impl From<CoreEventType> for EventType {
580589
CoreEventType::EventChannelOverflow { n } => EventChannelOverflow { n },
581590
CoreEventType::AccountsChanged => AccountsChanged,
582591
CoreEventType::AccountsItemChanged => AccountsItemChanged,
583-
CoreEventType::IncomingCall { msg_id } => IncomingCall {
592+
CoreEventType::IncomingCall {
593+
msg_id,
594+
place_call_info,
595+
} => IncomingCall {
584596
msg_id: msg_id.to_u32(),
597+
place_call_info,
585598
},
586-
CoreEventType::IncomingCallAccepted { msg_id } => IncomingCallAccepted {
599+
CoreEventType::IncomingCallAccepted {
600+
msg_id,
601+
accept_call_info,
602+
} => IncomingCallAccepted {
587603
msg_id: msg_id.to_u32(),
604+
accept_call_info,
588605
},
589-
CoreEventType::OutgoingCallAccepted { msg_id } => OutgoingCallAccepted {
606+
CoreEventType::OutgoingCallAccepted {
607+
msg_id,
608+
accept_call_info,
609+
} => OutgoingCallAccepted {
590610
msg_id: msg_id.to_u32(),
611+
accept_call_info,
591612
},
592613
CoreEventType::CallEnded { msg_id } => CallEnded {
593614
msg_id: msg_id.to_u32(),

0 commit comments

Comments
 (0)