3 Copyright (C) 2010 Simon MORLAT (simon.morlat@free.fr)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "linphonecore.h"
25 #include "mediastreamer2/mediastream.h"
28 static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details);
30 static bool_t media_parameters_changed(LinphoneCall *call, SalMediaDescription *oldmd, SalMediaDescription *newmd){
31 return !sal_media_description_equals(oldmd,newmd) || call->up_bw!=linphone_core_get_upload_bandwidth(call->core);
34 void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *new_md){
35 SalMediaDescription *oldmd=call->resultdesc;
37 if (lc->ringstream!=NULL){
38 ring_stop(lc->ringstream);
42 sal_media_description_ref(new_md);
43 call->media_pending=FALSE;
45 call->media_pending=TRUE;
47 call->resultdesc=new_md;
48 if (call->audiostream && call->audiostream->ticker){
49 /* we already started media: check if we really need to restart it*/
51 if (!media_parameters_changed(call,oldmd,new_md) && !call->playing_ringbacktone){
52 sal_media_description_unref(oldmd);
54 ms_message("Early media finished, unmuting inputs...");
55 /*we were in early media, now we want to enable real media */
56 linphone_call_enable_camera (call,linphone_call_camera_enabled (call));
57 if (call->audiostream)
58 linphone_core_mute_mic (lc, linphone_core_is_mic_muted(lc));
60 if (call->videostream && call->camera_active)
61 video_stream_change_camera(call->videostream,lc->video_conf.device );
64 ms_message("No need to restart streams, SDP is unchanged.");
67 ms_message("Media descriptions are different, need to restart the streams.");
70 linphone_call_stop_media_streams (call);
71 linphone_call_init_media_streams (call);
74 sal_media_description_unref(oldmd);
77 bool_t all_muted=FALSE;
78 bool_t send_ringbacktone=FALSE;
80 if (call->audiostream==NULL){
81 /*this happens after pausing the call locally. The streams is destroyed and then we wait the 200Ok to recreate it*/
82 linphone_call_init_media_streams (call);
84 if (call->state==LinphoneCallIncomingEarlyMedia && linphone_core_get_remote_ringback_tone (lc)!=NULL){
85 send_ringbacktone=TRUE;
87 if (call->state==LinphoneCallIncomingEarlyMedia ||
88 (call->state==LinphoneCallOutgoingEarlyMedia && !call->params.real_early_media)){
91 linphone_call_start_media_streams(call,all_muted,send_ringbacktone);
95 static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to){
97 for(elem=lc->calls;elem!=NULL;elem=elem->next){
98 LinphoneCall *call=(LinphoneCall*)elem->data;
99 if (linphone_address_weak_equal(call->log->from,from) &&
100 linphone_address_weak_equal(call->log->to, to)){
107 static void call_received(SalOp *h){
108 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
111 const char *from,*to;
113 LinphoneAddress *from_parsed;
114 LinphoneAddress *from_addr, *to_addr;
115 SalMediaDescription *md;
116 bool_t propose_early_media=lp_config_get_int(lc->config,"sip","incoming_calls_early_media",FALSE);
117 const char *ringback_tone=linphone_core_get_remote_ringback_tone (lc);
119 /* first check if we can answer successfully to this invite */
120 if (lc->presence_mode==LinphoneStatusBusy ||
121 lc->presence_mode==LinphoneStatusOffline ||
122 lc->presence_mode==LinphoneStatusDoNotDisturb ||
123 lc->presence_mode==LinphoneStatusMoved){
124 if (lc->presence_mode==LinphoneStatusBusy )
125 sal_call_decline(h,SalReasonBusy,NULL);
126 else if (lc->presence_mode==LinphoneStatusOffline)
127 sal_call_decline(h,SalReasonTemporarilyUnavailable,NULL);
128 else if (lc->presence_mode==LinphoneStatusDoNotDisturb)
129 sal_call_decline(h,SalReasonTemporarilyUnavailable,NULL);
130 else if (lc->alt_contact!=NULL && lc->presence_mode==LinphoneStatusMoved)
131 sal_call_decline(h,SalReasonRedirect,lc->alt_contact);
135 if (!linphone_core_can_we_add_call(lc)){/*busy*/
136 sal_call_decline(h,SalReasonBusy,NULL);
140 from=sal_op_get_from(h);
142 from_addr=linphone_address_new(from);
143 to_addr=linphone_address_new(to);
145 if (is_duplicate_call(lc,from_addr,to_addr)){
146 ms_warning("Receiving duplicated call, refusing this one.");
147 sal_call_decline(h,SalReasonBusy,NULL);
148 linphone_address_destroy(from_addr);
149 linphone_address_destroy(to_addr);
153 call=linphone_call_new_incoming(lc,from_addr,to_addr,h);
154 sal_call_set_local_media_description(h,call->localdesc);
155 md=sal_call_get_final_media_description(h);
157 if (md && sal_media_description_empty(md)){
158 sal_call_decline(h,SalReasonMedia,NULL);
159 linphone_call_unref(call);
163 /* the call is acceptable so we can now add it to our list */
164 linphone_core_add_call(lc,call);
166 from_parsed=linphone_address_new(sal_op_get_from(h));
167 linphone_address_clean(from_parsed);
168 tmp=linphone_address_as_string(from_parsed);
169 linphone_address_destroy(from_parsed);
170 barmesg=ortp_strdup_printf("%s %s%s",tmp,_("is contacting you"),
171 (sal_call_autoanswer_asked(h)) ?_(" and asked autoanswer."):_("."));
172 if (lc->vtable.show) lc->vtable.show(lc);
173 if (lc->vtable.display_status)
174 lc->vtable.display_status(lc,barmesg);
176 /* play the ring if this is the only call*/
177 if (lc->sound_conf.ring_sndcard!=NULL && ms_list_size(lc->calls)==1){
178 lc->current_call=call;
179 if (lc->ringstream && lc->dmfs_playing_start_time!=0){
180 ring_stop(lc->ringstream);
182 lc->dmfs_playing_start_time=0;
184 if(lc->ringstream==NULL && lc->sound_conf.local_ring){
185 MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
186 ms_message("Starting local ring...");
187 lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,ringcard);
191 ms_message("the local ring is already started");
194 /*TODO : play a tone within the context of the current call */
198 linphone_call_ref(call); /*prevent the call from being destroyed while we are notifying, if the user declines within the state callback */
199 linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
201 if (call->state==LinphoneCallIncomingReceived){
202 sal_call_notify_ringing(h,propose_early_media || ringback_tone!=NULL);
204 if (propose_early_media || ringback_tone!=NULL){
205 linphone_call_set_state(call,LinphoneCallIncomingEarlyMedia,"Incoming call early media");
206 linphone_core_update_streams(lc,call,md);
208 if (sal_call_get_replaces(call->op)!=NULL && lp_config_get_int(lc->config,"sip","auto_answer_replacing_calls",1)){
209 linphone_core_accept_call(lc,call);
212 linphone_call_unref(call);
218 static void call_ringing(SalOp *h){
219 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
220 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(h);
221 SalMediaDescription *md;
223 if (call==NULL) return;
225 if (lc->vtable.display_status)
226 lc->vtable.display_status(lc,_("Remote ringing."));
228 md=sal_call_get_final_media_description(h);
230 if (lc->ringstream && lc->dmfs_playing_start_time!=0){
231 ring_stop(lc->ringstream);
233 lc->dmfs_playing_start_time=0;
235 if (lc->ringstream!=NULL) return; /*already ringing !*/
236 if (lc->sound_conf.play_sndcard!=NULL){
237 MSSndCard *ringcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
238 lc->ringstream=ring_start(lc->sound_conf.remote_ring,2000,ringcard);
240 ms_message("Remote ringing...");
241 if (lc->vtable.display_status)
242 lc->vtable.display_status(lc,_("Remote ringing..."));
243 linphone_call_set_state(call,LinphoneCallOutgoingRinging,"Remote ringing");
245 /*accept early media */
246 if (call->audiostream && call->audiostream->ticker!=NULL){
247 /*streams already started */
248 ms_message("Early media already started.");
251 if (lc->vtable.show) lc->vtable.show(lc);
252 if (lc->vtable.display_status)
253 lc->vtable.display_status(lc,_("Early media."));
254 linphone_call_set_state(call,LinphoneCallOutgoingEarlyMedia,"Early media");
255 if (lc->ringstream!=NULL){
256 ring_stop(lc->ringstream);
259 ms_message("Doing early media...");
260 linphone_core_update_streams (lc,call,md);
266 * - when the call is accepted
267 * - when a request is accepted (pause, resume)
269 static void call_accepted(SalOp *op){
270 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
271 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
272 SalMediaDescription *md;
275 ms_warning("No call to accept.");
279 md=sal_call_get_final_media_description(op);
281 if (call->state==LinphoneCallOutgoingProgress ||
282 call->state==LinphoneCallOutgoingRinging ||
283 call->state==LinphoneCallOutgoingEarlyMedia){
284 linphone_call_set_state(call,LinphoneCallConnected,"Connected");
286 if (md && !sal_media_description_empty(md)){
287 if (sal_media_description_has_dir(md,SalStreamSendOnly) ||
288 sal_media_description_has_dir(md,SalStreamInactive)){
289 if (lc->vtable.display_status){
290 char *tmp=linphone_call_get_remote_address_as_string (call);
291 char *msg=ms_strdup_printf(_("Call with %s is paused."),tmp);
292 lc->vtable.display_status(lc,msg);
296 linphone_core_update_streams (lc,call,md);
297 linphone_call_set_state(call,LinphoneCallPaused,"Call paused");
298 }else if (sal_media_description_has_dir(md,SalStreamRecvOnly)){
299 /*we are put on hold when the call is initially accepted */
300 if (lc->vtable.display_status){
301 char *tmp=linphone_call_get_remote_address_as_string (call);
302 char *msg=ms_strdup_printf(_("Call answered by %s - on hold."),tmp);
303 lc->vtable.display_status(lc,msg);
307 linphone_core_update_streams (lc,call,md);
308 linphone_call_set_state(call,LinphoneCallPausedByRemote,"Call paused by remote");
310 if (call->state==LinphoneCallStreamsRunning){
311 /*media was running before, the remote as acceted a call modification (that is
312 a reinvite made by us. We must notify the application this reinvite was accepted*/
313 linphone_call_set_state(call, LinphoneCallUpdated, "Call updated");
315 if (call->state==LinphoneCallResuming){
316 if (lc->vtable.display_status){
317 lc->vtable.display_status(lc,_("Call resumed."));
320 if (lc->vtable.display_status){
321 char *tmp=linphone_call_get_remote_address_as_string (call);
322 char *msg=ms_strdup_printf(_("Call answered by %s."),tmp);
323 lc->vtable.display_status(lc,msg);
329 linphone_core_update_streams (lc,call,md);
330 linphone_call_set_state(call, LinphoneCallStreamsRunning, "Streams running");
331 lc->current_call=call;
335 ms_error("Incompatible SDP offer received in 200Ok, need to abort the call");
336 linphone_core_abort_call(lc,call,"No codec intersection");
340 static void call_ack(SalOp *op){
341 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
342 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
344 ms_warning("No call to be ACK'd");
347 if (call->media_pending){
348 SalMediaDescription *md=sal_call_get_final_media_description(op);
349 if (md && !sal_media_description_empty(md)){
350 if (call->state==LinphoneCallStreamsRunning){
351 /*media was running before, the remote as acceted a call modification (that is
352 a reinvite made by us. We must notify the application this reinvite was accepted*/
353 linphone_call_set_state(call, LinphoneCallUpdated, "Call updated");
355 linphone_core_update_streams (lc,call,md);
356 linphone_call_set_state (call,LinphoneCallStreamsRunning,"Connected (streams running)");
359 ms_error("Incompatible SDP response received in ACK, need to abort the call");
360 linphone_core_abort_call(lc,call,"No codec intersection");
367 /* this callback is called when an incoming re-INVITE modifies the session*/
368 static void call_updating(SalOp *op){
369 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
370 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
371 LinphoneCallState prevstate=LinphoneCallIdle;
372 SalMediaDescription *md;
374 md=sal_call_get_final_media_description(op);
376 if (md && !sal_media_description_empty(md))
378 if (sal_media_description_has_dir(call->localdesc,SalStreamSendRecv)){
379 ms_message("Our local status is SalStreamSendRecv");
380 if (sal_media_description_has_dir (md,SalStreamRecvOnly) || sal_media_description_has_dir(md,SalStreamInactive)){
381 /* we are being paused */
382 if(lc->vtable.display_status)
383 lc->vtable.display_status(lc,_("We are being paused..."));
384 linphone_call_set_state (call,LinphoneCallPausedByRemote,"Call paused by remote");
385 }else if (!sal_media_description_has_dir(call->resultdesc,SalStreamSendRecv) && sal_media_description_has_dir(md,SalStreamSendRecv)){
386 if(lc->vtable.display_status)
387 lc->vtable.display_status(lc,_("We have been resumed..."));
388 linphone_call_set_state (call,LinphoneCallStreamsRunning,"Connected (streams running)");
389 lc->current_call=call;
391 prevstate=call->state;
392 linphone_call_set_state(call, LinphoneCallUpdatedByRemote,"Call updated by remote");
395 /*accept the modification (sends a 200Ok)*/
397 linphone_core_update_streams (lc,call,md);
398 if (prevstate!=LinphoneCallIdle){
399 linphone_call_set_state (call,prevstate,"Connected (streams running)");
404 static void call_terminated(SalOp *op, const char *from){
405 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
406 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
408 if (call==NULL) return;
410 if (linphone_call_get_state(call)==LinphoneCallEnd || linphone_call_get_state(call)==LinphoneCallError){
411 ms_warning("call_terminated: ignoring.");
414 ms_message("Current call terminated...");
415 //we stop the call only if we have this current call or if we are in call
416 if (lc->ringstream!=NULL && ( (ms_list_size(lc->calls) == 1) || linphone_core_in_call(lc) )) {
417 ring_stop(lc->ringstream);
420 linphone_call_stop_media_streams(call);
421 if (lc->vtable.show!=NULL)
423 if (lc->vtable.display_status!=NULL)
424 lc->vtable.display_status(lc,_("Call terminated."));
426 linphone_call_set_state(call, LinphoneCallEnd,"Call ended");
429 static void call_failure(SalOp *op, SalError error, SalReason sr, const char *details, int code){
430 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
431 char *msg486=_("User is busy.");
432 char *msg480=_("User is temporarily unavailable.");
433 /*char *retrymsg=_("%s. Retry after %i minute(s).");*/
434 char *msg600=_("User does not want to be disturbed.");
435 char *msg603=_("Call declined.");
436 const char *msg=details;
437 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
440 ms_warning("Call faillure reported on already cleaned call ?");
444 if (lc->vtable.show) lc->vtable.show(lc);
446 if (error==SalErrorNoResponse){
447 msg=_("No response.");
448 if (lc->vtable.display_status)
449 lc->vtable.display_status(lc,msg);
450 }else if (error==SalErrorProtocol){
451 msg=details ? details : _("Protocol error.");
452 if (lc->vtable.display_status)
453 lc->vtable.display_status(lc, msg);
454 }else if (error==SalErrorFailure){
456 case SalReasonDeclined:
458 if (lc->vtable.display_status)
459 lc->vtable.display_status(lc,msg603);
463 if (lc->vtable.display_status)
464 lc->vtable.display_status(lc,msg486);
466 case SalReasonRedirect:
468 if (lc->vtable.display_status)
469 lc->vtable.display_status(lc,msg);
471 case SalReasonTemporarilyUnavailable:
473 if (lc->vtable.display_status)
474 lc->vtable.display_status(lc,msg480);
476 case SalReasonNotFound:
478 if (lc->vtable.display_status)
479 lc->vtable.display_status(lc,msg);
481 case SalReasonDoNotDisturb:
483 if (lc->vtable.display_status)
484 lc->vtable.display_status(lc,msg600);
487 msg=_("No common codecs");
488 if (lc->vtable.display_status)
489 lc->vtable.display_status(lc,msg);
492 if (lc->vtable.display_status)
493 lc->vtable.display_status(lc,_("Call failed."));
497 if (lc->ringstream!=NULL) {
498 ring_stop(lc->ringstream);
501 linphone_call_stop_media_streams (call);
502 if (sr!=SalReasonDeclined) linphone_call_set_state(call,LinphoneCallError,msg);
504 call->reason=LinphoneReasonDeclined;
505 linphone_call_set_state(call,LinphoneCallEnd,"Call declined.");
509 static void call_released(SalOp *op){
510 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
512 linphone_call_set_state(call,LinphoneCallReleased,"Call released");
513 }else ms_error("call_released() for already destroyed call ?");
516 static void auth_requested(SalOp *h, const char *realm, const char *username){
517 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
518 LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username);
519 ms_message("auth_requested() for realm=%s, username=%s",realm,username);
521 if (ai && ai->works==FALSE && ai->usecount>=3){
522 /*case we tried 3 times to authenticate, without success */
523 /*Better is to stop (implemeted below in else statement), and retry later*/
524 if (ms_time(NULL)-ai->last_use_time>30){
525 ai->usecount=0; /*so that we can allow to retry */
529 if (ai && (ai->works || ai->usecount<3)){
531 sai.username=ai->username;
532 sai.userid=ai->userid;
534 sai.password=ai->passwd;
535 ms_message("auth_requested(): authenticating realm=%s, username=%s",realm,username);
536 sal_op_authenticate(h,&sai);
538 ai->last_use_time=ms_time(NULL);
540 if (ai && ai->works==FALSE) {
541 sal_op_cancel_authentication(h);
543 if (lc->vtable.auth_info_requested)
544 lc->vtable.auth_info_requested(lc,realm,username);
548 static void auth_success(SalOp *h, const char *realm, const char *username){
549 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
550 LinphoneAuthInfo *ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username);
552 ms_message("%s/%s authentication works.",realm,username);
557 static void register_success(SalOp *op, bool_t registered){
558 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
559 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op);
562 cfg->registered=registered;
563 linphone_proxy_config_set_error(cfg,LinphoneReasonNone);
564 linphone_proxy_config_set_state(cfg, registered ? LinphoneRegistrationOk : LinphoneRegistrationCleared ,
565 registered ? "Registration sucessful" : "Unregistration done");
566 if (lc->vtable.display_status){
567 if (cfg->registered) msg=ms_strdup_printf(_("Registration on %s successful."),sal_op_get_proxy(op));
568 else msg=ms_strdup_printf(_("Unregistration on %s done."),sal_op_get_proxy(op));
569 lc->vtable.display_status(lc,msg);
575 static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details){
576 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
577 LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)sal_op_get_user_pointer(op);
580 ms_warning("Registration failed for unknown proxy config.");
584 details=_("no response timeout");
586 if (lc->vtable.display_status) {
587 char *msg=ortp_strdup_printf(_("Registration on %s failed: %s"),sal_op_get_proxy(op),details );
588 lc->vtable.display_status(lc,msg);
591 if (error== SalErrorFailure && reason == SalReasonForbidden) {
592 linphone_proxy_config_set_error(cfg, LinphoneReasonBadCredentials);
593 } else if (error == SalErrorNoResponse) {
594 linphone_proxy_config_set_error(cfg, LinphoneReasonNoResponse);
596 linphone_proxy_config_set_state(cfg,LinphoneRegistrationFailed,details);
597 if (error== SalErrorFailure && reason == SalReasonForbidden) {
598 const char *realm=NULL,*username=NULL;
599 if (sal_op_get_auth_requested(op,&realm,&username)==0){
600 if (lc->vtable.auth_info_requested)
601 lc->vtable.auth_info_requested(lc,realm,username);
606 static void vfu_request(SalOp *op){
608 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer (op);
610 ms_warning("VFU request but no call !");
613 if (call->videostream)
614 video_stream_send_vfu(call->videostream);
618 static void dtmf_received(SalOp *op, char dtmf){
619 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
620 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
621 if (lc->vtable.dtmf_received != NULL)
622 lc->vtable.dtmf_received(lc, call, dtmf);
625 static void refer_received(Sal *sal, SalOp *op, const char *referto){
626 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
627 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
629 if (call->refer_to!=NULL){
630 ms_free(call->refer_to);
632 call->refer_to=ms_strdup(referto);
633 call->refer_pending=TRUE;
634 linphone_call_set_state(call,LinphoneCallRefered,"Refered");
635 if (lc->vtable.display_status){
636 char *msg=ms_strdup_printf(_("We are transferred to %s"),referto);
637 lc->vtable.display_status(lc,msg);
640 if (call->state!=LinphoneCallPaused){
641 ms_message("Automatically pausing current call to accept transfer.");
642 linphone_core_pause_call(lc,call);
644 linphone_core_start_refered_call(lc,call);
645 sal_call_accept_refer(op);
646 }else if (lc->vtable.refer_received){
647 lc->vtable.refer_received(lc,referto);
648 sal_call_accept_refer(op);
652 static void text_received(Sal *sal, const char *from, const char *msg){
653 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
654 linphone_core_text_received(lc,from,msg);
657 static void notify(SalOp *op, const char *from, const char *msg){
658 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
659 LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer (op);
660 ms_message("get a %s notify from %s",msg,from);
661 if(lc->vtable.notify_recv)
662 lc->vtable.notify_recv(lc,call,from,msg);
665 static void notify_presence(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg){
666 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
667 linphone_notify_recv(lc,op,ss,status);
670 static void subscribe_received(SalOp *op, const char *from){
671 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
672 linphone_subscription_new(lc,op,from);
675 static void subscribe_closed(SalOp *op, const char *from){
676 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
677 linphone_subscription_closed(lc,op);
680 static void internal_message(Sal *sal, const char *msg){
681 LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
686 static void ping_reply(SalOp *op){
687 LinphoneCall *call=(LinphoneCall*) sal_op_get_user_pointer(op);
688 ms_message("ping reply !");
690 if (call->state==LinphoneCallOutgoingInit){
691 linphone_core_start_invite(call->core,call,NULL);
696 ms_warning("ping reply without call attached...");
700 SalCallbacks linphone_sal_callbacks={