From 1d85405c459d995cff457df7a6a728c582e71054 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 5 Nov 2015 11:44:16 +0100 Subject: [PATCH] remote_provisioning.c: modify linphone_core_set_provisioning_uri to return -1 if URI cannot be parsed, 0 otherwise --- coreapi/linphonecore.h | 5 +++-- coreapi/remote_provisioning.c | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 7c6934221..60a704ca5 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -3926,10 +3926,11 @@ typedef void (*ContactSearchCallback)( LinphoneContactSearch* id, MSList* friend * Calling this function does not load the configuration. It will write the value into configuration so that configuration * from remote URI will take place at next LinphoneCore start. * @param lc the linphone core - * @param uri the http or https uri to use in order to download the configuration. + * @param uri the http or https uri to use in order to download the configuration. Passing NULL will disable remote provisionning. + * @return -1 if uri could not be parsed, 0 otherwise. Note that this does not check validity of URI endpoint nor scheme and download may still fail. * @ingroup initializing **/ -LINPHONE_PUBLIC void linphone_core_set_provisioning_uri(LinphoneCore *lc, const char*uri); +LINPHONE_PUBLIC int linphone_core_set_provisioning_uri(LinphoneCore *lc, const char*uri); /** * Get provisioning URI. diff --git a/coreapi/remote_provisioning.c b/coreapi/remote_provisioning.c index 2d7091bd7..9d638307c 100644 --- a/coreapi/remote_provisioning.c +++ b/coreapi/remote_provisioning.c @@ -129,8 +129,15 @@ int linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char } } -void linphone_core_set_provisioning_uri(LinphoneCore *lc, const char *uri) { - lp_config_set_string(lc->config,"misc","config-uri",uri); +int linphone_core_set_provisioning_uri(LinphoneCore *lc, const char *remote_provisioning_uri) { + belle_generic_uri_t *uri=remote_provisioning_uri?belle_generic_uri_parse(remote_provisioning_uri):NULL; + if (!remote_provisioning_uri||uri) { + lp_config_set_string(lc->config,"misc","config-uri",remote_provisioning_uri); + return 0; + } + ms_error("Invalid provisioning URI [%s] (could not be parsed)",remote_provisioning_uri); + return -1; + } const char*linphone_core_get_provisioning_uri(const LinphoneCore *lc){