Skip to content

Commit 49e910d

Browse files
committed
Merge in abstractions in Desktop projects.
1 parent 9e055af commit 49e910d

29 files changed

+79
-143
lines changed

Desktop.Linux/Program.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ public static async Task Main(string[] args)
4444

4545
services.AddSingleton<IOrganizationIdProvider, OrganizationIdProvider>();
4646
services.AddSingleton<IEmbeddedServerDataProvider, EmbeddedServerDataProvider>();
47-
48-
services.AddRemoteControlLinux(
49-
config =>
50-
{
51-
config.AddBrandingProvider<BrandingProvider>();
52-
});
47+
services.AddRemoteControlLinux();
5348

5449
services.AddLogging(builder =>
5550
{

Desktop.Linux/Services/AppStartup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Remotely.Desktop.UI.Services;
55
using Remotely.Shared.Models;
66
using Microsoft.Extensions.Logging;
7+
using Desktop.Shared.Services;
78

89
namespace Remotely.Desktop.Linux.Services;
910

Desktop.Linux/Startup/IServiceCollectionExtensions.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ public static class IServiceCollectionExtensions
1717
/// </summary>
1818
/// <param name="services"></param>
1919
/// <param name="clientConfig"></param>
20-
public static void AddRemoteControlLinux(
21-
this IServiceCollection services,
22-
Action<IRemoteControlClientBuilder> clientConfig)
20+
public static void AddRemoteControlLinux(this IServiceCollection services)
2321
{
24-
services.AddRemoteControlXplat(clientConfig);
22+
services.AddRemoteControlXplat();
2523
services.AddRemoteControlUi();
2624

2725
services.AddSingleton<IAppStartup, AppStartup>();

Desktop.Shared/Abstractions/IBrandingProvider.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

Desktop.Shared/Services/BrandingProvider.cs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
namespace Desktop.Shared.Services;
1212

13+
public interface IBrandingProvider
14+
{
15+
BrandingInfo CurrentBranding { get; }
16+
Task Initialize();
17+
void SetBrandingInfo(BrandingInfo brandingInfo);
18+
}
19+
1320
public class BrandingProvider : IBrandingProvider
1421
{
1522
private readonly IAppState _appState;
@@ -56,9 +63,9 @@ public async Task Initialize()
5663
};
5764
}
5865

59-
if (_brandingInfo.Icon?.Any() != true)
66+
if (_brandingInfo.Icon is not { Length: > 0 })
6067
{
61-
using var mrs = typeof(BrandingProvider).Assembly.GetManifestResourceStream("Desktop.Shared.Assets.Remotely_Icon.png");
68+
using var mrs = typeof(BrandingProvider).Assembly.GetManifestResourceStream("Remotely.Desktop.Shared.Assets.Remotely_Icon.png");
6269
using var ms = new MemoryStream();
6370
mrs!.CopyTo(ms);
6471

@@ -87,21 +94,24 @@ private async Task<Result<BrandingInfo>> TryGetBrandingInfo()
8794

8895
var result = _embeddedDataSearcher.TryGetEmbeddedData(filePath);
8996

90-
if (!result.IsSuccess)
91-
{
92-
return result.HadException ?
93-
Result.Fail<BrandingInfo>(result.Exception) :
94-
Result.Fail<BrandingInfo>(result.Reason);
95-
}
96-
97-
if (!string.IsNullOrWhiteSpace(result.Value.OrganizationId))
97+
if (result.IsSuccess)
9898
{
99-
_orgIdProvider.OrganizationId = result.Value.OrganizationId;
99+
if (!string.IsNullOrWhiteSpace(result.Value.OrganizationId))
100+
{
101+
_orgIdProvider.OrganizationId = result.Value.OrganizationId;
102+
}
103+
104+
if (result.Value.ServerUrl is not null)
105+
{
106+
_appState.Host = result.Value.ServerUrl.AbsoluteUri;
107+
}
100108
}
101109

102-
if (result.Value.ServerUrl is not null)
110+
if (string.IsNullOrWhiteSpace(_appState.Host))
103111
{
104-
_appState.Host = result.Value.ServerUrl.AbsoluteUri;
112+
return result.HadException ?
113+
Result.Fail<BrandingInfo>(result.Exception) :
114+
Result.Fail<BrandingInfo>(result.Reason);
105115
}
106116
}
107117

Desktop.Shared/Startup/IServiceCollectionExtensions.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55
using Microsoft.Extensions.Logging;
66
using Bitbound.SimpleMessenger;
77
using Desktop.Shared.Services;
8+
using Remotely.Desktop.Shared.Abstractions;
89

910
namespace Remotely.Desktop.Shared.Startup;
1011

1112
public static class IServiceCollectionExtensions
1213
{
1314
internal static void AddRemoteControlXplat(
14-
this IServiceCollection services,
15-
Action<IRemoteControlClientBuilder> clientConfig)
15+
this IServiceCollection services)
1616
{
17-
var builder = new RemoteControlClientBuilder(services);
18-
clientConfig.Invoke(builder);
19-
builder.Validate();
20-
2117
services.AddLogging(builder =>
2218
{
2319
builder.AddConsole().AddDebug();
@@ -31,6 +27,7 @@ internal static void AddRemoteControlXplat(
3127
services.AddSingleton(s => WeakReferenceMessenger.Default);
3228
services.AddSingleton<IDesktopEnvironment, DesktopEnvironment>();
3329
services.AddSingleton<IDtoMessageHandler, DtoMessageHandler>();
30+
services.AddSingleton<IBrandingProvider, BrandingProvider>();
3431
services.AddSingleton<IAppState, AppState>();
3532
services.AddSingleton<IViewerFactory, ViewerFactory>();
3633
services.AddTransient<IScreenCaster, ScreenCaster>();

Desktop.Shared/Startup/RemoteControlClientBuilder.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

Desktop.UI/Services/ViewModelFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.Extensions.Logging;
55
using System.IO;
6+
using Desktop.Shared.Services;
67

78
namespace Remotely.Desktop.UI.Services;
89

Desktop.UI/ViewModels/BrandedViewModelBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Remotely.Shared.Entities;
99
using System.IO;
1010
using System.Reflection;
11+
using Desktop.Shared.Services;
1112

1213
namespace Remotely.Desktop.UI.ViewModels;
1314

@@ -66,7 +67,7 @@ private void ApplyBrandingImpl()
6667

6768
ProductName = _brandingInfo.Product;
6869

69-
if (_brandingInfo.Icon?.Any() == true)
70+
if (_brandingInfo.Icon is { Length: > 0 })
7071
{
7172
using var imageStream = new MemoryStream(_brandingInfo.Icon);
7273
Icon = new Bitmap(imageStream);

Desktop.UI/ViewModels/ChatWindowViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Remotely.Desktop.Shared.Reactive;
99
using Microsoft.Extensions.DependencyInjection;
1010
using Remotely.Shared.Models;
11+
using Desktop.Shared.Services;
1112

1213
namespace Remotely.Desktop.UI.ViewModels;
1314

0 commit comments

Comments
 (0)