diff --git a/.cproject b/.cproject index 4df5a2726..539e03aa9 100644 --- a/.cproject +++ b/.cproject @@ -56,7 +56,7 @@ - + diff --git a/.project b/.project index c66540e4e..be0bf116a 100644 --- a/.project +++ b/.project @@ -23,7 +23,7 @@ org.eclipse.cdt.make.core.buildArguments - CFLAGS="-g -Wall -Werror" + CFLAGS="-g -Wall -Werror" V=1 org.eclipse.cdt.make.core.buildCommand diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 0a0a1248c..696f55807 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -17,7 +17,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "sal_impl.h" - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif void sal_enable_logs(){ belle_sip_set_log_level(BELLE_SIP_LOG_MESSAGE); } @@ -66,8 +68,8 @@ static void process_io_error(void *user_ctx, const belle_sip_io_error_event_t *e ms_error("process_io_error not implemented yet"); } static void process_request_event(void *user_ctx, const belle_sip_request_event_t *event) { - belle_sip_server_transaction_t* server_transaction = belle_sip_request_event_get_server_transaction(event); - SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(server_transaction)); + /*belle_sip_server_transaction_t* server_transaction = belle_sip_request_event_get_server_transaction(event); + SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(server_transaction));*/ ms_error("sal process_request_event not implemented yet"); } @@ -168,7 +170,13 @@ static void process_transaction_terminated(void *user_ctx, const belle_sip_trans } Sal * sal_init(){ + char stack_string[64]; Sal * sal=ms_new0(Sal,1); + snprintf(stack_string,sizeof(stack_string)-1,"(belle-sip/%s)",belle_sip_version_to_string()); + sal->user_agent=belle_sip_header_user_agent_new(); + belle_sip_header_user_agent_add_product(sal->user_agent, PACKAGE_NAME "/" LINPHONE_VERSION); + belle_sip_header_user_agent_add_product(sal->user_agent,stack_string); + belle_sip_object_ref(sal->user_agent); sal->stack = belle_sip_stack_new(NULL); sal->prov = belle_sip_stack_create_provider(sal->stack,NULL); sal->listener_callbacks.process_dialog_terminated=process_dialog_terminated; @@ -235,6 +243,7 @@ void sal_set_callbacks(Sal *ctx, const SalCallbacks *cbs){ void sal_uninit(Sal* sal){ + belle_sip_object_unref(sal->user_agent); belle_sip_object_unref(sal->prov); belle_sip_object_unref(sal->stack); ms_free(sal); @@ -269,7 +278,8 @@ ortp_socket_t sal_get_socket(Sal *ctx){ return -1; } void sal_set_user_agent(Sal *ctx, const char *user_agent){ - ms_error("sal_set_user_agent not implemented yet"); + belle_sip_header_user_agent_set_products(ctx->user_agent,NULL); + belle_sip_header_user_agent_add_product(ctx->user_agent,user_agent); return ; } /*keepalive period in ms*/ diff --git a/coreapi/bellesip_sal/sal_impl.h b/coreapi/bellesip_sal/sal_impl.h index 9fb6c73ba..33a7e0ea2 100644 --- a/coreapi/bellesip_sal/sal_impl.h +++ b/coreapi/bellesip_sal/sal_impl.h @@ -29,6 +29,7 @@ struct Sal{ belle_sip_listener_callbacks_t listener_callbacks; belle_sip_stack_t* stack; belle_sip_provider_t *prov; + belle_sip_header_user_agent_t* user_agent; void *up; /*user pointer*/ int session_expires; }; diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index cd5eeecc3..89d6e8644 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -120,6 +120,7 @@ belle_sip_request_t* sal_op_build_request(SalOp *op,const char* method) { belle_sip_header_via_new(), 70); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(contact_header)); + belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(op->base.root->user_agent)); return req; } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 668874e2b..f02a457b5 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1470,15 +1470,17 @@ extern const char *eXosip_get_version(); #endif static void apply_user_agent(LinphoneCore *lc){ +#if !USE_BELLESIP /*default user agent is handled at sal level*/ char ua_string[256]; snprintf(ua_string,sizeof(ua_string)-1,"%s/%s (eXosip2/%s)",_ua_name,_ua_version, -#if HAVE_EXOSIP_GET_VERSION && !USE_BELLESIP +#if HAVE_EXOSIP_GET_VERSION eXosip_get_version() #else "unknown" #endif ); if (lc->sal) sal_set_user_agent(lc->sal,ua_string); +#endif } /** @@ -1537,7 +1539,9 @@ static int apply_transports(LinphoneCore *lc){ transport_error(lc,"tls",tr->tls_port); } } + apply_user_agent(lc); + return 0; }