diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 6f3e2215a..057e27388 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1295,9 +1295,7 @@ static void ui_config_read(LinphoneCore *lc) linphone_friend_unref(lf); } -#ifndef CALL_LOGS_STORAGE_ENABLED call_logs_read_from_config_file(lc); -#endif } /* @@ -4948,20 +4946,27 @@ void linphone_core_set_call_logs_database_path(LinphoneCore *lc, const char *pat const MSList* linphone_core_get_call_logs(LinphoneCore *lc) { #ifdef CALL_LOGS_STORAGE_ENABLED - linphone_core_get_call_history(lc); + if (lc->logs_db) { + linphone_core_get_call_history(lc); + } #endif return lc->call_logs; } void linphone_core_clear_call_logs(LinphoneCore *lc) { + bool_t call_logs_sqlite_db_found = FALSE; lc->missed_calls=0; #ifdef CALL_LOGS_STORAGE_ENABLED - linphone_core_delete_call_history(lc); -#else - ms_list_for_each(lc->call_logs, (void (*)(void*))linphone_call_log_unref); - lc->call_logs = ms_list_free(lc->call_logs); - call_logs_write_to_config_file(lc); + if (lc->logs_db) { + call_logs_sqlite_db_found = TRUE; + linphone_core_delete_call_history(lc); + } #endif + if (!call_logs_sqlite_db_found) { + ms_list_for_each(lc->call_logs, (void (*)(void*))linphone_call_log_unref); + lc->call_logs = ms_list_free(lc->call_logs); + call_logs_write_to_config_file(lc); + } } int linphone_core_get_missed_calls_count(LinphoneCore *lc) { @@ -4973,13 +4978,18 @@ void linphone_core_reset_missed_calls_count(LinphoneCore *lc) { } void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl) { + bool_t call_logs_sqlite_db_found = FALSE; #ifdef CALL_LOGS_STORAGE_ENABLED - linphone_core_delete_call_log(lc, cl); -#else - lc->call_logs = ms_list_remove(lc->call_logs, cl); - call_logs_write_to_config_file(lc); - linphone_call_log_unref(cl); + if (lc->logs_db) { + call_logs_sqlite_db_found = TRUE; + linphone_core_delete_call_log(lc, cl); + } #endif + if (!call_logs_sqlite_db_found) { + lc->call_logs = ms_list_remove(lc->call_logs, cl); + call_logs_write_to_config_file(lc); + linphone_call_log_unref(cl); + } } void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { diff --git a/tester/call_tester.c b/tester/call_tester.c index ce7d9a4ac..dd61b5eba 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -4950,13 +4950,24 @@ static void call_with_network_switch_and_ice(void){ #ifdef CALL_LOGS_STORAGE_ENABLED +static void call_logs_if_no_db_set() { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new("laure_call_logs_rc"); + BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 10); + + BC_ASSERT_TRUE(call(marie, laure)); + wait_for_until(marie->lc, laure->lc, NULL, 5, 1000); + end_call(marie, laure); + + BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 11); +} + static void call_logs_migrate() { LinphoneCoreManager* laure = linphone_core_manager_new("laure_call_logs_rc"); char *logs_db = create_filepath(bc_tester_get_writable_dir_prefix(), "call_logs", "db"); int i = 0; int incoming_count = 0, outgoing_count = 0, missed_count = 0, aborted_count = 0, decline_count = 0, video_enabled_count = 0; - call_logs_read_from_config_file(laure->lc); BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 10); linphone_core_set_call_logs_database_path(laure->lc, logs_db); @@ -5181,6 +5192,7 @@ test_t call_tests[] = { { "Call with generic NACK RTCP feedback", call_with_generic_nack_rtcp_feedback }, { "Call with complex late offering", call_with_complex_late_offering }, #ifdef CALL_LOGS_STORAGE_ENABLED + { "Call log working if no db set", call_logs_if_no_db_set }, { "Call log storage migration from rc to db", call_logs_migrate }, { "Call log storage in sqlite database", call_logs_sqlite_storage }, #endif diff --git a/tester/rcfiles/laure_call_logs_rc b/tester/rcfiles/laure_call_logs_rc index c1ad0f492..268707287 100644 --- a/tester/rcfiles/laure_call_logs_rc +++ b/tester/rcfiles/laure_call_logs_rc @@ -1,3 +1,49 @@ +[sip] +sip_port=5092 +sip_tcp_port=5092 +sip_tls_port=5093 +default_proxy=0 +ping_with_options=0 +register_only_when_network_is_up=0 + +[auth_info_0] +username=laure +userid=laure +passwd=secret +realm="sip.example.org" + + +[proxy_0] +reg_proxy=sip.example.org +reg_identity=sip:laure@sip.example.org +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + + +[rtp] +audio_rtp_port=9010-9390 +video_rtp_port=9410-9910 + +[video] +display=0 +capture=0 +show_local=0 +size=qcif +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general +stun_server=stun.linphone.org + [call_log_0] dir=0 status=0