From 838ed670376052eae1443962cef4627d5fa5428a Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 30 Nov 2017 10:54:25 +0100 Subject: [PATCH] keep enhancing chat room management --- Classes/ChatConversationTableView.m | 2 +- Classes/LinphoneAppDelegate.m | 4 ++-- Classes/LinphoneUI/UIChatBubblePhotoCell.h | 1 + Classes/LinphoneUI/UIChatBubblePhotoCell.m | 6 ++++++ Classes/LinphoneUI/UIChatBubbleTextCell.m | 7 ++++--- submodules/linphone | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index 84f859825..2ed350c75 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -173,7 +173,7 @@ if (cell == nil) cell = [[NSClassFromString(kCellId) alloc] initWithIdentifier:kCellId]; - [cell setChatMessage:chat]; + [cell setEvent:event]; if (chat) [cell update]; diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 3ae73242e..c0b744e57 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -675,7 +675,7 @@ didInvalidatePushTokenForType:(NSString *)type { objectForKey:@"from_addr"]; [LinphoneManager.instance send:replyText to:from_address]; } else if ([response.actionIdentifier isEqual:@"Seen"]) { - NSString *from = [response.notification.request.content.userInfo objectForKey:@"chat_room_address"]; + NSString *from = [response.notification.request.content.userInfo objectForKey:@"from_addr"]; LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, [from UTF8String]); if (room) { linphone_chat_room_mark_as_read(room); @@ -844,7 +844,7 @@ didInvalidatePushTokenForType:(NSString *)type { // use the standard handler [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; } else if ([identifier isEqualToString:@"mark_read"]) { - NSString *from = [notification.userInfo objectForKey:@"chat_room_address"]; + NSString *from = [notification.userInfo objectForKey:@"from_addr"]; LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, [from UTF8String]); if (room) { if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.h b/Classes/LinphoneUI/UIChatBubblePhotoCell.h index f196dbcd1..2689f216b 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.h +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.h @@ -35,6 +35,7 @@ @property(weak, nonatomic) IBOutlet UIView *totalView; @property(strong, nonatomic) IBOutlet UITapGestureRecognizer *imageGestureRecognizer; +- (void)setEvent:(LinphoneEventLog *)event; - (void)setChatMessage:(LinphoneChatMessage *)message; - (void)connectToFileDelegate:(FileTransferDelegate *)ftd; - (IBAction)onDownloadClick:(id)event; diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index 893e95055..664bbe9fd 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -51,6 +51,12 @@ } #pragma mark - +- (void)setEvent:(LinphoneEventLog *)event { + if (!event || !(linphone_event_log_get_type(event) == LinphoneEventLogTypeConferenceChatMessage)) + return; + + [self setChatMessage:linphone_event_log_get_chat_message(event)]; +} - (void)setChatMessage:(LinphoneChatMessage *)amessage { _imageGestureRecognizer.enabled = NO; diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 124d468d3..0285e557c 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -44,6 +44,7 @@ } - (void)dealloc { + [self setEvent:NULL]; [self setChatMessage:NULL]; } @@ -79,7 +80,7 @@ linphone_chat_message_set_user_data(_message, (void *)CFBridgingRetain(self)); LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(_message); linphone_chat_message_cbs_set_msg_state_changed(cbs, message_status); - linphone_chat_message_cbs_set_user_data(cbs, (__bridge void *)self); + linphone_chat_message_cbs_set_user_data(cbs, (void *)_event); } } @@ -263,9 +264,9 @@ #pragma mark - State changed handling static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state) { LOGI(@"State for message [%p] changed to %s", msg, linphone_chat_message_state_to_string(state)); - UIChatBubbleTextCell *data = (__bridge UIChatBubbleTextCell *)linphone_chat_message_cbs_get_user_data(linphone_chat_message_get_callbacks(msg)); + LinphoneEventLog *event = (LinphoneEventLog *)linphone_chat_message_cbs_get_user_data(linphone_chat_message_get_callbacks(msg)); ChatConversationView *view = VIEW(ChatConversationView); - [view.tableController updateEventEntry:data.event]; + [view.tableController updateEventEntry:event]; } - (void)displayImdmStatus:(LinphoneChatMessageState)state { diff --git a/submodules/linphone b/submodules/linphone index cea7ca8bb..af709ad4c 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit cea7ca8bb14a2cf087e6417f5ab49aa45eb04a66 +Subproject commit af709ad4c943c735787d2b5acd6b20c5fc4d9667