better chatroom management

This commit is contained in:
Benjamin Reis 2017-11-29 15:29:04 +01:00
parent 03310c038e
commit 43c8388698
4 changed files with 29 additions and 18 deletions

View file

@ -136,7 +136,9 @@ static UICompositeViewDescription *compositeDescription = nil;
&& (strcmp(linphone_chat_room_get_subject(_chatRoom) ?: LINPHONE_DUMMY_SUBJECT, LINPHONE_DUMMY_SUBJECT) != 0 || linphone_chat_room_get_nb_participants(_chatRoom) > 1))
_addressLabel.text = [NSString stringWithUTF8String:linphone_chat_room_get_subject(_chatRoom)];
else {
const LinphoneAddress *addr = linphone_participant_get_address(linphone_chat_room_get_participants(_chatRoom)->data);
bctbx_list_t *participants = linphone_chat_room_get_participants(_chatRoom);
LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL;
const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_chatRoom);
[ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr];
}
@ -501,7 +503,10 @@ static UICompositeViewDescription *compositeDescription = nil;
}
- (IBAction)onCallClick:(id)sender {
[LinphoneManager.instance call:linphone_participant_get_address(linphone_chat_room_get_participants(_chatRoom)->data)];
bctbx_list_t *participants = linphone_chat_room_get_participants(_chatRoom);
LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL;
const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(_chatRoom);
[LinphoneManager.instance call:addr];
}
- (IBAction)onListSwipe:(id)sender {

View file

@ -672,12 +672,14 @@ didInvalidatePushTokenForType:(NSString *)type {
} else if ([response.actionIdentifier isEqual:@"Reply"]) {
NSString *replyText =
[(UNTextInputNotificationResponse *)response userText];
NSString *from = [response.notification.request.content.userInfo
objectForKey:@"from_addr"];
[LinphoneManager.instance send:replyText to:from];
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];
} else if ([response.actionIdentifier isEqual:@"Seen"]) {
NSString *from = [response.notification.request.content.userInfo
objectForKey:@"from_addr"];
objectForKey:@"chat_room_address"];
LinphoneChatRoom *room =
linphone_core_get_chat_room_from_uri(LC, [from UTF8String]);
if (room) {
@ -848,7 +850,7 @@ 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"];
NSString *from = [notification.userInfo objectForKey:@"chat_room_address"];
LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, [from UTF8String]);
if (room) {
if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive)
@ -891,8 +893,9 @@ didInvalidatePushTokenForType:(NSString *)type {
} else if ([notification.category isEqualToString:@"incoming_msg"] &&
[identifier isEqualToString:@"reply_inline"]) {
NSString *replyText = [responseInfo objectForKey:UIUserNotificationActionResponseTypedTextKey];
NSString *from = [notification.userInfo objectForKey:@"from_addr"];
[LinphoneManager.instance send:replyText to:from];
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];
}
completionHandler();
}

View file

@ -1169,9 +1169,11 @@ 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 };
notif.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"call-id" : callID, @"chat_room_address" : room_uri};
notif.accessibilityLabel = @"Message notif";
[[UIApplication sharedApplication] presentLocalNotificationNow:notif];
}
@ -1210,9 +1212,11 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, LinphoneAut
} else {
content.body = 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] : @"";
content.sound = [UNNotificationSound soundNamed:@"msg.caf"];
content.categoryIdentifier = @"msg_cat";
content.userInfo = @{ @"from" : from, @"from_addr" : remote_uri, @"CallId" : callID };
content.userInfo = @{@"from" : from, @"from_addr" : remote_uri, @"CallId" : callID, @"chat_room_address" : room_uri};
content.accessibilityLabel = @"Message notif";
UNNotificationRequest *req =
[UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL];

View file

@ -69,13 +69,12 @@
_addressLabel.text = [NSString stringWithUTF8String:subject];
[_avatarImage setImage:[UIImage imageNamed:@"chat_group_avatar.png"] bordered:NO withRoundedRadius:YES];
} else {
if (linphone_chat_room_get_participants(chatRoom) != NULL) {
LinphoneParticipant *participant = linphone_chat_room_get_participants(chatRoom)->data;
const LinphoneAddress *addr = linphone_participant_get_address(participant);
if (addr) {
[ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr];
[_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES];
}
bctbx_list_t *participants = linphone_chat_room_get_participants(chatRoom);
LinphoneParticipant *firstParticipant = participants ? (LinphoneParticipant *)participants->data : NULL;
const LinphoneAddress *addr = firstParticipant ? linphone_participant_get_address(firstParticipant) : linphone_chat_room_get_peer_address(chatRoom);
if (addr) {
[ContactDisplay setDisplayNameLabel:_addressLabel forAddress:addr];
[_avatarImage setImage:[FastAddressBook imageForAddress:addr] bordered:NO withRoundedRadius:YES];
} else {
_addressLabel.text = [NSString stringWithUTF8String:LINPHONE_DUMMY_SUBJECT];
}