aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-05-09 18:43:11 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-05-09 18:43:11 -0400
commit35a7986b3f2c40e66bb7da6a9ae91b38cc763422 (patch)
treea81b31b24b2372ce2c8f23faedcf240f8bd7e700 /MediaBrowser.Controller
parent2b2832076471f789d46faf938596c57a18601e1f (diff)
added model classes for remote control
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Dto/DtoBuilder.cs2
-rw-r--r--MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs45
-rw-r--r--MediaBrowser.Controller/Dto/UserDtoBuilder.cs2
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj2
-rw-r--r--MediaBrowser.Controller/Session/SessionInfo.cs66
5 files changed, 115 insertions, 2 deletions
diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs
index 167ff2f78..ca08a3290 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");
}
/// <summary>
diff --git a/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs b/MediaBrowser.Controller/Dto/SessionInfoDtoBuilder.cs
new file mode 100644
index 000000000..850af573f
--- /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
+{
+ /// <summary>
+ /// Class SessionInfoDtoBuilder
+ /// </summary>
+ public static class SessionInfoDtoBuilder
+ {
+ /// <summary>
+ /// Gets the session info dto.
+ /// </summary>
+ /// <param name="session">The session.</param>
+ /// <returns>SessionInfoDto.</returns>
+ 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 ad90a392c..892bd5dd0 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 c54a446fb..378011e34 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -70,6 +70,7 @@
<Link>Properties\SharedVersion.cs</Link>
</Compile>
<Compile Include="Configuration\IServerConfigurationManager.cs" />
+ <Compile Include="Dto\SessionInfoDtoBuilder.cs" />
<Compile Include="Session\ISessionManager.cs" />
<Compile Include="Drawing\ImageExtensions.cs" />
<Compile Include="Drawing\ImageHeader.cs" />
@@ -191,6 +192,7 @@
<Compile Include="Providers\FolderProviderFromXml.cs" />
<Compile Include="Providers\ImageFromMediaLocationProvider.cs" />
<Compile Include="Providers\MediaInfo\FFProbeVideoInfoProvider.cs" />
+ <Compile Include="Session\SessionInfo.cs" />
<Compile Include="Sorting\IBaseItemComparer.cs" />
<Compile Include="Sorting\IUserBaseItemComparer.cs" />
<Compile Include="Updates\IInstallationManager.cs" />
diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs
new file mode 100644
index 000000000..21c65df97
--- /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
+{
+ /// <summary>
+ /// Class SessionInfo
+ /// </summary>
+ public class SessionInfo
+ {
+ /// <summary>
+ /// Gets or sets the id.
+ /// </summary>
+ /// <value>The id.</value>
+ public Guid Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the user id.
+ /// </summary>
+ /// <value>The user id.</value>
+ public Guid? UserId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the type of the client.
+ /// </summary>
+ /// <value>The type of the client.</value>
+ public string Client { get; set; }
+
+ /// <summary>
+ /// Gets or sets the last activity date.
+ /// </summary>
+ /// <value>The last activity date.</value>
+ public DateTime LastActivityDate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name of the device.
+ /// </summary>
+ /// <value>The name of the device.</value>
+ public string DeviceName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the now playing item.
+ /// </summary>
+ /// <value>The now playing item.</value>
+ public BaseItem NowPlayingItem { get; set; }
+
+ /// <summary>
+ /// Gets or sets the now playing position ticks.
+ /// </summary>
+ /// <value>The now playing position ticks.</value>
+ public long? NowPlayingPositionTicks { get; set; }
+
+ /// <summary>
+ /// Gets or sets the device id.
+ /// </summary>
+ /// <value>The device id.</value>
+ public string DeviceId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the web socket.
+ /// </summary>
+ /// <value>The web socket.</value>
+ public IWebSocketConnection WebSocket { get; set; }
+ }
+}