GetByName() public static method

public static GetByName ( FieldValue values, string name ) : FieldValue
values FieldValue
name string
return FieldValue
示例#1
0
 public Account()
 {
     _server = FieldValue.GetByName(values, "server");
     _server.PropertyChanged += (s, e) => RaisePropertyChanged("server");
     _username = FieldValue.GetByName(values, "username");
     _username.PropertyChanged += (s, e) => RaisePropertyChanged("username");
     _name = FieldValue.GetByName(values, "name");
     _name.PropertyChanged += (s, e) => RaisePropertyChanged("name");
     _guid = FieldValue.GetByName(values, "guid");
     _guid.PropertyChanged += (s, e) => {
         if (!guid_ok(this, _guid.value) || String.IsNullOrEmpty(_guid.value))
         {
             for (int i = 1; i <= 10; i++)
             {
                 int val = i == 10 ? 0 : i;                         // want 0 checked last.
                 if (guid_ok(this, val.ToString()))
                 {
                     _guid.value = val.ToString();
                     return;
                 }
             }
         }
         RaisePropertyChanged("guid");
         RaisePropertyChanged("gateway_id");
     };
     _caller_id_name = FieldValue.GetByName(values, "caller_id_name");
     _caller_id_name.PropertyChanged += (s, e) => RaisePropertyChanged("caller_id_name");
     _caller_id_number = FieldValue.GetByName(values, "caller_id_number");
     _caller_id_number.PropertyChanged += (s, e) => RaisePropertyChanged("caller_id_number");
     _guid.value      = "1";
     PropertyChanged += Account_PropertyChanged;
     state            = "NOREG";
 }
示例#2
0
 public string getSendVoicemailURL()
 {
     if (send_voicemail_val == null)
     {
         send_voicemail_val = FieldValue.GetByName(values, "sip_send_voicemail_url");
     }
     return(send_voicemail_val.value);
 }
示例#3
0
 public string getCheckVoicemailURL()
 {
     if (check_voicemail_val == null)
     {
         check_voicemail_val = FieldValue.GetByName(values, "sip_check_voicemail_url");
     }
     return(check_voicemail_val.value);
 }
示例#4
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);
        }
示例#5
0
        public Conference GetConference()
        {
            var socket = Conference.instance;

            foreach (SettingsField field in fields)
            {
                FieldValue val = FieldValue.GetByName(socket.values, field.name);
                if (val != null)
                {
                    val.value = field.value;
                }
            }
            return(socket);
        }
示例#6
0
        public Sofia GetSofia()
        {
            Sofia sofia = new Sofia();

            foreach (SettingsField field in fields)
            {
                FieldValue val = FieldValue.GetByName(sofia.values, field.name);
                if (val != null)
                {
                    val.value = field.value;
                }
            }
            return(sofia);
        }
        public EventSocket GetEventSocket()
        {
            EventSocket socket = new EventSocket();

            foreach (SettingsField field in fields)
            {
                FieldValue val = FieldValue.GetByName(socket.values, field.name);
                if (val != null)
                {
                    val.value = field.value;
                }
            }
            return(socket);
        }
示例#8
0
        public Account GetAccount()
        {
            Account act = new Account {
                enabled = enabled, is_default_account = is_default_account
            };

            foreach (SettingsField field in fields)
            {
                FieldValue val = FieldValue.GetByName(act.values, field.name);
                if (val != null)
                {
                    val.value = field.value;
                }
            }
            return(act);
        }
示例#9
0
        private bool sofia_actual_profile_check(bool is_last_try)
        {
            String res = Utils.api_exec("sofia", "xmlstatus profile softphone").ToLower().Trim();

            if (res == "invalid command!")
            {
                if (!is_last_try)
                {
                    return(false);
                }
                MessageBox.Show("Warning mod_sofia module does not seem to be loaded please make sure it exists");
                master_profile_ok = false;
                return(false);
            }
            if (res == "invalid profile!")
            {
                if (!is_last_try)
                {
                    return(false);
                }
                String tls_port_msg = "";
                if (FieldValue.GetByName(values, "tls").value == "true")
                {
                    tls_port_msg += " and tls bind port (" + FieldValue.GetByName(values, "tls-sip-port").value + ")";
                }
                var message_res = MessageBox.Show("Warning the master sofia profile was not able to load and the phone will most likely _not_ work, make sure the local bind port (" + FieldValue.GetByName(values, "sip-port").value + ")" + tls_port_msg + " is free(set under the Advanced tab of in the sofia settings) and FSClient is allowed through your firewall, otherwise check the freeswitch.log for more details. This can sometimes happen when you lose network connection. You can try reloading the sofia profile by editing the sofia settings and clicking save to see if fixed.   Do you want to try and reload sofia now?", "Sofia Profile Not Loaded", MessageBoxButton.YesNo);
                master_profile_ok = false;
                if (message_res == MessageBoxResult.Yes)
                {
                    reload_config(RELOAD_CONFIG_MODE.MODULE);
                }
                return(false);
            }
            if (res.Contains("<context>public</context>") == false)
            {
                if (!is_last_try)
                {
                    return(false);
                }
                master_profile_ok = false;
                MessageBox.Show("I believe there may be a problem with sofia, but I do not know what");
                return(false);
            }
            master_profile_ok = true;
            return(true);
        }
示例#10
0
        private bool tls_cert_exist_check()
        {
            String base_dir = FieldValue.GetByName(values, "tls-cert-dir").value;

            if (String.IsNullOrWhiteSpace(base_dir))
            {
                base_dir = "conf/ssl";
            }
            //this is what freeswitch uses by default if its empty, if this changes this code needs to be updated
            base_dir = base_dir.Replace('/', '\\');             //windows file path
            if (base_dir[base_dir.Length - 1] != '\\')
            {
                base_dir += '\\';
            }
            if (!System.IO.File.Exists(base_dir + "cafile.pem"))
            {
                MessageBox.Show("Your sofia settings have TLS enabled however you do not have a cafile.pem in your cert folder, this will most likely cause the entire softphone profile not to load so I am disabling TLS in the profile for now");
                return(false);
            }
            return(true);
        }