int linphone_event_update_subscribe(LinphoneEvent *lev, const LinphoneContent *body){ SalBody salbody; switch (lev->subscription_state){ case LinphoneSubscriptionNone: ms_error("linphone_event_update_subscribe(): this is not a subscribed event."); return -1; break; case LinphoneSubscriptionIncomingReceived: case LinphoneSubscriptionOutoingInit: case LinphoneSubscriptionTerminated: ms_error("linphone_event_update_subscribe(): cannot update subscription while in state [%s]", linphone_subscription_state_to_string(lev->subscription_state)); return -1; break; case LinphoneSubscriptionActive: case LinphoneSubscriptionExpiring: case LinphoneSubscriptionError: case LinphoneSubscriptionPending: /*those states are ok*/ break; } if (lev->dir!=LinphoneSubscriptionOutgoing){ ms_error("linphone_event_deny_subscription(): cannot update an incoming subscription."); return -1; } return sal_subscribe(lev->op,NULL,NULL,NULL,-1,sal_body_from_content(&salbody,body)); }
LinphoneEvent *linphone_core_subscribe(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires, const LinphoneContent *body){ LinphoneEvent *lev=linphone_event_new(lc, LinphoneSubscriptionOutgoing, event); SalBody salbody; linphone_configure_op(lc,lev->op,resource,NULL,TRUE); sal_op_set_manual_refresher_mode(lev->op,!lp_config_get_int(lc->config,"sip","refresh_generic_subscribe",1)); lev->resource_addr=linphone_address_clone(resource); lev->from=linphone_address_clone((LinphoneAddress*)sal_op_get_from_address(lev->op)); sal_subscribe(lev->op,NULL,NULL,event,expires,sal_body_from_content(&salbody,body)); linphone_event_set_state(lev,LinphoneSubscriptionOutoingInit); return lev; }
int linphone_event_notify(LinphoneEvent *lev, const LinphoneContent *body){ SalBody salbody; if (lev->subscription_state!=LinphoneSubscriptionActive){ ms_error("linphone_event_notify(): cannot notify if subscription is not active."); return -1; } if (lev->dir!=LinphoneSubscriptionIncoming){ ms_error("linphone_event_notify(): cannot notify if not an incoming subscription."); return -1; } return sal_notify(lev->op,sal_body_from_content(&salbody,body)); }
LinphoneEvent *linphone_core_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires, const LinphoneContent *body){ SalBody salbody; int err; LinphoneEvent *lev=linphone_event_new(lc,LinphoneSubscriptionInvalidDir, event); linphone_configure_op(lc,lev->op,resource,NULL,lp_config_get_int(lc->config,"sip","publish_msg_with_contact",0)); sal_op_set_manual_refresher_mode(lev->op,!lp_config_get_int(lc->config,"sip","refresh_generic_publish",1)); err=sal_publish(lev->op,NULL,NULL,event,expires,sal_body_from_content(&salbody,body)); if (err==0){ linphone_event_set_publish_state(lev,LinphonePublishProgress); }else{ linphone_event_unref(lev); lev=NULL; } return lev; }
int linphone_event_update_publish(LinphoneEvent *lev, const LinphoneContent *body){ SalBody salbody; int err; if (lev->publish_state==LinphonePublishNone){ ms_error("linphone_event_update_publish(): this is not a PUBLISH event."); return -1; } err=sal_publish(lev->op,NULL,NULL,NULL,-1,sal_body_from_content(&salbody,body)); if (err==0){ linphone_event_set_publish_state(lev,LinphonePublishProgress); }else{ linphone_event_set_publish_state(lev,LinphonePublishError); } return err; }
static int _linphone_event_send_publish(LinphoneEvent *lev, const LinphoneContent *body, bool_t notify_err){ SalBody salbody; int err; if (lev->dir!=LinphoneSubscriptionInvalidDir){ ms_error("linphone_event_update_publish(): this is not a PUBLISH event."); return -1; } if (lev->send_custom_headers){ sal_op_set_sent_custom_header(lev->op,lev->send_custom_headers); lev->send_custom_headers=NULL; }else sal_op_set_sent_custom_header(lev->op,NULL); err=sal_publish(lev->op,NULL,NULL,lev->name,lev->expires,sal_body_from_content(&salbody,body)); if (err==0){ linphone_event_set_publish_state(lev,LinphonePublishProgress); }else if (notify_err){ linphone_event_set_publish_state(lev,LinphonePublishError); } return err; }
int linphone_event_send_subscribe(LinphoneEvent *lev, const LinphoneContent *body){ SalBody salbody; int err; if (lev->dir!=LinphoneSubscriptionOutgoing){ ms_error("linphone_event_send_subscribe(): cannot send or update something that is not an outgoing subscription."); return -1; } switch (lev->subscription_state){ case LinphoneSubscriptionIncomingReceived: case LinphoneSubscriptionTerminated: case LinphoneSubscriptionOutgoingInit: ms_error("linphone_event_send_subscribe(): cannot update subscription while in state [%s]", linphone_subscription_state_to_string(lev->subscription_state)); return -1; break; case LinphoneSubscriptionNone: case LinphoneSubscriptionActive: case LinphoneSubscriptionExpiring: case LinphoneSubscriptionError: case LinphoneSubscriptionPending: /*those states are ok*/ break; } if (lev->send_custom_headers){ sal_op_set_sent_custom_header(lev->op,lev->send_custom_headers); lev->send_custom_headers=NULL; }else sal_op_set_sent_custom_header(lev->op,NULL); err=sal_subscribe(lev->op,NULL,NULL,lev->name,lev->expires,sal_body_from_content(&salbody,body)); if (err==0){ if (lev->subscription_state==LinphoneSubscriptionNone) linphone_event_set_state(lev,LinphoneSubscriptionOutgoingInit); } return err; }
/** * Send a LinphoneInfoMessage through an established call * @param call the call * @param info the info message **/ int linphone_call_send_info_message(LinphoneCall *call, const LinphoneInfoMessage *info){ SalBody body; sal_op_set_sent_custom_header(call->op,info->headers); return sal_send_info(call->op,NULL, NULL, sal_body_from_content(&body,&info->content)); }