Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add server id to dto's
  • Loading branch information
LukePulverenti committed Oct 30, 2014
1 parent 8337877 commit 2358bc3
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 37 deletions.
2 changes: 2 additions & 0 deletions MediaBrowser.Model/ApiClient/ServerCredentials.cs
Expand Up @@ -35,6 +35,8 @@ public void AddOrUpdateServer(ServerInfo server)
// Merge the data
existing.DateLastAccessed = new[] { existing.DateLastAccessed, server.DateLastAccessed }.Max();

existing.UserLinkType = server.UserLinkType;

if (!string.IsNullOrEmpty(server.AccessToken))
{
existing.AccessToken = server.AccessToken;
Expand Down
4 changes: 3 additions & 1 deletion MediaBrowser.Model/ApiClient/ServerInfo.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Model.System;
using MediaBrowser.Model.Connect;
using MediaBrowser.Model.System;
using System;
using System.Collections.Generic;

Expand All @@ -15,6 +16,7 @@ public class ServerInfo
public List<WakeOnLanInfo> WakeOnLanInfos { get; set; }
public DateTime DateLastAccessed { get; set; }
public String ExchangeToken { get; set; }
public UserLinkType? UserLinkType { get; set; }

public ServerInfo()
{
Expand Down
1 change: 1 addition & 0 deletions MediaBrowser.Model/Connect/ConnectUserServer.cs
Expand Up @@ -9,5 +9,6 @@ public class ConnectUserServer
public string AccessKey { get; set; }
public string SystemId { get; set; }
public string LocalAddress { get; set; }
public string UserType { get; set; }
}
}
9 changes: 8 additions & 1 deletion MediaBrowser.Model/LiveTv/BaseTimerInfoDto.cs
@@ -1,10 +1,11 @@
using System;
using System.ComponentModel;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Extensions;

namespace MediaBrowser.Model.LiveTv
{
public class BaseTimerInfoDto : IHasPropertyChangedEvent
public class BaseTimerInfoDto : IHasPropertyChangedEvent, IHasServerId
{
/// <summary>
/// Occurs when a property value changes.
Expand All @@ -16,6 +17,12 @@ public class BaseTimerInfoDto : IHasPropertyChangedEvent
/// </summary>
public string Id { get; set; }

/// <summary>
/// Gets or sets the server identifier.
/// </summary>
/// <value>The server identifier.</value>
public string ServerId { get; set; }

/// <summary>
/// Gets or sets the external identifier.
/// </summary>
Expand Down
10 changes: 8 additions & 2 deletions MediaBrowser.Model/LiveTv/ChannelInfoDto.cs
Expand Up @@ -13,14 +13,20 @@ namespace MediaBrowser.Model.LiveTv
/// Class ChannelInfoDto
/// </summary>
[DebuggerDisplay("Name = {Name}, Number = {Number}")]
public class ChannelInfoDto : IHasPropertyChangedEvent, IItemDto
public class ChannelInfoDto : IHasPropertyChangedEvent, IItemDto, IHasServerId
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }


/// <summary>
/// Gets or sets the server identifier.
/// </summary>
/// <value>The server identifier.</value>
public string ServerId { get; set; }

/// <summary>
/// Gets or sets the identifier.
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion MediaBrowser.Model/LiveTv/ProgramInfoDto.cs
Expand Up @@ -11,7 +11,7 @@
namespace MediaBrowser.Model.LiveTv
{
[DebuggerDisplay("Name = {Name}, StartTime = {StartDate}, EndTime = {EndDate}")]
public class ProgramInfoDto : IHasPropertyChangedEvent, IItemDto
public class ProgramInfoDto : IHasPropertyChangedEvent, IItemDto, IHasServerId
{
/// <summary>
/// Id of the program.
Expand All @@ -24,6 +24,12 @@ public class ProgramInfoDto : IHasPropertyChangedEvent, IItemDto
/// <value>The primary image aspect ratio.</value>
public double? PrimaryImageAspectRatio { get; set; }

/// <summary>
/// Gets or sets the server identifier.
/// </summary>
/// <value>The server identifier.</value>
public string ServerId { get; set; }

/// <summary>
/// Gets or sets the original primary image aspect ratio.
/// </summary>
Expand Down
13 changes: 10 additions & 3 deletions MediaBrowser.Model/LiveTv/RecordingGroupDto.cs
@@ -1,15 +1,22 @@
using System.ComponentModel;
using System.Diagnostics;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Extensions;
using System.ComponentModel;
using System.Diagnostics;

namespace MediaBrowser.Model.LiveTv
{
/// <summary>
/// Class RecordingGroupDto.
/// </summary>
[DebuggerDisplay("Name = {Name}, Count = {RecordingCount}")]
public class RecordingGroupDto : IHasPropertyChangedEvent
public class RecordingGroupDto : IHasPropertyChangedEvent, IHasServerId
{
/// <summary>
/// Gets or sets the server identifier.
/// </summary>
/// <value>The server identifier.</value>
public string ServerId { get; set; }

/// <summary>
/// Gets or sets the name.
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion MediaBrowser.Model/LiveTv/RecordingInfoDto.cs
Expand Up @@ -11,7 +11,7 @@
namespace MediaBrowser.Model.LiveTv
{
[DebuggerDisplay("Name = {Name}, ChannelName = {ChannelName}")]
public class RecordingInfoDto : IHasPropertyChangedEvent, IItemDto
public class RecordingInfoDto : IHasPropertyChangedEvent, IItemDto, IHasServerId
{
/// <summary>
/// Id of the recording.
Expand All @@ -24,6 +24,12 @@ public class RecordingInfoDto : IHasPropertyChangedEvent, IItemDto
/// <value>The primary image aspect ratio.</value>
public double? PrimaryImageAspectRatio { get; set; }

/// <summary>
/// Gets or sets the server identifier.
/// </summary>
/// <value>The server identifier.</value>
public string ServerId { get; set; }

/// <summary>
/// Gets or sets the original primary image aspect ratio.
/// </summary>
Expand Down
22 changes: 15 additions & 7 deletions MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
Expand All @@ -22,13 +23,15 @@ public class LiveTvDtoService

private readonly IUserDataManager _userDataManager;
private readonly IDtoService _dtoService;
private readonly IApplicationHost _appHost;

public LiveTvDtoService(IDtoService dtoService, IUserDataManager userDataManager, IImageProcessor imageProcessor, ILogger logger)
public LiveTvDtoService(IDtoService dtoService, IUserDataManager userDataManager, IImageProcessor imageProcessor, ILogger logger, IApplicationHost appHost)
{
_dtoService = dtoService;
_userDataManager = userDataManager;
_imageProcessor = imageProcessor;
_logger = logger;
_appHost = appHost;
}

public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, LiveTvChannel channel)
Expand All @@ -53,7 +56,8 @@ public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, Live
ServiceName = service.Name,
ExternalProgramId = info.ProgramId,
Priority = info.Priority,
RunTimeTicks = (info.EndDate - info.StartDate).Ticks
RunTimeTicks = (info.EndDate - info.StartDate).Ticks,
ServerId = _appHost.SystemId
};

if (!string.IsNullOrEmpty(info.ProgramId))
Expand Down Expand Up @@ -99,7 +103,8 @@ public SeriesTimerInfoDto GetSeriesTimerInfoDto(SeriesTimerInfo info, ILiveTvSer
ExternalChannelId = info.ChannelId,
ExternalProgramId = info.ProgramId,
ServiceName = service.Name,
ChannelName = channelName
ChannelName = channelName,
ServerId = _appHost.SystemId
};

if (!string.IsNullOrEmpty(info.ChannelId))
Expand Down Expand Up @@ -219,7 +224,8 @@ public RecordingInfoDto GetRecordingInfoDto(ILiveTvRecording recording, LiveTvCh
RunTimeTicks = (info.EndDate - info.StartDate).Ticks,
OriginalAirDate = info.OriginalAirDate,

MediaSources = recording.GetMediaSources(true).ToList()
MediaSources = recording.GetMediaSources(true).ToList(),
ServerId = _appHost.SystemId
};

dto.MediaStreams = dto.MediaSources.SelectMany(i => i.MediaStreams).ToList();
Expand Down Expand Up @@ -314,7 +320,8 @@ public ChannelInfoDto GetChannelInfoDto(LiveTvChannel info, LiveTvProgram curren
Id = info.Id.ToString("N"),
MediaType = info.MediaType,
ExternalId = info.ExternalId,
MediaSources = info.GetMediaSources(true).ToList()
MediaSources = info.GetMediaSources(true).ToList(),
ServerId = _appHost.SystemId
};

if (user != null)
Expand Down Expand Up @@ -368,7 +375,8 @@ public ProgramInfoDto GetProgramInfoDto(LiveTvProgram item, LiveTvChannel channe
IsKids = item.IsKids,
IsPremiere = item.IsPremiere,
Type = "Program",
MediaType = item.MediaType
MediaType = item.MediaType,
ServerId = _appHost.SystemId
};

if (item.EndDate.HasValue)
Expand Down
7 changes: 4 additions & 3 deletions MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.ScheduledTasks;
Expand Down Expand Up @@ -60,7 +61,7 @@ public class LiveTvManager : ILiveTvManager, IDisposable

private readonly SemaphoreSlim _refreshSemaphore = new SemaphoreSlim(1, 1);

public LiveTvManager(IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer)
public LiveTvManager(IApplicationHost appHost, IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer)
{
_config = config;
_fileSystem = fileSystem;
Expand All @@ -74,7 +75,7 @@ public LiveTvManager(IServerConfigurationManager config, IFileSystem fileSystem,
_dtoService = dtoService;
_userDataManager = userDataManager;

_tvDtoService = new LiveTvDtoService(dtoService, userDataManager, imageProcessor, logger);
_tvDtoService = new LiveTvDtoService(dtoService, userDataManager, imageProcessor, logger, appHost);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion MediaBrowser.ServerApplication/ApplicationHost.cs
Expand Up @@ -530,7 +530,7 @@ protected override async Task RegisterResources(IProgress<double> progress)
var playlistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("PlaylistManager"), UserManager);
RegisterSingleInstance<IPlaylistManager>(playlistManager);

LiveTvManager = new LiveTvManager(ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer);
LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer);
RegisterSingleInstance(LiveTvManager);

UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, FileSystemManager, UserManager, ChannelManager, LiveTvManager, ApplicationPaths, playlistManager);
Expand Down
Expand Up @@ -392,10 +392,9 @@

self.logout = function () {

var i, length;
var promises = [];

for (i = 0, length = apiClients.length; i < length; i++) {
for (var i = 0, length = apiClients.length; i < length; i++) {

var apiClient = apiClients[i];

Expand All @@ -404,16 +403,21 @@
}
}

var done = function () {
return $.when(promises).done(function () {

var credentials = credentialProvider.credentials();

for (i = 0, length = credentials.servers.length; i < length; i++) {
credentials.servers[i].UserId = null;
credentials.servers[i].AccessToken = null;
credentials.servers[i].ExchangeToken = null;
var servers = credentials.servers.filter(function (u) {
return u.UserLinkType != "Guest";
});

for (var j = 0, numServers = servers.length; j < numServers; j++) {
servers[j].UserId = null;
servers[j].AccessToken = null;
servers[j].ExchangeToken = null;
}

credentials.servers = servers;
credentials.ConnectAccessToken = null;
credentials.ConnectUserId = null;

Expand All @@ -422,9 +426,7 @@
connectUser = null;

$(self).trigger('signedout');
};

return $.when(promises).done(done);
});
};

self.connectUserId = function () {
Expand Down Expand Up @@ -458,7 +460,8 @@
Id: i.SystemId,
Name: i.Name,
RemoteAddress: i.Url,
LocalAddress: null
LocalAddress: i.LocalAddress,
UserLinkType: (i.UserType || '').toLowerCase() == "guest" ? "Guest" : "LinkedUser"
};
});

Expand Down
4 changes: 2 additions & 2 deletions Nuget/MediaBrowser.Common.Internal.nuspec
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.502</version>
<version>3.0.503</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
Expand All @@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.502" />
<dependency id="MediaBrowser.Common" version="3.0.503" />
<dependency id="NLog" version="3.1.0.0" />
<dependency id="SimpleInjector" version="2.6.0" />
<dependency id="sharpcompress" version="0.10.2" />
Expand Down
2 changes: 1 addition & 1 deletion Nuget/MediaBrowser.Common.nuspec
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.502</version>
<version>3.0.503</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
Expand Down
2 changes: 1 addition & 1 deletion Nuget/MediaBrowser.Model.Signed.nuspec
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Model.Signed</id>
<version>3.0.502</version>
<version>3.0.503</version>
<title>MediaBrowser.Model - Signed Edition</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
Expand Down
4 changes: 2 additions & 2 deletions Nuget/MediaBrowser.Server.Core.nuspec
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.502</version>
<version>3.0.503</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
Expand All @@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.502" />
<dependency id="MediaBrowser.Common" version="3.0.503" />
</dependencies>
</metadata>
<files>
Expand Down

0 comments on commit 2358bc3

Please sign in to comment.