mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-06 21:33:08 +00:00
add new api "linphone_core_interpret_url"
This commit is contained in:
parent
7593b0073c
commit
308b63c9ce
5 changed files with 45 additions and 44 deletions
|
|
@ -27,13 +27,13 @@
|
|||
|
||||
LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to){
|
||||
LinphoneAddress *parsed_url=NULL;
|
||||
char *route;
|
||||
if (linphone_core_interpret_url(lc,to,&parsed_url,&route)){
|
||||
|
||||
if ((parsed_url=linphone_core_interpret_url(lc,to))!=NULL){
|
||||
LinphoneChatRoom *cr=ms_new0(LinphoneChatRoom,1);
|
||||
cr->lc=lc;
|
||||
cr->peer=linphone_address_as_string(parsed_url);
|
||||
cr->peer_url=parsed_url;
|
||||
cr->route=route;
|
||||
cr->route=ms_strdup(linphone_core_get_route(lc));
|
||||
lc->chatrooms=ms_list_append(lc->chatrooms,(void *)cr);
|
||||
return cr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1678,32 +1678,25 @@ void linphone_core_iterate(LinphoneCore *lc){
|
|||
}
|
||||
|
||||
|
||||
bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, LinphoneAddress **real_parsed_url, char **route){
|
||||
LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url){
|
||||
enum_lookup_res_t *enumres=NULL;
|
||||
LinphoneAddress *parsed_url=NULL;
|
||||
char *enum_domain=NULL;
|
||||
LinphoneProxyConfig *proxy=lc->default_proxy;;
|
||||
char *tmpurl;
|
||||
const char *tmproute;
|
||||
LinphoneAddress *uri;
|
||||
|
||||
if (real_parsed_url!=NULL) *real_parsed_url=NULL;
|
||||
*route=NULL;
|
||||
tmproute=linphone_core_get_route(lc);
|
||||
|
||||
if (is_enum(url,&enum_domain)){
|
||||
lc->vtable.display_status(lc,_("Looking for telephone number destination..."));
|
||||
if (enum_lookup(enum_domain,&enumres)<0){
|
||||
lc->vtable.display_status(lc,_("Could not resolve this number."));
|
||||
ms_free(enum_domain);
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
ms_free(enum_domain);
|
||||
tmpurl=enumres->sip_address[0];
|
||||
if (real_parsed_url!=NULL) *real_parsed_url=linphone_address_new(tmpurl);
|
||||
uri=linphone_address_new(tmpurl);
|
||||
enum_lookup_res_free(enumres);
|
||||
if (tmproute) *route=ms_strdup(tmproute);
|
||||
return TRUE;
|
||||
return uri;
|
||||
}
|
||||
/* check if we have a "sip:" */
|
||||
if (strstr(url,"sip:")==NULL){
|
||||
|
|
@ -1714,8 +1707,7 @@ bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, LinphoneAd
|
|||
uri=linphone_address_new(tmpurl);
|
||||
ms_free(tmpurl);
|
||||
if (uri){
|
||||
if (real_parsed_url!=NULL) *real_parsed_url=uri;
|
||||
return TRUE;
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1725,31 +1717,24 @@ bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, LinphoneAd
|
|||
char normalized_username[128];
|
||||
uri=linphone_address_new(identity);
|
||||
if (uri==NULL){
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
linphone_address_set_display_name(uri,NULL);
|
||||
linphone_proxy_config_normalize_number(proxy,url,normalized_username,
|
||||
sizeof(normalized_username));
|
||||
linphone_address_set_username(uri,normalized_username);
|
||||
|
||||
if (real_parsed_url!=NULL) *real_parsed_url=uri;
|
||||
if (tmproute) *route=ms_strdup(tmproute);
|
||||
return TRUE;
|
||||
}else return FALSE;
|
||||
return uri;
|
||||
}else return NULL;
|
||||
}
|
||||
parsed_url=linphone_address_new(url);
|
||||
if (parsed_url!=NULL){
|
||||
if (real_parsed_url!=NULL) *real_parsed_url=parsed_url;
|
||||
else linphone_address_destroy(parsed_url);
|
||||
if (tmproute) *route=ms_strdup(tmproute);
|
||||
|
||||
return TRUE;
|
||||
uri=linphone_address_new(url);
|
||||
if (uri!=NULL){
|
||||
return uri;
|
||||
}
|
||||
/* else we could not do anything with url given by user, so display an error */
|
||||
if (lc->vtable.display_warning!=NULL){
|
||||
lc->vtable.display_warning(lc,_("Could not parse given sip address. A sip url usually looks like sip:user@domain"));
|
||||
}
|
||||
return FALSE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1890,16 +1875,32 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphonePro
|
|||
*
|
||||
* @ingroup call_control
|
||||
* @param lc the LinphoneCore object
|
||||
* @param url the destination of the call (sip address, or phone number).
|
||||
**/
|
||||
int linphone_core_invite(LinphoneCore *lc, const char *url){
|
||||
LinphoneAddress *addr=linphone_core_interpret_url(lc,url);
|
||||
if (addr){
|
||||
int err=linphone_core_invite_address(lc,addr);
|
||||
linphone_address_destroy(addr);
|
||||
return err;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates an outgoing call given a destination LinphoneAddress
|
||||
*
|
||||
* @ingroup call_control
|
||||
* @param lc the LinphoneCore object
|
||||
* @param url the destination of the call (sip address).
|
||||
**/
|
||||
int linphone_core_invite(LinphoneCore *lc, const char *url)
|
||||
int linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *real_parsed_url)
|
||||
{
|
||||
int err=0;
|
||||
char *route=NULL;
|
||||
const char *route=NULL;
|
||||
const char *from=NULL;
|
||||
LinphoneProxyConfig *proxy=NULL;
|
||||
LinphoneAddress *parsed_url2=NULL;
|
||||
LinphoneAddress *real_parsed_url=NULL;
|
||||
char *real_url=NULL;
|
||||
LinphoneProxyConfig *dest_proxy=NULL;
|
||||
LinphoneCall *call;
|
||||
|
|
@ -1910,9 +1911,8 @@ int linphone_core_invite(LinphoneCore *lc, const char *url)
|
|||
}
|
||||
|
||||
linphone_core_get_default_proxy(lc,&proxy);
|
||||
if (!linphone_core_interpret_url(lc,url,&real_parsed_url,&route)){
|
||||
return -1;
|
||||
}
|
||||
route=linphone_core_get_route(lc);
|
||||
|
||||
real_url=linphone_address_as_string(real_parsed_url);
|
||||
dest_proxy=linphone_core_lookup_known_proxy(lc,real_parsed_url);
|
||||
|
||||
|
|
@ -1931,7 +1931,7 @@ int linphone_core_invite(LinphoneCore *lc, const char *url)
|
|||
|
||||
parsed_url2=linphone_address_new(from);
|
||||
|
||||
call=linphone_call_new_outgoing(lc,parsed_url2,real_parsed_url);
|
||||
call=linphone_call_new_outgoing(lc,parsed_url2,linphone_address_clone(real_parsed_url));
|
||||
sal_op_set_route(call->op,route);
|
||||
|
||||
lc->call=call;
|
||||
|
|
@ -1946,21 +1946,19 @@ int linphone_core_invite(LinphoneCore *lc, const char *url)
|
|||
}
|
||||
|
||||
if (real_url!=NULL) ms_free(real_url);
|
||||
if (route!=NULL) ms_free(route);
|
||||
return err;
|
||||
}
|
||||
|
||||
int linphone_core_refer(LinphoneCore *lc, const char *url)
|
||||
{
|
||||
char *real_url=NULL;
|
||||
LinphoneAddress *real_parsed_url=NULL;
|
||||
LinphoneAddress *real_parsed_url=linphone_core_interpret_url(lc,url);
|
||||
LinphoneCall *call;
|
||||
char *route;
|
||||
if (!linphone_core_interpret_url(lc,url,&real_parsed_url, &route)){
|
||||
|
||||
if (!real_parsed_url){
|
||||
/* bad url */
|
||||
return -1;
|
||||
}
|
||||
if (route!=NULL) ms_free(route);
|
||||
call=lc->call;
|
||||
if (call==NULL){
|
||||
ms_warning("No established call to refer.");
|
||||
|
|
|
|||
|
|
@ -467,8 +467,12 @@ LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
|
|||
/* function to be periodically called in a main loop */
|
||||
void linphone_core_iterate(LinphoneCore *lc);
|
||||
|
||||
LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url);
|
||||
|
||||
int linphone_core_invite(LinphoneCore *lc, const char *url);
|
||||
|
||||
int linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr);
|
||||
|
||||
int linphone_core_refer(LinphoneCore *lc, const char *url);
|
||||
|
||||
bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ void linphone_core_start_media_streams(LinphoneCore *lc, struct _LinphoneCall *c
|
|||
void linphone_core_stop_media_streams(LinphoneCore *lc, struct _LinphoneCall *call);
|
||||
const char * linphone_core_get_identity(LinphoneCore *lc);
|
||||
const char * linphone_core_get_route(LinphoneCore *lc);
|
||||
bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, LinphoneAddress **real_parsed_url, char **route);
|
||||
void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose);
|
||||
void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses);
|
||||
void linphone_core_stop_waiting(LinphoneCore *lc);
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ int sal_notify_close(SalOp *op){
|
|||
if (identity==NULL) identity=sal_op_get_to(op);
|
||||
osip_message_set_contact(msg,identity);
|
||||
eXosip_insubscription_send_request(op->did,msg);
|
||||
}else ms_error("could not create notify for incoming subscription.");
|
||||
}else ms_error("sal_notify_close(): could not create notify for incoming subscription.");
|
||||
eXosip_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue