mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
add sanity checks in LinphoneEvent api
This commit is contained in:
parent
2c8da39ac7
commit
187c55bfd8
2 changed files with 32 additions and 3 deletions
|
|
@ -136,9 +136,23 @@ LinphoneEvent *linphone_core_subscribe(LinphoneCore *lc, const LinphoneAddress *
|
|||
|
||||
int linphone_event_update_subscribe(LinphoneEvent *lev, const LinphoneContent *body){
|
||||
SalBody salbody;
|
||||
if (lev->subscription_state!=LinphoneSubscriptionActive){
|
||||
ms_error("linphone_event_update_subscribe(): cannot update subscription if subscription wasn't accepted.");
|
||||
return -1;
|
||||
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.");
|
||||
|
|
@ -203,6 +217,12 @@ LinphoneEvent *linphone_core_publish(LinphoneCore *lc, const LinphoneAddress *re
|
|||
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);
|
||||
|
|
@ -282,3 +302,7 @@ const LinphoneAddress *linphone_event_get_resource(const LinphoneEvent *lev){
|
|||
return lev->resource_addr;
|
||||
}
|
||||
|
||||
LinphoneCore *linphone_event_get_core(const LinphoneEvent *lev){
|
||||
return lev->lc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -230,6 +230,11 @@ LINPHONE_PUBLIC const LinphoneAddress *linphone_event_get_from(const LinphoneEve
|
|||
**/
|
||||
LINPHONE_PUBLIC const LinphoneAddress *linphone_event_get_resource(const LinphoneEvent *lev);
|
||||
|
||||
/**
|
||||
* Returns back pointer to the LinphoneCore that created this LinphoneEvent
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneCore *linphone_event_get_core(const LinphoneEvent *lev);
|
||||
|
||||
/**
|
||||
* @}
|
||||
**/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue