@@ -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
*
@@ -4489,6 +4562,8 @@ int dc_msg_is_info (const dc_msg_t* msg);
4489
4562
* the UI should change the corresponding string using #DC_STR_INVALID_UNENCRYPTED_MAIL
4490
4563
* and also offer a way to fix the encryption, eg. by a button offering a QR scan
4491
4564
* - DC_INFO_WEBXDC_INFO_MESSAGE (32) - Info-message created by webxdc app sending `update.info`
4565
+ * - DC_INFO_OUTGOING_CALL (50) - Info-message refers to an outgoing call
4566
+ * - DC_INFO_INCOMING_CALL (55) - Info-message refers to an incoming call
4492
4567
*
4493
4568
* Even when you display an icon,
4494
4569
* you should still display the text of the informational message using dc_msg_get_text()
@@ -4517,6 +4592,8 @@ int dc_msg_get_info_type (const dc_msg_t* msg);
4517
4592
#define DC_INFO_PROTECTION_DISABLED 12
4518
4593
#define DC_INFO_INVALID_UNENCRYPTED_MAIL 13
4519
4594
#define DC_INFO_WEBXDC_INFO_MESSAGE 32
4595
+ #define DC_INFO_OUTGOING_CALL 50
4596
+ #define DC_INFO_INCOMING_CALL 55
4520
4597
4521
4598
4522
4599
/**
@@ -6514,6 +6591,38 @@ void dc_event_unref(dc_event_t* event);
6514
6591
*/
6515
6592
#define DC_EVENT_CHANNEL_OVERFLOW 2400
6516
6593
6594
+
6595
+
6596
+ /**
6597
+ * Incoming call.
6598
+ * UI will usually start ringing.
6599
+ *
6600
+ * If user takes action, dc_accept_incoming_call() or dc_end_call() should be called.
6601
+ *
6602
+ * Otherwise, ringing should end on #DC_EVENT_CALL_ENDED
6603
+ * or #DC_EVENT_INCOMING_CALL_ACCEPTED
6604
+ *
6605
+ * @param data1 (int) msg_id
6606
+ */
6607
+ #define DC_EVENT_INCOMING_CALL 2550
6608
+
6609
+ /**
6610
+ * The callee accepted an incoming call on another another device using dc_accept_incoming_call().
6611
+ * The caller gets the event #DC_EVENT_OUTGOING_CALL_ACCEPTED at the same time.
6612
+ */
6613
+ #define DC_EVENT_INCOMING_CALL_ACCEPTED 2560
6614
+
6615
+ /**
6616
+ * A call placed using dc_place_outgoing_call() was accepted by the callee using dc_accept_incoming_call().
6617
+ */
6618
+ #define DC_EVENT_OUTGOING_CALL_ACCEPTED 2570
6619
+
6620
+ /**
6621
+ * An incoming or outgoing call was ended using dc_end_call().
6622
+ */
6623
+ #define DC_EVENT_CALL_ENDED 2580
6624
+
6625
+
6517
6626
/**
6518
6627
* @}
6519
6628
*/
0 commit comments