mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Use linphone_core_search_chat_room rather than linphone_core_get_chat_room, in order to fix chatrooms being empty when using multiple accounts
This commit is contained in:
parent
0a05baea1e
commit
abf598b654
7 changed files with 24 additions and 16 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue