chat: update linphone and fix chat rooms usage to avoid crashes when receiving ACK after having deleted the chat room

This commit is contained in:
Gautier Pelloux-Prayer 2015-09-04 16:02:07 +02:00
parent 683fc0de03
commit 0a4d30aa3f
7 changed files with 13 additions and 20 deletions

View file

@ -75,8 +75,8 @@ static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRo
- (MSList *)sortChatRooms {
MSList *sorted = nil;
MSList *unsorted = linphone_core_get_chat_rooms([LinphoneManager getLc]);
MSList *iter = unsorted;
const MSList *unsorted = linphone_core_get_chat_rooms([LinphoneManager getLc]);
const MSList *iter = unsorted;
while (iter) {
// store last message in user data
@ -176,8 +176,7 @@ static void chatTable_free_chatrooms(void *data) {
[ftd cancel];
}
}
linphone_chat_room_delete_history(chatRoom);
linphone_chat_room_unref(chatRoom);
linphone_core_delete_chat_room(linphone_chat_room_get_lc(chatRoom), chatRoom);
data = ms_list_remove(data, chatRoom);
// will force a call to [self loadData]

View file

@ -98,14 +98,12 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)startChatRoom {
// Push ChatRoom
LinphoneChatRoom *room =
linphone_core_get_or_create_chat_room([LinphoneManager getLc], [addressField.text UTF8String]);
linphone_core_get_chat_room_from_uri([LinphoneManager getLc], [addressField.text UTF8String]);
if (room != nil) {
ChatRoomViewController *controller = DYNAMIC_CAST(
[[PhoneMainView instance] changeCurrentView:[ChatRoomViewController compositeViewDescription] push:TRUE],
ChatRoomViewController);
if (controller != nil) {
LinphoneChatRoom *room =
linphone_core_get_or_create_chat_room([LinphoneManager getLc], [addressField.text UTF8String]);
[controller setChatRoom:room];
}
} else {

View file

@ -644,7 +644,7 @@ static const ContactSections_e contactSections[ContactSections_MAX] = {ContactSe
ChatRoomViewController);
if (controller != nil) {
LinphoneChatRoom *room =
linphone_core_get_or_create_chat_room([LinphoneManager getLc], [dest UTF8String]);
linphone_core_get_chat_room_from_uri([LinphoneManager getLc], [dest UTF8String]);
[controller setChatRoom:room];
}
}

View file

@ -358,11 +358,8 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (IBAction)onMessageClick:(id)event {
LinphoneAddress *addr;
addr = linphone_call_log_get_remote_address(callLog);
char *lAddress = linphone_address_as_string_uri_only(addr);
if (lAddress == NULL)
const LinphoneAddress *addr = linphone_call_log_get_remote_address(callLog);
if (addr == NULL)
return;
// Go to ChatRoom view
[[PhoneMainView instance] changeCurrentView:[ChatViewController compositeViewDescription]];
@ -370,10 +367,9 @@ static UICompositeViewDescription *compositeDescription = nil;
[[PhoneMainView instance] changeCurrentView:[ChatRoomViewController compositeViewDescription] push:TRUE],
ChatRoomViewController);
if (controller != nil) {
LinphoneChatRoom *room = linphone_core_get_or_create_chat_room([LinphoneManager getLc], lAddress);
LinphoneChatRoom *room = linphone_core_get_chat_room([LinphoneManager getLc], addr);
[controller setChatRoom:room];
}
ms_free(lAddress);
}
@end

View file

@ -317,7 +317,7 @@
}
- (LinphoneChatRoom *)findChatRoomForContact:(NSString *)contact {
MSList *rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]);
const MSList *rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]);
const char *from = [contact UTF8String];
while (rooms) {
const LinphoneAddress *room_from_address = linphone_chat_room_get_peer_address((LinphoneChatRoom *)rooms->data);
@ -445,7 +445,7 @@
[self application:application didReceiveLocalNotification:notification];
} else if ([identifier isEqualToString:@"mark_read"]) {
NSString *from = [notification.userInfo objectForKey:@"from_addr"];
LinphoneChatRoom *room = linphone_core_get_or_create_chat_room(lc, [from UTF8String]);
LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(lc, [from UTF8String]);
if (room) {
linphone_chat_room_mark_as_read(room);
[[PhoneMainView instance] updateApplicationBadgeNumber];

View file

@ -2048,8 +2048,8 @@ static void audioRouteChangeListenerCallback(void *inUserData, // 1
+ (int)unreadMessageCount {
int count = 0;
MSList *rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]);
MSList *item = rooms;
const MSList *rooms = linphone_core_get_chat_rooms([LinphoneManager getLc]);
const MSList *item = rooms;
while (item) {
LinphoneChatRoom *room = (LinphoneChatRoom *)item->data;
if (room) {

@ -1 +1 @@
Subproject commit 9f2b9df16a2f6537196a7f2ec8db792d63287a9d
Subproject commit 44327da3ec399aa4eb29a4fb93a585bd99c47af5