Skip to content

Commit 2f0eb8a

Browse files
committed
relay place_call_info and accept_call_info
1 parent 1ccbbbd commit 2f0eb8a

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
/**
@@ -6729,7 +6731,7 @@ void dc_event_unref(dc_event_t* event);
67296731
* or #DC_EVENT_INCOMING_CALL_ACCEPTED
67306732
*
67316733
* @param data1 (int) msg_id ID of the info-message referring to the call.
6732-
* The call URL is avauilable at dc_msg_get_videochat_url().
6734+
* @param data2 (char*) place_call_info, text passed to dc_place_outgoing_call()
67336735
*/
67346736
#define DC_EVENT_INCOMING_CALL 2550
67356737

@@ -6741,6 +6743,7 @@ void dc_event_unref(dc_event_t* event);
67416743
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
67426744
*
67436745
* @param data1 (int) msg_id ID of the info-message referring to the call
6746+
* @param data2 (char*) accept_call_info, text passed to dc_place_outgoing_call()
67446747
*/
67456748
#define DC_EVENT_INCOMING_CALL_ACCEPTED 2560
67466749

@@ -6751,6 +6754,7 @@ void dc_event_unref(dc_event_t* event);
67516754
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
67526755
*
67536756
* @param data1 (int) msg_id ID of the info-message referring to the call
6757+
* @param data2 (char*) accept_call_info, text passed to dc_accept_incoming_call()
67546758
*/
67556759
#define DC_EVENT_OUTGOING_CALL_ACCEPTED 2570
67566760

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
@@ -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)