Exemple #1
0
                private void ZProcessListMailbox(cResponseDataListMailbox pListMailbox, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cMailboxCache), nameof(ZProcessListMailbox));

                    var lItem = ZItem(pListMailbox.MailboxName);

                    lItem.SetListFlags(new cListFlags(mSequence++, pListMailbox.Flags), lContext);

                    if (mCapabilities.ListExtended)
                    {
                        if ((mMailboxCacheDataItems & fMailboxCacheDataItems.subscribed) != 0)
                        {
                            lItem.SetLSubFlags(new cLSubFlags(mSequence++, (pListMailbox.Flags & fListFlags.subscribed) != 0), lContext);
                        }
                        else if ((pListMailbox.Flags & fListFlags.subscribed) != 0)
                        {
                            lItem.SetLSubFlags(new cLSubFlags(mSequence++, true), lContext);
                        }
                    }
                }
Exemple #2
0
                public bool Process(cBytesCursor pCursor, out cResponseData rResponseData, cTrace.cContext pParentContext)
                {
                    var lContext = pParentContext.NewMethod(nameof(cResponseDataParserList), nameof(Process));

                    if (!pCursor.SkipBytes(kListSpace))
                    {
                        rResponseData = null; return(false);
                    }

                    if (!pCursor.GetFlags(out var lFlags) ||
                        !pCursor.SkipByte(cASCII.SPACE) ||
                        !pCursor.GetMailboxDelimiter(out var lDelimiter) ||
                        !pCursor.SkipByte(cASCII.SPACE) ||
                        !pCursor.GetAString(out IList <byte> lEncodedMailboxPath) ||
                        !ZProcessExtendedItems(pCursor, out var lExtendedItems) ||
                        !pCursor.Position.AtEnd)
                    {
                        lContext.TraceWarning("likely malformed list response");
                        rResponseData = null;
                        return(true);
                    }

                    if (lEncodedMailboxPath.Count == 0)
                    {
                        if (lFlags.Count == 0 && lExtendedItems.Count == 0)
                        {
                            if (lDelimiter == null)
                            {
                                rResponseData = new cResponseDataListDelimiter();
                            }
                            else
                            {
                                rResponseData = new cResponseDataListDelimiter((char)lDelimiter.Value);
                            }
                        }
                        else
                        {
                            lContext.TraceWarning("likely malformed list delimiter response");
                            rResponseData = null;
                        }
                    }
                    else
                    {
                        if (cMailboxName.TryConstruct(lEncodedMailboxPath, lDelimiter, mUTF8Enabled, out var lMailboxName))
                        {
                            fListFlags lListFlags = 0;

                            if (lFlags.Contains(@"\Noinferiors", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.noinferiors | fListFlags.hasnochildren;
                            }
                            if (lFlags.Contains(@"\Noselect", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.noselect;
                            }
                            if (lFlags.Contains(@"\Marked", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.marked;
                            }
                            if (lFlags.Contains(@"\Unmarked", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.unmarked;
                            }

                            if (lFlags.Contains(@"\NonExistent", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.noselect | fListFlags.nonexistent;
                            }
                            if (lFlags.Contains(@"\Subscribed", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.subscribed;
                            }
                            if (lFlags.Contains(@"\Remote", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.remote;
                            }
                            if (lFlags.Contains(@"\HasChildren", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.haschildren;
                            }
                            if (lFlags.Contains(@"\HasNoChildren", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.hasnochildren;
                            }

                            if (lFlags.Contains(@"\All", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.all;
                            }
                            if (lFlags.Contains(@"\Archive", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.archive;
                            }
                            if (lFlags.Contains(@"\Drafts", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.drafts;
                            }
                            if (lFlags.Contains(@"\Flagged", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.flagged;
                            }
                            if (lFlags.Contains(@"\Junk", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.junk;
                            }
                            if (lFlags.Contains(@"\Sent", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.sent;
                            }
                            if (lFlags.Contains(@"\Trash", StringComparer.InvariantCultureIgnoreCase))
                            {
                                lListFlags |= fListFlags.trash;
                            }

                            bool lHasSubscribedChildren = false;

                            foreach (var lItem in lExtendedItems)
                            {
                                if (lItem.Tag.Equals("childinfo", StringComparison.InvariantCultureIgnoreCase) && lItem.Value.Contains("subscribed", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    lHasSubscribedChildren = true;
                                    break;
                                }
                            }

                            rResponseData = new cResponseDataListMailbox(lMailboxName, lListFlags, lHasSubscribedChildren);
                        }
                        else
                        {
                            lContext.TraceWarning("likely malformed list mailbox response");
                            rResponseData = null;
                        }
                    }

                    return(true);
                }