Commit f5f80c92 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Few fixes for when using friends without the database storage

parent f3e7ce47
...@@ -601,8 +601,13 @@ void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig * ...@@ -601,8 +601,13 @@ void linphone_friend_update_subscribes(LinphoneFriend *fr, LinphoneProxyConfig *
} }
void linphone_friend_save(LinphoneFriend *fr, LinphoneCore *lc) { void linphone_friend_save(LinphoneFriend *fr, LinphoneCore *lc) {
if (!lc) return;
#ifdef FRIENDS_SQL_STORAGE_ENABLED #ifdef FRIENDS_SQL_STORAGE_ENABLED
linphone_core_store_friend_in_db(lc, fr); if (lc->friends_db_file) {
linphone_core_store_friend_in_db(lc, fr);
} else {
linphone_core_write_friends_config(lc);
}
#else #else
linphone_core_write_friends_config(lc); linphone_core_write_friends_config(lc);
#endif #endif
...@@ -690,7 +695,6 @@ void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf) { ...@@ -690,7 +695,6 @@ void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf) {
} }
if (linphone_core_ready(lc)) linphone_friend_apply(lf, lc); if (linphone_core_ready(lc)) linphone_friend_apply(lf, lc);
else lf->commit = TRUE; else lf->commit = TRUE;
linphone_friend_save(lf, lc);
} }
void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *lf) { void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *lf) {
......
...@@ -431,9 +431,7 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList * ...@@ -431,9 +431,7 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *
if (synchronize) { if (synchronize) {
list->dirty_friends_to_update = ms_list_append(list->dirty_friends_to_update, linphone_friend_ref(lf)); list->dirty_friends_to_update = ms_list_append(list->dirty_friends_to_update, linphone_friend_ref(lf));
} }
#ifdef FRIENDS_SQL_STORAGE_ENABLED linphone_friend_save(lf, lf->lc);
linphone_core_store_friend_in_db(lf->lc, lf);
#endif
return LinphoneFriendListOK; return LinphoneFriendListOK;
} }
...@@ -466,6 +464,9 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie ...@@ -466,6 +464,9 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
} }
} }
} }
if (!list->lc->friends_db_file) {
linphone_core_write_friends_config(list->lc);
}
lf->friend_list = NULL; lf->friend_list = NULL;
linphone_friend_unref(lf); linphone_friend_unref(lf);
...@@ -785,9 +786,6 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis ...@@ -785,9 +786,6 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis
} }
vcards = ms_list_next(vcards); vcards = ms_list_next(vcards);
} }
#ifndef FRIENDS_SQL_STORAGE_ENABLED
linphone_core_write_friends_config(list->lc);
#endif
return count; return count;
} }
...@@ -821,9 +819,6 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l ...@@ -821,9 +819,6 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l
} }
vcards = ms_list_next(vcards); vcards = ms_list_next(vcards);
} }
#ifndef FRIENDS_SQL_STORAGE_ENABLED
linphone_core_write_friends_config(list->lc);
#endif
return count; return count;
} }
......
...@@ -519,6 +519,13 @@ LINPHONE_PUBLIC void linphone_core_set_friends_database_path(LinphoneCore *lc, c ...@@ -519,6 +519,13 @@ LINPHONE_PUBLIC void linphone_core_set_friends_database_path(LinphoneCore *lc, c
**/ **/
LINPHONE_PUBLIC void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc);
/**
* Saves a friend either in database if configured, otherwise in linphonerc
* @param fr the linphone friend to save
* @param lc the linphone core
*/
void linphone_friend_save(LinphoneFriend *fr, LinphoneCore *lc);
/** /**
* @} * @}
*/ */
......
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