Files
nfoguard/NFOGuard.Emby.Plugin/LicenseManager.cs
T
2025-09-12 09:04:23 -04:00

66 lines
2.2 KiB
C#

using System;
using System.Threading.Tasks;
using MediaBrowser.Model.Logging;
namespace NFOGuard.Emby.Plugin
{
public class LicenseManager
{
private readonly ILogger _logger;
public LicenseManager(ILogger logger)
{
_logger = logger;
}
public async Task<bool> ValidateLicenseAsync(string licenseKey)
{
try
{
// TODO: Implement actual license validation
// For now, return true for testing
// In production, this would call your licensing server
if (string.IsNullOrEmpty(licenseKey))
{
_logger.Info("NFOGuard :: No license key provided, running in trial mode");
return false;
}
// Placeholder for license validation logic
// You would implement your own licensing server/API here
_logger.Info($"NFOGuard :: Validating license key: {licenseKey.Substring(0, Math.Min(8, licenseKey.Length))}...");
// For now, accept any non-empty key as valid
return !string.IsNullOrWhiteSpace(licenseKey);
}
catch (Exception ex)
{
_logger.ErrorException("NFOGuard :: License validation error", ex);
return false;
}
}
public bool IsTrialExpired()
{
// Implement trial logic here
// For example, check installation date vs current date
var installDate = Plugin.Instance.Configuration.InstallDate;
if (installDate == DateTime.MinValue)
{
Plugin.Instance.Configuration.InstallDate = DateTime.UtcNow;
Plugin.Instance.SaveConfiguration();
return false;
}
var trialDays = 30; // 30-day trial
return DateTime.UtcNow > installDate.AddDays(trialDays);
}
public bool CanUseFeature()
{
// Check if license is valid or trial is still active
return Plugin.Instance.Configuration.LicenseValid || !IsTrialExpired();
}
}
}