diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 23ca6ebde..86cd728d9 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -243,6 +243,17 @@ static UICompositeViewDescription *compositeDescription = nil; // reload address book to prepend proxy config domain to contacts' phone number // todo: STOP doing that! [[LinphoneManager.instance fastAddressBook] reload]; + } else { + UIAlertView *error = [[UIAlertView alloc] + initWithTitle:NSLocalizedString(@"Assistant error", nil) + message:NSLocalizedString( + @"Could not configure your account, please check parameters or try again later", nil) + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Cancel", nil) + otherButtonTitles:nil]; + [error show]; + _waitView.hidden = YES; + return; } } @@ -528,9 +539,6 @@ static UICompositeViewDescription *compositeDescription = nil; } case LinphoneRegistrationFailed: { _waitView.hidden = true; - if ([message isEqualToString:@"Forbidden"]) { - message = NSLocalizedString(@"Incorrect username or password.", nil); - } DTAlertView *alert = [[DTAlertView alloc] initWithTitle:NSLocalizedString(@"Registration failure", nil) message:message delegate:nil diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 30ae69930..558ab7bc2 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -837,13 +837,71 @@ static void linphone_iphone_configuring_status_changed(LinphoneCore *lc, Linphon - (void)onRegister:(LinphoneCore *)lc cfg:(LinphoneProxyConfig *)cfg state:(LinphoneRegistrationState)state - message:(const char *)message { - LOGI(@"New registration state: %s (message: %s)", linphone_registration_state_to_string(state), message); + message:(const char *)cmessage { + LOGI(@"New registration state: %s (message: %s)", linphone_registration_state_to_string(state), cmessage); + + LinphoneReason reason = linphone_proxy_config_get_error(cfg); + NSString *message = nil; + switch (reason) { + case LinphoneReasonBadCredentials: + message = NSLocalizedString(@"Bad credentials, check your account settings", nil); + break; + case LinphoneReasonNoResponse: + message = NSLocalizedString(@"No response received from remote", nil); + break; + case LinphoneReasonUnsupportedContent: + message = NSLocalizedString(@"Unsupported content", nil); + break; + case LinphoneReasonIOError: + message = NSLocalizedString( + @"Cannot reach the server: either it is an invalid address or it may be temporary down.", nil); + break; + + case LinphoneReasonUnauthorized: + message = NSLocalizedString(@"Operation is unauthorized because missing credential", nil); + break; + case LinphoneReasonNoMatch: + message = NSLocalizedString(@"Operation could not be executed by server or remote client because it " + @"didn't have any context for it", + nil); + break; + case LinphoneReasonMovedPermanently: + message = NSLocalizedString(@"Resource moved permanently", nil); + break; + case LinphoneReasonGone: + message = NSLocalizedString(@"Resource no longer exists", nil); + break; + case LinphoneReasonTemporarilyUnavailable: + message = NSLocalizedString(@"Temporarily unavailable", nil); + break; + case LinphoneReasonAddressIncomplete: + message = NSLocalizedString(@"Address incomplete", nil); + break; + case LinphoneReasonNotImplemented: + message = NSLocalizedString(@"Not implemented", nil); + break; + case LinphoneReasonBadGateway: + message = NSLocalizedString(@"Bad gateway", nil); + break; + case LinphoneReasonServerTimeout: + message = NSLocalizedString(@"Server timeout", nil); + break; + case LinphoneReasonNotAcceptable: + case LinphoneReasonDoNotDisturb: + case LinphoneReasonDeclined: + case LinphoneReasonNotFound: + case LinphoneReasonNotAnswered: + case LinphoneReasonBusy: + case LinphoneReasonNone: + case LinphoneReasonUnknown: + message = NSLocalizedString(@"Unknown error", nil); + break; + } // Post event - NSDictionary *dict = [NSDictionary - dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:state], @"state", [NSValue valueWithPointer:cfg], @"cfg", - [NSString stringWithUTF8String:message], @"message", nil]; + NSDictionary *dict = + [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:state], @"state", + [NSValue valueWithPointer:cfg], @"cfg", message, @"message", nil]; [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneRegistrationUpdate object:self userInfo:dict]; } diff --git a/Classes/LinphoneUI/StatusBarView.m b/Classes/LinphoneUI/StatusBarView.m index d5d29b0ea..a4556e5af 100644 --- a/Classes/LinphoneUI/StatusBarView.m +++ b/Classes/LinphoneUI/StatusBarView.m @@ -55,6 +55,10 @@ selector:@selector(notifyReceived:) name:kLinphoneNotifyReceived object:nil]; + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(mainViewChanged:) + name:kLinphoneMainViewChange + object:nil]; [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(callUpdate:) @@ -82,6 +86,7 @@ [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneGlobalStateUpdate object:nil]; [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneNotifyReceived object:nil]; [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneCallUpdate object:nil]; + [NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneMainViewChange object:nil]; if (callQualityTimer != nil) { [callQualityTimer invalidate]; @@ -106,7 +111,11 @@ } - (void)globalStateUpdate:(NSNotification *)notif { - [self registrationUpdate:notif]; + [self registrationUpdate:nil]; +} + +- (void)mainViewChanged:(NSNotification *)notif { + [self registrationUpdate:nil]; } - (void)onCallEncryptionChanged:(NSNotification *)notif { @@ -174,7 +183,9 @@ NSString *message = nil; LinphoneGlobalState gstate = linphone_core_get_global_state(LC); - if (gstate == LinphoneGlobalOn && !linphone_core_is_network_reachable(LC)) { + if ([PhoneMainView.instance.currentView equal:AssistantView.compositeViewDescription]) { + message = NSLocalizedString(@"Configuring account", nil); + } else if (gstate == LinphoneGlobalOn && !linphone_core_is_network_reachable(LC)) { message = NSLocalizedString(@"Network down", nil); } else if (gstate == LinphoneGlobalConfiguring) { message = NSLocalizedString(@"Fetching remote configuration", nil); diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 7a068f4c3..b66948bc7 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -285,68 +285,10 @@ static RootViewManager *rootViewManagerInstance = nil; - (void)registrationUpdate:(NSNotification *)notif { LinphoneRegistrationState state = [[notif.userInfo objectForKey:@"state"] intValue]; - LinphoneProxyConfig *cfg = [[notif.userInfo objectForKey:@"cfg"] pointerValue]; - if (state == LinphoneRegistrationFailed && + if (state == LinphoneRegistrationFailed && ![currentView equal:AssistantView.compositeViewDescription] && [UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { - LinphoneReason reason = linphone_proxy_config_get_error(cfg); - NSString *message = nil; - switch (reason) { - case LinphoneReasonBadCredentials: - message = NSLocalizedString(@"Bad credentials, check your account settings", nil); - break; - case LinphoneReasonNoResponse: - message = NSLocalizedString(@"No response received from remote", nil); - break; - case LinphoneReasonUnsupportedContent: - message = NSLocalizedString(@"Unsupported content", nil); - break; - case LinphoneReasonIOError: - message = NSLocalizedString( - @"Cannot reach the server: either it is an invalid address or it may be temporary down.", nil); - break; - - case LinphoneReasonUnauthorized: - message = NSLocalizedString(@"Operation is unauthorized because missing credential", nil); - break; - case LinphoneReasonNoMatch: - message = NSLocalizedString(@"Operation could not be executed by server or remote client because it " - @"didn't have any context for it", - nil); - break; - case LinphoneReasonMovedPermanently: - message = NSLocalizedString(@"Resource moved permanently", nil); - break; - case LinphoneReasonGone: - message = NSLocalizedString(@"Resource no longer exists", nil); - break; - case LinphoneReasonTemporarilyUnavailable: - message = NSLocalizedString(@"Temporarily unavailable", nil); - break; - case LinphoneReasonAddressIncomplete: - message = NSLocalizedString(@"Address incomplete", nil); - break; - case LinphoneReasonNotImplemented: - message = NSLocalizedString(@"Not implemented", nil); - break; - case LinphoneReasonBadGateway: - message = NSLocalizedString(@"Bad gateway", nil); - break; - case LinphoneReasonServerTimeout: - message = NSLocalizedString(@"Server timeout", nil); - break; - case LinphoneReasonNotAcceptable: - case LinphoneReasonDoNotDisturb: - case LinphoneReasonDeclined: - case LinphoneReasonNotFound: - case LinphoneReasonNotAnswered: - case LinphoneReasonBusy: - case LinphoneReasonNone: - case LinphoneReasonUnknown: - message = NSLocalizedString(@"Unknown error", nil); - break; - } UIAlertView *error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Registration failure", nil) - message:message + message:[notif.userInfo objectForKey:@"message"] delegate:nil cancelButtonTitle:NSLocalizedString(@"Continue", nil) otherButtonTitles:nil, nil]; diff --git a/submodules/linphone b/submodules/linphone index 6df64fa84..bd5690713 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 6df64fa84ccca09a3378a6aa12aeafcd5d296f83 +Subproject commit bd569071365ff85b62721d8058fa8de7bd5cd015