2026-02-04 15:44:23 +01:00
|
|
|
// Copyright (c) 2026 Duplicati Inc. All rights reserved.
|
|
|
|
|
|
|
|
|
|
using Duplicati.Library.Common.IO;
|
|
|
|
|
using Duplicati.Library.Interface;
|
2026-02-15 22:03:57 +01:00
|
|
|
using Google.Apis.Gmail.v1;
|
2026-02-04 15:44:23 +01:00
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
namespace Duplicati.Proprietary.GoogleWorkspace.SourceItems;
|
|
|
|
|
|
2026-02-15 22:03:57 +01:00
|
|
|
internal class GmailSettingsSourceEntry(string userId, string parentPath, GmailService service)
|
2026-02-04 15:44:23 +01:00
|
|
|
: MetaEntryBase(Util.AppendDirSeparator(SystemIO.IO_OS.PathCombine(parentPath, "Settings")), null, null)
|
|
|
|
|
{
|
|
|
|
|
public override async IAsyncEnumerable<ISourceProviderEntry> Enumerate([EnumeratorCancellation] CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
if (cancellationToken.IsCancellationRequested)
|
|
|
|
|
yield break;
|
2026-02-15 22:03:57 +01:00
|
|
|
yield return new GmailSettingFileSourceEntry(userId, this.Path, "filters.json", GmailSettingType.Filters, service);
|
2026-02-04 15:44:23 +01:00
|
|
|
if (cancellationToken.IsCancellationRequested)
|
|
|
|
|
yield break;
|
2026-02-15 22:03:57 +01:00
|
|
|
yield return new GmailSettingFileSourceEntry(userId, this.Path, "forwarding.json", GmailSettingType.Forwarding, service);
|
2026-02-04 15:44:23 +01:00
|
|
|
if (cancellationToken.IsCancellationRequested)
|
|
|
|
|
yield break;
|
2026-02-15 22:03:57 +01:00
|
|
|
yield return new GmailSettingFileSourceEntry(userId, this.Path, "vacation.json", GmailSettingType.Vacation, service);
|
2026-02-04 15:44:23 +01:00
|
|
|
if (cancellationToken.IsCancellationRequested)
|
|
|
|
|
yield break;
|
2026-02-15 22:03:57 +01:00
|
|
|
yield return new GmailSettingFileSourceEntry(userId, this.Path, "signatures.json", GmailSettingType.Signatures, service);
|
2026-02-04 15:44:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Task<Dictionary<string, string?>> GetMinorMetadata(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult(new Dictionary<string, string?>
|
|
|
|
|
{
|
|
|
|
|
{ "gsuite:v", "1" },
|
|
|
|
|
{ "gsuite:Type", SourceItemType.GmailSettings.ToString() },
|
|
|
|
|
{ "gsuite:Name", "Settings" },
|
2026-02-11 16:23:27 +01:00
|
|
|
{ "gsuite:Id", "Settings" }
|
2026-02-04 15:44:23 +01:00
|
|
|
}
|
|
|
|
|
.Where(kv => !string.IsNullOrEmpty(kv.Value))
|
|
|
|
|
.ToDictionary(kv => kv.Key, kv => kv.Value));
|
|
|
|
|
}
|
|
|
|
|
}
|