Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added listen interface option #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
279 changes: 154 additions & 125 deletions SimpleDLNA/FormSettings.Designer.cs

Large diffs are not rendered by default.

79 changes: 67 additions & 12 deletions SimpleDLNA/FormSettings.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,76 @@
using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;

namespace NMaier.SimpleDlna.GUI
{
public partial class FormSettings : NMaier.Windows.Forms.Form
{
public FormSettings()
public partial class FormSettings : NMaier.Windows.Forms.Form
{
InitializeComponent();
Icon = Properties.Resources.preferencesIcon;
}
public FormSettings()
{
InitializeComponent();
Icon = Properties.Resources.preferencesIcon;
}

private void buttonBrowseCacheFile_Click(object sender, EventArgs e)
{
if (folderBrowserDialog.ShowDialog() == DialogResult.OK) {
textCacheFile.Text = folderBrowserDialog.SelectedPath;
}
private void buttonBrowseCacheFile_Click(object sender, EventArgs e)
{
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
textCacheFile.Text = folderBrowserDialog.SelectedPath;
}
}

private void buttonOK_Click(object sender, EventArgs e)
{

}

private void FormSettings_Load(object sender, EventArgs e)
{
comboInterfaceList.Items.Add("Auto");
if (global::NMaier.SimpleDlna.GUI.Properties.Settings.Default.listeninterface == "Auto")
{
comboInterfaceList.SelectedItem = ("Auto");
}

foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
{
IPInterfaceProperties ipProps = netInterface.GetIPProperties();
foreach (UnicastIPAddressInformation addr in ipProps.UnicastAddresses)
{
if (addr.Address.AddressFamily == AddressFamily.InterNetwork)
{
comboInterfaceList.Items.Add(addr.Address.ToString() + " (" + netInterface.Name + ")");
}

if (netInterface.Id == global::NMaier.SimpleDlna.GUI.Properties.Settings.Default.listeninterface)
{
comboInterfaceList.SelectedItem = (addr.Address.ToString() + " (" + netInterface.Name + ")");
}
}
}

}

private void comboInterfaceList_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 0; i < comboInterfaceList.Items.Count; i++)
{
foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
{
if (comboInterfaceList.Text.Contains(netInterface.Name))
{
global::NMaier.SimpleDlna.GUI.Properties.Settings.Default.listeninterface = (netInterface.Id);
return;
}
}
}
global::NMaier.SimpleDlna.GUI.Properties.Settings.Default.listeninterface = ("Auto");

}
}
}
}
14 changes: 13 additions & 1 deletion SimpleDLNA/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions SimpleDLNA/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
<Setting Name="startminimized" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="listeninterface" Type="System.String" Scope="User">
<Value Profile="(Default)">Auto</Value>
</Setting>
</Settings>
</SettingsFile>
2 changes: 1 addition & 1 deletion SimpleDLNA/ServerListViewItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ where d.Exists
authorizer.AddMethod(new UserAgentAuthorizer(Description.UserAgents));
}
fileServer.Authorizer = authorizer;
server.RegisterMediaServer(fileServer);
server.RegisterMediaServer(fileServer, global::NMaier.SimpleDlna.GUI.Properties.Settings.Default.listeninterface);
state = State.Running;
var elapsed = DateTime.Now - start;
LogManager.GetLogger("State").Logger.Log(
Expand Down
3 changes: 3 additions & 0 deletions SimpleDLNA/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<setting name="startminimized" serializeAs="String">
<value>False</value>
</setting>
<setting name="listeninterface" serializeAs="String">
<value>Auto</value>
</setting>
</NMaier.SimpleDlna.GUI.Properties.Settings>
</userSettings>
</configuration>
Binary file added UpgradeLog.htm
Binary file not shown.
6 changes: 1 addition & 5 deletions sdlna.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sdlna", "sdlna\sdlna.csproj", "{C99E77FD-0728-4A2F-A9C0-47AAC7CAEFED}"
EndProject
Expand All @@ -22,8 +22,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "util", "util\util.csproj",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDLNA", "SimpleDLNA\SimpleDLNA.csproj", "{9BAEFB29-C818-446B-9BB5-014E6A0CBB49}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "setup", "setup\setup.vdproj", "{3C78015C-E0A0-45BD-BE00-FEF8D1477DAE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Global", "Global", "{4710D7C1-4ADC-4D3E-BD48-3295B7573B2A}"
ProjectSection(SolutionItems) = preProject
GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs
Expand Down Expand Up @@ -62,8 +60,6 @@ Global
{9BAEFB29-C818-446B-9BB5-014E6A0CBB49}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BAEFB29-C818-446B-9BB5-014E6A0CBB49}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BAEFB29-C818-446B-9BB5-014E6A0CBB49}.Release|Any CPU.Build.0 = Release|Any CPU
{3C78015C-E0A0-45BD-BE00-FEF8D1477DAE}.Debug|Any CPU.ActiveCfg = Debug
{3C78015C-E0A0-45BD-BE00-FEF8D1477DAE}.Release|Any CPU.ActiveCfg = Release
{56667283-EBCD-4D63-BF61-FF319CB28A0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56667283-EBCD-4D63-BF61-FF319CB28A0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56667283-EBCD-4D63-BF61-FF319CB28A0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
4 changes: 2 additions & 2 deletions sdlna/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private static void Main(string[] args)
var fs = SetupFileServer(
options, types, new DirectoryInfo[] { d });
friendlyName = fs.FriendlyName;
server.RegisterMediaServer(fs);
server.RegisterMediaServer(fs, "Auto");
server.NoticeFormat("{0} mounted", d.FullName);
}
}
Expand All @@ -138,7 +138,7 @@ private static void Main(string[] args)
options.Directories[0], options.Directories.Length);
var fs = SetupFileServer(options, types, options.Directories);
friendlyName = fs.FriendlyName;
server.RegisterMediaServer(fs);
server.RegisterMediaServer(fs, "Auto");
server.NoticeFormat(
"{0} ({1}) mounted",
options.Directories[0], options.Directories.Length);
Expand Down
Loading