Ejemplo n.º 1
0
        public async Task ProcessAsync <T>(IMessageStateHandler <T> messageStateHandler, IPipelineInformation pipelineInformation, IMessageProcessor next, CancellationToken cancellationToken) where T : class, IMessage
        {
            IMessageAttachment attachment = null;
            var queueName = AutoMessageMapper.GetQueueName <T>();

            try
            {
                string attachmentId = null;
                if (typeof(ICommandWithAttachment).IsAssignableFrom(typeof(T)))
                {
                    attachmentId = AttachmentUtility.GetAttachmentIds(messageStateHandler.MessageProperties).FirstOrDefault();
                    if (!string.IsNullOrEmpty(attachmentId))
                    {
                        attachment = await _attachmentProvider.GetAttachmentAsync(queueName, attachmentId, cancellationToken).ConfigureAwait(false);

                        var message = (ICommandWithAttachment)await messageStateHandler.GetMessageAsync().ConfigureAwait(false);

                        message.Attachment = attachment;
                    }
                }

                await next.ProcessAsync(messageStateHandler, cancellationToken).ConfigureAwait(false);

                if (attachment != null)
                {
                    attachment.Stream?.Dispose();
                    await _attachmentProvider.DeleteAttachmentAsync(queueName, attachmentId, cancellationToken).ConfigureAwait(false);
                }
            }
            finally
            {
                attachment?.Stream?.Dispose();
            }
        }
Ejemplo n.º 2
0
        public void AddAttachmentToZip(AttachmentWellInfo attachmentWellInfo, UserContext userContext, HttpContext httpContext)
        {
            if (attachmentWellInfo == null)
            {
                throw new ArgumentNullException("attachmentWellInfo");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
            {
                this.hasEmbeddedItem = true;
            }
            bool   doNeedToFilterHtml = AttachmentUtility.DoNeedToFilterHtml(attachmentWellInfo.MimeType, attachmentWellInfo.FileExtension, attachmentWellInfo.AttachmentLevel, userContext);
            bool   isNotHtmlandNotXml = !AttachmentUtility.GetIsHtmlOrXml(attachmentWellInfo.MimeType, attachmentWellInfo.FileExtension);
            bool   doNotSniff         = AttachmentUtility.GetDoNotSniff(attachmentWellInfo.AttachmentLevel, userContext);
            string text = attachmentWellInfo.AttachmentName;

            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
            {
                text += attachmentWellInfo.FileExtension;
            }
            string text2 = this.ConditionZipEntryFileName(text);

            attachmentWellInfo.FileName = text2;
            ZipEntryAttachment value = new ZipEntryAttachment(text2, attachmentWellInfo, doNeedToFilterHtml, doNotSniff, isNotHtmlandNotXml);

            this.files.Add(text2, value);
        }
Ejemplo n.º 3
0
 public AttachmentWellInfo(AttachmentCollection collection, Attachment attachment, bool isJunkOrPhishing)
 {
     this.collection   = collection;
     this.attachmentId = attachment.Id;
     if (isJunkOrPhishing)
     {
         this.attachmentLevel = AttachmentPolicy.Level.Block;
     }
     else
     {
         this.attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(attachment, UserContextManager.GetUserContext());
     }
     this.attachmentType = attachment.AttachmentType;
     this.fileName       = attachment.FileName;
     if (this.attachmentType == AttachmentType.EmbeddedMessage)
     {
         using (Item itemAsReadOnly = ((ItemAttachment)attachment).GetItemAsReadOnly(null))
         {
             this.displayName = AttachmentUtility.GetEmbeddedAttachmentDisplayName(itemAsReadOnly);
         }
         this.fileExtension = ".msg";
     }
     else
     {
         this.displayName   = attachment.DisplayName;
         this.fileExtension = ((attachment.FileExtension == null) ? string.Empty : attachment.FileExtension);
     }
     this.isInline       = attachment.IsInline;
     this.attachmentSize = attachment.Size;
     this.attachmentName = AttachmentUtility.CalculateAttachmentName(this.displayName, this.fileName);
     this.mimeType       = AttachmentUtility.CalculateContentType(attachment);
     this.textCharset    = attachment.TextCharset;
 }
Ejemplo n.º 4
0
        public void WriteArchive(HttpContext httpContext)
        {
            AttachmentUtility.SetResponseHeadersForZipAttachments(httpContext, this.zipFileName);
            List <string> list = new List <string>();

            if (this.hasEmbeddedItem)
            {
                foreach (KeyValuePair <string, ZipEntryAttachment> keyValuePair in this.files)
                {
                    list.Add(keyValuePair.Key);
                }
            }
            foreach (ZipEntryAttachment zipEntryAttachment in this.files.Values)
            {
                bool flag = zipEntryAttachment.AttachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage;
                this.bytesWritten += zipEntryAttachment.WriteToStream(httpContext.Response.OutputStream, httpContext, this.blockStatus, this.bytesWritten, flag ? list : null);
            }
            long startOfDirectory = this.bytesWritten;

            foreach (ZipEntryAttachment zipEntryAttachment2 in this.files.Values)
            {
                this.bytesWritten += (long)((ulong)zipEntryAttachment2.WriteCentralDirectoryStructure(httpContext.Response.OutputStream));
            }
            long endOfDirectory = this.bytesWritten;

            this.WriteTrailer(httpContext.Response.OutputStream, startOfDirectory, endOfDirectory);
            httpContext.ApplicationInstance.CompleteRequest();
        }
Ejemplo n.º 5
0
        public SaveResult SaveContact()
        {
            foreach (ContactPropertyInfo contactPropertyInfo in ContactUtilities.AllContactProperties)
            {
                if (contactPropertyInfo == ContactUtilities.FileAsId || contactPropertyInfo == ContactUtilities.PostalAddressId || contactPropertyInfo == ContactUtilities.DefaultPhoneNumber)
                {
                    this.SetInt(contactPropertyInfo);
                }
                else if (contactPropertyInfo == ContactUtilities.WorkAddressStreet || contactPropertyInfo == ContactUtilities.HomeStreet || contactPropertyInfo == ContactUtilities.OtherStreet)
                {
                    this.SetText(contactPropertyInfo, 256);
                }
                else
                {
                    this.SetText(contactPropertyInfo);
                }
            }
            this.SetEmail(ContactUtilities.Email1EmailAddress);
            this.SetEmail(ContactUtilities.Email2EmailAddress);
            this.SetEmail(ContactUtilities.Email3EmailAddress);
            this.SetNotes();
            AttachmentUtility.PromoteInlineAttachments(this.contact);
            ConflictResolutionResult conflictResolutionResult = this.Contact.Save(SaveMode.ResolveConflicts);

            if (conflictResolutionResult.SaveStatus != SaveResult.IrresolvableConflict && this.IsExistingItem && Globals.ArePerfCountersEnabled)
            {
                OwaSingleCounters.ItemsUpdated.Increment();
            }
            return(conflictResolutionResult.SaveStatus);
        }
        // Token: 0x06001E1D RID: 7709 RVA: 0x000AE4A4 File Offset: 0x000AC6A4
        public static void RenderInfobar(TextWriter output, ArrayList attachmentList, SanitizedHtmlString errorInAttachments, UserContext userContext)
        {
            if (attachmentList == null)
            {
                return;
            }
            int count = attachmentList.Count;

            if (count <= 0 && errorInAttachments == null)
            {
                return;
            }
            Infobar infobar = new Infobar();

            if (errorInAttachments != null)
            {
                infobar.AddMessage(errorInAttachments, InfobarMessageType.Warning, AttachmentWell.AttachmentInfobarErrorHtmlTag);
            }
            bool flag = AttachmentUtility.IsLevelOneAndBlock(attachmentList);

            if (flag)
            {
                infobar.AddMessage(SanitizedHtmlString.FromStringId(-2118248931), InfobarMessageType.Informational, AttachmentWell.AttachmentInfobarHtmlTag);
            }
            infobar.Render(output);
        }
Ejemplo n.º 7
0
        public void CleanupUnlinkedAttachments()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "AttachmentEventHandler.CleanupUnlinkedAttachments");
            OwaStoreObjectId owaStoreObjectId = (OwaStoreObjectId)base.GetParameter("Id");
            string           changeKey        = (string)base.GetParameter("CK");
            string           bodyMarkup       = (string)base.GetParameter("BodyMarkup");

            using (Item item = Utilities.GetItem <Item>(base.UserContext, owaStoreObjectId, changeKey, new PropertyDefinition[0]))
            {
                if (base.UserContext.IsIrmEnabled)
                {
                    Utilities.IrmDecryptIfRestricted(item, base.UserContext, true);
                }
                item.OpenAsReadWrite();
                AttachmentUtility.RemoveUnlinkedInlineAttachments(item, bodyMarkup);
                ConflictResolutionResult conflictResolutionResult = item.Save(SaveMode.ResolveConflicts);
                if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict)
                {
                    throw new OwaEventHandlerException("Could not save item due to conflict resolution failure", LocalizedStrings.GetNonEncoded(-482397486), OwaEventHandlerErrorCode.ConflictResolution);
                }
                item.Load();
                this.RenderTotalAttachmentSize(item);
                base.WriteChangeKey(item);
            }
        }
Ejemplo n.º 8
0
        protected void CreateAttachmentHelpers(AttachmentWellType wellType)
        {
            if (JunkEmailUtilities.IsJunkOrPhishing(this.Item, this.IsEmbeddedItem, base.UserContext))
            {
                this.shouldRenderAttachmentWell = false;
                return;
            }
            this.attachmentWellRenderObjects = AttachmentWell.GetAttachmentInformation(this.Item, this.AttachmentLinks, base.UserContext.IsPublicLogon, this.IsEmbeddedItem);
            if (this.attachmentWellRenderObjects != null && this.attachmentWellRenderObjects.Count > 0 && Utilities.IsClearSigned(this.Item))
            {
                AttachmentUtility.RemoveSmimeAttachment(this.attachmentWellRenderObjects);
            }
            if (this.Item is Contact)
            {
                OwaForm.RemoveContactPhoto(this.attachmentWellRenderObjects);
            }
            InfobarRenderingHelper infobarRenderingHelper = new InfobarRenderingHelper(this.attachmentWellRenderObjects);

            if (wellType == AttachmentWellType.ReadOnly && infobarRenderingHelper.HasLevelOneAndBlock)
            {
                this.infobar.AddMessageText(string.Format(CultureInfo.InvariantCulture, LocalizedStrings.GetNonEncoded(-824680214), new object[]
                {
                    infobarRenderingHelper.FileNameStringForLevelOneAndBlock
                }), InfobarMessageType.Informational);
            }
            else if (wellType != AttachmentWellType.ReadOnly && infobarRenderingHelper.HasLevelOneAndBlock)
            {
                this.infobar.AddMessageLocalized(-2118248931, InfobarMessageType.Informational);
            }
            bool flag = AttachmentUtility.IsOutLine(this.attachmentWellRenderObjects);

            this.shouldRenderAttachmentWell = (wellType == AttachmentWellType.ReadWrite || (flag && wellType == AttachmentWellType.ReadOnly && (infobarRenderingHelper.HasLevelTwo || infobarRenderingHelper.HasLevelThree || infobarRenderingHelper.HasWebReadyFirst)));
        }
        // Token: 0x06000433 RID: 1075 RVA: 0x00023EB8 File Offset: 0x000220B8
        private void RemoveAttachments()
        {
            char[]    separator = ",".ToCharArray();
            ArrayList arrayList = new ArrayList();

            string[] array = base.Request.Form["dLst"].Split(separator);
            int      num   = array.Length;

            for (int i = 0; i < num; i++)
            {
                AttachmentId attachmentId = AttachmentId.Deserialize(array[i]);
                if (base.Item.AttachmentCollection.Contains(attachmentId))
                {
                    arrayList.Add(attachmentId);
                }
            }
            if (arrayList.Count > 0)
            {
                AttachmentUtility.RemoveAttachment(base.Item, arrayList);
                base.Item.Save(SaveMode.ResolveConflicts);
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.ItemsUpdated.Increment();
                }
            }
            base.Item.Load();
            this.changeKeyString = base.Item.Id.ChangeKeyAsBase64String();
        }
Ejemplo n.º 10
0
        //
        // Methods
        //
        public void AddRobotToContainer(ArcBaseRobot bot)
        {
            bool flag = AttachmentUtility.HasAttachment(bot, ThingDefOf.Fire);

            if (flag)
            {
                AttachmentUtility.GetAttachment(bot, ThingDefOf.Fire).Destroy(0);
            }
            bot.stances.CancelBusyStanceHard();
            bot.jobs.StopAll(false);
            bot.pather.StopDead();
            bool drafted = bot.Drafted;

            if (drafted)
            {
                bot.drafter.Drafted = false;
            }
            bool flag2 = !this.container.Contains(bot);

            if (flag2)
            {
                this.container.Add(bot);
            }
            List <Map> maps = Find.Maps;

            for (int i = 0; i < maps.Count; i++)
            {
                maps [i].designationManager.RemoveAllDesignationsOn(bot, false);
            }
            this.DespawnRobot(bot, false);
        }
        // Token: 0x06000716 RID: 1814 RVA: 0x000377E8 File Offset: 0x000359E8
        internal static int SendDocumentContentToHttpStream(HttpContext httpContext, Stream stream, string fileName, string fileExtension, string contentType)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            if (string.IsNullOrEmpty(fileName))
            {
                fileName = LocalizedStrings.GetNonEncoded(1797976510);
            }
            if (fileExtension == null)
            {
                fileExtension = string.Empty;
            }
            if (contentType == null)
            {
                contentType = string.Empty;
            }
            bool flag = AttachmentUtility.DoNeedToFilterHtml(contentType, fileExtension, AttachmentPolicy.Level.Unknown, OwaContext.Get(httpContext).UserContext);

            if (flag)
            {
                AttachmentUtility.UpdateContentTypeForNeedToFilter(out contentType, null);
            }
            return(AttachmentHandler.SendDocumentContentToHttpStream(httpContext, stream, fileName, fileExtension, contentType, false, null, BlockStatus.DontKnow, AttachmentPolicy.Level.Unknown, flag));
        }
Ejemplo n.º 12
0
 // Token: 0x06001E1B RID: 7707 RVA: 0x000AE464 File Offset: 0x000AC664
 internal static ArrayList GetAttachmentInformation(OwaStoreObjectId owaConversationId, ItemPart itemPart, bool isLoggedOnFromPublicComputer, bool isEmbeddedItem, bool forceEnableItemLink)
 {
     if (itemPart.Attachments == null || itemPart.Attachments.Count == 0)
     {
         return(null);
     }
     return(AttachmentUtility.GetAttachmentList(owaConversationId, itemPart, isLoggedOnFromPublicComputer, isEmbeddedItem, true, forceEnableItemLink));
 }
Ejemplo n.º 13
0
 internal void SetShouldRenderDownloadAllLink(ArrayList attachmentWellInfos)
 {
     if (!this.IsJunkOrPhishing && attachmentWellInfos != null && attachmentWellInfos.Count > 0)
     {
         this.downloadAllCount            = AttachmentUtility.GetCountForDownloadAttachments(attachmentWellInfos);
         this.shouldRenderDownloadAllLink = (this.downloadAllCount > 1);
     }
 }
Ejemplo n.º 14
0
 // Token: 0x06001E1A RID: 7706 RVA: 0x000AE43C File Offset: 0x000AC63C
 internal static ArrayList GetAttachmentInformation(Item item, IList <AttachmentLink> attachmentLinks, bool isLoggedOnFromPublicComputer, bool isEmbeddedItem, bool forceEnableItemLink)
 {
     if (item.AttachmentCollection == null)
     {
         return(null);
     }
     return(AttachmentUtility.GetAttachmentList(item, attachmentLinks, isLoggedOnFromPublicComputer, isEmbeddedItem, true, forceEnableItemLink));
 }
Ejemplo n.º 15
0
        private void ProcessPost()
        {
            string text       = base.Request.Form["mId"];
            string text2      = base.Request.Form["mCK"];
            string bodyMarkup = base.Request.Form["sHtmlBdy"];

            if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2))
            {
                this.item = Utilities.GetItem <Item>(base.UserContext, text, text2, new PropertyDefinition[0]);
                if (base.UserContext.IsIrmEnabled)
                {
                    Utilities.IrmDecryptIfRestricted(this.item, base.UserContext, true);
                }
            }
            else
            {
                StoreObjectType itemType = StoreObjectType.Message;
                string          text3    = base.Request.Form["iT"];
                int             num;
                if (text3 != null && int.TryParse(text3, NumberStyles.Integer, CultureInfo.InvariantCulture, out num))
                {
                    itemType = (StoreObjectType)num;
                }
                OwaStoreObjectId destinationFolderId = null;
                string           text4 = base.Request.Form["sFldId"];
                if (!string.IsNullOrEmpty(text4))
                {
                    destinationFolderId = OwaStoreObjectId.CreateFromString(text4);
                }
                this.item = Utilities.CreateImplicitDraftItem(itemType, destinationFolderId);
                this.item.Save(SaveMode.ResolveConflicts);
                this.item.Load();
                if (Globals.ArePerfCountersEnabled)
                {
                    OwaSingleCounters.ItemsCreated.Increment();
                }
            }
            this.attachmentLinks = new List <SanitizedHtmlString>(base.Request.Files.Count);
            if (!this.IsInline)
            {
                this.attachResult = AttachmentUtility.AddAttachment(this.item, base.Request.Files, base.UserContext, false, bodyMarkup);
            }
            else
            {
                this.attachResult = AttachmentUtility.AddAttachment(this.item, base.Request.Files, base.UserContext, true, bodyMarkup, out this.attachmentLinks);
            }
            this.item.Load();
            if (Globals.ArePerfCountersEnabled)
            {
                OwaSingleCounters.ItemsUpdated.Increment();
            }
            if (!this.IsInline)
            {
                this.attachmentWellRenderObjects = null;
                bool isPublicLogon = base.UserContext.IsPublicLogon;
                this.attachmentWellRenderObjects = AttachmentWell.GetAttachmentInformation(this.item, null, isPublicLogon);
            }
        }
Ejemplo n.º 16
0
        // Token: 0x06000225 RID: 549 RVA: 0x00013E08 File Offset: 0x00012008
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            applicationElement = ApplicationElement.NotSet;
            type   = string.Empty;
            action = string.Empty;
            state  = string.Empty;
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();
            Item item  = null;
            Item item2 = null;
            Item item3 = null;

            try
            {
                HttpContext httpContext = owaContext.HttpContext;
                UserContext userContext = owaContext.UserContext;
                item = ReplyForwardUtilities.GetItemForRequest(owaContext, out item2);
                if (!(item is CalendarItemBase) && !(item is MessageItem))
                {
                    item3 = ReplyForwardUtilities.CreateForwardMessageWithItemAttached(item, userContext);
                }
                else
                {
                    item3 = ReplyForwardUtilities.CreateForwardItem(BodyFormat.TextPlain, item, ReplyForwardFlags.None, userContext, Utilities.GetParentFolderId(item2, item));
                }
                AttachmentUtility.PromoteInlineAttachments(item3);
                item3.Save(SaveMode.ResolveConflicts);
                item3.Load();
                ReplyForwardUtilities.DeleteLevelOneAttachments(item3, userContext);
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type   = item3.ClassName;
                preFormActionResponse.Action = "Forward";
                preFormActionResponse.AddParameter("id", item3.Id.ObjectId.ToBase64String());
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
                if (item2 != null)
                {
                    item2.Dispose();
                    item2 = null;
                }
                if (item3 != null)
                {
                    item3.Dispose();
                    item3 = null;
                }
            }
            return(preFormActionResponse);
        }
Ejemplo n.º 17
0
        // Token: 0x06002C65 RID: 11365 RVA: 0x000F758C File Offset: 0x000F578C
        private void RenderTotalAttachmentSize(Item item)
        {
            AttachmentCollection attachmentCollection = Utilities.GetAttachmentCollection(item, false, base.UserContext);
            int totalAttachmentSize = AttachmentUtility.GetTotalAttachmentSize(attachmentCollection);

            this.SanitizingWriter.Write("<div id=attSz>");
            this.SanitizingWriter.Write(totalAttachmentSize);
            this.SanitizingWriter.Write("</div>");
        }
        public PreFormActionResponse Execute(OwaContext owaContext, out ApplicationElement applicationElement, out string type, out string state, out string action)
        {
            if (owaContext == null)
            {
                throw new ArgumentNullException("owaContext");
            }
            applicationElement = ApplicationElement.NotSet;
            type   = string.Empty;
            action = string.Empty;
            state  = string.Empty;
            PreFormActionResponse preFormActionResponse = new PreFormActionResponse();
            Item item  = null;
            Item item2 = null;
            Item item3 = null;

            try
            {
                HttpContext httpContext = owaContext.HttpContext;
                UserContext userContext = owaContext.UserContext;
                item = ReplyForwardUtilities.GetItemForRequest(owaContext, out item2);
                if (!(item is CalendarItemBase) && !(item is MessageItem))
                {
                    throw new OwaInvalidRequestException("Item is not supported for reply");
                }
                if (item is ReportMessage)
                {
                    Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(2128562495));
                }
                item3 = ReplyForwardUtilities.CreateReplyItem(BodyFormat.TextPlain, item, ReplyForwardFlags.None, userContext, null);
                AttachmentUtility.PromoteInlineAttachments(item3);
                item3.Save(SaveMode.ResolveConflicts);
                item3.Load();
                preFormActionResponse.ApplicationElement = ApplicationElement.Item;
                preFormActionResponse.Type   = "IPM.Note";
                preFormActionResponse.Action = "Reply";
                preFormActionResponse.AddParameter("id", item3.Id.ObjectId.ToBase64String());
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
                if (item2 != null)
                {
                    item2.Dispose();
                    item2 = null;
                }
                if (item3 != null)
                {
                    item3.Dispose();
                    item3 = null;
                }
            }
            return(preFormActionResponse);
        }
Ejemplo n.º 19
0
        private static void RenderAttachment(TextWriter output, AttachmentWellInfo attachmentInfoObject, UserContext userContext, ArrayList previousAttachmentDisplayNames)
        {
            ItemAttachment itemAttachment = null;
            Item           item           = null;
            string         value          = null;

            try
            {
                if (attachmentInfoObject.AttachmentType == AttachmentType.EmbeddedMessage)
                {
                    itemAttachment = (ItemAttachment)attachmentInfoObject.OpenAttachment();
                    item           = itemAttachment.GetItemAsReadOnly(new PropertyDefinition[]
                    {
                        TaskSchema.TaskType
                    });
                }
                if (item != null)
                {
                    value = Utilities.HtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(AttachmentUtility.GetEmbeddedAttachmentDisplayName(item), previousAttachmentDisplayNames, true));
                }
                else
                {
                    value = Utilities.HtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(attachmentInfoObject.AttachmentName, previousAttachmentDisplayNames, false));
                }
            }
            catch (ObjectNotFoundException)
            {
                return;
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
                if (itemAttachment != null)
                {
                    itemAttachment.Dispose();
                    itemAttachment = null;
                }
            }
            output.Write("<span id=\"spnAtmt\" tabindex=\"-1\">");
            output.Write(value);
            long size = attachmentInfoObject.Size;

            if (size > 0L)
            {
                output.Write(userContext.DirectionMark);
                output.Write(" ");
                output.Write(LocalizedStrings.GetHtmlEncoded(6409762));
                Utilities.RenderSizeWithUnits(output, size, true);
                output.Write(userContext.DirectionMark);
                output.Write(LocalizedStrings.GetHtmlEncoded(-1023695022));
            }
            output.Write("</span>");
        }
Ejemplo n.º 20
0
        // Token: 0x0600303A RID: 12346 RVA: 0x0011AC24 File Offset: 0x00118E24
        internal static bool IsWebReadyDocument(DocumentLibraryObjectId objectId, UserContext userContext)
        {
            IDocument document;

            try
            {
                document = DocumentLibraryUtilities.LoadDocumentLibraryItem(objectId, userContext);
            }
            catch (AccessDeniedException)
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI access is denied.");
                return(false);
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.DocumentsTracer.TraceDebug(0L, "URI object not found.");
                return(false);
            }
            if (document == null)
            {
                return(false);
            }
            PropertyDefinition propertyDefinition = null;

            if ((objectId.UriFlags & UriFlags.SharepointDocument) == UriFlags.SharepointDocument)
            {
                propertyDefinition = SharepointDocumentSchema.FileType;
            }
            else if ((objectId.UriFlags & UriFlags.UncDocument) == UriFlags.UncDocument)
            {
                propertyDefinition = UncDocumentSchema.FileType;
            }
            object obj = document.TryGetProperty(propertyDefinition);
            string mimeType;

            if (!(obj is PropertyError))
            {
                mimeType = (obj as string);
            }
            else
            {
                mimeType = string.Empty;
            }
            string fileName = Path.GetFileName(document.Uri.ToString());
            string fileExtension;

            if (string.IsNullOrEmpty(fileName))
            {
                fileExtension = string.Empty;
            }
            else
            {
                fileExtension = Path.GetExtension(fileName);
            }
            return(AttachmentUtility.IsWebReadyDocument(fileExtension, mimeType));
        }
        // Token: 0x0600071C RID: 1820 RVA: 0x00037B9C File Offset: 0x00035D9C
        private void ProcessAttachment(Attachment attachment, HttpContext httpContext, BlockStatus blockStatus)
        {
            if (attachment == null)
            {
                throw new ArgumentNullException("attachment");
            }
            OwaContext  owaContext  = OwaContext.Get(httpContext);
            UserContext userContext = owaContext.UserContext;
            Stream      stream      = null;

            try
            {
                StreamAttachmentBase streamAttachment = AttachmentUtility.GetStreamAttachment(attachment);
                if (streamAttachment == null)
                {
                    ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessAttachment: attachment is not derived from AttachmentStream");
                }
                else
                {
                    AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(streamAttachment, userContext);
                    if (attachmentLevel == AttachmentPolicy.Level.Block)
                    {
                        Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(-2000404449), LocalizedStrings.GetNonEncoded(-615885395));
                    }
                    else
                    {
                        string fileName = AttachmentUtility.CalculateAttachmentName(streamAttachment.DisplayName, streamAttachment.FileName);
                        string text     = streamAttachment.FileExtension;
                        if (text == null)
                        {
                            text = string.Empty;
                        }
                        string empty       = string.Empty;
                        bool   contentType = this.GetContentType(httpContext, streamAttachment, attachmentLevel, out empty);
                        bool   isInline    = this.GetIsInline(streamAttachment, attachmentLevel);
                        stream = AttachmentUtility.GetStream(streamAttachment);
                        if (stream == null)
                        {
                            ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessAttachment: Image conversion of OLE attachment failure");
                        }
                        else
                        {
                            AttachmentHandler.SendDocumentContentToHttpStream(httpContext, stream, fileName, text, empty, isInline, streamAttachment.TextCharset, blockStatus, attachmentLevel, contentType);
                        }
                    }
                }
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }
        }
        // Token: 0x060009F6 RID: 2550 RVA: 0x00045548 File Offset: 0x00043748
        private void CreateAttachmentInfobarHelper(ArrayList attachmentList)
        {
            if (attachmentList == null || attachmentList.Count <= 0)
            {
                return;
            }
            StringBuilder    stringBuilder    = new StringBuilder();
            int              num              = 0;
            UserContext      userContext      = UserContextManager.GetUserContext();
            AttachmentPolicy attachmentPolicy = userContext.AttachmentPolicy;

            foreach (object obj in attachmentList)
            {
                AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
                bool flag = AttachmentUtility.IsWebReadyDocument(attachmentWellInfo.FileExtension, attachmentWellInfo.MimeType);
                if (flag && (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Block || attachmentPolicy.ForceWebReadyDocumentViewingFirst))
                {
                    this.hasWebReadyFirst = true;
                }
                if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Block)
                {
                    this.hasLevelOne = true;
                    if (!flag)
                    {
                        this.hasLevelOneAndBlock = true;
                        num++;
                        if (num == 16)
                        {
                            stringBuilder.Append(",...");
                        }
                        else if (num <= 15)
                        {
                            if (num != 1)
                            {
                                stringBuilder.Append(", ");
                            }
                            stringBuilder.Append(attachmentWellInfo.AttachmentName);
                        }
                    }
                }
                else if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.ForceSave)
                {
                    this.hasLevelTwo = true;
                }
                else if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Allow)
                {
                    this.hasLevelThree = true;
                }
            }
            if (stringBuilder.Length > 0)
            {
                this.fileNameStringForLevelOneAndBlock = stringBuilder.ToString();
            }
        }
 // Token: 0x06001986 RID: 6534 RVA: 0x00095324 File Offset: 0x00093524
 private void WriteFileData(Stream inputStream, Stream outputStream, HttpContext httpContext, BlockStatus blockStatus)
 {
     uint[] array = new uint[3];
     if (this.CompressionMethod == 8)
     {
         array = AttachmentUtility.CompressAndWriteOutputStream(httpContext.Response.OutputStream, inputStream, true);
         this.attachmentBytesWritten = array[0];
         this.checkSum       = array[1];
         this.attachmentSize = (long)((ulong)array[2]);
         return;
     }
     this.attachmentBytesWritten = AttachmentUtility.WriteOutputStream(httpContext.Response.OutputStream, inputStream);
 }
        public void PromoteInlineAttachments()
        {
            MessageItem messageItem = null;

            try
            {
                bool flag  = base.IsParameterSet("Id");
                bool flag2 = false;
                if (flag)
                {
                    messageItem = base.GetRequestItem <MessageItem>(new PropertyDefinition[0]);
                }
                else
                {
                    messageItem = this.CreateNewMessageItem();
                }
                if (OwaContext.Current.UserContext.IsIrmEnabled)
                {
                    Utilities.IrmDecryptIfRestricted(messageItem, OwaContext.Current.UserContext, true);
                }
                if (base.IsParameterSet("Body") && (string)base.GetParameter("Body") != null)
                {
                    flag2 = AttachmentUtility.RemoveUnlinkedInlineAttachments(messageItem, (string)base.GetParameter("Body"));
                }
                bool flag3 = AttachmentUtility.PromoteInlineAttachments(messageItem);
                flag2 = (flag2 || flag3);
                if (flag2)
                {
                    messageItem.Load();
                    base.WriteChangeKey(messageItem);
                    if (flag3)
                    {
                        if (OwaContext.Current.UserContext.IsIrmEnabled)
                        {
                            Utilities.IrmDecryptIfRestricted(messageItem, OwaContext.Current.UserContext, true);
                        }
                        ArrayList attachmentInformation = AttachmentWell.GetAttachmentInformation(messageItem, null, base.UserContext.IsPublicLogon);
                        RenderingUtilities.RenderAttachmentItems(this.SanitizingWriter, attachmentInformation, base.UserContext);
                    }
                }
            }
            finally
            {
                if (messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
        }
        // Token: 0x0600042F RID: 1071 RVA: 0x00023760 File Offset: 0x00021960
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (base.OwaContext.FormsRegistryContext.Action != null)
            {
                this.action = base.OwaContext.FormsRegistryContext.Action;
            }
            if (string.IsNullOrEmpty(this.action))
            {
                this.messageIdString = Utilities.GetQueryStringParameter(base.Request, "id", true);
                this.changeKeyString = null;
            }
            else
            {
                this.messageIdString = Utilities.GetFormParameter(base.Request, "hidid", true);
                this.changeKeyString = Utilities.GetFormParameter(base.Request, "hidchk", true);
            }
            this.GetItem();
            string a;

            if ((a = this.action) != null)
            {
                if (!(a == "Add"))
                {
                    if (a == "Del")
                    {
                        if (Utilities.GetFormParameter(base.Request, "dLst", false) != null)
                        {
                            this.RemoveAttachments();
                        }
                    }
                }
                else
                {
                    this.AddAttachments();
                }
            }
            this.attachmentList = AttachmentWell.GetAttachmentInformation(base.Item, base.AttachmentLinks, base.UserContext.IsPublicLogon);
            if (base.Item is Contact)
            {
                OwaForm.RemoveContactPhoto(this.attachmentList);
            }
            CalendarItemBaseData userContextData = EditCalendarItemHelper.GetUserContextData(base.UserContext);

            if (userContextData != null && userContextData.Id != null && !string.IsNullOrEmpty("hidchk") && userContextData.Id.Equals(base.Item.Id.ObjectId) && userContextData.ChangeKey != this.changeKeyString)
            {
                userContextData.ChangeKey = this.changeKeyString;
            }
            this.levelOneFound = AttachmentUtility.IsLevelOneAndBlock(this.attachmentList);
        }
Ejemplo n.º 26
0
        internal static ArrayList GetAttachmentInformation(Item item, IList <AttachmentLink> attachmentLinks, bool isLoggedOnFromPublicComputer, bool isEmbeddedItem)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (item.AttachmentCollection == null)
            {
                return(null);
            }
            int       count     = item.AttachmentCollection.Count;
            ArrayList arrayList = new ArrayList();

            return(AttachmentUtility.GetAttachmentList(item, attachmentLinks, isLoggedOnFromPublicComputer, isEmbeddedItem, false));
        }
        // Token: 0x0600071F RID: 1823 RVA: 0x00037D98 File Offset: 0x00035F98
        private bool GetContentType(HttpContext httpContext, StreamAttachmentBase streamAttachment, AttachmentPolicy.Level level, out string contentType)
        {
            contentType = AttachmentUtility.CalculateContentType(streamAttachment);
            bool flag = AttachmentUtility.DoNeedToFilterHtml(contentType, streamAttachment.FileExtension, level, OwaContext.Get(httpContext).UserContext);

            if (string.IsNullOrEmpty(contentType) && this.IsVoiceMailAttachment(httpContext))
            {
                contentType = "audio/x-ms-wma";
            }
            else if (flag)
            {
                AttachmentUtility.UpdateContentTypeForNeedToFilter(out contentType, streamAttachment.TextCharset);
            }
            return(flag);
        }
 // Token: 0x06000718 RID: 1816 RVA: 0x000378E4 File Offset: 0x00035AE4
 private static void SetAttachmentResponseHeaders(HttpContext httpContext, string fileName, string contentType, bool isInline, AttachmentPolicy.Level level)
 {
     if (level == AttachmentPolicy.Level.ForceSave)
     {
         httpContext.Response.AppendHeader("X-Download-Options", "noopen");
     }
     AttachmentUtility.SetContentDispositionResponseHeader(httpContext, fileName, isInline);
     httpContext.Response.AppendHeader("Content-Type", contentType + "; authoritative=true;");
     if (isInline && OwaContext.Current.UserContext.IsPublicLogon)
     {
         Utilities.MakePageNoCacheNoStore(httpContext.Response);
         return;
     }
     httpContext.Response.Cache.SetExpires(AttachmentUtility.GetAttachmentExpiryDate());
 }
Ejemplo n.º 29
0
 // Token: 0x06002AE1 RID: 10977 RVA: 0x000F1A24 File Offset: 0x000EFC24
 protected void CreateAttachmentHelpers()
 {
     if (this.IrmItemHelper != null && this.IrmItemHelper.IsRestrictedButIrmFeatureDisabledOrDecryptionFailed)
     {
         this.shouldRenderAttachmentWell = false;
         return;
     }
     this.attachmentWellRenderObjects = AttachmentWell.GetAttachmentInformation(this.Message, base.AttachmentLinks, base.UserContext.IsPublicLogon, base.IsEmbeddedItem, base.ForceEnableItemLink);
     if (this.attachmentWellRenderObjects != null && this.attachmentWellRenderObjects.Count > 0 && this.IsSMimeItem)
     {
         AttachmentUtility.RemoveSmimeAttachment(this.attachmentWellRenderObjects);
     }
     base.SetShouldRenderDownloadAllLink(this.attachmentWellRenderObjects);
     this.shouldRenderAttachmentWell = RenderingUtilities.AddAttachmentInfobarMessages(base.Item, base.IsEmbeddedItem, base.ForceEnableItemLink, this.infobar, this.attachmentWellRenderObjects);
 }
Ejemplo n.º 30
0
 // Token: 0x06001E15 RID: 7701 RVA: 0x000AE356 File Offset: 0x000AC556
 public static void RenderAttachmentWell(TextWriter output, AttachmentWellType wellType, ArrayList attachmentList, UserContext userContext, bool isConversationAndIrmCopyRestricted)
 {
     if (output == null)
     {
         throw new ArgumentNullException("output");
     }
     if (userContext == null)
     {
         throw new ArgumentNullException("userContext");
     }
     if (wellType == AttachmentWellType.ReadOnly && AttachmentUtility.IsLevelOneAndBlockOnly(attachmentList))
     {
         return;
     }
     AttachmentWell.RenderAttachmentWell(output, wellType, attachmentList, userContext, false, isConversationAndIrmCopyRestricted);
 }