public void MoveTo(ImapMailboxInfo destinationMailbox, bool subscribe) { if (destinationMailbox == null) throw new ArgumentNullException("destinationMailbox"); destinationMailbox.ThrowIfCanNotHaveChild(); MoveTo(destinationMailbox.GetFullNameOf(mailbox.LeafName), subscribe); }
public void CopyTo(ImapMailboxInfo destinationMailbox) { CopyToCore(destinationMailbox); }
/* * RENAME */ public void MoveTo(ImapMailboxInfo destinationMailbox) { MoveTo(destinationMailbox, ImapClient.DefaultSubscription); }
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; }
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; }
internal void ThrowIfNotSelected(ImapMailboxInfo mailbox) { if (!IsSelected(mailbox)) throw new ImapMailboxClosedException(mailbox.FullName); }
public void MoveTo(ImapMailboxInfo destinationMailbox) { StoreCore(CopyToCore(destinationMailbox), markAsDeletedStoreDataItem); }
internal bool IsSelected(ImapMailboxInfo mailbox) { bool discard; return IsSelected(mailbox, out discard); }
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; }
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; }
public ImapOpenedMailboxInfo OpenMailbox(ImapMailboxInfo mailbox) { return OpenMailbox(mailbox, DefaultSelectReadOnly); }
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()); }
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")); }
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); }