using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Entities.Shared;
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Models.Authentication;
using Wino.Core.Domain.Models.Connectivity;
using Wino.Core.Domain.Models.Synchronization;
namespace Wino.Core.Domain.Interfaces;
///
/// Interface for the singleton synchronization manager that handles synchronizer instances and operations.
///
public interface ISynchronizationManager
{
///
/// Initializes the SynchronizationManager with required dependencies.
///
Task InitializeAsync(ISynchronizerFactory synchronizerFactory,
IImapTestService imapTestService,
IAccountService accountService,
INotificationBuilder notificationBuilder,
IAuthenticationProvider authenticationProvider);
///
/// Tests IMAP server connectivity for the given server information.
///
Task TestImapConnectivityAsync(CustomServerInformation serverInformation, bool allowSSLHandshake);
///
/// Starts a new mail synchronization for the given account.
///
Task SynchronizeMailAsync(MailSynchronizationOptions options,
CancellationToken cancellationToken = default);
///
/// Checks if there is an ongoing synchronization for the given account.
///
bool IsAccountSynchronizing(Guid accountId);
///
/// Gets the latest centralized synchronization progress snapshot for the given account and category.
///
AccountSynchronizationProgress GetSynchronizationProgress(Guid accountId, SynchronizationProgressCategory category);
///
/// Queues a mail action request to the corresponding account's synchronizer with optional synchronization triggering.
///
Task QueueRequestAsync(IRequestBase request, Guid accountId, bool triggerSynchronization);
///
/// Handles folder synchronization for the given account.
///
Task SynchronizeFoldersAsync(Guid accountId,
CancellationToken cancellationToken = default);
///
/// Handles alias synchronization for the given account.
///
Task SynchronizeAliasesAsync(Guid accountId,
CancellationToken cancellationToken = default);
///
/// Handles category synchronization for the given account.
///
Task SynchronizeCategoriesAsync(Guid accountId,
CancellationToken cancellationToken = default);
///
/// Handles profile synchronization for the given account.
///
Task SynchronizeProfileAsync(Guid accountId,
CancellationToken cancellationToken = default);
///
/// Handles calendar synchronization for the given account.
///
Task SynchronizeCalendarAsync(CalendarSynchronizationOptions options,
CancellationToken cancellationToken = default);
///
/// Downloads a MIME message for the given mail item.
///
Task DownloadMimeMessageAsync(MailCopy mailItem, Guid accountId,
CancellationToken cancellationToken = default);
///
/// Creates a new synchronizer for a newly added account.
///
IWinoSynchronizerBase CreateSynchronizerForAccount(MailAccount account);
///
/// Cancels ongoing synchronizations for the given account.
///
Task CancelSynchronizationsAsync(Guid accountId);
///
/// Destroys the synchronizer for the given account.
///
Task DestroySynchronizerAsync(Guid accountId);
///
/// Gets all cached synchronizers.
///
IEnumerable GetAllSynchronizers();
///
/// Gets a synchronizer for the given account ID.
///
Task GetSynchronizerAsync(Guid accountId);
///
/// Handles OAuth authentication for the specified provider.
///
Task HandleAuthorizationAsync(MailProviderType providerType,
MailAccount account = null,
bool proposeCopyAuthorizationURL = false);
}