提交 6f661d9b authored 作者: Mitch Capper's avatar Mitch Capper

Added EventSocket config generation so you can control the event socket port…

Added EventSocket config generation so you can control the event socket port from within FSClient.  Generalized some standard config generation items. Ensure the freeswitch.xml file exists or else core will crash. Warn is trying to reload portaudio settings during a call.
上级 1a03d507
...@@ -48,6 +48,10 @@ namespace FSClient { ...@@ -48,6 +48,10 @@ namespace FSClient {
return; return;
is_inited = true; is_inited = true;
try { try {
if (! System.IO.File.Exists("conf/freeswitch.xml")){
MessageBox.Show("conf/freeswitch.xml is not found, without it we must quit.", "Missing Base Configuration File", MessageBoxButton.OK, MessageBoxImage.Error);
Environment.Exit(-1);
}
if (System.IO.File.Exists("log/freeswitch.log")) { if (System.IO.File.Exists("log/freeswitch.log")) {
try { try {
System.IO.File.WriteAllText("log/freeswitch.log", ""); System.IO.File.WriteAllText("log/freeswitch.log", "");
...@@ -71,6 +75,11 @@ namespace FSClient { ...@@ -71,6 +75,11 @@ namespace FSClient {
else else
sofia = new Sofia(); sofia = new Sofia();
if (Properties.Settings.Default.EventSocket != null)
event_socket = Properties.Settings.Default.EventSocket.GetEventSocket();
else
event_socket = new EventSocket();
} catch (Exception e) { } catch (Exception e) {
MessageBoxResult res = MessageBox.Show( MessageBoxResult res = MessageBox.Show(
"Unable to properly load our settings if you continue existing settings may be lost, do you want to continue?(No to exit)\n" + "Unable to properly load our settings if you continue existing settings may be lost, do you want to continue?(No to exit)\n" +
...@@ -228,6 +237,10 @@ namespace FSClient { ...@@ -228,6 +237,10 @@ namespace FSClient {
} }
public void reload_audio_devices(bool and_settings, bool no_save) { public void reload_audio_devices(bool and_settings, bool no_save) {
if(active_calls > 0){
MessageBox.Show("Unable to reload audio devices while calls are active");
return;
}
if (and_settings && !no_save) if (and_settings && !no_save)
SaveAudioSettings(); SaveAudioSettings();
audio_devices = PortAudio.get_devices(true); audio_devices = PortAudio.get_devices(true);
...@@ -327,6 +340,7 @@ namespace FSClient { ...@@ -327,6 +340,7 @@ namespace FSClient {
Properties.Settings.Default.UseNumberOnlyInput = UseNumberOnlyInput; Properties.Settings.Default.UseNumberOnlyInput = UseNumberOnlyInput;
Properties.Settings.Default.Sofia = new SettingsSofia(sofia); Properties.Settings.Default.Sofia = new SettingsSofia(sofia);
Properties.Settings.Default.EventSocket = new SettingsEventSocket(event_socket);
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
} catch (Exception e) {//if there is an error doing saving lets skip saving any settings to avoid overriding something else } catch (Exception e) {//if there is an error doing saving lets skip saving any settings to avoid overriding something else
MessageBox.Show("Error saving settings out: " + e.Message + "\n" + e.StackTrace); MessageBox.Show("Error saving settings out: " + e.Message + "\n" + e.StackTrace);
...@@ -566,12 +580,16 @@ namespace FSClient { ...@@ -566,12 +580,16 @@ namespace FSClient {
return _instance ?? (_instance = new Broker()); return _instance ?? (_instance = new Broker());
} }
ContactPluginManager contact_plugin_manager; private ContactPluginManager contact_plugin_manager;
HeadsetPluginManager headset_plugin_manager; private HeadsetPluginManager headset_plugin_manager;
Sofia sofia; private Sofia sofia;
private EventSocket event_socket;
public void edit_sofia() { public void edit_sofia() {
sofia.edit(); sofia.edit();
} }
public void edit_event_socket() {
event_socket.edit();
}
public void reload_sofia(Sofia.RELOAD_CONFIG_MODE mode) { public void reload_sofia(Sofia.RELOAD_CONFIG_MODE mode) {
sofia.reload_config(mode); sofia.reload_config(mode);
} }
...@@ -598,24 +616,35 @@ namespace FSClient { ...@@ -598,24 +616,35 @@ namespace FSClient {
} }
#region Config Generation #region Config Generation
XmlDocument sofia_doc;
private string get_sofia_xml() {
sofia_doc = new XmlDocument(); private delegate void config_gen_del(XmlNode parent);
XmlNode doc = sofia_doc.CreateElement("document");
sofia_doc.AppendChild(doc); 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"); XmlUtils.AddNodeAttrib(doc, "type", "freeswitch/xml");
XmlNode sect = XmlUtils.AddNodeNode(doc, "section"); XmlNode sect = XmlUtils.AddNodeNode(doc, "section");
XmlUtils.AddNodeAttrib(sect, "name", "configuration"); XmlUtils.AddNodeAttrib(sect, "name", "configuration");
sofia.gen_config(sect);
//sofia_doc.Save(@"c:\temp\out.xml"); XmlNode config_node = XmlUtils.AddNodeNode(sect, "configuration");
return sofia_doc.OuterXml; 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;
} }
private string xml_search(FreeSWITCH.SwitchXmlSearchBinding.XmlBindingArgs args) { private string xml_search(FreeSWITCH.SwitchXmlSearchBinding.XmlBindingArgs args) {
if (args.KeyName == "name" && args.KeyValue == "sofia.conf" && args.Section == "configuration" && args.TagName == "configuration") { if (args.KeyName != "name" || args.Section != "configuration" || args.TagName != "configuration")
return get_sofia_xml(); return null;
switch (args.KeyValue){
case "sofia.conf":
return generate_xml_config(args.KeyValue, "Sofia Endpoint", sofia.gen_config);
case "event_socket.conf":
return generate_xml_config(args.KeyValue, "Socket Client", event_socket.gen_config);
} }
return null; return null;
} }
private static IDisposable search_bind; private static IDisposable search_bind;
#endregion #endregion
......
...@@ -96,15 +96,6 @@ ...@@ -96,15 +96,6 @@
</settings> </settings>
</configuration> </configuration>
<configuration name="event_socket.conf" description="Socket Client">
<settings>
<param name="nat-map" value="false"/>
<param name="listen-ip" value="127.0.0.1"/>
<param name="listen-port" value="8022"/>
<param name="password" value="ClueCon"/>
</settings>
</configuration>
<configuration name="post_load_modules.conf" description="Modules"> <configuration name="post_load_modules.conf" description="Modules">
<modules> <modules>
</modules> </modules>
......
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
</Compile> </Compile>
<Compile Include="Converters.cs" /> <Compile Include="Converters.cs" />
<Compile Include="DelayedFunction.cs" /> <Compile Include="DelayedFunction.cs" />
<Compile Include="EventSocket.cs" />
<Compile Include="Field.cs" /> <Compile Include="Field.cs" />
<Compile Include="FSEvent.cs" /> <Compile Include="FSEvent.cs" />
<Compile Include="GenericEditor.xaml.cs"> <Compile Include="GenericEditor.xaml.cs">
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" > <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" >
<Button Content="Reload Devices" Height="23" Name="btnReloadDevices" Width="100" Click="btnReloadDevices_Click" /> <Button Content="Reload Devices" Height="23" Name="btnReloadDevices" Width="100" Click="btnReloadDevices_Click" />
<Button Content="Sofia Settings" Height="23" Name="btnSofiaSettings" Width="100" Margin="10,0,0,0" Click="btnSofiaSettings_Click" /> <Button Content="Sofia Settings" Height="23" Name="btnSofiaSettings" Width="100" Margin="10,0,0,0" Click="btnSofiaSettings_Click" />
<Button Content="Event Socket Settings" Height="23" Name="btnEventSocketSettings" Width="125" Margin="10,0,0,0" Click="btnEventSocketSettings_Click" />
</StackPanel> </StackPanel>
</Grid> </Grid>
......
...@@ -82,5 +82,9 @@ namespace FSClient { ...@@ -82,5 +82,9 @@ namespace FSClient {
private void btnSofiaSettings_Click(object sender, RoutedEventArgs e) { private void btnSofiaSettings_Click(object sender, RoutedEventArgs e) {
broker.edit_sofia(); broker.edit_sofia();
} }
private void btnEventSocketSettings_Click(object sender, RoutedEventArgs e){
broker.edit_event_socket();
}
} }
} }
...@@ -176,5 +176,16 @@ namespace FSClient.Properties { ...@@ -176,5 +176,16 @@ namespace FSClient.Properties {
this["SettingsUpgrade"] = value; this["SettingsUpgrade"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::FSClient.SettingsEventSocket EventSocket {
get {
return ((global::FSClient.SettingsEventSocket)(this["EventSocket"]));
}
set {
this["EventSocket"] = value;
}
}
} }
} }
\ No newline at end of file
...@@ -41,5 +41,8 @@ ...@@ -41,5 +41,8 @@
<Setting Name="SettingsUpgrade" Type="System.Boolean" Scope="User"> <Setting Name="SettingsUpgrade" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="EventSocket" Type="FSClient.SettingsEventSocket" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>
\ No newline at end of file
...@@ -71,12 +71,8 @@ namespace FSClient { ...@@ -71,12 +71,8 @@ namespace FSClient {
}; };
public FieldValue[] values = FieldValue.FieldValues(fields); public FieldValue[] values = FieldValue.FieldValues(fields);
public void gen_config(XmlNode parent) { public void gen_config(XmlNode config_node) {
XmlNode config_node = XmlUtils.AddNodeNode(parent, "configuration");
XmlUtils.AddNodeAttrib(config_node, "name", "sofia.conf");
XmlUtils.AddNodeAttrib(config_node, "description", "Sofia Endpoint");
XmlNode global_settings = XmlUtils.AddNodeNode(config_node, "global_settings"); XmlNode global_settings = XmlUtils.AddNodeNode(config_node, "global_settings");
Utils.add_xml_param(global_settings, "auto-restart", "true"); Utils.add_xml_param(global_settings, "auto-restart", "true");
Utils.add_xml_param(global_settings, "debug-presence", "0"); Utils.add_xml_param(global_settings, "debug-presence", "0");
...@@ -115,8 +111,7 @@ namespace FSClient { ...@@ -115,8 +111,7 @@ namespace FSClient {
DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 100); DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 100);
break; break;
case RELOAD_CONFIG_MODE.MODULE: case RELOAD_CONFIG_MODE.MODULE:
Utils.api_exec("unload", "mod_sofia"); Utils.api_exec("reload", "mod_sofia");
Utils.api_exec("load", "mod_sofia");
DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 500); DelayedFunction.DelayedCall("SofiaProfileCheck", sofia_profile_check, 500);
break; break;
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论