forked from mirrors/linphone-iphone
Send message text separately from attachements in basic chat rooms
This commit is contained in:
parent
d4d3f95b96
commit
df1b24f86b
3 changed files with 30 additions and 12 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -402,7 +402,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);
|
||||
}
|
||||
|
|
@ -410,10 +410,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;
|
||||
}
|
||||
|
||||
|
|
@ -527,8 +527,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]);
|
||||
|
|
@ -536,6 +539,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 {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue