Exemplo n.º 1
0
        public LoadedItemPart Load(StoreId objectId, IStorePropertyBag propertyBagFromTree, HtmlStreamOptionCallback htmlCallback, PropertyDefinition[] propertyDefinitions, long bytesLoadedForConversation, bool isSmimeSupported, string domainName)
        {
            LoadedItemPart result;

            using (IItem item = this.xsoFactory.BindToItem(this.mailboxSession, objectId, propertyDefinitions))
            {
                ItemPartIrmInfo itemPartIrmInfo = this.GetItemPartIrmInfo(item);
                bool            isIrmEnabled    = itemPartIrmInfo != ItemPartIrmInfo.NotRestricted && this.canOpenIrmMessage;
                result = this.CreateLoadedItemPart(item, propertyBagFromTree, htmlCallback, propertyDefinitions, itemPartIrmInfo, isIrmEnabled, bytesLoadedForConversation, isSmimeSupported, domainName);
            }
            return(result);
        }
Exemplo n.º 2
0
        private LoadedItemPart CreateLoadedItemPart(IItem item, IStorePropertyBag propertyBagFromTree, HtmlStreamOptionCallback htmlCallback, PropertyDefinition[] additionalPropertyDefinitions, ItemPartIrmInfo itemPartIrmInfo, bool isIrmEnabled, long bytesLoadedForConversation, bool isSmimeSupported, string domainName)
        {
            ConversationBodyScanner bodyScanner = null;
            long bytesLoaded = 0L;

            PropertyDefinition[] loadedProperties = InternalSchema.Combine <PropertyDefinition>(this.queriedPropertyDefinitions, additionalPropertyDefinitions).ToArray <PropertyDefinition>();
            IStorePropertyBag    propertyBag      = this.CalculatePropertyBag(propertyBagFromTree, item, additionalPropertyDefinitions);
            BodyFragmentInfo     bodyFragmentInfo = null;
            bool didLoadSucceed = false;

            if (this.TryLoadBodyScanner(item, htmlCallback, bytesLoadedForConversation, isIrmEnabled, out bodyScanner, out bytesLoaded))
            {
                bodyFragmentInfo = new BodyFragmentInfo(bodyScanner);
                didLoadSucceed   = true;
            }
            AttachmentCollection attachmentCollection = item.AttachmentCollection;

            if (isIrmEnabled)
            {
                this.InitializeIrmInfo(item, itemPartIrmInfo, out attachmentCollection);
            }
            string itemClass = item.TryGetProperty(StoreObjectSchema.ItemClass) as string;

            if (isSmimeSupported && ObjectClass.IsSmimeClearSigned(itemClass))
            {
                this.InitializeSmimeInfo(item, domainName, out attachmentCollection);
            }
            return(new LoadedItemPart(item, propertyBag, bodyFragmentInfo, loadedProperties, itemPartIrmInfo, didLoadSucceed, bytesLoaded, attachmentCollection));
        }
Exemplo n.º 3
0
        private bool TryLoadBodyScanner(IItem item, HtmlStreamOptionCallback callback, long bytesLoadedForConversation, bool isIrmEnabled, out ConversationBodyScanner bodyScanner, out long bytesRead)
        {
            bodyScanner = null;
            Item item2 = null;

            bytesRead = 0L;
            Body body = item.Body;

            if (body == null)
            {
                ExTraceGlobals.ConversationTracer.TraceError(0L, "ConversationDataExtractor::LoadBodyScanner: ConversationItem has no body");
                return(false);
            }
            try
            {
                if (ObjectClass.IsSmime(item.ClassName) && !ObjectClass.IsSmimeClearSigned(item.ClassName) && item is MessageItem)
                {
                    if (ItemConversion.TryOpenSMimeContent((MessageItem)item, ConvertUtils.GetInboundConversionOptions(), out item2))
                    {
                        body = item2.Body;
                    }
                }
                else if (isIrmEnabled)
                {
                    body = this.GetBodyFromRightsManagedMessageItem(item);
                }
                if (body != null)
                {
                    if (callback != null)
                    {
                        KeyValuePair <HtmlStreamingFlags, HtmlCallbackBase> keyValuePair = callback((Item)item);
                        bodyScanner = body.GetConversationBodyScanner(keyValuePair.Value, ConversationDataExtractor.MaxBytesForConversation, bytesLoadedForConversation, true, keyValuePair.Key == HtmlStreamingFlags.FilterHtml, out bytesRead);
                    }
                    else
                    {
                        bodyScanner = body.GetConversationBodyScanner(null, ConversationDataExtractor.MaxBytesForConversation, bytesLoadedForConversation, true, true, out bytesRead);
                    }
                }
                else
                {
                    ExTraceGlobals.ConversationTracer.TraceError(0L, "ConversationDataExtractor::LoadBodyScanner: ConversationItem has no body");
                }
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.ConversationTracer.TraceError(0L, "ObjectNotFoundException thrown from ConversationDataExtractor::LoadBodyScanner");
                bodyScanner = null;
                bytesRead   = 0L;
            }
            catch (TextConvertersException)
            {
                ExTraceGlobals.ConversationTracer.TraceError(0L, "TextConvertersException thrown from Body::GetConversationBodyScanner");
                bodyScanner = null;
                bytesRead   = 0L;
            }
            catch (MessageLoadFailedInConversationException)
            {
                ExTraceGlobals.ConversationTracer.TraceError(0L, "MessageLoadFailedInConversationException thrown from Body::GetConversationBodyScanner");
                bodyScanner = null;
                bytesRead   = 0L;
            }
            finally
            {
                if (item2 != null)
                {
                    item2.Dispose();
                    item2 = null;
                }
            }
            return(bodyScanner != null);
        }