Support email address as username in the wizard.

This commit is contained in:
Ghislain MARY 2013-02-26 14:56:56 +01:00
parent 9a95856642
commit 027b640476

View file

@ -384,11 +384,17 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)addProxyConfig:(NSString*)username password:(NSString*)password domain:(NSString*)domain server:(NSString*)server {
LinphoneCore *lc = [LinphoneManager getLc];
[self clearProxyConfig];
if(server == nil) {
server = domain;
}
const char* identity = [[NSString stringWithFormat:@"sip:%@@%@", username, domain] UTF8String];
char normalizedUserName[256];
LinphoneAddress* linphoneAddress = linphone_address_new(linphone_core_get_identity(lc));
linphone_proxy_config_normalize_number(NULL, [username cStringUsingEncoding:[NSString defaultCStringEncoding]], normalizedUserName, sizeof(normalizedUserName));
linphone_address_set_username(linphoneAddress, normalizedUserName);
linphone_address_set_domain(linphoneAddress, [domain UTF8String]);
const char* identity = linphone_address_as_string_uri_only(linphoneAddress);
LinphoneProxyConfig* proxyCfg = linphone_core_create_proxy_config([LinphoneManager getLc]);
LinphoneAuthInfo* info = linphone_auth_info_new([username UTF8String], NULL, [password UTF8String], NULL, NULL);
linphone_proxy_config_set_identity(proxyCfg, identity);
@ -408,6 +414,17 @@ static UICompositeViewDescription *compositeDescription = nil;
linphone_core_add_auth_info([LinphoneManager getLc], info);
}
- (NSString*)identityFromUsername:(NSString*)username {
char normalizedUserName[256];
LinphoneAddress* linphoneAddress = linphone_address_new(linphone_core_get_identity([LinphoneManager getLc]));
linphone_proxy_config_normalize_number(NULL, [username cStringUsingEncoding:[NSString defaultCStringEncoding]], normalizedUserName, sizeof(normalizedUserName));
linphone_address_set_username(linphoneAddress, normalizedUserName);
linphone_address_set_domain(linphoneAddress, [[[LinphoneManager instance] lpConfigStringForKey:@"domain" forSection:@"wizard"] UTF8String]);
NSString* uri = [NSString stringWithUTF8String:linphone_address_as_string_uri_only(linphoneAddress)];
NSString* scheme = [NSString stringWithUTF8String:linphone_address_get_scheme(linphoneAddress)];
return [uri substringFromIndex:[scheme length] + 1];
}
- (void)checkUserExist:(NSString*)username {
[LinphoneLogger log:LinphoneLoggerLog format:@"XMLRPC check_account %@", username];
@ -521,7 +538,8 @@ static UICompositeViewDescription *compositeDescription = nil;
- (IBAction)onCheckValidationClick:(id)sender {
NSString *username = [WizardViewController findTextField:ViewElement_Username view:contentView].text;
[self checkAccountValidation:[NSString stringWithFormat:@"%@@%@", username, [[LinphoneManager instance] lpConfigStringForKey:@"domain" forSection:@"wizard"]]];
NSString *identity = [self identityFromUsername:username];
[self checkAccountValidation:identity];
}
- (IBAction)onSignInExternalClick:(id)sender {
@ -617,7 +635,8 @@ static UICompositeViewDescription *compositeDescription = nil;
[errorView show];
[errorView release];
} else {
[self checkUserExist:username];
NSString *identity = [self identityFromUsername:username];
[self checkUserExist:identity];
}
}
@ -719,7 +738,8 @@ static UICompositeViewDescription *compositeDescription = nil;
NSString *username = [WizardViewController findTextField:ViewElement_Username view:contentView].text;
NSString *password = [WizardViewController findTextField:ViewElement_Password view:contentView].text;
NSString *email = [WizardViewController findTextField:ViewElement_Email view:contentView].text;
[self createAccount:[NSString stringWithFormat:@"%@@%@", username, [[LinphoneManager instance] lpConfigStringForKey:@"domain" forSection:@"wizard"]] password:password email:email];
NSString* identity = [self identityFromUsername:username];
[self createAccount:identity password:password email:email];
}
} else if([[request method] isEqualToString:@"create_account_with_useragent"]) {
if([response object] == [NSNumber numberWithInt:0]) {