public static void add_xml_param(XmlNode node, String name, String value) { XmlNode param_node = XmlUtils.AddNodeNode(node, "param"); XmlUtils.AddNodeAttrib(param_node, "name", name); XmlUtils.AddNodeAttrib(param_node, "value", value); }
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); }
public void gen_config(XmlNode config_node) { XmlNode settings = XmlUtils.AddNodeNode(config_node, "settings"); foreach (FieldValue value in values) { if (String.IsNullOrEmpty(value.field.xml_name)) { continue; } if (String.IsNullOrWhiteSpace(value.value) && !AllowedEmptyFields.Contains(value.field.name)) { continue; } Utils.add_xml_param(settings, value.field.xml_name, value.value); } }
private void create_gateway_node(XmlNode gateways_node, bool tls_enabled, bool tls_only) { XmlNode node = XmlUtils.AddNodeNode(gateways_node, "gateway"); XmlUtils.AddNodeAttrib(node, "name", gateway_id); old_gateway_id = gateway_id; foreach (FieldValue value in values) { if (String.IsNullOrEmpty(value.field.xml_name)) { continue; } if (String.IsNullOrWhiteSpace(value.value) && !AllowedEmptyFields.Contains(value.field.name)) { continue; } if (value.field.name == "register-transport") { if (value.value == "tls" && !tls_enabled) { MessageBox.Show("Warning the register-transport for account: " + name + " is set to tls, however you have tls disabled in your sofia settings this account will be disabled for now"); gateways_node.RemoveChild(node); enabled = false; return; } if (value.value != "tls" && tls_only) { MessageBox.Show("Warning the register-transport for account: " + name + " is not set to tls, however you have tls only enabled in your sofia settings this account will be disabled for now"); gateways_node.RemoveChild(node); enabled = false; return; } } if (value.field.name == "sip_secure_media") { secure_media = value.value == "true"; } Utils.add_xml_param(node, value.field.xml_name, value.value); } //Was preventing gateway ID from being passed to create_channel so removed (needed for incoming calls) //FieldValue user = FieldValue.GetByName(values, "username"); //Utils.add_xml_param(node, "extension-in-contact", user.value); }
private string generate_xml_config(String name, String desc, config_gen_del func) { XmlDocument root_doc = new XmlDocument(); XmlNode doc = root_doc.CreateElement("document"); root_doc.AppendChild(doc); XmlUtils.AddNodeAttrib(doc, "type", "freeswitch/xml"); XmlNode sect = XmlUtils.AddNodeNode(doc, "section"); XmlUtils.AddNodeAttrib(sect, "name", "configuration"); XmlNode config_node = XmlUtils.AddNodeNode(sect, "configuration"); XmlUtils.AddNodeAttrib(config_node, "name", name); XmlUtils.AddNodeAttrib(config_node, "description", desc); func(config_node); //root_doc.Save(@"c:\temp\fs_" + name); return(root_doc.OuterXml); }
public void gen_config(XmlNode config_node) { var controls = XmlUtils.AddNodeNode(config_node, "caller-controls"); var control_group = XmlUtils.AddNodeNode(controls, "group"); XmlUtils.AddNodeAttrib(control_group, "name", "default"); var profiles = XmlUtils.AddNodeNode(config_node, "profiles"); var profile = XmlUtils.AddNodeNode(profiles, "profile"); XmlUtils.AddNodeAttrib(profile, "name", "default"); foreach (FieldValue value in values) { if (String.IsNullOrEmpty(value.field.xml_name)) { continue; } if (String.IsNullOrWhiteSpace(value.value) && !AllowedEmptyFields.Contains(value.field.name)) { continue; } Utils.add_xml_param(profile, value.field.xml_name, value.value); } //File.WriteAllText(@"c:\temp\conf.xml",config_node.OuterXml); }