Skip to content

Commit ab8aedf

Browse files
authored
refine call states (#7179)
- sync declined calls from callee to caller, as usual in all larger messengers - introduce the call states "Missed call", "Declined call" and "Cancelled all" ("Ended call" is gone) - allow calling end_call()/accept_call() for already ended/accepted calls, in practise, handling all cornercases is tricky in UI - and the state needs anyways to be tracked. - track and show the call duration the duration calculation depends on local time, but it is displayed only coarse and is not needed for any state. this can be improved as needed, timestamps of the corresponding messages are probably better at some point. or ending device sends its view of the time around. but for the first throw, it seems good enough if we finally want that set of states, it can be exposed to a json-info in a subsequent call, so that the UI can render it more nicely. fallback strings as follows will stay for now to make adaption in other UI easy, and for debugging: <img width="320" alt="IMG_0154" src="https://github.com/user-attachments/assets/09a89bfb-66f4-4184-b05c-e8040b96cf44" /> successor of #6650
1 parent b6ab13f commit ab8aedf

File tree

9 files changed

+276
-199
lines changed

9 files changed

+276
-199
lines changed

deltachat-ffi/deltachat.h

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,21 +1216,21 @@ uint32_t dc_init_webxdc_integration (dc_context_t* context, uint32_t c
12161216

12171217
/**
12181218
* Start an outgoing call.
1219-
* This sends a message with all relevant information to the callee,
1219+
* This sends a message of type #DC_MSG_CALL with all relevant information to the callee,
12201220
* who will get informed by an #DC_EVENT_INCOMING_CALL event and rings.
12211221
*
12221222
* Possible actions during ringing:
12231223
*
12241224
* - caller cancels the call using dc_end_call():
1225-
* callee receives #DC_EVENT_CALL_ENDED
1225+
* callee receives #DC_EVENT_CALL_ENDED and has a "Missed Call"
12261226
*
12271227
* - callee accepts using dc_accept_incoming_call():
12281228
* caller receives #DC_EVENT_OUTGOING_CALL_ACCEPTED.
12291229
* callee's devices receive #DC_EVENT_INCOMING_CALL_ACCEPTED, call starts
12301230
*
1231-
* - callee rejects using dc_end_call():
1232-
* caller receives #DC_EVENT_CALL_ENDED after 1 minute timeout.
1233-
* callee's other devices receive #DC_EVENT_CALL_ENDED
1231+
* - callee declines using dc_end_call():
1232+
* caller receives #DC_EVENT_CALL_ENDED and has a "Declinced Call".
1233+
* callee's other devices receive #DC_EVENT_CALL_ENDED and have a "Cancelled Call",
12341234
*
12351235
* - callee is already in a call:
12361236
* in this case, UI may decide to show a notification instead of ringing.
@@ -1240,7 +1240,9 @@ uint32_t dc_init_webxdc_integration (dc_context_t* context, uint32_t c
12401240
* after 1 minute without action,
12411241
* caller and callee receive #DC_EVENT_CALL_ENDED
12421242
* to prevent endless ringing of callee
1243-
* in case caller got offline without being able to send cancellation message
1243+
* in case caller got offline without being able to send cancellation message.
1244+
* for caller, this is a "Cancelled Call";
1245+
* for callee, this is a "Missed Call"
12441246
*
12451247
* Actions during the call:
12461248
*
@@ -1276,13 +1278,15 @@ uint32_t dc_place_outgoing_call (dc_context_t* context, uint32_t ch
12761278
* All affected devices will receive
12771279
* either #DC_EVENT_OUTGOING_CALL_ACCEPTED or #DC_EVENT_INCOMING_CALL_ACCEPTED.
12781280
*
1281+
* If the call is already accepted or ended, nothing happens.
1282+
*
12791283
* @memberof dc_context_t
12801284
* @param context The context object.
12811285
* @param msg_id The ID of the call to accept.
12821286
* This is the ID reported by #DC_EVENT_INCOMING_CALL
12831287
* and equals to the ID of the corresponding info message.
12841288
* @param accept_call_info any data that other devices receive
1285-
* in #DC_EVENT_OUTGOING_CALL_ACCEPTED or #DC_EVENT_INCOMING_CALL_ACCEPTED.
1289+
* in #DC_EVENT_OUTGOING_CALL_ACCEPTED.
12861290
* @return 1=success, 0=error
12871291
*/
12881292
int dc_accept_incoming_call (dc_context_t* context, uint32_t msg_id, const char* accept_call_info);
@@ -1291,17 +1295,13 @@ uint32_t dc_place_outgoing_call (dc_context_t* context, uint32_t ch
12911295
/**
12921296
* End incoming or outgoing call.
12931297
*
1294-
* From the view of the caller, a "cancellation",
1295-
* from the view of callee, a "rejection".
1298+
* For unaccepted calls ended by the caller, this is a "cancellation".
1299+
* Unaccepted calls ended by the callee are a "decline".
12961300
* If the call was accepted, this is a "hangup".
12971301
*
1298-
* For accepted calls,
1299-
* all participant devices get informed about the ended call via #DC_EVENT_CALL_ENDED.
1300-
* For not accepted calls, only the caller will inform the callee.
1302+
* All participant devices get informed about the ended call via #DC_EVENT_CALL_ENDED.
13011303
*
1302-
* If the callee rejects, the caller will get a timeout or give up at some point -
1303-
* same as for all other reasons the call cannot be established: Device not in reach, device muted, connectivity etc.
1304-
* This is to protect privacy of the callee, avoiding to check if callee is online.
1304+
* If the call is already ended, nothing happens.
13051305
*
13061306
* @memberof dc_context_t
13071307
* @param context The context object.
@@ -6724,29 +6724,27 @@ void dc_event_unref(dc_event_t* event);
67246724
* or show a notification if there is already a call in some profile.
67256725
*
67266726
* Together with this event,
6727-
* an info-message is added to the corresponding chat.
6728-
* The info-message, however, is _not_ additionally notified using #DC_EVENT_INCOMING_MSG,
6729-
* if needed, this has to be done by the UI explicitly.
6727+
* a message of type #DC_MSG_CALL is added to the corresponding chat;
6728+
* this message is announced and updated by the usual even as #DC_EVENT_MSGS_CHANGED.
67306729
*
67316730
* If user takes action, dc_accept_incoming_call() or dc_end_call() should be called.
67326731
*
67336732
* Otherwise, ringing should end on #DC_EVENT_CALL_ENDED
67346733
* or #DC_EVENT_INCOMING_CALL_ACCEPTED
67356734
*
6736-
* @param data1 (int) msg_id ID of the info-message referring to the call.
6735+
* @param data1 (int) msg_id ID of the message referring to the call.
67376736
* @param data2 (char*) place_call_info, text passed to dc_place_outgoing_call()
67386737
*/
67396738
#define DC_EVENT_INCOMING_CALL 2550
67406739

67416740
/**
6742-
* The callee accepted an incoming call on another device using dc_accept_incoming_call().
6741+
* The callee accepted an incoming call on this or another device using dc_accept_incoming_call().
67436742
* The caller gets the event #DC_EVENT_OUTGOING_CALL_ACCEPTED at the same time.
67446743
*
67456744
* The event is sent unconditionally when the corresponding message is received.
67466745
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
67476746
*
6748-
* @param data1 (int) msg_id ID of the info-message referring to the call
6749-
* @param data2 (char*) accept_call_info, text passed to dc_place_outgoing_call()
6747+
* @param data1 (int) msg_id ID of the message referring to the call
67506748
*/
67516749
#define DC_EVENT_INCOMING_CALL_ACCEPTED 2560
67526750

@@ -6756,7 +6754,7 @@ void dc_event_unref(dc_event_t* event);
67566754
* The event is sent unconditionally when the corresponding message is received.
67576755
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
67586756
*
6759-
* @param data1 (int) msg_id ID of the info-message referring to the call
6757+
* @param data1 (int) msg_id ID of the message referring to the call
67606758
* @param data2 (char*) accept_call_info, text passed to dc_accept_incoming_call()
67616759
*/
67626760
#define DC_EVENT_OUTGOING_CALL_ACCEPTED 2570
@@ -6768,7 +6766,7 @@ void dc_event_unref(dc_event_t* event);
67686766
* The event is sent unconditionally when the corresponding message is received.
67696767
* UI should only take action in case call UI was opened before, otherwise the event should be ignored.
67706768
*
6771-
* @param data1 (int) msg_id ID of the info-message referring to the call
6769+
* @param data1 (int) msg_id ID of the message referring to the call
67726770
*/
67736771
#define DC_EVENT_CALL_ENDED 2580
67746772

deltachat-ffi/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,17 +779,15 @@ pub unsafe extern "C" fn dc_event_get_data2_str(event: *mut dc_event_t) -> *mut
779779
| EventType::ChatlistChanged
780780
| EventType::AccountsChanged
781781
| EventType::AccountsItemChanged
782+
| EventType::IncomingCallAccepted { .. }
782783
| EventType::WebxdcRealtimeAdvertisementReceived { .. } => ptr::null_mut(),
783784
EventType::IncomingCall {
784785
place_call_info, ..
785786
} => {
786787
let data2 = place_call_info.to_c_string().unwrap_or_default();
787788
data2.into_raw()
788789
}
789-
EventType::IncomingCallAccepted {
790-
accept_call_info, ..
791-
}
792-
| EventType::OutgoingCallAccepted {
790+
EventType::OutgoingCallAccepted {
793791
accept_call_info, ..
794792
} => {
795793
let data2 = accept_call_info.to_c_string().unwrap_or_default();

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,6 @@ pub enum EventType {
430430
IncomingCallAccepted {
431431
/// ID of the info message referring to the call.
432432
msg_id: u32,
433-
/// User-defined info passed to dc_accept_incoming_call()
434-
accept_call_info: String,
435433
},
436434

437435
/// Outgoing call accepted.
@@ -604,12 +602,8 @@ impl From<CoreEventType> for EventType {
604602
msg_id: msg_id.to_u32(),
605603
place_call_info,
606604
},
607-
CoreEventType::IncomingCallAccepted {
608-
msg_id,
609-
accept_call_info,
610-
} => IncomingCallAccepted {
605+
CoreEventType::IncomingCallAccepted { msg_id } => IncomingCallAccepted {
611606
msg_id: msg_id.to_u32(),
612-
accept_call_info,
613607
},
614608
CoreEventType::OutgoingCallAccepted {
615609
msg_id,

0 commit comments

Comments
 (0)