using System; using static Vanara.PInvoke.BITS; namespace Vanara.IO { /// Flags for ACL information to maintain when using SMB to download or upload a file. [Flags] public enum BackgroundCopyACLFlags { /// If set exclusively, BITS uses the default ACL information of the destination folder. None = BG_COPY_FILE.BG_COPY_FILE_NONE, /// /// If set, the file's owner information is maintained. Otherwise, the user who calls the /// method owns the file. /// Owner = BG_COPY_FILE.BG_COPY_FILE_OWNER, /// /// If set, the file's group information is maintained. Otherwise, BITS uses the job owner's primary group to assign the group /// information to the file. /// Group = BG_COPY_FILE.BG_COPY_FILE_GROUP, /// /// If set, BITS copies the explicit ACEs from the source file and inheritable ACEs from the destination folder. Otherwise, BITS /// copies the inheritable ACEs from the destination folder. If the destination folder does not contain inheritable ACEs, BITS uses /// the default DACL from the owner's account. /// Dacl = BG_COPY_FILE.BG_COPY_FILE_DACL, /// /// If set, BITS copies the explicit ACEs from the source file and inheritable ACEs from the destination folder. Otherwise, BITS /// copies the inheritable ACEs from the destination folder. /// Sacl = BG_COPY_FILE.BG_COPY_FILE_SACL, /// If set, BITS copies the owner and ACL information. This is the same as setting all the flags individually. All = BG_COPY_FILE.BG_COPY_FILE_ALL } /// Defines the constant values that specify the BITS cost state. [Flags] public enum BackgroundCopyCost : uint { /// Unrestricted. Unrestricted = BITS_COST_STATE.BITS_COST_STATE_UNRESTRICTED, /// Capped usage unknown. CappedUsageUnknown = BITS_COST_STATE.BITS_COST_STATE_CAPPED_USAGE_UNKNOWN, /// Below cap. BelowCap = BITS_COST_STATE.BITS_COST_STATE_BELOW_CAP, /// Near cap. NearCap = BITS_COST_STATE.BITS_COST_STATE_NEAR_CAP, /// Overcap charged. OvercapCharged = BITS_COST_STATE.BITS_COST_STATE_OVERCAP_CHARGED, /// Overcap throttled. OvercapThrottled = BITS_COST_STATE.BITS_COST_STATE_OVERCAP_THROTTLED, /// Usage-based. UsageBased = BITS_COST_STATE.BITS_COST_STATE_USAGE_BASED, /// Roaming Roaming = BITS_COST_STATE.BITS_COST_STATE_ROAMING, /// Ignore congestion. IgnoreCongestion = BITS_COST_STATE.BITS_COST_OPTION_IGNORE_CONGESTION, /// Reserved. Reserved = BITS_COST_STATE.BITS_COST_STATE_RESERVED, /// Transfer not roaming. TransferNotRoaming = BITS_COST_STATE.BITS_COST_STATE_TRANSFER_NOT_ROAMING, /// Transfer no surcharge. TransferNoSurcharge = BITS_COST_STATE.BITS_COST_STATE_TRANSFER_NO_SURCHARGE, /// Transfer standard. TransferStandard = BITS_COST_STATE.BITS_COST_STATE_TRANSFER_STANDARD, /// Transfer unrestricted. TransferUnrestricted = BITS_COST_STATE.BITS_COST_STATE_TRANSFER_UNRESTRICTED, /// Transfer always. TransferAlways = BITS_COST_STATE.BITS_COST_STATE_TRANSFER_ALWAYS, } /// Defines the constant values that specify the context in which the error occurred. public enum BackgroundCopyErrorContext { /// An error has not occurred. None = BG_ERROR_CONTEXT.BG_ERROR_CONTEXT_NONE, /// The error context is unknown. Unknown = BG_ERROR_CONTEXT.BG_ERROR_CONTEXT_UNKNOWN, /// The transfer queue manager generated the error. GeneralQueueManager = BG_ERROR_CONTEXT.BG_ERROR_CONTEXT_GENERAL_QUEUE_MANAGER, /// The error was generated while the queue manager was notifying the client of an event. QueueManagerNotification = BG_ERROR_CONTEXT.BG_ERROR_CONTEXT_QUEUE_MANAGER_NOTIFICATION, /// The error was related to the specified local file. For example, permission was denied or the volume was unavailable. LocalFile = BG_ERROR_CONTEXT.BG_ERROR_CONTEXT_LOCAL_FILE, /// The error was related to the specified remote file. For example, the URL was not accessible. RemoteFile = BG_ERROR_CONTEXT.BG_ERROR_CONTEXT_REMOTE_FILE, /// /// The transport layer generated the error. These errors are general transport failures (these errors are not specific to the /// remote file). /// GeneralTransport = BG_ERROR_CONTEXT.BG_ERROR_CONTEXT_GENERAL_TRANSPORT, /// The server application that BITS passed the upload file to generated an error while processing the upload file. RemoteApplication = BG_ERROR_CONTEXT.BG_ERROR_CONTEXT_REMOTE_APPLICATION } /// Defines the constant values that specify the authentication scheme to use when a proxy or server requests user authentication. public enum BackgroundCopyJobCredentialScheme { /// Basic is a scheme in which the user name and password are sent in clear-text to the server or proxy. Basic = BG_AUTH_SCHEME.BG_AUTH_SCHEME_BASIC, /// Digest is a challenge-response scheme that uses a server-specified data string for the challenge. Digest = BG_AUTH_SCHEME.BG_AUTH_SCHEME_DIGEST, /// /// Simple and Protected Negotiation protocol (Snego) is a challenge-response scheme that negotiates with the server or proxy to /// determine which scheme to use for authentication. Examples are the Kerberos protocol and NTLM. /// Negotiate = BG_AUTH_SCHEME.BG_AUTH_SCHEME_NEGOTIATE, /// /// NTLM is a challenge-response scheme that uses the credentials of the user for authentication in a Windows network environment. /// NTLM = BG_AUTH_SCHEME.BG_AUTH_SCHEME_NTLM, /// Passport is a centralized authentication service provided by Microsoft that offers a single logon for member sites. Passport = BG_AUTH_SCHEME.BG_AUTH_SCHEME_PASSPORT } /// Defines the constant values that specify whether the credentials are used for proxy or server user authentication requests. public enum BackgroundCopyJobCredentialTarget : uint { /// Undefined. Undefined = 0, /// Use credentials for server requests. Server = BG_AUTH_TARGET.BG_AUTH_TARGET_SERVER, /// Use credentials for proxy requests. Proxy = BG_AUTH_TARGET.BG_AUTH_TARGET_PROXY } /// Defines the constant values that specify the priority level of a job. public enum BackgroundCopyJobPriority { /// /// Transfers the job in the foreground. Foreground transfers compete for network bandwidth with other applications, which can /// impede the user's network experience. This is the highest priority level. /// Foreground = BG_JOB_PRIORITY.BG_JOB_PRIORITY_FOREGROUND, /// /// Transfers the job in the background with a high priority. Background transfers use idle network bandwidth of the client to /// transfer files. This is the highest background priority level. /// High = BG_JOB_PRIORITY.BG_JOB_PRIORITY_HIGH, /// /// Transfers the job in the background with a normal priority. Background transfers use idle network bandwidth of the client to /// transfer files. This is the default priority level. /// Normal = BG_JOB_PRIORITY.BG_JOB_PRIORITY_NORMAL, /// /// Transfers the job in the background with a low priority. Background transfers use idle network bandwidth of the client to /// transfer files. This is the lowest background priority level. /// Low = BG_JOB_PRIORITY.BG_JOB_PRIORITY_LOW } /// HTTP security flags that indicate which errors to ignore when connecting to the server. [Flags] public enum BackgroundCopyJobSecurity { /// Allows the server to redirect your request to another server. This is the default. AllowSilentRedirect = BG_HTTP_SECURITY.BG_HTTP_REDIRECT_POLICY_ALLOW_SILENT, /// Check the certificate revocation list (CRL) to verify that the server certificate has not been revoked. CheckCRL = BG_HTTP_SECURITY.BG_SSL_ENABLE_CRL_CHECK, /// Ignores errors caused when the certificate host name of the server does not match the host name in the request. IgnoreInvalidCerts = BG_HTTP_SECURITY.BG_SSL_IGNORE_CERT_CN_INVALID, /// Ignores errors caused by an expired certificate. IgnoreExpiredCerts = BG_HTTP_SECURITY.BG_SSL_IGNORE_CERT_DATE_INVALID, /// Ignore errors associated with an unknown certification authority (CA). IgnoreUnknownCA = BG_HTTP_SECURITY.BG_SSL_IGNORE_UNKNOWN_CA, /// Ignore errors associated with the use of a certificate. IgnoreWrongCertUsage = BG_HTTP_SECURITY.BG_SSL_IGNORE_CERT_WRONG_USAGE, /// Allows the server to redirect your request to another server. BITS updates the remote name with the final URL. AllowReportedRedirect = BG_HTTP_SECURITY.BG_HTTP_REDIRECT_POLICY_ALLOW_REPORT, /// /// Places the job in the fatal error state when the server redirects your request to another server. BITS updates the remote name /// with the redirected URL. /// DisallowRedirect = BG_HTTP_SECURITY.BG_HTTP_REDIRECT_POLICY_DISALLOW, /// /// Allows the server to redirect an HTTPS request to an HTTP URL. /// You can combine this flag with AllowSilentRedirect and AllowReportedRedirect. /// AllowHttpsToHttpRedirect = BG_HTTP_SECURITY.BG_HTTP_REDIRECT_POLICY_ALLOW_HTTPS_TO_HTTP, } /// Defines constant values for the different states of a job. public enum BackgroundCopyJobState { /// /// Specifies that the job is in the queue and waiting to run. If a user logs off while their job is transferring, the job /// transitions to the queued state. /// Queued = BG_JOB_STATE.BG_JOB_STATE_QUEUED, /// /// Specifies that BITS is trying to connect to the server. If the connection succeeds, the state of the job becomes Transferring; /// otherwise, the state becomes TransientError. /// Connecting = BG_JOB_STATE.BG_JOB_STATE_CONNECTING, /// Specifies that BITS is transferring data for the job. Transferring = BG_JOB_STATE.BG_JOB_STATE_TRANSFERRING, /// /// Specifies that the job is suspended (paused). To suspend a job, call the method. BITS /// automatically suspends a job when it is created. The job remains suspended until you call the , , or method. /// Suspended = BG_JOB_STATE.BG_JOB_STATE_SUSPENDED, /// /// Specifies that a non-recoverable error occurred (the service is unable to transfer the file). If the error, such as an /// access-denied error, can be corrected, call the method after the error is fixed. However, /// if the error cannot be corrected, call the method to cancel the job, or call the method to accept the portion of a download job that transferred successfully. /// Error = BG_JOB_STATE.BG_JOB_STATE_ERROR, /// /// Specifies that a recoverable error occurred. BITS will retry jobs in the transient error state based on the retry interval you /// specify (see ). The state of the job changes to if the job fails to make progress (see ). /// BITS does not retry the job if a network disconnect or disk lock error occurred (for example, chkdsk is running) or the /// MaxInternetBandwidth Group Policy is zero. /// TransientError = BG_JOB_STATE.BG_JOB_STATE_TRANSIENT_ERROR, /// /// Specifies that your job was successfully processed. You must call the method to /// acknowledge completion of the job and to make the files available to the client. /// Transferred = BG_JOB_STATE.BG_JOB_STATE_TRANSFERRED, /// /// Specifies that you called the method to acknowledge that your job completed successfully. /// Acknowledged = BG_JOB_STATE.BG_JOB_STATE_ACKNOWLEDGED, /// /// Specifies that you called the method to cancel the job (remove the job from the transfer queue). /// Cancelled = BG_JOB_STATE.BG_JOB_STATE_CANCELLED } /// Defines constant values that specify the type of transfer job, such as download. public enum BackgroundCopyJobType { /// Specifies that the job downloads files to the client. Download = BG_JOB_TYPE.BG_JOB_TYPE_DOWNLOAD, /// Specifies that the job uploads a file to the server. Upload = BG_JOB_TYPE.BG_JOB_TYPE_UPLOAD, /// Specifies that the job uploads a file to the server and receives a reply file from the server application. UploadReply = BG_JOB_TYPE.BG_JOB_TYPE_UPLOAD_REPLY } }