private void SetUser(UserProfile userProfile) { try { if (userProfile != null && UserProxy != null) { UserProxy.SetUserProfile(userProfile, _localSharesList, _serverSharesList); } else { UserProxy?.Clear(); } IsUserSelected = userProfile != null; IsSystemUserSelected = userProfile?.ProfileType == UserProfileType.ClientProfile; IsRestrictedToOwn = CheckRestrictedToOwn(); ProfileTypeName = userProfile != null?LocalizationHelper.Translate("[UserConfig." + userProfile.ProfileType + "]") : string.Empty; SetSelectedShares(); SetSelectedRestrictionGroups(); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Error("UserConfigModel: Error selecting user", e); } }
public UserConfigModel() { _isHomeServerConnectedProperty = new WProperty(typeof(bool), false); _showLocalSharesProperty = new WProperty(typeof(bool), false); _isLocalHomeServerProperty = new WProperty(typeof(bool), false); _anyShareAvailableProperty = new WProperty(typeof(bool), false); _selectShareInfoProperty = new WProperty(typeof(string), string.Empty); _selectedRestrictionGroupsInfoProperty = new WProperty(typeof(string), string.Empty); _profileTypeNameProperty = new WProperty(typeof(string), string.Empty); _isRestrictedToOwnProperty = new WProperty(typeof(bool), false); _isUserSelectedProperty = new WProperty(typeof(bool), false); _isSystemUserSelectedProperty = new WProperty(typeof(bool), false); _templateList = new ItemsList(); ListItem item = null; foreach (var profile in UserSettingStorage.UserProfileTemplates) { item = new ListItem(); item.SetLabel(Consts.KEY_NAME, profile.TemplateName); item.AdditionalProperties[Consts.KEY_PROFILE_TEMPLATE_ID] = profile.TemplateId; _templateList.Add(item); } RequestRestrictions(); FillRestrictionGroupList(); UserProxy = new UserProxy(); }
public UserLanguageModel() { _isHomeServerConnectedProperty = new WProperty(typeof(bool), false); _isRestrictedToOwnProperty = new WProperty(typeof(bool), false); _isUserSelectedProperty = new WProperty(typeof(bool), false); List <CultureInfo> cultures = new List <CultureInfo>(CultureInfo.GetCultures(CultureTypes.SpecificCultures)); cultures.Sort(CompareByName); _langaugeList = new ItemsList(); ListItem item = new ListItem(); item.SetLabel(Consts.KEY_NAME, LocalizationHelper.CreateResourceString("[UserConfig.Default]")); item.AdditionalProperties[Consts.KEY_LANGUAGE] = ""; _langaugeList.Add(item); foreach (var ci in cultures) { item = new ListItem(); item.SetLabel(Consts.KEY_NAME, LocalizationHelper.CreateStaticString(ci.DisplayName)); item.AdditionalProperties[Consts.KEY_LANGUAGE] = ci; _langaugeList.Add(item); } UserProxy = new UserProxy(); }
private void OnAutoLoginUserSelectionChanged(AbstractProperty property, object oldValue) { UserProxy userProfile = null; lock (_syncObj) { userProfile = (UserProxy)_autoLoginUserList.Where(i => i.Selected).FirstOrDefault(); } SelectAutoUser(userProfile); }
/// <summary> /// this will turn the _users list into the _usersExposed list /// </summary> private async Task RefreshUserList() { // clear the exposed users list _loginUserList.Clear(); _autoLoginUserList.Clear(); IUserManagement userManagement = ServiceRegistration.Get <IUserManagement>(); if (userManagement.UserProfileDataManagement == null) { return; } // Get our local client profile, it will be available for local login var localSystemGuid = Guid.Parse(ServiceRegistration.Get <ISettingsManager>().Load <SystemResolverSettings>().SystemId); UserProxy proxy; proxy = new UserProxy(); proxy.SetLabel(Consts.KEY_NAME, LocalizationHelper.Translate(Consts.RES_DISABLE)); proxy.SetUserProfile(new UserProfile(Guid.Empty, LocalizationHelper.Translate(Consts.RES_DISABLE))); proxy.Selected = UserSettingStorage.AutoLoginUser == Guid.Empty; proxy.SelectedProperty.Attach(OnAutoLoginUserSelectionChanged); _autoLoginUserList.Add(proxy); // add users to expose them var users = await userManagement.UserProfileDataManagement.GetProfilesAsync(); foreach (UserProfile user in users) { var isCurrentClient = user.ProfileId == localSystemGuid; if (user.ProfileType != UserProfileType.ClientProfile || isCurrentClient) { proxy = new UserProxy(); proxy.SetLabel(Consts.KEY_NAME, user.Name); proxy.SetUserProfile(user); if (UserSettingStorage.AutoLoginUser == user.ProfileId) { proxy.Selected = true; } proxy.SelectedProperty.Attach(OnAutoLoginUserSelectionChanged); _autoLoginUserList.Add(proxy); if (!isCurrentClient) { _loginUserList.Add(proxy); } } } // tell the skin that something might have changed _loginUserList.FireChange(); _autoLoginUserList.FireChange(); }
/// <summary> /// selects a user /// </summary> /// <param name="item"></param> public void SelectUser(UserProxy item) { UserPassword = ""; IsPasswordIncorrect = false; _passwordUser = item.Id; if (!string.IsNullOrEmpty(item.Password)) { ServiceRegistration.Get <IScreenManager>().ShowDialog("DialogEnterPassword", (string name, Guid id) => { _ = LoginUser(_passwordUser, UserPassword); }); } else { _ = LoginUser(_passwordUser, UserPassword); } }
private void SetUser(UserProfile userProfile) { try { if (userProfile != null && UserProxy != null) { UserProxy.SetUserProfile(userProfile); } else { UserProxy?.Clear(); } IsUserSelected = userProfile != null; IsRestrictedToOwn = CheckRestrictedToOwn(); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Error("UserLanguageModel: Error selecting user", e); } }
public void SelectAutoUser(UserProxy item) { if (item == null) { return; } UserPassword = ""; IsPasswordIncorrect = false; _passwordUser = item.Id; if (!string.IsNullOrEmpty(item.Password) && UserSettingStorage.AutoLoginUser != item.Id) { ServiceRegistration.Get <IScreenManager>().ShowDialog("DialogEnterPassword", (string name, Guid id) => { _ = SetAutoLoginUser(_passwordUser, UserPassword); }); } else { _ = SetAutoLoginUser(_passwordUser, UserPassword); } }