Add all ChatConversation callbacks (delegates)

This commit is contained in:
Benoit Martins 2023-02-15 15:33:56 +01:00 committed by QuentinArguillere
parent 8a4f1046c6
commit 54bfcb22e0
7 changed files with 109 additions and 25 deletions

View file

@ -217,7 +217,7 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (void)onValidate {
ChatConversationView *view = VIEW(ChatConversationView);
ChatConversationViewSwift *view = VIEW(ChatConversationViewSwift);
// Change subject if necessary
if (![_oldSubject isEqualToString:_nameLabel.text])
linphone_chat_room_set_subject(_room, _nameLabel.text.UTF8String);

View file

@ -398,7 +398,7 @@ static UICompositeViewDescription *compositeDescription = nil;
linphone_chat_room_cbs_set_is_composing_received(_chatRoomCbs, on_chat_room_is_composing_received);
linphone_chat_room_cbs_set_conference_joined(_chatRoomCbs, on_chat_room_conference_joined);
linphone_chat_room_cbs_set_conference_left(_chatRoomCbs, on_chat_room_conference_left);
linphone_chat_room_cbs_set_security_event(_chatRoomCbs, on_chat_room_conference_alert);
linphone_chat_room_cbs_set_security_event(_chatRoomCbs, on_chat_room_conference_alert);
linphone_chat_room_cbs_set_user_data(_chatRoomCbs, (__bridge void*)self);
linphone_chat_room_add_callbacks(_chatRoom, _chatRoomCbs);
}

View file

@ -27,6 +27,12 @@ public extension ChatConversationTableView {
super.viewDidAppear(animated)
createFloatingButton()
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidAppear(animated)
self.floatingScrollButton?.removeFromSuperview()
self.floatingScrollBackground?.removeFromSuperview()
}
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if let lastCellRowIndex = tableView.indexPathsForVisibleRows?.last?.row {

View file

@ -113,7 +113,7 @@
[view equal:ChatConversationCreateView.compositeViewDescription] ||
[view equal:ChatConversationInfoView.compositeViewDescription] ||
[view equal:ChatConversationImdnView.compositeViewDescription] ||
[view equal:ChatConversationView.compositeViewDescription];
[view equal:ChatConversationViewSwift.compositeViewDescription];
if ([LinphoneManager.instance lpConfigBoolForKey:@"disable_chat_feature"] && [self viewIsCurrentlyPortrait]) {
CGFloat itemWidth = [UIScreen mainScreen].bounds.size.width/3;
[_chatButton setEnabled:false];

View file

@ -465,7 +465,7 @@ static RootViewManager *rootViewManagerInstance = nil;
// we'll already be on the corresponding chat conversation view, no need to go anywhere else
if (dict||dictFile||dictUrl){
[self changeCurrentView:ChatsListView.compositeViewDescription];
}else if (![[self currentView].name isEqualToString:@"ChatConversationView"]) {
}else if (![[self currentView].name isEqualToString:@"ChatConversationViewSwift"]) {
if (linphone_core_get_global_state(LC) != LinphoneGlobalOn) {
[self changeCurrentView:DialerView.compositeViewDescription];
@ -851,7 +851,7 @@ static RootViewManager *rootViewManagerInstance = nil;
return;
}
[self goToChatRoom:room];
[self goToChatRoomSwift:room];
}
- (LinphoneChatRoom *)createChatRoom:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView isEncrypted:(BOOL)isEncrypted isGroup:(BOOL)isGroup{
@ -874,7 +874,7 @@ static RootViewManager *rootViewManagerInstance = nil;
return nil;
}
LinphoneChatRoom *basicRoom = linphone_core_get_chat_room(LC, addresses->data);
[self goToChatRoom:basicRoom];
[self goToChatRoomSwift:basicRoom];
return nil;
}
@ -939,11 +939,11 @@ void main_view_chat_room_conference_joined(LinphoneChatRoom *cr, const LinphoneE
PhoneMainView *view = PhoneMainView.instance;
LOGI(@"Chat room [%p] conference joined.", cr);
linphone_chat_room_remove_callbacks(cr, linphone_chat_room_get_current_callbacks(cr));
[view goToChatRoom:cr];
[view goToChatRoomSwift:cr];
if (!IPAD)
return;
if (PhoneMainView.instance.currentView != ChatsListView.compositeViewDescription && PhoneMainView.instance.currentView != ChatConversationView.compositeViewDescription)
if (PhoneMainView.instance.currentView != ChatsListView.compositeViewDescription && PhoneMainView.instance.currentView != ChatConversationViewSwift.compositeViewDescription)
return;
ChatsListView *mainView = VIEW(ChatsListView);
@ -962,7 +962,7 @@ void main_view_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomSta
break;
case LinphoneChatRoomStateTerminated:
LOGI(@"Chat room [%p] has been terminated.", cr);
[view goToChatRoom:cr];
[view goToChatRoomSwift:cr];
break;
default:
break;

View file

@ -66,7 +66,7 @@ import AVFoundation
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: top_bar_height*2), collectionViewLayout: layout)
collectionView.translatesAutoresizingMaskIntoConstraints = false
collectionView.backgroundColor = UIColor(white: 1, alpha: 0.5)
collectionView.backgroundColor = VoipTheme.voipToolbarBackgroundColor.get()
return collectionView
}()
@ -207,9 +207,24 @@ import AVFoundation
self.on_chat_room_is_composing_received(room, remoteAddress, isComposing)
}, onChatMessageReceived: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_chat_message_received(room, event)
},
onChatMessageSending: { (room: ChatRoom, event: EventLog) -> Void in
}, onChatMessageSending: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_chat_message_sending(room, event)
}, onParticipantAdded: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_participant_changed(room, event)
}, onParticipantRemoved: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_participant_changed(room, event)
}, onParticipantAdminStatusChanged: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_participant_admin_status_changed(room, event)
}, onStateChanged: { (room: ChatRoom, state: ChatRoom.State) -> Void in
self.on_chat_room_state_changed(room)
}, onSecurityEvent: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_conference_alert(room, event)
}, onSubjectChanged: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_subject_changed(room, event)
}, onConferenceJoined: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_conference_joined(room, event)
}, onConferenceLeft: { (room: ChatRoom, event: EventLog) -> Void in
self.on_chat_room_conference_left(room, event)
}
)
@ -217,7 +232,7 @@ import AVFoundation
tableController.tableView.separatorColor = .clear
if !chatRoom!.isReadOnly {
messageView.ephemeralIndicator.isHidden = (linphone_chat_room_ephemeral_enabled(chatRoom?.getCobject) == 0)
messageView.ephemeralIndicator.isHidden = !chatRoom!.ephemeralEnabled
}
workItem = DispatchWorkItem {
@ -483,7 +498,7 @@ import AVFoundation
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_delete_messages)
if !chatRoom!.isReadOnly {
messageView.ephemeralIndicator.isHidden = (linphone_chat_room_ephemeral_enabled(chatRoom?.getCobject) == 0)
messageView.ephemeralIndicator.isHidden = !chatRoom!.ephemeralEnabled
}
}
@ -509,14 +524,7 @@ import AVFoundation
titleParticipants.isHidden = false
let participants = chatRoom?.participants
participantsGroupLabel.text = ""
participants?.forEach{ participant in
if participantsGroupLabel.text != "" {
participantsGroupLabel.text = participantsGroupLabel.text! + ", "
}
participantsGroupLabel.text = participantsGroupLabel.text! + FastAddressBook.displayName(for: linphone_participant_get_address(participant.getCobject))
}
updateParticipantLabel()
}
@ -524,15 +532,28 @@ import AVFoundation
if !chatRoom!.isReadOnly{
changeCallIcon(groupChat: changeIcon)
action1BisButton.isEnabled = true
}else{
action1Button.isHidden = true
action1BisButton.isHidden = true
action1BisButton.isHidden = false
action1BisButton.isEnabled = false
}
let secureLevel = FastAddressBook.image(for: linphone_chat_room_get_security_level(cChatRoom))
changeSecureLevel(secureLevel: secureLevel != nil, imageBadge: secureLevel)
initDataSource(groupeChat: !isOneToOneChat, secureLevel: secureLevel != nil, cChatRoom: cChatRoom)
}
func updateParticipantLabel(){
let participants = chatRoom?.participants
participantsGroupLabel.text = ""
participants?.forEach{ participant in
if participantsGroupLabel.text != "" {
participantsGroupLabel.text = participantsGroupLabel.text! + ", "
}
participantsGroupLabel.text = participantsGroupLabel.text! + FastAddressBook.displayName(for: linphone_participant_get_address(participant.getCobject))
}
}
func onCallClick(cChatRoom: OpaquePointer?) {
let firstParticipant = chatRoom?.participants.first
let addr = (firstParticipant != nil) ? linphone_participant_get_address(firstParticipant?.getCobject) : linphone_chat_room_get_peer_address(cChatRoom);
@ -676,7 +697,7 @@ import AVFoundation
}
let msg = rootMessage
let basic = ChatConversationView.isBasicChatRoom(chatRoom?.getCobject)
let basic = ChatConversationViewSwift.isBasicChatRoom(chatRoom?.getCobject)
let params = linphone_account_get_params(linphone_core_get_default_account(LinphoneManager.getLc()))
let cpimEnabled = linphone_account_params_cpim_in_basic_chat_room_enabled(params)
@ -1869,4 +1890,61 @@ import AVFoundation
messageView.isHidden = chatRoom!.isReadOnly
}
}
func on_chat_room_state_changed(_ cr: ChatRoom?) {
configureMessageField()
action1BisButton.isEnabled = !chatRoom!.isReadOnly
let isOneToOneChat = chatRoom!.hasCapability(mask: Int(LinphoneChatRoomCapabilitiesOneToOne.rawValue))
let secureLevel = FastAddressBook.image(for: linphone_chat_room_get_security_level(cr?.getCobject))
initDataSource(groupeChat: !isOneToOneChat, secureLevel: secureLevel != nil, cChatRoom: (cr?.getCobject)!)
}
func on_chat_room_subject_changed(_ cr: ChatRoom?, _ event_log: EventLog?) {
let subject = event_log?.subject != nil ? event_log?.subject : cr?.subject
if let subject {
titleGroupLabel.text = subject
titleLabel.text = subject
tableController.addEventEntry(event_log?.getCobject)
tableController.scroll(toBottom: true)
}
}
func on_chat_room_participant_changed(_ cr: ChatRoom?, _ event_log: EventLog?) {
tableController.addEventEntry(event_log?.getCobject)
updateParticipantLabel()
tableController.scroll(toBottom: true)
let secureLevel = FastAddressBook.image(for: linphone_chat_room_get_security_level(cr?.getCobject))
changeSecureLevel(secureLevel: secureLevel != nil, imageBadge: secureLevel)
}
func on_chat_room_participant_admin_status_changed(_ cr: ChatRoom?, _ event_log: EventLog?) {
tableController.addEventEntry(event_log?.getCobject)
tableController.scroll(toBottom: true)
}
func on_chat_room_conference_joined(_ cr: ChatRoom?, _ event_log: EventLog?) {
tableController.addEventEntry(event_log?.getCobject)
tableController.scroll(toBottom: true)
}
func on_chat_room_conference_left(_ cr: ChatRoom?, _ event_log: EventLog?) {
tableController.addEventEntry(event_log?.getCobject)
tableController.scroll(toBottom: true)
}
func on_chat_room_conference_alert(_ cr: ChatRoom?, _ event_log: EventLog?) {
tableController.addEventEntry(event_log?.getCobject)
updateParticipantLabel()
tableController.scroll(toBottom: true)
let secureLevel = FastAddressBook.image(for: linphone_chat_room_get_security_level(cr?.getCobject))
changeSecureLevel(secureLevel: secureLevel != nil, imageBadge: secureLevel)
}
class func markAsRead(chatRoom: ChatRoom?) {
if chatRoom == nil {
return
}
chatRoom!.markAsRead()
PhoneMainView.instance().updateApplicationBadgeNumber()
}
}

View file

@ -241,7 +241,7 @@ import SnapKit
recordingWaveView.progressViewStyle = .bar
recordingWaveView.layer.cornerRadius = 5
recordingWaveView.backgroundColor = VoipTheme.backgroundWhiteBlack.get()
recordingWaveView.progressTintColor = .green
recordingWaveView.progressTintColor = UIColor("L")
recordingWaveView.clipsToBounds = true
recordingWaveView.layer.sublayers![1].cornerRadius = 5
recordingWaveView.subviews[1].clipsToBounds = true