提交 b61f841a authored 作者: Mitch Capper's avatar Mitch Capper

Redid options.xaml so layout grows better. Added record call option. Fixed…

Redid options.xaml so layout grows better. Added record call option. Fixed slight bug in plugin manager base.
上级 b3157509
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
...@@ -69,9 +70,9 @@ namespace FSClient { ...@@ -69,9 +70,9 @@ namespace FSClient {
Environment.Exit(-1); Environment.Exit(-1);
} }
} }
Account.LoadSettings(); Account.LoadSettings();
recordings_folder = Properties.Settings.Default.RecordingPath;
IncomingBalloons = Properties.Settings.Default.IncomingBalloons; IncomingBalloons = Properties.Settings.Default.IncomingBalloons;
IncomingTopMost = Properties.Settings.Default.FrontOnIncoming; IncomingTopMost = Properties.Settings.Default.FrontOnIncoming;
ClearDTMFS = Properties.Settings.Default.ClearDTMFS; ClearDTMFS = Properties.Settings.Default.ClearDTMFS;
...@@ -352,8 +353,8 @@ namespace FSClient { ...@@ -352,8 +353,8 @@ namespace FSClient {
Properties.Settings.Default.IncomingBalloons = IncomingBalloons; Properties.Settings.Default.IncomingBalloons = IncomingBalloons;
Properties.Settings.Default.FrontOnIncoming = IncomingTopMost; Properties.Settings.Default.FrontOnIncoming = IncomingTopMost;
Properties.Settings.Default.ClearDTMFS = ClearDTMFS; Properties.Settings.Default.ClearDTMFS = ClearDTMFS;
Properties.Settings.Default.UseNumberOnlyInput = UseNumberOnlyInput; Properties.Settings.Default.UseNumberOnlyInput = UseNumberOnlyInput;
Properties.Settings.Default.RecordingPath = recordings_folder;
Properties.Settings.Default.Sofia = new SettingsSofia(sofia); Properties.Settings.Default.Sofia = new SettingsSofia(sofia);
Properties.Settings.Default.ContactPlugins = contact_plugin_manager.GetSettings(); Properties.Settings.Default.ContactPlugins = contact_plugin_manager.GetSettings();
Properties.Settings.Default.HeadsetPlugins = headset_plugin_manager.GetSettings(); Properties.Settings.Default.HeadsetPlugins = headset_plugin_manager.GetSettings();
...@@ -587,7 +588,25 @@ namespace FSClient { ...@@ -587,7 +588,25 @@ namespace FSClient {
} }
} }
private string _cur_dial_str; private string _cur_dial_str;
public Utils.ObjectEventHandler<string> cur_dial_strChanged; public Utils.ObjectEventHandler<string> cur_dial_strChanged;
public string recordings_folder {
get { return _recordings_folder; }
set {
if (value == _recordings_folder)
return;
if (! Directory.Exists(value)){
Directory.CreateDirectory(value);
if (! Directory.Exists(value)) //maybe we should prompt here if there is an issue but then again if they don't want to use recordings lets not force it
value = null;
}
_recordings_folder = value;
if (recordings_folderChanged != null)
recordings_folderChanged(this, value);
}
}
private string _recordings_folder;
public Utils.ObjectEventHandler<string> recordings_folderChanged;
#endregion #endregion
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows; using System.Windows;
...@@ -229,6 +230,10 @@ namespace FSClient { ...@@ -229,6 +230,10 @@ namespace FSClient {
menu.Items.Add(CreateMenuItem("Call on Account " + account.name, create_outgoing_call)); menu.Items.Add(CreateMenuItem("Call on Account " + account.name, create_outgoing_call));
} }
else { else {
if (am_recording_file != null)
menu.Items.Add(CreateMenuItem("Stop Recording Call", StopRecordCall));
else if (broker.recordings_folder != null)
menu.Items.Add(CreateMenuItem("Record Call", RecordCall));
menu.Items.Add(CreateMenuItem("Transfer", TransferPrompt)); menu.Items.Add(CreateMenuItem("Transfer", TransferPrompt));
item = new MenuItem() { Header = "Their Volume" }; item = new MenuItem() { Header = "Their Volume" };
for (int x = -4; x <= 4; x++) { for (int x = -4; x <= 4; x++) {
...@@ -251,6 +256,29 @@ namespace FSClient { ...@@ -251,6 +256,29 @@ namespace FSClient {
CallRightClickMenuShowing(this, new CallRightClickEventArgs { call = this, menu = menu }); CallRightClickMenuShowing(this, new CallRightClickEventArgs { call = this, menu = menu });
} }
} }
private void StopRecordCall(){
Utils.bgapi_exec("uuid_record", leg_b_uuid + " stop \"" + am_recording_file + "\"");
am_recording_file = null;
}
private string am_recording_file;
private void RecordCall(){
String full_path = broker.recordings_folder.Replace('/', '\\');
if (! full_path.Contains(":\\"))
full_path = Path.Combine(Directory.GetCurrentDirectory(),full_path); //freeswitch is not happy with relative paths when using quotes
full_path = Path.Combine(full_path,"rec_" + other_party_number + "_" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
int num =1;
String orig_full_path = full_path;
while (File.Exists(full_path + ".wav"))
full_path = orig_full_path + "." + num++;
full_path = full_path.Replace('\\', '/'); //seems freeswitch will selectively escape what it cant otherwise
am_recording_file = full_path + ".wav";
Utils.bgapi_exec("uuid_setvar", leg_b_uuid + " record_stereo true");
Utils.bgapi_exec("uuid_record", leg_b_uuid + " start \"" + am_recording_file +"\"");
}
private void Call_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { private void Call_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
CallPropertyEventArgs args = new CallPropertyEventArgs(this, e.PropertyName); CallPropertyEventArgs args = new CallPropertyEventArgs(this, e.PropertyName);
if (e.PropertyName == "state" && CallStateChanged != null) if (e.PropertyName == "state" && CallStateChanged != null)
...@@ -407,6 +435,8 @@ namespace FSClient { ...@@ -407,6 +435,8 @@ namespace FSClient {
start_time = DateTime.Now; start_time = DateTime.Now;
if (duration_timer == null) if (duration_timer == null)
duration_timer = new System.Threading.Timer(DurationTimerFired, null, 1000, 1000); duration_timer = new System.Threading.Timer(DurationTimerFired, null, 1000, 1000);
if (broker == null)
broker = Broker.get_instance();
} }
private static void DurationTimerFired(object obj) { private static void DurationTimerFired(object obj) {
if (Application.Current != null) if (Application.Current != null)
...@@ -463,8 +493,8 @@ namespace FSClient { ...@@ -463,8 +493,8 @@ namespace FSClient {
return menu; return menu;
} }
private static Broker broker;
public void SetOurAudioLevel(int level){ public void SetOurAudioLevel(int level){
if (level > 4 || level < -4) if (level > 4 || level < -4)
return; return;
......
<Window x:Class="FSClient.Options" <Window x:Class="FSClient.Options"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Options" Height="360" Width="550" Loaded="Window_Loaded" Closing="Window_Closing" WindowStyle="ThreeDBorderWindow" ResizeMode="NoResize" Icon="phone.ico"> Title="Options" Height="390" Width="550" Loaded="Window_Loaded" Closing="Window_Closing" WindowStyle="ThreeDBorderWindow" ResizeMode="NoResize" Icon="phone.ico">
<Window.Resources> <Window.Resources>
<Style x:Key="OptionHeaderStyle" TargetType="{x:Type TextBlock}"> <Style x:Key="OptionHeaderStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontWeight" Value="Bold"/> <Setter Property="FontWeight" Value="Bold"/>
...@@ -10,53 +10,68 @@ ...@@ -10,53 +10,68 @@
<Setter Property="HorizontalAlignment" Value="Right"/> <Setter Property="HorizontalAlignment" Value="Right"/>
</Style> </Style>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/> <ColumnDefinition Width="170"/>
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition /> <RowDefinition />
<RowDefinition /> <RowDefinition Height="80" />
<RowDefinition /> <RowDefinition Height="30" />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="1" Text="Headset Device:" Style="{DynamicResource OptionHeaderStyle}" /> <Grid Grid.ColumnSpan="2">
<ComboBox Height="23" Grid.Row="1" Grid.Column="1" Name="comboHeadsetDevice" Width="340" /> <Grid.ColumnDefinitions>
<ColumnDefinition Width="170"/>
<TextBlock Grid.Row="2" Text="Main Input:" Style="{DynamicResource OptionHeaderStyle}" /> <ColumnDefinition/>
<ComboBox Height="23" Grid.Row="2" Grid.Column="1" Name="comboHeadsetInput" Width="340" /> </Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<TextBlock Grid.Row="3" Text="Main Output:" Style="{DynamicResource OptionHeaderStyle}" /> <RowDefinition />
<ComboBox Height="23" Grid.Row="3" Grid.Column="1" Name="comboHeadsetOutput" Width="340" /> <RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<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="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" />
<Button Content="Plugin Settings" Height="23" Name="btnPluginSettings" Width="100" Margin="10,0,0,0" Click="btnPluginSettings_Click" />
</StackPanel>
<TextBlock Grid.Row="1" Text="Headset Device:" Style="{DynamicResource OptionHeaderStyle}" />
<ComboBox Height="23" Grid.Row="1" Grid.Column="1" Name="comboHeadsetDevice" Width="340" />
<TextBlock Grid.Row="4" Text="Speakerphone Input:" Style="{DynamicResource OptionHeaderStyle}" /> <TextBlock Grid.Row="2" Text="Main Input:" Style="{DynamicResource OptionHeaderStyle}" />
<ComboBox Height="23" Grid.Row="4" Grid.Column="1" Name="comboSpeakerInput" Width="340" /> <ComboBox Height="23" Grid.Row="2" Grid.Column="1" Name="comboHeadsetInput" Width="340" />
<TextBlock Grid.Row="5" Text="Speakerphone Output:" Style="{DynamicResource OptionHeaderStyle}" />
<ComboBox Height="23" Grid.Row="5" Grid.Column="1" Name="comboSpeakerOutput" Width="340" /> <TextBlock Grid.Row="3" Text="Main Output:" Style="{DynamicResource OptionHeaderStyle}" />
<TextBlock Grid.Row="6" Text="Ring Device:" Style="{DynamicResource OptionHeaderStyle}" /> <ComboBox Height="23" Grid.Row="3" Grid.Column="1" Name="comboHeadsetOutput" Width="340" />
<ComboBox Height="23" Grid.Row="6" Grid.Column="1" Name="comboRingDevice" Width="340" />
<StackPanel Grid.Row="7" Grid.Column="1" Grid.RowSpan="3"> <TextBlock Grid.Row="4" Text="Speakerphone Input:" Style="{DynamicResource OptionHeaderStyle}" />
<CheckBox x:Name="chkIncomingFront" Content="Bring To Front On Incoming Calls" VerticalAlignment="Center" FontWeight="Bold" FontSize="13.333" /> <ComboBox Height="23" Grid.Row="4" Grid.Column="1" Name="comboSpeakerInput" Width="340" />
<CheckBox x:Name="chkIncomingBalloons" Content="Show Incoming Call Notification Balloons" VerticalAlignment="Center" FontWeight="Bold" FontSize="13.333" /> <TextBlock Grid.Row="5" Text="Speakerphone Output:" Style="{DynamicResource OptionHeaderStyle}" />
<CheckBox x:Name="chkClearDTMFS" Content="Clear Key Presses In Call Stats On Disconnect" VerticalAlignment="Center" FontWeight="Bold" FontSize="13.333" /> <ComboBox Height="23" Grid.Row="5" Grid.Column="1" Name="comboSpeakerOutput" Width="340" />
<CheckBox x:Name="chkUseNumbers" Content="Only Allow Numerical Input While Dialing" VerticalAlignment="Center" FontWeight="Bold" FontSize="13.333" /> <TextBlock Grid.Row="6" Text="Ring Device:" Style="{DynamicResource OptionHeaderStyle}" />
</StackPanel> <ComboBox Height="23" Grid.Row="6" Grid.Column="1" Name="comboRingDevice" Width="340" />
<Button Content="Save" Grid.Row="10" Height="23" HorizontalAlignment="Left" Margin="101,0,0,0" Name="btnSave" VerticalAlignment="Center" Width="75" Grid.ColumnSpan="2" Click="btnSave_Click" /> <TextBlock Grid.Row="7" Text="Recording Path:" Style="{DynamicResource OptionHeaderStyle}" />
<Button Content="Cancel" Grid.Column="1" Grid.Row="10" Height="23" HorizontalAlignment="Left" Margin="172,0,0,0" Name="btnCancel" VerticalAlignment="Center" Width="75" Click="btnCancel_Click" /> <StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="1">
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" > <TextBox Height="23" Name="txtRecordingPath" Width="286" Margin="10,0" />
<Button Content="Reload Devices" Height="23" Name="btnReloadDevices" Width="100" Click="btnReloadDevices_Click" /> <Button Name="btnPathBrowse" Content="Browse" Height="25" Click="btnPathBrowse_Click" />
<Button Content="Sofia Settings" Height="23" Name="btnSofiaSettings" Width="100" Margin="10,0,0,0" Click="btnSofiaSettings_Click" /> </StackPanel>
<Button Content="Event Socket Settings" Height="23" Name="btnEventSocketSettings" Width="125" Margin="10,0,0,0" Click="btnEventSocketSettings_Click" /> </Grid>
<Button Content="Plugin Settings" Height="23" Name="btnPluginSettings" Width="100" Margin="10,0,0,0" Click="btnPluginSettings_Click" /> <StackPanel Grid.Row="1" Grid.Column="1" Grid.RowSpan="3">
<CheckBox x:Name="chkIncomingFront" Content="Bring To Front On Incoming Calls" VerticalAlignment="Center" FontWeight="Bold" FontSize="13.333" />
<CheckBox x:Name="chkIncomingBalloons" Content="Show Incoming Call Notification Balloons" VerticalAlignment="Center" FontWeight="Bold" FontSize="13.333" />
<CheckBox x:Name="chkClearDTMFS" Content="Clear Key Presses In Call Stats On Disconnect" VerticalAlignment="Center" FontWeight="Bold" FontSize="13.333" />
<CheckBox x:Name="chkUseNumbers" Content="Only Allow Numerical Input While Dialing" VerticalAlignment="Center" FontWeight="Bold" FontSize="13.333" />
</StackPanel> </StackPanel>
<Button Content="Save" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="101,0,0,0" Name="btnSave" VerticalAlignment="Center" Width="75" Grid.ColumnSpan="2" Click="btnSave_Click" />
<Button Content="Cancel" Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="172,0,0,0" Name="btnCancel" VerticalAlignment="Center" Width="75" Click="btnCancel_Click" />
</Grid> </Grid>
</Window> </Window>
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Forms;
using WF=System.Windows.Forms;
namespace FSClient { namespace FSClient {
/// <summary> /// <summary>
/// Interaction logic for Options.xaml /// Interaction logic for Options.xaml
...@@ -34,7 +36,8 @@ namespace FSClient { ...@@ -34,7 +36,8 @@ namespace FSClient {
chkIncomingBalloons.IsChecked = broker.IncomingBalloons; chkIncomingBalloons.IsChecked = broker.IncomingBalloons;
chkIncomingFront.IsChecked = broker.IncomingTopMost; chkIncomingFront.IsChecked = broker.IncomingTopMost;
chkClearDTMFS.IsChecked = broker.ClearDTMFS; chkClearDTMFS.IsChecked = broker.ClearDTMFS;
chkUseNumbers.IsChecked = broker.UseNumberOnlyInput; chkUseNumbers.IsChecked = broker.UseNumberOnlyInput;
txtRecordingPath.Text = broker.recordings_folder;
comboHeadsetDevice.SelectedItem = broker.ActiveHeadset(); comboHeadsetDevice.SelectedItem = broker.ActiveHeadset();
if (comboHeadsetDevice.SelectedIndex == -1) if (comboHeadsetDevice.SelectedIndex == -1)
...@@ -54,7 +57,8 @@ namespace FSClient { ...@@ -54,7 +57,8 @@ namespace FSClient {
broker.IncomingBalloons = chkIncomingBalloons.IsChecked == true; broker.IncomingBalloons = chkIncomingBalloons.IsChecked == true;
broker.IncomingTopMost = chkIncomingFront.IsChecked == true; broker.IncomingTopMost = chkIncomingFront.IsChecked == true;
broker.ClearDTMFS = chkClearDTMFS.IsChecked == true; broker.ClearDTMFS = chkClearDTMFS.IsChecked == true;
broker.UseNumberOnlyInput = chkUseNumbers.IsChecked == true; broker.UseNumberOnlyInput = chkUseNumbers.IsChecked == true;
broker.recordings_folder = txtRecordingPath.Text;
broker.SetActiveHeadset(comboHeadsetDevice.SelectedItem as string); broker.SetActiveHeadset(comboHeadsetDevice.SelectedItem as string);
broker.SaveSettings(); broker.SaveSettings();
...@@ -89,6 +93,15 @@ namespace FSClient { ...@@ -89,6 +93,15 @@ namespace FSClient {
private void btnPluginSettings_Click(object sender, RoutedEventArgs e){ private void btnPluginSettings_Click(object sender, RoutedEventArgs e){
broker.edit_plugins(); broker.edit_plugins();
}
private void btnPathBrowse_Click(object sender, RoutedEventArgs e) {
WF.FolderBrowserDialog dlg = new WF.FolderBrowserDialog();
dlg.SelectedPath = txtRecordingPath.Text;
DialogResult res = dlg.ShowDialog();
if (res != System.Windows.Forms.DialogResult.OK)
return;
txtRecordingPath.Text = dlg.SelectedPath;
} }
} }
} }
...@@ -140,7 +140,7 @@ namespace FSClient { ...@@ -140,7 +140,7 @@ namespace FSClient {
protected abstract void SetPlugins(IEnumerable<PluginData> plugins); protected abstract void SetPlugins(IEnumerable<PluginData> plugins);
public virtual void SetPluginEnabled(bool enabled, PluginData plugin){ public virtual void SetPluginEnabled(bool enabled, PluginData plugin){
plugin.enabled = false; plugin.enabled = enabled;
} }
public abstract void Dispose(); public abstract void Dispose();
} }
......
...@@ -187,6 +187,7 @@ namespace FSClient.Properties { ...@@ -187,6 +187,7 @@ namespace FSClient.Properties {
this["EventSocket"] = value; this["EventSocket"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::FSClient.SettingsPluginDataCollection HeadsetPlugins { public global::FSClient.SettingsPluginDataCollection HeadsetPlugins {
...@@ -197,6 +198,7 @@ namespace FSClient.Properties { ...@@ -197,6 +198,7 @@ namespace FSClient.Properties {
this["HeadsetPlugins"] = value; this["HeadsetPlugins"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::FSClient.SettingsPluginDataCollection ContactPlugins { public global::FSClient.SettingsPluginDataCollection ContactPlugins {
...@@ -207,5 +209,17 @@ namespace FSClient.Properties { ...@@ -207,5 +209,17 @@ namespace FSClient.Properties {
this["ContactPlugins"] = value; this["ContactPlugins"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("recordings")]
public string RecordingPath {
get {
return ((string)(this["RecordingPath"]));
}
set {
this["RecordingPath"] = value;
}
}
} }
} }
\ No newline at end of file
...@@ -50,5 +50,8 @@ ...@@ -50,5 +50,8 @@
<Setting Name="ContactPlugins" Type="FSClient.SettingsPluginDataCollection" Scope="User"> <Setting Name="ContactPlugins" Type="FSClient.SettingsPluginDataCollection" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="RecordingPath" Type="System.String" Scope="User">
<Value Profile="(Default)">recordings</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>
\ No newline at end of file
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
<setting name="SettingsUpgrade" serializeAs="String"> <setting name="SettingsUpgrade" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </setting>
<setting name="RecordingPath" serializeAs="String">
<value>recordings</value>
</setting>
</FSClient.Properties.Settings> </FSClient.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论