Commit 474bce2b authored by Ghislain MARY's avatar Ghislain MARY

Separate creation and start of core.

parent e3219d2e
......@@ -151,26 +151,75 @@ void linphone_factory_clean(void){
}
}
LinphoneCore *linphone_factory_create_core_2(const LinphoneFactory *factory, LinphoneCoreCbs *cbs,
const char *config_path, const char *factory_config_path, void *user_data, void *system_context) {
static LinphoneCore *_linphone_factory_create_core (
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
const char *config_path,
const char *factory_config_path,
void *user_data,
void *system_context,
bool_t automatically_start
) {
bctbx_init_logger(FALSE);
LpConfig *config = lp_config_new_with_factory(config_path, factory_config_path);
LinphoneCore *lc = _linphone_core_new_with_config(cbs, config, user_data, system_context);
LinphoneCore *lc = _linphone_core_new_with_config(cbs, config, user_data, system_context, automatically_start);
lp_config_unref(config);
return lc;
}
LinphoneCore *linphone_factory_create_core(const LinphoneFactory *factory, LinphoneCoreCbs *cbs,
const char *config_path, const char *factory_config_path){
return linphone_factory_create_core_2(factory, cbs, config_path, factory_config_path, NULL, NULL);
}
LinphoneCore *linphone_factory_create_core_with_config(const LinphoneFactory *factory, LinphoneCoreCbs *cbs, LinphoneConfig *config) {
return _linphone_core_new_with_config(cbs, config, NULL, NULL);
}
LinphoneCore *linphone_factory_create_core_with_config_2(const LinphoneFactory *factory, LinphoneCoreCbs *cbs, LinphoneConfig *config, void *user_data, void *system_context) {
return _linphone_core_new_with_config(cbs, config, user_data, system_context);
LinphoneCore *linphone_factory_create_core (
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
const char *config_path,
const char *factory_config_path
) {
return _linphone_factory_create_core(factory, cbs, config_path, factory_config_path, NULL, NULL, TRUE);
}
LinphoneCore *linphone_factory_create_core_2 (
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
const char *config_path,
const char *factory_config_path,
void *user_data,
void *system_context
) {
return _linphone_factory_create_core(factory, cbs, config_path, factory_config_path, user_data, system_context, TRUE);
}
LinphoneCore *linphone_factory_create_core_3 (
const LinphoneFactory *factory,
const char *config_path,
const char *factory_config_path,
void *system_context
) {
return _linphone_factory_create_core(factory, NULL, config_path, factory_config_path, NULL, system_context, FALSE);
}
LinphoneCore *linphone_factory_create_core_with_config (
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
LinphoneConfig *config
) {
return _linphone_core_new_with_config(cbs, config, NULL, NULL, TRUE);
}
LinphoneCore *linphone_factory_create_core_with_config_2 (
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
LinphoneConfig *config,
void *user_data,
void *system_context
) {
return _linphone_core_new_with_config(cbs, config, user_data, system_context, TRUE);
}
LinphoneCore *linphone_factory_create_core_with_config_3 (
const LinphoneFactory *factory,
LinphoneConfig *config,
void *system_context
) {
return _linphone_core_new_with_config(NULL, config, NULL, system_context, FALSE);
}
LinphoneCoreCbs *linphone_factory_create_core_cbs(const LinphoneFactory *factory) {
......
......@@ -1990,7 +1990,7 @@ void linphone_core_reload_ms_plugins(LinphoneCore *lc, const char *path){
codecs_config_read(lc);
}
static void linphone_core_start(LinphoneCore * lc) {
static void _linphone_core_start(LinphoneCore * lc) {
LinphoneFriendList *list = linphone_core_create_friend_list(lc);
linphone_friend_list_set_display_name(list, "_default");
linphone_core_add_friend_list(lc, list);
......@@ -2032,7 +2032,7 @@ void linphone_configuring_terminated(LinphoneCore *lc, LinphoneConfiguringState
belle_sip_object_unref(lc->provisioning_http_listener);
lc->provisioning_http_listener = NULL;
}
linphone_core_start(lc);
_linphone_core_start(lc);
}
......@@ -2220,8 +2220,7 @@ static void _linphone_core_init_account_creator_service(LinphoneCore *lc) {
linphone_core_set_account_creator_service(lc, service);
}
static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig *config, void * userdata, void *system_context){
const char *remote_provisioning_uri = NULL;
static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig *config, void * userdata, void *system_context, bool_t automatically_start) {
LinphoneFactory *lfactory = linphone_factory_get();
LinphoneCoreCbs *internal_cbs = _linphone_core_cbs_new();
const char *msplugins_dir;
......@@ -2256,14 +2255,8 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig
if (cbs != NULL) {
_linphone_core_add_callbacks(lc, cbs, FALSE);
} else {
LinphoneCoreCbs *fallback_cbs = linphone_factory_create_core_cbs(linphone_factory_get());
_linphone_core_add_callbacks(lc, fallback_cbs, FALSE);
belle_sip_object_unref(fallback_cbs);
}
linphone_core_set_state(lc,LinphoneGlobalStartup,"Starting up");
ortp_set_log_handler(NULL); /*remove ortp default log handler*/
ortp_init();
......@@ -2309,12 +2302,30 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig
lc->vcard_context = linphone_vcard_context_new();
linphone_core_initialize_supported_content_types(lc);
lc->bw_controller = ms_bandwidth_controller_new();
if (automatically_start) {
linphone_core_start(lc);
}
}
void linphone_core_start (LinphoneCore *lc) {
linphone_core_set_state(lc,LinphoneGlobalStartup,"Starting up");
if (lc->sal->get_root_ca()) {
belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, lc->sal->get_root_ca());
belle_http_provider_set_tls_crypto_config(lc->http_provider, lc->http_crypto_config);
}
linphone_core_set_state(lc, LinphoneGlobalConfiguring, "Configuring");
remote_provisioning_uri = linphone_core_get_provisioning_uri(lc);
if (remote_provisioning_uri == NULL) {
const char *remote_provisioning_uri = linphone_core_get_provisioning_uri(lc);
if (remote_provisioning_uri) {
if (linphone_remote_provisioning_download_and_apply(lc, remote_provisioning_uri) == -1)
linphone_configuring_terminated(lc, LinphoneConfiguringFailed, "Bad URI");
} else {
linphone_configuring_terminated(lc, LinphoneConfiguringSkipped, NULL);
} // else linphone_core_start will be called after the remote provisioning (see linphone_core_iterate)
lc->bw_controller = ms_bandwidth_controller_new();
}
}
#ifdef __ANDROID__
......@@ -2328,10 +2339,10 @@ static void _linphone_core_set_system_context(LinphoneCore *lc, void *system_con
}
#endif
LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata, void *system_context) {
LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata, void *system_context, bool_t automatically_start) {
LinphoneCore *core = L_INIT(Core);
Core::create(core);
linphone_core_init(core, cbs, config, userdata, system_context);
linphone_core_init(core, cbs, config, userdata, system_context, automatically_start);
return core;
}
......@@ -2341,7 +2352,7 @@ LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVTable *vtable, st
LinphoneCore *core = NULL;
if (vtable != NULL) *local_vtable = *vtable;
_linphone_core_cbs_set_v_table(cbs, local_vtable, TRUE);
core = _linphone_core_new_with_config(cbs, config, userdata, NULL);
core = _linphone_core_new_with_config(cbs, config, userdata, NULL, TRUE);
linphone_core_cbs_unref(cbs);
return core;
}
......@@ -3216,7 +3227,6 @@ void linphone_core_iterate(LinphoneCore *lc){
time_t current_real_time = ms_time(NULL);
int64_t diff_time;
bool_t one_second_elapsed=FALSE;
const char *remote_provisioning_uri = NULL;
if (lc->network_reachable_to_be_notified) {
lc->network_reachable_to_be_notified=FALSE;
......@@ -3225,22 +3235,6 @@ void linphone_core_iterate(LinphoneCore *lc){
linphone_core_resolve_stun_server(lc);
}
}
if (linphone_core_get_global_state(lc) == LinphoneGlobalStartup) {
if (lc->sal->get_root_ca()) {
belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, lc->sal->get_root_ca());
belle_http_provider_set_tls_crypto_config(lc->http_provider, lc->http_crypto_config);
}
linphone_core_set_state(lc, LinphoneGlobalConfiguring, "Configuring");
remote_provisioning_uri = linphone_core_get_provisioning_uri(lc);
if (remote_provisioning_uri) {
int err = linphone_remote_provisioning_download_and_apply(lc, remote_provisioning_uri);
if (err == -1) {
linphone_configuring_terminated(lc, LinphoneConfiguringFailed, "Bad URI");
}
} // else linphone_configuring_terminated has already been called in linphone_core_init
}
if (lc->prevtime_ms == 0){
lc->prevtime_ms = curtime_ms;
}
......
......@@ -342,7 +342,7 @@ LINPHONE_PUBLIC int linphone_core_get_call_history_size(LinphoneCore *lc);
int linphone_core_get_edge_bw(LinphoneCore *lc);
int linphone_core_get_edge_ptime(LinphoneCore *lc);
LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata, void *system_context);
LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata, void *system_context, bool_t automatically_start);
int linphone_upnp_init(LinphoneCore *lc);
void linphone_upnp_destroy(LinphoneCore *lc);
......
......@@ -871,13 +871,13 @@ LINPHONE_PUBLIC const char *linphone_core_get_version(void);
LINPHONE_PUBLIC const char *linphone_core_get_user_agent(LinphoneCore *lc);
/**
* @deprecated Use #linphone_core_get_user_agent instead.
* @deprecated 2016-12-20: Use #linphone_core_get_user_agent instead.
* @donotwrap
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_name(void);
/**
* @deprecated Use #linphone_core_get_user_agent instead.
* @deprecated 2016-12-20: Use #linphone_core_get_user_agent instead.
* @donotwrap
**/
LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_version(void);
......@@ -904,7 +904,7 @@ LINPHONE_PUBLIC LINPHONE_DEPRECATED const char *linphone_core_get_user_agent_ver
* @param userdata an opaque user pointer that can be retrieved at any time (for example in
* callbacks) using linphone_core_get_user_data().
* @see linphone_core_new_with_config
* @deprecated Use linphone_factory_create_core() instead.
* @deprecated 2017-01-12: Use linphone_factory_create_core() instead.
* @donotwrap
**/
LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
......@@ -921,11 +921,18 @@ LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new(const Linpho
* @param userdata an opaque user pointer that can be retrieved at any time (for example in
* callbacks) using linphone_core_get_user_data().
* @see linphone_core_new
* @deprecated Use linphone_factory_create_core_with_config() instead.
* @deprecated 2017-01-12: Use linphone_factory_create_core_with_config() instead.
* @donotwrap
**/
LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVTable *vtable, LpConfig *config, void *userdata);
/**
* Start a LinphoneCore object after it has been instantiated.
* @ingroup initializing
* @param[in] core The #LinphoneCore object to be started
*/
LINPHONE_PUBLIC void linphone_core_start (LinphoneCore *core);
/**
* Increment the reference counter of a #LinphoneCore object.
* @param lc The #LinphoneCore which the ref counter is to be incremented.
......
......@@ -62,10 +62,14 @@ LINPHONE_PUBLIC void linphone_factory_clean(void);
* The settings in this factory file always override the one in the normal config file.
* It is OPTIONAL, use NULL if unneeded.
* @see linphone_core_new_with_config
* @deprecated 2018-01-10: Use linphone_factory_create_core_3() instead
*/
LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core(const LinphoneFactory *factory, LinphoneCoreCbs *cbs,
const char *config_path, const char *factory_config_path);
LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core(
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
const char *config_path,
const char *factory_config_path
);
/**
* Instanciate a #LinphoneCore object.
......@@ -87,10 +91,41 @@ LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core(const LinphoneFactory
* @param user_data an application pointer associated with the returned core.
* @param system_context a pointer to a system object required by the core to operate. Currently it is required to pass an android Context on android, pass NULL on other platforms.
* @see linphone_core_new_with_config
* @deprecated 2018-01-10: Use linphone_factory_create_core_3() instead
*/
LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_2(const LinphoneFactory *factory, LinphoneCoreCbs *cbs,
const char *config_path, const char *factory_config_path, void *user_data, void *system_context);
LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_2 (
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
const char *config_path,
const char *factory_config_path,
void *user_data,
void *system_context
);
/**
* Instantiate a #LinphoneCore object.
*
* The LinphoneCore object is the primary handle for doing all phone actions. It should be unique within your
* application.
* The LinphoneCore object is not started automatically, you need to call linphone_core_start() to that effect.
* @param[in] factory The #LinphoneFactory singleton.
* @param[in] config_path A path to a config file. If it does not exists it will be created. The config file is used to
* store all settings, proxies... so that all these settings become persistent over the life of the LinphoneCore object.
* It is allowed to set a NULL config file. In that case LinphoneCore will not store any settings.
* @param[in] factory_config_path A path to a read-only config file that can be used to store hard-coded preferences
* such as proxy settings or internal preferences. The settings in this factory file always override the ones in the
* normal config file. It is optional, use NULL if unneeded.
* @param[in] system_context A pointer to a system object required by the core to operate. Currently it is required to
* pass an android Context on android, pass NULL on other platforms.
* @see linphone_core_new_with_config_3
* @deprecated 2018-01-10: Use linphone_factory_create_core_3() instead
*/
LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_3 (
const LinphoneFactory *factory,
const char *config_path,
const char *factory_config_path,
void *system_context
);
/**
* Instantiates a LinphoneCore object with a given LpConfig.
......@@ -103,8 +138,13 @@ LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_2(const LinphoneFacto
* with linphone_core_remove_cbs().
* @param config a pointer to an LpConfig object holding the configuration of the LinphoneCore to be instantiated.
* @see linphone_core_new
* @deprecated 2018-01-10: Use linphone_factory_create_core_with_config_3() instead
*/
LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_with_config(const LinphoneFactory *factory, LinphoneCoreCbs *cbs, LinphoneConfig *config);
LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_with_config (
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
LinphoneConfig *config
);
/**
* Instantiates a LinphoneCore object with a given LpConfig.
......@@ -119,8 +159,34 @@ LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_with_config(const Lin
* @param user_data an application pointer associated with the returned core.
* @param system_context a pointer to a system object required by the core to operate. Currently it is required to pass an android Context on android, pass NULL on other platforms.
* @see linphone_core_new
* @deprecated 2018-01-10: Use linphone_factory_create_core_with_config_3() instead
*/
LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_with_config_2(const LinphoneFactory *factory, LinphoneCoreCbs *cbs, LinphoneConfig *config, void *user_data, void *system_context);
LINPHONE_DEPRECATED LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_with_config_2 (
const LinphoneFactory *factory,
LinphoneCoreCbs *cbs,
LinphoneConfig *config,
void *user_data,
void *system_context
);
/**
* Instantiate a LinphoneCore object with a given LinphoneConfig.
*
* The LinphoneCore object is the primary handle for doing all phone actions. It should be unique within your
* application.
* The LinphoneCore object is not started automatically, you need to call linphone_core_start() to that effect.
* @param[in] factory The #LinphoneFactory singleton.
* @param[in] config A #LinphoneConfig object holding the configuration for the LinphoneCore to be instantiated.
* @param[in] system_context A pointer to a system object required by the core to operate. Currently it is required to
* pass an android Context on android, pass NULL on other platforms.
* @see linphone_factory_create_core_3
* @deprecated 2018-01-10: Use linphone_factory_create_core_with_config_3() instead
*/
LINPHONE_PUBLIC LinphoneCore *linphone_factory_create_core_with_config_3 (
const LinphoneFactory *factory,
LinphoneConfig *config,
void *system_context
);
/**
* Instanciate a #LinphoneCoreCbs object.
......
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