1 diff -dur linphone-3.6.0.orig/coreapi/sal_eXosip2.c linphone-3.6.0/coreapi/sal_eXosip2.c
2 --- linphone-3.6.0.orig/coreapi/sal_eXosip2.c 2013-06-17 11:11:08.000000000 +0200
3 +++ linphone-3.6.0/coreapi/sal_eXosip2.c 2013-06-17 11:21:40.000000000 +0200
5 static void update_contact_from_response(SalOp *op, osip_message_t *response);
8 +struct eXosip_t *eXo = 0;
10 void _osip_list_set_empty(osip_list_t *l, void (*freefunc)(void*)){
12 while(!osip_list_eol(l,0)) {
16 void sal_get_default_local_ip(Sal *sal, int address_family,char *ip, size_t iplen){
17 - if (eXosip_guess_localip(address_family,ip,iplen)<0){
18 + if (eXosip_guess_localip(eXo,address_family,ip,iplen)<0){
19 /*default to something */
20 strncpy(ip,address_family==AF_INET6 ? "::1" : "127.0.0.1",iplen);
21 ms_error("Could not find default routable ip address !");
23 eXosip_event_free(op->pending_auth);
25 sal_remove_register(op->base.root,op->rid);
26 - eXosip_register_remove(op->rid);
27 + eXosip_register_remove(eXo,op->rid);
30 ms_message("Cleaning cid %i",op->cid);
32 osip_trace_initialize_func (OSIP_INFO4,&_osip_trace_func);
36 + eXo=eXosip_malloc();
39 sal->keepalive_period=30;
44 void sal_uninit(Sal* sal){
53 int sal_unlisten_ports(Sal *ctx){
63 #ifdef HAVE_EXOSIP_RESET_TRANSPORTS
65 ms_message("Exosip transports reset.");
66 - eXosip_reset_transports();
67 + eXosip_reset_transports(eXo);
72 eXosip_tls_ctx_t tlsCtx;
73 memset(&tlsCtx, 0, sizeof(tlsCtx));
74 snprintf(tlsCtx.root_ca_cert, sizeof(tlsCtx.client.cert), "%s", ctx->rootCa);
75 - eXosip_set_tls_ctx(&tlsCtx);
76 + eXosip_set_option(eXo, EXOSIP_OPT_SET_TLS_CERTIFICATES_INFO, (void*)&tlsCtx);
78 #ifdef HAVE_EXOSIP_TLS_VERIFY_CERTIFICATE
79 - eXosip_tls_verify_certificate(ctx->verify_server_certs);
80 + eXosip_set_option(eXo, EXOSIP_OPT_SET_TLS_VERIFY_CERTIFICATE, (void*)&ctx->verify_server_certs);
82 #ifdef HAVE_EXOSIP_TLS_VERIFY_CN
83 eXosip_tls_verify_cn(ctx->verify_server_cn);
88 - eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &keepalive);
89 + eXosip_set_option (eXo, EXOSIP_OPT_UDP_KEEP_ALIVE, &keepalive);
94 if (!ctx->tcp_tls_keepalive) keepalive=-1;
95 - eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE,&keepalive);
96 + eXosip_set_option (eXo, EXOSIP_OPT_UDP_KEEP_ALIVE,&keepalive);
102 /*see if it looks like an IPv6 address*/
103 int use_rports = ctx->use_rports; // Copy char to int to avoid bad alignment
104 - eXosip_set_option(EXOSIP_OPT_USE_RPORT,&use_rports);
105 - int dont_use_101 = !ctx->use_101; // Copy char to int to avoid bad alignment
106 - eXosip_set_option(EXOSIP_OPT_DONT_SEND_101,&dont_use_101);
107 + eXosip_set_option(eXo, EXOSIP_OPT_USE_RPORT,&use_rports);
108 + //int dont_use_101 = !ctx->use_101; // Copy char to int to avoid bad alignment
109 + //eXosip_set_option(eXo, EXOSIP_OPT_DONT_SEND_101,&dont_use_101); // FIXME is this possible with eXosip2 >= 4.0.0?
110 sal_set_dscp(ctx,ctx->dscp);
111 sal_use_dates(ctx,ctx->add_dates);
113 @@ -429,14 +433,14 @@
114 ms_fatal("SIP over DTLS is not supported yet.");
117 - err=eXosip_listen_addr(proto, addr, port, ipv6 ? PF_INET6 : PF_INET, is_secure);
118 + err=eXosip_listen_addr(eXo, proto, addr, port, ipv6 ? PF_INET6 : PF_INET, is_secure);
123 ortp_socket_t sal_get_socket(Sal *ctx){
124 #ifdef HAVE_EXOSIP_GET_SOCKET
125 - return eXosip_get_socket(IPPROTO_UDP);
126 + return eXosip_get_socket(eXo, IPPROTO_UDP);
128 ms_warning("Sorry, eXosip does not have eXosip_get_socket() method");
133 void sal_set_user_agent(Sal *ctx, const char *user_agent){
134 - eXosip_set_user_agent(user_agent);
135 + eXosip_set_user_agent(eXo, user_agent);
138 void sal_use_session_timers(Sal *ctx, int expires){
140 #ifdef EXOSIP_OPT_REGISTER_WITH_DATE
143 - eXosip_set_option(EXOSIP_OPT_REGISTER_WITH_DATE,&tmp);
144 + eXosip_set_option(eXo,EXOSIP_OPT_REGISTER_WITH_DATE,&tmp);
147 if (enabled) ms_warning("Exosip does not support EXOSIP_OPT_REGISTER_WITH_DATE option.");
149 void sal_verify_server_certificates(Sal *ctx, bool_t verify){
150 ctx->verify_server_certs=verify;
151 #ifdef HAVE_EXOSIP_TLS_VERIFY_CERTIFICATE
152 - eXosip_tls_verify_certificate(verify);
153 + eXosip_set_option(eXo, EXOSIP_OPT_SET_TLS_VERIFY_CERTIFICATE, (void*)&verify);
158 h->terminated = FALSE;
160 route = sal_op_get_route(h);
161 - err=eXosip_call_build_initial_invite(&invite,to,from,route,"Phone call");
162 + err=eXosip_call_build_initial_invite(eXo,&invite,to,from,route,"Phone call");
164 ms_error("Could not create call. Error %d (from=%s to=%s route=%s)",
165 err, from, to, route);
167 osip_message_set_header(invite,"Referred-By",h->referred_by);
171 - err=eXosip_call_send_initial_invite(invite);
174 + err=eXosip_call_send_initial_invite(eXo,invite);
175 + eXosip_unlock(eXo);
178 ms_error("Fail to send invite ! Error code %d", err);
180 /*if early media send also 180 and 183 */
184 - eXosip_call_build_answer(h->tid,183,&msg);
186 + eXosip_call_build_answer(eXo,h->tid,183,&msg);
190 @@ -697,13 +701,13 @@
191 sdp_message_free(h->sdp_answer);
194 - eXosip_call_send_answer(h->tid,183,msg);
195 + eXosip_call_send_answer(eXo,h->tid,183,msg);
198 + eXosip_unlock(eXo);
201 - eXosip_call_send_answer(h->tid,180,NULL);
204 + eXosip_call_send_answer(eXo,h->tid,180,NULL);
205 + eXosip_unlock(eXo);
211 const char *contact=sal_op_get_contact(h);
213 - int err=eXosip_call_build_answer(h->tid,200,&msg);
214 + int err=eXosip_call_build_answer(eXo,h->tid,200,&msg);
215 if (err<0 || msg==NULL){
216 ms_error("Fail to build answer for call: err=%i",err);
218 @@ -741,38 +745,38 @@
220 ms_error("You are accepting a call but not defined any media capabilities !");
222 - eXosip_call_send_answer(h->tid,200,msg);
223 + eXosip_call_send_answer(eXo,h->tid,200,msg);
227 int sal_call_decline(SalOp *h, SalReason reason, const char *redirect){
228 if (reason==SalReasonBusy){
230 - eXosip_call_send_answer(h->tid,486,NULL);
233 + eXosip_call_send_answer(eXo,h->tid,486,NULL);
234 + eXosip_unlock(eXo);
236 else if (reason==SalReasonTemporarilyUnavailable){
238 - eXosip_call_send_answer(h->tid,480,NULL);
241 + eXosip_call_send_answer(eXo,h->tid,480,NULL);
242 + eXosip_unlock(eXo);
243 }else if (reason==SalReasonDoNotDisturb){
245 - eXosip_call_send_answer(h->tid,600,NULL);
248 + eXosip_call_send_answer(eXo,h->tid,600,NULL);
249 + eXosip_unlock(eXo);
250 }else if (reason==SalReasonMedia){
252 - eXosip_call_send_answer(h->tid,415,NULL);
255 + eXosip_call_send_answer(eXo,h->tid,415,NULL);
256 + eXosip_unlock(eXo);
257 }else if (redirect!=NULL && reason==SalReasonRedirect){
260 if (strstr(redirect,"sip:")!=0) code=302;
263 - eXosip_call_build_answer(h->tid,code,&msg);
265 + eXosip_call_build_answer(eXo,h->tid,code,&msg);
266 osip_message_set_contact(msg,redirect);
267 - eXosip_call_send_answer(h->tid,code,msg);
269 + eXosip_call_send_answer(eXo,h->tid,code,msg);
270 + eXosip_unlock(eXo);
271 }else sal_call_terminate(h);
274 @@ -798,18 +802,18 @@
276 static int send_notify_for_refer(int did, const char *sipfrag){
279 - eXosip_call_build_notify(did,EXOSIP_SUBCRSTATE_ACTIVE,&msg);
281 + eXosip_call_build_notify(eXo,did,EXOSIP_SUBCRSTATE_ACTIVE,&msg);
284 + eXosip_unlock(eXo);
285 ms_warning("Could not build NOTIFY for refer.");
288 osip_message_set_content_type(msg,"message/sipfrag");
289 osip_message_set_header(msg,"Event","refer");
290 osip_message_set_body(msg,sipfrag,strlen(sipfrag));
291 - eXosip_call_send_request(did,msg);
293 + eXosip_call_send_request(eXo,did,msg);
294 + eXosip_unlock(eXo);
299 sal_op_set_to(op,to);
300 sal_exosip_fix_route(op);
302 - eXosip_options_build_request (&options, sal_op_get_to(op),
303 + eXosip_options_build_request (eXo, &options, sal_op_get_to(op),
304 sal_op_get_from(op),sal_op_get_route(op));
306 if (op->base.root->session_expires!=0){
308 osip_message_set_supported(options, "timer");
310 sal_add_other(sal_op_get_sal(op),op,options);
311 - return eXosip_options_send_request(options);
312 + return eXosip_options_send_request(eXo, options);
316 @@ -861,11 +865,11 @@
317 int sal_call_refer(SalOp *h, const char *refer_to){
318 osip_message_t *msg=NULL;
321 - eXosip_call_build_refer(h->did,refer_to, &msg);
322 - if (msg) err=eXosip_call_send_request(h->did, msg);
324 + eXosip_call_build_refer(eXo,h->did,refer_to, &msg);
325 + if (msg) err=eXosip_call_send_request(eXo,h->did, msg);
328 + eXosip_unlock(eXo);
332 @@ -873,26 +877,26 @@
333 osip_message_t *msg=NULL;
334 char referto[256]={0};
337 - if (eXosip_call_get_referto(other_call_h->did,referto,sizeof(referto)-1)!=0){
339 + if (eXosip_call_get_referto(eXo,other_call_h->did,referto,sizeof(referto)-1)!=0){
340 ms_error("eXosip_call_get_referto() failed for did=%i",other_call_h->did);
342 + eXosip_unlock(eXo);
345 - eXosip_call_build_refer(h->did,referto, &msg);
346 + eXosip_call_build_refer(eXo,h->did,referto, &msg);
347 osip_message_set_header(msg,"Referred-By",h->base.from);
348 - if (msg) err=eXosip_call_send_request(h->did, msg);
349 + if (msg) err=eXosip_call_send_request(eXo,h->did, msg);
352 + eXosip_unlock(eXo);
356 SalOp *sal_call_get_replaces(SalOp *h){
357 if (h!=NULL && h->replaces!=NULL){
360 - cid=eXosip_call_find_by_replaces(h->replaces);
363 + cid=eXosip_call_find_by_replaces(eXo,h->replaces);
364 + eXosip_unlock(eXo);
366 SalOp *ret=sal_find_call(h->base.root,cid);
368 @@ -906,17 +910,17 @@
373 - eXosip_call_build_info(h->did,&msg);
375 + eXosip_call_build_info(eXo,h->did,&msg);
377 snprintf(dtmf_body, sizeof(dtmf_body), "Signal=%c\r\nDuration=250\r\n", dtmf);
378 osip_message_set_body(msg,dtmf_body,strlen(dtmf_body));
379 osip_message_set_content_type(msg,"application/dtmf-relay");
380 snprintf(clen,sizeof(clen),"%lu",(unsigned long)strlen(dtmf_body));
381 osip_message_set_content_length(msg,clen);
382 - eXosip_call_send_request(h->did,msg);
383 + eXosip_call_send_request(eXo,h->did,msg);
386 + eXosip_unlock(eXo);
390 @@ -925,23 +929,23 @@
391 if (info->userid==NULL || info->userid[0]=='\0') userid=info->username;
392 else userid=info->userid;
393 ms_message("Authentication info for username [%s], id[%s], realm [%s] added to eXosip", info->username,userid, info->realm);
394 - eXosip_add_authentication_info (info->username,userid,
395 + eXosip_add_authentication_info (eXo,info->username,userid,
396 info->password, NULL,info->realm);
399 * Just for symmetry ;-)
401 static void pop_auth_from_exosip() {
402 - eXosip_clear_authentication_info();
403 + eXosip_clear_authentication_info(eXo);
406 int sal_call_terminate(SalOp *h){
408 if (h == NULL) return -1;
409 if (h->auth_info) push_auth_to_exosip(h->auth_info);
411 - err=eXosip_call_terminate(h->cid,h->did);
414 + err=eXosip_call_terminate(eXo,h->cid,h->did);
415 + eXosip_unlock(eXo);
416 if (!h->base.root->reuse_authorization) pop_auth_from_exosip();
418 ms_warning("Exosip could not terminate the call: cid=%i did=%i", h->cid,h->did);
422 update_contact_from_response(h,h->pending_auth->response);
424 - eXosip_default_action(h->pending_auth);
427 + eXosip_default_action(eXo,h->pending_auth);
428 + eXosip_unlock(eXo);
429 ms_message("eXosip_default_action() done");
430 if (!h->base.root->reuse_authorization) pop_auth_from_exosip();
432 @@ -1210,9 +1214,9 @@
434 if (op==NULL || op->terminated==TRUE) {
435 ms_warning("This call has been canceled.");
437 - eXosip_call_terminate(ev->cid,ev->did);
440 + eXosip_call_terminate(eXo,ev->cid,ev->did);
441 + eXosip_unlock(eXo);
445 @@ -1249,9 +1253,9 @@
447 if (op==NULL || op->terminated==TRUE) {
448 ms_warning("This call has been already terminated.");
450 - eXosip_call_terminate(ev->cid,ev->did);
453 + eXosip_call_terminate(eXo,ev->cid,ev->did);
454 + eXosip_unlock(eXo);
458 @@ -1266,12 +1270,12 @@
459 sdp_message_free(sdp);
460 if (op->base.local_media) sdp_process(op);
462 - eXosip_call_build_ack(ev->did,&msg);
463 + eXosip_call_build_ack(eXo,ev->did,&msg);
465 ms_warning("This call has been already terminated.");
467 - eXosip_call_terminate(ev->cid,ev->did);
470 + eXosip_call_terminate(eXo,ev->cid,ev->did);
471 + eXosip_unlock(eXo);
474 contact=sal_op_get_contact(op);
475 @@ -1284,7 +1288,7 @@
476 sdp_message_free(op->sdp_answer);
479 - eXosip_call_send_ack(ev->did,msg);
480 + eXosip_call_send_ack(eXo,ev->did,msg);
481 sal->callbacks.call_accepted(op);
484 @@ -1458,7 +1462,7 @@
488 - eXosip_default_action(ev);
489 + eXosip_default_action(eXo,ev);
493 @@ -1508,17 +1512,17 @@
498 - eXosip_call_build_info(h->did,&msg);
500 + eXosip_call_build_info(eXo,h->did,&msg);
502 osip_message_set_body(msg,info_body,strlen(info_body));
503 osip_message_set_content_type(msg,"application/media_control+xml");
504 snprintf(clen,sizeof(clen),"%lu",(unsigned long)strlen(info_body));
505 osip_message_set_content_length(msg,clen);
506 - eXosip_call_send_request(h->did,msg);
507 + eXosip_call_send_request(eXo,h->did,msg);
508 ms_message("Sending VFU request !");
511 + eXosip_unlock(eXo);
514 static void process_media_control_xml(Sal *sal, eXosip_event_t *ev){
515 @@ -1537,20 +1541,20 @@
516 ms_message("Receiving VFU request !");
517 if (sal->callbacks.vfu_request){
518 sal->callbacks.vfu_request(op);
519 - eXosip_call_build_answer(ev->tid,200,&ans);
520 + eXosip_call_build_answer(eXo,ev->tid,200,&ans);
522 - eXosip_call_send_answer(ev->tid,200,ans);
523 + eXosip_call_send_answer(eXo,ev->tid,200,ans);
527 /*in all other cases we must say it is not implemented.*/
529 osip_message_t *ans=NULL;
531 - eXosip_call_build_answer(ev->tid,501,&ans);
533 + eXosip_call_build_answer(eXo,ev->tid,501,&ans);
535 - eXosip_call_send_answer(ev->tid,501,ans);
537 + eXosip_call_send_answer(eXo,ev->tid,501,ans);
538 + eXosip_unlock(eXo);
542 @@ -1579,11 +1583,11 @@
543 sal->callbacks.dtmf_received(op, tmp[0]);
547 - eXosip_call_build_answer(ev->tid,200,&ans);
549 + eXosip_call_build_answer(eXo,ev->tid,200,&ans);
551 - eXosip_call_send_answer(ev->tid,200,ans);
553 + eXosip_call_send_answer(eXo,ev->tid,200,ans);
554 + eXosip_unlock(eXo);
558 @@ -1628,11 +1632,11 @@
560 osip_from_free(from);
563 - eXosip_call_build_answer(ev->tid,202,&ans);
565 + eXosip_call_build_answer(eXo,ev->tid,202,&ans);
567 - eXosip_call_send_answer(ev->tid,202,ans);
569 + eXosip_call_send_answer(eXo,ev->tid,202,ans);
570 + eXosip_unlock(eXo);
574 @@ -1677,11 +1681,11 @@
577 /*answer that we received the notify*/
579 - eXosip_call_build_answer(ev->tid,200,&ans);
581 + eXosip_call_build_answer(eXo,ev->tid,200,&ans);
583 - eXosip_call_send_answer(ev->tid,200,ans);
585 + eXosip_call_send_answer(eXo,ev->tid,200,ans);
586 + eXosip_unlock(eXo);
590 @@ -1699,28 +1703,28 @@
592 ms_message("Unhandled SIP INFO.");
593 /*send an "Not implemented" answer*/
595 - eXosip_call_build_answer(ev->tid,501,&ans);
597 + eXosip_call_build_answer(eXo,ev->tid,501,&ans);
599 - eXosip_call_send_answer(ev->tid,501,ans);
601 + eXosip_call_send_answer(eXo,ev->tid,501,ans);
602 + eXosip_unlock(eXo);
605 /*empty SIP INFO, probably to test we are alive. Send an empty answer*/
607 - eXosip_call_build_answer(ev->tid,200,&ans);
609 + eXosip_call_build_answer(eXo,ev->tid,200,&ans);
611 - eXosip_call_send_answer(ev->tid,200,ans);
613 + eXosip_call_send_answer(eXo,ev->tid,200,ans);
614 + eXosip_unlock(eXo);
616 }else if(MSG_IS_MESSAGE(ev->request)){
617 /* SIP messages could be received into call */
618 text_received(sal, ev);
620 - eXosip_call_build_answer(ev->tid,200,&ans);
622 + eXosip_call_build_answer(eXo,ev->tid,200,&ans);
624 - eXosip_call_send_answer(ev->tid,200,ans);
626 + eXosip_call_send_answer(eXo,ev->tid,200,ans);
627 + eXosip_unlock(eXo);
628 }else if(MSG_IS_REFER(ev->request)){
629 SalOp *op=find_op(sal,ev);
631 @@ -1729,13 +1733,13 @@
632 }else if(MSG_IS_NOTIFY(ev->request)){
633 process_notify(sal,ev);
634 }else if (MSG_IS_OPTIONS(ev->request)){
636 - eXosip_call_build_answer(ev->tid,200,&ans);
638 + eXosip_call_build_answer(eXo,ev->tid,200,&ans);
640 fill_options_answer(ans);
641 - eXosip_call_send_answer(ev->tid,200,ans);
642 + eXosip_call_send_answer(eXo,ev->tid,200,ans);
645 + eXosip_unlock(eXo);
647 }else ms_warning("call_message_new: No request ?");
649 @@ -1743,11 +1747,11 @@
650 static void inc_update(Sal *sal, eXosip_event_t *ev){
651 osip_message_t *msg=NULL;
652 ms_message("Processing incoming UPDATE");
654 - eXosip_message_build_answer(ev->tid,200,&msg);
656 + eXosip_message_build_answer(eXo,ev->tid,200,&msg);
658 - eXosip_message_send_answer(ev->tid,200,msg);
660 + eXosip_message_send_answer(eXo,ev->tid,200,msg);
661 + eXosip_unlock(eXo);
664 static bool_t comes_from_local_if(osip_message_t *msg){
665 @@ -1874,12 +1878,12 @@
666 if (ev->request==NULL) return;
667 if (strcmp(ev->request->sip_method,"MESSAGE")==0){
668 text_received(sal,ev);
669 - eXosip_message_send_answer(ev->tid,200,NULL);
670 + eXosip_message_send_answer(eXo,ev->tid,200,NULL);
671 }else if (strcmp(ev->request->sip_method,"OPTIONS")==0){
672 osip_message_t *options=NULL;
673 - eXosip_options_build_answer(ev->tid,200,&options);
674 + eXosip_options_build_answer(eXo,ev->tid,200,&options);
675 fill_options_answer(options);
676 - eXosip_options_send_answer(ev->tid,200,options);
677 + eXosip_options_send_answer(eXo,ev->tid,200,options);
678 }else if (strncmp(ev->request->sip_method, "REFER", 5) == 0){
679 ms_message("Receiving REFER request !");
680 if (comes_from_local_if(ev->request)) {
681 @@ -1896,7 +1900,7 @@
684 /*answer with a 501 Not implemented*/
685 - eXosip_message_send_answer(ev->tid,501,NULL);
686 + eXosip_message_send_answer(eXo,ev->tid,501,NULL);
690 @@ -2007,25 +2011,25 @@
691 ms_message("Contact do not match, resending register.");
695 - eXosip_register_build_register(op->rid,op->expires,&msg);
697 + eXosip_register_build_register(eXo,op->rid,op->expires,&msg);
700 + eXosip_unlock(eXo);
701 ms_warning("Fail to create a contact updated register.");
704 if (fix_message_contact(op,msg,last_answer,op->base.root->expire_old_contact)) {
705 - eXosip_register_send_register(op->rid,msg);
707 + eXosip_register_send_register(eXo,op->rid,msg);
708 + eXosip_unlock(eXo);
709 ms_message("Resending new register with updated contact");
710 update_contact_from_response(op,last_answer);
713 ms_warning("Fail to send updated register.");
715 + eXosip_unlock(eXo);
719 + eXosip_unlock(eXo);
723 @@ -2078,10 +2082,10 @@
726 }else op->expires*=2;
728 - eXosip_register_build_register(op->rid,op->expires,&msg);
729 - eXosip_register_send_register(op->rid,msg);
732 + eXosip_register_build_register(eXo,op->rid,op->expires,&msg);
733 + eXosip_register_send_register(eXo,op->rid,msg);
734 + eXosip_unlock(eXo);
737 case 606: /*Not acceptable, workaround for proxies that don't like private addresses
738 @@ -2156,7 +2160,9 @@
739 ms_message("CALL_CLOSED or CANCELLED\n");
740 call_terminated(sal,ev);
742 +#ifdef EXOSIP_CALL_TIMEOUT
743 case EXOSIP_CALL_TIMEOUT:
745 case EXOSIP_CALL_NOANSWER:
746 ms_message("CALL_TIMEOUT or NOANSWER\n");
747 return call_failure(sal,ev);
748 @@ -2184,7 +2190,7 @@
750 case EXOSIP_CALL_REDIRECTED:
751 ms_message("CALL_REDIRECTED");
752 - eXosip_default_action(ev);
753 + eXosip_default_action(eXo, ev);
755 case EXOSIP_CALL_PROCEEDING:
756 ms_message("CALL_PROCEEDING");
757 @@ -2213,13 +2219,17 @@
758 ms_message("CALL_IN_SUBSCRIPTION_NEW ");
759 sal_exosip_subscription_recv(sal,ev);
761 +#ifdef EXOSIP_IN_SUBSCRIPTION_RELEASED
762 case EXOSIP_IN_SUBSCRIPTION_RELEASED:
763 ms_message("CALL_SUBSCRIPTION_NEW ");
764 sal_exosip_in_subscription_closed(sal,ev);
767 +#ifdef EXOSIP_SUBSCRIPTION_UPDATE
768 case EXOSIP_SUBSCRIPTION_UPDATE:
769 ms_message("CALL_SUBSCRIPTION_UPDATE");
772 case EXOSIP_SUBSCRIPTION_NOTIFY:
773 ms_message("CALL_SUBSCRIPTION_NOTIFY");
774 sal_exosip_notify_recv(sal,ev);
775 @@ -2228,10 +2238,6 @@
776 ms_message("EXOSIP_SUBSCRIPTION_ANSWERED, ev->sid=%i, ev->did=%i\n",ev->sid,ev->did);
777 sal_exosip_subscription_answered(sal,ev);
779 - case EXOSIP_SUBSCRIPTION_CLOSED:
780 - ms_message("EXOSIP_SUBSCRIPTION_CLOSED\n");
781 - sal_exosip_subscription_closed(sal,ev);
783 case EXOSIP_SUBSCRIPTION_REQUESTFAILURE: /**< announce a request failure */
784 if (ev->response && (ev->response->status_code == 407 || ev->response->status_code == 401)){
785 return process_authentication(sal,ev);
786 @@ -2266,7 +2272,7 @@
788 return process_authentication(sal,ev);
790 - eXosip_automatic_action ();
791 + eXosip_automatic_action (eXo);
795 @@ -2282,21 +2288,21 @@
797 int sal_iterate(Sal *sal){
799 - while((ev=eXosip_event_wait(0,0))!=NULL){
800 + while((ev=eXosip_event_wait(eXo,0,0))!=NULL){
801 if (process_event(sal,ev))
802 eXosip_event_free(ev);
804 #ifdef HAVE_EXOSIP_TRYLOCK
805 if (eXosip_trylock()==0){
806 - eXosip_automatic_refresh();
808 + eXosip_automatic_refresh(eXo);
809 + eXosip_unlock(eXo);
811 ms_warning("eXosip_trylock busy.");
815 - eXosip_automatic_refresh();
818 + eXosip_automatic_refresh(eXo);
819 + eXosip_unlock(eXo);
823 @@ -2361,26 +2367,26 @@
825 if (uri) ms_free(uri);
826 sal_address_destroy(from_parsed);
828 - h->rid=eXosip_register_build_initial_register(from,domain,NULL,expires,&msg);
830 + h->rid=eXosip_register_build_initial_register(eXo,from,domain,NULL,expires,&msg);
832 if (contact) register_set_contact(msg,contact);
833 sal_message_add_route(msg,proxy);
834 sal_add_register(h->base.root,h);
836 ms_error("Could not build initial register.");
838 + eXosip_unlock(eXo);
843 - eXosip_register_build_register(h->rid,expires,&msg);
845 + eXosip_register_build_register(eXo,h->rid,expires,&msg);
846 sal_message_add_route(msg,proxy);
849 - eXosip_register_send_register(h->rid,msg);
850 + eXosip_register_send_register(eXo,h->rid,msg);
853 + eXosip_unlock(eXo);
855 return (msg != NULL) ? 0 : -1;
857 @@ -2399,7 +2405,7 @@
858 /*iOS hack: in the keep alive handler, we have no more than 10 seconds to refresh registers, otherwise the application is suspended forever.
859 * In order to prevent this case that can occur when the exosip thread is busy with DNS while network isn't in a good shape, we try to take
860 * the exosip lock in a non blocking way, and give up if it takes too long*/
861 - while (eXosip_trylock()!=0){
862 + while (eXosip_trylock(eXo)!=0){
865 if (tries>30) {/*after 3 seconds, give up*/
866 @@ -2409,26 +2415,26 @@
873 - eXosip_register_build_register(op->rid,expires,&msg);
874 + eXosip_register_build_register(eXo,op->rid,expires,&msg);
876 if (contact) register_set_contact(msg,contact);
877 sal_message_add_route(msg,sal_op_get_route(op));
878 - eXosip_register_send_register(op->rid,msg);
879 + eXosip_register_send_register(eXo,op->rid,msg);
880 }else ms_error("Could not build REGISTER refresh message.");
882 + eXosip_unlock(eXo);
883 return (msg != NULL) ? 0 : -1;
887 int sal_unregister(SalOp *h){
888 osip_message_t *msg=NULL;
890 - eXosip_register_build_register(h->rid,0,&msg);
891 - if (msg) eXosip_register_send_register(h->rid,msg);
893 + eXosip_register_build_register(eXo,h->rid,0,&msg);
894 + if (msg) eXosip_register_send_register(eXo,h->rid,msg);
895 else ms_warning("Could not build unREGISTER !");
897 + eXosip_unlock(eXo);
901 @@ -2598,7 +2604,7 @@
905 - eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &ctx->keepalive_period);
906 + eXosip_set_option (eXo, EXOSIP_OPT_UDP_KEEP_ALIVE, &ctx->keepalive_period);
908 unsigned int sal_get_keepalive_period(Sal *ctx) {
909 return ctx->keepalive_period;
910 @@ -2636,12 +2642,12 @@
912 osip_message_t *reinvite=NULL;
915 - if(eXosip_call_build_request(h->did,"INVITE",&reinvite) != 0 || reinvite==NULL){
918 + if(eXosip_call_build_request(eXo,h->did,"INVITE",&reinvite) != 0 || reinvite==NULL){
919 + eXosip_unlock(eXo);
923 + eXosip_unlock(eXo);
924 osip_message_set_subject(reinvite,subject);
925 osip_message_set_allow(reinvite, "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
926 if (h->base.contact){
927 @@ -2656,9 +2662,9 @@
928 h->sdp_offering=TRUE;
929 set_sdp_from_desc(reinvite,h->base.local_media);
930 }else h->sdp_offering=FALSE;
932 - err = eXosip_call_send_request(h->did, reinvite);
935 + err = eXosip_call_send_request(eXo, h->did, reinvite);
936 + eXosip_unlock(eXo);
940 diff -dur linphone-3.6.0.orig/coreapi/sal_eXosip2_presence.c linphone-3.6.0/coreapi/sal_eXosip2_presence.c
941 --- linphone-3.6.0.orig/coreapi/sal_eXosip2_presence.c 2013-06-17 11:11:08.000000000 +0200
942 +++ linphone-3.6.0/coreapi/sal_eXosip2_presence.c 2013-06-17 11:12:12.000000000 +0200
945 static presence_type_t presence_style = PIDF;
947 +extern struct eXosip_t *eXo;
949 SalOp * sal_find_out_subscribe(Sal *sal, int sid){
953 sal_op_set_to(op,to);
955 sal_exosip_fix_route(op);
957 - eXosip_message_build_request(&sip,"MESSAGE",sal_op_get_to(op),
959 + eXosip_message_build_request(eXo,&sip,"MESSAGE",sal_op_get_to(op),
960 sal_op_get_from(op),sal_op_get_route(op));
962 sal_exosip_add_custom_headers(sip,op->base.custom_headers);
963 @@ -122,30 +124,30 @@
964 osip_message_set_content_type(sip,content_type);
965 if (msg) osip_message_set_body(sip,msg,strlen(msg));
966 sal_add_other(op->base.root,op,sip);
967 - eXosip_message_send_request(sip);
968 + eXosip_message_send_request(eXo,sip);
970 ms_error("Could not build MESSAGE request !");
973 + eXosip_unlock(eXo);
977 /* we are currently in communication with the destination */
980 //First we generate an INFO message to get the current call_id and a good cseq
981 - eXosip_call_build_request(op->did,"MESSAGE",&sip);
982 + eXosip_call_build_request(eXo,op->did,"MESSAGE",&sip);
985 ms_warning("could not get a build info to send MESSAGE, maybe no previous call established ?");
987 + eXosip_unlock(eXo);
990 sal_exosip_add_custom_headers(sip,op->base.custom_headers);
991 msg_add_current_date(sip);
992 osip_message_set_content_type(sip,content_type);
993 if (msg) osip_message_set_body(sip,msg,strlen(msg));
994 - eXosip_call_send_request(op->did,sip);
996 + eXosip_call_send_request(eXo,op->did,sip);
997 + eXosip_unlock(eXo);
1001 @@ -161,20 +163,20 @@
1003 sal_op_set_to(op,to);
1004 sal_exosip_fix_route(op);
1006 - eXosip_subscribe_build_initial_request(&msg,sal_op_get_to(op),sal_op_get_from(op),
1008 + eXosip_subscribe_build_initial_request(eXo,&msg,sal_op_get_to(op),sal_op_get_from(op),
1009 sal_op_get_route(op),"presence",600);
1011 ms_error("Could not build subscribe request to %s",to);
1013 + eXosip_unlock(eXo);
1016 if (op->base.contact){
1017 _osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
1018 osip_message_set_contact(msg,op->base.contact);
1020 - op->sid=eXosip_subscribe_send_initial_request(msg);
1022 + op->sid=eXosip_subscribe_send_initial_request(eXo,msg);
1023 + eXosip_unlock(eXo);
1025 osip_message_free(msg);
1027 @@ -189,39 +191,39 @@
1028 ms_error("cannot unsubscribe, no dialog !");
1032 - eXosip_subscribe_build_refresh_request(op->did,&msg);
1034 + eXosip_subscribe_build_refresh_request(eXo,op->did,&msg);
1036 osip_message_set_expires(msg,"0");
1037 - eXosip_subscribe_send_refresh_request(op->did,msg);
1038 + eXosip_subscribe_send_refresh_request(eXo,op->did,msg);
1039 }else ms_error("Could not build subscribe refresh request ! op->sid=%i, op->did=%i",
1042 + eXosip_unlock(eXo);
1046 int sal_subscribe_accept(SalOp *op){
1047 osip_message_t *msg=NULL;
1049 - eXosip_insubscription_build_answer(op->tid,202,&msg);
1051 + eXosip_insubscription_build_answer(eXo,op->tid,202,&msg);
1053 ms_error("Fail to build answer to subscribe.");
1055 + eXosip_unlock(eXo);
1058 if (op->base.contact){
1059 _osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
1060 osip_message_set_contact(msg,op->base.contact);
1062 - eXosip_insubscription_send_answer(op->tid,202,msg);
1064 + eXosip_insubscription_send_answer(eXo,op->tid,202,msg);
1065 + eXosip_unlock(eXo);
1069 int sal_subscribe_decline(SalOp *op){
1071 - eXosip_insubscription_send_answer(op->tid,401,NULL);
1074 + eXosip_insubscription_send_answer(eXo,op->tid,401,NULL);
1075 + eXosip_unlock(eXo);
1079 @@ -597,39 +599,39 @@
1081 int sal_notify_presence(SalOp *op, SalPresenceStatus status, const char *status_message){
1082 osip_message_t *msg=NULL;
1083 - eXosip_ss_t ss=EXOSIP_SUBCRSTATE_ACTIVE;
1084 + int ss=EXOSIP_SUBCRSTATE_ACTIVE;
1086 ms_warning("Cannot notify, subscription was closed.");
1091 - eXosip_insubscription_build_notify(op->did,ss,DEACTIVATED,&msg);
1093 + eXosip_insubscription_build_notify(eXo,op->did,ss,DEACTIVATED,&msg);
1095 const char *identity=sal_op_get_contact(op);
1096 if (identity==NULL) identity=sal_op_get_to(op);
1097 _osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
1098 osip_message_set_contact(msg,identity);
1099 add_presence_body(msg,status);
1100 - eXosip_insubscription_send_request(op->did,msg);
1101 + eXosip_insubscription_send_request(eXo,op->did,msg);
1102 }else ms_error("could not create notify for incoming subscription.");
1104 + eXosip_unlock(eXo);
1108 int sal_notify_close(SalOp *op){
1109 osip_message_t *msg=NULL;
1111 - eXosip_insubscription_build_notify(op->did,EXOSIP_SUBCRSTATE_TERMINATED,DEACTIVATED,&msg);
1113 + eXosip_insubscription_build_notify(eXo,op->did,EXOSIP_SUBCRSTATE_TERMINATED,DEACTIVATED,&msg);
1115 const char *identity=sal_op_get_contact(op);
1116 if (identity==NULL) identity=sal_op_get_to(op);
1117 osip_message_set_contact(msg,identity);
1118 add_presence_body(msg,SalPresenceOffline);
1119 - eXosip_insubscription_send_request(op->did,msg);
1120 + eXosip_insubscription_send_request(eXo,op->did,msg);
1121 }else ms_error("sal_notify_close(): could not create notify for incoming subscription"
1122 " did=%i, nid=%i",op->did,op->nid);
1124 + eXosip_unlock(eXo);
1130 mk_presence_body (presence_mode, from, buf, sizeof (buf), presence_style);
1132 - i = eXosip_build_publish(&pub,to, from, NULL, "presence", "600",
1133 + i = eXosip_build_publish(eXo,&pub,to, from, NULL, "presence", "600",
1134 presence_style ? "application/xpidf+xml" : "application/pidf+xml", buf);
1136 ms_warning("Failed to build publish request.");
1137 @@ -650,10 +652,10 @@
1139 sal_message_add_route(pub,route);
1142 - i = eXosip_publish(pub, to); /* should update the sip-if-match parameter
1144 + i = eXosip_publish(eXo, pub, to); /* should update the sip-if-match parameter
1145 from sip-etag from last 200ok of PUBLISH */
1147 + eXosip_unlock(eXo);
1149 ms_message("Failed to send publish request.");
1151 @@ -693,10 +695,10 @@
1153 osip_message_t *msg=NULL;
1154 ms_warning("Probably a refresh subscribe");
1156 - eXosip_insubscription_build_answer(ev->tid,202,&msg);
1157 - eXosip_insubscription_send_answer(ev->tid,202,msg);
1160 + eXosip_insubscription_build_answer(eXo,ev->tid,202,&msg);
1161 + eXosip_insubscription_send_answer(eXo,ev->tid,202,msg);
1162 + eXosip_unlock(eXo);
1164 }else _sal_exosip_subscription_recv(sal,ev);