Commit d447704d authored by Simon Morlat's avatar Simon Morlat

add "encoding" field to LinphoneContent

parent 8cda14a4
......@@ -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;
}
......
......@@ -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;
......
......@@ -114,6 +114,7 @@ struct _LinphoneContent{
char *subtype; /**<mime subtype for the data, for example "html"*/
void *data; /**<the actual data buffer, usually a string */
size_t size; /**<the size of the data buffer, excluding null character despite null character is always set for convenience.*/
char *encoding; /**<The encoding of the data buffer, for example "gzip"*/
};
/**
......
......@@ -345,6 +345,7 @@ typedef struct SalBody{
const char *subtype;
const void *data;
size_t size;
const char *encoding;
}SalBody;
typedef void (*SalOnCallReceived)(SalOp *op);
......
......@@ -38,7 +38,7 @@ void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *
void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
stats* counters = get_stats(lc);
LinphoneCoreManager *mgr=get_manager(lc);
LinphoneContent content;
LinphoneContent content={0};
content.type="application";
content.subtype="somexml2";
......@@ -96,7 +96,7 @@ void linphone_publish_state_changed(LinphoneCore *lc, LinphoneEvent *ev, Linphon
static void subscribe_test_declined(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
LinphoneContent content;
LinphoneContent content={0};
MSList* lcs=ms_list_append(NULL,marie->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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment