register works.

This commit is contained in:
Simon Morlat 2010-02-08 13:49:52 +01:00
parent 037145b937
commit e487df8d7d
4 changed files with 33 additions and 32 deletions

View file

@ -343,6 +343,7 @@ static void register_success(SalOp *op, bool_t registered){
LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op);
char *msg;
gstate_new_state(lc, GSTATE_REG_OK, NULL);
cfg->registered=registered;
if (cfg->registered) msg=ms_strdup_printf(_("Registration on %s successful."),sal_op_get_proxy(op));
else msg=ms_strdup_printf(_("Unregistration on %s done."),sal_op_get_proxy(op));
if (lc->vtable.display_status)

View file

@ -49,6 +49,8 @@ static void toggle_video_preview(LinphoneCore *lc, bool_t val);
/* same for remote ring (ringback)*/
#define REMOTE_RING "ringback.wav"
extern SalCallbacks linphone_sal_callbacks;
void lc_callback_obj_init(LCCallbackObj *obj,LinphoneCoreCbFunc func,void* ud)
{
obj->_func=func;
@ -704,6 +706,7 @@ static MSList *add_missing_codecs(SalStreamType mtype, MSList *l){
}
if (pt && ms_filter_codec_supported(pt->mime_type)){
if (ms_list_find(l,pt)==NULL){
payload_type_set_flag(pt,PAYLOAD_TYPE_ENABLED);
ms_message("Adding new codec %s/%i with fmtp %s",
pt->mime_type,pt->clock_rate,pt->recv_fmtp ? pt->recv_fmtp : "");
if (strcasecmp(pt->mime_type,"speex")==0 ||
@ -957,13 +960,9 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
if (factory_config_path)
lp_config_read_file(lc->config,factory_config_path);
#ifdef VINCENT_MAURY_RSVP
/* default qos parameters : rsvp on, rpc off */
lc->rsvp_enable = 1;
lc->rpc_enable = 0;
#endif
lc->sal=sal_init();
sal_set_user_pointer(lc->sal,lc);
sal_set_callbacks(lc->sal,&linphone_sal_callbacks);
if (lp_config_get_int(lc->config,"sip","use_session_timers",0)==1){
sal_use_session_timers(lc->sal,200);
}
@ -1046,9 +1045,8 @@ int linphone_core_set_primary_contact(LinphoneCore *lc, const char *contact)
{
LinphoneAddress *ctt;
if ((ctt=linphone_address_new(contact))!=0) {
if ((ctt=linphone_address_new(contact))==0) {
ms_error("Bad contact url: %s",contact);
linphone_address_destroy(ctt);
return -1;
}
if (lc->sip_conf.contact!=NULL) ms_free(lc->sip_conf.contact);
@ -1098,8 +1096,9 @@ const char *linphone_core_get_primary_contact(LinphoneCore *lc){
}
url=linphone_address_new(lc->sip_conf.contact);
if (!url){
ms_error("Could not parse identity contact !");
url=linphone_address_new("sip:unknown@unkwownhost");
}else ms_error("Could not parse identity contact !");
}
linphone_core_get_local_ip(lc, NULL, tmp);
if (strcmp(tmp,"127.0.0.1")==0 || strcmp(tmp,"::1")==0 ){
ms_warning("Local loopback network only !");

View file

@ -227,6 +227,7 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){
if (obj->op)
sal_op_release(obj->op);
obj->op=sal_op_new(obj->lc->sal);
sal_op_set_user_pointer(obj->op,obj);
sal_register(obj->op,obj->reg_proxy,obj->reg_identity,obj->expires);
}
}

View file

@ -91,7 +91,7 @@ void sal_exosip_fix_route(SalOp *op){
SalOp * sal_op_new(Sal *sal){
SalOp *op=ms_new(SalOp,1);
__sal_op_init(op,sal);
op->cid=op->did=op->tid=op->rid=op->nid=op->sid-1;
op->cid=op->did=op->tid=op->rid=op->nid=op->sid=-1;
op->supports_session_timers=FALSE;
op->sdp_offering=TRUE;
op->pending_auth=NULL;
@ -674,10 +674,19 @@ int sal_op_get_auth_requested(SalOp *op, const char **realm, const char **userna
return -1;
}
static SalOp *find_op(Sal *sal, eXosip_event_t *ev){
if (ev->external_reference)
return (SalOp*)ev->external_reference;
if (ev->rid>0){
return sal_find_register(sal,ev->rid);
}
return NULL;
}
static bool_t process_authentication(Sal *sal, eXosip_event_t *ev){
SalOp *op;
const char *username,*realm;
op=(SalOp*)ev->external_reference;
op=find_op(sal,ev);
if (op==NULL){
ms_warning("No operation associated with this authentication !");
return TRUE;
@ -696,7 +705,7 @@ static bool_t process_authentication(Sal *sal, eXosip_event_t *ev){
static void authentication_ok(Sal *sal, eXosip_event_t *ev){
SalOp *op;
const char *username,*realm;
op=(SalOp*)ev->external_reference;
op=find_op(sal,ev);
if (op==NULL){
ms_warning("No operation associated with this authentication_ok!");
return ;
@ -945,22 +954,14 @@ static void other_request(Sal *sal, eXosip_event_t *ev){
}
}
static void update_contact(SalOp *op, const char *received, const char *rport){
SalAddress *addr=sal_address_new(sal_op_get_contact(op));
char *tmp;
sal_address_set_domain(addr,received);
sal_address_set_port(addr,rport);
tmp=sal_address_as_string(addr);
sal_op_set_contact(op,tmp);
ms_free(tmp);
}
static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *orig_request, osip_message_t *last_answer){
osip_message_t *msg;
const char *rport,*received;
osip_via_t *via=NULL;
osip_generic_param_t *param=NULL;
osip_contact_t *ctt=NULL;
char *tmp;
osip_message_get_via(last_answer,0,&via);
if (!via) return FALSE;
osip_via_param_get_byname(via,"rport",&param);
@ -1003,8 +1004,10 @@ static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *ori
ctt->url->port=osip_strdup(rport);
eXosip_register_send_register(op->rid,msg);
eXosip_unlock();
update_contact(op,received,rport);
ms_message("Resending new register with updated contact %s:%s",received,rport);
osip_contact_to_str(ctt,&tmp);
sal_op_set_contact(op,tmp);
ms_message("Resending new register with updated contact %s",tmp);
ms_free(tmp);
return TRUE;
}
@ -1165,22 +1168,19 @@ static bool_t process_event(Sal *sal, eXosip_event_t *ev){
int sal_iterate(Sal *sal){
eXosip_event_t *ev;
if (sal->running){
while((ev=eXosip_event_wait(0,0))!=NULL){
if (process_event(sal,ev))
eXosip_event_free(ev);
}
eXosip_lock();
eXosip_automatic_refresh();
eXosip_unlock();
while((ev=eXosip_event_wait(0,0))!=NULL){
if (process_event(sal,ev))
eXosip_event_free(ev);
}
eXosip_lock();
eXosip_automatic_refresh();
eXosip_unlock();
return 0;
}
int sal_register(SalOp *h, const char *proxy, const char *from, int expires){
osip_message_t *msg;
sal_op_set_route(h,proxy);
sal_exosip_fix_route(h);
if (h->rid==-1){
eXosip_lock();
h->rid=eXosip_register_build_initial_register(from,proxy,sal_op_get_contact(h),expires,&msg);