Commit a38e2220 authored by Ghislain MARY's avatar Ghislain MARY

Separate client chat room instantiation and creation on the server when adding...

Separate client chat room instantiation and creation on the server when adding the first participants.
parent bb9c6de6
......@@ -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) {
......
......@@ -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);
......
......@@ -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);
/**
......
......@@ -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.
......
......@@ -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<LinphonePrivate::Address> 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<LinphonePrivate::ClientGroupChatRoom>(core, me, l));
L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared<LinphonePrivate::ClientGroupChatRoom>(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;
}
......
......@@ -31,15 +31,13 @@ ClientGroupChatRoomPrivate::ClientGroupChatRoomPrivate (LinphoneCore *core) : Ch
// =============================================================================
ClientGroupChatRoom::ClientGroupChatRoom (LinphoneCore *core, const Address &me, list<Address> &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<Participant>(factoryUri);
CallSessionParams csp;
shared_ptr<CallSession> 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<Participant> ClientGroupChatRoom::addParticipant (const Address &addr
}
void ClientGroupChatRoom::addParticipants (const list<Address> &addresses, const CallSessionParams *params, bool hasMedia) {
L_D(ClientGroupChatRoom);
if (d->state == ChatRoom::State::Instantiated) {
shared_ptr<CallSession> 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<shared_ptr<Participant>> ClientGroupChatRoom::getParticipants () const {
return participants;
return RemoteConference::getParticipants();
}
void ClientGroupChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
......
......@@ -35,7 +35,7 @@ class ClientGroupChatRoomPrivate;
class ClientGroupChatRoom : public ChatRoom, public RemoteConference {
public:
ClientGroupChatRoom (LinphoneCore *core, const Address &me, std::list<Address> &addresses);
ClientGroupChatRoom (LinphoneCore *core, const Address &me);
virtual ~ClientGroupChatRoom () = default;
public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment