コード例 #1
0
 private static void StartAttributeIfNecessary(TnefWriter writer, TnefAttributeTag attributeTag, TnefAttributeLevel attributeLevel, ref bool startAttribute)
 {
     if (startAttribute)
     {
         writer.StartAttribute(attributeTag, attributeLevel);
         startAttribute = false;
     }
 }
コード例 #2
0
        private void WriteTnefParticipant(TnefAttributeTag legacyTnefAttribute, ConversionItemParticipants.ParticipantIndex index)
        {
            Participant participant = this.addressCache.Participants[index];

            if (ItemToTnefConverter.IsCompleteParticipant(participant))
            {
                this.tnefWriter.StartAttribute(legacyTnefAttribute, TnefAttributeLevel.Message);
                EmbeddedParticipantProperty embeddedParticipantProperty = ConversionItemParticipants.GetEmbeddedParticipantProperty(index);
                this.tnefWriter.WriteProperty(embeddedParticipantProperty.EmailAddressPropertyDefinition, participant.EmailAddress);
                this.tnefWriter.WriteProperty(embeddedParticipantProperty.RoutingTypePropertyDefinition, participant.RoutingType);
                this.tnefWriter.WriteProperty(embeddedParticipantProperty.DisplayNamePropertyDefinition, string.IsNullOrEmpty(participant.DisplayName) ? participant.EmailAddress : participant.DisplayName);
            }
        }
コード例 #3
0
        private void WriteMessageAttribute(TnefAttributeTag attribute, TnefPropertyTag tnefProperty, StorePropertyDefinition property)
        {
            object        obj           = this.item.TryGetProperty(property);
            PropertyError propertyError = obj as PropertyError;

            if (propertyError == null)
            {
                if (attribute == TnefAttributeTag.OriginalMessageClass || attribute == TnefAttributeTag.MessageClass)
                {
                    string value = obj as string;
                    if (string.IsNullOrEmpty(value))
                    {
                        return;
                    }
                }
                this.tnefWriter.StartAttribute(attribute, TnefAttributeLevel.Message);
                this.tnefWriter.WriteProperty(tnefProperty, obj);
                return;
            }
            if (PropertyError.IsPropertyValueTooBig(propertyError))
            {
                try
                {
                    using (Stream stream = this.item.OpenPropertyStream(property, PropertyOpenMode.ReadOnly))
                    {
                        using (Stream stream2 = this.tnefWriter.OpenAttributeStream(attribute, TnefAttributeLevel.Message))
                        {
                            Util.StreamHandler.CopyStreamData(stream, stream2);
                        }
                    }
                }
                catch (ObjectNotFoundException)
                {
                }
            }
        }
コード例 #4
0
        private void ReadAttribute()
        {
            TnefPropertyTag @null = TnefPropertyTag.Null;

            if (base.CurrentComponentType == ConversionComponentType.FileAttachment)
            {
                TnefAttributeTag attributeTag = this.reader.AttributeTag;
                if (attributeTag <= TnefAttributeTag.AttachModifyDate)
                {
                    if (attributeTag != TnefAttributeTag.AttachTitle)
                    {
                        switch (attributeTag)
                        {
                        case TnefAttributeTag.AttachCreateDate:
                        case TnefAttributeTag.AttachModifyDate:
                            break;

                        default:
                            goto IL_71;
                        }
                    }
                }
                else
                {
                    switch (attributeTag)
                    {
                    case TnefAttributeTag.AttachData:
                    case TnefAttributeTag.AttachMetaFile:
                        break;

                    case (TnefAttributeTag)426000:
                        goto IL_71;

                    default:
                        if (attributeTag != TnefAttributeTag.AttachTransportFilename && attributeTag != TnefAttributeTag.Attachment)
                        {
                            goto IL_71;
                        }
                        break;
                    }
                }
                this.ParseAttachmentProperties();
                goto IL_77;
IL_71:
                this.EndAttachment();
            }
IL_77:
            if (base.CurrentComponentType == ConversionComponentType.Message)
            {
                TnefAttributeTag attributeTag2 = this.reader.AttributeTag;
                if (attributeTag2 <= TnefAttributeTag.RequestResponse)
                {
                    if (attributeTag2 <= TnefAttributeTag.Body)
                    {
                        if (attributeTag2 <= TnefAttributeTag.Subject)
                        {
                            if (attributeTag2 != TnefAttributeTag.From && attributeTag2 != TnefAttributeTag.Subject)
                            {
                                goto IL_211;
                            }
                        }
                        else
                        {
                            switch (attributeTag2)
                            {
                            case TnefAttributeTag.MessageId:
                            case TnefAttributeTag.ParentId:
                            case TnefAttributeTag.ConversationId:
                                break;

                            default:
                                if (attributeTag2 != TnefAttributeTag.Body)
                                {
                                    goto IL_211;
                                }
                                break;
                            }
                        }
                    }
                    else if (attributeTag2 <= TnefAttributeTag.DateReceived)
                    {
                        switch (attributeTag2)
                        {
                        case TnefAttributeTag.DateStart:
                        case TnefAttributeTag.DateEnd:
                            break;

                        default:
                            switch (attributeTag2)
                            {
                            case TnefAttributeTag.DateSent:
                            case TnefAttributeTag.DateReceived:
                                break;

                            default:
                                goto IL_211;
                            }
                            break;
                        }
                    }
                    else if (attributeTag2 != TnefAttributeTag.DateModified && attributeTag2 != TnefAttributeTag.RequestResponse)
                    {
                        goto IL_211;
                    }
                }
                else if (attributeTag2 <= TnefAttributeTag.MessageStatus)
                {
                    if (attributeTag2 <= TnefAttributeTag.AidOwner)
                    {
                        if (attributeTag2 != TnefAttributeTag.Priority && attributeTag2 != TnefAttributeTag.AidOwner)
                        {
                            goto IL_211;
                        }
                    }
                    else
                    {
                        switch (attributeTag2)
                        {
                        case TnefAttributeTag.Owner:
                        case TnefAttributeTag.SentFor:
                        case TnefAttributeTag.Delegate:
                            break;

                        default:
                            if (attributeTag2 != TnefAttributeTag.MessageStatus)
                            {
                                goto IL_211;
                            }
                            this.ParseMapiProperties(true);
                            return;
                        }
                    }
                }
                else if (attributeTag2 <= TnefAttributeTag.OriginalMessageClass)
                {
                    switch (attributeTag2)
                    {
                    case TnefAttributeTag.AttachRenderData:
                        this.StartNewAttachment();
                        this.ParseAttachRenderData();
                        return;

                    case TnefAttributeTag.MapiProperties:
                        break;

                    case TnefAttributeTag.RecipientTable:
                        this.ParseRecipientTable();
                        return;

                    case TnefAttributeTag.Attachment:
                    case (TnefAttributeTag)430086:
                        goto IL_211;

                    case TnefAttributeTag.OemCodepage:
                        base.SetProperty(InternalSchema.Codepage, this.reader.MessageCodepage);
                        return;

                    default:
                        if (attributeTag2 != TnefAttributeTag.OriginalMessageClass)
                        {
                            goto IL_211;
                        }
                        break;
                    }
                }
                else if (attributeTag2 != TnefAttributeTag.MessageClass)
                {
                    if (attributeTag2 != TnefAttributeTag.TnefVersion)
                    {
                        goto IL_211;
                    }
                    return;
                }
                this.ParseMapiProperties(false);
                return;

IL_211:
                StorageGlobals.ContextTraceDebug <uint>(ExTraceGlobals.CcInboundTnefTracer, "Unknown TNEF attribute encountered: 0x{0:X}. Ignoring.", (uint)this.reader.AttributeTag);
            }
        }
コード例 #5
0
 internal Stream OpenAttributeStream(TnefAttributeTag tag, TnefAttributeLevel level)
 {
     this.StartAttribute(tag, level);
     return(new ItemToTnefConverter.TnefContentWriterAttributeStream(this));
 }
コード例 #6
0
 internal void StartAttribute(TnefAttributeTag tag, TnefAttributeLevel level)
 {
     this.newTnefAttribute      = tag;
     this.newTnefAttributeLevel = level;
 }
コード例 #7
0
        private bool WriteModifiedProperty(TnefWriter writer, TnefReader reader, TnefPropertyTag propertyTag, object value, bool forceUnicode, ref bool startAttribute, byte[] scratchBuffer)
        {
            TnefPropertyReader   propertyReader       = reader.PropertyReader;
            TnefAttributeTag     attributeTag         = reader.AttributeTag;
            TnefAttributeLevel   attributeLevel       = reader.AttributeLevel;
            StoragePropertyValue storagePropertyValue = value as StoragePropertyValue;

            if (storagePropertyValue != null)
            {
                if (this.attachmentData != null && this.attachmentData.EmbeddedMessage != null && propertyReader.IsEmbeddedMessage)
                {
                    using (TnefReader embeddedMessageReader = propertyReader.GetEmbeddedMessageReader())
                    {
                        TnefPropertyBag.StartAttributeIfNecessary(writer, attributeTag, attributeLevel, ref startAttribute);
                        writer.StartProperty(propertyTag);
                        EmailMessage    embeddedMessage = this.attachmentData.EmbeddedMessage;
                        PureTnefMessage pureTnefMessage = embeddedMessage.PureTnefMessage;
                        Charset         textCharset     = pureTnefMessage.TextCharset;
                        using (TnefWriter embeddedMessageWriter = writer.GetEmbeddedMessageWriter(textCharset.CodePage))
                        {
                            pureTnefMessage.WriteMessage(embeddedMessageReader, embeddedMessageWriter, scratchBuffer);
                        }
                        return(true);
                    }
                }
                using (Stream readStream = storagePropertyValue.GetReadStream())
                {
                    int num = readStream.Read(scratchBuffer, 0, scratchBuffer.Length);
                    if (num > 0)
                    {
                        propertyTag = storagePropertyValue.PropertyTag;
                        if (propertyTag.ValueTnefType == TnefPropertyType.Unicode && TnefPropertyBag.IsLegacyAttribute(attributeTag))
                        {
                            return(false);
                        }
                        TnefPropertyBag.StartAttributeIfNecessary(writer, attributeTag, attributeLevel, ref startAttribute);
                        writer.StartProperty(propertyTag);
                        do
                        {
                            writer.WritePropertyRawValue(scratchBuffer, 0, num);
                            num = readStream.Read(scratchBuffer, 0, scratchBuffer.Length);
                        }while (num > 0);
                    }
                    return(true);
                }
            }
            if (propertyTag.ValueTnefType == TnefPropertyType.String8 && forceUnicode)
            {
                if (TnefPropertyBag.IsLegacyAttribute(attributeTag))
                {
                    return(false);
                }
                TnefPropertyBag.StartAttributeIfNecessary(writer, attributeTag, attributeLevel, ref startAttribute);
                writer.WriteProperty(propertyTag.ToUnicode(), value);
            }
            else
            {
                TnefPropertyBag.StartAttributeIfNecessary(writer, attributeTag, attributeLevel, ref startAttribute);
                writer.WriteProperty(propertyTag, value);
            }
            return(true);
        }
コード例 #8
0
        internal bool Write(TnefReader reader, TnefWriter writer, TnefAttributeLevel level, bool dropRecipientTable, bool forceUnicode, byte[] scratchBuffer)
        {
            IDictionary <TnefPropertyTag, object> dictionary = null;

            char[] array = null;
            bool   result;

            for (;;)
            {
                TnefPropertyReader propertyReader = reader.PropertyReader;
                if (0 >= propertyReader.PropertyCount)
                {
                    goto IL_37A;
                }
                TnefAttributeTag   attributeTag   = reader.AttributeTag;
                TnefAttributeLevel attributeLevel = reader.AttributeLevel;
                bool flag = true;
                while (propertyReader.ReadNextProperty())
                {
                    TnefPropertyTag propertyTag = propertyReader.PropertyTag;
                    if (TnefPropertyType.Null != propertyTag.ValueTnefType)
                    {
                        if (propertyReader.IsNamedProperty)
                        {
                            TnefNameId  propertyNameId = propertyReader.PropertyNameId;
                            TnefNameTag key            = new TnefNameTag(propertyNameId, propertyTag.ValueTnefType);
                            int         num;
                            if (this.supportedNamedProperties.TryGetValue(key, out num) && this.properties[num].IsDirty)
                            {
                                object obj = this[propertyNameId];
                                if (obj != null)
                                {
                                    TnefPropertyBag.StartAttributeIfNecessary(writer, attributeTag, attributeLevel, ref flag);
                                    writer.StartProperty(propertyTag, propertyNameId.PropertySetGuid, propertyNameId.Id);
                                    writer.WritePropertyValue(obj);
                                    continue;
                                }
                                continue;
                            }
                        }
                        else
                        {
                            TnefPropertyId id = propertyTag.Id;
                            int            num2;
                            if (this.supportedProperties.TryGetValue(propertyTag, out num2) && this.properties[num2].IsDirty && (this.attachmentData == null || this.attachmentData.EmbeddedMessage == null || TnefAttributeLevel.Attachment != level || TnefAttributeTag.AttachData != attributeTag || TnefPropertyId.AttachData != id))
                            {
                                object obj = this[id];
                                if (obj == null)
                                {
                                    continue;
                                }
                                if (!this.WriteModifiedProperty(writer, reader, propertyTag, obj, forceUnicode, ref flag, scratchBuffer))
                                {
                                    if (dictionary == null)
                                    {
                                        dictionary = new Dictionary <TnefPropertyTag, object>(TnefPropertyBag.PropertyTagComparer);
                                    }
                                    if (!dictionary.ContainsKey(propertyTag))
                                    {
                                        dictionary.Add(propertyTag, obj);
                                        continue;
                                    }
                                    continue;
                                }
                                else
                                {
                                    if (dictionary != null && dictionary.ContainsKey(propertyTag))
                                    {
                                        dictionary.Remove(propertyTag);
                                        continue;
                                    }
                                    continue;
                                }
                            }
                        }
                        if (propertyTag.ValueTnefType == TnefPropertyType.String8 && forceUnicode)
                        {
                            if (!TnefPropertyBag.IsLegacyAttribute(attributeTag))
                            {
                                TnefPropertyBag.StartAttributeIfNecessary(writer, attributeTag, attributeLevel, ref flag);
                                TnefPropertyBag.WriteUnicodeProperty(writer, propertyReader, propertyTag.ToUnicode(), ref array);
                            }
                        }
                        else if (propertyTag.IsTnefTypeValid)
                        {
                            TnefPropertyBag.StartAttributeIfNecessary(writer, attributeTag, attributeLevel, ref flag);
                            writer.WriteProperty(propertyReader);
                        }
                    }
                }
                if ((TnefAttributeTag.MapiProperties == attributeTag && level == TnefAttributeLevel.Message) || (TnefAttributeTag.Attachment == attributeTag && level == TnefAttributeLevel.Attachment))
                {
                    if (this.newProperties != null)
                    {
                        foreach (KeyValuePair <TnefPropertyTag, object> keyValuePair in this.newProperties)
                        {
                            object obj = keyValuePair.Value;
                            if (obj != null)
                            {
                                this.WriteModifiedProperty(writer, reader, keyValuePair.Key, obj, forceUnicode, ref flag, scratchBuffer);
                            }
                        }
                    }
                    if (dictionary != null)
                    {
                        foreach (KeyValuePair <TnefPropertyTag, object> keyValuePair2 in dictionary)
                        {
                            this.WriteModifiedProperty(writer, reader, keyValuePair2.Key, keyValuePair2.Value, forceUnicode, ref flag, scratchBuffer);
                        }
                    }
                    if (this.newNamedProperties != null)
                    {
                        using (IEnumerator <KeyValuePair <TnefNameTag, object> > enumerator3 = this.newNamedProperties.GetEnumerator())
                        {
                            while (enumerator3.MoveNext())
                            {
                                KeyValuePair <TnefNameTag, object> keyValuePair3 = enumerator3.Current;
                                object obj = keyValuePair3.Value;
                                if (obj != null)
                                {
                                    TnefPropertyTag tag = new TnefPropertyTag((TnefPropertyId)(-32768), keyValuePair3.Key.Type);
                                    if (forceUnicode)
                                    {
                                        tag = tag.ToUnicode();
                                    }
                                    TnefPropertyBag.StartAttributeIfNecessary(writer, attributeTag, attributeLevel, ref flag);
                                    writer.StartProperty(tag, keyValuePair3.Key.Id.PropertySetGuid, keyValuePair3.Key.Id.Id);
                                    writer.WritePropertyValue(obj);
                                }
                            }
                            goto IL_3AC;
                        }
                        goto IL_37A;
                    }
                }
IL_3AC:
                if (!(result = reader.ReadNextAttribute()) || level != reader.AttributeLevel || TnefAttributeTag.AttachRenderData == reader.AttributeTag)
                {
                    break;
                }
                continue;
IL_37A:
                if (level != TnefAttributeLevel.Message || TnefAttributeTag.RecipientTable != reader.AttributeTag)
                {
                    writer.WriteAttribute(reader);
                    goto IL_3AC;
                }
                if (!dropRecipientTable)
                {
                    this.parentMessage.WriteRecipients(reader.PropertyReader, writer, ref array);
                    goto IL_3AC;
                }
                goto IL_3AC;
            }
            return(result);
        }
コード例 #9
0
 private static bool IsLegacyAttribute(TnefAttributeTag tag)
 {
     return(tag != TnefAttributeTag.MapiProperties && tag != TnefAttributeTag.Attachment && tag != TnefAttributeTag.RecipientTable);
 }