From d96228ef44add10b882a977ec53688e00059a46d Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Fri, 23 Sep 2022 00:37:26 +0200 Subject: [PATCH] Option to schedule meeting from group chat --- Classes/ChatConversationView.m | 45 +++++++++++++------ .../Voip/ViewModels/ConferenceViewModel.swift | 8 ++++ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 484d525bc..8a31f6d29 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -1781,7 +1781,14 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog [self onToggleMenu:nil]; BOOL isEncrypted = ![ChatConversationView isBasicChatRoom:_chatRoom]; - if (indexPath.row == 0) { + int firstIndex = isOneToOne ? 0 : 1; + + if (!isOneToOne && indexPath.row == 0) { //Schedule meeting + [ConferenceViewModelBridge scheduleFromGroupChatWithCChatRoom:_chatRoom]; + [PhoneMainView.instance popToView:ConferenceSchedulingView.compositeViewDescription]; + } + + if (indexPath.row == firstIndex) { if (isOneToOne) { [self addOrGoToContact:linphone_chat_room_get_peer_address(_chatRoom)]; } else { @@ -1789,27 +1796,27 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog } } - if (isEncrypted && indexPath.row == 1) { + if (isEncrypted && indexPath.row == 1+firstIndex) { [self goToDeviceListView]; } BOOL canEphemeral = [self canAdminEphemeral:_chatRoom]; - if (canEphemeral && indexPath.row == 2) { + if (canEphemeral && indexPath.row == 2+firstIndex) { EphemeralSettingsView *view = VIEW(EphemeralSettingsView); view.room = _chatRoom; [PhoneMainView.instance popToView:view.compositeViewDescription]; } - if ((!isEncrypted && indexPath.row == 1) || (isEncrypted && indexPath.row == 3)) { + if ((!isEncrypted && indexPath.row == 1+firstIndex) || (isEncrypted && indexPath.row == 3+firstIndex)) { [self toggleMuteConversation]; } - if ((!isEncrypted && indexPath.row == 2) || (isEncrypted && indexPath.row == 4)) { + if ((!isEncrypted && indexPath.row == 2+firstIndex) || (isEncrypted && indexPath.row == 4+firstIndex)) { [_tableController onEditClick:nil]; [self onEditionChangeClick:nil]; } - if ((isEncrypted && ((!canEphemeral && indexPath.row == 4)||(canEphemeral && indexPath.row == 5))) - || (!isEncrypted && indexPath.row == 3)) { + if ((isEncrypted && ((!canEphemeral && indexPath.row == 4+firstIndex)||(canEphemeral && indexPath.row == 5+firstIndex))) + || (!isEncrypted && indexPath.row == 3+firstIndex)) { [self showAddressAndIdentityPopup]; } } @@ -1832,13 +1839,23 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog if ([self canAdminEphemeral:_chatRoom]) ++nbRows; + if (!isOneToOne) // schedule meeting + ++nbRows; + return nbRows; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [[UITableViewCell alloc] init]; - if (indexPath.row == 0) { + int firstIndex = isOneToOne ? 0 : 1; + + if (!isOneToOne && indexPath.row == 0) { + cell.imageView.image = [LinphoneUtils resizeImage:[UIImage imageNamed:@"menu_voip_meeting_schedule"] newSize:CGSizeMake(25, 25)]; + cell.textLabel.text = NSLocalizedString(@"Schedule a meeting",nil); + } + + if (indexPath.row == firstIndex) { if (isOneToOne) { Contact *contact = [FastAddressBook getContactWithAddress:linphone_chat_room_get_peer_address(_chatRoom)]; if (contact == nil) { @@ -1854,18 +1871,18 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog } } - if (isEncrypted && indexPath.row == 1) { + if (isEncrypted && indexPath.row == 1+firstIndex) { cell.imageView.image = [LinphoneUtils resizeImage:[UIImage imageNamed:@"menu_security_default.png"] newSize:CGSizeMake(20, 25)]; cell.textLabel.text = NSLocalizedString(@"Conversation's devices",nil); } bool canEphemeral = [self canAdminEphemeral:_chatRoom]; - if (canEphemeral && indexPath.row == 2) { + if (canEphemeral && indexPath.row == 2+firstIndex) { cell.imageView.image = [LinphoneUtils resizeImage:[UIImage imageNamed:@"ephemeral_messages_default.png"] newSize:CGSizeMake(20, 25)]; cell.textLabel.text = NSLocalizedString(@"Ephemeral messages",nil); } - if ((isEncrypted && indexPath.row == 3) || (!isEncrypted && indexPath.row == 1)) { + if ((isEncrypted && indexPath.row == 3+firstIndex) || (!isEncrypted && indexPath.row == 1+firstIndex)) { if ([self isConversationMuted]) { cell.imageView.image = [LinphoneUtils resizeImage:[UIImage imageNamed:@"menu_notifications_off.png"] newSize:CGSizeMake(20, 25)]; cell.textLabel.text = NSLocalizedString(@"NOT IMPLEMENTED",nil); @@ -1875,13 +1892,13 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog } } - if ((isEncrypted && indexPath.row == 4) || (!isEncrypted && indexPath.row == 2)) { + if ((isEncrypted && indexPath.row == 4+firstIndex) || (!isEncrypted && indexPath.row == 2+firstIndex)) { cell.imageView.image = [LinphoneUtils resizeImage:[UIImage imageNamed:@"delete_default.png"] newSize:CGSizeMake(20, 25)]; cell.textLabel.text = NSLocalizedString(@"Delete messages",nil); } - if ((isEncrypted && ((!canEphemeral && indexPath.row == 4)||(canEphemeral && indexPath.row == 5))) - || (!isEncrypted && indexPath.row == 3)) { + if ((isEncrypted && ((!canEphemeral && indexPath.row == 4+firstIndex)||(canEphemeral && indexPath.row == 5+firstIndex))) + || (!isEncrypted && indexPath.row == 3+firstIndex)) { cell.imageView.image = [LinphoneUtils resizeImage:[UIImage imageNamed:@"chat_group_informations.png"] newSize:CGSizeMake(25, 25)]; cell.textLabel.text = NSLocalizedString(@"Show address and identity",nil); } diff --git a/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift b/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift index c503a603f..d1479cd5a 100644 --- a/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift +++ b/Classes/Swift/Voip/ViewModels/ConferenceViewModel.swift @@ -498,6 +498,14 @@ class ConferenceViewModel { VoipDialog.toast(message: message) } + @objc static func scheduleFromGroupChat(cChatRoom: OpaquePointer ) { + ConferenceSchedulingViewModel.shared.reset() + ChatRoom.getSwiftObject(cObject: cChatRoom).participants.forEach { + ConferenceSchedulingViewModel.shared.selectedAddresses.value?.append($0.address!) + } + ConferenceSchedulingViewModel.shared.scheduleForLater.value = true + } + }