diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index c0b744e57..0971fbe02 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -669,21 +669,31 @@ didInvalidatePushTokenForType:(NSString *)type { } else if ([response.actionIdentifier isEqual:@"Decline"]) { linphone_call_decline(call, LinphoneReasonDeclined); } else if ([response.actionIdentifier isEqual:@"Reply"]) { - NSString *replyText = - [(UNTextInputNotificationResponse *)response userText]; - NSString *from_address = [response.notification.request.content.userInfo - objectForKey:@"from_addr"]; - [LinphoneManager.instance send:replyText to:from_address]; - } else if ([response.actionIdentifier isEqual:@"Seen"]) { - 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); - TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)]; - [tab update:YES]; - [PhoneMainView.instance updateApplicationBadgeNumber]; - } + NSString *replyText = [(UNTextInputNotificationResponse *)response userText]; + NSString *peer_address = [response.notification.request.content.userInfo objectForKey:@"peer_addr"]; + NSString *local_address = [response.notification.request.content.userInfo objectForKey:@"local_addr"]; + LinphoneAddress *peer = linphone_address_new(peer_address.UTF8String); + LinphoneAddress *local = linphone_address_new(local_address.UTF8String); + LinphoneChatRoom *room = linphone_core_find_chat_room(LC, peer, local); + if(room) + [LinphoneManager.instance send:replyText toChatRoom:room]; + linphone_address_unref(peer); + linphone_address_unref(local); + } else if ([response.actionIdentifier isEqual:@"Seen"]) { + NSString *peer_address = [response.notification.request.content.userInfo objectForKey:@"peer_addr"]; + NSString *local_address = [response.notification.request.content.userInfo objectForKey:@"local_addr"]; + LinphoneAddress *peer = linphone_address_new(peer_address.UTF8String); + LinphoneAddress *local = linphone_address_new(local_address.UTF8String); + LinphoneChatRoom *room = linphone_core_find_chat_room(LC, peer, local); + if (room) { + linphone_chat_room_mark_as_read(room); + TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)]; + [tab update:YES]; + [PhoneMainView.instance updateApplicationBadgeNumber]; + } + linphone_address_unref(peer); + linphone_address_unref(local); } else if ([response.actionIdentifier isEqual:@"Cancel"]) { LOGI(@"User declined video proposal"); if (call == linphone_core_get_current_call(LC)) { @@ -844,16 +854,21 @@ didInvalidatePushTokenForType:(NSString *)type { // use the standard handler [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; } else if ([identifier isEqualToString:@"mark_read"]) { - NSString *from = [notification.userInfo objectForKey:@"from_addr"]; - LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, [from UTF8String]); + NSString *peer_address = [notification.userInfo objectForKey:@"peer_addr"]; + NSString *local_address = [notification.userInfo objectForKey:@"local_addr"]; + LinphoneAddress *peer = linphone_address_new(peer_address.UTF8String); + LinphoneAddress *local = linphone_address_new(local_address.UTF8String); + LinphoneChatRoom *room = linphone_core_find_chat_room(LC, peer, local); if (room) { if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) linphone_chat_room_mark_as_read(room); TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController - getCachedController:NSStringFromClass(TabBarView.class)]; + getCachedController:NSStringFromClass(TabBarView.class)]; [tab update:YES]; [PhoneMainView.instance updateApplicationBadgeNumber]; } + linphone_address_unref(peer); + linphone_address_unref(local); } } } @@ -887,8 +902,16 @@ didInvalidatePushTokenForType:(NSString *)type { } else if ([notification.category isEqualToString:@"incoming_msg"] && [identifier isEqualToString:@"reply_inline"]) { NSString *replyText = [responseInfo objectForKey:UIUserNotificationActionResponseTypedTextKey]; - NSString *from_address = [notification.userInfo objectForKey:@"from_addr"]; - [LinphoneManager.instance send:replyText to:from_address]; + NSString *peer_address = [responseInfo objectForKey:@"peer_addr"]; + NSString *local_address = [responseInfo objectForKey:@"local_addr"]; + LinphoneAddress *peer = linphone_address_new(peer_address.UTF8String); + LinphoneAddress *local = linphone_address_new(local_address.UTF8String); + LinphoneChatRoom *room = linphone_core_find_chat_room(LC, peer, local); + if (room) + [LinphoneManager.instance send:replyText toChatRoom:room]; + + linphone_address_unref(peer); + linphone_address_unref(local); } completionHandler(); } diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index adba17596..67d1114f2 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -160,7 +160,7 @@ typedef struct _LinphoneManagerSounds { + (NSString*)cacheDirectory; - (void)acceptCall:(LinphoneCall *)call evenWithVideo:(BOOL)video; -- (void)send:(NSString *)replyText to:(NSString *)to; +- (void)send:(NSString *)replyText toChatRoom:(LinphoneChatRoom *)room; - (void)call:(const LinphoneAddress *)address; - (BOOL)doCall:(const LinphoneAddress *)iaddr; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 1b34971a8..e4a8f706f 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1077,15 +1077,21 @@ 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_room_get_peer_address(room); - NSString *from = [FastAddressBook displayNameForAddress:remoteAddress]; + const LinphoneAddress *peerAddress = linphone_chat_room_get_peer_address(room); + NSString *from = [FastAddressBook displayNameForAddress:peerAddress]; 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); + char *peer_address = linphone_address_as_string_uri_only(peerAddress); + NSString *peer_uri = [NSString stringWithUTF8String:peer_address]; + ms_free(peer_address); + + const LinphoneAddress *localAddress = linphone_chat_room_get_local_address(room); + char *local_address = linphone_address_as_string_uri_only(localAddress); + NSString *local_uri = [NSString stringWithUTF8String:local_address]; + ms_free(local_address); + int index = [(NSNumber *)[_pushDict objectForKey:callID] intValue] - 1; LOGI(@"Decrementing index of long running task for call id : %@ with index : %d", callID, index); [_pushDict setValue:[NSNumber numberWithInt:index] forKey:callID]; @@ -1174,7 +1180,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } notif.alertAction = NSLocalizedString(@"Show", nil); notif.soundName = @"msg.caf"; - notif.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"call-id" : callID}; + notif.userInfo = @{@"from" : from, @"peer_addr" : peer_uri, @"local_addr" : local_uri, @"call-id" : callID}; notif.accessibilityLabel = @"Message notif"; [[UIApplication sharedApplication] presentLocalNotificationNow:notif]; } @@ -1220,7 +1226,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut } content.sound = [UNNotificationSound soundNamed:@"msg.caf"]; content.categoryIdentifier = @"msg_cat"; - content.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"CallId" : callID}; + content.userInfo = @{@"from" : from, @"peer_addr" : peer_uri, @"local_addr" : local_uri, @"CallId" : callID}; content.accessibilityLabel = @"Message notif"; UNNotificationRequest *req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL]; @@ -2538,22 +2544,17 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { linphone_call_accept_with_params(call, lcallParams); } -- (void)send:(NSString *)replyText to:(NSString *)to { - LinphoneCore *lc = [LinphoneManager getLc]; - LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(lc, [to UTF8String]); - if (room) { - LinphoneChatMessage *msg = linphone_chat_room_create_message(room, replyText.UTF8String); - linphone_chat_room_send_chat_message(room, msg); +- (void)send:(NSString *)replyText toChatRoom:(LinphoneChatRoom *)room { + LinphoneChatMessage *msg = linphone_chat_room_create_message(room, replyText.UTF8String); + linphone_chat_room_send_chat_message(room, msg); - if (linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room)) { - [LinphoneManager.instance alertLIME:room]; - } - linphone_chat_room_mark_as_read(room); - TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController - getCachedController:NSStringFromClass(TabBarView.class)]; - [tab update:YES]; - [PhoneMainView.instance updateApplicationBadgeNumber]; - } + if (linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room)) + [LinphoneManager.instance alertLIME:room]; + + linphone_chat_room_mark_as_read(room); + TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)]; + [tab update:YES]; + [PhoneMainView.instance updateApplicationBadgeNumber]; } - (void)call:(const LinphoneAddress *)iaddr { diff --git a/submodules/linphone b/submodules/linphone index af709ad4c..d111d78f7 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit af709ad4c943c735787d2b5acd6b20c5fc4d9667 +Subproject commit d111d78f71114d0ec0ba01af93a344c1d318cf59