Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 478686 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-223 / +1108 lines)
Line  Link Here
0
-- a/coreapi/authentication.c
0
++ b/coreapi/authentication.c
Lines 308-314 void linphone_core_add_auth_info(Linphon Link Here
308
			sai.userid=ai->userid;
308
			sai.userid=ai->userid;
309
			sai.realm=ai->realm;
309
			sai.realm=ai->realm;
310
			sai.password=ai->passwd;
310
			sai.password=ai->passwd;
311
			sal_op_authenticate(op,&sai);
311
			sal_op_authenticate(lc->sal,op,&sai);
312
			ai->usecount++;
312
			ai->usecount++;
313
		}
313
		}
314
	}
314
	}
315
-- a/coreapi/callbacks.c
315
++ b/coreapi/callbacks.c
Lines 224-242 static void call_received(SalOp *h){ Link Here
224
	    lc->presence_mode==LinphoneStatusDoNotDisturb ||
224
	    lc->presence_mode==LinphoneStatusDoNotDisturb ||
225
	    lc->presence_mode==LinphoneStatusMoved){
225
	    lc->presence_mode==LinphoneStatusMoved){
226
		if (lc->presence_mode==LinphoneStatusBusy )
226
		if (lc->presence_mode==LinphoneStatusBusy )
227
			sal_call_decline(h,SalReasonBusy,NULL);
227
			sal_call_decline(lc->sal,h,SalReasonBusy,NULL);
228
		else if (lc->presence_mode==LinphoneStatusOffline)
228
		else if (lc->presence_mode==LinphoneStatusOffline)
229
			sal_call_decline(h,SalReasonTemporarilyUnavailable,NULL);
229
			sal_call_decline(lc->sal,h,SalReasonTemporarilyUnavailable,NULL);
230
		else if (lc->presence_mode==LinphoneStatusDoNotDisturb)
230
		else if (lc->presence_mode==LinphoneStatusDoNotDisturb)
231
			sal_call_decline(h,SalReasonTemporarilyUnavailable,NULL);
231
			sal_call_decline(lc->sal,h,SalReasonTemporarilyUnavailable,NULL);
232
		else if (lc->alt_contact!=NULL && lc->presence_mode==LinphoneStatusMoved)
232
		else if (lc->alt_contact!=NULL && lc->presence_mode==LinphoneStatusMoved)
233
			sal_call_decline(h,SalReasonRedirect,lc->alt_contact);
233
			sal_call_decline(lc->sal,h,SalReasonRedirect,lc->alt_contact);
234
		sal_op_release(h);
234
		sal_op_release(lc->sal,h);
235
		return;
235
		return;
236
	}
236
	}
237
	if (!linphone_core_can_we_add_call(lc)){/*busy*/
237
	if (!linphone_core_can_we_add_call(lc)){/*busy*/
238
		sal_call_decline(h,SalReasonBusy,NULL);
238
		sal_call_decline(lc->sal,h,SalReasonBusy,NULL);
239
		sal_op_release(h);
239
		sal_op_release(lc->sal,h);
240
		return;
240
		return;
241
	}
241
	}
242
	from=sal_op_get_from(h);
242
	from=sal_op_get_from(h);
Lines 246-253 static void call_received(SalOp *h){ Link Here
246
246
247
	if ((already_a_call_with_remote_address(lc,from_addr) && prevent_colliding_calls) || already_a_call_pending(lc)){
247
	if ((already_a_call_with_remote_address(lc,from_addr) && prevent_colliding_calls) || already_a_call_pending(lc)){
248
		ms_warning("Receiving another call while one is ringing or initiated, refusing this one with busy message.");
248
		ms_warning("Receiving another call while one is ringing or initiated, refusing this one with busy message.");
249
		sal_call_decline(h,SalReasonBusy,NULL);
249
		sal_call_decline(lc->sal,h,SalReasonBusy,NULL);
250
		sal_op_release(h);
250
		sal_op_release(lc->sal,h);
251
		linphone_address_destroy(from_addr);
251
		linphone_address_destroy(from_addr);
252
		linphone_address_destroy(to_addr);
252
		linphone_address_destroy(to_addr);
253
		return;
253
		return;
Lines 449-455 static void call_accept_update(LinphoneC Link Here
449
	}
449
	}
450
#endif //BUILD_UPNP
450
#endif //BUILD_UPNP
451
	linphone_call_update_remote_session_id_and_ver(call);
451
	linphone_call_update_remote_session_id_and_ver(call);
452
	sal_call_accept(call->op);
452
	sal_call_accept(lc->sal,call->op);
453
	md=sal_call_get_final_media_description(call->op);
453
	md=sal_call_get_final_media_description(call->op);
454
	if (md && !sal_media_description_empty(md))
454
	if (md && !sal_media_description_empty(md))
455
		linphone_core_update_streams(lc,call,md);
455
		linphone_core_update_streams(lc,call,md);
Lines 701-707 static void auth_requested(SalOp *h, con Link Here
701
		sai.realm=ai->realm;
701
		sai.realm=ai->realm;
702
		sai.password=ai->passwd;
702
		sai.password=ai->passwd;
703
		ms_message("auth_requested(): authenticating realm=%s, username=%s",realm,username);
703
		ms_message("auth_requested(): authenticating realm=%s, username=%s",realm,username);
704
		sal_op_authenticate(h,&sai);
704
		sal_op_authenticate(lc->sal,h,&sai);
705
		ai->usecount++;
705
		ai->usecount++;
706
		ai->last_use_time=ms_time(NULL);
706
		ai->last_use_time=ms_time(NULL);
707
	}else{
707
	}else{
Lines 936-941 static int op_equals(LinphoneCall *a, Sa Link Here
936
	return a->op !=b; /*return 0 if equals*/
936
	return a->op !=b; /*return 0 if equals*/
937
}
937
}
938
static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status){
938
static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status){
939
	LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
939
	LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )sal_op_get_user_pointer(op);
940
	LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )sal_op_get_user_pointer(op);
940
	const MSList* calls = linphone_core_get_calls(chat_msg->chat_room->lc);
941
	const MSList* calls = linphone_core_get_calls(chat_msg->chat_room->lc);
941
	
942
	
Lines 950-956 static void text_delivery_update(SalOp * Link Here
950
	
951
	
951
	if (!ms_list_find_custom((MSList*)calls, (MSCompareFunc) op_equals, op)) {
952
	if (!ms_list_find_custom((MSList*)calls, (MSCompareFunc) op_equals, op)) {
952
		/*op was only create for messaging purpose, destroying*/
953
		/*op was only create for messaging purpose, destroying*/
953
		sal_op_release(op);
954
		sal_op_release(lc->sal, op);
954
	}
955
	}
955
}
956
}
956
957
957
-- a/coreapi/chat.c
958
++ b/coreapi/chat.c
Lines 98-107 static void _linphone_chat_room_send_mes Link Here
98
	}
98
	}
99
	if (msg->external_body_url) {
99
	if (msg->external_body_url) {
100
		content_type=ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"",msg->external_body_url);
100
		content_type=ms_strdup_printf("message/external-body; access-type=URL; URL=\"%s\"",msg->external_body_url);
101
		sal_message_send(op,identity,cr->peer,content_type, NULL);
101
		sal_message_send(cr->lc->sal,op,identity,cr->peer,content_type, NULL);
102
		ms_free(content_type);
102
		ms_free(content_type);
103
	} else {
103
	} else {
104
		sal_text_send(op, identity, cr->peer,msg->message);
104
		sal_text_send(cr->lc->sal, op, identity, cr->peer,msg->message);
105
	}
105
	}
106
	msg->dir=LinphoneChatMessageOutgoing;
106
	msg->dir=LinphoneChatMessageOutgoing;
107
	msg->from=linphone_address_new(identity);
107
	msg->from=linphone_address_new(identity);
108
-- a/coreapi/friend.c
108
++ b/coreapi/friend.c
Lines 131-143 void __linphone_friend_do_subscribe(Linp Link Here
131
			fr->lc->vtable.notify_recv(fr->lc,(LinphoneFriend*)fr);
131
			fr->lc->vtable.notify_recv(fr->lc,(LinphoneFriend*)fr);
132
		 */
132
		 */
133
	}else{
133
	}else{
134
		sal_op_release(fr->outsub);
134
		sal_op_release(fr->lc->sal,fr->outsub);
135
		fr->outsub=NULL;
135
		fr->outsub=NULL;
136
	}
136
	}
137
	fr->outsub=sal_op_new(fr->lc->sal);
137
	fr->outsub=sal_op_new(fr->lc->sal);
138
	sal_op_set_route(fr->outsub,route);
138
	sal_op_set_route(fr->outsub,route);
139
	sal_op_set_contact(fr->outsub,fixed_contact);
139
	sal_op_set_contact(fr->outsub,fixed_contact);
140
	sal_subscribe_presence(fr->outsub,from,friend);
140
	sal_subscribe_presence(fr->lc->sal,fr->outsub,from,friend);
141
	fr->subscribe_active=TRUE;
141
	fr->subscribe_active=TRUE;
142
	ms_free(friend);
142
	ms_free(friend);
143
}
143
}
Lines 278-290 void linphone_friend_notify(LinphoneFrie Link Here
278
	ms_message("Want to notify %s, insub=%p",addr,lf->insub);
278
	ms_message("Want to notify %s, insub=%p",addr,lf->insub);
279
	ms_free(addr);
279
	ms_free(addr);
280
	if (lf->insub!=NULL){
280
	if (lf->insub!=NULL){
281
		sal_notify_presence(lf->insub,linphone_online_status_to_sal(os),NULL);
281
		sal_notify_presence(lf->lc->sal,lf->insub,linphone_online_status_to_sal(os),NULL);
282
	}
282
	}
283
}
283
}
284
284
285
static void linphone_friend_unsubscribe(LinphoneFriend *lf){
285
static void linphone_friend_unsubscribe(LinphoneFriend *lf){
286
	if (lf->outsub!=NULL) {
286
	if (lf->outsub!=NULL) {
287
		sal_unsubscribe(lf->outsub);
287
		sal_unsubscribe(lf->lc->sal,lf->outsub);
288
		lf->subscribe_active=FALSE;
288
		lf->subscribe_active=FALSE;
289
	}
289
	}
290
}
290
}
Lines 292-309 static void linphone_friend_unsubscribe( Link Here
292
void linphone_friend_close_subscriptions(LinphoneFriend *lf){
292
void linphone_friend_close_subscriptions(LinphoneFriend *lf){
293
	linphone_friend_unsubscribe(lf);
293
	linphone_friend_unsubscribe(lf);
294
	if (lf->insub){
294
	if (lf->insub){
295
		sal_notify_close(lf->insub);
295
		sal_notify_close(lf->lc->sal,lf->insub);
296
		
296
		
297
	}
297
	}
298
}
298
}
299
299
300
void linphone_friend_destroy(LinphoneFriend *lf){
300
void linphone_friend_destroy(LinphoneFriend *lf){
301
	if (lf->insub) {
301
	if (lf->insub) {
302
		sal_op_release(lf->insub);
302
		sal_op_release(lf->lc->sal,lf->insub);
303
		lf->insub=NULL;
303
		lf->insub=NULL;
304
	}
304
	}
305
	if (lf->outsub){
305
	if (lf->outsub){
306
		sal_op_release(lf->outsub);
306
		sal_op_release(lf->lc->sal,lf->outsub);
307
		lf->outsub=NULL;
307
		lf->outsub=NULL;
308
	}
308
	}
309
	if (lf->uri!=NULL) linphone_address_destroy(lf->uri);
309
	if (lf->uri!=NULL) linphone_address_destroy(lf->uri);
310
-- a/coreapi/linphonecall.c
310
++ b/coreapi/linphonecall.c
Lines 526-532 LinphoneCall * linphone_call_new_incomin Link Here
526
			from_str=linphone_address_as_string_uri_only(from);
526
			from_str=linphone_address_as_string_uri_only(from);
527
			sal_op_set_route(call->ping_op,sal_op_get_network_origin(op));
527
			sal_op_set_route(call->ping_op,sal_op_get_network_origin(op));
528
			sal_op_set_user_pointer(call->ping_op,call);
528
			sal_op_set_user_pointer(call->ping_op,call);
529
			sal_ping(call->ping_op,linphone_core_find_best_identity(lc,from,NULL),from_str);
529
			sal_ping(lc->sal,call->ping_op,linphone_core_find_best_identity(lc,from,NULL),from_str);
530
			ms_free(from_str);
530
			ms_free(from_str);
531
		}
531
		}
532
	}
532
	}
Lines 714-720 void linphone_call_set_state(LinphoneCal Link Here
714
			if (call->op!=NULL) {
714
			if (call->op!=NULL) {
715
				/* so that we cannot have anymore upcalls for SAL
715
				/* so that we cannot have anymore upcalls for SAL
716
				 concerning this call*/
716
				 concerning this call*/
717
				sal_op_release(call->op);
717
				sal_op_release(lc->sal,call->op);
718
				call->op=NULL;
718
				call->op=NULL;
719
			}
719
			}
720
			linphone_call_unref(call);
720
			linphone_call_unref(call);
Lines 729-735 static void linphone_call_destroy(Linpho Link Here
729
#endif //BUILD_UPNP
729
#endif //BUILD_UPNP
730
	linphone_call_delete_ice_session(obj);
730
	linphone_call_delete_ice_session(obj);
731
	if (obj->op!=NULL) {
731
	if (obj->op!=NULL) {
732
		sal_op_release(obj->op);
732
		sal_op_release(obj->core->sal,obj->op);
733
		obj->op=NULL;
733
		obj->op=NULL;
734
	}
734
	}
735
	if (obj->resultdesc!=NULL) {
735
	if (obj->resultdesc!=NULL) {
Lines 741-747 static void linphone_call_destroy(Linpho Link Here
741
		obj->localdesc=NULL;
741
		obj->localdesc=NULL;
742
	}
742
	}
743
	if (obj->ping_op) {
743
	if (obj->ping_op) {
744
		sal_op_release(obj->ping_op);
744
		sal_op_release(obj->core->sal,obj->ping_op);
745
	}
745
	}
746
	if (obj->refer_to){
746
	if (obj->refer_to){
747
		ms_free(obj->refer_to);
747
		ms_free(obj->refer_to);
Lines 956-962 int linphone_call_get_duration(const Lin Link Here
956
 * This function allows the application to know whether a new incoming call is a one that replaces another one.
956
 * This function allows the application to know whether a new incoming call is a one that replaces another one.
957
**/
957
**/
958
LinphoneCall *linphone_call_get_replaced_call(LinphoneCall *call){
958
LinphoneCall *linphone_call_get_replaced_call(LinphoneCall *call){
959
	SalOp *op=sal_call_get_replaces(call->op);
959
	SalOp *op=sal_call_get_replaces(call->core->sal,call->op);
960
	if (op){
960
	if (op){
961
		return (LinphoneCall*)sal_op_get_user_pointer(op);
961
		return (LinphoneCall*)sal_op_get_user_pointer(op);
962
	}
962
	}
Lines 987-993 void linphone_call_enable_camera (Linpho Link Here
987
void linphone_call_send_vfu_request(LinphoneCall *call)
987
void linphone_call_send_vfu_request(LinphoneCall *call)
988
{
988
{
989
	if (LinphoneCallStreamsRunning == linphone_call_get_state(call))
989
	if (LinphoneCallStreamsRunning == linphone_call_get_state(call))
990
		sal_call_send_vfu_request(call->op);
990
		sal_call_send_vfu_request(call->core->sal,call->op);
991
}
991
}
992
#endif
992
#endif
993
993
994
-- a/coreapi/linphonecore.c
994
++ b/coreapi/linphonecore.c
Lines 27-32 Foundation, Inc., 59 Temple Place - Suit Link Here
27
#include <math.h>
27
#include <math.h>
28
#include <ortp/telephonyevents.h>
28
#include <ortp/telephonyevents.h>
29
#include <ortp/zrtp.h>
29
#include <ortp/zrtp.h>
30
31
#ifdef HAVE_EXOSIP2_EXOSIP_H
32
#include <eXosip2/eXosip.h>
33
#endif
34
30
#include "mediastreamer2/mediastream.h"
35
#include "mediastreamer2/mediastream.h"
31
#include "mediastreamer2/mseventqueue.h"
36
#include "mediastreamer2/mseventqueue.h"
32
#include "mediastreamer2/msvolume.h"
37
#include "mediastreamer2/msvolume.h"
Lines 1773-1782 int linphone_core_get_sip_port(LinphoneC Link Here
1773
static char _ua_name[64]="Linphone";
1778
static char _ua_name[64]="Linphone";
1774
static char _ua_version[64]=LINPHONE_VERSION;
1779
static char _ua_version[64]=LINPHONE_VERSION;
1775
1780
1776
#ifdef HAVE_EXOSIP_GET_VERSION
1777
extern const char *eXosip_get_version();
1778
#endif
1779
1780
static void apply_user_agent(LinphoneCore *lc){
1781
static void apply_user_agent(LinphoneCore *lc){
1781
	char ua_string[256];
1782
	char ua_string[256];
1782
	snprintf(ua_string,sizeof(ua_string)-1,"%s/%s (eXosip2/%s)",_ua_name,_ua_version,
1783
	snprintf(ua_string,sizeof(ua_string)-1,"%s/%s (eXosip2/%s)",_ua_name,_ua_version,
Lines 2302-2308 void linphone_core_start_refered_call(Li Link Here
2302
2303
2303
void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, LinphoneCall *newcall){
2304
void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, LinphoneCall *newcall){
2304
	if (referer->op!=NULL){
2305
	if (referer->op!=NULL){
2305
		sal_call_notify_refer_state(referer->op,newcall ? newcall->op : NULL);
2306
		sal_call_notify_refer_state(lc->sal,referer->op,newcall ? newcall->op : NULL);
2306
	}
2307
	}
2307
}
2308
}
2308
2309
Lines 2445-2451 int linphone_core_start_invite(LinphoneC Link Here
2445
	}
2446
	}
2446
	real_url=linphone_address_as_string(call->log->to);
2447
	real_url=linphone_address_as_string(call->log->to);
2447
	from=linphone_address_as_string(call->log->from);
2448
	from=linphone_address_as_string(call->log->from);
2448
	err=sal_call(call->op,from,real_url);
2449
	err=sal_call(lc->sal,call->op,from,real_url);
2449
	call->log->call_id=ms_strdup(sal_op_get_call_id(call->op)); /*must be known at that time*/
2450
	call->log->call_id=ms_strdup(sal_op_get_call_id(call->op)); /*must be known at that time*/
2450
2451
2451
	if (lc->sip_conf.sdp_200_ack){
2452
	if (lc->sip_conf.sdp_200_ack){
Lines 2642-2648 LinphoneCall * linphone_core_invite_addr Link Here
2642
			/*defer the start of the call after the OPTIONS ping*/
2643
			/*defer the start of the call after the OPTIONS ping*/
2643
			call->ping_replied=FALSE;
2644
			call->ping_replied=FALSE;
2644
			call->ping_op=sal_op_new(lc->sal);
2645
			call->ping_op=sal_op_new(lc->sal);
2645
			sal_ping(call->ping_op,from,real_url);
2646
			sal_ping(lc->sal,call->ping_op,from,real_url);
2646
			sal_op_set_user_pointer(call->ping_op,call);
2647
			sal_op_set_user_pointer(call->ping_op,call);
2647
			call->start_time=time(NULL);
2648
			call->start_time=time(NULL);
2648
			defer = TRUE;
2649
			defer = TRUE;
Lines 2677-2683 int linphone_core_transfer_call(Linphone Link Here
2677
	}
2678
	}
2678
	//lc->call=NULL; //Do not do that you will lose the call afterward . . .
2679
	//lc->call=NULL; //Do not do that you will lose the call afterward . . .
2679
	real_url=linphone_address_as_string (real_parsed_url);
2680
	real_url=linphone_address_as_string (real_parsed_url);
2680
	sal_call_refer(call->op,real_url);
2681
	sal_call_refer(lc->sal,call->op,real_url);
2681
	ms_free(real_url);
2682
	ms_free(real_url);
2682
	linphone_address_destroy(real_parsed_url);
2683
	linphone_address_destroy(real_parsed_url);
2683
	linphone_call_set_transfer_state(call, LinphoneCallOutgoingInit);
2684
	linphone_call_set_transfer_state(call, LinphoneCallOutgoingInit);
Lines 2699-2705 int linphone_core_transfer_call(Linphone Link Here
2699
 * close the call with us (the 'dest' call).
2700
 * close the call with us (the 'dest' call).
2700
**/
2701
**/
2701
int linphone_core_transfer_call_to_another(LinphoneCore *lc, LinphoneCall *call, LinphoneCall *dest){
2702
int linphone_core_transfer_call_to_another(LinphoneCore *lc, LinphoneCall *call, LinphoneCall *dest){
2702
	int result = sal_call_refer_with_replaces (call->op,dest->op);
2703
	int result = sal_call_refer_with_replaces (lc->sal,call->op,dest->op);
2703
	linphone_call_set_transfer_state(call, LinphoneCallOutgoingInit);
2704
	linphone_call_set_transfer_state(call, LinphoneCallOutgoingInit);
2704
	return result;
2705
	return result;
2705
}
2706
}
Lines 2741-2747 void linphone_core_notify_incoming_call( Link Here
2741
	md=sal_call_get_final_media_description(call->op);
2742
	md=sal_call_get_final_media_description(call->op);
2742
	if (md){
2743
	if (md){
2743
		if (sal_media_description_empty(md) || linphone_core_incompatible_security(lc,md)){
2744
		if (sal_media_description_empty(md) || linphone_core_incompatible_security(lc,md)){
2744
			sal_call_decline(call->op,SalReasonMedia,NULL);
2745
			sal_call_decline(lc->sal,call->op,SalReasonMedia,NULL);
2745
			linphone_call_unref(call);
2746
			linphone_call_unref(call);
2746
			return;
2747
			return;
2747
		}
2748
		}
Lines 2785-2798 void linphone_core_notify_incoming_call( Link Here
2785
	linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
2786
	linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
2786
2787
2787
	if (call->state==LinphoneCallIncomingReceived){
2788
	if (call->state==LinphoneCallIncomingReceived){
2788
		sal_call_notify_ringing(call->op,propose_early_media || ringback_tone!=NULL);
2789
		sal_call_notify_ringing(lc->sal,call->op,propose_early_media || ringback_tone!=NULL);
2789
2790
2790
		if (propose_early_media || ringback_tone!=NULL){
2791
		if (propose_early_media || ringback_tone!=NULL){
2791
			linphone_call_set_state(call,LinphoneCallIncomingEarlyMedia,"Incoming call early media");
2792
			linphone_call_set_state(call,LinphoneCallIncomingEarlyMedia,"Incoming call early media");
2792
			md=sal_call_get_final_media_description(call->op);
2793
			md=sal_call_get_final_media_description(call->op);
2793
			linphone_core_update_streams(lc,call,md);
2794
			linphone_core_update_streams(lc,call,md);
2794
		}
2795
		}
2795
		if (sal_call_get_replaces(call->op)!=NULL && lp_config_get_int(lc->config,"sip","auto_answer_replacing_calls",1)){
2796
		if (sal_call_get_replaces(lc->sal,call->op)!=NULL && lp_config_get_int(lc->config,"sip","auto_answer_replacing_calls",1)){
2796
			linphone_core_accept_call(lc,call);
2797
			linphone_core_accept_call(lc,call);
2797
		}
2798
		}
2798
	}
2799
	}
Lines 2821-2827 int linphone_core_start_update_call(Linp Link Here
2821
	if (lc->vtable.display_status)
2822
	if (lc->vtable.display_status)
2822
		lc->vtable.display_status(lc,_("Modifying call parameters..."));
2823
		lc->vtable.display_status(lc,_("Modifying call parameters..."));
2823
	sal_call_set_local_media_description (call->op,call->localdesc);
2824
	sal_call_set_local_media_description (call->op,call->localdesc);
2824
	return sal_call_update(call->op,subject);
2825
	return sal_call_update(lc->sal,call->op,subject);
2825
}
2826
}
2826
2827
2827
/**
2828
/**
Lines 2950-2956 int linphone_core_start_accept_call_upda Link Here
2950
#endif //BUILD_UPNP
2951
#endif //BUILD_UPNP
2951
	linphone_call_update_remote_session_id_and_ver(call);
2952
	linphone_call_update_remote_session_id_and_ver(call);
2952
	sal_call_set_local_media_description(call->op,call->localdesc);
2953
	sal_call_set_local_media_description(call->op,call->localdesc);
2953
	sal_call_accept(call->op);
2954
	sal_call_accept(lc->sal,call->op);
2954
	md=sal_call_get_final_media_description(call->op);
2955
	md=sal_call_get_final_media_description(call->op);
2955
	if (md && !sal_media_description_empty(md))
2956
	if (md && !sal_media_description_empty(md))
2956
		linphone_core_update_streams (lc,call,md);
2957
		linphone_core_update_streams (lc,call,md);
Lines 2993-2999 int linphone_core_accept_call_update(Lin Link Here
2993
	if (keep_sdp_version &&(remote_desc->session_id == call->remote_session_id) && (remote_desc->session_ver == call->remote_session_ver)) {
2994
	if (keep_sdp_version &&(remote_desc->session_id == call->remote_session_id) && (remote_desc->session_ver == call->remote_session_ver)) {
2994
		/* Remote has sent an INVITE with the same SDP as before, so send a 200 OK with the same SDP as before. */
2995
		/* Remote has sent an INVITE with the same SDP as before, so send a 200 OK with the same SDP as before. */
2995
		ms_warning("SDP version has not changed, send same SDP as before.");
2996
		ms_warning("SDP version has not changed, send same SDP as before.");
2996
		sal_call_accept(call->op);
2997
		sal_call_accept(lc->sal,call->op);
2997
		linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
2998
		linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
2998
		return 0;
2999
		return 0;
2999
	}
3000
	}
Lines 3101-3107 int linphone_core_accept_call_with_param Link Here
3101
	}
3102
	}
3102
3103
3103
	/* check if this call is supposed to replace an already running one*/
3104
	/* check if this call is supposed to replace an already running one*/
3104
	replaced=sal_call_get_replaces(call->op);
3105
	replaced=sal_call_get_replaces(lc->sal,call->op);
3105
	if (replaced){
3106
	if (replaced){
3106
		LinphoneCall *rc=(LinphoneCall*)sal_op_get_user_pointer (replaced);
3107
		LinphoneCall *rc=(LinphoneCall*)sal_op_get_user_pointer (replaced);
3107
		if (rc){
3108
		if (rc){
Lines 3159-3165 int linphone_core_accept_call_with_param Link Here
3159
	}
3160
	}
3160
3161
3161
	linphone_call_update_remote_session_id_and_ver(call);
3162
	linphone_call_update_remote_session_id_and_ver(call);
3162
	sal_call_accept(call->op);
3163
	sal_call_accept(lc->sal,call->op);
3163
	if (lc->vtable.display_status!=NULL)
3164
	if (lc->vtable.display_status!=NULL)
3164
		lc->vtable.display_status(lc,_("Connected."));
3165
		lc->vtable.display_status(lc,_("Connected."));
3165
	lc->current_call=call;
3166
	lc->current_call=call;
Lines 3175-3181 int linphone_core_accept_call_with_param Link Here
3175
}
3176
}
3176
3177
3177
int linphone_core_abort_call(LinphoneCore *lc, LinphoneCall *call, const char *error){
3178
int linphone_core_abort_call(LinphoneCore *lc, LinphoneCall *call, const char *error){
3178
	sal_call_terminate(call->op);
3179
	sal_call_terminate(lc->sal,call->op);
3179
3180
3180
	/*stop ringing*/
3181
	/*stop ringing*/
3181
	if (lc->ringstream!=NULL) {
3182
	if (lc->ringstream!=NULL) {
Lines 3218-3224 static void terminate_call(LinphoneCore Link Here
3218
3219
3219
int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri){
3220
int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri){
3220
	if (call->state==LinphoneCallIncomingReceived){
3221
	if (call->state==LinphoneCallIncomingReceived){
3221
		sal_call_decline(call->op,SalReasonRedirect,redirect_uri);
3222
		sal_call_decline(lc->sal,call->op,SalReasonRedirect,redirect_uri);
3222
		call->reason=LinphoneReasonDeclined;
3223
		call->reason=LinphoneReasonDeclined;
3223
		terminate_call(lc,call);
3224
		terminate_call(lc,call);
3224
	}else{
3225
	}else{
Lines 3252-3258 int linphone_core_terminate_call(Linphon Link Here
3252
	{
3253
	{
3253
		call = the_call;
3254
		call = the_call;
3254
	}
3255
	}
3255
	sal_call_terminate(call->op);
3256
	sal_call_terminate(lc->sal,call->op);
3256
	terminate_call(lc,call);
3257
	terminate_call(lc,call);
3257
	return 0;
3258
	return 0;
3258
}
3259
}
Lines 3284-3290 int linphone_core_decline_call(LinphoneC Link Here
3284
			return -1;
3285
			return -1;
3285
		break;
3286
		break;
3286
	}
3287
	}
3287
	sal_call_decline(call->op,sal_reason,NULL);
3288
	sal_call_decline(lc->sal,call->op,sal_reason,NULL);
3288
	terminate_call(lc,call);
3289
	terminate_call(lc,call);
3289
	return 0;
3290
	return 0;
3290
}
3291
}
Lines 3378-3384 int _linphone_core_pause_call(LinphoneCo Link Here
3378
		return -1;
3379
		return -1;
3379
	}
3380
	}
3380
	sal_call_set_local_media_description(call->op,call->localdesc);
3381
	sal_call_set_local_media_description(call->op,call->localdesc);
3381
	if (sal_call_update(call->op,subject) != 0){
3382
	if (sal_call_update(lc->sal,call->op,subject) != 0){
3382
		if (lc->vtable.display_warning)
3383
		if (lc->vtable.display_warning)
3383
			lc->vtable.display_warning(lc,_("Could not pause the call"));
3384
			lc->vtable.display_warning(lc,_("Could not pause the call"));
3384
	}
3385
	}
Lines 3461-3467 int linphone_core_resume_call(LinphoneCo Link Here
3461
	sal_call_set_local_media_description(call->op,call->localdesc);
3462
	sal_call_set_local_media_description(call->op,call->localdesc);
3462
	sal_media_description_set_dir(call->localdesc,SalStreamSendRecv);
3463
	sal_media_description_set_dir(call->localdesc,SalStreamSendRecv);
3463
	if (call->params.in_conference && !call->current_params.in_conference) subject="Conference";
3464
	if (call->params.in_conference && !call->current_params.in_conference) subject="Conference";
3464
	if(sal_call_update(call->op,subject) != 0){
3465
	if(sal_call_update(lc->sal,call->op,subject) != 0){
3465
		return -1;
3466
		return -1;
3466
	}
3467
	}
3467
	linphone_call_set_state (call,LinphoneCallResuming,"Resuming");
3468
	linphone_call_set_state (call,LinphoneCallResuming,"Resuming");
Lines 4177-4183 void linphone_core_send_dtmf(LinphoneCor Link Here
4177
	}
4178
	}
4178
	if (linphone_core_get_use_info_for_dtmf(lc)!=0){
4179
	if (linphone_core_get_use_info_for_dtmf(lc)!=0){
4179
		/* Out of Band DTMF (use INFO method) */
4180
		/* Out of Band DTMF (use INFO method) */
4180
		sal_call_send_dtmf(call->op,dtmf);
4181
		sal_call_send_dtmf(lc->sal,call->op,dtmf);
4181
	}
4182
	}
4182
}
4183
}
4183
4184
4184
-- a/coreapi/presence.c
4185
++ b/coreapi/presence.c
Lines 79-99 void linphone_subscription_new(LinphoneC Link Here
79
	if (linphone_find_friend(lc->friends,uri,&lf)!=NULL){
79
	if (linphone_find_friend(lc->friends,uri,&lf)!=NULL){
80
		lf->insub=op;
80
		lf->insub=op;
81
		lf->inc_subscribe_pending=TRUE;
81
		lf->inc_subscribe_pending=TRUE;
82
		sal_subscribe_accept(op);
82
		sal_subscribe_accept(lc->sal,op);
83
		linphone_friend_done(lf);	/*this will do all necessary actions */
83
		linphone_friend_done(lf);	/*this will do all necessary actions */
84
	}else{
84
	}else{
85
		/* check if this subscriber is in our black list */
85
		/* check if this subscriber is in our black list */
86
		if (linphone_find_friend(lc->subscribers,uri,&lf)){
86
		if (linphone_find_friend(lc->subscribers,uri,&lf)){
87
			if (lf->pol==LinphoneSPDeny){
87
			if (lf->pol==LinphoneSPDeny){
88
				ms_message("Rejecting %s because we already rejected it once.",from);
88
				ms_message("Rejecting %s because we already rejected it once.",from);
89
				sal_subscribe_decline(op);
89
				sal_subscribe_decline(lc->sal,op);
90
			}
90
			}
91
			else {
91
			else {
92
				/* else it is in wait for approval state, because otherwise it is in the friend list.*/
92
				/* else it is in wait for approval state, because otherwise it is in the friend list.*/
93
				ms_message("New subscriber found in friend list, in %s state.",__policy_enum_to_str(lf->pol));
93
				ms_message("New subscriber found in friend list, in %s state.",__policy_enum_to_str(lf->pol));
94
			}
94
			}
95
		}else {
95
		}else {
96
			sal_subscribe_accept(op);
96
			sal_subscribe_accept(lc->sal,op);
97
			linphone_core_add_subscriber(lc,tmp,op);
97
			linphone_core_add_subscriber(lc,tmp,op);
98
		}
98
		}
99
	}
99
	}
Lines 150-156 void linphone_notify_recv(LinphoneCore * Link Here
150
		ms_message("But this person is not part of our friend list, so we don't care.");
150
		ms_message("But this person is not part of our friend list, so we don't care.");
151
	}
151
	}
152
	if (ss==SalSubscribeTerminated){
152
	if (ss==SalSubscribeTerminated){
153
		sal_op_release(op);
153
		sal_op_release(lc->sal,op);
154
		if (lf){
154
		if (lf){
155
			lf->outsub=NULL;
155
			lf->outsub=NULL;
156
			lf->subscribe_active=FALSE;
156
			lf->subscribe_active=FALSE;
Lines 161-167 void linphone_notify_recv(LinphoneCore * Link Here
161
void linphone_subscription_closed(LinphoneCore *lc, SalOp *op){
161
void linphone_subscription_closed(LinphoneCore *lc, SalOp *op){
162
	LinphoneFriend *lf;
162
	LinphoneFriend *lf;
163
	lf=linphone_find_friend_by_inc_subscribe(lc->friends,op);
163
	lf=linphone_find_friend_by_inc_subscribe(lc->friends,op);
164
	sal_op_release(op);
164
	sal_op_release(lc->sal,op);
165
	if (lf!=NULL){
165
	if (lf!=NULL){
166
		lf->insub=NULL;
166
		lf->insub=NULL;
167
	}else{
167
	}else{
168
-- a/coreapi/proxy.c
168
++ b/coreapi/proxy.c
Lines 84-91 void linphone_proxy_config_destroy(Linph Link Here
84
	if (obj->realm!=NULL) ms_free(obj->realm);
84
	if (obj->realm!=NULL) ms_free(obj->realm);
85
	if (obj->type!=NULL) ms_free(obj->type);
85
	if (obj->type!=NULL) ms_free(obj->type);
86
	if (obj->dial_prefix!=NULL) ms_free(obj->dial_prefix);
86
	if (obj->dial_prefix!=NULL) ms_free(obj->dial_prefix);
87
	if (obj->op) sal_op_release(obj->op);
87
	if (obj->op) sal_op_release(obj->lc->sal, obj->op);
88
	if (obj->publish_op) sal_op_release(obj->publish_op);
88
	if (obj->publish_op) sal_op_release(obj->lc->sal,obj->publish_op);
89
}
89
}
90
90
91
/**
91
/**
Lines 245-251 void linphone_proxy_config_edit(Linphone Link Here
245
	if (obj->reg_sendregister){
245
	if (obj->reg_sendregister){
246
		/* unregister */
246
		/* unregister */
247
		if (obj->state != LinphoneRegistrationNone && obj->state != LinphoneRegistrationCleared) {
247
		if (obj->state != LinphoneRegistrationNone && obj->state != LinphoneRegistrationCleared) {
248
			sal_unregister(obj->op);
248
			sal_unregister(obj->lc->sal,obj->op);
249
		}
249
		}
250
	}
250
	}
251
}
251
}
Lines 312-324 static void linphone_proxy_config_regist Link Here
312
	if (obj->reg_sendregister){
312
	if (obj->reg_sendregister){
313
		char *contact;
313
		char *contact;
314
		if (obj->op)
314
		if (obj->op)
315
			sal_op_release(obj->op);
315
			sal_op_release(obj->lc->sal,obj->op);
316
		obj->op=sal_op_new(obj->lc->sal);
316
		obj->op=sal_op_new(obj->lc->sal);
317
		contact=guess_contact_for_register(obj);
317
		contact=guess_contact_for_register(obj);
318
		sal_op_set_contact(obj->op,contact);
318
		sal_op_set_contact(obj->op,contact);
319
		ms_free(contact);
319
		ms_free(contact);
320
		sal_op_set_user_pointer(obj->op,obj);
320
		sal_op_set_user_pointer(obj->op,obj);
321
		if (sal_register(obj->op,obj->reg_proxy,obj->reg_identity,obj->expires)==0) {
321
		if (sal_register(obj->lc->sal,obj->op,obj->reg_proxy,obj->reg_identity,obj->expires)==0) {
322
			linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress,"Registration in progress");
322
			linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress,"Registration in progress");
323
		} else {
323
		} else {
324
			linphone_proxy_config_set_state(obj,LinphoneRegistrationFailed,"Registration failed");
324
			linphone_proxy_config_set_state(obj,LinphoneRegistrationFailed,"Registration failed");
Lines 332-338 static void linphone_proxy_config_regist Link Here
332
**/
332
**/
333
void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj){
333
void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj){
334
	if (obj->reg_sendregister && obj->op){
334
	if (obj->reg_sendregister && obj->op){
335
		if (sal_register_refresh(obj->op,obj->expires) == 0) {
335
		if (sal_register_refresh(obj->lc->sal,obj->op,obj->expires) == 0) {
336
			linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress, "Refresh registration");
336
			linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress, "Refresh registration");
337
		}
337
		}
338
	}
338
	}
Lines 793-802 int linphone_proxy_config_send_publish(L Link Here
793
	int err;
793
	int err;
794
	SalOp *op=sal_op_new(proxy->lc->sal);
794
	SalOp *op=sal_op_new(proxy->lc->sal);
795
	sal_op_set_route(op,proxy->reg_proxy);
795
	sal_op_set_route(op,proxy->reg_proxy);
796
	err=sal_publish(op,linphone_proxy_config_get_identity(proxy),
796
	err=sal_publish(proxy->lc->sal,op,linphone_proxy_config_get_identity(proxy),
797
	    linphone_proxy_config_get_identity(proxy),linphone_online_status_to_sal(presence_mode));
797
	    linphone_proxy_config_get_identity(proxy),linphone_online_status_to_sal(presence_mode));
798
	if (proxy->publish_op!=NULL)
798
	if (proxy->publish_op!=NULL)
799
		sal_op_release(proxy->publish_op);
799
		sal_op_release(proxy->lc->sal, proxy->publish_op);
800
	proxy->publish_op=op;
800
	proxy->publish_op=op;
801
	return err;
801
	return err;
802
}
802
}
803
-- a/coreapi/sal_eXosip2.c
803
++ b/coreapi/sal_eXosip2.c
Lines 46-52 void _osip_list_set_empty(osip_list_t *l Link Here
46
}
46
}
47
47
48
void sal_get_default_local_ip(Sal *sal, int address_family,char *ip, size_t iplen){
48
void sal_get_default_local_ip(Sal *sal, int address_family,char *ip, size_t iplen){
49
#ifdef HAVE_STRUCT_EXOSIP_T
50
	if (eXosip_guess_localip(sal->excontext, address_family, ip, iplen) < 0){
51
#else
49
	if (eXosip_guess_localip(address_family,ip,iplen)<0){
52
	if (eXosip_guess_localip(address_family,ip,iplen)<0){
53
#endif
50
		/*default to something */
54
		/*default to something */
51
		strncpy(ip,address_family==AF_INET6 ? "::1" : "127.0.0.1",iplen);
55
		strncpy(ip,address_family==AF_INET6 ? "::1" : "127.0.0.1",iplen);
52
		ms_error("Could not find default routable ip address !");
56
		ms_error("Could not find default routable ip address !");
Lines 185-198 bool_t sal_call_autoanswer_asked(SalOp * Link Here
185
	return op->auto_answer_asked;
189
	return op->auto_answer_asked;
186
}
190
}
187
191
188
void sal_op_release(SalOp *op){
192
void sal_op_release(Sal *ctx, SalOp *op){
189
	if (op->sdp_answer)
193
	if (op->sdp_answer)
190
		sdp_message_free(op->sdp_answer);
194
		sdp_message_free(op->sdp_answer);
191
	if (op->pending_auth)
195
	if (op->pending_auth)
192
		eXosip_event_free(op->pending_auth);
196
		eXosip_event_free(op->pending_auth);
193
	if (op->rid!=-1){
197
	if (op->rid!=-1){
194
		sal_remove_register(op->base.root,op->rid);
198
		sal_remove_register(op->base.root,op->rid);
195
		eXosip_register_remove(op->rid);
199
		eXosip_register_remove(ctx->excontext, op->rid);
196
	}
200
	}
197
	if (op->cid!=-1){
201
	if (op->cid!=-1){
198
		ms_message("Cleaning cid %i",op->cid);
202
		ms_message("Cleaning cid %i",op->cid);
Lines 273-280 Sal * sal_init(){ Link Here
273
		osip_trace_initialize_func (OSIP_INFO4,&_osip_trace_func);
277
		osip_trace_initialize_func (OSIP_INFO4,&_osip_trace_func);
274
		firsttime=FALSE;
278
		firsttime=FALSE;
275
	}
279
	}
276
	eXosip_init();
277
	sal=ms_new0(Sal,1);
280
	sal=ms_new0(Sal,1);
281
#ifdef HAVE_STRUCT_EXOSIP_T
282
	sal->excontext = eXosip_malloc();
283
	eXosip_init(sal->excontext);
284
	/* order with ms_new0 changed, maybe free(sal) on error? */
285
#else
286
	eXosip_init();
287
#endif
278
	sal->keepalive_period=30;
288
	sal->keepalive_period=30;
279
	sal->double_reg=TRUE;
289
	sal->double_reg=TRUE;
280
	sal->use_rports=TRUE;
290
	sal->use_rports=TRUE;
Lines 290-296 Sal * sal_init(){ Link Here
290
}
300
}
291
301
292
void sal_uninit(Sal* sal){
302
void sal_uninit(Sal* sal){
303
#ifdef HAVE_STRUCT_EXOSIP_T
304
	eXosip_quit(sal->excontext);
305
	free(sal->excontext);
306
#else
293
	eXosip_quit();
307
	eXosip_quit();
308
#endif
294
	if (sal->rootCa)
309
	if (sal->rootCa)
295
		ms_free(sal->rootCa);
310
		ms_free(sal->rootCa);
296
	ms_free(sal);
311
	ms_free(sal);
Lines 348-355 void sal_set_callbacks(Sal *ctx, const S Link Here
348
363
349
int sal_unlisten_ports(Sal *ctx){
364
int sal_unlisten_ports(Sal *ctx){
350
	if (ctx->running){
365
	if (ctx->running){
366
#ifdef HAVE_STRUCT_EXOSIP_T
367
		eXosip_quit(ctx->excontext);
368
#else
351
		eXosip_quit();
369
		eXosip_quit();
370
#endif
371
#ifdef HAVE_STRUCT_EXOSIP_T
372
		eXosip_init(ctx->excontext);
373
#else
352
		eXosip_init();
374
		eXosip_init();
375
#endif
353
		ctx->running=FALSE;
376
		ctx->running=FALSE;
354
	}
377
	}
355
	return 0;
378
	return 0;
Lines 359-371 int sal_reset_transports(Sal *ctx){ Link Here
359
#ifdef HAVE_EXOSIP_RESET_TRANSPORTS
382
#ifdef HAVE_EXOSIP_RESET_TRANSPORTS
360
	if (ctx->running){
383
	if (ctx->running){
361
		ms_message("Exosip transports reset.");
384
		ms_message("Exosip transports reset.");
385
#ifdef HAVE_STRUCT_EXOSIP_T
386
		eXosip_reset_transports(ctx->excontext);
387
#else
362
		eXosip_reset_transports();
388
		eXosip_reset_transports();
389
#endif
363
	}
390
	}
364
	return 0;
391
	return 0;
365
#else
392
#else /* HAVE_EXOSIP_RESET_TRANSPORTS */
366
	ms_warning("sal_reset_transports() not implemented in this version.");
393
	ms_warning("sal_reset_transports() not implemented in this version.");
367
	return -1;
394
	return -1;
368
#endif
395
#endif /* HAVE_EXOSIP_RESET_TRANSPORTS */
369
}
396
}
370
397
371
398
Lines 374-382 static void set_tls_options(Sal *ctx){ Link Here
374
		eXosip_tls_ctx_t tlsCtx;
401
		eXosip_tls_ctx_t tlsCtx;
375
		memset(&tlsCtx, 0, sizeof(tlsCtx));
402
		memset(&tlsCtx, 0, sizeof(tlsCtx));
376
		snprintf(tlsCtx.root_ca_cert, sizeof(tlsCtx.client.cert), "%s", ctx->rootCa);
403
		snprintf(tlsCtx.root_ca_cert, sizeof(tlsCtx.client.cert), "%s", ctx->rootCa);
404
#ifdef EXOSIP_OPT_SET_TLS_CERTIFICATES_INFO
405
		eXosip_set_option(ctx->excontext, EXOSIP_OPT_SET_TLS_CERTIFICATES_INFO, &tlsCtx);
406
#else
377
		eXosip_set_tls_ctx(&tlsCtx);
407
		eXosip_set_tls_ctx(&tlsCtx);
378
	}                       
408
#endif
379
#ifdef HAVE_EXOSIP_TLS_VERIFY_CERTIFICATE
409
	}
410
#ifdef EXOSIP_OPT_SET_TLS_VERIFY_CERTIFICATE
411
	eXosip_set_option(ctx->excontext, EXOSIP_OPT_SET_TLS_VERIFY_CERTIFICATE,
412
			  &ctx->verify_server_certs); 
413
#elif defined HAVE_EXOSIP_TLS_VERIFY_CERTIFICATE
380
	eXosip_tls_verify_certificate(ctx->verify_server_certs);
414
	eXosip_tls_verify_certificate(ctx->verify_server_certs);
381
#endif
415
#endif
382
#ifdef HAVE_EXOSIP_TLS_VERIFY_CN
416
#ifdef HAVE_EXOSIP_TLS_VERIFY_CN
Lines 386-395 static void set_tls_options(Sal *ctx){ Link Here
386
420
387
void sal_set_dscp(Sal *ctx, int dscp){
421
void sal_set_dscp(Sal *ctx, int dscp){
388
	ctx->dscp=dscp;
422
	ctx->dscp=dscp;
389
#ifdef HAVE_EXOSIP_DSCP
423
	if (dscp!=-1) {
390
	if (dscp!=-1)
424
#ifdef EXOSIP_OPT_SET_DSCP
425
#ifdef HAVE_STRUCT_EXOSIP_T
426
		eXosip_set_option(ctx->excontext, EXOSIP_OPT_SET_DSCP, &ctx->dscp);
427
#else
391
		eXosip_set_option(EXOSIP_OPT_SET_DSCP,&ctx->dscp);
428
		eXosip_set_option(EXOSIP_OPT_SET_DSCP,&ctx->dscp);
392
#endif
429
#endif
430
#endif /* EXOSIP_OPT_SET_DSCP */
431
        }
393
}
432
}
394
433
395
int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int is_secure){
434
int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int is_secure){
Lines 402-414 int sal_listen_port(Sal *ctx, const char Link Here
402
	switch (tr) {
441
	switch (tr) {
403
	case SalTransportUDP:
442
	case SalTransportUDP:
404
		proto=IPPROTO_UDP;
443
		proto=IPPROTO_UDP;
444
#ifdef HAVE_STRUCT_EXOSIP_T
445
		eXosip_set_option (ctx->excontext, EXOSIP_OPT_UDP_KEEP_ALIVE, &keepalive);
446
#else
405
		eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &keepalive);
447
		eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &keepalive);
448
#endif
406
		break;
449
		break;
407
	case SalTransportTCP:
450
	case SalTransportTCP:
408
	case SalTransportTLS:
451
	case SalTransportTLS:
409
		proto= IPPROTO_TCP;
452
		proto= IPPROTO_TCP;
410
		if (!ctx->tcp_tls_keepalive) keepalive=-1;
453
		if (!ctx->tcp_tls_keepalive) keepalive=-1;
454
#ifdef HAVE_STRUCT_EXOSIP_T
455
		eXosip_set_option (ctx->excontext, EXOSIP_OPT_UDP_KEEP_ALIVE, &keepalive);
456
#else
411
		eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE,&keepalive);
457
		eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE,&keepalive);
458
#endif
412
		set_tls_options(ctx);
459
		set_tls_options(ctx);
413
		break;
460
		break;
414
	default:
461
	default:
Lines 416-424 int sal_listen_port(Sal *ctx, const char Link Here
416
	}
463
	}
417
	/*see if it looks like an IPv6 address*/
464
	/*see if it looks like an IPv6 address*/
418
	int use_rports = ctx->use_rports; // Copy char to int to avoid bad alignment
465
	int use_rports = ctx->use_rports; // Copy char to int to avoid bad alignment
466
#ifdef HAVE_STRUCT_EXOSIP_T
467
	eXosip_set_option(ctx->excontext, EXOSIP_OPT_USE_RPORT, &use_rports);
468
#else
419
	eXosip_set_option(EXOSIP_OPT_USE_RPORT,&use_rports);
469
	eXosip_set_option(EXOSIP_OPT_USE_RPORT,&use_rports);
470
#endif
471
#ifdef EXOSIP_OPT_DONT_SEND_101
420
	int dont_use_101 = !ctx->use_101; // Copy char to int to avoid bad alignment
472
	int dont_use_101 = !ctx->use_101; // Copy char to int to avoid bad alignment
421
	eXosip_set_option(EXOSIP_OPT_DONT_SEND_101,&dont_use_101);
473
	eXosip_set_option(EXOSIP_OPT_DONT_SEND_101,&dont_use_101);
474
#endif
422
	sal_set_dscp(ctx,ctx->dscp);
475
	sal_set_dscp(ctx,ctx->dscp);
423
	sal_use_dates(ctx,ctx->add_dates);
476
	sal_use_dates(ctx,ctx->add_dates);
424
477
Lines 429-435 int sal_listen_port(Sal *ctx, const char Link Here
429
		ms_fatal("SIP over DTLS is not supported yet.");
482
		ms_fatal("SIP over DTLS is not supported yet.");
430
		return -1;
483
		return -1;
431
	}
484
	}
485
#ifdef HAVE_STRUCT_EXOSIP_T
486
	err=eXosip_listen_addr(ctx->excontext, proto, addr, port, ipv6 ?  PF_INET6 : PF_INET, is_secure);
487
#else
432
	err=eXosip_listen_addr(proto, addr, port, ipv6 ?  PF_INET6 : PF_INET, is_secure);
488
	err=eXosip_listen_addr(proto, addr, port, ipv6 ?  PF_INET6 : PF_INET, is_secure);
489
#endif
433
	ctx->running=TRUE;
490
	ctx->running=TRUE;
434
	return err;
491
	return err;
435
}
492
}
Lines 444-450 ortp_socket_t sal_get_socket(Sal *ctx){ Link Here
444
}
501
}
445
502
446
void sal_set_user_agent(Sal *ctx, const char *user_agent){
503
void sal_set_user_agent(Sal *ctx, const char *user_agent){
504
#ifdef HAVE_STRUCT_EXOSIP_T
505
	eXosip_set_user_agent(ctx->excontext, user_agent);
506
#else
447
	eXosip_set_user_agent(user_agent);
507
	eXosip_set_user_agent(user_agent);
508
#endif
448
}
509
}
449
510
450
void sal_use_session_timers(Sal *ctx, int expires){
511
void sal_use_session_timers(Sal *ctx, int expires){
Lines 472-482 void sal_use_dates(Sal *ctx, bool_t enab Link Here
472
#ifdef EXOSIP_OPT_REGISTER_WITH_DATE
533
#ifdef EXOSIP_OPT_REGISTER_WITH_DATE
473
	{
534
	{
474
		int tmp=enabled;
535
		int tmp=enabled;
536
#ifdef HAVE_STRUCT_EXOSIP_T
537
		eXosip_set_option(ctx->excontext, EXOSIP_OPT_REGISTER_WITH_DATE, &tmp);
538
#else
475
		eXosip_set_option(EXOSIP_OPT_REGISTER_WITH_DATE,&tmp);
539
		eXosip_set_option(EXOSIP_OPT_REGISTER_WITH_DATE,&tmp);
540
#endif
476
	}
541
	}
477
#else
542
#else /* EXOSIP_OPT_REGISTER_WITH_DATE */
478
	if (enabled) ms_warning("Exosip does not support EXOSIP_OPT_REGISTER_WITH_DATE option.");
543
	if (enabled) ms_warning("Exosip does not support EXOSIP_OPT_REGISTER_WITH_DATE option.");
479
#endif
544
#endif /* EXOSIP_OPT_REGISTER_WITH_DATE */
480
}
545
}
481
546
482
void sal_use_rport(Sal *ctx, bool_t use_rports){
547
void sal_use_rport(Sal *ctx, bool_t use_rports){
Lines 499-505 const char *sal_get_root_ca(Sal* ctx) { Link Here
499
564
500
void sal_verify_server_certificates(Sal *ctx, bool_t verify){
565
void sal_verify_server_certificates(Sal *ctx, bool_t verify){
501
	ctx->verify_server_certs=verify;
566
	ctx->verify_server_certs=verify;
502
#ifdef HAVE_EXOSIP_TLS_VERIFY_CERTIFICATE
567
#ifdef EXOSIP_OPT_SET_TLS_VERIFY_CERTIFICATE
568
	eXosip_set_option(ctx->excontext, EXOSIP_OPT_SET_TLS_VERIFY_CERTIFICATE, &verify); 
569
#elif defined HAVE_EXOSIP_TLS_VERIFY_CERTIFICATE
503
	eXosip_tls_verify_certificate(verify);
570
	eXosip_tls_verify_certificate(verify);
504
#endif
571
#endif
505
}
572
}
Lines 626-632 int sal_call_set_local_media_description Link Here
626
	return 0;
693
	return 0;
627
}
694
}
628
695
629
int sal_call(SalOp *h, const char *from, const char *to){
696
int sal_call(Sal *ctx, SalOp *h, const char *from, const char *to){
630
	int err;
697
	int err;
631
	const char *route;
698
	const char *route;
632
	osip_message_t *invite=NULL;
699
	osip_message_t *invite=NULL;
Lines 638-644 int sal_call(SalOp *h, const char *from, Link Here
638
	h->terminated = FALSE;
705
	h->terminated = FALSE;
639
706
640
	route = sal_op_get_route(h);
707
	route = sal_op_get_route(h);
708
#ifdef HAVE_STRUCT_EXOSIP_T
709
	err=eXosip_call_build_initial_invite(ctx->excontext, &invite, to, from, route, "Phone call");
710
#else
641
	err=eXosip_call_build_initial_invite(&invite,to,from,route,"Phone call");
711
	err=eXosip_call_build_initial_invite(&invite,to,from,route,"Phone call");
712
#endif
642
	if (err!=0){
713
	if (err!=0){
643
		ms_error("Could not create call. Error %d (from=%s to=%s route=%s)",
714
		ms_error("Could not create call. Error %d (from=%s to=%s route=%s)",
644
				err, from, to, route);
715
				err, from, to, route);
Lines 664-672 int sal_call(SalOp *h, const char *from, Link Here
664
			osip_message_set_header(invite,"Referred-By",h->referred_by);
735
			osip_message_set_header(invite,"Referred-By",h->referred_by);
665
	}
736
	}
666
	
737
	
738
#ifdef HAVE_STRUCT_EXOSIP_T
739
	eXosip_lock(ctx->excontext);
740
#else
667
	eXosip_lock();
741
	eXosip_lock();
742
#endif
743
#ifdef HAVE_STRUCT_EXOSIP_T
744
	err=eXosip_call_send_initial_invite(ctx->excontext, invite);
745
#else
668
	err=eXosip_call_send_initial_invite(invite);
746
	err=eXosip_call_send_initial_invite(invite);
747
#endif
748
#ifdef HAVE_STRUCT_EXOSIP_T
749
	eXosip_unlock(ctx->excontext);
750
#else
669
	eXosip_unlock();
751
	eXosip_unlock();
752
#endif
670
	h->cid=err;
753
	h->cid=err;
671
	if (err<0){
754
	if (err<0){
672
		ms_error("Fail to send invite ! Error code %d", err);
755
		ms_error("Fail to send invite ! Error code %d", err);
Lines 682-695 int sal_call(SalOp *h, const char *from, Link Here
682
	return 0;
765
	return 0;
683
}
766
}
684
767
685
int sal_call_notify_ringing(SalOp *h, bool_t early_media){
768
int sal_call_notify_ringing(Sal *ctx, SalOp *h, bool_t early_media){
686
	osip_message_t *msg;
769
	osip_message_t *msg;
687
	
770
	
688
	/*if early media send also 180 and 183 */
771
	/*if early media send also 180 and 183 */
689
	if (early_media){
772
	if (early_media){
690
		msg=NULL;
773
		msg=NULL;
774
#ifdef HAVE_STRUCT_EXOSIP_T
775
		eXosip_lock(ctx->excontext);
776
#else
691
		eXosip_lock();
777
		eXosip_lock();
778
#endif
779
#ifdef HAVE_STRUCT_EXOSIP_T
780
		eXosip_call_build_answer(ctx->excontext, h->tid, 183, &msg);
781
#else
692
		eXosip_call_build_answer(h->tid,183,&msg);
782
		eXosip_call_build_answer(h->tid,183,&msg);
783
#endif
693
		if (msg){
784
		if (msg){
694
			sdp_process(h);
785
			sdp_process(h);
695
			if (h->sdp_answer){
786
			if (h->sdp_answer){
Lines 697-718 int sal_call_notify_ringing(SalOp *h, bo Link Here
697
				sdp_message_free(h->sdp_answer);
788
				sdp_message_free(h->sdp_answer);
698
				h->sdp_answer=NULL;
789
				h->sdp_answer=NULL;
699
			}
790
			}
791
#ifdef HAVE_STRUCT_EXOSIP_T
792
			eXosip_call_send_answer(ctx->excontext, h->tid, 183, msg);
793
#else
700
			eXosip_call_send_answer(h->tid,183,msg);
794
			eXosip_call_send_answer(h->tid,183,msg);
795
#endif
701
		}
796
		}
797
#ifdef HAVE_STRUCT_EXOSIP_T
798
		eXosip_unlock(ctx->excontext);
799
#else
702
		eXosip_unlock();
800
		eXosip_unlock();
801
#endif
703
	}else{
802
	}else{
803
#ifdef HAVE_STRUCT_EXOSIP_T
804
		eXosip_lock(ctx->excontext);
805
#else
704
		eXosip_lock();
806
		eXosip_lock();
807
#endif
808
#ifdef HAVE_STRUCT_EXOSIP_T
809
		eXosip_call_send_answer(ctx->excontext, h->tid, 180, NULL);
810
#else
705
		eXosip_call_send_answer(h->tid,180,NULL);
811
		eXosip_call_send_answer(h->tid,180,NULL);
812
#endif
813
#ifdef HAVE_STRUCT_EXOSIP_T
814
		eXosip_unlock(ctx->excontext);
815
#else
706
		eXosip_unlock();
816
		eXosip_unlock();
817
#endif
707
	}
818
	}
708
	return 0;
819
	return 0;
709
}
820
}
710
821
711
int sal_call_accept(SalOp * h){
822
int sal_call_accept(Sal *ctx, SalOp * h){
712
	osip_message_t *msg;
823
	osip_message_t *msg;
713
	const char *contact=sal_op_get_contact(h);
824
	const char *contact=sal_op_get_contact(h);
714
	/* sends a 200 OK */
825
	/* sends a 200 OK */
826
#ifdef HAVE_STRUCT_EXOSIP_T
827
	int err=eXosip_call_build_answer(ctx->excontext, h->tid, 200, &msg);
828
#else
715
	int err=eXosip_call_build_answer(h->tid,200,&msg);
829
	int err=eXosip_call_build_answer(h->tid,200,&msg);
830
#endif
716
	if (err<0 || msg==NULL){
831
	if (err<0 || msg==NULL){
717
		ms_error("Fail to build answer for call: err=%i",err);
832
		ms_error("Fail to build answer for call: err=%i",err);
718
		return -1;
833
		return -1;
Lines 741-779 int sal_call_accept(SalOp * h){ Link Here
741
	}else{
856
	}else{
742
		ms_error("You are accepting a call but not defined any media capabilities !");
857
		ms_error("You are accepting a call but not defined any media capabilities !");
743
	}
858
	}
859
#ifdef HAVE_STRUCT_EXOSIP_T
860
	eXosip_call_send_answer(ctx->excontext, h->tid, 200, msg);
861
#else
744
	eXosip_call_send_answer(h->tid,200,msg);
862
	eXosip_call_send_answer(h->tid,200,msg);
863
#endif
745
	return 0;
864
	return 0;
746
}
865
}
747
866
748
int sal_call_decline(SalOp *h, SalReason reason, const char *redirect){
867
int sal_call_decline(Sal * ctx, SalOp *h, SalReason reason, const char *redirect){
749
	if (reason==SalReasonBusy){
868
	if (reason==SalReasonBusy){
869
#ifdef HAVE_STRUCT_EXOSIP_T
870
		eXosip_lock(ctx->excontext);
871
#else
750
		eXosip_lock();
872
		eXosip_lock();
873
#endif
874
#ifdef HAVE_STRUCT_EXOSIP_T
875
		eXosip_call_send_answer(ctx->excontext, h->tid, 486, NULL);
876
#else
751
		eXosip_call_send_answer(h->tid,486,NULL);
877
		eXosip_call_send_answer(h->tid,486,NULL);
878
#endif
879
#ifdef HAVE_STRUCT_EXOSIP_T
880
		eXosip_unlock(ctx->excontext);
881
#else
752
		eXosip_unlock();
882
		eXosip_unlock();
883
#endif
753
	}
884
	}
754
	else if (reason==SalReasonTemporarilyUnavailable){
885
	else if (reason==SalReasonTemporarilyUnavailable){
886
#ifdef HAVE_STRUCT_EXOSIP_T
887
		eXosip_lock(ctx->excontext);
888
#else
755
		eXosip_lock();
889
		eXosip_lock();
890
#endif
891
#ifdef HAVE_STRUCT_EXOSIP_T
892
		eXosip_call_send_answer(ctx->excontext, h->tid, 480, NULL);
893
#else
756
		eXosip_call_send_answer(h->tid,480,NULL);
894
		eXosip_call_send_answer(h->tid,480,NULL);
895
#endif
896
#ifdef HAVE_STRUCT_EXOSIP_T
897
		eXosip_unlock(ctx->excontext);
898
#else
757
		eXosip_unlock();
899
		eXosip_unlock();
900
#endif
758
	}else if (reason==SalReasonDoNotDisturb){
901
	}else if (reason==SalReasonDoNotDisturb){
902
#ifdef HAVE_STRUCT_EXOSIP_T
903
		eXosip_lock(ctx->excontext);
904
#else
759
		eXosip_lock();
905
		eXosip_lock();
906
#endif
907
#ifdef HAVE_STRUCT_EXOSIP_T
908
		eXosip_call_send_answer(ctx->excontext, h->tid, 600, NULL);
909
#else
760
		eXosip_call_send_answer(h->tid,600,NULL);
910
		eXosip_call_send_answer(h->tid,600,NULL);
911
#endif
912
#ifdef HAVE_STRUCT_EXOSIP_T
913
		eXosip_unlock(ctx->excontext);
914
#else
761
		eXosip_unlock();
915
		eXosip_unlock();
916
#endif
762
	}else if (reason==SalReasonMedia){
917
	}else if (reason==SalReasonMedia){
918
#ifdef HAVE_STRUCT_EXOSIP_T
919
		eXosip_lock(ctx->excontext);
920
#else
763
		eXosip_lock();
921
		eXosip_lock();
922
#endif
923
#ifdef HAVE_STRUCT_EXOSIP_T
924
		eXosip_call_send_answer(ctx->excontext, h->tid, 415, NULL);
925
#else
764
		eXosip_call_send_answer(h->tid,415,NULL);
926
		eXosip_call_send_answer(h->tid,415,NULL);
927
#endif
928
#ifdef HAVE_STRUCT_EXOSIP_T
929
		eXosip_unlock(ctx->excontext);
930
#else
765
		eXosip_unlock();
931
		eXosip_unlock();
932
#endif
766
	}else if (redirect!=NULL && reason==SalReasonRedirect){
933
	}else if (redirect!=NULL && reason==SalReasonRedirect){
767
		osip_message_t *msg;
934
		osip_message_t *msg;
768
		int code;
935
		int code;
769
		if (strstr(redirect,"sip:")!=0) code=302;
936
		if (strstr(redirect,"sip:")!=0) code=302;
770
		else code=380;
937
		else code=380;
938
#ifdef HAVE_STRUCT_EXOSIP_T
939
		eXosip_lock(ctx->excontext);
940
#else
771
		eXosip_lock();
941
		eXosip_lock();
942
#endif
943
#ifdef HAVE_STRUCT_EXOSIP_T
944
		eXosip_call_build_answer(ctx->excontext, h->tid, code, &msg);
945
#else
772
		eXosip_call_build_answer(h->tid,code,&msg);
946
		eXosip_call_build_answer(h->tid,code,&msg);
947
#endif
773
		osip_message_set_contact(msg,redirect);
948
		osip_message_set_contact(msg,redirect);
949
#ifdef HAVE_STRUCT_EXOSIP_T
950
		eXosip_call_send_answer(ctx->excontext, h->tid, code, msg);
951
#else
774
		eXosip_call_send_answer(h->tid,code,msg);
952
		eXosip_call_send_answer(h->tid,code,msg);
953
#endif
954
#ifdef HAVE_STRUCT_EXOSIP_T
955
		eXosip_unlock(ctx->excontext);
956
#else
775
		eXosip_unlock();
957
		eXosip_unlock();
776
	}else sal_call_terminate(h);
958
#endif
959
	}else sal_call_terminate(ctx, h);
777
	return 0;
960
	return 0;
778
}
961
}
779
962
Lines 796-834 int sal_call_set_referer(SalOp *h, SalOp Link Here
796
	return 0;
979
	return 0;
797
}
980
}
798
981
799
static int send_notify_for_refer(int did, const char *sipfrag){
982
static int send_notify_for_refer(Sal *ctx, int did, const char *sipfrag){
800
	osip_message_t *msg;
983
	osip_message_t *msg;
984
#ifdef HAVE_STRUCT_EXOSIP_T
985
	eXosip_lock(ctx->excontext);
986
#else
801
	eXosip_lock();
987
	eXosip_lock();
988
#endif
989
#ifdef HAVE_STRUCT_EXOSIP_T
990
	eXosip_call_build_notify(ctx->excontext, did, EXOSIP_SUBCRSTATE_ACTIVE, &msg);
991
#else
802
	eXosip_call_build_notify(did,EXOSIP_SUBCRSTATE_ACTIVE,&msg);
992
	eXosip_call_build_notify(did,EXOSIP_SUBCRSTATE_ACTIVE,&msg);
993
#endif
803
	if (msg==NULL){
994
	if (msg==NULL){
995
#ifdef HAVE_STRUCT_EXOSIP_T
996
		eXosip_unlock(ctx->excontext);
997
#else
804
		eXosip_unlock();
998
		eXosip_unlock();
999
#endif
805
		ms_warning("Could not build NOTIFY for refer.");
1000
		ms_warning("Could not build NOTIFY for refer.");
806
		return -1;
1001
		return -1;
807
	}
1002
	}
808
	osip_message_set_content_type(msg,"message/sipfrag");
1003
	osip_message_set_content_type(msg,"message/sipfrag");
809
	osip_message_set_header(msg,"Event","refer");
1004
	osip_message_set_header(msg,"Event","refer");
810
	osip_message_set_body(msg,sipfrag,strlen(sipfrag));
1005
	osip_message_set_body(msg,sipfrag,strlen(sipfrag));
1006
#ifdef HAVE_STRUCT_EXOSIP_T
1007
	eXosip_call_send_request(ctx->excontext, did, msg);
1008
#else
811
	eXosip_call_send_request(did,msg);
1009
	eXosip_call_send_request(did,msg);
1010
#endif
1011
#ifdef HAVE_STRUCT_EXOSIP_T
1012
	eXosip_unlock(ctx->excontext);
1013
#else
812
	eXosip_unlock();
1014
	eXosip_unlock();
1015
#endif
813
	return 0;
1016
	return 0;
814
}
1017
}
815
1018
816
/* currently only support to notify trying and 200Ok*/
1019
/* currently only support to notify trying and 200Ok*/
817
int sal_call_notify_refer_state(SalOp *h, SalOp *newcall){
1020
int sal_call_notify_refer_state(Sal *ctx, SalOp *h, SalOp *newcall){
818
	if (newcall==NULL){
1021
	if (newcall==NULL){
819
		/* in progress*/
1022
		/* in progress*/
820
		send_notify_for_refer(h->did,"SIP/2.0 100 Trying\r\n");
1023
		send_notify_for_refer(ctx, h->did,"SIP/2.0 100 Trying\r\n");
821
	}
1024
	}
822
	else if (newcall->cid!=-1){
1025
	else if (newcall->cid!=-1){
823
		if (newcall->did==-1){
1026
		if (newcall->did==-1){
824
			/* not yet established*/
1027
			/* not yet established*/
825
			if (!newcall->terminated){
1028
			if (!newcall->terminated){
826
				/* in progress*/
1029
				/* in progress*/
827
				send_notify_for_refer(h->did,"SIP/2.0 100 Trying\r\n");
1030
				send_notify_for_refer(ctx, h->did,"SIP/2.0 100 Trying\r\n");
828
			}
1031
			}
829
		}else{
1032
		}else{
830
			if (!newcall->terminated){
1033
			if (!newcall->terminated){
831
				if (send_notify_for_refer(h->did,"SIP/2.0 200 Ok\r\n")==-1){
1034
				if (send_notify_for_refer(ctx, h->did,"SIP/2.0 200 Ok\r\n")==-1){
832
					/* we need previous notify transaction to complete, so buffer the request for later*/
1035
					/* we need previous notify transaction to complete, so buffer the request for later*/
833
					h->sipfrag_pending="SIP/2.0 200 Ok\r\n";
1036
					h->sipfrag_pending="SIP/2.0 200 Ok\r\n";
834
				}
1037
				}
Lines 838-898 int sal_call_notify_refer_state(SalOp *h Link Here
838
	return 0;
1041
	return 0;
839
}
1042
}
840
1043
841
int sal_ping(SalOp *op, const char *from, const char *to){
1044
int sal_ping(Sal *ctx, SalOp *op, const char *from, const char *to){
842
	osip_message_t *options=NULL;
1045
	osip_message_t *options=NULL;
843
	
1046
	
844
	sal_op_set_from(op,from);
1047
	sal_op_set_from(op,from);
845
	sal_op_set_to(op,to);
1048
	sal_op_set_to(op,to);
846
	sal_exosip_fix_route(op);
1049
	sal_exosip_fix_route(op);
847
1050
1051
#ifdef HAVE_STRUCT_EXOSIP_T
1052
	eXosip_options_build_request (ctx->excontext, &options, sal_op_get_to(op),
1053
			sal_op_get_from(op),sal_op_get_route(op));
1054
#else
848
	eXosip_options_build_request (&options, sal_op_get_to(op),
1055
	eXosip_options_build_request (&options, sal_op_get_to(op),
849
			sal_op_get_from(op),sal_op_get_route(op));
1056
			sal_op_get_from(op),sal_op_get_route(op));
1057
#endif
850
	if (options){
1058
	if (options){
851
		if (op->base.root->session_expires!=0){
1059
		if (op->base.root->session_expires!=0){
852
			osip_message_set_header(options, "Session-expires", "200");
1060
			osip_message_set_header(options, "Session-expires", "200");
853
			osip_message_set_supported(options, "timer");
1061
			osip_message_set_supported(options, "timer");
854
		}
1062
		}
855
		sal_add_other(sal_op_get_sal(op),op,options);
1063
		sal_add_other(sal_op_get_sal(op),op,options);
1064
#ifdef HAVE_STRUCT_EXOSIP_T
1065
		return eXosip_options_send_request(ctx->excontext, options);
1066
#else
856
		return eXosip_options_send_request(options);
1067
		return eXosip_options_send_request(options);
1068
#endif
857
	}
1069
	}
858
	return -1;
1070
	return -1;
859
}
1071
}
860
1072
861
int sal_call_refer(SalOp *h, const char *refer_to){
1073
int sal_call_refer(Sal *ctx, SalOp *h, const char *refer_to){
862
	osip_message_t *msg=NULL;
1074
	osip_message_t *msg=NULL;
863
	int err=0;
1075
	int err=0;
1076
#ifdef HAVE_STRUCT_EXOSIP_T
1077
	eXosip_lock(ctx->excontext);
1078
#else
864
	eXosip_lock();
1079
	eXosip_lock();
1080
#endif
1081
#ifdef HAVE_STRUCT_EXOSIP_T
1082
	eXosip_call_build_refer(ctx->excontext, h->did, refer_to, &msg);
1083
#else
865
	eXosip_call_build_refer(h->did,refer_to, &msg);
1084
	eXosip_call_build_refer(h->did,refer_to, &msg);
866
	if (msg) err=eXosip_call_send_request(h->did, msg);
1085
#endif
1086
	if (msg) {
1087
#ifdef HAVE_STRUCT_EXOSIP_T
1088
		err=eXosip_call_send_request(ctx->excontext, h->did, msg);
1089
#else
1090
		err=eXosip_call_send_request(h->did, msg);
1091
#endif
1092
	}
867
	else err=-1;
1093
	else err=-1;
1094
#ifdef HAVE_STRUCT_EXOSIP_T
1095
	eXosip_unlock(ctx->excontext);
1096
#else
868
	eXosip_unlock();
1097
	eXosip_unlock();
1098
#endif
869
	return err;
1099
	return err;
870
}
1100
}
871
1101
872
int sal_call_refer_with_replaces(SalOp *h, SalOp *other_call_h){
1102
int sal_call_refer_with_replaces(Sal *ctx, SalOp *h, SalOp *other_call_h){
873
	osip_message_t *msg=NULL;
1103
	osip_message_t *msg=NULL;
874
	char referto[256]={0};
1104
	char referto[256]={0};
875
	int err=0;
1105
	int err=0;
1106
#ifdef HAVE_STRUCT_EXOSIP_T
1107
	eXosip_lock(ctx->excontext);
1108
#else
876
	eXosip_lock();
1109
	eXosip_lock();
1110
#endif
1111
#ifdef HAVE_STRUCT_EXOSIP_T
1112
	if (eXosip_call_get_referto(ctx->excontext, other_call_h->did,referto,sizeof(referto)-1)!=0){
1113
#else
877
	if (eXosip_call_get_referto(other_call_h->did,referto,sizeof(referto)-1)!=0){
1114
	if (eXosip_call_get_referto(other_call_h->did,referto,sizeof(referto)-1)!=0){
1115
#endif
878
		ms_error("eXosip_call_get_referto() failed for did=%i",other_call_h->did);
1116
		ms_error("eXosip_call_get_referto() failed for did=%i",other_call_h->did);
1117
#ifdef HAVE_STRUCT_EXOSIP_T
1118
		eXosip_unlock(ctx->excontext);
1119
#else
879
		eXosip_unlock();
1120
		eXosip_unlock();
1121
#endif
880
		return -1;
1122
		return -1;
881
	}
1123
	}
1124
#ifdef HAVE_STRUCT_EXOSIP_T
1125
	eXosip_call_build_refer(ctx->excontext, h->did,referto, &msg);
1126
#else
882
	eXosip_call_build_refer(h->did,referto, &msg);
1127
	eXosip_call_build_refer(h->did,referto, &msg);
1128
#endif
883
	osip_message_set_header(msg,"Referred-By",h->base.from);
1129
	osip_message_set_header(msg,"Referred-By",h->base.from);
884
	if (msg) err=eXosip_call_send_request(h->did, msg);
1130
	if (msg) {
1131
#ifdef HAVE_STRUCT_EXOSIP_T
1132
		err=eXosip_call_send_request(ctx->excontext, h->did, msg);
1133
#else
1134
		err=eXosip_call_send_request(h->did, msg);
1135
#endif
1136
	}
885
	else err=-1;
1137
	else err=-1;
1138
#ifdef HAVE_STRUCT_EXOSIP_T
1139
	eXosip_unlock(ctx->excontext);
1140
#else
886
	eXosip_unlock();
1141
	eXosip_unlock();
1142
#endif
887
	return err;
1143
	return err;
888
}
1144
}
889
1145
890
SalOp *sal_call_get_replaces(SalOp *h){
1146
SalOp *sal_call_get_replaces(Sal *ctx, SalOp *h){
891
	if (h!=NULL && h->replaces!=NULL){
1147
	if (h!=NULL && h->replaces!=NULL){
892
		int cid;
1148
		int cid;
1149
#ifdef HAVE_STRUCT_EXOSIP_T
1150
		eXosip_lock(ctx->excontext);
1151
#else
893
		eXosip_lock();
1152
		eXosip_lock();
1153
#endif
1154
#ifdef HAVE_STRUCT_EXOSIP_T
1155
		cid=eXosip_call_find_by_replaces(ctx->excontext, h->replaces);
1156
#else
894
		cid=eXosip_call_find_by_replaces(h->replaces);
1157
		cid=eXosip_call_find_by_replaces(h->replaces);
1158
#endif
1159
#ifdef HAVE_STRUCT_EXOSIP_T
1160
		eXosip_unlock(ctx->excontext);
1161
#else
895
		eXosip_unlock();
1162
		eXosip_unlock();
1163
#endif
896
		if (cid>0){
1164
		if (cid>0){
897
			SalOp *ret=sal_find_call(h->base.root,cid);
1165
			SalOp *ret=sal_find_call(h->base.root,cid);
898
			return ret;
1166
			return ret;
Lines 901-948 SalOp *sal_call_get_replaces(SalOp *h){ Link Here
901
	return NULL;
1169
	return NULL;
902
}
1170
}
903
1171
904
int sal_call_send_dtmf(SalOp *h, char dtmf){
1172
int sal_call_send_dtmf(Sal *ctx, SalOp *h, char dtmf){
905
	osip_message_t *msg=NULL;
1173
	osip_message_t *msg=NULL;
906
	char dtmf_body[128];
1174
	char dtmf_body[128];
907
	char clen[10];
1175
	char clen[10];
908
1176
1177
#ifdef HAVE_STRUCT_EXOSIP_T
1178
	eXosip_lock(ctx->excontext);
1179
#else
909
	eXosip_lock();
1180
	eXosip_lock();
1181
#endif
1182
#ifdef HAVE_STRUCT_EXOSIP_T
1183
	eXosip_call_build_info(ctx->excontext, h->did, &msg);
1184
#else
910
	eXosip_call_build_info(h->did,&msg);
1185
	eXosip_call_build_info(h->did,&msg);
1186
#endif
911
	if (msg){
1187
	if (msg){
912
		snprintf(dtmf_body, sizeof(dtmf_body), "Signal=%c\r\nDuration=250\r\n", dtmf);
1188
		snprintf(dtmf_body, sizeof(dtmf_body), "Signal=%c\r\nDuration=250\r\n", dtmf);
913
		osip_message_set_body(msg,dtmf_body,strlen(dtmf_body));
1189
		osip_message_set_body(msg,dtmf_body,strlen(dtmf_body));
914
		osip_message_set_content_type(msg,"application/dtmf-relay");
1190
		osip_message_set_content_type(msg,"application/dtmf-relay");
915
		snprintf(clen,sizeof(clen),"%lu",(unsigned long)strlen(dtmf_body));
1191
		snprintf(clen,sizeof(clen),"%lu",(unsigned long)strlen(dtmf_body));
916
		osip_message_set_content_length(msg,clen);		
1192
		osip_message_set_content_length(msg,clen);		
1193
#ifdef HAVE_STRUCT_EXOSIP_T
1194
		eXosip_call_send_request(ctx->excontext, h->did, msg);
1195
#else
917
		eXosip_call_send_request(h->did,msg);
1196
		eXosip_call_send_request(h->did,msg);
1197
#endif
918
	}
1198
	}
1199
#ifdef HAVE_STRUCT_EXOSIP_T
1200
	eXosip_unlock(ctx->excontext);
1201
#else
919
	eXosip_unlock();
1202
	eXosip_unlock();
1203
#endif
920
	return 0;
1204
	return 0;
921
}
1205
}
922
1206
923
static void push_auth_to_exosip(const SalAuthInfo *info){
1207
static void push_auth_to_exosip(Sal *ctx, const SalAuthInfo *info){
924
	const char *userid;
1208
	const char *userid;
925
	if (info->userid==NULL || info->userid[0]=='\0') userid=info->username;
1209
	if (info->userid==NULL || info->userid[0]=='\0') userid=info->username;
926
	else userid=info->userid;
1210
	else userid=info->userid;
927
	ms_message("Authentication info for username [%s], id[%s], realm [%s] added to eXosip", info->username,userid, info->realm);
1211
	ms_message("Authentication info for username [%s], id[%s], realm [%s] added to eXosip", info->username,userid, info->realm);
1212
#ifdef HAVE_STRUCT_EXOSIP_T
1213
	eXosip_add_authentication_info (ctx->excontext, info->username,userid,
1214
                                  info->password, NULL,info->realm);
1215
#else
928
	eXosip_add_authentication_info (info->username,userid,
1216
	eXosip_add_authentication_info (info->username,userid,
929
                                  info->password, NULL,info->realm);
1217
                                  info->password, NULL,info->realm);
1218
#endif
930
}
1219
}
931
/*
1220
/*
932
 * Just for symmetry ;-)
1221
 * Just for symmetry ;-)
933
 */
1222
 */
934
static void pop_auth_from_exosip() {
1223
static void pop_auth_from_exosip(Sal *ctx) {
935
	eXosip_clear_authentication_info();
1224
	eXosip_clear_authentication_info(ctx->excontext);
936
}
1225
}
937
1226
938
int sal_call_terminate(SalOp *h){
1227
int sal_call_terminate(Sal *ctx, SalOp *h){
939
	int err;
1228
	int err;
940
	if (h == NULL) return -1;
1229
	if (h == NULL) return -1;
941
	if (h->auth_info) push_auth_to_exosip(h->auth_info);
1230
	if (h->auth_info) push_auth_to_exosip(ctx, h->auth_info);
1231
#ifdef HAVE_STRUCT_EXOSIP_T
1232
	eXosip_lock(ctx->excontext);
1233
#else
942
	eXosip_lock();
1234
	eXosip_lock();
1235
#endif
1236
#ifdef HAVE_STRUCT_EXOSIP_T
1237
	err=eXosip_call_terminate(ctx->excontext, h->cid, h->did);
1238
#else
943
	err=eXosip_call_terminate(h->cid,h->did);
1239
	err=eXosip_call_terminate(h->cid,h->did);
1240
#endif
1241
#ifdef HAVE_STRUCT_EXOSIP_T
1242
	eXosip_unlock(ctx->excontext);
1243
#else
944
	eXosip_unlock();
1244
	eXosip_unlock();
945
	if (!h->base.root->reuse_authorization) pop_auth_from_exosip();
1245
#endif
1246
	if (!h->base.root->reuse_authorization) pop_auth_from_exosip(ctx);
946
	if (err!=0){
1247
	if (err!=0){
947
		ms_warning("Exosip could not terminate the call: cid=%i did=%i", h->cid,h->did);
1248
		ms_warning("Exosip could not terminate the call: cid=%i did=%i", h->cid,h->did);
948
	}
1249
	}
Lines 950-956 int sal_call_terminate(SalOp *h){ Link Here
950
	return 0;
1251
	return 0;
951
}
1252
}
952
1253
953
void sal_op_authenticate(SalOp *h, const SalAuthInfo *info){
1254
void sal_op_authenticate(Sal *ctx, SalOp *h, const SalAuthInfo *info){
954
       bool_t terminating=FALSE;
1255
       bool_t terminating=FALSE;
955
       if (h->pending_auth && strcmp(h->pending_auth->request->sip_method,"BYE")==0) {
1256
       if (h->pending_auth && strcmp(h->pending_auth->request->sip_method,"BYE")==0) {
956
               terminating=TRUE;
1257
               terminating=TRUE;
Lines 958-964 void sal_op_authenticate(SalOp *h, const Link Here
958
       if (h->terminated && !terminating) return;
1259
       if (h->terminated && !terminating) return;
959
1260
960
       if (h->pending_auth){
1261
       if (h->pending_auth){
961
		push_auth_to_exosip(info);
1262
	        push_auth_to_exosip(ctx, info);
962
		
1263
		
963
        /*FIXME exosip does not take into account this update register message*/
1264
        /*FIXME exosip does not take into account this update register message*/
964
	/*
1265
	/*
Lines 967-977 void sal_op_authenticate(SalOp *h, const Link Here
967
        };
1268
        };
968
	*/
1269
	*/
969
		update_contact_from_response(h,h->pending_auth->response);
1270
		update_contact_from_response(h,h->pending_auth->response);
1271
#ifdef HAVE_STRUCT_EXOSIP_T
1272
		eXosip_lock(ctx->excontext);
1273
#else
970
		eXosip_lock();
1274
		eXosip_lock();
1275
#endif
1276
#ifdef HAVE_STRUCT_EXOSIP_T
1277
		eXosip_default_action(ctx->excontext, h->pending_auth);
1278
#else
971
		eXosip_default_action(h->pending_auth);
1279
		eXosip_default_action(h->pending_auth);
1280
#endif
1281
#ifdef HAVE_STRUCT_EXOSIP_T
1282
		eXosip_unlock(ctx->excontext);
1283
#else
972
		eXosip_unlock();
1284
		eXosip_unlock();
1285
#endif
973
		ms_message("eXosip_default_action() done");
1286
		ms_message("eXosip_default_action() done");
974
		if (!h->base.root->reuse_authorization) pop_auth_from_exosip();
1287
		if (!h->base.root->reuse_authorization) pop_auth_from_exosip(ctx);
975
		
1288
		
976
		if (h->auth_info) sal_auth_info_delete(h->auth_info); /*if already exist*/
1289
		if (h->auth_info) sal_auth_info_delete(h->auth_info); /*if already exist*/
977
		h->auth_info=sal_auth_info_clone(info); /*store auth info for subsequent request*/
1290
		h->auth_info=sal_auth_info_clone(info); /*store auth info for subsequent request*/
Lines 1210-1218 static int call_proceeding(Sal *sal, eXo Link Here
1210
1523
1211
	if (op==NULL || op->terminated==TRUE) {
1524
	if (op==NULL || op->terminated==TRUE) {
1212
		ms_warning("This call has been canceled.");
1525
		ms_warning("This call has been canceled.");
1526
#ifdef HAVE_STRUCT_EXOSIP_T
1527
		eXosip_lock(sal->excontext);
1528
#else
1213
		eXosip_lock();
1529
		eXosip_lock();
1530
#endif
1531
#ifdef HAVE_STRUCT_EXOSIP_T
1532
		eXosip_call_terminate(sal->excontext, ev->cid, ev->did);
1533
#else
1214
		eXosip_call_terminate(ev->cid,ev->did);
1534
		eXosip_call_terminate(ev->cid,ev->did);
1535
#endif
1536
#ifdef HAVE_STRUCT_EXOSIP_T
1537
		eXosip_unlock(sal->excontext);
1538
#else
1215
		eXosip_unlock();
1539
		eXosip_unlock();
1540
#endif
1216
		return -1;
1541
		return -1;
1217
	}
1542
	}
1218
	if (ev->did>0)
1543
	if (ev->did>0)
Lines 1249-1257 static void call_accepted(Sal *sal, eXos Link Here
1249
	
1574
	
1250
	if (op==NULL || op->terminated==TRUE) {
1575
	if (op==NULL || op->terminated==TRUE) {
1251
		ms_warning("This call has been already terminated.");
1576
		ms_warning("This call has been already terminated.");
1577
#ifdef HAVE_STRUCT_EXOSIP_T
1578
		eXosip_lock(sal->excontext);
1579
#else
1252
		eXosip_lock();
1580
		eXosip_lock();
1581
#endif
1582
#ifdef HAVE_STRUCT_EXOSIP_T
1583
		eXosip_call_terminate(sal->excontext, ev->cid, ev->did);
1584
#else
1253
		eXosip_call_terminate(ev->cid,ev->did);
1585
		eXosip_call_terminate(ev->cid,ev->did);
1586
#endif
1587
#ifdef HAVE_STRUCT_EXOSIP_T
1588
		eXosip_unlock(sal->excontext);
1589
#else
1254
		eXosip_unlock();
1590
		eXosip_unlock();
1591
#endif
1255
		return ;
1592
		return ;
1256
	}
1593
	}
1257
1594
Lines 1266-1277 static void call_accepted(Sal *sal, eXos Link Here
1266
		sdp_message_free(sdp);
1603
		sdp_message_free(sdp);
1267
		if (op->base.local_media) sdp_process(op);
1604
		if (op->base.local_media) sdp_process(op);
1268
	}
1605
	}
1606
#ifdef HAVE_STRUCT_EXOSIP_T
1607
	eXosip_call_build_ack(sal->excontext, ev->did, &msg);
1608
#else
1269
	eXosip_call_build_ack(ev->did,&msg);
1609
	eXosip_call_build_ack(ev->did,&msg);
1610
#endif
1270
	if (msg==NULL) {
1611
	if (msg==NULL) {
1271
		ms_warning("This call has been already terminated.");
1612
		ms_warning("This call has been already terminated.");
1613
#ifdef HAVE_STRUCT_EXOSIP_T
1614
		eXosip_lock(sal->excontext);
1615
#else
1272
		eXosip_lock();
1616
		eXosip_lock();
1617
#endif
1618
#ifdef HAVE_STRUCT_EXOSIP_T
1619
		eXosip_call_terminate(sal->excontext, ev->cid, ev->did);
1620
#else
1273
		eXosip_call_terminate(ev->cid,ev->did);
1621
		eXosip_call_terminate(ev->cid,ev->did);
1622
#endif
1623
#ifdef HAVE_STRUCT_EXOSIP_T
1624
		eXosip_unlock(sal->excontext);
1625
#else
1274
		eXosip_unlock();
1626
		eXosip_unlock();
1627
#endif
1275
		return ;
1628
		return ;
1276
	}
1629
	}
1277
	contact=sal_op_get_contact(op);
1630
	contact=sal_op_get_contact(op);
Lines 1284-1290 static void call_accepted(Sal *sal, eXos Link Here
1284
		sdp_message_free(op->sdp_answer);
1637
		sdp_message_free(op->sdp_answer);
1285
		op->sdp_answer=NULL;
1638
		op->sdp_answer=NULL;
1286
	}
1639
	}
1640
#ifdef HAVE_STRUCT_EXOSIP_T
1641
	eXosip_call_send_ack(sal->excontext, ev->did, msg);
1642
#else
1287
	eXosip_call_send_ack(ev->did,msg);
1643
	eXosip_call_send_ack(ev->did,msg);
1644
#endif
1288
	sal->callbacks.call_accepted(op);
1645
	sal->callbacks.call_accepted(op);
1289
}
1646
}
1290
1647
Lines 1458-1464 static bool_t call_failure(Sal *sal, eXo Link Here
1458
			sr=SalReasonMedia;
1815
			sr=SalReasonMedia;
1459
		break;
1816
		break;
1460
		case 422:
1817
		case 422:
1818
#ifdef HAVE_STRUCT_EXOSIP_T
1819
			eXosip_default_action(sal->excontext, ev);
1820
#else
1461
			eXosip_default_action(ev);
1821
			eXosip_default_action(ev);
1822
#endif
1462
			return TRUE;
1823
			return TRUE;
1463
		break;
1824
		break;
1464
		case 480:
1825
		case 480:
Lines 1494-1500 static bool_t call_failure(Sal *sal, eXo Link Here
1494
}
1855
}
1495
1856
1496
/* Request remote side to send us VFU */
1857
/* Request remote side to send us VFU */
1497
void sal_call_send_vfu_request(SalOp *h){
1858
void sal_call_send_vfu_request(Sal *ctx, SalOp *h){
1498
	osip_message_t *msg=NULL;
1859
	osip_message_t *msg=NULL;
1499
	char info_body[] =
1860
	char info_body[] =
1500
			"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
1861
			"<?xml version=\"1.0\" encoding=\"utf-8\" ?>"
Lines 1508-1524 void sal_call_send_vfu_request(SalOp *h) Link Here
1508
1869
1509
	char clen[10];
1870
	char clen[10];
1510
1871
1872
#ifdef HAVE_STRUCT_EXOSIP_T
1873
	eXosip_lock(ctx->excontext);
1874
#else
1511
	eXosip_lock();
1875
	eXosip_lock();
1876
#endif
1877
#ifdef HAVE_STRUCT_EXOSIP_T
1878
	eXosip_call_build_info(ctx->excontext, h->did, &msg);
1879
#else
1512
	eXosip_call_build_info(h->did,&msg);
1880
	eXosip_call_build_info(h->did,&msg);
1881
#endif
1513
	if (msg){
1882
	if (msg){
1514
		osip_message_set_body(msg,info_body,strlen(info_body));
1883
		osip_message_set_body(msg,info_body,strlen(info_body));
1515
		osip_message_set_content_type(msg,"application/media_control+xml");
1884
		osip_message_set_content_type(msg,"application/media_control+xml");
1516
		snprintf(clen,sizeof(clen),"%lu",(unsigned long)strlen(info_body));
1885
		snprintf(clen,sizeof(clen),"%lu",(unsigned long)strlen(info_body));
1517
		osip_message_set_content_length(msg,clen);
1886
		osip_message_set_content_length(msg,clen);
1887
#ifdef HAVE_STRUCT_EXOSIP_T
1888
		eXosip_call_send_request(ctx->excontext, h->did, msg);
1889
#else
1518
		eXosip_call_send_request(h->did,msg);
1890
		eXosip_call_send_request(h->did,msg);
1891
#endif
1519
		ms_message("Sending VFU request !");
1892
		ms_message("Sending VFU request !");
1520
	}
1893
	}
1894
#ifdef HAVE_STRUCT_EXOSIP_T
1895
	eXosip_unlock(ctx->excontext);
1896
#else
1521
	eXosip_unlock();
1897
	eXosip_unlock();
1898
#endif
1522
}
1899
}
1523
1900
1524
static void process_media_control_xml(Sal *sal, eXosip_event_t *ev){
1901
static void process_media_control_xml(Sal *sal, eXosip_event_t *ev){
Lines 1537-1556 static void process_media_control_xml(Sa Link Here
1537
		ms_message("Receiving VFU request !");
1914
		ms_message("Receiving VFU request !");
1538
		if (sal->callbacks.vfu_request){
1915
		if (sal->callbacks.vfu_request){
1539
			sal->callbacks.vfu_request(op);
1916
			sal->callbacks.vfu_request(op);
1917
#ifdef HAVE_STRUCT_EXOSIP_T
1918
			eXosip_call_build_answer(sal->excontext, ev->tid, 200, &ans);
1919
#else
1540
			eXosip_call_build_answer(ev->tid,200,&ans);
1920
			eXosip_call_build_answer(ev->tid,200,&ans);
1921
#endif
1541
			if (ans)
1922
			if (ans)
1923
#ifdef HAVE_STRUCT_EXOSIP_T
1924
				eXosip_call_send_answer(sal->excontext, ev->tid, 200, ans);
1925
#else
1542
				eXosip_call_send_answer(ev->tid,200,ans);
1926
				eXosip_call_send_answer(ev->tid,200,ans);
1927
#endif
1543
			return;
1928
			return;
1544
		}
1929
		}
1545
	}
1930
	}
1546
	/*in all other cases we must say it is not implemented.*/
1931
	/*in all other cases we must say it is not implemented.*/
1547
	{
1932
	{
1548
		osip_message_t *ans=NULL;
1933
		osip_message_t *ans=NULL;
1934
#ifdef HAVE_STRUCT_EXOSIP_T
1935
		eXosip_lock(sal->excontext);
1936
#else
1549
		eXosip_lock();
1937
		eXosip_lock();
1938
#endif
1939
#ifdef HAVE_STRUCT_EXOSIP_T
1940
		eXosip_call_build_answer(sal->excontext, ev->tid, 501, &ans);
1941
#else
1550
		eXosip_call_build_answer(ev->tid,501,&ans);
1942
		eXosip_call_build_answer(ev->tid,501,&ans);
1551
		if (ans)
1943
#endif
1944
		if (ans) {
1945
#ifdef HAVE_STRUCT_EXOSIP_T
1946
			eXosip_call_send_answer(sal->excontext, ev->tid, 501, ans);
1947
#else
1552
			eXosip_call_send_answer(ev->tid,501,ans);
1948
			eXosip_call_send_answer(ev->tid,501,ans);
1949
#endif
1950
		}
1951
#ifdef HAVE_STRUCT_EXOSIP_T
1952
		eXosip_unlock(sal->excontext);
1953
#else
1553
		eXosip_unlock();
1954
		eXosip_unlock();
1955
#endif
1554
	}
1956
	}
1555
}
1957
}
1556
1958
Lines 1579-1589 static void process_dtmf_relay(Sal *sal, Link Here
1579
					sal->callbacks.dtmf_received(op, tmp[0]);
1981
					sal->callbacks.dtmf_received(op, tmp[0]);
1580
			}
1982
			}
1581
		}
1983
		}
1984
#ifdef HAVE_STRUCT_EXOSIP_T
1985
		eXosip_lock(sal->excontext);
1986
#else
1582
		eXosip_lock();
1987
		eXosip_lock();
1988
#endif
1989
#ifdef HAVE_STRUCT_EXOSIP_T
1990
		eXosip_call_build_answer(sal->excontext, ev->tid, 200, &ans);
1991
#else
1583
		eXosip_call_build_answer(ev->tid,200,&ans);
1992
		eXosip_call_build_answer(ev->tid,200,&ans);
1584
		if (ans)
1993
#endif
1994
		if (ans) {
1995
#ifdef HAVE_STRUCT_EXOSIP_T
1996
			eXosip_call_send_answer(sal->excontext, ev->tid, 200, ans);
1997
#else
1585
			eXosip_call_send_answer(ev->tid,200,ans);
1998
			eXosip_call_send_answer(ev->tid,200,ans);
1999
#endif
2000
		}
2001
#ifdef HAVE_STRUCT_EXOSIP_T
2002
		eXosip_unlock(sal->excontext);
2003
#else
1586
		eXosip_unlock();
2004
		eXosip_unlock();
2005
#endif
1587
	}
2006
	}
1588
}
2007
}
1589
2008
Lines 1628-1638 static void process_refer(Sal *sal, SalO Link Here
1628
			osip_free(tmp);
2047
			osip_free(tmp);
1629
			osip_from_free(from);
2048
			osip_from_free(from);
1630
		}
2049
		}
2050
#ifdef HAVE_STRUCT_EXOSIP_T
2051
		eXosip_lock(sal->excontext);
2052
#else
1631
		eXosip_lock();
2053
		eXosip_lock();
2054
#endif
2055
#ifdef HAVE_STRUCT_EXOSIP_T
2056
		eXosip_call_build_answer(sal->excontext, ev->tid, 202, &ans);
2057
#else
1632
		eXosip_call_build_answer(ev->tid,202,&ans);
2058
		eXosip_call_build_answer(ev->tid,202,&ans);
1633
		if (ans)
2059
#endif
2060
		if (ans) {
2061
#ifdef HAVE_STRUCT_EXOSIP_T
2062
			eXosip_call_send_answer(sal->excontext, ev->tid, 202, ans);
2063
#else
1634
			eXosip_call_send_answer(ev->tid,202,ans);
2064
			eXosip_call_send_answer(ev->tid,202,ans);
2065
#endif
2066
		}
2067
#ifdef HAVE_STRUCT_EXOSIP_T
2068
		eXosip_unlock(sal->excontext);
2069
#else
1635
		eXosip_unlock();
2070
		eXosip_unlock();
2071
#endif
1636
	}
2072
	}
1637
	else
2073
	else
1638
	{
2074
	{
Lines 1677-1687 static void process_notify(Sal *sal, eXo Link Here
1677
		}
2113
		}
1678
	}
2114
	}
1679
	/*answer that we received the notify*/
2115
	/*answer that we received the notify*/
2116
#ifdef HAVE_STRUCT_EXOSIP_T
2117
	eXosip_lock(sal->excontext);
2118
#else
1680
	eXosip_lock();
2119
	eXosip_lock();
2120
#endif
2121
#ifdef HAVE_STRUCT_EXOSIP_T
2122
	eXosip_call_build_answer(sal->excontext, ev->tid, 200, &ans);
2123
#else
1681
	eXosip_call_build_answer(ev->tid,200,&ans);
2124
	eXosip_call_build_answer(ev->tid,200,&ans);
1682
	if (ans)
2125
#endif
2126
	if (ans) {
2127
#ifdef HAVE_STRUCT_EXOSIP_T
2128
		eXosip_call_send_answer(sal->excontext, ev->tid, 200, ans);
2129
#else
1683
		eXosip_call_send_answer(ev->tid,200,ans);
2130
		eXosip_call_send_answer(ev->tid,200,ans);
2131
#endif
2132
	}
2133
#ifdef HAVE_STRUCT_EXOSIP_T
2134
	eXosip_unlock(sal->excontext);
2135
#else
1684
	eXosip_unlock();
2136
	eXosip_unlock();
2137
#endif
1685
	osip_free(from);
2138
	osip_free(from);
1686
}
2139
}
1687
2140
Lines 1699-1726 static void call_message_new(Sal *sal, e Link Here
1699
				else {
2152
				else {
1700
					ms_message("Unhandled SIP INFO.");
2153
					ms_message("Unhandled SIP INFO.");
1701
					/*send an "Not implemented" answer*/
2154
					/*send an "Not implemented" answer*/
2155
#ifdef HAVE_STRUCT_EXOSIP_T
2156
					eXosip_lock(sal->excontext);
2157
#else
1702
					eXosip_lock();
2158
					eXosip_lock();
2159
#endif
2160
#ifdef HAVE_STRUCT_EXOSIP_T
2161
					eXosip_call_build_answer(sal->excontext, ev->tid, 501, &ans);
2162
#else
1703
					eXosip_call_build_answer(ev->tid,501,&ans);
2163
					eXosip_call_build_answer(ev->tid,501,&ans);
1704
					if (ans)
2164
#endif
2165
					if (ans) {
2166
#ifdef HAVE_STRUCT_EXOSIP_T
2167
						eXosip_call_send_answer(sal->excontext, ev->tid, 501, ans);
2168
#else
1705
						eXosip_call_send_answer(ev->tid,501,ans);
2169
						eXosip_call_send_answer(ev->tid,501,ans);
2170
#endif
2171
					}
2172
#ifdef HAVE_STRUCT_EXOSIP_T
2173
					eXosip_unlock(sal->excontext);
2174
#else
1706
					eXosip_unlock();
2175
					eXosip_unlock();
2176
#endif
1707
				}
2177
				}
1708
			}else{
2178
			}else{
1709
				/*empty SIP INFO, probably to test we are alive. Send an empty answer*/
2179
				/*empty SIP INFO, probably to test we are alive. Send an empty answer*/
2180
#ifdef HAVE_STRUCT_EXOSIP_T
2181
				eXosip_lock(sal->excontext);
2182
#else
1710
				eXosip_lock();
2183
				eXosip_lock();
2184
#endif
2185
#ifdef HAVE_STRUCT_EXOSIP_T
2186
				eXosip_call_build_answer(sal->excontext, ev->tid, 200, &ans);
2187
#else
1711
				eXosip_call_build_answer(ev->tid,200,&ans);
2188
				eXosip_call_build_answer(ev->tid,200,&ans);
1712
				if (ans)
2189
#endif
2190
				if (ans) {
2191
#ifdef HAVE_STRUCT_EXOSIP_T
2192
					eXosip_call_send_answer(sal->excontext, ev->tid, 200, ans);
2193
#else
1713
					eXosip_call_send_answer(ev->tid,200,ans);
2194
					eXosip_call_send_answer(ev->tid,200,ans);
2195
#endif
2196
				}
2197
#ifdef HAVE_STRUCT_EXOSIP_T
2198
				eXosip_unlock(sal->excontext);
2199
#else
1714
				eXosip_unlock();
2200
				eXosip_unlock();
2201
#endif
1715
			}
2202
			}
1716
		}else if(MSG_IS_MESSAGE(ev->request)){
2203
		}else if(MSG_IS_MESSAGE(ev->request)){
1717
			/* SIP messages could be received into call */
2204
			/* SIP messages could be received into call */
1718
			text_received(sal, ev);
2205
			text_received(sal, ev);
2206
#ifdef HAVE_STRUCT_EXOSIP_T
2207
			eXosip_lock(sal->excontext);
2208
#else
1719
			eXosip_lock();
2209
			eXosip_lock();
2210
#endif
2211
#ifdef HAVE_STRUCT_EXOSIP_T
2212
			eXosip_call_build_answer(sal->excontext, ev->tid, 200, &ans);
2213
#else
1720
			eXosip_call_build_answer(ev->tid,200,&ans);
2214
			eXosip_call_build_answer(ev->tid,200,&ans);
1721
			if (ans)
2215
#endif
2216
			if (ans) {
2217
#ifdef HAVE_STRUCT_EXOSIP_T
2218
				eXosip_call_send_answer(sal->excontext, ev->tid, 200, ans);
2219
#else
1722
				eXosip_call_send_answer(ev->tid,200,ans);
2220
				eXosip_call_send_answer(ev->tid,200,ans);
2221
#endif
2222
			}
2223
#ifdef HAVE_STRUCT_EXOSIP_T
2224
			eXosip_unlock(sal->excontext);
2225
#else
1723
			eXosip_unlock();
2226
			eXosip_unlock();
2227
#endif
1724
		}else if(MSG_IS_REFER(ev->request)){
2228
		}else if(MSG_IS_REFER(ev->request)){
1725
			SalOp *op=find_op(sal,ev);
2229
			SalOp *op=find_op(sal,ev);
1726
			
2230
			
Lines 1729-1741 static void call_message_new(Sal *sal, e Link Here
1729
		}else if(MSG_IS_NOTIFY(ev->request)){
2233
		}else if(MSG_IS_NOTIFY(ev->request)){
1730
			process_notify(sal,ev);
2234
			process_notify(sal,ev);
1731
		}else if (MSG_IS_OPTIONS(ev->request)){
2235
		}else if (MSG_IS_OPTIONS(ev->request)){
2236
#ifdef HAVE_STRUCT_EXOSIP_T
2237
			eXosip_lock(sal->excontext);
2238
#else
1732
			eXosip_lock();
2239
			eXosip_lock();
2240
#endif
2241
#ifdef HAVE_STRUCT_EXOSIP_T
2242
			eXosip_call_build_answer(sal->excontext, ev->tid, 200, &ans);
2243
#else
1733
			eXosip_call_build_answer(ev->tid,200,&ans);
2244
			eXosip_call_build_answer(ev->tid,200,&ans);
2245
#endif
1734
			if (ans){
2246
			if (ans){
1735
				fill_options_answer(ans);
2247
				fill_options_answer(ans);
2248
#ifdef HAVE_STRUCT_EXOSIP_T
2249
				eXosip_call_send_answer(sal->excontext, ev->tid, 200, ans);
2250
#else
1736
				eXosip_call_send_answer(ev->tid,200,ans);
2251
				eXosip_call_send_answer(ev->tid,200,ans);
2252
#endif
1737
			}
2253
			}
2254
#ifdef HAVE_STRUCT_EXOSIP_T
2255
			eXosip_unlock(sal->excontext);
2256
#else
1738
			eXosip_unlock();
2257
			eXosip_unlock();
2258
#endif
1739
		}
2259
		}
1740
	}else ms_warning("call_message_new: No request ?");
2260
	}else ms_warning("call_message_new: No request ?");
1741
}
2261
}
Lines 1743-1753 static void call_message_new(Sal *sal, e Link Here
1743
static void inc_update(Sal *sal, eXosip_event_t *ev){
2263
static void inc_update(Sal *sal, eXosip_event_t *ev){
1744
	osip_message_t *msg=NULL;
2264
	osip_message_t *msg=NULL;
1745
	ms_message("Processing incoming UPDATE");
2265
	ms_message("Processing incoming UPDATE");
2266
#ifdef HAVE_STRUCT_EXOSIP_T
2267
	eXosip_lock(sal->excontext);
2268
#else
1746
	eXosip_lock();
2269
	eXosip_lock();
2270
#endif
2271
#ifdef HAVE_STRUCT_EXOSIP_T
2272
	eXosip_message_build_answer(sal->excontext, ev->tid, 200, &msg);
2273
#else
1747
	eXosip_message_build_answer(ev->tid,200,&msg);
2274
	eXosip_message_build_answer(ev->tid,200,&msg);
1748
	if (msg!=NULL)
2275
#endif
2276
	if (msg!=NULL) {
2277
#ifdef HAVE_STRUCT_EXOSIP_T
2278
		eXosip_message_send_answer(sal->excontext, ev->tid, 200, msg);
2279
#else
1749
		eXosip_message_send_answer(ev->tid,200,msg);
2280
		eXosip_message_send_answer(ev->tid,200,msg);
2281
#endif
2282
	}
2283
#ifdef HAVE_STRUCT_EXOSIP_T
2284
	eXosip_unlock(sal->excontext);
2285
#else
1750
	eXosip_unlock();
2286
	eXosip_unlock();
2287
#endif
1751
}
2288
}
1752
2289
1753
static bool_t comes_from_local_if(osip_message_t *msg){
2290
static bool_t comes_from_local_if(osip_message_t *msg){
Lines 1865-1871 static void text_received(Sal *sal, eXos Link Here
1865
	salmsg.message_id=message_id;
2402
	salmsg.message_id=message_id;
1866
	salmsg.time=date!=NULL ? mktime_utc(&ret) : time(NULL);
2403
	salmsg.time=date!=NULL ? mktime_utc(&ret) : time(NULL);
1867
	sal->callbacks.text_received(op,&salmsg);
2404
	sal->callbacks.text_received(op,&salmsg);
1868
	sal_op_release(op);
2405
	sal_op_release(sal, op);
1869
	osip_free(from);
2406
	osip_free(from);
1870
}
2407
}
1871
2408
Lines 1874-1885 static void other_request(Sal *sal, eXos Link Here
1874
	if (ev->request==NULL) return;
2411
	if (ev->request==NULL) return;
1875
	if (strcmp(ev->request->sip_method,"MESSAGE")==0){
2412
	if (strcmp(ev->request->sip_method,"MESSAGE")==0){
1876
		text_received(sal,ev);
2413
		text_received(sal,ev);
2414
#ifdef HAVE_STRUCT_EXOSIP_T
2415
		eXosip_message_send_answer(sal->excontext, ev->tid, 200, NULL);
2416
#else
1877
		eXosip_message_send_answer(ev->tid,200,NULL);
2417
		eXosip_message_send_answer(ev->tid,200,NULL);
2418
#endif
1878
	}else if (strcmp(ev->request->sip_method,"OPTIONS")==0){
2419
	}else if (strcmp(ev->request->sip_method,"OPTIONS")==0){
1879
		osip_message_t *options=NULL;
2420
		osip_message_t *options=NULL;
2421
#ifdef HAVE_STRUCT_EXOSIP_T
2422
		eXosip_options_build_answer(sal->excontext, ev->tid, 200, &options);
2423
#else
1880
		eXosip_options_build_answer(ev->tid,200,&options);
2424
		eXosip_options_build_answer(ev->tid,200,&options);
2425
#endif
1881
		fill_options_answer(options);
2426
		fill_options_answer(options);
2427
#ifdef HAVE_STRUCT_EXOSIP_T
2428
		eXosip_options_send_answer(sal->excontext, ev->tid, 200, options);
2429
#else
1882
		eXosip_options_send_answer(ev->tid,200,options);
2430
		eXosip_options_send_answer(ev->tid,200,options);
2431
#endif
1883
	}else if (strncmp(ev->request->sip_method, "REFER", 5) == 0){
2432
	}else if (strncmp(ev->request->sip_method, "REFER", 5) == 0){
1884
		ms_message("Receiving REFER request !");
2433
		ms_message("Receiving REFER request !");
1885
		if (comes_from_local_if(ev->request)) {
2434
		if (comes_from_local_if(ev->request)) {
Lines 1896-1902 static void other_request(Sal *sal, eXos Link Here
1896
			osip_free(tmp);
2445
			osip_free(tmp);
1897
		}
2446
		}
1898
		/*answer with a 501 Not implemented*/
2447
		/*answer with a 501 Not implemented*/
2448
#ifdef HAVE_STRUCT_EXOSIP_T
2449
		eXosip_message_send_answer(sal->excontext, ev->tid, 501, NULL);
2450
#else
1899
		eXosip_message_send_answer(ev->tid,501,NULL);
2451
		eXosip_message_send_answer(ev->tid,501,NULL);
2452
#endif
1900
	}
2453
	}
1901
}
2454
}
1902
2455
Lines 1959-1965 static bool_t fix_message_contact(SalOp Link Here
1959
	return TRUE;    
2512
	return TRUE;    
1960
}
2513
}
1961
2514
1962
static bool_t register_again_with_updated_contact(SalOp *op, osip_message_t *orig_request, osip_message_t *last_answer){
2515
static bool_t register_again_with_updated_contact(Sal *ctx, SalOp *op, osip_message_t *orig_request, osip_message_t *last_answer){
1963
	osip_contact_t *ctt=NULL;
2516
	osip_contact_t *ctt=NULL;
1964
	SalAddress* ori_contact_address=NULL;
2517
	SalAddress* ori_contact_address=NULL;
1965
	const char *received;
2518
	const char *received;
Lines 2007-2031 static bool_t register_again_with_update Link Here
2007
		ms_message("Contact do not match, resending register.");
2560
		ms_message("Contact do not match, resending register.");
2008
	else return FALSE;
2561
	else return FALSE;
2009
2562
2563
#ifdef HAVE_STRUCT_EXOSIP_T
2564
	eXosip_lock(ctx->excontext);
2565
#else
2010
	eXosip_lock();
2566
	eXosip_lock();
2567
#endif
2568
#ifdef HAVE_STRUCT_EXOSIP_T
2569
	eXosip_register_build_register(ctx->excontext, op->rid, op->expires, &msg);
2570
#else
2011
	eXosip_register_build_register(op->rid,op->expires,&msg);
2571
	eXosip_register_build_register(op->rid,op->expires,&msg);
2572
#endif
2012
	if (msg==NULL){
2573
	if (msg==NULL){
2574
#ifdef HAVE_STRUCT_EXOSIP_T
2575
	    eXosip_unlock(ctx->excontext);
2576
#else
2013
	    eXosip_unlock();
2577
	    eXosip_unlock();
2578
#endif
2014
	    ms_warning("Fail to create a contact updated register.");
2579
	    ms_warning("Fail to create a contact updated register.");
2015
	    return FALSE;
2580
	    return FALSE;
2016
	}
2581
	}
2017
	if (fix_message_contact(op,msg,last_answer,op->base.root->expire_old_contact)) {
2582
	if (fix_message_contact(op,msg,last_answer,op->base.root->expire_old_contact)) {
2583
#ifdef HAVE_STRUCT_EXOSIP_T
2584
		eXosip_register_send_register(ctx->excontext, op->rid, msg);
2585
#else
2018
		eXosip_register_send_register(op->rid,msg);
2586
		eXosip_register_send_register(op->rid,msg);
2587
#endif
2588
#ifdef HAVE_STRUCT_EXOSIP_T
2589
		eXosip_unlock(ctx->excontext);  
2590
#else
2019
		eXosip_unlock();  
2591
		eXosip_unlock();  
2592
#endif
2020
		ms_message("Resending new register with updated contact");
2593
		ms_message("Resending new register with updated contact");
2021
		update_contact_from_response(op,last_answer);
2594
		update_contact_from_response(op,last_answer);
2022
		return TRUE;
2595
		return TRUE;
2023
	} else {
2596
	} else {
2024
	    ms_warning("Fail to send updated register.");
2597
	    ms_warning("Fail to send updated register.");
2598
#ifdef HAVE_STRUCT_EXOSIP_T
2599
	    eXosip_unlock(ctx->excontext);
2600
#else
2025
	    eXosip_unlock();
2601
	    eXosip_unlock();
2602
#endif
2026
	    return FALSE;
2603
	    return FALSE;
2027
	}
2604
	}
2605
#ifdef HAVE_STRUCT_EXOSIP_T
2606
	eXosip_unlock(ctx->excontext);
2607
#else
2028
	eXosip_unlock();
2608
	eXosip_unlock();
2609
#endif
2029
	return FALSE;
2610
	return FALSE;
2030
}
2611
}
2031
2612
Lines 2040-2046 static void registration_success(Sal *sa Link Here
2040
	osip_message_get_expires(ev->request,0,&h);
2621
	osip_message_get_expires(ev->request,0,&h);
2041
	if (h!=NULL && atoi(h->hvalue)!=0){
2622
	if (h!=NULL && atoi(h->hvalue)!=0){
2042
		registered=TRUE;
2623
		registered=TRUE;
2043
		if (!register_again_with_updated_contact(op,ev->request,ev->response)){
2624
		if (!register_again_with_updated_contact(sal,op,ev->request,ev->response)){
2044
			sal->callbacks.register_success(op,registered);
2625
			sal->callbacks.register_success(op,registered);
2045
		}
2626
		}
2046
	}else {
2627
	}else {
Lines 2078-2087 static bool_t registration_failure(Sal * Link Here
2078
					if (val>op->expires)
2659
					if (val>op->expires)
2079
						op->expires=val;
2660
						op->expires=val;
2080
				}else op->expires*=2;
2661
				}else op->expires*=2;
2662
#ifdef HAVE_STRUCT_EXOSIP_T
2663
				eXosip_lock(sal->excontext);
2664
#else
2081
				eXosip_lock();
2665
				eXosip_lock();
2666
#endif
2667
#ifdef HAVE_STRUCT_EXOSIP_T
2668
				eXosip_register_build_register(sal->excontext, op->rid, op->expires, &msg);
2669
#else
2082
				eXosip_register_build_register(op->rid,op->expires,&msg);
2670
				eXosip_register_build_register(op->rid,op->expires,&msg);
2671
#endif
2672
#ifdef HAVE_STRUCT_EXOSIP_T
2673
				eXosip_register_send_register(sal->excontext, op->rid, msg);
2674
#else
2083
				eXosip_register_send_register(op->rid,msg);
2675
				eXosip_register_send_register(op->rid,msg);
2676
#endif
2677
#ifdef HAVE_STRUCT_EXOSIP_T
2678
				eXosip_unlock(sal->excontext);
2679
#else
2084
				eXosip_unlock();
2680
				eXosip_unlock();
2681
#endif
2085
			}
2682
			}
2086
		break;
2683
		break;
2087
		case 606: /*Not acceptable, workaround for proxies that don't like private addresses
2684
		case 606: /*Not acceptable, workaround for proxies that don't like private addresses
Lines 2092-2098 static bool_t registration_failure(Sal * Link Here
2092
		default:
2689
		default:
2093
			/* if contact is up to date, process the failure, otherwise resend a new register with
2690
			/* if contact is up to date, process the failure, otherwise resend a new register with
2094
				updated contact first, just in case the faillure is due to incorrect contact */
2691
				updated contact first, just in case the faillure is due to incorrect contact */
2095
			if (ev->response && register_again_with_updated_contact(op,ev->request,ev->response))
2692
			if (ev->response && register_again_with_updated_contact(sal,op,ev->request,ev->response))
2096
				return TRUE; /*we are retrying with an updated contact*/
2693
				return TRUE; /*we are retrying with an updated contact*/
2097
			if (status_code==403){
2694
			if (status_code==403){
2098
				se=SalErrorFailure;
2695
				se=SalErrorFailure;
Lines 2136-2142 static void process_in_call_reply(Sal *s Link Here
2136
	if (ev->response){
2733
	if (ev->response){
2137
		if (ev->request && strcmp(osip_message_get_method(ev->request),"NOTIFY")==0){
2734
		if (ev->request && strcmp(osip_message_get_method(ev->request),"NOTIFY")==0){
2138
			if (op->sipfrag_pending){
2735
			if (op->sipfrag_pending){
2139
				send_notify_for_refer(op->did,op->sipfrag_pending);
2736
				send_notify_for_refer(sal, op->did,op->sipfrag_pending);
2140
				op->sipfrag_pending=NULL;
2737
				op->sipfrag_pending=NULL;
2141
			}
2738
			}
2142
		}
2739
		}
Lines 2156-2162 static bool_t process_event(Sal *sal, eX Link Here
2156
			ms_message("CALL_CLOSED or CANCELLED\n");
2753
			ms_message("CALL_CLOSED or CANCELLED\n");
2157
			call_terminated(sal,ev);
2754
			call_terminated(sal,ev);
2158
			break;
2755
			break;
2756
#ifdef EXOSIP_CALL_TIMEOUT
2159
		case EXOSIP_CALL_TIMEOUT:
2757
		case EXOSIP_CALL_TIMEOUT:
2758
#endif
2160
		case EXOSIP_CALL_NOANSWER:
2759
		case EXOSIP_CALL_NOANSWER:
2161
			ms_message("CALL_TIMEOUT or NOANSWER\n");
2760
			ms_message("CALL_TIMEOUT or NOANSWER\n");
2162
			return call_failure(sal,ev);
2761
			return call_failure(sal,ev);
Lines 2184-2190 static bool_t process_event(Sal *sal, eX Link Here
2184
			break;
2783
			break;
2185
		case EXOSIP_CALL_REDIRECTED:
2784
		case EXOSIP_CALL_REDIRECTED:
2186
			ms_message("CALL_REDIRECTED");
2785
			ms_message("CALL_REDIRECTED");
2786
#ifdef HAVE_STRUCT_EXOSIP_T
2787
			eXosip_default_action(sal->excontext, ev);
2788
#else
2187
			eXosip_default_action(ev);
2789
			eXosip_default_action(ev);
2790
#endif
2188
			break;
2791
			break;
2189
		case EXOSIP_CALL_PROCEEDING:
2792
		case EXOSIP_CALL_PROCEEDING:
2190
			ms_message("CALL_PROCEEDING");
2793
			ms_message("CALL_PROCEEDING");
Lines 2213-2225 static bool_t process_event(Sal *sal, eX Link Here
2213
			ms_message("CALL_IN_SUBSCRIPTION_NEW ");
2816
			ms_message("CALL_IN_SUBSCRIPTION_NEW ");
2214
			sal_exosip_subscription_recv(sal,ev);
2817
			sal_exosip_subscription_recv(sal,ev);
2215
			break;
2818
			break;
2819
#ifdef EXOSIP_IN_SUBSCRIPTION_RELEASED
2216
		case EXOSIP_IN_SUBSCRIPTION_RELEASED:
2820
		case EXOSIP_IN_SUBSCRIPTION_RELEASED:
2217
			ms_message("CALL_SUBSCRIPTION_NEW ");
2821
			ms_message("CALL_SUBSCRIPTION_NEW ");
2218
			sal_exosip_in_subscription_closed(sal,ev);
2822
			sal_exosip_in_subscription_closed(sal,ev);
2219
			break;
2823
			break;
2824
#endif
2825
#ifdef EXOSIP_SUBSCRIPTION_UPDATE
2220
		case EXOSIP_SUBSCRIPTION_UPDATE:
2826
		case EXOSIP_SUBSCRIPTION_UPDATE:
2221
			ms_message("CALL_SUBSCRIPTION_UPDATE");
2827
			ms_message("CALL_SUBSCRIPTION_UPDATE");
2222
			break;
2828
			break;
2829
#endif
2223
		case EXOSIP_SUBSCRIPTION_NOTIFY:
2830
		case EXOSIP_SUBSCRIPTION_NOTIFY:
2224
			ms_message("CALL_SUBSCRIPTION_NOTIFY");
2831
			ms_message("CALL_SUBSCRIPTION_NOTIFY");
2225
			sal_exosip_notify_recv(sal,ev);
2832
			sal_exosip_notify_recv(sal,ev);
Lines 2228-2237 static bool_t process_event(Sal *sal, eX Link Here
2228
			ms_message("EXOSIP_SUBSCRIPTION_ANSWERED, ev->sid=%i, ev->did=%i\n",ev->sid,ev->did);
2835
			ms_message("EXOSIP_SUBSCRIPTION_ANSWERED, ev->sid=%i, ev->did=%i\n",ev->sid,ev->did);
2229
			sal_exosip_subscription_answered(sal,ev);
2836
			sal_exosip_subscription_answered(sal,ev);
2230
			break;
2837
			break;
2838
#ifdef EXOSIP_SUBSCRIPTION_CLOSED
2231
		case EXOSIP_SUBSCRIPTION_CLOSED:
2839
		case EXOSIP_SUBSCRIPTION_CLOSED:
2232
			ms_message("EXOSIP_SUBSCRIPTION_CLOSED\n");
2840
			ms_message("EXOSIP_SUBSCRIPTION_CLOSED\n");
2233
			sal_exosip_subscription_closed(sal,ev);
2841
			sal_exosip_subscription_closed(sal,ev);
2234
			break;
2842
			break;
2843
#endif
2235
		case EXOSIP_SUBSCRIPTION_REQUESTFAILURE:   /**< announce a request failure      */
2844
		case EXOSIP_SUBSCRIPTION_REQUESTFAILURE:   /**< announce a request failure      */
2236
			if (ev->response && (ev->response->status_code == 407 || ev->response->status_code == 401)){
2845
			if (ev->response && (ev->response->status_code == 407 || ev->response->status_code == 401)){
2237
				return process_authentication(sal,ev);
2846
				return process_authentication(sal,ev);
Lines 2266-2272 static bool_t process_event(Sal *sal, eX Link Here
2266
					case 401:
2875
					case 401:
2267
						return process_authentication(sal,ev);
2876
						return process_authentication(sal,ev);
2268
					case 412: {
2877
					case 412: {
2878
#ifdef HAVE_STRUCT_EXOSIP_T
2879
						eXosip_automatic_action (sal->excontext);
2880
#else
2269
						eXosip_automatic_action ();
2881
						eXosip_automatic_action ();
2882
#endif
2270
						return 1;
2883
						return 1;
2271
					}
2884
					}
2272
				}
2885
				}
Lines 2282-2303 static bool_t process_event(Sal *sal, eX Link Here
2282
2895
2283
int sal_iterate(Sal *sal){
2896
int sal_iterate(Sal *sal){
2284
	eXosip_event_t *ev;
2897
	eXosip_event_t *ev;
2898
#ifdef HAVE_STRUCT_EXOSIP_T
2899
	while((ev=eXosip_event_wait(sal->excontext, 0, 0))!=NULL){
2900
#else
2285
	while((ev=eXosip_event_wait(0,0))!=NULL){
2901
	while((ev=eXosip_event_wait(0,0))!=NULL){
2902
#endif
2286
		if (process_event(sal,ev))
2903
		if (process_event(sal,ev))
2287
			eXosip_event_free(ev);
2904
			eXosip_event_free(ev);
2288
	}
2905
	}
2289
#ifdef HAVE_EXOSIP_TRYLOCK
2906
#ifdef HAVE_EXOSIP_TRYLOCK
2907
2290
	if (eXosip_trylock()==0){
2908
	if (eXosip_trylock()==0){
2909
#ifdef HAVE_STRUCT_EXOSIP_T
2910
		eXosip_automatic_refresh(sal->excontext);
2911
#else
2291
		eXosip_automatic_refresh();
2912
		eXosip_automatic_refresh();
2913
#endif
2914
#ifdef HAVE_STRUCT_EXOSIP_T
2915
		eXosip_unlock(sal->excontext);
2916
#else
2292
		eXosip_unlock();
2917
		eXosip_unlock();
2918
#endif
2293
	}else{
2919
	}else{
2294
		ms_warning("eXosip_trylock busy.");
2920
		ms_warning("eXosip_trylock busy.");
2295
	}
2921
	}
2922
2923
#else /* HAVE_EXOSIP_TRYLOCK */
2924
2925
#ifdef HAVE_STRUCT_EXOSIP_T
2926
	eXosip_lock(sal->excontext);
2296
#else
2927
#else
2297
	eXosip_lock();
2928
	eXosip_lock();
2929
#endif
2930
#ifdef HAVE_STRUCT_EXOSIP_T
2931
	eXosip_automatic_refresh(sal->excontext);
2932
#else
2298
	eXosip_automatic_refresh();
2933
	eXosip_automatic_refresh();
2934
#endif
2935
#ifdef HAVE_STRUCT_EXOSIP_T
2936
	eXosip_unlock(sal->excontext);
2937
#else
2299
	eXosip_unlock();
2938
	eXosip_unlock();
2300
#endif
2939
#endif
2940
2941
#endif /* HAVE_EXOSIP_TRYLOCK */
2301
	return 0;
2942
	return 0;
2302
}
2943
}
2303
2944
Lines 2337-2343 void sal_message_add_route(osip_message_ Link Here
2337
}
2978
}
2338
2979
2339
2980
2340
int sal_register(SalOp *h, const char *proxy, const char *from, int expires){
2981
int sal_register(Sal *ctx, SalOp *h, const char *proxy, const char *from, int expires){
2341
	osip_message_t *msg;
2982
	osip_message_t *msg;
2342
	const char *contact=sal_op_get_contact(h);
2983
	const char *contact=sal_op_get_contact(h);
2343
2984
Lines 2361-2391 int sal_register(SalOp *h, const char *p Link Here
2361
		}
3002
		}
2362
		if (uri) ms_free(uri);
3003
		if (uri) ms_free(uri);
2363
		sal_address_destroy(from_parsed);
3004
		sal_address_destroy(from_parsed);
3005
#ifdef HAVE_STRUCT_EXOSIP_T
3006
		eXosip_lock(ctx->excontext);
3007
#else
2364
		eXosip_lock();
3008
		eXosip_lock();
3009
#endif
3010
#ifdef HAVE_STRUCT_EXOSIP_T
3011
		h->rid=eXosip_register_build_initial_register(ctx->excontext, from, domain,
3012
							      NULL, expires, &msg);
3013
#else
2365
		h->rid=eXosip_register_build_initial_register(from,domain,NULL,expires,&msg);
3014
		h->rid=eXosip_register_build_initial_register(from,domain,NULL,expires,&msg);
3015
#endif
2366
		if (msg){
3016
		if (msg){
2367
			if (contact) register_set_contact(msg,contact);
3017
			if (contact) register_set_contact(msg,contact);
2368
			sal_message_add_route(msg,proxy);
3018
			sal_message_add_route(msg,proxy);
2369
			sal_add_register(h->base.root,h);
3019
			sal_add_register(h->base.root,h);
2370
		}else{
3020
		}else{
2371
			ms_error("Could not build initial register.");
3021
			ms_error("Could not build initial register.");
3022
#ifdef HAVE_STRUCT_EXOSIP_T
3023
			eXosip_unlock(ctx->excontext);
3024
#else
2372
			eXosip_unlock();
3025
			eXosip_unlock();
3026
#endif
2373
			return -1;
3027
			return -1;
2374
		}
3028
		}
2375
	}else{
3029
	}else{
3030
#ifdef HAVE_STRUCT_EXOSIP_T
3031
		eXosip_lock(ctx->excontext);
3032
#else
2376
		eXosip_lock();
3033
		eXosip_lock();
3034
#endif
3035
#ifdef HAVE_STRUCT_EXOSIP_T
3036
		eXosip_register_build_register(ctx->excontext, h->rid, expires, &msg);
3037
#else
2377
		eXosip_register_build_register(h->rid,expires,&msg);
3038
		eXosip_register_build_register(h->rid,expires,&msg);
3039
#endif
2378
		sal_message_add_route(msg,proxy);
3040
		sal_message_add_route(msg,proxy);
2379
	}
3041
	}
2380
	if (msg){
3042
	if (msg){
3043
#ifdef HAVE_STRUCT_EXOSIP_T
3044
		eXosip_register_send_register(ctx->excontext, h->rid, msg);
3045
#else
2381
		eXosip_register_send_register(h->rid,msg);
3046
		eXosip_register_send_register(h->rid,msg);
3047
#endif
2382
	}
3048
	}
3049
#ifdef HAVE_STRUCT_EXOSIP_T
3050
	eXosip_unlock(ctx->excontext);
3051
#else
2383
	eXosip_unlock();
3052
	eXosip_unlock();
3053
#endif
2384
	h->expires=expires;
3054
	h->expires=expires;
2385
	return (msg != NULL) ? 0 : -1;
3055
	return (msg != NULL) ? 0 : -1;
2386
}
3056
}
2387
3057
2388
int sal_register_refresh(SalOp *op, int expires){
3058
int sal_register_refresh(Sal *ctx, SalOp *op, int expires){
2389
	osip_message_t *msg=NULL;
3059
	osip_message_t *msg=NULL;
2390
	const char *contact=sal_op_get_contact(op);
3060
	const char *contact=sal_op_get_contact(op);
2391
	
3061
	
Lines 2408-2434 int sal_register_refresh(SalOp *op, int Link Here
2408
			}
3078
			}
2409
		}
3079
		}
2410
	}
3080
	}
3081
#else /* HAVE_EXOSIP_TRYLOCK */
3082
#ifdef HAVE_STRUCT_EXOSIP_T
3083
	eXosip_lock(ctx->excontext);
2411
#else
3084
#else
2412
	eXosip_lock();
3085
	eXosip_lock();
2413
#endif
3086
#endif
3087
#endif /* HAVE_EXOSIP_TRYLOCK */
3088
#ifdef HAVE_STRUCT_EXOSIP_T
3089
	eXosip_register_build_register(ctx->excontext, op->rid, expires, &msg);
3090
#else
2414
	eXosip_register_build_register(op->rid,expires,&msg);
3091
	eXosip_register_build_register(op->rid,expires,&msg);
3092
#endif
2415
	if (msg!=NULL){
3093
	if (msg!=NULL){
2416
		if (contact) register_set_contact(msg,contact);
3094
		if (contact) register_set_contact(msg,contact);
2417
		sal_message_add_route(msg,sal_op_get_route(op));
3095
		sal_message_add_route(msg,sal_op_get_route(op));
3096
#ifdef HAVE_STRUCT_EXOSIP_T
3097
		eXosip_register_send_register(ctx->excontext, op->rid, msg);
3098
#else
2418
		eXosip_register_send_register(op->rid,msg);
3099
		eXosip_register_send_register(op->rid,msg);
3100
#endif
2419
	}else ms_error("Could not build REGISTER refresh message.");
3101
	}else ms_error("Could not build REGISTER refresh message.");
3102
#ifdef HAVE_STRUCT_EXOSIP_T
3103
	eXosip_unlock(ctx->excontext);
3104
#else
2420
	eXosip_unlock();
3105
	eXosip_unlock();
3106
#endif
2421
	return (msg != NULL) ? 0 : -1;
3107
	return (msg != NULL) ? 0 : -1;
2422
}
3108
}
2423
3109
2424
3110
int sal_unregister(Sal *ctx, SalOp *h){
2425
int sal_unregister(SalOp *h){
2426
	osip_message_t *msg=NULL;
3111
	osip_message_t *msg=NULL;
3112
#ifdef HAVE_STRUCT_EXOSIP_T
3113
	eXosip_lock(ctx->excontext);
3114
#else
2427
	eXosip_lock();
3115
	eXosip_lock();
2428
	eXosip_register_build_register(h->rid,0,&msg);
3116
#endif
3117
#ifdef HAVE_STRUCT_EXOSIP_T
3118
	eXosip_register_build_register(ctx->excontext, h->rid, 0, &msg);
3119
#else
3120
	eXosip_register_build_register(h->rid, 0, &msg);
3121
#endif
3122
#ifdef HAVE_STRUCT_EXOSIP_T
3123
	if (msg) eXosip_register_send_register(ctx->excontext, h->rid,msg);
3124
#else
2429
	if (msg) eXosip_register_send_register(h->rid,msg);
3125
	if (msg) eXosip_register_send_register(h->rid,msg);
3126
#endif
2430
	else ms_warning("Could not build unREGISTER !");
3127
	else ms_warning("Could not build unREGISTER !");
3128
#ifdef HAVE_STRUCT_EXOSIP_T
3129
	eXosip_unlock(ctx->excontext);
3130
#else
2431
	eXosip_unlock();
3131
	eXosip_unlock();
3132
#endif
2432
	return 0;
3133
	return 0;
2433
}
3134
}
2434
3135
Lines 2598-2605 void sal_set_keepalive_period(Sal *ctx,u Link Here
2598
		default:
3299
		default:
2599
			break;
3300
			break;
2600
	}
3301
	}
3302
#ifdef HAVE_STRUCT_EXOSIP_T
3303
	eXosip_set_option (ctx->excontext, EXOSIP_OPT_UDP_KEEP_ALIVE, &ctx->keepalive_period);
3304
#else
2601
	eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &ctx->keepalive_period);
3305
	eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &ctx->keepalive_period);
3306
#endif
2602
}
3307
}
3308
2603
unsigned int sal_get_keepalive_period(Sal *ctx) {
3309
unsigned int sal_get_keepalive_period(Sal *ctx) {
2604
	return ctx->keepalive_period;
3310
	return ctx->keepalive_period;
2605
}
3311
}
Lines 2632-2647 void sal_address_set_transport(SalAddres Link Here
2632
}
3338
}
2633
3339
2634
/* sends a reinvite. Local media description may have changed by application since call establishment*/
3340
/* sends a reinvite. Local media description may have changed by application since call establishment*/
2635
int sal_call_update(SalOp *h, const char *subject){
3341
int sal_call_update(Sal *sal, SalOp *h, const char *subject){
2636
	int err=0;
3342
	int err=0;
2637
	osip_message_t *reinvite=NULL;
3343
	osip_message_t *reinvite=NULL;
2638
3344
3345
#ifdef HAVE_STRUCT_EXOSIP_T
3346
	eXosip_lock(sal->excontext);
3347
#else
2639
	eXosip_lock();
3348
	eXosip_lock();
3349
#endif
3350
#ifdef HAVE_STRUCT_EXOSIP_T
3351
	if(eXosip_call_build_request(sal->excontext, h->did, "INVITE", &reinvite) != 0 || reinvite==NULL){
3352
#else
2640
	if(eXosip_call_build_request(h->did,"INVITE",&reinvite) != 0 || reinvite==NULL){
3353
	if(eXosip_call_build_request(h->did,"INVITE",&reinvite) != 0 || reinvite==NULL){
3354
#endif
3355
#ifdef HAVE_STRUCT_EXOSIP_T
3356
		eXosip_unlock(sal->excontext);
3357
#else
2641
		eXosip_unlock();
3358
		eXosip_unlock();
3359
#endif
2642
		return -1;
3360
		return -1;
2643
	}
3361
	}
3362
#ifdef HAVE_STRUCT_EXOSIP_T
3363
	eXosip_unlock(sal->excontext);
3364
#else
2644
	eXosip_unlock();
3365
	eXosip_unlock();
3366
#endif
2645
	osip_message_set_subject(reinvite,subject);
3367
	osip_message_set_subject(reinvite,subject);
2646
	osip_message_set_allow(reinvite, "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
3368
	osip_message_set_allow(reinvite, "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
2647
	if (h->base.contact){
3369
	if (h->base.contact){
Lines 2656-2664 int sal_call_update(SalOp *h, const char Link Here
2656
		h->sdp_offering=TRUE;
3378
		h->sdp_offering=TRUE;
2657
		set_sdp_from_desc(reinvite,h->base.local_media);
3379
		set_sdp_from_desc(reinvite,h->base.local_media);
2658
	}else h->sdp_offering=FALSE;
3380
	}else h->sdp_offering=FALSE;
3381
#ifdef HAVE_STRUCT_EXOSIP_T
3382
	eXosip_lock(sal->excontext);
3383
#else
2659
	eXosip_lock();
3384
	eXosip_lock();
3385
#endif
3386
#ifdef HAVE_STRUCT_EXOSIP_T
3387
	err = eXosip_call_send_request(sal->excontext, h->did, reinvite);
3388
#else
2660
	err = eXosip_call_send_request(h->did, reinvite);
3389
	err = eXosip_call_send_request(h->did, reinvite);
3390
#endif
3391
#ifdef HAVE_STRUCT_EXOSIP_T
3392
	eXosip_unlock(sal->excontext);
3393
#else
2661
	eXosip_unlock();
3394
	eXosip_unlock();
3395
#endif
2662
	return err;
3396
	return err;
2663
}
3397
}
2664
3398
2665
-- a/coreapi/sal_eXosip2.h
3399
++ b/coreapi/sal_eXosip2.h
Lines 53-58 struct Sal{ Link Here
53
	bool_t expire_old_contact;
53
	bool_t expire_old_contact;
54
	bool_t add_dates;
54
	bool_t add_dates;
55
	bool_t tcp_tls_keepalive;
55
	bool_t tcp_tls_keepalive;
56
#ifdef HAVE_STRUCT_EXOSIP_T
57
	struct eXosip_t *excontext;
58
#endif
56
};
59
};
57
60
58
struct SalOp{
61
struct SalOp{
59
-- a/coreapi/sal_eXosip2_presence.c
62
++ b/coreapi/sal_eXosip2_presence.c
Lines 17-22 along with this program; if not, write t Link Here
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
*/
18
*/
19
19
20
#ifdef HAVE_CONFIG_H
21
#include "config.h"
22
#endif
20
23
21
#include "sal_eXosip2.h"
24
#include "sal_eXosip2.h"
22
25
Lines 101-107 static void msg_add_current_date(osip_me Link Here
101
}
104
}
102
105
103
106
104
int sal_message_send(SalOp *op, const char *from, const char *to, const char* content_type, const char *msg){
107
int sal_message_send(Sal *ctx, SalOp *op, const char *from, const char *to, const char* content_type, const char *msg){
105
	osip_message_t *sip=NULL;
108
	osip_message_t *sip=NULL;
106
109
107
	if(op->cid == -1)
110
	if(op->cid == -1)
Lines 113-180 int sal_message_send(SalOp *op, const ch Link Here
113
			sal_op_set_to(op,to);
116
			sal_op_set_to(op,to);
114
117
115
		sal_exosip_fix_route(op);
118
		sal_exosip_fix_route(op);
119
#ifdef HAVE_STRUCT_EXOSIP_T
120
		eXosip_lock(ctx->excontext);
121
#else
116
		eXosip_lock();
122
		eXosip_lock();
123
#endif
124
#ifdef HAVE_STRUCT_EXOSIP_T
125
		eXosip_message_build_request(ctx->excontext, &sip, "MESSAGE", sal_op_get_to(op),
126
			sal_op_get_from(op),sal_op_get_route(op));
127
#else
117
		eXosip_message_build_request(&sip,"MESSAGE",sal_op_get_to(op),
128
		eXosip_message_build_request(&sip,"MESSAGE",sal_op_get_to(op),
118
			sal_op_get_from(op),sal_op_get_route(op));
129
			sal_op_get_from(op),sal_op_get_route(op));
130
#endif
119
		if (sip!=NULL){
131
		if (sip!=NULL){
120
			sal_exosip_add_custom_headers(sip,op->base.custom_headers);
132
			sal_exosip_add_custom_headers(sip,op->base.custom_headers);
121
			msg_add_current_date(sip);
133
			msg_add_current_date(sip);
122
			osip_message_set_content_type(sip,content_type);
134
			osip_message_set_content_type(sip,content_type);
123
			if (msg) osip_message_set_body(sip,msg,strlen(msg));
135
			if (msg) osip_message_set_body(sip,msg,strlen(msg));
124
			sal_add_other(op->base.root,op,sip);
136
			sal_add_other(op->base.root,op,sip);
137
#ifdef HAVE_STRUCT_EXOSIP_T
138
			eXosip_message_send_request(ctx->excontext, sip);
139
#else
125
			eXosip_message_send_request(sip);
140
			eXosip_message_send_request(sip);
141
#endif
126
		}else{
142
		}else{
127
			ms_error("Could not build MESSAGE request !");
143
			ms_error("Could not build MESSAGE request !");
128
		}
144
		}
145
#ifdef HAVE_STRUCT_EXOSIP_T
146
		eXosip_unlock(ctx->excontext);
147
#else
129
		eXosip_unlock();
148
		eXosip_unlock();
149
#endif
130
	}
150
	}
131
	else
151
	else
132
	{
152
	{
133
		/* we are currently in communication with the destination */
153
		/* we are currently in communication with the destination */
154
#ifdef HAVE_STRUCT_EXOSIP_T
155
		eXosip_lock(ctx->excontext);
156
#else
134
		eXosip_lock();
157
		eXosip_lock();
158
#endif
135
		//First we generate an INFO message to get the current call_id and a good cseq
159
		//First we generate an INFO message to get the current call_id and a good cseq
160
#ifdef HAVE_STRUCT_EXOSIP_T
161
		eXosip_call_build_request(ctx->excontext, op->did, "MESSAGE", &sip);
162
#else
136
		eXosip_call_build_request(op->did,"MESSAGE",&sip);
163
		eXosip_call_build_request(op->did,"MESSAGE",&sip);
164
#endif
137
		if(sip == NULL)
165
		if(sip == NULL)
138
		{
166
		{
139
			ms_warning("could not get a build info to send MESSAGE, maybe no previous call established ?");
167
			ms_warning("could not get a build info to send MESSAGE, maybe no previous call established ?");
168
#ifdef HAVE_STRUCT_EXOSIP_T
169
			eXosip_unlock(ctx->excontext);
170
#else
140
			eXosip_unlock();
171
			eXosip_unlock();
172
#endif
141
			return -1;
173
			return -1;
142
		}
174
		}
143
		sal_exosip_add_custom_headers(sip,op->base.custom_headers);
175
		sal_exosip_add_custom_headers(sip,op->base.custom_headers);
144
		msg_add_current_date(sip);
176
		msg_add_current_date(sip);
145
		osip_message_set_content_type(sip,content_type);
177
		osip_message_set_content_type(sip,content_type);
146
		if (msg) osip_message_set_body(sip,msg,strlen(msg));
178
		if (msg) osip_message_set_body(sip,msg,strlen(msg));
179
#ifdef HAVE_STRUCT_EXOSIP_T
180
		eXosip_call_send_request(ctx->excontext, op->did, sip);
181
#else
147
		eXosip_call_send_request(op->did,sip);
182
		eXosip_call_send_request(op->did,sip);
183
#endif
184
#ifdef HAVE_STRUCT_EXOSIP_T
185
		eXosip_unlock(ctx->excontext);
186
#else
148
		eXosip_unlock();
187
		eXosip_unlock();
188
#endif
149
	}
189
	}
150
	return 0;
190
	return 0;
151
}
191
}
152
192
153
int sal_text_send(SalOp *op, const char *from, const char *to, const char *msg) {
193
int sal_text_send(Sal *ctx, SalOp *op, const char *from, const char *to, const char *msg) {
154
	return sal_message_send(op,from,to,"text/plain",msg);
194
	return sal_message_send(ctx,op,from,to,"text/plain",msg);
155
}
195
}
156
/*presence Subscribe/notify*/
196
/*presence Subscribe/notify*/
157
int sal_subscribe_presence(SalOp *op, const char *from, const char *to){
197
int sal_subscribe_presence(Sal *ctx, SalOp *op, const char *from, const char *to){
158
	osip_message_t *msg=NULL;
198
	osip_message_t *msg=NULL;
159
	if (from)
199
	if (from)
160
		sal_op_set_from(op,from);
200
		sal_op_set_from(op,from);
161
	if (to)
201
	if (to)
162
		sal_op_set_to(op,to);
202
		sal_op_set_to(op,to);
163
	sal_exosip_fix_route(op);
203
	sal_exosip_fix_route(op);
204
#ifdef HAVE_STRUCT_EXOSIP_T
205
	eXosip_lock(ctx->excontext);
206
#else
164
	eXosip_lock();
207
	eXosip_lock();
208
#endif
209
#ifdef HAVE_STRUCT_EXOSIP_T
210
	eXosip_subscribe_build_initial_request(ctx->excontext, &msg, sal_op_get_to(op),
211
		sal_op_get_from(op), sal_op_get_route(op), "presence", 600);
212
#else
165
	eXosip_subscribe_build_initial_request(&msg,sal_op_get_to(op),sal_op_get_from(op),
213
	eXosip_subscribe_build_initial_request(&msg,sal_op_get_to(op),sal_op_get_from(op),
166
	    	sal_op_get_route(op),"presence",600);
214
	    	sal_op_get_route(op),"presence",600);
215
#endif
167
	if (msg==NULL){
216
	if (msg==NULL){
168
		ms_error("Could not build subscribe request to %s",to);
217
		ms_error("Could not build subscribe request to %s",to);
218
#ifdef HAVE_STRUCT_EXOSIP_T
219
		eXosip_unlock(ctx->excontext);
220
#else
169
		eXosip_unlock();
221
		eXosip_unlock();
222
#endif
170
		return -1;
223
		return -1;
171
	}
224
	}
172
	if (op->base.contact){
225
	if (op->base.contact){
173
		_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
226
		_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
174
		osip_message_set_contact(msg,op->base.contact);
227
		osip_message_set_contact(msg,op->base.contact);
175
	}
228
	}
229
#ifdef HAVE_STRUCT_EXOSIP_T
230
	op->sid=eXosip_subscribe_send_initial_request(ctx->excontext, msg);
231
#else
176
	op->sid=eXosip_subscribe_send_initial_request(msg);
232
	op->sid=eXosip_subscribe_send_initial_request(msg);
233
#endif
234
#ifdef HAVE_STRUCT_EXOSIP_T
235
	eXosip_unlock(ctx->excontext);
236
#else
177
	eXosip_unlock();
237
	eXosip_unlock();
238
#endif
178
	if (op->sid==-1){
239
	if (op->sid==-1){
179
		osip_message_free(msg);
240
		osip_message_free(msg);
180
		return -1;
241
		return -1;
Lines 183-227 int sal_subscribe_presence(SalOp *op, co Link Here
183
	return 0;
244
	return 0;
184
}
245
}
185
246
186
int sal_unsubscribe(SalOp *op){
247
int sal_unsubscribe(Sal *ctx, SalOp *op){
187
	osip_message_t *msg=NULL;
248
	osip_message_t *msg=NULL;
188
	if (op->did==-1){
249
	if (op->did==-1){
189
		ms_error("cannot unsubscribe, no dialog !");
250
		ms_error("cannot unsubscribe, no dialog !");
190
		return -1;
251
		return -1;
191
	}
252
	}
253
#ifdef HAVE_STRUCT_EXOSIP_T
254
	eXosip_lock(ctx->excontext);
255
#else
192
	eXosip_lock();
256
	eXosip_lock();
257
#endif
258
#ifdef HAVE_STRUCT_EXOSIP_T
259
	eXosip_subscribe_build_refresh_request(ctx->excontext, op->did, &msg);
260
#else
193
	eXosip_subscribe_build_refresh_request(op->did,&msg);
261
	eXosip_subscribe_build_refresh_request(op->did,&msg);
262
#endif
194
	if (msg){
263
	if (msg){
195
		osip_message_set_expires(msg,"0");
264
		osip_message_set_expires(msg,"0");
265
#ifdef HAVE_STRUCT_EXOSIP_T
266
		eXosip_subscribe_send_refresh_request(ctx->excontext, op->did, msg);
267
#else
196
		eXosip_subscribe_send_refresh_request(op->did,msg);
268
		eXosip_subscribe_send_refresh_request(op->did,msg);
269
#endif
197
	}else ms_error("Could not build subscribe refresh request ! op->sid=%i, op->did=%i",
270
	}else ms_error("Could not build subscribe refresh request ! op->sid=%i, op->did=%i",
198
	    	op->sid,op->did);
271
	    	op->sid,op->did);
272
#ifdef HAVE_STRUCT_EXOSIP_T
273
	eXosip_unlock(ctx->excontext);
274
#else
199
	eXosip_unlock();
275
	eXosip_unlock();
276
#endif
200
	return 0;
277
	return 0;
201
}
278
}
202
279
203
int sal_subscribe_accept(SalOp *op){
280
int sal_subscribe_accept(Sal *ctx, SalOp *op){
204
	osip_message_t *msg=NULL;
281
	osip_message_t *msg=NULL;
282
#ifdef HAVE_STRUCT_EXOSIP_T
283
	eXosip_lock(ctx->excontext);
284
#else
205
	eXosip_lock();
285
	eXosip_lock();
286
#endif
287
#ifdef HAVE_STRUCT_EXOSIP_T
288
	eXosip_insubscription_build_answer(ctx->excontext, op->tid, 202, &msg);
289
#else
206
	eXosip_insubscription_build_answer(op->tid,202,&msg);
290
	eXosip_insubscription_build_answer(op->tid,202,&msg);
291
#endif
207
	if (msg==NULL){
292
	if (msg==NULL){
208
		ms_error("Fail to build answer to subscribe.");
293
		ms_error("Fail to build answer to subscribe.");
294
#ifdef HAVE_STRUCT_EXOSIP_T
295
		eXosip_unlock(ctx->excontext);
296
#else
209
		eXosip_unlock();
297
		eXosip_unlock();
298
#endif
210
		return -1;
299
		return -1;
211
	}
300
	}
212
	if (op->base.contact){
301
	if (op->base.contact){
213
		_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
302
		_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
214
		osip_message_set_contact(msg,op->base.contact);
303
		osip_message_set_contact(msg,op->base.contact);
215
	}
304
	}
305
#ifdef HAVE_STRUCT_EXOSIP_T
306
	eXosip_insubscription_send_answer(ctx->excontext, op->tid, 202, msg);
307
#else
216
	eXosip_insubscription_send_answer(op->tid,202,msg);
308
	eXosip_insubscription_send_answer(op->tid,202,msg);
309
#endif
310
#ifdef HAVE_STRUCT_EXOSIP_T
311
	eXosip_unlock(ctx->excontext);
312
#else
217
	eXosip_unlock();
313
	eXosip_unlock();
314
#endif
218
	return 0;
315
	return 0;
219
}
316
}
220
317
221
int sal_subscribe_decline(SalOp *op){
318
int sal_subscribe_decline(Sal *ctx, SalOp *op){
319
#ifdef HAVE_STRUCT_EXOSIP_T
320
	eXosip_lock(ctx->excontext);
321
#else
222
	eXosip_lock();
322
	eXosip_lock();
323
#endif
324
#ifdef HAVE_STRUCT_EXOSIP_T
325
	eXosip_insubscription_send_answer(ctx->excontext, op->tid, 401, NULL);
326
#else
223
	eXosip_insubscription_send_answer(op->tid,401,NULL);
327
	eXosip_insubscription_send_answer(op->tid,401,NULL);
328
#endif
329
#ifdef HAVE_STRUCT_EXOSIP_T
330
	eXosip_unlock(ctx->excontext);
331
#else
224
	eXosip_unlock();
332
	eXosip_unlock();
333
#endif
225
	return 0;
334
	return 0;
226
}
335
}
227
336
Lines 595-639 static void add_presence_body(osip_messa Link Here
595
}
704
}
596
705
597
706
598
int sal_notify_presence(SalOp *op, SalPresenceStatus status, const char *status_message){
707
int sal_notify_presence(Sal *ctx, SalOp *op, SalPresenceStatus status, const char *status_message){
599
	osip_message_t *msg=NULL;
708
	osip_message_t *msg=NULL;
709
#if 1
710
	enum eXosip_ss ss=EXOSIP_SUBCRSTATE_ACTIVE;
711
#else
600
	eXosip_ss_t ss=EXOSIP_SUBCRSTATE_ACTIVE;
712
	eXosip_ss_t ss=EXOSIP_SUBCRSTATE_ACTIVE;
713
#endif
601
	if (op->nid==-1){
714
	if (op->nid==-1){
602
		ms_warning("Cannot notify, subscription was closed.");
715
		ms_warning("Cannot notify, subscription was closed.");
603
		return -1;
716
		return -1;
604
	}
717
	}
605
	
718
	
719
#ifdef HAVE_STRUCT_EXOSIP_T
720
	eXosip_lock(ctx->excontext);
721
#else
606
	eXosip_lock();
722
	eXosip_lock();
723
#endif
724
#ifdef HAVE_STRUCT_EXOSIP_T
725
	eXosip_insubscription_build_notify(ctx->excontext, op->did, ss, DEACTIVATED, &msg);
726
#else
607
	eXosip_insubscription_build_notify(op->did,ss,DEACTIVATED,&msg);
727
	eXosip_insubscription_build_notify(op->did,ss,DEACTIVATED,&msg);
728
#endif
608
	if (msg!=NULL){
729
	if (msg!=NULL){
609
		const char *identity=sal_op_get_contact(op);
730
		const char *identity=sal_op_get_contact(op);
610
		if (identity==NULL) identity=sal_op_get_to(op);
731
		if (identity==NULL) identity=sal_op_get_to(op);
611
		_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
732
		_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
612
		osip_message_set_contact(msg,identity);
733
		osip_message_set_contact(msg,identity);
613
		add_presence_body(msg,status);
734
		add_presence_body(msg,status);
735
#ifdef HAVE_STRUCT_EXOSIP_T
736
		eXosip_insubscription_send_request(ctx->excontext, op->did, msg);
737
#else
614
		eXosip_insubscription_send_request(op->did,msg);
738
		eXosip_insubscription_send_request(op->did,msg);
739
#endif
615
	}else ms_error("could not create notify for incoming subscription.");
740
	}else ms_error("could not create notify for incoming subscription.");
741
#ifdef HAVE_STRUCT_EXOSIP_T
742
	eXosip_unlock(ctx->excontext);
743
#else
616
	eXosip_unlock();
744
	eXosip_unlock();
745
#endif
617
	return 0;
746
	return 0;
618
}
747
}
619
748
620
int sal_notify_close(SalOp *op){
749
int sal_notify_close(Sal *ctx, SalOp *op){
621
	osip_message_t *msg=NULL;
750
	osip_message_t *msg=NULL;
751
#ifdef HAVE_STRUCT_EXOSIP_T
752
	eXosip_lock(ctx->excontext);
753
#else
622
	eXosip_lock();
754
	eXosip_lock();
755
#endif
756
#ifdef HAVE_STRUCT_EXOSIP_T
757
	eXosip_insubscription_build_notify(ctx->excontext, op->did, EXOSIP_SUBCRSTATE_TERMINATED,
758
                DEACTIVATED, &msg);
759
#else
623
	eXosip_insubscription_build_notify(op->did,EXOSIP_SUBCRSTATE_TERMINATED,DEACTIVATED,&msg);
760
	eXosip_insubscription_build_notify(op->did,EXOSIP_SUBCRSTATE_TERMINATED,DEACTIVATED,&msg);
761
#endif
624
	if (msg!=NULL){
762
	if (msg!=NULL){
625
		const char *identity=sal_op_get_contact(op);
763
		const char *identity=sal_op_get_contact(op);
626
		if (identity==NULL) identity=sal_op_get_to(op);
764
		if (identity==NULL) identity=sal_op_get_to(op);
627
		osip_message_set_contact(msg,identity);
765
		osip_message_set_contact(msg,identity);
628
		add_presence_body(msg,SalPresenceOffline);
766
		add_presence_body(msg,SalPresenceOffline);
767
#ifdef HAVE_STRUCT_EXOSIP_T
768
		eXosip_insubscription_send_request(ctx->excontext, op->did, msg);
769
#else
629
		eXosip_insubscription_send_request(op->did,msg);
770
		eXosip_insubscription_send_request(op->did,msg);
771
#endif
630
	}else ms_error("sal_notify_close(): could not create notify for incoming subscription"
772
	}else ms_error("sal_notify_close(): could not create notify for incoming subscription"
631
	    " did=%i, nid=%i",op->did,op->nid);
773
	    " did=%i, nid=%i",op->did,op->nid);
774
#ifdef HAVE_STRUCT_EXOSIP_T
775
	eXosip_unlock(ctx->excontext);
776
#else
632
	eXosip_unlock();
777
	eXosip_unlock();
778
#endif
633
	return 0;
779
	return 0;
634
}
780
}
635
781
636
int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus presence_mode){
782
int sal_publish(Sal *ctx, SalOp *op, const char *from, const char *to, SalPresenceStatus presence_mode){
637
	osip_message_t *pub;
783
	osip_message_t *pub;
638
	int i;
784
	int i;
639
	char buf[1024];
785
	char buf[1024];
Lines 641-648 int sal_publish(SalOp *op, const char *f Link Here
641
787
642
	mk_presence_body (presence_mode, from, buf, sizeof (buf), presence_style);
788
	mk_presence_body (presence_mode, from, buf, sizeof (buf), presence_style);
643
789
790
#ifdef HAVE_STRUCT_EXOSIP_T
791
	i = eXosip_build_publish(ctx->excontext, &pub, to, from, NULL, "presence", "600",
792
		presence_style ? "application/xpidf+xml" : "application/pidf+xml", buf);
793
#else
644
	i = eXosip_build_publish(&pub,to, from, NULL, "presence", "600", 
794
	i = eXosip_build_publish(&pub,to, from, NULL, "presence", "600", 
645
		presence_style ? "application/xpidf+xml" : "application/pidf+xml", buf);
795
		presence_style ? "application/xpidf+xml" : "application/pidf+xml", buf);
796
#endif
646
	if (i<0){
797
	if (i<0){
647
		ms_warning("Failed to build publish request.");
798
		ms_warning("Failed to build publish request.");
648
		return -1;
799
		return -1;
Lines 650-659 int sal_publish(SalOp *op, const char *f Link Here
650
	if (route)
801
	if (route)
651
		sal_message_add_route(pub,route);
802
		sal_message_add_route(pub,route);
652
	
803
	
804
#ifdef HAVE_STRUCT_EXOSIP_T
805
	eXosip_lock(ctx->excontext);
806
#else
653
	eXosip_lock();
807
	eXosip_lock();
808
#endif
809
#ifdef HAVE_STRUCT_EXOSIP_T
810
	i = eXosip_publish(ctx->excontext, pub, to); /* should update the sip-if-match parameter
811
				    from sip-etag  from last 200ok of PUBLISH */
812
#else
654
	i = eXosip_publish(pub, to); /* should update the sip-if-match parameter
813
	i = eXosip_publish(pub, to); /* should update the sip-if-match parameter
655
				    from sip-etag  from last 200ok of PUBLISH */
814
				    from sip-etag  from last 200ok of PUBLISH */
815
#endif
816
#ifdef HAVE_STRUCT_EXOSIP_T
817
	eXosip_unlock(ctx->excontext);
818
#else
656
	eXosip_unlock();
819
	eXosip_unlock();
820
#endif
657
	if (i<0){
821
	if (i<0){
658
		ms_message("Failed to send publish request.");
822
		ms_message("Failed to send publish request.");
659
		return -1;
823
		return -1;
Lines 693-702 void sal_exosip_subscription_recv(Sal *s Link Here
693
		}else {
857
		}else {
694
			osip_message_t *msg=NULL;
858
			osip_message_t *msg=NULL;
695
			ms_warning("Probably a refresh subscribe");
859
			ms_warning("Probably a refresh subscribe");
860
#ifdef HAVE_STRUCT_EXOSIP_T
861
			eXosip_lock(sal->excontext);
862
#else
696
			eXosip_lock();
863
			eXosip_lock();
864
#endif
865
#ifdef HAVE_STRUCT_EXOSIP_T
866
			eXosip_insubscription_build_answer(sal->excontext, ev->tid, 202, &msg);
867
#else
697
			eXosip_insubscription_build_answer(ev->tid,202,&msg);
868
			eXosip_insubscription_build_answer(ev->tid,202,&msg);
869
#endif
870
#ifdef HAVE_STRUCT_EXOSIP_T
871
			eXosip_insubscription_send_answer(sal->excontext, ev->tid, 202, msg);
872
#else
698
			eXosip_insubscription_send_answer(ev->tid,202,msg);
873
			eXosip_insubscription_send_answer(ev->tid,202,msg);
874
#endif
875
#ifdef HAVE_STRUCT_EXOSIP_T
876
			eXosip_unlock(sal->excontext);
877
#else
699
			eXosip_unlock();
878
			eXosip_unlock();
879
#endif
700
		}
880
		}
701
	}else _sal_exosip_subscription_recv(sal,ev);
881
	}else _sal_exosip_subscription_recv(sal,ev);
702
}
882
}
703
-- a/coreapi/sal.h
883
++ b/coreapi/sal.h
Lines 382-389 void sal_op_set_contact(SalOp *op, const Link Here
382
void sal_op_set_route(SalOp *op, const char *route);
382
void sal_op_set_route(SalOp *op, const char *route);
383
void sal_op_set_from(SalOp *op, const char *from);
383
void sal_op_set_from(SalOp *op, const char *from);
384
void sal_op_set_to(SalOp *op, const char *to);
384
void sal_op_set_to(SalOp *op, const char *to);
385
void sal_op_release(SalOp *h);
385
void sal_op_release(Sal *ctx, SalOp *h);
386
void sal_op_authenticate(SalOp *h, const SalAuthInfo *info);
386
void sal_op_authenticate(Sal *ctx, SalOp *h, const SalAuthInfo *info);
387
void sal_op_cancel_authentication(SalOp *h);
387
void sal_op_cancel_authentication(SalOp *h);
388
void sal_op_set_user_pointer(SalOp *h, void *up);
388
void sal_op_set_user_pointer(SalOp *h, void *up);
389
int sal_op_get_auth_requested(SalOp *h, const char **realm, const char **username);
389
int sal_op_get_auth_requested(SalOp *h, const char **realm, const char **username);
Lines 402-452 const char* sal_op_get_call_id(const Sal Link Here
402
402
403
/*Call API*/
403
/*Call API*/
404
int sal_call_set_local_media_description(SalOp *h, SalMediaDescription *desc);
404
int sal_call_set_local_media_description(SalOp *h, SalMediaDescription *desc);
405
int sal_call(SalOp *h, const char *from, const char *to);
405
int sal_call(Sal *ctx, SalOp *h, const char *from, const char *to);
406
int sal_call_notify_ringing(SalOp *h, bool_t early_media);
406
int sal_call_notify_ringing(Sal *ctx, SalOp *h, bool_t early_media);
407
/*accept an incoming call or, during a call accept a reINVITE*/
407
/*accept an incoming call or, during a call accept a reINVITE*/
408
int sal_call_accept(SalOp*h);
408
int sal_call_accept(Sal *ctx, SalOp *h);
409
int sal_call_decline(SalOp *h, SalReason reason, const char *redirection /*optional*/);
409
int sal_call_decline(Sal *ctx, SalOp *h, SalReason reason, const char *redirection /*optional*/);
410
int sal_call_update(SalOp *h, const char *subject);
410
int sal_call_update(Sal *sal, SalOp *h, const char *subject);
411
SalMediaDescription * sal_call_get_remote_media_description(SalOp *h);
411
SalMediaDescription * sal_call_get_remote_media_description(SalOp *h);
412
SalMediaDescription * sal_call_get_final_media_description(SalOp *h);
412
SalMediaDescription * sal_call_get_final_media_description(SalOp *h);
413
int sal_call_refer(SalOp *h, const char *refer_to);
413
int sal_call_refer(Sal *ctx, SalOp *h, const char *refer_to);
414
int sal_call_refer_with_replaces(SalOp *h, SalOp *other_call_h);
414
int sal_call_refer_with_replaces(Sal *ctx, SalOp *h, SalOp *other_call_h);
415
int sal_call_accept_refer(SalOp *h);
415
int sal_call_accept_refer(SalOp *h);
416
/*informs this call is consecutive to an incoming refer */
416
/*informs this call is consecutive to an incoming refer */
417
int sal_call_set_referer(SalOp *h, SalOp *refered_call);
417
int sal_call_set_referer(SalOp *h, SalOp *refered_call);
418
/* returns the SalOp of a call that should be replaced by h, if any */
418
/* returns the SalOp of a call that should be replaced by h, if any */
419
SalOp *sal_call_get_replaces(SalOp *h);
419
SalOp *sal_call_get_replaces(Sal *ctx, SalOp *h);
420
int sal_call_send_dtmf(SalOp *h, char dtmf);
420
int sal_call_send_dtmf(Sal *ctx, SalOp *h, char dtmf);
421
int sal_call_terminate(SalOp *h);
421
int sal_call_terminate(Sal *ctx, SalOp *h);
422
bool_t sal_call_autoanswer_asked(SalOp *op);
422
bool_t sal_call_autoanswer_asked(SalOp *op);
423
void sal_call_send_vfu_request(SalOp *h);
423
void sal_call_send_vfu_request(Sal *ctx, SalOp *h);
424
int sal_call_is_offerer(const SalOp *h);
424
int sal_call_is_offerer(const SalOp *h);
425
int sal_call_notify_refer_state(SalOp *h, SalOp *newcall);
425
int sal_call_notify_refer_state(Sal *ctx, SalOp *h, SalOp *newcall);
426
426
427
/*Registration*/
427
/*Registration*/
428
int sal_register(SalOp *op, const char *proxy, const char *from, int expires);
428
int sal_register(Sal *ctx, SalOp *op, const char *proxy, const char *from, int expires);
429
int sal_register_refresh(SalOp *op, int expires);
429
int sal_register_refresh(Sal *ctx, SalOp *op, int expires);
430
int sal_unregister(SalOp *h);
430
int sal_unregister(Sal *ctx, SalOp *h);
431
431
432
/*Messaging */
432
/*Messaging */
433
int sal_text_send(SalOp *op, const char *from, const char *to, const char *text);
433
int sal_text_send(Sal *ctx, SalOp *op, const char *from, const char *to, const char *text);
434
int sal_message_send(SalOp *op, const char *from, const char *to, const char* content_type, const char *msg);
434
int sal_message_send(Sal *ctx, SalOp *op, const char *from, const char *to, const char* content_type, const char *msg);
435
435
436
/*presence Subscribe/notify*/
436
/*presence Subscribe/notify*/
437
int sal_subscribe_presence(SalOp *op, const char *from, const char *to);
437
int sal_subscribe_presence(Sal *ctx, SalOp *op, const char *from, const char *to);
438
int sal_unsubscribe(SalOp *op);
438
int sal_unsubscribe(Sal *ctx, SalOp *op);
439
int sal_subscribe_accept(SalOp *op);
439
int sal_subscribe_accept(Sal *ctx, SalOp *op);
440
int sal_subscribe_decline(SalOp *op);
440
int sal_subscribe_decline(Sal *ctx, SalOp *op);
441
int sal_notify_presence(SalOp *op, SalPresenceStatus status, const char *status_message);
441
int sal_notify_presence(Sal *ctx, SalOp *op, SalPresenceStatus status, const char *status_message);
442
int sal_notify_close(SalOp *op);
442
int sal_notify_close(Sal *ctx, SalOp *op);
443
443
444
/*presence publish */
444
/*presence publish */
445
int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus status);
445
int sal_publish(Sal *ctx, SalOp *op, const char *from, const char *to, SalPresenceStatus status);
446
446
447
447
448
/*ping: main purpose is to obtain its own contact address behind firewalls*/
448
/*ping: main purpose is to obtain its own contact address behind firewalls*/
449
int sal_ping(SalOp *op, const char *from, const char *to);
449
int sal_ping(Sal *ctx, SalOp *op, const char *from, const char *to);
450
450
451
451
452
452
453
-- a/m4/exosip.m4
453
++ b/m4/exosip.m4
Lines 13-76 case $host_alias in Link Here
13
	;;
13
	;;
14
esac
14
esac
15
15
16
16
dnl eXosip embeded stuff
17
dnl eXosip embeded stuff
17
EXOSIP_CFLAGS="$OSIP_CFLAGS -DOSIP_MT "
18
EXOSIP_CFLAGS="$OSIP_CFLAGS -DOSIP_MT "
18
EXOSIP_LIBS="$OSIP_LIBS -leXosip2  "
19
EXOSIP_LIBS="$OSIP_LIBS -leXosip2 "
20
19
21
20
CPPFLAGS_save=$CPPFLAGS
22
dnl check for eXosip2 headers
21
CPPFLAGS="$OSIP_CFLAGS $CPPFLAGS"
23
AC_CHECK_HEADERS([eXosip2/eXosip.h],
22
AC_CHECK_HEADER([eXosip2/eXosip.h], ,AC_MSG_ERROR([Could not find eXosip2 headers !]))
24
        [], [AC_MSG_ERROR([Could not find eXosip2 headers])]
23
24
dnl check exosip support of DSCP in exosip
25
AC_MSG_CHECKING([for DSCP support in exosip])
26
AC_TRY_COMPILE([#include <eXosip2/eXosip.h>],
27
	[int dscp=0;eXosip_set_option(EXOSIP_OPT_SET_DSCP,&dscp);],
28
	has_exosip_dscp=yes,
29
	has_exosip_dscp=no
30
)
25
)
31
AC_MSG_RESULT($has_exosip_dscp)
32
if test "$has_exosip_dscp" = "yes" ; then
33
	AC_DEFINE( HAVE_EXOSIP_DSCP, 1, [Define if exosip dscp available] )
34
fi
35
26
36
CPPFLAGS=$CPPFLAGS_save
27
dnl check for eXosip2 libs
28
AC_SEARCH_LIBS([eXosip_init], [eXosip2],
29
        [], [AC_MSG_ERROR([Could not find eXosip2 library])]
30
)
37
31
32
AC_CHECK_FUNCS([ eXosip_malloc eXosip_set_tls_ctx eXosip_get_version eXosip_tls_verify_certificate eXosip_tls_verify_cn eXosip_trylock eXosip_reset_transports ])
38
33
34
if test "x$ac_cv_func_eXosip_malloc" == xyes; then
35
        AC_DEFINE([HAVE_STRUCT_EXOSIP_T], [1], [Define if struct eXosip_t exists.])
36
elif test "x$ac_cv_func_eXosip_set_tls_ctx" != xyes; then
37
        AC_MSG_ERROR([Could not find eXosip2 library with version >= 3.5.0 !])
38
fi
39
39
40
dnl check for eXosip2 libs
41
LDFLAGS_save=$LDFLAGS
42
LDFLAGS="$OSIP_LIBS $LDFLAGS $OPENSSL_LIBS"
43
LIBS_save=$LIBS
44
AC_CHECK_LIB([eXosip2],[eXosip_set_tls_ctx],
45
	[],
46
	[AC_MSG_ERROR([Could not find eXosip2 library with version >= 3.5.0 !])],
47
	[-losipparser2 -losip2 ])
48
AC_CHECK_LIB([eXosip2],[eXosip_get_version],
49
	[AC_DEFINE([HAVE_EXOSIP_GET_VERSION],[1],[Defined when eXosip_get_version is available])],
50
	[],
51
	[-losipparser2 -losip2 ])
52
AC_CHECK_LIB([eXosip2],[eXosip_tls_verify_certificate],
53
	[AC_DEFINE([HAVE_EXOSIP_TLS_VERIFY_CERTIFICATE],[1],[Defined when eXosip_tls_verify_certificate is available])],
54
	[AC_MSG_WARN([Could not find eXosip_tls_verify_certificate in eXosip2 !])],
55
	[-losipparser2 -losip2 ])
56
AC_CHECK_LIB([eXosip2],[eXosip_tls_verify_cn],
57
	[AC_DEFINE([HAVE_EXOSIP_TLS_VERIFY_CN],[1],[Defined when eXosip_tls_verify_certificate is available])],
58
	[AC_MSG_WARN([Could not find eXosip_tls_verify_cn in eXosip2 !])],
59
	[-losipparser2 -losip2 ])
60
AC_CHECK_LIB([eXosip2],[eXosip_trylock],
61
	[AC_DEFINE([HAVE_EXOSIP_TRYLOCK],[1],[Defined when eXosip_get_socket is available])],
62
	[],
63
	[-losipparser2 -losip2 ])
64
AC_CHECK_LIB([eXosip2],[eXosip_reset_transports],
65
	[AC_DEFINE([HAVE_EXOSIP_RESET_TRANSPORTS],[1],[Defined when eXosip_reset_transports is available])],
66
	[],
67
	[-losipparser2 -losip2 ])
68
dnl AC_CHECK_LIB([eXosip2],[eXosip_get_naptr],
69
dnl	[AC_DEFINE([HAVE_EXOSIP_NAPTR_SUPPORT],[1],[Defined when eXosip_get_naptr is available])],
70
dnl	[],
71
dnl	[-losipparser2 -losip2 ])
72
LIBS=$LIBS_save
73
LDFLAGS=$LDFLAGS_save
74
40
75
AC_SUBST(EXOSIP_CFLAGS)
41
AC_SUBST(EXOSIP_CFLAGS)
76
AC_SUBST(EXOSIP_LIBS)
42
AC_SUBST(EXOSIP_LIBS)

Return to bug 478686