コード例 #1
0
        /// <summary>sends STATUS command</summary>
        /// <remarks>valid in authenticated state</remarks>
        private ImapCommandResult StatusInternal(string mailboxName, ImapStatusDataItem statusDataItem, out ImapStatusAttributeList statusAttributes, out ImapMailbox statusMailbox)
        {
            RejectNonAuthenticatedState();

              RejectInvalidMailboxNameArgument(mailboxName);

              if (statusDataItem == null)
            throw new ArgumentNullException("statusDataItem");

              /*
               * 6.3.10. STATUS Command
               *
               *            Note: The STATUS command is intended to access the
               *            status of mailboxes other than the currently selected
               *            mailbox.  Because the STATUS command can cause the
               *            mailbox to be opened internally, and because this
               *            information is available by other means on the selected
               *            mailbox, the STATUS command SHOULD NOT be used on the
               *            currently selected mailbox.
               */
              var existStatusMailbox = mailboxManager.GetExist(mailboxName);

              if (existStatusMailbox != null) {
            if (existStatusMailbox == selectedMailbox)
              throw new ImapProtocolViolationException("the STATUS command SHOULD NOT be used on the currently selected mailbox");

            if (existStatusMailbox.IsUnselectable)
              throw new ImapProtocolViolationException("the STATUS command SHOULD NOT be used on the mailbox that has \\Noselect or \\NonExistent attribute");
              }

              statusAttributes = null;
              statusMailbox = null;

              using (var t = new StatusTransaction(connection)) {
            // mailbox name
            t.RequestArguments["mailbox name"] = new ImapMailboxNameString(mailboxName);

            // status data item names
            t.RequestArguments["status data item names"] = statusDataItem;

            if (ProcessTransaction(t).Succeeded) {
              statusMailbox = mailboxManager.GetExistOrCreate(mailboxName);

              statusAttributes = t.Result.Value;
              statusMailbox.UpdateStatus(statusAttributes);
            }
            else {
              ProcessMailboxRefferalResponse(t.Result.TaggedStatusResponse);
            }

            return t.Result;
              }
        }
コード例 #2
0
        /// <summary>sends STATUS command</summary>
        /// <remarks>valid in authenticated state</remarks>
        public ImapCommandResult Status(string mailboxName, ImapStatusDataItem statusDataItem, out ImapStatusAttributeList statusAttributes)
        {
            ImapMailbox discard;

              return StatusInternal(mailboxName, statusDataItem, out statusAttributes, out discard);
        }