2011-07-09 20:19:33 +02:00
|
|
|
|
using System;
|
|
|
|
|
using NLog;
|
2011-04-29 08:06:13 +02:00
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
using NzbDrone.Core.Repository;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.ExternalNotification
|
|
|
|
|
{
|
|
|
|
|
public abstract class ExternalNotificationProviderBase
|
|
|
|
|
{
|
|
|
|
|
protected readonly Logger _logger;
|
|
|
|
|
protected readonly ConfigProvider _configProvider;
|
|
|
|
|
protected readonly ExternalNotificationProvider _externalNotificationProvider;
|
|
|
|
|
|
2011-04-29 08:32:51 +02:00
|
|
|
|
protected ExternalNotificationProviderBase(ConfigProvider configProvider, ExternalNotificationProvider externalNotificationProvider)
|
2011-04-29 08:06:13 +02:00
|
|
|
|
{
|
|
|
|
|
_configProvider = configProvider;
|
|
|
|
|
_externalNotificationProvider = externalNotificationProvider;
|
|
|
|
|
_logger = LogManager.GetLogger(GetType().ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the name for the notification provider
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract string Name { get; }
|
|
|
|
|
|
|
|
|
|
public ExternalNotificationSetting Settings
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _externalNotificationProvider.GetSettings(GetType());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Notify(ExternalNotificationType type, string message, int seriesId = 0)
|
|
|
|
|
{
|
|
|
|
|
if (type == ExternalNotificationType.Grab)
|
|
|
|
|
OnGrab(message);
|
|
|
|
|
|
|
|
|
|
else if (type == ExternalNotificationType.Download)
|
2011-07-09 20:19:33 +02:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
var series = new Series();
|
|
|
|
|
OnDownload(message, series);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-29 08:06:13 +02:00
|
|
|
|
|
|
|
|
|
else if (type == ExternalNotificationType.Rename)
|
2011-07-09 20:19:33 +02:00
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
var series = new Series();
|
|
|
|
|
OnRename(message, series);
|
|
|
|
|
}
|
2011-04-29 08:06:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Performs the on grab action
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name = "message">The message to send to the receiver</param>
|
|
|
|
|
public abstract void OnGrab(string message);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Performs the on download action
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name = "message">The message to send to the receiver</param>
|
2011-07-09 20:19:33 +02:00
|
|
|
|
/// <param name = "series">The Series for the new download</param>
|
|
|
|
|
public abstract void OnDownload(string message, Series series);
|
2011-04-29 08:06:13 +02:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Performs the on rename action
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name = "message">The message to send to the receiver</param>
|
2011-07-09 20:19:33 +02:00
|
|
|
|
/// <param name = "series">The Series for the new download</param>
|
|
|
|
|
public abstract void OnRename(string message, Series series);
|
2011-04-29 08:06:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|