From 313fbaa6481f7e7f04d3ab1a32635da3557f2529 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sun, 28 Apr 2013 11:34:03 +0200 Subject: [PATCH] implement use_dates and dates in text messages. --- coreapi/bellesip_sal/sal_impl.c | 8 ++++++++ coreapi/bellesip_sal/sal_impl.h | 1 + coreapi/bellesip_sal/sal_op_call.c | 8 +------- coreapi/bellesip_sal/sal_op_message.c | 6 +++++- coreapi/bellesip_sal/sal_op_registration.c | 6 +++++- coreapi/callbacks.c | 1 + 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 5e1d197bf..c868854b6 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -677,3 +677,11 @@ const char* sal_op_type_to_string(const SalOpType_t type) { return "SalOpUnknown"; } } + +void sal_expire_old_registration_contacts(Sal *ctx, bool_t enabled){ + ms_warning("sal_expire_old_registration_contacts not implemented "); +} + +void sal_use_dates(Sal *ctx, bool_t enabled){ + ctx->use_dates=enabled; +} diff --git a/coreapi/bellesip_sal/sal_impl.h b/coreapi/bellesip_sal/sal_impl.h index 487eb046a..a53afd4c8 100644 --- a/coreapi/bellesip_sal/sal_impl.h +++ b/coreapi/bellesip_sal/sal_impl.h @@ -42,6 +42,7 @@ struct Sal{ bool_t nat_helper_enabled; bool_t tls_verify; bool_t tls_verify_cn; + bool_t use_dates; }; typedef enum SalOpSate { diff --git a/coreapi/bellesip_sal/sal_op_call.c b/coreapi/bellesip_sal/sal_op_call.c index 2401df88c..d399b11d1 100644 --- a/coreapi/bellesip_sal/sal_op_call.c +++ b/coreapi/bellesip_sal/sal_op_call.c @@ -787,12 +787,6 @@ int sal_call_is_offerer(const SalOp *h){ return h->sdp_offering; } -void sal_expire_old_registration_contacts(Sal *ctx, bool_t enabled){ - ms_warning("sal_expire_old_registration_contacts not implemented "); -} - -void sal_use_dates(Sal *ctx, bool_t enabled){ - ms_warning("sal_use_dates not implemented yet"); -} + diff --git a/coreapi/bellesip_sal/sal_op_message.c b/coreapi/bellesip_sal/sal_op_message.c index a1e8a3e54..96ce30d8b 100644 --- a/coreapi/bellesip_sal/sal_op_message.c +++ b/coreapi/bellesip_sal/sal_op_message.c @@ -87,6 +87,7 @@ static void process_request_event(void *op_base, const belle_sip_request_event_t belle_sip_response_t* resp; belle_sip_header_call_id_t* call_id = belle_sip_message_get_header_by_type(req,belle_sip_header_call_id_t); belle_sip_header_cseq_t* cseq = belle_sip_message_get_header_by_type(req,belle_sip_header_cseq_t); + belle_sip_header_date_t *date=belle_sip_message_get_header_by_type(req,belle_sip_header_date_t); SalMessage salmsg; char message_id[256]={0}; int response_code=501; @@ -109,6 +110,7 @@ static void process_request_event(void *op_base, const belle_sip_request_event_t salmsg.text=plain_text?belle_sip_message_get_body(BELLE_SIP_MESSAGE(req)):NULL; salmsg.url=external_body?belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(content_type),"URL"):NULL; salmsg.message_id=message_id; + salmsg.time=date ? belle_sip_header_date_get_time(date) : time(NULL); op->base.root->callbacks.text_received(op,&salmsg); belle_sip_object_unref(address); belle_sip_free(from); @@ -124,10 +126,11 @@ static void process_request_event(void *op_base, const belle_sip_request_event_t } int sal_message_send(SalOp *op, const char *from, const char *to, const char* content_type, const char *msg){ - /*FIXME impement time*/ belle_sip_request_t* req; char content_type_raw[256]; size_t content_length = msg?strlen(msg):0; + time_t curtime=time(NULL); + sal_op_message_fill_cbs(op); if (from) sal_op_set_from(op,from); @@ -138,6 +141,7 @@ int sal_message_send(SalOp *op, const char *from, const char *to, const char* co snprintf(content_type_raw,sizeof(content_type_raw),BELLE_SIP_CONTENT_TYPE ": %s",content_type); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_content_type_parse(content_type_raw))); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_content_length_create(content_length))); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_date_create_from_time(&curtime))); belle_sip_message_set_body(BELLE_SIP_MESSAGE(req),msg,content_length); return sal_op_send_request(op,req); diff --git a/coreapi/bellesip_sal/sal_op_registration.c b/coreapi/bellesip_sal/sal_op_registration.c index 9fc43103f..2bda3266c 100644 --- a/coreapi/bellesip_sal/sal_op_registration.c +++ b/coreapi/bellesip_sal/sal_op_registration.c @@ -73,6 +73,7 @@ static void register_refresher_listener ( const belle_sip_refresher_t* refresher int sal_register(SalOp *op, const char *proxy, const char *from, int expires){ belle_sip_request_t *req; belle_sip_uri_t* req_uri; + op->type=SalOpRegister; sal_op_set_from(op,from); sal_op_set_to(op,from); @@ -80,7 +81,10 @@ int sal_register(SalOp *op, const char *proxy, const char *from, int expires){ req = sal_op_build_request(op,"REGISTER"); req_uri = belle_sip_request_get_uri(req); belle_sip_uri_set_user(req_uri,NULL); /*remove userinfo if any*/ - + if (op->base.root->use_dates){ + time_t curtime=time(NULL); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_date_create_from_time(&curtime))); + } return sal_op_send_and_create_refresher(op,req,expires,register_refresher_listener); } diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 7323573d4..b64500e0c 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -967,6 +967,7 @@ static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status){ chat_msg->state=chatStatusSal2Linphone(status); linphone_chat_message_store_state(chat_msg); if (chat_msg && chat_msg->cb) { + ms_message("Notifying text delivery with status %i",chat_msg->state); chat_msg->cb(chat_msg ,chat_msg->state ,chat_msg->cb_ud);