Ejemplo n.º 1
0
        public void MoveTo(ImapMailboxInfo destinationMailbox, bool subscribe)
        {
            if (destinationMailbox == null)
            throw new ArgumentNullException("destinationMailbox");

              destinationMailbox.ThrowIfCanNotHaveChild();

              MoveTo(destinationMailbox.GetFullNameOf(mailbox.LeafName), subscribe);
        }
Ejemplo n.º 2
0
 public void CopyTo(ImapMailboxInfo destinationMailbox)
 {
     CopyToCore(destinationMailbox);
 }
Ejemplo n.º 3
0
 /*
  * RENAME
  */
 public void MoveTo(ImapMailboxInfo destinationMailbox)
 {
     MoveTo(destinationMailbox, ImapClient.DefaultSubscription);
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 6
0
 internal void ThrowIfNotSelected(ImapMailboxInfo mailbox)
 {
     if (!IsSelected(mailbox))
     throw new ImapMailboxClosedException(mailbox.FullName);
 }
Ejemplo n.º 7
0
 public void MoveTo(ImapMailboxInfo destinationMailbox)
 {
     StoreCore(CopyToCore(destinationMailbox), markAsDeletedStoreDataItem);
 }
Ejemplo n.º 8
0
        internal bool IsSelected(ImapMailboxInfo mailbox)
        {
            bool discard;

              return IsSelected(mailbox, out discard);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 11
0
 public ImapOpenedMailboxInfo OpenMailbox(ImapMailboxInfo mailbox)
 {
     return OpenMailbox(mailbox, DefaultSelectReadOnly);
 }
Ejemplo n.º 12
0
        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());
        }
Ejemplo n.º 13
0
        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"));
        }
Ejemplo n.º 14
0
        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);
        }