add connect linking

This commit is contained in:
Luke Pulverenti
2014-09-14 11:10:51 -04:00
parent 4f3ea6c6c3
commit 5c615fa024
42 changed files with 542 additions and 78 deletions

View File

@@ -186,7 +186,7 @@ namespace MediaBrowser.Common.Implementations
{
if (_deviceId == null)
{
_deviceId = new DeviceId(ApplicationPaths, LogManager.GetLogger("SystemId"));
_deviceId = new DeviceId(ApplicationPaths, LogManager.GetLogger("SystemId"), NetworkManager);
}
return _deviceId.Value;

View File

@@ -1,4 +1,6 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System;
using System.IO;
@@ -9,6 +11,7 @@ namespace MediaBrowser.Common.Implementations.Devices
public class DeviceId
{
private readonly IApplicationPaths _appPaths;
private readonly INetworkManager _networkManager;
private readonly ILogger _logger;
private readonly object _syncLock = new object();
@@ -67,7 +70,23 @@ namespace MediaBrowser.Common.Implementations.Devices
private string GetNewId()
{
return Guid.NewGuid().ToString("N");
// When generating an Id, base it off of the app path + mac address
// But we can't fail here, so if we can't get the mac address then just use a random guid
string mac;
try
{
mac = _networkManager.GetMacAddress();
}
catch
{
mac = Guid.NewGuid().ToString("N");
}
mac += "-" + _appPaths.ApplicationPath;
return mac.GetMD5().ToString("N");
}
private string GetDeviceId()
@@ -85,10 +104,11 @@ namespace MediaBrowser.Common.Implementations.Devices
private string _id;
public DeviceId(IApplicationPaths appPaths, ILogger logger)
public DeviceId(IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager)
{
_appPaths = appPaths;
_logger = logger;
_networkManager = networkManager;
}
public string Value