diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 820a1d7ea..71c7aeaa9 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -2491,6 +2491,54 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { } - (void)call:(const LinphoneAddress *)iaddr { + // First verify that network is available, abort otherwise. + if (!linphone_core_is_network_reachable(theLinphoneCore)) { + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Network Error", nil) + message:NSLocalizedString(@"There is no network connection available, enable WIFI or WWAN prior to place a call", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; + return; + } + + // Then check that no GSM calls are in progress, abort otherwise. + CTCallCenter *callCenter = [[CTCallCenter alloc] init]; + if ([callCenter currentCalls] != nil && floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { + LOGE(@"GSM call in progress, cancelling outgoing SIP call request"); + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Cannot make call", nil) + message:NSLocalizedString(@"Please terminate GSM call first.", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; + return; + } + + // Then check that the supplied address is valid + if (!iaddr) { + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Invalid SIP address", nil) + message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to place a " + @"call or use a valid SIP address (I.E sip:john@example.net)", nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; + return; + } + if (linphone_core_get_calls_nb(theLinphoneCore) < 1 && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { NSUUID *uuid = [NSUUID UUID]; @@ -2509,54 +2557,6 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { } - (BOOL)doCall:(const LinphoneAddress *)iaddr { - // First verify that network is available, abort otherwise. - if (!linphone_core_is_network_reachable(theLinphoneCore)) { - UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Network Error", nil) - message:NSLocalizedString(@"There is no network connection available, enable WIFI or WWAN prior to place a call", nil) - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) {}]; - - [errView addAction:defaultAction]; - [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; - return FALSE; - } - - // Then check that no GSM calls are in progress, abort otherwise. - CTCallCenter *callCenter = [[CTCallCenter alloc] init]; - if ([callCenter currentCalls] != nil && floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { - LOGE(@"GSM call in progress, cancelling outgoing SIP call request"); - UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Cannot make call", nil) - message:NSLocalizedString(@"Please terminate GSM call first.", nil) - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) {}]; - - [errView addAction:defaultAction]; - [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; - return FALSE; - } - - // Then check that the supplied address is valid - if (!iaddr) { - UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Invalid SIP address", nil) - message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to place a " - @"call or use a valid SIP address (I.E sip:john@example.net)", nil) - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) {}]; - - [errView addAction:defaultAction]; - [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; - return FALSE; - } - LinphoneAddress *addr = linphone_address_clone(iaddr); NSString *displayName = [FastAddressBook displayNameForAddress:addr];