you can now leave a chat room

This commit is contained in:
Benjamin Reis 2017-11-08 16:57:29 +01:00
parent 8f8805ff03
commit 6880f77846
4 changed files with 18 additions and 4 deletions

View file

@ -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;
}

View file

@ -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 {

View file

@ -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 {

@ -1 +1 @@
Subproject commit 79e6d1ca3cbf9fb61e2c1329327217db99205aae
Subproject commit 64802f026b3e2dfb2942db2e530f0e77e1d9dbb6