Skip to content

Commit

Permalink
Move library.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Nov 23, 2024
1 parent 9128a86 commit 5728802
Show file tree
Hide file tree
Showing 77 changed files with 294 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ControlR.Libraries.Clients\ControlR.Libraries.Clients.csproj" />
<ProjectReference Include="..\ControlR.Libraries.DevicesCommon\ControlR.Libraries.DevicesCommon.csproj" />
<ProjectReference Include="..\ControlR.Libraries.DevicesNative\ControlR.Libraries.DevicesNative.csproj" />
<ProjectReference Include="..\ControlR.Libraries.Signalr.Client\ControlR.Libraries.Signalr.Client.csproj" />
<ProjectReference Include="..\Libraries\ControlR.Libraries.Clients\ControlR.Libraries.Clients.csproj" />
<ProjectReference Include="..\Libraries\ControlR.Libraries.DevicesCommon\ControlR.Libraries.DevicesCommon.csproj" />
<ProjectReference Include="..\Libraries\ControlR.Libraries.DevicesNative\ControlR.Libraries.DevicesNative.csproj" />
<ProjectReference Include="..\Libraries\ControlR.Libraries.Signalr.Client\ControlR.Libraries.Signalr.Client.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ControlR.Libraries.Agent.Interfaces;
namespace ControlR.Agent.Common.Interfaces;

public interface IAgentInstaller
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ControlR.Libraries.Agent.Models;
using ControlR.Agent.Common.Models;

namespace ControlR.Libraries.Agent.Interfaces;
namespace ControlR.Agent.Common.Interfaces;

public interface IDeviceDataGenerator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ControlR.Libraries.Agent.Interfaces;
namespace ControlR.Agent.Common.Interfaces;

public interface IElevationChecker
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ControlR.Libraries.Shared.Enums;

namespace ControlR.Libraries.Agent.Interfaces;
namespace ControlR.Agent.Common.Interfaces;
internal interface IPowerControl
{
Task ChangeState(PowerStateChangeType type);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ControlR.Libraries.Shared.Primitives;

namespace ControlR.Libraries.Agent.Interfaces;
namespace ControlR.Agent.Common.Interfaces;
internal interface IStreamerLauncher
{
Task<Result> CreateSession(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ControlR.Libraries.Shared.Dtos.StreamerDtos;
using Microsoft.Extensions.Hosting;

namespace ControlR.Libraries.Agent.Interfaces;
namespace ControlR.Agent.Common.Interfaces;
internal interface IStreamerUpdater : IHostedService
{
Task<bool> EnsureLatestVersion(
Expand Down
4 changes: 4 additions & 0 deletions ControlR.Agent.Common/Interfaces/ITerminalSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace ControlR.Agent.Common.Interfaces;
internal interface ITerminalSession
{
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MessagePack;
namespace ControlR.Libraries.Agent.IpcDtos;
namespace ControlR.Agent.Common.IpcDtos;

[MessagePackObject]
public record DesktopRequestDto();
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ControlR.Libraries.Shared.Serialization;
using MessagePack;

namespace ControlR.Libraries.Agent.IpcDtos;
namespace ControlR.Agent.Common.IpcDtos;

[MessagePackObject]
public record DesktopResponseDto([property: MsgPackKey] string DesktopName);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MessagePack;

namespace ControlR.Libraries.Agent.IpcDtos;
namespace ControlR.Agent.Common.IpcDtos;

[MessagePackObject]
public record ShutdownRequestDto();
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using MessagePack;
using System.Runtime.InteropServices;

namespace ControlR.Libraries.Agent.Models;
namespace ControlR.Agent.Common.Models;

public class DeviceModel
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ControlR.Libraries.Agent.Models;
namespace ControlR.Agent.Common.Models;
internal enum StartupMode
{
None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Diagnostics;
using ControlR.Libraries.Shared.Helpers;

namespace ControlR.Libraries.Agent.Models;
namespace ControlR.Agent.Common.Models;

internal class StreamingSession(string viewerConnectionId) : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ControlR.Libraries.Agent.Options;
namespace ControlR.Agent.Common.Options;
public class InstanceOptions
{
public const string SectionKey = "InstanceOptions";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Hosting;

namespace ControlR.Libraries.Agent.Services;
namespace ControlR.Agent.Common.Services;

internal class AgentHeartbeatTimer(
IAgentHubConnection hubConnection,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Diagnostics;
using System.Runtime.Versioning;
using ControlR.Agent.Common.Interfaces;
using ControlR.Devices.Native.Services;
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Libraries.Shared.Dtos.StreamerDtos;
using ControlR.Libraries.Shared.Interfaces.HubClients;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;

namespace ControlR.Libraries.Agent.Services;
namespace ControlR.Agent.Common.Services;

internal class AgentHubClient(
IAgentHubConnection hubConnection,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Libraries.Agent.Models;
using ControlR.Agent.Common.Interfaces;
using ControlR.Agent.Common.Models;
using ControlR.Libraries.Shared.Dtos.ServerApi;
using ControlR.Libraries.Shared.Dtos.StreamerDtos;
using Microsoft.AspNetCore.Http.Connections;
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.Hosting;

namespace ControlR.Libraries.Agent.Services;
namespace ControlR.Agent.Common.Services;

public interface IAgentHubConnection : IAsyncDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Security.Cryptography;
using ControlR.Libraries.Agent.Options;
using ControlR.Agent.Common.Options;
using ControlR.Libraries.Shared.Constants;
using ControlR.Libraries.Shared.Services.Http;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;

namespace ControlR.Libraries.Agent.Services;
namespace ControlR.Agent.Common.Services;

internal interface IAgentUpdater : IHostedService
{
Expand Down Expand Up @@ -123,39 +123,39 @@ public async Task CheckForUpdate(CancellationToken cancellationToken = default)
switch (_environmentHelper.Platform)
{
case SystemPlatform.Windows:
{
await _processInvoker
.Start(tempPath, installCommand)
.WaitForExitAsync(linkedCts.Token);
}
{
await _processInvoker
.Start(tempPath, installCommand)
.WaitForExitAsync(linkedCts.Token);
}
break;

case SystemPlatform.Linux:
{
await _processInvoker
.Start("sudo", $"chmod +x {tempPath}")
.WaitForExitAsync(linkedCts.Token);

await _processInvoker.StartAndWaitForExit(
"/bin/bash",
$"-c \"{tempPath} {installCommand} &\"",
true,
linkedCts.Token);
}
{
await _processInvoker
.Start("sudo", $"chmod +x {tempPath}")
.WaitForExitAsync(linkedCts.Token);

await _processInvoker.StartAndWaitForExit(
"/bin/bash",
$"-c \"{tempPath} {installCommand} &\"",
true,
linkedCts.Token);
}
break;

case SystemPlatform.MacOs:
{
await _processInvoker
.Start("sudo", $"chmod +x {tempPath}")
.WaitForExitAsync(linkedCts.Token);

await _processInvoker.StartAndWaitForExit(
"/bin/zsh",
$"-c \"{tempPath} {installCommand} &\"",
true,
linkedCts.Token);
}
{
await _processInvoker
.Start("sudo", $"chmod +x {tempPath}")
.WaitForExitAsync(linkedCts.Token);

await _processInvoker.StartAndWaitForExit(
"/bin/zsh",
$"-c \"{tempPath} {installCommand} &\"",
true,
linkedCts.Token);
}
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using ControlR.Libraries.Shared.Constants;
using Microsoft.Extensions.Options;

namespace ControlR.Libraries.Agent.Services.Base;
namespace ControlR.Agent.Common.Services.Base;

internal abstract class AgentInstallerBase(
IFileSystem fileSystem,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using ControlR.Libraries.Agent.Models;
using ControlR.Agent.Common.Models;
using Microsoft.Extensions.Options;

namespace ControlR.Libraries.Agent.Services.Base;
namespace ControlR.Agent.Common.Services.Base;

internal class DeviceDataGeneratorBase(
ISystemEnvironment environmentHelper,
Expand Down Expand Up @@ -69,7 +69,7 @@ public DeviceModel GetDeviceBase(
double cpuUtilization,
string agentVersion)
{

return new DeviceModel
{
Id = deviceId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Agent.Common.Interfaces;
using Microsoft.Extensions.Hosting;
using System.Diagnostics;

namespace ControlR.Libraries.Agent.Services;
namespace ControlR.Agent.Common.Services;

internal interface ICpuUtilizationSampler : IHostedService
{
Expand All @@ -13,7 +13,7 @@ internal class CpuUtilizationSampler(IElevationChecker elevationChecker, ILogger
: BackgroundService, ICpuUtilizationSampler
{
private readonly HashSet<int> _ignoredProcesses = [];

private double _currentUtilization;

public double CurrentUtilization => _currentUtilization;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using ControlR.Devices.Native.Services;
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Agent.Common.Interfaces;
using ControlR.Devices.Native.Services;
using Microsoft.Extensions.Hosting;

namespace ControlR.Libraries.Agent.Services;
namespace ControlR.Agent.Common.Services;

internal class DtoHandler(
IAgentHubConnection agentHub,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Agent.Common.Interfaces;
using ControlR.Libraries.Shared.Extensions;
using ControlR.Libraries.Shared.Primitives;

namespace ControlR.Libraries.Agent.Services.Fakes;
namespace ControlR.Agent.Common.Services.Fakes;
internal class StreamerLauncherFake : IStreamerLauncher
{
public Task<Result> CreateSession(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Agent.Common.Interfaces;
using ControlR.Libraries.Shared.Dtos.StreamerDtos;
using Microsoft.Extensions.Hosting;

namespace ControlR.Libraries.Agent.Services.Fakes;
namespace ControlR.Agent.Common.Services.Fakes;

internal class StreamerUpdaterFake(ILogger<StreamerUpdaterFake> logger) : BackgroundService, IStreamerUpdater
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Hosting;

namespace ControlR.Libraries.Agent.Services;
namespace ControlR.Agent.Common.Services;

public class HubConnectionInitializer(IAgentHubConnection _agentHubConnection) : IHostedService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Diagnostics;
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Libraries.Agent.Options;
using ControlR.Libraries.Agent.Services.Base;
using ControlR.Agent.Common.Interfaces;
using ControlR.Agent.Common.Options;
using ControlR.Agent.Common.Services.Base;
using ControlR.Libraries.DevicesNative.Linux;
using ControlR.Libraries.Shared.Constants;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;

namespace ControlR.Libraries.Agent.Services.Linux;
namespace ControlR.Agent.Common.Services.Linux;

internal class AgentInstallerLinux(
IHostApplicationLifetime lifetime,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Libraries.Agent.Models;
using ControlR.Libraries.Agent.Services.Base;
using ControlR.Agent.Common.Interfaces;
using ControlR.Agent.Common.Models;
using ControlR.Agent.Common.Services.Base;
using Microsoft.Extensions.Options;

namespace ControlR.Libraries.Agent.Services.Linux;
namespace ControlR.Agent.Common.Services.Linux;

internal class DeviceDataGeneratorLinux(
IProcessManager processInvoker,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Agent.Common.Interfaces;
using ControlR.Libraries.DevicesNative.Linux;

namespace ControlR.Libraries.Agent.Services.Linux;
namespace ControlR.Agent.Common.Services.Linux;

public class ElevationCheckerLinux : IElevationChecker
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ControlR.Libraries.Agent.Interfaces;
using ControlR.Agent.Common.Interfaces;
using ControlR.Libraries.Shared.Enums;

namespace ControlR.Libraries.Agent.Services.Linux;
namespace ControlR.Agent.Common.Services.Linux;
internal class PowerControlLinux(IProcessManager processInvoker) : IPowerControl
{
private readonly IProcessManager _processInvoker = processInvoker;
Expand Down
Loading

0 comments on commit 5728802

Please sign in to comment.