Ejemplo n.º 1
0
        private void Initialize(Item originalItem, bool isReplyAll, bool shouldUseSender)
        {
            this.isReplyAll      = isReplyAll;
            this.shouldUseSender = shouldUseSender;
            LastAction lastAction;

            if (isReplyAll)
            {
                lastAction = LastAction.ReplyToAll;
            }
            else
            {
                lastAction = LastAction.ReplyToSender;
            }
            IconIndex iconIndex = IconIndex.MailReplied;

            if (this.originalItemSigned)
            {
                iconIndex = IconIndex.MailSmimeSignedReplied;
            }
            else if (this.originalItemEncrypted)
            {
                iconIndex = IconIndex.MailEncryptedReplied;
            }
            else if (this.originalItemIrm)
            {
                iconIndex = IconIndex.MailIrmReplied;
            }
            if (originalItem.Id != null && originalItem.Id.ObjectId != null && !originalItem.Id.ObjectId.IsFakeId && !(originalItem is PostItem))
            {
                this.newItem.SafeSetProperty(InternalSchema.ReplyForwardStatus, ReplyForwardUtils.EncodeReplyForwardStatus(lastAction, iconIndex, originalItem.Id));
            }
        }
Ejemplo n.º 2
0
 internal static string EncodeReplyForwardStatus(LastAction lastAction, IconIndex iconIndex, VersionedId id)
 {
     if (id == null)
     {
         return(string.Empty);
     }
     return(ReplyForwardUtils.EncodeReplyForwardStatus(lastAction, iconIndex, id.ToBase64String()));
 }
Ejemplo n.º 3
0
        internal VotingResponse(MessageItem originalItem, MessageItem newItem, ReplyForwardConfiguration configuration, string votingResponse) : base(originalItem, newItem, configuration, true)
        {
            this.votingResponse = votingResponse;
            this.newItem.SafeSetProperty(InternalSchema.IsVotingResponse, 1);
            int lastAction = originalItem.VotingInfo.GetOptionsList().IndexOf(votingResponse) + 1;

            this.newItem.SafeSetProperty(InternalSchema.ReplyForwardStatus, ReplyForwardUtils.EncodeReplyForwardStatus((LastAction)lastAction, IconIndex.MailReplied, originalItem.Id));
        }
Ejemplo n.º 4
0
        internal static void UpdateOriginalItemProperties(Item sentItem)
        {
            object[] array = ReplyForwardUtils.DecodeReplyForwardStatus(sentItem.TryGetProperty(InternalSchema.ReplyForwardStatus) as string);
            if (array == null)
            {
                return;
            }
            if ((int)array[0] < 0)
            {
                return;
            }
            PropertyDefinition[] array2 = new PropertyDefinition[]
            {
                InternalSchema.LastVerbExecuted,
                InternalSchema.LastVerbExecutionTime,
                InternalSchema.IconIndex,
                InternalSchema.MessageAnswered
            };
            object[]    array3  = new object[array2.Length];
            VersionedId storeId = VersionedId.Deserialize((string)array[2]);

            try
            {
                using (Item item = Item.Bind(sentItem.Session, storeId))
                {
                    if (!(item is CalendarItemBase))
                    {
                        array3[0] = (int)array[0];
                        array3[1] = ExDateTime.GetNow(sentItem.Session.ExTimeZone);
                        if (item is MeetingMessage)
                        {
                            array3[2] = item.GetValueOrDefault <int>(InternalSchema.IconIndex, -1);
                        }
                        else
                        {
                            array3[2] = (int)array[1];
                        }
                        array3[3] = true;
                        item.SetProperties(array2, array3);
                        ConflictResolutionResult conflictResolutionResult = item.Save(SaveMode.ResolveConflicts);
                        if (conflictResolutionResult.SaveStatus != SaveResult.Success)
                        {
                            ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "ReplyForwardCommon::UpdateOriginalItemProperties. {0}", "The original item has been changed thus update on the original item may not be done accurately.");
                        }
                    }
                }
            }
            catch (StoragePermanentException arg)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <StoragePermanentException>(0L, "ReplyForwardCommon::UpdateOriginalItemProperties. The parent item cannot be found. It might have been deleted. Exception = {0}.", arg);
            }
            catch (StorageTransientException arg2)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <StorageTransientException>(0L, "ReplyForwardCommon::UpdateOriginalItemProperties. The parent item cannot be found. It might have been deleted. Exception = {0}.", arg2);
            }
        }
Ejemplo n.º 5
0
        internal static VersionedId GetAssociatedId(MessageItem message)
        {
            string valueOrDefault = message.GetValueOrDefault <string>(InternalSchema.ReplyForwardStatus, string.Empty);

            object[]    array  = ReplyForwardUtils.DecodeReplyForwardStatus(valueOrDefault);
            VersionedId result = null;

            if (array != null && array.Length == 3 && array[2] is string)
            {
                result = VersionedId.Deserialize(Convert.FromBase64String((string)array[2]));
            }
            return(result);
        }
Ejemplo n.º 6
0
        internal static CultureInfo CalculateReplyForwardCulture(CultureInfo culture, Item newItem)
        {
            CultureInfo cultureInfo = null;

            if (culture != null)
            {
                cultureInfo = culture;
            }
            else if (newItem.Session != null)
            {
                cultureInfo = newItem.Session.InternalCulture;
            }
            if (cultureInfo != null && LocaleMap.GetLcidFromCulture(cultureInfo) == 4100)
            {
                return(ReplyForwardUtils.GetCultureEnglishUS());
            }
            return(cultureInfo);
        }
Ejemplo n.º 7
0
        internal ForwardCreation(Item originalItem, MessageItem message, ReplyForwardConfiguration parameters) : base(originalItem, message, parameters, true)
        {
            LastAction lastAction = LastAction.Forward;
            IconIndex  iconIndex  = IconIndex.MailForwarded;

            if (this.originalItemSigned)
            {
                iconIndex = IconIndex.MailSmimeSignedForwarded;
            }
            else if (this.originalItemEncrypted)
            {
                iconIndex = IconIndex.MailEncryptedForwarded;
            }
            else if (this.originalItemIrm)
            {
                iconIndex = IconIndex.MailIrmForwarded;
            }
            if (originalItem.Id != null && originalItem.Id.ObjectId != null && !originalItem.Id.ObjectId.IsFakeId && !(originalItem is PostItem))
            {
                this.newItem.SafeSetProperty(InternalSchema.ReplyForwardStatus, ReplyForwardUtils.EncodeReplyForwardStatus(lastAction, iconIndex, originalItem.Id));
            }
        }
Ejemplo n.º 8
0
        internal ReplyForwardCommon(Item originalItem, Item newItem, ReplyForwardConfiguration parameters, bool decodeSmime)
        {
            Util.ThrowOnNullArgument(parameters, "parameters");
            if (decodeSmime && ObjectClass.IsSmime(originalItem.ClassName))
            {
                if (parameters.ConversionOptionsForSmime == null || parameters.ConversionOptionsForSmime.IgnoreImceaDomain || parameters.ConversionOptionsForSmime.ImceaEncapsulationDomain == null)
                {
                    throw new InvalidOperationException("Cannot decode SMIME without valid ConversionOptionsForSmime");
                }
                this.originalItem = originalItem;
                MessageItem messageItem = originalItem as MessageItem;
                if (messageItem != null)
                {
                    Item item = messageItem.FetchSmimeContent(parameters.ConversionOptionsForSmime.ImceaEncapsulationDomain);
                    if (item != null)
                    {
                        this.originalItem = item;
                        this.originalItem[InternalSchema.NormalizedSubjectInternal] = messageItem.GetValueOrDefault <string>(InternalSchema.NormalizedSubjectInternal, string.Empty);
                        this.originalItem[InternalSchema.Sender] = messageItem.Sender;
                        this.originalItem[InternalSchema.From]   = messageItem.From;
                    }
                }
            }
            else
            {
                this.originalItem = originalItem;
            }
            this.newItem    = newItem;
            this.parameters = parameters;
            this.culture    = ReplyForwardUtils.CalculateReplyForwardCulture(parameters.Culture, newItem);
            if (this.culture == null)
            {
                throw new InvalidOperationException("Forward message culture is unknown");
            }
            this.FetchPropertiesFromOriginalItem();
            if (originalItem is MessageItem)
            {
                if (originalItem.MapiMessage != null)
                {
                    SetReadFlags readFlag = parameters.ShouldSuppressReadReceipt ? SetReadFlags.SuppressReceipt : SetReadFlags.None;
                    try
                    {
                        StoreSession session = originalItem.Session;
                        bool         flag    = false;
                        try
                        {
                            if (session != null)
                            {
                                session.BeginMapiCall();
                                session.BeginServerHealthCall();
                                flag = true;
                            }
                            if (StorageGlobals.MapiTestHookBeforeCall != null)
                            {
                                StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                            }
                            originalItem.MapiMessage.SetReadFlag(readFlag);
                        }
                        catch (MapiPermanentException ex)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex, session, this, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("ReplyForwardCommon::ctor.", new object[0]),
                                ex
                            });
                        }
                        catch (MapiRetryableException ex2)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("ReplyForwardCommon::ctor.", new object[0]),
                                ex2
                            });
                        }
                        finally
                        {
                            try
                            {
                                if (session != null)
                                {
                                    session.EndMapiCall();
                                    if (flag)
                                    {
                                        session.EndServerHealthCall();
                                    }
                                }
                            }
                            finally
                            {
                                if (StorageGlobals.MapiTestHookAfterCall != null)
                                {
                                    StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                                }
                            }
                        }
                    }
                    catch (StoragePermanentException)
                    {
                    }
                    catch (StorageTransientException)
                    {
                    }
                }
                (this.originalItem as MessageItem).IsRead = true;
            }
            else if (this.originalItem is CalendarItemOccurrence)
            {
                this.parentPropValues[ParentPropertyIndex.IsRecurring]               = true;
                this.parentPropValues[ParentPropertyIndex.AppointmentRecurring]      = false;
                this.parentPropValues[ParentPropertyIndex.RecurrenceType]            = 0;
                this.parentPropValues[ParentPropertyIndex.TimeZoneBlob]              = new PropertyError(InternalSchema.TimeZoneBlob, PropertyErrorCode.NotFound);
                this.parentPropValues[ParentPropertyIndex.AppointmentRecurrenceBlob] = new PropertyError(InternalSchema.AppointmentRecurrenceBlob, PropertyErrorCode.NotFound);
                this.parentPropValues[ParentPropertyIndex.IsException]               = true;
                if (string.IsNullOrEmpty(this.parentPropValues[ParentPropertyIndex.RecurrencePattern] as string))
                {
                    CalendarItemOccurrence calendarItemOccurrence = this.originalItem as CalendarItemOccurrence;
                    this.parentPropValues[ParentPropertyIndex.RecurrencePattern] = calendarItemOccurrence.OccurrencePropertyBag.MasterCalendarItem.GenerateWhen();
                }
            }
            string valueOrDefault = originalItem.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            this.originalItemSigned = (ObjectClass.IsOfClass(valueOrDefault, "IPM.Note.Secure.Sign") || ObjectClass.IsSmimeClearSigned(valueOrDefault));
            if (!this.originalItemSigned)
            {
                this.originalItemEncrypted = (ObjectClass.IsOfClass(valueOrDefault, "IPM.Note.Secure") || ObjectClass.IsSmime(valueOrDefault));
            }
            string valueOrDefault2 = originalItem.GetValueOrDefault <string>(InternalSchema.ContentClass, string.Empty);

            this.originalItemIrm = ObjectClass.IsRightsManagedContentClass(valueOrDefault2);
        }
Ejemplo n.º 9
0
 internal static void SetAssociatedId(MessageItem message, VersionedId associatedId)
 {
     message.SafeSetProperty(InternalSchema.ReplyForwardStatus, ReplyForwardUtils.EncodeReplyForwardStatus((LastAction)(-1), IconIndex.Default, associatedId));
 }