diff --git a/Classes/ChatConversationView.h b/Classes/ChatConversationView.h index 7c76cb286..ec0ec8f15 100644 --- a/Classes/ChatConversationView.h +++ b/Classes/ChatConversationView.h @@ -132,6 +132,7 @@ + (void)writeMediaToGallery:(NSString *)name fileType:(NSString *)fileType; +(UIImage *)getBasicImage; +(UIImage*)drawText:(NSString*)text image:(UIImage *)image textSize:(CGFloat)textSize; ++(BOOL) isBasicChatRoom:(LinphoneChatRoom *)room; - (void)configureForRoom:(BOOL)editing; - (IBAction)onBackClick:(id)event; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index b6cb0751e..87d4d5779 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -403,7 +403,7 @@ static UICompositeViewDescription *compositeDescription = nil; [self update]; [self shareFile]; - if (![self isBasicChatRoom]) { + if (![ChatConversationView isBasicChatRoom:_chatRoom]) { [self setupPopupMenu]; _ephemeralndicator.hidden = !linphone_chat_room_ephemeral_enabled(_chatRoom); } @@ -411,10 +411,10 @@ static UICompositeViewDescription *compositeDescription = nil; } --(BOOL) isBasicChatRoom { - if (!_chatRoom) ++(BOOL) isBasicChatRoom:(LinphoneChatRoom *)room { + if (!room) return true; - LinphoneChatRoomCapabilitiesMask capabilities = linphone_chat_room_get_capabilities(_chatRoom); + LinphoneChatRoomCapabilitiesMask capabilities = linphone_chat_room_get_capabilities(room); return capabilities & LinphoneChatRoomCapabilitiesBasic; } @@ -528,8 +528,11 @@ static UICompositeViewDescription *compositeDescription = nil; } LinphoneChatMessage *msg = rootMessage; - if (message && message.length > 0) - linphone_chat_message_add_utf8_text_content(msg, message.UTF8String); + BOOL basic = [ChatConversationView isBasicChatRoom:_chatRoom]; + if (message && message.length > 0) { + if (!basic) + linphone_chat_message_add_utf8_text_content(msg, message.UTF8String); + } if (externalUrl) { linphone_chat_message_set_external_body_url(msg, [[externalUrl absoluteString] UTF8String]); @@ -537,6 +540,9 @@ static UICompositeViewDescription *compositeDescription = nil; // we must ref & unref message because in case of error, it will be destroy otherwise linphone_chat_message_send(msg); + if (basic && message && message.length > 0) { + linphone_chat_message_send(linphone_chat_room_create_message_from_utf8(_chatRoom, message.UTF8String)); + } return TRUE; } @@ -640,8 +646,8 @@ static UICompositeViewDescription *compositeDescription = nil; [_backToCallButton update]; _infoButton.hidden = (isOneToOne|| !_backToCallButton.hidden || _tableController.tableView.isEditing); _callButton.hidden = !_backToCallButton.hidden || !_infoButton.hidden || _tableController.tableView.isEditing; - _toggleMenuButton.hidden = [self isBasicChatRoom] || _tableController.tableView.isEditing; - _tableController.editButton.hidden = _tableController.editButton.hidden || ![self isBasicChatRoom]; + _toggleMenuButton.hidden = [ChatConversationView isBasicChatRoom:_chatRoom] || _tableController.tableView.isEditing; + _tableController.editButton.hidden = _tableController.editButton.hidden || ![ChatConversationView isBasicChatRoom:_chatRoom]; } - (void)updateParticipantLabel { diff --git a/Classes/Utils/FileTransferDelegate.m b/Classes/Utils/FileTransferDelegate.m index 0738c54b4..9f10ffa86 100644 --- a/Classes/Utils/FileTransferDelegate.m +++ b/Classes/Utils/FileTransferDelegate.m @@ -118,8 +118,10 @@ static void file_transfer_progress_indication_send(LinphoneChatMessage *message, _message = rootMessage; linphone_chat_message_add_file_content(_message, content); BOOL isOneToOneChat = linphone_chat_room_get_capabilities(chatRoom) & LinphoneChatRoomCapabilitiesOneToOne; - if (!isOneToOneChat && (_text!=nil && ![_text isEqualToString:@""])) - linphone_chat_message_add_text_content(_message, [_text UTF8String]); + BOOL basic = [ChatConversationView isBasicChatRoom:linphone_chat_message_get_chat_room(rootMessage)]; + + if (!basic && !isOneToOneChat && (_text!=nil && ![_text isEqualToString:@""])) + linphone_chat_message_add_utf8_text_content(_message, [_text UTF8String]); linphone_content_unref(content); linphone_chat_message_cbs_set_file_transfer_progress_indication(linphone_chat_message_get_callbacks(_message), file_transfer_progress_indication_send); @@ -130,6 +132,9 @@ static void file_transfer_progress_indication_send(LinphoneChatMessage *message, LOGI(@"%p Uploading content from message %p", self, _message); linphone_chat_message_send(_message); + if (basic && !isOneToOneChat && (_text!=nil && ![_text isEqualToString:@""])) { + linphone_chat_message_send(linphone_chat_room_create_message_from_utf8(linphone_chat_message_get_chat_room(rootMessage), _text.UTF8String)); + } } - (void)uploadFileContent: (FileContext *)context forChatRoom:(LinphoneChatRoom *)chatRoom rootMessage:(LinphoneChatMessage *)rootMessage{ @@ -159,8 +164,11 @@ static void file_transfer_progress_indication_send(LinphoneChatMessage *message, linphone_content_unref(content); } - if (_text!=nil && ![_text isEqualToString:@""]) - linphone_chat_message_add_text_content(_message, [_text UTF8String]); + BOOL basic = [ChatConversationView isBasicChatRoom:linphone_chat_message_get_chat_room(rootMessage)]; + + + if (!basic && _text!=nil && ![_text isEqualToString:@""]) + linphone_chat_message_add_utf8_text_content(_message, [_text UTF8String]); // todo indication progress [LinphoneManager setValueInMessageAppData:names forKey:@"multiparts" inMessage:_message]; @@ -168,6 +176,9 @@ static void file_transfer_progress_indication_send(LinphoneChatMessage *message, LOGI(@"%p Uploading content from message %p", self, _message); linphone_chat_message_send(_message); + if (basic && _text!=nil && ![_text isEqualToString:@""]) { + linphone_chat_message_send(linphone_chat_room_create_message_from_utf8(linphone_chat_message_get_chat_room(rootMessage), _text.UTF8String)); + } }