mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 20:18:09 +00:00
Fix crash when calling invalid SIP address with CallKit
This commit is contained in:
parent
5d92ce525f
commit
a2e1ab26bb
1 changed files with 48 additions and 48 deletions
|
|
@ -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];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue