Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
95e3f26d
Commit
95e3f26d
authored
Dec 13, 2013
by
Simon Morlat
Browse files
implement manual mode refresher for generic subscribe
parent
70f9617b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
51 additions
and
11 deletions
+51
-11
coreapi/bellesip_sal/sal_op_events.c
coreapi/bellesip_sal/sal_op_events.c
+2
-0
coreapi/bellesip_sal/sal_op_impl.c
coreapi/bellesip_sal/sal_op_impl.c
+6
-0
coreapi/callbacks.c
coreapi/callbacks.c
+2
-0
coreapi/event.c
coreapi/event.c
+2
-0
coreapi/event.h
coreapi/event.h
+3
-2
coreapi/linphonecore.c
coreapi/linphonecore.c
+2
-0
coreapi/linphonecore.h
coreapi/linphonecore.h
+2
-2
coreapi/misc.c
coreapi/misc.c
+5
-0
include/sal/sal.h
include/sal/sal.h
+2
-1
tester/eventapi_tester.c
tester/eventapi_tester.c
+24
-6
tester/liblinphone_tester.h
tester/liblinphone_tester.h
+1
-0
No files found.
coreapi/bellesip_sal/sal_op_events.c
View file @
95e3f26d
...
...
@@ -52,6 +52,8 @@ static void subscribe_refresher_listener (belle_sip_refresher_t* refresher
if
(
status_code
>=
200
){
sal_compute_sal_errors_from_code
(
status_code
,
&
error
,
&
sr
);
op
->
base
.
root
->
callbacks
.
subscribe_response
(
op
,
sss
,
error
,
sr
);
}
else
if
(
status_code
==
0
){
op
->
base
.
root
->
callbacks
.
on_expire
(
op
);
}
}
...
...
coreapi/bellesip_sal/sal_op_impl.c
View file @
95e3f26d
...
...
@@ -358,6 +358,9 @@ SalReason sal_reason_to_sip_code(SalReason r){
case
SalReasonNotAcceptable
:
ret
=
488
;
break
;
case
SalReasonNoMatch
:
ret
=
481
;
break
;
}
return
ret
;
}
...
...
@@ -391,6 +394,9 @@ void sal_compute_sal_errors_from_code(int code ,SalError* sal_err,SalReason* sal
*
sal_err
=
SalErrorFailure
;
*
sal_reason
=
SalReasonTemporarilyUnavailable
;
break
;
case
481
:
*
sal_err
=
SalErrorFailure
;
*
sal_reason
=
SalReasonNoMatch
;
case
486
:
*
sal_err
=
SalErrorFailure
;
*
sal_reason
=
SalReasonBusy
;
...
...
coreapi/callbacks.c
View file @
95e3f26d
...
...
@@ -1108,6 +1108,8 @@ static void on_expire(SalOp *op){
if
(
linphone_event_get_publish_state
(
lev
)
==
LinphonePublishOk
){
linphone_event_set_publish_state
(
lev
,
LinphonePublishExpiring
);
}
else
if
(
linphone_event_get_subscription_state
(
lev
)
==
LinphoneSubscriptionActive
){
linphone_event_set_state
(
lev
,
LinphoneSubscriptionExpiring
);
}
}
...
...
coreapi/event.c
View file @
95e3f26d
...
...
@@ -40,6 +40,7 @@ const char *linphone_subscription_state_to_string(LinphoneSubscriptionState stat
case
LinphoneSubscriptionActive
:
return
"LinphoneSubscriptionActive"
;
case
LinphoneSubscriptionTerminated
:
return
"LinphoneSubscriptionTerminated"
;
case
LinphoneSubscriptionError
:
return
"LinphoneSubscriptionError"
;
case
LinphoneSubscriptionExpiring
:
return
"LinphoneSubscriptionExpiring"
;
}
return
NULL
;
}
...
...
@@ -124,6 +125,7 @@ LinphoneEvent *linphone_core_subscribe(LinphoneCore *lc, const LinphoneAddress *
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
));
...
...
coreapi/event.h
View file @
95e3f26d
...
...
@@ -57,7 +57,8 @@ enum _LinphoneSubscriptionState{
LinphoneSubscriptionPending
,
/**<Subscription is pending, waiting for user approval*/
LinphoneSubscriptionActive
,
/**<Subscription is accepted.*/
LinphoneSubscriptionTerminated
,
/**<Subscription is terminated normally*/
LinphoneSubscriptionError
/**<Subscription encountered an error, indicated by linphone_event_get_reason()*/
LinphoneSubscriptionError
,
/**<Subscription encountered an error, indicated by linphone_event_get_reason()*/
LinphoneSubscriptionExpiring
,
/**<Subscription is about to expire, only sent if [sip]->refresh_generic_subscribe property is set to 0.*/
};
/**
...
...
@@ -72,7 +73,7 @@ LINPHONE_PUBLIC const char *linphone_subscription_state_to_string(LinphoneSubscr
**/
enum
_LinphonePublishState
{
LinphonePublishNone
,
/**< Initial state, do not use**/
LinphonePublishProgress
,
/**<An outgoing
s
ub
cription
was created*/
LinphonePublishProgress
,
/**<An outgoing
p
ub
lish
was created
and submitted
*/
LinphonePublishOk
,
/**<Publish is accepted.*/
LinphonePublishError
,
/**<Publish encoutered an error, linphone_event_get_reason() gives reason code*/
LinphonePublishExpiring
,
/**<Publish is about to expire, only sent if [sip]->refresh_generic_publish property is set to 0.*/
...
...
coreapi/linphonecore.c
View file @
95e3f26d
...
...
@@ -5916,6 +5916,8 @@ const char *linphone_reason_to_string(LinphoneReason err){
return
"Unauthorized"
;
case
LinphoneReasonNotAcceptable
:
return
"Not acceptable here"
;
case
LinphoneReasonNoMatch
:
return
"No match"
;
}
return
"unknown error"
;
}
...
...
coreapi/linphonecore.h
View file @
95e3f26d
...
...
@@ -165,8 +165,8 @@ enum _LinphoneReason{
LinphoneReasonIOError
,
/**<Transport error: connection failures, disconnections etc...*/
LinphoneReasonDoNotDisturb
,
/**<Do not disturb reason*/
LinphoneReasonUnauthorized
,
/**<Operation is unauthorized because missing credential*/
LinphoneReasonNotAcceptable
/**<Operation like call update rejected by peer*/
LinphoneReasonNotAcceptable
,
/**<Operation like call update rejected by peer*/
LinphoneReasonNoMatch
/**<Operation could not be executed by server or remote client because it didn't have any context for it*/
};
/**
...
...
coreapi/misc.c
View file @
95e3f26d
...
...
@@ -1244,6 +1244,8 @@ SalReason linphone_reason_to_sal(LinphoneReason reason){
return
SalReasonUnauthorized
;
case
LinphoneReasonNotAcceptable
:
return
SalReasonNotAcceptable
;
case
LinphoneReasonNoMatch
:
return
SalReasonNoMatch
;
}
return
SalReasonUnknown
;
}
...
...
@@ -1290,6 +1292,9 @@ LinphoneReason linphone_reason_from_sal(SalReason r){
case
SalReasonNotAcceptable
:
ret
=
LinphoneReasonNotAcceptable
;
break
;
case
SalReasonNoMatch
:
ret
=
LinphoneReasonNoMatch
;
break
;
}
return
ret
;
}
...
...
include/sal/sal.h
View file @
95e3f26d
...
...
@@ -284,7 +284,8 @@ typedef enum SalReason{
SalReasonServiceUnavailable
,
SalReasonRequestPending
,
SalReasonUnauthorized
,
SalReasonNotAcceptable
SalReasonNotAcceptable
,
SalReasonNoMatch
/*equivalent to 481 Transaction/Call leg does not exist*/
}
SalReason
;
const
char
*
sal_reason_to_string
(
const
SalReason
reason
);
...
...
tester/eventapi_tester.c
View file @
95e3f26d
...
...
@@ -76,6 +76,10 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li
counters
->
number_of_LinphoneSubscriptionError
++
;
mgr
->
lev
=
NULL
;
break
;
case
LinphoneSubscriptionExpiring
:
counters
->
number_of_LinphoneSubscriptionExpiring
++
;
mgr
->
lev
=
NULL
;
break
;
}
}
...
...
@@ -119,13 +123,18 @@ static void subscribe_test_declined(void) {
linphone_core_manager_destroy
(
pauline
);
}
typedef
enum
RefreshTestType
{
NoRefresh
,
AutoRefresh
,
ManualRefresh
}
RefreshTestType
;
static
void
subscribe_test_with_args
(
bool_t
terminated_by_subscriber
,
bool_t
test_
refresh
ing
)
{
static
void
subscribe_test_with_args
(
bool_t
terminated_by_subscriber
,
RefreshTestType
refresh
_type
)
{
LinphoneCoreManager
*
marie
=
linphone_core_manager_new
(
"marie_rc"
);
LinphoneCoreManager
*
pauline
=
linphone_core_manager_new
(
"pauline_rc"
);
LinphoneContent
content
=
{
0
};
LinphoneEvent
*
lev
;
int
expires
=
test_r
efresh
ing
?
4
:
600
;
int
expires
=
refresh_type
!=
NoR
efresh
?
4
:
600
;
MSList
*
lcs
=
ms_list_append
(
NULL
,
marie
->
lc
);
...
...
@@ -147,9 +156,13 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, bool_t tes
/*make sure marie receives first notification before terminating*/
CU_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_NotifyReceived
,
1
,
1000
));
if
(
test_r
efresh
ing
){
if
(
refresh_type
==
AutoR
efresh
){
wait_for_list
(
lcs
,
NULL
,
0
,
6000
);
CU_ASSERT_TRUE
(
linphone_event_get_subscription_state
(
pauline
->
lev
)
==
LinphoneSubscriptionActive
);
}
else
if
(
refresh_type
==
ManualRefresh
){
CU_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionExpiring
,
1
,
4000
));
linphone_event_update_subscribe
(
lev
,
NULL
);
CU_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
2000
));
}
if
(
terminated_by_subscriber
){
...
...
@@ -167,18 +180,22 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, bool_t tes
}
static
void
subscribe_test_terminated_by_subscriber
(
void
){
subscribe_test_with_args
(
TRUE
,
FALSE
);
subscribe_test_with_args
(
TRUE
,
NoRefresh
);
}
static
void
subscribe_test_terminated_by_notifier
(
void
){
subscribe_test_with_args
(
FALSE
,
FALSE
);
subscribe_test_with_args
(
FALSE
,
NoRefresh
);
}
/* Caution: this test does not really check that the subscribe are refreshed, because the core is not managing the expiration of
* unrefreshed subscribe dialogs. So it is just checking that it is not crashing.
*/
static
void
subscribe_test_refreshed
(
void
){
subscribe_test_with_args
(
TRUE
,
TRUE
);
subscribe_test_with_args
(
TRUE
,
AutoRefresh
);
}
static
void
subscribe_test_manually_refreshed
(
void
){
subscribe_test_with_args
(
TRUE
,
ManualRefresh
);
}
static
void
publish_test_with_args
(
bool_t
refresh
){
...
...
@@ -234,6 +251,7 @@ test_t event_tests[] = {
{
"Subscribe declined"
,
subscribe_test_declined
},
{
"Subscribe terminated by subscriber"
,
subscribe_test_terminated_by_subscriber
},
{
"Subscribe refreshed"
,
subscribe_test_refreshed
},
{
"Subscribe manually refreshed"
,
subscribe_test_manually_refreshed
},
{
"Subscribe terminated by notifier"
,
subscribe_test_terminated_by_notifier
},
{
"Publish"
,
publish_test
},
{
"Publish without automatic refresh"
,
publish_no_auto_test
}
...
...
tester/liblinphone_tester.h
View file @
95e3f26d
...
...
@@ -163,6 +163,7 @@ typedef struct _stats {
int
number_of_LinphoneSubscriptionActive
;
int
number_of_LinphoneSubscriptionTerminated
;
int
number_of_LinphoneSubscriptionError
;
int
number_of_LinphoneSubscriptionExpiring
;
int
number_of_LinphonePublishProgress
;
int
number_of_LinphonePublishOk
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment