diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 530c5e812..6b61ac6b6 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -116,8 +116,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)loadAssistantConfig:(NSString *)rcFilename { NSString *fullPath = [@"file://" stringByAppendingString:[LinphoneManager bundleFile:rcFilename]]; - linphone_core_set_provisioning_uri([LinphoneManager getLc], - [fullPath cStringUsingEncoding:[NSString defaultCStringEncoding]]); + linphone_core_set_provisioning_uri([LinphoneManager getLc], fullPath.UTF8String); [[LinphoneManager instance] lpConfigSetInt:1 forKey:@"transient_provisioning" forSection:@"misc"]; // For some reason, video preview hangs for 15seconds when resetting linphone core from here... diff --git a/Classes/Base.lproj/CallView.xib b/Classes/Base.lproj/CallView.xib index 57699759b..377e9a707 100644 --- a/Classes/Base.lproj/CallView.xib +++ b/Classes/Base.lproj/CallView.xib @@ -10,7 +10,6 @@ - @@ -88,17 +87,6 @@ - @@ -156,7 +144,7 @@ - + diff --git a/Classes/CallIncomingView.m b/Classes/CallIncomingView.m index bd83fda4d..16c8caf77 100644 --- a/Classes/CallIncomingView.m +++ b/Classes/CallIncomingView.m @@ -83,6 +83,7 @@ static UICompositeViewDescription *compositeDescription = nil; } else if ([LinphoneManager.instance lpConfigBoolForKey:@"auto_answer"]) { LinphoneCallState state = linphone_call_get_state(call); if (state == LinphoneCallIncomingReceived) { + LOGI(@"Auto answering call"); [self onAcceptClick:nil]; } } diff --git a/Classes/CallView.h b/Classes/CallView.h index c031cf845..4726a6e6c 100644 --- a/Classes/CallView.h +++ b/Classes/CallView.h @@ -83,7 +83,6 @@ @property(nonatomic, strong) IBOutlet UIDigitButton *starButton; @property(nonatomic, strong) IBOutlet UIDigitButton *zeroButton; @property(nonatomic, strong) IBOutlet UIDigitButton *sharpButton; -@property(weak, nonatomic) IBOutlet UILabel *addressLabel; @property(weak, nonatomic) IBOutlet UIRoundedImageView *avatarImage; @property(weak, nonatomic) IBOutlet UILabel *nameLabel; @property(weak, nonatomic) IBOutlet UILabel *durationLabel; @@ -91,7 +90,6 @@ @property(weak, nonatomic) IBOutlet UIView *noActiveCallView; @property(weak, nonatomic) IBOutlet UIView *conferenceView; @property(strong, nonatomic) IBOutlet CallPausedTableView *conferenceCallsTable; -@property(weak, nonatomic) IBOutlet UIPauseButton *conferencePauseButton; - (IBAction)onRoutesClick:(id)sender; - (IBAction)onRoutesBluetoothClick:(id)sender; diff --git a/Classes/CallView.m b/Classes/CallView.m index 80b359aec..40ecb738f 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -233,7 +233,6 @@ static UICompositeViewDescription *compositeDescription = nil; [_speakerButton update]; [_microButton update]; [_pauseButton update]; - [_conferencePauseButton update]; [_videoButton update]; [_hangupButton update]; @@ -464,7 +463,6 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { const LinphoneAddress *addr = linphone_call_get_remote_address(call); [ContactDisplay setDisplayNameLabel:_nameLabel forAddress:addr]; char *uri = linphone_address_as_string_uri_only(addr); - _addressLabel.text = [NSString stringWithUTF8String:uri]; ms_free(uri); _avatarImage.image = [FastAddressBook getContactImage:[FastAddressBook getContactWithAddress:addr] thumbnail:NO]; diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 50b0cf0c1..10d6f5014 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -122,8 +122,7 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info } - (void)addCurrentContactContactField:(NSString *)address { - LinphoneAddress *linphoneAddress = linphone_core_interpret_url( - [LinphoneManager getLc], [address cStringUsingEncoding:[NSString defaultCStringEncoding]]); + LinphoneAddress *linphoneAddress = linphone_core_interpret_url([LinphoneManager getLc], address.UTF8String); NSString *username = [NSString stringWithUTF8String:linphone_address_get_username(linphoneAddress)]; if (([username rangeOfString:@"@"].length > 0) && diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 764fc6382..43848f853 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -440,7 +440,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); proxyAddress = [NSString stringWithFormat:@"sip:%@", proxyAddress]; } - char *proxy = ms_strdup([proxyAddress cStringUsingEncoding:[NSString defaultCStringEncoding]]); + char *proxy = ms_strdup(proxyAddress.UTF8String); LinphoneAddress *proxy_addr = linphone_address_new(proxy); if (proxy_addr) { @@ -466,15 +466,14 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); char normalizedUserName[256]; LinphoneAddress *linphoneAddress = linphone_address_new("sip:user@domain.com"); - linphone_proxy_config_normalize_number(proxyCfg, - [username cStringUsingEncoding:[NSString defaultCStringEncoding]], - normalizedUserName, sizeof(normalizedUserName)); + linphone_proxy_config_normalize_number(proxyCfg, username.UTF8String, normalizedUserName, + sizeof(normalizedUserName)); linphone_address_set_username(linphoneAddress, normalizedUserName); - linphone_address_set_domain(linphoneAddress, [domain cStringUsingEncoding:[NSString defaultCStringEncoding]]); + linphone_address_set_domain(linphoneAddress, [domain UTF8String]); const char *identity = linphone_address_as_string_uri_only(linphoneAddress); - const char *password = [accountPassword cStringUsingEncoding:[NSString defaultCStringEncoding]]; - const char *ha1 = [accountHa1 cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char *password = [accountPassword UTF8String]; + const char *ha1 = [accountHa1 UTF8String]; if (linphone_proxy_config_set_identity(proxyCfg, identity) == -1) { error = NSLocalizedString(@"Invalid username or domain", nil); @@ -492,8 +491,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } if ([prefix length] > 0) { - linphone_proxy_config_set_dial_prefix(proxyCfg, - [prefix cStringUsingEncoding:[NSString defaultCStringEncoding]]); + linphone_proxy_config_set_dial_prefix(proxyCfg, [prefix UTF8String]); } if ([self objectForKey:@"substitute_+_by_00_preference"]) { @@ -508,7 +506,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); linphone_proxy_config_enable_avpf(proxyCfg, use_avpf); linphone_proxy_config_set_expires(proxyCfg, expire); - LinphoneAuthInfo *proxyAi = linphone_proxy_config_find_auth_info(proxyCfg); + LinphoneAuthInfo *proxyAi = (LinphoneAuthInfo *)linphone_proxy_config_find_auth_info(proxyCfg); // setup auth info if (proxyAi) { linphone_auth_info_set_username(proxyAi, username.UTF8String); @@ -771,8 +769,7 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); } else if ([lTunnelPrefMode isEqualToString:@"auto"]) { mode = tunnel_auto; } else { - LOGE(@"Unexpected tunnel mode [%s]", - [lTunnelPrefMode cStringUsingEncoding:[NSString defaultCStringEncoding]]); + LOGE(@"Unexpected tunnel mode [%s]", [lTunnelPrefMode UTF8String]); } } @@ -806,9 +803,8 @@ extern void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); NSString *username = [self stringForKey:@"primary_username_preference"]; LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed(lc); if (parsed != NULL) { - linphone_address_set_display_name(parsed, - [displayname cStringUsingEncoding:[NSString defaultCStringEncoding]]); - linphone_address_set_username(parsed, [username cStringUsingEncoding:[NSString defaultCStringEncoding]]); + linphone_address_set_display_name(parsed, [displayname UTF8String]); + linphone_address_set_username(parsed, [username UTF8String]); char *contact = linphone_address_as_string(parsed); linphone_core_set_primary_contact(lc, contact); ms_free(contact); diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 161ba03de..bdb2ba85b 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -494,8 +494,7 @@ exit_dbmigration: NSString *chatDBFileName = [LinphoneManager documentFile:kLinphoneInternalChatDBFilename]; if ([self migrateChatDBIfNeeded:theLinphoneCore]) { // if a migration was performed, we should reinitialize the chat database - linphone_core_set_chat_database_path(theLinphoneCore, - [chatDBFileName cStringUsingEncoding:[NSString defaultCStringEncoding]]); + linphone_core_set_chat_database_path(theLinphoneCore, [chatDBFileName UTF8String]); } /* AVPF migration */ @@ -771,6 +770,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char @"state" : [NSNumber numberWithInt:state], @"message" : [NSString stringWithUTF8String:message] }; + LOGI(@"Call %p changed to state %s: %s", call, linphone_call_state_to_string(state), message); [[NSNotificationCenter defaultCenter] postNotificationName:kLinphoneCallUpdate object:self userInfo:dict]; } @@ -929,6 +929,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char ms_free(c_address); if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { + // Create a new notification UILocalNotification *notif = [[UILocalNotification alloc] init]; if (notif) { @@ -1296,8 +1297,7 @@ static LinphoneCoreVTable linphonec_vtable = {.show = NULL, // get default config from bundle NSString *zrtpSecretsFileName = [LinphoneManager documentFile:@"zrtp_secrets"]; NSString *chatDBFileName = [LinphoneManager documentFile:kLinphoneInternalChatDBFilename]; - const char *lRootCa = - [[LinphoneManager bundleFile:@"rootca.pem"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char *lRootCa = [[LinphoneManager bundleFile:@"rootca.pem"] UTF8String]; NSString *device = [NSString stringWithFormat:@"%@_%@_iOS%@", [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleDisplayName"], @@ -1312,29 +1312,24 @@ static LinphoneCoreVTable linphonec_vtable = {.show = NULL, linphone_core_set_root_ca(theLinphoneCore, lRootCa); // Set audio assets - const char *lRing = - [[LinphoneManager bundleFile:@"ring.wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char *lRing = [[LinphoneManager bundleFile:@"ring.wav"] UTF8String]; linphone_core_set_ring(theLinphoneCore, lRing); - const char *lRingBack = - [[LinphoneManager bundleFile:@"ringback.wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char *lRingBack = [[LinphoneManager bundleFile:@"ringback.wav"] UTF8String]; linphone_core_set_ringback(theLinphoneCore, lRingBack); - // const char *lPlay = - // [[LinphoneManager bundleFile:@"hold.wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; - // linphone_core_set_play_file(theLinphoneCore, lPlay); + const char *lPlay = [[LinphoneManager bundleFile:@"hold.wav"] UTF8String]; + linphone_core_set_play_file(theLinphoneCore, lPlay); + + linphone_core_set_zrtp_secrets_file(theLinphoneCore, [zrtpSecretsFileName UTF8String]); + linphone_core_set_chat_database_path(theLinphoneCore, [chatDBFileName UTF8String]); + linphone_core_set_call_logs_database_path(theLinphoneCore, [chatDBFileName UTF8String]); - linphone_core_set_zrtp_secrets_file(theLinphoneCore, - [zrtpSecretsFileName cStringUsingEncoding:[NSString defaultCStringEncoding]]); - linphone_core_set_chat_database_path(theLinphoneCore, - [chatDBFileName cStringUsingEncoding:[NSString defaultCStringEncoding]]); - linphone_core_set_call_logs_database_path(theLinphoneCore, - [chatDBFileName cStringUsingEncoding:[NSString defaultCStringEncoding]]); [self migrationLinphoneSettings]; [self setupNetworkReachabilityCallback]; NSString *path = [LinphoneManager bundleFile:@"nowebcamCIF.jpg"]; if (path) { - const char *imagePath = [path cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char *imagePath = [path UTF8String]; LOGI(@"Using '%s' as source image for no webcam", imagePath); linphone_core_set_static_picture(theLinphoneCore, imagePath); } @@ -1362,8 +1357,7 @@ static LinphoneCoreVTable linphonec_vtable = {.show = NULL, linphone_core_enable_video(theLinphoneCore, FALSE, FALSE); } - LOGI(@"Linphone [%s] started on [%s]", linphone_core_get_version(), - [[UIDevice currentDevice].model cStringUsingEncoding:[NSString defaultCStringEncoding]]); + LOGI(@"Linphone [%s] started on [%s]", linphone_core_get_version(), [[UIDevice currentDevice].model UTF8String]); // Post event NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSValue valueWithPointer:theLinphoneCore] forKey:@"core"]; @@ -1441,22 +1435,18 @@ static BOOL libStarted = FALSE; libmswebrtc_init(); // Set audio assets - const char *lRing = - [[LinphoneManager bundleFile:@"ring.wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char *lRing = [[LinphoneManager bundleFile:@"ring.wav"] UTF8String]; lp_config_set_string(configDb, "sound", "local_ring", lRing); - const char *lRingBack = - [[LinphoneManager bundleFile:@"ringback.wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char *lRingBack = [[LinphoneManager bundleFile:@"ringback.wav"] UTF8String]; lp_config_set_string(configDb, "sound", "ringback_tone", lRingBack); - // const char *lPlay = - // [[LinphoneManager bundleFile:@"hold.wav"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; - // lp_config_set_string(configDb, "sound", "hold_music", lPlay); + const char *lPlay = [[LinphoneManager bundleFile:@"hold.wav"] UTF8String]; + lp_config_set_string(configDb, "sound", "hold_music", lPlay); theLinphoneCore = linphone_core_new_with_config(&linphonec_vtable, configDb, (__bridge void *)(self) /* user_data */); /* set the CA file no matter what, since the remote provisioning could be hitting an HTTPS server */ - const char *lRootCa = - [[LinphoneManager bundleFile:@"rootca.pem"] cStringUsingEncoding:[NSString defaultCStringEncoding]]; + const char *lRootCa = [[LinphoneManager bundleFile:@"rootca.pem"] UTF8String]; linphone_core_set_root_ca(theLinphoneCore, lRootCa); linphone_core_set_user_certificates_path(theLinphoneCore, [[LinphoneManager cacheDirectory] UTF8String]); @@ -1768,8 +1758,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { factory = factoryIpad; } NSString *confiFileName = [LinphoneManager documentFile:@"linphonerc"]; - configDb = lp_config_new_with_factory([confiFileName cStringUsingEncoding:[NSString defaultCStringEncoding]], - [factory cStringUsingEncoding:[NSString defaultCStringEncoding]]); + configDb = lp_config_new_with_factory([confiFileName UTF8String], [factory UTF8String]); } #pragma mark - Audio route Functions @@ -1803,7 +1792,7 @@ static void audioRouteChangeListenerCallback(void *inUserData, // 1 OSStatus lStatus = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &lNewRouteSize, &lNewRoute); if (!lStatus && lNewRouteSize > 0) { NSString *route = (__bridge NSString *)lNewRoute; - LOGI(@"Current audio route is [%s]", [route cStringUsingEncoding:[NSString defaultCStringEncoding]]); + LOGI(@"Current audio route is [%s]", [route UTF8String]); speakerEnabled = [route isEqualToString:@"Speaker"] || [route isEqualToString:@"SpeakerAndMicrophone"]; if (!LinphoneManager.runningOnIpad && [route isEqualToString:@"HeadsetBT"] && !speakerEnabled) { @@ -1907,18 +1896,7 @@ static void audioRouteChangeListenerCallback(void *inUserData, // 1 // Continue by checking that the provided address is a valid SIP address, abort otherwise. if ([address length] == 0) { // no address provided... nothing to do - } else if (![address canBeConvertedToEncoding:[NSString defaultCStringEncoding]]) { - UIAlertView *error = [[UIAlertView alloc] - initWithTitle:NSLocalizedString(@"Invalid SIP address", nil) - message:NSLocalizedString( - @"Some invalid characters where found in the given SIP address. Please correct it.", - nil) - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil]; - [error show]; - } else if ((addr = linphone_core_interpret_url( - theLinphoneCore, [address cStringUsingEncoding:[NSString defaultCStringEncoding]])) == NULL) { + } else if ((addr = linphone_core_interpret_url(theLinphoneCore, address.UTF8String)) == NULL) { UIAlertView *error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Invalid SIP address", nil) message:NSLocalizedString(@"Either configure a SIP proxy server from settings prior to place a " @@ -1937,14 +1915,13 @@ static void audioRouteChangeListenerCallback(void *inUserData, // 1 LOGI(@"Enabling low bandwidth mode"); linphone_call_params_enable_low_bandwidth(lcallParams, YES); } + if (displayName != nil) { - linphone_address_set_display_name(addr, - [displayName cStringUsingEncoding:[NSString defaultCStringEncoding]]); + linphone_address_set_display_name(addr, displayName.UTF8String); } if ([[LinphoneManager instance] lpConfigBoolForKey:@"override_domain_with_default_one"]) { linphone_address_set_domain( - addr, [[[LinphoneManager instance] lpConfigStringForKey:@"domain" forSection:@"assistant"] - cStringUsingEncoding:[NSString defaultCStringEncoding]]); + addr, [[[LinphoneManager instance] lpConfigStringForKey:@"domain" forSection:@"assistant"] UTF8String]); } if (transfer) { diff --git a/Classes/Utils/Utils.m b/Classes/Utils/Utils.m index 890d666dc..89789b812 100644 --- a/Classes/Utils/Utils.m +++ b/Classes/Utils/Utils.m @@ -33,8 +33,7 @@ va_list args; va_start(args, format); NSString *str = [[NSString alloc] initWithFormat:format arguments:args]; - NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(CFStringGetSystemEncoding()); - const char *utf8str = [str cStringUsingEncoding:enc]; + const char *utf8str = [str cStringUsingEncoding:NSString.defaultCStringEncoding]; int filesize = 20; const char *filename = strchr(file, '/') ? strrchr(file, '/') + 1 : file; if (severity <= ORTP_DEBUG) {