diff --git a/coreapi/chat.c b/coreapi/chat.c index 5140df79a..61708382c 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -123,8 +123,8 @@ LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAd return ret; } -LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc, const bctbx_list_t *addresses) { - return linphone_client_group_chat_room_new(lc, addresses); +LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc) { + return linphone_client_group_chat_room_new(lc); } void linphone_core_delete_chat_room(LinphoneCore *lc, LinphoneChatRoom *cr) { diff --git a/coreapi/private.h b/coreapi/private.h index 193d5d8ff..ecd503718 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -460,7 +460,7 @@ void _linphone_proxy_config_release_ops(LinphoneProxyConfig *obj); /*chat*/ LinphoneChatRoom * linphone_chat_room_new(LinphoneCore *core, const LinphoneAddress *addr); -LinphoneChatRoom * linphone_client_group_chat_room_new(LinphoneCore *lc, const bctbx_list_t *addresses); +LinphoneChatRoom * linphone_client_group_chat_room_new(LinphoneCore *lc); void linphone_chat_room_release(LinphoneChatRoom *cr); void linphone_chat_room_set_call(LinphoneChatRoom *cr, LinphoneCall *call); bctbx_list_t * linphone_chat_room_get_transient_messages(const LinphoneChatRoom *cr); diff --git a/include/linphone/api/c-chat-message.h b/include/linphone/api/c-chat-message.h index bf69e0df7..74f2753d1 100644 --- a/include/linphone/api/c-chat-message.h +++ b/include/linphone/api/c-chat-message.h @@ -294,8 +294,6 @@ LINPHONE_PUBLIC void linphone_chat_message_cancel_file_transfer(LinphoneChatMess */ LINPHONE_PUBLIC void linphone_chat_message_resend(LinphoneChatMessage *msg); -LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc, const bctbx_list_t *addresses); - LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_peer_address(LinphoneChatMessage *msg); /** diff --git a/include/linphone/core.h b/include/linphone/core.h index e738629af..ebb981018 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -4822,6 +4822,15 @@ LINPHONE_PUBLIC void linphone_core_set_chat_database_path(LinphoneCore *lc, cons **/ LINPHONE_PUBLIC const char *linphone_core_get_chat_database_path(const LinphoneCore *lc); +/** + * Create a client-side group chat room. When calling this function the chat room is only created + * at the client-side and is empty. Pou need to call linphone_chat_room_add_participants() to + * create at the server side and add participants to it. + * @param[in] lc A #LinphoneCore object + * @return The newly created client-side group chat room. + */ +LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_client_group_chat_room(LinphoneCore *lc); + /** * Get a chat room whose peer is the supplied address. If it does not exist yet, it will be created. * No reference is transfered to the application. The LinphoneCore keeps a reference on the chat room. diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index 48eaee264..65f5c9b25 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -281,7 +281,7 @@ LinphoneChatRoom *linphone_chat_room_new (LinphoneCore *core, const LinphoneAddr return cr; } -LinphoneChatRoom *linphone_client_group_chat_room_new (LinphoneCore *core, const bctbx_list_t *addresses) { +LinphoneChatRoom *linphone_client_group_chat_room_new (LinphoneCore *core) { const char *factoryUri = linphone_core_get_chat_conference_factory_uri(core); if (!factoryUri) return nullptr; @@ -294,12 +294,10 @@ LinphoneChatRoom *linphone_client_group_chat_room_new (LinphoneCore *core, const if (from.empty()) from = linphone_core_get_primary_contact(core); LinphonePrivate::Address me(from); - std::list l = L_GET_CPP_LIST_OF_CPP_OBJ_FROM_C_LIST_OF_STRUCT_PTR(addresses, Address, Address); LinphoneChatRoom *cr = _linphone_ChatRoom_init(); - L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared(core, me, l)); + L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared(core, me)); linphone_core_notify_chat_room_instantiated(core, cr); L_GET_PRIVATE_FROM_C_OBJECT(cr)->setState(LinphonePrivate::ChatRoom::State::Instantiated); - L_GET_PRIVATE_FROM_C_OBJECT(cr)->setState(LinphonePrivate::ChatRoom::State::CreationPending); return cr; } diff --git a/src/chat/client-group-chat-room.cpp b/src/chat/client-group-chat-room.cpp index 9cd3592e0..b413930d9 100644 --- a/src/chat/client-group-chat-room.cpp +++ b/src/chat/client-group-chat-room.cpp @@ -31,15 +31,13 @@ ClientGroupChatRoomPrivate::ClientGroupChatRoomPrivate (LinphoneCore *core) : Ch // ============================================================================= -ClientGroupChatRoom::ClientGroupChatRoom (LinphoneCore *core, const Address &me, list
&addresses) +ClientGroupChatRoom::ClientGroupChatRoom (LinphoneCore *core, const Address &me) : ChatRoom(*new ChatRoomPrivate(core)), RemoteConference(core, me, nullptr) { string factoryUri = linphone_core_get_chat_conference_factory_uri(core); focus = make_shared(factoryUri); CallSessionParams csp; shared_ptr session = focus->getPrivate()->createSession(*this, &csp, false, this); session->configure(LinphoneCallOutgoing, nullptr, nullptr, me, focus->getAddress()); - session->initiateOutgoing(); - session->startInvite(nullptr); // TODO } @@ -52,24 +50,30 @@ shared_ptr ClientGroupChatRoom::addParticipant (const Address &addr } void ClientGroupChatRoom::addParticipants (const list
&addresses, const CallSessionParams *params, bool hasMedia) { + L_D(ClientGroupChatRoom); + if (d->state == ChatRoom::State::Instantiated) { + shared_ptr session = focus->getPrivate()->getSession(); + session->initiateOutgoing(); + session->startInvite(nullptr); + d->setState(ChatRoom::State::CreationPending); + } // TODO } bool ClientGroupChatRoom::canHandleParticipants () const { - return true; + return RemoteConference::canHandleParticipants(); } const string& ClientGroupChatRoom::getId () const { - return id; + return RemoteConference::getId(); } int ClientGroupChatRoom::getNbParticipants () const { - // TODO - return 1; + return RemoteConference::getNbParticipants(); } list> ClientGroupChatRoom::getParticipants () const { - return participants; + return RemoteConference::getParticipants(); } void ClientGroupChatRoom::removeParticipant (const shared_ptr &participant) { diff --git a/src/chat/client-group-chat-room.h b/src/chat/client-group-chat-room.h index 5dacb98f2..aa31265c4 100644 --- a/src/chat/client-group-chat-room.h +++ b/src/chat/client-group-chat-room.h @@ -35,7 +35,7 @@ class ClientGroupChatRoomPrivate; class ClientGroupChatRoom : public ChatRoom, public RemoteConference { public: - ClientGroupChatRoom (LinphoneCore *core, const Address &me, std::list
&addresses); + ClientGroupChatRoom (LinphoneCore *core, const Address &me); virtual ~ClientGroupChatRoom () = default; public: