From 35a7986b3f2c40e66bb7da6a9ae91b38cc763422 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 9 May 2013 18:43:11 -0400 Subject: added model classes for remote control --- MediaBrowser.Controller/Dto/DtoBuilder.cs | 2 +- .../Dto/SessionInfoDtoBuilder.cs | 45 +++++++++++++++ MediaBrowser.Controller/Dto/UserDtoBuilder.cs | 2 +- .../MediaBrowser.Controller.csproj | 2 + MediaBrowser.Controller/Session/SessionInfo.cs | 66 ++++++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs create mode 100644 MediaBrowser.Controller/Session/SessionInfo.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs index 167ff2f78e..ca08a32906 100644 --- a/MediaBrowser.Controller/Dto/DtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/DtoBuilder.cs @@ -868,7 +868,7 @@ namespace MediaBrowser.Controller.Dto return GetClientItemId(indexFolder.Parent) + IndexFolderDelimeter + (indexFolder.IndexName ?? string.Empty) + IndexFolderDelimeter + indexFolder.Id; } - return item.Id.ToString(); + return item.Id.ToString("N"); } /// diff --git a/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs b/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs new file mode 100644 index 0000000000..850af573ff --- /dev/null +++ b/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs @@ -0,0 +1,45 @@ +using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Net; +using MediaBrowser.Model.Session; + +namespace MediaBrowser.Controller.Dto +{ + /// + /// Class SessionInfoDtoBuilder + /// + public static class SessionInfoDtoBuilder + { + /// + /// Gets the session info dto. + /// + /// The session. + /// SessionInfoDto. + public static SessionInfoDto GetSessionInfoDto(SessionInfo session) + { + var dto = new SessionInfoDto + { + Client = session.Client, + DeviceId = session.DeviceId, + DeviceName = session.DeviceName, + Id = session.Id, + LastActivityDate = session.LastActivityDate, + NowPlayingPositionTicks = session.NowPlayingPositionTicks + }; + + if (session.NowPlayingItem != null) + { + dto.NowPlayingItem = DtoBuilder.GetBaseItemInfo(session.NowPlayingItem); + } + + if (session.UserId.HasValue) + { + dto.UserId = session.UserId.Value.ToString("N"); + } + + dto.SupportsRemoteControl = session.WebSocket != null && + session.WebSocket.State == WebSocketState.Open; + + return dto; + } + } +} diff --git a/MediaBrowser.Controller/Dto/UserDtoBuilder.cs b/MediaBrowser.Controller/Dto/UserDtoBuilder.cs index ad90a392c9..892bd5dd0e 100644 --- a/MediaBrowser.Controller/Dto/UserDtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/UserDtoBuilder.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Controller.Dto var dto = new UserDto { - Id = user.Id.ToString(), + Id = user.Id.ToString("N"), Name = user.Name, HasPassword = !String.IsNullOrEmpty(user.Password), LastActivityDate = user.LastActivityDate, diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index c54a446fb3..378011e34f 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -70,6 +70,7 @@ Properties\SharedVersion.cs + @@ -191,6 +192,7 @@ + diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs new file mode 100644 index 0000000000..21c65df975 --- /dev/null +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -0,0 +1,66 @@ +using MediaBrowser.Common.Net; +using MediaBrowser.Controller.Entities; +using System; + +namespace MediaBrowser.Controller.Session +{ + /// + /// Class SessionInfo + /// + public class SessionInfo + { + /// + /// Gets or sets the id. + /// + /// The id. + public Guid Id { get; set; } + + /// + /// Gets or sets the user id. + /// + /// The user id. + public Guid? UserId { get; set; } + + /// + /// Gets or sets the type of the client. + /// + /// The type of the client. + public string Client { get; set; } + + /// + /// Gets or sets the last activity date. + /// + /// The last activity date. + public DateTime LastActivityDate { get; set; } + + /// + /// Gets or sets the name of the device. + /// + /// The name of the device. + public string DeviceName { get; set; } + + /// + /// Gets or sets the now playing item. + /// + /// The now playing item. + public BaseItem NowPlayingItem { get; set; } + + /// + /// Gets or sets the now playing position ticks. + /// + /// The now playing position ticks. + public long? NowPlayingPositionTicks { get; set; } + + /// + /// Gets or sets the device id. + /// + /// The device id. + public string DeviceId { get; set; } + + /// + /// Gets or sets the web socket. + /// + /// The web socket. + public IWebSocketConnection WebSocket { get; set; } + } +} -- cgit v1.2.3