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.
21 #include "sal_eXosip2.h"
30 * REVISIT: this static variable forces every dialog to use the same presence description type depending
31 * on what is received on a single dialog...
33 static presence_type_t presence_style = PIDF;
35 SalOp * sal_find_out_subscribe(Sal *sal, int sid){
38 for(elem=sal->out_subscribes;elem!=NULL;elem=elem->next){
39 op=(SalOp*)elem->data;
40 if (op->sid==sid) return op;
42 ms_message("No op for sid %i",sid);
46 static void sal_add_out_subscribe(Sal *sal, SalOp *op){
47 sal->out_subscribes=ms_list_append(sal->out_subscribes,op);
50 void sal_remove_out_subscribe(Sal *sal, SalOp *op){
51 sal->out_subscribes=ms_list_remove(sal->out_subscribes,op);
54 SalOp * sal_find_in_subscribe(Sal *sal, int nid){
57 for(elem=sal->in_subscribes;elem!=NULL;elem=elem->next){
58 op=(SalOp*)elem->data;
59 if (op->nid==nid) return op;
64 static SalOp * sal_find_in_subscribe_by_call_id(Sal *sal, osip_call_id_t *call_id){
67 for(elem=sal->in_subscribes;elem!=NULL;elem=elem->next){
68 op=(SalOp*)elem->data;
69 if (op->call_id && osip_call_id_match(op->call_id,call_id)==0)
75 static void sal_add_in_subscribe(Sal *sal, SalOp *op, osip_message_t *subs){
76 osip_call_id_clone(subs->call_id,&op->call_id);
77 sal->in_subscribes=ms_list_append(sal->in_subscribes,op);
80 void sal_remove_in_subscribe(Sal *sal, SalOp *op){
81 sal->in_subscribes=ms_list_remove(sal->in_subscribes,op);
84 int sal_text_send(SalOp *op, const char *from, const char *to, const char *msg){
85 osip_message_t *sip=NULL;
89 /* we are not currently in communication with the destination */
91 sal_op_set_from(op,from);
96 eXosip_message_build_request(&sip,"MESSAGE",sal_op_get_to(op),
97 sal_op_get_from(op),sal_op_get_route(op));
99 osip_message_set_content_type(sip,"text/plain");
100 osip_message_set_body(sip,msg,strlen(msg));
101 sal_add_other(op->base.root,op,sip);
102 eXosip_message_send_request(sip);
104 ms_error("Could not build MESSAGE request !");
110 /* we are currently in communication with the destination */
112 //First we generate an INFO message to get the current call_id and a good cseq
113 eXosip_call_build_request(op->did,"MESSAGE",&sip);
116 ms_warning("could not get a build info to send MESSAGE, maybe no previous call established ?");
120 osip_message_set_content_type(sip,"text/plain");
121 osip_message_set_body(sip,msg,strlen(msg));
122 eXosip_call_send_request(op->did,sip);
128 /*presence Subscribe/notify*/
129 int sal_subscribe_presence(SalOp *op, const char *from, const char *to){
132 sal_op_set_from(op,from);
134 sal_op_set_to(op,to);
135 sal_exosip_fix_route(op);
137 eXosip_subscribe_build_initial_request(&msg,sal_op_get_to(op),sal_op_get_from(op),
138 sal_op_get_route(op),"presence",600);
139 if (op->base.contact){
140 _osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
141 osip_message_set_contact(msg,op->base.contact);
143 op->sid=eXosip_subscribe_send_initial_request(msg);
146 osip_message_free(msg);
149 sal_add_out_subscribe(op->base.root,op);
153 int sal_unsubscribe(SalOp *op){
154 osip_message_t *msg=NULL;
156 ms_error("cannot unsubscribe, no dialog !");
160 eXosip_subscribe_build_refresh_request(op->did,&msg);
162 osip_message_set_expires(msg,"0");
163 eXosip_subscribe_send_refresh_request(op->did,msg);
164 }else ms_error("Could not build subscribe refresh request ! op->sid=%i, op->did=%i",
170 int sal_subscribe_accept(SalOp *op){
173 eXosip_insubscription_build_answer(op->tid,202,&msg);
174 if (op->base.contact){
175 _osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
176 osip_message_set_contact(msg,op->base.contact);
178 eXosip_insubscription_send_answer(op->tid,202,msg);
183 int sal_subscribe_decline(SalOp *op){
185 eXosip_insubscription_send_answer(op->tid,401,NULL);
190 static void mk_presence_body (const SalPresenceStatus online_status, const char *contact_info,
191 char *buf, size_t buflen, presence_type_t ptype) {
194 /* definition from http://msdn.microsoft.com/en-us/library/cc246202%28PROT.10%29.aspx */
197 if (online_status==SalPresenceOnline)
199 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
200 <!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
202 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
204 <address uri=\"%s\" priority=\"0.800000\">\n\
205 <status status=\"open\" />\n\
206 <msnsubstatus substatus=\"online\" />\n\
209 </presence>", contact_info, atom_id, contact_info);
212 else if (online_status == SalPresenceBusy ||
213 online_status == SalPresenceDonotdisturb)
215 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
216 <!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
218 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
220 <address uri=\"%s\" priority=\"0.800000\">\n\
221 <status status=\"inuse\" />\n\
222 <msnsubstatus substatus=\"busy\" />\n\
224 </atom>\n</presence>", contact_info, atom_id, contact_info);
227 else if (online_status==SalPresenceBerightback)
229 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
230 <!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
232 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
234 <address uri=\"%s\" priority=\"0.800000\">\n\
235 <status status=\"open\" />\n\
236 <msnsubstatus substatus=\"berightback\" />\n\
239 </presence>", contact_info, atom_id, contact_info);
242 else if (online_status == SalPresenceAway ||
243 online_status == SalPresenceMoved)
245 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
246 <!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
248 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
250 <address uri=\"%s\" priority=\"0.800000\">\n\
251 <status status=\"open\" />\n\
252 <msnsubstatus substatus=\"away\" />\n\
255 </presence>", contact_info, atom_id, contact_info);
258 else if (online_status==SalPresenceOnthephone)
260 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
261 <!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
263 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
265 <address uri=\"%s\" priority=\"0.800000\">\n\
266 <status status=\"inuse\" />\n\
267 <msnsubstatus substatus=\"onthephone\" />\n\
270 </presence>", contact_info, atom_id, contact_info);
273 else if (online_status==SalPresenceOuttolunch)
275 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
276 <!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
278 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
280 <address uri=\"%s\" priority=\"0.800000\">\n\
281 <status status=\"open\" />\n\
282 <msnsubstatus substatus=\"outtolunch\" />\n\
285 </presence>", contact_info, atom_id, contact_info);
290 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
291 <!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
293 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
295 <address uri=\"%s\" priority=\"0.800000\">\n\
296 <status status=\"closed\" />\n\
297 <msnsubstatus substatus=\"away\" />\n\
300 </presence>", contact_info, atom_id, contact_info);
305 /* Couldn't find schema http://schemas.microsoft.com/2002/09/sip/presence
306 * so messages format has been taken from Communigate that can send notify
307 * requests with this schema
311 if (online_status==SalPresenceOnline)
313 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
314 <!DOCTYPE presence SYSTEM \"http://schemas.microsoft.com/2002/09/sip/presence\">\n\
316 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
318 <address uri=\"%s\">\n\
319 <status status=\"open\" />\n\
320 <msnsubstatus substatus=\"online\" />\n\
323 </presence>", contact_info, atom_id, contact_info);
326 else if (online_status == SalPresenceBusy ||
327 online_status == SalPresenceDonotdisturb)
329 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
330 <!DOCTYPE presence SYSTEM \"http://schemas.microsoft.com/2002/09/sip/presence\">\n\
332 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
334 <address uri=\"%s\">\n\
335 <status status=\"inuse\" />\n\
336 <msnsubstatus substatus=\"busy\" />\n\
338 </atom>\n</presence>", contact_info, atom_id, contact_info);
341 else if (online_status==SalPresenceBerightback)
343 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
344 <!DOCTYPE presence SYSTEM \"http://schemas.microsoft.com/2002/09/sip/presence\">\n\
346 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
348 <address uri=\"%s\">\n\
349 <status status=\"inactive\" />\n\
350 <msnsubstatus substatus=\"berightback\" />\n\
353 </presence>", contact_info, atom_id, contact_info);
356 else if (online_status == SalPresenceAway ||
357 online_status == SalPresenceMoved)
359 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
360 <!DOCTYPE presence SYSTEM \"http://schemas.microsoft.com/2002/09/sip/presence\">\n\
362 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
364 <address uri=\"%s\">\n\
365 <status status=\"inactive\" />\n\
366 <msnsubstatus substatus=\"idle\" />\n\
369 </presence>", contact_info, atom_id, contact_info);
372 else if (online_status==SalPresenceOnthephone)
374 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
375 <!DOCTYPE presence SYSTEM \"http://schemas.microsoft.com/2002/09/sip/presence\">\n\
377 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
379 <address uri=\"%s\">\n\
380 <status status=\"inuse\" />\n\
381 <msnsubstatus substatus=\"onthephone\" />\n\
384 </presence>", contact_info, atom_id, contact_info);
387 else if (online_status==SalPresenceOuttolunch)
389 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
390 <!DOCTYPE presence SYSTEM \"http://schemas.microsoft.com/2002/09/sip/presence\">\n\
392 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
394 <address uri=\"%s\">\n\
395 <status status=\"inactive\" />\n\
396 <msnsubstatus substatus=\"outtolunch\" />\n\
399 </presence>", contact_info, atom_id, contact_info);
404 snprintf(buf, buflen, "<?xml version=\"1.0\"?>\n\
405 <!DOCTYPE presence SYSTEM \"http://schemas.microsoft.com/2002/09/sip/presence\">\n\
407 <presentity uri=\"%s;method=SUBSCRIBE\" />\n\
409 <address uri=\"%s\">\n\
410 <status status=\"closed\" />\n\
411 <msnsubstatus substatus=\"offline\" />\n\
414 </presence>", contact_info, atom_id, contact_info);
418 default: { /* use pidf+xml as default format, rfc4479, rfc4480, rfc3863 */
420 if (online_status==SalPresenceOnline)
422 snprintf(buf, buflen, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
423 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \
424 xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" \
425 xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" \
427 <tuple id=\"sg89ae\">\n\
428 <status><basic>open</basic></status>\n\
429 <contact priority=\"0.8\">%s</contact>\n\
432 contact_info, contact_info);
434 else if (online_status == SalPresenceBusy ||
435 online_status == SalPresenceDonotdisturb)
437 snprintf(buf, buflen, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
438 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \
439 xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" \
440 xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" \
442 <tuple id=\"sg89ae\">\n\
443 <status><basic>open</basic></status>\n\
444 <contact priority=\"0.8\">%s</contact>\n\
446 <dm:person id=\"sg89aep\">\n\
447 <rpid:activities><rpid:busy/></rpid:activities>\n\
450 contact_info, contact_info);
452 else if (online_status==SalPresenceBerightback)
454 snprintf(buf, buflen, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
455 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \
456 xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" \
457 xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" \
459 <tuple id=\"sg89ae\">\n\
460 <status><basic>open</basic></status>\n\
461 <contact priority=\"0.8\">%s</contact>\n\
463 <dm:person id=\"sg89aep\">\n\
464 <rpid:activities><rpid:in-transit/></rpid:activities>\n\
467 contact_info, contact_info);
469 else if (online_status == SalPresenceAway ||
470 online_status == SalPresenceMoved)
472 snprintf(buf, buflen, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
473 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \
474 xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" \
475 xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" \
477 <tuple id=\"sg89ae\">\n\
478 <status><basic>open</basic></status>\n\
479 <contact priority=\"0.8\">%s</contact>\n\
481 <dm:person id=\"sg89aep\">\n\
482 <rpid:activities><rpid:away/></rpid:activities>\n\
485 contact_info, contact_info);
487 else if (online_status==SalPresenceOnthephone)
489 snprintf(buf, buflen, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
490 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \
491 xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" \
492 xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" \
494 <tuple id=\"sg89ae\">\n\
495 <status><basic>open</basic></status>\n\
496 <contact priority=\"0.8\">%s</contact>\n\
498 <dm:person id=\"sg89aep\">\n\
499 <rpid:activities><rpid:on-the-phone/></rpid:activities>\n\
502 contact_info, contact_info);
504 else if (online_status==SalPresenceOuttolunch)
506 snprintf(buf, buflen, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
507 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \
508 xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" \
509 xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" \
511 <tuple id=\"7777\">\n\
512 <status><basic>open</basic></status>\n\
513 <contact priority=\"0.8\">%s</contact>\n\
515 <dm:person id=\"78787878\">\n\
516 <rpid:activities><rpid:meal/></rpid:activities>\n\
517 <rpid:note>Out to lunch</rpid:note> \n\
520 contact_info, contact_info);
524 snprintf(buf, buflen, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
525 <presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \
526 xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" \
527 xmlns:rpid=\"urn:ietf:params:xml:ns:pidf:rpid\" \
529 <tuple id=\"sg89ae\">\n\
530 <status><basic>closed</basic></status>\n\
531 <contact priority=\"0.8\">%s</contact>\n\
533 </presence>\n", contact_info, contact_info);
541 static void add_presence_body(osip_message_t *notify, SalPresenceStatus online_status)
546 osip_from_t *from=NULL;
547 from=osip_message_get_from(notify);
548 osip_uri_to_str(from->url,&contact_info);
550 mk_presence_body (online_status, contact_info, buf, sizeof (buf), presence_style);
552 osip_message_set_body(notify, buf, strlen(buf));
553 osip_message_set_content_type(notify,
554 presence_style ? "application/xpidf+xml" : "application/pidf+xml");
556 osip_free(contact_info);
560 int sal_notify_presence(SalOp *op, SalPresenceStatus status, const char *status_message){
562 eXosip_ss_t ss=EXOSIP_SUBCRSTATE_ACTIVE;
564 ms_warning("Cannot notify, subscription was closed.");
569 eXosip_insubscription_build_notify(op->did,ss,DEACTIVATED,&msg);
571 const char *identity=sal_op_get_contact(op);
572 if (identity==NULL) identity=sal_op_get_to(op);
573 _osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
574 osip_message_set_contact(msg,identity);
575 add_presence_body(msg,status);
576 eXosip_insubscription_send_request(op->did,msg);
577 }else ms_error("could not create notify for incoming subscription.");
582 int sal_notify_close(SalOp *op){
583 osip_message_t *msg=NULL;
585 eXosip_insubscription_build_notify(op->did,EXOSIP_SUBCRSTATE_TERMINATED,DEACTIVATED,&msg);
587 const char *identity=sal_op_get_contact(op);
588 if (identity==NULL) identity=sal_op_get_to(op);
589 osip_message_set_contact(msg,identity);
590 add_presence_body(msg,SalPresenceOffline);
591 eXosip_insubscription_send_request(op->did,msg);
592 }else ms_error("sal_notify_close(): could not create notify for incoming subscription"
593 " did=%i, nid=%i",op->did,op->nid);
598 int sal_publish(SalOp *op, const char *from, const char *to, SalPresenceStatus presence_mode){
603 mk_presence_body (presence_mode, from, buf, sizeof (buf), presence_style);
605 i = eXosip_build_publish(&pub,from, to, NULL, "presence", "300",
606 presence_style ? "application/xpidf+xml" : "application/pidf+xml", buf);
608 ms_warning("Failed to build publish request.");
613 i = eXosip_publish(pub, to); /* should update the sip-if-match parameter
614 from sip-etag from last 200ok of PUBLISH */
617 ms_message("Failed to send publish request.");
620 sal_add_other(sal_op_get_sal(op),op,pub);
624 static void _sal_exosip_subscription_recv(Sal *sal, eXosip_event_t *ev){
625 SalOp *op=sal_op_new(sal);
630 osip_from_to_str(ev->request->from,&tmp);
631 sal_op_set_from(op,tmp);
633 osip_from_to_str(ev->request->to,&tmp);
634 sal_op_set_to(op,tmp);
636 sal_add_in_subscribe(sal,op,ev->request);
637 sal->callbacks.subscribe_received(op,sal_op_get_from(op));
640 void sal_exosip_subscription_recv(Sal *sal, eXosip_event_t *ev){
641 /*workaround a bug in eXosip: incoming SUBSCRIBES within dialog with expires: 0 are
642 recognized as new incoming subscribes*/
643 SalOp *op=sal_find_in_subscribe_by_call_id(sal,ev->request->call_id);
646 osip_message_header_get_byname(ev->request,"expires",0,&h);
647 if (h && h->hvalue && atoi(h->hvalue)==0){
648 ms_warning("This susbscribe is not a new one but terminates an old one.");
651 sal_exosip_subscription_closed(sal,ev);
653 osip_message_t *msg=NULL;
654 ms_warning("Probably a refresh subscribe");
656 eXosip_insubscription_build_answer(ev->tid,202,&msg);
657 eXosip_insubscription_send_answer(ev->tid,202,msg);
660 }else _sal_exosip_subscription_recv(sal,ev);
663 void sal_exosip_notify_recv(Sal *sal, eXosip_event_t *ev){
664 SalOp *op=sal_find_out_subscribe(sal,ev->sid);
666 osip_from_t *from=NULL;
667 osip_body_t *body=NULL;
668 SalPresenceStatus estatus=SalPresenceOffline;
670 ms_message("Receiving notify with sid=%i,nid=%i",ev->sid,ev->nid);
673 ms_error("No operation related to this notify !");
676 if (ev->request==NULL) return;
678 from=ev->request->from;
679 osip_message_get_body(ev->request,0,&body);
681 ms_error("No body in NOTIFY");
684 osip_from_to_str(from,&tmp);
685 if (strstr(body->body,"pending")!=NULL){
686 estatus=SalPresenceOffline;
687 }else if (strstr(body->body,"busy")!=NULL){
688 estatus=SalPresenceBusy;
689 }else if (strstr(body->body,"berightback")!=NULL
690 || strstr(body->body,"in-transit")!=NULL ){
691 estatus=SalPresenceBerightback;
692 }else if (strstr(body->body,"away")!=NULL
693 || strstr(body->body,"idle")){
694 estatus=SalPresenceAway;
695 }else if (strstr(body->body,"onthephone")!=NULL
696 || strstr(body->body,"on-the-phone")!=NULL){
697 estatus=SalPresenceOnthephone;
698 }else if (strstr(body->body,"outtolunch")!=NULL
699 || strstr(body->body,"meal")!=NULL){
700 estatus=SalPresenceOuttolunch;
701 }else if (strstr(body->body,"closed")!=NULL){
702 estatus=SalPresenceOffline;
703 }else if ((strstr(body->body,"online")!=NULL) || (strstr(body->body,"open")!=NULL)) {
704 estatus=SalPresenceOnline;
706 estatus=SalPresenceOffline;
708 ms_message("We are notified that %s has online status %i",tmp,estatus);
709 if (ev->ss_status==EXOSIP_SUBCRSTATE_TERMINATED) {
710 sal_remove_out_subscribe(sal,op);
713 ms_message("And outgoing subscription terminated by remote.");
715 sal->callbacks.notify_presence(op,op->sid!=-1 ? SalSubscribeActive : SalSubscribeTerminated, estatus,NULL);
717 /* try to detect presence message style used by server,
718 * and switch our presence messages to servers style */
719 if (strstr (body->body, "//IETF//DTD RFCxxxx XPIDF 1.0//EN") != NULL) {
720 presence_style = RFCxxxx;
721 } else if (strstr(body->body,"http://schemas.microsoft.com/2002/09/sip/presence")!=NULL) {
722 presence_style = MSOLDPRES;
728 void sal_exosip_subscription_answered(Sal *sal,eXosip_event_t *ev){
729 SalOp *op=sal_find_out_subscribe(sal,ev->sid);
731 ms_error("Subscription answered but no associated op !");
737 void sal_exosip_in_subscription_closed(Sal *sal, eXosip_event_t *ev){
738 SalOp *op=sal_find_in_subscribe(sal,ev->nid);
741 ms_error("Incoming subscription closed but no associated op !");
746 sal_remove_in_subscribe(sal,op);
750 osip_from_to_str(ev->request->from,&tmp);
751 sal->callbacks.subscribe_closed(op,tmp);
756 void sal_exosip_subscription_closed(Sal *sal,eXosip_event_t *ev){
757 SalOp *op=sal_find_out_subscribe(sal,ev->sid);
759 ms_error("Subscription closed but no associated op !");
762 sal_remove_out_subscribe(sal,op);
765 sal->callbacks.notify_presence(op,SalSubscribeTerminated, SalPresenceOffline,NULL);