team-ljyzipelo

공개
93줄2.7 KB
1using System.Security;
2using Zipelo.Core;
3
4namespace Zipelo.Desktop;
5
6public enum WorkspaceAction
7{
8 List,
9 Extract,
10 Create
11}
12
13public enum WorkspaceOutcome
14{
15 Completed,
16 Partial,
17 Cancelled,
18 Failed
19}
20
21public sealed record WorkspaceRequest(
22 Guid JobId,
23 WorkspaceAction Action,
24 IReadOnlyList<string> Sources,
25 string? Destination = null)
26{
27 public string Format { get; init; } = "zip";
28}
29
30public sealed record FileRow(string Name, string Size, string Verification)
31{
32 public string EntryId { get; init; } = "";
33 public EntryKind Kind { get; init; }
34 public EntryOutcome Outcome { get; init; }
35 public ArchiveError Error { get; init; }
36}
37
38public sealed record WorkspaceProgress(long ProcessedBytes, long? TotalBytes)
39{
40 public Guid JobId { get; init; }
41 public long Sequence { get; init; }
42 public JobState State { get; init; } = JobState.Running;
43}
44
45public sealed record PasswordChallenge(Guid JobId, Guid RequestId)
46{
47 public int Attempt { get; init; } = 1;
48}
49
50public sealed record WorkspaceResult(
51 WorkspaceOutcome Outcome,
52 IReadOnlyList<FileRow> Entries)
53{
54 public Guid JobId { get; init; }
55 public ArchiveError Error { get; init; }
56 public Zipelo.Ui.CreationResult? Creation { get; init; }
57}
58
59// UI 측 연결 경계임. 실제 코어 계약과 연결하는 어댑터는 별도 구현함.
60public interface IArchiveWorkspace
61{
62 bool IsAvailable { get; }
63
64 Task<WorkspaceResult> ExecuteAsync(
65 WorkspaceRequest request,
66 IProgress<WorkspaceProgress> progress,
67 Func<PasswordChallenge, CancellationToken, Task<SecureString?>> requestPassword,
68 CancellationToken cancellationToken);
69}
70
71public sealed class UnavailableWorkspace : IArchiveWorkspace, IWorkspaceCapabilities
72{
73 public bool IsAvailable => false;
74 public string AvailabilityMessage { get; internal set; } =
75 "작업 프로세스가 아직 연결되지 않았습니다. 파일을 처리할 수 없습니다.";
76 public bool CanExecute(WorkspaceAction action, string format) => false;
77
78 public Task<WorkspaceResult> ExecuteAsync(
79 WorkspaceRequest request,
80 IProgress<WorkspaceProgress> progress,
81 Func<PasswordChallenge, CancellationToken, Task<SecureString?>> requestPassword,
82 CancellationToken cancellationToken)
83 {
84 throw new NotSupportedException("압축 엔진이 아직 연결되지 않았습니다.");
85 }
86}
87
88// 기능 조회는 실제 연결된 호스트가 제공함. 해제 검증 전에는 해제 능력을 게시하지 않음.
89public interface IWorkspaceCapabilities
90{
91 bool CanExecute(WorkspaceAction action, string format);
92 string AvailabilityMessage { get; }
93}