コード例 #1
0
ファイル: ImapMailboxInfo.cs プロジェクト: pengyancai/cs-util
        public void MoveTo(ImapMailboxInfo destinationMailbox, bool subscribe)
        {
            if (destinationMailbox == null)
            throw new ArgumentNullException("destinationMailbox");

              destinationMailbox.ThrowIfCanNotHaveChild();

              MoveTo(destinationMailbox.GetFullNameOf(mailbox.LeafName), subscribe);
        }
コード例 #2
0
 public void CopyTo(ImapMailboxInfo destinationMailbox)
 {
     CopyToCore(destinationMailbox);
 }
コード例 #3
0
ファイル: ImapMailboxInfo.cs プロジェクト: pengyancai/cs-util
 /*
  * RENAME
  */
 public void MoveTo(ImapMailboxInfo destinationMailbox)
 {
     MoveTo(destinationMailbox, ImapClient.DefaultSubscription);
 }
コード例 #4
0
        private ImapSequenceSet CopyToCore(ImapMailboxInfo destinationMailbox)
        {
            if (destinationMailbox == null)
            throw new ArgumentNullException("destinationMailbox");
              if (!destinationMailbox.Exists)
            throw new ImapProtocolViolationException("destination mailbox is not existent");

              var sequenceOrUidSet = GetSequenceOrUidSet();

              if (sequenceOrUidSet.IsEmpty)
            return sequenceOrUidSet; // do nothing

              Mailbox.CheckSelected();
              Mailbox.CheckUidValidity(UidValidity, sequenceOrUidSet);

              PrepareOperation();

              Mailbox.ProcessResult(Client.Session.Copy(sequenceOrUidSet, destinationMailbox.Mailbox));

              return sequenceOrUidSet;
        }
コード例 #5
0
        private ImapSequenceSet CopyToCore(string destinationMailboxName, bool tryCreate, out ImapMailboxInfo createdMailboxInfo)
        {
            var sequenceOrUidSet = GetSequenceOrUidSet();

              createdMailboxInfo = null;

              if (sequenceOrUidSet.IsEmpty)
            return sequenceOrUidSet; // do nothing

              Mailbox.CheckSelected();
              Mailbox.CheckUidValidity(UidValidity, sequenceOrUidSet);

              PrepareOperation();

              ImapMailbox createdMailbox = null;

              if (tryCreate) {
            Mailbox.ProcessResult(Client.Session.Copy(sequenceOrUidSet,
                                                  ImapClient.GetValidatedMailboxName(destinationMailboxName),
                                                  out createdMailbox));
              }
              else {
            Mailbox.ProcessResult(Client.Session.Copy(sequenceOrUidSet,
                                                  ImapClient.GetValidatedMailboxName(destinationMailboxName)),
                              delegate(ImapResponseCode code) {
                                if (code == ImapResponseCode.TryCreate)
                                  throw new ImapMailboxNotFoundException(destinationMailboxName);
                                else
                                    return true;
                              });
              }

              if (createdMailbox != null) {
            // retrieve mailbox flags
            ImapClient.ThrowIfError(Client.Session.List(createdMailbox));

            createdMailboxInfo = new ImapMailboxInfo(Client, createdMailbox);
              }

              return sequenceOrUidSet;
        }
コード例 #6
0
 internal void ThrowIfNotSelected(ImapMailboxInfo mailbox)
 {
     if (!IsSelected(mailbox))
     throw new ImapMailboxClosedException(mailbox.FullName);
 }
コード例 #7
0
 public void MoveTo(ImapMailboxInfo destinationMailbox)
 {
     StoreCore(CopyToCore(destinationMailbox), markAsDeletedStoreDataItem);
 }
コード例 #8
0
        internal bool IsSelected(ImapMailboxInfo mailbox)
        {
            bool discard;

              return IsSelected(mailbox, out discard);
        }
コード例 #9
0
        internal bool IsSelected(ImapMailboxInfo mailbox, out bool readOnly)
        {
            var selected = Session.SelectedMailbox != null && string.Equals(Session.SelectedMailbox.Name, mailbox.Mailbox.Name);

              if (selected)
            readOnly = Session.SelectedMailbox.ReadOnly;
              else
            readOnly = false;

              return selected;
        }
コード例 #10
0
        public ImapOpenedMailboxInfo OpenMailbox(ImapMailboxInfo mailbox, bool readOnly)
        {
            if (mailbox == null)
            throw new ArgumentNullException("mailbox");
              if (!mailbox.Exists)
            throw new ImapProtocolViolationException("mailbox is not existent");
              else if (mailbox.IsUnselectable)
            throw new ImapProtocolViolationException("mailbox is not existent");

              if (ServerCapabilities.Has(ImapCapability.CondStore))
            ThrowIfError(readOnly
                     ? Session.ExamineCondStore(mailbox.FullName)
                     : Session.SelectCondStore(mailbox.FullName));
              else
            ThrowIfError(readOnly
                     ? Session.Examine(mailbox.FullName)
                     : Session.Select(mailbox.FullName));

              openedMailbox = new ImapOpenedMailboxInfo(this, Session.SelectedMailbox);

              return openedMailbox;
        }
コード例 #11
0
 public ImapOpenedMailboxInfo OpenMailbox(ImapMailboxInfo mailbox)
 {
     return OpenMailbox(mailbox, DefaultSelectReadOnly);
 }
コード例 #12
0
ファイル: ImapMailboxInfo.cs プロジェクト: pengyancai/cs-util
        private void GetMailboxesNoInferiorsOrNonHierarchical(ImapPseudoServer server, ImapMailboxInfo mailbox)
        {
            var mailboxes = mailbox.GetMailboxes();

              Assert.IsNotNull(mailboxes);

              var enumerator = mailboxes.GetEnumerator();

              Assert.IsNotNull(enumerator);
              Assert.IsFalse(enumerator.MoveNext());
        }
コード例 #13
0
ファイル: ImapMailboxInfo.cs プロジェクト: pengyancai/cs-util
        private void MoveToNewNameSubscribeCanNotHaveChild(ImapPseudoServer server, ImapMailboxInfo mailbox)
        {
            // RENAME
              server.EnqueueTaggedResponse("$tag OK done\r\n");
              // UNSUBSCRIBE
              server.EnqueueTaggedResponse("$tag OK done\r\n");
              // SUBSCRIBE
              server.EnqueueTaggedResponse("$tag OK done\r\n");

              mailbox.MoveTo("OldSent", true);

              Assert.That(server.DequeueRequest(), Text.EndsWith("RENAME \"Sent\" \"OldSent\"\r\n"));
              Assert.That(server.DequeueRequest(), Text.EndsWith("UNSUBSCRIBE \"Sent\"\r\n"));
              Assert.That(server.DequeueRequest(), Text.EndsWith("SUBSCRIBE \"OldSent\"\r\n"));
        }
コード例 #14
0
ファイル: ImapMailboxInfo.cs プロジェクト: pengyancai/cs-util
        private void MoveToDestinationMailboxDestinationCanNotHaveChild(ImapPseudoServer server, ImapMailboxInfo destMailbox)
        {
            // LIST
              server.EnqueueTaggedResponse("* LIST () \"/\" src\r\n" +
                                   "$tag OK done\r\n");

              var sourceMailbox = destMailbox.Client.GetMailbox("src");

              Assert.That(server.DequeueRequest(), Text.EndsWith("LIST \"\" \"src\"\r\n"));

              sourceMailbox.MoveTo(destMailbox);
        }