mirror of
https://github.com/cyanfish/naps2.git
synced 2024-11-10 14:28:12 +03:00
Make SDK config classes into records
This commit is contained in:
parent
136ef5313b
commit
9600d7b639
@ -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; }
|
||||
}
|
@ -34,7 +34,6 @@ public class FileConfigScope<TConfig> : ConfigScope<TConfig>
|
||||
|
||||
protected override void SetInternal<T>(Expression<Func<TConfig, T>> 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();
|
||||
}
|
||||
|
@ -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 }
|
||||
};
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
using NAPS2.Serialization;
|
||||
|
||||
namespace NAPS2.Config;
|
||||
|
||||
public class SslSetup
|
||||
{
|
||||
public SecureString? WorkerCert { get; set; }
|
||||
|
||||
public SecureString? WorkerPrivateKey { get; set; }
|
||||
}
|
@ -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,
|
||||
|
@ -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";
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
public interface IMapiWrapper
|
||||
{
|
||||
bool CanLoadClient(string clientName);
|
||||
bool CanLoadClient(string? clientName);
|
||||
|
||||
Task<MapiSendMailReturnCode> SendEmail(string clientName, EmailMessage message);
|
||||
Task<MapiSendMailReturnCode> SendEmail(string? clientName, EmailMessage message);
|
||||
}
|
@ -26,7 +26,7 @@ public class MapiDispatcher
|
||||
/// <param name="clientName">The MAPI client name.</param>
|
||||
/// <param name="message">The object describing the email message.</param>
|
||||
/// <returns>The MAPI return code.</returns>
|
||||
public async Task<MapiSendMailReturnCode> SendEmail(string clientName, EmailMessage message)
|
||||
public async Task<MapiSendMailReturnCode> SendEmail(string? clientName, EmailMessage message)
|
||||
{
|
||||
if (UseWorker && !_mapiWrapper.CanLoadClient(clientName))
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ public class SystemEmailClients
|
||||
|
||||
private static string GetDllPath(string? clientName)
|
||||
{
|
||||
if (clientName == null)
|
||||
if (string.IsNullOrEmpty(clientName))
|
||||
{
|
||||
return DEFAULT_MAPI_DLL;
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
@ -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;
|
||||
}
|
@ -1,3 +1,21 @@
|
||||
namespace NAPS2.ImportExport.Pdf;
|
||||
|
||||
public record PdfExportParams(PdfMetadata? Metadata = null, PdfEncryption? Encryption = null, PdfCompat Compat = PdfCompat.Default);
|
||||
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;
|
||||
}
|
@ -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; } = "";
|
||||
}
|
@ -72,7 +72,7 @@ public class WorkerServiceAdapter
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MapiSendMailReturnCode> SendMapiEmail(string clientName, EmailMessage message)
|
||||
public async Task<MapiSendMailReturnCode> SendMapiEmail(string? clientName, EmailMessage message)
|
||||
{
|
||||
var req = new SendMapiEmailRequest { ClientName = clientName, EmailMessageXml = message.ToXml() };
|
||||
var resp = await _client.SendMapiEmailAsync(req);
|
||||
|
Loading…
Reference in New Issue
Block a user