Initial commit.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
public class AccountSignature
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string HtmlBody { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using SQLite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Back storage for simple name-address book.
|
||||
/// These values will be inserted during MIME fetch.
|
||||
/// </summary>
|
||||
|
||||
|
||||
// TODO: This can easily evolve to Contact store, just like People app in Windows 10/11.
|
||||
// Do it.
|
||||
public class AddressInformation : IEquatable<AddressInformation>
|
||||
{
|
||||
[PrimaryKey]
|
||||
public string Address { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public string DisplayName => Address == Name ? Address : $"{Name} <{Address}>";
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals(obj as AddressInformation);
|
||||
}
|
||||
|
||||
public bool Equals(AddressInformation other)
|
||||
{
|
||||
return !(other is null) &&
|
||||
Address == other.Address &&
|
||||
Name == other.Name;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = -1717786383;
|
||||
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Address);
|
||||
hashCode = hashCode * -1521134295 + EqualityComparer<string>.Default.GetHashCode(Name);
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public static bool operator ==(AddressInformation left, AddressInformation right)
|
||||
{
|
||||
return EqualityComparer<AddressInformation>.Default.Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(AddressInformation left, AddressInformation right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
using Wino.Core.Domain.Enums;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
public class CustomServerInformation
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
public string DisplayName { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string IncomingServer { get; set; }
|
||||
public string IncomingServerUsername { get; set; }
|
||||
public string IncomingServerPassword { get; set; }
|
||||
public string IncomingServerPort { get; set; }
|
||||
|
||||
public CustomIncomingServerType IncomingServerType { get; set; }
|
||||
|
||||
public string OutgoingServer { get; set; }
|
||||
public string OutgoingServerPort { get; set; }
|
||||
public string OutgoingServerUsername { get; set; }
|
||||
public string OutgoingServerPassword { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// useSSL True: SslOnConnect
|
||||
/// useSSL False: StartTlsWhenAvailable
|
||||
/// </summary>
|
||||
|
||||
public ImapConnectionSecurity IncomingServerSocketOption { get; set; }
|
||||
public ImapAuthenticationMethod IncomingAuthenticationMethod { get; set; }
|
||||
|
||||
|
||||
public ImapConnectionSecurity OutgoingServerSocketOption { get; set; }
|
||||
public ImapAuthenticationMethod OutgoingAuthenticationMethod { get; set; }
|
||||
|
||||
public string ProxyServer { get; set; }
|
||||
public string ProxyServerPort { get; set; }
|
||||
|
||||
[Obsolete("As 1.7.0")]
|
||||
public bool IncomingRequiresSSL { get; set; }
|
||||
|
||||
[Obsolete("As 1.7.0")]
|
||||
public bool OutgoingRequresSSL { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
using Wino.Core.Domain.Enums;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
public class MailAccount
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Given name of the account in Wino.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO: Display name of the authenticated user/account.
|
||||
/// API integrations will query this value from the API.
|
||||
/// IMAP is populated by user on setup dialog.
|
||||
/// </summary>
|
||||
|
||||
public string ProfileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Account e-mail address.
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provider type of the account. Outlook,Gmail etc...
|
||||
/// </summary>
|
||||
public MailProviderType ProviderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For tracking change delta.
|
||||
/// Gmail : historyId
|
||||
/// Outlook: deltaToken
|
||||
/// </summary>
|
||||
public string SynchronizationDeltaIdentifier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the signature to be used for this account.
|
||||
/// Null if no signature should be used.
|
||||
/// </summary>
|
||||
public Guid? SignatureId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the account has any reason for an interactive user action to fix continue operating.
|
||||
/// </summary>
|
||||
public AccountAttentionReason AttentionReason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the id of the merged inbox this account belongs to.
|
||||
/// </summary>
|
||||
public Guid? MergedInboxId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the merged inbox this account belongs to.
|
||||
/// Ignored for all SQLite operations.
|
||||
/// </summary>
|
||||
[Ignore]
|
||||
public MergedInbox MergedInbox { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Populated only when account has custom server information.
|
||||
/// </summary>
|
||||
|
||||
[Ignore]
|
||||
public CustomServerInformation ServerInformation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Account preferences.
|
||||
/// </summary>
|
||||
[Ignore]
|
||||
public MailAccountPreferences Preferences { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
public class MailAccountPreferences
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id of the account in MailAccount table.
|
||||
/// </summary>
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether sent draft messages should be appended to the sent folder.
|
||||
/// Some IMAP servers do this automatically, some don't.
|
||||
/// It's disabled by default.
|
||||
/// </summary>
|
||||
public bool ShouldAppendMessagesToSentFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the notifications are enabled for the account.
|
||||
/// </summary>
|
||||
public bool IsNotificationsEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom account identifier color in hex.
|
||||
/// </summary>
|
||||
public string AccountColorHex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the account has Focused inbox support.
|
||||
/// Null if the account provider type doesn't support Focused inbox.
|
||||
/// </summary>
|
||||
public bool? IsFocusedInboxEnabled { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Models.MailItem;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary of the parsed MIME messages.
|
||||
/// Wino will do non-network operations on this table and others from the original MIME.
|
||||
/// </summary>
|
||||
public class MailCopy : IMailItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique Id of the mail.
|
||||
/// </summary>
|
||||
[PrimaryKey]
|
||||
public Guid UniqueId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Not unique id of the item. Some operations held on this Id, some on the UniqueId.
|
||||
/// Same message can be in different folder. In that case UniqueId is used.
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Folder that this mail belongs to.
|
||||
/// </summary>
|
||||
public Guid FolderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Conversation id for the mail.
|
||||
/// </summary>
|
||||
public string ThreadId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// MIME MessageId if exists.
|
||||
/// </summary>
|
||||
public string MessageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// References header from MIME
|
||||
/// </summary>
|
||||
public string References { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// In-Reply-To header from MIME
|
||||
/// </summary>
|
||||
public string InReplyTo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name for the sender.
|
||||
/// </summary>
|
||||
public string FromName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Address of the sender.
|
||||
/// </summary>
|
||||
public string FromAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Subject of the mail.
|
||||
/// </summary>
|
||||
public string Subject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Short preview of the content.
|
||||
/// </summary>
|
||||
public string PreviewText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Date that represents this mail has been created in provider servers.
|
||||
/// Stored always in UTC.
|
||||
/// </summary>
|
||||
public DateTime CreationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Importance of the mail.
|
||||
/// </summary>
|
||||
public MailImportance Importance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Read status for the mail.
|
||||
/// </summary>
|
||||
public bool IsRead { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Flag status.
|
||||
/// Flagged for Outlook.
|
||||
/// Important for Gmail.
|
||||
/// </summary>
|
||||
public bool IsFlagged { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// To support Outlook.
|
||||
/// Gmail doesn't use it.
|
||||
/// </summary>
|
||||
public bool IsFocused { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether mail has attachments included or not.
|
||||
/// </summary>
|
||||
public bool HasAttachments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Assigned draft id.
|
||||
/// </summary>
|
||||
public string DraftId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this copy is draft or not.
|
||||
/// </summary>
|
||||
public bool IsDraft { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// File id that this mail is assigned to.
|
||||
/// This Id is immutable. It's used to find the file in the file system.
|
||||
/// Even after mapping local draft to remote draft, it will not change.
|
||||
/// </summary>
|
||||
public Guid FileId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Folder that this mail is assigned to.
|
||||
/// Warning: This field is not populated by queries.
|
||||
/// Services or View Models are responsible for populating this field.
|
||||
/// </summary>
|
||||
[Ignore]
|
||||
public MailItemFolder AssignedFolder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Account that this mail is assigned to.
|
||||
/// Warning: This field is not populated by queries.
|
||||
/// Services or View Models are responsible for populating this field.
|
||||
/// </summary>
|
||||
[Ignore]
|
||||
public MailAccount AssignedAccount { get; set; }
|
||||
|
||||
public override string ToString() => $"{Subject} <-> {Id}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using SQLite;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Models.Folders;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
[DebuggerDisplay("{FolderName} - {SpecialFolderType}")]
|
||||
public class MailItemFolder : IMailItemFolder
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string RemoteFolderId { get; set; }
|
||||
public string ParentRemoteFolderId { get; set; }
|
||||
|
||||
public Guid MailAccountId { get; set; }
|
||||
public string FolderName { get; set; }
|
||||
public SpecialFolderType SpecialFolderType { get; set; }
|
||||
public bool IsSystemFolder { get; set; }
|
||||
public bool IsSticky { get; set; }
|
||||
public bool IsSynchronizationEnabled { get; set; }
|
||||
public bool IsHidden { get; set; }
|
||||
public bool ShowUnreadCount { get; set; }
|
||||
public DateTime? LastSynchronizedDate { get; set; }
|
||||
|
||||
// For IMAP
|
||||
public uint UidValidity { get; set; }
|
||||
public long HighestModeSeq { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Outlook shares delta changes per-folder. Gmail is for per-account.
|
||||
/// This is only used for Outlook provider.
|
||||
/// </summary>
|
||||
public string DeltaToken { get; set; }
|
||||
|
||||
// For GMail Labels
|
||||
public string TextColorHex { get; set; }
|
||||
public string BackgroundColorHex { get; set; }
|
||||
|
||||
[Ignore]
|
||||
public List<IMailItemFolder> ChildFolders { get; set; } = [];
|
||||
|
||||
// Category and Move type folders are not valid move targets.
|
||||
// These folders are virtual. They don't exist on the server.
|
||||
public bool IsMoveTarget => !(SpecialFolderType == SpecialFolderType.More || SpecialFolderType == SpecialFolderType.Category);
|
||||
|
||||
public bool ContainsSpecialFolderType(SpecialFolderType type)
|
||||
{
|
||||
if (SpecialFolderType == type)
|
||||
return true;
|
||||
|
||||
foreach (var child in ChildFolders)
|
||||
{
|
||||
if (child.SpecialFolderType == type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return child.ContainsSpecialFolderType(type);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string ToString() => FolderName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
public class MergedInbox
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
public record SystemFolderConfiguration(MailItemFolder SentFolder,
|
||||
MailItemFolder DraftFolder,
|
||||
MailItemFolder ArchiveFolder,
|
||||
MailItemFolder TrashFolder,
|
||||
MailItemFolder JunkFolder);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using SQLite;
|
||||
using Wino.Core.Domain.Models.Authentication;
|
||||
|
||||
namespace Wino.Core.Domain.Entities
|
||||
{
|
||||
public class TokenInformation : TokenInformationBase
|
||||
{
|
||||
[PrimaryKey]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
public void RefreshTokens(TokenInformationBase tokenInformationBase)
|
||||
{
|
||||
if (tokenInformationBase == null)
|
||||
throw new ArgumentNullException(nameof(tokenInformationBase));
|
||||
|
||||
AccessToken = tokenInformationBase.AccessToken;
|
||||
RefreshToken = tokenInformationBase.RefreshToken;
|
||||
ExpiresAt = tokenInformationBase.ExpiresAt;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user