From d5e59ae6eef31be6600fa4ce875bfcea70f1d85e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 19 Oct 2017 10:39:42 +0200 Subject: [PATCH] content_set_buffer now takes a uint8_t* instead of a void* so it can be correctly wrapped automatically --- coreapi/content.c | 6 +++--- coreapi/proxy.c | 2 +- include/linphone/content.h | 4 ++-- .../local-conference-event-handler.cpp | 2 +- tester/eventapi_tester.c | 18 +++++++++--------- tester/flexisip_tester.c | 4 ++-- tester/message_tester.c | 2 +- wrappers/java/genwrapper.py | 10 +--------- 8 files changed, 20 insertions(+), 28 deletions(-) diff --git a/coreapi/content.c b/coreapi/content.c index 86d2cfbcc..055591ee5 100644 --- a/coreapi/content.c +++ b/coreapi/content.c @@ -118,11 +118,11 @@ void linphone_content_set_subtype(LinphoneContent *content, const char *subtype) sal_body_handler_set_subtype(content->body_handler, subtype); } -void * linphone_content_get_buffer(const LinphoneContent *content) { - return sal_body_handler_get_data(content->body_handler); +uint8_t * linphone_content_get_buffer(const LinphoneContent *content) { + return (uint8_t *)sal_body_handler_get_data(content->body_handler); } -void linphone_content_set_buffer(LinphoneContent *content, const void *buffer, size_t size) { +void linphone_content_set_buffer(LinphoneContent *content, const uint8_t *buffer, size_t size) { void *data; sal_body_handler_set_size(content->body_handler, size); data = belle_sip_malloc(size + 1); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 47fae5ed0..63a0af6eb 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -887,7 +887,7 @@ int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphonePrese } content = linphone_content_new(); - linphone_content_set_buffer(content,presence_body,strlen(presence_body)); + linphone_content_set_buffer(content, (const uint8_t *)presence_body,strlen(presence_body)); linphone_content_set_type(content, "application"); linphone_content_set_subtype(content,"pidf+xml"); if (proxy->sip_etag) { diff --git a/include/linphone/content.h b/include/linphone/content.h index 653d4344a..78ebc3114 100644 --- a/include/linphone/content.h +++ b/include/linphone/content.h @@ -94,7 +94,7 @@ LINPHONE_PUBLIC void linphone_content_set_subtype(LinphoneContent *content, cons * @param[in] content LinphoneContent object. * @return The content data buffer. */ -LINPHONE_PUBLIC void * linphone_content_get_buffer(const LinphoneContent *content); +LINPHONE_PUBLIC uint8_t * linphone_content_get_buffer(const LinphoneContent *content); /** * Set the content data buffer, usually a string. @@ -102,7 +102,7 @@ LINPHONE_PUBLIC void * linphone_content_get_buffer(const LinphoneContent *conten * @param[in] buffer The content data buffer. * @param[in] size The size of the content data buffer. */ -LINPHONE_PUBLIC void linphone_content_set_buffer(LinphoneContent *content, const void *buffer, size_t size); +LINPHONE_PUBLIC void linphone_content_set_buffer(LinphoneContent *content, const uint8_t *buffer, size_t size); /** * Get the string content data buffer. diff --git a/src/conference/local-conference-event-handler.cpp b/src/conference/local-conference-event-handler.cpp index 92c6149e2..94ca0c870 100644 --- a/src/conference/local-conference-event-handler.cpp +++ b/src/conference/local-conference-event-handler.cpp @@ -38,7 +38,7 @@ using namespace Xsd::ConferenceInfo; static void doNotify (const string ¬ify, LinphoneEvent *lev) { LinphoneContent *content = linphone_core_create_content(lev->lc); - linphone_content_set_buffer(content, notify.c_str(), strlen(notify.c_str())); + linphone_content_set_buffer(content, (const uint8_t *)notify.c_str(), strlen(notify.c_str())); linphone_event_notify(lev, content); linphone_content_unref(content); } diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index 7bbdbf24e..8d3e7d600 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -55,7 +55,7 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li content = linphone_core_create_content(lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml2"); - linphone_content_set_buffer(content,notify_content,strlen(notify_content)); + linphone_content_set_buffer(content,(const uint8_t *)notify_content,strlen(notify_content)); ms_message("Subscription state [%s] from [%s]",linphone_subscription_state_to_string(state),from); ms_free(from); @@ -138,7 +138,7 @@ static void subscribe_test_declined(void) { content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + linphone_content_set_buffer(content,(const uint8_t *)subscribe_content,strlen(subscribe_content)); pauline->decline_subscribe=TRUE; @@ -186,7 +186,7 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + linphone_content_set_buffer(content,(const uint8_t *)subscribe_content,strlen(subscribe_content)); lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",expires,content); linphone_event_ref(lev); @@ -244,7 +244,7 @@ static void subscribe_test_with_args2(bool_t terminated_by_subscriber, RefreshTe content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + linphone_content_set_buffer(content,(const uint8_t *)subscribe_content,strlen(subscribe_content)); lev=linphone_core_create_subscribe(marie->lc,pauline->identity,"dodo",expires); linphone_event_add_custom_header(lev,"My-Header","pouet"); @@ -332,7 +332,7 @@ static void subscribe_loosing_dialog(void) { content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + linphone_content_set_buffer(content,(const uint8_t *)subscribe_content,strlen(subscribe_content)); lev=linphone_core_create_subscribe(marie->lc,pauline->identity,"dodo",expires); linphone_event_add_custom_header(lev,"My-Header","pouet"); @@ -395,7 +395,7 @@ static void subscribe_with_io_error(void) { content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + linphone_content_set_buffer(content,(const uint8_t *)subscribe_content,strlen(subscribe_content)); lev=linphone_core_create_subscribe(marie->lc,pauline->identity,"dodo",expires); linphone_event_add_custom_header(lev,"My-Header","pouet"); @@ -449,7 +449,7 @@ static void subscribe_not_timely_responded(void) { content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + linphone_content_set_buffer(content,(const uint8_t *)subscribe_content,strlen(subscribe_content)); lev=linphone_core_create_subscribe(marie->lc,pauline->identity,"dodo",expires); linphone_event_add_custom_header(lev,"My-Header","pouet"); @@ -495,7 +495,7 @@ static void publish_test_with_args(bool_t refresh, int expires){ content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + linphone_content_set_buffer(content,(const uint8_t *)subscribe_content,strlen(subscribe_content)); lp_config_set_int(linphone_core_get_config(marie->lc),"sip","refresh_generic_publish",refresh); @@ -551,7 +551,7 @@ static void out_of_dialog_notify(void){ content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content,notify_content,strlen(notify_content)); + linphone_content_set_buffer(content,(const uint8_t *)notify_content,strlen(notify_content)); lev = linphone_core_create_notify(marie->lc,pauline->identity,"dodo"); linphone_event_ref(lev); diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 9c46c2942..1eca49e28 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -42,7 +42,7 @@ static void subscribe_forking(void) { content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); - linphone_content_set_buffer(content, liblinphone_tester_get_subscribe_content(), strlen(liblinphone_tester_get_subscribe_content())); + linphone_content_set_buffer(content, (const uint8_t *)liblinphone_tester_get_subscribe_content(), strlen(liblinphone_tester_get_subscribe_content())); lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",expires,content); @@ -1102,7 +1102,7 @@ static void test_list_subscribe (void) { linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"resource-lists+xml"); - linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); + linphone_content_set_buffer(content,(const uint8_t *)subscribe_content,strlen(subscribe_content)); lev=linphone_core_create_subscribe(marie->lc,list_name,"presence",60); diff --git a/tester/message_tester.c b/tester/message_tester.c index 0cd61f82a..98c7a1f83 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -833,7 +833,7 @@ void info_message_base(bool_t with_content) { LinphoneContent* ct=linphone_core_create_content(marie->lc); linphone_content_set_type(ct,"application"); linphone_content_set_subtype(ct,"somexml"); - linphone_content_set_buffer(ct,info_content,strlen(info_content)); + linphone_content_set_buffer(ct,(const uint8_t *)info_content,strlen(info_content)); linphone_info_message_set_content(info,ct); linphone_content_unref(ct); } diff --git a/wrappers/java/genwrapper.py b/wrappers/java/genwrapper.py index 6c4445e6c..46fa2138e 100644 --- a/wrappers/java/genwrapper.py +++ b/wrappers/java/genwrapper.py @@ -249,17 +249,9 @@ class JavaTranslator(object): return 'char' elif _type.name == 'void': if isReturn: - if _type.isref and jni: - return 'jbyteArray' - if _type.isref: - return 'byte[]' return 'void' if jni: - if _type.isref and _type.isconst: - return 'jbyteArray' return 'jobject' - if _type.isref and _type.isconst: - return 'byte[]' return 'Object' return _type.name @@ -423,7 +415,7 @@ class JavaTranslator(object): methodDict['params_impl'] += '(' + argCType + ') ' + argname elif type(arg.type) is AbsApi.BaseType: - if (arg.type.name == 'integer' and arg.type.size is not None and arg.type.isref) or (arg.type.name == 'void' and arg.type.isref and arg.type.isconst): + if arg.type.name == 'integer' and arg.type.size is not None and arg.type.isref: methodDict['bytes'].append({'bytesargname': argname, 'bytesargtype' : self.translate_as_c_base_type(arg.type)}) methodDict['params_impl'] += 'c_' + argname elif arg.type.name == 'string':