diff --git a/NAPS2.Lib.Common/Config/CommonConfig.cs b/NAPS2.Lib.Common/Config/CommonConfig.cs index cc6f67cf3..e0d6898b4 100644 --- a/NAPS2.Lib.Common/Config/CommonConfig.cs +++ b/NAPS2.Lib.Common/Config/CommonConfig.cs @@ -167,10 +167,6 @@ public class CommonConfig [Common] public KeyboardShortcuts KeyboardShortcuts { get; set; } = new KeyboardShortcuts(); - [Config] - [Common] - public SslSetup SslSetup { get; set; } = new SslSetup(); - [Common] public ScanProfile? DefaultProfileSettings { get; set; } } \ No newline at end of file diff --git a/NAPS2.Lib.Common/Config/FileConfigScope.cs b/NAPS2.Lib.Common/Config/FileConfigScope.cs index 45dfa1fa3..69175930d 100644 --- a/NAPS2.Lib.Common/Config/FileConfigScope.cs +++ b/NAPS2.Lib.Common/Config/FileConfigScope.cs @@ -34,7 +34,6 @@ public class FileConfigScope : ConfigScope protected override void SetInternal(Expression> accessor, T value) { - // TODO: As we got rid of SetAll, replace it with something that allows multiple writes before flushing to disk _changes.Set(accessor, value); WriteHandshake(); } diff --git a/NAPS2.Lib.Common/Config/InternalDefaults.cs b/NAPS2.Lib.Common/Config/InternalDefaults.cs index ac498e2d6..94e41a670 100644 --- a/NAPS2.Lib.Common/Config/InternalDefaults.cs +++ b/NAPS2.Lib.Common/Config/InternalDefaults.cs @@ -180,11 +180,6 @@ public static class InternalDefaults ZoomIn = "Ctrl+Oemplus", ZoomOut = "Ctrl+OemMinus" }, - SslSetup = new SslSetup - { - WorkerCert = "", - WorkerPrivateKey = "" - }, DefaultProfileSettings = new ScanProfile { Version = ScanProfile.CURRENT_VERSION } }; } \ No newline at end of file diff --git a/NAPS2.Lib.Common/Config/SslSetup.cs b/NAPS2.Lib.Common/Config/SslSetup.cs deleted file mode 100644 index 75b1f63ff..000000000 --- a/NAPS2.Lib.Common/Config/SslSetup.cs +++ /dev/null @@ -1,10 +0,0 @@ -using NAPS2.Serialization; - -namespace NAPS2.Config; - -public class SslSetup -{ - public SecureString? WorkerCert { get; set; } - - public SecureString? WorkerPrivateKey { get; set; } -} \ No newline at end of file diff --git a/NAPS2.Lib.WinForms/WinForms/FPdfSettings.cs b/NAPS2.Lib.WinForms/WinForms/FPdfSettings.cs index ac73bcb57..2b409f118 100644 --- a/NAPS2.Lib.WinForms/WinForms/FPdfSettings.cs +++ b/NAPS2.Lib.WinForms/WinForms/FPdfSettings.cs @@ -76,14 +76,14 @@ public partial class FPdfSettings : FormBase { DefaultFileName = txtDefaultFilePath.Text, SkipSavePrompt = cbSkipSavePrompt.Checked, - Metadata = + Metadata = new PdfMetadata { Title = txtTitle.Text, Author = txtAuthor.Text, Subject = txtSubject.Text, Keywords = txtKeywords.Text }, - Encryption = + Encryption = new PdfEncryption { EncryptPdf = cbEncryptPdf.Checked, OwnerPassword = txtOwnerPassword.Text, diff --git a/NAPS2.Sdk/ImportExport/Email/EmailSettings.cs b/NAPS2.Sdk/ImportExport/Email/EmailSettings.cs index 0f433149c..b5bae5ea5 100644 --- a/NAPS2.Sdk/ImportExport/Email/EmailSettings.cs +++ b/NAPS2.Sdk/ImportExport/Email/EmailSettings.cs @@ -1,6 +1,6 @@ namespace NAPS2.ImportExport.Email; -public class EmailSettings +public record EmailSettings { - public string? AttachmentName { get; set; } + public string AttachmentName { get; init; } = "Scan.pdf"; } \ No newline at end of file diff --git a/NAPS2.Sdk/ImportExport/Email/Mapi/IMapiWrapper.cs b/NAPS2.Sdk/ImportExport/Email/Mapi/IMapiWrapper.cs index 447f5a78a..c3cfbd356 100644 --- a/NAPS2.Sdk/ImportExport/Email/Mapi/IMapiWrapper.cs +++ b/NAPS2.Sdk/ImportExport/Email/Mapi/IMapiWrapper.cs @@ -2,7 +2,7 @@ public interface IMapiWrapper { - bool CanLoadClient(string clientName); + bool CanLoadClient(string? clientName); - Task SendEmail(string clientName, EmailMessage message); + Task SendEmail(string? clientName, EmailMessage message); } \ No newline at end of file diff --git a/NAPS2.Sdk/ImportExport/Email/Mapi/MapiDispatcher.cs b/NAPS2.Sdk/ImportExport/Email/Mapi/MapiDispatcher.cs index 461612787..c71f13221 100644 --- a/NAPS2.Sdk/ImportExport/Email/Mapi/MapiDispatcher.cs +++ b/NAPS2.Sdk/ImportExport/Email/Mapi/MapiDispatcher.cs @@ -26,7 +26,7 @@ public class MapiDispatcher /// The MAPI client name. /// The object describing the email message. /// The MAPI return code. - public async Task SendEmail(string clientName, EmailMessage message) + public async Task SendEmail(string? clientName, EmailMessage message) { if (UseWorker && !_mapiWrapper.CanLoadClient(clientName)) { diff --git a/NAPS2.Sdk/ImportExport/Email/Mapi/SystemEmailClients.cs b/NAPS2.Sdk/ImportExport/Email/Mapi/SystemEmailClients.cs index 69ad448f8..e7b1727d0 100644 --- a/NAPS2.Sdk/ImportExport/Email/Mapi/SystemEmailClients.cs +++ b/NAPS2.Sdk/ImportExport/Email/Mapi/SystemEmailClients.cs @@ -70,7 +70,7 @@ public class SystemEmailClients private static string GetDllPath(string? clientName) { - if (clientName == null) + if (string.IsNullOrEmpty(clientName)) { return DEFAULT_MAPI_DLL; } diff --git a/NAPS2.Sdk/ImportExport/Images/ImageSettings.cs b/NAPS2.Sdk/ImportExport/Images/ImageSettings.cs index 370b6ede0..4d42f3723 100644 --- a/NAPS2.Sdk/ImportExport/Images/ImageSettings.cs +++ b/NAPS2.Sdk/ImportExport/Images/ImageSettings.cs @@ -1,14 +1,14 @@ namespace NAPS2.ImportExport.Images; -public class ImageSettings +public record ImageSettings { - public string? DefaultFileName { get; set; } + public string? DefaultFileName { get; init; } - public bool SkipSavePrompt { get; set; } + public bool SkipSavePrompt { get; init; } - public int JpegQuality { get; set; } + public int JpegQuality { get; init; } = 75; - public TiffCompression TiffCompression { get; set; } + public TiffCompression TiffCompression { get; init; } = TiffCompression.Auto; - public bool SinglePageTiff { get; set; } + public bool SinglePageTiff { get; init; } } \ No newline at end of file diff --git a/NAPS2.Sdk/ImportExport/Pdf/PdfEncryption.cs b/NAPS2.Sdk/ImportExport/Pdf/PdfEncryption.cs index 07986ea63..fb6f9d50f 100644 --- a/NAPS2.Sdk/ImportExport/Pdf/PdfEncryption.cs +++ b/NAPS2.Sdk/ImportExport/Pdf/PdfEncryption.cs @@ -1,16 +1,16 @@ namespace NAPS2.ImportExport.Pdf; -public class PdfEncryption +public record PdfEncryption { - public bool EncryptPdf { get; set; } - public string? UserPassword { get; set; } - public string? OwnerPassword { get; set; } - public bool AllowContentCopyingForAccessibility { get; set; } = true; - public bool AllowAnnotations { get; set; } = true; - public bool AllowDocumentAssembly { get; set; } = true; - public bool AllowContentCopying { get; set; } = true; - public bool AllowFormFilling { get; set; } = true; - public bool AllowFullQualityPrinting { get; set; } = true; - public bool AllowDocumentModification { get; set; } = true; - public bool AllowPrinting { get; set; } = true; + public bool EncryptPdf { get; init; } + public string? UserPassword { get; init; } + public string? OwnerPassword { get; init; } + public bool AllowContentCopyingForAccessibility { get; init; } = true; + public bool AllowAnnotations { get; init; } = true; + public bool AllowDocumentAssembly { get; init; } = true; + public bool AllowContentCopying { get; init; } = true; + public bool AllowFormFilling { get; init; } = true; + public bool AllowFullQualityPrinting { get; init; } = true; + public bool AllowDocumentModification { get; init; } = true; + public bool AllowPrinting { get; init; } = true; } \ No newline at end of file diff --git a/NAPS2.Sdk/ImportExport/Pdf/PdfExportParams.cs b/NAPS2.Sdk/ImportExport/Pdf/PdfExportParams.cs index f5b6ec7f0..1dbeecad4 100644 --- a/NAPS2.Sdk/ImportExport/Pdf/PdfExportParams.cs +++ b/NAPS2.Sdk/ImportExport/Pdf/PdfExportParams.cs @@ -1,3 +1,21 @@ namespace NAPS2.ImportExport.Pdf; -public record PdfExportParams(PdfMetadata? Metadata = null, PdfEncryption? Encryption = null, PdfCompat Compat = PdfCompat.Default); \ No newline at end of file +public record PdfExportParams +{ + public PdfExportParams() + { + } + + public PdfExportParams(PdfMetadata metadata, PdfEncryption encryption, PdfCompat compat) + { + Metadata = metadata; + Encryption = encryption; + Compat = compat; + } + + public PdfMetadata Metadata { get; init; } = new(); + + public PdfEncryption Encryption { get; init; } = new(); + + public PdfCompat Compat { get; init; } = PdfCompat.Default; +} \ No newline at end of file diff --git a/NAPS2.Sdk/ImportExport/Pdf/PdfMetadata.cs b/NAPS2.Sdk/ImportExport/Pdf/PdfMetadata.cs index a9ee35977..7ae003da0 100644 --- a/NAPS2.Sdk/ImportExport/Pdf/PdfMetadata.cs +++ b/NAPS2.Sdk/ImportExport/Pdf/PdfMetadata.cs @@ -1,10 +1,10 @@ namespace NAPS2.ImportExport.Pdf; -public class PdfMetadata +public record PdfMetadata { - public string? Author { get; set; } - public string? Creator { get; set; } - public string? Keywords { get; set; } - public string? Subject { get; set; } - public string? Title { get; set; } + public string Author { get; init; } = ""; + public string Creator { get; init; } = ""; + public string Keywords { get; init; } = ""; + public string Subject { get; init; } = ""; + public string Title { get; init; } = ""; } \ No newline at end of file diff --git a/NAPS2.Sdk/Remoting/Worker/WorkerServiceAdapter.cs b/NAPS2.Sdk/Remoting/Worker/WorkerServiceAdapter.cs index 640bebe05..4af760b82 100644 --- a/NAPS2.Sdk/Remoting/Worker/WorkerServiceAdapter.cs +++ b/NAPS2.Sdk/Remoting/Worker/WorkerServiceAdapter.cs @@ -72,7 +72,7 @@ public class WorkerServiceAdapter } } - public async Task SendMapiEmail(string clientName, EmailMessage message) + public async Task SendMapiEmail(string? clientName, EmailMessage message) { var req = new SendMapiEmailRequest { ClientName = clientName, EmailMessageXml = message.ToXml() }; var resp = await _client.SendMapiEmailAsync(req);