Skip to content

Commit

Permalink
feat(pedm): initial integration of new desktop agent (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
thenextman authored Nov 6, 2024
1 parent 10aae47 commit eb25d99
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 144 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ jobs:
echo "dagent-package=$DAgentPackage" >> $Env:GITHUB_OUTPUT
$DAgentPedmDesktopExecutable = Join-Path $TargetOutputPath "DevolutionsPedmDesktop.exe"
echo "dagent-pedm-desktop-executable=$DAgentPedmDesktopExecutable" >> $Env:GITHUB_OUTPUT
$DAgentDesktopAgentOutputPath = Join-Path $TargetOutputPath "DesktopAgent"
echo "dagent-desktop-agent-output-path=$DAgentDesktopAgentOutputPath" >> $Env:GITHUB_OUTPUT
$DAgentPedmShellExtDll = Join-Path $TargetOutputPath "DevolutionsPedmShellExt.dll"
echo "dagent-pedm-shell-ext-dll=$DAgentPedmShellExtDll" >> $Env:GITHUB_OUTPUT
Expand Down Expand Up @@ -648,7 +648,7 @@ jobs:
CARGO_PACKAGE: devolutions-agent
run: |
if ($Env:RUNNER_OS -eq "Windows") {
$Env:DAGENT_PEDM_DESKTOP_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-pedm-desktop-executable }}"
$Env:DAGENT_DESKTOP_AGENT_OUTPUT_PATH = "${{ steps.load-variables.outputs.dagent-desktop-agent-output-path }}"
$Env:DAGENT_PEDM_SHELL_EXT_DLL = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-dll }}"
$Env:DAGENT_PEDM_SHELL_EXT_MSIX = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-msix }}"
$Env:DAGENT_SESSION_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-session-executable }}"
Expand All @@ -665,7 +665,7 @@ jobs:
run: |
if ($Env:RUNNER_OS -eq "Windows") {
$Env:DAGENT_PACKAGE = "${{ steps.load-variables.outputs.dagent-package }}"
$Env:DAGENT_PEDM_DESKTOP_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-pedm-desktop-executable }}"
$Env:DAGENT_DESKTOP_AGENT_OUTPUT_PATH = "${{ steps.load-variables.outputs.dagent-desktop-agent-output-path }}"
$Env:DAGENT_PEDM_SHELL_EXT_DLL = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-dll }}"
$Env:DAGENT_PEDM_SHELL_EXT_MSIX = "${{ steps.load-variables.outputs.dagent-pedm-shell-ext-msix }}"
$Env:DAGENT_SESSION_EXECUTABLE = "${{ steps.load-variables.outputs.dagent-session-executable }}"
Expand Down
26 changes: 11 additions & 15 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ jobs:
$IncludePattern = switch ('${{ matrix.project }}') {
'devolutions-gateway' { 'DevolutionsGateway_*.exe' }
'devolutions-agent' { 'DevolutionsAgent_*.exe', 'DevolutionsPedmShellExt.dll',
'DevolutionsPedmShellExt.msix', 'DevolutionsPedmDesktop.exe' }
'DevolutionsPedmShellExt.msix', 'DevolutionsDesktopAgent.exe' }
'jetsocat' { 'jetsocat_*' }
}
$ExcludePattern = "*.pdb"
Expand Down Expand Up @@ -300,6 +300,15 @@ jobs:
name: native-libs
path: native-libs

- name: Zip debug symbol files
if: matrix.project == 'devolutions-agent' && matrix.os == 'windows'
shell: pwsh
run: |
$PackageRoot = Join-Path ${{ runner.temp }} ${{ matrix.project}}
Get-ChildItem "$PackageRoot\windows\x86_64\*.pdb" -Recurse | Compress-Archive -DestinationPath "$PackageRoot\windows\x86_64\DevolutionsAgent-x86_64-${{ needs.preflight.outputs.version }}.symbols.zip" -CompressionLevel Optimal
Get-ChildItem "$PackageRoot\windows\x86_64\*.pdb" -Recurse | Remove-Item | Out-Null
- name: Regenerate Gateway MSI
if: matrix.project == 'devolutions-gateway' && matrix.os == 'windows'
shell: pwsh
Expand All @@ -322,7 +331,7 @@ jobs:
run: |
$PackageRoot = Join-Path ${{ runner.temp }} ${{ matrix.project}}
$Env:DAGENT_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include '*DevolutionsAgent*.exe' | Select -First 1
$Env:DAGENT_PEDM_DESKTOP_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include 'DevolutionsPedmDesktop.exe' | Select -First 1
$Env:DAGENT_DESKTOP_AGENT_OUTPUT_PATH = Join-Path $PackageRoot ${{ matrix.os }} x86_64 DesktopAgent
$Env:DAGENT_PEDM_SHELL_EXT_DLL = Get-ChildItem -Path $PackageRoot -Recurse -Include 'DevolutionsPedmShellExt.dll' | Select -First 1
$Env:DAGENT_PEDM_SHELL_EXT_MSIX = Get-ChildItem -Path $PackageRoot -Recurse -Include 'DevolutionsPedmShellExt.msix' | Select -First 1
$Env:DAGENT_SESSION_EXECUTABLE = Get-ChildItem -Path $PackageRoot -Recurse -Include 'DevolutionsSession.exe' | Select -First 1
Expand Down Expand Up @@ -426,19 +435,6 @@ jobs:
}
}
- name: Zip debug symbol files
if: matrix.project == 'devolutions-agent' && matrix.os == 'windows'
shell: pwsh
run: |
$PackageRoot = Join-Path ${{ runner.temp }} ${{ matrix.project}}
Get-ChildItem -Path $PackageRoot -Recurse
Compress-Archive "$PackageRoot\windows\x86_64\*.pdb" "$PackageRoot\windows\x86_64\DevolutionsAgent-x86_64-${{ needs.preflight.outputs.version }}.symbols.zip" -CompressionLevel Optimal
Remove-Item "$PackageRoot\windows\x86_64\*.pdb" | Out-Null
Get-ChildItem -Path $PackageRoot -Recurse
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
16 changes: 9 additions & 7 deletions ci/tlk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,17 @@ class TlkRecipe
}

if ($this.Product -Eq "agent" -And $this.Target.IsWindows()) {
& './crates/devolutions-pedm/DevolutionsPedmDesktop/build.ps1' | Out-Host
if (Test-Path Env:DAGENT_DESKTOP_AGENT_OUTPUT_PATH) {
& './dotnet/DesktopAgent/build.ps1' | Out-Host
$DesktopAgentOutputPath = $Env:DAGENT_DESKTOP_AGENT_OUTPUT_PATH
Remove-Item -Path "$DesktopAgentOutputPath" -Recurse -Force -ErrorAction SilentlyContinue
New-Item -Path "$DesktopAgentOutputPath" -ItemType 'Directory' -Force | Out-Null

if (Test-Path Env:DAGENT_PEDM_DESKTOP_EXECUTABLE) {
$builtDesktopExe = Get-ChildItem -Recurse -Include 'DevolutionsPedmDesktop.exe' | Select-Object -First 1
$builtDesktopPdb = Get-ChildItem -Recurse -Include 'DevolutionsPedmDesktop.pdb' | Select-Object -First 1

Copy-Item -Path $builtDesktopExe -Destination $Env:DAGENT_PEDM_DESKTOP_EXECUTABLE
Copy-Item -Path $builtDesktopPdb -Destination $(Get-DestinationSymbolFile $Env:DAGENT_PEDM_DESKTOP_EXECUTABLE $this.Target)
$BuiltDesktop = Get-ChildItem -Path "./dotnet/DesktopAgent/bin/Release/*" -Recurse -Include *.dll,*.exe,*.pdb

foreach ($File in $BuiltDesktop) {
Copy-Item $File.FullName -Destination $DesktopAgentOutputPath
}
}

if (Test-Path Env:DAGENT_SESSION_EXECUTABLE) {
Expand Down
9 changes: 9 additions & 0 deletions dotnet/DesktopAgent/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/env pwsh

$ErrorActionPreference = "Stop"

Push-Location -Path $PSScriptRoot

& 'MSBuild.exe' "/t:restore,build" "/p:Configuration=Release" | Out-Host

Pop-Location
29 changes: 16 additions & 13 deletions package/AgentWindowsManaged/Dialogs/FeaturesDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 16 additions & 33 deletions package/AgentWindowsManaged/Dialogs/FeaturesDialog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using DevolutionsAgent.Dialogs;
Expand Down Expand Up @@ -30,46 +29,24 @@ void FeaturesDialog_Load(object sender, System.EventArgs e)
if (drawTextOnlyProp.IsNotEmpty())
{
if (string.Compare(drawTextOnlyProp, "false", true) == 0)
{
drawTextOnly = false;
}
}
else
{
float dpi = CreateGraphics().DpiY;

if (dpi == 96) // the checkbox custom drawing is only compatible with 96 DPI
{
drawTextOnly = false;
}
}

ReadOnlyTreeNode.Behavior.AttachTo(featuresTree, drawTextOnly);

banner.Image = Runtime.Session.GetResourceBitmap("WixUI_Bmp_Banner");
BuildFeaturesHierarchy();

ResetLayout();
}

void ResetLayout()
{
// The form controls are properly anchored and will be correctly resized on parent form
// resizing. However the initial sizing by WinForm runtime doesn't a do good job with DPI
// other than 96. Thus manual resizing is the only reliable option apart from going WPF.

float ratio = (float)banner.Image.Width / (float)banner.Image.Height;
topPanel.Height = (int)(banner.Width / ratio);
topBorder.Top = topPanel.Height + 1;

var upShift = (int)(next.Height * 2.3) - bottomPanel.Height;
bottomPanel.Top -= upShift;
bottomPanel.Height += upShift;

middlePanel.Top = topBorder.Bottom + 5;
middlePanel.Height = (bottomPanel.Top - 5) - middlePanel.Top;

featuresTree.Width = (int)((middlePanel.Width / 3.0) * 1.75);

descriptionPanel.Left = featuresTree.Right + 10;
descriptionPanel.Width = middlePanel.Width - descriptionPanel.Left - 10;

featuresTree.Nodes[0].EnsureVisible();
}

/// <summary>
Expand All @@ -82,7 +59,7 @@ void ResetLayout()
/// </summary>
public static List<string> InitialUserSelectedItems { get; private set; }

void BuildFeaturesHierarchy()
private void BuildFeaturesHierarchy()
{
features = Runtime.Session.Features;

Expand Down Expand Up @@ -110,7 +87,9 @@ void BuildFeaturesHierarchy()
item.View = view;

if (item.Parent != null && item.Display != FeatureDisplay.hidden)
{
(item.Parent.View as TreeNode).Nodes.Add(view); //link child view to parent view
}

// even if the item is hidden process all its children so the correct hierarchy is established

Expand All @@ -123,10 +102,14 @@ void BuildFeaturesHierarchy()
});

if (UserSelectedItems != null)
{
view.Checked = UserSelectedItems.Contains((view.Tag as FeatureItem).Name);
}

if (item.Display == FeatureDisplay.expand)
{
view.Expand();
}
}

//add views to the treeView control
Expand All @@ -143,20 +126,20 @@ void BuildFeaturesHierarchy()
isAutoCheckingActive = true;
}

void SaveUserSelection()
private void SaveUserSelection()
{
UserSelectedItems = features.Where(x => x.IsViewChecked())
.Select(x => x.Name)
.OrderBy(x => x)
.ToList();
}

void featuresTree_AfterSelect(object sender, TreeViewEventArgs e)
private void featuresTree_AfterSelect(object sender, TreeViewEventArgs e)
{
description.Text = e.Node.FeatureItem().Description.LocalizeWith(Runtime.Localize);
}

void featuresTree_AfterCheck(object sender, TreeViewEventArgs e)
private void featuresTree_AfterCheck(object sender, TreeViewEventArgs e)
{
if (isAutoCheckingActive)
{
Expand Down Expand Up @@ -186,7 +169,7 @@ void featuresTree_AfterCheck(object sender, TreeViewEventArgs e)
}
}

void reset_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
private void reset_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
isAutoCheckingActive = false;
features.ForEach(f => f.ResetViewChecked());
Expand Down
Loading

0 comments on commit eb25d99

Please sign in to comment.