mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
improve LinphoneEvent api:
- better error notification - allow publish without expires
This commit is contained in:
parent
7aec150bf4
commit
39f9ec6a48
6 changed files with 29 additions and 14 deletions
|
|
@ -106,7 +106,9 @@ int sal_publish(SalOp *op, const char *from, const char *to, const char *eventna
|
|||
}
|
||||
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("Event",eventname));
|
||||
sal_op_add_body(op,BELLE_SIP_MESSAGE(req),body);
|
||||
return sal_op_send_and_create_refresher(op,req,expires,publish_refresher_listener);
|
||||
if (expires!=-1)
|
||||
return sal_op_send_and_create_refresher(op,req,expires,publish_refresher_listener);
|
||||
else return sal_op_send_request(op,req);
|
||||
} else {
|
||||
/*update status*/
|
||||
const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->refresher);
|
||||
|
|
|
|||
|
|
@ -1052,6 +1052,7 @@ static void info_received(SalOp *op, const SalBody *body){
|
|||
|
||||
static void subscribe_response(SalOp *op, SalSubscribeStatus status){
|
||||
LinphoneEvent *lev=(LinphoneEvent*)sal_op_get_user_pointer(op);
|
||||
const SalErrorInfo *ei=sal_op_get_error_info(op);
|
||||
|
||||
if (lev==NULL) return;
|
||||
|
||||
|
|
@ -1060,7 +1061,10 @@ static void subscribe_response(SalOp *op, SalSubscribeStatus status){
|
|||
}else if (status==SalSubscribePending){
|
||||
linphone_event_set_state(lev,LinphoneSubscriptionPending);
|
||||
}else{
|
||||
linphone_event_set_state(lev,LinphoneSubscriptionError);
|
||||
if (lev->subscription_state==LinphoneSubscriptionActive && ei->reason==SalReasonIOError){
|
||||
linphone_event_set_state(lev,LinphoneSubscriptionOutgoingProgress);
|
||||
}
|
||||
else linphone_event_set_state(lev,LinphoneSubscriptionError);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1111,9 +1115,12 @@ static void on_publish_response(SalOp* op){
|
|||
linphone_event_set_publish_state(lev,LinphonePublishOk);
|
||||
else
|
||||
linphone_event_set_publish_state(lev,LinphonePublishCleared);
|
||||
|
||||
}else{
|
||||
linphone_event_set_publish_state(lev,LinphonePublishError);
|
||||
if (lev->publish_state==LinphonePublishOk){
|
||||
linphone_event_set_publish_state(lev,LinphonePublishProgress);
|
||||
}else{
|
||||
linphone_event_set_publish_state(lev,LinphonePublishError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ void linphone_event_terminate(LinphoneEvent *lev){
|
|||
}
|
||||
|
||||
if (lev->publish_state!=LinphonePublishNone){
|
||||
if (lev->publish_state==LinphonePublishOk){
|
||||
if (lev->publish_state==LinphonePublishOk && lev->expires!=-1){
|
||||
sal_publish(lev->op,NULL,NULL,NULL,0,NULL);
|
||||
}else sal_op_stop_refreshing(lev->op);
|
||||
linphone_event_set_publish_state(lev,LinphonePublishCleared);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ typedef enum _LinphoneSubscriptionDir LinphoneSubscriptionDir;
|
|||
**/
|
||||
enum _LinphoneSubscriptionState{
|
||||
LinphoneSubscriptionNone, /**< Initial state, should not be used.**/
|
||||
LinphoneSubscriptionOutgoingInit, /**<An outgoing subcription was created*/
|
||||
LinphoneSubscriptionOutgoingProgress, /**<An outgoing subcription was sent*/
|
||||
LinphoneSubscriptionIncomingReceived, /**<An incoming subcription is received*/
|
||||
LinphoneSubscriptionPending, /**<Subscription is pending, waiting for user approval*/
|
||||
LinphoneSubscriptionActive, /**<Subscription is accepted.*/
|
||||
|
|
@ -63,6 +63,7 @@ enum _LinphoneSubscriptionState{
|
|||
/*typo compatibility*/
|
||||
#define LinphoneSubscriptionOutoingInit LinphoneSubscriptionOutgoingInit
|
||||
|
||||
#define LinphoneSubscriptionOutgoingInit LinphoneSubscriptionOutgoingProgress
|
||||
/**
|
||||
* Typedef for subscription state enum.
|
||||
**/
|
||||
|
|
@ -169,7 +170,7 @@ LINPHONE_PUBLIC int linphone_event_notify(LinphoneEvent *lev, const LinphoneCont
|
|||
* @param lc the #LinphoneCore
|
||||
* @param resource the resource uri for the event
|
||||
* @param event the event name
|
||||
* @param expires the lifetime of the publication
|
||||
* @param expires the lifetime of event being published, -1 if no associated duration, in which case it will not be refreshed.
|
||||
* @param body the actual published data
|
||||
* @return the LinphoneEvent holding the context of the publish.
|
||||
**/
|
||||
|
|
@ -182,7 +183,7 @@ LINPHONE_PUBLIC LinphoneEvent *linphone_core_publish(LinphoneCore *lc, const Lin
|
|||
* @param lc the #LinphoneCore
|
||||
* @param resource the resource uri for the event
|
||||
* @param event the event name
|
||||
* @param expires the lifetime of the publication
|
||||
* @param expires the lifetime of event being published, -1 if no associated duration, in which case it will not be refreshed.
|
||||
* @return the LinphoneEvent holding the context of the publish.
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneEvent *linphone_core_create_publish(LinphoneCore *lc, const LinphoneAddress *resource, const char *event, int expires);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public enum SubscriptionState {
|
|||
/**
|
||||
* An outgoing subcription was created.
|
||||
*/
|
||||
OutoingInit(1),
|
||||
OutoingProgress(1),
|
||||
/**
|
||||
* An incoming subcription is received.
|
||||
*/
|
||||
|
|
@ -41,7 +41,7 @@ public enum SubscriptionState {
|
|||
static protected SubscriptionState fromInt(int value) throws LinphoneCoreException{
|
||||
switch(value){
|
||||
case 0: return None;
|
||||
case 1: return OutoingInit;
|
||||
case 1: return OutoingProgress;
|
||||
case 2: return IncomingReceived;
|
||||
case 3: return Pending;
|
||||
case 4: return Active;
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ static void subscribe_test_manually_refreshed(void){
|
|||
subscribe_test_with_args(TRUE,ManualRefresh);
|
||||
}
|
||||
|
||||
static void publish_test_with_args(bool_t refresh){
|
||||
static void publish_test_with_args(bool_t refresh, int expires){
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
LinphoneContent content={0};
|
||||
|
|
@ -304,7 +304,7 @@ static void publish_test_with_args(bool_t refresh){
|
|||
|
||||
lp_config_set_int(marie->lc->config,"sip","refresh_generic_publish",refresh);
|
||||
|
||||
lev=linphone_core_create_publish(marie->lc,pauline->identity,"dodo",5);
|
||||
lev=linphone_core_create_publish(marie->lc,pauline->identity,"dodo",expires);
|
||||
linphone_event_add_custom_header(lev,"CustomHeader","someValue");
|
||||
linphone_event_send_publish(lev,&content);
|
||||
linphone_event_ref(lev);
|
||||
|
|
@ -332,11 +332,15 @@ static void publish_test_with_args(bool_t refresh){
|
|||
}
|
||||
|
||||
static void publish_test(){
|
||||
publish_test_with_args(TRUE);
|
||||
publish_test_with_args(TRUE,5);
|
||||
}
|
||||
|
||||
static void publish_no_auto_test(){
|
||||
publish_test_with_args(FALSE);
|
||||
publish_test_with_args(FALSE,5);
|
||||
}
|
||||
|
||||
static void publish_without_expires(){
|
||||
publish_test_with_args(TRUE,-1);
|
||||
}
|
||||
|
||||
test_t event_tests[] = {
|
||||
|
|
@ -347,6 +351,7 @@ test_t event_tests[] = {
|
|||
{ "Subscribe manually refreshed", subscribe_test_manually_refreshed },
|
||||
{ "Subscribe terminated by notifier", subscribe_test_terminated_by_notifier },
|
||||
{ "Publish", publish_test },
|
||||
{ "Publish without expires", publish_without_expires },
|
||||
{ "Publish without automatic refresh",publish_no_auto_test }
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue