From 4b87055a9b31752b1dcaf78cd0f651a86ce5a307 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 10 Sep 2015 15:08:45 +0200 Subject: [PATCH] fix wizard --- Classes/AssistantView.h | 32 +- Classes/AssistantView.m | 414 +++++++++++------------ Classes/Base.lproj/AssistantSubviews.xib | 5 +- Classes/Base.lproj/AssistantView.xib | 2 + Classes/ChatConversationView.m | 8 +- Classes/SideMenuView.m | 9 +- 6 files changed, 228 insertions(+), 242 deletions(-) diff --git a/Classes/AssistantView.h b/Classes/AssistantView.h index 04aea901a..378341236 100644 --- a/Classes/AssistantView.h +++ b/Classes/AssistantView.h @@ -22,8 +22,8 @@ #import "UICompositeView.h" #import "TPKeyboardAvoidingScrollView.h" -@interface AssistantView : TPMultiLayoutViewController { +@interface AssistantView + : TPMultiLayoutViewController { @private UITextField *activeTextField; UIView *currentView; @@ -31,22 +31,22 @@ NSMutableArray *historyViews; } -@property(nonatomic, weak) IBOutlet TPKeyboardAvoidingScrollView *contentView; -@property(nonatomic, weak) IBOutlet UIView *waitView; -@property(nonatomic, weak) IBOutlet UIButton *backButton; +@property(nonatomic, strong) IBOutlet TPKeyboardAvoidingScrollView *contentView; +@property(nonatomic, strong) IBOutlet UIView *waitView; +@property(nonatomic, strong) IBOutlet UIButton *backButton; -@property(nonatomic, weak) IBOutlet UIView *welcomeView; -@property(nonatomic, weak) IBOutlet UIView *createAccountView; -@property(nonatomic, weak) IBOutlet UIView *createAccountActivationView; -@property(nonatomic, weak) IBOutlet UIView *linphoneLoginView; -@property(nonatomic, weak) IBOutlet UIView *loginView; -@property(weak, nonatomic) IBOutlet UIView *remoteProvisionningView; +@property(nonatomic, strong) IBOutlet UIView *welcomeView; +@property(nonatomic, strong) IBOutlet UIView *createAccountView; +@property(nonatomic, strong) IBOutlet UIView *createAccountActivationView; +@property(nonatomic, strong) IBOutlet UIView *linphoneLoginView; +@property(nonatomic, strong) IBOutlet UIView *loginView; +@property(nonatomic, strong) IBOutlet UIView *remoteProvisionningView; -@property(nonatomic, weak) IBOutlet UIImageView *welcomeLogoImage; -@property(nonatomic, weak) IBOutlet UIButton *gotoCreateAccountButton; -@property(nonatomic, weak) IBOutlet UIButton *gotoLinphoneLoginButton; -@property(nonatomic, weak) IBOutlet UIButton *gotoLoginButton; -@property(weak, nonatomic) IBOutlet UIButton *gotoRemoteProvisionningButton; +@property(nonatomic, strong) IBOutlet UIImageView *welcomeLogoImage; +@property(nonatomic, strong) IBOutlet UIButton *gotoCreateAccountButton; +@property(nonatomic, strong) IBOutlet UIButton *gotoLinphoneLoginButton; +@property(nonatomic, strong) IBOutlet UIButton *gotoLoginButton; +@property(nonatomic, strong) IBOutlet UIButton *gotoRemoteProvisionningButton; - (void)reset; - (void)fillDefaultValues; diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index a71b933d6..abc42c592 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -112,6 +112,12 @@ static UICompositeViewDescription *compositeDescription = nil; } } +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { + [_contentView contentSizeToFit]; +} + +#pragma mark - Utils + - (void)displayUsernameAsPhoneOrUsername { BOOL usePhoneNumber = [LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number"]; @@ -127,7 +133,109 @@ static UICompositeViewDescription *compositeDescription = nil; } } -#pragma mark - +- (BOOL)verificationWithUsername:(NSString *)username + password:(NSString *)password + domain:(NSString *)domain + withTransport:(NSString *)transport { + NSMutableString *errors = [NSMutableString string]; + if ([username length] == 0) { + [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a valid username.\n", nil)]]; + } + + if (domain != nil && [domain length] == 0) { + [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a valid domain.\n", nil)]]; + } + + if ([errors length]) { + UIAlertView *errorView = + [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Check error(s)", nil) + message:[errors substringWithRange:NSMakeRange(0, [errors length] - 1)] + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue", nil) + otherButtonTitles:nil, nil]; + [errorView show]; + return FALSE; + } + return TRUE; +} +- (void)verificationSignInWithUsername:(NSString *)username + password:(NSString *)password + domain:(NSString *)domain + withTransport:(NSString *)transport { + if ([self verificationWithUsername:username password:password domain:domain withTransport:transport]) { + _waitView.hidden = false; + if ([LinphoneManager instance].connectivity == none) { + DTAlertView *alert = [[DTAlertView alloc] + initWithTitle:NSLocalizedString(@"No connectivity", nil) + message:NSLocalizedString(@"You can either skip verification or connect to the Internet first.", + nil)]; + [alert addCancelButtonWithTitle:NSLocalizedString(@"Stay here", nil) + block:^{ + _waitView.hidden = true; + }]; + [alert + addButtonWithTitle:NSLocalizedString(@"Continue", nil) + block:^{ + _waitView.hidden = true; + [self addProxyConfig:username password:password domain:domain withTransport:transport]; + [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; + }]; + [alert show]; + } else { + BOOL success = [self addProxyConfig:username password:password domain:domain withTransport:transport]; + if (!success) { + _waitView.hidden = true; + } + } + } +} + +- (BOOL)verificationRegisterWithUsername:(NSString *)username + password:(NSString *)password + password2:(NSString *)password2 + email:(NSString *)email { + NSMutableString *errors = [NSMutableString string]; + NSInteger username_length = + [[LinphoneManager instance] lpConfigIntForKey:@"username_length" forSection:@"assistant"]; + NSInteger password_length = + [[LinphoneManager instance] lpConfigIntForKey:@"password_length" forSection:@"assistant"]; + + if ([username length] < username_length) { + [errors + appendString:[NSString stringWithFormat:NSLocalizedString( + @"The username is too short (minimum %d characters).\n", nil), + username_length]]; + } + + if ([password length] < password_length) { + [errors + appendString:[NSString stringWithFormat:NSLocalizedString( + @"The password is too short (minimum %d characters).\n", nil), + password_length]]; + } + + if (![password2 isEqualToString:password]) { + [errors appendString:NSLocalizedString(@"The passwords are different.\n", nil)]; + } + + NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @".+@.+\\.[A-Za-z]{2}[A-Za-z]*"]; + if (![emailTest evaluateWithObject:email]) { + [errors appendString:NSLocalizedString(@"The email is invalid.\n", nil)]; + } + + if ([errors length]) { + UIAlertView *errorView = + [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Check error(s)", nil) + message:[errors substringWithRange:NSMakeRange(0, [errors length] - 1)] + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue", nil) + otherButtonTitles:nil, nil]; + [errorView show]; + return FALSE; + } + + return TRUE; +} + (void)cleanTextField:(UIView *)view { if ([view isKindOfClass:[UITextField class]]) { @@ -140,7 +248,6 @@ static UICompositeViewDescription *compositeDescription = nil; } - (void)fillDefaultValues { - LinphoneCore *lc = [LinphoneManager getLc]; [self resetTextFields]; @@ -243,7 +350,7 @@ static UICompositeViewDescription *compositeDescription = nil; static BOOL placement_done = NO; // indicates if the button placement has been done in the assistant choice view // Change toolbar buttons following view - _backButton.enabled = (view == _welcomeView); + _backButton.enabled = (view != _welcomeView); [self displayUsernameAsPhoneOrUsername]; @@ -423,54 +530,6 @@ static UICompositeViewDescription *compositeDescription = nil; return [uri substringFromIndex:[scheme length] + 1]; } -#pragma mark - Linphone XMLRPC - -- (void)checkUserExist:(NSString *)username { - LOGI(@"XMLRPC check_account %@", username); - - NSURL *URL = - [NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]]; - XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL]; - [request setMethod:@"check_account" withParameters:[NSArray arrayWithObjects:username, nil]]; - - XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager]; - [manager spawnConnectionWithXMLRPCRequest:request delegate:self]; - - _waitView.hidden = false; -} - -- (void)createAccount:(NSString *)identity password:(NSString *)password email:(NSString *)email { - NSString *useragent = [LinphoneManager getUserAgent]; - LOGI(@"XMLRPC create_account_with_useragent %@ %@ %@ %@", identity, password, email, useragent); - - NSURL *URL = - [NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]]; - XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL]; - [request setMethod:@"create_account_with_useragent" - withParameters:[NSArray arrayWithObjects:identity, password, email, useragent, nil]]; - - XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager]; - [manager spawnConnectionWithXMLRPCRequest:request delegate:self]; - - _waitView.hidden = false; -} - -- (void)checkAccountValidation:(NSString *)identity { - LOGI(@"XMLRPC check_account_validated %@", identity); - - NSURL *URL = - [NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]]; - XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL]; - [request setMethod:@"check_account_validated" withParameters:[NSArray arrayWithObjects:identity, nil]]; - - XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager]; - [manager spawnConnectionWithXMLRPCRequest:request delegate:self]; - - _waitView.hidden = false; -} - -#pragma mark - - - (void)registrationUpdate:(LinphoneRegistrationState)state forProxy:(LinphoneProxyConfig *)proxy message:(NSString *)message { @@ -528,6 +587,52 @@ static UICompositeViewDescription *compositeDescription = nil; linphone_core_set_default_proxy_config([LinphoneManager getLc], NULL); } +#pragma mark - Linphone XMLRPC + +- (void)checkUserExist:(NSString *)username { + LOGI(@"XMLRPC check_account %@", username); + + NSURL *URL = + [NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]]; + XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL]; + [request setMethod:@"check_account" withParameters:[NSArray arrayWithObjects:username, nil]]; + + XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager]; + [manager spawnConnectionWithXMLRPCRequest:request delegate:self]; + + _waitView.hidden = false; +} + +- (void)createAccount:(NSString *)identity password:(NSString *)password email:(NSString *)email { + NSString *useragent = [LinphoneManager getUserAgent]; + LOGI(@"XMLRPC create_account_with_useragent %@ %@ %@ %@", identity, password, email, useragent); + + NSURL *URL = + [NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]]; + XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL]; + [request setMethod:@"create_account_with_useragent" + withParameters:[NSArray arrayWithObjects:identity, password, email, useragent, nil]]; + + XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager]; + [manager spawnConnectionWithXMLRPCRequest:request delegate:self]; + + _waitView.hidden = false; +} + +- (void)checkAccountValidation:(NSString *)identity { + LOGI(@"XMLRPC check_account_validated %@", identity); + + NSURL *URL = + [NSURL URLWithString:[[LinphoneManager instance] lpConfigStringForKey:@"service_url" forSection:@"assistant"]]; + XMLRPCRequest *request = [[XMLRPCRequest alloc] initWithURL:URL]; + [request setMethod:@"check_account_validated" withParameters:[NSArray arrayWithObjects:identity, nil]]; + + XMLRPCConnectionManager *manager = [XMLRPCConnectionManager sharedManager]; + [manager spawnConnectionWithXMLRPCRequest:request delegate:self]; + + _waitView.hidden = false; +} + #pragma mark - UITextFieldDelegate Functions - (BOOL)textFieldShouldReturn:(UITextField *)textField { @@ -599,6 +704,39 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Action Functions +- (IBAction)onLoginClick:(id)sender { + NSString *username = [self findTextField:ViewElement_Username].text; + NSString *password = [self findTextField:ViewElement_Password].text; + NSString *domain = [self findTextField:ViewElement_Domain].text; + UISegmentedControl *transportChooser = + (UISegmentedControl *)[self findView:ViewElement_Transport inView:_contentView ofType:UISegmentedControl.class]; + NSString *transport = [transportChooser titleForSegmentAtIndex:transportChooser.selectedSegmentIndex]; + [self verificationSignInWithUsername:username password:password domain:domain withTransport:transport]; +} + +- (IBAction)onLinphoneLoginClick:(id)sender { + NSString *username = [self findTextField:ViewElement_Username].text; + NSString *password = [self findTextField:ViewElement_Password].text; + + // domain and server will be configured from the default proxy values + [self verificationSignInWithUsername:username password:password domain:nil withTransport:nil]; +} + +- (IBAction)onCreateAccountClick:(id)sender { + UITextField *username_tf = [self findTextField:ViewElement_Username]; + NSString *username = username_tf.text; + NSString *password = [self findTextField:ViewElement_Password].text; + NSString *password2 = [self findTextField:ViewElement_Password2].text; + NSString *email = [self findTextField:ViewElement_Email].text; + + if ([self verificationRegisterWithUsername:username password:password password2:password2 email:email]) { + username = [username lowercaseString]; + [username_tf setText:username]; + NSString *identity = [self identityFromUsername:username]; + [self checkUserExist:identity]; + } +} + - (IBAction)onBackClick:(id)sender { if ([historyViews count] > 0) { UIView *view = [historyViews lastObject]; @@ -648,143 +786,6 @@ static UICompositeViewDescription *compositeDescription = nil; [remoteInput show]; } -- (BOOL)verificationWithUsername:(NSString *)username - password:(NSString *)password - domain:(NSString *)domain - withTransport:(NSString *)transport { - NSMutableString *errors = [NSMutableString string]; - if ([username length] == 0) { - [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a valid username.\n", nil)]]; - } - - if (domain != nil && [domain length] == 0) { - [errors appendString:[NSString stringWithFormat:NSLocalizedString(@"Please enter a valid domain.\n", nil)]]; - } - - if ([errors length]) { - UIAlertView *errorView = - [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Check error(s)", nil) - message:[errors substringWithRange:NSMakeRange(0, [errors length] - 1)] - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Continue", nil) - otherButtonTitles:nil, nil]; - [errorView show]; - return FALSE; - } - return TRUE; -} -- (void)verificationSignInWithUsername:(NSString *)username - password:(NSString *)password - domain:(NSString *)domain - withTransport:(NSString *)transport { - if ([self verificationWithUsername:username password:password domain:domain withTransport:transport]) { - _waitView.hidden = false; - if ([LinphoneManager instance].connectivity == none) { - DTAlertView *alert = [[DTAlertView alloc] - initWithTitle:NSLocalizedString(@"No connectivity", nil) - message:NSLocalizedString(@"You can either skip verification or connect to the Internet first.", - nil)]; - [alert addCancelButtonWithTitle:NSLocalizedString(@"Stay here", nil) - block:^{ - _waitView.hidden = true; - }]; - [alert - addButtonWithTitle:NSLocalizedString(@"Continue", nil) - block:^{ - _waitView.hidden = true; - [self addProxyConfig:username password:password domain:domain withTransport:transport]; - [PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription]; - }]; - [alert show]; - } else { - BOOL success = [self addProxyConfig:username password:password domain:domain withTransport:transport]; - if (!success) { - _waitView.hidden = true; - } - } - } -} - -- (IBAction)onLoginClick:(id)sender { - NSString *username = [self findTextField:ViewElement_Username].text; - NSString *password = [self findTextField:ViewElement_Password].text; - NSString *domain = [self findTextField:ViewElement_Domain].text; - UISegmentedControl *transportChooser = - (UISegmentedControl *)[self findView:ViewElement_Transport inView:_contentView ofType:UISegmentedControl.class]; - NSString *transport = [transportChooser titleForSegmentAtIndex:transportChooser.selectedSegmentIndex]; - [self verificationSignInWithUsername:username password:password domain:domain withTransport:transport]; -} - -- (IBAction)onLinphoneLoginClick:(id)sender { - NSString *username = [self findTextField:ViewElement_Username].text; - NSString *password = [self findTextField:ViewElement_Password].text; - - // domain and server will be configured from the default proxy values - [self verificationSignInWithUsername:username password:password domain:nil withTransport:nil]; -} - -- (BOOL)verificationRegisterWithUsername:(NSString *)username - password:(NSString *)password - password2:(NSString *)password2 - email:(NSString *)email { - NSMutableString *errors = [NSMutableString string]; - NSInteger username_length = - [[LinphoneManager instance] lpConfigIntForKey:@"username_length" forSection:@"assistant"]; - NSInteger password_length = - [[LinphoneManager instance] lpConfigIntForKey:@"password_length" forSection:@"assistant"]; - - if ([username length] < username_length) { - [errors - appendString:[NSString stringWithFormat:NSLocalizedString( - @"The username is too short (minimum %d characters).\n", nil), - username_length]]; - } - - if ([password length] < password_length) { - [errors - appendString:[NSString stringWithFormat:NSLocalizedString( - @"The password is too short (minimum %d characters).\n", nil), - password_length]]; - } - - if (![password2 isEqualToString:password]) { - [errors appendString:NSLocalizedString(@"The passwords are different.\n", nil)]; - } - - NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @".+@.+\\.[A-Za-z]{2}[A-Za-z]*"]; - if (![emailTest evaluateWithObject:email]) { - [errors appendString:NSLocalizedString(@"The email is invalid.\n", nil)]; - } - - if ([errors length]) { - UIAlertView *errorView = - [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Check error(s)", nil) - message:[errors substringWithRange:NSMakeRange(0, [errors length] - 1)] - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Continue", nil) - otherButtonTitles:nil, nil]; - [errorView show]; - return FALSE; - } - - return TRUE; -} - -- (IBAction)onCreateAccountClick:(id)sender { - UITextField *username_tf = [self findTextField:ViewElement_Username]; - NSString *username = username_tf.text; - NSString *password = [self findTextField:ViewElement_Password].text; - NSString *password2 = [self findTextField:ViewElement_Password2].text; - NSString *email = [self findTextField:ViewElement_Email].text; - - if ([self verificationRegisterWithUsername:username password:password password2:password2 email:email]) { - username = [username lowercaseString]; - [username_tf setText:username]; - NSString *identity = [self identityFromUsername:username]; - [self checkUserExist:identity]; - } -} - - (IBAction)onRemoteProvisionningClick:(id)sender { NSString *username = [self findTextField:ViewElement_Username].text; NSString *password = [self findTextField:ViewElement_Password].text; @@ -810,29 +811,13 @@ static UICompositeViewDescription *compositeDescription = nil; } } -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { - [_contentView contentSizeToFit]; -} +#pragma mark - Event Functions -#pragma mark - UIAlertViewDelegate - -- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { - if (buttonIndex == 1) { /* fetch */ - NSString *url = [alertView textFieldAtIndex:0].text; - if ([url length] > 0) { - // missing prefix will result in http:// being used - if ([url rangeOfString:@"://"].location == NSNotFound) - url = [NSString stringWithFormat:@"http://%@", url]; - - LOGI(@"Should use remote provisioning URL %@", url); - linphone_core_set_provisioning_uri([LinphoneManager getLc], [url UTF8String]); - - _waitView.hidden = false; - [[LinphoneManager instance] resetLinphoneCore]; - } - } else { - LOGI(@"Canceled remote provisioning"); - } +- (void)registrationUpdateEvent:(NSNotification *)notif { + NSString *message = [notif.userInfo objectForKey:@"message"]; + [self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue] + forProxy:[[notif.userInfo objectForKeyedSubscript:@"cfg"] pointerValue] + message:message]; } - (void)configuringUpdate:(NSNotification *)notif { @@ -866,15 +851,6 @@ static UICompositeViewDescription *compositeDescription = nil; } } -#pragma mark - Event Functions - -- (void)registrationUpdateEvent:(NSNotification *)notif { - NSString *message = [notif.userInfo objectForKey:@"message"]; - [self registrationUpdate:[[notif.userInfo objectForKey:@"state"] intValue] - forProxy:[[notif.userInfo objectForKeyedSubscript:@"cfg"] pointerValue] - message:message]; -} - #pragma mark - XMLRPCConnectionDelegate Functions - (void)request:(XMLRPCRequest *)request didReceiveResponse:(XMLRPCResponse *)response { diff --git a/Classes/Base.lproj/AssistantSubviews.xib b/Classes/Base.lproj/AssistantSubviews.xib index 13c2e7f36..bc951e115 100644 --- a/Classes/Base.lproj/AssistantSubviews.xib +++ b/Classes/Base.lproj/AssistantSubviews.xib @@ -10,6 +10,7 @@ + @@ -527,7 +528,7 @@ - + @@ -637,7 +638,7 @@ - + diff --git a/Classes/Base.lproj/AssistantView.xib b/Classes/Base.lproj/AssistantView.xib index 5309592e2..a43bf0813 100644 --- a/Classes/Base.lproj/AssistantView.xib +++ b/Classes/Base.lproj/AssistantView.xib @@ -1,11 +1,13 @@ + + diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index b20ac1f1e..e88ebab4e 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -166,9 +166,11 @@ static UICompositeViewDescription *compositeDescription = nil; self->chatRoom = room; [messageField setText:@""]; [tableController setChatRoom:room]; - [self update]; - linphone_chat_room_mark_as_read(chatRoom); - [self setComposingVisible:linphone_chat_room_is_remote_composing(chatRoom) withDelay:0]; + if (chatRoom != NULL) { + [self update]; + linphone_chat_room_mark_as_read(chatRoom); + [self setComposingVisible:linphone_chat_room_is_remote_composing(chatRoom) withDelay:0]; + } [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneMessageReceived object:self]; } diff --git a/Classes/SideMenuView.m b/Classes/SideMenuView.m index 18c2730f9..f2237e48e 100644 --- a/Classes/SideMenuView.m +++ b/Classes/SideMenuView.m @@ -28,8 +28,12 @@ char *as_string = linphone_address_as_string(addr); _addressLabel.text = [NSString stringWithUTF8String:as_string]; ms_free(as_string); - [FastAddressBook getContactImage:[FastAddressBook getContactWithLinphoneAddress:addr] thumbnail:NO]; + } else { + _nameLabel.text = @"No account"; + _addressLabel.text = NSLocalizedString(@"No address", nil); } + + // set avatar if available NSURL *url = [NSURL URLWithString:[LinphoneManager.instance lpConfigStringForKey:@"avatar"]]; if (url) { [LinphoneManager.instance.photoLibrary assetForURL:url @@ -42,7 +46,7 @@ }); } failureBlock:^(NSError *error) { - LOGE(@"Can't read image"); + LOGE(@"Can't read avatar"); }]; } else { [_avatarImage setImage:[UIImage imageNamed:@"avatar"]]; @@ -50,6 +54,7 @@ } - (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; [self updateHeader]; [_sideMenuTableViewController.tableView reloadData]; }