@@ -1222,6 +1222,79 @@ void dc_set_webxdc_integration (dc_context_t* context, const char* f
1222
1222
uint32_t dc_init_webxdc_integration (dc_context_t * context , uint32_t chat_id );
1223
1223
1224
1224
1225
+ /**
1226
+ * Start an outgoing call.
1227
+ * This sends a message with all relevant information to the callee,
1228
+ * who will get informed by an #DC_EVENT_INCOMING_CALL event and rings.
1229
+ *
1230
+ * Possible actions during ringing:
1231
+ * - callee accepts using dc_accept_incoming_call(), caller receives #DC_EVENT_OUTGOING_CALL_ACCEPTED,
1232
+ * callee's devices receive #DC_EVENT_INCOMING_CALL_ACCEPTED, call starts
1233
+ * - callee rejects using dc_end_call(), caller receives #DC_EVENT_CALL_ENDED,
1234
+ * callee's other devices receive #DC_EVENT_CALL_ENDED, done.
1235
+ * - caller cancels the call using dc_end_call(), callee receives #DC_EVENT_CALL_ENDED, done.
1236
+ * - after 2 minutes, caller and callee both should end the call.
1237
+ * this is to prevent endless ringing of callee
1238
+ * in case caller got offline without being able to send cancellation message.
1239
+ *
1240
+ * Actions during the call:
1241
+ * - callee ends the call using dc_end_call(), caller receives #DC_EVENT_CALL_ENDED
1242
+ * - caller ends the call using dc_end_call(), callee receives #DC_EVENT_CALL_ENDED
1243
+ *
1244
+ * Note, that the events are for updating the call screen,
1245
+ * possible status messages are added and updated as usual, including the known events.
1246
+ * In the UI, the sorted chatlist is used as an overview about calls as well as messages.
1247
+ * To place a call with a contact that has no chat yet, use dc_create_chat_by_contact_id() first.
1248
+ *
1249
+ * @memberof dc_context_t
1250
+ * @param context The context object.
1251
+ * @param chat_id The chat to place a call for.
1252
+ * This needs to be a one-to-one chat.
1253
+ * @return ID of the system message announcing the call.
1254
+ */
1255
+ uint32_t dc_place_outgoing_call (dc_context_t * context , uint32_t chat_id );
1256
+
1257
+
1258
+ /**
1259
+ * Accept incoming call.
1260
+ *
1261
+ * This implicitly accepts the contact request, if not yet done.
1262
+ * All affected devices will receive
1263
+ * either #DC_EVENT_OUTGOING_CALL_ACCEPTED or #DC_EVENT_INCOMING_CALL_ACCEPTED.
1264
+ *
1265
+ * @memberof dc_context_t
1266
+ * @param context The context object.
1267
+ * @param msg_id The ID of the call to accept.
1268
+ * This is the ID reported by #DC_EVENT_INCOMING_CALL
1269
+ * and equal to the ID of the corresponding info message.
1270
+ * @return 1=success, 0=error
1271
+ */
1272
+ int dc_accept_incoming_call (dc_context_t * context , uint32_t msg_id );
1273
+
1274
+
1275
+ /**
1276
+ * End incoming or outgoing call.
1277
+ *
1278
+ * From the view of the caller, a "cancellation",
1279
+ * from the view of callee, a "rejection".
1280
+ * If the call was accepted, this is a "hangup".
1281
+ *
1282
+ * For accepted calls,
1283
+ * all participant devices get informed about the ended call via #DC_EVENT_CALL_ENDED.
1284
+ * For not accepted calls, only the caller will inform the callee.
1285
+ *
1286
+ * If the callee rejects, the caller will get an timeout or give up at some point -
1287
+ * same as for all other reasons the call cannot be established: Device not in reach, device muted, connectivity etc.
1288
+ * This is to protect privacy of the callee, avoiding to check if callee is online.
1289
+ *
1290
+ * @memberof dc_context_t
1291
+ * @param context The context object.
1292
+ * @param msg_id the ID of the call.
1293
+ * @return 1=success, 0=error
1294
+ */
1295
+ int dc_end_call (dc_context_t * context , uint32_t msg_id );
1296
+
1297
+
1225
1298
/**
1226
1299
* Save a draft for a chat in the database.
1227
1300
*
@@ -4517,6 +4590,8 @@ int dc_msg_is_info (const dc_msg_t* msg);
4517
4590
* the UI should change the corresponding string using #DC_STR_INVALID_UNENCRYPTED_MAIL
4518
4591
* and also offer a way to fix the encryption, eg. by a button offering a QR scan
4519
4592
* - DC_INFO_WEBXDC_INFO_MESSAGE (32) - Info-message created by webxdc app sending `update.info`
4593
+ * - DC_INFO_OUTGOING_CALL (50) - Info-message refers to an outgoing call
4594
+ * - DC_INFO_INCOMING_CALL (55) - Info-message refers to an incoming call
4520
4595
*
4521
4596
* For the messages that refer to a CONTACT,
4522
4597
* dc_msg_get_info_contact_id() returns the contact ID.
@@ -4572,6 +4647,8 @@ uint32_t dc_msg_get_info_contact_id (const dc_msg_t* msg);
4572
4647
#define DC_INFO_PROTECTION_DISABLED 12
4573
4648
#define DC_INFO_INVALID_UNENCRYPTED_MAIL 13
4574
4649
#define DC_INFO_WEBXDC_INFO_MESSAGE 32
4650
+ #define DC_INFO_OUTGOING_CALL 50
4651
+ #define DC_INFO_INCOMING_CALL 55
4575
4652
4576
4653
4577
4654
/**
@@ -6569,6 +6646,38 @@ void dc_event_unref(dc_event_t* event);
6569
6646
*/
6570
6647
#define DC_EVENT_CHANNEL_OVERFLOW 2400
6571
6648
6649
+
6650
+
6651
+ /**
6652
+ * Incoming call.
6653
+ * UI will usually start ringing.
6654
+ *
6655
+ * If user takes action, dc_accept_incoming_call() or dc_end_call() should be called.
6656
+ *
6657
+ * Otherwise, ringing should end on #DC_EVENT_CALL_ENDED
6658
+ * or #DC_EVENT_INCOMING_CALL_ACCEPTED
6659
+ *
6660
+ * @param data1 (int) msg_id
6661
+ */
6662
+ #define DC_EVENT_INCOMING_CALL 2550
6663
+
6664
+ /**
6665
+ * The callee accepted an incoming call on another another device using dc_accept_incoming_call().
6666
+ * The caller gets the event #DC_EVENT_OUTGOING_CALL_ACCEPTED at the same time.
6667
+ */
6668
+ #define DC_EVENT_INCOMING_CALL_ACCEPTED 2560
6669
+
6670
+ /**
6671
+ * A call placed using dc_place_outgoing_call() was accepted by the callee using dc_accept_incoming_call().
6672
+ */
6673
+ #define DC_EVENT_OUTGOING_CALL_ACCEPTED 2570
6674
+
6675
+ /**
6676
+ * An incoming or outgoing call was ended using dc_end_call().
6677
+ */
6678
+ #define DC_EVENT_CALL_ENDED 2580
6679
+
6680
+
6572
6681
/**
6573
6682
* @}
6574
6683
*/
0 commit comments