using System;

namespace AipGateway.AIP
{
    public class SetFileInfo
    {
        public int errorNo {  get; set; }
        public string errorMsg { get; set; } = string.Empty;

        public string lableGuid { get; set; } = string.Empty;
        public string templateGuid {  get; set; } = string.Empty;
        public string fileOwner {  get; set; } = string.Empty;
        public Int64 fileSize { get; set; }

        public string newFileName {  get; set; } = string.Empty;
        public string newFileOwner {  get; set; } = string.Empty;
        public string newFileLabelGuid { get; set; } = string.Empty;
        public string newFileTemplateGuid {  get; set; } = string.Empty;
        public Int64 newFileSize { get; set; }
    }

    public class AipFileInfo
    {
        public int errorCode { get; set; } = 0;
        public string errorMessage { get; set; } = string.Empty;

        public AipContentLabel Content{ get; set; }

        public AipLabel Label { get; set; }

        public AipProtection Protection { get; set; }

        public Int64 FileSize { get; set; }

        public string OutputFileName { get; set; }

        //public static implicit operator List<object>(AipFileInfo v)
        //{
        //    throw new NotImplementedException();
        //}
    }

    public enum AipAssignmentMethod
    {
        /// <summary>Label assignment method is standard</summary>
        Standard,
        /// <summary>Label assignment method is privileged</summary>
        Privileged,
        /// <summary>Label assignment method is automatic</summary>
        Auto,
    }

    public enum AipProtectionType
    {
        /// <summary>Protection was created from a template</summary>
        TemplateBased,
        /// <summary>Protection was created ad hoc</summary>
        Custom,
    }

    public class AipLabelInfo
    {
        /// <summary>The unique GUID for the label within the tenant</summary>
        public string LabelId { get; set; } = "";

        /// <summary>GUID of the tenant that owns the label</summary>
        public string TenantId { get; set; } = "";

    }

    public class AipProtectionDescriptor
    {
        /// <summary>The protection type</summary>
        public AipProtectionType ProtectionType { get; set; }

        /// <summary>Collection of users-to-roles mappings</summary>
        // public List<Microsoft.InformationProtection.UserRoles> UserRoles { get; set; }
        //
        // /// <summary>Collection of users-to-rights mappings</summary>
        // public List<Microsoft.InformationProtection.UserRights> UserRights { get; set; }

        /// <summary>
        /// The RMS template id for template protection, license id for adhoc protection, if any
        /// </summary>
        public string TemplateId { get; set; }

        /// <summary>
        /// Gets the Label info, if any
        /// This property will only be populated in ProtectionDescriptors for preexisting protected content. i.e. It is
        /// a field populated by the server at the moment protected content is consumed.
        /// </summary>
        public AipLabelInfo LabelInformation { get; set; }

        /// <summary>
        /// Gets the Label id, if any
        /// This property will only be populated in ProtectionDescriptors for preexisting protected content. i.e. It is
        /// a field populated by the server at the moment protected content is consumed.
        /// </summary>
        public string LabelId { get; set; }

        /// <summary>The owner of protection</summary>
        public string Owner { get; set; }

        /// <summary>
        /// Gets the content id
        /// Publishing licenses will have this identifier surrounded by curly braces "{}".
        /// Those braces are removed from the value returned here
        /// </summary>
        public string ContentId { get; set; }

        /// <summary>The protection name</summary>
        public string Name { get; set; }

        /// <summary>The protection description</summary>
        public string Description { get; set; }

        /// <summary>
        /// Whether or not protection allows offline content access (default = true)
        /// </summary>
        public bool AllowOfflineAccess { get; set; }

        /// <summary>Protection referrer address</summary>
        public string Referrer { get; set; }

        /// <summary>Protection expiration time</summary>
        public DateTime? ContentValidUntil { get; set; }

        /// <summary>App-specific data that was encrypted</summary>
        // public Dictionary<string, string> EncryptedAppData { get; set; }
        //
        // /// <summary>App-specific data that was signed</summary>
        // public Dictionary<string, string> SignedAppData { get; set; }

        /// <summary>The double key url</summary>
        public string DoubleKeyUrl { get; set; }
    }

    public class AipProtection
    {
        public AipProtectionDescriptor ProtectionDescriptor { get; set; }

        /// <summary>Email address of content owner</summary>
        public string Owner { get; set; }

        /// <summary>The user associated with the protection handler</summary>
        public string IssuedTo { get; set; }

        /// <summary>Whether or not the current user is the content owner</summary>
        public bool IsIssuedToOwner { get; set; }

        /// <summary>
        /// The unique identifier for the document/content
        /// Publishing licenses will have this identifier surrounded by curly braces "{}".
        /// Those braces are removed from the value returned here
        /// </summary>
        public string ContentId { get; set; }

        /// <summary> Whether or not protection handler uses deprecated crypto algorithms (ECB) for backward compatibility </summary>
        public bool UseDeprecatedAlgorithms { get; set; }

        /// <summary> Whether or not protection handler grants user 'audited extract' right </summary>
        public bool AuditedExtractAllowed { get; set; }

        /// <summary> The block size (in bytes) for the cipher mode used by this ProtectionHandler </summary>
        public long BlockSize { get; set; }
    }

    public class AipContentLabel
    {
        //public AipLabel Label { get; set; }
        public DateTime CreationTime { get; set; }

        /// <summary>The assignment method of the label.</summary>
        public AipAssignmentMethod AssignmentMethod { get; set; }

        /// <summary>Returns true if protection was applied by the label or not.</summary>
        public bool IsProtectionAppliedFromLabel { get; set; }
    }

}
