/// <summary> /// Initialises a new instance with the specified item and sort direction. /// </summary> /// <param name="pItem"></param> /// <param name="pDesc">Indicates a descending sort.</param> public cSortItem(eSortItem pItem, bool pDesc) { Item = pItem; switch (pItem) { case eSortItem.received: Attribute = fMessageCacheAttributes.received; break; case eSortItem.cc: case eSortItem.sent: case eSortItem.from: case eSortItem.subject: case eSortItem.to: case eSortItem.displayfrom: case eSortItem.displayto: Attribute = fMessageCacheAttributes.envelope; break; case eSortItem.size: Attribute = fMessageCacheAttributes.size; break; default: throw new ArgumentOutOfRangeException(nameof(pItem)); } Desc = pDesc; }
public cMessageCacheItem(iMessageCache pMessageCache, int pCacheSequence) { mMessageCache = pMessageCache ?? throw new ArgumentNullException(nameof(pMessageCache)); mCacheSequence = pCacheSequence; if (pMessageCache.NoModSeq) { mAttributes = fMessageCacheAttributes.modseq; mModSeq = 0; } else { mAttributes = 0; mModSeq = null; } }
/// <summary> /// Initialises a new instance using the specified <see cref="cMessage"/> properties. /// </summary> /// <param name="pProperties">The message properties to cache the backing data for.</param> public cMessageCacheItems(fMessageProperties pProperties) { Attributes = 0; // see comments elsewhere as to why mdnsent is commented out if ((pProperties & (fMessageProperties.flags | fMessageProperties.answered | fMessageProperties.flagged | fMessageProperties.deleted | fMessageProperties.seen | fMessageProperties.draft | fMessageProperties.recent | /* fMessageProperties.mdnsent | */ fMessageProperties.forwarded | fMessageProperties.submitpending | fMessageProperties.submitted)) != 0) { Attributes |= fMessageCacheAttributes.flags; } if ((pProperties & (fMessageProperties.envelope | fMessageProperties.sent | fMessageProperties.subject | fMessageProperties.basesubject | fMessageProperties.from | fMessageProperties.sender | fMessageProperties.replyto | fMessageProperties.to | fMessageProperties.cc | fMessageProperties.bcc | fMessageProperties.inreplyto | fMessageProperties.messageid)) != 0) { Attributes |= fMessageCacheAttributes.envelope; } if ((pProperties & fMessageProperties.received) != 0) { Attributes |= fMessageCacheAttributes.received; } if ((pProperties & fMessageProperties.size) != 0) { Attributes |= fMessageCacheAttributes.size; } if ((pProperties & fMessageProperties.bodystructure | fMessageProperties.attachments | fMessageProperties.plaintextsizeinbytes) != 0) { Attributes |= fMessageCacheAttributes.bodystructure; } if ((pProperties & fMessageProperties.uid) != 0) { Attributes |= fMessageCacheAttributes.uid; } if ((pProperties & fMessageProperties.modseq) != 0) { Attributes |= fMessageCacheAttributes.modseq; } cHeaderFieldNameList lNames = new cHeaderFieldNameList(); if ((pProperties & fMessageProperties.references) != 0) { lNames.Add(kHeaderFieldName.References); } if ((pProperties & fMessageProperties.importance) != 0) { lNames.Add(kHeaderFieldName.Importance); } Names = new cHeaderFieldNames(lNames); }
public cResponseDataFetch(uint pMSN, fMessageCacheAttributes pAttributes, cFetchableFlags pFlags, cEnvelope pEnvelope, DateTime?pReceived, IList <byte> pRFC822, IList <byte> pRFC822Header, IList <byte> pRFC822Text, uint?pSize, cBodyPart pBody, cBodyPart pBodyStructure, IList <cBody> pBodies, uint?pUID, cHeaderFields pHeaderFields, IDictionary <string, uint> pBinarySizes, ulong?pModSeq) { MSN = pMSN; Attributes = pAttributes; Flags = pFlags; Envelope = pEnvelope; Received = pReceived; RFC822 = pRFC822 == null ? null : new cBytes(pRFC822); RFC822Header = pRFC822Header == null ? null : new cBytes(pRFC822Header); RFC822Text = pRFC822Text == null ? null : new cBytes(pRFC822Text); Size = pSize; Body = pBody; BodyStructure = pBodyStructure; Bodies = new ReadOnlyCollection <cBody>(pBodies); UID = pUID; HeaderFields = pHeaderFields; BinarySizes = new cBinarySizes(pBinarySizes); ModSeq = pModSeq; }
private void cmdAHSet_Click(object sender, EventArgs e) { if (!ValidateChildren(ValidationConstraints.Enabled)) { return; } fMessageCacheAttributes lAttributes = 0; if (chkAHEnvelope.Checked) { lAttributes |= fMessageCacheAttributes.envelope; } if (chkAHFlags.Checked) { lAttributes |= fMessageCacheAttributes.flags; } if (chkAHReceived.Checked) { lAttributes |= fMessageCacheAttributes.received; } if (chkAHSize.Checked) { lAttributes |= fMessageCacheAttributes.size; } if (chkAHUID.Checked) { lAttributes |= fMessageCacheAttributes.uid; } if (chkAHModSeq.Checked) { lAttributes |= fMessageCacheAttributes.modseq; } if (chkAHBodyStructure.Checked) { lAttributes |= fMessageCacheAttributes.bodystructure; } ZTryParseHeaderFieldNames(txtAHHeaderFieldNames.Text, out var lNames); mClient.DefaultMessageCacheItems = new cMessageCacheItems(lAttributes, lNames ?? cHeaderFieldNames.Empty); }
/// <summary> /// Gets the client-side and server-side requirements for this sort order. /// </summary> /// <param name="rSortDisplay">Gets set to <see langword="true"/> if <see cref="cCapabilities.SortDisplay"/> must be in use for the server to do the sort.</param> /// <returns>The set of message attributes required for the comparison implied by the value of this instance.</returns> public fMessageCacheAttributes Attributes(out bool rSortDisplay) { rSortDisplay = false; fMessageCacheAttributes lAttributes = 0; if (Items != null) { foreach (var lItem in Items) { lAttributes |= lItem.Attribute; if (lItem.Item == eSortItem.displayfrom || lItem.Item == eSortItem.displayto) { rSortDisplay = true; } } } return(lAttributes); }
public void Update(cResponseDataFetch lFetch, out fMessageCacheAttributes rAttributesSet, out fMessageProperties rPropertiesChanged) { rAttributesSet = ~mAttributes & lFetch.Attributes; rPropertiesChanged = 0; if ((rAttributesSet & fMessageCacheAttributes.flags) != 0) { Flags = lFetch.Flags; } else if (lFetch.Flags != null) { foreach (var lFlag in Flags.SymmetricDifference(lFetch.Flags)) { rAttributesSet |= fMessageCacheAttributes.flags; rPropertiesChanged |= fMessageProperties.flags | LMessageProperty(lFlag); } Flags = lFetch.Flags; } if ((rAttributesSet & fMessageCacheAttributes.envelope) != 0) { Envelope = lFetch.Envelope; } if ((rAttributesSet & fMessageCacheAttributes.received) != 0) { Received = lFetch.Received; } if ((rAttributesSet & fMessageCacheAttributes.size) != 0) { Size = lFetch.Size; } if ((rAttributesSet & fMessageCacheAttributes.body) != 0) { mBody = lFetch.Body; } if ((rAttributesSet & fMessageCacheAttributes.bodystructure) != 0) { BodyStructure = lFetch.BodyStructure; } if ((rAttributesSet & fMessageCacheAttributes.uid) != 0 && mMessageCache.UIDValidity != 0) { UID = new cUID(mMessageCache.UIDValidity, lFetch.UID.Value); } if (!mMessageCache.NoModSeq) { if ((rAttributesSet & fMessageCacheAttributes.modseq) != 0) { mModSeq = lFetch.ModSeq; } else if (lFetch.ModSeq != null && lFetch.ModSeq != mModSeq) { rAttributesSet |= fMessageCacheAttributes.modseq; rPropertiesChanged |= fMessageProperties.modseq; mModSeq = lFetch.ModSeq; } } HeaderFields += lFetch.HeaderFields; BinarySizes += lFetch.BinarySizes; mAttributes |= lFetch.Attributes; fMessageProperties LMessageProperty(string pFlag) { if (pFlag.Equals(kMessageFlag.Answered, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.answered); } if (pFlag.Equals(kMessageFlag.Flagged, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.flagged); } if (pFlag.Equals(kMessageFlag.Deleted, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.deleted); } if (pFlag.Equals(kMessageFlag.Seen, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.seen); } if (pFlag.Equals(kMessageFlag.Draft, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.draft); } if (pFlag.Equals(kMessageFlag.Recent, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.recent); } // see comments elsewhere as to why this is commented out //if (pFlag.Equals(kMessageFlagName.MDNSent, StringComparison.InvariantCultureIgnoreCase)) return fMessageProperties.mdnsent; if (pFlag.Equals(kMessageFlag.Forwarded, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.forwarded); } if (pFlag.Equals(kMessageFlag.SubmitPending, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.submitpending); } if (pFlag.Equals(kMessageFlag.Submitted, StringComparison.InvariantCultureIgnoreCase)) { return(fMessageProperties.submitted); } return(0); } }
/// <summary> /// Initialises a new instance using the specified IMAP message attributes and header field names. /// </summary> /// <param name="pAttributes"></param> /// <param name="pNames">Can't be <see langword="null"/>, may be empty.</param> public cMessageCacheItems(fMessageCacheAttributes pAttributes, cHeaderFieldNames pNames) { Attributes = pAttributes; Names = pNames ?? throw new ArgumentNullException(nameof(pNames)); }