From 729bd6a5561c2b6dc240a9f05af03f3feed1fc68 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Tue, 15 Oct 2019 14:23:14 +0200 Subject: [PATCH] some fix for lime devices view --- Classes/DevicesListView.m | 15 +++++++++++---- Classes/LinphoneCoreSettingsStore.m | 5 +---- Classes/LinphoneUI/UIDevicesDetails.h | 2 +- Classes/LinphoneUI/UIDevicesDetails.m | 19 +++++++++++++++++-- Classes/SettingsView.m | 4 ---- Podfile | 4 ++-- Settings/InAppSettings.bundle/Call.plist | 24 ++++++++++++++++++++++++ Settings/InAppSettings.bundle/Chat.plist | 22 ---------------------- 8 files changed, 56 insertions(+), 39 deletions(-) diff --git a/Classes/DevicesListView.m b/Classes/DevicesListView.m index 2bffcbf50..4eb48d10f 100644 --- a/Classes/DevicesListView.m +++ b/Classes/DevicesListView.m @@ -74,8 +74,9 @@ static UICompositeViewDescription *compositeDescription = nil; } LinphoneParticipant *me = linphone_chat_room_get_me(_room); - [_devicesMenuEntries - addObject:[[DevicesMenuEntry alloc] initWithTitle:me number:0 isMe:TRUE]]; + // not show me if there is only one device + if (bctbx_list_size(linphone_participant_get_devices(me)) > 1) + [_devicesMenuEntries addObject:[[DevicesMenuEntry alloc] initWithTitle:me number:0 isMe:TRUE]]; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [_tableView reloadData]; @@ -117,14 +118,20 @@ static UICompositeViewDescription *compositeDescription = nil; entry->myself ? cell.addressLabel.text = NSLocalizedString(@"Me", nil) : [ContactDisplay setDisplayNameLabel:cell.addressLabel forAddress:linphone_participant_get_address(entry->participant)]; cell.participant = entry->participant; - [cell update:(entry->numberOfDevices != 0)]; + [cell update:(entry->numberOfDevices != 0) isMyself:entry->myself]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { DevicesMenuEntry *entry = [_devicesMenuEntries objectAtIndex:indexPath.row]; - NSInteger num = (entry->numberOfDevices != 0) ? 0: bctbx_list_size(linphone_participant_get_devices(entry->participant)); + NSInteger num = 0; + if (entry->numberOfDevices == 0) { + num = bctbx_list_size(linphone_participant_get_devices(entry->participant)); + // not show current device + if (entry->myself) + num -= 1; + } [_devicesMenuEntries replaceObjectAtIndex:indexPath.row withObject:[[DevicesMenuEntry alloc] initWithTitle:entry->participant number:num isMe:entry->myself]]; [_tableView reloadData]; } diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 00ab58d35..c979d8b13 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -337,7 +337,6 @@ // chat section { - [self setInteger:linphone_core_lime_enabled(LC) forKey:@"use_lime_preference"]; [self setCString:linphone_core_get_file_transfer_server(LC) forKey:@"file_transfer_server_url_preference"]; int maxSize = linphone_core_get_max_size_for_auto_download_incoming_files(LC); [self setObject:maxSize==0 ? @"Always" : (maxSize==-1 ? @"Nerver" : @"Customize") forKey:@"auto_download_mode"]; @@ -770,9 +769,7 @@ linphone_core_set_media_encryption_mandatory(LC, [self boolForKey:@"media_encrption_mandatory_preference"]); // chat section - int val = [self integerForKey:@"use_lime_preference"]; - linphone_core_enable_lime(LC, val); - if (val == LinphoneLimeMandatory && (linphone_core_get_media_encryption(LC) != LinphoneMediaEncryptionZRTP)) { + if (linphone_core_get_media_encryption(LC) != LinphoneMediaEncryptionZRTP) { linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionZRTP); [self setCString:"ZRTP" forKey:@"media_encryption_preference"]; UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"ZRTP activation", nil) diff --git a/Classes/LinphoneUI/UIDevicesDetails.h b/Classes/LinphoneUI/UIDevicesDetails.h index aa556287d..b934c1ff3 100644 --- a/Classes/LinphoneUI/UIDevicesDetails.h +++ b/Classes/LinphoneUI/UIDevicesDetails.h @@ -31,5 +31,5 @@ - (IBAction)onSecurityCallClick:(id)sender; - (id)initWithIdentifier:(NSString *)identifier; -- (void)update:(BOOL)listOpen; +- (void)update:(BOOL)listOpen isMyself:(BOOL)isMyself; @end diff --git a/Classes/LinphoneUI/UIDevicesDetails.m b/Classes/LinphoneUI/UIDevicesDetails.m index b5530cccd..8cc13fa4c 100644 --- a/Classes/LinphoneUI/UIDevicesDetails.m +++ b/Classes/LinphoneUI/UIDevicesDetails.m @@ -37,8 +37,23 @@ return self; } -- (void)update:(BOOL)listOpen { - _devices = linphone_participant_get_devices(_participant); +- (void)update:(BOOL)listOpen isMyself:(BOOL)isMyself { + _devices = linphone_participant_get_devices(_participant); + if (isMyself) { + // remove my device + // TODO replaced by bctbx_list_remove_custom when server can remove device which has no app + bctbx_list_t *cur; + bctbx_list_t *elem = _devices; + while (elem != NULL) { + cur = elem; + elem = elem->next; + if ([[NSString stringWithUTF8String:linphone_participant_device_get_name(cur->data) ? : + linphone_address_as_string_uri_only(linphone_participant_device_get_address(cur->data))] isEqualToString:[[UIDevice currentDevice] name]]) { + _devices = bctbx_list_remove(_devices, cur->data); + break; + } + } + } UIImage *image = [FastAddressBook imageForSecurityLevel:linphone_participant_get_security_level(_participant)]; if (bctbx_list_size(_devices) == 1) { [_securityButton setImage:image forState:UIControlStateNormal]; diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index 7875f6063..eae57d6a4 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -596,10 +596,6 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat [hiddenKeys addObject:@"media_encryption_preference"]; } - if (!linphone_core_lime_available(LC)) { - [hiddenKeys addObject:@"use_lime_preference"]; - } - #ifndef DEBUG [hiddenKeys addObject:@"debug_actions_group"]; [hiddenKeys addObject:@"release_button"]; diff --git a/Podfile b/Podfile index ae9a8666c..05790a20c 100644 --- a/Podfile +++ b/Podfile @@ -5,9 +5,9 @@ source "https://github.com/CocoaPods/Specs.git" def basic_pods if ENV['PODFILE_PATH'].nil? - pod 'linphone-sdk', '4.2' + pod 'linphone-sdk/basic-frameworks', '> 4.3.0-alpha' else - pod 'linphone-sdk', :path => ENV['PODFILE_PATH'] # loacl sdk + pod 'linphone-sdk/basic-frameworks', :path => ENV['PODFILE_PATH'] # loacl sdk end if not ENV['USE_CRASHLYTHICS'].nil? diff --git a/Settings/InAppSettings.bundle/Call.plist b/Settings/InAppSettings.bundle/Call.plist index abd10a652..c9e27aee4 100644 --- a/Settings/InAppSettings.bundle/Call.plist +++ b/Settings/InAppSettings.bundle/Call.plist @@ -98,6 +98,30 @@ Type PSToggleSwitchSpecifier + + DefaultValue + None + Key + media_encryption_preference + Title + Media Encryption + Titles + + None + SRTP + ZRTP + DTLS + + Type + PSMultiValueSpecifier + Values + + None + SRTP + ZRTP + DTLS + + DefaultValue diff --git a/Settings/InAppSettings.bundle/Chat.plist b/Settings/InAppSettings.bundle/Chat.plist index 7a79b86d0..dbc290ddb 100644 --- a/Settings/InAppSettings.bundle/Chat.plist +++ b/Settings/InAppSettings.bundle/Chat.plist @@ -40,28 +40,6 @@ IASKTextAlignment IASKUITextAlignmentRight - - DefaultValue - 0 - Type - PSMultiValueSpecifier - Titles - - Disabled - Preferred - Mandatory - - Values - - 0 - 2 - 1 - - Title - Encrypt messages with LIME - Key - use_lime_preference - Type PSGroupSpecifier