SettingsView
settingsStore 는 LinphoneCoreSettingsStore 를 복제한다
[settingsStore removeAccount];
[self recomputeAccountLabelsAndSync];
[self recomputeAccountLabelsAndSync];
[_settingsController.navigationController popViewControllerAnimated:NO];
- (void)viewDidLoad {
[super viewDidLoad];
settingsStore = [[LinphoneCoreSettingsStore alloc] init];
_settingsController.showDoneButton = FALSE;
_settingsController.delegate = self;
_settingsController.showCreditsFooter = FALSE;
_settingsController.settingsStore = settingsStore;//settingsStore 는 LinphoneCoreSettingsStore 를 복제한다
[_navigationController.view setBackgroundColor:[UIColor clearColor]];
_navigationController.view.frame = self.subView.frame;
[_navigationController pushViewController:_settingsController animated:FALSE];
[self.view addSubview:_navigationController.view];
}
[settingsStore removeAccount];
[self recomputeAccountLabelsAndSync];
[self recomputeAccountLabelsAndSync];
[_settingsController.navigationController popViewControllerAnimated:NO];
LinphoneCoreSettingsStore.m
- (void)removeAccount {
LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
[self integerForKey:@"current_proxy_config_preference"]);
const MSList *lists = linphone_core_get_friends_lists(LC);
while (lists) {
linphone_friend_list_enable_subscriptions(lists->data, FALSE);
linphone_friend_list_update_subscriptions(lists->data);
lists = lists->next;
}
BOOL isDefault = (linphone_core_get_default_account(LC) == account);
const LinphoneAuthInfo *ai = linphone_account_find_auth_info(account);
linphone_core_remove_account(LC, account);
if (ai) {
// Friend list unsubscription above is not instantanous, so give a bit of a time margin before finishing the removal of the auth info
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
linphone_core_remove_auth_info(LC, ai);
});
}
[self setInteger:-1 forKey:@"current_proxy_config_preference"];
if (isDefault) {
// if we removed the default proxy config, set another one instead
if (linphone_core_get_account_list(LC) != NULL) {
linphone_core_set_default_account(LC, (LinphoneAccount *)(linphone_core_get_account_list(LC)->data));
}
}
[self transformLinphoneCoreToKeys];
}