1- // Copyright 2021 Ammo Goettsch
1+ // Copyright 2021 Helios Contributors
22//
33// HeliosFalcon is free software: you can redistribute it and/or modify
44// it under the terms of the GNU General Public License as published by
4848- on status report
4949 - if disabled due to no magic cookie on load, show special status asking to enable for consent
5050 - show configuration that will be generated
51- - warn if profile wants to start/stop RTT but global policy disallows it
51+ - error if profile wants to start/stop RTT but global policy disallows it
5252- on ready check
5353 - make sure falcon interface is configured
5454 - make sure file either does not exist or is helios owned
55- - make sure process control we plan to use is actually permitted (warn or error if start/stop is configurable)
55+ - error if profile wants to start/stop RTT but global policy disallows it
5656- on profile start
5757 - refuse to overwrite non-Helios file
5858 - launch RTT process
@@ -218,7 +218,7 @@ internal IEnumerable<StatusReportItem> OnStatusReport(IEnumerable<ShadowVisual>
218218 Status =
219219 "RTT feature has been disabled, because an existing RTT configuration would be overwritten by this profile" ,
220220 Recommendation =
221- "Enable the RTT feature again to back up the existing file and let Helios to generate RTT displays"
221+ "Enable the RTT feature again to back up the existing file and let Helios generate RTT displays"
222222 } . AsReport ( ) ;
223223 }
224224
@@ -227,7 +227,17 @@ internal IEnumerable<StatusReportItem> OnStatusReport(IEnumerable<ShadowVisual>
227227 return new StatusReportItem [ 0 ] ;
228228 }
229229
230- // REVISIT: for now, we show the whole generated file
230+ // gather status from child objects, if any
231+ IEnumerable < StatusReportItem > processControlReport =
232+ ProcessControl ? . OnStatusReport ( ) ?? new StatusReportItem [ 0 ] ;
233+
234+ return processControlReport
235+ . Concat ( ReportLInes ( ) ) ;
236+ }
237+
238+ private IEnumerable < StatusReportItem > ReportLInes ( )
239+ {
240+ // we show the whole generated file, so it will be in the interface status report
231241 return _lines
232242 . Select ( line => new StatusReportItem
233243 {
@@ -309,21 +319,49 @@ internal void OnInteractivelyEnabled(CheckBox source)
309319 }
310320
311321 /// <summary>
312- /// create a single ready check item for our parent's ReadyCheck
322+ /// create a ready check items for our parent's ReadyCheck
313323 /// </summary>
314324 /// <returns></returns>
315- internal StatusReportItem OnReadyCheck ( )
325+ internal IEnumerable < StatusReportItem > OnReadyCheck ( )
316326 {
327+ if ( DisabledUntilConsent )
328+ {
329+ yield return new StatusReportItem
330+ {
331+ Severity = StatusReportItem . SeverityCode . Error ,
332+ Status =
333+ "RTT feature has been disabled, because an existing RTT configuration would be overwritten by this profile" ,
334+ Link = StatusReportItem . ProfileEditor ,
335+ Recommendation =
336+ "Enable the RTT feature again to back up the existing file and let Helios generate RTT displays"
337+ } ;
338+ yield break ;
339+ }
340+
317341 if ( ! Enabled )
318342 {
319- return new StatusReportItem
343+ yield return new StatusReportItem
320344 {
321345 Status = "RTT client configuration feature is not enabled" ,
322346 Flags = StatusReportItem . StatusFlags . ConfigurationUpToDate | StatusReportItem . StatusFlags . Verbose
323347
324348 } ;
349+ yield break ;
350+ }
351+
352+ yield return CheckConfigFile ( ) ;
353+
354+ if ( ProcessControl != null )
355+ {
356+ foreach ( StatusReportItem statusReportItem in ProcessControl . OnReadyCheck ( ) )
357+ {
358+ yield return statusReportItem ;
359+ }
325360 }
361+ }
326362
363+ private StatusReportItem CheckConfigFile ( )
364+ {
327365 if ( string . IsNullOrEmpty ( Parent . FalconPath ) )
328366 {
329367 return new StatusReportItem
@@ -388,8 +426,6 @@ internal StatusReportItem OnReadyCheck()
388426
389427 internal void OnProfileStart ( )
390428 {
391- StartedProcess = false ;
392-
393429 // check for Helios ownership of the RTT file and if it is ours, write the RTT configuration for the current profile,
394430 // which may not be the most recent one we configured in Profile Editor
395431 if ( ! UpdateRttConfigurationFile ( ) )
@@ -398,27 +434,12 @@ internal void OnProfileStart()
398434 return ;
399435 }
400436
401- if ( ProcessControl ? . StartRtt ?? false )
402- {
403- // launch RTT
404- string selectedClient = ProcessControl . SelectClient ( Networked ) ;
405- StartedProcess =
406- ProcessControl . StartRTTClient ( Path . Combine ( Parent . FalconPath , "Tools" , "RTTRemote" , selectedClient ) ) ;
407- Logger . Info ( $ "launching RTT client: { selectedClient } ") ;
408- }
437+ ProcessControl ? . OnProfileStart ( Parent , Networked ) ;
409438 }
410439
411440 internal void OnProfileStop ( )
412441 {
413- if ( ! StartedProcess )
414- {
415- return ;
416- }
417-
418- if ( ProcessControl ? . StopRtt ?? false )
419- {
420- ProcessControl . KillRTTCllient ( Path . GetFileNameWithoutExtension ( ProcessControl . SelectClient ( Networked ) ) ) ;
421- }
442+ ProcessControl ? . OnProfileStop ( Parent , Networked ) ;
422443 }
423444
424445 /// <summary>
@@ -816,12 +837,6 @@ public ICommand EnabledCommand
816837 [ XmlIgnore ]
817838 public IRttGeneratorHost Parent { get ; internal set ; }
818839
819- /// <summary>
820- /// if true, we started RTT process on this run
821- /// </summary>
822- [ XmlIgnore ]
823- public bool StartedProcess { get ; private set ; }
824-
825840 #endregion
826841
827842 /// <summary>
0 commit comments