From 6880f77846ab0eac2eeb4c13886e82afc1c204a0 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 8 Nov 2017 16:57:29 +0100 Subject: [PATCH] you can now leave a chat room --- Classes/ChatConversationInfoView.m | 11 +++++++++-- Classes/ChatConversationView.m | 5 +++++ Classes/ChatsListView.m | 4 +++- submodules/linphone | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Classes/ChatConversationInfoView.m b/Classes/ChatConversationInfoView.m index ea5798c06..36191ba28 100644 --- a/Classes/ChatConversationInfoView.m +++ b/Classes/ChatConversationInfoView.m @@ -151,6 +151,9 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onQuitClick:(id)sender { + LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(_room); + linphone_chat_room_cbs_set_user_data(cbs, (__bridge void*)self); + linphone_chat_room_cbs_set_state_changed(cbs, chat_room_state_changed); linphone_chat_room_leave(_room); } @@ -210,7 +213,7 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - chat room callbacks -- (void)onChatRoomCreated:(LinphoneChatRoom *)cr { +- (void)goToChatRoom:(LinphoneChatRoom *)cr { ChatConversationView *view = VIEW(ChatConversationView); view.chatRoom = cr; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; @@ -220,11 +223,15 @@ void chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newStat switch (newState) { case LinphoneChatRoomStateCreated: LOGI(@"Chat room [%p] created on server.", cr); - [(__bridge ChatConversationInfoView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr)) onChatRoomCreated:cr]; + [(__bridge ChatConversationInfoView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr)) goToChatRoom:cr]; break; case LinphoneChatRoomStateCreationFailed: LOGE(@"Chat room [%p] could not be created on server.", cr); break; + case LinphoneChatRoomStateTerminated: + LOGI(@"Chat room [%p] has been terminated.", cr); + [(__bridge ChatConversationInfoView *)linphone_chat_room_cbs_get_user_data(linphone_chat_room_get_callbacks(cr)) goToChatRoom:cr]; + break; default: break; } diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 716d32bc7..b604f0883 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -136,6 +136,11 @@ static UICompositeViewDescription *compositeDescription = nil; _addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom)]; [self updateParticipantLabel]; + + if (linphone_chat_room_get_state(_chatRoom) == LinphoneChatRoomStateTerminated) { + _messageField.editable = false; + _messageView.userInteractionEnabled = false; + } } - (void)viewWillDisappear:(BOOL)animated { diff --git a/Classes/ChatsListView.m b/Classes/ChatsListView.m index f0be82727..bac12b035 100644 --- a/Classes/ChatsListView.m +++ b/Classes/ChatsListView.m @@ -80,7 +80,9 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - Action Functions - (IBAction)onAddClick:(id)event { - [PhoneMainView.instance changeCurrentView:ChatConversationCreateView.compositeViewDescription]; + ChatConversationCreateView *view = VIEW(ChatConversationCreateView); + view.isForEditing = false; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } - (IBAction)onEditionChangeClick:(id)sender { diff --git a/submodules/linphone b/submodules/linphone index 79e6d1ca3..64802f026 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 79e6d1ca3cbf9fb61e2c1329327217db99205aae +Subproject commit 64802f026b3e2dfb2942db2e530f0e77e1d9dbb6