// Token: 0x06000620 RID: 1568 RVA: 0x00030A78 File Offset: 0x0002EC78
        public static void RenderReadBody(TextWriter output, Item item, OwaSafeHtmlCallbackBase callBack, bool isJunkOrPhishing)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (item == null)
            {
                return;
            }
            ReportMessage reportMessage = item as ReportMessage;
            bool          flag          = null != reportMessage;

            if (Utilities.IsOpaqueSigned(item))
            {
                MessageItem messageItem = item as MessageItem;
                Item        item2       = null;
                if (messageItem != null && ItemConversion.TryOpenSMimeContent(messageItem, OwaContext.Current.UserContext.Configuration.DefaultAcceptedDomain.Name, out item2))
                {
                    item = item2;
                }
            }
            if (item.Body == null || (flag && item.Body.Size <= 0L))
            {
                if (flag)
                {
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        Charset charset;
                        reportMessage.GenerateReportBody(memoryStream, out charset);
                        item.OpenAsReadWrite();
                        BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextHtml, charset.Name);
                        using (Stream stream = item.Body.OpenWriteStream(configuration))
                        {
                            memoryStream.Position = 0L;
                            memoryStream.WriteTo(stream);
                        }
                        goto IL_DC;
                    }
                }
                return;
            }
IL_DC:
            Body body = item.Body;

            if (!OwaContext.Current.UserContext.IsBasicExperience && OwaContext.Current.UserContext.IsIrmEnabled && Utilities.IsIrmRestrictedAndDecrypted(item))
            {
                body = ((RightsManagedMessageItem)item).ProtectedBody;
            }
            if (body.Size > 0L)
            {
                Markup markup = Markup.Html;
                if (isJunkOrPhishing)
                {
                    markup = Markup.PlainText;
                }
                BodyConversionUtilities.ConvertAndOutputBody(output, body, markup, callBack, false);
            }
        }
Example #2
0
        private void InitializeSmimeInfo(IItem item, string domainName, out AttachmentCollection attachmentCollection)
        {
            attachmentCollection = item.AttachmentCollection;
            MessageItem messageItem = item as MessageItem;
            Item        item2;

            if (messageItem != null && ItemConversion.TryOpenSMimeContent(messageItem, domainName, out item2))
            {
                attachmentCollection = item2.AttachmentCollection;
            }
        }
Example #3
0
 public byte[] CalculateBodyTag(out int latestMessagePartWordCount)
 {
     latestMessagePartWordCount = int.MinValue;
     if (this.IsBodyDefined && this.Size / 2048L <= 2048L)
     {
         try
         {
             ConversationBodyScanner conversationBodyScanner = this.GetConversationBodyScanner();
             latestMessagePartWordCount = conversationBodyScanner.CalculateLatestMessagePartWordCount();
             BodyFragmentInfo bodyFragmentInfo = new BodyFragmentInfo(conversationBodyScanner);
             return(bodyFragmentInfo.BodyTag.ToByteArray());
         }
         catch (TextConvertersException)
         {
             return(new byte[Body.BodyTagLength]);
         }
     }
     if (ObjectClass.IsSmime(this.coreItem.ClassName()) && !ObjectClass.IsSmimeClearSigned(this.coreItem.ClassName()))
     {
         Item item = null;
         try
         {
             InboundConversionOptions inboundConversionOptions = ConvertUtils.GetInboundConversionOptions();
             if (ItemConversion.TryOpenSMimeContent(this.coreItem, inboundConversionOptions, out item))
             {
                 return(item.Body.CalculateBodyTag(out latestMessagePartWordCount));
             }
         }
         finally
         {
             if (item != null)
             {
                 item.Dispose();
             }
         }
     }
     return(new byte[12]);
 }
Example #4
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);
        }