mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 06:08:07 +00:00
Fix contacts migration from rc to db
This commit is contained in:
parent
0feee4b5bb
commit
b88693f4f4
3 changed files with 21 additions and 4 deletions
|
|
@ -1366,6 +1366,13 @@ void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ms_list_size(linphone_friend_list_get_friends(lfl)) > 0) {
|
||||
linphone_core_remove_friend_list(lc, lfl);
|
||||
lfl = linphone_core_create_friend_list(lc);
|
||||
linphone_core_add_friend_list(lc, lfl);
|
||||
linphone_friend_list_unref(lfl);
|
||||
}
|
||||
|
||||
for (i = 0; (lf = linphone_friend_new_from_config_file(lc, i)) != NULL; i++) {
|
||||
char friend_section[32];
|
||||
|
||||
|
|
|
|||
|
|
@ -445,7 +445,9 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie
|
|||
if (elem == NULL) return LinphoneFriendListNonExistentFriend;
|
||||
|
||||
#ifdef FRIENDS_SQL_STORAGE_ENABLED
|
||||
linphone_core_remove_friend_from_db(lf->lc, lf);
|
||||
if (lf && lf->lc && lf->lc->friends_db) {
|
||||
linphone_core_remove_friend_from_db(lf->lc, lf);
|
||||
}
|
||||
#endif
|
||||
if (remove_from_server) {
|
||||
LinphoneVcard *lvc = linphone_friend_get_vcard(lf);
|
||||
|
|
|
|||
|
|
@ -155,18 +155,22 @@ static void friends_if_no_db_set(void) {
|
|||
#ifdef FRIENDS_SQL_STORAGE_ENABLED
|
||||
static void friends_migration(void) {
|
||||
LinphoneCoreManager* manager = linphone_core_manager_new2("friends_rc", FALSE);
|
||||
LpConfig *lpc = linphone_core_get_config(manager->lc);
|
||||
LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc);
|
||||
const MSList *friends = linphone_friend_list_get_friends(lfl);
|
||||
MSList *friends_from_db = NULL;
|
||||
char *friends_db = create_filepath(bc_tester_get_writable_dir_prefix(), "friends", "db");
|
||||
BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d");
|
||||
BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d");
|
||||
BC_ASSERT_EQUAL(lp_config_get_int(lpc, "misc", "friends_migration_done", 0), 0, int, "%i");
|
||||
|
||||
unlink(friends_db);
|
||||
linphone_core_set_friends_database_path(manager->lc, friends_db);
|
||||
lfl = linphone_core_get_default_friend_list(manager->lc);
|
||||
friends = linphone_friend_list_get_friends(lfl);
|
||||
BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d");
|
||||
friends_from_db = linphone_core_fetch_friends_from_db(manager->lc, lfl);
|
||||
BC_ASSERT_EQUAL(ms_list_size(friends_from_db), 3, int, "%d");
|
||||
BC_ASSERT_EQUAL(lp_config_get_int(lpc, "misc", "friends_migration_done", 0), 1, int, "%i");
|
||||
|
||||
friends_from_db = ms_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref);
|
||||
unlink(friends_db);
|
||||
|
|
@ -181,12 +185,16 @@ typedef struct _LinphoneFriendListStats {
|
|||
|
||||
static void friend_list_created_cb(LinphoneCore *lc, LinphoneFriendList *list) {
|
||||
LinphoneFriendListStats *stats = (LinphoneFriendListStats *)linphone_friend_list_get_user_data(list);
|
||||
stats->new_list_count++;
|
||||
if (stats) {
|
||||
stats->new_list_count++;
|
||||
}
|
||||
}
|
||||
|
||||
static void friend_list_removed_cb(LinphoneCore *lc, LinphoneFriendList *list) {
|
||||
LinphoneFriendListStats *stats = (LinphoneFriendListStats *)linphone_friend_list_get_user_data(list);
|
||||
stats->removed_list_count++;
|
||||
if (stats) {
|
||||
stats->removed_list_count++;
|
||||
}
|
||||
}
|
||||
|
||||
static void friends_sqlite_storage(void) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue