diff --git a/Classes/ChatConversationInfoView.h b/Classes/ChatConversationInfoView.h index 68cb3ab89..ba781d684 100644 --- a/Classes/ChatConversationInfoView.h +++ b/Classes/ChatConversationInfoView.h @@ -35,6 +35,7 @@ @property(nonatomic) LinphoneChatRoom *room; @property(nonatomic) LinphoneChatRoomCbs *chatRoomCbs; @property(nonatomic) const char *peerAddress; +@property(nonatomic) const char *localAddress; @property (weak, nonatomic) IBOutlet UIIconButton *nextButton; @property (weak, nonatomic) IBOutlet UIRoundBorderedButton *quitButton; diff --git a/Classes/ChatConversationInfoView.m b/Classes/ChatConversationInfoView.m index a4ac1c6b7..a0cd6af2e 100644 --- a/Classes/ChatConversationInfoView.m +++ b/Classes/ChatConversationInfoView.m @@ -84,6 +84,7 @@ static UICompositeViewDescription *compositeDescription = nil; _room = NULL; _chatRoomCbs = NULL; _peerAddress = NULL; + _localAddress = NULL; } - (void)viewWillAppear:(BOOL)animated { @@ -153,10 +154,11 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)onLinphoneCoreReady:(NSNotification *)notif { if ((LinphoneGlobalState)[[[notif userInfo] valueForKey:@"state"] integerValue] == LinphoneGlobalOn) { - if (!_create && _peerAddress) { + if (!_create && _peerAddress && _localAddress) { LinphoneAddress *peerAddr = linphone_core_create_address([LinphoneManager getLc], _peerAddress); - if (peerAddr) { - _room = linphone_core_get_chat_room([LinphoneManager getLc], peerAddr); + LinphoneAddress *localAddr = linphone_core_create_address([LinphoneManager getLc], _localAddress); + if (peerAddr && localAddr) { + _room = linphone_core_search_chat_room([LinphoneManager getLc], NULL, localAddr, peerAddr, NULL); } [self configure]; } diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index f7d93687f..929b6b4b9 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -83,7 +83,6 @@ LinphoneChatRoomCapabilitiesMask capabilities = linphone_chat_room_get_capabilities(_chatRoom); bool oneToOne = capabilities & LinphoneChatRoomCapabilitiesOneToOne; bctbx_list_t *chatRoomEvents = linphone_chat_room_get_history_events(_chatRoom, 0); - int unread_count = 0; bctbx_list_t *head = chatRoomEvents; diff --git a/Classes/ChatConversationView.h b/Classes/ChatConversationView.h index edc5eeea6..16ab31f55 100644 --- a/Classes/ChatConversationView.h +++ b/Classes/ChatConversationView.h @@ -63,6 +63,7 @@ @property(nonatomic) LinphoneChatRoomCbs *chatRoomCbs; @property(nonatomic) Boolean markAsRead; @property(nonatomic) const char *peerAddress; +@property(nonatomic) const char *localAddress; @property (strong, nonatomic) FileDataSource *FileDataSource; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index f88ac30f7..ec0d3c753 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -337,8 +337,9 @@ static UICompositeViewDescription *compositeDescription = nil; // force offset recomputing [_messageField refreshHeight]; LinphoneAddress *peerAddr = linphone_core_create_address([LinphoneManager getLc], _peerAddress); - if (peerAddr) { - _chatRoom = linphone_core_get_chat_room([LinphoneManager getLc], peerAddr); + LinphoneAddress *localAddr = linphone_core_create_address([LinphoneManager getLc], _localAddress); + if (peerAddr && localAddr) { + _chatRoom = linphone_core_search_chat_room([LinphoneManager getLc], NULL, localAddr, peerAddr, NULL); if (_chatRoom) { isOneToOne = linphone_chat_room_get_capabilities(_chatRoom) & LinphoneChatRoomCapabilitiesOneToOne; isEncrypted = linphone_chat_room_get_capabilities(_chatRoom) & LinphoneChatRoomCapabilitiesEncrypted; @@ -507,8 +508,9 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)onLinphoneCoreReady:(NSNotification *)notif { if (linphone_core_get_global_state(LC) == LinphoneGlobalOn) { LinphoneAddress *peerAddr = linphone_core_create_address([LinphoneManager getLc], _peerAddress); - if (peerAddr) { - _chatRoom = linphone_core_get_chat_room([LinphoneManager getLc], peerAddr); + LinphoneAddress *localAddr = linphone_core_create_address([LinphoneManager getLc], _localAddress); + if (peerAddr && localAddr) { + _chatRoom = linphone_core_search_chat_room([LinphoneManager getLc], NULL, localAddr, peerAddr, NULL); if (_chatRoom) { isOneToOne = linphone_chat_room_get_capabilities(_chatRoom) & LinphoneChatRoomCapabilitiesOneToOne; isEncrypted = linphone_chat_room_get_capabilities(_chatRoom) & LinphoneChatRoomCapabilitiesEncrypted; @@ -974,6 +976,7 @@ static UICompositeViewDescription *compositeDescription = nil; view.oldSubject = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT]; view.room = _chatRoom; view.peerAddress = _peerAddress; + view.localAddress = _localAddress; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index c4f328b03..c4518ed2c 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -527,15 +527,15 @@ - (void) userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { // If an app extension launch a user notif while app is in fg, it is catch by the app - NSString *category = [[[notification request] content] categoryIdentifier]; - if (category && [category isEqualToString:@"app_active"]) { - return; - } - + NSString *category = [[[notification request] content] categoryIdentifier]; + if (category && [category isEqualToString:@"app_active"]) { + return; + } + if (category && [category isEqualToString:@"msg_cat"] && [UIApplication sharedApplication].applicationState == UIApplicationStateActive) { if ((PhoneMainView.instance.currentView == ChatsListView.compositeViewDescription)) return; - + if (PhoneMainView.instance.currentView == ChatConversationView.compositeViewDescription) { NSDictionary *userInfo = [[[notification request] content] userInfo]; NSString *peerAddress = userInfo[@"peer_addr"]; @@ -543,12 +543,12 @@ if (peerAddress && localAddress) { LinphoneAddress *peer = linphone_core_create_address([LinphoneManager getLc], peerAddress.UTF8String); LinphoneAddress *local = linphone_core_create_address([LinphoneManager getLc], localAddress.UTF8String); - LinphoneChatRoom *room = linphone_core_find_chat_room([LinphoneManager getLc], peer, local); + LinphoneChatRoom *room = linphone_core_search_chat_room([LinphoneManager getLc], NULL, local, peer, NULL); if (room == PhoneMainView.instance.currentRoom) return; } } } - + completionHandler(UNNotificationPresentationOptionAlert); } diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index e3029d004..44abc6ae7 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -915,7 +915,9 @@ static RootViewManager *rootViewManagerInstance = nil; [view clearMessageView]; view.chatRoom = cr; view.peerAddress = linphone_address_as_string(linphone_chat_room_get_peer_address(cr)); + view.localAddress = linphone_address_as_string(linphone_chat_room_get_local_address(cr)); self.currentRoom = view.chatRoom; + if (PhoneMainView.instance.currentView == view.compositeViewDescription) [view configureForRoom:FALSE]; else