Esempio n. 1
0
        /// <summary>
        /// Set or update quota limits.
        /// </summary>
        /// <param name="mailboxFullName">
        /// Must be a full mailbox name.
        /// </param>
        /// <param name="storageLimit">
        /// Quota limit in kBytes for message storage or <c>0</c> for no storage limit.
        /// </param>
        /// <param name="messageLimit">
        /// Quota limit for messages or <c>0</c> for no message limit.
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/>
        /// </returns>
        /// <remarks>
        /// The <see cref="ZIMapServer.HasLimit"/> is checked to see if an 
        /// attempt to set a storage limit is ignored because the server does not
        /// support storage limits.  The same behaviour applies to message limits.
        /// In these cases no error status is returned.
        /// </remarks>
        public bool QuotaLimit(string mailboxFullName,
                               uint storageLimit, uint messageLimit)
        {
            if(factory == null) return false;
            if(string.IsNullOrEmpty(mailboxFullName))
                mailboxFullName = mailboxName;
            if(mailboxFullName == null) return false;

            ZIMapCommand.GetQuotaRoot gqr;
            string root;
            using(gqr = new ZIMapCommand.GetQuotaRoot(factory))
            {   gqr.Queue(mailboxFullName);
                if(!gqr.CheckSuccess("QuotaLimits failed: {1}")) return false;
                root = gqr.Roots[0];
            }

            if(!Server.HasLimit("storage")) storageLimit = 0;
            if(!Server.HasLimit("message")) messageLimit = 0;

            ZIMapCommand.SetQuota cmd;
            using(cmd = new ZIMapCommand.SetQuota(factory))
            {   StringBuilder sb = new StringBuilder();
                if(messageLimit > 0) sb.Append("MESSAGE " + messageLimit);
                if(storageLimit > 0)
                {   if(sb.Length > 0) sb.Append(' ');
                    sb.Append("STORAGE " + storageLimit);
                }
                cmd.Queue(root, sb.ToString());
                return cmd.CheckSuccess("QuotaLimits failed: {1}");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Return quota information for a single Mailbox.
        /// </summary>
        /// <param name="mailboxFullName">
        /// Must be a full mailbox name.
        /// </param>
        /// <param name="info">
        /// A structure that receives the returned quota information.
        /// </param>
        /// <returns>
        /// <c>true</c> on success.
        /// </returns>
        /// <remarks>
        /// The quota root name is not always the same as the mailbox name, see
        /// the description of the return value.
        /// </remarks>
        public bool QuotaInfos(string mailboxFullName, out QuotaInfo info)
        {
            if(factory == null)
                mailboxFullName = null;
            else if(string.IsNullOrEmpty(mailboxFullName))
                mailboxFullName = mailboxName;
            if(mailboxFullName == null)
            {   info = new QuotaInfo();
                return false;
            }

            ZIMapCommand.GetQuotaRoot gqr = new ZIMapCommand.GetQuotaRoot(factory);
            if(gqr != null) gqr.Queue(mailboxFullName);
            return QuotaInfos(gqr, out info);
        }