2024-01-31 18:46:37 +01:00
parent 3c4867a276
commit 2dd82aad13
3 changed files with 14 additions and 8 deletions

View File

@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System.Net.Http.Headers;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using Tranga.LibraryConnectors;
using Tranga.NotificationConnectors;
@ -12,7 +13,7 @@ public class TrangaSettings
public string workingDirectory { get; private set; }
public int apiPortNumber { get; init; }
public string styleSheet { get; private set; }
public string? customUserAgent { get; set; } = null;
public ProductInfoHeaderValue userAgent { get; set; } = new ("Tranga", "1.0");
[JsonIgnore] public string settingsFilePath => Path.Join(workingDirectory, "settings.json");
[JsonIgnore] public string libraryConnectorsFilePath => Path.Join(workingDirectory, "libraryConnectors.json");
[JsonIgnore] public string notificationConnectorsFilePath => Path.Join(workingDirectory, "notificationConnectors.json");
@ -120,6 +121,11 @@ public class TrangaSettings
ExportSettings();
}
public void UpdateUserAgent(string customUserAgent)
{
this.userAgent = new ProductInfoHeaderValue(ProductHeaderValue.Parse(customUserAgent));
}
public void ExportSettings()
{
if (File.Exists(settingsFilePath))