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