FSClient.Account.create_gateway_nodes C# (CSharp) Method

create_gateway_nodes() public static method

public static create_gateway_nodes ( XmlNode gateways_node, bool tls_enabled, bool tls_only ) : void
gateways_node System.Xml.XmlNode
tls_enabled bool
tls_only bool
return void
        public static void create_gateway_nodes(XmlNode gateways_node, bool tls_enabled, bool tls_only)
        {
            foreach (Account account in accounts) {
                if (account.enabled)
                    account.create_gateway_node(gateways_node, tls_enabled, tls_only);
            }
        }

Usage Example

Example #1
0
        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);
        }