feat(postit): separate call interfaces from text chat
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
c36b7e02c6
commit
972b1a5cce
17 changed files with 379 additions and 130 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using Avalonia.Headless.XUnit;
|
||||
using Avalonia.Controls;
|
||||
using PostIt.Views.Chat;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.ViewModels.Chat;
|
||||
|
|
@ -89,6 +91,71 @@ public sealed class CallTransportRoutingTests
|
|||
while (!condition()) await Task.Delay(10, timeout.Token);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Selecting_a_room_member_prepares_both_transports_without_inviting()
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling);
|
||||
await using var webRtc = new WebRtcCallViewModel(signaling);
|
||||
var chat = new ChatViewModel(settings: new Settings())
|
||||
{
|
||||
LanCall = lan, VideoCall = webRtc, IsConnected = true, SelectedRoom = "General",
|
||||
FocusedUsers = new()
|
||||
};
|
||||
chat.FocusedUsers.Add("bob");
|
||||
Assert.False(chat.OpenCallCommand.CanExecute(null));
|
||||
chat.SelectedUser = "bob";
|
||||
Assert.True(chat.OpenCallCommand.CanExecute(null));
|
||||
var page = chat.PrepareCallPage();
|
||||
Assert.Same(chat, page.Chat);
|
||||
Assert.Equal("bob", lan.Target);
|
||||
Assert.Equal("bob", webRtc.Target);
|
||||
Assert.False(lan.Busy);
|
||||
Assert.False(webRtc.Busy);
|
||||
chat.FocusedUsers.Remove("bob");
|
||||
Assert.Null(chat.SelectedUser);
|
||||
Assert.False(chat.OpenCallCommand.CanExecute(null));
|
||||
chat.FocusedUsers.Add("bob");
|
||||
chat.SelectedUser = "bob";
|
||||
chat.SelectedRoom = "Other";
|
||||
Assert.Null(chat.SelectedUser);
|
||||
Assert.False(chat.OpenCallCommand.CanExecute(null));
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
[InlineData(CallTransports.LanSrtp)]
|
||||
[InlineData(CallTransports.WebRtc)]
|
||||
public async Task Leaving_text_chat_preserves_invitation_and_leaving_call_page_ends_it(string transport)
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling);
|
||||
await using var webRtc = new WebRtcCallViewModel(signaling);
|
||||
var chat = new ChatViewModel(settings: new Settings())
|
||||
{
|
||||
LanCall = lan, VideoCall = webRtc, IsConnected = true, SelectedRoom = "General",
|
||||
FocusedUsers = new()
|
||||
};
|
||||
var call = new CallSession(Guid.NewGuid(), "General", "alice", "bob", false,
|
||||
DateTimeOffset.UtcNow.AddMinutes(1), transport);
|
||||
signaling.Invite(call);
|
||||
await WaitAsync(() => lan.Incoming || webRtc.Incoming);
|
||||
Assert.True(chat.ShowCallCommand.CanExecute(null));
|
||||
var window = new Window { Content = new ChatPage { DataContext = chat } };
|
||||
try
|
||||
{
|
||||
window.Show();
|
||||
window.Content = new CallPage { DataContext = new CallPageViewModel(chat) };
|
||||
Assert.Empty(signaling.EndedCalls);
|
||||
Assert.True(lan.Incoming || webRtc.Incoming);
|
||||
window.Content = null;
|
||||
await WaitAsync(() => signaling.EndedCalls.Count != 0);
|
||||
Assert.Equal([call.Id], signaling.EndedCalls);
|
||||
Assert.False(lan.Busy);
|
||||
Assert.False(webRtc.Busy);
|
||||
}
|
||||
finally { window.Close(); }
|
||||
}
|
||||
|
||||
private sealed class Signaling : IWebRtcCallSignaling
|
||||
{
|
||||
public event Action<CallSession>? Invitation;
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ public static class ServiceCollectionHelpers
|
|||
AddReusablePage<ActivitiesPage>();
|
||||
services.AddTransient<CommandFormsPage>();
|
||||
services.AddTransient<ChatPage>();
|
||||
services.AddTransient<CallPage>();
|
||||
services.AddTransient<RdvPage>();
|
||||
services.AddTransient<BrushPage>();
|
||||
services.AddTransient<BillingQueriesPage>();
|
||||
|
|
|
|||
|
|
@ -7,5 +7,6 @@ namespace PostIt.ViewModels.Chat
|
|||
{
|
||||
public string? Name { get; set; }
|
||||
public List<string> Users { get; set; } = new();
|
||||
public List<string>? UserNames { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public class ViewLocator : IDataTemplate
|
|||
AdministrationPageViewModel => services.GetRequiredService<AdministrationPage>(),
|
||||
ResourceUsageReliefPageViewModel => services.GetRequiredService<ResourceUsageReliefPage>(),
|
||||
ChatViewModel => services.GetRequiredService<ChatPage>(),
|
||||
CallPageViewModel => services.GetRequiredService<CallPage>(),
|
||||
null => new TextBlock { Text = "No view for <null>" },
|
||||
_ => new TextBlock { Text = $"No view for {data.GetType().Name}" }
|
||||
};
|
||||
|
|
|
|||
12
src/PostIt/PostIt/ViewModels/Chat/CallPageViewModel.cs
Normal file
12
src/PostIt/PostIt/ViewModels/Chat/CallPageViewModel.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace PostIt.ViewModels.Chat;
|
||||
|
||||
public sealed class CallPageViewModel(ChatViewModel chat) : ViewModelBase
|
||||
{
|
||||
public ChatViewModel Chat { get; } = chat;
|
||||
public override bool CanNavigateNext { get; protected set; } = false;
|
||||
public override bool CanNavigatePrevious { get; protected set; } = true;
|
||||
|
||||
public Task HangupAsync() => Chat.HangupCallsAsync();
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
|
@ -63,11 +64,17 @@ namespace PostIt.ViewModels.Chat
|
|||
(OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid());
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(OpenCallCommand), nameof(ShowCallCommand))]
|
||||
public partial WebRtcCallViewModel? VideoCall { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(OpenCallCommand), nameof(ShowCallCommand))]
|
||||
public partial LanCallViewModel? LanCall { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(OpenCallCommand))]
|
||||
public partial string? SelectedUser { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string CurrentRoom { get; set; } = "General";
|
||||
|
||||
|
|
@ -79,6 +86,7 @@ namespace PostIt.ViewModels.Chat
|
|||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(SendMessageCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(OpenCallCommand), nameof(ShowCallCommand))]
|
||||
public partial bool IsConnected { get; set; } = false;
|
||||
|
||||
[ObservableProperty]
|
||||
|
|
@ -92,6 +100,7 @@ namespace PostIt.ViewModels.Chat
|
|||
// alors les notifications système.
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(SendMessageCommand))]
|
||||
[NotifyCanExecuteChangedFor(nameof(OpenCallCommand))]
|
||||
public partial string? SelectedRoom { get; set; }
|
||||
|
||||
// Notifications globales (connexion, erreurs de join, ...)
|
||||
|
|
@ -110,8 +119,39 @@ namespace PostIt.ViewModels.Chat
|
|||
[ObservableProperty]
|
||||
public partial ObservableCollection<string> FocusedUsers { get; set; } = _noUsers;
|
||||
|
||||
partial void OnFocusedUsersChanging(ObservableCollection<string> value) =>
|
||||
FocusedUsers.CollectionChanged -= OnFocusedUsersCollectionChanged;
|
||||
|
||||
partial void OnFocusedUsersChanged(ObservableCollection<string> value)
|
||||
{
|
||||
value.CollectionChanged += OnFocusedUsersCollectionChanged;
|
||||
OpenCallCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
|
||||
private void OnFocusedUsersCollectionChanged(object? sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
if (SelectedUser != null && !FocusedUsers.Contains(SelectedUser)) SelectedUser = null;
|
||||
OpenCallCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
|
||||
private void UpdateRoomUsers(string type, string room, string user)
|
||||
{
|
||||
if (!_usersByRoom.TryGetValue(room, out var users)) return;
|
||||
if (string.Equals(type, NotificationTypes.UserJoin, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (!users.Contains(user)) users.Add(user);
|
||||
}
|
||||
else if (string.Equals(type, NotificationTypes.UserPart, StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(type, NotificationTypes.Kick, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var separator = user.IndexOf(':');
|
||||
users.Remove(separator < 0 ? user : user[..separator]);
|
||||
}
|
||||
}
|
||||
|
||||
partial void OnSelectedRoomChanged(string? value)
|
||||
{
|
||||
SelectedUser = null;
|
||||
if (VideoCall != null) VideoCall.Room = value ?? "";
|
||||
if (LanCall != null) LanCall.Room = value ?? "";
|
||||
FocusedMessages = value != null && _messagesByRoom.TryGetValue(value, out var msgs)
|
||||
|
|
@ -120,6 +160,46 @@ namespace PostIt.ViewModels.Chat
|
|||
? users : _noUsers;
|
||||
}
|
||||
|
||||
private bool CanShowCall() => IsConnected && (VideoCall != null || LanCall != null);
|
||||
|
||||
private bool CanOpenCall() => CanShowCall() && SelectedRoom != null &&
|
||||
!string.IsNullOrWhiteSpace(SelectedUser) && FocusedUsers.Contains(SelectedUser);
|
||||
|
||||
internal CallPageViewModel PrepareCallPage()
|
||||
{
|
||||
if (!CanOpenCall())
|
||||
throw new InvalidOperationException("Selectionnez un utilisateur present dans le salon et connectez le chat.");
|
||||
if (VideoCall?.Busy != true && LanCall?.Busy != true)
|
||||
{
|
||||
if (VideoCall != null) VideoCall.Target = SelectedUser!;
|
||||
if (LanCall != null) LanCall.Target = SelectedUser!;
|
||||
}
|
||||
return new CallPageViewModel(this);
|
||||
}
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanOpenCall))]
|
||||
private Task OpenCallAsync() => NavigateToCallAsync(configureTarget: true);
|
||||
|
||||
[RelayCommand(CanExecute = nameof(CanShowCall))]
|
||||
private Task ShowCallAsync() => NavigateToCallAsync(configureTarget: false);
|
||||
|
||||
private async Task NavigateToCallAsync(bool configureTarget)
|
||||
{
|
||||
try
|
||||
{
|
||||
var app = App.Current as App ?? throw new InvalidOperationException("Application indisponible.");
|
||||
var page = configureTarget ? PrepareCallPage() : new CallPageViewModel(this);
|
||||
await app.PushPageAsync(page);
|
||||
}
|
||||
catch (Exception error) { Log($"Impossible d'ouvrir l'appel : {error.Message}"); }
|
||||
}
|
||||
|
||||
public async Task HangupCallsAsync()
|
||||
{
|
||||
if (VideoCall != null) await VideoCall.HangupAsync();
|
||||
if (LanCall != null) await LanCall.HangupAsync();
|
||||
}
|
||||
|
||||
// Trace une notification système dans la vue courante
|
||||
// (et dans le journal global pour consultation ultérieure).
|
||||
private void Log(string line)
|
||||
|
|
@ -167,8 +247,7 @@ namespace PostIt.ViewModels.Chat
|
|||
if (_transport == null || room == null) return;
|
||||
try
|
||||
{
|
||||
if (VideoCall != null) await VideoCall.HangupAsync();
|
||||
if (LanCall != null) await LanCall.HangupAsync();
|
||||
await HangupCallsAsync();
|
||||
await _transport.LeaveAsync(room);
|
||||
JoinedRooms.Remove(room);
|
||||
_messagesByRoom.Remove(room);
|
||||
|
|
@ -351,9 +430,7 @@ namespace PostIt.ViewModels.Chat
|
|||
roomLog.Add($"*{user} a interagi avec le salon {room} (Action: {type})");
|
||||
else
|
||||
Log($"*{user} a interagi avec le salon {room} (Action: {type})");
|
||||
if (type == "UserJoin" && _usersByRoom.TryGetValue(room, out var users)
|
||||
&& !users.Contains(user))
|
||||
users.Add(user);
|
||||
UpdateRoomUsers(type, room, user);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -422,7 +499,7 @@ namespace PostIt.ViewModels.Chat
|
|||
roomLog = _messagesByRoom[roomName] = new();
|
||||
roomLog.Add($"Salon rejoint avec succès : {roomName}");
|
||||
var users = _usersByRoom[roomName] = new();
|
||||
foreach (var u in roomInfo.Users) users.Add(u);
|
||||
foreach (var u in roomInfo.UserNames ?? roomInfo.Users) users.Add(u);
|
||||
if (!JoinedRooms.Contains(roomName))
|
||||
JoinedRooms.Add(roomName);
|
||||
SelectedRoom = roomName;
|
||||
|
|
|
|||
|
|
@ -251,6 +251,8 @@ public partial class LanCallViewModel : ObservableObject, IAsyncDisposable
|
|||
if (_call != null) throw new InvalidOperationException("Invitation concurrente inattendue.");
|
||||
if (call.RelayOnly) throw new InvalidOperationException("Le mode LAN ne peut pas masquer les adresses IP.");
|
||||
_call = call;
|
||||
Room = call.RoomName;
|
||||
Target = call.Caller;
|
||||
Busy = true;
|
||||
Incoming = true;
|
||||
Status = $"{call.Caller} propose un appel SRTP dans {call.RoomName}. Acceptez ou refusez.";
|
||||
|
|
|
|||
|
|
@ -168,6 +168,8 @@ public partial class WebRtcCallViewModel : ObservableObject, IAsyncDisposable
|
|||
return;
|
||||
}
|
||||
_call = call;
|
||||
Room = call.RoomName;
|
||||
Target = call.Caller;
|
||||
_caller = false;
|
||||
_callLifetime = CancellationTokenSource.CreateLinkedTokenSource(_lifetime.Token);
|
||||
Busy = Incoming = true;
|
||||
|
|
|
|||
101
src/PostIt/PostIt/Views/Chat/CallPage.axaml
Normal file
101
src/PostIt/PostIt/Views/Chat/CallPage.axaml
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<ContentPage
|
||||
x:Class="PostIt.Views.Chat.CallPage"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:PostIt.ViewModels.Chat"
|
||||
xmlns:services="using:PostIt.Services"
|
||||
x:DataType="vm:CallPageViewModel"
|
||||
Header="Appel audio-video">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
|
||||
<StackPanel Margin="16" Spacing="16">
|
||||
<TextBlock Text="Choisissez WebRTC ou SRTP direct. Les deux participants doivent etre presents dans le meme salon. Quitter cette page termine l'appel."
|
||||
TextWrapping="Wrap" />
|
||||
<StackPanel IsVisible="{Binding Chat.SupportsVideoCalls}">
|
||||
<TextBlock Text="Appel video WebRTC" FontSize="20" FontWeight="SemiBold" Margin="0,0,0,8" />
|
||||
<StackPanel DataContext="{Binding Chat.VideoCall}" x:DataType="vm:WebRtcCallViewModel"
|
||||
IsEnabled="{Binding $parent[ContentPage].((vm:CallPageViewModel)DataContext).Chat.IsConnected}" Spacing="8">
|
||||
<TextBlock Text="Android et Linux : medias chiffres par WebRTC (DTLS-SRTP), ICE/STUN/TURN. Activez le masquage IP dans votre profil pour imposer un relais TURN aux deux participants, sans repli direct. La camera et le microphone ne demarrent qu'apres acceptation."
|
||||
TextWrapping="Wrap" />
|
||||
<WrapPanel IsEnabled="{Binding CanConfigure}" IsVisible="{Binding !RemoteVideo}">
|
||||
<Button Content="Actualiser les peripheriques" Command="{Binding RefreshDevicesCommand}" Margin="0,0,8,4" />
|
||||
<ComboBox Width="190" ItemsSource="{Binding Cameras}" SelectedItem="{Binding Camera}"
|
||||
PlaceholderText="Camera" Margin="0,0,8,4">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:CaptureDevice">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<ComboBox Width="190" ItemsSource="{Binding Microphones}" SelectedItem="{Binding Microphone}"
|
||||
PlaceholderText="Microphone" Margin="0,0,8,4">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:CaptureDevice">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<TextBlock Text="{Binding Target}" VerticalAlignment="Center" Margin="0,0,8,4" />
|
||||
</WrapPanel>
|
||||
<CheckBox Content="Si le masquage IP est desactive, je consens a partager mon adresse IP avec le pair."
|
||||
IsChecked="{Binding AllowAddressDisclosure}" IsEnabled="{Binding CanConfigure}"
|
||||
IsVisible="{Binding !RemoteVideo}" />
|
||||
<WrapPanel>
|
||||
<Button Content="Appeler dans la salle active" Command="{Binding InviteCommand}" IsEnabled="{Binding !Busy}" Margin="0,0,8,4" />
|
||||
<Button Content="Accepter" Command="{Binding AcceptCommand}" IsEnabled="{Binding Incoming}" Margin="0,0,8,4" />
|
||||
<Button Content="Refuser / Raccrocher" Command="{Binding HangupCommand}" IsEnabled="{Binding Busy}" Margin="0,0,8,4" />
|
||||
</WrapPanel>
|
||||
<TextBlock Text="{Binding Status}" TextWrapping="Wrap" />
|
||||
<Grid ColumnDefinitions="*,2*" Height="280" IsVisible="{Binding !!RemoteVideo}">
|
||||
<ContentControl Content="{Binding LocalVideo}" Margin="0,0,8,0" />
|
||||
<ContentControl Grid.Column="1" Content="{Binding RemoteVideo}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel IsVisible="{Binding Chat.SupportsLanCalls}">
|
||||
<TextBlock Text="Appel direct IPv4/IPv6 SRTP (LAN/VPN ou IP publique)"
|
||||
FontSize="20" FontWeight="SemiBold" TextWrapping="Wrap" Margin="0,0,0,8" />
|
||||
<StackPanel DataContext="{Binding Chat.LanCall}" x:DataType="vm:LanCallViewModel"
|
||||
IsEnabled="{Binding $parent[ContentPage].((vm:CallPageViewModel)DataContext).Chat.IsConnected}" Spacing="8">
|
||||
<TextBlock Text="Connexion directe sans TURN ni traversee NAT : le pair connait votre IP. Le masquage IP doit etre desactive dans les profils des deux participants. Les medias sont chiffres par SRTP. Ouvrez le port UDP pair choisi et le suivant ; HTTPS est requis pour la signalisation. Casque recommande."
|
||||
TextWrapping="Wrap" />
|
||||
<WrapPanel IsEnabled="{Binding CanConfigure}" IsVisible="{Binding !RemoteVideo}">
|
||||
<Button Content="Actualiser les peripheriques" Command="{Binding RefreshDevicesCommand}" Margin="0,0,8,4" />
|
||||
<ComboBox Width="160" ItemsSource="{Binding Addresses}" SelectedItem="{Binding Address}"
|
||||
PlaceholderText="Adresse IPv4/IPv6 de cette machine" Margin="0,0,8,4" />
|
||||
<TextBox Width="80" Text="{Binding Port}" PlaceholderText="Port pair" Margin="0,0,8,4" />
|
||||
<ComboBox Width="190" ItemsSource="{Binding Cameras}" SelectedItem="{Binding Camera}"
|
||||
PlaceholderText="Camera" Margin="0,0,8,4">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:CaptureDevice">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<ComboBox Width="190" ItemsSource="{Binding Microphones}" SelectedItem="{Binding Microphone}"
|
||||
PlaceholderText="Microphone" Margin="0,0,8,4">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:CaptureDevice">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<TextBlock Text="{Binding Target}" VerticalAlignment="Center" Margin="0,0,8,4" />
|
||||
</WrapPanel>
|
||||
<CheckBox Content="Je consens a partager mon adresse IP avec le pair."
|
||||
IsChecked="{Binding AllowAddressDisclosure}" IsEnabled="{Binding CanConfigure}"
|
||||
IsVisible="{Binding !RemoteVideo}" />
|
||||
<WrapPanel>
|
||||
<Button Content="Appeler dans la salle active" Command="{Binding InviteCommand}" IsEnabled="{Binding !Busy}" Margin="0,0,8,4" />
|
||||
<Button Content="Accepter" Command="{Binding AcceptCommand}" IsEnabled="{Binding Incoming}" Margin="0,0,8,4" />
|
||||
<Button Content="Refuser / Raccrocher" Command="{Binding HangupCommand}" IsEnabled="{Binding Busy}" Margin="0,0,8,4" />
|
||||
</WrapPanel>
|
||||
<TextBlock Text="{Binding Status}" TextWrapping="Wrap" />
|
||||
<Grid ColumnDefinitions="*,2*" Height="280" IsVisible="{Binding !!RemoteVideo}">
|
||||
<ContentControl Content="{Binding LocalVideo}" Margin="0,0,8,0" />
|
||||
<ContentControl Grid.Column="1" Content="{Binding RemoteVideo}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</ContentPage>
|
||||
16
src/PostIt/PostIt/Views/Chat/CallPage.axaml.cs
Normal file
16
src/PostIt/PostIt/Views/Chat/CallPage.axaml.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using PostIt.ViewModels.Chat;
|
||||
|
||||
namespace PostIt.Views.Chat;
|
||||
|
||||
public partial class CallPage : ContentPage
|
||||
{
|
||||
public CallPage() => InitializeComponent();
|
||||
|
||||
protected override async void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnDetachedFromVisualTree(e);
|
||||
if (DataContext is CallPageViewModel call) await call.HangupAsync();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,15 +2,8 @@
|
|||
x:Class="PostIt.Views.Chat.ChatPage"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:md="using:MarkdownViewer.Core.Controls"
|
||||
xmlns:models="using:Yavsc.Blogspot"
|
||||
xmlns:postitControls="using:PostIt.Controls"
|
||||
xmlns:views="using:PostIt.Views.Chat"
|
||||
xmlns:vm="using:PostIt.ViewModels.Chat"
|
||||
xmlns:services="using:PostIt.Services"
|
||||
x:DataType="vm:ChatViewModel"
|
||||
>
|
||||
<Design.DataContext>
|
||||
|
|
@ -66,7 +59,7 @@
|
|||
Margin="10,0,0,0"
|
||||
BorderBrush="#E0E0E0"
|
||||
BorderThickness="1">
|
||||
<Grid RowDefinitions="Auto, *">
|
||||
<Grid RowDefinitions="Auto, *, Auto">
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="5"
|
||||
|
|
@ -76,7 +69,10 @@
|
|||
<ListBox
|
||||
Grid.Row="1"
|
||||
BorderThickness="0"
|
||||
ItemsSource="{Binding FocusedUsers}" />
|
||||
ItemsSource="{Binding FocusedUsers}"
|
||||
SelectedItem="{Binding SelectedUser}" />
|
||||
<Button Grid.Row="2" Margin="5" Content="Ouvrir l'appel"
|
||||
Command="{Binding OpenCallCommand}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
|
@ -104,99 +100,12 @@
|
|||
Content="Envoyer" />
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer Grid.Row="3" MaxHeight="520" Margin="0,0,0,8">
|
||||
<StackPanel>
|
||||
<TextBlock Text="Invitation WebRTC recue : ouvrez le panneau WebRTC pour repondre."
|
||||
IsVisible="{Binding VideoCall.Incoming}" TextWrapping="Wrap" />
|
||||
<TextBlock Text="Invitation SRTP directe recue : ouvrez le panneau d'appel direct pour repondre."
|
||||
IsVisible="{Binding LanCall.Incoming}" TextWrapping="Wrap" />
|
||||
<Expander Header="Appel video WebRTC" IsVisible="{Binding SupportsVideoCalls}" IsExpanded="True"
|
||||
IsEnabled="{Binding IsConnected}" Margin="0,0,0,8">
|
||||
<StackPanel DataContext="{Binding VideoCall}" x:DataType="vm:WebRtcCallViewModel" Spacing="8">
|
||||
<TextBlock Text="Android et Linux : medias chiffres par WebRTC (DTLS-SRTP), ICE/STUN/TURN. Activez le masquage IP dans votre profil pour imposer un relais TURN aux deux participants, sans repli direct. La camera et le microphone ne demarrent qu'apres acceptation."
|
||||
TextWrapping="Wrap" />
|
||||
<WrapPanel IsEnabled="{Binding CanConfigure}" IsVisible="{Binding !RemoteVideo}">
|
||||
<Button Content="Actualiser les peripheriques" Command="{Binding RefreshDevicesCommand}" Margin="0,0,8,4" />
|
||||
<ComboBox Width="190" ItemsSource="{Binding Cameras}" SelectedItem="{Binding Camera}"
|
||||
PlaceholderText="Camera" Margin="0,0,8,4">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:CaptureDevice">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<ComboBox Width="190" ItemsSource="{Binding Microphones}" SelectedItem="{Binding Microphone}"
|
||||
PlaceholderText="Microphone" Margin="0,0,8,4">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:CaptureDevice">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<TextBox Width="170" Text="{Binding Target}" PlaceholderText="Pseudo du pair" Margin="0,0,8,4" />
|
||||
</WrapPanel>
|
||||
<CheckBox Content="Si le masquage IP est desactive, je consens a partager mon adresse IP avec le pair."
|
||||
IsChecked="{Binding AllowAddressDisclosure}" IsEnabled="{Binding CanConfigure}"
|
||||
IsVisible="{Binding !RemoteVideo}" />
|
||||
<WrapPanel>
|
||||
<Button Content="Appeler dans la salle active" Command="{Binding InviteCommand}" IsEnabled="{Binding !Busy}" Margin="0,0,8,4" />
|
||||
<Button Content="Accepter" Command="{Binding AcceptCommand}" IsEnabled="{Binding Incoming}" Margin="0,0,8,4" />
|
||||
<Button Content="Refuser / Raccrocher" Command="{Binding HangupCommand}" IsEnabled="{Binding Busy}" Margin="0,0,8,4" />
|
||||
</WrapPanel>
|
||||
<TextBlock Text="{Binding Status}" TextWrapping="Wrap" />
|
||||
<Grid ColumnDefinitions="*,2*" Height="280" IsVisible="{Binding !!RemoteVideo}">
|
||||
<ContentControl Content="{Binding LocalVideo}" Margin="0,0,8,0" />
|
||||
<ContentControl Grid.Column="1" Content="{Binding RemoteVideo}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
|
||||
<Expander Header="Appel direct IPv4/IPv6 SRTP (LAN/VPN ou IP publique)"
|
||||
IsVisible="{Binding SupportsLanCalls}" IsExpanded="True"
|
||||
IsEnabled="{Binding IsConnected}">
|
||||
<StackPanel DataContext="{Binding LanCall}" x:DataType="vm:LanCallViewModel" Spacing="8">
|
||||
<TextBlock Text="Connexion directe sans TURN ni traversee NAT : le pair connait votre IP. Le masquage IP doit etre desactive dans les profils des deux participants. Les medias sont chiffres par SRTP. Ouvrez le port UDP pair choisi et le suivant ; HTTPS est requis pour la signalisation. Casque recommande."
|
||||
TextWrapping="Wrap" />
|
||||
<WrapPanel IsEnabled="{Binding CanConfigure}" IsVisible="{Binding !RemoteVideo}">
|
||||
<Button Content="Actualiser les peripheriques" Command="{Binding RefreshDevicesCommand}" Margin="0,0,8,4" />
|
||||
<ComboBox Width="160" ItemsSource="{Binding Addresses}" SelectedItem="{Binding Address}"
|
||||
PlaceholderText="Adresse IPv4/IPv6 de cette machine" Margin="0,0,8,4" />
|
||||
<TextBox Width="80" Text="{Binding Port}" PlaceholderText="Port pair" Margin="0,0,8,4" />
|
||||
<ComboBox Width="190" ItemsSource="{Binding Cameras}" SelectedItem="{Binding Camera}"
|
||||
PlaceholderText="Camera" Margin="0,0,8,4">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:CaptureDevice">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<ComboBox Width="190" ItemsSource="{Binding Microphones}" SelectedItem="{Binding Microphone}"
|
||||
PlaceholderText="Microphone" Margin="0,0,8,4">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="services:CaptureDevice">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<TextBox Width="170" Text="{Binding Target}" PlaceholderText="Pseudo du pair" Margin="0,0,8,4" />
|
||||
</WrapPanel>
|
||||
<CheckBox Content="Je consens a partager mon adresse IP avec le pair."
|
||||
IsChecked="{Binding AllowAddressDisclosure}" IsEnabled="{Binding CanConfigure}"
|
||||
IsVisible="{Binding !RemoteVideo}" />
|
||||
<WrapPanel>
|
||||
<Button Content="Appeler dans la salle active" Command="{Binding InviteCommand}" IsEnabled="{Binding !Busy}" Margin="0,0,8,4" />
|
||||
<Button Content="Accepter" Command="{Binding AcceptCommand}" IsEnabled="{Binding Incoming}" Margin="0,0,8,4" />
|
||||
<Button Content="Refuser / Raccrocher" Command="{Binding HangupCommand}" IsEnabled="{Binding Busy}" Margin="0,0,8,4" />
|
||||
</WrapPanel>
|
||||
<TextBlock Text="{Binding Status}" TextWrapping="Wrap" />
|
||||
<Grid ColumnDefinitions="*,2*" Height="280" IsVisible="{Binding !!RemoteVideo}">
|
||||
<ContentControl Content="{Binding LocalVideo}" Margin="0,0,8,0" />
|
||||
<ContentControl Grid.Column="1" Content="{Binding RemoteVideo}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Expander>
|
||||
<StackPanel Grid.Row="3" Margin="0,0,0,8" Spacing="4">
|
||||
<Button Content="Repondre a l'invitation WebRTC" Command="{Binding ShowCallCommand}"
|
||||
IsVisible="{Binding VideoCall.Incoming}" />
|
||||
<Button Content="Repondre a l'invitation SRTP directe" Command="{Binding ShowCallCommand}"
|
||||
IsVisible="{Binding LanCall.Incoming}" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
<postitControls:StatusBar
|
||||
x:Name="StatusBar"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using PostIt.ViewModels.Chat;
|
||||
namespace PostIt.Views.Chat;
|
||||
public partial class ChatPage : ContentPage
|
||||
{
|
||||
|
|
@ -9,14 +7,4 @@ public partial class ChatPage : ContentPage
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override async void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnDetachedFromVisualTree(e);
|
||||
if (DataContext is ChatViewModel chat)
|
||||
{
|
||||
if (chat.VideoCall is { } video) await video.HangupAsync();
|
||||
if (chat.LanCall is { } lan) await lan.HangupAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue