multi accounts in progress..

This commit is contained in:
Gautier Pelloux-Prayer 2015-09-08 16:01:05 +02:00
parent 0d0c0cd99e
commit f43bed58e6
10 changed files with 264 additions and 168 deletions

View file

@ -491,7 +491,7 @@
<color key="backgroundColor" red="0.88235294119999996" green="0.88235294119999996" blue="0.88235294119999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" label="Domain "/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" secureTextEntry="YES"/>
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
<connections>
<outlet property="delegate" destination="-1" id="AEK-wy-Dko"/>
</connections>
@ -618,7 +618,7 @@
<color key="backgroundColor" red="0.88235294119999996" green="0.88235294119999996" blue="0.88235294119999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<accessibility key="accessibilityConfiguration" label="Domain "/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" secureTextEntry="YES"/>
<textInputTraits key="textInputTraits" autocorrectionType="no"/>
<connections>
<outlet property="delegate" destination="-1" id="6Mx-mR-LQx"/>
</connections>

View file

@ -122,6 +122,19 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
// root section
{
const MSList *accounts = linphone_core_get_proxy_config_list([LinphoneManager getLc]);
int count = ms_list_size(accounts);
for (int i = 1; i <= count; i++, accounts = accounts->next) {
NSString *key = [NSString stringWithFormat:@"account_%d_menu", i];
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)accounts->data;
[self setCString:linphone_address_get_username(linphone_proxy_config_get_identity_address(proxy))
forKey:key];
}
}
// account section
{
// todo
/*
LinphoneProxyConfig *cfg = NULL;
linphone_core_get_default_proxy(lc, &cfg);
if (cfg) {
@ -191,6 +204,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
[self setCString:linphone_auth_info_get_ha1(ai) forKey:@"ha1_preference"];
}
[self setBool:[lm lpConfigBoolForKey:@"advanced_account_preference"] forKey:@"advanced_account_preference"];
*/
}
// audio section

View file

@ -622,10 +622,20 @@
}
completion:^(BOOL finished) {
_sideMenuView.hidden = hidden;
if (hidden) {
[self.sideMenuViewController viewWillDisappear:animated];
} else {
[self.sideMenuViewController viewWillAppear:animated];
}
}];
} else {
_sideMenuView.frame = d;
_sideMenuView.hidden = hidden;
if (hidden) {
[self.sideMenuViewController viewWillDisappear:animated];
} else {
[self.sideMenuViewController viewWillAppear:animated];
}
}
}

View file

@ -23,7 +23,8 @@
#import "IASKAppSettingsViewController.h"
#import "LinphoneCoreSettingsStore.h"
@interface SettingsViewController: UIViewController<IASKSettingsDelegate, UICompositeViewDelegate, UIAlertViewDelegate, MFMailComposeViewControllerDelegate> {
@interface SettingsViewController
: UIViewController <IASKSettingsDelegate, UICompositeViewDelegate, MFMailComposeViewControllerDelegate> {
@private
LinphoneCoreSettingsStore* settingsStore;
}

View file

@ -539,6 +539,20 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
if ([specifier.key hasPrefix:@"account_"] && [specifier.key hasSuffix:@"_menu"]) {
const MSList *accounts = linphone_core_get_proxy_config_list([LinphoneManager getLc]);
int index = [[specifier.key substringFromIndex:@"account_".length] stringByReplacingOccurrencesOfString:@"_menu"
withString:@""]
.intValue -
1;
if (index < ms_list_size(accounts)) {
LinphoneProxyConfig *proxy = (LinphoneProxyConfig *)ms_list_nth_data(accounts, index);
NSString *name = [NSString
stringWithUTF8String:linphone_address_get_username(linphone_proxy_config_get_identity_address(proxy))];
[specifier.specifierDict setValue:name forKey:kIASKTitle];
}
}
return specifier;
}
@ -546,6 +560,11 @@ static UICompositeViewDescription *compositeDescription = nil;
LinphoneManager *lm = [LinphoneManager instance];
NSMutableSet *hiddenKeys = [NSMutableSet set];
const MSList *accounts = linphone_core_get_proxy_config_list([LinphoneManager getLc]);
for (int i = ms_list_size(accounts) + 1; i <= 5; i++) {
[hiddenKeys addObject:[NSString stringWithFormat:@"account_%d_menu", i]];
}
if (!linphone_core_sip_transport_supported([LinphoneManager getLc], LinphoneTransportTls)) {
[hiddenKeys addObject:@"media_encryption_preference"];
}
@ -657,15 +676,6 @@ static UICompositeViewDescription *compositeDescription = nil;
return hiddenKeys;
}
- (void)goToWizard {
WizardViewController *controller =
DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[WizardViewController compositeViewDescription]],
WizardViewController);
if (controller != nil) {
[controller reset];
}
}
#pragma mark - IASKSettingsDelegate Functions
- (void)settingsViewControllerDidEnd:(IASKAppSettingsViewController *)sender {
@ -692,20 +702,8 @@ static UICompositeViewDescription *compositeDescription = nil;
}
#endif
if ([key isEqual:@"wizard_button"]) {
if (linphone_core_get_default_proxy_config(lc) == NULL) {
[self goToWizard];
return;
}
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"Warning", nil)
message:
NSLocalizedString(
@"Launching the Wizard will delete any existing proxy config.\nAre you sure to want it?",
nil)
delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", nil)
otherButtonTitles:NSLocalizedString(@"Launch Wizard", nil), nil];
[alert show];
[PhoneMainView.instance changeCurrentView:WizardViewController.compositeViewDescription];
return;
} else if ([key isEqual:@"clear_proxy_button"]) {
if (linphone_core_get_default_proxy_config(lc) == NULL) {
return;
@ -759,15 +757,6 @@ static UICompositeViewDescription *compositeDescription = nil;
}
}
#pragma mark - UIAlertView delegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex != 1)
return; /* cancel */
else
[self goToWizard];
}
#pragma mark - Mail composer for send log
- (void)emailAttachment:(NSData *)attachment mimeType:(NSString *)type name:(NSString *)attachmentName {
if (attachmentName == nil || type == nil || attachmentName == nil) {

View file

@ -58,17 +58,29 @@
#pragma mark - Table View Controller
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
return ms_list_size(linphone_core_get_proxy_config_list([LinphoneManager getLc])) > 1 ? 2 : 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_sideMenuEntries count];
if (section == 0) {
// default account is shown in the header already
return ms_list_size(linphone_core_get_proxy_config_list([LinphoneManager getLc])) - 1;
} else {
return [_sideMenuEntries count];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
SideMenuEntry *entry = [_sideMenuEntries objectAtIndex:indexPath.row];
UITableViewCell *cell = [[UITableViewCell alloc] init];
cell.textLabel.text = entry->title;
if (indexPath.section == 0) {
LinphoneProxyConfig *proxy =
ms_list_nth_data(linphone_core_get_proxy_config_list([LinphoneManager getLc]), (int)indexPath.row);
cell.textLabel.text = [NSString
stringWithUTF8String:linphone_address_get_username(linphone_proxy_config_get_identity_address(proxy))];
} else {
SideMenuEntry *entry = [_sideMenuEntries objectAtIndex:indexPath.row];
cell.textLabel.text = entry->title;
}
return cell;
}

View file

@ -32,6 +32,7 @@
- (void)viewWillAppear:(BOOL)animated {
[self updateHeader];
[_sideMenuTableViewController.tableView reloadData];
}
- (IBAction)onLateralSwipe:(id)sender {

View file

@ -377,7 +377,6 @@ static UICompositeViewDescription *compositeDescription = nil;
LinphoneManager *lm = [LinphoneManager instance];
[lm configurePushTokenForProxyConfig:proxyCfg];
[lm removeAllAccounts];
linphone_proxy_config_enable_register(proxyCfg, true);
linphone_core_add_auth_info(lc, info);
@ -477,7 +476,14 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark -
- (void)registrationUpdate:(LinphoneRegistrationState)state message:(NSString *)message {
- (void)registrationUpdate:(LinphoneRegistrationState)state
forProxy:(LinphoneProxyConfig *)proxy
message:(NSString *)message {
// in wizard we only care about ourself
if (proxy != linphone_core_get_default_proxy_config([LinphoneManager getLc])) {
return;
}
switch (state) {
case LinphoneRegistrationOk: {
_waitView.hidden = true;
@ -523,6 +529,8 @@ static UICompositeViewDescription *compositeDescription = nil;
linphone_core_enable_video_preview([LinphoneManager getLc], FALSE);
[[LinphoneManager instance] resetLinphoneCore];
linphone_core_enable_video_preview([LinphoneManager getLc], hasPreview);
// we will set the new default proxy config in the wizard
linphone_core_set_default_proxy_config([LinphoneManager getLc], NULL);
}
#pragma mark - UITextFieldDelegate Functions
@ -864,7 +872,9 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)registrationUpdateEvent:(NSNotification *)notif {
NSString *message = [notif.userInfo objectForKey:@"message"];
[self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue] message:message];
[self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue]
forProxy:[[notif.userInfo objectForKeyedSubscript:@"cfg"] pointerValue]
message:message];
}
#pragma mark - XMLRPCConnectionDelegate Functions

View file

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Key</key>
<string>clear_proxy_button</string>
<key>Title</key>
<string>Clear Account</string>
<key>Type</key>
<string>IASKButtonSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>username_preference</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>Title</key>
<string>User name</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>userid_preference</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>Title</key>
<string>User ID</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<true/>
<key>Key</key>
<string>password_preference</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>Title</key>
<string>Password</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>domain_preference</string>
<key>KeyboardType</key>
<string>URL</string>
<key>Title</key>
<string>Domain</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>proxy_preference</string>
<key>KeyboardType</key>
<string>URL</string>
<key>Title</key>
<string>Proxy</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<string>udp</string>
<key>Key</key>
<string>transport_preference</string>
<key>Title</key>
<string>Transport</string>
<key>Titles</key>
<array>
<string>UDP</string>
<string>TCP</string>
<string>TLS</string>
</array>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Values</key>
<array>
<string>udp</string>
<string>tcp</string>
<string>tls</string>
</array>
</dict>
<dict>
<key>Title</key>
<string>Outbound proxy</string>
<key>DefaultValue</key>
<false/>
<key>Key</key>
<string>outbound_proxy_preference</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>Title</key>
<string>AVPF</string>
<key>DefaultValue</key>
<true/>
<key>Key</key>
<string>avpf_preference</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>More options</string>
<key>Key</key>
<string>advanced_account_preference</string>
<key>DefaultValue</key>
<false/>
</dict>
</array>
</dict>
</plist>

View file

@ -6,7 +6,7 @@
<array>
<dict>
<key>Title</key>
<string>SIP account</string>
<string>SIP accounts</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
@ -20,153 +20,53 @@
</dict>
<dict>
<key>Key</key>
<string>clear_proxy_button</string>
<string>account_1_menu</string>
<key>File</key>
<string>Account</string>
<key>Title</key>
<string>Clear Account</string>
<string>Account 1</string>
<key>Type</key>
<string>IASKButtonSpecifier</string>
<string>PSChildPaneSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>username_preference</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<string>account_2_menu</string>
<key>File</key>
<string>Account</string>
<key>Title</key>
<string>User name</string>
<string>Account 2</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<string>PSChildPaneSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>userid_preference</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<string>account_3_menu</string>
<key>File</key>
<string>Account</string>
<key>Title</key>
<string>User ID</string>
<string>Account 3</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<string>PSChildPaneSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<true/>
<key>Key</key>
<string>password_preference</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<string>account_4_menu</string>
<key>File</key>
<string>Account</string>
<key>Title</key>
<string>Password</string>
<string>Account 4</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
<string>PSChildPaneSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>domain_preference</string>
<key>KeyboardType</key>
<string>URL</string>
<string>account_5_menu</string>
<key>File</key>
<string>Account</string>
<key>Title</key>
<string>Domain</string>
<string>Account 5</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>proxy_preference</string>
<key>KeyboardType</key>
<string>URL</string>
<key>Title</key>
<string>Proxy</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<string>udp</string>
<key>Key</key>
<string>transport_preference</string>
<key>Title</key>
<string>Transport</string>
<key>Titles</key>
<array>
<string>UDP</string>
<string>TCP</string>
<string>TLS</string>
</array>
<key>Type</key>
<string>PSMultiValueSpecifier</string>
<key>Values</key>
<array>
<string>udp</string>
<string>tcp</string>
<string>tls</string>
</array>
</dict>
<dict>
<key>Title</key>
<string>Outbound proxy</string>
<key>DefaultValue</key>
<false/>
<key>Key</key>
<string>outbound_proxy_preference</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>Title</key>
<string>AVPF</string>
<key>DefaultValue</key>
<true/>
<key>Key</key>
<string>avpf_preference</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
<key>Title</key>
<string>More options</string>
<key>Key</key>
<string>advanced_account_preference</string>
<key>DefaultValue</key>
<false/>
<string>PSChildPaneSpecifier</string>
</dict>
<dict>
<key>Title</key>