Example #1
0
        // Token: 0x06002292 RID: 8850 RVA: 0x0007F0D0 File Offset: 0x0007D2D0
        private bool ConvertLegacyItemIdFormatIfNecessary(SimpleConfiguration <TargetFolderMRUEntry> folderMruConfig, CallContext callContext)
        {
            bool result = false;

            foreach (TargetFolderMRUEntry targetFolderMRUEntry in folderMruConfig.Entries)
            {
                if (targetFolderMRUEntry.EwsFolderIdEntry == null)
                {
                    try
                    {
                        OwaStoreObjectId  owaStoreObjectId  = OwaStoreObjectId.CreateFromString(targetFolderMRUEntry.FolderId);
                        ExchangePrincipal exchangePrincipal = (owaStoreObjectId.MailboxOwnerLegacyDN != null) ? ExchangePrincipal.FromLegacyDN(callContext.SessionCache.GetMailboxIdentityMailboxSession().GetADSessionSettings(), owaStoreObjectId.MailboxOwnerLegacyDN) : callContext.AccessingPrincipal;
                        new IdConverter(callContext);
                        FolderId folderIdFromStoreId = IdConverter.GetFolderIdFromStoreId(owaStoreObjectId.StoreId, new MailboxId(exchangePrincipal.MailboxInfo.MailboxGuid));
                        targetFolderMRUEntry.EwsFolderIdEntry = folderIdFromStoreId.Id;
                        result = true;
                    }
                    catch (OwaInvalidIdFormatException)
                    {
                    }
                    catch (OwaInvalidRequestException)
                    {
                    }
                    catch (ObjectNotFoundException)
                    {
                    }
                }
            }
            return(result);
        }
        public string GetCalendarFolder()
        {
            CalendarGroup[] array = new CalendarGroup[]
            {
                new CalendarGroup()
            };
            array[0].GroupId   = Guid.Empty.ToString();
            array[0].GroupType = CalendarGroupType.MyCalendars;
            array[0].GroupName = string.Empty;
            array[0].ItemId    = new Microsoft.Exchange.Services.Core.Types.ItemId(array[0].GroupId, array[0].GroupId);
            array[0].Calendars = new CalendarEntry[1];
            LocalCalendarEntry localCalendarEntry = new LocalCalendarEntry();

            localCalendarEntry.CalendarColor     = CalendarColor.Auto;
            localCalendarEntry.IsDefaultCalendar = true;
            array[0].Calendars[0] = localCalendarEntry;
            CalendarFolderType calendarFolderType = new CalendarFolderType();

            calendarFolderType.FolderId                                  = IdConverter.GetFolderIdFromStoreId(AnonymousUserContext.Current.PublishedCalendarId, new MailboxId(AnonymousUserContext.Current.ExchangePrincipal.MailboxInfo.MailboxGuid));
            localCalendarEntry.ItemId                                    = new Microsoft.Exchange.Services.Core.Types.ItemId("calendarEntryFor" + calendarFolderType.FolderId.Id, "calendarEntryChangeKeyFor" + calendarFolderType.FolderId.ChangeKey);
            calendarFolderType.DisplayName                               = AntiXssEncoder.HtmlEncode(AnonymousUserContext.Current.PublishedCalendarName, false);
            calendarFolderType.ChildFolderCount                          = new int?(0);
            calendarFolderType.ChildFolderCountSpecified                 = true;
            calendarFolderType.ExtendedProperty                          = null;
            calendarFolderType.FolderClass                               = "IPF.Appointment";
            calendarFolderType.EffectiveRights                           = new EffectiveRightsType();
            calendarFolderType.EffectiveRights.CreateAssociated          = false;
            calendarFolderType.EffectiveRights.CreateContents            = false;
            calendarFolderType.EffectiveRights.CreateHierarchy           = false;
            calendarFolderType.EffectiveRights.Delete                    = false;
            calendarFolderType.EffectiveRights.Modify                    = false;
            calendarFolderType.EffectiveRights.Read                      = true;
            calendarFolderType.EffectiveRights.ViewPrivateItemsSpecified = false;
            localCalendarEntry.CalendarFolderId                          = calendarFolderType.FolderId;
            GetCalendarFoldersResponse instance = new GetCalendarFoldersResponse(array, new CalendarFolderType[]
            {
                calendarFolderType
            });

            return(SessionDataHandler.EmitPayload("calendarFolders", JsonConverter.ToJSON(instance)));
        }
        // Token: 0x06001A9A RID: 6810 RVA: 0x00063C00 File Offset: 0x00061E00
        private PeopleFilter MakePeopleFilter(StoreId folderId, StoreId parentId, MailboxId mailboxId, string displayName, int sortGroupPriority, bool isReadOnly)
        {
            ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(folderId, mailboxId, null);
            FolderId parentFolderId = null;

            if (parentId != null)
            {
                parentFolderId = IdConverter.GetFolderIdFromStoreId(parentId, mailboxId);
            }
            return(new PeopleFilter
            {
                DisplayName = displayName,
                FolderId = new FolderId
                {
                    Id = concatenatedId.Id
                },
                ParentFolderId = parentFolderId,
                SortGroupPriority = sortGroupPriority,
                IsReadOnly = isReadOnly
            });
        }
        public string GetUserConfiguration()
        {
            OwaUserConfiguration owaUserConfiguration = new OwaUserConfiguration();

            owaUserConfiguration.UserOptions                           = new UserOptionsType();
            owaUserConfiguration.UserOptions.TimeZone                  = AnonymousUserContext.Current.TimeZone.AlternativeId;
            owaUserConfiguration.UserOptions.TimeFormat                = MailboxRegionalConfiguration.GetDefaultTimeFormat(CultureInfo.CurrentUICulture);
            owaUserConfiguration.UserOptions.DateFormat                = MailboxRegionalConfiguration.GetDefaultDateFormat(CultureInfo.CurrentUICulture);
            owaUserConfiguration.UserOptions.WorkingHours              = new WorkingHoursType(0, 1440, 127, AnonymousUserContext.Current.TimeZone, AnonymousUserContext.Current.TimeZone);
            owaUserConfiguration.ApplicationSettings                   = new ApplicationSettingsType();
            owaUserConfiguration.ApplicationSettings.AnalyticsEnabled  = false;
            owaUserConfiguration.ApplicationSettings.InferenceEnabled  = false;
            owaUserConfiguration.ApplicationSettings.WatsonEnabled     = false;
            owaUserConfiguration.ApplicationSettings.DefaultTraceLevel = TraceLevel.Off;
            owaUserConfiguration.ApplicationSettings.InstrumentationSendIntervalSeconds = 0;
            owaUserConfiguration.SessionSettings = new SessionSettingsType();
            owaUserConfiguration.SessionSettings.ArchiveDisplayName           = string.Empty;
            owaUserConfiguration.SessionSettings.CanActAsOwner                = false;
            owaUserConfiguration.SessionSettings.IsExplicitLogon              = false;
            owaUserConfiguration.SessionSettings.IsExplicitLogonOthersMailbox = false;
            owaUserConfiguration.SessionSettings.UserCulture         = AnonymousUserContext.Current.Culture.Name;
            owaUserConfiguration.SessionSettings.UserDisplayName     = AntiXssEncoder.HtmlEncode(AnonymousUserContext.Current.ExchangePrincipal.MailboxInfo.DisplayName, false);
            owaUserConfiguration.SessionSettings.MaxMessageSizeInKb  = 0;
            owaUserConfiguration.SessionSettings.DefaultFolderIds    = new FolderId[1];
            owaUserConfiguration.SessionSettings.DefaultFolderIds[0] = IdConverter.GetFolderIdFromStoreId(AnonymousUserContext.Current.PublishedCalendarId, new MailboxId(AnonymousUserContext.Current.ExchangePrincipal.MailboxInfo.MailboxGuid));
            owaUserConfiguration.SessionSettings.DefaultFolderNames  = new string[]
            {
                DefaultFolderType.Calendar.ToString()
            };
            owaUserConfiguration.PolicySettings = new PolicySettingsType();
            owaUserConfiguration.PolicySettings.PlacesEnabled  = false;
            owaUserConfiguration.PolicySettings.WeatherEnabled = false;
            owaUserConfiguration.ViewStateConfiguration        = new OwaViewStateConfiguration();
            owaUserConfiguration.ViewStateConfiguration.CalendarViewTypeDesktop = 4;
            owaUserConfiguration.ViewStateConfiguration.CalendarViewTypeNarrow  = 1;
            owaUserConfiguration.ViewStateConfiguration.CalendarViewTypeWide    = 4;
            owaUserConfiguration.SegmentationSettings          = new SegmentationSettingsType(0UL);
            owaUserConfiguration.SegmentationSettings.Calendar = true;
            return(SessionDataHandler.EmitPayload("owaUserConfig", JsonConverter.ToJSON(owaUserConfiguration)));
        }
        // Token: 0x06000D28 RID: 3368 RVA: 0x0003165C File Offset: 0x0002F85C
        protected override NotificationPayloadBase GetPayloadFromNotification(StoreObjectId folderId, QueryNotification notification)
        {
            CalendarItemNotificationPayload calendarItemNotificationPayload = new CalendarItemNotificationPayload();

            calendarItemNotificationPayload.FolderId       = StoreId.StoreIdToEwsId(base.MailboxGuid, folderId);
            calendarItemNotificationPayload.SubscriptionId = base.SubscriptionId;
            calendarItemNotificationPayload.EventType      = notification.EventType;
            calendarItemNotificationPayload.Source         = new MailboxLocation(base.MailboxGuid);
            EwsCalendarItemType ewsCalendarItemType = new EwsCalendarItemType();

            ewsCalendarItemType.InstanceKey      = notification.Index;
            calendarItemNotificationPayload.Item = ewsCalendarItemType;
            if (notification.EventType != QueryNotificationType.RowDeleted)
            {
                VersionedId itemProperty = RowNotificationHandler.GetItemProperty <VersionedId>(notification, 0);
                if (itemProperty == null)
                {
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "Invalid StoreId for calendar item notification.");
                    calendarItemNotificationPayload.Reload = true;
                    return(calendarItemNotificationPayload);
                }
                ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(itemProperty, new MailboxId(base.MailboxGuid), null);
                ewsCalendarItemType.ItemId  = new ItemId(concatenatedId.Id, concatenatedId.ChangeKey);
                ewsCalendarItemType.Start   = base.GetDateTimeProperty(notification, 2);
                ewsCalendarItemType.End     = base.GetDateTimeProperty(notification, 3);
                ewsCalendarItemType.Subject = RowNotificationHandler.GetItemProperty <string>(notification, 4);
                ewsCalendarItemType.LegacyFreeBusyStatusString = BusyTypeConverter.ToString((BusyType)RowNotificationHandler.GetItemProperty <int>(notification, 5));
                ewsCalendarItemType.IsAllDayEvent = RowNotificationHandler.GetItemProperty <bool?>(notification, 6);
                ewsCalendarItemType.IsRecurring   = new bool?(RowNotificationHandler.GetItemProperty <byte[]>(notification, 7) != null);
                if (RowNotificationHandler.IsPropertyDefined(notification, 8))
                {
                    ewsCalendarItemType.Organizer = RowNotificationHandler.CreateRecipientFromParticipant((Participant)notification.Row[8]);
                }
                ewsCalendarItemType.IsMeeting            = RowNotificationHandler.GetItemProperty <bool?>(notification, 9);
                ewsCalendarItemType.MyResponseTypeString = ResponseTypeConverter.ToString((ResponseType)RowNotificationHandler.GetItemProperty <int>(notification, 10));
                ewsCalendarItemType.SensitivityString    = SensitivityConverter.ToString(RowNotificationHandler.GetItemProperty <Sensitivity>(notification, 11));
                ewsCalendarItemType.HasAttachments       = RowNotificationHandler.GetItemProperty <bool?>(notification, 12);
                LocationSourceType itemProperty2 = (LocationSourceType)RowNotificationHandler.GetItemProperty <int>(notification, 26);
                ewsCalendarItemType.EnhancedLocation = ((itemProperty2 == LocationSourceType.None) ? new EnhancedLocationType
                {
                    DisplayName = RowNotificationHandler.GetItemProperty <string>(notification, 13),
                    PostalAddress = new Microsoft.Exchange.Services.Core.Types.PostalAddress()
                } : new EnhancedLocationType
                {
                    DisplayName = RowNotificationHandler.GetItemProperty <string>(notification, 24),
                    Annotation = RowNotificationHandler.GetItemProperty <string>(notification, 25),
                    PostalAddress = new Microsoft.Exchange.Services.Core.Types.PostalAddress
                    {
                        LocationSource = itemProperty2,
                        LocationUri = RowNotificationHandler.GetItemProperty <string>(notification, 27),
                        Latitude = this.GetLocationPropertyValue(notification, 28),
                        Longitude = this.GetLocationPropertyValue(notification, 29),
                        Accuracy = this.GetLocationPropertyValue(notification, 30),
                        Altitude = this.GetLocationPropertyValue(notification, 31),
                        AltitudeAccuracy = this.GetLocationPropertyValue(notification, 32),
                        Street = RowNotificationHandler.GetItemProperty <string>(notification, 33),
                        City = RowNotificationHandler.GetItemProperty <string>(notification, 34),
                        State = RowNotificationHandler.GetItemProperty <string>(notification, 35),
                        Country = RowNotificationHandler.GetItemProperty <string>(notification, 36),
                        PostalCode = RowNotificationHandler.GetItemProperty <string>(notification, 37)
                    }
                });
                StoreId itemProperty3 = RowNotificationHandler.GetItemProperty <StoreId>(notification, 14);
                ewsCalendarItemType.ParentFolderId = IdConverter.GetFolderIdFromStoreId(itemProperty3, new MailboxId(base.MailboxGuid));
                byte[] itemProperty4 = RowNotificationHandler.GetItemProperty <byte[]>(notification, 15);
                if (itemProperty4 != null)
                {
                    try
                    {
                        GlobalObjectId globalObjectId = new GlobalObjectId(itemProperty4);
                        ewsCalendarItemType.UID = globalObjectId.Uid;
                    }
                    catch (CorruptDataException ex)
                    {
                        ExTraceGlobals.NotificationsCallTracer.TraceError <string>((long)this.GetHashCode(), "Exception setting the UID in CalendarItemNotificationHandler:GetPayloadFromNotification. Exception: {1}", ex.Message);
                    }
                }
                ewsCalendarItemType.AppointmentState       = new int?(RowNotificationHandler.GetItemProperty <int>(notification, 16));
                ewsCalendarItemType.IsCancelled            = new bool?((ewsCalendarItemType.AppointmentState.Value & 4) == 4);
                ewsCalendarItemType.CalendarItemTypeString = CalendarItemTypeConverter.ToString(RowNotificationHandler.GetItemProperty <CalendarItemType>(notification, 17));
                ewsCalendarItemType.AppointmentReplyTime   = base.GetDateTimeProperty(notification, 18);
                if (RowNotificationHandler.IsPropertyDefined(notification, 19))
                {
                    ewsCalendarItemType.JoinOnlineMeetingUrl = RowNotificationHandler.GetItemProperty <string>(notification, 19);
                }
                ewsCalendarItemType.Categories  = RowNotificationHandler.GetItemProperty <string[]>(notification, 20);
                ewsCalendarItemType.IsOrganizer = new bool?(RowNotificationHandler.GetItemProperty <bool>(notification, 23));
                ConversationId itemProperty5 = RowNotificationHandler.GetItemProperty <ConversationId>(notification, 21);
                string         id            = IdConverter.ConversationIdToEwsId(base.MailboxGuid, itemProperty5);
                ewsCalendarItemType.ConversationId      = new ItemId(id, null);
                ewsCalendarItemType.IsResponseRequested = new bool?(RowNotificationHandler.GetItemProperty <bool>(notification, 22));
                try
                {
                    base.UserContext.LockAndReconnectMailboxSession(3000);
                    ewsCalendarItemType.EffectiveRights = EffectiveRightsProperty.GetFromEffectiveRights(EffectiveRights.Modify | EffectiveRights.Read | EffectiveRights.Delete, base.UserContext.MailboxSession);
                }
                finally
                {
                    if (base.UserContext.MailboxSessionLockedByCurrentThread())
                    {
                        base.UserContext.UnlockAndDisconnectMailboxSession();
                    }
                }
            }
            return(calendarItemNotificationPayload);
        }