Ejemplo n.º 1
0
        private void WriteEntryIdReference(PropTagFolderMapping ptfm, byte[] folderId, FolderHierarchy.GetPropsDelegate getProps, FolderHierarchy.SetPropsDelegate setProps)
        {
            InboxNamedPropFolderMapping inboxNamedPropFolderMapping = ptfm as InboxNamedPropFolderMapping;
            PropTag propTag;

            if (inboxNamedPropFolderMapping != null)
            {
                propTag = this.MbxWrapper.NamedPropMapper.MapNamedProp(inboxNamedPropFolderMapping.NamedPropData, PropType.Binary);
            }
            else
            {
                propTag = ptfm.Ptag;
            }
            MrsTracer.Service.Debug("Writing WKF reference {0}: {1} -> {2}", new object[]
            {
                ptfm.WKFType,
                propTag,
                TraceUtils.DumpEntryId(folderId)
            });
            InboxIndexedFolderMapping inboxIndexedFolderMapping = ptfm as InboxIndexedFolderMapping;
            object value;

            if (inboxIndexedFolderMapping != null)
            {
                List <byte[]>   list  = new List <byte[]>();
                PropValueData[] array = getProps(new PropTag[]
                {
                    propTag
                });
                byte[][] array2 = array[0].Value as byte[][];
                if (array2 != null)
                {
                    list.AddRange(array2);
                }
                while (list.Count < inboxIndexedFolderMapping.EntryIndex + 1)
                {
                    list.Add(Array <byte> .Empty);
                }
                list[inboxIndexedFolderMapping.EntryIndex] = folderId;
                value = list.ToArray();
            }
            else
            {
                value = folderId;
            }
            PropValueData[] pvda = new PropValueData[]
            {
                new PropValueData(propTag, value)
            };
            setProps(pvda);
        }
Ejemplo n.º 2
0
        private void WriteWellKnownFolderReference(WellKnownFolderType wkfType, byte[] folderId)
        {
            WellKnownFolderMapping wellKnownFolderMapping = FolderHierarchyUtils.FindWKFMapping(wkfType, (int)this.Flags);
            PropTagFolderMapping   propTagFolderMapping   = wellKnownFolderMapping as PropTagFolderMapping;

            if (propTagFolderMapping != null)
            {
                if (propTagFolderMapping is MailboxRootFolderMapping)
                {
                    IDestinationMailbox mbx = this.MbxWrapper.Mailbox as IDestinationMailbox;
                    this.WriteEntryIdReference(propTagFolderMapping, folderId, (PropTag[] pta) => mbx.GetProps(pta), delegate(PropValueData[] pvda)
                    {
                        mbx.SetProps(pvda);
                    });
                    return;
                }
                if (propTagFolderMapping is InboxFolderMapping)
                {
                    this.WriteWellKnownFolderReferenceToFolder(WellKnownFolderType.Inbox, wkfType, propTagFolderMapping, folderId);
                    this.WriteWellKnownFolderReferenceToFolder(WellKnownFolderType.NonIpmSubtree, wkfType, propTagFolderMapping, folderId);
                    return;
                }
            }
            else
            {
                if (wellKnownFolderMapping is NamedFolderMapping)
                {
                    return;
                }
                MrsTracer.Service.Warning("Unable to write WKF reference {0} -> {1}", new object[]
                {
                    wkfType,
                    TraceUtils.DumpEntryId(folderId)
                });
            }
        }
Ejemplo n.º 3
0
        private void WriteWellKnownFolderReferenceToFolder(WellKnownFolderType targetFolderType, WellKnownFolderType wkfType, PropTagFolderMapping ptfm, byte[] folderId)
        {
            FolderMapping wellKnownFolder = this.GetWellKnownFolder(targetFolderType);

            if (wellKnownFolder == null && targetFolderType == WellKnownFolderType.NonIpmSubtree)
            {
                wellKnownFolder = this.GetWellKnownFolder(WellKnownFolderType.Root);
            }
            if (wellKnownFolder == null)
            {
                MrsTracer.Service.Warning("There's no {0} in the target mailbox, not writing WKF reference for {1}", new object[]
                {
                    targetFolderType,
                    wkfType
                });
            }
            IDestinationMailbox destinationMailbox = this.MbxWrapper.Mailbox as IDestinationMailbox;

            using (IDestinationFolder folder = destinationMailbox.GetFolder(wellKnownFolder.EntryId))
            {
                if (folder == null)
                {
                    MrsTracer.Service.Error("{0} disappeared??? Not writing WKF reference for {1}", new object[]
                    {
                        targetFolderType,
                        wkfType
                    });
                }
                else
                {
                    this.WriteEntryIdReference(ptfm, folderId, (PropTag[] pta) => folder.GetProps(pta), delegate(PropValueData[] pvda)
                    {
                        folder.SetProps(pvda);
                    });
                }
            }
        }