private async void UpdateWolClient(GrpcApplicationAgent agent) { if (!await IsAuthorizedAsync()) { return; } var package = await WakeOnLanManager.GetMacPackageAsync(agent); await WakeOnLanManager.UpdateDefinitionAsync(package); }
public static async Task <MacPackage> GetMacPackageAsync(GrpcApplicationAgent agent) { Log.Trace("Building Mac package"); var addresses = await agent.DesktopClient.GetNetworkMacAddressesAsync(TimeSpan.FromSeconds(5)); var hostName = await agent.DesktopClient.GetHostNameAsync(TimeSpan.FromSeconds(5)); var macPackage = new MacPackage(); macPackage.Addresses = addresses.Select(d => d.MacAddress).ToArray(); macPackage.HostName = hostName; Log.Trace("Package created for {HostName}", hostName); return(macPackage); }
public override void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); var ipAddress = GetConnectionAddress(); var machineName = Arguments.GetString(ArgumentTargetMachineName); var ipPort = GetConnectionPort(); // if (!HasBeenResumedBefore) // Activity.SetStatusBarTitle($"{machineName}"); _agent?.Dispose(); _agent = this.GetAgent(); UpdateWolClient(_agent); }
private async Task <LoginResponse> GetLoginResponseAsync(GrpcApplicationAgent grpcApplicationAgent, JwtLoginCredentials input) { try { return(await grpcApplicationAgent.FullDesktopClient.LoginAsync(new LoginRequest() { User = input.User, Password = input.Password })); } catch (RpcException exception) { Log.Error(exception, "Login error"); return(new LoginResponse() { InvalidCredentials = true }); } }
private static async Task <bool> CheckIsAuthenticatedAsync(GrpcApplicationAgent agent) { var authenticated = true; CheckIsAuthenticatedResponse response = null; try { response = await agent.FullDesktopClient.CheckIsAuthenticatedAsync(new CheckIsAuthenticatedRequest()).ResponseAsync; } catch (RpcException exception) when(exception.Status.StatusCode == StatusCode.Unauthenticated) { authenticated = false; } catch (RpcException exception) { Log.Error(exception); ToastHelper.Display("Failed to check authentication state", ToastLength.Long); authenticated = false; } return(authenticated && response.Result); }
private async Task <bool> TryUpdateAuthenticationAsync(GrpcApplicationAgent agent, HostEndpointAddress endpointAddress) { var input = await LoginDialog.GetInputAsync("Authentication required"); if (input == null) { ToastHelper.Display("Authentication required", ToastLength.Long); return(false); } var loginResponse = await GetLoginResponseAsync(agent, input); if (loginResponse.InvalidCredentials) { ToastHelper.Display("Invalid credentials", ToastLength.Long); return(false); } var authenticationStorage = new AuthenticationStorage(endpointAddress); await authenticationStorage.UpdateAsync(loginResponse.AccessToken, loginResponse.RefreshToken).ConfigureAwait(false); return(true); }
public override async void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); _seekBar = view.FindViewById <SeekBar>(Resource.Id.seekBar1); _textView = view.FindViewById <TextView>(Resource.Id.textView1); _imageViewMasterToggle = view.FindViewById <ImageView>(Resource.Id.button1); _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView1); _swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout1); _agent?.Dispose(); _agent = this.GetAgent(); _imageViewMasterToggle.Clickable = true; _swipeRefreshLayout.Refresh += SwipeRefreshLayoutOnRefresh; var dataSource = new AudioApplicationDataSource(_agent); dataSource.UpdateRequired += DataSourceOnUpdateRequired; _recyclerView.SetAdapter(dataSource); _imageViewMasterToggle.Click += ToggleMuteClicked; _seekBar.ProgressChanged += SeekBarOnProgressChanged; _seekBar.SetProgress(await _agent.DesktopClient.GetMasterVolumeAsync(TimeSpan.FromSeconds(5), 45), false); }
protected abstract Task <bool> ExecuteFinalizerAsync(GrpcApplicationAgent agent);
protected override async Task <bool> ExecuteFinalizerAsync(GrpcApplicationAgent agent) { return(await agent.DesktopClient.RestartAsync(TimeSpan.FromSeconds(5), false, TimeSpan.FromSeconds(60))); }
public AudioApplicationDataSource(GrpcApplicationAgent agent) { _agent = agent; }
protected override async Task <bool> ExecuteFinalizerAsync(GrpcApplicationAgent agent) { return(await agent.DesktopClient.HibernateAsync(TimeSpan.FromSeconds(5))); }