2019-12-20 15:30:51 -05:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 14:54:44 -05:00
|
|
|
using System;
|
2014-04-26 23:42:05 -04:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2019-01-13 14:18:07 -05:00
|
|
|
using MediaBrowser.Controller.Notifications;
|
2016-10-23 22:45:23 -04:00
|
|
|
using MediaBrowser.Model.Globalization;
|
2019-01-13 14:18:07 -05:00
|
|
|
using MediaBrowser.Model.Notifications;
|
2014-04-26 23:42:05 -04:00
|
|
|
|
2018-09-12 13:26:21 -04:00
|
|
|
namespace Emby.Notifications
|
2014-04-26 23:42:05 -04:00
|
|
|
{
|
|
|
|
public class CoreNotificationTypes : INotificationTypeFactory
|
|
|
|
{
|
|
|
|
private readonly ILocalizationManager _localization;
|
|
|
|
|
2019-02-06 14:53:05 -05:00
|
|
|
public CoreNotificationTypes(ILocalizationManager localization)
|
2014-04-26 23:42:05 -04:00
|
|
|
{
|
|
|
|
_localization = localization;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<NotificationTypeInfo> GetNotificationTypes()
|
|
|
|
{
|
2019-02-06 14:53:05 -05:00
|
|
|
var knownTypes = new NotificationTypeInfo[]
|
2014-04-26 23:42:05 -04:00
|
|
|
{
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.ApplicationUpdateInstalled.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.InstallationFailed.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.PluginInstalled.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
2014-04-28 23:56:20 -04:00
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.PluginError.ToString()
|
2014-04-28 23:56:20 -04:00
|
|
|
},
|
2014-04-26 23:42:05 -04:00
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.PluginUninstalled.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.PluginUpdateInstalled.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.ServerRestartRequired.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.TaskFailed.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.NewLibraryContent.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.AudioPlayback.ToString()
|
2014-04-26 23:42:05 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.VideoPlayback.ToString()
|
2014-05-16 13:11:07 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.AudioPlaybackStopped.ToString()
|
2014-05-16 13:11:07 -04:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.VideoPlaybackStopped.ToString()
|
2015-01-26 11:47:15 -05:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
2015-03-02 00:16:29 -05:00
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.UserLockedOut.ToString()
|
2019-02-06 14:53:05 -05:00
|
|
|
},
|
|
|
|
new NotificationTypeInfo
|
2014-04-27 13:54:43 -04:00
|
|
|
{
|
2018-09-12 13:26:21 -04:00
|
|
|
Type = NotificationType.ApplicationUpdateAvailable.ToString()
|
2019-02-06 14:53:05 -05:00
|
|
|
}
|
|
|
|
};
|
2014-04-27 13:54:43 -04:00
|
|
|
|
2014-04-26 23:42:05 -04:00
|
|
|
foreach (var type in knownTypes)
|
|
|
|
{
|
|
|
|
Update(type);
|
|
|
|
}
|
|
|
|
|
2017-10-13 01:44:20 -04:00
|
|
|
var systemName = _localization.GetLocalizedString("System");
|
2014-04-28 23:56:20 -04:00
|
|
|
|
|
|
|
return knownTypes.OrderByDescending(i => string.Equals(i.Category, systemName, StringComparison.OrdinalIgnoreCase))
|
|
|
|
.ThenBy(i => i.Category)
|
|
|
|
.ThenBy(i => i.Name);
|
2014-04-26 23:42:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Update(NotificationTypeInfo note)
|
|
|
|
{
|
|
|
|
note.Name = _localization.GetLocalizedString("NotificationOption" + note.Type) ?? note.Type;
|
|
|
|
|
|
|
|
note.IsBasedOnUserEvent = note.Type.IndexOf("Playback", StringComparison.OrdinalIgnoreCase) != -1;
|
|
|
|
|
|
|
|
if (note.Type.IndexOf("Playback", StringComparison.OrdinalIgnoreCase) != -1)
|
|
|
|
{
|
2017-10-13 01:44:20 -04:00
|
|
|
note.Category = _localization.GetLocalizedString("User");
|
2014-04-26 23:42:05 -04:00
|
|
|
}
|
2015-01-26 11:47:15 -05:00
|
|
|
else if (note.Type.IndexOf("Plugin", StringComparison.OrdinalIgnoreCase) != -1)
|
2014-04-28 23:56:20 -04:00
|
|
|
{
|
2017-10-13 01:44:20 -04:00
|
|
|
note.Category = _localization.GetLocalizedString("Plugin");
|
2014-04-28 23:56:20 -04:00
|
|
|
}
|
2015-03-02 00:16:29 -05:00
|
|
|
else if (note.Type.IndexOf("UserLockedOut", StringComparison.OrdinalIgnoreCase) != -1)
|
|
|
|
{
|
2017-10-13 01:44:20 -04:00
|
|
|
note.Category = _localization.GetLocalizedString("User");
|
2015-03-02 00:16:29 -05:00
|
|
|
}
|
2014-04-26 23:42:05 -04:00
|
|
|
else
|
|
|
|
{
|
2017-10-13 01:44:20 -04:00
|
|
|
note.Category = _localization.GetLocalizedString("System");
|
2014-04-26 23:42:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|