Commit 71db9280 authored by smorlat's avatar smorlat

abstract address and uris directly in liblinphone api.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@769 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent d82234aa
......@@ -1249,12 +1249,13 @@ linphonec_proxy_use(LinphoneCore *lc, int index)
static void
linphonec_friend_display(LinphoneFriend *fr)
{
char *name = linphone_friend_get_name(fr);
char *addr = linphone_friend_get_addr(fr);
//char *url = linphone_friend_get_url(fr);
linphonec_out("name: %s\n", name);
linphonec_out("address: %s\n", addr);
LinphoneUri *uri=linphone_uri_clone(linphone_friend_get_uri(fr));
char *str;
linphonec_out("name: %s\n", linphone_uri_get_display_name(uri));
linphone_uri_set_display_name(uri,NULL);
str=linphone_uri_as_string(uri);
linphonec_out("address: %s\n", str);
}
static int
......@@ -1272,8 +1273,9 @@ linphonec_friend_list(LinphoneCore *lc, char *pat)
for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n )
{
if ( pat ) {
char *name = linphone_friend_get_name(friend->data);
if ( ! strstr(name, pat) ) continue;
const char *name = linphone_uri_get_display_name(
linphone_friend_get_uri((LinphoneFriend*)friend->data));
if (name && ! strstr(name, pat) ) continue;
}
linphonec_out("****** Friend %i *******\n",n);
linphonec_friend_display((LinphoneFriend*)friend->data);
......@@ -1293,8 +1295,11 @@ linphonec_friend_call(LinphoneCore *lc, unsigned int num)
{
if ( n == num )
{
addr = linphone_friend_get_addr(friend->data);
return lpc_cmd_call(lc, addr);
int ret;
addr = linphone_uri_as_string(linphone_friend_get_uri((LinphoneFriend*)friend->data));
ret=lpc_cmd_call(lc, addr);
ms_free(addr);
return ret;
}
}
linphonec_out("No such friend %u\n", num);
......
......@@ -27,13 +27,12 @@
#include <eXosip2/eXosip.h>
LinphoneChatRoom * linphone_core_create_chat_room(LinphoneCore *lc, const char *to){
char *real_url=NULL;
osip_from_t *parsed_url=NULL;
LinphoneUri *parsed_url=NULL;
char *route;
if (linphone_core_interpret_url(lc,to,&real_url,&parsed_url,&route)){
if (linphone_core_interpret_url(lc,to,&parsed_url,&route)){
LinphoneChatRoom *cr=ms_new0(LinphoneChatRoom,1);
cr->lc=lc;
cr->peer=real_url;
cr->peer=linphone_uri_as_string(parsed_url);
cr->peer_url=parsed_url;
cr->route=route;
lc->chatrooms=ms_list_append(lc->chatrooms,(void *)cr);
......@@ -46,7 +45,7 @@
void linphone_chat_room_destroy(LinphoneChatRoom *cr){
LinphoneCore *lc=cr->lc;
lc->chatrooms=ms_list_remove(lc->chatrooms,(void *) cr);
osip_from_free(cr->peer_url);
linphone_uri_destroy(cr->peer_url);
ms_free(cr->peer);
ms_free(cr->route);
}
......@@ -60,9 +59,9 @@ void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg){
eXosip_message_send_request(sip);
}
bool_t linphone_chat_room_matches(LinphoneChatRoom *cr, osip_from_t *from){
if (cr->peer_url->url->username && from->url->username &&
strcmp(cr->peer_url->url->username,from->url->username)==0) return TRUE;
bool_t linphone_chat_room_matches(LinphoneChatRoom *cr, const LinphoneUri *from){
if (linphone_uri_get_username(cr->peer_url) && linphone_uri_get_username(from) &&
strcmp(linphone_uri_get_username(cr->peer_url),linphone_uri_get_username(from))==0) return TRUE;
return FALSE;
}
......@@ -74,9 +73,10 @@ void linphone_core_text_received(LinphoneCore *lc, eXosip_event_t *ev){
MSList *elem;
const char *msg;
LinphoneChatRoom *cr=NULL;
char *cleanfrom;
char *from;
osip_from_t *from_url=ev->request->from;
osip_body_t *body=NULL;
LinphoneUri *uri;
osip_message_get_body(ev->request,0,&body);
if (body==NULL){
......@@ -84,20 +84,25 @@ void linphone_core_text_received(LinphoneCore *lc, eXosip_event_t *ev){
return;
}
msg=body->body;
from_2char_without_params(from_url,&cleanfrom);
osip_from_to_str(from_url,&from);
uri=linphone_uri_new(from);
osip_free(from);
linphone_uri_clean(uri);
for(elem=lc->chatrooms;elem!=NULL;elem=ms_list_next(elem)){
cr=(LinphoneChatRoom*)elem->data;
if (linphone_chat_room_matches(cr,from_url)){
if (linphone_chat_room_matches(cr,uri)){
break;
}
cr=NULL;
}
from=linphone_uri_as_string(uri);
if (cr==NULL){
/* create a new chat room */
cr=linphone_core_create_chat_room(lc,cleanfrom);
cr=linphone_core_create_chat_room(lc,from);
}
linphone_chat_room_text_received(cr,lc,cleanfrom,msg);
osip_free(cleanfrom);
linphone_uri_destroy(uri);
linphone_chat_room_text_received(cr,lc,from,msg);
ms_free(from);
}
......
......@@ -321,7 +321,7 @@ int linphone_inc_new_call(LinphoneCore *lc, eXosip_event_t *ev)
eXosip_unlock();
goto end;
}
lc->call=linphone_call_new_incoming(lc,from,to,ev);
lc->call=linphone_call_new_incoming(lc,linphone_uri_new(from),linphone_uri_new(to),ev);
sdp=eXosip_get_sdp_info(ev->request);
if (sdp==NULL){
......
......@@ -77,19 +77,19 @@ const char *linphone_online_status_to_string(LinphoneOnlineStatus ss){
}
static int friend_data_compare(const void * a, const void * b, void * data){
osip_from_t *fa=((LinphoneFriend*)a)->url;
osip_from_t *fb=((LinphoneFriend*)b)->url;
char *ua,*ub;
ua=fa->url->username;
ub=fb->url->username;
LinphoneUri *fa=((LinphoneFriend*)a)->uri;
LinphoneUri *fb=((LinphoneFriend*)b)->uri;
const char *ua,*ub;
ua=linphone_uri_get_username(fa);
ub=linphone_uri_get_username(fb);
if (ua!=NULL && ub!=NULL) {
//printf("Comparing usernames %s,%s\n",ua,ub);
return strcasecmp(ua,ub);
}
else {
/* compare hosts*/
ua=fa->url->host;
ub=fb->url->host;
ua=linphone_uri_get_domain(fa);
ub=linphone_uri_get_domain(fb);
if (ua!=NULL && ub!=NULL){
int ret=strcasecmp(ua,ub);
//printf("Comparing hostnames %s,%s,res=%i\n",ua,ub,ret);
......@@ -104,11 +104,11 @@ static int friend_compare(const void * a, const void * b){
}
MSList *find_friend(MSList *fl, const osip_from_t *friend, LinphoneFriend **lf){
MSList *linphone_find_friend(MSList *fl, const LinphoneUri *friend, LinphoneFriend **lf){
MSList *res=NULL;
LinphoneFriend dummy;
if (lf!=NULL) *lf=NULL;
dummy.url=(osip_from_t*)friend;
dummy.uri=(LinphoneUri*)friend;
res=ms_list_find_custom(fl,friend_compare,&dummy);
if (lf!=NULL && res!=NULL) *lf=(LinphoneFriend*)res->data;
return res;
......@@ -137,7 +137,7 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){
const char *route=NULL;
const char *from=NULL;
osip_message_t *msg=NULL;
osip_from_to_str(fr->url,&friend);
friend=linphone_uri_as_string(fr->uri);
if (fr->proxy!=NULL){
route=fr->proxy->reg_route;
from=fr->proxy->reg_identity;
......@@ -150,7 +150,7 @@ void __linphone_friend_do_subscribe(LinphoneFriend *fr){
eXosip_subscribe_build_initial_request(&msg,friend,from,route,"presence",600);
eXosip_subscribe_send_initial_request(msg);
eXosip_unlock();
osip_free(friend);
ms_free(friend);
}
......@@ -176,63 +176,56 @@ LinphoneFriend *linphone_friend_new_with_addr(const char *addr){
}
void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result){
int err;
osip_from_t *fr=NULL;
osip_from_init(&fr);
err=osip_from_parse(fr,uri);
if (err<0){
LinphoneUri *fr=NULL;
*result=NULL;
fr=linphone_uri_new(uri);
if (fr==NULL){
char *tmp=NULL;
if (strchr(uri,'@')!=NULL){
LinphoneUri *u;
/*try adding sip:*/
tmp=ms_strdup_printf("sip:%s",uri);
u=linphone_uri_new(tmp);
if (u!=NULL){
*result=tmp;
}
}else if (lc->default_proxy!=NULL){
/*try adding domain part from default current proxy*/
osip_from_t *id=NULL;
osip_from_init(&id);
if (osip_from_parse(id,linphone_core_get_identity(lc))==0){
if (id->url->port!=NULL && strlen(id->url->port)>0)
tmp=ms_strdup_printf("sip:%s@%s:%s",uri,id->url->host,id->url->port);
else tmp=ms_strdup_printf("sip:%s@%s",uri,id->url->host);
LinphoneUri * id=linphone_uri_new(linphone_core_get_identity(lc));
if (id!=NULL){
linphone_uri_set_username(id,uri);
*result=linphone_uri_as_string(id);
linphone_uri_destroy(id);
}
osip_from_free(id);
}
if (osip_from_parse(fr,tmp)==0){
if (*result){
/*looks good */
ms_message("%s interpreted as %s",uri,tmp);
*result=tmp;
}else *result=NULL;
}else *result=ms_strdup(uri);
osip_from_free(fr);
ms_message("%s interpreted as %s",uri,*result);
}else{
ms_warning("Fail to interpret friend uri %s",uri);
}
}else *result=linphone_uri_as_string(fr);
linphone_uri_destroy(fr);
}
int linphone_friend_set_sip_addr(LinphoneFriend *lf, const char *addr){
int err;
osip_from_t *fr=NULL;
osip_from_init(&fr);
err=osip_from_parse(fr,addr);
if (err<0) {
LinphoneUri *fr=linphone_uri_new(addr);
if (fr==NULL) {
ms_warning("Invalid friend sip uri: %s",addr);
osip_from_free(fr);
return -1;
}
if (lf->url!=NULL) osip_from_free(lf->url);
lf->url=fr;
if (lf->uri!=NULL) linphone_uri_destroy(lf->uri);
lf->uri=fr;
return 0;
}
int linphone_friend_set_name(LinphoneFriend *lf, const char *name){
osip_from_t *fr=lf->url;
LinphoneUri *fr=lf->uri;
if (fr==NULL){
ms_error("linphone_friend_set_sip_addr() must be called before linphone_friend_set_name().");
return -1;
}
if (fr->displayname!=NULL){
osip_free(fr->displayname);
fr->displayname=NULL;
}
if (name && name[0]!='\0'){
fr->displayname=osip_strdup(name);
}
linphone_uri_set_display_name(fr,name);
return 0;
}
......@@ -560,7 +553,7 @@ static void linphone_friend_unsubscribe(LinphoneFriend *lf){
void linphone_friend_destroy(LinphoneFriend *lf){
linphone_friend_notify(lf,EXOSIP_SUBCRSTATE_TERMINATED,LINPHONE_STATUS_CLOSED);
linphone_friend_unsubscribe(lf);
if (lf->url!=NULL) osip_from_free(lf->url);
if (lf->uri!=NULL) linphone_uri_destroy(lf->uri);
if (lf->info!=NULL) buddy_info_free(lf->info);
ms_free(lf);
}
......@@ -571,29 +564,10 @@ void linphone_friend_check_for_removed_proxy(LinphoneFriend *lf, LinphoneProxyCo
}
}
char *linphone_friend_get_addr(LinphoneFriend *lf){
char *ret,*tmp;
if (lf->url==NULL) return NULL;
osip_uri_to_str(lf->url->url,&tmp);
ret=ms_strdup(tmp);
osip_free(tmp);
return ret;
const LinphoneUri *linphone_friend_get_uri(const LinphoneFriend *lf){
return lf->uri;
}
char *linphone_friend_get_name(LinphoneFriend *lf){
if (lf->url==NULL) return NULL;
if (lf->url->displayname==NULL) return NULL;
return ms_strdup(lf->url->displayname);
}
char * linphone_friend_get_url(LinphoneFriend *lf){
char *tmp,*ret;
if (lf->url==NULL) return NULL;
osip_from_to_str(lf->url,&tmp);
ret=ms_strdup(tmp);
ms_free(tmp);
return ret;
}
bool_t linphone_friend_get_send_subscribe(const LinphoneFriend *lf){
return lf->subscribe;
......@@ -612,7 +586,7 @@ BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf){
}
void linphone_friend_apply(LinphoneFriend *fr, LinphoneCore *lc){
if (fr->url==NULL) {
if (fr->uri==NULL) {
ms_warning("No sip url defined.");
return;
}
......@@ -657,7 +631,7 @@ void linphone_friend_done(LinphoneFriend *fr){
void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf)
{
ms_return_if_fail(lf->lc==NULL);
ms_return_if_fail(lf->url!=NULL);
ms_return_if_fail(lf->uri!=NULL);
lc->friends=ms_list_append(lc->friends,lf);
linphone_friend_apply(lf,lc);
return ;
......@@ -679,22 +653,26 @@ static bool_t username_match(const char *u1, const char *u2){
}
LinphoneFriend *linphone_core_get_friend_by_uri(const LinphoneCore *lc, const char *uri){
osip_from_t *from;
osip_from_init(&from);
LinphoneUri *puri=linphone_uri_new(uri);
const MSList *elem;
if (osip_from_parse(from,uri)!=0){
osip_from_free(from);
const char *username=linphone_uri_get_username(puri);
const char *domain=linphone_uri_get_domain(puri);
LinphoneFriend *lf=NULL;
if (puri==NULL){
return NULL;
}
for(elem=lc->friends;elem!=NULL;elem=ms_list_next(elem)){
LinphoneFriend *lf=(LinphoneFriend*)elem->data;
const char *it_username=lf->url->url->username;
const char *it_host=lf->url->url->host;
if (strcasecmp(from->url->host,it_host)==0 && username_match(from->url->username,it_username)){
return lf;
lf=(LinphoneFriend*)elem->data;
const char *it_username=linphone_uri_get_username(lf->uri);
const char *it_host=linphone_uri_get_domain(lf->uri);;
if (strcasecmp(domain,it_host)==0 && username_match(username,it_username)){
break;
}
lf=NULL;
}
return NULL;
linphone_uri_destroy(puri);
return lf;
}
#define key_compare(key, word) strncasecmp((key),(word),strlen(key))
......@@ -781,8 +759,8 @@ void linphone_friend_write_to_config_file(LpConfig *config, LinphoneFriend *lf,
lp_config_clean_section(config,key);
return;
}
if (lf->url!=NULL){
osip_from_to_str(lf->url,&tmp);
if (lf->uri!=NULL){
tmp=linphone_uri_as_string(lf->uri);
if (tmp==NULL) {
return;
}
......
This diff is collapsed.
......@@ -19,8 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef LINPHONECORE_H
#define LINPHONECORE_H
#include <osipparser2/osip_message.h>
#include "ortp/ortp.h"
#include "ortp/payloadtype.h"
#include "mediastreamer2/mscommon.h"
......@@ -147,6 +145,26 @@ typedef struct autoreplier_config
const char *message; /* the path of the file to be played */
}autoreplier_config_t;
struct osip_from;
typedef struct osip_from LinphoneUri;
LinphoneUri * linphone_uri_new(const char *uri);
LinphoneUri * linphone_uri_clone(const LinphoneUri *uri);
const char *linphone_uri_get_scheme(const LinphoneUri *u);
const char *linphone_uri_get_display_name(const LinphoneUri* u);
const char *linphone_uri_get_username(const LinphoneUri *u);
const char *linphone_uri_get_domain(const LinphoneUri *u);
void linphone_uri_set_display_name(LinphoneUri *u, const char *display_name);
void linphone_uri_set_username(LinphoneUri *uri, const char *username);
void linphone_uri_set_domain(LinphoneUri *uri, const char *host);
void linphone_uri_set_port(LinphoneUri *uri, const char *port);
void linphone_uri_set_port_int(LinphoneUri *uri, int port);
/*remove tags, params etc... so that it is displayable to the user*/
void linphone_uri_clean(LinphoneUri *uri);
char *linphone_uri_as_string(const LinphoneUri *u);
char *linphone_uri_as_string_without_display_name(const LinphoneUri *u);
void linphone_uri_destroy(LinphoneUri *u);
struct _LinphoneCore;
struct _sdp_context;
......@@ -166,11 +184,10 @@ typedef enum _LinphoneCallStatus {
typedef struct _LinphoneCallLog{
LinphoneCallDir dir;
LinphoneCallStatus status;
char *from;
char *to;
LinphoneUri *from;
LinphoneUri *to;
char start_date[128];
int duration;
} LinphoneCallLog;
......@@ -204,7 +221,7 @@ typedef enum _LinphoneOnlineStatus{
const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
typedef struct _LinphoneFriend{
osip_from_t *url;
LinphoneUri *uri;
int in_did;
int out_did;
int sid;
......@@ -228,10 +245,7 @@ int linphone_friend_set_proxy(LinphoneFriend *fr, struct _LinphoneProxyConfig *c
void linphone_friend_edit(LinphoneFriend *fr);
void linphone_friend_done(LinphoneFriend *fr);
void linphone_friend_destroy(LinphoneFriend *lf);
/* memory returned by those 3 functions must be freed */
char *linphone_friend_get_name(LinphoneFriend *lf);
char *linphone_friend_get_addr(LinphoneFriend *lf);
char *linphone_friend_get_url(LinphoneFriend *lf); /* name <sip address> */
const LinphoneUri *linphone_friend_get_uri(const LinphoneFriend *lf);
bool_t linphone_friend_get_send_subscribe(const LinphoneFriend *lf);
LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf);
LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf);
......@@ -336,7 +350,7 @@ struct _LinphoneChatRoom{
struct _LinphoneCore *lc;
char *peer;
char *route;
osip_from_t *peer_url;
LinphoneUri *peer_url;
void * user_data;
};
typedef struct _LinphoneChatRoom LinphoneChatRoom;
......@@ -560,7 +574,7 @@ bool_t linphone_core_get_guess_hostname(LinphoneCore *lc);
bool_t linphone_core_ipv6_enabled(LinphoneCore *lc);
void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val);
osip_from_t *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
LinphoneUri *linphone_core_get_primary_contact_parsed(LinphoneCore *lc);
/*0= no bandwidth limit*/
void linphone_core_set_download_bandwidth(LinphoneCore *lc, int bw);
......@@ -749,7 +763,7 @@ void linphone_core_set_record_file(LinphoneCore *lc, const char *file);
gstate_t linphone_core_get_state(const LinphoneCore *lc, gstate_group_t group);
int linphone_core_get_current_call_duration(const LinphoneCore *lc);
const char *linphone_core_get_remote_uri(LinphoneCore *lc);
const LinphoneUri *linphone_core_get_remote_uri(LinphoneCore *lc);
int linphone_core_get_mtu(const LinphoneCore *lc);
void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
......@@ -791,7 +805,7 @@ void linphone_core_start_media_streams(LinphoneCore *lc, struct _LinphoneCall *c
void linphone_core_stop_media_streams(LinphoneCore *lc);
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, char **real_url, osip_to_t **real_parsed_url, char **route);
bool_t linphone_core_interpret_url(LinphoneCore *lc, const char *url, LinphoneUri **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);
......
......@@ -35,10 +35,9 @@ void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, int
fl->inc_subscribe_pending=TRUE;
lc->subscribers=ms_list_append(lc->subscribers,(void *)fl);
if (lc->vtable.new_unknown_subscriber!=NULL) {
char *clean_subscriber; /* we need to remove tags...*/
from_2char_without_params(fl->url,&clean_subscriber);
lc->vtable.new_unknown_subscriber(lc,fl,clean_subscriber);
ms_free(clean_subscriber);
char *subscriber=linphone_uri_as_string(fl->uri);
lc->vtable.new_unknown_subscriber(lc,fl,subscriber);
ms_free(subscriber);
}
}
......@@ -75,12 +74,12 @@ void linphone_subscription_new(LinphoneCore *lc, eXosip_event_t *ev){
osip_from_t *from=ev->request->from;
char *tmp;
osip_message_t *msg=NULL;
LinphoneUri *uri;
osip_from_to_str(ev->request->from,&tmp);
uri=linphone_uri_new(tmp);
ms_message("Receiving new subscription from %s.",tmp);
/* check if we answer to this subscription */
if (find_friend(lc->friends,from,&lf)!=NULL){
if (linphone_find_friend(lc->friends,uri,&lf)!=NULL){
lf->in_did=ev->did;
linphone_friend_set_nid(lf,ev->nid);
eXosip_insubscription_build_answer(ev->tid,202,&msg);
......@@ -89,7 +88,7 @@ void linphone_subscription_new(LinphoneCore *lc, eXosip_event_t *ev){
linphone_friend_done(lf); /*this will do all necessary actions */
}else{
/* check if this subscriber is in our black list */
if (find_friend(lc->subscribers,from,&lf)){
if (linphone_find_friend(lc->subscribers,uri,&lf)){
if (lf->pol==LinphoneSPDeny){
ms_message("Rejecting %s because we already rejected it once.",from);
eXosip_insubscription_send_answer(ev->tid,401,NULL);
......@@ -113,7 +112,7 @@ void linphone_notify_recv(LinphoneCore *lc, eXosip_event_t *ev)
const char *img="sip-closed.png";
char *tmp;
LinphoneFriend *lf;
osip_from_t *friend=NULL;
LinphoneUri *friend=NULL;
osip_from_t *from=NULL;
osip_body_t *body=NULL;
LinphoneOnlineStatus estatus=LINPHONE_STATUS_UNKNOWN;
......@@ -169,8 +168,8 @@ void linphone_notify_recv(LinphoneCore *lc, eXosip_event_t *ev)
}
lf=linphone_find_friend_by_sid(lc->friends,ev->sid);
if (lf!=NULL){
friend=lf->url;
from_2char_without_params(friend,&tmp);
friend=lf->uri;
tmp=linphone_uri_as_string(friend);
lf->status=estatus;
lc->vtable.notify_recv(lc,(LinphoneFriend*)lf,tmp,status,img);
ms_free(tmp);
......@@ -187,13 +186,17 @@ void linphone_notify_recv(LinphoneCore *lc, eXosip_event_t *ev)
void linphone_subscription_answered(LinphoneCore *lc, eXosip_event_t *ev){
LinphoneFriend *lf;
osip_from_t *from=ev->response->to;
find_friend(lc->friends,from,&lf);
char *tmp;
osip_from_to_str(from,&tmp);
LinphoneUri *uri=linphone_uri_new(tmp);
linphone_find_friend(lc->friends,uri,&lf);
if (lf!=NULL){
lf->out_did=ev->did;
linphone_friend_set_sid(lf,ev->sid);
}else{
ms_warning("Receiving answer for unknown subscribe sip:%s@%s", from->url->username,from->url->host);
}
ms_free(tmp);
}
void linphone_subscription_closed(LinphoneCore *lc,eXosip_event_t *ev){
LinphoneFriend *lf;
......
......@@ -100,13 +100,13 @@ typedef struct _LinphoneCall
bool_t supports_session_timers;
} LinphoneCall;
LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, const osip_from_t *from, const osip_to_t *to);
LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, const char *from, const char *to, eXosip_event_t *ev);
LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneUri *from, LinphoneUri *to);
LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, LinphoneUri *from, LinphoneUri *to, eXosip_event_t *ev);
#define linphone_call_set_state(lcall,st) (lcall)->state=(st)
void linphone_call_destroy(struct _LinphoneCall *obj);
/* private: */
LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *local, char * remote);
LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneUri *local, LinphoneUri * remote);
void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call);
void linphone_call_log_destroy(LinphoneCallLog *cl);
......@@ -176,7 +176,7 @@ void linphone_call_init_media_params(LinphoneCall *call);
void linphone_set_sdp(osip_message_t *sip, const char *sdp);
MSList *find_friend(MSList *fl, const osip_from_t *friend, LinphoneFriend **lf);
MSList *linphone_find_friend(MSList *fl, const LinphoneUri *fri, LinphoneFriend **lf);
LinphoneFriend *linphone_find_friend_by_nid(MSList *l, int nid);
LinphoneFriend *linphone_find_friend_by_sid(MSList *l, int sid);
......@@ -187,7 +187,7 @@ void linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call);
void linphone_core_write_friends_config(LinphoneCore* lc);
void linphone_proxy_config_update(LinphoneProxyConfig *cfg);
void linphone_proxy_config_get_contact(LinphoneProxyConfig *cfg, const char **ip, int *port);
LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const char *uri);
LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneUri *uri);
int linphone_core_get_local_ip_for(const char *dest, char *result);
#endif /* _PRIVATE_H */
......@@ -30,13 +30,13 @@ static void sip_login_init_instance(SipSetupContext *ctx){
linphone_proxy_config_enable_register(cfg,FALSE);
}
static void guess_display_name(osip_from_t *from){
char *dn=(char*)osip_malloc(strlen(from->url->username)+3);
char *it=from->url->username;
static void guess_display_name(LinphoneUri *from){
char *dn=(char*)ms_malloc(strlen(linphone_uri_get_username(from))+3);
const char *it;
char *wptr=dn;
bool_t begin=TRUE;
bool_t surname=0;
for(it=from->url->username;*it!='\0';++it){
for(it=linphone_uri_get_username(from);*it!='\0';++it){
if (begin){
*wptr=toupper(*it);
begin=FALSE;
......@@ -48,35 +48,34 @@ static void guess_display_name(osip_from_t *from){
}else *wptr=*it;
wptr++;
}
if (from->displayname!=NULL) osip_free(from->displayname);
from->displayname=dn;
linphone_uri_set_display_name(from,dn);
ms_free(dn);
}
static int sip_login_do_login(SipSetupContext * ctx, const char *uri, const char *passwd){
LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx);
LinphoneCore *lc=linphone_proxy_config_get_core(cfg);
LinphoneAuthInfo *auth;
osip_from_t *parsed_uri;
LinphoneUri *parsed_uri;
char *tmp;
osip_from_init(&parsed_uri);
if (osip_from_parse(parsed_uri,uri)==-1){
osip_from_free(parsed_uri);
parsed_uri=linphone_uri_new(uri);
if (parsed_uri==NULL){
return -1;
}
if (parsed_uri->displayname==NULL || strlen(parsed_uri->displayname)==0){
if (linphone_uri_get_display_name(parsed_uri)!=NULL){
guess_display_name(parsed_uri);
}
osip_from_to_str(parsed_uri,&tmp);
tmp=linphone_uri_as_string(parsed_uri);
linphone_proxy_config_set_identity(cfg,tmp);
if (passwd ) {
auth=linphone_auth_info_new(parsed_uri->url->username,NULL,passwd,NULL,NULL);
auth=linphone_auth_info_new(linphone_uri_get_username(parsed_uri),NULL,passwd,NULL,NULL);
linphone_core_add_auth_info(lc,auth);
}
linphone_proxy_config_enable_register(cfg,TRUE);
linphone_proxy_config_done(cfg);
osip_free(tmp);
osip_from_free(parsed_uri);
ms_free(tmp);
linphone_uri_destroy(parsed_uri);
ms_message("SipLogin: done");
return 0;
}
......
......@@ -136,12 +136,14 @@ int sip_setup_context_account_exists(SipSetupContext *ctx, const char *uri){
}
int sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, const char *passwd){
osip_from_t *from;
osip_from_init(&from);
osip_from_parse(from,uri);
strncpy(ctx->domain,from->url->host,sizeof(ctx->domain));
strncpy(ctx->username,from->url->username,sizeof(ctx->username));
osip_from_free(from);
LinphoneUri *from=linphone_uri_new(uri);
if (from==NULL) {
ms_warning("Fail to parse %s",uri);
return -1;
}
strncpy(ctx->domain,linphone_uri_get_domain(from),sizeof(ctx->domain));
strncpy(ctx->username,linphone_uri_get_username(from),sizeof(ctx->username));
linphone_uri_destroy(from);
if (ctx->funcs->login_account)
return ctx->funcs->login_account(ctx,uri,passwd);
return -1;
......
......@@ -104,7 +104,7 @@ static void linphone_gtk_set_selection_to_uri_bar(GtkTreeView *treeview){
if (gtk_tree_selection_get_selected (select, &model, &iter))
{
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
friend=linphone_friend_get_url(lf);
friend=linphone_uri_as_string(linphone_friend_get_uri(lf));
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),friend);
ms_free(friend);
}
......@@ -309,22 +309,20 @@ void linphone_gtk_show_friends(void){