Commit 5eee43e7 authored by Simon Morlat's avatar Simon Morlat

Send IMDN when related proxy config has registered. This avoids IMDN message...

Send IMDN when related proxy config has registered. This avoids IMDN message to be challenged, and to cause 403 because of multiple transaction being authenticated at a time.
parent b4a783ff
......@@ -112,14 +112,24 @@ void Imdn::onGlobalStateChanged (LinphoneGlobalState state) {
}
}
void Imdn::onRegistrationStateChanged(LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message){
if (state == LinphoneRegistrationOk && cfg == getRelatedProxyConfig()){
// When we are registered to the proxy, then send pending notification if any.
sentImdnMessages.clear();
send();
}
}
void Imdn::onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) {
if (sipNetworkReachable) {
// When the SIP network gets up, retry notification
if (sipNetworkReachable && getRelatedProxyConfig() == nullptr) {
// When the SIP network gets up and this chatroom isn't related to any proxy configuration, retry notification
sentImdnMessages.clear();
send();
}
}
// -----------------------------------------------------------------------------
string Imdn::createXml (const string &id, time_t timestamp, Imdn::Type imdnType, LinphoneReason reason) {
......@@ -226,8 +236,21 @@ bool Imdn::aggregationEnabled () const {
return (chatRoom->canHandleCpim() && linphone_config_get_bool(config, "misc", "aggregate_imdn", TRUE));
}
LinphoneProxyConfig * Imdn::getRelatedProxyConfig(){
LinphoneAddress *addr = linphone_address_new(chatRoom->getLocalAddress().asString().c_str());
LinphoneProxyConfig *cfg = linphone_core_lookup_proxy_by_identity(chatRoom->getCore()->getCCore(), addr);
linphone_address_unref(addr);
return cfg;
}
void Imdn::send () {
try {
LinphoneProxyConfig *cfg = getRelatedProxyConfig();
if (cfg && linphone_proxy_config_get_state(cfg) != LinphoneRegistrationOk){
lInfo() << "Proxy config not registered, will wait to send pending IMDNs";
return;
}
if (!linphone_core_is_network_reachable(chatRoom->getCore()->getCCore()))
return;
} catch (const bad_weak_ptr &) {
......
......@@ -66,7 +66,7 @@ public:
// CoreListener
void onGlobalStateChanged (LinphoneGlobalState state) override;
void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override;
void onRegistrationStateChanged(LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const std::string &message) override;
bool aggregationEnabled () const;
static std::string createXml (const std::string &id, time_t time, Imdn::Type imdnType, LinphoneReason reason);
......@@ -74,6 +74,7 @@ public:
static bool isError (const std::shared_ptr<ChatMessage> &chatMessage);
private:
LinphoneProxyConfig *getRelatedProxyConfig();
static int timerExpired (void *data, unsigned int revents);
void send ();
......
......@@ -977,6 +977,36 @@ static void early_cancelled_call(void) {
linphone_core_manager_destroy(pauline);
}
static void call_called_without_any_response(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new2( "pauline_rc",FALSE);
LinphoneCall* out_call = linphone_core_invite_address(pauline->lc,marie->identity);
/* we don't schedule marie, because we want NO response at all.*/
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallOutgoingInit,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallOutgoingProgress,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallOutgoingProgress,1));
/* Wait a bit. */
BC_ASSERT_TRUE(wait_for_until(pauline->lc,NULL,NULL,0,2000));
/* Cancel the call. */
linphone_call_terminate(out_call);
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneCallEnd,1));
/* Now schedule marie. */
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallIncomingReceived,1));
/* The call should end shortly because the proxy will cancel it*/
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallReleased,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallReleased,1));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void cancelled_ringing_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
......@@ -5204,6 +5234,7 @@ test_t call_tests[] = {
TEST_NO_TAG("Call declined with error", call_declined_with_error),
TEST_NO_TAG("Call declined with retry after", call_declined_with_retry_after),
TEST_NO_TAG("Cancelled call", cancelled_call),
TEST_NO_TAG("Call cancelled without response", call_called_without_any_response),
TEST_NO_TAG("Early cancelled call", early_cancelled_call),
TEST_NO_TAG("Call with DNS timeout", call_with_dns_time_out),
TEST_NO_TAG("Cancelled ringing call", cancelled_ringing_call),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment