// Token: 0x06000FC2 RID: 4034 RVA: 0x000599D0 File Offset: 0x00057BD0
        protected override bool ClientAccepts(IContentProperty srcProperty, BodyType type, out long estimatedDataSize, out long truncationSize)
        {
            IContent16Property content16Property = srcProperty as IContent16Property;

            if (content16Property == null)
            {
                throw new UnexpectedTypeException("IContent16Property", content16Property);
            }
            estimatedDataSize = 0L;
            bool flag;

            if (!base.IsAcceptable(type, out truncationSize, out flag))
            {
                return(false);
            }
            this.dataString   = content16Property.BodyString;
            estimatedDataSize = (long)this.dataString.Length;
            if (truncationSize < 0L || estimatedDataSize <= truncationSize)
            {
                base.Truncated = false;
            }
            else
            {
                if (flag)
                {
                    this.dataString = null;
                    return(false);
                }
                this.dataString = this.dataString.Remove((int)truncationSize);
                base.Truncated  = true;
            }
            return(true);
        }
        // Token: 0x06001449 RID: 5193 RVA: 0x00074E8C File Offset: 0x0007308C
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            Item             item            = (Item)base.XsoItem;
            IContentProperty contentProperty = (IContentProperty)srcProperty;

            switch (contentProperty.GetNativeType())
            {
            case BodyType.PlainText:
                break;

            case BodyType.Html:
                goto IL_D3;

            case BodyType.Rtf:
                if (contentProperty.Body.Length > 0L)
                {
                    using (Stream stream = XsoContentProperty.OpenBodyWriteStream(item, Microsoft.Exchange.Data.Storage.BodyFormat.ApplicationRtf))
                    {
                        try
                        {
                            StreamHelper.CopyStreamWithBase64Conversion(contentProperty.Body, stream, -1, false);
                        }
                        catch (FormatException innerException)
                        {
                            throw new AirSyncPermanentException(StatusCode.Sync_ServerError, innerException, false)
                                  {
                                      ErrorStringForProtocolLogger = "RtfToBase64StreamError"
                                  };
                        }
                        return;
                    }
                }
                using (TextWriter textWriter = item.Body.OpenTextWriter(Microsoft.Exchange.Data.Storage.BodyFormat.TextPlain))
                {
                    textWriter.Write(string.Empty);
                    return;
                }
                break;

            default:
                goto IL_F8;
            }
            using (Stream stream2 = XsoContentProperty.OpenBodyWriteStream(item, Microsoft.Exchange.Data.Storage.BodyFormat.TextPlain))
            {
                StreamHelper.CopyStream(contentProperty.Body, stream2);
                return;
            }
IL_D3:
            using (Stream stream3 = XsoContentProperty.OpenBodyWriteStream(item, Microsoft.Exchange.Data.Storage.BodyFormat.TextHtml))
            {
                StreamHelper.CopyStream(contentProperty.Body, stream3);
                return;
            }
IL_F8:
            throw new ConversionException("Source body property does not have Rtf or Text body present");
        }
Exemplo n.º 3
0
        // Token: 0x06000FB6 RID: 4022 RVA: 0x00059604 File Offset: 0x00057804
        protected virtual bool ClientAccepts(IContentProperty srcProperty, BodyType type, out long estimatedDataSize, out long truncationSize)
        {
            estimatedDataSize = 0L;
            bool flag;

            if (this.IsAcceptable(type, out truncationSize, out flag))
            {
                if (truncationSize >= 0L && flag)
                {
                    this.data = srcProperty.GetData(type, -1L, out estimatedDataSize, out this.attachments);
                    if (this.data.Length >= truncationSize && estimatedDataSize > truncationSize)
                    {
                        this.data      = null;
                        this.Truncated = true;
                        return(false);
                    }
                    this.Truncated    = false;
                    estimatedDataSize = this.data.Length;
                }
                else
                {
                    this.data = srcProperty.GetData(type, truncationSize, out estimatedDataSize, out this.attachments);
                    if (truncationSize < 0L)
                    {
                        this.Truncated = false;
                    }
                    else if (this.data.Length >= truncationSize && estimatedDataSize > truncationSize)
                    {
                        this.Truncated = true;
                    }
                    else
                    {
                        this.Truncated = false;
                    }
                }
                return(true);
            }
            this.data      = null;
            this.Truncated = true;
            return(false);
        }
Exemplo n.º 4
0
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            IContentProperty contentProperty = (IContentProperty)srcProperty;
            BodyType         nativeType      = contentProperty.GetNativeType();

            if (nativeType == BodyType.Mime && string.Equals(base.XsoItem.ClassName, "IPM.NOTE.MOBILE.MMS", StringComparison.OrdinalIgnoreCase))
            {
                Item itemOut = (Item)base.XsoItem;
                InboundConversionOptions inboundConversionOptions = AirSyncUtility.GetInboundConversionOptions();
                inboundConversionOptions.ClearCategories = false;
                try
                {
                    Stream body = ((IContentProperty)srcProperty).Body;
                    ItemConversion.ConvertAnyMimeToItem(itemOut, body, inboundConversionOptions);
                    goto IL_8A;
                }
                catch (ExchangeDataException ex)
                {
                    throw new ConversionException("Mime conversion for MMS item failed due to InvalidCharSetError", ex.InnerException);
                }
                catch (ConversionFailedException ex2)
                {
                    throw new ConversionException("Mime conversion for MMS item failed due to InvalidMime", ex2.InnerException);
                }
            }
            base.InternalCopyFromModified(srcProperty);
IL_8A:
            if (string.Equals(base.XsoItem.ClassName, "IPM.NOTE.MOBILE.SMS", StringComparison.OrdinalIgnoreCase))
            {
                MessageItem  messageItem  = (MessageItem)base.XsoItem;
                StreamReader streamReader = new StreamReader(((IContentProperty)srcProperty).Body);
                char[]       array        = new char[78];
                int          length       = streamReader.ReadBlock(array, 0, array.Length);
                messageItem.Subject = new string(array, 0, length);
            }
        }
Exemplo n.º 5
0
        // Token: 0x06000FB5 RID: 4021 RVA: 0x00059390 File Offset: 0x00057590
        protected override void InternalCopyFrom(IProperty sourceProperty)
        {
            IContentProperty contentProperty = sourceProperty as IContentProperty;

            if (contentProperty == null)
            {
                throw new UnexpectedTypeException("IContentProperty", sourceProperty);
            }
            contentProperty.PreProcessProperty();
            try
            {
                long num = 0L;
                bool flag;
                long num3;
                if (BodyUtility.IsAskingForMIMEData(contentProperty, base.Options) && this.IsAcceptable(BodyType.Mime, out num, out flag))
                {
                    int num2 = -1;
                    this.bodyType = BodyType.Mime;
                    this.MIMEData = contentProperty.MIMEData;
                    if (base.Options.Contains("MIMETruncation"))
                    {
                        num2 = (int)base.Options["MIMETruncation"];
                    }
                    if (num2 >= 0 && (long)num2 < this.MIMEData.Length)
                    {
                        this.Truncated = true;
                        this.MIMESize  = (long)num2;
                    }
                    else
                    {
                        this.Truncated = false;
                        this.MIMESize  = this.MIMEData.Length;
                    }
                    num3 = contentProperty.MIMEData.Length;
                }
                else
                {
                    this.bodyType = contentProperty.GetNativeType();
                    if (this.bodyType == BodyType.None)
                    {
                        return;
                    }
                    num3 = contentProperty.Size;
                    foreach (BodyType bodyType in AirSyncContentProperty.GetPrioritizedBodyTypes(this.bodyType))
                    {
                        try
                        {
                            long num4;
                            if (this.ClientAccepts(contentProperty, bodyType, out num4, out num))
                            {
                                this.bodyType = bodyType;
                                num3          = num4;
                                break;
                            }
                        }
                        catch (ObjectNotFoundException arg)
                        {
                            AirSyncDiagnostics.TraceInfo <BodyType, ObjectNotFoundException>(ExTraceGlobals.AirSyncTracer, this, "ClientAccepts({0}) has thrown {1}", bodyType, arg);
                            num3          = 0L;
                            this.bodyType = BodyType.None;
                        }
                    }
                }
                if (contentProperty.IsIrmErrorMessage)
                {
                    this.Truncated = true;
                }
                base.XmlNode = base.XmlParentNode.OwnerDocument.CreateElement(base.AirSyncTagNames[0], base.Namespace);
                base.XmlParentNode.AppendChild(base.XmlNode);
                XmlNode xmlNode     = base.XmlNode;
                string  elementName = "Type";
                int     num5        = (int)this.bodyType;
                base.AppendChildNode(xmlNode, elementName, num5.ToString(CultureInfo.InvariantCulture));
                base.AppendChildNode(base.XmlNode, "EstimatedDataSize", num3.ToString(CultureInfo.InvariantCulture));
                if (this.Truncated)
                {
                    base.AppendChildNode(base.XmlNode, "Truncated", "1");
                }
                this.CopyData();
            }
            finally
            {
                contentProperty.PostProcessProperty();
            }
        }