mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-06-02 19:40:08 +00:00
[mod_signalwire] Make this module working with libks and signalwire-c in versions 2.0
* [mod_signalwire] Fix load credentials data from json * [mod_signalwire] Fix parsing of configuration response
This commit is contained in:
parent
4d3b0a5778
commit
eec1fd737c
@ -228,7 +228,7 @@ static ks_status_t load_credentials_from_json(ks_json_t *json)
|
|||||||
const char *relay_connector_id = NULL;
|
const char *relay_connector_id = NULL;
|
||||||
|
|
||||||
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
||||||
if ((bootstrap = ks_json_get_string(json, "bootstrap")) == NULL) {
|
if ((bootstrap = ks_json_get_object_string(json, "bootstrap", NULL)) == NULL) {
|
||||||
#else
|
#else
|
||||||
if ((bootstrap = ks_json_get_object_cstr(json, "bootstrap")) == NULL) {
|
if ((bootstrap = ks_json_get_object_cstr(json, "bootstrap")) == NULL) {
|
||||||
#endif
|
#endif
|
||||||
@ -238,7 +238,7 @@ static ks_status_t load_credentials_from_json(ks_json_t *json)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
||||||
if ((relay_connector_id = ks_json_get_string(json, "relay_connector_id")) == NULL) {
|
if ((relay_connector_id = ks_json_get_object_string(json, "relay_connector_id", NULL)) == NULL) {
|
||||||
#else
|
#else
|
||||||
if ((relay_connector_id = ks_json_get_object_cstr(json, "relay_connector_id")) == NULL) {
|
if ((relay_connector_id = ks_json_get_object_cstr(json, "relay_connector_id")) == NULL) {
|
||||||
#endif
|
#endif
|
||||||
@ -797,6 +797,7 @@ static ks_status_t load_credentials(void)
|
|||||||
status = KS_STATUS_FAIL;
|
status = KS_STATUS_FAIL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
json = ks_json_parse(data);
|
json = ks_json_parse(data);
|
||||||
@ -805,6 +806,7 @@ static ks_status_t load_credentials(void)
|
|||||||
status = KS_STATUS_FAIL;
|
status = KS_STATUS_FAIL;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = load_credentials_from_json(json);
|
status = load_credentials_from_json(json);
|
||||||
ks_json_delete(&json);
|
ks_json_delete(&json);
|
||||||
|
|
||||||
@ -981,7 +983,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_signalwire_load)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
sslLoadWindowsCACertificate();
|
sslLoadWindowsCACertificate();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
swclt_config_create(&globals.config);
|
swclt_config_create(&globals.config);
|
||||||
load_config();
|
load_config();
|
||||||
@ -1206,6 +1207,7 @@ static void mod_signalwire_state_configure(void)
|
|||||||
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
||||||
if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &reply)) {
|
if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &reply)) {
|
||||||
if (reply->type == SWCLT_CMD_TYPE_RESULT) {
|
if (reply->type == SWCLT_CMD_TYPE_RESULT) {
|
||||||
|
ks_json_t *result;
|
||||||
#else
|
#else
|
||||||
if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &cmd)) {
|
if (!swclt_sess_provisioning_configure(globals.signalwire_session, "freeswitch", local_endpoint, external_endpoint, globals.relay_connector_id, &cmd)) {
|
||||||
SWCLT_CMD_TYPE cmd_type;
|
SWCLT_CMD_TYPE cmd_type;
|
||||||
@ -1215,7 +1217,8 @@ static void mod_signalwire_state_configure(void)
|
|||||||
#endif
|
#endif
|
||||||
signalwire_provisioning_configure_response_t *configure_res;
|
signalwire_provisioning_configure_response_t *configure_res;
|
||||||
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
||||||
if (!SIGNALWIRE_PROVISIONING_CONFIGURE_RESPONSE_PARSE(reply->pool, reply->json, &configure_res)) {
|
result = ks_json_get_object_item(reply->json, "result");
|
||||||
|
if (!SIGNALWIRE_PROVISIONING_CONFIGURE_RESPONSE_PARSE(reply->pool, result, &configure_res)) {
|
||||||
#else
|
#else
|
||||||
swclt_cmd_result(cmd, &result);
|
swclt_cmd_result(cmd, &result);
|
||||||
result = ks_json_get_object_item(result, "result");
|
result = ks_json_get_object_item(result, "result");
|
||||||
@ -1223,7 +1226,7 @@ static void mod_signalwire_state_configure(void)
|
|||||||
#endif
|
#endif
|
||||||
ks_json_t *configuration = configure_res->configuration;
|
ks_json_t *configuration = configure_res->configuration;
|
||||||
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
#if SIGNALWIRE_CLIENT_C_VERSION_MAJOR >= 2
|
||||||
const char *configuration_profile = ks_json_get_string(configuration, "profile");
|
const char *configuration_profile = ks_json_get_object_string(configuration, "profile", NULL);
|
||||||
#else
|
#else
|
||||||
const char *configuration_profile = ks_json_get_object_cstr(configuration, "profile");
|
const char *configuration_profile = ks_json_get_object_cstr(configuration, "profile");
|
||||||
#endif
|
#endif
|
||||||
@ -1231,6 +1234,7 @@ static void mod_signalwire_state_configure(void)
|
|||||||
switch_xml_free(globals.signalwire_profile);
|
switch_xml_free(globals.signalwire_profile);
|
||||||
globals.signalwire_profile = NULL;
|
globals.signalwire_profile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\"\n", configuration_profile);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\"%s\"\n", configuration_profile);
|
||||||
globals.signalwire_profile = switch_xml_parse_str_dynamic((char *)configuration_profile, SWITCH_TRUE);
|
globals.signalwire_profile = switch_xml_parse_str_dynamic((char *)configuration_profile, SWITCH_TRUE);
|
||||||
if (!globals.signalwire_profile) {
|
if (!globals.signalwire_profile) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user