Ejemplo n.º 1
0
        public static bool IsMessage(string itemClass, bool includeCalendaringMessages = false)
        {
            bool flag = ObjectClass.IsOfClass(itemClass, "IPM.Note") || ObjectClass.IsOfClass(itemClass, "REPORT");

            if (includeCalendaringMessages)
            {
                flag |= (ObjectClass.IsMeetingMessage(itemClass) || ObjectClass.IsMeetingMessageSeries(itemClass));
            }
            return(flag);
        }
Ejemplo n.º 2
0
        private static void CompleteFlagStatus(PropertyBag.BasicPropertyStore propertyBag)
        {
            string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsMeetingMessage(valueOrDefault))
            {
                propertyBag.Delete(InternalSchema.MapiFlagStatus);
                propertyBag.Delete(InternalSchema.ItemColor);
                propertyBag.SetValueWithFixup(InternalSchema.TaskStatus, TaskStatus.Completed);
                return;
            }
            propertyBag.SetValueWithFixup(InternalSchema.MapiFlagStatus, FlagStatus.Complete);
            propertyBag.SetValueWithFixup(InternalSchema.TaskStatus, TaskStatus.Completed);
            propertyBag.Delete(InternalSchema.ItemColor);
        }
Ejemplo n.º 3
0
 private static string GenerateWhen(Item item)
 {
     if (item is MeetingMessage)
     {
         return((item as MeetingMessage).GenerateWhen());
     }
     if (item is CalendarItemBase)
     {
         return((item as CalendarItemBase).GenerateWhen());
     }
     if (ObjectClass.IsMeetingMessage(item.ClassName))
     {
         return(string.Empty);
     }
     throw new ArgumentException("Unsupported type, this is a bug");
 }
Ejemplo n.º 4
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            bool?  flag           = null;
            string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault) || ObjectClass.IsCalendarItemSeries(valueOrDefault))
            {
                AppointmentStateFlags valueOrDefault2 = propertyBag.GetValueOrDefault <AppointmentStateFlags>(InternalSchema.AppointmentStateInternal);
                flag = new bool?(IsOrganizerProperty.GetForCalendarItem(valueOrDefault, valueOrDefault2));
            }
            else if (ObjectClass.IsMeetingMessage(valueOrDefault))
            {
                MeetingMessage meetingMessage = propertyBag.Context.StoreObject as MeetingMessage;
                if (meetingMessage != null)
                {
                    CalendarItemBase calendarItemBase = null;
                    try
                    {
                        calendarItemBase = meetingMessage.GetCorrelatedItemInternal(true);
                    }
                    catch (CorruptDataException)
                    {
                    }
                    catch (CorrelationFailedException)
                    {
                    }
                    if (calendarItemBase != null)
                    {
                        flag = new bool?(calendarItemBase.IsOrganizer());
                    }
                    else if (!(meetingMessage is MeetingResponse))
                    {
                        flag = new bool?(meetingMessage.IsMailboxOwnerTheSender());
                    }
                }
            }
            if (flag != null)
            {
                return(flag);
            }
            return(new PropertyError(this, PropertyErrorCode.NotFound));
        }
Ejemplo n.º 5
0
        private static Charset GetItemOutboundMimeCharsetInternal(Item item, OutboundConversionOptions options)
        {
            object  obj            = item.TryGetProperty(InternalSchema.InternetCpid);
            bool    valueOrDefault = item.GetValueOrDefault <bool>(InternalSchema.IsAutoForwarded, false);
            string  className      = item.ClassName;
            Charset charset        = null;

            if (valueOrDefault || (obj is PropertyError && !item.Body.IsBodyDefined) || (options != null && options.DetectionOptions.PreferredCharset != null && (options.DetectionOptions.RequiredCoverage < 100 || ObjectClass.IsTaskRequest(className) || ObjectClass.IsMeetingMessage(className))))
            {
                charset = ConvertUtils.DetectOutboundCharset(item, options, obj, !valueOrDefault);
                if (charset != null)
                {
                    if (!item.CharsetDetector.IsItemCharsetKnownWithoutDetection(BodyCharsetFlags.DisableCharsetDetection, charset, out charset))
                    {
                        throw new InvalidOperationException();
                    }
                    return(charset);
                }
            }
            if (!(obj is PropertyError) && Charset.TryGetCharset((int)obj, out charset) && ConvertUtils.TryTransformCharset(ref charset))
            {
                return(charset);
            }
            object obj2 = item.TryGetProperty(InternalSchema.Codepage);

            if (!(obj2 is PropertyError) && Charset.TryGetCharset((int)obj2, out charset))
            {
                charset = charset.Culture.MimeCharset;
                if (ConvertUtils.TryTransformCharset(ref charset))
                {
                    return(charset);
                }
            }
            return(Charset.GetCharset(65001));
        }
Ejemplo n.º 6
0
        internal static Charset GetItemOutboundMimeCharset(Item item, OutboundConversionOptions options)
        {
            Charset charset   = ConvertUtils.GetItemOutboundMimeCharsetInternal(item, options);
            string  className = item.ClassName;

            if (options.DetectionOptions.PreferredCharset == null && charset.CodePage != 54936 && (ObjectClass.IsTaskRequest(className) || ObjectClass.IsMeetingMessage(className) || ObjectClass.IsCalendarItem(className)))
            {
                charset = Charset.GetCharset(65001);
            }
            return(charset);
        }
Ejemplo n.º 7
0
        public static void CreateForwardReplyHeader(ReplyForwardConfiguration configuration, Item item, ForwardReplyHeaderOptions headerOptions = null)
        {
            if (!(item is MessageItem) && !(item is CalendarItemBase) && !(item is PostItem))
            {
                throw new ArgumentException("HTML reply forward headers can only be created for MessageItem, CalendarItemBase and PostItem");
            }
            if (headerOptions == null)
            {
                headerOptions = new ForwardReplyHeaderOptions();
            }
            CultureInfo cultureInfo = configuration.Culture ?? item.Session.InternalCulture;

            if (item is PostItem)
            {
                ReplyForwardHeader.CreatePostReplyForwardHeader(configuration, item, headerOptions, cultureInfo);
            }
            IList <IRecipientBase> toRecipients = null;
            IList <IRecipientBase> ccRecipients = null;
            string from          = string.Empty;
            string sender        = null;
            string fromLabel     = ClientStrings.FromColon.ToString(cultureInfo);
            string toLabel       = ClientStrings.ToColon.ToString(cultureInfo);
            string ccLabel       = ClientStrings.CcColon.ToString(cultureInfo);
            bool   isMeetingItem = ObjectClass.IsMeetingMessage(item.ClassName);

            if (item is MessageItem)
            {
                MessageItem messageItem = (MessageItem)item;
                if (messageItem.From != null)
                {
                    from = messageItem.From.DisplayName;
                }
                if (messageItem.Sender != null)
                {
                    sender = messageItem.Sender.DisplayName;
                }
                toRecipients = ReplyForwardHeader.GetMessageRecipientCollection(RecipientItemType.To, messageItem);
                ccRecipients = ReplyForwardHeader.GetMessageRecipientCollection(RecipientItemType.Cc, messageItem);
            }
            else if (item is CalendarItemBase)
            {
                CalendarItemBase calendarItemBase = (CalendarItemBase)item;
                if (calendarItemBase.Organizer != null)
                {
                    from = calendarItemBase.Organizer.DisplayName;
                }
                toRecipients = ReplyForwardHeader.GetCalendarItemRecipientCollection(AttendeeType.Required, calendarItemBase);
                ccRecipients = ReplyForwardHeader.GetCalendarItemRecipientCollection(AttendeeType.Optional, calendarItemBase);
            }
            BodyInjectionFormat bodyPrefixFormat;
            string bodyPrefix;

            switch (configuration.TargetFormat)
            {
            case BodyFormat.TextPlain:
                bodyPrefixFormat = BodyInjectionFormat.Text;
                bodyPrefix       = ReplyForwardHeader.CreateTextReplyForwardHeader(item, headerOptions, fromLabel, from, sender, toLabel, ccLabel, toRecipients, ccRecipients, isMeetingItem, cultureInfo, configuration.TimeZone);
                break;

            case BodyFormat.TextHtml:
            case BodyFormat.ApplicationRtf:
                bodyPrefixFormat = BodyInjectionFormat.Html;
                bodyPrefix       = ReplyForwardHeader.CreateHtmlReplyForwardHeader(item, headerOptions, fromLabel, from, sender, toLabel, ccLabel, toRecipients, ccRecipients, isMeetingItem, cultureInfo, configuration.TimeZone);
                break;

            default:
                throw new ArgumentException("Unsupported body format");
            }
            configuration.AddBodyPrefix(bodyPrefix, bodyPrefixFormat);
        }
Ejemplo n.º 8
0
 private void WriteRecipientTable()
 {
     if (this.tnefType != TnefType.LegacyTnef || this.isEmbeddedItem)
     {
         this.tnefWriter.StartAttribute(TnefAttributeTag.RecipientTable, TnefAttributeLevel.Message);
         List <ConversionRecipientEntry> recipients = this.addressCache.Recipients;
         if (recipients != null)
         {
             this.conversionResult.RecipientCount = recipients.Count;
             foreach (ConversionRecipientEntry conversionRecipientEntry in recipients)
             {
                 if (!(this.item is MessageItem) || this.options.DemoteBcc || conversionRecipientEntry.RecipientItemType != RecipientItemType.Bcc || ((conversionRecipientEntry.Participant.GetValueOrDefault <bool>(ParticipantSchema.IsRoom, false) || conversionRecipientEntry.Participant.GetValueOrDefault <bool>(ParticipantSchema.IsResource, false)) && ObjectClass.IsMeetingMessage(this.item.ClassName)))
                 {
                     this.WriteRecipient(conversionRecipientEntry);
                 }
             }
         }
     }
 }
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            string text = validatablePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;

            if (!string.IsNullOrEmpty(text) && (ObjectClass.IsCalendarItem(text) || ObjectClass.IsRecurrenceException(text) || ObjectClass.IsMeetingMessage(text)) && validatablePropertyBag.IsPropertyDirty(InternalSchema.AppointmentStateInternal))
            {
                object obj = validatablePropertyBag.TryGetProperty(InternalSchema.AppointmentStateInternal);
                if (obj is int)
                {
                    AppointmentStateFlags appointmentStateFlags = (AppointmentStateFlags)obj;
                    if (EnumValidator <AppointmentStateFlags> .IsValidValue(appointmentStateFlags))
                    {
                        PropertyValueTrackingData originalPropertyInformation = validatablePropertyBag.GetOriginalPropertyInformation(InternalSchema.AppointmentStateInternal);
                        if (originalPropertyInformation.PropertyValueState == PropertyTrackingInformation.Modified && originalPropertyInformation.OriginalPropertyValue != null && !PropertyError.IsPropertyNotFound(originalPropertyInformation.OriginalPropertyValue))
                        {
                            AppointmentStateFlags appointmentStateFlags2 = (AppointmentStateFlags)originalPropertyInformation.OriginalPropertyValue;
                            bool flag  = (appointmentStateFlags2 & AppointmentStateFlags.Received) == AppointmentStateFlags.None;
                            bool flag2 = (appointmentStateFlags & AppointmentStateFlags.Received) == AppointmentStateFlags.None;
                            if (flag != flag2)
                            {
                                return(new StoreObjectValidationError(context, InternalSchema.AppointmentStateInternal, obj, this));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 10
0
        private ConflictResolutionResult ApplyAcr(PropertyBag acrPropBag, SaveMode saveMode)
        {
            Dictionary <PropertyDefinition, AcrPropertyProfile.ValuesToResolve> valuesToResolve = this.GetValuesToResolve(acrPropBag);
            string valueOrDefault = this.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault) || ObjectClass.IsMeetingMessage(valueOrDefault))
            {
                LocationIdentifierHelper           locationIdentifierHelper = new LocationIdentifierHelper();
                AcrPropertyProfile.ValuesToResolve valuesToResolve2;
                object serverValue;
                if (valuesToResolve.TryGetValue(InternalSchema.ChangeList, out valuesToResolve2))
                {
                    locationIdentifierHelper.ChangeBuffer = (byte[])valuesToResolve2.ClientValue;
                    serverValue = valuesToResolve2.ServerValue;
                }
                else
                {
                    serverValue = new PropertyError(InternalSchema.ChangeList, PropertyErrorCode.NotFound);
                }
                locationIdentifierHelper.SetLocationIdentifier(53909U, LastChangeAction.AcrPerformed);
                valuesToResolve2 = new AcrPropertyProfile.ValuesToResolve(locationIdentifierHelper.ChangeBuffer, serverValue, null);
                valuesToResolve[InternalSchema.ChangeList] = valuesToResolve2;
            }
            ConflictResolutionResult conflictResolutionResult = this.profile.ResolveConflicts(valuesToResolve);

            if (this.propertiesWrittenAsStream.Count > 0)
            {
                List <PropertyConflict> list = new List <PropertyConflict>(conflictResolutionResult.PropertyConflicts);
                foreach (PropertyDefinition propertyDefinition in this.propertiesWrittenAsStream.Keys)
                {
                    PropertyConflict item = new PropertyConflict(propertyDefinition, null, null, null, null, false);
                    list.Add(item);
                }
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, list.ToArray());
            }
            if (this.irresolvableChanges || saveMode == SaveMode.FailOnAnyConflict)
            {
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, conflictResolutionResult.PropertyConflicts);
            }
            if (conflictResolutionResult.SaveStatus != SaveResult.IrresolvableConflict)
            {
                List <PropertyDefinition> list2 = new List <PropertyDefinition>();
                List <PropertyDefinition> list3 = new List <PropertyDefinition>();
                List <object>             list4 = new List <object>();
                if (this.propertyBag == acrPropBag)
                {
                    foreach (PropertyConflict propertyConflict in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict.ResolvedValue) && (!PropertyError.IsPropertyError(propertyConflict.ClientValue) || !PropertyError.IsPropertyNotFound(propertyConflict.ClientValue)))
                            {
                                list2.Add(propertyConflict.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict.ResolvedValue != propertyConflict.ClientValue)
                        {
                            list3.Add(propertyConflict.PropertyDefinition);
                            list4.Add(propertyConflict.ResolvedValue);
                        }
                    }
                }
                else
                {
                    foreach (PropertyConflict propertyConflict2 in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict2.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict2.ResolvedValue))
                            {
                                list2.Add(propertyConflict2.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict2.ServerValue != propertyConflict2.ResolvedValue)
                        {
                            list3.Add(propertyConflict2.PropertyDefinition);
                            list4.Add(propertyConflict2.ResolvedValue);
                        }
                    }
                }
                for (int k = 0; k < list2.Count; k++)
                {
                    acrPropBag.Delete(list2[k]);
                }
                for (int l = 0; l < list3.Count; l++)
                {
                    acrPropBag[list3[l]] = list4[l];
                }
            }
            return(conflictResolutionResult);
        }
Ejemplo n.º 11
0
        public static MessageItem CreateForward(MessageItem originalItem, bool asAttachment, CultureInfo culture, string imceaDomain, string xLoop, ExTimeZone timeZone, IRuleEvaluationContext context)
        {
            Util.ThrowOnNullArgument(originalItem, "originalItem");
            Util.ThrowOnNullArgument(culture, "culture");
            Util.ThrowOnNullOrEmptyArgument(imceaDomain, "imceaDomain");
            ExTraceGlobals.StorageTracer.Information(0L, "RuleMessageUtils::CreateForward.");
            MessageItem messageItem = null;
            bool        flag        = false;
            MessageItem result;

            try
            {
                ForwardCreationFlags forwardCreationFlags = ForwardCreationFlags.None;
                string className = originalItem.ClassName;
                if (ObjectClass.IsMeetingMessage(className))
                {
                    forwardCreationFlags |= ForwardCreationFlags.TreatAsMeetingMessage;
                }
                messageItem = context.CreateMessageItem(InternalSchema.ContentConversionProperties);
                messageItem[InternalSchema.ItemClass] = "IPM.Note";
                StoreSession storeSession = context.StoreSession ?? originalItem.Session;
                if (asAttachment)
                {
                    ForwardAsAttachmentCreation forwardAsAttachmentCreation = new ForwardAsAttachmentCreation(originalItem, messageItem, new ReplyForwardConfiguration(forwardCreationFlags, culture)
                    {
                        XLoop    = xLoop,
                        TimeZone = timeZone,
                        ConversionOptionsForSmime = new InboundConversionOptions(storeSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), imceaDomain)
                    });
                    forwardAsAttachmentCreation.PopulateProperties();
                }
                else
                {
                    bool flag2        = ObjectClass.IsMeetingCancellation(className);
                    bool flag3        = ObjectClass.IsMeetingRequest(className);
                    bool isRestricted = originalItem.IsRestricted;
                    if (flag2)
                    {
                        messageItem[InternalSchema.ItemClass] = "IPM.Schedule.Meeting.Canceled";
                        messageItem[InternalSchema.IconIndex] = IconIndex.AppointmentMeetCancel;
                    }
                    else if (flag3)
                    {
                        messageItem[InternalSchema.ItemClass]           = "IPM.Schedule.Meeting.Request";
                        messageItem[InternalSchema.IsResponseRequested] = true;
                        messageItem[InternalSchema.IsReplyRequested]    = true;
                    }
                    else if (isRestricted)
                    {
                        messageItem[StoreObjectSchema.ContentClass] = "rpmsg.message";
                        messageItem.IconIndex = IconIndex.MailIrm;
                    }
                    BodyFormat format = originalItem.Body.Format;
                    ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(format, forwardCreationFlags, culture);
                    replyForwardConfiguration.XLoop    = xLoop;
                    replyForwardConfiguration.TimeZone = timeZone;
                    replyForwardConfiguration.ConversionOptionsForSmime = new InboundConversionOptions(storeSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), imceaDomain);
                    RuleMessageUtils.GenerateHeader(replyForwardConfiguration, originalItem);
                    ForwardCreation forwardCreation = new ForwardCreation(originalItem, messageItem, replyForwardConfiguration);
                    forwardCreation.PopulateProperties();
                    if (flag2 || flag3)
                    {
                        AppointmentStateFlags appointmentStateFlags = messageItem.GetValueOrDefault <AppointmentStateFlags>(InternalSchema.AppointmentState);
                        appointmentStateFlags |= (AppointmentStateFlags.Meeting | AppointmentStateFlags.Received);
                        messageItem[InternalSchema.AppointmentState] = appointmentStateFlags;
                        int num = messageItem.GetValueOrDefault <int>(InternalSchema.AppointmentAuxiliaryFlags, 0);
                        num |= 4;
                        messageItem[InternalSchema.AppointmentAuxiliaryFlags] = num;
                        if (flag3)
                        {
                            List <BlobRecipient> list = BlobRecipientParser.ReadRecipients(originalItem, InternalSchema.UnsendableRecipients);
                            list = MeetingRequest.FilterBlobRecipientList(list);
                            list = MeetingRequest.MergeRecipientLists(originalItem.Recipients, list);
                            list = MeetingRequest.FilterBlobRecipientList(list);
                            BlobRecipientParser.WriteRecipients(messageItem, InternalSchema.UnsendableRecipients, list);
                        }
                    }
                }
                flag   = true;
                result = messageItem;
            }
            finally
            {
                if (!flag && messageItem != null)
                {
                    messageItem.Dispose();
                    messageItem = null;
                }
            }
            return(result);
        }
Ejemplo n.º 12
0
 private static OutlookModule GetModuleForObjectClass(string objectClass)
 {
     if (objectClass == null)
     {
         return(OutlookModule.None);
     }
     if (ObjectClass.IsCalendarFolder(objectClass) || ObjectClass.IsCalendarItem(objectClass))
     {
         return(OutlookModule.Calendar);
     }
     if (ObjectClass.IsContactsFolder(objectClass) || ObjectClass.IsContact(objectClass) || ObjectClass.IsDistributionList(objectClass))
     {
         return(OutlookModule.Contacts);
     }
     if (ObjectClass.IsJournalFolder(objectClass) || ObjectClass.IsJournalItem(objectClass))
     {
         return(OutlookModule.Journal);
     }
     if (ObjectClass.IsNotesFolder(objectClass) || ObjectClass.IsNotesItem(objectClass))
     {
         return(OutlookModule.Notes);
     }
     if (ObjectClass.IsTaskFolder(objectClass) || ObjectClass.IsTask(objectClass))
     {
         return(OutlookModule.Tasks);
     }
     if (ObjectClass.IsMessageFolder(objectClass) || ObjectClass.IsMessage(objectClass, false) || ObjectClass.IsMeetingMessage(objectClass) || ObjectClass.IsTaskRequest(objectClass) || ObjectClass.IsReport(objectClass))
     {
         return(OutlookModule.Mail);
     }
     return(OutlookModule.None);
 }
Ejemplo n.º 13
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            string valueOrDefault = propertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass);

            if (valueOrDefault == null)
            {
                return(RecurrenceType.None);
            }
            if (ObjectClass.IsTask(valueOrDefault) || ObjectClass.IsTaskRequest(valueOrDefault))
            {
                if (propertyBag.GetValueOrDefault <bool>(InternalSchema.IsOneOff))
                {
                    return(RecurrenceType.None);
                }
                byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TaskRecurrence);
                return(RecurrenceTypeProperty.GetTaskRecurrenceTypeFromBlob(valueOrDefault2));
            }
            else
            {
                if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault) || ObjectClass.IsMeetingMessage(valueOrDefault))
                {
                    return(propertyBag.GetValueOrDefault <RecurrenceType>(InternalSchema.MapiRecurrenceType));
                }
                return(RecurrenceType.None);
            }
        }