diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index c24b14f34..1b84a20a4 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -240,6 +240,10 @@ static UICompositeViewDescription *compositeDescription = nil; linphone_chat_message_unref(msg); [_tableController scrollToBottom:true]; + + if(linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(_chatRoom)) { + [LinphoneManager.instance alertLIME:_chatRoom]; + } return TRUE; } diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 2c2682b0e..56fd9ab28 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -271,7 +271,6 @@ actions:[NSArray arrayWithObjects:act_confirm, act_deny, nil] intentIdentifiers:[[NSMutableArray alloc] init] options:UNNotificationCategoryOptionCustomDismissAction]; - [UNUserNotificationCenter currentNotificationCenter].delegate = self; [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionAlert | UNAuthorizationOptionSound | @@ -708,6 +707,10 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response if (room) { LinphoneChatMessage *msg = linphone_chat_room_create_message(room, replyText.UTF8String); linphone_chat_room_send_chat_message(room, msg); + + if(linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room)) { + [LinphoneManager.instance alertLIME:room]; + } linphone_chat_room_mark_as_read(room); TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)]; @@ -750,6 +753,8 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response if (linphone_core_get_current_call(LC) == call) { linphone_call_set_authentication_token_verified(call, NO); } + } else if ([response.actionIdentifier isEqual:@"Call"]) { + } else { // in this case the value is : com.apple.UNNotificationDefaultActionIdentifier if ([response.notification.request.content.categoryIdentifier isEqual:@"call_cat"]) { [PhoneMainView.instance displayIncomingCall:call]; @@ -898,6 +903,11 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response if (room) { LinphoneChatMessage *msg = linphone_chat_room_create_message(room, replyText.UTF8String); linphone_chat_room_send_chat_message(room, msg); + + if(linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room)) { + [LinphoneManager.instance alertLIME:room]; + } + linphone_chat_room_mark_as_read(room); [PhoneMainView.instance updateApplicationBadgeNumber]; } diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 6529a0fb7..dbd914ca4 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -323,6 +323,12 @@ [self setBool:[lm lpConfigBoolForKey:@"repeat_call_notification"] forKey:@"repeat_call_notification_preference"]; } + + // 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"]; + } // network section { @@ -409,7 +415,6 @@ [self setCString:linphone_address_get_username(parsed) forKey:@"primary_username_preference"]; linphone_address_destroy(parsed); } - [self setCString:linphone_core_get_file_transfer_server(LC) forKey:@"file_transfer_server_url_preference"]; } changedDict = [[NSMutableDictionary alloc] init]; @@ -742,6 +747,29 @@ [lm lpConfigSetBool:[self boolForKey:@"repeat_call_notification_preference"] forKey:@"repeat_call_notification"]; } + + // 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)) { + linphone_core_set_media_encryption(LC, LinphoneMediaEncryptionZRTP); + [self setCString:"ZRTP" forKey:@"media_encryption_preference"]; + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"ZRTP activation", nil) + message:NSLocalizedString(@"LIME requires ZRTP encryption.\n" + @"By activating LIME you automatically ZRTP media encryption.", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + [errView addAction:defaultAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; + } + linphone_core_set_file_transfer_server( + LC, [[self stringForKey:@"file_transfer_server_url_preference"] UTF8String]); + } // network section { @@ -878,9 +906,6 @@ [lm lpConfigSetInt:[self integerForKey:@"account_mandatory_advanced_preference"] forKey:@"account_mandatory_advanced_preference"]; - - linphone_core_set_file_transfer_server( - LC, [[self stringForKey:@"file_transfer_server_url_preference"] UTF8String]); } changedDict = [[NSMutableDictionary alloc] init]; diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index c785def8c..eb48a0452 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -140,6 +140,7 @@ typedef struct _LinphoneManagerSounds { - (void)acceptCallForCallId:(NSString*)callid; - (LinphoneCall *)callByCallId:(NSString *)call_id; - (void)cancelLocalNotifTimerForCallId:(NSString*)callid; +- (void) alertLIME:(LinphoneChatRoom *)room; + (BOOL)langageDirectionIsRTL; + (void)kickOffNetworkConnection; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index d60560963..1ee361e56 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1360,6 +1360,27 @@ static void linphone_iphone_call_encryption_changed(LinphoneCore *lc, LinphoneCa } #pragma mark - Message composition start +- (void) alertLIME:(LinphoneChatRoom *)room { + UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"LIME Error", nil) + message:NSLocalizedString(@"You are trying to send a message using LIME to a contact not verified by ZRTP.\n" + @"Please call this contact and verify his ZRTP key before sending your messages.", + nil) + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) {}]; + [errView addAction:defaultAction]; + + UIAlertAction* callAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Call", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + [self call:linphone_chat_room_get_peer_address(room)]; + }]; + [errView addAction:callAction]; + [PhoneMainView.instance presentViewController:errView animated:YES completion:nil]; +} + - (void)onMessageComposeReceived:(LinphoneCore *)core forRoom:(LinphoneChatRoom *)room { [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneTextComposeEvent diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index ad771a29e..e658f782d 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -593,6 +593,10 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat if (!linphone_core_sip_transport_supported(LC, LinphoneTransportTls)) { [hiddenKeys addObject:@"media_encryption_preference"]; } + + if(!linphone_core_lime_available(LC)) { + [hiddenKeys addObject:@"use_lime_preference"]; + } #ifndef DEBUG [hiddenKeys addObject:@"debug_actions_group"]; diff --git a/Classes/Utils/FileTransferDelegate.m b/Classes/Utils/FileTransferDelegate.m index dc63afed5..ddd22a714 100644 --- a/Classes/Utils/FileTransferDelegate.m +++ b/Classes/Utils/FileTransferDelegate.m @@ -9,6 +9,7 @@ #import "FileTransferDelegate.h" #import "Utils.h" #import "PhoneMainView.h" +#import "LinphoneManager.h" @interface FileTransferDelegate () @property(strong) NSMutableData *data; @@ -171,8 +172,12 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m } LOGI(@"%p Uploading content from message %p", self, _message); - linphone_chat_room_send_chat_message(chatRoom, _message); + + if(linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(chatRoom)) { + [LinphoneManager.instance alertLIME:chatRoom]; + } + } - (BOOL)download:(LinphoneChatMessage *)message { diff --git a/Settings/InAppSettings.bundle/Advanced.plist b/Settings/InAppSettings.bundle/Advanced.plist index 2e3e28ca1..d97e858c8 100644 --- a/Settings/InAppSettings.bundle/Advanced.plist +++ b/Settings/InAppSettings.bundle/Advanced.plist @@ -160,28 +160,6 @@ IASKTextAlignment IASKUITextAlignmentRight - - Type - PSGroupSpecifier - Title - File sharing - - - AutocapitalizationType - None - AutocorrectionType - No - KeyboardType - URL - Type - PSTextFieldSpecifier - Title - Server URL - Key - file_transfer_server_url_preference - IASKTextAlignment - IASKUITextAlignmentRight - diff --git a/Settings/InAppSettings.bundle/Root.plist b/Settings/InAppSettings.bundle/Root.plist index f37c4fd13..cbaee0e91 100644 --- a/Settings/InAppSettings.bundle/Root.plist +++ b/Settings/InAppSettings.bundle/Root.plist @@ -114,6 +114,16 @@ Type PSChildPaneSpecifier + + Type + PSChildPaneSpecifier + Key + message_menu + Title + Chat + File + Message + Key network_menu diff --git a/Settings/InAppSettings.bundle/message.plist b/Settings/InAppSettings.bundle/message.plist new file mode 100644 index 000000000..17739d229 --- /dev/null +++ b/Settings/InAppSettings.bundle/message.plist @@ -0,0 +1,53 @@ + + + + + PreferenceSpecifiers + + + DefaultValue + 0 + Type + PSMultiValueSpecifier + Titles + + Disabled + Preferred + Mandatory + + Values + + 0 + 2 + 1 + + Title + Encrypt messages with LIME + Key + use_lime_preference + + + Type + PSGroupSpecifier + Title + File sharing + + + AutocapitalizationType + None + AutocorrectionType + No + KeyboardType + URL + Type + PSTextFieldSpecifier + Title + Server URL + Key + file_transfer_server_url_preference + IASKTextAlignment + IASKUITextAlignmentRight + + + + diff --git a/Settings/message.plist b/Settings/message.plist new file mode 100644 index 000000000..15f4d8b46 --- /dev/null +++ b/Settings/message.plist @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/submodules/belcard b/submodules/belcard index 63e61b0ae..f5a8603f8 160000 --- a/submodules/belcard +++ b/submodules/belcard @@ -1 +1 @@ -Subproject commit 63e61b0ae0f20e6d9f790335184fa4a0fc2a90ab +Subproject commit f5a8603f8e379486d3a4bfa4d74861b0a2d880dd diff --git a/submodules/linphone b/submodules/linphone index 1c92cdd44..2751c8a70 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 1c92cdd4466d8af34ff3faa1db7e2e3f0c8f5d46 +Subproject commit 2751c8a703152f553247aa96d7b6d3ba72f4c4b1