From 6d97e6ed024ca413fb8af4c38d8232c8ce7d53d4 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 29 Nov 2017 16:04:59 +0100 Subject: [PATCH] even better management for chat rooms --- Classes/LinphoneAppDelegate.m | 7 ++----- Classes/LinphoneManager.m | 24 ++++++++++++++---------- submodules/linphone | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 33b79fe4a..dcb97bcd9 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -672,11 +672,9 @@ didInvalidatePushTokenForType:(NSString *)type { } else if ([response.actionIdentifier isEqual:@"Reply"]) { NSString *replyText = [(UNTextInputNotificationResponse *)response userText]; - NSString *chat_room_address = [response.notification.request.content.userInfo - objectForKey:@"chat_room_address"]; NSString *from_address = [response.notification.request.content.userInfo objectForKey:@"from_addr"]; - [LinphoneManager.instance send:replyText to:[chat_room_address isEqualToString:@""] ? from_address : chat_room_address]; + [LinphoneManager.instance send:replyText to:from_address]; } else if ([response.actionIdentifier isEqual:@"Seen"]) { NSString *from = [response.notification.request.content.userInfo objectForKey:@"chat_room_address"]; @@ -893,9 +891,8 @@ didInvalidatePushTokenForType:(NSString *)type { } else if ([notification.category isEqualToString:@"incoming_msg"] && [identifier isEqualToString:@"reply_inline"]) { NSString *replyText = [responseInfo objectForKey:UIUserNotificationActionResponseTypedTextKey]; - NSString *chat_room_address = [notification.userInfo objectForKey:@"chat_room_address"]; NSString *from_address = [notification.userInfo objectForKey:@"from_addr"]; - [LinphoneManager.instance send:replyText to:[chat_room_address isEqualToString:@""] ? from_address : chat_room_address]; + [LinphoneManager.instance send:replyText to:from_address]; } completionHandler(); } diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 00b35def8..1b34971a8 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1077,9 +1077,12 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } #pragma deploymate pop NSString *callID = [NSString stringWithUTF8String:linphone_chat_message_get_custom_header(msg, "Call-ID")]; - const LinphoneAddress *remoteAddress = linphone_chat_message_get_from_address(msg); + const LinphoneAddress *remoteAddress = linphone_chat_room_get_peer_address(room); NSString *from = [FastAddressBook displayNameForAddress:remoteAddress]; + const LinphoneAddress *fromAddress = linphone_chat_message_get_from_address(msg); + NSString *fromMsg = [FastAddressBook displayNameForAddress:fromAddress]; + char *c_address = linphone_address_as_string_uri_only(remoteAddress); NSString *remote_uri = [NSString stringWithUTF8String:c_address]; ms_free(c_address); @@ -1169,11 +1172,9 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } else { notif.alertBody = [NSString stringWithFormat:NSLocalizedString(@"IM_MSG", nil), from]; } - char *room_address = linphone_chat_room_get_conference_address(room) ? linphone_address_as_string_uri_only(linphone_chat_room_get_conference_address(room)) : NULL; - NSString *room_uri = room_address ? [NSString stringWithUTF8String:room_address] : @""; notif.alertAction = NSLocalizedString(@"Show", nil); notif.soundName = @"msg.caf"; - notif.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"call-id" : callID, @"chat_room_address" : room_uri}; + notif.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"call-id" : callID}; notif.accessibilityLabel = @"Message notif"; [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } @@ -1206,17 +1207,20 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut [[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:categories]; UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; content.title = NSLocalizedString(@"Message received", nil); + const char* subject = linphone_chat_room_get_subject(room) ?: LINPHONE_DUMMY_SUBJECT; if ([LinphoneManager.instance lpConfigBoolForKey:@"show_msg_in_notif" withDefault:YES]) { - content.subtitle = from; - content.body = [UIChatBubbleTextCell TextMessageForChat:msg]; + content.subtitle = strcmp(subject, LINPHONE_DUMMY_SUBJECT) != 0 ? [NSString stringWithUTF8String:subject] : fromMsg; + content.body = strcmp(subject, LINPHONE_DUMMY_SUBJECT) != 0 + ? [NSString stringWithFormat:@"%@ : %@", fromMsg, [UIChatBubbleTextCell TextMessageForChat:msg]] + : [UIChatBubbleTextCell TextMessageForChat:msg]; } else { - content.body = from; + content.body = strcmp(subject, LINPHONE_DUMMY_SUBJECT) != 0 + ? [NSString stringWithFormat:@"%@ : %@",[NSString stringWithUTF8String:subject], fromMsg] + : fromMsg; } - char *room_address = linphone_chat_room_get_conference_address(room) ? linphone_address_as_string_uri_only(linphone_chat_room_get_conference_address(room)) : NULL; - NSString *room_uri = room_address ? [NSString stringWithUTF8String:room_address] : @""; content.sound = [UNNotificationSound soundNamed:@"msg.caf"]; content.categoryIdentifier = @"msg_cat"; - content.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"CallId" : callID, @"chat_room_address" : room_uri}; + content.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"CallId" : callID}; content.accessibilityLabel = @"Message notif"; UNNotificationRequest *req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL]; diff --git a/submodules/linphone b/submodules/linphone index d7bc4b66a..a23c0e4f2 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit d7bc4b66ac414e6b6b5c0cd30bedcbcde4a9c05b +Subproject commit a23c0e4f202b043a08db2bf232863c195f5c94d2