diff --git a/Classes/ChatConversationView.h b/Classes/ChatConversationView.h index c83688f95..741ce5c58 100644 --- a/Classes/ChatConversationView.h +++ b/Classes/ChatConversationView.h @@ -103,6 +103,7 @@ - (void)update; - (void)openFileWithURL:(NSURL *)url; - (void)clearMessageView; +- (void)configureMessageField; - (void)showFileDownloadError; - (NSURL *)getICloudFileUrl:(NSString *)name; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index e0a577f28..d8770fe8d 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -269,10 +269,7 @@ static UICompositeViewDescription *compositeDescription = nil; _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT]; [self updateParticipantLabel]; - - _messageField.editable = !linphone_chat_room_has_been_left(_chatRoom); - _pictureButton.enabled = !linphone_chat_room_has_been_left(_chatRoom); - _messageView.userInteractionEnabled = !linphone_chat_room_has_been_left(_chatRoom); + [self configureMessageField]; [_tableController setChatRoom:_chatRoom]; _chatView.hidden = NO; @@ -283,6 +280,22 @@ static UICompositeViewDescription *compositeDescription = nil; [self shareFile]; } +- (void)configureMessageField { + LinphoneChatRoomCapabilitiesMask capabilities = linphone_chat_room_get_capabilities(_chatRoom); + if (capabilities & LinphoneChatRoomCapabilitiesOneToOne) { + _messageField.editable = TRUE; + _pictureButton.enabled = TRUE; + _messageView.userInteractionEnabled = TRUE; + if (linphone_chat_room_has_been_left(_chatRoom)) { + linphone_chat_room_add_participant(_chatRoom, linphone_participant_get_address(linphone_chat_room_get_me(_chatRoom))); + } + } else { + _messageField.editable = !linphone_chat_room_has_been_left(_chatRoom); + _pictureButton.enabled = !linphone_chat_room_has_been_left(_chatRoom); + _messageView.userInteractionEnabled = !linphone_chat_room_has_been_left(_chatRoom); + } +} + - (void)shareFile { NSString* groupName = [NSString stringWithFormat:@"group.%@.linphoneExtension",[[NSBundle mainBundle] bundleIdentifier]]; @@ -999,9 +1012,7 @@ static UICompositeViewDescription *compositeDescription = nil; void on_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) { ChatConversationView *view = (__bridge ChatConversationView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_current_callbacks(cr)); - view.messageField.editable = !linphone_chat_room_has_been_left(cr); - view.pictureButton.enabled = !linphone_chat_room_has_been_left(cr); - view.messageView.userInteractionEnabled = !linphone_chat_room_has_been_left(cr); + [view configureMessageField]; } void on_chat_room_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {