Ejemplo n.º 1
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.º 2
0
        internal static void RenderAttachmentLinkForItem(TextWriter output, AttachmentWellInfo attachmentInfoObject, Item item, string itemId, UserContext userContext, ArrayList previousAttachmentDisplayNames, AttachmentWell.AttachmentWellFlags flags, bool prependSemicolon = false)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (attachmentInfoObject == null)
            {
                throw new ArgumentNullException("attachmentInfoObject");
            }
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            SanitizedHtmlString value;
            bool flag;

            if ((attachmentInfoObject.AttachmentLevel == AttachmentPolicy.Level.ForceSave || attachmentInfoObject.AttachmentLevel == AttachmentPolicy.Level.Allow) && AttachmentWell.AttachmentWellFlags.RenderEmbeddedItem == (flags & AttachmentWell.AttachmentWellFlags.RenderEmbeddedItem))
            {
                string format = string.Empty;
                if (attachmentInfoObject.AttachmentLevel == AttachmentPolicy.Level.Allow)
                {
                    format = "<a id=\"{0}\" href=\"#\" onclick=\"{1}\" title=\"{2}\" oncontextmenu=\"return false;\">{3}</a>";
                }
                else
                {
                    format = "<a id=\"{0}\" href=\"#\" onclick=\"{1}\" title=\"{2}\">{3}</a>";
                }
                SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder = new SanitizingStringBuilder <OwaHtml>();
                sanitizingStringBuilder.Append("?ae=Item&t=");
                sanitizingStringBuilder.Append(Utilities.UrlEncode(item.ClassName));
                sanitizingStringBuilder.Append("&atttyp=embdd");
                if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(item.ClassName))
                {
                    sanitizingStringBuilder.Append("&a=Read");
                }
                SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder2 = new SanitizingStringBuilder <OwaHtml>();
                if ((flags & AttachmentWell.AttachmentWellFlags.RenderReachedMaxEmbeddedDepth) == (AttachmentWell.AttachmentWellFlags) 0)
                {
                    sanitizingStringBuilder2.Append("return onClkEmbItem('");
                    sanitizingStringBuilder2.Append <SanitizedHtmlString>(sanitizingStringBuilder.ToSanitizedString <SanitizedHtmlString>());
                    sanitizingStringBuilder2.Append("','");
                    sanitizingStringBuilder2.Append(Utilities.UrlEncode(attachmentInfoObject.AttachmentId.ToBase64String()));
                    sanitizingStringBuilder2.Append("');");
                }
                else
                {
                    sanitizingStringBuilder2.Append("return alert(L_ErrRchMxEmbDpth)");
                }
                string embeddedAttachmentDisplayName = AttachmentUtility.GetEmbeddedAttachmentDisplayName(item);
                value = SanitizedHtmlString.Format(format, new object[]
                {
                    "lnkAtmt",
                    sanitizingStringBuilder2.ToSanitizedString <SanitizedHtmlString>(),
                    embeddedAttachmentDisplayName,
                    AttachmentUtility.TrimAttachmentDisplayName(embeddedAttachmentDisplayName, previousAttachmentDisplayNames, true)
                });
                flag = false;
            }
            else
            {
                value = Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(AttachmentUtility.GetEmbeddedAttachmentDisplayName(item), previousAttachmentDisplayNames, true));
                flag  = true;
            }
            if (prependSemicolon)
            {
                output.Write("; ");
            }
            output.Write("<span id=\"spnAtmt\" tabindex=\"-1\" level=\"3\"");
            if (flag)
            {
                output.Write(" class=\"dsbl\"");
            }
            output.Write(">");
            output.Write("<img class=\"sI\" src=\"");
            SmallIconManager.RenderItemIconUrl(output, userContext, item.ClassName);
            output.Write("\" alt=\"\">");
            output.Write(value);
            output.Write("</span>");
        }
Ejemplo n.º 3
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>");
        }
        // Token: 0x06001E1F RID: 7711 RVA: 0x000AE510 File Offset: 0x000AC710
        public static void RenderAttachments(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 (attachmentList == null || attachmentList.Count <= 0)
            {
                return;
            }
            bool flag = true;

            Utilities.GetEmbeddedDepth(HttpContext.Current.Request);
            ArrayList previousAttachmentDisplayNames = new ArrayList();
            Item      item = null;

            try
            {
                foreach (object obj in attachmentList)
                {
                    AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
                    AttachmentUtility.AttachmentLinkFlags attachmentLinkFlag = AttachmentUtility.GetAttachmentLinkFlag(wellType, attachmentWellInfo);
                    if (AttachmentUtility.AttachmentLinkFlags.Skip != (AttachmentUtility.AttachmentLinkFlags.Skip & attachmentLinkFlag))
                    {
                        ItemAttachment itemAttachment = null;
                        Item           item2          = null;
                        try
                        {
                            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
                            {
                                if (attachmentWellInfo.MessageId != null)
                                {
                                    if (item != null)
                                    {
                                        StoreObjectId storeObjectId = StoreId.GetStoreObjectId(item.Id);
                                        if (!storeObjectId.Equals(attachmentWellInfo.MessageId.StoreObjectId))
                                        {
                                            item.Dispose();
                                            item = null;
                                        }
                                    }
                                    if (item == null)
                                    {
                                        item = Utilities.GetItem <Item>(userContext, attachmentWellInfo.MessageId, false, null);
                                    }
                                    AttachmentCollection attachmentCollection = item.AttachmentCollection;
                                    if (userContext.IsIrmEnabled && Utilities.IrmDecryptIfRestricted(item, userContext))
                                    {
                                        attachmentCollection = ((RightsManagedMessageItem)item).ProtectedAttachmentCollection;
                                    }
                                    itemAttachment = (ItemAttachment)attachmentCollection.Open(attachmentWellInfo.AttachmentId);
                                }
                                else
                                {
                                    itemAttachment = (ItemAttachment)attachmentWellInfo.OpenAttachment();
                                }
                                item2 = itemAttachment.GetItemAsReadOnly(new PropertyDefinition[]
                                {
                                    TaskSchema.TaskType
                                });
                            }
                            if (!flag)
                            {
                                output.Write("; ");
                            }
                            else
                            {
                                flag = false;
                            }
                            output.Write("<span id=spnAtmt tabindex=\"-1\" ");
                            if (wellType == AttachmentWellType.ReadOnly && AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink != (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag))
                            {
                                output.Write("class=\"dsbl\"");
                            }
                            if (attachmentWellInfo.MessageId != null)
                            {
                                output.Write(" _sId=\"");
                                Utilities.SanitizeHtmlEncode(attachmentWellInfo.MessageId.ToString(), output);
                                output.Write("\"");
                            }
                            string text;
                            if (item2 != null)
                            {
                                text = AttachmentUtility.GetEmbeddedAttachmentDisplayName(item2);
                            }
                            else
                            {
                                text = attachmentWellInfo.AttachmentName;
                            }
                            output.Write(" _attid=\"");
                            output.Write(Utilities.SanitizeHtmlEncode(attachmentWellInfo.AttachmentId.ToBase64String()));
                            output.Write("\" _level=");
                            output.Write((int)attachmentWellInfo.AttachmentLevel);
                            output.Write(" _attname=\"");
                            output.Write(Utilities.SanitizeHtmlEncode(text));
                            output.Write("\" _attsize=\"");
                            output.Write(attachmentWellInfo.Size);
                            output.Write("\" _fIsItem=\"");
                            output.Write(item2 != null);
                            output.Write("\"");
                            if (attachmentWellInfo.AttachmentType != AttachmentType.EmbeddedMessage)
                            {
                                output.Write(" _protectable=\"");
                                bool flag2 = false;
                                try
                                {
                                    flag2 = ProtectorsManager.Instance.IsProtectorRegistered(attachmentWellInfo.FileExtension);
                                }
                                catch (AttachmentProtectionException)
                                {
                                }
                                output.Write(flag2 ? "1" : "0");
                                output.Write("\"");
                            }
                            if (item2 != null)
                            {
                                Task task = item2 as Task;
                                if ((task != null && !TaskUtilities.IsAssignedTask(task)) || item2 is Contact || item2 is DistributionList)
                                {
                                    output.Write(" _qs=\"ae=PreFormAction&a=OpenEmbedded&t=");
                                }
                                else
                                {
                                    output.Write(" _qs=\"ae=Item&t=");
                                }
                                Utilities.SanitizeHtmlEncode(Utilities.UrlEncode(item2.ClassName), output);
                                if (task != null && TaskUtilities.IsAssignedTask(task))
                                {
                                    output.Write("&s=Assigned");
                                }
                                output.Write("\"");
                            }
                            output.Write(">");
                            bool flag3 = AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink == (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag);
                            if (flag3)
                            {
                                string text2 = null;
                                if (item2 != null || attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Allow)
                                {
                                    text2 = "3";
                                }
                                else if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.ForceSave)
                                {
                                    text2 = "2";
                                }
                                if (text2 != null)
                                {
                                    output.Write("<a class=\"lnkClickAtmt\" id=\"lnkAtmt\" _fAllwCM=\"1\" href=\"#\" target=_blank ");
                                    Utilities.RenderScriptHandler(output, "onclick", string.Concat(new string[]
                                    {
                                        "atLnk(event, ",
                                        text2,
                                        ", ",
                                        isConversationAndIrmCopyRestricted ? "1" : "0",
                                        ");"
                                    }));
                                    output.Write(" title=\"");
                                    Utilities.SanitizeHtmlEncode(text, output);
                                    if (text2 == "3" & item2 != null)
                                    {
                                        output.Write("\" oncontextmenu=\"return false;");
                                    }
                                    output.Write("\">");
                                }
                            }
                            if (item2 != null)
                            {
                                SmallIconManager.RenderItemIcon(output, userContext, item2.ClassName, false, "sI", new string[0]);
                            }
                            else
                            {
                                string fileExtension = string.Empty;
                                if (attachmentWellInfo.FileExtension != null)
                                {
                                    fileExtension = attachmentWellInfo.FileExtension;
                                }
                                SmallIconManager.RenderFileIcon(output, userContext, fileExtension, "sI", new string[0]);
                            }
                            if (item2 != null)
                            {
                                Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(text, previousAttachmentDisplayNames, true), output);
                            }
                            else
                            {
                                Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(text, previousAttachmentDisplayNames, false), output);
                                long size = attachmentWellInfo.Size;
                                if (size > 0L)
                                {
                                    output.Write(userContext.DirectionMark);
                                    output.Write(" ");
                                    output.Write(SanitizedHtmlString.FromStringId(6409762));
                                    Utilities.RenderSizeWithUnits(output, size, true);
                                    output.Write(userContext.DirectionMark);
                                    output.Write(SanitizedHtmlString.FromStringId(-1023695022));
                                }
                            }
                            if (flag3)
                            {
                                output.Write("</a>");
                            }
                            if (item2 == null && AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink == (AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink & attachmentLinkFlag))
                            {
                                AttachmentWell.RenderWebReadyLink(output, userContext);
                            }
                            if (wellType == AttachmentWellType.ReadWrite)
                            {
                                output.Write("<span class=\"delLnk\">");
                                userContext.RenderThemeImage(output, ThemeFileId.DeleteSmall, null, new object[]
                                {
                                    "id=delImg"
                                });
                                output.Write("</span>");
                            }
                            output.Write("</span>");
                        }
                        catch (ObjectNotFoundException)
                        {
                        }
                        catch (StorageTransientException)
                        {
                        }
                        finally
                        {
                            if (item2 != null)
                            {
                                item2.Dispose();
                                item2 = null;
                            }
                            if (itemAttachment != null)
                            {
                                itemAttachment.Dispose();
                                itemAttachment = null;
                            }
                        }
                    }
                }
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
            }
        }