1
1
using Microsoft . AspNetCore . SignalR . Client ;
2
2
using Remotely . Agent . Interfaces ;
3
3
using Remotely . Shared . Models ;
4
+ using Remotely . Shared . Services ;
4
5
using Remotely . Shared . Utilities ;
5
6
using System ;
6
7
using System . Collections . Generic ;
@@ -15,13 +16,15 @@ namespace Remotely.Agent.Services
15
16
public class AppLauncherLinux : IAppLauncher
16
17
{
17
18
private readonly string _rcBinaryPath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "Desktop" , EnvironmentHelper . DesktopExecutableFileName ) ;
19
+ private readonly IProcessInvoker _processInvoker ;
20
+ private readonly ConnectionInfo _connectionInfo ;
18
21
19
- public AppLauncherLinux ( ConfigService configService )
22
+ public AppLauncherLinux ( ConfigService configService , IProcessInvoker processInvoker )
20
23
{
21
- ConnectionInfo = configService . GetConnectionInfo ( ) ;
24
+ _processInvoker = processInvoker ;
25
+ _connectionInfo = configService . GetConnectionInfo ( ) ;
22
26
}
23
27
24
- private ConnectionInfo ConnectionInfo { get ; }
25
28
26
29
public async Task < int > LaunchChatService ( string orgName , string requesterID , HubConnection hubConnection )
27
30
{
@@ -43,8 +46,8 @@ await hubConnection.SendAsync("DisplayMessage",
43
46
$ "-mode Chat " +
44
47
$ "-requester \" { requesterID } \" " +
45
48
$ "-organization \" { orgName } \" " +
46
- $ "-host \" { ConnectionInfo . Host } \" " +
47
- $ "-orgid \" { ConnectionInfo . OrganizationID } \" ";
49
+ $ "-host \" { _connectionInfo . Host } \" " +
50
+ $ "-orgid \" { _connectionInfo . OrganizationID } \" ";
48
51
return StartLinuxDesktopApp ( args ) ;
49
52
}
50
53
catch ( Exception ex )
@@ -76,9 +79,9 @@ await hubConnection.SendAsync("DisplayMessage",
76
79
$ "-mode Unattended " +
77
80
$ "-requester \" { requesterID } \" " +
78
81
$ "-serviceid \" { serviceID } \" " +
79
- $ "-deviceid { ConnectionInfo . DeviceID } " +
80
- $ "-host \" { ConnectionInfo . Host } \" " +
81
- $ "-orgid \" { ConnectionInfo . OrganizationID } \" ";
82
+ $ "-deviceid { _connectionInfo . DeviceID } " +
83
+ $ "-host \" { _connectionInfo . Host } \" " +
84
+ $ "-orgid \" { _connectionInfo . OrganizationID } \" ";
82
85
StartLinuxDesktopApp ( args ) ;
83
86
}
84
87
catch ( Exception ex )
@@ -96,9 +99,9 @@ public async Task RestartScreenCaster(List<string> viewerIDs, string serviceID,
96
99
$ "-mode Unattended " +
97
100
$ "-requester \" { requesterID } \" " +
98
101
$ "-serviceid \" { serviceID } \" " +
99
- $ "-deviceid { ConnectionInfo . DeviceID } " +
100
- $ "-host \" { ConnectionInfo . Host } \" " +
101
- $ "-orgid \" { ConnectionInfo . OrganizationID } \" " +
102
+ $ "-deviceid { _connectionInfo . DeviceID } " +
103
+ $ "-host \" { _connectionInfo . Host } \" " +
104
+ $ "-orgid \" { _connectionInfo . OrganizationID } \" " +
102
105
$ "-relaunch true " +
103
106
$ "-viewers { string . Join ( "," , viewerIDs ) } ";
104
107
StartLinuxDesktopApp ( args ) ;
@@ -116,7 +119,7 @@ private int StartLinuxDesktopApp(string args)
116
119
var xauthority = GetXorgAuth ( ) ;
117
120
118
121
var display = ":0" ;
119
- var whoString = EnvironmentHelper . StartProcessWithResults ( "who" , "" ) ? . Trim ( ) ;
122
+ var whoString = _processInvoker . InvokeProcessOutput ( "who" , "" ) ? . Trim ( ) ;
120
123
var username = "" ;
121
124
122
125
if ( ! string . IsNullOrWhiteSpace ( whoString ) )
@@ -155,7 +158,7 @@ private string GetXorgAuth()
155
158
{
156
159
try
157
160
{
158
- var processes = EnvironmentHelper . StartProcessWithResults ( "ps" , "-eaf" ) ? . Split ( Environment . NewLine ) ;
161
+ var processes = _processInvoker . InvokeProcessOutput ( "ps" , "-eaf" ) ? . Split ( Environment . NewLine ) ;
159
162
if ( processes ? . Length > 0 )
160
163
{
161
164
var xorgLine = processes . FirstOrDefault ( x => x . Contains ( "xorg" , StringComparison . OrdinalIgnoreCase ) ) ;
0 commit comments