Archive meeting workflow and screenshot changes

This commit is contained in:
2026-05-27 12:55:19 +02:00
parent 2422236ef7
commit 12832dde84
48 changed files with 3041 additions and 43 deletions
+63 -13
View File
@@ -13,7 +13,7 @@ public sealed class GlobalHotkeyService : BackgroundService
private readonly ILaunchProfileOptionsProvider launchProfiles;
private readonly MeetingRecordingCoordinator coordinator;
private readonly ILogger<GlobalHotkeyService> logger;
private readonly Dictionary<int, string> hotkeyProfiles = [];
private readonly Dictionary<int, LaunchProfileHotkey> registeredHotkeys = [];
private TaskCompletionSource? messageLoopCompletion;
private uint messageThreadId;
@@ -66,42 +66,44 @@ public sealed class GlobalHotkeyService : BackgroundService
for (var index = 0; index < hotkeys.Count; index++)
{
var profileHotkey = hotkeys[index];
var hotkey = HotkeyDefinition.Parse(profileHotkey.Toggle);
var hotkey = HotkeyDefinition.Parse(profileHotkey.Hotkey);
var hotkeyId = HotkeyIdBase + index;
if (!RegisterHotKey(IntPtr.Zero, hotkeyId, (uint)hotkey.Modifiers, hotkey.VirtualKey))
{
logger.LogWarning(
"Could not register global hotkey {Hotkey} for launch profile {LaunchProfile}",
profileHotkey.Toggle,
profileHotkey.ProfileName);
"Could not register global hotkey {Hotkey} for launch profile {LaunchProfile} action {Action}",
profileHotkey.Hotkey,
profileHotkey.ProfileName,
profileHotkey.Action);
continue;
}
hotkeyProfiles[hotkeyId] = profileHotkey.ProfileName;
registeredHotkeys[hotkeyId] = profileHotkey;
logger.LogInformation(
"Registered global hotkey {Hotkey} for launch profile {LaunchProfile}",
profileHotkey.Toggle,
profileHotkey.ProfileName);
"Registered global hotkey {Hotkey} for launch profile {LaunchProfile} action {Action}",
profileHotkey.Hotkey,
profileHotkey.ProfileName,
profileHotkey.Action);
}
try
{
while (!stoppingToken.IsCancellationRequested && GetMessage(out var message, IntPtr.Zero, 0, 0) > 0)
{
if (message.Message == WmHotkey && hotkeyProfiles.TryGetValue((int)message.WParam, out var profileName))
if (message.Message == WmHotkey && registeredHotkeys.TryGetValue((int)message.WParam, out var hotkey))
{
_ = Task.Run(() => ToggleRecordingAsync(profileName), CancellationToken.None);
_ = Task.Run(() => HandleHotkeyAsync(hotkey), CancellationToken.None);
}
}
}
finally
{
foreach (var hotkeyId in hotkeyProfiles.Keys)
foreach (var hotkeyId in registeredHotkeys.Keys)
{
UnregisterHotKey(IntPtr.Zero, hotkeyId);
}
hotkeyProfiles.Clear();
registeredHotkeys.Clear();
messageThreadId = 0;
}
}
@@ -112,6 +114,22 @@ public sealed class GlobalHotkeyService : BackgroundService
return base.StopAsync(cancellationToken);
}
private async Task HandleHotkeyAsync(LaunchProfileHotkey hotkey)
{
switch (hotkey.Action)
{
case LaunchProfileHotkeyAction.ToggleRecording:
await ToggleRecordingAsync(hotkey.ProfileName);
break;
case LaunchProfileHotkeyAction.AbortRecording:
await AbortRecordingAsync(hotkey.ProfileName);
break;
case LaunchProfileHotkeyAction.CaptureScreenshot:
await CaptureScreenshotAsync(hotkey.ProfileName);
break;
}
}
private async Task ToggleRecordingAsync(string profileName)
{
try
@@ -128,6 +146,38 @@ public sealed class GlobalHotkeyService : BackgroundService
}
}
private async Task AbortRecordingAsync(string profileName)
{
try
{
var status = await coordinator.AbortAsync(CancellationToken.None);
logger.LogInformation(
"Hotkey aborted recording for launch profile {LaunchProfile}. IsRecording={IsRecording}",
profileName,
status.IsRecording);
}
catch (Exception exception)
{
logger.LogError(exception, "Hotkey abort failed");
}
}
private async Task CaptureScreenshotAsync(string profileName)
{
try
{
var result = await coordinator.CaptureScreenshotAsync(profileName, CancellationToken.None);
logger.LogInformation(
"Hotkey captured screenshot for launch profile {LaunchProfile}: {ScreenshotPath}",
profileName,
result.ScreenshotPath);
}
catch (Exception exception)
{
logger.LogError(exception, "Hotkey screenshot capture failed");
}
}
private void PostQuitToMessageThread()
{
var threadId = messageThreadId;