public void sofia_profile_check() { if (!sofia_actual_profile_check(false)) { DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check_last, 1200); } }
private void handle_key_action(char key) { if (txtNumber.IsReadOnly == false && txtNumber.IsKeyboardFocused) { int ind = txtNumber.CaretIndex; if (txtNumber.SelectionStart >= 0) { status.dial_str = status.dial_str.Remove(txtNumber.SelectionStart, txtNumber.SelectionLength); } status.dial_str = status.dial_str.Insert(ind, key.ToString()); txtNumber.CaretIndex = ind + 1; } else { status.dial_str += key; } //status.dial_str += key; if (key != '*' && key != '#' && (key < '0' || key > '9') && (key < 'A' || key > 'D')) { return; } if (Call.active_call != null && Call.active_call.state == Call.CALL_STATE.Answered) { Call.active_call.send_dtmf(key.ToString()); } else { #if !NO_FS PortAudio.PlayDTMF(key, null, true); DelayedFunction.DelayedCall("PortAudioLastDigitHitStreamClose", close_streams, 5000); #endif } }
private void CallStateChangedHandler(object sender, Call.CallPropertyEventArgs args) { if (args.call.state == Call.CALL_STATE.Ringing && !args.call.is_outgoing) { if (IncomingTopMost) { MainWindow.get_instance().BringToFront(); } if (IncomingBalloons && !DND) { IncomingCallNotification.ShowCallNotification(args.call); if (Call.active_call != args.call && Call.active_call != null) { HandleCallWaiting(null, args.call); } } else if (IncomingKeyboardFocus) { Utils.SetForegroundWindow(MainWindow.get_instance()); } } if (DND && args.call != null && args.call.is_outgoing == false && args.call.state == Call.CALL_STATE.Ringing) { args.call.hangup("Call ignored due to DND"); } if (args.call != null && args.call.call_ended && ClearDTMFS) { args.call.dtmfs = ""; } DelayedFunction.DelayedCall("broker_updatestatus", UpdateStatus, 500); }
private void init_freeswitch() { try { //it would be better if this was in the init function but it seems some dll load errors won't be caught if it is. #if !NO_FS fs_core_init(); #else fs_inited = false; #endif if (FreeswitchLoaded != null) { FreeswitchLoaded(this, null); } fully_loaded = true; Debug.WriteLine("Startup time: " + (DateTime.Now - start_time).TotalSeconds); } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; } MessageBox.Show("Unable to properly init freeswitch core due to:\n" + e.Message + "\n" + e.StackTrace, "Error Starting Freeswitch Core", MessageBoxButton.OK, MessageBoxImage.Error); fs_inited = false; Environment.Exit(-1); } #if !NO_FS DelayedFunction.DelayedCall("SofiaProfileCheck", sofia.sofia_profile_check, 100); //Lets try to reload devices after FSClient has spun up just to make sure everything is inited. DelayedFunction.DelayedCall("ReloadAudioDevices", quiet_reload_audio_devices, 2000); DelayedFunction.DelayedCall("ReloadAudioDevices2", quiet_reload_audio_devices, 5000); DelayedFunction.DelayedCall("ReloadAudioDevices3", quiet_reload_audio_devices, 20000); #endif }
void users_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { conf_visible = users.Count > 0 ? Visibility.Visible : Visibility.Hidden; if (am_recording_file != null && users.Count == 0) { am_recording_file = null; } DelayedFunction.DelayedCall("ConferenceOnlyUsLeft", only_us_left_check, 2000); }
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); }
private void HandleError(PluginError error, PluginData.PluginDataState failed_state = PluginData.PluginDataState.DISABLED_ERROR) { if (error.plugin == null) { error.plugin = error.device.plugin; } if ((DateTime.Now - error.plugin.last_error_time).TotalSeconds > 60 * 5) //if no errors for 5 minutes reset error count { error.plugin.error_tries_left = DEFAULT_PLUGIN_RETRIES; } error.plugin.last_error_time = DateTime.Now; error.plugin.last_error = error.exception.Message; String restart_msg = error.plugin.error_tries_left > 0 ? " will try to restart/init it " + error.plugin.error_tries_left + " more times" : " will not be restarting it"; Utils.PluginLog(PluginManagerName(), "Plugin " + error.plugin.plugin.ProviderName() + " had an error due to: " + error.exception.Message + "\n" + restart_msg); List <DeviceData> to_remove = new List <DeviceData>(); lock (devices_lock) { foreach (DeviceData device in devices) { if (device.plugin == error.plugin) { try { device.device.SetActive(false); } catch (Exception) { Utils.PluginLog(PluginManagerName(), "While handling error wasn't able to deactivate device, not a major issue"); } to_remove.Add(device); } } } lock (devices_lock) { foreach (DeviceData device in to_remove) { devices.Remove(device); } } error.plugin.plugin.Terminate(); if (error.plugin.error_tries_left-- > 0) { DelayedFunction.DelayedCall("IHeadsetPlugin_PluginStart_ " + error.plugin.plugin.ProviderName(), () => init_plugin(error.plugin), 1000); //give it a second } else { error.plugin.state = failed_state; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { PositionWindows(); lblCaller.Text = call.other_party_name + " - " + call.other_party_number; Title = "FSClient Incoming Call " + lblCaller.Text; prop_changed = new System.ComponentModel.PropertyChangedEventHandler(call_PropertyChanged); call.PropertyChanged += prop_changed; btnSendVoicemail.Visibility = call.CanSendToVoicemail() ? Visibility.Visible : Visibility.Hidden; btnTransfer.ContextMenu = Broker.get_instance().XFERContextMenu(); btnTransfer.DataContext = call; if (Broker.get_instance().IncomingKeyboardFocus) { DelayedFunction.DelayedCall("BubbleTop", MakeUsTop, 500); } Show(); Topmost = true; }
private Broker() { start_time = DateTime.Now; _instance = this; upgrade_settings(); Utils.PluginLog("", ""); //clear file headset_plugin_manager = new HeadsetPluginManager(); conference = Conference.instance; NewEvent += Call.NewFSEvent; NewEvent += Account.NewEvent; NewEvent += conference.NewFSEvent; Call.CallStateChanged += CallStateChangedHandler; init_us(); DelayedFunction.DelayedCall("LoadContactManager", initContactManager, 1000); }
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; } }
private void Account_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "is_default_account") { if (!is_default_account) { DelayedFunction.DelayedCall("Account_ensure_default", ensure_default_account, 500); return; } foreach (Account account in accounts) { if (account != this) { account.is_default_account = false; } } default_account = this; } }