forked from mirrors/linphone-iphone
Do not display accounts that have the “hidden” custom parameters enabled
This commit is contained in:
parent
a77d6bb1b6
commit
5dda082a75
9 changed files with 96 additions and 32 deletions
|
|
@ -127,7 +127,9 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
if (!mustRestoreView) {
|
||||
new_account = NULL;
|
||||
number_of_accounts_before = bctbx_list_size(linphone_core_get_account_list(LC));
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
number_of_accounts_before = bctbx_list_size(accounts);
|
||||
bctbx_free(accounts);
|
||||
[self resetTextFields];
|
||||
[self changeView:_welcomeView back:FALSE animation:FALSE];
|
||||
}
|
||||
|
|
@ -1011,10 +1013,13 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[LinphoneManager.instance lpConfigSetInt:[NSDate new].timeIntervalSince1970
|
||||
forKey:@"must_link_account_time"];
|
||||
[LinphoneManager.instance configurePushProviderForAccounts];
|
||||
if (number_of_accounts_before < bctbx_list_size(linphone_core_get_account_list(LC))) {
|
||||
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
if (number_of_accounts_before < bctbx_list_size(accounts)) {
|
||||
LOGI(@"A proxy config was set up with the remote provisioning, skip assistant");
|
||||
[self onDialerClick:nil];
|
||||
}
|
||||
bctbx_free(accounts);
|
||||
|
||||
_waitView.hidden = true;
|
||||
if (nextView == nil) {
|
||||
|
|
|
|||
|
|
@ -69,14 +69,15 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
object:nil];
|
||||
|
||||
// Update on show
|
||||
const MSList *list = linphone_core_get_account_list([LinphoneManager getLc]);
|
||||
MSList *list = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
if (list != NULL) {
|
||||
LinphoneAccount *account = (LinphoneAccount *)list->data;
|
||||
if (account) {
|
||||
[self registrationUpdate:linphone_account_get_state(account)];
|
||||
}
|
||||
}
|
||||
|
||||
bctbx_list_free(list);
|
||||
|
||||
if (account_creator) {
|
||||
linphone_account_creator_unref(account_creator);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,9 @@
|
|||
}
|
||||
|
||||
- (void)transformAccountToKeys:(NSString *)username {
|
||||
const MSList *accountList = linphone_core_get_account_list(LC);
|
||||
//const MSList *accountList = linphone_core_get_account_list(LC);
|
||||
MSList *accountListToBeFreed = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
MSList *accountList = accountListToBeFreed;
|
||||
while (username && accountList &&
|
||||
strcmp(username.UTF8String,
|
||||
linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(accountList->data)))) != 0) {
|
||||
|
|
@ -234,9 +236,11 @@
|
|||
[self setCString:linphone_auth_info_get_algorithm(ai) forKey:@"ha1_algo_preference"];
|
||||
}
|
||||
|
||||
MSList *accountsList = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
int idx = (int)bctbx_list_index(linphone_core_get_account_list(LC), account);
|
||||
[self setInteger:idx forKey:@"current_proxy_config_preference"];
|
||||
|
||||
bctbx_list_free(accountsList);
|
||||
|
||||
int expires = linphone_account_params_get_expires(accountParams);
|
||||
[self setInteger:expires forKey:@"account_expire_preference"];
|
||||
|
||||
|
|
@ -255,6 +259,7 @@
|
|||
[self setBool:dial_escape_plus forKey:@"account_substitute_+_by_00_preference"];
|
||||
}
|
||||
}
|
||||
bctbx_list_free(accountListToBeFreed);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -343,15 +348,17 @@
|
|||
|
||||
// root section
|
||||
{
|
||||
const bctbx_list_t *accounts = linphone_core_get_account_list(LC);
|
||||
size_t count = bctbx_list_size(accounts);
|
||||
for (size_t i = 1; i <= count; i++, accounts = accounts->next) {
|
||||
MSList *accountsListToBeFreed = [lm createAccountsNotHiddenList];
|
||||
MSList *accountsList = accountsListToBeFreed;
|
||||
size_t count = bctbx_list_size(accountsList);
|
||||
for (size_t i = 1; i <= count; i++, accountsList = accountsList->next) {
|
||||
NSString *key = [NSString stringWithFormat:@"menu_account_%lu", i];
|
||||
LinphoneAccount *account = (LinphoneAccount *)accounts->data;
|
||||
LinphoneAccount *account = (LinphoneAccount *)accountsList->data;
|
||||
[self setCString:linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(account)))
|
||||
forKey:key];
|
||||
}
|
||||
|
||||
bctbx_free(accountsListToBeFreed);
|
||||
|
||||
[self setBool:linphone_core_video_display_enabled(LC) forKey:@"enable_video_preference"];
|
||||
[self setBool:[LinphoneManager.instance lpConfigBoolForKey:@"auto_answer"]
|
||||
forKey:@"enable_auto_answer_preference"];
|
||||
|
|
@ -625,9 +632,11 @@
|
|||
|
||||
linphone_address_set_transport(proxy_addr, type);
|
||||
}
|
||||
|
||||
account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
|
||||
|
||||
MSList *accountList= [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
account = bctbx_list_nth_data(accountList,
|
||||
[self integerForKey:@"current_proxy_config_preference"]);
|
||||
bctbx_free(accountList);
|
||||
|
||||
// if account was deleted, it is not present anymore
|
||||
if (account == NULL)
|
||||
|
|
@ -1094,7 +1103,9 @@
|
|||
NSString *rls_uri = [lm lpConfigStringForKey:@"rls_uri" inSection:@"sip" withDefault:@"sips:rls@sip.linphone.org"];
|
||||
LinphoneAddress *rls_addr = linphone_address_new(rls_uri.UTF8String);
|
||||
const char *rls_domain = linphone_address_get_domain(rls_addr);
|
||||
const MSList *accounts = linphone_core_get_account_list(LC);
|
||||
|
||||
MSList *accountListToBeFreed = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
const MSList *accounts = accountListToBeFreed;
|
||||
if (!accounts) // Enable it if no proxy config for first launch of app
|
||||
[self setInteger:1 forKey:@"use_rls_presence"];
|
||||
else {
|
||||
|
|
@ -1108,6 +1119,7 @@
|
|||
}
|
||||
}
|
||||
linphone_address_unref(rls_addr);
|
||||
bctbx_free(accountListToBeFreed);
|
||||
}
|
||||
|
||||
[lm lpConfigSetInt:[self integerForKey:@"use_rls_presence"] forKey:@"use_rls_presence"];
|
||||
|
|
@ -1149,9 +1161,12 @@
|
|||
}
|
||||
|
||||
- (void)removeAccount {
|
||||
LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
|
||||
|
||||
MSList *accountList = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
LinphoneAccount *account = bctbx_list_nth_data(accountList,
|
||||
[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);
|
||||
|
|
@ -1172,11 +1187,12 @@
|
|||
|
||||
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));
|
||||
if (accountList != NULL) {
|
||||
linphone_core_set_default_account(LC, (LinphoneAccount *)(accountList->data));
|
||||
}
|
||||
}
|
||||
[self transformLinphoneCoreToKeys];
|
||||
bctbx_free(accountList);
|
||||
}
|
||||
|
||||
- (void)removeLdap {
|
||||
|
|
|
|||
|
|
@ -174,6 +174,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
|
||||
- (void)silentPushFailed:(NSTimer*)timer;
|
||||
|
||||
- (MSList *) createAccountsNotHiddenList; // needs to be unref
|
||||
- (void)removeAllAccounts;
|
||||
|
||||
+ (BOOL)isMyself:(const LinphoneAddress *)addr;
|
||||
|
|
|
|||
|
|
@ -2214,6 +2214,23 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
|
||||
#pragma mark -
|
||||
|
||||
- (MSList *) createAccountsNotHiddenList {
|
||||
MSList *list = NULL;
|
||||
const MSList *accounts = linphone_core_get_account_list(LC);
|
||||
while (accounts) {
|
||||
const char *isHidden = linphone_account_get_custom_param(accounts->data, "hidden");
|
||||
if (isHidden == NULL || strcmp(linphone_account_get_custom_param(accounts->data, "hidden"), "1") != 0) {
|
||||
if (!list) {
|
||||
list = bctbx_list_new(accounts->data);
|
||||
} else {
|
||||
bctbx_list_append(list, accounts->data);
|
||||
}
|
||||
}
|
||||
accounts = accounts->next;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
- (void)removeAllAccounts {
|
||||
linphone_core_clear_accounts(LC);
|
||||
linphone_core_clear_all_auth_info(LC);
|
||||
|
|
|
|||
|
|
@ -193,11 +193,13 @@
|
|||
message = NSLocalizedString(@"Fetching remote configuration", nil);
|
||||
} else if (account == NULL) {
|
||||
state = LinphoneRegistrationNone;
|
||||
if (linphone_core_get_account_list(LC) != NULL) {
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
if (accounts != NULL) {
|
||||
message = NSLocalizedString(@"No default account", nil);
|
||||
} else {
|
||||
message = NSLocalizedString(@"No account configured", nil);
|
||||
}
|
||||
bctbx_free(accounts);
|
||||
|
||||
} else {
|
||||
state = linphone_account_get_state(account);
|
||||
|
|
@ -408,10 +410,15 @@
|
|||
- (IBAction)onRegistrationStateClick:(id)sender {
|
||||
if (linphone_core_get_default_account(LC)) {
|
||||
linphone_core_refresh_registers(LC);
|
||||
} else if (linphone_core_get_account_list(LC)) {
|
||||
[PhoneMainView.instance changeCurrentView:SettingsView.compositeViewDescription];
|
||||
} else {
|
||||
[PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription];
|
||||
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
if (accounts) {
|
||||
[PhoneMainView.instance changeCurrentView:SettingsView.compositeViewDescription];
|
||||
} else {
|
||||
[PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription];
|
||||
}
|
||||
bctbx_free(accounts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -445,8 +445,11 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
|
|||
linphone_account_creator_set_password(creator, _tmpPwd.UTF8String);
|
||||
[settingsStore setObject:_tmpPwd forKey:@"account_mandatory_password_preference"];
|
||||
|
||||
MSList *accountList = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
|
||||
[settingsStore integerForKey:@"current_proxy_config_preference"]);
|
||||
bctbx_free(accountList);
|
||||
|
||||
if (account != NULL) {
|
||||
const LinphoneAuthInfo *auth = linphone_account_find_auth_info(account);
|
||||
if (auth) {
|
||||
|
|
@ -583,7 +586,7 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
|
|||
}
|
||||
|
||||
if ([specifier.key hasPrefix:@"menu_account_"]) {
|
||||
const bctbx_list_t *accounts = linphone_core_get_account_list(LC);
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
int index = [specifier.key substringFromIndex:@"menu_account_".length].intValue - 1;
|
||||
if (index < bctbx_list_size(accounts)) {
|
||||
LinphoneAccount *account = (LinphoneAccount *)bctbx_list_nth_data(accounts, index);
|
||||
|
|
@ -591,6 +594,7 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
|
|||
stringWithUTF8String:linphone_address_get_username(linphone_account_params_get_identity_address(linphone_account_get_params(account)))];
|
||||
[specifier.specifierDict setValue:name forKey:kIASKTitle];
|
||||
}
|
||||
bctbx_free(accounts);
|
||||
}
|
||||
|
||||
if ([specifier.key hasPrefix:@"ldap_"]) {
|
||||
|
|
@ -625,12 +629,12 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
|
|||
- (NSSet *)findHiddenKeys {
|
||||
LinphoneManager *lm = LinphoneManager.instance;
|
||||
NSMutableSet *hiddenKeys = [NSMutableSet set];
|
||||
|
||||
const MSList *accounts = linphone_core_get_account_list(LC);
|
||||
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
for (size_t i = bctbx_list_size(accounts) + 1; i <= 5; i++) {
|
||||
[hiddenKeys addObject:[NSString stringWithFormat:@"menu_account_%lu", i]];
|
||||
}
|
||||
|
||||
bctbx_free(accounts);
|
||||
const MSList *ldaps = linphone_core_get_ldap_list(LC);
|
||||
for (size_t i = bctbx_list_size(ldaps) + 1; i <= 5; i++) {
|
||||
[hiddenKeys addObject:[NSString stringWithFormat:@"ldap_%lu", i]];
|
||||
|
|
@ -901,8 +905,11 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
|
|||
if (pwd && ![pwd isEqualToString:@""]) {
|
||||
if ([pwd isEqualToString:conf_pwd]) {
|
||||
_tmpPwd = pwd;
|
||||
LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
|
||||
[settingsStore integerForKey:@"current_proxy_config_preference"]);
|
||||
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
LinphoneAccount *account = bctbx_list_nth_data(accounts,
|
||||
[settingsStore integerForKey:@"current_proxy_config_preference"]);
|
||||
bctbx_free(accounts);
|
||||
const LinphoneAuthInfo *ai = linphone_account_find_auth_info(account);
|
||||
|
||||
LinphoneAccountCreator *account_creator = linphone_account_creator_new(
|
||||
|
|
|
|||
|
|
@ -66,7 +66,10 @@
|
|||
changeCurrentView:AssistantView.compositeViewDescription];
|
||||
}]];
|
||||
BOOL mustLink = ([LinphoneManager.instance lpConfigIntForKey:@"must_link_account_time"] > 0);
|
||||
BOOL hasAccount = linphone_core_get_account_list(LC) != NULL;
|
||||
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
BOOL hasAccount = accounts != NULL;
|
||||
bctbx_free(accounts);
|
||||
if (mustLink && hasAccount) {
|
||||
[_sideMenuEntries
|
||||
addObject:[[SideMenuEntry alloc] initWithTitle:NSLocalizedString(@"Link my account", nil)
|
||||
|
|
@ -127,9 +130,12 @@
|
|||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if (section == 0) {
|
||||
|
||||
BOOL hasDefault = (linphone_core_get_default_account(LC) != NULL);
|
||||
// default account is shown in the header already
|
||||
size_t count = bctbx_list_size(linphone_core_get_account_list(LC));
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
size_t count = bctbx_list_size(accounts);
|
||||
bctbx_free(accounts);
|
||||
return MAX(0, (int)count - (hasDefault ? 1 : 0));
|
||||
} else {
|
||||
return [_sideMenuEntries count];
|
||||
|
|
@ -142,12 +148,14 @@
|
|||
// isLcInitialized called here because this is called when going in bg after LC destroy
|
||||
if (indexPath.section == 0 && [LinphoneManager isLcInitialized]) {
|
||||
// do not display default account here, it is already in header view
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
int idx =
|
||||
linphone_core_get_default_account(LC)
|
||||
? bctbx_list_index(linphone_core_get_account_list(LC), linphone_core_get_default_account(LC))
|
||||
? bctbx_list_index(accounts, linphone_core_get_default_account(LC))
|
||||
: HUGE_VAL;
|
||||
LinphoneAccount *account = bctbx_list_nth_data(linphone_core_get_account_list(LC),
|
||||
LinphoneAccount *account = bctbx_list_nth_data(accounts,
|
||||
(int)indexPath.row + (idx <= indexPath.row ? 1 : 0));
|
||||
bctbx_free(accounts);
|
||||
if (account) {
|
||||
cell.textLabel.text = [NSString stringWithUTF8String:linphone_account_params_get_identity(linphone_account_get_params(account))];
|
||||
cell.imageView.image = [StatusBarView imageForState:linphone_account_get_state(account)];
|
||||
|
|
|
|||
|
|
@ -70,7 +70,9 @@
|
|||
_addressLabel.text = str ? [NSString stringWithUTF8String:str] : NSLocalizedString(@"No address", nil);
|
||||
if (str) ms_free(str);
|
||||
} else {
|
||||
_nameLabel.text = linphone_core_get_account_list(LC) ? NSLocalizedString(@"No default account", nil) : NSLocalizedString(@"No account", nil);
|
||||
MSList *accounts = [LinphoneManager.instance createAccountsNotHiddenList];
|
||||
_nameLabel.text = accounts ? NSLocalizedString(@"No default account", nil) : NSLocalizedString(@"No account", nil);
|
||||
bctbx_free(accounts);
|
||||
// display direct IP:port address so that we can be reached
|
||||
LinphoneAddress *addr = linphone_core_get_primary_contact_parsed(LC);
|
||||
if (addr) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue