internal ConversionAddressCache(ConversionLimitsTracker limitsTracker, bool useSimpleDisplayName, bool ewsOutboundMimeConversion) : base(useSimpleDisplayName, ewsOutboundMimeConversion)
 {
     this.limitsTracker = limitsTracker;
     if (!this.limitsTracker.EnforceLimits)
     {
         this.disableLengthValidation = true;
     }
     this.propertyBag = new MemoryPropertyBag();
     this.propertyBag.SetAllPropertiesLoaded();
     this.recipients       = new ConversionRecipientList();
     this.replyTo          = new ReplyTo(this.propertyBag, false);
     this.itemParticipants = new ConversionItemParticipants(this.propertyBag, this.ewsOutboundMimeConversion);
     base.AddParticipantList(this.recipients);
     base.AddParticipantList(this.ReplyTo);
     base.AddParticipantList(this.itemParticipants);
     this.cacheProperties = new HashSet <NativeStorePropertyDefinition>(Util.MergeArrays <NativeStorePropertyDefinition>(new ICollection <NativeStorePropertyDefinition>[]
     {
         this.itemParticipants.CacheProperties,
         new NativeStorePropertyDefinition[]
         {
             InternalSchema.MapiReplyToBlob,
             InternalSchema.MapiReplyToNames
         }
     }));
 }
示例#2
0
 private void SetLimitsTracker(ConversionLimitsTracker limitsTracker)
 {
     this.limitsTracker = limitsTracker;
     if (this.IsTopLevelMessage)
     {
         this.limitsTracker.CountMessageBody();
     }
 }
 internal override void WriteMimePart(MimeStreamWriter mimeWriter, ConversionLimitsTracker limits, MimePartInfo part, ItemToMimeConverter.MimeFlags mimeFlags)
 {
     if ((mimeFlags & ItemToMimeConverter.MimeFlags.SkipContent) != ItemToMimeConverter.MimeFlags.SkipContent)
     {
         mimeWriter.WritePartWithHeaders(part.SmimePart, false);
         return;
     }
     mimeWriter.WriteHeadersFromPart(part.SmimePart);
 }
示例#4
0
 public ImapItemConverter(Item itemIn, OutboundConversionOptions options)
 {
     StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::ctor.");
     using (DisposeGuard disposeGuard = this.Guard())
     {
         Util.ThrowOnNullArgument(itemIn, "itemIn");
         Util.ThrowOnNullArgument(options, "options");
         Util.ThrowOnNullOrEmptyArgument(options.ImceaEncapsulationDomain, "options.ImceaEncapsulationDomain");
         if (!ItemConversion.IsItemClassConvertibleToMime(itemIn.ClassName))
         {
             StorageGlobals.ContextTraceError <string>(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::CheckItemType: wrong item type, {0}", itemIn.ClassName);
             throw new WrongObjectTypeException(ServerStrings.ConversionInvalidItemType(itemIn.ClassName));
         }
         this.itemIn  = itemIn;
         this.options = options;
         using (StorageGlobals.SetTraceContext(this.options))
         {
             using (StorageGlobals.SetTraceContext(this.itemIn))
             {
                 if (this.options.GenerateMimeSkeleton)
                 {
                     PropertyError propertyError = this.itemIn.TryGetProperty(InternalSchema.MimeSkeleton) as PropertyError;
                     if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound)
                     {
                         if (this.itemIn.IsReadOnly)
                         {
                             this.itemIn.OpenAsReadWrite();
                         }
                         this.itemNeedsSave = true;
                         using (Stream stream = this.itemIn.OpenPropertyStream(InternalSchema.MimeSkeleton, PropertyOpenMode.Create))
                         {
                             using (Stream stream2 = new MimeStreamWriter.MimeTextStream(null))
                             {
                                 using (ItemToMimeConverter itemToMimeConverter = new ItemToMimeConverter(itemIn, options, ConverterFlags.GenerateSkeleton))
                                 {
                                     using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(stream2, stream, itemToMimeConverter.GetItemMimeEncodingOptions(this.options), MimeStreamWriter.Flags.ForceMime))
                                     {
                                         ConversionLimitsTracker limits = new ConversionLimitsTracker(this.options.Limits);
                                         itemToMimeConverter.ConvertItemToMime(mimeStreamWriter, limits);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 ItemToMimeConverter itemToMimeConverter2 = new ItemToMimeConverter(itemIn, options, ConverterFlags.None);
                 this.mimeProvider        = IImapMimeProvider.CreateInstance(itemToMimeConverter2);
                 this.itemEncodingOptions = itemToMimeConverter2.GetItemMimeEncodingOptions(this.options);
             }
         }
         disposeGuard.Success();
     }
 }
示例#5
0
        internal InboundMessageWriter(ICoreItem item, InboundConversionOptions options, MimeMessageLevel messageLevel)
        {
            StorageGlobals.TraceConstructIDisposable(this);
            this.disposeTracker    = this.GetDisposeTracker();
            this.parent            = null;
            this.isTopLevelMessage = (messageLevel == MimeMessageLevel.TopLevelMessage);
            this.SetItem(item, options, false);
            ConversionLimitsTracker conversionLimitsTracker = new ConversionLimitsTracker(options.Limits);
            InboundAddressCache     addressCache            = new InboundAddressCache(options, conversionLimitsTracker, messageLevel);

            this.SetAddressCache(addressCache, true);
            this.SetLimitsTracker(conversionLimitsTracker);
            this.componentType = ConversionComponentType.Message;
        }
示例#6
0
        private InboundMessageWriter(InboundMessageWriter parent, ICoreItem item)
        {
            StorageGlobals.TraceConstructIDisposable(this);
            this.disposeTracker    = this.GetDisposeTracker();
            this.parent            = parent;
            this.isTopLevelMessage = false;
            this.SetItem(item, parent.ConversionOptions, true);
            ConversionLimitsTracker conversionLimitsTracker = parent.LimitsTracker;

            conversionLimitsTracker.StartEmbeddedMessage();
            InboundAddressCache addressCache = new InboundAddressCache(parent.ConversionOptions, conversionLimitsTracker, MimeMessageLevel.AttachedMessage);

            this.SetAddressCache(addressCache, true);
            this.SetLimitsTracker(conversionLimitsTracker);
            this.componentType = ConversionComponentType.Message;
        }
示例#7
0
 private void WriteMimePart(IImapMimeProvider mimeProvider, MimeStreamWriter writer, OutboundConversionOptions options, MimePartInfo partInfo, ItemToMimeConverter.MimeFlags conversionFlags)
 {
     try
     {
         ConvertUtils.CallCts(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::WriteMimePart", ServerStrings.ConversionCorruptContent, delegate
         {
             ConversionLimitsTracker limits = new ConversionLimitsTracker(options.Limits);
             mimeProvider.WriteMimePart(writer, limits, partInfo, conversionFlags);
         });
     }
     catch (StoragePermanentException exc)
     {
         ItemConversion.SaveFailedItem(this.itemIn, options, exc);
         throw;
     }
 }
        internal void ConvertItemToMsgStorage(Item item, Stream outStream)
        {
            MsgStorageWriter msgStorageWriter = null;

            try
            {
                msgStorageWriter = new MsgStorageWriter(outStream);
                ConversionLimitsTracker conversionLimitsTracker = new ConversionLimitsTracker(this.options.Limits);
                conversionLimitsTracker.CountMessageBody();
                this.InternalConvertItemToMsgStorage(item, msgStorageWriter, conversionLimitsTracker);
            }
            finally
            {
                if (msgStorageWriter != null)
                {
                    msgStorageWriter.Dispose();
                }
            }
        }
示例#9
0
 internal ItemToTnefConverter(Item itemIn, OutboundAddressCache addressCache, ItemToTnefConverter.TnefContentWriter writer, OutboundConversionOptions options, ConversionLimitsTracker limits, TnefType tnefType, bool parsingEmbeddedItem) : this(itemIn, addressCache, options, limits, tnefType, parsingEmbeddedItem)
 {
     this.tnefWriter         = writer;
     this.tnefCorrelationKey = null;
     this.propertyChecker    = new TnefPropertyChecker(tnefType, parsingEmbeddedItem, options);
     this.disposeTracker     = this.GetDisposeTracker();
 }
示例#10
0
        internal ItemToTnefConverter(Item itemIn, OutboundAddressCache addressCache, Stream mimeOut, OutboundConversionOptions options, ConversionLimitsTracker limits, TnefType tnefType, string tnefCorrelationKey, bool parsingEmbeddedItem) : this(itemIn, addressCache, options, limits, tnefType, parsingEmbeddedItem)
        {
            this.tnefCorrelationKey = tnefCorrelationKey;
            Charset itemWindowsCharset = ConvertUtils.GetItemWindowsCharset(this.item, options);

            this.tnefWriter      = new ItemToTnefConverter.TnefContentWriter(mimeOut, itemWindowsCharset);
            this.propertyChecker = new TnefPropertyChecker(tnefType, parsingEmbeddedItem, options);
            this.disposeTracker  = this.GetDisposeTracker();
        }
示例#11
0
 internal abstract void WriteMimePart(MimeStreamWriter mimeWriter, ConversionLimitsTracker limits, MimePartInfo part, ItemToMimeConverter.MimeFlags mimeFlags);
示例#12
0
 internal Context(Encoding encoding, OutboundConversionOptions options, ConversionLimitsTracker limitsTracker)
 {
     this.Encoding     = encoding;
     this.AddressCache = new OutboundAddressCache(options, limitsTracker);
     this.Options      = options;
 }
示例#13
0
        internal static void Convert(Stream dataStream, Encoding encoding, Contact contact, OutboundConversionOptions options, ConversionLimitsTracker limitsTracker)
        {
            Util.ThrowOnNullArgument(options, "options");
            Util.ThrowOnNullOrEmptyArgument(options.ImceaEncapsulationDomain, "options.ImceaEncapsulationDomain");
            ContactWriter contactWriter = new ContactWriter(dataStream, encoding);

            contactWriter.StartVCard();
            OutboundVCardConverter.PropertyExporter.Context context = new OutboundVCardConverter.PropertyExporter.Context(encoding, options, limitsTracker);
            foreach (OutboundVCardConverter.PropertyExporter propertyExporter in OutboundVCardConverter.exporters)
            {
                propertyExporter.Export(contactWriter, contact, context);
            }
            contactWriter.EndVCard();
        }
        private void InternalConvertItemToMsgStorage(Item item, MsgStorageWriter writer, ConversionLimitsTracker limitsTracker)
        {
            this.item          = item;
            this.writer        = writer;
            this.limitsTracker = limitsTracker;
            this.addressCache  = new OutboundAddressCache(this.options, limitsTracker);
            ExTimeZone exTimeZone = this.item.PropertyBag.ExTimeZone;

            this.item.PropertyBag.ExTimeZone = ExTimeZone.UtcTimeZone;
            try
            {
                this.addressCache.CopyDataFromItem(this.item);
                this.WriteMessageProperties();
                this.WriteRecipientTable();
                this.WriteAttachments();
                this.writer.Flush();
            }
            finally
            {
                this.item.PropertyBag.ExTimeZone = exTimeZone;
            }
        }
 internal override void WriteMimePart(MimeStreamWriter mimeWriter, ConversionLimitsTracker limits, MimePartInfo part, ItemToMimeConverter.MimeFlags mimeFlags)
 {
     this.itemConverter.WriteMimePart(mimeWriter, limits, part, mimeFlags);
 }
示例#16
0
 private ItemToTnefConverter(Item itemIn, OutboundAddressCache addressCache, OutboundConversionOptions options, ConversionLimitsTracker limits, TnefType tnefType, bool parsingEmbeddedItem)
 {
     if (options.FilterAttachmentHandler != null)
     {
         throw new NotSupportedException("FilterAttachmentHandler is not supported in ItemToTnefConverter");
     }
     if (options.FilterBodyHandler != null)
     {
         throw new NotSupportedException("FilterBodyHandler is not supported in ItemToTnefConverter");
     }
     this.item           = itemIn;
     this.addressCache   = addressCache;
     this.options        = options;
     this.limitsTracker  = limits;
     this.isEmbeddedItem = parsingEmbeddedItem;
     this.tnefType       = tnefType;
 }
示例#17
0
 internal OutboundAddressCache(OutboundConversionOptions options, ConversionLimitsTracker limitsTracker) : base(limitsTracker, options.UseSimpleDisplayName, options.EwsOutboundMimeConversion)
 {
     this.outboundOptions = options;
 }
 internal InboundAddressCache(InboundConversionOptions options, ConversionLimitsTracker limitsTracker, MimeMessageLevel messageLevel) : base(limitsTracker, false, false)
 {
     this.inboundOptions    = options;
     this.mimeMessageLevel  = messageLevel;
     this.tnefRecipientList = null;
 }