Commit 95c39b0e authored by Ghislain MARY's avatar Ghislain MARY

Configure the conference factory uri on the proxy config instead of the core.

parent 59a66ca7
......@@ -5812,20 +5812,6 @@ void sip_config_uninit(LinphoneCore *lc)
}
if (i>=20) ms_warning("Cannot complete unregistration, giving up");
}
elem = config->proxies;
config->proxies=NULL; /*to make sure proxies cannot be refferenced during deletion*/
bctbx_list_free_with_data(elem,(void (*)(void*)) _linphone_proxy_config_release);
config->deleted_proxies=bctbx_list_free_with_data(config->deleted_proxies,(void (*)(void*)) _linphone_proxy_config_release);
/*no longuer need to write proxy config if not changedlinphone_proxy_config_write_to_config_file(lc->config,NULL,i);*/ /*mark the end */
lc->auth_info=bctbx_list_free_with_data(lc->auth_info,(void (*)(void*))linphone_auth_info_unref);
if (lc->vcard_context) {
linphone_vcard_context_destroy(lc->vcard_context);
}
lc->sal->reset_transports();
lc->sal->unlisten_ports(); /*to make sure no new messages are received*/
if (lc->http_provider) {
......@@ -5850,6 +5836,20 @@ void sip_config_uninit(LinphoneCore *lc)
delete lc->sal;
lc->sal=NULL;
elem = config->proxies;
config->proxies=NULL; /*to make sure proxies cannot be refferenced during deletion*/
bctbx_list_free_with_data(elem,(void (*)(void*)) _linphone_proxy_config_release);
config->deleted_proxies=bctbx_list_free_with_data(config->deleted_proxies,(void (*)(void*)) _linphone_proxy_config_release);
/*no longuer need to write proxy config if not changedlinphone_proxy_config_write_to_config_file(lc->config,NULL,i);*/ /*mark the end */
lc->auth_info=bctbx_list_free_with_data(lc->auth_info,(void (*)(void*))linphone_auth_info_unref);
if (lc->vcard_context) {
linphone_vcard_context_destroy(lc->vcard_context);
}
if (lc->sip_conf.guessed_contact)
ms_free(lc->sip_conf.guessed_contact);
if (config->contact)
......@@ -7042,20 +7042,15 @@ LinphoneConference *linphone_core_get_conference(LinphoneCore *lc) {
return lc->conf_ctx;
}
void linphone_core_set_conference_factory_uri(LinphoneCore *lc, const char *uri) {
lp_config_set_string(linphone_core_get_config(lc), "misc", "conference_factory_uri", uri);
}
const char * linphone_core_get_conference_factory_uri(const LinphoneCore *lc) {
return lp_config_get_string(linphone_core_get_config(lc), "misc", "conference_factory_uri", nullptr);
}
void linphone_core_enable_conference_server (LinphoneCore *lc, bool_t enable) {
lp_config_set_int(linphone_core_get_config(lc), "misc", "conference_server_enabled", enable);
}
bool_t _linphone_core_is_conference_creation (const LinphoneCore *lc, const LinphoneAddress *addr) {
const char *uri = linphone_core_get_conference_factory_uri(lc);
LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(lc);
if (!proxy)
return FALSE;
const char *uri = linphone_proxy_config_get_conference_factory_uri(proxy);
if (!uri)
return FALSE;
......
......@@ -907,7 +907,10 @@ void linphone_core_report_call_log(LinphoneCore *lc, LinphoneCallLog *call_log){
// TODO: This is a workaround that has to be removed ASAP
// Do not add calls made to the conference factory in the history
const char *conference_factory_uri = linphone_core_get_conference_factory_uri(lc);
const char *conference_factory_uri = nullptr;
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(lc, call_log->to);
if (proxy)
conference_factory_uri = linphone_proxy_config_get_conference_factory_uri(proxy);
if (conference_factory_uri) {
LinphoneAddress *conference_factory_addr = linphone_address_new(conference_factory_uri);
if (linphone_address_weak_equal(call_log->to, conference_factory_addr)) {
......
......@@ -131,6 +131,7 @@ struct _LinphoneProxyConfig
char *refkey;
char *sip_etag; /*publish context*/
char *conference_factory_uri;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneProxyConfig);
......
......@@ -249,6 +249,8 @@ void _linphone_proxy_config_destroy(LinphoneProxyConfig *cfg){
if (cfg->nat_policy != NULL) {
linphone_nat_policy_unref(cfg->nat_policy);
}
if (cfg->conference_factory_uri)
bctbx_free(cfg->conference_factory_uri);
if (cfg->ei){
linphone_error_info_unref(cfg->ei);
}
......@@ -1089,7 +1091,7 @@ int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **conf
return linphone_core_get_default_proxy_config_index(lc);
}
LinphoneProxyConfig * linphone_core_get_default_proxy_config(LinphoneCore *lc) {
LinphoneProxyConfig * linphone_core_get_default_proxy_config(const LinphoneCore *lc) {
return lc->default_proxy;
}
......@@ -1147,6 +1149,8 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC
lp_config_set_string(config, key, "nat_policy_ref", cfg->nat_policy->ref);
linphone_nat_policy_save_to_config(cfg->nat_policy);
}
lp_config_set_string(config, key, "conference_factory_uri", cfg->conference_factory_uri);
}
......@@ -1213,6 +1217,8 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore* lc
cfg->nat_policy = linphone_core_create_nat_policy_from_config(lc, nat_policy_ref);
}
CONFIGURE_STRING_VALUE(cfg, config, key, conference_factory_uri, "conference_factory_uri");
return cfg;
}
......@@ -1495,3 +1501,16 @@ void linphone_proxy_config_notify_publish_state_changed(LinphoneProxyConfig *cfg
cfg->presence_publish_event = NULL;
}
}
void linphone_proxy_config_set_conference_factory_uri(LinphoneProxyConfig *cfg, const char *uri) {
if (cfg->conference_factory_uri) {
bctbx_free(cfg->conference_factory_uri);
cfg->conference_factory_uri = nullptr;
}
if (uri)
cfg->conference_factory_uri = bctbx_strdup(uri);
}
const char * linphone_proxy_config_get_conference_factory_uri(const LinphoneProxyConfig *cfg) {
return cfg->conference_factory_uri;
}
......@@ -477,14 +477,6 @@ LINPHONE_PUBLIC void linphone_chat_room_add_compatible_participants (LinphoneCha
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED LinphoneCore* linphone_chat_room_get_lc(const LinphoneChatRoom *cr);
/**
* Destroy a LinphoneChatRoom.
* @param cr #LinphoneChatRoom object
* @deprecated Use linphone_chat_room_unref() instead.
* @donotwrap
*/
LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_chat_room_destroy(LinphoneChatRoom *cr);
/**
* @}
*/
......
......@@ -2017,7 +2017,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED int linphone_core_get_default_proxy(Linphone
* @param[in] lc LinphoneCore object
* @return The default proxy configuration.
**/
LINPHONE_PUBLIC LinphoneProxyConfig * linphone_core_get_default_proxy_config(LinphoneCore *lc);
LINPHONE_PUBLIC LinphoneProxyConfig * linphone_core_get_default_proxy_config(const LinphoneCore *lc);
/**
* Sets the default proxy.
......@@ -4252,20 +4252,6 @@ LINPHONE_PUBLIC LinphoneStatus linphone_core_stop_conference_recording(LinphoneC
*/
LINPHONE_PUBLIC LinphoneConference *linphone_core_get_conference(LinphoneCore *lc);
/**
* Set the conference factory uri.
* @param[in] lc A #LinphoneCore object
* @param[in] uri The uri of the conference factory
*/
void linphone_core_set_conference_factory_uri(LinphoneCore *lc, const char *uri);
/**
* Get the conference factory uri.
* @param[in] lc A #LinphoneCore object
* @return The uri of the conference factory
*/
const char * linphone_core_get_conference_factory_uri(const LinphoneCore *lc);
/**
* Enable the conference server feature. This has the effect to listen of the conference factory uri
* to create new conferences when receiving INVITE messages there.
......
......@@ -585,6 +585,20 @@ LINPHONE_PUBLIC LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const L
*/
LINPHONE_PUBLIC void linphone_proxy_config_set_nat_policy(LinphoneProxyConfig *cfg, LinphoneNatPolicy *policy);
/**
* Set the conference factory uri.
* @param[in] cfg A #LinphoneProxyConfig object
* @param[in] uri The uri of the conference factory
*/
void linphone_proxy_config_set_conference_factory_uri(LinphoneProxyConfig *cfg, const char *uri);
/**
* Get the conference factory uri.
* @param[in] cfg A #LinphoneProxyConfig object
* @return The uri of the conference factory
*/
const char * linphone_proxy_config_get_conference_factory_uri(const LinphoneProxyConfig *cfg);
/**
* @}
*/
......
......@@ -527,10 +527,20 @@ void linphone_chat_room_set_user_data (LinphoneChatRoom *cr, void *ud) {
// =============================================================================
LinphoneChatRoom *_linphone_client_group_chat_room_new (LinphoneCore *core, const char *uri, const char *subject, bool_t fallback) {
LinphoneAddress *addr = linphone_address_new(uri);
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(core, addr);
linphone_address_unref(addr);
string from;
LinphoneProxyConfig *proxy = nullptr;
if (uri) {
LinphoneAddress *addr = linphone_address_new(uri);
proxy = linphone_core_lookup_known_proxy(core, addr);
linphone_address_unref(addr);
} else {
proxy = linphone_core_get_default_proxy_config(core);
if (!proxy)
return nullptr;
uri = linphone_proxy_config_get_conference_factory_uri(proxy);
if (!uri)
return nullptr;
}
if (proxy) {
const LinphoneAddress *contactAddr = linphone_proxy_config_get_contact(proxy);
if (contactAddr) {
......@@ -569,8 +579,3 @@ LinphoneChatRoom *_linphone_server_group_chat_room_new (LinphoneCore *core, Linp
L_GET_PRIVATE_FROM_C_OBJECT(cr, ServerGroupChatRoom)->confirmCreation();
return cr;
}
/* DEPRECATED */
void linphone_chat_room_destroy (LinphoneChatRoom *cr) {
linphone_chat_room_unref(cr);
}
......@@ -53,10 +53,19 @@ public:
}
void sendChatMessage (const shared_ptr<ChatMessage> &chatMessage) override {
L_Q();
ProxyChatRoomPrivate::sendChatMessage(chatMessage);
const char *specs = linphone_core_get_linphone_specs(chatMessage->getCore()->getCCore());
time_t currentRealTime = ms_time(nullptr);
if (!linphone_core_get_conference_factory_uri(chatMessage->getCore()->getCCore())
LinphoneAddress *lAddr = linphone_address_new(
chatMessage->getChatRoom()->getChatRoomId().getLocalAddress().asString().c_str()
);
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(q->getCore()->getCCore(), lAddr);
linphone_address_unref(lAddr);
const char *conferenceFactoryUri = nullptr;
if (proxy)
conferenceFactoryUri = linphone_proxy_config_get_conference_factory_uri(proxy);
if (!conferenceFactoryUri
|| (chatRoom->getCapabilities() & ChatRoom::Capabilities::Conference)
|| clientGroupChatRoom
|| !specs || !strstr(specs, "groupchat")
......
......@@ -74,9 +74,15 @@ shared_ptr<AbstractChatRoom> CorePrivate::createBasicChatRoom (
chatRoom.reset(new RealTimeTextChatRoom(q->getSharedFromThis(), chatRoomId));
else {
BasicChatRoom *basicChatRoom = new BasicChatRoom(q->getSharedFromThis(), chatRoomId);
LinphoneAddress *lAddr = linphone_address_new(chatRoomId.getLocalAddress().asString().c_str());
LinphoneProxyConfig *proxy = linphone_core_lookup_known_proxy(q->getCCore(), lAddr);
linphone_address_unref(lAddr);
const char *conferenceFactoryUri = nullptr;
if (proxy)
conferenceFactoryUri = linphone_proxy_config_get_conference_factory_uri(proxy);
if (
capabilities & ChatRoom::Capabilities::Migratable &&
linphone_core_get_conference_factory_uri(q->getCCore()) &&
conferenceFactoryUri &&
linphone_config_get_bool(linphone_core_get_config(q->getCCore()),
"misc", "enable_basic_to_client_group_chat_room_migration", FALSE)
)
......@@ -94,14 +100,13 @@ shared_ptr<AbstractChatRoom> CorePrivate::createBasicChatRoom (
shared_ptr<AbstractChatRoom> CorePrivate::createClientGroupChatRoom (const string &subject, bool fallback) {
L_Q();
return L_GET_CPP_PTR_FROM_C_OBJECT(
_linphone_client_group_chat_room_new(
q->getCCore(),
linphone_core_get_conference_factory_uri(q->getCCore()),
L_STRING_TO_C(subject),
fallback ? TRUE : FALSE
)
LinphoneChatRoom *lcr = _linphone_client_group_chat_room_new(
q->getCCore(),
nullptr,
L_STRING_TO_C(subject),
fallback ? TRUE : FALSE
);
return lcr ? L_GET_CPP_PTR_FROM_C_OBJECT(lcr) : nullptr;
}
void CorePrivate::insertChatRoom (const shared_ptr<AbstractChatRoom> &chatRoom) {
......
......@@ -133,7 +133,8 @@ static void configure_core_for_conference (LinphoneCore *core, const char* usern
bctbx_free(newIdentity);
linphone_core_enable_conference_server(core, server);
char *factoryUri = linphone_address_as_string(factoryAddr);
linphone_core_set_conference_factory_uri(core, factoryUri);
LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(core);
linphone_proxy_config_set_conference_factory_uri(proxy, factoryUri);
bctbx_free(factoryUri);
linphone_core_set_linphone_specs(core, "groupchat");
}
......@@ -2264,11 +2265,12 @@ static void group_chat_room_migrate_from_basic_chat_room (void) {
// Enable chat room migration and restart core for Marie
_linphone_chat_room_enable_migration(marieCr, TRUE);
coresList = bctbx_list_remove(coresList, marie->lc);
linphone_core_manager_restart(marie, TRUE);
linphone_core_manager_reinit(marie);
bctbx_list_t *tmpCoresManagerList = bctbx_list_append(NULL, marie);
init_core_for_conference(tmpCoresManagerList);
bctbx_list_free(tmpCoresManagerList);
coresList = bctbx_list_append(coresList, marie->lc);
linphone_core_manager_start(marie, TRUE);
// Send a new message to initiate chat room migration
marieCr = linphone_core_get_chat_room(marie->lc, paulineAddr);
......@@ -2364,11 +2366,12 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) {
// Enable chat room migration and restart core for Marie
_linphone_chat_room_enable_migration(marieCr, TRUE);
coresList = bctbx_list_remove(coresList, marie->lc);
linphone_core_manager_restart(marie, TRUE);
linphone_core_manager_reinit(marie);
bctbx_list_t *tmpCoresManagerList = bctbx_list_append(NULL, marie);
init_core_for_conference(tmpCoresManagerList);
bctbx_list_free(tmpCoresManagerList);
coresList = bctbx_list_append(coresList, marie->lc);
linphone_core_manager_start(marie, TRUE);
// Send a new message to initiate chat room migration
LinphoneAddress *paulineAddr = linphone_address_new(linphone_core_get_identity(pauline->lc));
......
......@@ -28,7 +28,6 @@ pol=accept
subscribe=0
[misc]
conference_factory_uri=sip:conference-factory@conf.example.org
enable_basic_to_client_group_chat_room_migration=1
basic_to_client_group_chat_room_migration_timer=10
......
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