public void gen_config(XmlNode config_node)
{
XmlNode global_settings = XmlUtils.AddNodeNode(config_node, "global_settings");
Utils.add_xml_param(global_settings, "auto-restart", "true");
Utils.add_xml_param(global_settings, "log-level", "0");
XmlNode profiles = XmlUtils.AddNodeNode(config_node, "profiles");
XmlNode profile = XmlUtils.AddNodeNode(profiles, "profile");
XmlUtils.AddNodeAttrib(profile, "name", "softphone");
XmlNode gateways = XmlUtils.AddNodeNode(profile, "gateways");
Account.create_gateway_nodes(gateways, FieldValue.GetByName(values, "tls").value == "true", FieldValue.GetByName(values, "tls-only").value == "true");
XmlNode settings = XmlUtils.AddNodeNode(profile, "settings");
Utils.add_xml_param(settings, "context", "public");
Utils.add_xml_param(settings, "dialplan", "xml");
Utils.add_xml_param(settings, "disable-register", "true");
bool tls_cert_check_already = false;
foreach (FieldValue value in values)
{
if (String.IsNullOrEmpty(value.field.xml_name))
{
continue;
}
if (String.IsNullOrWhiteSpace(value.value) && !AllowedEmptyFields.Contains(value.field.name))
{
continue;
}
String param_value = value.value;
if ((value.field.name == "tls-only" || value.field.name == "tls") && value.value == "true" && !tls_cert_check_already)
{
if (!tls_cert_exist_check())
{
param_value = "false";
}
else
{
tls_cert_check_already = true;
}
}
Utils.add_xml_param(settings, value.field.xml_name, param_value);
if (value.field.xml_name == "codec-prefs")
{
Utils.add_xml_param(settings, "inbound-codec-prefs", param_value);
Utils.add_xml_param(settings, "outbound-codec-prefs", param_value);
}
}
DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 1000);
}