public OperationPermission(AccessType operation, bool allow, EntityMemberMask mask = null) { Util.Check((operation | AllowedOperations) == AllowedOperations, "Invalid operation value - only Peek, ReadStrict and UpdateStrict allowed."); Operation = AllowedOperations & operation; Mask = mask; if(!allow) Status = PermissionStatus.Denied; else if(Mask == null) Status = PermissionStatus.AllowAll; else Status = PermissionStatus.AllowMasked; }
internal void Merge(OperationPermission other) { Util.Check(this.Operation == other.Operation, "Operation must match for merge."); switch(Status) { case PermissionStatus.AllowAll: return; case PermissionStatus.Denied: this.Status = other.Status; this.Mask = other.Mask; return; case PermissionStatus.AllowMasked: switch(other.Status) { case PermissionStatus.Denied: return; case PermissionStatus.AllowAll: this.Status = PermissionStatus.AllowAll; return; case PermissionStatus.AllowMasked: this.Mask.Or(other.Mask); return; } break; } }
public PermissionResult(Permission permission, HiveId sourceId, PermissionStatus status) { Permission = permission; SourceId = sourceId; Status = status; }
public PermissionStatusResult(HiveId sourceId, PermissionStatus status, Guid permissionId) { SourceId = sourceId; Status = status; PermissionId = permissionId; }
private static IEnumerable<string> GetPermissionsWithStatus(PermissionsStatus permissionsStatus, PermissionStatus status) { return permissionsStatus.Status.Where(kvp => kvp.Value == status) .Select(kvp => kvp.Key); }
protected internal override string GetEntry(string parent, FsImageProto.INodeSection.INode inode) { StringBuilder buffer = new StringBuilder(); string inodeName = inode.GetName().ToStringUtf8(); Path path = new Path(parent.IsEmpty() ? "/" : parent, inodeName.IsEmpty() ? "/" : inodeName); buffer.Append(path.ToString()); PermissionStatus p = null; switch (inode.GetType()) { case FsImageProto.INodeSection.INode.Type.File: { FsImageProto.INodeSection.INodeFile file = inode.GetFile(); p = GetPermission(file.GetPermission()); Append(buffer, file.GetReplication()); Append(buffer, FormatDate(file.GetModificationTime())); Append(buffer, FormatDate(file.GetAccessTime())); Append(buffer, file.GetPreferredBlockSize()); Append(buffer, file.GetBlocksCount()); Append(buffer, FSImageLoader.GetFileSize(file)); Append(buffer, 0); // NS_QUOTA Append(buffer, 0); // DS_QUOTA break; } case FsImageProto.INodeSection.INode.Type.Directory: { FsImageProto.INodeSection.INodeDirectory dir = inode.GetDirectory(); p = GetPermission(dir.GetPermission()); Append(buffer, 0); // Replication Append(buffer, FormatDate(dir.GetModificationTime())); Append(buffer, FormatDate(0)); // Access time. Append(buffer, 0); // Block size. Append(buffer, 0); // Num blocks. Append(buffer, 0); // Num bytes. Append(buffer, dir.GetNsQuota()); Append(buffer, dir.GetDsQuota()); break; } case FsImageProto.INodeSection.INode.Type.Symlink: { FsImageProto.INodeSection.INodeSymlink s = inode.GetSymlink(); p = GetPermission(s.GetPermission()); Append(buffer, 0); // Replication Append(buffer, FormatDate(s.GetModificationTime())); Append(buffer, FormatDate(s.GetAccessTime())); Append(buffer, 0); // Block size. Append(buffer, 0); // Num blocks. Append(buffer, 0); // Num bytes. Append(buffer, 0); // NS_QUOTA Append(buffer, 0); // DS_QUOTA break; } default: { break; } } System.Diagnostics.Debug.Assert(p != null); Append(buffer, p.GetPermission().ToString()); Append(buffer, p.GetUserName()); Append(buffer, p.GetGroupName()); return(buffer.ToString()); }
internal async Task Request(PermissionType permission, PermissionStatus expectedStatus) { var status = await Permissions.CheckStatusAsync(permission); Assert.Equal(expectedStatus, status); }
public _INodeWithAdditionalFields_92(long baseArg1, byte[] baseArg2, PermissionStatus baseArg3, long baseArg4, long baseArg5) : base(baseArg1, baseArg2, baseArg3, baseArg4, baseArg5) { }
private static IEnumerable <string> GetPermissionsWithStatus(PermissionsStatus permissionsStatus, PermissionStatus status) { return(permissionsStatus.Status.Where(kvp => kvp.Value == status) .Select(kvp => kvp.Key)); }
/// <summary> /// 权限是否已授予 /// </summary> /// <param name="permissionStatus"></param> /// <returns></returns> public static bool IsOk(this PermissionStatus permissionStatus) => permissionStatus == PermissionStatus.Granted;
public static void Start() { IsBusy = false; try { Device.BeginInvokeOnMainThread(async() => { beaconLocater = DependencyService.Get <IBeaconLocater>(); beaconCollection = new ObservableCollection <BeaconItem>(); PermissionStatus status = PermissionStatus.Unknown; if (Device.RuntimePlatform == Device.iOS) { status = await CrossPermissions.Current .CheckPermissionStatusAsync(Permission.Location); if (status != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location)) { await App.Current.MainPage.DisplayAlert("Location", "Please switch on Location", "OK"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location); status = results[Permission.Location]; } } else if (Device.RuntimePlatform == Device.Android) { status = await CrossPermissions.Current .CheckPermissionStatusAsync(Permission.Bluetooth); if (status != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Bluetooth)) { await App.Current.MainPage.DisplayAlert("Bluetooth", "Please switch on Bluetooth", "OK"); } var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Bluetooth); status = results[Permission.Bluetooth]; } if (!CrossPermissions.Current.IsBluetoothEnabled()) { Device.BeginInvokeOnMainThread(async() => { var canBluetoothEnabled = await App.Current.MainPage.DisplayAlert("Bluetooth", "Please enable device Bluetooth to locate Beacons", "OK", "Cancel"); if (canBluetoothEnabled) { CrossPermissions.Current.OpenBluetoothSettings(); } }); } } if (status == PermissionStatus.Granted) { startTimer?.Stop(); startTimer = new TimerHolder(1000, () => { try { var beaconCollection = beaconLocater.GetAvailableBeacons(); var _BaseViewModel = Application.Current.MainPage.BindingContext as BaseViewModel; if (beaconCollection != null && beaconCollection.Count() > 0 && ( Helpers.Settings.SubCategorySettings == "Neuro" || Helpers.Settings.SubCategorySettings == "Emergency" )) { // _BaseViewModel.ImageName = "hospitalMap.png"; var closestBeacon = ((List <BeaconItem>)beaconCollection).OrderBy(b => b.CurrentDistance).First(); CrossLocalNotifications.Current.Show("PathFinder", "Wrong Direction", 101); CrossVibrate.Current.Vibration(TimeSpan.FromSeconds(1)); } else if (beaconCollection != null && beaconCollection.Count() > 0) { var closestBeacon = ((List <BeaconItem>)beaconCollection).OrderBy(b => b.CurrentDistance).First(); if (closestBeacon != null) { switch (closestBeacon.Minor) { case "10": if (LastLocation != "10") { CrossLocalNotifications.Current.Show("PathFinder", "You are at conference room projector", 101); Helpers.Settings.CurrentLocation = "projector"; _BaseViewModel.ImageName = "pj.png"; } LastLocation = "10"; break; case "15": if (LastLocation != "15") { CrossLocalNotifications.Current.Show("PathFinder", "You are at conference room tv", 101); Helpers.Settings.CurrentLocation = "tv"; _BaseViewModel.ImageName = "tv.png"; } LastLocation = "15"; break; case "20": if (LastLocation != "20") { CrossLocalNotifications.Current.Show("PathFinder", "You are at server room", 101); Helpers.Settings.CurrentLocation = "server"; _BaseViewModel.ImageName = "sr.png"; } LastLocation = "20"; break; } } // CrossVibrate.Current.Vibration(TimeSpan.FromSeconds(1)); } else { // _BaseViewModel.ImageName = "hospitalMap.png"; CrossLocalNotifications.Current.Cancel(101); CrossVibrate.Current.Vibration(TimeSpan.FromSeconds(0)); } } catch (Exception) { BeaconService.IsBusy = false; } }); startTimer.Start(); } }); } catch (Exception) { } }
public PermissionRequestResult(string permission, bool shouldShowRequestPermissionRationale, PermissionStatus status) { _permission = permission; _shouldShowRequestPermissionRationale = shouldShowRequestPermissionRationale; _status = status; }
private async void permissionCheck() { status = await Permissions.CheckStatusAsync <Permissions.LocationAlways>(); }
public async Task <string> Scan() { try { PermissionStatus status = await CrossPermissions.Current.CheckPermissionStatusAsync <CameraPermission>(); if (status != PermissionStatus.Granted) { status = await CrossPermissions.Current.RequestPermissionAsync <CameraPermission>(); } if (status != PermissionStatus.Granted) { IsSuccessful = false; Result = "Skanowanie kodu QR wymaga uprawnień do użycia kamery. Użytkownik odmówił tego uprawnienia. Spróbuj jeszcze raz i przyznaj odpowiednie uprawnienie"; } else { var options = new ZXing.Mobile.MobileBarcodeScanningOptions { PossibleFormats = new List <ZXing.BarcodeFormat> { ZXing.BarcodeFormat.QR_CODE }, TryHarder = false, AutoRotate = false, TryInverted = false, }; scanPage = new ZXingScannerPage(); scanPage.AutoFocus(); using (SemaphoreSlim semaphoreSlim = new SemaphoreSlim(0, 1)) { scanPage.OnScanResult += (result) => { //DateTime _start = DateTime.Now; scanPage.IsScanning = false; Device.BeginInvokeOnMainThread(async() => { Application.Current.MainPage.Navigation.PopAsync(); try { Result = result.Text; } catch (Exception ex) { Result = ex.Message; } semaphoreSlim.Release(); }); }; await Application.Current.MainPage.Navigation.PushAsync(scanPage); await semaphoreSlim.WaitAsync(); } } } catch (Exception ex) { } return(Result); }
/// <summary>constructor</summary> public INodeDirectory(long id, byte[] name, PermissionStatus permissions, long mtime ) : base(id, name, permissions, mtime, 0L) { }