api_exec() 공개 정적인 메소드

public static api_exec ( String cmd, String args ) : string
cmd String
args String
리턴 string
예제 #1
0
 private void KillGateway()
 {
     if (!String.IsNullOrEmpty(old_gateway_id))
     {
         Utils.api_exec("sofia", "profile softphone killgw " + old_gateway_id);
     }
 }
예제 #2
0
        public static void refresh_devices(bool force = false)
        {
            if (!force && !Broker.get_instance().fully_loaded)
            {
                return;
            }
            foreach (InternalAudioDevice device in _devices)
            {
                device.is_alive = false;
            }
            Utils.api_exec("pa", "rescan");
            XmlDocument doc = null;

            try{
                doc = XmlUtils.GetDocument(Utils.api_exec("pa", "devlist xml"));
            }catch (KeyNotFoundException) {
                MessageBox.Show("Portaudio did not return a device list most likely because it cannot find an active microphone or speaker it can use, FSClient will now exit.", "Missing Device List", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(-1);
                return;
            }
            XmlNode node = XmlUtils.GetNode(doc, "devices", 0);

            foreach (XmlNode child in node.ChildNodes)
            {
                AudioDevice dev = new AudioDevice(
                    cur_guid, XmlUtils.GetNodeAttrib(child, "name"),
                    int.Parse(XmlUtils.GetNodeAttrib(child, "inputs")),
                    int.Parse(XmlUtils.GetNodeAttrib(child, "outputs"))
                    );
                int  dev_id       = int.Parse(XmlUtils.GetNodeAttrib(child, "id"));
                bool found_device = false;
                foreach (InternalAudioDevice device in _devices)                //TODO: Probably should sort here
                {
                    if (device.device.name == dev.name && device.is_alive == false)
                    {
                        device.is_alive = true;
                        device.id       = dev_id;
                        found_device    = true;
                        break;
                    }
                }
                if (!found_device)
                {
                    InternalAudioDevice new_device = new InternalAudioDevice {
                        device = dev, is_alive = true, id = dev_id
                    };
                    cur_guid++;
                    _devices.Add(new_device);
                }
            }
            _pub_devices = (from c in _devices where c.is_alive select c.device).ToArray();
        }
예제 #3
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);
        }
예제 #4
0
        public void reload_config(RELOAD_CONFIG_MODE mode)
        {
            switch (mode)
            {
            case RELOAD_CONFIG_MODE.SOFT:
                Utils.api_exec("sofia", "profile softphone rescan reloadxml");
                break;

            case RELOAD_CONFIG_MODE.HARD:
                Utils.api_exec("sofia", "profile softphone restart reloadxml");
                break;

            case RELOAD_CONFIG_MODE.MODULE:
                Utils.api_exec("reload", "mod_sofia");
                DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 1500);
                break;
            }
        }