diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-02 15:08:58 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-10-02 15:08:58 -0400 |
| commit | 33a3e215d03d2e8dad3e653e7c75258dc7eb4989 (patch) | |
| tree | f6becfc2487bfd7e6c8b6b29c6a615a727c6e887 | |
| parent | 0abc9d34937f2b1d6cddc5dcc45766940650c8c3 (diff) | |
added user data save event
| -rw-r--r-- | MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Common.Implementations/BaseApplicationHost.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/IUserDataManager.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs | 36 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 3 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Session/ISessionController.cs (renamed from MediaBrowser.Controller/Session/ISessionRemoteController.cs) | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Session/ISessionManager.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Session/SessionInfo.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/UserDataManager.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Session/SessionManager.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Session/WebSocketController.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 2 |
12 files changed, 74 insertions, 15 deletions
diff --git a/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs b/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs index d225bdd99..9cc62a6dc 100644 --- a/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs +++ b/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs @@ -64,7 +64,7 @@ namespace MediaBrowser.Api if (!string.IsNullOrEmpty(client) && !string.IsNullOrEmpty(deviceId) && !string.IsNullOrEmpty(device) && !string.IsNullOrEmpty(version)) { - SessionManager.LogConnectionActivity(client, version, deviceId, device, user); + SessionManager.LogSessionActivity(client, version, deviceId, device, user); } } } diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 4a614f42d..8b8e81e8a 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -413,6 +413,11 @@ namespace MediaBrowser.Common.Implementations { Logger.Error("Error creating {0}", ex, type.Name); +#if DEBUG + throw; +#endif + + // Don't blow up in release mode return null; } } diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs index 95eadbd64..5a4dcd55d 100644 --- a/MediaBrowser.Controller/Library/IUserDataManager.cs +++ b/MediaBrowser.Controller/Library/IUserDataManager.cs @@ -12,6 +12,11 @@ namespace MediaBrowser.Controller.Library public interface IUserDataManager { /// <summary> + /// Occurs when [user data saved]. + /// </summary> + event EventHandler<UserDataSaveEventArgs> UserDataSaved; + + /// <summary> /// Saves the user data. /// </summary> /// <param name="userId">The user id.</param> diff --git a/MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs b/MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs new file mode 100644 index 000000000..752bed618 --- /dev/null +++ b/MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs @@ -0,0 +1,36 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Entities; +using System; + +namespace MediaBrowser.Controller.Library +{ + /// <summary> + /// Class UserDataSaveEventArgs + /// </summary> + public class UserDataSaveEventArgs : EventArgs + { + /// <summary> + /// Gets or sets the user id. + /// </summary> + /// <value>The user id.</value> + public Guid UserId { get; set; } + + /// <summary> + /// Gets or sets the key. + /// </summary> + /// <value>The key.</value> + public string Key { get; set; } + + /// <summary> + /// Gets or sets the save reason. + /// </summary> + /// <value>The save reason.</value> + public UserDataSaveReason SaveReason { get; set; } + + /// <summary> + /// Gets or sets the user data. + /// </summary> + /// <value>The user data.</value> + public UserItemData UserData { get; set; } + } +} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 760ff382c..b032da826 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -98,6 +98,7 @@ <Compile Include="Library\IMetadataSaver.cs" /> <Compile Include="Library\ItemUpdateType.cs" /> <Compile Include="Library\IUserDataManager.cs" /> + <Compile Include="Library\UserDataSaveEventArgs.cs" /> <Compile Include="LiveTv\ChannelInfo.cs" /> <Compile Include="LiveTv\ILiveTvManager.cs" /> <Compile Include="LiveTv\ILiveTvService.cs" /> @@ -174,7 +175,7 @@ <Compile Include="Kernel.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Providers\BaseMetadataProvider.cs" /> - <Compile Include="Session\ISessionRemoteController.cs" /> + <Compile Include="Session\ISessionController.cs" /> <Compile Include="Session\PlaybackInfo.cs" /> <Compile Include="Session\PlaybackProgressInfo.cs" /> <Compile Include="Session\PlaybackStopInfo.cs" /> diff --git a/MediaBrowser.Controller/Session/ISessionRemoteController.cs b/MediaBrowser.Controller/Session/ISessionController.cs index 9ba5c983d..f37d63b72 100644 --- a/MediaBrowser.Controller/Session/ISessionRemoteController.cs +++ b/MediaBrowser.Controller/Session/ISessionController.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Controller.Session { - public interface ISessionRemoteController + public interface ISessionController { /// <summary> /// Supportses the specified session. diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 138aa1fc3..6ee57eb46 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Controller.Session /// Adds the parts. /// </summary> /// <param name="remoteControllers">The remote controllers.</param> - void AddParts(IEnumerable<ISessionRemoteController> remoteControllers); + void AddParts(IEnumerable<ISessionController> remoteControllers); /// <summary> /// Occurs when [playback start]. @@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Session /// <param name="user">The user.</param> /// <returns>Task.</returns> /// <exception cref="System.ArgumentNullException">user</exception> - Task<SessionInfo> LogConnectionActivity(string clientType, string appVersion, string deviceId, string deviceName, User user); + Task<SessionInfo> LogSessionActivity(string clientType, string appVersion, string deviceId, string deviceName, User user); /// <summary> /// Used to report that playback has started for an item diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index dc934b70a..d50f19c1f 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using System.Linq; -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Net; using System; +using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Session { diff --git a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs index 5dcfe0edd..34ad7f235 100644 --- a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Common.Events; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Entities; @@ -15,6 +16,8 @@ namespace MediaBrowser.Server.Implementations.Library /// </summary> public class UserDataManager : IUserDataManager { + public event EventHandler<UserDataSaveEventArgs> UserDataSaved; + private readonly ConcurrentDictionary<string, UserItemData> _userData = new ConcurrentDictionary<string, UserItemData>(); private readonly ILogger _logger; @@ -84,6 +87,15 @@ namespace MediaBrowser.Server.Implementations.Library throw; } + + EventHelper.FireEventIfNotNull(UserDataSaved, this, new UserDataSaveEventArgs + { + Key = key, + UserData = userData, + SaveReason = reason, + UserId = userId + + }, _logger); } /// <summary> diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index d91f0ee0c..efb8dbe10 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -78,8 +78,8 @@ namespace MediaBrowser.Server.Implementations.Session _userRepository = userRepository; } - private List<ISessionRemoteController> _remoteControllers; - public void AddParts(IEnumerable<ISessionRemoteController> remoteControllers) + private List<ISessionController> _remoteControllers; + public void AddParts(IEnumerable<ISessionController> remoteControllers) { _remoteControllers = remoteControllers.ToList(); } @@ -104,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Session /// <returns>Task.</returns> /// <exception cref="System.UnauthorizedAccessException"></exception> /// <exception cref="System.ArgumentNullException">user</exception> - public async Task<SessionInfo> LogConnectionActivity(string clientType, string appVersion, string deviceId, string deviceName, User user) + public async Task<SessionInfo> LogSessionActivity(string clientType, string appVersion, string deviceId, string deviceName, User user) { if (string.IsNullOrEmpty(clientType)) { @@ -442,7 +442,7 @@ namespace MediaBrowser.Server.Implementations.Session /// </summary> /// <param name="session">The session.</param> /// <returns>IEnumerable{ISessionRemoteController}.</returns> - private IEnumerable<ISessionRemoteController> GetControllers(SessionInfo session) + private IEnumerable<ISessionController> GetControllers(SessionInfo session) { return _remoteControllers.Where(i => i.Supports(session)); } diff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs index 6915cfc64..fb0bc9b7c 100644 --- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs +++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Session { - public class WebSocketController : ISessionRemoteController + public class WebSocketController : ISessionController { public bool Supports(SessionInfo session) { diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 2d9f22ead..c9d079fc7 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -427,7 +427,7 @@ namespace MediaBrowser.ServerApplication ProviderManager.AddParts(GetExports<BaseMetadataProvider>()); - SessionManager.AddParts(GetExports<ISessionRemoteController>()); + SessionManager.AddParts(GetExports<ISessionController>()); ImageProcessor.AddParts(GetExports<IImageEnhancer>()); |
