Skip to content

Commit

Permalink
IMAP Improvements (#558)
Browse files Browse the repository at this point in the history
* Fixing an issue where scrollviewer overrides a part of template in mail list. Adjusted zoomed out header grid's corner radius.

* IDLE implementation, imap synchronization strategies basics and condstore synchronization.

* Adding iCloud and Yahoo as special IMAP handling scenario.

* iCloud special imap handling.

* Support for killing synchronizers.

* Update privacy policy url.

* Batching condstore downloads into 50, using SORT extension for searches if supported.

* Bumping some nugets. More on the imap synchronizers.

* Delegating idle synchronizations to server to post-sync operations.

* Update mailkit to resolve qresync bug with iCloud.

* Fixing remote highest mode seq checks for qresync and condstore synchronizers.

* Yahoo custom settings.

* Bump google sdk package.

* Fixing the build issue....

* NRE on canceled token accounts during setup.

* Server crash handlers.

* Remove ARM32. Upgrade server to .NET 9.

* Fix icons for yahoo and apple.

* Fixed an issue where disabled folders causing an exception on forced sync.

* Remove smtp encoding constraint.

* Remove commented code.

* Fixing merge conflict

* Addressing double registrations for mailkit remote folder events in synchronizers.

* Making sure idle canceled result is not reported.

* Fixing custom imap server dialog opening.

* Fixing the issue with account creation making the previously selected account as selected as well.

* Fixing app close behavior and logging app close.
  • Loading branch information
bkaankose authored Feb 15, 2025
1 parent 30f1257 commit ee9e41c
Show file tree
Hide file tree
Showing 108 changed files with 2,051 additions and 1,125 deletions.
16 changes: 0 additions & 16 deletions Wino.Authentication/Office365Authenticator.cs

This file was deleted.

9 changes: 0 additions & 9 deletions Wino.Calendar.Packaging/Wino.Calendar.Packaging.wapproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
Expand Down Expand Up @@ -76,7 +68,6 @@
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
<ItemGroup>
<PackageReference Include="Microsoft.Identity.Client" Version="4.66.2" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
Expand Down
8 changes: 1 addition & 7 deletions Wino.Calendar.ViewModels/AccountManagementViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private async Task AddNewAccountAsync()
if (accountCreationDialogResult == null) return;

var accountCreationCancellationTokenSource = new CancellationTokenSource();
var accountCreationDialog = CalendarDialogService.GetAccountCreationDialog(accountCreationDialogResult.ProviderType);
var accountCreationDialog = CalendarDialogService.GetAccountCreationDialog(accountCreationDialogResult);

accountCreationDialog.ShowDialog(accountCreationCancellationTokenSource);
accountCreationDialog.State = AccountCreationDialogState.SigningIn;
Expand All @@ -92,7 +92,6 @@ private async Task AddNewAccountAsync()
{
ProviderType = accountCreationDialogResult.ProviderType,
Name = accountCreationDialogResult.AccountName,
AccountColorHex = accountCreationDialogResult.AccountColorHex,
Id = Guid.NewGuid()
};

Expand All @@ -104,13 +103,8 @@ private async Task AddNewAccountAsync()
if (accountCreationDialog.State == AccountCreationDialogState.Canceled)
throw new AccountSetupCanceledException();


tokenInformationResponse.ThrowIfFailed();

//var tokenInformation = tokenInformationResponse.Data;
//createdAccount.Address = tokenInformation.Address;
//tokenInformation.AccountId = createdAccount.Id;

await AccountService.CreateAccountAsync(createdAccount, null);

// Sync profile information if supported.
Expand Down
1 change: 0 additions & 1 deletion Wino.Calendar.ViewModels/Wino.Calendar.ViewModels.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Identity.Client" Version="4.66.2" />
<PackageReference Include="TimePeriodLibrary.NET" Version="2.1.5" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion Wino.Calendar/Services/ProviderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public List<IProviderDetail> GetAvailableProviders()

foreach (var type in providers)
{
providerList.Add(new ProviderDetail(type));
providerList.Add(new ProviderDetail(type, SpecialImapProvider.None));
}

return providerList;
Expand Down
25 changes: 1 addition & 24 deletions Wino.Calendar/Wino.Calendar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,6 @@
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM64\Debug\</OutputPath>
Expand Down Expand Up @@ -334,7 +311,7 @@
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="Win2D.uwp">
<Version>1.28.0</Version>
<Version>1.28.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
8 changes: 7 additions & 1 deletion Wino.Core.Domain/Entities/Shared/MailAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public class MailAccount
/// </summary>
public Guid? MergedInboxId { get; set; }

/// <summary>
/// Gets or sets the additional IMAP provider assignment for the account.
/// Providers that use IMAP as a synchronizer but have special requirements.
/// </summary>
public SpecialImapProvider SpecialImapProvider { get; set; }

/// <summary>
/// Contains the merged inbox this account belongs to.
/// Ignored for all SQLite operations.
Expand All @@ -95,7 +101,7 @@ public class MailAccount
/// <summary>
/// Gets whether the account can perform ProfileInformation sync type.
/// </summary>
public bool IsProfileInfoSyncSupported => ProviderType == MailProviderType.Outlook || ProviderType == MailProviderType.Office365 || ProviderType == MailProviderType.Gmail;
public bool IsProfileInfoSyncSupported => ProviderType == MailProviderType.Outlook || ProviderType == MailProviderType.Gmail;

/// <summary>
/// Gets whether the account can perform AliasInformation sync type.
Expand Down
4 changes: 1 addition & 3 deletions Wino.Core.Domain/Enums/MailProviderType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ public enum MailProviderType
{
Outlook,
Gmail,
Office365,
Yahoo,
IMAP4
IMAP4 = 4 // 2-3 were removed after release. Don't change for backward compatibility.
}
}
4 changes: 2 additions & 2 deletions Wino.Core.Domain/Enums/MailSynchronizationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{
public enum MailSynchronizationType
{
// Shared
UpdateProfile, // Only update profile information
ExecuteRequests, // Run the queued requests, and then synchronize if needed.
FoldersOnly, // Only synchronize folder metadata.
InboxOnly, // Only Inbox, Sent and Draft folders.
InboxOnly, // Only Inbox, Sent, Draft and Deleted folders.
CustomFolders, // Only sync folders that are specified in the options.
FullFolders, // Synchronize all folders. This won't update profile or alias information.
Alias, // Only update alias information
IMAPIdle // Idle client triggered synchronization.
}
}
9 changes: 9 additions & 0 deletions Wino.Core.Domain/Enums/SpecialImapProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Wino.Core.Domain.Enums
{
public enum SpecialImapProvider
{
None,
iCloud,
Yahoo
}
}
10 changes: 10 additions & 0 deletions Wino.Core.Domain/Exceptions/ImapSynchronizerStrategyException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Wino.Core.Domain.Exceptions
{
public class ImapSynchronizerStrategyException : System.Exception
{
public ImapSynchronizerStrategyException(string message) : base(message)
{

}
}
}
3 changes: 2 additions & 1 deletion Wino.Core.Domain/Interfaces/IAccountCreationDialog.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Threading;
using System.Threading.Tasks;
using Wino.Core.Domain.Enums;

namespace Wino.Core.Domain.Interfaces
{
public interface IAccountCreationDialog
{
void ShowDialog(CancellationTokenSource cancellationTokenSource);
Task ShowDialogAsync(CancellationTokenSource cancellationTokenSource);
void Complete(bool cancel);
AccountCreationDialogState State { get; set; }
}
Expand Down
6 changes: 0 additions & 6 deletions Wino.Core.Domain/Interfaces/IBaseSynchronizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ public interface IBaseSynchronizer
/// <param name="request">Request to queue.</param>
void QueueRequest(IRequestBase request);

/// <summary>
/// TODO
/// </summary>
/// <returns>Whether active synchronization is stopped or not.</returns>
bool CancelActiveSynchronization();

/// <summary>
/// Synchronizes profile information with the server.
/// Sender name and Profile picture are updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ public interface ICustomFolderSynchronizationRequest
/// Which folders to sync after this operation?
/// </summary>
List<Guid> SynchronizationFolderIds { get; }

/// <summary>
/// If true, additional folders like Sent, Drafts and Deleted will not be synchronized
/// </summary>
bool ExcludeMustHaveFolders { get; }
}
}
2 changes: 1 addition & 1 deletion Wino.Core.Domain/Interfaces/IDialogServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Task<bool> ShowWinoCustomMessageDialogAsync(string title,
string dontAskAgainConfigurationKey = "");
Task<bool> ShowCustomThemeBuilderDialogAsync();
Task<AccountCreationDialogResult> ShowAccountProviderSelectionDialogAsync(List<IProviderDetail> availableProviders);
IAccountCreationDialog GetAccountCreationDialog(MailProviderType type);
IAccountCreationDialog GetAccountCreationDialog(AccountCreationDialogResult accountCreationDialogResult);
Task<List<SharedFile>> PickFilesAsync(params object[] typeFilters);
Task<string> PickFilePathAsync(string saveFileName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Wino.Core.Domain.Interfaces
{
public interface ICustomServerAccountCreationDialog : IAccountCreationDialog
public interface IImapAccountCreationDialog : IAccountCreationDialog
{
/// <summary>
/// Returns the custom server information from the dialog..
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using MailKit.Net.Imap;

namespace Wino.Core.Domain.Interfaces
{
/// <summary>
/// Provides a synchronization strategy for synchronizing IMAP folders based on the server capabilities.
/// </summary>
public interface IImapSynchronizationStrategyProvider
{
IImapSynchronizerStrategy GetSynchronizationStrategy(IImapClient client);
}
}
17 changes: 17 additions & 0 deletions Wino.Core.Domain/Interfaces/IImapSynchronizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Models.MailItem;

namespace Wino.Core.Domain.Interfaces
{
public interface IImapSynchronizer
{
uint InitialMessageDownloadCountPerFolder { get; }

Task<List<NewMailItemPackage>> CreateNewMailPackagesAsync(ImapMessageCreationPackage message, MailItemFolder assignedFolder, CancellationToken cancellationToken = default);
Task StartIdleClientAsync();
Task StopIdleClientAsync();
}
}
22 changes: 22 additions & 0 deletions Wino.Core.Domain/Interfaces/IImapSynchronizerStrategy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MailKit.Net.Imap;
using Wino.Core.Domain.Entities.Mail;

namespace Wino.Core.Domain.Interfaces
{
public interface IImapSynchronizerStrategy
{
/// <summary>
/// Synchronizes given folder with the ImapClient client from the client pool.
/// </summary>
/// <param name="client">Client to perform sync with. I love Mira and Jasminka</param>
/// <param name="folder">Folder to synchronize.</param>
/// <param name="synchronizer">Imap synchronizer that downloads messages.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>List of new downloaded message ids that don't exist locally.</returns>
Task<List<string>> HandleSynchronizationAsync(IImapClient client, MailItemFolder folder, IImapSynchronizer synchronizer, CancellationToken cancellationToken = default);
}
}

9 changes: 9 additions & 0 deletions Wino.Core.Domain/Interfaces/IMailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MailKit;
using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Entities.Shared;
using Wino.Core.Domain.Models.MailItem;
Expand Down Expand Up @@ -108,5 +109,13 @@ public interface IMailService
/// <param name="draftCreationOptions">Options like new email/forward/draft.</param>
/// <returns>Draft MailCopy and Draft MimeMessage as base64.</returns>
Task<(MailCopy draftMailCopy, string draftBase64MimeMessage)> CreateDraftAsync(Guid accountId, DraftCreationOptions draftCreationOptions);

/// <summary>
/// Returns ids
/// </summary>
/// <param name="folderId"></param>
/// <param name="uniqueIds"></param>
/// <returns></returns>
Task<List<MailCopy>> GetExistingMailsAsync(Guid folderId, IEnumerable<UniqueId> uniqueIds);
}
}
1 change: 1 addition & 0 deletions Wino.Core.Domain/Interfaces/IProviderDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Wino.Core.Domain.Interfaces
public interface IProviderDetail
{
MailProviderType Type { get; }
SpecialImapProvider SpecialImapProvider { get; }
string Name { get; }
string Description { get; }
string ProviderImage { get; }
Expand Down
10 changes: 10 additions & 0 deletions Wino.Core.Domain/Interfaces/ISpecialImapProviderConfigResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Wino.Core.Domain.Entities.Shared;
using Wino.Core.Domain.Models.Accounts;

namespace Wino.Core.Domain.Interfaces
{
public interface ISpecialImapProviderConfigResolver
{
CustomServerInformation GetServerInformation(MailAccount account, AccountCreationDialogResult dialogResult);
}
}
1 change: 1 addition & 0 deletions Wino.Core.Domain/Interfaces/ISynchronizerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public interface ISynchronizerFactory
{
Task<IWinoSynchronizerBase> GetAccountSynchronizerAsync(Guid accountId);
Task InitializeAsync();
Task DeleteSynchronizerAsync(Guid accountId);
}
}
7 changes: 7 additions & 0 deletions Wino.Core.Domain/Interfaces/IWinoSynchronizerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,12 @@ public interface IWinoSynchronizerBase : IBaseSynchronizer
/// <param name="transferProgress">Optional progress reporting for download operation.</param>
/// <param name="cancellationToken">Cancellation token.</param>
Task DownloadMissingMimeMessageAsync(IMailItem mailItem, ITransferProgress transferProgress, CancellationToken cancellationToken = default);

/// <summary>
/// 1. Cancel active synchronization.
/// 2. Stop all running tasks.
/// 3. Dispose all resources.
/// </summary>
Task KillSynchronizerAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

namespace Wino.Core.Domain.Models.Accounts
{
public record AccountCreationDialogResult(MailProviderType ProviderType, string AccountName, string AccountColorHex = "");
public record AccountCreationDialogResult(MailProviderType ProviderType, string AccountName, SpecialImapProviderDetails SpecialImapProviderDetails);
}
Loading

0 comments on commit ee9e41c

Please sign in to comment.