mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-25 23:28:09 +00:00
Added remove custom header method for chat message + test
This commit is contained in:
parent
c9b8fb6eb2
commit
b45e6dcc8d
5 changed files with 50 additions and 1 deletions
|
|
@ -993,6 +993,14 @@ const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name){
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SalCustomHeader *sal_custom_header_remove(SalCustomHeader *ch, const char *name) {
|
||||
belle_sip_message_t *msg=(belle_sip_message_t*)ch;
|
||||
if (msg==NULL) return NULL;
|
||||
|
||||
belle_sip_message_remove_header(msg, name);
|
||||
return (SalCustomHeader*)msg;
|
||||
}
|
||||
|
||||
void sal_custom_header_free(SalCustomHeader *ch){
|
||||
if (ch==NULL) return;
|
||||
belle_sip_object_unref((belle_sip_message_t*)ch);
|
||||
|
|
|
|||
|
|
@ -1129,6 +1129,10 @@ const char *linphone_chat_message_get_custom_header(LinphoneChatMessage *msg, co
|
|||
return sal_custom_header_find(msg->custom_headers, header_name);
|
||||
}
|
||||
|
||||
void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const char *header_name) {
|
||||
msg->custom_headers = sal_custom_header_remove(msg->custom_headers, header_name);
|
||||
}
|
||||
|
||||
bool_t linphone_chat_message_is_read(LinphoneChatMessage *msg) {
|
||||
return msg->is_read;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1804,7 +1804,7 @@ LINPHONE_PUBLIC LinphoneAddress *linphone_chat_message_get_local_address(const L
|
|||
/**
|
||||
* Add custom headers to the message.
|
||||
* @param message the message
|
||||
* @param header_name name of the header_name
|
||||
* @param header_name name of the header
|
||||
* @param header_value header value
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_chat_message_add_custom_header(LinphoneChatMessage* message, const char *header_name, const char *header_value);
|
||||
|
|
@ -1814,6 +1814,12 @@ LINPHONE_PUBLIC void linphone_chat_message_add_custom_header(LinphoneChatMessage
|
|||
* @param header_name header name searched
|
||||
**/
|
||||
LINPHONE_PUBLIC const char * linphone_chat_message_get_custom_header(LinphoneChatMessage* message, const char *header_name);
|
||||
/**
|
||||
* Removes a custom header from the message.
|
||||
* @param message the message
|
||||
* @param header_name name of the header to remove
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_chat_message_remove_custom_header(LinphoneChatMessage *msg, const char *header_name);
|
||||
/**
|
||||
* Returns TRUE if the message has been read, otherwise returns FALSE.
|
||||
* @param message the message
|
||||
|
|
|
|||
|
|
@ -851,6 +851,7 @@ void sal_resolve_cancel(SalResolverContext *ctx);
|
|||
|
||||
SalCustomHeader *sal_custom_header_append(SalCustomHeader *ch, const char *name, const char *value);
|
||||
const char *sal_custom_header_find(const SalCustomHeader *ch, const char *name);
|
||||
SalCustomHeader *sal_custom_header_remove(SalCustomHeader *ch, const char *name);
|
||||
void sal_custom_header_free(SalCustomHeader *ch);
|
||||
SalCustomHeader *sal_custom_header_clone(const SalCustomHeader *ch);
|
||||
|
||||
|
|
|
|||
|
|
@ -1901,6 +1901,35 @@ void file_transfer_with_http_proxy(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void chat_message_custom_headers(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
|
||||
LinphoneChatRoom* chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
|
||||
LinphoneChatMessage* msg = linphone_chat_room_create_message(chat_room, "Lorem Ipsum");
|
||||
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg);
|
||||
|
||||
linphone_chat_message_add_custom_header(msg, "Test1", "Value1");
|
||||
linphone_chat_message_add_custom_header(msg, "Test2", "Value2");
|
||||
linphone_chat_message_remove_custom_header(msg, "Test1");
|
||||
|
||||
linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed);
|
||||
linphone_chat_room_send_chat_message(chat_room,msg);
|
||||
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1));
|
||||
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1));
|
||||
|
||||
if (marie->stat.last_received_chat_message) {
|
||||
const char *header = linphone_chat_message_get_custom_header(marie->stat.last_received_chat_message, "Test2");
|
||||
BC_ASSERT_STRING_EQUAL(header, "Value2");
|
||||
header = linphone_chat_message_get_custom_header(marie->stat.last_received_chat_message, "Test1");
|
||||
BC_ASSERT_PTR_NULL(header);
|
||||
BC_ASSERT_STRING_EQUAL(marie->stat.last_received_chat_message->message, "Lorem Ipsum");
|
||||
}
|
||||
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
test_t message_tests[] = {
|
||||
TEST_NO_TAG("Text message", text_message),
|
||||
TEST_NO_TAG("Text message within call dialog", text_message_within_call_dialog),
|
||||
|
|
@ -1956,6 +1985,7 @@ test_t message_tests[] = {
|
|||
TEST_ONE_TAG("Real Time Text offer answer with different payload numbers (sender side)", real_time_text_message_different_text_codecs_payload_numbers_sender_side, "RTT"),
|
||||
TEST_ONE_TAG("Real Time Text offer answer with different payload numbers (receiver side)", real_time_text_message_different_text_codecs_payload_numbers_receiver_side, "RTT"),
|
||||
TEST_ONE_TAG("Real Time Text copy paste", real_time_text_copy_paste, "RTT"),
|
||||
TEST_NO_TAG("IM Encryption Engine custom headers", chat_message_custom_headers),
|
||||
};
|
||||
|
||||
test_suite_t message_test_suite = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue