// Token: 0x060013E0 RID: 5088 RVA: 0x00072734 File Offset: 0x00070934
        public IEnumerator <Attachment12Data> GetEnumerator()
        {
            Item             message        = base.XsoItem as Item;
            Attachment12Data attachmentData = null;

            if (message == null)
            {
                throw new UnexpectedTypeException("Item", base.XsoItem);
            }
            MeetingRequest meetingRequest = base.XsoItem as MeetingRequest;

            if (meetingRequest == null || !meetingRequest.IsDelegated())
            {
                string idbase = null;
                if (this.idmapping != null)
                {
                    idbase = this.idmapping[MailboxSyncItemId.CreateForNewItem(message.Id.ObjectId)];
                }
                if (idbase == null)
                {
                    idbase = message.Id.ObjectId.ToBase64String();
                }
                if (message is MessageItem && ((MessageItem)message).IsRestricted && !BodyConversionUtilities.IsMessageRestrictedAndDecoded(message) && !BodyConversionUtilities.IsIRMFailedToDecode(message))
                {
                    object prop = message.TryGetProperty(MessageItemSchema.DRMLicense);
                    if (prop is byte[][])
                    {
                        byte[][] license = (byte[][])prop;
                        if (license.Length > 0)
                        {
                            attachmentData                   = new Attachment14Data();
                            attachmentData.DisplayName       = "message.rpmsg.license";
                            attachmentData.Method            = 1;
                            attachmentData.EstimatedDataSize = (long)license[0].Length;
                            attachmentData.IsInline          = false;
                            attachmentData.FileReference     = HttpUtility.UrlEncode(idbase + ":DRMLicense");
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Add DRM license as attachment, message is MessageItem {0}, message.IsRestricted {1}, IsDecoded {2}, FailedToDecode {3}", new object[]
                            {
                                message is MessageItem,
                                ((MessageItem)message).IsRestricted,
                                BodyConversionUtilities.IsMessageRestrictedAndDecoded(message),
                                BodyConversionUtilities.IsIRMFailedToDecode(message)
                            });
                            yield return(attachmentData);
                        }
                        else
                        {
                            AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. Length = {0}", license.Length);
                        }
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. prop = {0}", new object[]
                        {
                            prop
                        });
                    }
                }
                AttachmentCollection attachmentCollection = null;
                if (BodyConversionUtilities.IsMessageRestrictedAndDecoded(message))
                {
                    attachmentCollection = ((RightsManagedMessageItem)message).ProtectedAttachmentCollection;
                }
                else
                {
                    if (BodyConversionUtilities.IsIRMFailedToDecode(message))
                    {
                        goto IL_3FC;
                    }
                    attachmentCollection = message.AttachmentCollection;
                }
                int index = -1;
                foreach (AttachmentHandle handle in attachmentCollection)
                {
                    using (Attachment attachment = attachmentCollection.Open(handle))
                    {
                        if (BodyUtility.IsClearSigned(message) && (string.Equals(attachment.FileName, "smime.p7m", StringComparison.OrdinalIgnoreCase) || string.Equals(attachment.ContentType, "multipart/signed", StringComparison.OrdinalIgnoreCase)))
                        {
                            continue;
                        }
                        attachmentData = this.GetAttachmentData(message, attachment, idbase, ref index);
                    }
                    if (attachmentData != null)
                    {
                        yield return(attachmentData);
                    }
                }
            }
IL_3FC:
            yield break;
        }
Ejemplo n.º 2
0
        // Token: 0x060013EF RID: 5103 RVA: 0x00073204 File Offset: 0x00071404
        public IEnumerator <AttachmentData> GetEnumerator()
        {
            Item message = base.XsoItem as Item;

            if (message == null)
            {
                throw new UnexpectedTypeException("Item", base.XsoItem);
            }
            string baseId = null;

            if (this.idmapping != null)
            {
                baseId = this.idmapping[MailboxSyncItemId.CreateForNewItem(message.Id.ObjectId)];
            }
            if (baseId == null)
            {
                baseId = message.Id.ObjectId.ToBase64String();
            }
            if (base.XsoItem is MessageItem && ((MessageItem)message).IsRestricted)
            {
                object prop = message.TryGetProperty(MessageItemSchema.DRMLicense);
                if (prop is byte[][])
                {
                    byte[][] license = (byte[][])prop;
                    if (license.Length > 0)
                    {
                        yield return(new AttachmentData
                        {
                            AttMethod = 1,
                            AttSize = (long)license[0].Length,
                            DisplayName = "message.rpmsg.license",
                            AttName = HttpUtility.UrlEncode(baseId + ":DRMLicense")
                        });
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. Length = {0}", license.Length);
                    }
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Failed to fetch the license property on the DRM message. Prop = {0}", new object[]
                    {
                        prop
                    });
                }
            }
            int index = -1;

            foreach (AttachmentHandle handle in message.AttachmentCollection)
            {
                index++;
                AttachmentData attachmentData = default(AttachmentData);
                Attachment     attachment     = null;
                try
                {
                    attachment = message.AttachmentCollection.Open(handle);
                    if (BodyUtility.IsClearSigned(message) && (string.Compare(attachment.FileName, "smime.p7m", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(attachment.ContentType, "multipart/signed", StringComparison.OrdinalIgnoreCase) == 0))
                    {
                        continue;
                    }
                    attachmentData.AttName = HttpUtility.UrlEncode(baseId + ":" + index);
                    if (string.IsNullOrEmpty(attachmentData.DisplayName))
                    {
                        if (!string.IsNullOrEmpty(attachment.FileName))
                        {
                            attachmentData.DisplayName = attachment.FileName;
                        }
                        else if (attachment.AttachmentType == AttachmentType.EmbeddedMessage)
                        {
                            using (Item itemAsReadOnly = ((ItemAttachment)attachment).GetItemAsReadOnly(null))
                            {
                                attachmentData.DisplayName = (itemAsReadOnly.TryGetProperty(ItemSchema.Subject) as string);
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(attachmentData.DisplayName))
                    {
                        attachmentData.DisplayName = "????";
                    }
                    attachmentData.AttMethod = (int)attachment.TryGetProperty(AttachmentSchema.AttachMethod);
                    attachmentData.AttSize   = attachment.Size;
                }
                finally
                {
                    if (attachment != null)
                    {
                        attachment.Dispose();
                        attachment = null;
                    }
                }
                yield return(attachmentData);
            }
            yield break;
        }