// Token: 0x060014EB RID: 5355 RVA: 0x00079B0C File Offset: 0x00077D0C
        private void LoadPictureData(StreamAttachment picture)
        {
            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.GetPicture(), getting picture attachment data.");
            Stream stream = null;

            try
            {
                stream = picture.GetContentStream();
                if (stream.Length <= 37500L)
                {
                    byte[] array = new byte[stream.Length];
                    int    num   = stream.Read(array, 0, array.Length);
                    if (num == array.Length)
                    {
                        this.cachedPicture = Convert.ToBase64String(array);
                    }
                }
            }
            catch (ObjectNotFoundException)
            {
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        // Token: 0x06000F44 RID: 3908 RVA: 0x00056F60 File Offset: 0x00055160
        protected override void InternalCopyFrom(IProperty srcProperty)
        {
            IAttachments12Property attachments12Property = srcProperty as IAttachments12Property;

            if (attachments12Property == null)
            {
                throw new UnexpectedTypeException("IAttachments12Property", srcProperty);
            }
            base.XmlNode = base.XmlParentNode.OwnerDocument.CreateElement(base.AirSyncTagNames[0], base.Namespace);
            foreach (Attachment12Data attachment12Data in attachments12Property)
            {
                XmlNode xmlNode = base.XmlParentNode.OwnerDocument.CreateElement("Attachment", base.Namespace);
                this.CopyAttachment(xmlNode, attachment12Data);
                if (attachment12Data.Id != null)
                {
                    this.nodeMap[attachment12Data.Id] = base.XmlNode.AppendChild(xmlNode);
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.XsoTracer, this, "Skip attachment {0}, its ID is null", attachment12Data.DisplayName);
                }
            }
            if (base.XmlNode.HasChildNodes)
            {
                base.XmlParentNode.AppendChild(base.XmlNode);
                base.PostProcessingDelegate = new PropertyBase.PostProcessProperties(this.PostProcessAttachments);
            }
        }
        // Token: 0x060014E8 RID: 5352 RVA: 0x000798B4 File Offset: 0x00077AB4
        protected override void InternalSetToDefault(IProperty srcProperty)
        {
            Contact contact = base.XsoItem as Contact;

            contact.Load(new PropertyDefinition[]
            {
                XsoPictureProperty.hasPicture
            });
            object obj = contact.TryGetProperty(XsoPictureProperty.hasPicture);

            if (obj != null && obj is bool && (bool)obj)
            {
                foreach (AttachmentHandle handle in contact.AttachmentCollection)
                {
                    using (Attachment attachment = contact.AttachmentCollection.Open(handle))
                    {
                        attachment.Load(new PropertyDefinition[]
                        {
                            XsoPictureProperty.ispictureAttach
                        });
                        obj = attachment.TryGetProperty(XsoPictureProperty.ispictureAttach);
                        if (obj != null && obj is bool && (bool)obj)
                        {
                            contact.AttachmentCollection.Remove(attachment.Id);
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.InternalSetToDefault(), removed picture attachment");
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        // Token: 0x0600147E RID: 5246 RVA: 0x00076708 File Offset: 0x00074908
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            string  stringData = ((IStringProperty)srcProperty).StringData;
            Contact contact    = base.XsoItem as Contact;

            if (string.IsNullOrEmpty(stringData))
            {
                contact.EmailAddresses.Remove(this.emailIndex);
                return;
            }
            Participant participant = contact.EmailAddresses[this.emailIndex];
            string      text        = null;
            string      text2       = null;

            if (participant != null && !string.IsNullOrEmpty(participant.EmailAddress))
            {
                text2 = EmailAddressConverter.LookupEmailAddressString(participant, contact.Session.MailboxOwner);
                text  = XsoEmailProperty.GetFullEmailString(participant.DisplayName, text2);
                AirSyncDiagnostics.TraceDebug <string, string, string>(ExTraceGlobals.XsoTracer, this, "XSOEmailProperty convertedSmtpAddress :{0}, currentEmail:{1}, RoutingType:{2}", text2, text, participant.RoutingType);
                if (participant.RoutingType == "EX" && text2 == participant.EmailAddress)
                {
                    text2 = SmtpProxyAddress.EncapsulateAddress("EX", participant.EmailAddress, SendMailBase.DefaultDomain);
                    text  = XsoEmailProperty.GetFullEmailString(participant.EmailAddress, text2);
                }
            }
            if (stringData != text && stringData != text2)
            {
                contact.EmailAddresses.Remove(this.emailIndex);
                contact.EmailAddresses.Add(this.emailIndex, EmailAddressConverter.CreateParticipant(stringData));
            }
        }
        // Token: 0x06000025 RID: 37 RVA: 0x000053AC File Offset: 0x000035AC
        public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
        {
            Handler handler = new Handler();

            AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.RequestsTracer, this, "IHttpHandlerFactory.GetHandler called. Handler {0} created.", handler.GetHashCode());
            return(handler);
        }
        public static string LookupEmailAddressString(Participant participant, IExchangePrincipal exchangePrincipal, bool addBrackets)
        {
            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "Calling EmailAddressConverter.LookupEmailAddressString()");
            if (null == participant)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "participant is null.");
                throw new ArgumentNullException("participant null");
            }
            if (exchangePrincipal == null)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "value of exchange principal is null.");
                throw new ArgumentNullException("exchangePrincipal null");
            }
            if (string.IsNullOrEmpty(participant.EmailAddress))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "participant's emailAddress is null. Returning Display name instead.");
                return(EmailAddressConverter.AddBrackets(participant.DisplayName, "<{0}>", addBrackets));
            }
            if (participant.RoutingType == "EX")
            {
                Participant cachedParticipant = EmailAddressConverter.GetCachedParticipant(participant.EmailAddress);
                if (cachedParticipant != null)
                {
                    participant = cachedParticipant;
                }
            }
            if (participant.RoutingType == "SMTP")
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "participant's is already of Routing Type SMTP. return participant's email address.");
                return(EmailAddressConverter.AddBrackets(participant.EmailAddress, "<{0}>", addBrackets));
            }
            Participant participant2 = null;

            try
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "Fetching SmtpAddress property from MAPI");
                object obj = participant.TryGetProperty(ParticipantSchema.SmtpAddress);
                if (obj != null && obj is string)
                {
                    return(EmailAddressConverter.AddBrackets((string)obj, "<{0}>", addBrackets));
                }
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "calling TryConveryTo to convert Participant to SMTP");
                participant2 = EmailAddressConverter.DoADLookup(exchangePrincipal, participant);
            }
            catch (StoragePermanentException)
            {
                AirSyncDiagnostics.TraceError(ExTraceGlobals.CommonTracer, null, "StorePermanentException during ADLookUp while converting Participant to SMTP");
            }
            if (participant2 != null)
            {
                AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.CommonTracer, null, "Convert to SMTP successful. Returned EmailAddress {0} , Format {1}", participant2.EmailAddress, "<{0}>");
                if (participant.RoutingType == "EX")
                {
                    EmailAddressConverter.CacheParticipant(participant.EmailAddress, participant2);
                }
                return(EmailAddressConverter.AddBrackets(participant2.EmailAddress, "<{0}>", addBrackets));
            }
            AirSyncDiagnostics.TraceDebug <string, string, string>(ExTraceGlobals.CommonTracer, null, "Could not convert participant to SMTP routing type. Returned RoutingType:{0}, EmailAddress:{1} and Format: {2}", participant.RoutingType, participant.EmailAddress, "[{0}]");
            return(EmailAddressConverter.AddBrackets(participant.RoutingType + ":" + participant.EmailAddress, "[{0}]", addBrackets));
        }
Ejemplo n.º 7
0
        // Token: 0x060013F3 RID: 5107 RVA: 0x000735A4 File Offset: 0x000717A4
        public IEnumerator <AttendeeData> GetEnumerator()
        {
            CalendarItemBase calItem = base.XsoItem as CalendarItemBase;

            if (calItem == null)
            {
                throw new UnexpectedTypeException("CalendarItemBase", base.XsoItem);
            }
            AirSyncDiagnostics.TraceInfo <int, GlobalObjectId>(ExTraceGlobals.XsoTracer, this, "Adding Attendees to meeting request.Count :{0}, GlobalObjectID: {1}", calItem.AttendeeCollection.Count, calItem.GlobalObjectId);
            bool anyAttendeeAdded = false;

            foreach (Attendee attendee in calItem.AttendeeCollection)
            {
                if (!attendee.IsOrganizer)
                {
                    if (attendee.Participant.EmailAddress != null)
                    {
                        anyAttendeeAdded = true;
                        yield return(new AttendeeData(EmailAddressConverter.LookupEmailAddressString(attendee.Participant, calItem.Session.MailboxOwner), attendee.Participant.DisplayName));
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.XsoTracer, this, "Attendee '{0}' skipped because there is no email address. Meeting Subject:'{1}'.", (attendee.Participant.DisplayName == null) ? "<Null>" : attendee.Participant.DisplayName, calItem.Subject);
                    }
                }
            }
            if (!anyAttendeeAdded && !calItem.IsOrganizer() && calItem.IsMeeting && calItem.AttendeeCollection.Count > 0)
            {
                AirSyncDiagnostics.TraceDebug <int, GlobalObjectId, string>(ExTraceGlobals.XsoTracer, this, "No Attendees were added for this meeting, Adding current user as default attendee. Actual Attendees Count: {0}, GlobalObjectId:{1}, Subject:{2}", calItem.AttendeeCollection.Count, calItem.GlobalObjectId, calItem.Subject);
                Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "ExplictlyAddingUserToMeeting");
                MailboxSession session = (MailboxSession)calItem.Session;
                yield return(new AttendeeData(session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(), session.MailboxOwner.MailboxInfo.DisplayName));
            }
            yield break;
        }
        // Token: 0x06000F84 RID: 3972 RVA: 0x00058C7C File Offset: 0x00056E7C
        protected override void InternalCopyFrom(IProperty srcProperty)
        {
            IBusyStatusProperty busyStatusProperty = srcProperty as IBusyStatusProperty;

            if (busyStatusProperty == null)
            {
                throw new UnexpectedTypeException("IBusyStatusProperty", srcProperty);
            }
            switch (busyStatusProperty.BusyStatus)
            {
            case BusyType.Free:
                base.CreateAirSyncNode("0");
                return;

            case BusyType.Tentative:
                base.CreateAirSyncNode("1");
                return;

            case BusyType.Busy:
                base.CreateAirSyncNode("2");
                return;

            case BusyType.OOF:
                base.CreateAirSyncNode("3");
                return;

            default:
                AirSyncDiagnostics.TraceDebug <BusyType>(ExTraceGlobals.CommonTracer, this, "Remapping unknown BusyStatus {0} to 0 (Free).", busyStatusProperty.BusyStatus);
                base.CreateAirSyncNode("0");
                return;
            }
        }
        // Token: 0x06000026 RID: 38 RVA: 0x000053D8 File Offset: 0x000035D8
        public void ReleaseHandler(IHttpHandler handler)
        {
            Handler handler2 = handler as Handler;

            if (handler2 == null)
            {
                throw new ArgumentNullException("handler");
            }
            AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.RequestsTracer, this, "IHttpHandlerFactory.ReleaseHandler called on {0}.", handler2.GetHashCode());
        }
Ejemplo n.º 10
0
        // Token: 0x06001499 RID: 5273 RVA: 0x000775E0 File Offset: 0x000757E0
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            CalendarItemBase calendarItemBase = base.XsoItem as CalendarItemBase;

            if (calendarItemBase == null)
            {
                throw new UnexpectedTypeException("CalendarItemBase", base.XsoItem);
            }
            IExtendedAttendeesProperty extendedAttendeesProperty = srcProperty as IExtendedAttendeesProperty;

            if (extendedAttendeesProperty == null)
            {
                throw new UnexpectedTypeException("IExtendedAttendeesProperty", srcProperty);
            }
            if (calendarItemBase.IsOrganizer())
            {
                ADObjectId adobjectId = null;
                calendarItemBase.AttendeeCollection.Clear();
                foreach (ExtendedAttendeeData extendedAttendeeData in extendedAttendeesProperty)
                {
                    Participant participant = new Participant(extendedAttendeeData.DisplayName, extendedAttendeeData.EmailAddress, "SMTP");
                    if (adobjectId == null && calendarItemBase.Session.MailboxOwner.MailboxInfo.Configuration.AddressBookPolicy != null)
                    {
                        adobjectId = DirectoryHelper.GetGlobalAddressListFromAddressBookPolicy(calendarItemBase.Session.MailboxOwner.MailboxInfo.Configuration.AddressBookPolicy, calendarItemBase.Session.GetADConfigurationSession(true, ConsistencyMode.IgnoreInvalid));
                    }
                    Participant[] array = Participant.TryConvertTo(new Participant[]
                    {
                        participant
                    }, "EX", calendarItemBase.Session.MailboxOwner, adobjectId);
                    Participant participant2 = (array != null && array.Length > 0) ? array[0] : null;
                    if (participant2 == null)
                    {
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.XsoTracer, this, "participant Conversion from SMTP to Ex failed. {0}", extendedAttendeeData.EmailAddress);
                    }
                    if (extendedAttendeeData.SendExtendedData)
                    {
                        calendarItemBase.AttendeeCollection.Add((participant2 != null) ? participant2 : participant, (AttendeeType)extendedAttendeeData.Type, new ResponseType?((ResponseType)extendedAttendeeData.Status), null, false);
                    }
                    else
                    {
                        calendarItemBase.AttendeeCollection.Add((participant2 != null) ? participant2 : participant, (AttendeeType)extendedAttendeeData.Type, null, null, false);
                    }
                }
                if (calendarItemBase.AttendeeCollection.Count > 0)
                {
                    calendarItemBase.IsMeeting = true;
                }
                calendarItemBase.UnsafeSetMeetingRequestWasSent(true);
                return;
            }
            AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.XsoTracer, this, "XsoExtendedAttendeesProperty::InternalCopyFromModified.Skip copying attendees as current user is not organizer.Existing Attendee Count:{0}", calendarItemBase.AttendeeCollection.Count);
        }
Ejemplo n.º 11
0
        // Token: 0x0600139D RID: 5021 RVA: 0x00070E84 File Offset: 0x0006F084
        internal static bool IsMessageRestrictedAndDecoded(Item item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            RightsManagedMessageItem rightsManagedMessageItem = item as RightsManagedMessageItem;

            if (rightsManagedMessageItem != null && rightsManagedMessageItem.IsRestricted && rightsManagedMessageItem.IsDecoded)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, item, "The message is restricted and decoded");
                return(true);
            }
            return(false);
        }
Ejemplo n.º 12
0
        // Token: 0x0600139E RID: 5022 RVA: 0x00070ECC File Offset: 0x0006F0CC
        internal static bool IsIRMFailedToDecode(Item item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            RightsManagedMessageItem rightsManagedMessageItem = item as RightsManagedMessageItem;

            if (rightsManagedMessageItem != null && rightsManagedMessageItem.DecryptionStatus.Failed && rightsManagedMessageItem.DecryptionStatus.FailureCode != RightsManagementFailureCode.InternalLicensingDisabled && rightsManagedMessageItem.DecryptionStatus.FailureCode != RightsManagementFailureCode.ExternalLicensingDisabled)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, item, "The message is failed to decode");
                return(true);
            }
            return(false);
        }
Ejemplo n.º 13
0
        // Token: 0x0600149A RID: 5274 RVA: 0x00077800 File Offset: 0x00075A00
        protected override void InternalSetToDefault(IProperty srcProperty)
        {
            CalendarItemBase calendarItemBase = base.XsoItem as CalendarItemBase;

            if (calendarItemBase == null)
            {
                throw new UnexpectedTypeException("CalendarItemBase", base.XsoItem);
            }
            if (calendarItemBase.IsOrganizer())
            {
                calendarItemBase.AttendeeCollection.Clear();
                return;
            }
            AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.XsoTracer, this, "XsoExtendedAttendeesProperty::InternalSetToDefault.Skip copying attendees as current user is not organizer.Existing Attendee Count:{0}", calendarItemBase.AttendeeCollection.Count);
        }
Ejemplo n.º 14
0
 private static Participant DoADLookup(IExchangePrincipal exchangePrincipal, Participant participant)
 {
     if (TestHooks.EmailAddressConverter_ADLookup != null)
     {
         return(TestHooks.EmailAddressConverter_ADLookup(participant));
     }
     Participant[] array = Participant.TryConvertTo(new Participant[]
     {
         participant
     }, "SMTP", exchangePrincipal, null);
     if (array == null || array.Length == 0)
     {
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, ("Convert to SMTP failed. Received null smtpParticipant for participant: " + participant.EmailAddress) ?? "<NULL>");
         return(null);
     }
     return(array[0]);
 }
        private string RetrieveOrganizerInfo(Item item)
        {
            if (item == null)
            {
                AirSyncDiagnostics.TraceError(ExTraceGlobals.XsoTracer, this, "Organizer could not be set. No item found.");
                return(null);
            }
            string text  = null;
            string text2 = null;
            string text3 = null;

            try
            {
                text = item.GetValueOrDefault <string>(CalendarItemBaseSchema.OrganizerEmailAddress);
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.XsoTracer, this, "OrganizerEmailAddress: {0}", text);
                text2 = item.GetValueOrDefault <string>(CalendarItemBaseSchema.OrganizerType);
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.XsoTracer, this, "OrganizerType: {0}", text2);
                text3 = item.GetValueOrDefault <string>(CalendarItemBaseSchema.OrganizerDisplayName);
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.XsoTracer, this, "OrganizerDisplayName: {0}", text3);
            }
            catch (PropertyErrorException ex)
            {
                AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.XsoTracer, this, "PropertyErrorException retrieving Organizer info: {0}", ex.Message);
            }
            if (string.IsNullOrEmpty(text))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Organizer could not be set. OrganizerEmailAddress could not be retrieved");
                return(null);
            }
            if (SmtpAddress.IsValidSmtpAddress(text) && !string.Equals(text2, "SMTP".ToString(), StringComparison.InvariantCultureIgnoreCase))
            {
                AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.XsoTracer, this, "Meeting Request Organizer Type is invalid: OrganizerType:{0}. Defaulting to Smtp  RoutingType", text2);
                text2 = "SMTP".ToString();
            }
            Participant participant       = new Participant(text3, text, text2);
            string      participantString = EmailAddressConverter.GetParticipantString(participant, item.Session.MailboxOwner);

            AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.XsoTracer, this, "Meeting Request Organizer: {0}", participantString);
            return(participantString);
        }
Ejemplo n.º 16
0
        // Token: 0x0600152B RID: 5419 RVA: 0x0007BF24 File Offset: 0x0007A124
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            IStringProperty stringProperty = (IStringProperty)srcProperty;

            byte[] array = base.XsoItem.TryGetProperty(base.PropertyDef) as byte[];
            if (array == null)
            {
                array = new GlobalObjectId(stringProperty.StringData).Bytes;
                base.XsoItem[CalendarItemBaseSchema.GlobalObjectId]      = array;
                base.XsoItem[CalendarItemBaseSchema.CleanGlobalObjectId] = array;
                return;
            }
            GlobalObjectId globalObjectId = new GlobalObjectId(array);

            if (globalObjectId.Uid != stringProperty.StringData)
            {
                AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.XsoTracer, this, "Client overwrote Uid from {0} to {1}", globalObjectId.Uid, stringProperty.StringData);
            }
            array = new GlobalObjectId(stringProperty.StringData).Bytes;
            base.XsoItem[CalendarItemBaseSchema.GlobalObjectId]      = array;
            base.XsoItem[CalendarItemBaseSchema.CleanGlobalObjectId] = array;
        }
Ejemplo n.º 17
0
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            base.InternalCopyFromModified(srcProperty);
            IMultivaluedProperty <string> multivaluedProperty = srcProperty as IMultivaluedProperty <string>;

            foreach (string name in multivaluedProperty)
            {
                this.CheckAddCategory(name);
            }
            try
            {
                if (this.needToSaveMCL && this.MasterCategoryList != null)
                {
                    this.MasterCategoryList.Save();
                    this.needToSaveMCL = false;
                }
            }
            catch (LocalizedException arg)
            {
                AirSyncDiagnostics.TraceDebug <LocalizedException>(ExTraceGlobals.XsoTracer, this, "Failed to save MCL, exception: {0}", arg);
                Command.CurrentCommand.ProtocolLogger.SetValue(ProtocolLoggerData.Error, "FailedToSaveMCL");
            }
        }
        // Token: 0x060014EA RID: 5354 RVA: 0x000799E0 File Offset: 0x00077BE0
        private void GetPicture()
        {
            this.cachedPicture = null;
            Contact contact = base.XsoItem as Contact;

            contact.Load(new PropertyDefinition[]
            {
                XsoPictureProperty.hasPicture
            });
            object obj = contact.TryGetProperty(XsoPictureProperty.hasPicture);

            if (obj != null && obj is bool && (bool)obj)
            {
                foreach (AttachmentHandle handle in contact.AttachmentCollection)
                {
                    using (Attachment attachment = contact.AttachmentCollection.Open(handle))
                    {
                        StreamAttachment streamAttachment = attachment as StreamAttachment;
                        if (streamAttachment != null)
                        {
                            streamAttachment.Load(new PropertyDefinition[]
                            {
                                XsoPictureProperty.ispictureAttach
                            });
                            obj = streamAttachment.TryGetProperty(XsoPictureProperty.ispictureAttach);
                            if (obj != null && obj is bool && (bool)obj)
                            {
                                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.GetPicture(), picture attachment exists.");
                                this.LoadPictureData(streamAttachment);
                                break;
                            }
                        }
                    }
                }
            }
        }
        // Token: 0x060014E7 RID: 5351 RVA: 0x00079568 File Offset: 0x00077768
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            IPictureProperty pictureProperty = (IPictureProperty)srcProperty;

            if (string.IsNullOrEmpty(pictureProperty.PictureData))
            {
                this.InternalSetToDefault(srcProperty);
                return;
            }
            if (pictureProperty.PictureData.Length > 50000)
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.ProtocolTracer, null, "The size of contact picture is bigger than 50000 base64 chars");
                throw new ConversionException("The size of contact picture is bigger than 50000 base64 chars");
            }
            AttachmentId attachmentId = null;
            Contact      contact      = base.XsoItem as Contact;

            contact.Load(new PropertyDefinition[]
            {
                XsoPictureProperty.hasPicture
            });
            object obj = contact.TryGetProperty(XsoPictureProperty.hasPicture);

            if (obj != null && obj is bool && (bool)obj)
            {
                foreach (AttachmentHandle handle in contact.AttachmentCollection)
                {
                    using (Attachment attachment = contact.AttachmentCollection.Open(handle))
                    {
                        attachment.Load(new PropertyDefinition[]
                        {
                            XsoPictureProperty.ispictureAttach
                        });
                        obj = attachment.TryGetProperty(XsoPictureProperty.ispictureAttach);
                        if (obj != null && obj is bool && (bool)obj)
                        {
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.InternalCopyFromModified(), picture attachment exists.");
                            attachmentId = attachment.Id;
                            break;
                        }
                    }
                }
            }
            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.InternalCopyFromModified(), creating a new picture attachment.");
            using (Attachment attachment2 = contact.AttachmentCollection.Create(AttachmentType.Stream))
            {
                attachment2[XsoPictureProperty.ispictureAttach]    = true;
                attachment2[AttachmentSchema.DisplayName]          = "ContactPicture.jpg";
                attachment2[XsoPictureProperty.attachFileName]     = string.Empty;
                attachment2[XsoPictureProperty.attachLongFileName] = "ContactPicture.jpg";
                attachment2[XsoPictureProperty.urlCompName]        = "ContactPicture.jpg";
                attachment2[XsoPictureProperty.attachExtension]    = "jpg";
                attachment2[XsoPictureProperty.attachFlags]        = 0;
                attachment2[XsoPictureProperty.attachmentFlags]    = 0;
                attachment2[XsoPictureProperty.attachmentHidden]   = false;
                attachment2[XsoPictureProperty.attachmentLinkId]   = 0;
                attachment2[XsoPictureProperty.attachEncoding]     = new byte[0];
                attachment2[XsoPictureProperty.exceptionStartTime] = new DateTime(4501, 1, 1);
                attachment2[XsoPictureProperty.exceptionEndTime]   = new DateTime(4501, 1, 1);
                contact[XsoPictureProperty.hasPicture]             = true;
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.CommonTracer, null, "XsoPictureProperty.InternalCopyFromModified(), writing the data to picture attachment.");
                using (Stream contentStream = ((StreamAttachment)attachment2).GetContentStream())
                {
                    contentStream.Position = 0L;
                    byte[] array = Convert.FromBase64String(pictureProperty.PictureData);
                    contentStream.Write(array, 0, array.Length);
                }
                attachment2.Save();
            }
            if (attachmentId != null)
            {
                contact.AttachmentCollection.Remove(attachmentId);
            }
        }
Ejemplo n.º 20
0
        public static SyncStateUpgradeResult CheckAndUpgradeSyncStates(MailboxSession mailboxSession, DeviceIdentity deviceIdentity)
        {
            if (mailboxSession == null)
            {
                throw new ArgumentNullException("mailboxSession");
            }
            SafeHGlobalHandle   safeHGlobalHandle   = SafeHGlobalHandle.InvalidHandle;
            TiFolderSyncUpgrade tiFolderSyncUpgrade = new TiFolderSyncUpgrade();

            tiFolderSyncUpgrade.MailboxSession = mailboxSession;
            MailboxUtility           mailboxUtility           = new MailboxUtility();
            MailboxUtilityDeviceInfo mailboxUtilityDeviceInfo = null;
            MemoryStream             memoryStream             = null;

            try
            {
                mailboxUtility.MailboxSessionForUtility = mailboxSession;
                mailboxUtilityDeviceInfo = mailboxUtility.GetDevice(deviceIdentity);
                if (mailboxUtilityDeviceInfo == null)
                {
                    AirSyncDiagnostics.TraceDebug <DeviceIdentity>(ExTraceGlobals.TiUpgradeTracer, null, "Failed to retrieve device info for: {0}", deviceIdentity);
                    return(SyncStateUpgradeResult.NoTiSyncState);
                }
                AirSyncDiagnostics.TraceDebug <DeviceIdentity>(ExTraceGlobals.TiUpgradeTracer, null, "Starting sync state upgrade for device: {0}", deviceIdentity);
                safeHGlobalHandle = NativeMethods.AllocHGlobal(Marshal.SizeOf(typeof(FolderInfo)));
                StoreObjectId storeObjectId = null;
                storeObjectId = mailboxUtilityDeviceInfo.StoreObjectId;
                HashSet <string> folderList             = mailboxUtilityDeviceInfo.FolderList;
                FolderInfo       folderInfo             = default(FolderInfo);
                bool             containsFoldersyncFile = false;
                memoryStream = mailboxUtility.GetSyncState(storeObjectId, "FolderSyncFile");
                if (memoryStream != null)
                {
                    using (SafeHGlobalHandle safeHGlobalHandle2 = NativeMethods.AllocHGlobal((int)memoryStream.Length))
                    {
                        Marshal.Copy(memoryStream.GetBuffer(), 0, safeHGlobalHandle2.DangerousGetHandle(), (int)memoryStream.Length);
                        int num = SyncStateUpgrader.Foldersync_upgrade(safeHGlobalHandle2, (uint)memoryStream.Length, safeHGlobalHandle);
                        if (num != 0)
                        {
                            throw new AirSyncPermanentException(false);
                        }
                    }
                    folderInfo             = (FolderInfo)Marshal.PtrToStructure(safeHGlobalHandle.DangerousGetHandle(), typeof(FolderInfo));
                    containsFoldersyncFile = true;
                    MailboxUtility.ReclaimStream(memoryStream);
                    memoryStream = null;
                }
                Dictionary <string, StoreObjectType> dictionary2;
                Dictionary <string, StoreObjectId>   dictionary = SyncStateUpgrader.UpgradeFolderSyncHierarchySyncState(tiFolderSyncUpgrade, containsFoldersyncFile, folderInfo, deviceIdentity, out dictionary2);
                if (dictionary == null)
                {
                    mailboxUtility.DeleteFolder(mailboxUtilityDeviceInfo.StoreObjectId, true);
                }
                else
                {
                    SyncStateUpgradeHelper syncStateUpgradeHelper = new SyncStateUpgradeHelper(mailboxSession, tiFolderSyncUpgrade.SyncStateStorage);
                    foreach (string key in dictionary2.Keys)
                    {
                        StoreObjectType storeObjectType = dictionary2[key];
                        if (storeObjectType != StoreObjectType.Folder && storeObjectType != StoreObjectType.ContactsFolder && storeObjectType != StoreObjectType.CalendarFolder && storeObjectType != StoreObjectType.TasksFolder)
                        {
                            AirSyncDiagnostics.TraceDebug <StoreObjectType>(ExTraceGlobals.TiUpgradeTracer, null, "Removing unknown Ti folder of type {0}", storeObjectType);
                            dictionary.Remove(key);
                        }
                    }
                    if (!syncStateUpgradeHelper.UpgradeSyncState(dictionary, dictionary2, folderList, mailboxUtility, storeObjectId))
                    {
                        AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.TiUpgradeTracer, null, "Failed to upgrade folders for {0}", mailboxUtilityDeviceInfo.DisplayName);
                        mailboxUtility.DeleteFolder(mailboxUtilityDeviceInfo.StoreObjectId, true);
                        return(SyncStateUpgradeResult.UpgradeFailed);
                    }
                    tiFolderSyncUpgrade.UpdateLastFolderId(syncStateUpgradeHelper.MaxFolderSeen);
                }
                AirSyncDiagnostics.FaultInjectionTracer.TraceTest(3236310333U);
            }
            catch (Exception arg)
            {
                if (mailboxUtilityDeviceInfo != null)
                {
                    mailboxUtility.DeleteSyncStateStorage(new DeviceIdentity(mailboxUtilityDeviceInfo.DisplayName, mailboxUtilityDeviceInfo.ParentDisplayName, "AirSync"));
                }
                AirSyncDiagnostics.TraceDebug <DeviceIdentity, Exception>(ExTraceGlobals.TiUpgradeTracer, null, "Sync state upgrade failed for device: {0}\r\nException:\r\n{1}", deviceIdentity, arg);
                throw;
            }
            finally
            {
                if (memoryStream != null)
                {
                    MailboxUtility.ReclaimStream(memoryStream);
                    memoryStream = null;
                }
                if (mailboxUtilityDeviceInfo != null)
                {
                    mailboxUtility.DeleteFolder(mailboxUtilityDeviceInfo.StoreObjectId, true);
                }
                if (tiFolderSyncUpgrade != null)
                {
                    tiFolderSyncUpgrade.Close();
                    tiFolderSyncUpgrade = null;
                }
                safeHGlobalHandle.Close();
            }
            AirSyncDiagnostics.TraceDebug <DeviceIdentity>(ExTraceGlobals.TiUpgradeTracer, null, "Finished sync state upgrade for device: {0}", deviceIdentity);
            return(SyncStateUpgradeResult.UpgradeComplete);
        }
Ejemplo n.º 21
0
        // Token: 0x060013EF RID: 5103 RVA: 0x00073204 File Offset: 0x00071404
        public IEnumerator <AttachmentData> GetEnumerator()
        {
            Item message = base.XsoItem as Item;

            if (message == null)
            {
                throw new UnexpectedTypeException("Item", base.XsoItem);
            }
            string baseId = null;

            if (this.idmapping != null)
            {
                baseId = this.idmapping[MailboxSyncItemId.CreateForNewItem(message.Id.ObjectId)];
            }
            if (baseId == null)
            {
                baseId = message.Id.ObjectId.ToBase64String();
            }
            if (base.XsoItem is MessageItem && ((MessageItem)message).IsRestricted)
            {
                object prop = message.TryGetProperty(MessageItemSchema.DRMLicense);
                if (prop is byte[][])
                {
                    byte[][] license = (byte[][])prop;
                    if (license.Length > 0)
                    {
                        yield return(new AttachmentData
                        {
                            AttMethod = 1,
                            AttSize = (long)license[0].Length,
                            DisplayName = "message.rpmsg.license",
                            AttName = HttpUtility.UrlEncode(baseId + ":DRMLicense")
                        });
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. Length = {0}", license.Length);
                    }
                }
                else
                {
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Failed to fetch the license property on the DRM message. Prop = {0}", new object[]
                    {
                        prop
                    });
                }
            }
            int index = -1;

            foreach (AttachmentHandle handle in message.AttachmentCollection)
            {
                index++;
                AttachmentData attachmentData = default(AttachmentData);
                Attachment     attachment     = null;
                try
                {
                    attachment = message.AttachmentCollection.Open(handle);
                    if (BodyUtility.IsClearSigned(message) && (string.Compare(attachment.FileName, "smime.p7m", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(attachment.ContentType, "multipart/signed", StringComparison.OrdinalIgnoreCase) == 0))
                    {
                        continue;
                    }
                    attachmentData.AttName = HttpUtility.UrlEncode(baseId + ":" + index);
                    if (string.IsNullOrEmpty(attachmentData.DisplayName))
                    {
                        if (!string.IsNullOrEmpty(attachment.FileName))
                        {
                            attachmentData.DisplayName = attachment.FileName;
                        }
                        else if (attachment.AttachmentType == AttachmentType.EmbeddedMessage)
                        {
                            using (Item itemAsReadOnly = ((ItemAttachment)attachment).GetItemAsReadOnly(null))
                            {
                                attachmentData.DisplayName = (itemAsReadOnly.TryGetProperty(ItemSchema.Subject) as string);
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(attachmentData.DisplayName))
                    {
                        attachmentData.DisplayName = "????";
                    }
                    attachmentData.AttMethod = (int)attachment.TryGetProperty(AttachmentSchema.AttachMethod);
                    attachmentData.AttSize   = attachment.Size;
                }
                finally
                {
                    if (attachment != null)
                    {
                        attachment.Dispose();
                        attachment = null;
                    }
                }
                yield return(attachmentData);
            }
            yield break;
        }
Ejemplo n.º 22
0
        protected override void InternalCopyFromModified(IProperty srcProperty)
        {
            CalendarItem        calendarItem       = base.XsoItem as CalendarItem;
            IExceptionsProperty exceptionsProperty = srcProperty as IExceptionsProperty;
            XsoDataObject       xsoDataObject      = null;

            foreach (ExceptionInstance exceptionInstance in exceptionsProperty)
            {
                ExDateTime exDateTime  = ExTimeZone.UtcTimeZone.ConvertDateTime(exceptionInstance.ExceptionStartTime);
                ExDateTime exDateTime2 = calendarItem.ExTimeZone.ConvertDateTime(exDateTime);
                if (exceptionInstance.Deleted == 1)
                {
                    if (calendarItem.Id == null)
                    {
                        calendarItem.Save(SaveMode.ResolveConflicts);
                        calendarItem.Load();
                    }
                    try
                    {
                        this.ValidateCalendarItem(calendarItem);
                        calendarItem.DeleteOccurrenceByOriginalStartTime(exDateTime2);
                        continue;
                    }
                    catch (OccurrenceNotFoundException)
                    {
                        AirSyncDiagnostics.TraceDebug <ExDateTime>(ExTraceGlobals.XsoTracer, this, "Exception with OriginalStartTime: {0} already deleted.", exDateTime2);
                        continue;
                    }
                }
                if (xsoDataObject == null)
                {
                    xsoDataObject = this.schemaState.GetInnerXsoDataObject();
                }
                CalendarItemOccurrence calendarItemOccurrence = null;
                try
                {
                    if (calendarItem.Id != null)
                    {
                        this.ValidateCalendarItem(calendarItem);
                        calendarItemOccurrence = calendarItem.OpenOccurrenceByOriginalStartTime(exDateTime2, xsoDataObject.GetPrefetchProperties());
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "New calendar recurrence item added with exceptions.  Extra save (RPC to store) needed for this");
                        calendarItem.Save(SaveMode.ResolveConflicts);
                        calendarItem.Load();
                        this.ValidateCalendarItem(calendarItem);
                        calendarItemOccurrence = calendarItem.OpenOccurrenceByOriginalStartTime(exDateTime2, xsoDataObject.GetPrefetchProperties());
                    }
                    if (calendarItemOccurrence == null)
                    {
                        throw new ConversionException("Could not open the Calendar Occurrence using the Original StartTime");
                    }
                    calendarItemOccurrence.OpenAsReadWrite();
                    try
                    {
                        xsoDataObject.Bind(calendarItemOccurrence);
                        xsoDataObject.CopyFrom(exceptionInstance.ModifiedException);
                    }
                    finally
                    {
                        xsoDataObject.Unbind();
                    }
                    calendarItemOccurrence.Save(SaveMode.NoConflictResolution);
                }
                finally
                {
                    if (calendarItemOccurrence != null)
                    {
                        calendarItemOccurrence.Dispose();
                    }
                }
            }
        }
        // Token: 0x060013E1 RID: 5089 RVA: 0x00072750 File Offset: 0x00070950
        protected virtual Attachment12Data GetAttachmentData(Item message, Attachment attachment, string idbase, ref int index)
        {
            index++;
            Attachment14Data attachment14Data = new Attachment14Data();

            attachment14Data.Id = attachment.Id;
            if (BodyConversionUtilities.IsMessageRestrictedAndDecoded(message) && AirSyncUtility.IsProtectedVoicemailItem(message))
            {
                if (AttachmentHelper.IsProtectedVoiceAttachment(attachment.DisplayName))
                {
                    string valueOrDefault = message.GetValueOrDefault <string>(MessageItemSchema.RequireProtectedPlayOnPhone);
                    if (valueOrDefault != null && valueOrDefault.Equals("true", StringComparison.OrdinalIgnoreCase))
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Skip attachment requires protected play on phone");
                        return(null);
                    }
                    attachment14Data.DisplayName = AttachmentHelper.GetUnprotectedVoiceAttachmentName(attachment.DisplayName);
                }
                else
                {
                    if (AttachmentHelper.IsProtectedTranscriptAttachment(attachment.DisplayName))
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Skip protected transcript attachment");
                        return(null);
                    }
                    attachment14Data.DisplayName = attachment.DisplayName;
                }
            }
            else
            {
                attachment14Data.DisplayName = attachment.DisplayName;
            }
            if (string.IsNullOrEmpty(attachment14Data.DisplayName))
            {
                if (!string.IsNullOrEmpty(attachment.FileName))
                {
                    attachment14Data.DisplayName = attachment.FileName;
                    if (attachment.AttachmentType == AttachmentType.Ole && attachment.DisplayName.LastIndexOf('.') < 0)
                    {
                        Attachment14Data attachment14Data2 = attachment14Data;
                        attachment14Data2.DisplayName += ".jpg";
                    }
                }
                else if (attachment.AttachmentType == AttachmentType.EmbeddedMessage)
                {
                    using (Item itemAsReadOnly = ((ItemAttachment)attachment).GetItemAsReadOnly(null))
                    {
                        attachment14Data.DisplayName = (itemAsReadOnly.TryGetProperty(ItemSchema.Subject) as string);
                    }
                }
            }
            if (string.IsNullOrEmpty(attachment14Data.DisplayName))
            {
                attachment14Data.DisplayName = "????";
            }
            AirSyncDiagnostics.TraceDebug <int, string>(ExTraceGlobals.XsoTracer, this, "Attachment {0}, display name {1}", index, attachment14Data.DisplayName);
            attachment14Data.FileReference     = HttpUtility.UrlEncode(idbase + ":" + index);
            attachment14Data.Method            = Convert.ToByte((int)attachment.TryGetProperty(AttachmentSchema.AttachMethod));
            attachment14Data.EstimatedDataSize = attachment.Size;
            if (attachment.IsInline)
            {
                if (string.IsNullOrEmpty(attachment.ContentId))
                {
                    attachment14Data.ContentId = Guid.NewGuid().ToString();
                }
                else
                {
                    attachment14Data.ContentId = attachment.ContentId;
                }
            }
            if (attachment.ContentLocation != null)
            {
                attachment14Data.ContentLocation = attachment.ContentLocation.ToString();
            }
            if (!BodyConversionUtilities.IsMessageRestrictedAndDecoded(message))
            {
                attachment14Data.IsInline = attachment.IsInline;
            }
            return(attachment14Data);
        }
        // Token: 0x060013E0 RID: 5088 RVA: 0x00072734 File Offset: 0x00070934
        public IEnumerator <Attachment12Data> GetEnumerator()
        {
            Item             message        = base.XsoItem as Item;
            Attachment12Data attachmentData = null;

            if (message == null)
            {
                throw new UnexpectedTypeException("Item", base.XsoItem);
            }
            MeetingRequest meetingRequest = base.XsoItem as MeetingRequest;

            if (meetingRequest == null || !meetingRequest.IsDelegated())
            {
                string idbase = null;
                if (this.idmapping != null)
                {
                    idbase = this.idmapping[MailboxSyncItemId.CreateForNewItem(message.Id.ObjectId)];
                }
                if (idbase == null)
                {
                    idbase = message.Id.ObjectId.ToBase64String();
                }
                if (message is MessageItem && ((MessageItem)message).IsRestricted && !BodyConversionUtilities.IsMessageRestrictedAndDecoded(message) && !BodyConversionUtilities.IsIRMFailedToDecode(message))
                {
                    object prop = message.TryGetProperty(MessageItemSchema.DRMLicense);
                    if (prop is byte[][])
                    {
                        byte[][] license = (byte[][])prop;
                        if (license.Length > 0)
                        {
                            attachmentData                   = new Attachment14Data();
                            attachmentData.DisplayName       = "message.rpmsg.license";
                            attachmentData.Method            = 1;
                            attachmentData.EstimatedDataSize = (long)license[0].Length;
                            attachmentData.IsInline          = false;
                            attachmentData.FileReference     = HttpUtility.UrlEncode(idbase + ":DRMLicense");
                            AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Add DRM license as attachment, message is MessageItem {0}, message.IsRestricted {1}, IsDecoded {2}, FailedToDecode {3}", new object[]
                            {
                                message is MessageItem,
                                ((MessageItem)message).IsRestricted,
                                BodyConversionUtilities.IsMessageRestrictedAndDecoded(message),
                                BodyConversionUtilities.IsIRMFailedToDecode(message)
                            });
                            yield return(attachmentData);
                        }
                        else
                        {
                            AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. Length = {0}", license.Length);
                        }
                    }
                    else
                    {
                        AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. prop = {0}", new object[]
                        {
                            prop
                        });
                    }
                }
                AttachmentCollection attachmentCollection = null;
                if (BodyConversionUtilities.IsMessageRestrictedAndDecoded(message))
                {
                    attachmentCollection = ((RightsManagedMessageItem)message).ProtectedAttachmentCollection;
                }
                else
                {
                    if (BodyConversionUtilities.IsIRMFailedToDecode(message))
                    {
                        goto IL_3FC;
                    }
                    attachmentCollection = message.AttachmentCollection;
                }
                int index = -1;
                foreach (AttachmentHandle handle in attachmentCollection)
                {
                    using (Attachment attachment = attachmentCollection.Open(handle))
                    {
                        if (BodyUtility.IsClearSigned(message) && (string.Equals(attachment.FileName, "smime.p7m", StringComparison.OrdinalIgnoreCase) || string.Equals(attachment.ContentType, "multipart/signed", StringComparison.OrdinalIgnoreCase)))
                        {
                            continue;
                        }
                        attachmentData = this.GetAttachmentData(message, attachment, idbase, ref index);
                    }
                    if (attachmentData != null)
                    {
                        yield return(attachmentData);
                    }
                }
            }
IL_3FC:
            yield break;
        }