Пример #1
0
        private Theme LoadUserTheme()
        {
            ConfigurationContext configurationContext = new ConfigurationContext(this);
            Theme result;

            if (configurationContext.IsFeatureEnabled(Feature.Themes))
            {
                string text = null;
                try
                {
                    base.LockAndReconnectMailboxSession(30000);
                    UserConfigurationPropertyDefinition propertyDefinition = UserOptionPropertySchema.Instance.GetPropertyDefinition(UserConfigurationPropertyId.ThemeStorageId);
                    UserOptionsType userOptionsType = new UserOptionsType();
                    userOptionsType.Load(base.MailboxSession, new UserConfigurationPropertyDefinition[]
                    {
                        propertyDefinition
                    });
                    text = userOptionsType.ThemeStorageId;
                }
                catch (Exception)
                {
                    ExTraceGlobals.ThemesTracer.TraceError(0L, "Failed to find the user's theme from UserOptions");
                }
                finally
                {
                    base.UnlockAndDisconnectMailboxSession();
                }
                if (string.IsNullOrEmpty(text))
                {
                    result = this.DefaultTheme;
                }
                else
                {
                    uint idFromStorageId = ThemeManagerFactory.GetInstance(this.CurrentOwaVersion).GetIdFromStorageId(text);
                    if (idFromStorageId == 4294967295U)
                    {
                        result = this.DefaultTheme;
                    }
                    else
                    {
                        result = ThemeManagerFactory.GetInstance(this.CurrentOwaVersion).Themes[(int)((UIntPtr)idFromStorageId)];
                    }
                }
            }
            else
            {
                result = this.DefaultTheme;
            }
            return(result);
        }
Пример #2
0
        protected override ThemeSelectionInfoType InternalExecute()
        {
            ISet <string> set         = new HashSet <string>();
            UserContext   userContext = UserContextManager.GetUserContext(HttpContext.Current);
            IEnumerable <ThemeStyleResource> userMouseThemedResources = this.GetUserMouseThemedResources(userContext);

            foreach (ThemeStyleResource themeStyleResource in userMouseThemedResources)
            {
                string item = Globals.FormatURIForCDN(themeStyleResource.StyleDirectory) + themeStyleResource.ResourceName;
                set.Add(item);
            }
            string currentOwaVersion = userContext.CurrentOwaVersion;

            return(new ThemeSelectionInfoType
            {
                Themes = ThemeManagerFactory.GetInstance(currentOwaVersion).Themes,
                CssPaths = set.Distinct <string>().ToArray <string>(),
                ThemePath = ResourcePathBuilderUtilities.GetThemeResourcesRelativeFolderPath(ResourcePathBuilderUtilities.GetResourcesRelativeFolderPath(currentOwaVersion))
            });
        }
Пример #3
0
        // Token: 0x06001BCE RID: 7118 RVA: 0x0006B2E4 File Offset: 0x000694E4
        protected override SetUserThemeResponse InternalExecute()
        {
            UserContext          userContext          = UserContextManager.GetUserContext(CallContext.Current.HttpContext, CallContext.Current.EffectiveCaller, true);
            ConfigurationContext configurationContext = new ConfigurationContext(userContext);
            SetUserThemeResponse setUserThemeResponse = new SetUserThemeResponse
            {
                OwaSuccess  = false,
                O365Success = false
            };

            if (!configurationContext.IsFeatureEnabled(Feature.Themes) || string.IsNullOrEmpty(this.request.ThemeId))
            {
                return(setUserThemeResponse);
            }
            uint idFromStorageId = ThemeManagerFactory.GetInstance(userContext.CurrentOwaVersion).GetIdFromStorageId(this.request.ThemeId);

            this.tracer.TraceDebug <uint>(1L, "SetUserTheme.InternalExecute::id='{0}'", idFromStorageId);
            if (idFromStorageId == 4294967295U)
            {
                throw new OwaInvalidOperationException("The theme doesn't exist any more on the server");
            }
            string userPrincipalName = userContext.LogonIdentity.GetOWAMiniRecipient().UserPrincipalName;

            setUserThemeResponse.O365Success = this.UpdateO365Theme(this.request.ThemeId, userPrincipalName, userContext);
            if (this.request.ThemeId == userContext.DefaultTheme.StorageId)
            {
                this.request.ThemeId = string.Empty;
            }
            UserConfigurationPropertyDefinition propertyDefinition = UserOptionPropertySchema.Instance.GetPropertyDefinition(UserConfigurationPropertyId.ThemeStorageId);

            new UserOptionsType
            {
                ThemeStorageId = this.request.ThemeId
            }.Commit(base.CallContext, new UserConfigurationPropertyDefinition[]
            {
                propertyDefinition
            });
            setUserThemeResponse.OwaSuccess = true;
            userContext.ClearCachedTheme();
            return(setUserThemeResponse);
        }
Пример #4
0
        private IEnumerable <ThemeStyleResource> GetUserMouseThemedResources(UserContext userContext)
        {
            if (userContext == null || userContext.FeaturesManager == null)
            {
                return(new ThemeStyleResource[0]);
            }
            List <ThemeStyleResource> list   = new List <ThemeStyleResource>();
            string       owaVersion          = userContext.CurrentOwaVersion;
            SlabManifest slabManifest        = SlabManifestCollectionFactory.GetInstance(owaVersion).GetSlabManifest(SlabManifestType.Standard, LayoutType.Mouse);
            IDictionary <string, Slab> slabs = slabManifest.GetSlabs(userContext.FeaturesManager.GetClientEnabledFeatures(), LayoutType.Mouse);
            Slab bootSlab = null;

            if (slabs.ContainsKey("boot"))
            {
                bootSlab = slabs["boot"];
                list.AddRange(UserResourcesFinder.GetUserDataEmbededStylesLinks(bootSlab, owaVersion));
            }
            IEnumerable <SlabStyleFile> source = (from p in slabManifest.GetSlabs(userContext.FeaturesManager.GetClientEnabledFeatures(), LayoutType.Mouse)
                                                  where p.Value != bootSlab
                                                  select p).SelectMany((KeyValuePair <string, Slab> p) => p.Value.Styles);
            IEnumerable <ThemeStyleResource> collection = from style in source
                                                          where style.IsSprite()
                                                          select new ThemeStyleResource(style.Name, ResourceTarget.MouseOnly, owaVersion, ThemeManagerFactory.GetInstance(owaVersion).ShouldSkipThemeFolder);

            list.AddRange(collection);
            IEnumerable <LocalizedThemeStyleResource> collection2 = from style in source
                                                                    where !style.IsSprite()
                                                                    select new LocalizedThemeStyleResource(style.Name, ResourceTarget.MouseOnly, owaVersion, ThemeManagerFactory.GetInstance(owaVersion).ShouldSkipThemeFolder);

            list.AddRange(collection2);
            return(list);
        }