public override IEnumerator <Attachment12Data> GetEnumerator()
        {
            int nodeIndex = 0;

            foreach (Attachment12Data attachment12Data in this)
            {
                Attachment14Data attachment14 = (Attachment14Data)attachment12Data;
                XmlNodeList      childNodes   = base.XmlNode.ChildNodes;
                int i;
                nodeIndex = (i = nodeIndex) + 1;
                XmlNode attachmentNode = childNodes[i];
                foreach (object obj in attachmentNode)
                {
                    XmlNode xmlNode = (XmlNode)obj;
                    string  name;
                    if ((name = xmlNode.Name) != null)
                    {
                        if (!(name == "UmAttOrder"))
                        {
                            if (name == "UmAttDuration")
                            {
                                attachment14.Duration = Convert.ToInt32(xmlNode.InnerText);
                            }
                        }
                        else
                        {
                            attachment14.Order = Convert.ToInt32(xmlNode.InnerText);
                        }
                    }
                }
                yield return(attachment14);
            }
            yield break;
        }
Beispiel #2
0
        protected override Attachment12Data GetAttachmentData(Item message, Attachment attachment, string idbase, ref int index)
        {
            Attachment14Data attachment14Data = (Attachment14Data)base.GetAttachmentData(message, attachment, idbase, ref index);

            if (attachment14Data == null)
            {
                return(null);
            }
            if (this.IsEvmMessage())
            {
                if (this.evmAttachmentOrders == null && base.Count > 1)
                {
                    this.evmAttachmentOrders = new List <int>(base.Count);
                }
                attachment14Data.Order = Xso14AttachmentsProperty.GetEvmAttachmentOrder(message.GetValueOrDefault <string>(MessageItemSchema.VoiceMessageAttachmentOrder), attachment14Data.DisplayName);
                if (this.evmAttachmentOrders != null)
                {
                    if (this.evmAttachmentOrders.Contains(attachment14Data.Order))
                    {
                        attachment14Data.Order = -1;
                    }
                    else
                    {
                        this.evmAttachmentOrders.Add(attachment14Data.Order);
                    }
                }
                if (Xso14AttachmentsProperty.IsTheLatestEvmAttachment(attachment14Data.Order))
                {
                    attachment14Data.Duration = message.GetValueOrDefault <int>(MessageItemSchema.VoiceMessageDuration, -1);
                }
            }
            return(attachment14Data);
        }
Beispiel #3
0
        private Attachment14Data CreateAttachment14Data(IAttachment attachment)
        {
            Attachment14Data attachment14Data = new Attachment14Data();

            attachment14Data.DisplayName       = attachment.Name;
            attachment14Data.EstimatedDataSize = attachment.Size;
            attachment14Data.IsInline          = attachment.IsInline;
            attachment14Data.FileReference     = HttpUtility.UrlEncode(base.Item.Id + ":" + attachment.Id);
            attachment14Data.Id = EntitySyncItemId.GetAttachmentId(attachment.Id);
            FileAttachment fileAttachment = attachment as FileAttachment;
            ItemAttachment itemAttachment = attachment as ItemAttachment;

            if (fileAttachment != null)
            {
                attachment14Data.Method          = 1;
                attachment14Data.ContentId       = fileAttachment.ContentId;
                attachment14Data.ContentLocation = fileAttachment.ContentLocation;
                if (fileAttachment.Content != null)
                {
                    attachment14Data.EstimatedDataSize = (long)fileAttachment.Content.Length;
                }
            }
            else
            {
                if (itemAttachment == null)
                {
                    throw new ConversionException(string.Format("Attachment type \"{0}\" is not supported.", attachment.GetType().FullName));
                }
                attachment14Data.Method = 5;
            }
            return(attachment14Data);
        }
        protected override void CopyAttachment(XmlNode attachmentNode, Attachment12Data attachment)
        {
            base.CopyAttachment(attachmentNode, attachment);
            Attachment14Data attachment14Data = attachment as Attachment14Data;

            if (attachment14Data == null)
            {
                throw new UnexpectedTypeException("Attachment14Data", attachment);
            }
            if (attachment14Data.Order != -1)
            {
                XmlNode xmlNode = base.XmlParentNode.OwnerDocument.CreateElement("UmAttOrder", "Email2:");
                xmlNode.InnerText = attachment14Data.Order.ToString(CultureInfo.InvariantCulture);
                attachmentNode.AppendChild(xmlNode);
            }
            if (attachment14Data.Duration != -1)
            {
                XmlNode xmlNode2 = base.XmlParentNode.OwnerDocument.CreateElement("UmAttDuration", "Email2:");
                xmlNode2.InnerText = attachment14Data.Duration.ToString(CultureInfo.InvariantCulture);
                attachmentNode.AppendChild(xmlNode2);
            }
        }
        // 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;
        }
        // Token: 0x060013E1 RID: 5089 RVA: 0x00072750 File Offset: 0x00070950
        protected virtual Attachment12Data GetAttachmentData(Item message, Attachment attachment, string idbase, ref int index)
        {
            index++;
            Attachment14Data attachment14Data = new Attachment14Data();

            attachment14Data.Id = attachment.Id;
            if (BodyConversionUtilities.IsMessageRestrictedAndDecoded(message) && AirSyncUtility.IsProtectedVoicemailItem(message))
            {
                if (AttachmentHelper.IsProtectedVoiceAttachment(attachment.DisplayName))
                {
                    string valueOrDefault = message.GetValueOrDefault <string>(MessageItemSchema.RequireProtectedPlayOnPhone);
                    if (valueOrDefault != null && valueOrDefault.Equals("true", StringComparison.OrdinalIgnoreCase))
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Skip attachment requires protected play on phone");
                        return(null);
                    }
                    attachment14Data.DisplayName = AttachmentHelper.GetUnprotectedVoiceAttachmentName(attachment.DisplayName);
                }
                else
                {
                    if (AttachmentHelper.IsProtectedTranscriptAttachment(attachment.DisplayName))
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Skip protected transcript attachment");
                        return(null);
                    }
                    attachment14Data.DisplayName = attachment.DisplayName;
                }
            }
            else
            {
                attachment14Data.DisplayName = attachment.DisplayName;
            }
            if (string.IsNullOrEmpty(attachment14Data.DisplayName))
            {
                if (!string.IsNullOrEmpty(attachment.FileName))
                {
                    attachment14Data.DisplayName = attachment.FileName;
                    if (attachment.AttachmentType == AttachmentType.Ole && attachment.DisplayName.LastIndexOf('.') < 0)
                    {
                        Attachment14Data attachment14Data2 = attachment14Data;
                        attachment14Data2.DisplayName += ".jpg";
                    }
                }
                else if (attachment.AttachmentType == AttachmentType.EmbeddedMessage)
                {
                    using (Item itemAsReadOnly = ((ItemAttachment)attachment).GetItemAsReadOnly(null))
                    {
                        attachment14Data.DisplayName = (itemAsReadOnly.TryGetProperty(ItemSchema.Subject) as string);
                    }
                }
            }
            if (string.IsNullOrEmpty(attachment14Data.DisplayName))
            {
                attachment14Data.DisplayName = "????";
            }
            AirSyncDiagnostics.TraceDebug <int, string>(ExTraceGlobals.XsoTracer, this, "Attachment {0}, display name {1}", index, attachment14Data.DisplayName);
            attachment14Data.FileReference     = HttpUtility.UrlEncode(idbase + ":" + index);
            attachment14Data.Method            = Convert.ToByte((int)attachment.TryGetProperty(AttachmentSchema.AttachMethod));
            attachment14Data.EstimatedDataSize = attachment.Size;
            if (attachment.IsInline)
            {
                if (string.IsNullOrEmpty(attachment.ContentId))
                {
                    attachment14Data.ContentId = Guid.NewGuid().ToString();
                }
                else
                {
                    attachment14Data.ContentId = attachment.ContentId;
                }
            }
            if (attachment.ContentLocation != null)
            {
                attachment14Data.ContentLocation = attachment.ContentLocation.ToString();
            }
            if (!BodyConversionUtilities.IsMessageRestrictedAndDecoded(message))
            {
                attachment14Data.IsInline = attachment.IsInline;
            }
            return(attachment14Data);
        }