From d447704d15116739389c4e0903b48708bb381d21 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 14 Nov 2013 22:12:09 +0100 Subject: [PATCH] add "encoding" field to LinphoneContent --- coreapi/bellesip_sal/sal_op_impl.c | 13 ++++++++++++- coreapi/info.c | 5 +++++ coreapi/linphonecore.h | 1 + include/sal/sal.h | 1 + tester/eventapi_tester.c | 8 ++++---- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index 30bede48a..02cb90a1f 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -540,6 +540,7 @@ const char *sal_op_get_remote_contact(const SalOp *op){ void sal_op_add_body(SalOp *op, belle_sip_message_t *req, const SalBody *body){ belle_sip_message_remove_header((belle_sip_message_t*)req,"Content-type"); belle_sip_message_remove_header((belle_sip_message_t*)req,"Content-length"); + belle_sip_message_remove_header((belle_sip_message_t*)req,"Content-encoding"); belle_sip_message_set_body((belle_sip_message_t*)req,NULL,0); if (body && body->type && body->subtype && body->data){ belle_sip_message_add_header((belle_sip_message_t*)req, @@ -547,6 +548,10 @@ void sal_op_add_body(SalOp *op, belle_sip_message_t *req, const SalBody *body){ belle_sip_message_add_header((belle_sip_message_t*)req, (belle_sip_header_t*)belle_sip_header_content_length_create(body->size)); belle_sip_message_set_body((belle_sip_message_t*)req,(const char*)body->data,body->size); + if (body->encoding){ + belle_sip_message_add_header((belle_sip_message_t*)req,(belle_sip_header_t*) + belle_sip_header_create("Content-encoding",body->encoding)); + } } } @@ -555,23 +560,29 @@ bool_t sal_op_get_body(SalOp *op, belle_sip_message_t *msg, SalBody *salbody){ const char *body = NULL; belle_sip_header_content_type_t *content_type; belle_sip_header_content_length_t *clen=NULL; + belle_sip_header_t *content_encoding; content_type=belle_sip_message_get_header_by_type(msg,belle_sip_header_content_type_t); if (content_type){ body=belle_sip_message_get_body(msg); clen=belle_sip_message_get_header_by_type(msg,belle_sip_header_content_length_t); } + content_encoding=belle_sip_message_get_header(msg,"Content-encoding"); + + memset(salbody,0,sizeof(SalBody)); if (content_type && body && clen) { salbody->type=belle_sip_header_content_type_get_type(content_type); salbody->subtype=belle_sip_header_content_type_get_subtype(content_type); salbody->data=body; salbody->size=belle_sip_header_content_length_get_content_length(clen); + if (content_encoding) + salbody->encoding=belle_sip_header_get_unparsed_value(content_encoding); return TRUE; } - memset(salbody,0,sizeof(SalBody)); return FALSE; } + void sal_op_set_privacy(SalOp* op,SalPrivacyMask privacy) { op->privacy=privacy; } diff --git a/coreapi/info.c b/coreapi/info.c index 539855ab8..ff7ff3c93 100644 --- a/coreapi/info.c +++ b/coreapi/info.c @@ -45,6 +45,7 @@ struct _LinphoneInfoMessage{ static void linphone_content_copy(LinphoneContent *obj, const LinphoneContent *ref){ SET_STRING(obj,type,ref->type); SET_STRING(obj,subtype,ref->subtype); + SET_STRING(obj,encoding,ref->encoding); if (obj->data) { ms_free(obj->data); obj->data=NULL; @@ -61,11 +62,13 @@ void linphone_content_uninit(LinphoneContent * obj){ if (obj->type) ms_free(obj->type); if (obj->subtype) ms_free(obj->subtype); if (obj->data) ms_free(obj->data); + if (obj->encoding) ms_free(obj->encoding); } LinphoneContent *linphone_content_copy_from_sal_body(LinphoneContent *obj, const SalBody *ref){ SET_STRING(obj,type,ref->type); SET_STRING(obj,subtype,ref->subtype); + SET_STRING(obj,encoding,ref->encoding); if (obj->data) { ms_free(obj->data); obj->data=NULL; @@ -84,6 +87,7 @@ const LinphoneContent *linphone_content_from_sal_body(LinphoneContent *obj, cons obj->type=(char*)ref->type; obj->subtype=(char*)ref->subtype; obj->data=(void*)ref->data; + obj->encoding=(char*)ref->encoding; obj->size=ref->size; return obj; } @@ -96,6 +100,7 @@ SalBody *sal_body_from_content(SalBody *body, const LinphoneContent *lc){ body->subtype=lc->subtype; body->data=lc->data; body->size=lc->size; + body->encoding=lc->encoding; return body; } return NULL; diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index af64a7887..9ba12e8e8 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -114,6 +114,7 @@ struct _LinphoneContent{ char *subtype; /**lc); lcs=ms_list_append(lcs,pauline->lc); @@ -123,7 +123,7 @@ static void subscribe_test_declined(void) { static void subscribe_test_with_args(bool_t terminated_by_subscriber, bool_t test_refreshing) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); - LinphoneContent content; + LinphoneContent content={0}; LinphoneEvent *lev; int expires= test_refreshing ? 4 : 600; MSList* lcs=ms_list_append(NULL,marie->lc); @@ -184,7 +184,7 @@ static void subscribe_test_refreshed(void){ static void publish_test_with_args(bool_t refresh){ LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); - LinphoneContent content; + LinphoneContent content={0}; LinphoneEvent *lev; MSList* lcs=ms_list_append(NULL,marie->lc); lcs=ms_list_append(lcs,pauline->lc);