feat(postit): restore direct calls and list contacts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
e35cc5a87f
commit
c36b7e02c6
16 changed files with 438 additions and 55 deletions
115
src/PostIt/PostIt.Tests/CallTransportRoutingTests.cs
Normal file
115
src/PostIt/PostIt.Tests/CallTransportRoutingTests.cs
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
using Avalonia.Headless.XUnit;
|
||||
using PostIt.Services;
|
||||
using PostIt.ViewModels;
|
||||
using PostIt.ViewModels.Chat;
|
||||
using Yavsc.Abstract.Chat.Calls;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class CallTransportRoutingTests
|
||||
{
|
||||
[AvaloniaTheory]
|
||||
[InlineData(CallTransports.LanSrtp)]
|
||||
[InlineData(CallTransports.WebRtc)]
|
||||
public async Task Incoming_calls_are_handled_only_by_the_matching_transport(string transport)
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling);
|
||||
await using var webRtc = new WebRtcCallViewModel(signaling);
|
||||
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.Equal(transport == CallTransports.LanSrtp, lan.Incoming);
|
||||
Assert.Equal(transport == CallTransports.WebRtc, webRtc.Incoming);
|
||||
Assert.Empty(signaling.EndedCalls);
|
||||
|
||||
if (lan.Incoming) await lan.HangupAsync();
|
||||
else await webRtc.HangupAsync();
|
||||
Assert.Equal([call.Id], signaling.EndedCalls);
|
||||
Assert.False(lan.Busy);
|
||||
Assert.False(webRtc.Busy);
|
||||
}
|
||||
|
||||
[AvaloniaFact]
|
||||
public async Task Unknown_transport_is_rejected_once_without_starting_either_call()
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
await using var lan = new LanCallViewModel(signaling);
|
||||
await using var webRtc = new WebRtcCallViewModel(signaling);
|
||||
var call = new CallSession(Guid.NewGuid(), "General", "alice", "bob", false,
|
||||
DateTimeOffset.UtcNow.AddMinutes(1), "unknown");
|
||||
|
||||
signaling.Invite(call);
|
||||
await WaitAsync(() => signaling.EndedCalls.Count != 0);
|
||||
|
||||
Assert.Equal([call.Id], signaling.EndedCalls);
|
||||
Assert.False(lan.Busy);
|
||||
Assert.False(webRtc.Busy);
|
||||
}
|
||||
|
||||
[AvaloniaTheory]
|
||||
[InlineData(CallTransports.LanSrtp)]
|
||||
[InlineData(CallTransports.WebRtc)]
|
||||
public async Task Chat_updates_both_rooms_and_disconnects_the_active_transport(string transport)
|
||||
{
|
||||
var signaling = new Signaling();
|
||||
var chat = new ChatViewModel(settings: new Settings());
|
||||
var lan = new LanCallViewModel(signaling);
|
||||
var webRtc = new WebRtcCallViewModel(signaling);
|
||||
chat.LanCall = lan;
|
||||
chat.VideoCall = webRtc;
|
||||
chat.SelectedRoom = "General";
|
||||
Assert.Equal("General", lan.Room);
|
||||
Assert.Equal("General", webRtc.Room);
|
||||
|
||||
var call = new CallSession(Guid.NewGuid(), "General", "alice", "bob", false,
|
||||
DateTimeOffset.UtcNow.AddMinutes(1), transport);
|
||||
signaling.Invite(call);
|
||||
await WaitAsync(() => lan.Incoming || webRtc.Incoming);
|
||||
await chat.DisconnectAsync();
|
||||
|
||||
Assert.Equal([call.Id], signaling.EndedCalls);
|
||||
Assert.Null(chat.LanCall);
|
||||
Assert.Null(chat.VideoCall);
|
||||
Assert.False(lan.Busy);
|
||||
Assert.False(webRtc.Busy);
|
||||
signaling.Invite(call);
|
||||
Assert.False(lan.Incoming);
|
||||
Assert.False(webRtc.Incoming);
|
||||
}
|
||||
|
||||
private static async Task WaitAsync(Func<bool> condition)
|
||||
{
|
||||
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(TestContext.Current.CancellationToken);
|
||||
timeout.CancelAfter(TimeSpan.FromSeconds(5));
|
||||
while (!condition()) await Task.Delay(10, timeout.Token);
|
||||
}
|
||||
|
||||
private sealed class Signaling : IWebRtcCallSignaling
|
||||
{
|
||||
public event Action<CallSession>? Invitation;
|
||||
public event Action<CallAccepted>? Accepted;
|
||||
public event Action<CallEnded>? Ended;
|
||||
public event Action<Guid, CallSignal>? Signal;
|
||||
public event Action? Interrupted;
|
||||
public List<Guid> EndedCalls { get; } = [];
|
||||
|
||||
public void Invite(CallSession call) => Invitation?.Invoke(call);
|
||||
public Task<CallSession> InviteAsync(string room, string user, CancellationToken ct = default) =>
|
||||
throw new NotSupportedException();
|
||||
public Task<CallSession> InviteLanAsync(string room, string user, CancellationToken ct = default) =>
|
||||
throw new NotSupportedException();
|
||||
public Task AcceptAsync(Guid callId, CancellationToken ct = default) => throw new NotSupportedException();
|
||||
public Task EndAsync(Guid callId, CancellationToken ct = default)
|
||||
{
|
||||
EndedCalls.Add(callId);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public Task SendAsync(Guid callId, CallSignal signal, CancellationToken ct = default) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
61
src/PostIt/PostIt.Tests/ContactsPageViewModelTests.cs
Normal file
61
src/PostIt/PostIt.Tests/ContactsPageViewModelTests.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using PostIt.ViewModels;
|
||||
using Yavsc.Api.Client;
|
||||
|
||||
namespace PostIt.Tests;
|
||||
|
||||
[Trait("Category", "non-reg")]
|
||||
public sealed class ContactsPageViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Contacts_are_deduplicated_and_show_all_their_circles()
|
||||
{
|
||||
await using var api = new FakeApi();
|
||||
var vm = new ContactsPageViewModel(new CircleApiClient(api, "https://example.test/"));
|
||||
await vm.RefreshAsync();
|
||||
var contact = Assert.Single(vm.Contacts);
|
||||
Assert.Equal("bob-id", contact.Id);
|
||||
Assert.Equal("Bob", contact.DisplayName);
|
||||
Assert.Equal("Amis, Travail", contact.Circles);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Missing_circle_is_reported_instead_of_showing_incomplete_contacts()
|
||||
{
|
||||
await using var api = new FakeApi { MissingCircle = true };
|
||||
var vm = new ContactsPageViewModel(new CircleApiClient(api, "https://example.test/"));
|
||||
await vm.RefreshAsync();
|
||||
Assert.Empty(vm.Contacts);
|
||||
Assert.Contains("n'est plus disponible", vm.Status);
|
||||
Assert.False(vm.IsBusy);
|
||||
}
|
||||
|
||||
private sealed class FakeApi : IYavscApiClient
|
||||
{
|
||||
public HttpClient Http { get; } = new();
|
||||
public bool MissingCircle { get; init; }
|
||||
|
||||
public Task<T> CallAsync<T>(HttpMethod method, string path, object? body = null, CancellationToken ct = default)
|
||||
{
|
||||
string json = path switch
|
||||
{
|
||||
"circle" => """[{"id":1,"name":"Travail"},{"id":2,"name":"Amis"}]""",
|
||||
"circle/1/members" => """[{"id":"bob-id","userName":"bob","fullName":"Bob"}]""",
|
||||
"circle/2/members" when MissingCircle => "null",
|
||||
"circle/2/members" => """[{"id":"bob-id","userName":"bob","fullName":"Bob"}]""",
|
||||
_ => throw new HttpRequestException("Unexpected path", null, HttpStatusCode.NotFound)
|
||||
};
|
||||
return Task.FromResult(JsonSerializer.Deserialize<T>(json,
|
||||
new JsonSerializerOptions { PropertyNameCaseInsensitive = true })!);
|
||||
}
|
||||
|
||||
public Task<T> CallAsync<T>(HttpMethod method, string path, Func<HttpContent> contentFactory, CancellationToken ct = default) =>
|
||||
throw new NotSupportedException();
|
||||
public Task CallAsync(HttpMethod method, string path, object? body = null, CancellationToken ct = default) =>
|
||||
throw new NotSupportedException();
|
||||
public Task CallAsync(HttpMethod method, string path, Func<HttpContent> contentFactory, CancellationToken ct = default) =>
|
||||
throw new NotSupportedException();
|
||||
public ValueTask DisposeAsync() { Http.Dispose(); return ValueTask.CompletedTask; }
|
||||
}
|
||||
}
|
||||
|
|
@ -81,6 +81,7 @@ public static class ServiceCollectionHelpers
|
|||
AddReusablePage<HomePage>();
|
||||
AddReusablePage<SignaturePage>();
|
||||
AddReusablePage<CirclesPage>();
|
||||
services.AddTransient<ContactsPage>();
|
||||
AddReusablePage<ActivitiesPage>();
|
||||
services.AddTransient<CommandFormsPage>();
|
||||
services.AddTransient<ChatPage>();
|
||||
|
|
@ -129,6 +130,7 @@ public static class ServiceCollectionHelpers
|
|||
services.AddTransient<ResourceUsageReliefPageViewModel>();
|
||||
services.AddSingleton<SignaturePageViewModel>();
|
||||
services.AddSingleton<CirclesPageViewModel>();
|
||||
services.AddTransient<ContactsPageViewModel>();
|
||||
services.AddSingleton<ActivitiesPageViewModel>();
|
||||
services.AddTransient<SelectableHairPrestationItem>();
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public class ViewLocator : IDataTemplate
|
|||
AddCircleMemberDialogViewModel => services.GetRequiredService<AddCircleMemberDialog>(),
|
||||
ConfirmationDialogViewModel => services.GetRequiredService<ConfirmationDialog>(),
|
||||
CirclesPageViewModel => services.GetRequiredService<CirclesPage>(),
|
||||
ContactsPageViewModel => services.GetRequiredService<ContactsPage>(),
|
||||
PostAclDialogViewModel => services.GetRequiredService<PostAclDialog>(),
|
||||
BillingQueriesPageViewModel => services.GetRequiredService<BillingQueriesPage>(),
|
||||
BillingQueryDetailsPageViewModel => services.GetRequiredService<BillingQueryDetailsPage>(),
|
||||
|
|
|
|||
66
src/PostIt/PostIt/ViewModels/ACL/ContactsPageViewModel.cs
Normal file
66
src/PostIt/PostIt/ViewModels/ACL/ContactsPageViewModel.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Yavsc.Api.Client;
|
||||
using Yavsc.Api.Client.Dtos;
|
||||
|
||||
namespace PostIt.ViewModels;
|
||||
|
||||
public sealed record ContactEntry(string Id, string UserName, string DisplayName, string Circles);
|
||||
|
||||
public partial class ContactsPageViewModel(CircleApiClient client) : ViewModelBase
|
||||
{
|
||||
public ObservableCollection<ContactEntry> Contacts { get; } = [];
|
||||
|
||||
[ObservableProperty]
|
||||
public partial bool IsBusy { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string Status { get; set; } = "Pret.";
|
||||
|
||||
public override bool CanNavigateNext { get; protected set; } = false;
|
||||
public override bool CanNavigatePrevious { get; protected set; } = true;
|
||||
|
||||
[RelayCommand]
|
||||
public async Task RefreshAsync()
|
||||
{
|
||||
IsBusy = true;
|
||||
try
|
||||
{
|
||||
var circles = await client.GetMyCirclesAsync()
|
||||
?? throw new InvalidOperationException("Le serveur n'a pas renvoye les cercles.");
|
||||
var members = new List<(CircleDto Circle, CircleMemberDto Member)>();
|
||||
foreach (var circle in circles)
|
||||
{
|
||||
var list = await client.GetMembersAsync(circle.Id)
|
||||
?? throw new InvalidOperationException($"Le cercle {circle.Name} n'est plus disponible.");
|
||||
members.AddRange(list.Select(member => (circle, member)));
|
||||
}
|
||||
var contacts = members.GroupBy(item => item.Member.Id, StringComparer.Ordinal)
|
||||
.Select(group =>
|
||||
{
|
||||
var member = group.First().Member;
|
||||
if (string.IsNullOrWhiteSpace(member.Id) || string.IsNullOrWhiteSpace(member.UserName))
|
||||
throw new InvalidOperationException("Un membre de cercle n'a pas d'identifiant ou de pseudo.");
|
||||
return new ContactEntry(member.Id, member.UserName,
|
||||
string.IsNullOrWhiteSpace(member.FullName) ? member.UserName : member.FullName,
|
||||
string.Join(", ", group.Select(item => item.Circle.Name).Distinct().OrderBy(name => name)));
|
||||
})
|
||||
.OrderBy(contact => contact.DisplayName, StringComparer.CurrentCultureIgnoreCase)
|
||||
.ToArray();
|
||||
Contacts.Clear();
|
||||
foreach (var contact in contacts) Contacts.Add(contact);
|
||||
Status = $"{Contacts.Count} contact(s).";
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
Contacts.Clear();
|
||||
Status = $"Impossible de charger les contacts : {error.Message}";
|
||||
}
|
||||
finally { IsBusy = false; }
|
||||
}
|
||||
}
|
||||
|
|
@ -59,9 +59,15 @@ namespace PostIt.ViewModels.Chat
|
|||
public bool SupportsVideoCalls => Platform.CreateWebRtcMedia != null ||
|
||||
(OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid());
|
||||
|
||||
public bool SupportsLanCalls => Platform.CreateLanCallMedia != null ||
|
||||
(OperatingSystem.IsLinux() && !OperatingSystem.IsAndroid());
|
||||
|
||||
[ObservableProperty]
|
||||
public partial WebRtcCallViewModel? VideoCall { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial LanCallViewModel? LanCall { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string CurrentRoom { get; set; } = "General";
|
||||
|
||||
|
|
@ -107,6 +113,7 @@ namespace PostIt.ViewModels.Chat
|
|||
partial void OnSelectedRoomChanged(string? value)
|
||||
{
|
||||
if (VideoCall != null) VideoCall.Room = value ?? "";
|
||||
if (LanCall != null) LanCall.Room = value ?? "";
|
||||
FocusedMessages = value != null && _messagesByRoom.TryGetValue(value, out var msgs)
|
||||
? msgs : _systemMessages;
|
||||
FocusedUsers = value != null && _usersByRoom.TryGetValue(value, out var users)
|
||||
|
|
@ -161,6 +168,7 @@ namespace PostIt.ViewModels.Chat
|
|||
try
|
||||
{
|
||||
if (VideoCall != null) await VideoCall.HangupAsync();
|
||||
if (LanCall != null) await LanCall.HangupAsync();
|
||||
await _transport.LeaveAsync(room);
|
||||
JoinedRooms.Remove(room);
|
||||
_messagesByRoom.Remove(room);
|
||||
|
|
@ -210,12 +218,8 @@ namespace PostIt.ViewModels.Chat
|
|||
private async Task DisconnectCoreAsync()
|
||||
{
|
||||
Exception? callError = null;
|
||||
if (VideoCall != null)
|
||||
{
|
||||
try { await VideoCall.DisposeAsync(); }
|
||||
catch (Exception error) { callError = error; }
|
||||
finally { VideoCall = null; }
|
||||
}
|
||||
try { await DisposeCallViewModelsAsync(); }
|
||||
catch (Exception error) { callError = error; }
|
||||
Calls?.Dispose();
|
||||
Calls = null;
|
||||
try
|
||||
|
|
@ -239,6 +243,24 @@ namespace PostIt.ViewModels.Chat
|
|||
}
|
||||
}
|
||||
|
||||
private async Task DisposeCallViewModelsAsync()
|
||||
{
|
||||
Exception? callError = null;
|
||||
if (VideoCall != null)
|
||||
{
|
||||
try { await VideoCall.DisposeAsync(); }
|
||||
catch (Exception error) { callError = error; }
|
||||
finally { VideoCall = null; }
|
||||
}
|
||||
if (LanCall != null)
|
||||
{
|
||||
try { await LanCall.DisposeAsync(); }
|
||||
catch (Exception error) { callError = callError == null ? error : new AggregateException(callError, error); }
|
||||
finally { LanCall = null; }
|
||||
}
|
||||
if (callError != null) throw callError;
|
||||
}
|
||||
|
||||
public async Task ConnectAsync()
|
||||
{
|
||||
if (_api?.IsSigningOut == true)
|
||||
|
|
@ -269,13 +291,12 @@ namespace PostIt.ViewModels.Chat
|
|||
return;
|
||||
if (_connection != null)
|
||||
{
|
||||
if (VideoCall != null)
|
||||
try { await DisposeCallViewModelsAsync(); }
|
||||
finally
|
||||
{
|
||||
await VideoCall.DisposeAsync();
|
||||
VideoCall = null;
|
||||
Calls?.Dispose();
|
||||
Calls = null;
|
||||
}
|
||||
Calls?.Dispose();
|
||||
Calls = null;
|
||||
}
|
||||
Status = new StatusNotice("Connexion en cours...", StatusSeverity.Info,
|
||||
new RelayCheckCommand("Vérifier la connexion", async () => await CheckConnectionAsync()));
|
||||
|
|
@ -298,9 +319,15 @@ namespace PostIt.ViewModels.Chat
|
|||
Calls = new CallSignalingClient(_connection);
|
||||
if (SupportsVideoCalls)
|
||||
VideoCall = new WebRtcCallViewModel(Calls, settings: _settings) { Room = SelectedRoom ?? "" };
|
||||
else
|
||||
Calls.Invitation += call => PostForCurrentSession(() =>
|
||||
Log($"Invitation audio-vidéo de {call.Caller} dans {call.RoomName} ; transport non disponible sur cette plateforme."));
|
||||
if (SupportsLanCalls)
|
||||
LanCall = new LanCallViewModel(Calls, settings: _settings) { Room = SelectedRoom ?? "" };
|
||||
Calls.Invitation += call =>
|
||||
{
|
||||
if ((call.Transport == Yavsc.Abstract.Chat.Calls.CallTransports.LanSrtp && !SupportsLanCalls) ||
|
||||
(call.Transport != Yavsc.Abstract.Chat.Calls.CallTransports.LanSrtp && !SupportsVideoCalls))
|
||||
PostForCurrentSession(() =>
|
||||
Log($"Invitation audio-vidéo de {call.Caller} dans {call.RoomName} ; transport non disponible sur cette plateforme."));
|
||||
};
|
||||
Calls.Ended += call => PostForCurrentSession(() =>
|
||||
Log($"Appel terminé : {call.Reason}."));
|
||||
|
||||
|
|
|
|||
|
|
@ -243,22 +243,20 @@ public partial class LanCallViewModel : ObservableObject, IAsyncDisposable
|
|||
return RunAsync(() => StopAsync("Appel termine.", true));
|
||||
}
|
||||
|
||||
private void OnInvitation(CallSession call) => Queue(async () =>
|
||||
private void OnInvitation(CallSession call)
|
||||
{
|
||||
if (call.Transport != CallTransports.LanSrtp)
|
||||
if (call.Transport != CallTransports.LanSrtp) return;
|
||||
Queue(async () =>
|
||||
{
|
||||
await _signaling.EndAsync(call.Id, _lifetime.Token);
|
||||
Status = "Invitation WebRTC non prise en charge par le mode LAN.";
|
||||
return;
|
||||
}
|
||||
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;
|
||||
Busy = true;
|
||||
Incoming = true;
|
||||
Status = $"{call.Caller} propose un appel SRTP dans {call.RoomName}. Acceptez ou refusez.";
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
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;
|
||||
Busy = true;
|
||||
Incoming = true;
|
||||
Status = $"{call.Caller} propose un appel SRTP dans {call.RoomName}. Acceptez ou refusez.";
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
|
||||
private void OnAccepted(CallAccepted accepted) => Queue(async () =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -156,22 +156,26 @@ public partial class WebRtcCallViewModel : ObservableObject, IAsyncDisposable
|
|||
return RunAsync(() => StopAsync("Appel termine.", true));
|
||||
}
|
||||
|
||||
private void OnInvitation(CallSession call) => Queue(async () =>
|
||||
private void OnInvitation(CallSession call)
|
||||
{
|
||||
if (call.Transport != CallTransports.WebRtc || _call is not null)
|
||||
if (call.Transport == CallTransports.LanSrtp) return;
|
||||
Queue(async () =>
|
||||
{
|
||||
await _signaling.EndAsync(call.Id, _lifetime.Token);
|
||||
Status = "Invitation refusee : transport incompatible ou appel deja en cours.";
|
||||
return;
|
||||
}
|
||||
_call = call;
|
||||
_caller = false;
|
||||
_callLifetime = CancellationTokenSource.CreateLinkedTokenSource(_lifetime.Token);
|
||||
Busy = Incoming = true;
|
||||
Status = $"{call.Caller} propose un appel dans {call.RoomName}. "
|
||||
+ (call.RelayOnly ? "Masquage IP : relais TURN obligatoire. " : "Mode direct : consentement au partage IP requis. ")
|
||||
+ "Acceptez ou refusez.";
|
||||
});
|
||||
if (call.Transport != CallTransports.WebRtc || _call is not null)
|
||||
{
|
||||
await _signaling.EndAsync(call.Id, _lifetime.Token);
|
||||
Status = "Invitation refusee : transport incompatible ou appel deja en cours.";
|
||||
return;
|
||||
}
|
||||
_call = call;
|
||||
_caller = false;
|
||||
_callLifetime = CancellationTokenSource.CreateLinkedTokenSource(_lifetime.Token);
|
||||
Busy = Incoming = true;
|
||||
Status = $"{call.Caller} propose un appel dans {call.RoomName}. "
|
||||
+ (call.RelayOnly ? "Masquage IP : relais TURN obligatoire. " : "Mode direct : consentement au partage IP requis. ")
|
||||
+ "Acceptez ou refusez.";
|
||||
});
|
||||
}
|
||||
|
||||
private void OnAccepted(CallAccepted accepted) => Queue(async () =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public class HomePageViewModel : ViewModelBase
|
|||
OpenPerformerConfiguration = new AsyncRelayCommand(OpenPerformerConfigurationAsync);
|
||||
OpenAdministration = new AsyncRelayCommand(OpenAdministrationAsync, () => SessionStatus.IsAdministrator);
|
||||
OpenChat = new AsyncRelayCommand(OpenChatAsync);
|
||||
OpenContacts = new AsyncRelayCommand(OpenContactsAsync);
|
||||
OpenPodcasts = new AsyncRelayCommand(async () =>
|
||||
{
|
||||
var app = Application.Current as App ?? throw new InvalidOperationException("Application indisponible.");
|
||||
|
|
@ -89,6 +90,7 @@ public class HomePageViewModel : ViewModelBase
|
|||
|
||||
|
||||
public IAsyncRelayCommand OpenChat { get; }
|
||||
public IAsyncRelayCommand OpenContacts { get; }
|
||||
public IAsyncRelayCommand OpenPodcasts { get; }
|
||||
public bool SupportsPodcasts => Platform.IsPodcastSupported;
|
||||
public IAsyncRelayCommand OpenBlogs { get; }
|
||||
|
|
@ -264,6 +266,15 @@ public class HomePageViewModel : ViewModelBase
|
|||
|
||||
}
|
||||
|
||||
private async Task OpenContactsAsync()
|
||||
{
|
||||
var app = Application.Current as App ?? throw new InvalidOperationException("Application indisponible.");
|
||||
var vm = app.ServiceProvider?.GetRequiredService<ContactsPageViewModel>()
|
||||
?? throw new InvalidOperationException("Page contacts indisponible.");
|
||||
await app.PushPageAsync(vm);
|
||||
await vm.RefreshAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ouvre la page « Mes fichiers » (espace de stockage personnel),
|
||||
/// servie par le host Blogs via <c>api/v1/fs</c>.
|
||||
|
|
|
|||
23
src/PostIt/PostIt/Views/ACL/ContactsPage.axaml
Normal file
23
src/PostIt/PostIt/Views/ACL/ContactsPage.axaml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<ContentPage
|
||||
x:Class="PostIt.Views.ContactsPage"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:PostIt.ViewModels"
|
||||
x:DataType="vm:ContactsPageViewModel"
|
||||
Header="Contacts">
|
||||
<Grid Margin="16" RowDefinitions="Auto,Auto,*">
|
||||
<Button Content="Actualiser" Command="{Binding RefreshCommand}" IsEnabled="{Binding !IsBusy}" />
|
||||
<TextBlock Grid.Row="1" Margin="0,8" Text="{Binding Status}" TextWrapping="Wrap" />
|
||||
<ListBox Grid.Row="2" ItemsSource="{Binding Contacts}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:ContactEntry">
|
||||
<StackPanel Margin="4" Spacing="3">
|
||||
<TextBlock FontWeight="SemiBold" Text="{Binding DisplayName}" />
|
||||
<TextBlock Text="{Binding UserName}" />
|
||||
<TextBlock Text="{Binding Circles}" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
8
src/PostIt/PostIt/Views/ACL/ContactsPage.axaml.cs
Normal file
8
src/PostIt/PostIt/Views/ACL/ContactsPage.axaml.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
using Avalonia.Controls;
|
||||
|
||||
namespace PostIt.Views;
|
||||
|
||||
public partial class ContactsPage : ContentPage
|
||||
{
|
||||
public ContactsPage() => InitializeComponent();
|
||||
}
|
||||
|
|
@ -104,9 +104,14 @@
|
|||
Content="Envoyer" />
|
||||
</Grid>
|
||||
|
||||
<Expander Grid.Row="3" Header="Appel video WebRTC" IsVisible="{Binding SupportsVideoCalls}" IsExpanded="True"
|
||||
<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">
|
||||
<ScrollViewer MaxHeight="520">
|
||||
<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" />
|
||||
|
|
@ -144,9 +149,55 @@
|
|||
<ContentControl Grid.Column="1" Content="{Binding RemoteVideo}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</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>
|
||||
</ScrollViewer>
|
||||
|
||||
<postitControls:StatusBar
|
||||
x:Name="StatusBar"
|
||||
Grid.Row="4"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ public partial class ChatPage : ContentPage
|
|||
protected override async void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnDetachedFromVisualTree(e);
|
||||
if (DataContext is ChatViewModel { VideoCall: { } call })
|
||||
await call.HangupAsync();
|
||||
if (DataContext is ChatViewModel chat)
|
||||
{
|
||||
if (chat.VideoCall is { } video) await video.HangupAsync();
|
||||
if (chat.LanCall is { } lan) await lan.HangupAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@
|
|||
Label="Podcasts : directs et replays" />
|
||||
</CommandBar.PrimaryCommands>
|
||||
<CommandBar.SecondaryCommands>
|
||||
<CommandBarButton
|
||||
Command="{Binding OpenContacts}"
|
||||
IsEnabled="{Binding SessionStatus.IsLoggedIn}"
|
||||
Label="Contacts" />
|
||||
<CommandBarButton
|
||||
HorizontalAlignment="Center"
|
||||
Command="{Binding OpenChat}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue