private static bool TryCalculateConversationCreatorSid(ConversationCreatorHelper.ConversationCreatorDefinitionData definitionData, ConversationCreatorHelper.MessageDeliveryScenario messageDeliveryScenario, byte[] itemOwnerSID, out byte[] conversationCreatorSid, out bool updateAllConversationMessages)
        {
            updateAllConversationMessages = false;
            if (messageDeliveryScenario == ConversationCreatorHelper.MessageDeliveryScenario.DeliveringRootMessage || messageDeliveryScenario == ConversationCreatorHelper.MessageDeliveryScenario.Unknown)
            {
                conversationCreatorSid = itemOwnerSID;
                return(true);
            }
            if (messageDeliveryScenario == ConversationCreatorHelper.MessageDeliveryScenario.DeliveringOutOfOrderRootMessage)
            {
                conversationCreatorSid        = itemOwnerSID;
                updateAllConversationMessages = true;
                return(true);
            }
            Conversation conversation = definitionData.Conversation;

            conversationCreatorSid = conversation.ConversationCreatorSID;
            if (conversationCreatorSid == null)
            {
                IConversationTreeNode rootMessageNode = definitionData.Conversation.ConversationTree.RootMessageNode;
                if (rootMessageNode == null)
                {
                    return(false);
                }
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "ConversationCreatorHelper::TryCalculateConversationCreatorSid : Probably the conversation was created before we started tracking the ConversationCreatorSID or the conversation was created from a message sent by X-Prem user. ConversationID:{0}", conversation.ConversationId.ToString());
                conversationCreatorSid        = rootMessageNode.GetValueOrDefault <byte[]>(InternalSchema.SenderSID, null);
                updateAllConversationMessages = (conversationCreatorSid != null);
            }
            return(conversationCreatorSid != null);
        }
        public List <IConversationTreeNode> Sort(IConversationTreeNode rootNode, ConversationTreeSortOrder sortOrder)
        {
            List <IConversationTreeNode>          list          = new List <IConversationTreeNode>();
            PriorityQueue <IConversationTreeNode> priorityQueue = new PriorityQueue <IConversationTreeNode>();

            this.AddNodeAndUnrelatedChildrenRecursively(priorityQueue, rootNode);
            while (priorityQueue.Count() > 0)
            {
                IConversationTreeNode conversationTreeNode = priorityQueue.Dequeue();
                if (conversationTreeNode.HasData)
                {
                    conversationTreeNode.SortOrder = sortOrder;
                    list.Add(conversationTreeNode);
                }
                foreach (IConversationTreeNode conversationTreeNode2 in conversationTreeNode.ChildNodes)
                {
                    if (conversationTreeNode.GetRelationTo(conversationTreeNode2) != ConversationTreeNodeRelation.Unrelated)
                    {
                        this.AddNodeAndUnrelatedChildrenRecursively(priorityQueue, conversationTreeNode2);
                    }
                }
            }
            if (sortOrder == ConversationTreeSortOrder.TraversalChronologicalDescending)
            {
                list.Reverse();
            }
            return(list);
        }
        private bool SetBodySummary(IConversationTree conversationTree, ref IStorePropertyBag propertyBag, object summary, StoreObjectId storeId)
        {
            bool result = false;
            QueryResultPropertyBag queryResultPropertyBag = new QueryResultPropertyBag(propertyBag, ConversationDataExtractor.BodyPropertiesCanBeExtracted, new object[]
            {
                summary,
                summary
            });

            propertyBag = queryResultPropertyBag.AsIStorePropertyBag();
            IConversationTreeNode conversationTreeNode = null;

            conversationTree.TryGetConversationTreeNode(storeId, out conversationTreeNode);
            foreach (StoreObjectId storeObjectId in conversationTreeNode.ToListStoreObjectId())
            {
                if (storeObjectId.Equals(storeId))
                {
                    LoadedItemPart loadedItemPart;
                    if (this.loadedItemParts.TryGetValue(storeObjectId, out loadedItemPart))
                    {
                        loadedItemPart.AddBodySummary(summary);
                        result = true;
                    }
                    conversationTreeNode.UpdatePropertyBag(storeObjectId, propertyBag);
                }
            }
            return(result);
        }
        public ItemPart GetItemPart(IConversationTree conversationTree, StoreObjectId itemId)
        {
            IStorePropertyBag     propertyBag          = null;
            ItemPart              itemPart             = null;
            IConversationTreeNode conversationTreeNode = null;

            if (!conversationTree.TryGetConversationTreeNode(itemId, out conversationTreeNode) || !conversationTreeNode.TryGetPropertyBag(itemId, out propertyBag))
            {
                throw new ArgumentException("No ConversationTreeNode/PropertyBag can be found for the passed StoreObjectId");
            }
            if (!this.itemParts.TryGetValue(itemId, out itemPart))
            {
                this.LoadItemPart(conversationTree, propertyBag);
                itemPart = this.loadedItemParts[itemId];
            }
            if (itemPart is LoadedItemPart && !itemPart.DidLoadSucceed)
            {
                return(itemPart);
            }
            if (itemPart.UniqueFragmentInfo == null)
            {
                LoadedItemPart loadedItemPart = (LoadedItemPart)itemPart;
                ExtractionData extractionData;
                if (!this.CanSkipDiffing(conversationTree, loadedItemPart, out extractionData))
                {
                    BodyFragmentInfo parentBodyFragment = null;
                    if (conversationTreeNode.ParentNode.HasData)
                    {
                        StoreObjectId mainStoreObjectId = conversationTreeNode.ParentNode.MainStoreObjectId;
                        if (this.treeNodeBodyFragment.ContainsKey(mainStoreObjectId))
                        {
                            parentBodyFragment = this.treeNodeBodyFragment[mainStoreObjectId].Key;
                        }
                        else
                        {
                            LoadedItemPart loadedItemPart2 = null;
                            if (!this.loadedItemParts.TryGetValue(mainStoreObjectId, out loadedItemPart2))
                            {
                                IStorePropertyBag propertyBag2;
                                if (!conversationTreeNode.ParentNode.TryGetPropertyBag(mainStoreObjectId, out propertyBag2))
                                {
                                    throw new ArgumentException("No Property bag can be found for the passed StoreObjectId on the ParentNode");
                                }
                                this.LoadItemPart(conversationTree, propertyBag2);
                                loadedItemPart2 = this.loadedItemParts[mainStoreObjectId];
                            }
                            parentBodyFragment = loadedItemPart2.BodyFragmentInfo;
                        }
                    }
                    ConversationDataExtractor.DiffItemParts(parentBodyFragment, loadedItemPart);
                }
                else
                {
                    itemPart.UniqueFragmentInfo     = extractionData.ChildUniqueBody;
                    itemPart.DisclaimerFragmentInfo = extractionData.ChildDisclaimer;
                }
            }
            return(itemPart);
        }
        private bool CanExtractItemPart(IConversationTree conversationTree, IStorePropertyBag propertyBag, out ParticipantTable recipientTable, out List <Participant> replyToParticipants)
        {
            IConversationTreeNode treeNode = null;
            StoreObjectId         objectId = ((VersionedId)propertyBag.TryGetProperty(ItemSchema.Id)).ObjectId;

            recipientTable      = null;
            replyToParticipants = null;
            if (!conversationTree.TryGetConversationTreeNode(objectId, out treeNode))
            {
                throw new ArgumentException("No ConversationTreeNode can be found for the passed StorePropertyBag");
            }
            if (this.itemParts.ContainsKey(objectId))
            {
                return(true);
            }
            if (this.OnBeforeItemLoad != null)
            {
                LoadItemEventArgs loadItemEventArgs = new LoadItemEventArgs(treeNode, propertyBag);
                this.OnBeforeItemLoad(this, loadItemEventArgs);
                if (loadItemEventArgs.MessagePropertyDefinitions != null)
                {
                    foreach (PropertyDefinition propertyDefinition in loadItemEventArgs.MessagePropertyDefinitions)
                    {
                        ICollection <PropertyDefinition> requiredPropertyDefinitionsWhenReading = propertyDefinition.RequiredPropertyDefinitionsWhenReading;
                        foreach (PropertyDefinition propertyDefinition2 in requiredPropertyDefinitionsWhenReading)
                        {
                            if (!conversationTree.IsPropertyLoaded(propertyDefinition2) && !ConversationDataExtractor.nonNativePropertiesCanBeExtracted.Contains(propertyDefinition2) && !ConversationDataExtractor.BodyPropertiesCanBeExtracted.Contains(propertyDefinition2))
                            {
                                this.optimizationInfo.UpdateItemExtraPropertiesNeeded(objectId);
                                return(false);
                            }
                        }
                    }
                }
            }
            if (true.Equals(propertyBag.TryGetProperty(StoreObjectSchema.IsRestricted)))
            {
                this.optimizationInfo.UpdateItemIrmProtected(objectId);
                return(false);
            }
            if (true.Equals(propertyBag.TryGetProperty(InternalSchema.MapiHasAttachment)))
            {
                if (true.Equals(propertyBag.TryGetProperty(ItemSchema.HasAttachment)))
                {
                    this.optimizationInfo.UpdateItemAttachmentPresent(objectId);
                }
                this.optimizationInfo.UpdateItemMapiAttachmentPresent(objectId);
                return(false);
            }
            recipientTable      = new ParticipantTable();
            replyToParticipants = new List <Participant>();
            if (!this.TryExtractRecipients(propertyBag, recipientTable, replyToParticipants))
            {
                this.optimizationInfo.UpdateItemParticipantNotFound(objectId);
                return(false);
            }
            return(true);
        }
        private IConversationTreeNode GetEquivalentNodeFromFamilyTree(IConversationTreeNode nodeFromSelectedConversation)
        {
            IConversationTreeNode result = null;

            if (nodeFromSelectedConversation == null || !this.conversationFamilyTree.TryGetConversationTreeNode(nodeFromSelectedConversation.MainStoreObjectId, out result))
            {
                LocalizedString localizedString = ServerStrings.ExItemNotFoundInConversation((nodeFromSelectedConversation != null) ? nodeFromSelectedConversation.MainStoreObjectId : null, this.ConversationFamilyId);
                ExTraceGlobals.ConversationTracer.TraceError((long)this.GetHashCode(), localizedString);
                throw new ObjectNotFoundException(localizedString);
            }
            return(result);
        }
        private IConversationTreeNode GetEquivalentNodeFromConversationTree(StoreObjectId itemId)
        {
            IConversationTreeNode result = null;

            if (!this.conversationTree.TryGetConversationTreeNode(itemId, out result))
            {
                LocalizedString localizedString = ServerStrings.ExItemNotFoundInConversation(itemId, this.conversationTree.RootMessageNode.ConversationId);
                ExTraceGlobals.ConversationTracer.TraceError((long)this.GetHashCode(), localizedString);
                throw new ObjectNotFoundException(localizedString);
            }
            return(result);
        }
        private bool CanSkipDiffing(IConversationTree conversationTree, LoadedItemPart loadedItemPart, out ExtractionData extractionData)
        {
            extractionData = null;
            IConversationTreeNode conversationTreeNode;

            if (conversationTree.TryGetConversationTreeNode(loadedItemPart.ObjectId, out conversationTreeNode))
            {
                IConversationTreeNode parentNode = conversationTreeNode.ParentNode;
                return(parentNode != null && parentNode.HasData && this.IsBodyPartPresent(loadedItemPart.BodyFragmentInfo, parentNode.StorePropertyBags[0], out extractionData));
            }
            return(false);
        }
Example #9
0
        private IConversationTree BuildTree(IConversationTreeNode rootNode, IList <IConversationTreeNode> nodes = null, HashSet <PropertyDefinition> loadedProperties = null)
        {
            nodes            = (nodes ?? new List <IConversationTreeNode>());
            loadedProperties = (loadedProperties ?? new HashSet <PropertyDefinition>());
            ConversationTreeSortOrder sortOrder = ConversationTreeSortOrder.DeepTraversalAscending;

            foreach (IConversationTreeNode node in nodes)
            {
                rootNode.TryAddChild(node);
            }
            rootNode.SortChildNodes(sortOrder);
            return(this.InternalInstantiate(sortOrder, rootNode, nodes, loadedProperties));
        }
Example #10
0
        private List <IConversationTreeNode> MatchAllNodes(IList <StoreObjectId> storeIds)
        {
            List <IConversationTreeNode> list = new List <IConversationTreeNode>(0);

            foreach (StoreObjectId storeObjectId in storeIds)
            {
                IConversationTreeNode item = null;
                if (this.ConversationTree.TryGetConversationTreeNode(storeObjectId, out item))
                {
                    list.Add(item);
                }
            }
            return(list);
        }
        private List <IStorePropertyBag> GetChildNodesNotOnThreadTree(ConversationId conversationThreadId, StoreObjectId itemId)
        {
            IConversationTreeNode    equivalentNodeFromConversationTree = this.GetEquivalentNodeFromConversationTree(itemId);
            List <IStorePropertyBag> list = new List <IStorePropertyBag>();

            foreach (IConversationTreeNode conversationTreeNode in equivalentNodeFromConversationTree.ChildNodes)
            {
                if (!conversationTreeNode.ConversationThreadId.Equals(conversationThreadId))
                {
                    list.Add(conversationTreeNode.MainPropertyBag);
                }
            }
            return(list);
        }
        public IStorePropertyBag CalculateBackwardPropertyBag(StoreObjectId rootNodeId)
        {
            if (this.isSingleThreadConversation)
            {
                return(null);
            }
            IConversationTreeNode equivalentNodeFromConversationTree = this.GetEquivalentNodeFromConversationTree(rootNodeId);

            if (equivalentNodeFromConversationTree != this.conversationTree.RootMessageNode)
            {
                return(equivalentNodeFromConversationTree.ParentNode.MainPropertyBag);
            }
            return(null);
        }
 public void SyncConversationTreeNodesContent(IEnumerable <IConversationTreeNode> threadNodes)
 {
     foreach (IConversationTreeNode conversationTreeNode in threadNodes)
     {
         IConversationTreeNode equivalentNodeFromConversationTree = this.GetEquivalentNodeFromConversationTree(conversationTreeNode.MainStoreObjectId);
         foreach (StoreObjectId itemId in conversationTreeNode.ToListStoreObjectId())
         {
             IStorePropertyBag bag;
             if (equivalentNodeFromConversationTree.TryGetPropertyBag(itemId, out bag))
             {
                 conversationTreeNode.UpdatePropertyBag(itemId, bag);
             }
         }
     }
 }
        private IEnumerable <StoreObjectId> EnumerateBackwardInFamilyFromNode(IConversationTreeNode startNode)
        {
            if (startNode != null)
            {
                IConversationTreeNode nodeOnFamilyTree = this.GetEquivalentNodeFromFamilyTree(startNode);
                if (nodeOnFamilyTree != null && nodeOnFamilyTree != this.conversationFamilyTree.RootMessageNode)
                {
                    IConversationTreeNode ancestor = nodeOnFamilyTree.ParentNode;
                    while (ancestor != null && ancestor.HasData)
                    {
                        yield return(ancestor.MainStoreObjectId);

                        ancestor = ancestor.ParentNode;
                    }
                }
            }
            yield break;
        }
        private IStorePropertyBag CalculateBackwardPropertyBag(IConversationTreeNode rootNodeFromSelectedConversation)
        {
            if (this.IsSingleConversationFamily)
            {
                return(null);
            }
            if (rootNodeFromSelectedConversation == null)
            {
                return(null);
            }
            IConversationTreeNode equivalentNodeFromFamilyTree = this.GetEquivalentNodeFromFamilyTree(rootNodeFromSelectedConversation);

            if (equivalentNodeFromFamilyTree != this.conversationFamilyTree.RootMessageNode)
            {
                return(equivalentNodeFromFamilyTree.ParentNode.MainPropertyBag);
            }
            return(null);
        }
Example #16
0
        public IConversationTree Create(IEnumerable <IStorePropertyBag> queryResult, IEnumerable <PropertyDefinition> propertyDefinitions)
        {
            IConversationTreeNode rootNode = this.treeNodeFactory.CreateRootNode();

            if (queryResult == null)
            {
                return(this.BuildTree(rootNode, null, null));
            }
            Dictionary <UniqueItemHash, List <IStorePropertyBag> > dictionary = this.AggregateDuplicates(queryResult);
            IList <IConversationTreeNode> nodes   = this.InstantiateNodes(dictionary.Values);
            HashSet <PropertyDefinition>  hashSet = new HashSet <PropertyDefinition>();

            if (propertyDefinitions != null)
            {
                hashSet.AddRange(propertyDefinitions);
            }
            return(this.BuildTree(rootNode, nodes, hashSet));
        }
        private Dictionary <StoreObjectId, List <IStorePropertyBag> > CalculateForwardMessagePropertyBags(IConversationTree selectedConversationTree)
        {
            if (this.IsSingleConversationFamily)
            {
                return(null);
            }
            Dictionary <StoreObjectId, List <IStorePropertyBag> > dictionary = new Dictionary <StoreObjectId, List <IStorePropertyBag> >(selectedConversationTree.Count);
            ConversationId conversationId = this.ConversationId;

            foreach (IConversationTreeNode conversationTreeNode in selectedConversationTree)
            {
                IConversationTreeNode    equivalentNodeFromFamilyTree        = this.GetEquivalentNodeFromFamilyTree(conversationTreeNode);
                List <IStorePropertyBag> childNodesNotOnSelectedConversation = this.GetChildNodesNotOnSelectedConversation(conversationId, equivalentNodeFromFamilyTree);
                if (childNodesNotOnSelectedConversation.Count > 0)
                {
                    dictionary.Add(conversationTreeNode.MainStoreObjectId, childNodesNotOnSelectedConversation);
                }
            }
            return(dictionary);
        }
 private void SyncConversationTrees()
 {
     if (this.IsSingleConversationFamily)
     {
         return;
     }
     this.backwardMessagePropertyBag = null;
     this.forwardConversationRootMessagePropertyBags = null;
     foreach (IConversationTreeNode conversationTreeNode in this.selectedConversationTree)
     {
         IConversationTreeNode equivalentNodeFromFamilyTree = this.GetEquivalentNodeFromFamilyTree(conversationTreeNode);
         foreach (StoreObjectId itemId in conversationTreeNode.ToListStoreObjectId())
         {
             IStorePropertyBag bag;
             if (equivalentNodeFromFamilyTree.TryGetPropertyBag(itemId, out bag))
             {
                 conversationTreeNode.UpdatePropertyBag(itemId, bag);
             }
         }
     }
 }
 private MiniStateTreeNode(IConversationTreeNode conversationTreeNode, Func <StoreObjectId, long> idConverter, ICollection <IConversationTreeNode> nodesToExclude)
 {
     foreach (IConversationTreeNode conversationTreeNode2 in conversationTreeNode.ChildNodes)
     {
         if (nodesToExclude == null || !nodesToExclude.Contains(conversationTreeNode2))
         {
             this.ChildNodes.Add(new MiniStateTreeNode(conversationTreeNode2, idConverter, nodesToExclude));
         }
     }
     foreach (StoreObjectId arg in conversationTreeNode.ToListStoreObjectId())
     {
         try
         {
             long item = idConverter(arg);
             this.ItemIdHashes.Add(item);
         }
         catch (StoragePermanentException ex)
         {
             ExTraceGlobals.StorageTracer.TraceError(0L, ex.Message);
         }
     }
 }
Example #20
0
        // Token: 0x06001F8D RID: 8077 RVA: 0x000B5D14 File Offset: 0x000B3F14
        private void RenderConversationPartMetaDataExpandos(TextWriter writer, IConversationTreeNode current, Folder dataFolder, StoreObjectId currentFolderId, ExDateTime?lastDeliveryTime)
        {
            base.RenderMessageViewItemMetaDataExpandos(writer);
            if (lastDeliveryTime != null && this.DataSource.GetItemProperty <ExDateTime>(ItemSchema.ReceivedTime, ExDateTime.MinValue) == lastDeliveryTime)
            {
                writer.Write(" ");
                writer.Write("fLR");
                writer.Write("=");
                writer.Write(1);
            }
            if (current.ParentNode != null && current.ParentNode.ParentNode != null)
            {
                VersionedId versionedId = (VersionedId)current.ParentNode.StorePropertyBags[0].TryGetProperty(ItemSchema.Id);
                if (versionedId != null)
                {
                    writer.Write(" ");
                    writer.Write("pId");
                    writer.Write("=");
                    Utilities.HtmlEncode(Utilities.GetItemIdString(versionedId.ObjectId, dataFolder), writer);
                }
            }
            writer.Write(" ");
            writer.Write("fId");
            writer.Write("=");
            Utilities.HtmlEncode(currentFolderId.ToBase64String(), writer);
            StoreObjectId storeObjectId = base.UserContext.GetDeletedItemsFolderId((MailboxSession)dataFolder.Session).StoreObjectId;

            writer.Write(" ");
            writer.Write("fInDelItms");
            writer.Write("=");
            Utilities.HtmlEncode(currentFolderId.Equals(storeObjectId) ? "1" : "0", writer);
            bool flag = Utilities.IsDefaultFolderId(base.UserContext.MailboxSession, currentFolderId, DefaultFolderType.JunkEmail);

            writer.Write(" ");
            writer.Write("fJnk");
            writer.Write("=");
            writer.Write(flag ? "1" : "0");
        }
Example #21
0
        public void LoadItemParts(IConversationTree conversationTree, IList <StoreObjectId> storeIds, string searchString, CultureInfo cultureinfo, out List <IConversationTreeNode> nodes)
        {
            Util.ThrowOnNullOrEmptyArgument(storeIds, "storeIds");
            nodes = new List <IConversationTreeNode>(0);
            this.ConversationDataExtractor.LoadItemParts(conversationTree, new Collection <StoreObjectId>(storeIds));
            if (string.IsNullOrEmpty(searchString))
            {
                nodes = this.MatchAllNodes(storeIds);
                return;
            }
            IList <string> words = null;

            if (this.InternalTryAqsMatch(storeIds, searchString, cultureinfo, out words, out nodes))
            {
                return;
            }
            bool flag = false;

            foreach (StoreObjectId storeObjectId in storeIds)
            {
                ItemPart itemPart = this.ConversationDataExtractor.GetItemPart(conversationTree, storeObjectId);
                if (itemPart.UniqueFragmentInfo != null && itemPart.UniqueFragmentInfo.IsMatchFound(words))
                {
                    IConversationTreeNode item = null;
                    if (conversationTree.TryGetConversationTreeNode(storeObjectId, out item))
                    {
                        nodes.Add(item);
                        flag = true;
                    }
                }
            }
            if (!flag)
            {
                nodes = this.MatchAllNodes(storeIds);
            }
        }
        private void RecursiveLoadBodyFragments(IConversationTree conversationTree, IConversationTreeNode treeNode, ICollection <StoreObjectId> itemPartsToLoad, out bool forceParentLoadBodyFragment)
        {
            IStorePropertyBag storePropertyBag = null;
            StoreObjectId     storeObjectId    = null;

            forceParentLoadBodyFragment = false;
            if (treeNode.HasData)
            {
                foreach (IStorePropertyBag storePropertyBag2 in treeNode.StorePropertyBags)
                {
                    StoreObjectId objectId = ((VersionedId)storePropertyBag2.TryGetProperty(ItemSchema.Id)).ObjectId;
                    storePropertyBag = storePropertyBag2;
                    storeObjectId    = objectId;
                    if (itemPartsToLoad == null || itemPartsToLoad.Contains(objectId))
                    {
                        forceParentLoadBodyFragment = true;
                        break;
                    }
                }
            }
            BodyFragmentInfo bodyFragmentInfo = null;
            bool             flag             = false;
            bool             flag2            = false;

            foreach (IConversationTreeNode conversationTreeNode in treeNode.ChildNodes)
            {
                ConversationTreeNode conversationTreeNode2 = (ConversationTreeNode)conversationTreeNode;
                bool flag3;
                this.RecursiveLoadBodyFragments(conversationTree, conversationTreeNode2, itemPartsToLoad, out flag3);
                flag2 = (flag2 || flag3);
                if (storePropertyBag != null)
                {
                    if (this.itemParts.ContainsKey(storeObjectId))
                    {
                        flag             = true;
                        bodyFragmentInfo = (this.treeNodeBodyFragment.ContainsKey(treeNode.MainStoreObjectId) ? this.treeNodeBodyFragment[treeNode.MainStoreObjectId].Key : null);
                    }
                    else if (this.treeNodeBodyFragment.ContainsKey(conversationTreeNode2.MainStoreObjectId))
                    {
                        ExtractionData extractionData;
                        this.IsBodyPartPresent(this.treeNodeBodyFragment[conversationTreeNode2.MainStoreObjectId].Key, storePropertyBag, out extractionData);
                        if (extractionData != null && extractionData.BodyFragment != null)
                        {
                            if (!flag && extractionData.IsFormatReliable)
                            {
                                bodyFragmentInfo = extractionData.BodyFragment;
                                flag             = true;
                            }
                            else if (bodyFragmentInfo == null)
                            {
                                bodyFragmentInfo = extractionData.BodyFragment;
                            }
                        }
                    }
                }
            }
            if (!treeNode.HasData)
            {
                return;
            }
            bool flag4 = false;

            if (itemPartsToLoad != null && itemPartsToLoad.Contains(storeObjectId) && !flag)
            {
                flag4 = true;
            }
            else if (bodyFragmentInfo == null && (forceParentLoadBodyFragment || flag2))
            {
                flag4 = true;
            }
            if (flag4 && !this.loadedItemParts.ContainsKey(storeObjectId))
            {
                this.LoadItemPart(conversationTree, storePropertyBag);
            }
            if (this.loadedItemParts.ContainsKey(storeObjectId))
            {
                LoadedItemPart loadedItemPart = this.loadedItemParts[storeObjectId];
                if (this.InternalHasIrmFailed(storeObjectId))
                {
                    bodyFragmentInfo = null;
                }
                else
                {
                    bodyFragmentInfo = loadedItemPart.BodyFragmentInfo;
                    flag             = true;
                }
            }
            if (bodyFragmentInfo != null)
            {
                this.treeNodeBodyFragment[treeNode.MainStoreObjectId] = new KeyValuePair <BodyFragmentInfo, bool>(bodyFragmentInfo, flag);
            }
        }
 public ParticipantSet LoadReplyAllParticipants(IConversationTreeNode node)
 {
     return(this.dataExtractor.LoadReplyAllParticipants(this.selectedConversationTree, node));
 }
Example #24
0
 protected virtual IConversationTree InternalInstantiate(ConversationTreeSortOrder sortOrder, IConversationTreeNode rootNode, IList <IConversationTreeNode> nodes, HashSet <PropertyDefinition> loadedProperties)
 {
     return(new ConversationTree(sortOrder, rootNode, nodes, loadedProperties));
 }
Example #25
0
        // Token: 0x06001F8B RID: 8075 RVA: 0x000B5938 File Offset: 0x000B3B38
        private void RenderConversationPartRow(TextWriter writer, Folder contextFolder, Folder dataFolder, ExDateTime?lastDeliveryTime, int maximumIndentLevel)
        {
            IConversationTreeNode currentNode = this.ConversationPartsDataSource.GetCurrentNode();

            if (!ConversationUtilities.ShouldRenderItem(currentNode, (MailboxSession)dataFolder.Session))
            {
                return;
            }
            StoreObjectId itemProperty = this.DataSource.GetItemProperty <StoreObjectId>(StoreObjectSchema.ParentItemId);
            bool          flag         = (bool)this.DataSource.GetItemProperty <object>(MessageItemSchema.IsRead);
            bool          flag2        = !ConversationUtilities.IsLocalNode(currentNode);
            bool          flag3        = Utilities.IsDefaultFolderId((MailboxSession)dataFolder.Session, itemProperty, DefaultFolderType.DeletedItems);

            writer.Write("<div id=\"");
            writer.Write("ver");
            writer.Write("\" class=\"");
            writer.Write(flag2 ? "df " : string.Empty);
            writer.Write(flag ? string.Empty : "ur");
            writer.Write((this.DataSource.CurrentItem == this.DataSource.EndRange) ? " eclr" : string.Empty);
            writer.Write("\">");
            writer.Write("<div class=cData");
            ItemList2.RenderRowId(writer, this.DataSource.GetItemId());
            this.RenderConversationPartMetaDataExpandos(writer, currentNode, dataFolder, itemProperty, lastDeliveryTime);
            writer.Write(">");
            writer.Write("</div>");
            int num2;

            if (this.ConversationPartsDataSource.SortOrder == ConversationTreeSortOrder.DeepTraversalAscending || this.ConversationPartsDataSource.SortOrder == ConversationTreeSortOrder.DeepTraversalDescending)
            {
                IConversationTreeNode conversationTreeNode = currentNode;
                int num = 0;
                while (conversationTreeNode != null && num < maximumIndentLevel)
                {
                    num++;
                    conversationTreeNode = conversationTreeNode.ParentNode;
                }
                num2 = num * 4 + 18;
            }
            else
            {
                num2 = 22;
            }
            writer.Write("<div class=expc2 style=\"");
            writer.Write(base.UserContext.IsRtl ? "right:" : "left:");
            writer.Write(num2);
            writer.Write("px;width:");
            writer.Write(20);
            writer.Write("px;\">");
            base.RenderMessageIcon(writer);
            writer.Write("</div>");
            writer.Write("<div class=expc3 style=\"");
            writer.Write(base.UserContext.IsRtl ? "right:" : "left:");
            writer.Write(num2 + 20);
            writer.Write("px;\">");
            if (flag3)
            {
                writer.Write("<strike>");
            }
            base.RenderColumn(writer, ColumnId.From);
            if (flag3)
            {
                writer.Write("</strike>");
            }
            writer.Write("</div>");
            if (flag2)
            {
                base.UserContext.ClearFolderNameCache();
                writer.Write("<div class=\"expc4 df\">");
                base.RenderVLVAnchorOpen(writer);
                writer.Write(Utilities.HtmlEncode(base.UserContext.GetCachedFolderName(itemProperty, (MailboxSession)dataFolder.Session)));
                base.RenderVLVAnchorClose(writer);
                writer.Write("</div>");
            }
            else
            {
                writer.Write("<div class=\"expc4 r\">");
                base.RenderColumn(writer, ColumnId.DeliveryTime);
                writer.Write("</div>");
            }
            FlagStatus itemProperty2 = this.DataSource.GetItemProperty <FlagStatus>(ItemSchema.FlagStatus, FlagStatus.NotFlagged);

            writer.Write("<div class=\"c7");
            if (itemProperty2 != FlagStatus.NotFlagged)
            {
                writer.Write(" stky");
            }
            writer.Write("\" id=");
            writer.Write("divFlg");
            writer.Write(">");
            base.RenderColumn(writer, ColumnId.FlagDueDate);
            writer.Write("</div>");
            string[] itemProperty3 = this.DataSource.GetItemProperty <string[]>(ItemSchema.Categories, null);
            writer.Write("<div class=\"r c6");
            if (itemProperty3 != null && itemProperty3.Length > 0)
            {
                writer.Write(" stky");
            }
            writer.Write("\" id=");
            writer.Write("divCat");
            writer.Write(">");
            base.RenderColumn(writer, ColumnId.Categories);
            writer.Write("</div>");
            writer.Write("<div class=c5 style=\"text-decoration:none;\">");
            bool flag4 = base.RenderColumn(writer, ColumnId.Importance, false);

            base.RenderColumn(writer, ColumnId.HasAttachment, !flag4);
            writer.Write("</div>");
            base.RenderSelectionImage(writer);
            writer.Write("</div>");
        }
        public Stream GetData(BodyType type, long truncationSize, out long totalDataSize, out IEnumerable <AirSyncAttachmentInfo> attachments)
        {
            Item item = base.XsoItem as Item;

            attachments = null;
            if (item == null)
            {
                totalDataSize = 0L;
                return(null);
            }
            Stream stream;

            if (string.Equals(item.ClassName, "IPM.Note.SMIME", StringComparison.OrdinalIgnoreCase) && truncationSize != 0L)
            {
                string smimenotSupportedBodyHtml = XsoBodyPartProperty.GetSMIMENotSupportedBodyHtml(item.Session);
                stream        = new MemoryStream(Encoding.UTF8.GetBytes(smimenotSupportedBodyHtml));
                totalDataSize = stream.Length;
                return(stream);
            }
            switch (type)
            {
            case BodyType.None:
            case BodyType.PlainText:
            case BodyType.Rtf:
            case BodyType.Mime:
                throw new ConversionException(string.Format("Invalid body type requested: {0}", type));

            case BodyType.Html:
            {
                ConversationId valueOrDefault = item.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null);
                if (valueOrDefault == null)
                {
                    throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, null, false)
                          {
                              ErrorStringForProtocolLogger = "NoConversationIdForItem"
                          };
                }
                Conversation conversation;
                bool         orCreateConversation = Command.CurrentCommand.GetOrCreateConversation(valueOrDefault, true, out conversation);
                if (conversation == null)
                {
                    throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, null, false)
                          {
                              ErrorStringForProtocolLogger = "ConversationObjectLoadFailedForItem"
                          };
                }
                if (orCreateConversation)
                {
                    conversation.LoadItemParts(new List <StoreObjectId>
                        {
                            item.StoreObjectId
                        });
                }
                IConversationTreeNode conversationTreeNode = null;
                if (!conversation.ConversationTree.TryGetConversationTreeNode(item.StoreObjectId, out conversationTreeNode))
                {
                    AirSyncDiagnostics.TraceError <StoreObjectId>(ExTraceGlobals.AirSyncTracer, this, "Cannot find itemId {0} in conversation tree!", item.StoreObjectId);
                    totalDataSize = 0L;
                    return(null);
                }
                bool flag = false;
                AirSyncDiagnostics.FaultInjectionTracer.TraceTest <bool>(3970313533U, ref flag);
                if (flag)
                {
                    totalDataSize = 0L;
                    return(null);
                }
                ItemPart itemPart = conversation.GetItemPart(item.StoreObjectId);
                if (!itemPart.DidLoadSucceed)
                {
                    AirSyncDiagnostics.TraceError(ExTraceGlobals.AirSyncTracer, this, "ItemPart.DidLoadSucceed is false!");
                    stream        = null;
                    totalDataSize = 0L;
                    return(stream);
                }
                using (AirSyncStream airSyncStream = new AirSyncStream())
                {
                    try
                    {
                        using (HtmlWriter htmlWriter = new HtmlWriter(airSyncStream, Encoding.UTF8))
                        {
                            itemPart.WriteUniquePart(htmlWriter);
                            htmlWriter.Flush();
                        }
                    }
                    catch (TextConvertersException innerException)
                    {
                        throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, null, innerException, false);
                    }
                    airSyncStream.Seek(0L, SeekOrigin.Begin);
                    stream = new AirSyncStream();
                    uint streamHash;
                    StreamHelper.CopyStream(airSyncStream, stream, Encoding.UTF8, (int)truncationSize, true, out streamHash);
                    ((AirSyncStream)stream).StreamHash = (int)streamHash;
                    totalDataSize = ((truncationSize < 0L || airSyncStream.Length < truncationSize) ? stream.Length : airSyncStream.Length);
                    Dictionary <AttachmentId, AirSyncAttachmentInfo> dictionary = null;
                    if (itemPart.Attachments != null && itemPart.Attachments.Count > 0)
                    {
                        dictionary = itemPart.Attachments.ToDictionary((AttachmentInfo x) => x.AttachmentId, (AttachmentInfo x) => new AirSyncAttachmentInfo
                            {
                                AttachmentId = x.AttachmentId,
                                IsInline     = x.IsInline,
                                ContentId    = x.ContentId
                            });
                    }
                    Dictionary <AttachmentId, string> dictionary2;
                    Command.CurrentCommand.InlineAttachmentContentIdLookUp.TryGetValue(item.Id.ObjectId, out dictionary2);
                    if (dictionary2 != null)
                    {
                        if (dictionary != null)
                        {
                            foreach (KeyValuePair <AttachmentId, string> keyValuePair in dictionary2)
                            {
                                AirSyncAttachmentInfo airSyncAttachmentInfo;
                                if (dictionary.TryGetValue(keyValuePair.Key, out airSyncAttachmentInfo) && airSyncAttachmentInfo != null)
                                {
                                    airSyncAttachmentInfo.IsInline  = true;
                                    airSyncAttachmentInfo.ContentId = keyValuePair.Value;
                                }
                                else
                                {
                                    dictionary[keyValuePair.Key] = new AirSyncAttachmentInfo
                                    {
                                        AttachmentId = keyValuePair.Key,
                                        IsInline     = true,
                                        ContentId    = keyValuePair.Value
                                    };
                                }
                            }
                            attachments = dictionary.Values;
                        }
                        else
                        {
                            attachments = from inlineAttachment in dictionary2
                                          select new AirSyncAttachmentInfo
                            {
                                AttachmentId = inlineAttachment.Key,
                                IsInline     = true,
                                ContentId    = inlineAttachment.Value
                            };
                        }
                    }
                    else
                    {
                        attachments = ((dictionary != null) ? dictionary.Values : null);
                    }
                    return(stream);
                }
                break;
            }
            }
            stream        = null;
            totalDataSize = 0L;
            return(stream);
        }
 private void AddNodeAndUnrelatedChildrenRecursively(PriorityQueue <IConversationTreeNode> candidates, IConversationTreeNode targetNode)
 {
     candidates.Enqueue(targetNode);
     foreach (IConversationTreeNode conversationTreeNode in targetNode.ChildNodes)
     {
         if (targetNode.GetRelationTo(conversationTreeNode) == ConversationTreeNodeRelation.Unrelated)
         {
             this.AddNodeAndUnrelatedChildrenRecursively(candidates, conversationTreeNode);
         }
     }
 }
Example #28
0
 internal LoadItemEventArgs(IConversationTreeNode treeNode, IStorePropertyBag propertyBag)
 {
     this.treeNode    = treeNode;
     this.propertyBag = propertyBag;
 }
        private List <IStorePropertyBag> GetChildNodesNotOnSelectedConversation(ConversationId selectedConversationId, IConversationTreeNode node)
        {
            List <IStorePropertyBag> list = new List <IStorePropertyBag>();

            foreach (IConversationTreeNode conversationTreeNode in node.ChildNodes)
            {
                if (conversationTreeNode.ConversationId != null && !conversationTreeNode.ConversationId.Equals(selectedConversationId))
                {
                    list.Add(conversationTreeNode.MainPropertyBag);
                }
            }
            return(list);
        }
Example #30
0
 public bool ConversationNodeContainedInChildren(IConversationTreeNode node)
 {
     Util.ThrowOnNullOrEmptyArgument(node, "node");
     return(this.ConversationDataExtractor.ConversationNodeContainedInChildren(this.conversationTree, node));
 }