From 337754df1a82858505f6bc81ed559b4ebf2779bc Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Sat, 11 Apr 2020 09:52:46 -0700 Subject: [PATCH] Refactor and cleanup. --- Agent.Installer.Win/App.xaml.cs | 12 +--- Agent.Installer.Win/MainWindow.xaml.cs | 12 ---- .../Properties/AssemblyInfo.cs | 2 - .../Services/CommandLineParser.cs | 3 - Agent.Installer.Win/Services/Executor.cs | 4 -- .../Services/InstallerService.cs | 7 +- Agent.Installer.Win/Services/Logger.cs | 5 -- Agent.Installer.Win/Services/MessageBoxEx.cs | 7 +- Agent.Installer.Win/Services/ProcessEx.cs | 7 +- .../ViewModels/MainWindowViewModel.cs | 3 - .../ViewModels/ViewModelBase.cs | 7 +- Agent/Models/ChatSession.cs | 5 +- Agent/Program.cs | 43 ++--------- Agent/Services/AppLauncher.cs | 31 ++++---- Agent/Services/Bash.cs | 2 - Agent/Services/CMD.cs | 3 - Agent/Services/ChatClientService.cs | 7 +- Agent/Services/CommandExecutor.cs | 15 ++-- Agent/Services/ConfigService.cs | 4 +- Agent/Services/DeviceSocket.cs | 30 ++++++-- Agent/Services/Logger.cs | 6 +- Agent/Services/PSCore.cs | 3 - Agent/Services/ScriptRunner.cs | 2 - Agent/Services/Uninstaller.cs | 10 +-- Agent/Services/Updater.cs | 12 ++-- Agent/Services/WindowsPS.cs | 2 - Agent/Services/WindowsService.cs | 27 +++---- Desktop.Linux/Program.cs | 5 +- Desktop.Linux/Services/Config.cs | 5 -- Desktop.Linux/Services/Executor.cs | 4 -- .../ViewModels/HostNamePromptViewModel.cs | 8 +-- .../ViewModels/MainWindowViewModel.cs | 6 +- .../ViewModels/MessageBoxViewModel.cs | 3 - Desktop.Linux/ViewModels/ViewModelBase.cs | 5 +- Desktop.Linux/Views/MainWindow.xaml.cs | 1 - Desktop.Win/App.xaml.cs | 7 -- Desktop.Win/Controls/HostNamePrompt.xaml.cs | 15 +--- Desktop.Win/MainWindow.xaml.cs | 12 ---- Desktop.Win/Services/Config.cs | 5 -- Desktop.Win/Services/Executor.cs | 4 -- .../ViewModels/HostNamePromptViewModel.cs | 9 +-- Desktop.Win/ViewModels/ViewModelBase.cs | 7 +- ScreenCast.Core/Communication/CasterSocket.cs | 5 -- .../Communication/WebRtcSession.cs | 3 - ScreenCast.Core/Conductor.cs | 5 -- ScreenCast.Core/Enums/AppMode.cs | 8 +-- ScreenCast.Core/Interfaces/IAudioCapturer.cs | 6 +- .../Interfaces/IClipboardService.cs | 2 - .../Interfaces/IKeyboardMouseInput.cs | 5 -- ScreenCast.Core/Interfaces/IScreenCapturer.cs | 3 - ScreenCast.Core/Interfaces/IScreenCaster.cs | 3 - ScreenCast.Core/Models/Viewer.cs | 3 - ScreenCast.Core/ServiceContainer.cs | 2 - ScreenCast.Core/Services/ChatHostService.cs | 7 +- ScreenCast.Core/Services/IdleTimer.cs | 2 - ScreenCast.Core/Services/ScreenCasterBase.cs | 16 ++--- ScreenCast.Core/Utilities/ImageUtils.cs | 7 +- .../Services/AudioCapturerLinux.cs | 3 - .../Services/ClipboardServiceLinux.cs | 2 - .../Services/KeyboardMouseInputLinux.cs | 4 -- .../Services/ScreenCapturerLinux.cs | 1 - .../Services/ScreenCasterLinux.cs | 1 - ScreenCast.Linux/X11Interop/LibX11.cs | 4 -- ScreenCast.Linux/X11Interop/LibXtst.cs | 2 - ScreenCast.Win/Models/DirectXOutput.cs | 2 - ScreenCast.Win/Program.cs | 2 - ScreenCast.Win/Services/AudioCapturerWin.cs | 6 +- .../Services/ClipboardServiceWin.cs | 5 -- ScreenCast.Win/Services/CursorIconWatcher.cs | 8 +-- .../Services/KeyboardMouseInputWin.cs | 53 +++++--------- ScreenCast.Win/Services/ScreenCapturerWin.cs | 4 -- ScreenCast.Win/Services/ScreenCasterWin.cs | 5 -- Server/API/AgentUpdateController.cs | 3 - Server/API/AlertsController.cs | 6 +- Server/API/ClientDownloadsController.cs | 7 -- Server/API/CommandsController.cs | 3 - Server/API/DevicesController.cs | 6 +- Server/API/FileSharingController.cs | 6 -- Server/API/LoginController.cs | 7 +- .../API/OrganizationManagementController.cs | 9 +-- Server/API/RemoteControlController.cs | 4 -- Server/API/ScriptingController.cs | 4 +- Server/API/ServerLogsController.cs | 10 +-- .../Areas/Identity/IdentityHostingStartup.cs | 10 +-- .../Pages/Account/ConfirmEmail.cshtml.cs | 5 +- .../Account/ConfirmEmailChange.cshtml.cs | 5 +- .../Pages/Account/ForgotPassword.cshtml.cs | 5 +- .../Identity/Pages/Account/Login.cshtml.cs | 4 +- .../Identity/Pages/Account/Logout.cshtml.cs | 4 +- .../Pages/Account/Manage/ApiTokens.cshtml.cs | 1 - .../Manage/EnableAuthenticator.cshtml.cs | 6 +- .../Pages/Account/Manage/Index.cshtml.cs | 3 - .../Pages/Account/Manage/ManageNavPages.cs | 3 - .../Pages/Account/Manage/Options.cshtml.cs | 5 -- .../Account/Manage/Organization.cshtml.cs | 3 - .../Pages/Account/Manage/ServerLogs.cshtml.cs | 2 - .../Identity/Pages/Account/Register.cshtml.cs | 5 +- Server/Auth/ApiAuthorizationFilter.cs | 4 -- Server/Auth/PasswordGenerator.cs | 5 +- Server/Data/ApplicationDbContext.cs | 1 - Server/Migrations/20200305230311_Initial.cs | 3 +- Server/Models/ApiLogin.cs | 7 +- Server/Models/RCSessionInfo.cs | 3 - Server/Models/RecordingSessionState.cs | 6 +- Server/Models/RemoteControlFrame.cs | 2 - Server/Models/RemoteControlRequest.cs | 7 +- Server/Pages/About.cshtml.cs | 6 +- Server/Pages/Agents.cshtml.cs | 6 -- Server/Pages/Credits.cshtml.cs | 5 -- Server/Pages/EditDevice.cshtml.cs | 2 - Server/Pages/Error.cshtml.cs | 5 -- Server/Pages/Index.cshtml.cs | 3 +- Server/Pages/Invite.cshtml.cs | 6 +- Server/Pages/Privacy.cshtml.cs | 7 +- Server/Pages/RemoteControl.cshtml.cs | 7 +- Server/Pages/TwoFactorRequired.cshtml.cs | 7 +- Server/Program.cs | 11 +-- Server/Services/ApplicationConfig.cs | 8 +-- Server/Services/BrowserSocketHub.cs | 6 -- Server/Services/DataService.cs | 3 - Server/Services/DeviceSocketHub.cs | 5 -- Server/Services/EmailSender.cs | 5 -- Server/Services/PascalCasePolicy.cs | 5 +- Server/Services/RCBrowserSocketHub.cs | 3 - Server/Services/RCDeviceSocketHub.cs | 6 +- .../Services/RemoteControlSessionRecorder.cs | 7 +- Server/Startup.cs | 11 --- Shared/Enums/DynamicDtoType.cs | 5 +- Shared/Enums/Platform.cs | 6 +- Shared/Enums/RemoteControlMode.cs | 6 +- Shared/Enums/Theme.cs | 7 +- Shared/Helpers/TaskHelper.cs | 2 - Shared/Models/Alert.cs | 2 - Shared/Models/AlertOptions.cs | 5 +- Shared/Models/ApiToken.cs | 2 - Shared/Models/CommandResult.cs | 1 - Shared/Models/ConnectionInfo.cs | 2 - Shared/Models/CursorInfo.cs | 7 +- Shared/Models/Device.cs | 8 +-- Shared/Models/DeviceGroup.cs | 1 - Shared/Models/DeviceSetupOptions.cs | 6 +- Shared/Models/Drive.cs | 6 +- Shared/Models/EventLog.cs | 2 - Shared/Models/FrameInfo.cs | 4 -- Shared/Models/GenericCommandResult.cs | 4 -- Shared/Models/IDynamicDto.cs | 3 - Shared/Models/InviteLink.cs | 2 - Shared/Models/Organization.cs | 3 +- Shared/Models/PSCoreCommandResult.cs | 2 - Shared/Models/PSError.cs | 6 +- Shared/Models/RemotelyUser.cs | 4 -- Shared/Models/RemotelyUserOptions.cs | 2 - Shared/Models/ScreenCastRequest.cs | 6 +- Shared/Models/SharedFile.cs | 2 - Shared/Models/UserDevicePermission.cs | 2 - Shared/Models/WindowsSession.cs | 6 +- Shared/Services/DeviceInformation.cs | 21 +++--- Shared/Services/RandomGenerator.cs | 5 +- .../EnvironmentHelper.cs} | 71 +++++++++++-------- Shared/ViewModels/Organization/Invite.cs | 2 - .../Organization/OrganizationUser.cs | 6 +- Shared/Win32/ADVAPI32.cs | 2 - Shared/Win32/GDI32.cs | 4 -- Shared/Win32/User32.cs | 2 - Shared/Win32/Win32Interop.cs | 8 +-- Tests/CaptureTests.cs | 2 - Tests/DataServiceTests.cs | 11 +-- Tests/IoCActivator.cs | 5 -- Tests/TestData.cs | 6 -- 169 files changed, 218 insertions(+), 875 deletions(-) rename Shared/{Services/OSUtils.cs => Utilities/EnvironmentHelper.cs} (90%) diff --git a/Agent.Installer.Win/App.xaml.cs b/Agent.Installer.Win/App.xaml.cs index 370b45ca..716cf625 100644 --- a/Agent.Installer.Win/App.xaml.cs +++ b/Agent.Installer.Win/App.xaml.cs @@ -1,14 +1,4 @@ -using Remotely.Agent.Installer.Win.Services; -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; namespace Remotely.Agent.Installer.Win { diff --git a/Agent.Installer.Win/MainWindow.xaml.cs b/Agent.Installer.Win/MainWindow.xaml.cs index 94e808ba..0ded1eaf 100644 --- a/Agent.Installer.Win/MainWindow.xaml.cs +++ b/Agent.Installer.Win/MainWindow.xaml.cs @@ -1,19 +1,7 @@ using Remotely.Agent.Installer.Win.Services; using Remotely.Agent.Installer.Win.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; namespace Remotely.Agent.Installer.Win { diff --git a/Agent.Installer.Win/Properties/AssemblyInfo.cs b/Agent.Installer.Win/Properties/AssemblyInfo.cs index 38a0d006..d8aa9c65 100644 --- a/Agent.Installer.Win/Properties/AssemblyInfo.cs +++ b/Agent.Installer.Win/Properties/AssemblyInfo.cs @@ -1,6 +1,4 @@ using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows; diff --git a/Agent.Installer.Win/Services/CommandLineParser.cs b/Agent.Installer.Win/Services/CommandLineParser.cs index 92a4fbb1..0cdb4c69 100644 --- a/Agent.Installer.Win/Services/CommandLineParser.cs +++ b/Agent.Installer.Win/Services/CommandLineParser.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; namespace Remotely.Agent.Installer.Win.Services diff --git a/Agent.Installer.Win/Services/Executor.cs b/Agent.Installer.Win/Services/Executor.cs index b5ed799a..33d39bf2 100644 --- a/Agent.Installer.Win/Services/Executor.cs +++ b/Agent.Installer.Win/Services/Executor.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Input; namespace Remotely.Agent.Installer.Win.Services diff --git a/Agent.Installer.Win/Services/InstallerService.cs b/Agent.Installer.Win/Services/InstallerService.cs index 526ede86..33501c59 100644 --- a/Agent.Installer.Win/Services/InstallerService.cs +++ b/Agent.Installer.Win/Services/InstallerService.cs @@ -12,7 +12,6 @@ using System.Net; using System.Reflection; using System.Security.Principal; using System.ServiceProcess; -using System.Text; using System.Threading.Tasks; using System.Web.Script.Serialization; using System.Windows; @@ -24,7 +23,7 @@ namespace Remotely.Agent.Installer.Win.Services public event EventHandler ProgressMessageChanged; public event EventHandler ProgressValueChanged; - public static string CoreRuntimeVersion => "3.1.2"; + public static string CoreRuntimeVersion => "3.1.3"; private string InstallPath => Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Program Files", "Remotely"); private string Platform => Environment.Is64BitOperatingSystem ? "x64" : "x86"; private JavaScriptSerializer Serializer { get; } = new JavaScriptSerializer(); @@ -330,11 +329,11 @@ namespace Remotely.Agent.Installer.Win.Services var downloadUrl = string.Empty; if (Environment.Is64BitOperatingSystem) { - downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/3240250e-6fe0-4258-af69-85abef6c00de/e01ee0af6c65d894f4a02bdf6705ec7b/windowsdesktop-runtime-3.1.2-win-x64.exe"; + downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/5954c748-86a1-4823-9e7d-d35f6039317a/169e82cbf6fdeb678c5558c5d0a83834/windowsdesktop-runtime-3.1.3-win-x64.exe"; } else { - downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/b824906f-bd6e-4067-86a6-95c61620674d/cfcdab84a01cee94fdaa31271c3d4d47/windowsdesktop-runtime-3.1.2-win-x86.exe"; + downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/7cd5c874-5d11-4e72-81f0-4a005d956708/0eb310169770c893407169fc3abaac4f/windowsdesktop-runtime-3.1.3-win-x86.exe"; } var targetFile = Path.Combine(Path.GetTempPath(), "windowsdesktop-runtime.exe"); await client.DownloadFileTaskAsync(downloadUrl, targetFile); diff --git a/Agent.Installer.Win/Services/Logger.cs b/Agent.Installer.Win/Services/Logger.cs index 795648fd..ffaba451 100644 --- a/Agent.Installer.Win/Services/Logger.cs +++ b/Agent.Installer.Win/Services/Logger.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace Remotely.Agent.Installer.Win.Services { diff --git a/Agent.Installer.Win/Services/MessageBoxEx.cs b/Agent.Installer.Win/Services/MessageBoxEx.cs index a167e14c..b390db29 100644 --- a/Agent.Installer.Win/Services/MessageBoxEx.cs +++ b/Agent.Installer.Win/Services/MessageBoxEx.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; namespace Remotely.Agent.Installer.Win.Services { diff --git a/Agent.Installer.Win/Services/ProcessEx.cs b/Agent.Installer.Win/Services/ProcessEx.cs index 5b08a5b3..78d39ff8 100644 --- a/Agent.Installer.Win/Services/ProcessEx.cs +++ b/Agent.Installer.Win/Services/ProcessEx.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Diagnostics; namespace Remotely.Agent.Installer.Win.Services { diff --git a/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs b/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs index 5e198d77..f29ca985 100644 --- a/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs +++ b/Agent.Installer.Win/ViewModels/MainWindowViewModel.cs @@ -1,15 +1,12 @@ using Remotely.Agent.Installer.Win.Services; using Remotely.Shared.Models; using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Security.Principal; using System.ServiceProcess; -using System.Text; -using System.Threading; using System.Threading.Tasks; using System.Web.Script.Serialization; using System.Windows; diff --git a/Agent.Installer.Win/ViewModels/ViewModelBase.cs b/Agent.Installer.Win/ViewModels/ViewModelBase.cs index a0591ef2..0f1eecac 100644 --- a/Agent.Installer.Win/ViewModels/ViewModelBase.cs +++ b/Agent.Installer.Win/ViewModels/ViewModelBase.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; namespace Remotely.Agent.Installer.Win.ViewModels { diff --git a/Agent/Models/ChatSession.cs b/Agent/Models/ChatSession.cs index f7bb0b2f..e66ba049 100644 --- a/Agent/Models/ChatSession.cs +++ b/Agent/Models/ChatSession.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO.Pipes; -using System.Text; +using System.IO.Pipes; namespace Remotely.Agent.Models { diff --git a/Agent/Program.cs b/Agent/Program.cs index 840ca032..f3014537 100644 --- a/Agent/Program.cs +++ b/Agent/Program.cs @@ -1,23 +1,17 @@ using Remotely.Agent.Services; -using Remotely.Shared.Services; -using Newtonsoft.Json; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Runtime.InteropServices; using System.ServiceProcess; using System.Threading.Tasks; -using System.Diagnostics; using System.Threading; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Remotely.Shared.Utilities; namespace Remotely.Agent { public class Program { - public static bool IsDebug { get; set; } public static IServiceProvider Services { get; set; } @@ -65,7 +59,7 @@ namespace Remotely.Agent private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Logger.Write(e.ExceptionObject as Exception); - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { // Remove Secure Attention Sequence policy to allow app to simulate Ctrl + Alt + Del. var subkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true); @@ -76,43 +70,16 @@ namespace Remotely.Agent } } - private static async Task HandleConnection() - { - while (true) - { - try - { - if (!Services.GetRequiredService().IsConnected) - { - var waitTime = new Random().Next(1000, 30000); - Logger.Write($"Websocket closed. Reconnecting in {waitTime / 1000} seconds..."); - await Task.Delay(waitTime); - await Services.GetRequiredService().Connect(); - await Services.GetRequiredService().CheckForUpdates(); - } - } - catch (Exception ex) - { - Logger.Write(ex); - } - Thread.Sleep(1000); - } - } - private static async Task Init() { try { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; -#if DEBUG - IsDebug = true; -#endif - SetWorkingDirectory(); - if (!IsDebug && OSUtils.IsWindows) + if (!EnvironmentHelper.IsDebug && EnvironmentHelper.IsWindows) { _ = Task.Run(() => { @@ -120,7 +87,7 @@ namespace Remotely.Agent }); } - if (!IsDebug) + if (!EnvironmentHelper.IsDebug) { await Services.GetRequiredService().BeginChecking(); } @@ -130,7 +97,7 @@ namespace Remotely.Agent } finally { - await HandleConnection(); + await Services.GetRequiredService().HandleConnection(); } } diff --git a/Agent/Services/AppLauncher.cs b/Agent/Services/AppLauncher.cs index ab8e1152..d16b3589 100644 --- a/Agent/Services/AppLauncher.cs +++ b/Agent/Services/AppLauncher.cs @@ -1,13 +1,12 @@ using Microsoft.AspNetCore.SignalR.Client; using Remotely.Shared.Models; -using Remotely.Shared.Services; +using Remotely.Shared.Utilities; using Remotely.Shared.Win32; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Remotely.Agent.Services @@ -25,7 +24,7 @@ namespace Remotely.Agent.Services { try { - var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScreenCast", OSUtils.ScreenCastExecutableFileName); + var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScreenCast", EnvironmentHelper.ScreenCastExecutableFileName); if (!File.Exists(rcBinaryPath)) { await hubConnection.SendAsync("DisplayMessage", "Chat executable not found on target device.", "Executable not found on device.", requesterID); @@ -34,10 +33,10 @@ namespace Remotely.Agent.Services // Start ScreenCast. await hubConnection.SendAsync("DisplayMessage", $"Starting chat service...", "Starting chat service.", requesterID); - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { - if (Program.IsDebug) + if (EnvironmentHelper.IsDebug) { return Process.Start(rcBinaryPath, $"-mode Chat -requester {requesterID} -organization \"{orgName}\"").Id; } @@ -54,7 +53,7 @@ namespace Remotely.Agent.Services } } } - else if (OSUtils.IsLinux) + else if (EnvironmentHelper.IsLinux) { var args = $"xterm -e {rcBinaryPath} -mode Chat -requester {requesterID} -organization \"{orgName}\" & disown"; return StartLinuxScreenCaster(args); @@ -72,7 +71,7 @@ namespace Remotely.Agent.Services { try { - var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScreenCast", OSUtils.ScreenCastExecutableFileName); + var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScreenCast", EnvironmentHelper.ScreenCastExecutableFileName); if (!File.Exists(rcBinaryPath)) { await hubConnection.SendAsync("DisplayMessage", "Remote control executable not found on target device.", "Executable not found on device.", requesterID); @@ -82,10 +81,10 @@ namespace Remotely.Agent.Services // Start ScreenCast. await hubConnection.SendAsync("DisplayMessage", $"Starting remote control...", "Starting remote control.", requesterID); - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { - if (Program.IsDebug) + if (EnvironmentHelper.IsDebug) { Process.Start(rcBinaryPath, $"-mode Unattended -requester {requesterID} -serviceid {serviceID} -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host}"); } @@ -98,7 +97,7 @@ namespace Remotely.Agent.Services } } } - else if (OSUtils.IsLinux) + else if (EnvironmentHelper.IsLinux) { var args = $"{rcBinaryPath} -mode Unattended -requester {requesterID} -serviceid {serviceID} -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host} & disown"; StartLinuxScreenCaster(args); @@ -114,12 +113,12 @@ namespace Remotely.Agent.Services { try { - var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScreenCast", OSUtils.ScreenCastExecutableFileName); + var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScreenCast", EnvironmentHelper.ScreenCastExecutableFileName); // Start ScreenCast. - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { Logger.Write("Restarting screen caster."); - if (Program.IsDebug) + if (EnvironmentHelper.IsDebug) { Process.Start(rcBinaryPath, $"-mode Unattended -requester {requesterID} -serviceid {serviceID} -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host} -relaunch true -viewers {String.Join(",", viewerIDs)}"); } @@ -146,7 +145,7 @@ namespace Remotely.Agent.Services } } } - else if (OSUtils.IsLinux) + else if (EnvironmentHelper.IsLinux) { var args = $"{rcBinaryPath} -mode Unattended -requester {requesterID} -serviceid {serviceID} -deviceid {ConnectionInfo.DeviceID} -host {ConnectionInfo.Host} -relaunch true -viewers {string.Join(",", viewerIDs)} & disown"; StartLinuxScreenCaster(args); @@ -164,7 +163,7 @@ namespace Remotely.Agent.Services { var xauthority = string.Empty; - var processes = OSUtils.StartProcessWithResults("ps", "-eaf").Split(Environment.NewLine); + var processes = EnvironmentHelper.StartProcessWithResults("ps", "-eaf").Split(Environment.NewLine); var xorgLine = processes.FirstOrDefault(x => x.Contains("xorg")); var xorgSplit = xorgLine.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); var auth = xorgSplit[xorgSplit.IndexOf("-auth") + 1]; @@ -174,7 +173,7 @@ namespace Remotely.Agent.Services } var display = ":0"; - var whoString = OSUtils.StartProcessWithResults("w", "-h")?.Trim(); + var whoString = EnvironmentHelper.StartProcessWithResults("w", "-h")?.Trim(); var username = string.Empty; if (!string.IsNullOrWhiteSpace(whoString)) diff --git a/Agent/Services/Bash.cs b/Agent/Services/Bash.cs index c4f294fa..e95c9873 100644 --- a/Agent/Services/Bash.cs +++ b/Agent/Services/Bash.cs @@ -1,8 +1,6 @@ using Remotely.Shared.Models; using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Text; using System.Threading; using System.Collections.Concurrent; using Microsoft.Extensions.DependencyInjection; diff --git a/Agent/Services/CMD.cs b/Agent/Services/CMD.cs index 73ea1142..09d8350c 100644 --- a/Agent/Services/CMD.cs +++ b/Agent/Services/CMD.cs @@ -1,10 +1,7 @@ using Remotely.Shared.Models; -using Newtonsoft.Json; using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Diagnostics; -using System.Text; using System.Threading; using Microsoft.Extensions.DependencyInjection; diff --git a/Agent/Services/ChatClientService.cs b/Agent/Services/ChatClientService.cs index 8bceb3e9..270a1182 100644 --- a/Agent/Services/ChatClientService.cs +++ b/Agent/Services/ChatClientService.cs @@ -1,14 +1,11 @@ using Microsoft.AspNetCore.SignalR.Client; using Remotely.Agent.Models; -using Remotely.Shared.Services; +using Remotely.Shared.Utilities; using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Pipes; -using System.Linq; using System.Runtime.Caching; -using System.Text; using System.Threading; using System.Threading.Tasks; @@ -44,7 +41,7 @@ namespace Remotely.Agent.Services ChatSession chatSession; if (!ChatClients.Contains(senderConnectionID)) { - var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScreenCast", OSUtils.ScreenCastExecutableFileName); + var rcBinaryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScreenCast", EnvironmentHelper.ScreenCastExecutableFileName); var procID = await AppLauncher.LaunchChatService(orgName, senderConnectionID, hubConnection); var clientPipe = new NamedPipeClientStream(".", "Remotely_Chat" + senderConnectionID, PipeDirection.InOut, PipeOptions.Asynchronous); diff --git a/Agent/Services/CommandExecutor.cs b/Agent/Services/CommandExecutor.cs index c12cef9c..69246000 100644 --- a/Agent/Services/CommandExecutor.cs +++ b/Agent/Services/CommandExecutor.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.SignalR.Client; -using Remotely.Shared.Services; +using Remotely.Shared.Utilities; using System; -using System.Collections.Generic; using System.IO; using System.Net; using System.Text; @@ -41,7 +40,7 @@ namespace Remotely.Agent.Services break; } case "winps": - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { var result = WindowsPS.GetCurrent(senderConnectionID).WriteInput(command, commandID); var serializedResult = JsonSerializer.Serialize(result); @@ -57,7 +56,7 @@ namespace Remotely.Agent.Services } break; case "cmd": - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { var result = CMD.GetCurrent(senderConnectionID).WriteInput(command, commandID); var serializedResult = JsonSerializer.Serialize(result); @@ -73,7 +72,7 @@ namespace Remotely.Agent.Services } break; case "bash": - if (OSUtils.IsLinux) + if (EnvironmentHelper.IsLinux) { var result = Bash.GetCurrent(senderConnectionID).WriteInput(command, commandID); var serializedResult = JsonSerializer.Serialize(result); @@ -111,21 +110,21 @@ namespace Remotely.Agent.Services break; case "winps": - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { var result = WindowsPS.GetCurrent(senderUserName).WriteInput(command, commandID); await SendResultsViaAjax("WinPS", result); } break; case "cmd": - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { var result = CMD.GetCurrent(senderUserName).WriteInput(command, commandID); await SendResultsViaAjax("CMD", result); } break; case "bash": - if (OSUtils.IsLinux) + if (EnvironmentHelper.IsLinux) { var result = Bash.GetCurrent(senderUserName).WriteInput(command, commandID); await SendResultsViaAjax("Bash", result); diff --git a/Agent/Services/ConfigService.cs b/Agent/Services/ConfigService.cs index 396b90d3..bdc38326 100644 --- a/Agent/Services/ConfigService.cs +++ b/Agent/Services/ConfigService.cs @@ -1,9 +1,9 @@ using Remotely.Shared.Models; +using Remotely.Shared.Utilities; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; using System.Text.Json; namespace Remotely.Agent.Services @@ -45,7 +45,7 @@ namespace Remotely.Agent.Services public ConnectionInfo GetConnectionInfo() { - if (Program.IsDebug && Debugger.IsAttached) + if (EnvironmentHelper.IsDebug && Debugger.IsAttached) { return new ConnectionInfo() { diff --git a/Agent/Services/DeviceSocket.cs b/Agent/Services/DeviceSocket.cs index 62be23ad..0c104075 100644 --- a/Agent/Services/DeviceSocket.cs +++ b/Agent/Services/DeviceSocket.cs @@ -3,17 +3,16 @@ using Remotely.Shared.Services; using Microsoft.AspNetCore.SignalR.Client; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using System.Timers; -using System.Reflection; using Remotely.Shared.Win32; using Microsoft.Extensions.DependencyInjection; using System.Text.Json; +using System.Threading; namespace Remotely.Agent.Services { @@ -39,7 +38,7 @@ namespace Remotely.Agent.Services private CommandExecutor CommandExecutor { get; } private ConfigService ConfigService { get; } private ConnectionInfo ConnectionInfo { get; set; } - private Timer HeartbeatTimer { get; set; } + private System.Timers.Timer HeartbeatTimer { get; set; } private HubConnection HubConnection { get; set; } private bool IsServerVerified { get; set; } private ScriptRunner ScriptRunner { get; } @@ -89,11 +88,34 @@ namespace Remotely.Agent.Services } HeartbeatTimer?.Dispose(); - HeartbeatTimer = new Timer(TimeSpan.FromMinutes(5).TotalMilliseconds); + HeartbeatTimer = new System.Timers.Timer(TimeSpan.FromMinutes(5).TotalMilliseconds); HeartbeatTimer.Elapsed += HeartbeatTimer_Elapsed; HeartbeatTimer.Start(); } + public async Task HandleConnection() + { + while (true) + { + try + { + if (!IsConnected) + { + var waitTime = new Random().Next(1000, 30000); + Logger.Write($"Websocket closed. Reconnecting in {waitTime / 1000} seconds..."); + await Task.Delay(waitTime); + await Program.Services.GetRequiredService().Connect(); + await Program.Services.GetRequiredService().CheckForUpdates(); + } + } + catch (Exception ex) + { + Logger.Write(ex); + } + Thread.Sleep(1000); + } + } + public async Task SendHeartbeat() { var currentInfo = await DeviceInformation.Create(ConnectionInfo.DeviceID, ConnectionInfo.OrganizationID); diff --git a/Agent/Services/Logger.cs b/Agent/Services/Logger.cs index f7dc5659..e5c3a26d 100644 --- a/Agent/Services/Logger.cs +++ b/Agent/Services/Logger.cs @@ -1,12 +1,8 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; +using System; using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace Remotely.Agent.Services { diff --git a/Agent/Services/PSCore.cs b/Agent/Services/PSCore.cs index 03b7d4db..a56c0035 100644 --- a/Agent/Services/PSCore.cs +++ b/Agent/Services/PSCore.cs @@ -1,11 +1,8 @@ using Remotely.Shared.Models; -using Newtonsoft.Json; using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Linq; using System.Management.Automation; -using System.Text; using System.Timers; using Microsoft.Extensions.DependencyInjection; diff --git a/Agent/Services/ScriptRunner.cs b/Agent/Services/ScriptRunner.cs index 7921f1fe..b9bdb7c0 100644 --- a/Agent/Services/ScriptRunner.cs +++ b/Agent/Services/ScriptRunner.cs @@ -1,10 +1,8 @@ using Microsoft.AspNetCore.SignalR.Client; using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; -using System.Text; using System.Threading.Tasks; namespace Remotely.Agent.Services diff --git a/Agent/Services/Uninstaller.cs b/Agent/Services/Uninstaller.cs index c381d855..342878dc 100644 --- a/Agent/Services/Uninstaller.cs +++ b/Agent/Services/Uninstaller.cs @@ -1,11 +1,7 @@ -using Remotely.Shared.Services; +using Remotely.Shared.Utilities; using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; -using System.Management.Automation; -using System.Text; namespace Remotely.Agent.Services { @@ -13,13 +9,13 @@ namespace Remotely.Agent.Services { public void UninstallAgent() { - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { Process.Start("cmd.exe", "/c sc delete Remotely_Service"); var currentDir = AppDomain.CurrentDomain.BaseDirectory; Process.Start("cmd.exe", $"/c timeout 5 & rd /s /q \"{currentDir}\""); } - else if (OSUtils.IsLinux) + else if (EnvironmentHelper.IsLinux) { Process.Start("sudo", "systemctl stop remotely-agent").WaitForExit(); Directory.Delete("/usr/local/bin/Remotely", true); diff --git a/Agent/Services/Updater.cs b/Agent/Services/Updater.cs index c86bfb97..55593db1 100644 --- a/Agent/Services/Updater.cs +++ b/Agent/Services/Updater.cs @@ -1,15 +1,11 @@ -using Remotely.Shared.Services; -using Microsoft.AspNetCore.SignalR.Client; -using System; +using System; using System.Diagnostics; using System.IO; -using System.IO.Compression; -using System.Management.Automation; using System.Net; using System.Net.Http; using System.Threading.Tasks; -using System.Linq; using System.Threading; +using Remotely.Shared.Utilities; namespace Remotely.Agent.Services { @@ -60,7 +56,7 @@ namespace Remotely.Agent.Services await Task.Delay(TimeSpan.FromSeconds(waitTime)); Logger.Write($"Service Updater: Downloading installer."); - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { var filePath = Path.Combine(Path.GetTempPath(), "Remotely_Installer.exe"); @@ -75,7 +71,7 @@ namespace Remotely.Agent.Services Process.Start(filePath, $"-install -quiet -serverurl {connectionInfo.Host} -organizationid {connectionInfo.OrganizationID}"); } - else if (OSUtils.IsLinux) + else if (EnvironmentHelper.IsLinux) { var filePath = Path.Combine(Path.GetTempPath(), "RemotelyUpdate.sh"); diff --git a/Agent/Services/WindowsPS.cs b/Agent/Services/WindowsPS.cs index d35f6ec8..233661d6 100644 --- a/Agent/Services/WindowsPS.cs +++ b/Agent/Services/WindowsPS.cs @@ -2,9 +2,7 @@ using Remotely.Shared.Models; using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Diagnostics; -using System.Text; using System.Threading; namespace Remotely.Agent.Services diff --git a/Agent/Services/WindowsService.cs b/Agent/Services/WindowsService.cs index 5c8bfa3c..dd25ba40 100644 --- a/Agent/Services/WindowsService.cs +++ b/Agent/Services/WindowsService.cs @@ -1,12 +1,7 @@ -using Remotely.Shared.Services; +using Remotely.Shared.Utilities; using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Diagnostics; -using System.Runtime.InteropServices; using System.ServiceProcess; -using System.Text; namespace Remotely.Agent.Services { @@ -46,12 +41,9 @@ namespace Remotely.Agent.Services try { - if (OSUtils.IsWindows) - { - // Set Secure Attention Sequence policy to allow app to simulate Ctrl + Alt + Del. - var subkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true); - subkey.SetValue("SoftwareSASGeneration", "3", Microsoft.Win32.RegistryValueKind.DWord); - } + // Set Secure Attention Sequence policy to allow app to simulate Ctrl + Alt + Del. + var subkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true); + subkey.SetValue("SoftwareSASGeneration", "3", Microsoft.Win32.RegistryValueKind.DWord); } catch (Exception ex) { @@ -63,14 +55,11 @@ namespace Remotely.Agent.Services { try { - if (OSUtils.IsWindows) + // Remove Secure Attention Sequence policy to allow app to simulate Ctrl + Alt + Del. + var subkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true); + if (subkey.GetValue("SoftwareSASGeneration") != null) { - // Remove Secure Attention Sequence policy to allow app to simulate Ctrl + Alt + Del. - var subkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", true); - if (subkey.GetValue("SoftwareSASGeneration") != null) - { - subkey.DeleteValue("SoftwareSASGeneration"); - } + subkey.DeleteValue("SoftwareSASGeneration"); } } catch (Exception ex) diff --git a/Desktop.Linux/Program.cs b/Desktop.Linux/Program.cs index d20dc7c6..8331c0b7 100644 --- a/Desktop.Linux/Program.cs +++ b/Desktop.Linux/Program.cs @@ -1,9 +1,6 @@ -using System; -using Avalonia; +using Avalonia; using Avalonia.Logging.Serilog; using Avalonia.ReactiveUI; -using Remotely.Desktop.Linux.ViewModels; -using Remotely.Desktop.Linux.Views; namespace Remotely.Desktop.Linux { diff --git a/Desktop.Linux/Services/Config.cs b/Desktop.Linux/Services/Config.cs index dbb7dd7f..61f93304 100644 --- a/Desktop.Linux/Services/Config.cs +++ b/Desktop.Linux/Services/Config.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; using System.IO; -using System.Linq; -using System.Text; using System.Text.Json; -using System.Threading.Tasks; namespace Remotely.Desktop.Linux.Services { diff --git a/Desktop.Linux/Services/Executor.cs b/Desktop.Linux/Services/Executor.cs index 758373de..e7d0b85a 100644 --- a/Desktop.Linux/Services/Executor.cs +++ b/Desktop.Linux/Services/Executor.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Input; namespace Remotely.Desktop.Linux.Services diff --git a/Desktop.Linux/ViewModels/HostNamePromptViewModel.cs b/Desktop.Linux/ViewModels/HostNamePromptViewModel.cs index a7172898..995d93ed 100644 --- a/Desktop.Linux/ViewModels/HostNamePromptViewModel.cs +++ b/Desktop.Linux/ViewModels/HostNamePromptViewModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; +using System.Windows.Input; using Avalonia.Controls; using ReactiveUI; using Remotely.Desktop.Linux.Services; diff --git a/Desktop.Linux/ViewModels/MainWindowViewModel.cs b/Desktop.Linux/ViewModels/MainWindowViewModel.cs index 5fb00807..545514a4 100644 --- a/Desktop.Linux/ViewModels/MainWindowViewModel.cs +++ b/Desktop.Linux/ViewModels/MainWindowViewModel.cs @@ -12,19 +12,17 @@ using Remotely.ScreenCast.Core.Services; using Remotely.ScreenCast.Core.Communication; using Remotely.ScreenCast.Linux.Services; using Remotely.Shared.Models; -using Remotely.Shared.Services; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Drawing; -using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Windows.Input; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Remotely.Shared.Utilities; namespace Remotely.Desktop.Linux.ViewModels { @@ -38,7 +36,7 @@ namespace Remotely.Desktop.Linux.ViewModels public MainWindowViewModel() { Current = this; - if (!OSUtils.IsLinux) + if (!EnvironmentHelper.IsLinux) { return; } diff --git a/Desktop.Linux/ViewModels/MessageBoxViewModel.cs b/Desktop.Linux/ViewModels/MessageBoxViewModel.cs index 39dd4ada..da335fdd 100644 --- a/Desktop.Linux/ViewModels/MessageBoxViewModel.cs +++ b/Desktop.Linux/ViewModels/MessageBoxViewModel.cs @@ -1,9 +1,6 @@ using Avalonia.Controls; using Remotely.Desktop.Linux.Controls; using Remotely.Desktop.Linux.Services; -using System; -using System.Collections.Generic; -using System.Text; using System.Windows.Input; namespace Remotely.Desktop.Linux.ViewModels diff --git a/Desktop.Linux/ViewModels/ViewModelBase.cs b/Desktop.Linux/ViewModels/ViewModelBase.cs index 6527fe14..9c71adf2 100644 --- a/Desktop.Linux/ViewModels/ViewModelBase.cs +++ b/Desktop.Linux/ViewModels/ViewModelBase.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ReactiveUI; +using ReactiveUI; namespace Remotely.Desktop.Linux.ViewModels { diff --git a/Desktop.Linux/Views/MainWindow.xaml.cs b/Desktop.Linux/Views/MainWindow.xaml.cs index 0f557a15..2bf58d41 100644 --- a/Desktop.Linux/Views/MainWindow.xaml.cs +++ b/Desktop.Linux/Views/MainWindow.xaml.cs @@ -2,7 +2,6 @@ using Avalonia.Controls; using Avalonia.Markup.Xaml; using Remotely.Desktop.Linux.ViewModels; -using System.Threading.Tasks; namespace Remotely.Desktop.Linux.Views { diff --git a/Desktop.Win/App.xaml.cs b/Desktop.Win/App.xaml.cs index d47c094d..2260a8aa 100644 --- a/Desktop.Win/App.xaml.cs +++ b/Desktop.Win/App.xaml.cs @@ -1,16 +1,9 @@ using Microsoft.Extensions.DependencyInjection; -using Remotely.Desktop.Win.Services; -using Remotely.Desktop.Win.ViewModels; using Remotely.ScreenCast.Core; using Remotely.ScreenCast.Core.Services; using Remotely.Shared.Win32; using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; using System.Linq; -using System.Runtime.InteropServices; -using System.Threading.Tasks; using System.Windows; namespace Remotely.Desktop.Win diff --git a/Desktop.Win/Controls/HostNamePrompt.xaml.cs b/Desktop.Win/Controls/HostNamePrompt.xaml.cs index 98b35490..143536a8 100644 --- a/Desktop.Win/Controls/HostNamePrompt.xaml.cs +++ b/Desktop.Win/Controls/HostNamePrompt.xaml.cs @@ -1,17 +1,4 @@ -using Remotely.Desktop.Win.ViewModels; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; +using System.Windows; namespace Remotely.Desktop.Win.Controls { diff --git a/Desktop.Win/MainWindow.xaml.cs b/Desktop.Win/MainWindow.xaml.cs index 1410e00e..51f16ca0 100644 --- a/Desktop.Win/MainWindow.xaml.cs +++ b/Desktop.Win/MainWindow.xaml.cs @@ -1,23 +1,11 @@ using Remotely.Desktop.Win.ViewModels; -using Remotely.ScreenCast.Core.Models; -using Remotely.ScreenCast.Core.Services; -using Remotely.Shared.Win32; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; using System.Windows.Media.Animation; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; namespace Remotely.Desktop.Win { diff --git a/Desktop.Win/Services/Config.cs b/Desktop.Win/Services/Config.cs index e9185ac1..46d610f2 100644 --- a/Desktop.Win/Services/Config.cs +++ b/Desktop.Win/Services/Config.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; using System.IO; -using System.Linq; -using System.Text; using System.Text.Json; -using System.Threading.Tasks; namespace Remotely.Desktop.Win.Services { diff --git a/Desktop.Win/Services/Executor.cs b/Desktop.Win/Services/Executor.cs index d4650034..a4b856fa 100644 --- a/Desktop.Win/Services/Executor.cs +++ b/Desktop.Win/Services/Executor.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Input; namespace Remotely.Desktop.Win.Services diff --git a/Desktop.Win/ViewModels/HostNamePromptViewModel.cs b/Desktop.Win/ViewModels/HostNamePromptViewModel.cs index 9c918e42..fea61899 100644 --- a/Desktop.Win/ViewModels/HostNamePromptViewModel.cs +++ b/Desktop.Win/ViewModels/HostNamePromptViewModel.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Remotely.Desktop.Win.ViewModels +namespace Remotely.Desktop.Win.ViewModels { public class HostNamePromptViewModel : ViewModelBase { diff --git a/Desktop.Win/ViewModels/ViewModelBase.cs b/Desktop.Win/ViewModels/ViewModelBase.cs index 8e30a0c4..3e10fc06 100644 --- a/Desktop.Win/ViewModels/ViewModelBase.cs +++ b/Desktop.Win/ViewModels/ViewModelBase.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel; namespace Remotely.Desktop.Win.ViewModels { diff --git a/ScreenCast.Core/Communication/CasterSocket.cs b/ScreenCast.Core/Communication/CasterSocket.cs index 49bc79ab..bf771928 100644 --- a/ScreenCast.Core/Communication/CasterSocket.cs +++ b/ScreenCast.Core/Communication/CasterSocket.cs @@ -1,20 +1,15 @@ using Microsoft.AspNetCore.SignalR.Client; using Remotely.Shared.Models; -using Remotely.ScreenCast.Core.Models; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Diagnostics; using System.IO; using System.Net; using Remotely.ScreenCast.Core.Services; using Remotely.ScreenCast.Core.Interfaces; -using Remotely.Shared.Win32; using Microsoft.Extensions.DependencyInjection; -using Remotely.Shared.Services; namespace Remotely.ScreenCast.Core.Communication { diff --git a/ScreenCast.Core/Communication/WebRtcSession.cs b/ScreenCast.Core/Communication/WebRtcSession.cs index 0cf08cdb..137ce248 100644 --- a/ScreenCast.Core/Communication/WebRtcSession.cs +++ b/ScreenCast.Core/Communication/WebRtcSession.cs @@ -4,10 +4,7 @@ using Remotely.ScreenCast.Core.Services; using Remotely.Shared.Models; using System; using System.Collections.Generic; -using System.Diagnostics; -using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Remotely.ScreenCast.Core.Communication diff --git a/ScreenCast.Core/Conductor.cs b/ScreenCast.Core/Conductor.cs index d3d2d5c9..bb024cce 100644 --- a/ScreenCast.Core/Conductor.cs +++ b/ScreenCast.Core/Conductor.cs @@ -1,6 +1,5 @@ using Remotely.Shared.Models; using Remotely.ScreenCast.Core.Enums; -using Remotely.ScreenCast.Core.Interfaces; using Remotely.ScreenCast.Core.Models; using Remotely.ScreenCast.Core.Communication; using Remotely.ScreenCast.Core.Services; @@ -16,9 +15,6 @@ namespace Remotely.ScreenCast.Core public Conductor(CasterSocket casterSocket) { CasterSocket = casterSocket; -#if DEBUG - IsDebug = true; -#endif } public event EventHandler ScreenCastRequested; @@ -33,7 +29,6 @@ namespace Remotely.ScreenCast.Core public CasterSocket CasterSocket { get; private set; } public string DeviceID { get; private set; } public string Host { get; private set; } - public bool IsDebug { get; } public AppMode Mode { get; private set; } public string OrganizationName { get; private set; } public string RequesterID { get; private set; } diff --git a/ScreenCast.Core/Enums/AppMode.cs b/ScreenCast.Core/Enums/AppMode.cs index c231784c..8e381df4 100644 --- a/ScreenCast.Core/Enums/AppMode.cs +++ b/ScreenCast.Core/Enums/AppMode.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Remotely.ScreenCast.Core.Enums +namespace Remotely.ScreenCast.Core.Enums { public enum AppMode { diff --git a/ScreenCast.Core/Interfaces/IAudioCapturer.cs b/ScreenCast.Core/Interfaces/IAudioCapturer.cs index 397882b4..9986eb4e 100644 --- a/ScreenCast.Core/Interfaces/IAudioCapturer.cs +++ b/ScreenCast.Core/Interfaces/IAudioCapturer.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely.ScreenCast.Core.Interfaces +namespace Remotely.ScreenCast.Core.Interfaces { public interface IAudioCapturer { diff --git a/ScreenCast.Core/Interfaces/IClipboardService.cs b/ScreenCast.Core/Interfaces/IClipboardService.cs index a5891bea..a45999cc 100644 --- a/ScreenCast.Core/Interfaces/IClipboardService.cs +++ b/ScreenCast.Core/Interfaces/IClipboardService.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Remotely.ScreenCast.Core.Interfaces { diff --git a/ScreenCast.Core/Interfaces/IKeyboardMouseInput.cs b/ScreenCast.Core/Interfaces/IKeyboardMouseInput.cs index 9f0a397f..7012c087 100644 --- a/ScreenCast.Core/Interfaces/IKeyboardMouseInput.cs +++ b/ScreenCast.Core/Interfaces/IKeyboardMouseInput.cs @@ -1,9 +1,4 @@ using Remotely.ScreenCast.Core.Models; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Remotely.ScreenCast.Core.Interfaces { diff --git a/ScreenCast.Core/Interfaces/IScreenCapturer.cs b/ScreenCast.Core/Interfaces/IScreenCapturer.cs index 40df87b4..85755d34 100644 --- a/ScreenCast.Core/Interfaces/IScreenCapturer.cs +++ b/ScreenCast.Core/Interfaces/IScreenCapturer.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Remotely.ScreenCast.Core.Interfaces { diff --git a/ScreenCast.Core/Interfaces/IScreenCaster.cs b/ScreenCast.Core/Interfaces/IScreenCaster.cs index dbb1b191..61439d59 100644 --- a/ScreenCast.Core/Interfaces/IScreenCaster.cs +++ b/ScreenCast.Core/Interfaces/IScreenCaster.cs @@ -1,7 +1,4 @@ using Remotely.Shared.Models; -using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; namespace Remotely.ScreenCast.Core.Interfaces diff --git a/ScreenCast.Core/Models/Viewer.cs b/ScreenCast.Core/Models/Viewer.cs index 7f8bc42f..de3af080 100644 --- a/ScreenCast.Core/Models/Viewer.cs +++ b/ScreenCast.Core/Models/Viewer.cs @@ -2,10 +2,7 @@ using Remotely.ScreenCast.Core.Interfaces; using Remotely.ScreenCast.Core.Services; using System; -using System.Collections.Generic; -using System.Drawing; using System.Drawing.Imaging; -using System.Linq; using System.Threading.Tasks; namespace Remotely.ScreenCast.Core.Models diff --git a/ScreenCast.Core/ServiceContainer.cs b/ScreenCast.Core/ServiceContainer.cs index 3dd418aa..e9f84c90 100644 --- a/ScreenCast.Core/ServiceContainer.cs +++ b/ScreenCast.Core/ServiceContainer.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Remotely.ScreenCast.Core { diff --git a/ScreenCast.Core/Services/ChatHostService.cs b/ScreenCast.Core/Services/ChatHostService.cs index 5dabd42a..74508ab4 100644 --- a/ScreenCast.Core/Services/ChatHostService.cs +++ b/ScreenCast.Core/Services/ChatHostService.cs @@ -1,11 +1,6 @@ -using Remotely.ScreenCast.Core.Communication; -using System; -using System.Collections.Generic; -using System.Diagnostics; +using System; using System.IO; using System.IO.Pipes; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/ScreenCast.Core/Services/IdleTimer.cs b/ScreenCast.Core/Services/IdleTimer.cs index f62f6307..154de91f 100644 --- a/ScreenCast.Core/Services/IdleTimer.cs +++ b/ScreenCast.Core/Services/IdleTimer.cs @@ -1,8 +1,6 @@ using Remotely.ScreenCast.Core.Models; using System; using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Text; using System.Timers; namespace Remotely.ScreenCast.Core.Services diff --git a/ScreenCast.Core/Services/ScreenCasterBase.cs b/ScreenCast.Core/Services/ScreenCasterBase.cs index 5a6a21eb..9fed63bc 100644 --- a/ScreenCast.Core/Services/ScreenCasterBase.cs +++ b/ScreenCast.Core/Services/ScreenCasterBase.cs @@ -1,23 +1,15 @@ -using Microsoft.AspNetCore.SignalR.Client; -using Remotely.ScreenCast.Core.Models; +using Remotely.ScreenCast.Core.Models; using Remotely.ScreenCast.Core.Communication; -using Remotely.ScreenCast.Core.Services; using System; using System.Collections.Generic; -using System.Drawing; -using System.IO; using System.Linq; -using System.Runtime.InteropServices; -using System.Text; using System.Threading.Tasks; -using Remotely.Shared.Services; -using Remotely.Shared.Win32; using Remotely.ScreenCast.Core.Interfaces; using System.Diagnostics; -using System.Threading; using System.Drawing.Imaging; using Microsoft.Extensions.DependencyInjection; using Remotely.ScreenCast.Core.Utilities; +using Remotely.Shared.Utilities; namespace Remotely.ScreenCast.Core.Services { @@ -53,7 +45,7 @@ namespace Remotely.ScreenCast.Core.Services conductor.InvokeViewerAdded(viewer); } - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { await InitializeWebRtc(viewer, casterSocket); } @@ -82,7 +74,7 @@ namespace Remotely.ScreenCast.Core.Services break; } - if (conductor.IsDebug) + if (EnvironmentHelper.IsDebug) { while (fpsQueue.Any() && DateTimeOffset.Now - fpsQueue.Peek() > TimeSpan.FromSeconds(1)) { diff --git a/ScreenCast.Core/Utilities/ImageUtils.cs b/ScreenCast.Core/Utilities/ImageUtils.cs index cfe2a230..685a480f 100644 --- a/ScreenCast.Core/Utilities/ImageUtils.cs +++ b/ScreenCast.Core/Utilities/ImageUtils.cs @@ -1,14 +1,9 @@ -using Remotely.ScreenCast.Core.Models; -using System; -using System.Collections.Generic; +using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Runtime.Serialization.Formatters.Binary; -using System.Text; -using System.Threading.Tasks; namespace Remotely.ScreenCast.Core.Utilities { diff --git a/ScreenCast.Linux/Services/AudioCapturerLinux.cs b/ScreenCast.Linux/Services/AudioCapturerLinux.cs index a6f1b036..5e899553 100644 --- a/ScreenCast.Linux/Services/AudioCapturerLinux.cs +++ b/ScreenCast.Linux/Services/AudioCapturerLinux.cs @@ -1,7 +1,4 @@ using Remotely.ScreenCast.Core.Interfaces; -using System; -using System.Collections.Generic; -using System.Text; namespace Remotely.ScreenCast.Linux.Services { diff --git a/ScreenCast.Linux/Services/ClipboardServiceLinux.cs b/ScreenCast.Linux/Services/ClipboardServiceLinux.cs index 3b0e080a..919f9ded 100644 --- a/ScreenCast.Linux/Services/ClipboardServiceLinux.cs +++ b/ScreenCast.Linux/Services/ClipboardServiceLinux.cs @@ -1,10 +1,8 @@ using Remotely.ScreenCast.Core.Interfaces; using Remotely.ScreenCast.Core.Services; using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Text; namespace Remotely.ScreenCast.Linux.Services { diff --git a/ScreenCast.Linux/Services/KeyboardMouseInputLinux.cs b/ScreenCast.Linux/Services/KeyboardMouseInputLinux.cs index cf0e9114..6fc70b3b 100644 --- a/ScreenCast.Linux/Services/KeyboardMouseInputLinux.cs +++ b/ScreenCast.Linux/Services/KeyboardMouseInputLinux.cs @@ -1,11 +1,7 @@ using Remotely.ScreenCast.Core.Interfaces; using Remotely.ScreenCast.Core.Services; using Remotely.ScreenCast.Linux.X11Interop; -using Remotely.ScreenCast.Core; using System; -using System.Collections.Generic; -using System.Text; -using System.Linq; using Remotely.ScreenCast.Core.Models; namespace Remotely.ScreenCast.Linux.Services diff --git a/ScreenCast.Linux/Services/ScreenCapturerLinux.cs b/ScreenCast.Linux/Services/ScreenCapturerLinux.cs index 046fb075..2880c490 100644 --- a/ScreenCast.Linux/Services/ScreenCapturerLinux.cs +++ b/ScreenCast.Linux/Services/ScreenCapturerLinux.cs @@ -7,7 +7,6 @@ using System.Drawing; using System.Drawing.Imaging; using System.Linq; using System.Runtime.InteropServices; -using System.Text; namespace Remotely.ScreenCast.Linux.Services { diff --git a/ScreenCast.Linux/Services/ScreenCasterLinux.cs b/ScreenCast.Linux/Services/ScreenCasterLinux.cs index 1b4cfe4f..41230e96 100644 --- a/ScreenCast.Linux/Services/ScreenCasterLinux.cs +++ b/ScreenCast.Linux/Services/ScreenCasterLinux.cs @@ -6,7 +6,6 @@ using Remotely.Shared.Models; using System; using System.Collections.Generic; using System.Drawing; -using System.Text; using System.Threading.Tasks; namespace Remotely.ScreenCast.Linux.Services diff --git a/ScreenCast.Linux/X11Interop/LibX11.cs b/ScreenCast.Linux/X11Interop/LibX11.cs index 876f53f5..5bee950b 100644 --- a/ScreenCast.Linux/X11Interop/LibX11.cs +++ b/ScreenCast.Linux/X11Interop/LibX11.cs @@ -25,11 +25,7 @@ in this Software without prior written authorization from The Open Group. */ using System; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Security; -using System.Security.Permissions; -using System.Text; namespace Remotely.ScreenCast.Linux.X11Interop { diff --git a/ScreenCast.Linux/X11Interop/LibXtst.cs b/ScreenCast.Linux/X11Interop/LibXtst.cs index 44bb2d8f..ffe5f51d 100644 --- a/ScreenCast.Linux/X11Interop/LibXtst.cs +++ b/ScreenCast.Linux/X11Interop/LibXtst.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; namespace Remotely.ScreenCast.Linux.X11Interop { diff --git a/ScreenCast.Win/Models/DirectXOutput.cs b/ScreenCast.Win/Models/DirectXOutput.cs index bb91f321..bf572e2d 100644 --- a/ScreenCast.Win/Models/DirectXOutput.cs +++ b/ScreenCast.Win/Models/DirectXOutput.cs @@ -1,8 +1,6 @@ using SharpDX.Direct3D11; using SharpDX.DXGI; using System; -using System.Collections.Generic; -using System.Text; namespace Remotely.ScreenCast.Win.Models { diff --git a/ScreenCast.Win/Program.cs b/ScreenCast.Win/Program.cs index e5997a39..89436438 100644 --- a/ScreenCast.Win/Program.cs +++ b/ScreenCast.Win/Program.cs @@ -3,7 +3,6 @@ using Remotely.ScreenCast.Core; using Remotely.ScreenCast.Core.Services; using System; using System.Linq; -using System.Reflection; using System.Threading.Tasks; using Remotely.Shared.Win32; using System.Threading; @@ -12,7 +11,6 @@ using Remotely.ScreenCast.Core.Interfaces; using Remotely.ScreenCast.Core.Communication; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using System.Windows.Forms; namespace Remotely.ScreenCast.Win { diff --git a/ScreenCast.Win/Services/AudioCapturerWin.cs b/ScreenCast.Win/Services/AudioCapturerWin.cs index 59f54640..09afc36c 100644 --- a/ScreenCast.Win/Services/AudioCapturerWin.cs +++ b/ScreenCast.Win/Services/AudioCapturerWin.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Timers; using Microsoft.Extensions.DependencyInjection; using NAudio.Wave; using Remotely.ScreenCast.Core; diff --git a/ScreenCast.Win/Services/ClipboardServiceWin.cs b/ScreenCast.Win/Services/ClipboardServiceWin.cs index e5b21029..3ed9e9cb 100644 --- a/ScreenCast.Win/Services/ClipboardServiceWin.cs +++ b/ScreenCast.Win/Services/ClipboardServiceWin.cs @@ -1,13 +1,8 @@ using Remotely.ScreenCast.Core.Interfaces; using Remotely.ScreenCast.Core.Services; -using Remotely.ScreenCast.Core.Communication; using Remotely.Shared.Win32; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; namespace Remotely.ScreenCast.Win.Services diff --git a/ScreenCast.Win/Services/CursorIconWatcher.cs b/ScreenCast.Win/Services/CursorIconWatcher.cs index 99c48820..8c37020b 100644 --- a/ScreenCast.Win/Services/CursorIconWatcher.cs +++ b/ScreenCast.Win/Services/CursorIconWatcher.cs @@ -1,14 +1,8 @@ -using Remotely.ScreenCast.Core; -using Remotely.ScreenCast.Core.Models; -using System; -using System.Collections.Generic; +using System; using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.Timers; using System.Windows.Forms; using Remotely.Shared.Win32; diff --git a/ScreenCast.Win/Services/KeyboardMouseInputWin.cs b/ScreenCast.Win/Services/KeyboardMouseInputWin.cs index 6fc70371..5a75fc50 100644 --- a/ScreenCast.Win/Services/KeyboardMouseInputWin.cs +++ b/ScreenCast.Win/Services/KeyboardMouseInputWin.cs @@ -9,6 +9,7 @@ using Remotely.ScreenCast.Core.Services; using System.Collections.Concurrent; using System.Threading.Tasks; using Remotely.ScreenCast.Core; +using System.Runtime.InteropServices; namespace Remotely.ScreenCast.Win.Services { @@ -16,7 +17,7 @@ namespace Remotely.ScreenCast.Win.Services { public KeyboardMouseInputWin() { - StartInputActionThread(); + StartInputActionTask(); Application.ApplicationExit += Application_ApplicationExit; } @@ -24,7 +25,7 @@ namespace Remotely.ScreenCast.Win.Services private ConcurrentQueue InputActions { get; } = new ConcurrentQueue(); - private Thread InputActionsThread { get; set; } + private Task InputActionsTask { get; set; } private bool IsInputBlocked { get; set; } @@ -320,54 +321,36 @@ namespace Remotely.ScreenCast.Win.Services return keyCode; } - private void StartInputActionThread() + private void StartInputActionTask() { - InputActionsThread?.Abort(); - InputActionsThread = new Thread(() => + InputActionsTask?.Dispose(); + InputActionsTask = Task.Run(CheckQueue); + } + private void CheckQueue() + { + while (!ShutdownStarted && !Environment.HasShutdownStarted) { - while (!ShutdownStarted && !Environment.HasShutdownStarted) + if (InputActions.TryDequeue(out var action)) { - if (InputActions.TryDequeue(out var action)) - { - action(); - } - Thread.Sleep(1); + action(); } - }); - InputActionsThread.SetApartmentState(ApartmentState.STA); - InputActionsThread.Start(); + Thread.Sleep(1); + } } private void TryOnInputDesktop(Action inputAction) { - if (!InputActionsThread.IsAlive) + if (InputActionsTask.Status != TaskStatus.Running) { - StartInputActionThread(); + StartInputActionTask(); } InputActions.Enqueue(() => { if (!Win32Interop.SwitchToInputDesktop()) { - if (IsInputBlocked) - { - BlockInput(false); - } - - Task.Run(() => - { - Win32Interop.SwitchToInputDesktop(); - inputAction(); - }).Wait(); - - if (IsInputBlocked) - { - BlockInput(true); - } - } - else - { - inputAction(); + Logger.Write("Switch failed. Last Error: " + Marshal.GetLastWin32Error().ToString()); } + inputAction(); }); } } diff --git a/ScreenCast.Win/Services/ScreenCapturerWin.cs b/ScreenCast.Win/Services/ScreenCapturerWin.cs index 9ae8e264..21e9063a 100644 --- a/ScreenCast.Win/Services/ScreenCapturerWin.cs +++ b/ScreenCast.Win/Services/ScreenCapturerWin.cs @@ -26,17 +26,13 @@ using Remotely.ScreenCast.Core.Services; using Remotely.ScreenCast.Win.Models; using Remotely.Shared.Win32; using SharpDX; -using SharpDX.Direct3D; using SharpDX.Direct3D11; using SharpDX.DXGI; -using SharpDX.Mathematics.Interop; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.Linq; -using System.Threading; using System.Windows.Forms; namespace Remotely.ScreenCast.Win.Services diff --git a/ScreenCast.Win/Services/ScreenCasterWin.cs b/ScreenCast.Win/Services/ScreenCasterWin.cs index 6f33f5f0..6a0e1d88 100644 --- a/ScreenCast.Win/Services/ScreenCasterWin.cs +++ b/ScreenCast.Win/Services/ScreenCasterWin.cs @@ -1,17 +1,12 @@ using Remotely.ScreenCast.Core.Interfaces; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; -using Remotely.ScreenCast.Core.Enums; using Remotely.ScreenCast.Core.Services; using Remotely.ScreenCast.Core; -using Remotely.ScreenCast.Core.Models; using Remotely.Shared.Models; using Remotely.Shared.Win32; using Microsoft.Extensions.DependencyInjection; -using System.Threading; namespace Remotely.ScreenCast.Win.Services { diff --git a/Server/API/AgentUpdateController.cs b/Server/API/AgentUpdateController.cs index 51c18482..85bbe973 100644 --- a/Server/API/AgentUpdateController.cs +++ b/Server/API/AgentUpdateController.cs @@ -1,10 +1,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Remotely.Server.Services; -using System; -using System.Diagnostics; using System.IO; -using System.IO.Compression; namespace Remotely.Server.API { diff --git a/Server/API/AlertsController.cs b/Server/API/AlertsController.cs index 7567da1c..cad22101 100644 --- a/Server/API/AlertsController.cs +++ b/Server/API/AlertsController.cs @@ -1,14 +1,10 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Remotely.Server.Auth; using Remotely.Server.Services; using Remotely.Shared.Models; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; -using System.Net.Http; using System.Text.Json; using System.Threading.Tasks; diff --git a/Server/API/ClientDownloadsController.cs b/Server/API/ClientDownloadsController.cs index e207c6f3..3f7452a6 100644 --- a/Server/API/ClientDownloadsController.cs +++ b/Server/API/ClientDownloadsController.cs @@ -1,22 +1,15 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.FileProviders; using Microsoft.AspNetCore.Hosting; using Remotely.Server.Services; using Remotely.Server.Auth; -using Remotely.Shared.Models; -using System.Text.Json; using System.Text; using Microsoft.Extensions.Configuration; -using System.Diagnostics; using System.Threading; -using Remotely.Shared.Services; namespace Remotely.Server.API { diff --git a/Server/API/CommandsController.cs b/Server/API/CommandsController.cs index d3556dad..05568e39 100644 --- a/Server/API/CommandsController.cs +++ b/Server/API/CommandsController.cs @@ -1,14 +1,11 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; -using System.Xml.Serialization; using Remotely.Shared.Models; using Remotely.Server.Services; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Remotely.Server.Auth; diff --git a/Server/API/DevicesController.cs b/Server/API/DevicesController.cs index 55c230ac..417400f5 100644 --- a/Server/API/DevicesController.cs +++ b/Server/API/DevicesController.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; using Remotely.Shared.Models; using Remotely.Server.Services; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Remotely.Server.Auth; diff --git a/Server/API/FileSharingController.cs b/Server/API/FileSharingController.cs index e19a0dc2..e8a6e12f 100644 --- a/Server/API/FileSharingController.cs +++ b/Server/API/FileSharingController.cs @@ -1,13 +1,7 @@ using System; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; using Remotely.Server.Services; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Net.Http.Headers; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 diff --git a/Server/API/LoginController.cs b/Server/API/LoginController.cs index 5d77a7db..3a4ea874 100644 --- a/Server/API/LoginController.cs +++ b/Server/API/LoginController.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Remotely.Shared.Models; -using Remotely.Server.Data; using Remotely.Server.Models; using Remotely.Server.Services; using Microsoft.AspNetCore.SignalR; diff --git a/Server/API/OrganizationManagementController.cs b/Server/API/OrganizationManagementController.cs index 515e2f0c..f6d97d4d 100644 --- a/Server/API/OrganizationManagementController.cs +++ b/Server/API/OrganizationManagementController.cs @@ -1,17 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text.Encodings.Web; +using System.Text.Encodings.Web; using System.Threading.Tasks; using Remotely.Shared.Models; -using Remotely.Shared.ViewModels; -using Remotely.Server.Data; using Remotely.Server.Services; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Remotely.Shared.ViewModels.Organization; -using Microsoft.AspNetCore.Identity.UI.Services; using System.Text; using Microsoft.AspNetCore.WebUtilities; using Remotely.Server.Auth; diff --git a/Server/API/RemoteControlController.cs b/Server/API/RemoteControlController.cs index 2c24ce05..b5443997 100644 --- a/Server/API/RemoteControlController.cs +++ b/Server/API/RemoteControlController.cs @@ -1,15 +1,11 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Remotely.Shared.Models; -using Remotely.Server.Data; using Remotely.Server.Models; using Remotely.Server.Services; using Remotely.Server.Auth; diff --git a/Server/API/ScriptingController.cs b/Server/API/ScriptingController.cs index 4e0231ea..84456565 100644 --- a/Server/API/ScriptingController.cs +++ b/Server/API/ScriptingController.cs @@ -1,5 +1,4 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Remotely.Server.Services; @@ -9,7 +8,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Remotely.Shared.Helpers; -using Microsoft.AspNetCore.Http; using System.IO; using Remotely.Server.Auth; diff --git a/Server/API/ServerLogsController.cs b/Server/API/ServerLogsController.cs index 0aa67c65..0811f6f3 100644 --- a/Server/API/ServerLogsController.cs +++ b/Server/API/ServerLogsController.cs @@ -1,16 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Mime; -using System.Text; +using System.Text; using System.Text.Json; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Remotely.Server.Auth; using Remotely.Server.Services; -using Remotely.Shared.Models; namespace Remotely.Server.API { diff --git a/Server/Areas/Identity/IdentityHostingStartup.cs b/Server/Areas/Identity/IdentityHostingStartup.cs index 4d28f1e7..a38aadcc 100644 --- a/Server/Areas/Identity/IdentityHostingStartup.cs +++ b/Server/Areas/Identity/IdentityHostingStartup.cs @@ -1,12 +1,4 @@ -using System; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.UI; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Remotely.Server.Data; -using Remotely.Shared.Models; +using Microsoft.AspNetCore.Hosting; [assembly: HostingStartup(typeof(Remotely.Server.Areas.Identity.IdentityHostingStartup))] namespace Remotely.Server.Areas.Identity diff --git a/Server/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs b/Server/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs index fb2c459a..0295b96d 100644 --- a/Server/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/ConfirmEmail.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; diff --git a/Server/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs b/Server/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs index 46095a9f..bf9ad9b8 100644 --- a/Server/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/ConfirmEmailChange.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; diff --git a/Server/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs b/Server/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs index cf66254e..d7bdb0fb 100644 --- a/Server/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/ForgotPassword.cshtml.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.Text.Encodings.Web; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; diff --git a/Server/Areas/Identity/Pages/Account/Login.cshtml.cs b/Server/Areas/Identity/Pages/Account/Login.cshtml.cs index 7be3c92b..cc4cd2d4 100644 --- a/Server/Areas/Identity/Pages/Account/Login.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Login.cshtml.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; @@ -9,7 +8,6 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -using Remotely.Server.Data; using Remotely.Shared.Models; namespace Remotely.Server.Areas.Identity.Pages.Account diff --git a/Server/Areas/Identity/Pages/Account/Logout.cshtml.cs b/Server/Areas/Identity/Pages/Account/Logout.cshtml.cs index 6437de81..dc76e71f 100644 --- a/Server/Areas/Identity/Pages/Account/Logout.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Logout.cshtml.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; diff --git a/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml.cs b/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml.cs index dd532849..467c7e01 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Manage/ApiTokens.cshtml.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; diff --git a/Server/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs b/Server/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs index ddcf0bc3..8a19f8a4 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Manage/EnableAuthenticator.cshtml.cs @@ -1,7 +1,4 @@ -using System; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Text; using System.Text.Encodings.Web; using System.Linq; @@ -10,7 +7,6 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -using Remotely.Server.Data; using Remotely.Shared.Models; namespace Remotely.Server.Areas.Identity.Pages.Account.Manage diff --git a/Server/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs b/Server/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs index fa910340..21835238 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Manage/Index.cshtml.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; using System.Text.Encodings.Web; using System.Threading.Tasks; using Remotely.Shared.Models; -using Remotely.Server.Data; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; diff --git a/Server/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs b/Server/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs index 288d6dc2..95c8835f 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs +++ b/Server/Areas/Identity/Pages/Account/Manage/ManageNavPages.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Rendering; namespace Remotely.Server.Areas.Identity.Pages.Account.Manage diff --git a/Server/Areas/Identity/Pages/Account/Manage/Options.cshtml.cs b/Server/Areas/Identity/Pages/Account/Manage/Options.cshtml.cs index 521d7689..6cf12df8 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/Options.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Manage/Options.cshtml.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Remotely.Shared.Models; using Remotely.Server.Services; -using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; diff --git a/Server/Areas/Identity/Pages/Account/Manage/Organization.cshtml.cs b/Server/Areas/Identity/Pages/Account/Manage/Organization.cshtml.cs index de135f6b..fc63ca6e 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/Organization.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Manage/Organization.cshtml.cs @@ -1,5 +1,4 @@ using Remotely.Shared.Models; -using Remotely.Shared.ViewModels; using Remotely.Server.Services; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -11,8 +10,6 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; using System.Text.Encodings.Web; -using Microsoft.AspNetCore.Identity.UI.Services; -using System; namespace Remotely.Server.Areas.Identity.Pages.Account.Manage { diff --git a/Server/Areas/Identity/Pages/Account/Manage/ServerLogs.cshtml.cs b/Server/Areas/Identity/Pages/Account/Manage/ServerLogs.cshtml.cs index 4e731d17..c24e7efd 100644 --- a/Server/Areas/Identity/Pages/Account/Manage/ServerLogs.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Manage/ServerLogs.cshtml.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Remotely.Server.Services; diff --git a/Server/Areas/Identity/Pages/Account/Register.cshtml.cs b/Server/Areas/Identity/Pages/Account/Register.cshtml.cs index 659f5ce3..67102127 100644 --- a/Server/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/Server/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; @@ -8,12 +7,10 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Logging; -using Remotely.Server.Data; using Remotely.Server.Services; using Remotely.Shared.Models; diff --git a/Server/Auth/ApiAuthorizationFilter.cs b/Server/Auth/ApiAuthorizationFilter.cs index dd861b6c..b2f19649 100644 --- a/Server/Auth/ApiAuthorizationFilter.cs +++ b/Server/Auth/ApiAuthorizationFilter.cs @@ -1,10 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Remotely.Server.Services; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace Remotely.Server.Auth { diff --git a/Server/Auth/PasswordGenerator.cs b/Server/Auth/PasswordGenerator.cs index 955b40c3..9ca21cba 100644 --- a/Server/Auth/PasswordGenerator.cs +++ b/Server/Auth/PasswordGenerator.cs @@ -1,7 +1,4 @@ -using System.Security.Principal; -using System.Security.Cryptography; -using System.Threading; -using System.Collections.Specialized; +using System.Security.Cryptography; using System; namespace Remotely.Server.Auth diff --git a/Server/Data/ApplicationDbContext.cs b/Server/Data/ApplicationDbContext.cs index e67f967c..3b65cc24 100644 --- a/Server/Data/ApplicationDbContext.cs +++ b/Server/Data/ApplicationDbContext.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using Remotely.Shared.Models; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; diff --git a/Server/Migrations/20200305230311_Initial.cs b/Server/Migrations/20200305230311_Initial.cs index 3d80ef35..cf630943 100644 --- a/Server/Migrations/20200305230311_Initial.cs +++ b/Server/Migrations/20200305230311_Initial.cs @@ -1,5 +1,4 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; namespace Remotely.Server.Migrations { diff --git a/Server/Models/ApiLogin.cs b/Server/Models/ApiLogin.cs index 29667c18..414c4329 100644 --- a/Server/Models/ApiLogin.cs +++ b/Server/Models/ApiLogin.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Remotely.Server.Models +namespace Remotely.Server.Models { public class ApiLogin { diff --git a/Server/Models/RCSessionInfo.cs b/Server/Models/RCSessionInfo.cs index a32edc5d..99812ebd 100644 --- a/Server/Models/RCSessionInfo.cs +++ b/Server/Models/RCSessionInfo.cs @@ -1,8 +1,5 @@ using Remotely.Shared.Enums; using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace Remotely.Server.Models { diff --git a/Server/Models/RecordingSessionState.cs b/Server/Models/RecordingSessionState.cs index b9fc0e64..098f4f1f 100644 --- a/Server/Models/RecordingSessionState.cs +++ b/Server/Models/RecordingSessionState.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; +using System.Diagnostics; using System.Drawing; -using System.Linq; -using System.Threading.Tasks; namespace Remotely.Server.Models { diff --git a/Server/Models/RemoteControlFrame.cs b/Server/Models/RemoteControlFrame.cs index 89896c69..0db7208b 100644 --- a/Server/Models/RemoteControlFrame.cs +++ b/Server/Models/RemoteControlFrame.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Remotely.Server.Models { diff --git a/Server/Models/RemoteControlRequest.cs b/Server/Models/RemoteControlRequest.cs index 26bf9bff..2b6edc21 100644 --- a/Server/Models/RemoteControlRequest.cs +++ b/Server/Models/RemoteControlRequest.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Remotely.Server.Models +namespace Remotely.Server.Models { public class RemoteControlRequest { diff --git a/Server/Pages/About.cshtml.cs b/Server/Pages/About.cshtml.cs index 21409418..a6c33746 100644 --- a/Server/Pages/About.cshtml.cs +++ b/Server/Pages/About.cshtml.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace Remotely.Server.Pages { diff --git a/Server/Pages/Agents.cshtml.cs b/Server/Pages/Agents.cshtml.cs index cc9cfe2a..6698ecb0 100644 --- a/Server/Pages/Agents.cshtml.cs +++ b/Server/Pages/Agents.cshtml.cs @@ -1,9 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace Remotely.Server.Pages diff --git a/Server/Pages/Credits.cshtml.cs b/Server/Pages/Credits.cshtml.cs index 6dad3e14..78ace091 100644 --- a/Server/Pages/Credits.cshtml.cs +++ b/Server/Pages/Credits.cshtml.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace Remotely.Server.Pages diff --git a/Server/Pages/EditDevice.cshtml.cs b/Server/Pages/EditDevice.cshtml.cs index 2bdb7139..aaae78f0 100644 --- a/Server/Pages/EditDevice.cshtml.cs +++ b/Server/Pages/EditDevice.cshtml.cs @@ -1,8 +1,6 @@ -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; diff --git a/Server/Pages/Error.cshtml.cs b/Server/Pages/Error.cshtml.cs index 1da1e343..eda5e639 100644 --- a/Server/Pages/Error.cshtml.cs +++ b/Server/Pages/Error.cshtml.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Threading.Tasks; using Remotely.Server.Services; using Microsoft.AspNetCore.Diagnostics; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; diff --git a/Server/Pages/Index.cshtml.cs b/Server/Pages/Index.cshtml.cs index d1a9c7a4..7eb43615 100644 --- a/Server/Pages/Index.cshtml.cs +++ b/Server/Pages/Index.cshtml.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; diff --git a/Server/Pages/Invite.cshtml.cs b/Server/Pages/Invite.cshtml.cs index 4652853c..a76b028a 100644 --- a/Server/Pages/Invite.cshtml.cs +++ b/Server/Pages/Invite.cshtml.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Remotely.Server.Services; +using Remotely.Server.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; diff --git a/Server/Pages/Privacy.cshtml.cs b/Server/Pages/Privacy.cshtml.cs index 61a4fdef..cdc20259 100644 --- a/Server/Pages/Privacy.cshtml.cs +++ b/Server/Pages/Privacy.cshtml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace Remotely.Server.Pages { diff --git a/Server/Pages/RemoteControl.cshtml.cs b/Server/Pages/RemoteControl.cshtml.cs index 502824f0..cb5f1d37 100644 --- a/Server/Pages/RemoteControl.cshtml.cs +++ b/Server/Pages/RemoteControl.cshtml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc.RazorPages; namespace Remotely.Server.Pages diff --git a/Server/Pages/TwoFactorRequired.cshtml.cs b/Server/Pages/TwoFactorRequired.cshtml.cs index a91a463f..b109fab8 100644 --- a/Server/Pages/TwoFactorRequired.cshtml.cs +++ b/Server/Pages/TwoFactorRequired.cshtml.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.AspNetCore.Mvc.RazorPages; namespace Remotely.Server { diff --git a/Server/Program.cs b/Server/Program.cs index a5320aa2..bab6f263 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore; +using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -using Remotely.Shared.Services; +using Remotely.Shared.Utilities; namespace Remotely.Server { @@ -31,7 +26,7 @@ namespace Remotely.Server if (bool.TryParse(hostingContext.Configuration["ApplicationOptions:EnableWindowsEventLog"], out var enableEventLog)) { - if (OSUtils.IsWindows && enableEventLog) + if (EnvironmentHelper.IsWindows && enableEventLog) { logging.AddEventLog(); } diff --git a/Server/Services/ApplicationConfig.cs b/Server/Services/ApplicationConfig.cs index 3b354e91..65908896 100644 --- a/Server/Services/ApplicationConfig.cs +++ b/Server/Services/ApplicationConfig.cs @@ -1,10 +1,4 @@ -using Remotely.Shared.Models; -using Microsoft.Extensions.Configuration; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; namespace Remotely.Server.Services { diff --git a/Server/Services/BrowserSocketHub.cs b/Server/Services/BrowserSocketHub.cs index f0b257b9..922f0a5b 100644 --- a/Server/Services/BrowserSocketHub.cs +++ b/Server/Services/BrowserSocketHub.cs @@ -1,17 +1,11 @@ using Remotely.Shared.Models; -using Remotely.Server.Data; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.SignalR; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using System.Net; -using System.Net.WebSockets; using System.Text; using System.Threading.Tasks; diff --git a/Server/Services/DataService.cs b/Server/Services/DataService.cs index 205e5da7..28740320 100644 --- a/Server/Services/DataService.cs +++ b/Server/Services/DataService.cs @@ -1,5 +1,4 @@ using Remotely.Shared.Models; -using Remotely.Shared.ViewModels; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; @@ -11,8 +10,6 @@ using Remotely.Shared.ViewModels.Organization; using Remotely.Server.Data; using Microsoft.Extensions.Hosting; using System.Threading.Tasks; -using Remotely.Server.Auth; -using Microsoft.Extensions.Primitives; namespace Remotely.Server.Services { diff --git a/Server/Services/DeviceSocketHub.cs b/Server/Services/DeviceSocketHub.cs index 56f94b8b..8e13c139 100644 --- a/Server/Services/DeviceSocketHub.cs +++ b/Server/Services/DeviceSocketHub.cs @@ -1,16 +1,11 @@ using Remotely.Shared.Models; -using Remotely.Server.Data; using Microsoft.AspNetCore.SignalR; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; -using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.Internal; namespace Remotely.Server.Services { diff --git a/Server/Services/EmailSender.cs b/Server/Services/EmailSender.cs index c3b59314..a88402e2 100644 --- a/Server/Services/EmailSender.cs +++ b/Server/Services/EmailSender.cs @@ -1,9 +1,4 @@ -using Remotely.Server.Data; -using Newtonsoft.Json; using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Net; using System.Net.Mail; using System.Threading.Tasks; diff --git a/Server/Services/PascalCasePolicy.cs b/Server/Services/PascalCasePolicy.cs index 1393849b..9a91c5d4 100644 --- a/Server/Services/PascalCasePolicy.cs +++ b/Server/Services/PascalCasePolicy.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Linq; using System.Text.Json; -using System.Threading.Tasks; namespace Remotely.Server.Services { diff --git a/Server/Services/RCBrowserSocketHub.cs b/Server/Services/RCBrowserSocketHub.cs index 61496968..ea30d263 100644 --- a/Server/Services/RCBrowserSocketHub.cs +++ b/Server/Services/RCBrowserSocketHub.cs @@ -1,14 +1,11 @@ using Remotely.Shared.Models; -using Remotely.Server.Data; using Microsoft.AspNetCore.SignalR; using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Remotely.Shared.Enums; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Identity; namespace Remotely.Server.Services { diff --git a/Server/Services/RCDeviceSocketHub.cs b/Server/Services/RCDeviceSocketHub.cs index f0e8ea99..ca346425 100644 --- a/Server/Services/RCDeviceSocketHub.cs +++ b/Server/Services/RCDeviceSocketHub.cs @@ -1,12 +1,8 @@ -using Remotely.Server.Data; -using Microsoft.AspNetCore.SignalR; +using Microsoft.AspNetCore.SignalR; using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using System.IO; using System.Drawing; using Remotely.Shared.Models; using Remotely.Server.Models; diff --git a/Server/Services/RemoteControlSessionRecorder.cs b/Server/Services/RemoteControlSessionRecorder.cs index 93f63198..bb9a5fe8 100644 --- a/Server/Services/RemoteControlSessionRecorder.cs +++ b/Server/Services/RemoteControlSessionRecorder.cs @@ -1,15 +1,12 @@ using Microsoft.AspNetCore.Hosting; -using Remotely.Server.Data; using Remotely.Server.Models; -using Remotely.Shared.Services; +using Remotely.Shared.Utilities; using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; -using System.Linq; using System.Threading.Tasks; namespace Remotely.Server.Services @@ -63,7 +60,7 @@ namespace Remotely.Server.Services var ffmpegProc = new Process(); SessionStates[frame.ViewerID].FfmpegProcess = ffmpegProc; - switch (OSUtils.Platform) + switch (EnvironmentHelper.Platform) { case Shared.Enums.Platform.Windows: ffmpegProc.StartInfo.FileName = "ffmpeg.exe"; diff --git a/Server/Startup.cs b/Server/Startup.cs index fe4951c6..a2fd5ae4 100644 --- a/Server/Startup.cs +++ b/Server/Startup.cs @@ -1,12 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Remotely.Server.Data; @@ -17,20 +13,13 @@ using System.IO; using Remotely.Server.Services; using Microsoft.Extensions.FileProviders; using Microsoft.AspNetCore.StaticFiles; -using Microsoft.AspNetCore.SignalR; using Remotely.Shared.Models; -using Microsoft.AspNetCore.Http.Connections; using Remotely.Shared.Services; using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.AspNetCore.Identity.UI; -using Microsoft.AspNetCore.Cors.Infrastructure; -using Newtonsoft.Json; using System.Net; using Microsoft.Extensions.Hosting; -using Swashbuckle.AspNetCore.Swagger; using Microsoft.OpenApi.Models; using Remotely.Server.Auth; -using Microsoft.Data.SqlClient; using Npgsql; namespace Remotely.Server diff --git a/Shared/Enums/DynamicDtoType.cs b/Shared/Enums/DynamicDtoType.cs index 3f555417..c7929fea 100644 --- a/Shared/Enums/DynamicDtoType.cs +++ b/Shared/Enums/DynamicDtoType.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Runtime.Serialization; -using System.Text; +using System.Runtime.Serialization; namespace Remotely.Shared.Enums { diff --git a/Shared/Enums/Platform.cs b/Shared/Enums/Platform.cs index 84010dba..dc1d00cd 100644 --- a/Shared/Enums/Platform.cs +++ b/Shared/Enums/Platform.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely.Shared.Enums +namespace Remotely.Shared.Enums { public enum Platform { diff --git a/Shared/Enums/RemoteControlMode.cs b/Shared/Enums/RemoteControlMode.cs index d1e6ecf2..feb8e066 100644 --- a/Shared/Enums/RemoteControlMode.cs +++ b/Shared/Enums/RemoteControlMode.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely.Shared.Enums +namespace Remotely.Shared.Enums { public enum RemoteControlMode { diff --git a/Shared/Enums/Theme.cs b/Shared/Enums/Theme.cs index cd1d3377..722d4a47 100644 --- a/Shared/Enums/Theme.cs +++ b/Shared/Enums/Theme.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Runtime.Serialization; -using System.Text; - -namespace Remotely.Shared.Enums +namespace Remotely.Shared.Enums { public enum Theme { diff --git a/Shared/Helpers/TaskHelper.cs b/Shared/Helpers/TaskHelper.cs index e32db1a8..552a4c10 100644 --- a/Shared/Helpers/TaskHelper.cs +++ b/Shared/Helpers/TaskHelper.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Text; using System.Threading.Tasks; namespace Remotely.Shared.Helpers diff --git a/Shared/Models/Alert.cs b/Shared/Models/Alert.cs index e6c5d961..5e68cf8d 100644 --- a/Shared/Models/Alert.cs +++ b/Shared/Models/Alert.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Text; using System.Text.Json.Serialization; namespace Remotely.Shared.Models diff --git a/Shared/Models/AlertOptions.cs b/Shared/Models/AlertOptions.cs index 57af5749..e7b03511 100644 --- a/Shared/Models/AlertOptions.cs +++ b/Shared/Models/AlertOptions.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Net.Http; -using System.Text; +using System.Collections.Generic; namespace Remotely.Shared.Models { diff --git a/Shared/Models/ApiToken.cs b/Shared/Models/ApiToken.cs index a7997dc2..8e455da1 100644 --- a/Shared/Models/ApiToken.cs +++ b/Shared/Models/ApiToken.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Text; using System.Text.Json.Serialization; namespace Remotely.Shared.Models diff --git a/Shared/Models/CommandResult.cs b/Shared/Models/CommandResult.cs index 59abdb4e..fb1ee7ee 100644 --- a/Shared/Models/CommandResult.cs +++ b/Shared/Models/CommandResult.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Runtime.Serialization; using System.Text.Json.Serialization; namespace Remotely.Shared.Models diff --git a/Shared/Models/ConnectionInfo.cs b/Shared/Models/ConnectionInfo.cs index 8e8a7296..d4965d85 100644 --- a/Shared/Models/ConnectionInfo.cs +++ b/Shared/Models/ConnectionInfo.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Remotely.Shared.Models { diff --git a/Shared/Models/CursorInfo.cs b/Shared/Models/CursorInfo.cs index 22c517fc..4c6fd36c 100644 --- a/Shared/Models/CursorInfo.cs +++ b/Shared/Models/CursorInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Drawing; namespace Remotely.Shared.Models { diff --git a/Shared/Models/Device.cs b/Shared/Models/Device.cs index ee0db34d..536e2434 100644 --- a/Shared/Models/Device.cs +++ b/Shared/Models/Device.cs @@ -1,14 +1,8 @@ -using Remotely.Shared.Services; -using Microsoft.Management.Infrastructure; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Diagnostics; -using System.IO; -using System.Linq; using System.Runtime.InteropServices; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace Remotely.Shared.Models { diff --git a/Shared/Models/DeviceGroup.cs b/Shared/Models/DeviceGroup.cs index d0b9e4ca..7ff1fded 100644 --- a/Shared/Models/DeviceGroup.cs +++ b/Shared/Models/DeviceGroup.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Text; using System.Text.Json.Serialization; namespace Remotely.Shared.Models diff --git a/Shared/Models/DeviceSetupOptions.cs b/Shared/Models/DeviceSetupOptions.cs index 9a9d037d..ee2e05cc 100644 --- a/Shared/Models/DeviceSetupOptions.cs +++ b/Shared/Models/DeviceSetupOptions.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely.Shared.Models +namespace Remotely.Shared.Models { public class DeviceSetupOptions { diff --git a/Shared/Models/Drive.cs b/Shared/Models/Drive.cs index 5740665f..cef31eb0 100644 --- a/Shared/Models/Drive.cs +++ b/Shared/Models/Drive.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.IO; -using System.Text; +using System.IO; namespace Remotely.Shared.Models { diff --git a/Shared/Models/EventLog.cs b/Shared/Models/EventLog.cs index 595aeec4..45c5a1ad 100644 --- a/Shared/Models/EventLog.cs +++ b/Shared/Models/EventLog.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Text; using System.Text.Json.Serialization; namespace Remotely.Shared.Models diff --git a/Shared/Models/FrameInfo.cs b/Shared/Models/FrameInfo.cs index 36d8487a..f4fff79d 100644 --- a/Shared/Models/FrameInfo.cs +++ b/Shared/Models/FrameInfo.cs @@ -1,9 +1,5 @@ using Remotely.Shared.Enums; -using Remotely.Shared.Models; -using System; -using System.Collections.Generic; using System.Runtime.Serialization; -using System.Text; namespace Remotely.Shared.Models { diff --git a/Shared/Models/GenericCommandResult.cs b/Shared/Models/GenericCommandResult.cs index 48e17b8b..53315080 100644 --- a/Shared/Models/GenericCommandResult.cs +++ b/Shared/Models/GenericCommandResult.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Text; namespace Remotely.Shared.Models { diff --git a/Shared/Models/IDynamicDto.cs b/Shared/Models/IDynamicDto.cs index 5d555da9..7f0bd2cb 100644 --- a/Shared/Models/IDynamicDto.cs +++ b/Shared/Models/IDynamicDto.cs @@ -1,7 +1,4 @@ using Remotely.Shared.Enums; -using System; -using System.Collections.Generic; -using System.Text; namespace Remotely.Shared.Models { diff --git a/Shared/Models/InviteLink.cs b/Shared/Models/InviteLink.cs index d91c5ce5..e79d3fee 100644 --- a/Shared/Models/InviteLink.cs +++ b/Shared/Models/InviteLink.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Text; using System.Text.Json.Serialization; namespace Remotely.Shared.Models diff --git a/Shared/Models/Organization.cs b/Shared/Models/Organization.cs index 808f16c5..5f9afa0a 100644 --- a/Shared/Models/Organization.cs +++ b/Shared/Models/Organization.cs @@ -1,5 +1,4 @@ -using Remotely.Shared.Models; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; diff --git a/Shared/Models/PSCoreCommandResult.cs b/Shared/Models/PSCoreCommandResult.cs index 438022e5..a879d6c1 100644 --- a/Shared/Models/PSCoreCommandResult.cs +++ b/Shared/Models/PSCoreCommandResult.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Text; namespace Remotely.Shared.Models { diff --git a/Shared/Models/PSError.cs b/Shared/Models/PSError.cs index c6b152ed..fe7bdee9 100644 --- a/Shared/Models/PSError.cs +++ b/Shared/Models/PSError.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely.Shared.Models +namespace Remotely.Shared.Models { public class PSError { diff --git a/Shared/Models/RemotelyUser.cs b/Shared/Models/RemotelyUser.cs index 35019f7b..96d4ddd1 100644 --- a/Shared/Models/RemotelyUser.cs +++ b/Shared/Models/RemotelyUser.cs @@ -1,10 +1,6 @@ using Microsoft.AspNetCore.Identity; -using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace Remotely.Shared.Models { diff --git a/Shared/Models/RemotelyUserOptions.cs b/Shared/Models/RemotelyUserOptions.cs index e3766fd5..a28be225 100644 --- a/Shared/Models/RemotelyUserOptions.cs +++ b/Shared/Models/RemotelyUserOptions.cs @@ -1,6 +1,4 @@ using Remotely.Shared.Enums; -using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace Remotely.Shared.Models diff --git a/Shared/Models/ScreenCastRequest.cs b/Shared/Models/ScreenCastRequest.cs index 15b93dba..e7f91baf 100644 --- a/Shared/Models/ScreenCastRequest.cs +++ b/Shared/Models/ScreenCastRequest.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely.Shared.Models +namespace Remotely.Shared.Models { public class ScreenCastRequest { diff --git a/Shared/Models/SharedFile.cs b/Shared/Models/SharedFile.cs index 7e9146a4..22bc1ab6 100644 --- a/Shared/Models/SharedFile.cs +++ b/Shared/Models/SharedFile.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Text; namespace Remotely.Shared.Models { diff --git a/Shared/Models/UserDevicePermission.cs b/Shared/Models/UserDevicePermission.cs index d246172f..8e4bc7da 100644 --- a/Shared/Models/UserDevicePermission.cs +++ b/Shared/Models/UserDevicePermission.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Text; using System.Text.Json.Serialization; namespace Remotely.Shared.Models diff --git a/Shared/Models/WindowsSession.cs b/Shared/Models/WindowsSession.cs index 9495124e..384939a4 100644 --- a/Shared/Models/WindowsSession.cs +++ b/Shared/Models/WindowsSession.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely.Shared.Models +namespace Remotely.Shared.Models { public enum SessionType { diff --git a/Shared/Services/DeviceInformation.cs b/Shared/Services/DeviceInformation.cs index 21c473c1..0018347f 100644 --- a/Shared/Services/DeviceInformation.cs +++ b/Shared/Services/DeviceInformation.cs @@ -1,5 +1,5 @@ using Remotely.Shared.Models; -using Remotely.Shared.Services; +using Remotely.Shared.Utilities; using Remotely.Shared.Win32; using System; using System.Collections.Generic; @@ -7,7 +7,6 @@ using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Text; using System.Threading.Tasks; namespace Remotely.Shared.Services @@ -18,13 +17,13 @@ namespace Remotely.Shared.Services { DriveInfo systemDrive; - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { systemDrive = DriveInfo.GetDrives().FirstOrDefault(x => x.IsReady && x.RootDirectory.FullName.Contains(Path.GetPathRoot(Environment.SystemDirectory ?? Environment.CurrentDirectory))); } - else if (OSUtils.IsLinux) + else if (EnvironmentHelper.IsLinux) { systemDrive = new DriveInfo("/"); } @@ -38,7 +37,7 @@ namespace Remotely.Shared.Services { ID = deviceID, DeviceName = Environment.MachineName, - Platform = OSUtils.Platform.ToString(), + Platform = EnvironmentHelper.Platform.ToString(), ProcessorCount = Environment.ProcessorCount, OSArchitecture = RuntimeInformation.OSArchitecture, OSDescription = RuntimeInformation.OSDescription, @@ -128,13 +127,13 @@ namespace Remotely.Shared.Services { try { - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { return Win32Interop.GetActiveSessions().LastOrDefault()?.Username; } - else if (OSUtils.IsLinux) + else if (EnvironmentHelper.IsLinux) { - var users = OSUtils.StartProcessWithResults("users", ""); + var users = EnvironmentHelper.StartProcessWithResults("users", ""); return users?.Split()?.FirstOrDefault()?.Trim(); } throw new Exception("Unsupported operating system."); @@ -147,11 +146,11 @@ namespace Remotely.Shared.Services public static (double, double) GetMemoryInGB() { - if (OSUtils.IsWindows) + if (EnvironmentHelper.IsWindows) { return GetWinMemoryInGB(); } - else if (OSUtils.IsLinux) + else if (EnvironmentHelper.IsLinux) { return GetLinuxMemoryInGB(); } @@ -164,7 +163,7 @@ namespace Remotely.Shared.Services { try { - var results = OSUtils.StartProcessWithResults("cat", "/proc/meminfo"); + var results = EnvironmentHelper.StartProcessWithResults("cat", "/proc/meminfo"); var resultsArr = results.Split("\n".ToCharArray()); var freeKB = resultsArr .FirstOrDefault(x => x.Trim().StartsWith("MemAvailable")) diff --git a/Shared/Services/RandomGenerator.cs b/Shared/Services/RandomGenerator.cs index 850bc61d..eb9ea52a 100644 --- a/Shared/Services/RandomGenerator.cs +++ b/Shared/Services/RandomGenerator.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Security.Cryptography; -using System.Text; +using System.Security.Cryptography; using System.Linq; namespace Remotely.Shared.Services diff --git a/Shared/Services/OSUtils.cs b/Shared/Utilities/EnvironmentHelper.cs similarity index 90% rename from Shared/Services/OSUtils.cs rename to Shared/Utilities/EnvironmentHelper.cs index ee586348..0d49c596 100644 --- a/Shared/Services/OSUtils.cs +++ b/Shared/Utilities/EnvironmentHelper.cs @@ -3,25 +3,10 @@ using System; using System.Diagnostics; using System.Runtime.InteropServices; -namespace Remotely.Shared.Services +namespace Remotely.Shared.Utilities { - public static class OSUtils + public static class EnvironmentHelper { - public static bool IsLinux - { - get - { - return RuntimeInformation.IsOSPlatform(OSPlatform.Linux); - } - } - - public static bool IsWindows - { - get - { - return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - } - } public static string ClientExecutableFileName { get @@ -38,25 +23,33 @@ namespace Remotely.Shared.Services return fileExt; } } - public static string ScreenCastExecutableFileName + + public static bool IsDebug { get { - if (IsWindows) - { - return "Remotely_ScreenCast.exe"; - } - else if (IsLinux) - { - return "Remotely_ScreenCast.Linux"; - } - else - { - throw new Exception("Unsupported operating system."); - } +#if DEBUG + return true; +#else + return false; +#endif + } + } + public static bool IsLinux + { + get + { + return RuntimeInformation.IsOSPlatform(OSPlatform.Linux); } } + public static bool IsWindows + { + get + { + return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + } + } public static Platform Platform { get @@ -80,6 +73,24 @@ namespace Remotely.Shared.Services } } + public static string ScreenCastExecutableFileName + { + get + { + if (IsWindows) + { + return "Remotely_ScreenCast.exe"; + } + else if (IsLinux) + { + return "Remotely_ScreenCast.Linux"; + } + else + { + throw new Exception("Unsupported operating system."); + } + } + } public static string StartProcessWithResults(string command, string arguments) { var psi = new ProcessStartInfo(command, arguments); diff --git a/Shared/ViewModels/Organization/Invite.cs b/Shared/ViewModels/Organization/Invite.cs index 1b2adc97..cfe9e0a7 100644 --- a/Shared/ViewModels/Organization/Invite.cs +++ b/Shared/ViewModels/Organization/Invite.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Remotely.Shared.ViewModels.Organization { diff --git a/Shared/ViewModels/Organization/OrganizationUser.cs b/Shared/ViewModels/Organization/OrganizationUser.cs index 7dca47a6..49e1f689 100644 --- a/Shared/ViewModels/Organization/OrganizationUser.cs +++ b/Shared/ViewModels/Organization/OrganizationUser.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Remotely.Shared.ViewModels.Organization +namespace Remotely.Shared.ViewModels.Organization { public class OrganizationUser { diff --git a/Shared/Win32/ADVAPI32.cs b/Shared/Win32/ADVAPI32.cs index d946b1a1..8650d86b 100644 --- a/Shared/Win32/ADVAPI32.cs +++ b/Shared/Win32/ADVAPI32.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Runtime.InteropServices; using System.Security; diff --git a/Shared/Win32/GDI32.cs b/Shared/Win32/GDI32.cs index 3729b2f1..46a6ebcd 100644 --- a/Shared/Win32/GDI32.cs +++ b/Shared/Win32/GDI32.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace Remotely.Shared.Win32 { diff --git a/Shared/Win32/User32.cs b/Shared/Win32/User32.cs index b9b98cef..df23acd9 100644 --- a/Shared/Win32/User32.cs +++ b/Shared/Win32/User32.cs @@ -1,9 +1,7 @@ using Microsoft.Win32.SafeHandles; using System; -using System.Linq; using System.Runtime.ConstrainedExecution; using System.Runtime.InteropServices; -using System.Text; namespace Remotely.Shared.Win32 { diff --git a/Shared/Win32/Win32Interop.cs b/Shared/Win32/Win32Interop.cs index a94fd621..df9894fa 100644 --- a/Shared/Win32/Win32Interop.cs +++ b/Shared/Win32/Win32Interop.cs @@ -1,5 +1,4 @@ using Remotely.Shared.Models; -using Remotely.Shared.Win32; using System; using System.Collections.Generic; using System.Diagnostics; @@ -188,12 +187,7 @@ namespace Remotely.Shared.Win32 return false; } - if (!SetThreadDesktop(inputDesktop) || !SwitchDesktop(inputDesktop)) - { - return false; - } - - return true; + return SetThreadDesktop(inputDesktop) && SwitchDesktop(inputDesktop); } catch { diff --git a/Tests/CaptureTests.cs b/Tests/CaptureTests.cs index 950d36a6..fed2b469 100644 --- a/Tests/CaptureTests.cs +++ b/Tests/CaptureTests.cs @@ -2,11 +2,9 @@ using Remotely.ScreenCast.Core.Utilities; using Remotely.ScreenCast.Win.Services; using System; -using System.Collections.Generic; using System.Diagnostics; using System.Drawing.Imaging; using System.IO; -using System.Text; using System.Threading.Tasks; namespace Remotely.Tests diff --git a/Tests/DataServiceTests.cs b/Tests/DataServiceTests.cs index 68a2a09a..d938ac5b 100644 --- a/Tests/DataServiceTests.cs +++ b/Tests/DataServiceTests.cs @@ -1,20 +1,11 @@ -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Remotely.Server.Data; using Remotely.Server.Services; using Remotely.Shared.Models; using Remotely.Shared.Services; using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Remotely.Tests diff --git a/Tests/IoCActivator.cs b/Tests/IoCActivator.cs index 586b8c75..d7071a39 100644 --- a/Tests/IoCActivator.cs +++ b/Tests/IoCActivator.cs @@ -5,15 +5,10 @@ using Microsoft.Extensions.DependencyInjection; using Remotely.Server.Data; using Remotely.Server.Services; using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.EntityFrameworkCore.InMemory.Internal; using Microsoft.EntityFrameworkCore; using Remotely.Shared.Models; using Microsoft.AspNetCore.Identity; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Identity.UI.Services; namespace Remotely.Tests { diff --git a/Tests/TestData.cs b/Tests/TestData.cs index 999d717b..389e73d4 100644 --- a/Tests/TestData.cs +++ b/Tests/TestData.cs @@ -1,16 +1,10 @@ using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.Extensions.DependencyInjection; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Remotely.Server.Areas.Identity.Pages.Account.Manage; using Remotely.Server.Data; using Remotely.Server.Services; using Remotely.Shared.Models; -using Remotely.Shared.Services; -using System; -using System.Collections.Generic; using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Remotely.Tests