@@ -1215,6 +1215,103 @@ void dc_set_webxdc_integration (dc_context_t* context, const char* f
1215
1215
uint32_t dc_init_webxdc_integration (dc_context_t * context , uint32_t chat_id );
1216
1216
1217
1217
1218
+ /**
1219
+ * Start an outgoing call.
1220
+ * This sends a message with all relevant information to the callee,
1221
+ * who will get informed by an #DC_EVENT_INCOMING_CALL event and rings.
1222
+ *
1223
+ * Possible actions during ringing:
1224
+ *
1225
+ * - caller cancels the call using dc_end_call():
1226
+ * callee receives #DC_EVENT_CALL_ENDED
1227
+ *
1228
+ * - callee accepts using dc_accept_incoming_call():
1229
+ * caller receives #DC_EVENT_OUTGOING_CALL_ACCEPTED.
1230
+ * callee's devices receive #DC_EVENT_INCOMING_CALL_ACCEPTED, call starts
1231
+ *
1232
+ * - callee rejects using dc_end_call():
1233
+ * caller receives #DC_EVENT_CALL_ENDED after 1 minute timeout.
1234
+ * callee's other devices receive #DC_EVENT_CALL_ENDED
1235
+ *
1236
+ * - callee is already in a call:
1237
+ * in this case, UI may decide to show a notification instead of ringing.
1238
+ * otherwise, this is same as timeout
1239
+ *
1240
+ * - timeout:
1241
+ * after 1 minute without action,
1242
+ * caller and callee receive #DC_EVENT_CALL_ENDED
1243
+ * to prevent endless ringing of callee
1244
+ * in case caller got offline without being able to send cancellation message
1245
+ *
1246
+ * Actions during the call:
1247
+ *
1248
+ * - caller ends the call using dc_end_call():
1249
+ * callee receives #DC_EVENT_CALL_ENDED
1250
+ *
1251
+ * - callee ends the call using dc_end_call():
1252
+ * caller receives #DC_EVENT_CALL_ENDED
1253
+ *
1254
+ * Note, that the events are for updating the call screen,
1255
+ * possible status messages are added and updated as usual, including the known events.
1256
+ * In the UI, the sorted chatlist is used as an overview about calls as well as messages.
1257
+ * To place a call with a contact that has no chat yet, use dc_create_chat_by_contact_id() first.
1258
+ *
1259
+ * UI will usually allow only one call at the same time,
1260
+ * this has to be tracked by UI across profile, the core does not track this.
1261
+ *
1262
+ * @memberof dc_context_t
1263
+ * @param context The context object.
1264
+ * @param chat_id The chat to place a call for.
1265
+ * This needs to be a one-to-one chat.
1266
+ * @param place_call_info any data that other devices receive
1267
+ * in #DC_EVENT_INCOMING_CALL.
1268
+ * @return ID of the system message announcing the call.
1269
+ */
1270
+ uint32_t dc_place_outgoing_call (dc_context_t * context , uint32_t chat_id , const char * place_call_info );
1271
+
1272
+
1273
+ /**
1274
+ * Accept incoming call.
1275
+ *
1276
+ * This implicitly accepts the contact request, if not yet done.
1277
+ * All affected devices will receive
1278
+ * either #DC_EVENT_OUTGOING_CALL_ACCEPTED or #DC_EVENT_INCOMING_CALL_ACCEPTED.
1279
+ *
1280
+ * @memberof dc_context_t
1281
+ * @param context The context object.
1282
+ * @param msg_id The ID of the call to accept.
1283
+ * This is the ID reported by #DC_EVENT_INCOMING_CALL
1284
+ * and equals to the ID of the corresponding info message.
1285
+ * @param accept_call_info any data that other devices receive
1286
+ * in #DC_EVENT_OUTGOING_CALL_ACCEPTED or #DC_EVENT_INCOMING_CALL_ACCEPTED.
1287
+ * @return 1=success, 0=error
1288
+ */
1289
+ int dc_accept_incoming_call (dc_context_t * context , uint32_t msg_id , const char * accept_call_info );
1290
+
1291
+
1292
+ /**
1293
+ * End incoming or outgoing call.
1294
+ *
1295
+ * From the view of the caller, a "cancellation",
1296
+ * from the view of callee, a "rejection".
1297
+ * If the call was accepted, this is a "hangup".
1298
+ *
1299
+ * For accepted calls,
1300
+ * all participant devices get informed about the ended call via #DC_EVENT_CALL_ENDED.
1301
+ * For not accepted calls, only the caller will inform the callee.
1302
+ *
1303
+ * If the callee rejects, the caller will get a timeout or give up at some point -
1304
+ * same as for all other reasons the call cannot be established: Device not in reach, device muted, connectivity etc.
1305
+ * This is to protect privacy of the callee, avoiding to check if callee is online.
1306
+ *
1307
+ * @memberof dc_context_t
1308
+ * @param context The context object.
1309
+ * @param msg_id the ID of the call.
1310
+ * @return 1=success, 0=error
1311
+ */
1312
+ int dc_end_call (dc_context_t * context , uint32_t msg_id );
1313
+
1314
+
1218
1315
/**
1219
1316
* Save a draft for a chat in the database.
1220
1317
*
@@ -4546,6 +4643,8 @@ int dc_msg_is_info (const dc_msg_t* msg);
4546
4643
* and also offer a way to fix the encryption, eg. by a button offering a QR scan
4547
4644
* - DC_INFO_WEBXDC_INFO_MESSAGE (32) - Info-message created by webxdc app sending `update.info`
4548
4645
* - DC_INFO_CHAT_E2EE (50) - Info-message for "Chat is end-to-end-encrypted"
4646
+ * - DC_INFO_OUTGOING_CALL (60) - Info-message refers to an outgoing call
4647
+ * - DC_INFO_INCOMING_CALL (65) - Info-message refers to an incoming call
4549
4648
*
4550
4649
* For the messages that refer to a CONTACT,
4551
4650
* dc_msg_get_info_contact_id() returns the contact ID.
@@ -4602,6 +4701,8 @@ uint32_t dc_msg_get_info_contact_id (const dc_msg_t* msg);
4602
4701
#define DC_INFO_INVALID_UNENCRYPTED_MAIL 13
4603
4702
#define DC_INFO_WEBXDC_INFO_MESSAGE 32
4604
4703
#define DC_INFO_CHAT_E2EE 50
4704
+ #define DC_INFO_OUTGOING_CALL 60
4705
+ #define DC_INFO_INCOMING_CALL 65
4605
4706
4606
4707
4607
4708
/**
@@ -6636,6 +6737,63 @@ void dc_event_unref(dc_event_t* event);
6636
6737
*/
6637
6738
#define DC_EVENT_CHANNEL_OVERFLOW 2400
6638
6739
6740
+
6741
+
6742
+ /**
6743
+ * Incoming call.
6744
+ * UI will usually start ringing,
6745
+ * or show a notification if there is already a call in some profile.
6746
+ *
6747
+ * Together with this event,
6748
+ * an info-message is added to the corresponding chat.
6749
+ * The info-message, however, is _not_ additionally notified using #DC_EVENT_INCOMING_MSG,
6750
+ * if needed, this has to be done by the UI explicitly.
6751
+ *
6752
+ * If user takes action, dc_accept_incoming_call() or dc_end_call() should be called.
6753
+ *
6754
+ * Otherwise, ringing should end on #DC_EVENT_CALL_ENDED
6755
+ * or #DC_EVENT_INCOMING_CALL_ACCEPTED
6756
+ *
6757
+ * @param data1 (int) msg_id ID of the info-message referring to the call.
6758
+ * @param data2 (char*) place_call_info, text passed to dc_place_outgoing_call()
6759
+ */
6760
+ #define DC_EVENT_INCOMING_CALL 2550
6761
+
6762
+ /**
6763
+ * The callee accepted an incoming call on another device using dc_accept_incoming_call().
6764
+ * The caller gets the event #DC_EVENT_OUTGOING_CALL_ACCEPTED at the same time.
6765
+ *
6766
+ * The event is sent unconditionally when the corresponding message is received.
6767
+ * UI should only take action in case call UI was opened before, otherwise the event should be ignored.
6768
+ *
6769
+ * @param data1 (int) msg_id ID of the info-message referring to the call
6770
+ * @param data2 (char*) accept_call_info, text passed to dc_place_outgoing_call()
6771
+ */
6772
+ #define DC_EVENT_INCOMING_CALL_ACCEPTED 2560
6773
+
6774
+ /**
6775
+ * A call placed using dc_place_outgoing_call() was accepted by the callee using dc_accept_incoming_call().
6776
+ *
6777
+ * The event is sent unconditionally when the corresponding message is received.
6778
+ * UI should only take action in case call UI was opened before, otherwise the event should be ignored.
6779
+ *
6780
+ * @param data1 (int) msg_id ID of the info-message referring to the call
6781
+ * @param data2 (char*) accept_call_info, text passed to dc_accept_incoming_call()
6782
+ */
6783
+ #define DC_EVENT_OUTGOING_CALL_ACCEPTED 2570
6784
+
6785
+ /**
6786
+ * An incoming or outgoing call was ended using dc_end_call().
6787
+ * Moreover, the event is sent when the call was not accepted within 1 minute timeout.
6788
+ *
6789
+ * The event is sent unconditionally when the corresponding message is received.
6790
+ * UI should only take action in case call UI was opened before, otherwise the event should be ignored.
6791
+ *
6792
+ * @param data1 (int) msg_id ID of the info-message referring to the call
6793
+ */
6794
+ #define DC_EVENT_CALL_ENDED 2580
6795
+
6796
+
6639
6797
/**
6640
6798
* @}
6641
6799
*/
0 commit comments