Commit 60aee12e authored by Ghislain MARY's avatar Ghislain MARY

Fix linphone_core_get_chat_room() that was not creating the chat room if it did not exist yet.

parent bb673bb9
...@@ -268,18 +268,21 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneChatRoom, belle_sip_object_t, ...@@ -268,18 +268,21 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneChatRoom, belle_sip_object_t,
FALSE FALSE
); );
static LinphoneChatRoom * _linphone_core_create_chat_room(LinphoneCore *lc, const char *to){ static LinphoneChatRoom * _linphone_core_create_chat_room(LinphoneCore *lc, LinphoneAddress *addr) {
LinphoneAddress *parsed_url=NULL; LinphoneChatRoom *cr = belle_sip_object_new(LinphoneChatRoom);
cr->lc = lc;
if ((parsed_url=linphone_core_interpret_url(lc,to))!=NULL){ cr->peer = linphone_address_as_string(addr);
LinphoneChatRoom *cr=belle_sip_object_new(LinphoneChatRoom); cr->peer_url = addr;
cr->lc=lc; lc->chatrooms = ms_list_append(lc->chatrooms, (void *)cr);
cr->peer=linphone_address_as_string(parsed_url); return cr;
cr->peer_url=parsed_url; }
lc->chatrooms=ms_list_append(lc->chatrooms,(void *)cr);
return cr; static LinphoneChatRoom * _linphone_core_create_chat_room_from_url(LinphoneCore *lc, const char *to) {
} LinphoneAddress *parsed_url = NULL;
return NULL; if ((parsed_url = linphone_core_interpret_url(lc, to)) != NULL) {
return _linphone_core_create_chat_room(lc, parsed_url);
}
return NULL;
} }
LinphoneChatRoom * _linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAddress *addr){ LinphoneChatRoom * _linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAddress *addr){
...@@ -306,7 +309,7 @@ static LinphoneChatRoom * _linphone_core_get_or_create_chat_room(LinphoneCore* l ...@@ -306,7 +309,7 @@ static LinphoneChatRoom * _linphone_core_get_or_create_chat_room(LinphoneCore* l
ret=_linphone_core_get_chat_room(lc,to_addr); ret=_linphone_core_get_chat_room(lc,to_addr);
linphone_address_destroy(to_addr); linphone_address_destroy(to_addr);
if (!ret){ if (!ret){
ret=_linphone_core_create_chat_room(lc,to); ret=_linphone_core_create_chat_room_from_url(lc,to);
} }
return ret; return ret;
} }
...@@ -339,8 +342,12 @@ LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char * ...@@ -339,8 +342,12 @@ LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *
* @param addr a linphone address. * @param addr a linphone address.
* @returns #LinphoneChatRoom where messaging can take place. * @returns #LinphoneChatRoom where messaging can take place.
**/ **/
LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAddress *addr){ LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, LinphoneAddress *addr){
return _linphone_core_get_chat_room(lc, addr); LinphoneChatRoom *ret = _linphone_core_get_chat_room(lc, addr);
if (!ret) {
ret = _linphone_core_create_chat_room(lc, addr);
}
return ret;
} }
/** /**
......
...@@ -1374,7 +1374,7 @@ typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,Linph ...@@ -1374,7 +1374,7 @@ typedef void (*LinphoneChatMessageStateChangedCb)(LinphoneChatMessage* msg,Linph
LINPHONE_PUBLIC void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path); LINPHONE_PUBLIC void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path);
LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to); LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to);
LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_get_or_create_chat_room(LinphoneCore *lc, const char *to); LINPHONE_PUBLIC LinphoneChatRoom * linphone_core_get_or_create_chat_room(LinphoneCore *lc, const char *to);
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAddress *addr); LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, LinphoneAddress *addr);
LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const char *to); LINPHONE_PUBLIC LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const char *to);
LINPHONE_PUBLIC void linphone_core_disable_chat(LinphoneCore *lc, LinphoneReason deny_reason); LINPHONE_PUBLIC void linphone_core_disable_chat(LinphoneCore *lc, LinphoneReason deny_reason);
LINPHONE_PUBLIC void linphone_core_enable_chat(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_enable_chat(LinphoneCore *lc);
......
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