diff --git a/include/linphone/api/c-callbacks.h b/include/linphone/api/c-callbacks.h index f31219d14..c8cfc7142 100644 --- a/include/linphone/api/c-callbacks.h +++ b/include/linphone/api/c-callbacks.h @@ -226,6 +226,14 @@ typedef void (*LinphoneChatRoomCbsParticipantDeviceAddedCb) (LinphoneChatRoom *c * @param[in] participant The #LinphoneParticipant that has been removed from the chat room */ typedef void (*LinphoneChatRoomCbsParticipantDeviceRemovedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log); + +/** + * Callback used when a group chat room is created server-side to generate the address of the chat room. + * The function linphone_chat_room_set_conference_address() needs to be called by this callback. + * @param[in] cr #LinphoneChatRoom object + */ +typedef void (*LinphoneChatRoomCbsConferenceAddressGenerationCb) (LinphoneChatRoom *cr); + /** * @} **/ diff --git a/include/linphone/api/c-chat-room-cbs.h b/include/linphone/api/c-chat-room-cbs.h index ae515cc9d..49f5629db 100644 --- a/include/linphone/api/c-chat-room-cbs.h +++ b/include/linphone/api/c-chat-room-cbs.h @@ -228,6 +228,21 @@ LINPHONE_PUBLIC LinphoneChatRoomCbsParticipantDeviceRemovedCb linphone_chat_room * @param[in] cb The participant device removed callback to be used. */ LINPHONE_PUBLIC void linphone_chat_room_cbs_set_participant_device_removed (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantDeviceRemovedCb cb); + +/** + * Get the conference address generation callback. + * @param[in] cbs LinphoneChatRoomCbs object + * @return The current conference address generation callback + */ +LINPHONE_PUBLIC LinphoneChatRoomCbsConferenceAddressGenerationCb linphone_chat_room_cbs_get_conference_address_generation (const LinphoneChatRoomCbs *cbs); + +/** + * Set the conference address generation callback. + * @param[in] cbs LinphoneChatRoomCbs object + * @param[in] cb The conference address generation callback to be used + */ +LINPHONE_PUBLIC void linphone_chat_room_cbs_set_conference_address_generation (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsConferenceAddressGenerationCb cb); + /** * @} */ diff --git a/include/linphone/api/c-chat-room.h b/include/linphone/api/c-chat-room.h index 14da77ffa..244afe477 100644 --- a/include/linphone/api/c-chat-room.h +++ b/include/linphone/api/c-chat-room.h @@ -366,6 +366,14 @@ LINPHONE_PUBLIC void linphone_chat_room_set_subject (LinphoneChatRoom *cr, const */ LINPHONE_PUBLIC bctbx_list_t * linphone_chat_room_get_composing_addresses(LinphoneChatRoom *cr); +/** + * Set the conference address of a group chat room. This function needs to be called from the + * LinphoneChatRoomCbsConferenceAddressGenerationCb callback and only there. + * @param[in] cr A LinphoneChatRoom object + * @param[in] confAddr The conference address to be used by the group chat room + */ +LINPHONE_PUBLIC void linphone_chat_room_set_conference_address (LinphoneChatRoom *cr, const LinphoneAddress *confAddr); + /** * Returns back pointer to #LinphoneCore object. * @deprecated use linphone_chat_room_get_core() diff --git a/src/c-wrapper/api/c-chat-room-cbs.cpp b/src/c-wrapper/api/c-chat-room-cbs.cpp index 9bcb058d7..dc1beebbf 100644 --- a/src/c-wrapper/api/c-chat-room-cbs.cpp +++ b/src/c-wrapper/api/c-chat-room-cbs.cpp @@ -38,6 +38,7 @@ struct _LinphoneChatRoomCbs { LinphoneChatRoomCbsUndecryptableMessageReceivedCb undecryptableMessageReceivedCb; LinphoneChatRoomCbsChatMessageReceivedCb chatMessageReceivedCb; LinphoneChatRoomCbsChatMessageSentCb chatMessageSentCb; + LinphoneChatRoomCbsConferenceAddressGenerationCb conferenceAddressGenerationCb; }; BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoomCbs); @@ -169,3 +170,11 @@ LinphoneChatRoomCbsParticipantDeviceRemovedCb linphone_chat_room_cbs_get_partici void linphone_chat_room_cbs_set_participant_device_removed (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantDeviceRemovedCb cb) { cbs->participantDeviceRemovedCb = cb; } + +LinphoneChatRoomCbsConferenceAddressGenerationCb linphone_chat_room_cbs_get_conference_address_generation (const LinphoneChatRoomCbs *cbs) { + return cbs->conferenceAddressGenerationCb; +} + +void linphone_chat_room_cbs_set_conference_address_generation (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsConferenceAddressGenerationCb cb) { + cbs->conferenceAddressGenerationCb = cb; +} diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index 153d15cc3..e3014b4e4 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -24,6 +24,7 @@ #include "linphone/wrapper_utils.h" #include "c-wrapper/c-wrapper.h" +#include "address/identity-address.h" #include "chat/chat-room/basic-chat-room.h" #include "chat/chat-room/client-group-chat-room.h" #include "chat/chat-room/real-time-text-chat-room-p.h" @@ -309,6 +310,14 @@ LinphoneChatMessage *linphone_chat_room_create_file_transfer_message(LinphoneCha return object; } +void linphone_chat_room_set_conference_address (LinphoneChatRoom *cr, const LinphoneAddress *confAddr) { + char *addrStr = linphone_address_as_string(confAddr); + LinphonePrivate::ServerGroupChatRoomPrivate *sgcr = dynamic_cast(L_GET_PRIVATE_FROM_C_OBJECT(cr)); + if (sgcr) + sgcr->setConferenceAddress(LinphonePrivate::IdentityAddress(addrStr)); + bctbx_free(addrStr); +} + // ============================================================================= // Reference and user data handling functions. // ============================================================================= diff --git a/src/chat/chat-room/server-group-chat-room-p.h b/src/chat/chat-room/server-group-chat-room-p.h index b288e0979..9a8b18c17 100644 --- a/src/chat/chat-room/server-group-chat-room-p.h +++ b/src/chat/chat-room/server-group-chat-room-p.h @@ -49,9 +49,11 @@ public: void dispatchMessage (const Address &fromAddr, const Content &content); void storeOrUpdateMessage (const std::shared_ptr &msg) override; LinphoneReason messageReceived (SalOp *op, const SalMessage *msg) override; + void setConferenceAddress (const IdentityAddress &confAddr); private: void designateAdmin (); + void finalizeCreation (); bool isAdminLeft () const; std::list> removedParticipants; diff --git a/src/chat/chat-room/server-group-chat-room-stub.cpp b/src/chat/chat-room/server-group-chat-room-stub.cpp index 9356180ec..faace05d4 100644 --- a/src/chat/chat-room/server-group-chat-room-stub.cpp +++ b/src/chat/chat-room/server-group-chat-room-stub.cpp @@ -63,10 +63,14 @@ LinphoneReason ServerGroupChatRoomPrivate::messageReceived (SalOp *, const SalMe return LinphoneReasonNone; } +void ServerGroupChatRoomPrivate::setConferenceAddress (const IdentityAddress &confAddr) {} + // ----------------------------------------------------------------------------- void ServerGroupChatRoomPrivate::designateAdmin () {} +void ServerGroupChatRoomPrivate::finalizeCreation () {} + bool ServerGroupChatRoomPrivate::isAdminLeft () const { return false; }