diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 5947c6498..ade6c018a 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1805,8 +1805,22 @@ static void audioRouteChangeListenerCallback ( } LinphoneCall* call=NULL; + BOOL addressIsASCII = [address canBeConvertedToEncoding:[NSString defaultCStringEncoding]]; + if ([address length] == 0) return; //just return - if ([address hasPrefix:@"sip:"] || [address hasPrefix:@"sips:"]) { + + + if( !addressIsASCII ){ + UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Invalid SIP address",nil) + message:NSLocalizedString(@"The address should only contain ASCII data",nil) + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue",nil) + otherButtonTitles:nil]; + [error show]; + [error release]; + + } else if ([address hasPrefix:@"sip:"] || [address hasPrefix:@"sips:"]) { + LinphoneAddress* linphoneAddress = linphone_address_new([address cStringUsingEncoding:[NSString defaultCStringEncoding]]); if(displayName!=nil) { linphone_address_set_display_name(linphoneAddress,[displayName cStringUsingEncoding:[NSString defaultCStringEncoding]]); @@ -1819,7 +1833,9 @@ static void audioRouteChangeListenerCallback ( call=linphone_core_invite_address_with_params(theLinphoneCore, linphoneAddress, lcallParams); } linphone_address_destroy(linphoneAddress); + } else if (proxyCfg==nil){ + UIAlertView* error = [[UIAlertView alloc] initWithTitle: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) delegate:nil @@ -1827,7 +1843,8 @@ static void audioRouteChangeListenerCallback ( otherButtonTitles:nil]; [error show]; [error release]; - } else { + + } else { char normalizedUserName[256]; LinphoneAddress* linphoneAddress = linphone_address_new(linphone_core_get_identity(theLinphoneCore)); linphone_proxy_config_normalize_number(proxyCfg,[address cStringUsingEncoding:[NSString defaultCStringEncoding]],normalizedUserName,sizeof(normalizedUserName));