merge: people panel, roles, lock, invite, meeting options
- People, transcript and chat side panels are mutually exclusive Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -170,6 +170,8 @@ Feature parity with the Microsoft Teams desktop client.
170
170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person |
171
171
| Meeting extras | Partial | Share menu switch "Include computer sound" (remembered, mixed into the one audio track with the mic, own playback excluded on Windows 10 build 20348+), raise hand with queue badge, lower hand and Lower all hands for organizers, reactions on the sender's tile for 3 s, meeting chat in a 320 px side panel with unread badge. Checked with synthetic sources and the demo only; not yet live in a meeting or with a second person |
172
172
| Organizer controls | Partial | Amber lobby banner with View (Admit, Deny per person) and Admit all, tile menu (right-click or "..." on hover): Pin for me, Spotlight for everyone, Mute, Lower hand, Remove from meeting with a confirm dialog, "..." controls menu with Mute all. Request bodies built from the Teams code and unit tested; demo checked, not yet live with a second person |
173
| People panel, roles, lock, invite | Partial | People button before chat opens a 320 px panel (closes the chat): "People (N)" with Invite and "...", lobby with Admit / Deny / Admit all, raised hands in queue order, groups Organizers / Presenters / Attendees (flat "In this call" in 1:1 and group calls), row "..." with Pin, Spotlight, Mute, Disable / Allow mic and camera, Make presenter / attendee, Remove. "..." menu: Mute all, Lock / Unlock meeting ("Locked" chip, banner for organizers), mic and camera off for attendees, Add people (1:1). Invite adds a person to the running meeting or group call; in a 1:1 call it creates a group chat and escalates. Request bodies from the Teams code and unit tested; demo checked, nothing sent to the live service |
174
| Meeting options | Partial | Organizer "..." > Meeting options: lobby bypass, who can present, attendee mic and camera, meeting chat (On / In-meeting only / Off), reactions, record automatically. Reads and writes the `meetings/v1/options` service from the captured shapes, one request per changed option, errors inline. Not yet read or written live |
173
175
| Live captions | Partial | "..." > Turn on live captions: recorder bot joins, start command with a skype token, captions arrive on the SCTP data channel (data id 3), 2-line overlay with bold speaker that fades after 4 s. "Captions settings": spoken language (`setLanguage`), size S/M/L, position bottom/top (size and position remembered). "Show transcript": 320 px side panel with the whole call (speaker, mm:ss, text), search, Jump to latest. Message framing and parsing from the Teams code; `setLanguage` body from capture, not sent live; not yet seen with real speech |
174
176
| Backgrounds | Partial | Camera menu Background: None / Blur / Microsoft's default images / "Add image..." (remembered). The image list and thumbnails are fetched at runtime into the app data folder, nothing of Microsoft's ships with the app; the picture is cover-scaled behind the same segmentation mask (checked with a synthetic mask, demo with generated pictures, the CDN download only through `meet_now --background`). On-device MediaPipe selfie segmentation through tract (Apache-2.0 model, 11 ms per 640x360 frame in a release build), edge feathering, self view shows the result. Checked with a still photo and synthetic frames; not yet on a real camera |
175
177
| Camera effects | Partial | Camera menu "Effects" and Settings > Devices: Mirror my video (self view and camera test only, default on), Auto framing, Adjust brightness, Soft focus (Low / Medium / High in Settings). Framing, brightness and soft focus run on the send path, so others see them; one segmentation mask per frame is shared with the background. Crop planner, gamma and blend are unit tested; not yet checked on a real camera |
@@ -170,6 +170,8 @@ Feature parity with the Microsoft Teams desktop client.170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person |170
| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person |171
| Meeting extras | Partial | Share menu switch "Include computer sound" (remembered, mixed into the one audio track with the mic, own playback excluded on Windows 10 build 20348+), raise hand with queue badge, lower hand and Lower all hands for organizers, reactions on the sender's tile for 3 s, meeting chat in a 320 px side panel with unread badge. Checked with synthetic sources and the demo only; not yet live in a meeting or with a second person |171
| Meeting extras | Partial | Share menu switch "Include computer sound" (remembered, mixed into the one audio track with the mic, own playback excluded on Windows 10 build 20348+), raise hand with queue badge, lower hand and Lower all hands for organizers, reactions on the sender's tile for 3 s, meeting chat in a 320 px side panel with unread badge. Checked with synthetic sources and the demo only; not yet live in a meeting or with a second person |172
| Organizer controls | Partial | Amber lobby banner with View (Admit, Deny per person) and Admit all, tile menu (right-click or "..." on hover): Pin for me, Spotlight for everyone, Mute, Lower hand, Remove from meeting with a confirm dialog, "..." controls menu with Mute all. Request bodies built from the Teams code and unit tested; demo checked, not yet live with a second person |172
| Organizer controls | Partial | Amber lobby banner with View (Admit, Deny per person) and Admit all, tile menu (right-click or "..." on hover): Pin for me, Spotlight for everyone, Mute, Lower hand, Remove from meeting with a confirm dialog, "..." controls menu with Mute all. Request bodies built from the Teams code and unit tested; demo checked, not yet live with a second person |173
| People panel, roles, lock, invite | Partial | People button before chat opens a 320 px panel (closes the chat): "People (N)" with Invite and "...", lobby with Admit / Deny / Admit all, raised hands in queue order, groups Organizers / Presenters / Attendees (flat "In this call" in 1:1 and group calls), row "..." with Pin, Spotlight, Mute, Disable / Allow mic and camera, Make presenter / attendee, Remove. "..." menu: Mute all, Lock / Unlock meeting ("Locked" chip, banner for organizers), mic and camera off for attendees, Add people (1:1). Invite adds a person to the running meeting or group call; in a 1:1 call it creates a group chat and escalates. Request bodies from the Teams code and unit tested; demo checked, nothing sent to the live service |174
| Meeting options | Partial | Organizer "..." > Meeting options: lobby bypass, who can present, attendee mic and camera, meeting chat (On / In-meeting only / Off), reactions, record automatically. Reads and writes the `meetings/v1/options` service from the captured shapes, one request per changed option, errors inline. Not yet read or written live |173
| Live captions | Partial | "..." > Turn on live captions: recorder bot joins, start command with a skype token, captions arrive on the SCTP data channel (data id 3), 2-line overlay with bold speaker that fades after 4 s. "Captions settings": spoken language (`setLanguage`), size S/M/L, position bottom/top (size and position remembered). "Show transcript": 320 px side panel with the whole call (speaker, mm:ss, text), search, Jump to latest. Message framing and parsing from the Teams code; `setLanguage` body from capture, not sent live; not yet seen with real speech |175
| Live captions | Partial | "..." > Turn on live captions: recorder bot joins, start command with a skype token, captions arrive on the SCTP data channel (data id 3), 2-line overlay with bold speaker that fades after 4 s. "Captions settings": spoken language (`setLanguage`), size S/M/L, position bottom/top (size and position remembered). "Show transcript": 320 px side panel with the whole call (speaker, mm:ss, text), search, Jump to latest. Message framing and parsing from the Teams code; `setLanguage` body from capture, not sent live; not yet seen with real speech |174
| Backgrounds | Partial | Camera menu Background: None / Blur / Microsoft's default images / "Add image..." (remembered). The image list and thumbnails are fetched at runtime into the app data folder, nothing of Microsoft's ships with the app; the picture is cover-scaled behind the same segmentation mask (checked with a synthetic mask, demo with generated pictures, the CDN download only through `meet_now --background`). On-device MediaPipe selfie segmentation through tract (Apache-2.0 model, 11 ms per 640x360 frame in a release build), edge feathering, self view shows the result. Checked with a still photo and synthetic frames; not yet on a real camera |176
| Backgrounds | Partial | Camera menu Background: None / Blur / Microsoft's default images / "Add image..." (remembered). The image list and thumbnails are fetched at runtime into the app data folder, nothing of Microsoft's ships with the app; the picture is cover-scaled behind the same segmentation mask (checked with a synthetic mask, demo with generated pictures, the CDN download only through `meet_now --background`). On-device MediaPipe selfie segmentation through tract (Apache-2.0 model, 11 ms per 640x360 frame in a release build), edge feathering, self view shows the result. Checked with a still photo and synthetic frames; not yet on a real camera |175
| Camera effects | Partial | Camera menu "Effects" and Settings > Devices: Mirror my video (self view and camera test only, default on), Auto framing, Adjust brightness, Soft focus (Low / Medium / High in Settings). Framing, brightness and soft focus run on the send path, so others see them; one segmentation mask per frame is shared with the background. Crop planner, gamma and blend are unit tested; not yet checked on a real camera |177
| Camera effects | Partial | Camera menu "Effects" and Settings > Devices: Mirror my video (self view and camera test only, default on), Auto framing, Adjust brightness, Soft focus (Low / Medium / High in Settings). Framing, brightness and soft focus run on the send path, so others see them; one segmentation mask per frame is shared with the background. Crop planner, gamma and blend are unit tested; not yet checked on a real camera |@@ -338,6 +338,20 @@ impl AppState {
338
338
self.begin_breakout_move(moved, cx);
339
339
return;
340
340
}
341
CallUpdate::MeetingOptions(result) => {
342
if let Some(dialog) = call.options_dialog.as_mut() {
343
dialog.loaded(result);
344
}
345
cx.notify();
346
return;
347
}
348
CallUpdate::MeetingOptionsSaved(result) => {
349
if call.options_dialog.as_mut().is_some_and(|dialog| dialog.saved(result)) {
350
call.options_dialog = None;
351
}
352
cx.notify();
353
return;
354
}
341
355
_ => {}
342
356
}
343
357
if let (CallUpdate::Caption(entry), Some(thread)) = (&update, call.chat_thread()) {
@@ -522,6 +536,7 @@ impl AppState {
522
536
if call.chat_open {
523
537
call.transcript_open = false;
524
538
self.transcript_panel = None;
539
call.people_open = false;
525
540
}
526
541
cx.emit(AppEvent::Call);
527
542
cx.notify();
@@ -1348,6 +1363,7 @@ mod tests {
1348
1363
}),
1349
1364
spotlight: None,
1350
1365
organizer: false,
1366
..Default::default()
1351
1367
}]),
1352
1368
cx,
1353
1369
);
@@ -1381,6 +1397,7 @@ mod tests {
1381
1397
rank: 1,
1382
1398
}),
1383
1399
organizer: false,
1400
..Default::default()
1384
1401
}
1385
1402
}
1386
1403
@@ -338,6 +338,20 @@ impl AppState {338
self.begin_breakout_move(moved, cx);338
self.begin_breakout_move(moved, cx);339
return;339
return;340
}340
}341
CallUpdate::MeetingOptions(result) => {342
if let Some(dialog) = call.options_dialog.as_mut() {343
dialog.loaded(result);344
}345
cx.notify();346
return;347
}348
CallUpdate::MeetingOptionsSaved(result) => {349
if call.options_dialog.as_mut().is_some_and(|dialog| dialog.saved(result)) {350
call.options_dialog = None;351
}352
cx.notify();353
return;354
}341
_ => {}355
_ => {}342
}356
}343
if let (CallUpdate::Caption(entry), Some(thread)) = (&update, call.chat_thread()) {357
if let (CallUpdate::Caption(entry), Some(thread)) = (&update, call.chat_thread()) {@@ -522,6 +536,7 @@ impl AppState {522
if call.chat_open {536
if call.chat_open {523
call.transcript_open = false;537
call.transcript_open = false;524
self.transcript_panel = None;538
self.transcript_panel = None;539
call.people_open = false;525
}540
}526
cx.emit(AppEvent::Call);541
cx.emit(AppEvent::Call);527
cx.notify();542
cx.notify();@@ -1348,6 +1363,7 @@ mod tests {1348
}),1363
}),1349
spotlight: None,1364
spotlight: None,1350
organizer: false,1365
organizer: false,1366
..Default::default()1351
}]),1367
}]),1352
cx,1368
cx,1353
);1369
);@@ -1381,6 +1397,7 @@ mod tests {1381
rank: 1,1397
rank: 1,1382
}),1398
}),1383
organizer: false,1399
organizer: false,1400
..Default::default()1384
}1401
}1385
}1402
}1386
1403
@@ -4,11 +4,12 @@ use calling::CameraDevice;
4
4
use calling::video_frame::bgra_from_i420;
5
5
use calling::video_pattern::{PatternKind, pattern_frame};
6
6
use calling::{
7
AudioDevice, BackgroundChoice, BreakoutMove, CallCommand, CallControl, CallHandle, CallHealth,
7
AttendeeLimits, AudioDevice, BackgroundChoice, BreakoutMove, CallCommand, CallControl, CallHandle, CallHealth,
8
8
CallState, CallUpdate, Caller, CaptionEntry, CaptionState, ContentShare, DeviceChoice,
9
9
DeviceLists, EndReason, HealthSample, HoldState, IncomingRing, Limitation, MediaPath,
10
MeetingTarget, NetworkLevel, Progress, PublishedState, RaisedHand, Reaction, RosterEntry,
11
RecordingKind, ShareKind, ShareSource, StopScope, TransportDetails, VideoKey, call_channel,
10
MeetingCapability, MeetingOptions, MeetingRole, MeetingTarget, Modality, NetworkLevel, Progress,
11
PublishedState, RaisedHand, Reaction, RecordingKind, RosterEntry, ShareKind, ShareSource, StopScope,
12
TransportDetails, VideoKey, call_channel,
12
13
};
13
14
14
15
use super::demo_scene::self_view;
@@ -255,6 +256,8 @@ fn roster_of(people: &[Person], cameras: usize) -> Vec<RosterEntry> {
255
256
sharing: false,
256
257
hand: None,
257
258
spotlight: None,
259
role: Some(demo_role(index)),
260
limits: demo_limits(index),
258
261
organizer: false,
259
262
})
260
263
.collect()
@@ -479,6 +482,7 @@ async fn speak_until_hangup(
479
482
let mut output = DeviceChoice::SystemDefault;
480
483
let mut ticks = 0u32;
481
484
let mut share_sound = false;
485
let mut capability = MeetingCapability::default();
482
486
let mut tick = interval(LEVEL_PERIOD);
483
487
loop {
484
488
tokio::select! {
@@ -584,6 +588,38 @@ async fn speak_until_hangup(
584
588
roster.iter_mut().filter(|entry| entry.mri != DEMO_OWN_MRI).for_each(|entry| entry.muted = true);
585
589
control.send(CallUpdate::Roster(roster.clone()));
586
590
}
591
Some(CallCommand::SetLock(locked)) => {
592
capability.locked = locked;
593
control.send(CallUpdate::Capability(capability));
594
}
595
Some(CallCommand::SetRole { mri, role }) => {
596
roster.iter_mut().filter(|entry| entry.mri == mri).for_each(|entry| entry.role = Some(role));
597
control.send(CallUpdate::Roster(roster.clone()));
598
}
599
Some(CallCommand::SetAttendeeModality { mri, modality, allowed }) => {
600
if let Some(entry) = roster.iter_mut().find(|entry| entry.mri == mri) {
601
let (blocked, released) = match modality {
602
Modality::Mic => (&mut entry.limits.mic_blocked, &mut entry.limits.mic_released),
603
Modality::Camera => (&mut entry.limits.camera_blocked, &mut entry.limits.camera_released),
604
};
605
*blocked = (!allowed).then(|| demo_state("demo-blocked", 1));
606
*released = None;
607
}
608
control.send(CallUpdate::Roster(roster.clone()));
609
}
610
Some(CallCommand::SetAttendeeRestrictions { mic_off, camera_off }) => {
611
capability.attendee_mic_off = mic_off;
612
capability.attendee_camera_off = camera_off;
613
control.send(CallUpdate::Capability(capability));
614
}
615
Some(CallCommand::Invite { callees, .. }) => {
616
for callee in callees {
617
roster.push(RosterEntry { mri: callee.mri, display_name: callee.display_name, role: Some(MeetingRole::Attendee), ..RosterEntry::default() });
618
}
619
control.send(CallUpdate::Roster(roster.clone()));
620
}
621
Some(CallCommand::LoadMeetingOptions) => control.send(CallUpdate::MeetingOptions(Ok(demo_options()))),
622
Some(CallCommand::SaveMeetingOptions(_)) => control.send(CallUpdate::MeetingOptionsSaved(Ok(demo_options()))),
587
623
Some(CallCommand::Spotlight { mri }) => {
588
624
let rank = roster.iter().filter_map(|entry| entry.spotlight.as_ref().map(|state| state.rank)).max().unwrap_or(0) + 1;
589
625
if let Some(entry) = roster.iter_mut().find(|entry| entry.mri == mri) {
@@ -639,6 +675,38 @@ async fn speak_until_hangup(
639
675
}
640
676
}
641
677
678
fn demo_role(index: usize) -> MeetingRole {
679
match index {
680
3 => MeetingRole::Organizer,
681
0 | 1 => MeetingRole::Presenter,
682
_ => MeetingRole::Attendee,
683
}
684
}
685
686
fn demo_limits(index: usize) -> AttendeeLimits {
687
AttendeeLimits {
688
mic_blocked: (index == 5).then(|| demo_state("demo-blocked-5", 1)),
689
..AttendeeLimits::default()
690
}
691
}
692
693
fn demo_state(id: &str, rank: u64) -> PublishedState {
694
PublishedState { state_id: id.to_owned(), rank }
695
}
696
697
fn demo_options() -> MeetingOptions {
698
let option = |name: &str, value: serde_json::Value| serde_json::json!({"name": name, "currentValue": value});
699
MeetingOptions::from_response(&serde_json::json!({"options": [
700
option("AutoAdmittedUsers", serde_json::json!("EveryoneInCompany")),
701
option("PresenterOption", serde_json::json!("Everyone")),
702
option("AttendeeRestrictions", serde_json::json!("UnRestricted")),
703
option("AllowMeetingChat", serde_json::json!("Enabled")),
704
option("AllowTeamsMeetingReactions", serde_json::json!(true)),
705
option("AutoRecordAndTranscribeMode", serde_json::json!("Off")),
706
]}))
707
.expect("the demo options are complete")
708
}
709
642
710
fn demo_organizer() -> RosterEntry {
643
711
RosterEntry {
644
712
mri: DEMO_OWN_MRI.to_owned(),
@@ -650,6 +718,8 @@ fn demo_organizer() -> RosterEntry {
650
718
hand: None,
651
719
spotlight: None,
652
720
organizer: true,
721
role: Some(MeetingRole::Organizer),
722
..Default::default()
653
723
}
654
724
}
655
725
@@ -664,6 +734,7 @@ fn demo_waiting(index: usize, name: &str) -> RosterEntry {
664
734
hand: None,
665
735
spotlight: None,
666
736
organizer: false,
737
..Default::default()
667
738
}
668
739
}
669
740
@@ -723,6 +794,7 @@ fn set_demo_hand(roster: &mut Vec<RosterEntry>, mri: &str, raised: bool) {
723
794
hand: Some(demo_hand(next_rank)),
724
795
spotlight: None,
725
796
organizer: false,
797
..Default::default()
726
798
}),
727
799
}
728
800
}
@@ -4,11 +4,12 @@ use calling::CameraDevice;4
use calling::video_frame::bgra_from_i420;4
use calling::video_frame::bgra_from_i420;5
use calling::video_pattern::{PatternKind, pattern_frame};5
use calling::video_pattern::{PatternKind, pattern_frame};6
use calling::{6
use calling::{7
AudioDevice, BackgroundChoice, BreakoutMove, CallCommand, CallControl, CallHandle, CallHealth,7
AttendeeLimits, AudioDevice, BackgroundChoice, BreakoutMove, CallCommand, CallControl, CallHandle, CallHealth,8
CallState, CallUpdate, Caller, CaptionEntry, CaptionState, ContentShare, DeviceChoice,8
CallState, CallUpdate, Caller, CaptionEntry, CaptionState, ContentShare, DeviceChoice,9
DeviceLists, EndReason, HealthSample, HoldState, IncomingRing, Limitation, MediaPath,9
DeviceLists, EndReason, HealthSample, HoldState, IncomingRing, Limitation, MediaPath,10
MeetingTarget, NetworkLevel, Progress, PublishedState, RaisedHand, Reaction, RosterEntry,10
MeetingCapability, MeetingOptions, MeetingRole, MeetingTarget, Modality, NetworkLevel, Progress,11
RecordingKind, ShareKind, ShareSource, StopScope, TransportDetails, VideoKey, call_channel,11
PublishedState, RaisedHand, Reaction, RecordingKind, RosterEntry, ShareKind, ShareSource, StopScope,12
TransportDetails, VideoKey, call_channel,12
};13
};13
14
14
use super::demo_scene::self_view;15
use super::demo_scene::self_view;@@ -255,6 +256,8 @@ fn roster_of(people: &[Person], cameras: usize) -> Vec<RosterEntry> {255
sharing: false,256
sharing: false,256
hand: None,257
hand: None,257
spotlight: None,258
spotlight: None,259
role: Some(demo_role(index)),260
limits: demo_limits(index),258
organizer: false,261
organizer: false,259
})262
})260
.collect()263
.collect()@@ -479,6 +482,7 @@ async fn speak_until_hangup(479
let mut output = DeviceChoice::SystemDefault;482
let mut output = DeviceChoice::SystemDefault;480
let mut ticks = 0u32;483
let mut ticks = 0u32;481
let mut share_sound = false;484
let mut share_sound = false;485
let mut capability = MeetingCapability::default();482
let mut tick = interval(LEVEL_PERIOD);486
let mut tick = interval(LEVEL_PERIOD);483
loop {487
loop {484
tokio::select! {488
tokio::select! {@@ -584,6 +588,38 @@ async fn speak_until_hangup(584
roster.iter_mut().filter(|entry| entry.mri != DEMO_OWN_MRI).for_each(|entry| entry.muted = true);588
roster.iter_mut().filter(|entry| entry.mri != DEMO_OWN_MRI).for_each(|entry| entry.muted = true);585
control.send(CallUpdate::Roster(roster.clone()));589
control.send(CallUpdate::Roster(roster.clone()));586
}590
}591
Some(CallCommand::SetLock(locked)) => {592
capability.locked = locked;593
control.send(CallUpdate::Capability(capability));594
}595
Some(CallCommand::SetRole { mri, role }) => {596
roster.iter_mut().filter(|entry| entry.mri == mri).for_each(|entry| entry.role = Some(role));597
control.send(CallUpdate::Roster(roster.clone()));598
}599
Some(CallCommand::SetAttendeeModality { mri, modality, allowed }) => {600
if let Some(entry) = roster.iter_mut().find(|entry| entry.mri == mri) {601
let (blocked, released) = match modality {602
Modality::Mic => (&mut entry.limits.mic_blocked, &mut entry.limits.mic_released),603
Modality::Camera => (&mut entry.limits.camera_blocked, &mut entry.limits.camera_released),604
};605
*blocked = (!allowed).then(|| demo_state("demo-blocked", 1));606
*released = None;607
}608
control.send(CallUpdate::Roster(roster.clone()));609
}610
Some(CallCommand::SetAttendeeRestrictions { mic_off, camera_off }) => {611
capability.attendee_mic_off = mic_off;612
capability.attendee_camera_off = camera_off;613
control.send(CallUpdate::Capability(capability));614
}615
Some(CallCommand::Invite { callees, .. }) => {616
for callee in callees {617
roster.push(RosterEntry { mri: callee.mri, display_name: callee.display_name, role: Some(MeetingRole::Attendee), ..RosterEntry::default() });618
}619
control.send(CallUpdate::Roster(roster.clone()));620
}621
Some(CallCommand::LoadMeetingOptions) => control.send(CallUpdate::MeetingOptions(Ok(demo_options()))),622
Some(CallCommand::SaveMeetingOptions(_)) => control.send(CallUpdate::MeetingOptionsSaved(Ok(demo_options()))),587
Some(CallCommand::Spotlight { mri }) => {623
Some(CallCommand::Spotlight { mri }) => {588
let rank = roster.iter().filter_map(|entry| entry.spotlight.as_ref().map(|state| state.rank)).max().unwrap_or(0) + 1;624
let rank = roster.iter().filter_map(|entry| entry.spotlight.as_ref().map(|state| state.rank)).max().unwrap_or(0) + 1;589
if let Some(entry) = roster.iter_mut().find(|entry| entry.mri == mri) {625
if let Some(entry) = roster.iter_mut().find(|entry| entry.mri == mri) {@@ -639,6 +675,38 @@ async fn speak_until_hangup(639
}675
}640
}676
}641
677
678
fn demo_role(index: usize) -> MeetingRole {679
match index {680
3 => MeetingRole::Organizer,681
0 | 1 => MeetingRole::Presenter,682
_ => MeetingRole::Attendee,683
}684
}685
686
fn demo_limits(index: usize) -> AttendeeLimits {687
AttendeeLimits {688
mic_blocked: (index == 5).then(|| demo_state("demo-blocked-5", 1)),689
..AttendeeLimits::default()690
}691
}692
693
fn demo_state(id: &str, rank: u64) -> PublishedState {694
PublishedState { state_id: id.to_owned(), rank }695
}696
697
fn demo_options() -> MeetingOptions {698
let option = |name: &str, value: serde_json::Value| serde_json::json!({"name": name, "currentValue": value});699
MeetingOptions::from_response(&serde_json::json!({"options": [700
option("AutoAdmittedUsers", serde_json::json!("EveryoneInCompany")),701
option("PresenterOption", serde_json::json!("Everyone")),702
option("AttendeeRestrictions", serde_json::json!("UnRestricted")),703
option("AllowMeetingChat", serde_json::json!("Enabled")),704
option("AllowTeamsMeetingReactions", serde_json::json!(true)),705
option("AutoRecordAndTranscribeMode", serde_json::json!("Off")),706
]}))707
.expect("the demo options are complete")708
}709
642
fn demo_organizer() -> RosterEntry {710
fn demo_organizer() -> RosterEntry {643
RosterEntry {711
RosterEntry {644
mri: DEMO_OWN_MRI.to_owned(),712
mri: DEMO_OWN_MRI.to_owned(),@@ -650,6 +718,8 @@ fn demo_organizer() -> RosterEntry {650
hand: None,718
hand: None,651
spotlight: None,719
spotlight: None,652
organizer: true,720
organizer: true,721
role: Some(MeetingRole::Organizer),722
..Default::default()653
}723
}654
}724
}655
725
@@ -664,6 +734,7 @@ fn demo_waiting(index: usize, name: &str) -> RosterEntry {664
hand: None,734
hand: None,665
spotlight: None,735
spotlight: None,666
organizer: false,736
organizer: false,737
..Default::default()667
}738
}668
}739
}669
740
@@ -723,6 +794,7 @@ fn set_demo_hand(roster: &mut Vec<RosterEntry>, mri: &str, raised: bool) {723
hand: Some(demo_hand(next_rank)),794
hand: Some(demo_hand(next_rank)),724
spotlight: None,795
spotlight: None,725
organizer: false,796
organizer: false,797
..Default::default()726
}),798
}),727
}799
}728
}800
}@@ -72,6 +72,7 @@ impl AppState {
72
72
return;
73
73
};
74
74
call.chat_open = false;
75
call.people_open = false;
75
76
call.transcript_open = true;
76
77
let captions_off = !call.model.captions_on();
77
78
if captions_off {
@@ -72,6 +72,7 @@ impl AppState {72
return;72
return;73
};73
};74
call.chat_open = false;74
call.chat_open = false;75
call.people_open = false;75
call.transcript_open = true;76
call.transcript_open = true;76
let captions_off = !call.model.captions_on();77
let captions_off = !call.model.captions_on();77
if captions_off {78
if captions_off {@@ -16,8 +16,11 @@ mod list;
16
16
mod media;
17
17
mod mic;
18
18
mod model;
19
mod options_dialog;
19
20
mod overlay;
20
21
mod overlay_layout;
22
mod people;
23
mod people_actions;
21
24
mod pictures;
22
25
mod prejoin;
23
26
mod preview;
@@ -55,8 +58,10 @@ pub use model::{
55
58
ActiveCall, CAPTION_SHOWN, CallKind, CallModel, Focus, REACTION_SHOWN, Tile, TileSize,
56
59
TileState,
57
60
};
61
pub use options_dialog::OptionsDialog;
58
62
pub use overlay::CallWindows;
59
63
pub use prejoin::{AudioChoice, JoinOptions, PendingJoin, load_join_options};
64
pub use people::{PeopleSections, PersonRow, people_sections};
60
65
pub use preview::{CameraPreview, preview_backgrounds};
61
66
pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};
62
67
pub use ring::{MissedCall, RingEntry, Rings};
@@ -16,8 +16,11 @@ mod list;16
mod media;16
mod media;17
mod mic;17
mod mic;18
mod model;18
mod model;19
mod options_dialog;19
mod overlay;20
mod overlay;20
mod overlay_layout;21
mod overlay_layout;22
mod people;23
mod people_actions;21
mod pictures;24
mod pictures;22
mod prejoin;25
mod prejoin;23
mod preview;26
mod preview;@@ -55,8 +58,10 @@ pub use model::{55
ActiveCall, CAPTION_SHOWN, CallKind, CallModel, Focus, REACTION_SHOWN, Tile, TileSize,58
ActiveCall, CAPTION_SHOWN, CallKind, CallModel, Focus, REACTION_SHOWN, Tile, TileSize,56
TileState,59
TileState,57
};60
};61
pub use options_dialog::OptionsDialog;58
pub use overlay::CallWindows;62
pub use overlay::CallWindows;59
pub use prejoin::{AudioChoice, JoinOptions, PendingJoin, load_join_options};63
pub use prejoin::{AudioChoice, JoinOptions, PendingJoin, load_join_options};64
pub use people::{PeopleSections, PersonRow, people_sections};60
pub use preview::{CameraPreview, preview_backgrounds};65
pub use preview::{CameraPreview, preview_backgrounds};61
pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};66
pub use reminder::{MeetingToasts, subtitle as meeting_subtitle};62
pub use ring::{MissedCall, RingEntry, Rings};67
pub use ring::{MissedCall, RingEntry, Rings};@@ -4,9 +4,9 @@ use std::sync::Arc;
4
4
use std::time::{Duration, Instant};
5
5
6
6
use calling::{
7
CallCommand, CallState, CallUpdate, CameraDevice, CaptionEntry, CaptionState, ContentShare,
8
DeviceChoice, DeviceLists, EndKind, EndReason, HoldState, MeetingTarget, Progress, Reaction,
9
RosterEntry, ShareKind, ShareSource, SpeakingDetector, VideoHub,
7
AttendeeLimits, CallCommand, CallState, CallUpdate, CameraDevice, CaptionEntry, CaptionState, ContentShare,
8
DeviceChoice, DeviceLists, EndKind, EndReason, HoldState, MeetingCapability, MeetingRole,
9
MeetingTarget, Progress, Reaction, RosterEntry, ShareKind, ShareSource, SpeakingDetector, VideoHub,
10
10
};
11
11
use tokio::sync::mpsc::UnboundedSender;
12
12
@@ -18,6 +18,7 @@ use super::pictures::CallPictures;
18
18
use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};
19
19
use super::transcript::{Transcript, TranscriptEntry};
20
20
use super::view_settings::{CallLayout, ViewSettings};
21
use super::options_dialog::OptionsDialog;
21
22
use super::push_to_talk::PushToTalk;
22
23
23
24
pub const TEST_CALL_TITLE: &str = "Test call";
@@ -48,6 +49,8 @@ pub struct ActiveCall {
48
49
pub lobby_list_open: bool,
49
50
pub chat_open: bool,
50
51
pub transcript_open: bool,
52
pub people_open: bool,
53
pub options_dialog: Option<OptionsDialog>,
51
54
pub meeting_target: Option<MeetingTarget>,
52
55
pub pending_move: Option<PendingMove>,
53
56
pub consult: Option<ConsultCall>,
@@ -112,6 +115,8 @@ impl ActiveCall {
112
115
lobby_list_open: false,
113
116
chat_open: false,
114
117
transcript_open: false,
118
people_open: false,
119
options_dialog: None,
115
120
meeting_target: None,
116
121
pending_move: None,
117
122
consult: None,
@@ -166,6 +171,8 @@ pub struct Tile {
166
171
pub has_video: bool,
167
172
pub hand: Option<u64>,
168
173
pub spotlight: Option<u64>,
174
pub role: Option<MeetingRole>,
175
pub limits: AttendeeLimits,
169
176
}
170
177
171
178
impl Tile {
@@ -180,6 +187,8 @@ impl Tile {
180
187
has_video: false,
181
188
hand: None,
182
189
spotlight: None,
190
role: None,
191
limits: AttendeeLimits::default(),
183
192
}
184
193
}
185
194
}
@@ -265,6 +274,8 @@ pub struct CallModel {
265
274
pub own_hand: Option<u64>,
266
275
pub own_spotlight: Option<u64>,
267
276
pub organizer: bool,
277
pub own_role: Option<MeetingRole>,
278
pub capability: MeetingCapability,
268
279
pub pinned: Option<String>,
269
280
pub captions: CaptionState,
270
281
pub caption_lines: Vec<CaptionLine>,
@@ -325,6 +336,8 @@ impl CallModel {
325
336
own_hand: None,
326
337
own_spotlight: None,
327
338
organizer: false,
339
own_role: None,
340
capability: MeetingCapability::default(),
328
341
pinned: None,
329
342
captions: CaptionState::Off,
330
343
caption_lines: Vec::new(),
@@ -471,9 +484,12 @@ impl CallModel {
471
484
CallUpdate::Health(health) => self.health.apply(health),
472
485
CallUpdate::IncomingVideo(enabled) => self.health.incoming_video = enabled,
473
486
CallUpdate::Whiteboard(share) => self.whiteboard = share,
487
CallUpdate::Capability(capability) => self.capability = capability,
474
488
CallUpdate::BreakoutRoom { main } => self.main_meeting = Some(main),
475
489
CallUpdate::BlurTiming(_)
476
490
| CallUpdate::Organizer { .. }
491
| CallUpdate::MeetingOptions(_)
492
| CallUpdate::MeetingOptionsSaved(_)
477
493
| CallUpdate::WhiteboardUrl(_)
478
494
| CallUpdate::BreakoutMove(_)
479
495
| CallUpdate::ReplacementLink(_) => {}
@@ -593,6 +609,39 @@ impl CallModel {
593
609
self.kind == CallKind::Meeting && self.can_manage()
594
610
}
595
611
612
pub fn present_others(&self) -> usize {
613
self.tiles
614
.iter()
615
.filter(|tile| tile.state == TileState::Present)
616
.count()
617
}
618
619
pub fn can_invite(&self) -> bool {
620
let open_to_everyone = matches!(self.kind, CallKind::Direct | CallKind::Group);
621
self.is_live() && !self.lobby && (open_to_everyone || self.organizes_meeting())
622
}
623
624
pub fn tile_role(&self, mri: &str) -> Option<MeetingRole> {
625
self.tiles
626
.iter()
627
.find(|tile| tile.mri == mri)
628
.and_then(|tile| tile.role)
629
}
630
631
pub fn can_change_roles(&self, mri: &str) -> bool {
632
self.organizes_meeting() && self.tile_role(mri) != Some(MeetingRole::Organizer)
633
}
634
635
pub fn attendee_allowed(&self, mri: &str, modality: calling::Modality) -> bool {
636
let limits = self
637
.tiles
638
.iter()
639
.find(|tile| tile.mri == mri)
640
.map(|tile| tile.limits.clone())
641
.unwrap_or_default();
642
calling::modality_allowed(modality, self.capability, &limits)
643
}
644
596
645
pub fn can_lower_hands(&self) -> bool {
597
646
self.can_manage()
598
647
}
@@ -662,6 +711,11 @@ impl CallModel {
662
711
})
663
712
}
664
713
714
pub fn raised_hands(&self) -> usize {
715
self.tiles.iter().filter(|tile| tile.hand.is_some()).count()
716
+ usize::from(self.own_hand.is_some())
717
}
718
665
719
pub fn any_hand_raised(&self) -> bool {
666
720
self.own_hand.is_some() || self.tiles.iter().any(|tile| tile.hand.is_some())
667
721
}
@@ -689,6 +743,7 @@ impl CallModel {
689
743
own_entry.and_then(|entry| entry.spotlight.as_ref().map(|spotlight| spotlight.rank));
690
744
if let Some(entry) = own_entry {
691
745
self.organizer = entry.organizer;
746
self.own_role = entry.role;
692
747
}
693
748
for entry in entries
694
749
.iter()
@@ -706,6 +761,8 @@ impl CallModel {
706
761
tile.has_video = entry.has_video;
707
762
tile.hand = entry.hand.as_ref().map(|hand| hand.rank);
708
763
tile.spotlight = entry.spotlight.as_ref().map(|spotlight| spotlight.rank);
764
tile.role = entry.role;
765
tile.limits = entry.limits.clone();
709
766
if tile.name.is_empty() {
710
767
tile.name = entry.display_name.clone();
711
768
}
@@ -720,9 +777,14 @@ impl CallModel {
720
777
has_video: entry.has_video,
721
778
hand: entry.hand.as_ref().map(|hand| hand.rank),
722
779
spotlight: entry.spotlight.as_ref().map(|spotlight| spotlight.rank),
780
role: entry.role,
781
limits: entry.limits.clone(),
723
782
}),
724
783
}
725
784
}
785
if self.kind == CallKind::Direct && self.present_others() > 1 {
786
self.kind = CallKind::Group;
787
}
726
788
let own_mri = self.own_mri.clone();
727
789
let listed = |mri: &str| entries.iter().any(|entry| entry.mri == mri);
728
790
if self
@@ -1133,6 +1195,8 @@ mod tests {
1133
1195
hand: None,
1134
1196
spotlight: None,
1135
1197
organizer: false,
1198
role: None,
1199
limits: AttendeeLimits::default(),
1136
1200
}
1137
1201
}
1138
1202
@@ -4,9 +4,9 @@ use std::sync::Arc;4
use std::time::{Duration, Instant};4
use std::time::{Duration, Instant};5
5
6
use calling::{6
use calling::{7
CallCommand, CallState, CallUpdate, CameraDevice, CaptionEntry, CaptionState, ContentShare,7
AttendeeLimits, CallCommand, CallState, CallUpdate, CameraDevice, CaptionEntry, CaptionState, ContentShare,8
DeviceChoice, DeviceLists, EndKind, EndReason, HoldState, MeetingTarget, Progress, Reaction,8
DeviceChoice, DeviceLists, EndKind, EndReason, HoldState, MeetingCapability, MeetingRole,9
RosterEntry, ShareKind, ShareSource, SpeakingDetector, VideoHub,9
MeetingTarget, Progress, Reaction, RosterEntry, ShareKind, ShareSource, SpeakingDetector, VideoHub,10
};10
};11
use tokio::sync::mpsc::UnboundedSender;11
use tokio::sync::mpsc::UnboundedSender;12
12
@@ -18,6 +18,7 @@ use super::pictures::CallPictures;18
use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};18
use super::stage_layout::{FILMSTRIP_MAX, GALLERY_MAX, RECENT_SPEAKER, SPEAKER_HOLD, VisibleRotation, split_overflow};19
use super::transcript::{Transcript, TranscriptEntry};19
use super::transcript::{Transcript, TranscriptEntry};20
use super::view_settings::{CallLayout, ViewSettings};20
use super::view_settings::{CallLayout, ViewSettings};21
use super::options_dialog::OptionsDialog;21
use super::push_to_talk::PushToTalk;22
use super::push_to_talk::PushToTalk;22
23
23
pub const TEST_CALL_TITLE: &str = "Test call";24
pub const TEST_CALL_TITLE: &str = "Test call";@@ -48,6 +49,8 @@ pub struct ActiveCall {48
pub lobby_list_open: bool,49
pub lobby_list_open: bool,49
pub chat_open: bool,50
pub chat_open: bool,50
pub transcript_open: bool,51
pub transcript_open: bool,52
pub people_open: bool,53
pub options_dialog: Option<OptionsDialog>,51
pub meeting_target: Option<MeetingTarget>,54
pub meeting_target: Option<MeetingTarget>,52
pub pending_move: Option<PendingMove>,55
pub pending_move: Option<PendingMove>,53
pub consult: Option<ConsultCall>,56
pub consult: Option<ConsultCall>,@@ -112,6 +115,8 @@ impl ActiveCall {112
lobby_list_open: false,115
lobby_list_open: false,113
chat_open: false,116
chat_open: false,114
transcript_open: false,117
transcript_open: false,118
people_open: false,119
options_dialog: None,115
meeting_target: None,120
meeting_target: None,116
pending_move: None,121
pending_move: None,117
consult: None,122
consult: None,@@ -166,6 +171,8 @@ pub struct Tile {166
pub has_video: bool,171
pub has_video: bool,167
pub hand: Option<u64>,172
pub hand: Option<u64>,168
pub spotlight: Option<u64>,173
pub spotlight: Option<u64>,174
pub role: Option<MeetingRole>,175
pub limits: AttendeeLimits,169
}176
}170
177
171
impl Tile {178
impl Tile {@@ -180,6 +187,8 @@ impl Tile {180
has_video: false,187
has_video: false,181
hand: None,188
hand: None,182
spotlight: None,189
spotlight: None,190
role: None,191
limits: AttendeeLimits::default(),183
}192
}184
}193
}185
}194
}@@ -265,6 +274,8 @@ pub struct CallModel {265
pub own_hand: Option<u64>,274
pub own_hand: Option<u64>,266
pub own_spotlight: Option<u64>,275
pub own_spotlight: Option<u64>,267
pub organizer: bool,276
pub organizer: bool,277
pub own_role: Option<MeetingRole>,278
pub capability: MeetingCapability,268
pub pinned: Option<String>,279
pub pinned: Option<String>,269
pub captions: CaptionState,280
pub captions: CaptionState,270
pub caption_lines: Vec<CaptionLine>,281
pub caption_lines: Vec<CaptionLine>,@@ -325,6 +336,8 @@ impl CallModel {325
own_hand: None,336
own_hand: None,326
own_spotlight: None,337
own_spotlight: None,327
organizer: false,338
organizer: false,339
own_role: None,340
capability: MeetingCapability::default(),328
pinned: None,341
pinned: None,329
captions: CaptionState::Off,342
captions: CaptionState::Off,330
caption_lines: Vec::new(),343
caption_lines: Vec::new(),@@ -471,9 +484,12 @@ impl CallModel {471
CallUpdate::Health(health) => self.health.apply(health),484
CallUpdate::Health(health) => self.health.apply(health),472
CallUpdate::IncomingVideo(enabled) => self.health.incoming_video = enabled,485
CallUpdate::IncomingVideo(enabled) => self.health.incoming_video = enabled,473
CallUpdate::Whiteboard(share) => self.whiteboard = share,486
CallUpdate::Whiteboard(share) => self.whiteboard = share,487
CallUpdate::Capability(capability) => self.capability = capability,474
CallUpdate::BreakoutRoom { main } => self.main_meeting = Some(main),488
CallUpdate::BreakoutRoom { main } => self.main_meeting = Some(main),475
CallUpdate::BlurTiming(_)489
CallUpdate::BlurTiming(_)476
| CallUpdate::Organizer { .. }490
| CallUpdate::Organizer { .. }491
| CallUpdate::MeetingOptions(_)492
| CallUpdate::MeetingOptionsSaved(_)477
| CallUpdate::WhiteboardUrl(_)493
| CallUpdate::WhiteboardUrl(_)478
| CallUpdate::BreakoutMove(_)494
| CallUpdate::BreakoutMove(_)479
| CallUpdate::ReplacementLink(_) => {}495
| CallUpdate::ReplacementLink(_) => {}@@ -593,6 +609,39 @@ impl CallModel {593
self.kind == CallKind::Meeting && self.can_manage()609
self.kind == CallKind::Meeting && self.can_manage()594
}610
}595
611
612
pub fn present_others(&self) -> usize {613
self.tiles614
.iter()615
.filter(|tile| tile.state == TileState::Present)616
.count()617
}618
619
pub fn can_invite(&self) -> bool {620
let open_to_everyone = matches!(self.kind, CallKind::Direct | CallKind::Group);621
self.is_live() && !self.lobby && (open_to_everyone || self.organizes_meeting())622
}623
624
pub fn tile_role(&self, mri: &str) -> Option<MeetingRole> {625
self.tiles626
.iter()627
.find(|tile| tile.mri == mri)628
.and_then(|tile| tile.role)629
}630
631
pub fn can_change_roles(&self, mri: &str) -> bool {632
self.organizes_meeting() && self.tile_role(mri) != Some(MeetingRole::Organizer)633
}634
635
pub fn attendee_allowed(&self, mri: &str, modality: calling::Modality) -> bool {636
let limits = self637
.tiles638
.iter()639
.find(|tile| tile.mri == mri)640
.map(|tile| tile.limits.clone())641
.unwrap_or_default();642
calling::modality_allowed(modality, self.capability, &limits)643
}644
596
pub fn can_lower_hands(&self) -> bool {645
pub fn can_lower_hands(&self) -> bool {597
self.can_manage()646
self.can_manage()598
}647
}@@ -662,6 +711,11 @@ impl CallModel {662
})711
})663
}712
}664
713
714
pub fn raised_hands(&self) -> usize {715
self.tiles.iter().filter(|tile| tile.hand.is_some()).count()716
+ usize::from(self.own_hand.is_some())717
}718
665
pub fn any_hand_raised(&self) -> bool {719
pub fn any_hand_raised(&self) -> bool {666
self.own_hand.is_some() || self.tiles.iter().any(|tile| tile.hand.is_some())720
self.own_hand.is_some() || self.tiles.iter().any(|tile| tile.hand.is_some())667
}721
}@@ -689,6 +743,7 @@ impl CallModel {689
own_entry.and_then(|entry| entry.spotlight.as_ref().map(|spotlight| spotlight.rank));743
own_entry.and_then(|entry| entry.spotlight.as_ref().map(|spotlight| spotlight.rank));690
if let Some(entry) = own_entry {744
if let Some(entry) = own_entry {691
self.organizer = entry.organizer;745
self.organizer = entry.organizer;746
self.own_role = entry.role;692
}747
}693
for entry in entries748
for entry in entries694
.iter()749
.iter()@@ -706,6 +761,8 @@ impl CallModel {706
tile.has_video = entry.has_video;761
tile.has_video = entry.has_video;707
tile.hand = entry.hand.as_ref().map(|hand| hand.rank);762
tile.hand = entry.hand.as_ref().map(|hand| hand.rank);708
tile.spotlight = entry.spotlight.as_ref().map(|spotlight| spotlight.rank);763
tile.spotlight = entry.spotlight.as_ref().map(|spotlight| spotlight.rank);764
tile.role = entry.role;765
tile.limits = entry.limits.clone();709
if tile.name.is_empty() {766
if tile.name.is_empty() {710
tile.name = entry.display_name.clone();767
tile.name = entry.display_name.clone();711
}768
}@@ -720,9 +777,14 @@ impl CallModel {720
has_video: entry.has_video,777
has_video: entry.has_video,721
hand: entry.hand.as_ref().map(|hand| hand.rank),778
hand: entry.hand.as_ref().map(|hand| hand.rank),722
spotlight: entry.spotlight.as_ref().map(|spotlight| spotlight.rank),779
spotlight: entry.spotlight.as_ref().map(|spotlight| spotlight.rank),780
role: entry.role,781
limits: entry.limits.clone(),723
}),782
}),724
}783
}725
}784
}785
if self.kind == CallKind::Direct && self.present_others() > 1 {786
self.kind = CallKind::Group;787
}726
let own_mri = self.own_mri.clone();788
let own_mri = self.own_mri.clone();727
let listed = |mri: &str| entries.iter().any(|entry| entry.mri == mri);789
let listed = |mri: &str| entries.iter().any(|entry| entry.mri == mri);728
if self790
if self@@ -1133,6 +1195,8 @@ mod tests {1133
hand: None,1195
hand: None,1134
spotlight: None,1196
spotlight: None,1135
organizer: false,1197
organizer: false,1198
role: None,1199
limits: AttendeeLimits::default(),1136
}1200
}1137
}1201
}1138
1202
@@ -0,0 +1,115 @@
1
use calling::{MeetingOptions, OptionWrite};
2
3
#[derive(Debug, Clone, PartialEq)]
4
pub struct OptionsDialog {
5
pub original: Option<MeetingOptions>,
6
pub draft: Option<MeetingOptions>,
7
pub saving: bool,
8
pub error: Option<String>,
9
}
10
11
impl OptionsDialog {
12
pub fn loading() -> Self {
13
OptionsDialog { original: None, draft: None, saving: false, error: None }
14
}
15
16
pub fn loaded(&mut self, result: Result<MeetingOptions, String>) {
17
match result {
18
Ok(options) => {
19
self.original = Some(options.clone());
20
self.draft = Some(options);
21
self.error = None;
22
}
23
Err(error) => self.error = Some(error),
24
}
25
}
26
27
pub fn is_loading(&self) -> bool {
28
self.draft.is_none() && self.error.is_none()
29
}
30
31
pub fn changes(&self) -> Vec<OptionWrite> {
32
match (&self.original, &self.draft) {
33
(Some(original), Some(draft)) => original.changes(draft),
34
_ => Vec::new(),
35
}
36
}
37
38
pub fn can_save(&self) -> bool {
39
!self.saving && !self.changes().is_empty()
40
}
41
42
pub fn begin_save(&mut self) -> Option<Vec<OptionWrite>> {
43
if !self.can_save() {
44
return None;
45
}
46
self.saving = true;
47
self.error = None;
48
Some(self.changes())
49
}
50
51
pub fn saved(&mut self, result: Result<MeetingOptions, String>) -> bool {
52
self.saving = false;
53
match result {
54
Ok(_) => true,
55
Err(error) => {
56
self.error = Some(error);
57
false
58
}
59
}
60
}
61
}
62
63
#[cfg(test)]
64
mod tests {
65
use serde_json::json;
66
67
use super::*;
68
69
fn options() -> MeetingOptions {
70
let option = |name: &str, value: serde_json::Value| json!({"name": name, "currentValue": value});
71
MeetingOptions::from_response(&json!({"options": [
72
option("AutoAdmittedUsers", json!("EveryoneInCompany")),
73
option("PresenterOption", json!("Everyone")),
74
option("AttendeeRestrictions", json!("UnRestricted")),
75
option("AllowMeetingChat", json!("Enabled")),
76
option("AllowTeamsMeetingReactions", json!(true)),
77
option("AutoRecordAndTranscribeMode", json!("Off")),
78
]}))
79
.unwrap()
80
}
81
82
#[test]
83
fn a_dialog_loads_then_saves_only_what_changed() {
84
let mut dialog = OptionsDialog::loading();
85
assert!(dialog.is_loading());
86
assert!(dialog.begin_save().is_none());
87
dialog.loaded(Ok(options()));
88
assert!(!dialog.is_loading());
89
assert!(!dialog.can_save());
90
dialog.draft.as_mut().unwrap().reactions = false;
91
let writes = dialog.begin_save().expect("a change to save");
92
assert_eq!(writes.len(), 1);
93
assert_eq!(writes[0].name, "AllowTeamsMeetingReactions");
94
assert!(dialog.saving);
95
assert!(dialog.begin_save().is_none());
96
}
97
98
#[test]
99
fn errors_stay_inline_and_a_failed_save_can_be_retried() {
100
let mut dialog = OptionsDialog::loading();
101
dialog.loaded(Err("The options could not be read".into()));
102
assert!(!dialog.is_loading());
103
assert_eq!(dialog.error.as_deref(), Some("The options could not be read"));
104
dialog.loaded(Ok(options()));
105
assert_eq!(dialog.error, None);
106
dialog.draft.as_mut().unwrap().meeting_chat = "Disabled".into();
107
dialog.begin_save();
108
assert!(!dialog.saved(Err("the service refused AllowMeetingChat".into())));
109
assert!(!dialog.saving);
110
assert_eq!(dialog.error.as_deref(), Some("the service refused AllowMeetingChat"));
111
assert!(dialog.can_save());
112
dialog.begin_save();
113
assert!(dialog.saved(Ok(options())));
114
}
115
}
@@ -0,0 +1,115 @@1
use calling::{MeetingOptions, OptionWrite};2
3
#[derive(Debug, Clone, PartialEq)]4
pub struct OptionsDialog {5
pub original: Option<MeetingOptions>,6
pub draft: Option<MeetingOptions>,7
pub saving: bool,8
pub error: Option<String>,9
}10
11
impl OptionsDialog {12
pub fn loading() -> Self {13
OptionsDialog { original: None, draft: None, saving: false, error: None }14
}15
16
pub fn loaded(&mut self, result: Result<MeetingOptions, String>) {17
match result {18
Ok(options) => {19
self.original = Some(options.clone());20
self.draft = Some(options);21
self.error = None;22
}23
Err(error) => self.error = Some(error),24
}25
}26
27
pub fn is_loading(&self) -> bool {28
self.draft.is_none() && self.error.is_none()29
}30
31
pub fn changes(&self) -> Vec<OptionWrite> {32
match (&self.original, &self.draft) {33
(Some(original), Some(draft)) => original.changes(draft),34
_ => Vec::new(),35
}36
}37
38
pub fn can_save(&self) -> bool {39
!self.saving && !self.changes().is_empty()40
}41
42
pub fn begin_save(&mut self) -> Option<Vec<OptionWrite>> {43
if !self.can_save() {44
return None;45
}46
self.saving = true;47
self.error = None;48
Some(self.changes())49
}50
51
pub fn saved(&mut self, result: Result<MeetingOptions, String>) -> bool {52
self.saving = false;53
match result {54
Ok(_) => true,55
Err(error) => {56
self.error = Some(error);57
false58
}59
}60
}61
}62
63
#[cfg(test)]64
mod tests {65
use serde_json::json;66
67
use super::*;68
69
fn options() -> MeetingOptions {70
let option = |name: &str, value: serde_json::Value| json!({"name": name, "currentValue": value});71
MeetingOptions::from_response(&json!({"options": [72
option("AutoAdmittedUsers", json!("EveryoneInCompany")),73
option("PresenterOption", json!("Everyone")),74
option("AttendeeRestrictions", json!("UnRestricted")),75
option("AllowMeetingChat", json!("Enabled")),76
option("AllowTeamsMeetingReactions", json!(true)),77
option("AutoRecordAndTranscribeMode", json!("Off")),78
]}))79
.unwrap()80
}81
82
#[test]83
fn a_dialog_loads_then_saves_only_what_changed() {84
let mut dialog = OptionsDialog::loading();85
assert!(dialog.is_loading());86
assert!(dialog.begin_save().is_none());87
dialog.loaded(Ok(options()));88
assert!(!dialog.is_loading());89
assert!(!dialog.can_save());90
dialog.draft.as_mut().unwrap().reactions = false;91
let writes = dialog.begin_save().expect("a change to save");92
assert_eq!(writes.len(), 1);93
assert_eq!(writes[0].name, "AllowTeamsMeetingReactions");94
assert!(dialog.saving);95
assert!(dialog.begin_save().is_none());96
}97
98
#[test]99
fn errors_stay_inline_and_a_failed_save_can_be_retried() {100
let mut dialog = OptionsDialog::loading();101
dialog.loaded(Err("The options could not be read".into()));102
assert!(!dialog.is_loading());103
assert_eq!(dialog.error.as_deref(), Some("The options could not be read"));104
dialog.loaded(Ok(options()));105
assert_eq!(dialog.error, None);106
dialog.draft.as_mut().unwrap().meeting_chat = "Disabled".into();107
dialog.begin_save();108
assert!(!dialog.saved(Err("the service refused AllowMeetingChat".into())));109
assert!(!dialog.saving);110
assert_eq!(dialog.error.as_deref(), Some("the service refused AllowMeetingChat"));111
assert!(dialog.can_save());112
dialog.begin_save();113
assert!(dialog.saved(Ok(options())));114
}115
}@@ -0,0 +1,271 @@
1
use calling::{MeetingRole, Modality};
2
3
use super::model::{CallKind, CallModel, Tile, TileState};
4
5
const BOT_PREFIX: &str = "28:";
6
const FLAT_TITLE: &str = "In this call";
7
const OWN_NAME: &str = "You";
8
9
#[derive(Debug, Clone, PartialEq, Eq)]
10
pub struct PersonRow {
11
pub mri: String,
12
pub name: String,
13
pub user_id: Option<String>,
14
pub own: bool,
15
pub label: Option<&'static str>,
16
pub muted: bool,
17
pub mic_blocked: bool,
18
pub camera_on: bool,
19
pub camera_blocked: bool,
20
pub hand: Option<usize>,
21
pub ringing: bool,
22
}
23
24
#[derive(Debug, Clone, PartialEq, Eq)]
25
pub struct LobbyRow {
26
pub mri: String,
27
pub name: String,
28
pub user_id: Option<String>,
29
}
30
31
#[derive(Debug, Clone, PartialEq, Eq)]
32
pub struct PeopleGroup {
33
pub title: &'static str,
34
pub rows: Vec<PersonRow>,
35
}
36
37
#[derive(Debug, Clone, PartialEq, Eq, Default)]
38
pub struct PeopleSections {
39
pub count: usize,
40
pub lobby: Vec<LobbyRow>,
41
pub hands: Vec<PersonRow>,
42
pub groups: Vec<PeopleGroup>,
43
}
44
45
pub fn role_label(role: MeetingRole) -> &'static str {
46
match role {
47
MeetingRole::Organizer => "Organizer",
48
MeetingRole::Presenter => "Presenter",
49
MeetingRole::Attendee => "Attendee",
50
}
51
}
52
53
fn group_title(role: MeetingRole) -> &'static str {
54
match role {
55
MeetingRole::Organizer => "Organizers",
56
MeetingRole::Presenter => "Presenters",
57
MeetingRole::Attendee => "Attendees",
58
}
59
}
60
61
fn tile_row(model: &CallModel, tile: &Tile, role: Option<MeetingRole>) -> PersonRow {
62
let attendee = role != Some(MeetingRole::Organizer) && role != Some(MeetingRole::Presenter);
63
PersonRow {
64
mri: tile.mri.clone(),
65
name: tile.name.clone(),
66
user_id: tile.user_id.clone(),
67
own: false,
68
label: role.map(role_label),
69
muted: tile.muted,
70
mic_blocked: attendee && !model.attendee_allowed(&tile.mri, Modality::Mic),
71
camera_on: tile.has_video,
72
camera_blocked: attendee && !model.attendee_allowed(&tile.mri, Modality::Camera),
73
hand: tile.hand.map(|rank| model.hand_position(rank)),
74
ringing: tile.state == TileState::Invited,
75
}
76
}
77
78
fn own_row(model: &CallModel, role: Option<MeetingRole>) -> Option<PersonRow> {
79
let mri = model.own_mri.clone()?;
80
Some(PersonRow {
81
mri,
82
name: OWN_NAME.to_owned(),
83
user_id: None,
84
own: true,
85
label: role.map(role_label),
86
muted: model.muted,
87
mic_blocked: false,
88
camera_on: model.camera_on,
89
camera_blocked: false,
90
hand: model.own_hand.map(|rank| model.hand_position(rank)),
91
ringing: false,
92
})
93
}
94
95
fn by_name(rows: &mut [PersonRow]) {
96
rows.sort_by_key(|row| (!row.own, row.name.to_lowercase()));
97
}
98
99
pub fn people_sections(model: &CallModel) -> PeopleSections {
100
let in_meeting = model.kind == CallKind::Meeting;
101
let own_role = in_meeting.then(|| {
102
model
103
.own_role
104
.or_else(|| model.can_manage().then_some(MeetingRole::Organizer))
105
.unwrap_or(MeetingRole::Attendee)
106
});
107
let mut rows: Vec<(MeetingRole, PersonRow)> = Vec::new();
108
let mut lobby = Vec::new();
109
for tile in model.tiles.iter().filter(|tile| !tile.mri.starts_with(BOT_PREFIX)) {
110
match tile.state {
111
TileState::InLobby => lobby.push(LobbyRow {
112
mri: tile.mri.clone(),
113
name: tile.name.clone(),
114
user_id: tile.user_id.clone(),
115
}),
116
TileState::Present | TileState::Invited => {
117
let role = in_meeting.then(|| tile.role.unwrap_or(MeetingRole::Attendee));
118
rows.push((role.unwrap_or(MeetingRole::Attendee), tile_row(model, tile, role)));
119
}
120
TileState::Left => {}
121
}
122
}
123
if let Some(own) = own_row(model, own_role) {
124
rows.push((own_role.unwrap_or(MeetingRole::Attendee), own));
125
}
126
let count = rows.len();
127
let mut hands: Vec<PersonRow> = rows
128
.iter()
129
.filter(|(_, row)| row.hand.is_some())
130
.map(|(_, row)| row.clone())
131
.collect();
132
hands.sort_by_key(|row| row.hand);
133
let groups = if in_meeting {
134
[MeetingRole::Organizer, MeetingRole::Presenter, MeetingRole::Attendee]
135
.into_iter()
136
.filter_map(|role| {
137
let mut group: Vec<PersonRow> = rows
138
.iter()
139
.filter(|(row_role, _)| *row_role == role)
140
.map(|(_, row)| row.clone())
141
.collect();
142
by_name(&mut group);
143
(!group.is_empty()).then_some(PeopleGroup { title: group_title(role), rows: group })
144
})
145
.collect()
146
} else {
147
let mut flat: Vec<PersonRow> = rows.into_iter().map(|(_, row)| row).collect();
148
by_name(&mut flat);
149
vec![PeopleGroup { title: FLAT_TITLE, rows: flat }]
150
};
151
PeopleSections { count, lobby, hands, groups }
152
}
153
154
#[cfg(test)]
155
mod tests {
156
use std::time::Instant;
157
158
use calling::{AttendeeLimits, CallState, CallUpdate, MeetingCapability, PublishedState, RaisedHand, RosterEntry};
159
160
use super::*;
161
162
fn entry(mri: &str, name: &str, role: Option<MeetingRole>) -> RosterEntry {
163
RosterEntry { mri: mri.into(), display_name: name.into(), role, ..RosterEntry::default() }
164
}
165
166
fn raised(mut entry: RosterEntry, rank: u64) -> RosterEntry {
167
entry.hand = Some(RaisedHand { state_id: format!("s-{rank}"), rank });
168
entry
169
}
170
171
fn meeting(entries: Vec<RosterEntry>) -> CallModel {
172
let mut model = CallModel::meeting("Standup", true);
173
model.apply(CallUpdate::OwnIdentity { mri: "8:orgid:me".into() });
174
model.apply(CallUpdate::State(CallState::Connected { since: Instant::now() }));
175
model.apply(CallUpdate::Roster(entries));
176
model
177
}
178
179
fn titles(sections: &PeopleSections) -> Vec<&'static str> {
180
sections.groups.iter().map(|group| group.title).collect()
181
}
182
183
fn names(group: &PeopleGroup) -> Vec<&str> {
184
group.rows.iter().map(|row| row.name.as_str()).collect()
185
}
186
187
#[test]
188
fn a_meeting_groups_by_role_and_keeps_only_the_groups_that_exist() {
189
let model = meeting(vec![
190
entry("8:orgid:me", "Me", Some(MeetingRole::Organizer)),
191
entry("8:orgid:a", "Ana", Some(MeetingRole::Attendee)),
192
entry("8:orgid:b", "bo", Some(MeetingRole::Attendee)),
193
entry("8:orgid:c", "Cy", None),
194
]);
195
let sections = people_sections(&model);
196
assert_eq!(titles(§ions), vec!["Organizers", "Attendees"]);
197
assert_eq!(names(§ions.groups[0]), vec!["You"]);
198
assert_eq!(names(§ions.groups[1]), vec!["Ana", "bo", "Cy"]);
199
assert_eq!(sections.count, 4);
200
let presenter = meeting(vec![entry("8:orgid:p", "Pia", Some(MeetingRole::Presenter))]);
201
assert_eq!(titles(&people_sections(&presenter)), vec!["Organizers", "Presenters"]);
202
}
203
204
#[test]
205
fn direct_and_group_calls_show_one_flat_list_without_role_labels() {
206
let mut model = CallModel::people("Team", &[("8:orgid:a".into(), "Ana".into()), ("8:orgid:b".into(), "Bo".into())]);
207
model.apply(CallUpdate::OwnIdentity { mri: "8:orgid:me".into() });
208
model.apply(CallUpdate::State(CallState::Connected { since: Instant::now() }));
209
let sections = people_sections(&model);
210
assert_eq!(titles(§ions), vec!["In this call"]);
211
assert_eq!(names(§ions.groups[0]), vec!["You", "Ana", "Bo"]);
212
assert!(sections.groups[0].rows.iter().all(|row| row.label.is_none()));
213
assert!(sections.groups[0].rows[1].ringing);
214
}
215
216
#[test]
217
fn raised_hands_queue_in_raise_order_and_the_lobby_stays_out_of_the_groups() {
218
let mut waiting = entry("8:orgid:w", "Wen", None);
219
waiting.in_lobby = true;
220
let model = meeting(vec![
221
entry("8:orgid:me", "Me", Some(MeetingRole::Organizer)),
222
raised(entry("8:orgid:a", "Ana", None), 7),
223
raised(entry("8:orgid:b", "Bo", None), 3),
224
waiting,
225
]);
226
let sections = people_sections(&model);
227
let queue: Vec<(&str, Option<usize>)> = sections.hands.iter().map(|row| (row.name.as_str(), row.hand)).collect();
228
assert_eq!(queue, vec![("Bo", Some(1)), ("Ana", Some(2))]);
229
assert_eq!(sections.lobby.len(), 1);
230
assert_eq!(sections.lobby[0].name, "Wen");
231
assert_eq!(sections.count, 3);
232
}
233
234
#[test]
235
fn bots_stay_out_and_the_own_role_falls_back_to_the_organizer_flag() {
236
let model = meeting(vec![entry("28:recorder", "Recorder", Some(MeetingRole::Presenter))]);
237
let sections = people_sections(&model);
238
assert_eq!(sections.count, 1);
239
assert_eq!(sections.groups[0].title, "Organizers");
240
assert_eq!(sections.groups[0].rows[0].label, Some("Organizer"));
241
}
242
243
#[test]
244
fn only_attendees_show_blocked_microphones() {
245
let blocked = AttendeeLimits {
246
mic_blocked: Some(PublishedState { state_id: "x".into(), rank: 1 }),
247
..AttendeeLimits::default()
248
};
249
let mut limited = entry("8:orgid:a", "Ana", Some(MeetingRole::Attendee));
250
limited.limits = blocked.clone();
251
let mut presenter = entry("8:orgid:p", "Pia", Some(MeetingRole::Presenter));
252
presenter.limits = blocked;
253
let mut model = meeting(vec![limited, presenter, entry("8:orgid:b", "Bo", Some(MeetingRole::Attendee))]);
254
model.apply(CallUpdate::Capability(MeetingCapability { attendee_camera_off: true, ..MeetingCapability::default() }));
255
let sections = people_sections(&model);
256
let attendees = sections.groups.iter().find(|group| group.title == "Attendees").unwrap();
257
assert!(attendees.rows[0].mic_blocked && !attendees.rows[1].mic_blocked);
258
assert!(attendees.rows.iter().all(|row| row.camera_blocked));
259
let presenters = sections.groups.iter().find(|group| group.title == "Presenters").unwrap();
260
assert!(!presenters.rows[0].mic_blocked && !presenters.rows[0].camera_blocked);
261
}
262
263
#[test]
264
fn a_one_to_one_call_turns_into_a_group_when_a_third_person_joins() {
265
let mut model = CallModel::people("Ana", &[("8:orgid:a".into(), "Ana".into())]);
266
model.apply(CallUpdate::Roster(vec![entry("8:orgid:a", "Ana", None)]));
267
assert_eq!(model.kind, CallKind::Direct);
268
model.apply(CallUpdate::Roster(vec![entry("8:orgid:a", "Ana", None), entry("8:orgid:b", "Bo", None)]));
269
assert_eq!(model.kind, CallKind::Group);
270
}
271
}
@@ -0,0 +1,271 @@1
use calling::{MeetingRole, Modality};2
3
use super::model::{CallKind, CallModel, Tile, TileState};4
5
const BOT_PREFIX: &str = "28:";6
const FLAT_TITLE: &str = "In this call";7
const OWN_NAME: &str = "You";8
9
#[derive(Debug, Clone, PartialEq, Eq)]10
pub struct PersonRow {11
pub mri: String,12
pub name: String,13
pub user_id: Option<String>,14
pub own: bool,15
pub label: Option<&'static str>,16
pub muted: bool,17
pub mic_blocked: bool,18
pub camera_on: bool,19
pub camera_blocked: bool,20
pub hand: Option<usize>,21
pub ringing: bool,22
}23
24
#[derive(Debug, Clone, PartialEq, Eq)]25
pub struct LobbyRow {26
pub mri: String,27
pub name: String,28
pub user_id: Option<String>,29
}30
31
#[derive(Debug, Clone, PartialEq, Eq)]32
pub struct PeopleGroup {33
pub title: &'static str,34
pub rows: Vec<PersonRow>,35
}36
37
#[derive(Debug, Clone, PartialEq, Eq, Default)]38
pub struct PeopleSections {39
pub count: usize,40
pub lobby: Vec<LobbyRow>,41
pub hands: Vec<PersonRow>,42
pub groups: Vec<PeopleGroup>,43
}44
45
pub fn role_label(role: MeetingRole) -> &'static str {46
match role {47
MeetingRole::Organizer => "Organizer",48
MeetingRole::Presenter => "Presenter",49
MeetingRole::Attendee => "Attendee",50
}51
}52
53
fn group_title(role: MeetingRole) -> &'static str {54
match role {55
MeetingRole::Organizer => "Organizers",56
MeetingRole::Presenter => "Presenters",57
MeetingRole::Attendee => "Attendees",58
}59
}60
61
fn tile_row(model: &CallModel, tile: &Tile, role: Option<MeetingRole>) -> PersonRow {62
let attendee = role != Some(MeetingRole::Organizer) && role != Some(MeetingRole::Presenter);63
PersonRow {64
mri: tile.mri.clone(),65
name: tile.name.clone(),66
user_id: tile.user_id.clone(),67
own: false,68
label: role.map(role_label),69
muted: tile.muted,70
mic_blocked: attendee && !model.attendee_allowed(&tile.mri, Modality::Mic),71
camera_on: tile.has_video,72
camera_blocked: attendee && !model.attendee_allowed(&tile.mri, Modality::Camera),73
hand: tile.hand.map(|rank| model.hand_position(rank)),74
ringing: tile.state == TileState::Invited,75
}76
}77
78
fn own_row(model: &CallModel, role: Option<MeetingRole>) -> Option<PersonRow> {79
let mri = model.own_mri.clone()?;80
Some(PersonRow {81
mri,82
name: OWN_NAME.to_owned(),83
user_id: None,84
own: true,85
label: role.map(role_label),86
muted: model.muted,87
mic_blocked: false,88
camera_on: model.camera_on,89
camera_blocked: false,90
hand: model.own_hand.map(|rank| model.hand_position(rank)),91
ringing: false,92
})93
}94
95
fn by_name(rows: &mut [PersonRow]) {96
rows.sort_by_key(|row| (!row.own, row.name.to_lowercase()));97
}98
99
pub fn people_sections(model: &CallModel) -> PeopleSections {100
let in_meeting = model.kind == CallKind::Meeting;101
let own_role = in_meeting.then(|| {102
model103
.own_role104
.or_else(|| model.can_manage().then_some(MeetingRole::Organizer))105
.unwrap_or(MeetingRole::Attendee)106
});107
let mut rows: Vec<(MeetingRole, PersonRow)> = Vec::new();108
let mut lobby = Vec::new();109
for tile in model.tiles.iter().filter(|tile| !tile.mri.starts_with(BOT_PREFIX)) {110
match tile.state {111
TileState::InLobby => lobby.push(LobbyRow {112
mri: tile.mri.clone(),113
name: tile.name.clone(),114
user_id: tile.user_id.clone(),115
}),116
TileState::Present | TileState::Invited => {117
let role = in_meeting.then(|| tile.role.unwrap_or(MeetingRole::Attendee));118
rows.push((role.unwrap_or(MeetingRole::Attendee), tile_row(model, tile, role)));119
}120
TileState::Left => {}121
}122
}123
if let Some(own) = own_row(model, own_role) {124
rows.push((own_role.unwrap_or(MeetingRole::Attendee), own));125
}126
let count = rows.len();127
let mut hands: Vec<PersonRow> = rows128
.iter()129
.filter(|(_, row)| row.hand.is_some())130
.map(|(_, row)| row.clone())131
.collect();132
hands.sort_by_key(|row| row.hand);133
let groups = if in_meeting {134
[MeetingRole::Organizer, MeetingRole::Presenter, MeetingRole::Attendee]135
.into_iter()136
.filter_map(|role| {137
let mut group: Vec<PersonRow> = rows138
.iter()139
.filter(|(row_role, _)| *row_role == role)140
.map(|(_, row)| row.clone())141
.collect();142
by_name(&mut group);143
(!group.is_empty()).then_some(PeopleGroup { title: group_title(role), rows: group })144
})145
.collect()146
} else {147
let mut flat: Vec<PersonRow> = rows.into_iter().map(|(_, row)| row).collect();148
by_name(&mut flat);149
vec![PeopleGroup { title: FLAT_TITLE, rows: flat }]150
};151
PeopleSections { count, lobby, hands, groups }152
}153
154
#[cfg(test)]155
mod tests {156
use std::time::Instant;157
158
use calling::{AttendeeLimits, CallState, CallUpdate, MeetingCapability, PublishedState, RaisedHand, RosterEntry};159
160
use super::*;161
162
fn entry(mri: &str, name: &str, role: Option<MeetingRole>) -> RosterEntry {163
RosterEntry { mri: mri.into(), display_name: name.into(), role, ..RosterEntry::default() }164
}165
166
fn raised(mut entry: RosterEntry, rank: u64) -> RosterEntry {167
entry.hand = Some(RaisedHand { state_id: format!("s-{rank}"), rank });168
entry169
}170
171
fn meeting(entries: Vec<RosterEntry>) -> CallModel {172
let mut model = CallModel::meeting("Standup", true);173
model.apply(CallUpdate::OwnIdentity { mri: "8:orgid:me".into() });174
model.apply(CallUpdate::State(CallState::Connected { since: Instant::now() }));175
model.apply(CallUpdate::Roster(entries));176
model177
}178
179
fn titles(sections: &PeopleSections) -> Vec<&'static str> {180
sections.groups.iter().map(|group| group.title).collect()181
}182
183
fn names(group: &PeopleGroup) -> Vec<&str> {184
group.rows.iter().map(|row| row.name.as_str()).collect()185
}186
187
#[test]188
fn a_meeting_groups_by_role_and_keeps_only_the_groups_that_exist() {189
let model = meeting(vec![190
entry("8:orgid:me", "Me", Some(MeetingRole::Organizer)),191
entry("8:orgid:a", "Ana", Some(MeetingRole::Attendee)),192
entry("8:orgid:b", "bo", Some(MeetingRole::Attendee)),193
entry("8:orgid:c", "Cy", None),194
]);195
let sections = people_sections(&model);196
assert_eq!(titles(§ions), vec!["Organizers", "Attendees"]);197
assert_eq!(names(§ions.groups[0]), vec!["You"]);198
assert_eq!(names(§ions.groups[1]), vec!["Ana", "bo", "Cy"]);199
assert_eq!(sections.count, 4);200
let presenter = meeting(vec![entry("8:orgid:p", "Pia", Some(MeetingRole::Presenter))]);201
assert_eq!(titles(&people_sections(&presenter)), vec!["Organizers", "Presenters"]);202
}203
204
#[test]205
fn direct_and_group_calls_show_one_flat_list_without_role_labels() {206
let mut model = CallModel::people("Team", &[("8:orgid:a".into(), "Ana".into()), ("8:orgid:b".into(), "Bo".into())]);207
model.apply(CallUpdate::OwnIdentity { mri: "8:orgid:me".into() });208
model.apply(CallUpdate::State(CallState::Connected { since: Instant::now() }));209
let sections = people_sections(&model);210
assert_eq!(titles(§ions), vec!["In this call"]);211
assert_eq!(names(§ions.groups[0]), vec!["You", "Ana", "Bo"]);212
assert!(sections.groups[0].rows.iter().all(|row| row.label.is_none()));213
assert!(sections.groups[0].rows[1].ringing);214
}215
216
#[test]217
fn raised_hands_queue_in_raise_order_and_the_lobby_stays_out_of_the_groups() {218
let mut waiting = entry("8:orgid:w", "Wen", None);219
waiting.in_lobby = true;220
let model = meeting(vec![221
entry("8:orgid:me", "Me", Some(MeetingRole::Organizer)),222
raised(entry("8:orgid:a", "Ana", None), 7),223
raised(entry("8:orgid:b", "Bo", None), 3),224
waiting,225
]);226
let sections = people_sections(&model);227
let queue: Vec<(&str, Option<usize>)> = sections.hands.iter().map(|row| (row.name.as_str(), row.hand)).collect();228
assert_eq!(queue, vec![("Bo", Some(1)), ("Ana", Some(2))]);229
assert_eq!(sections.lobby.len(), 1);230
assert_eq!(sections.lobby[0].name, "Wen");231
assert_eq!(sections.count, 3);232
}233
234
#[test]235
fn bots_stay_out_and_the_own_role_falls_back_to_the_organizer_flag() {236
let model = meeting(vec![entry("28:recorder", "Recorder", Some(MeetingRole::Presenter))]);237
let sections = people_sections(&model);238
assert_eq!(sections.count, 1);239
assert_eq!(sections.groups[0].title, "Organizers");240
assert_eq!(sections.groups[0].rows[0].label, Some("Organizer"));241
}242
243
#[test]244
fn only_attendees_show_blocked_microphones() {245
let blocked = AttendeeLimits {246
mic_blocked: Some(PublishedState { state_id: "x".into(), rank: 1 }),247
..AttendeeLimits::default()248
};249
let mut limited = entry("8:orgid:a", "Ana", Some(MeetingRole::Attendee));250
limited.limits = blocked.clone();251
let mut presenter = entry("8:orgid:p", "Pia", Some(MeetingRole::Presenter));252
presenter.limits = blocked;253
let mut model = meeting(vec![limited, presenter, entry("8:orgid:b", "Bo", Some(MeetingRole::Attendee))]);254
model.apply(CallUpdate::Capability(MeetingCapability { attendee_camera_off: true, ..MeetingCapability::default() }));255
let sections = people_sections(&model);256
let attendees = sections.groups.iter().find(|group| group.title == "Attendees").unwrap();257
assert!(attendees.rows[0].mic_blocked && !attendees.rows[1].mic_blocked);258
assert!(attendees.rows.iter().all(|row| row.camera_blocked));259
let presenters = sections.groups.iter().find(|group| group.title == "Presenters").unwrap();260
assert!(!presenters.rows[0].mic_blocked && !presenters.rows[0].camera_blocked);261
}262
263
#[test]264
fn a_one_to_one_call_turns_into_a_group_when_a_third_person_joins() {265
let mut model = CallModel::people("Ana", &[("8:orgid:a".into(), "Ana".into())]);266
model.apply(CallUpdate::Roster(vec![entry("8:orgid:a", "Ana", None)]));267
assert_eq!(model.kind, CallKind::Direct);268
model.apply(CallUpdate::Roster(vec![entry("8:orgid:a", "Ana", None), entry("8:orgid:b", "Bo", None)]));269
assert_eq!(model.kind, CallKind::Group);270
}271
}@@ -0,0 +1,369 @@
1
use calling::{CallCommand, Callee, MeetingOptions, MeetingRole, Modality};
2
use gpui_kit::*;
3
4
use super::actions::NOT_CONNECTED_NOTICE;
5
use super::features::TransferCandidate;
6
use super::model::{CallKind, Tile};
7
use super::options_dialog::OptionsDialog;
8
use crate::app_state::{AppEvent, AppState};
9
use crate::runtime;
10
11
const INVITE_FAILED_NOTICE: &str = "Could not add that person";
12
const NO_PEER_NOTICE: &str = "This call cannot be extended";
13
14
impl AppState {
15
pub fn toggle_call_people(&mut self, cx: &mut Context<Self>) {
16
let Some(call) = self.call.as_mut() else {
17
return;
18
};
19
call.people_open = !call.people_open;
20
if call.people_open {
21
call.chat_open = false;
22
call.transcript_open = false;
23
self.transcript_panel = None;
24
}
25
cx.emit(AppEvent::Call);
26
cx.notify();
27
}
28
29
pub fn set_call_lock(&mut self, locked: bool, _cx: &mut Context<Self>) {
30
if self.call.as_ref().is_some_and(|call| call.model.organizes_meeting()) {
31
self.send_call_command(CallCommand::SetLock(locked));
32
}
33
}
34
35
pub fn set_call_role(&mut self, mri: String, role: MeetingRole, _cx: &mut Context<Self>) {
36
let allowed = self.call.as_ref().is_some_and(|call| {
37
call.model.can_change_roles(&mri) && role != MeetingRole::Organizer
38
});
39
if allowed {
40
self.send_call_command(CallCommand::SetRole { mri, role });
41
}
42
}
43
44
pub fn set_call_attendee_modality(
45
&mut self,
46
mri: String,
47
modality: Modality,
48
allowed: bool,
49
_cx: &mut Context<Self>,
50
) {
51
if self.call.as_ref().is_some_and(|call| call.model.can_change_roles(&mri)) {
52
self.send_call_command(CallCommand::SetAttendeeModality { mri, modality, allowed });
53
}
54
}
55
56
pub fn set_call_attendee_restrictions(&mut self, mic_off: bool, camera_off: bool, _cx: &mut Context<Self>) {
57
if self.call.as_ref().is_some_and(|call| call.model.organizes_meeting()) {
58
self.send_call_command(CallCommand::SetAttendeeRestrictions { mic_off, camera_off });
59
}
60
}
61
62
pub fn open_meeting_options(&mut self, cx: &mut Context<Self>) {
63
let Some(call) = self.call.as_mut().filter(|call| call.model.organizes_meeting()) else {
64
return;
65
};
66
call.options_dialog = Some(OptionsDialog::loading());
67
self.send_call_command(CallCommand::LoadMeetingOptions);
68
cx.notify();
69
}
70
71
pub fn close_meeting_options(&mut self, cx: &mut Context<Self>) {
72
if let Some(call) = self.call.as_mut().filter(|call| call.options_dialog.is_some()) {
73
call.options_dialog = None;
74
cx.notify();
75
}
76
}
77
78
pub fn edit_meeting_options(&mut self, edit: impl FnOnce(&mut MeetingOptions), cx: &mut Context<Self>) {
79
let Some(draft) = self
80
.call
81
.as_mut()
82
.and_then(|call| call.options_dialog.as_mut())
83
.and_then(|dialog| dialog.draft.as_mut())
84
else {
85
return;
86
};
87
edit(draft);
88
cx.notify();
89
}
90
91
pub fn save_meeting_options(&mut self, cx: &mut Context<Self>) {
92
let writes = self
93
.call
94
.as_mut()
95
.and_then(|call| call.options_dialog.as_mut())
96
.and_then(OptionsDialog::begin_save);
97
if let Some(writes) = writes {
98
self.send_call_command(CallCommand::SaveMeetingOptions(writes));
99
cx.notify();
100
}
101
}
102
103
pub fn invite_candidates(&self) -> Vec<TransferCandidate> {
104
let present: Vec<&str> = self
105
.call
106
.as_ref()
107
.map(|call| call.model.tiles.iter().map(|tile| tile.mri.as_str()).collect())
108
.unwrap_or_default();
109
self.transfer_candidates()
110
.into_iter()
111
.filter(|candidate| !present.contains(&candidate.mri.as_str()))
112
.collect()
113
}
114
115
pub fn open_invite_picker(
116
&mut self,
117
picker: Entity<crate::views::transfer_picker::TransferPicker>,
118
cx: &mut Context<Self>,
119
) {
120
if self.call.as_ref().is_some_and(|call| call.model.can_invite()) {
121
self.transfer_picker = Some(picker);
122
cx.notify();
123
}
124
}
125
126
pub fn invite_call_person(&mut self, target: TransferCandidate, cx: &mut Context<Self>) {
127
self.close_transfer_picker(cx);
128
let Some(call) = self.call.as_mut().filter(|call| call.model.can_invite()) else {
129
return;
130
};
131
let callee = Callee { mri: target.mri.clone(), display_name: target.name.clone() };
132
if !call.model.tiles.iter().any(|tile| tile.mri == callee.mri) {
133
call.model.tiles.push(Tile::invited(&callee.mri, &callee.display_name));
134
}
135
let one_to_one = call.model.kind == CallKind::Direct;
136
let peer_user_id = call
137
.model
138
.tiles
139
.iter()
140
.find(|tile| tile.mri != callee.mri)
141
.and_then(|tile| tile.user_id.clone());
142
let call_id = call.id;
143
cx.emit(AppEvent::Call);
144
cx.notify();
145
if !one_to_one || self.mode.demo {
146
self.send_call_command(CallCommand::Invite { callees: vec![callee], group_thread: None });
147
return;
148
}
149
let (Some(engine), Some(peer_user_id), Some(invited_user_id)) =
150
(self.engine.clone(), peer_user_id, target.user_id.clone())
151
else {
152
let notice = if self.engine.is_none() { NOT_CONNECTED_NOTICE } else { NO_PEER_NOTICE };
153
self.raise_notice(notice.to_owned(), None, cx);
154
return;
155
};
156
let receiver = runtime::spawn(async move {
157
engine.create_group(&[peer_user_id, invited_user_id], None).await
158
});
159
cx.spawn(async move |this, cx| {
160
let created = receiver.await.ok().and_then(Result::ok);
161
this.update(cx, |state, cx| match created {
162
Some(thread_id) if state.call.as_ref().is_some_and(|call| call.id == call_id) => {
163
state.send_call_command(CallCommand::Invite {
164
callees: vec![callee],
165
group_thread: Some(thread_id),
166
});
167
}
168
_ => state.raise_notice(INVITE_FAILED_NOTICE.to_owned(), None, cx),
169
})
170
.ok();
171
})
172
.detach();
173
}
174
}
175
176
#[cfg(test)]
177
mod tests {
178
use std::sync::Arc;
179
use std::time::Instant;
180
181
use calling::{
182
CallCommand, CallControl, CallState, CallUpdate, MeetingCapability, MeetingOptions, MeetingRole,
183
Modality, RosterEntry, call_channel,
184
};
185
use gpui_kit::{AppContext as _, Entity, TestAppContext};
186
use serde_json::json;
187
use store::Store;
188
189
use crate::app_state::{AppState, Mode};
190
use crate::call::{ActiveCall, CallModel, TransferCandidate};
191
192
fn app_with_meeting(cx: &mut TestAppContext, organizer: bool) -> (Entity<AppState>, CallControl) {
193
cx.update(gpui_kit::init);
194
let store = Arc::new(Store::open_in_memory().unwrap());
195
let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));
196
let (handle, control) = call_channel();
197
let mut model = CallModel::meeting("Standup", organizer);
198
model.apply(CallUpdate::State(CallState::Connected { since: Instant::now() }));
199
model.apply(CallUpdate::OwnIdentity { mri: "8:orgid:me".into() });
200
model.apply(CallUpdate::Roster(vec![RosterEntry {
201
mri: "8:orgid:a".into(),
202
display_name: "Ana".into(),
203
role: Some(MeetingRole::Attendee),
204
..RosterEntry::default()
205
}]));
206
cx.update(|cx| {
207
app.update(cx, |state, _| {
208
state.call = Some(ActiveCall::new(
209
7,
210
model,
211
handle.commands,
212
Some("19:meeting_x@thread.v2".into()),
213
handle.video,
214
));
215
})
216
});
217
(app, control)
218
}
219
220
fn options() -> MeetingOptions {
221
let option = |name: &str, value: serde_json::Value| json!({"name": name, "currentValue": value});
222
MeetingOptions::from_response(&json!({"options": [
223
option("AutoAdmittedUsers", json!("EveryoneInCompany")),
224
option("PresenterOption", json!("Everyone")),
225
option("AttendeeRestrictions", json!("UnRestricted")),
226
option("AllowMeetingChat", json!("Enabled")),
227
option("AllowTeamsMeetingReactions", json!(true)),
228
option("AutoRecordAndTranscribeMode", json!("Off")),
229
]}))
230
.unwrap()
231
}
232
233
#[gpui_kit::test]
234
fn the_people_panel_and_the_chat_panel_exclude_each_other(cx: &mut TestAppContext) {
235
let (app, _control) = app_with_meeting(cx, true);
236
let open = |app: &Entity<AppState>, cx: &mut TestAppContext| {
237
cx.update(|cx| {
238
let call = app.read(cx).call.as_ref().unwrap();
239
(call.people_open, call.chat_open)
240
})
241
};
242
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)));
243
assert_eq!(open(&app, cx), (false, true));
244
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_people(cx)));
245
assert_eq!(open(&app, cx), (true, false));
246
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)));
247
assert_eq!(open(&app, cx), (false, true));
248
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_people(cx)));
249
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_people(cx)));
250
assert_eq!(open(&app, cx), (false, false));
251
}
252
253
#[gpui_kit::test]
254
fn organizer_actions_become_commands_and_attendees_send_nothing(cx: &mut TestAppContext) {
255
let (attendee, mut attendee_control) = app_with_meeting(cx, false);
256
cx.update(|cx| {
257
attendee.update(cx, |state, cx| {
258
state.set_call_lock(true, cx);
259
state.set_call_role("8:orgid:a".into(), MeetingRole::Presenter, cx);
260
state.set_call_attendee_modality("8:orgid:a".into(), Modality::Mic, false, cx);
261
state.set_call_attendee_restrictions(true, false, cx);
262
state.open_meeting_options(cx);
263
})
264
});
265
assert_eq!(attendee_control.try_recv_command(), None);
266
let (organizer, mut control) = app_with_meeting(cx, true);
267
cx.update(|cx| {
268
organizer.update(cx, |state, cx| {
269
state.set_call_lock(true, cx);
270
state.set_call_role("8:orgid:a".into(), MeetingRole::Presenter, cx);
271
state.set_call_role("8:orgid:a".into(), MeetingRole::Organizer, cx);
272
state.set_call_attendee_modality("8:orgid:a".into(), Modality::Camera, false, cx);
273
state.set_call_attendee_restrictions(true, true, cx);
274
})
275
});
276
assert_eq!(control.try_recv_command(), Some(CallCommand::SetLock(true)));
277
assert_eq!(
278
control.try_recv_command(),
279
Some(CallCommand::SetRole { mri: "8:orgid:a".into(), role: MeetingRole::Presenter })
280
);
281
assert_eq!(
282
control.try_recv_command(),
283
Some(CallCommand::SetAttendeeModality { mri: "8:orgid:a".into(), modality: Modality::Camera, allowed: false })
284
);
285
assert_eq!(
286
control.try_recv_command(),
287
Some(CallCommand::SetAttendeeRestrictions { mic_off: true, camera_off: true })
288
);
289
assert_eq!(control.try_recv_command(), None);
290
}
291
292
#[gpui_kit::test]
293
fn the_capability_update_marks_the_meeting_as_locked(cx: &mut TestAppContext) {
294
let (app, _control) = app_with_meeting(cx, true);
295
cx.update(|cx| {
296
app.update(cx, |state, cx| {
297
state.apply_call_update(
298
7,
299
CallUpdate::Capability(MeetingCapability { locked: true, ..MeetingCapability::default() }),
300
cx,
301
)
302
})
303
});
304
assert!(cx.update(|cx| app.read(cx).call.as_ref().unwrap().model.capability.locked));
305
}
306
307
#[gpui_kit::test]
308
fn the_options_dialog_loads_saves_only_changes_and_keeps_errors_inline(cx: &mut TestAppContext) {
309
let (app, mut control) = app_with_meeting(cx, true);
310
cx.update(|cx| app.update(cx, |state, cx| state.open_meeting_options(cx)));
311
assert_eq!(control.try_recv_command(), Some(CallCommand::LoadMeetingOptions));
312
cx.update(|cx| {
313
app.update(cx, |state, cx| {
314
state.apply_call_update(7, CallUpdate::MeetingOptions(Err("The options could not be read".into())), cx)
315
})
316
});
317
let error = cx.update(|cx| app.read(cx).call.as_ref().unwrap().options_dialog.as_ref().unwrap().error.clone());
318
assert_eq!(error.as_deref(), Some("The options could not be read"));
319
cx.update(|cx| {
320
app.update(cx, |state, cx| {
321
state.apply_call_update(7, CallUpdate::MeetingOptions(Ok(options())), cx);
322
state.save_meeting_options(cx);
323
state.edit_meeting_options(|draft| draft.meeting_chat = "InMeeting".into(), cx);
324
state.save_meeting_options(cx);
325
})
326
});
327
let Some(CallCommand::SaveMeetingOptions(writes)) = control.try_recv_command() else {
328
panic!("a save command");
329
};
330
assert_eq!(writes.len(), 1);
331
assert_eq!(writes[0].name, "AllowMeetingChat");
332
assert_eq!(control.try_recv_command(), None);
333
cx.update(|cx| {
334
app.update(cx, |state, cx| {
335
state.apply_call_update(7, CallUpdate::MeetingOptionsSaved(Err("the service refused AllowMeetingChat".into())), cx)
336
})
337
});
338
assert!(cx.update(|cx| app.read(cx).call.as_ref().unwrap().options_dialog.is_some()));
339
cx.update(|cx| {
340
app.update(cx, |state, cx| {
341
state.apply_call_update(7, CallUpdate::MeetingOptionsSaved(Ok(options())), cx)
342
})
343
});
344
assert!(cx.update(|cx| app.read(cx).call.as_ref().unwrap().options_dialog.is_none()));
345
}
346
347
#[gpui_kit::test]
348
fn inviting_into_a_meeting_sends_the_person_and_shows_them_as_ringing(cx: &mut TestAppContext) {
349
let (app, mut control) = app_with_meeting(cx, true);
350
let candidate = TransferCandidate {
351
mri: "8:orgid:bo".into(),
352
name: "Bo".into(),
353
user_id: Some("bo".into()),
354
chat_id: "19:bo".into(),
355
};
356
cx.update(|cx| app.update(cx, |state, cx| state.invite_call_person(candidate, cx)));
357
let Some(CallCommand::Invite { callees, group_thread }) = control.try_recv_command() else {
358
panic!("an invite command");
359
};
360
assert_eq!(callees.len(), 1);
361
assert_eq!(callees[0].mri, "8:orgid:bo");
362
assert_eq!(group_thread, None);
363
let ringing = cx.update(|cx| {
364
let tiles = &app.read(cx).call.as_ref().unwrap().model.tiles;
365
tiles.iter().any(|tile| tile.mri == "8:orgid:bo" && tile.invited)
366
});
367
assert!(ringing);
368
}
369
}
@@ -0,0 +1,369 @@1
use calling::{CallCommand, Callee, MeetingOptions, MeetingRole, Modality};2
use gpui_kit::*;3
4
use super::actions::NOT_CONNECTED_NOTICE;5
use super::features::TransferCandidate;6
use super::model::{CallKind, Tile};7
use super::options_dialog::OptionsDialog;8
use crate::app_state::{AppEvent, AppState};9
use crate::runtime;10
11
const INVITE_FAILED_NOTICE: &str = "Could not add that person";12
const NO_PEER_NOTICE: &str = "This call cannot be extended";13
14
impl AppState {15
pub fn toggle_call_people(&mut self, cx: &mut Context<Self>) {16
let Some(call) = self.call.as_mut() else {17
return;18
};19
call.people_open = !call.people_open;20
if call.people_open {21
call.chat_open = false;22
call.transcript_open = false;23
self.transcript_panel = None;24
}25
cx.emit(AppEvent::Call);26
cx.notify();27
}28
29
pub fn set_call_lock(&mut self, locked: bool, _cx: &mut Context<Self>) {30
if self.call.as_ref().is_some_and(|call| call.model.organizes_meeting()) {31
self.send_call_command(CallCommand::SetLock(locked));32
}33
}34
35
pub fn set_call_role(&mut self, mri: String, role: MeetingRole, _cx: &mut Context<Self>) {36
let allowed = self.call.as_ref().is_some_and(|call| {37
call.model.can_change_roles(&mri) && role != MeetingRole::Organizer38
});39
if allowed {40
self.send_call_command(CallCommand::SetRole { mri, role });41
}42
}43
44
pub fn set_call_attendee_modality(45
&mut self,46
mri: String,47
modality: Modality,48
allowed: bool,49
_cx: &mut Context<Self>,50
) {51
if self.call.as_ref().is_some_and(|call| call.model.can_change_roles(&mri)) {52
self.send_call_command(CallCommand::SetAttendeeModality { mri, modality, allowed });53
}54
}55
56
pub fn set_call_attendee_restrictions(&mut self, mic_off: bool, camera_off: bool, _cx: &mut Context<Self>) {57
if self.call.as_ref().is_some_and(|call| call.model.organizes_meeting()) {58
self.send_call_command(CallCommand::SetAttendeeRestrictions { mic_off, camera_off });59
}60
}61
62
pub fn open_meeting_options(&mut self, cx: &mut Context<Self>) {63
let Some(call) = self.call.as_mut().filter(|call| call.model.organizes_meeting()) else {64
return;65
};66
call.options_dialog = Some(OptionsDialog::loading());67
self.send_call_command(CallCommand::LoadMeetingOptions);68
cx.notify();69
}70
71
pub fn close_meeting_options(&mut self, cx: &mut Context<Self>) {72
if let Some(call) = self.call.as_mut().filter(|call| call.options_dialog.is_some()) {73
call.options_dialog = None;74
cx.notify();75
}76
}77
78
pub fn edit_meeting_options(&mut self, edit: impl FnOnce(&mut MeetingOptions), cx: &mut Context<Self>) {79
let Some(draft) = self80
.call81
.as_mut()82
.and_then(|call| call.options_dialog.as_mut())83
.and_then(|dialog| dialog.draft.as_mut())84
else {85
return;86
};87
edit(draft);88
cx.notify();89
}90
91
pub fn save_meeting_options(&mut self, cx: &mut Context<Self>) {92
let writes = self93
.call94
.as_mut()95
.and_then(|call| call.options_dialog.as_mut())96
.and_then(OptionsDialog::begin_save);97
if let Some(writes) = writes {98
self.send_call_command(CallCommand::SaveMeetingOptions(writes));99
cx.notify();100
}101
}102
103
pub fn invite_candidates(&self) -> Vec<TransferCandidate> {104
let present: Vec<&str> = self105
.call106
.as_ref()107
.map(|call| call.model.tiles.iter().map(|tile| tile.mri.as_str()).collect())108
.unwrap_or_default();109
self.transfer_candidates()110
.into_iter()111
.filter(|candidate| !present.contains(&candidate.mri.as_str()))112
.collect()113
}114
115
pub fn open_invite_picker(116
&mut self,117
picker: Entity<crate::views::transfer_picker::TransferPicker>,118
cx: &mut Context<Self>,119
) {120
if self.call.as_ref().is_some_and(|call| call.model.can_invite()) {121
self.transfer_picker = Some(picker);122
cx.notify();123
}124
}125
126
pub fn invite_call_person(&mut self, target: TransferCandidate, cx: &mut Context<Self>) {127
self.close_transfer_picker(cx);128
let Some(call) = self.call.as_mut().filter(|call| call.model.can_invite()) else {129
return;130
};131
let callee = Callee { mri: target.mri.clone(), display_name: target.name.clone() };132
if !call.model.tiles.iter().any(|tile| tile.mri == callee.mri) {133
call.model.tiles.push(Tile::invited(&callee.mri, &callee.display_name));134
}135
let one_to_one = call.model.kind == CallKind::Direct;136
let peer_user_id = call137
.model138
.tiles139
.iter()140
.find(|tile| tile.mri != callee.mri)141
.and_then(|tile| tile.user_id.clone());142
let call_id = call.id;143
cx.emit(AppEvent::Call);144
cx.notify();145
if !one_to_one || self.mode.demo {146
self.send_call_command(CallCommand::Invite { callees: vec![callee], group_thread: None });147
return;148
}149
let (Some(engine), Some(peer_user_id), Some(invited_user_id)) =150
(self.engine.clone(), peer_user_id, target.user_id.clone())151
else {152
let notice = if self.engine.is_none() { NOT_CONNECTED_NOTICE } else { NO_PEER_NOTICE };153
self.raise_notice(notice.to_owned(), None, cx);154
return;155
};156
let receiver = runtime::spawn(async move {157
engine.create_group(&[peer_user_id, invited_user_id], None).await158
});159
cx.spawn(async move |this, cx| {160
let created = receiver.await.ok().and_then(Result::ok);161
this.update(cx, |state, cx| match created {162
Some(thread_id) if state.call.as_ref().is_some_and(|call| call.id == call_id) => {163
state.send_call_command(CallCommand::Invite {164
callees: vec![callee],165
group_thread: Some(thread_id),166
});167
}168
_ => state.raise_notice(INVITE_FAILED_NOTICE.to_owned(), None, cx),169
})170
.ok();171
})172
.detach();173
}174
}175
176
#[cfg(test)]177
mod tests {178
use std::sync::Arc;179
use std::time::Instant;180
181
use calling::{182
CallCommand, CallControl, CallState, CallUpdate, MeetingCapability, MeetingOptions, MeetingRole,183
Modality, RosterEntry, call_channel,184
};185
use gpui_kit::{AppContext as _, Entity, TestAppContext};186
use serde_json::json;187
use store::Store;188
189
use crate::app_state::{AppState, Mode};190
use crate::call::{ActiveCall, CallModel, TransferCandidate};191
192
fn app_with_meeting(cx: &mut TestAppContext, organizer: bool) -> (Entity<AppState>, CallControl) {193
cx.update(gpui_kit::init);194
let store = Arc::new(Store::open_in_memory().unwrap());195
let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));196
let (handle, control) = call_channel();197
let mut model = CallModel::meeting("Standup", organizer);198
model.apply(CallUpdate::State(CallState::Connected { since: Instant::now() }));199
model.apply(CallUpdate::OwnIdentity { mri: "8:orgid:me".into() });200
model.apply(CallUpdate::Roster(vec![RosterEntry {201
mri: "8:orgid:a".into(),202
display_name: "Ana".into(),203
role: Some(MeetingRole::Attendee),204
..RosterEntry::default()205
}]));206
cx.update(|cx| {207
app.update(cx, |state, _| {208
state.call = Some(ActiveCall::new(209
7,210
model,211
handle.commands,212
Some("19:meeting_x@thread.v2".into()),213
handle.video,214
));215
})216
});217
(app, control)218
}219
220
fn options() -> MeetingOptions {221
let option = |name: &str, value: serde_json::Value| json!({"name": name, "currentValue": value});222
MeetingOptions::from_response(&json!({"options": [223
option("AutoAdmittedUsers", json!("EveryoneInCompany")),224
option("PresenterOption", json!("Everyone")),225
option("AttendeeRestrictions", json!("UnRestricted")),226
option("AllowMeetingChat", json!("Enabled")),227
option("AllowTeamsMeetingReactions", json!(true)),228
option("AutoRecordAndTranscribeMode", json!("Off")),229
]}))230
.unwrap()231
}232
233
#[gpui_kit::test]234
fn the_people_panel_and_the_chat_panel_exclude_each_other(cx: &mut TestAppContext) {235
let (app, _control) = app_with_meeting(cx, true);236
let open = |app: &Entity<AppState>, cx: &mut TestAppContext| {237
cx.update(|cx| {238
let call = app.read(cx).call.as_ref().unwrap();239
(call.people_open, call.chat_open)240
})241
};242
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)));243
assert_eq!(open(&app, cx), (false, true));244
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_people(cx)));245
assert_eq!(open(&app, cx), (true, false));246
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_chat(cx)));247
assert_eq!(open(&app, cx), (false, true));248
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_people(cx)));249
cx.update(|cx| app.update(cx, |state, cx| state.toggle_call_people(cx)));250
assert_eq!(open(&app, cx), (false, false));251
}252
253
#[gpui_kit::test]254
fn organizer_actions_become_commands_and_attendees_send_nothing(cx: &mut TestAppContext) {255
let (attendee, mut attendee_control) = app_with_meeting(cx, false);256
cx.update(|cx| {257
attendee.update(cx, |state, cx| {258
state.set_call_lock(true, cx);259
state.set_call_role("8:orgid:a".into(), MeetingRole::Presenter, cx);260
state.set_call_attendee_modality("8:orgid:a".into(), Modality::Mic, false, cx);261
state.set_call_attendee_restrictions(true, false, cx);262
state.open_meeting_options(cx);263
})264
});265
assert_eq!(attendee_control.try_recv_command(), None);266
let (organizer, mut control) = app_with_meeting(cx, true);267
cx.update(|cx| {268
organizer.update(cx, |state, cx| {269
state.set_call_lock(true, cx);270
state.set_call_role("8:orgid:a".into(), MeetingRole::Presenter, cx);271
state.set_call_role("8:orgid:a".into(), MeetingRole::Organizer, cx);272
state.set_call_attendee_modality("8:orgid:a".into(), Modality::Camera, false, cx);273
state.set_call_attendee_restrictions(true, true, cx);274
})275
});276
assert_eq!(control.try_recv_command(), Some(CallCommand::SetLock(true)));277
assert_eq!(278
control.try_recv_command(),279
Some(CallCommand::SetRole { mri: "8:orgid:a".into(), role: MeetingRole::Presenter })280
);281
assert_eq!(282
control.try_recv_command(),283
Some(CallCommand::SetAttendeeModality { mri: "8:orgid:a".into(), modality: Modality::Camera, allowed: false })284
);285
assert_eq!(286
control.try_recv_command(),287
Some(CallCommand::SetAttendeeRestrictions { mic_off: true, camera_off: true })288
);289
assert_eq!(control.try_recv_command(), None);290
}291
292
#[gpui_kit::test]293
fn the_capability_update_marks_the_meeting_as_locked(cx: &mut TestAppContext) {294
let (app, _control) = app_with_meeting(cx, true);295
cx.update(|cx| {296
app.update(cx, |state, cx| {297
state.apply_call_update(298
7,299
CallUpdate::Capability(MeetingCapability { locked: true, ..MeetingCapability::default() }),300
cx,301
)302
})303
});304
assert!(cx.update(|cx| app.read(cx).call.as_ref().unwrap().model.capability.locked));305
}306
307
#[gpui_kit::test]308
fn the_options_dialog_loads_saves_only_changes_and_keeps_errors_inline(cx: &mut TestAppContext) {309
let (app, mut control) = app_with_meeting(cx, true);310
cx.update(|cx| app.update(cx, |state, cx| state.open_meeting_options(cx)));311
assert_eq!(control.try_recv_command(), Some(CallCommand::LoadMeetingOptions));312
cx.update(|cx| {313
app.update(cx, |state, cx| {314
state.apply_call_update(7, CallUpdate::MeetingOptions(Err("The options could not be read".into())), cx)315
})316
});317
let error = cx.update(|cx| app.read(cx).call.as_ref().unwrap().options_dialog.as_ref().unwrap().error.clone());318
assert_eq!(error.as_deref(), Some("The options could not be read"));319
cx.update(|cx| {320
app.update(cx, |state, cx| {321
state.apply_call_update(7, CallUpdate::MeetingOptions(Ok(options())), cx);322
state.save_meeting_options(cx);323
state.edit_meeting_options(|draft| draft.meeting_chat = "InMeeting".into(), cx);324
state.save_meeting_options(cx);325
})326
});327
let Some(CallCommand::SaveMeetingOptions(writes)) = control.try_recv_command() else {328
panic!("a save command");329
};330
assert_eq!(writes.len(), 1);331
assert_eq!(writes[0].name, "AllowMeetingChat");332
assert_eq!(control.try_recv_command(), None);333
cx.update(|cx| {334
app.update(cx, |state, cx| {335
state.apply_call_update(7, CallUpdate::MeetingOptionsSaved(Err("the service refused AllowMeetingChat".into())), cx)336
})337
});338
assert!(cx.update(|cx| app.read(cx).call.as_ref().unwrap().options_dialog.is_some()));339
cx.update(|cx| {340
app.update(cx, |state, cx| {341
state.apply_call_update(7, CallUpdate::MeetingOptionsSaved(Ok(options())), cx)342
})343
});344
assert!(cx.update(|cx| app.read(cx).call.as_ref().unwrap().options_dialog.is_none()));345
}346
347
#[gpui_kit::test]348
fn inviting_into_a_meeting_sends_the_person_and_shows_them_as_ringing(cx: &mut TestAppContext) {349
let (app, mut control) = app_with_meeting(cx, true);350
let candidate = TransferCandidate {351
mri: "8:orgid:bo".into(),352
name: "Bo".into(),353
user_id: Some("bo".into()),354
chat_id: "19:bo".into(),355
};356
cx.update(|cx| app.update(cx, |state, cx| state.invite_call_person(candidate, cx)));357
let Some(CallCommand::Invite { callees, group_thread }) = control.try_recv_command() else {358
panic!("an invite command");359
};360
assert_eq!(callees.len(), 1);361
assert_eq!(callees[0].mri, "8:orgid:bo");362
assert_eq!(group_thread, None);363
let ringing = cx.update(|cx| {364
let tiles = &app.read(cx).call.as_ref().unwrap().model.tiles;365
tiles.iter().any(|tile| tile.mri == "8:orgid:bo" && tile.invited)366
});367
assert!(ringing);368
}369
}@@ -166,6 +166,7 @@ mod frames {
166
166
];
167
167
const PREJOIN_LINK: &str = "https://teams.microsoft.com/l/meetup-join/19%3ameeting_guard%40thread.v2/0?context=%7b%22Tid%22%3a%22t%22%2c%22Oid%22%3a%22o%22%7d";
168
168
const CALL_TRANSCRIPT: &str = "shell/islands/main/call-transcript";
169
const PEOPLE_PANEL: &str = "shell/islands/main/call-people";
169
170
const MENU: &str = "popup-menu";
170
171
const OWN_STATUS: &str = "shell/title-bar/own-status";
171
172
const RECAP_TAB: &str = "shell/islands/main/recap-tab";
@@ -182,6 +183,7 @@ mod frames {
182
183
Call,
183
184
Prejoin,
184
185
CallTranscript,
186
CallPeople,
185
187
}
186
188
187
189
fn parent_of(path: &str) -> Option<&str> {
@@ -299,7 +301,7 @@ mod frames {
299
301
.chain(CALL_GUARDED)
300
302
.chain(CALLS_TAGS)
301
303
.chain(PREJOIN_TAGS)
302
.chain([&CALL_TRANSCRIPT, &MENU, &RECAP_TAB, &RECAP_REGION])
304
.chain([&CALL_TRANSCRIPT, &MENU, &RECAP_TAB, &RECAP_REGION, &PEOPLE_PANEL])
303
305
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))
304
306
.collect()
305
307
}
@@ -322,6 +324,7 @@ mod frames {
322
324
hand: None,
323
325
spotlight: None,
324
326
organizer: false,
327
..Default::default()
325
328
})
326
329
.collect(),
327
330
));
@@ -417,6 +420,7 @@ mod frames {
417
420
Screen::StatusMenu,
418
421
Screen::Call,
419
422
Screen::CallTranscript,
423
Screen::CallPeople,
420
424
];
421
425
for screen in screens {
422
426
let (screen_name, status_menu) = match screen {
@@ -426,14 +430,17 @@ mod frames {
426
430
}
427
431
(name, false)
428
432
}
429
Screen::Call => {
433
Screen::Call | Screen::CallPeople => {
434
let people_open = matches!(screen, Screen::CallPeople);
430
435
visual.update(|_, cx| {
431
436
app.update(cx, |state, cx| {
432
state.call = Some(gallery_call());
437
let mut call = gallery_call();
438
call.people_open = people_open;
439
state.call = Some(call);
433
440
cx.notify();
434
441
})
435
442
});
436
("call", false)
443
(if people_open { "call-people" } else { "call" }, false)
437
444
}
438
445
Screen::Prejoin => {
439
446
let state = visual.update(|_, cx| cx.global::<AppHandle>().0.clone());
@@ -479,14 +486,18 @@ mod frames {
479
486
("status-menu", true)
480
487
}
481
488
};
489
let is_call = matches!(screen_name, "call" | "call-people" | "call-transcript");
482
490
let tags = collect(&mut visual, status_menu.then_some(MENU));
483
491
let mut expected = GUARDED.to_vec();
484
if screen_name == "call" || screen_name == "call-transcript" {
492
if is_call {
485
493
expected.extend(CALL_GUARDED);
486
494
}
487
495
if screen_name == "call-transcript" {
488
496
expected.push(CALL_TRANSCRIPT);
489
497
}
498
if screen_name == "call-people" {
499
expected.push(PEOPLE_PANEL);
500
}
490
501
if status_menu {
491
502
expected.push(MENU);
492
503
}
@@ -520,7 +531,7 @@ mod frames {
520
531
visual.simulate_keystrokes("escape");
521
532
visual.run_until_parked();
522
533
}
523
if screen_name == "call" || screen_name == "call-transcript" {
534
if is_call {
524
535
visual.update(|_, cx| {
525
536
app.update(cx, |state, cx| {
526
537
state.call = None;
@@ -166,6 +166,7 @@ mod frames {166
];166
];167
const PREJOIN_LINK: &str = "https://teams.microsoft.com/l/meetup-join/19%3ameeting_guard%40thread.v2/0?context=%7b%22Tid%22%3a%22t%22%2c%22Oid%22%3a%22o%22%7d";167
const PREJOIN_LINK: &str = "https://teams.microsoft.com/l/meetup-join/19%3ameeting_guard%40thread.v2/0?context=%7b%22Tid%22%3a%22t%22%2c%22Oid%22%3a%22o%22%7d";168
const CALL_TRANSCRIPT: &str = "shell/islands/main/call-transcript";168
const CALL_TRANSCRIPT: &str = "shell/islands/main/call-transcript";169
const PEOPLE_PANEL: &str = "shell/islands/main/call-people";169
const MENU: &str = "popup-menu";170
const MENU: &str = "popup-menu";170
const OWN_STATUS: &str = "shell/title-bar/own-status";171
const OWN_STATUS: &str = "shell/title-bar/own-status";171
const RECAP_TAB: &str = "shell/islands/main/recap-tab";172
const RECAP_TAB: &str = "shell/islands/main/recap-tab";@@ -182,6 +183,7 @@ mod frames {182
Call,183
Call,183
Prejoin,184
Prejoin,184
CallTranscript,185
CallTranscript,186
CallPeople,185
}187
}186
188
187
fn parent_of(path: &str) -> Option<&str> {189
fn parent_of(path: &str) -> Option<&str> {@@ -299,7 +301,7 @@ mod frames {299
.chain(CALL_GUARDED)301
.chain(CALL_GUARDED)300
.chain(CALLS_TAGS)302
.chain(CALLS_TAGS)301
.chain(PREJOIN_TAGS)303
.chain(PREJOIN_TAGS)302
.chain([&CALL_TRANSCRIPT, &MENU, &RECAP_TAB, &RECAP_REGION])304
.chain([&CALL_TRANSCRIPT, &MENU, &RECAP_TAB, &RECAP_REGION, &PEOPLE_PANEL])303
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))305
.filter_map(|path| visual.debug_bounds(path).map(|bounds| (*path, bounds)))304
.collect()306
.collect()305
}307
}@@ -322,6 +324,7 @@ mod frames {322
hand: None,324
hand: None,323
spotlight: None,325
spotlight: None,324
organizer: false,326
organizer: false,327
..Default::default()325
})328
})326
.collect(),329
.collect(),327
));330
));@@ -417,6 +420,7 @@ mod frames {417
Screen::StatusMenu,420
Screen::StatusMenu,418
Screen::Call,421
Screen::Call,419
Screen::CallTranscript,422
Screen::CallTranscript,423
Screen::CallPeople,420
];424
];421
for screen in screens {425
for screen in screens {422
let (screen_name, status_menu) = match screen {426
let (screen_name, status_menu) = match screen {@@ -426,14 +430,17 @@ mod frames {426
}430
}427
(name, false)431
(name, false)428
}432
}429
Screen::Call => {433
Screen::Call | Screen::CallPeople => {434
let people_open = matches!(screen, Screen::CallPeople);430
visual.update(|_, cx| {435
visual.update(|_, cx| {431
app.update(cx, |state, cx| {436
app.update(cx, |state, cx| {432
state.call = Some(gallery_call());437
let mut call = gallery_call();438
call.people_open = people_open;439
state.call = Some(call);433
cx.notify();440
cx.notify();434
})441
})435
});442
});436
("call", false)443
(if people_open { "call-people" } else { "call" }, false)437
}444
}438
Screen::Prejoin => {445
Screen::Prejoin => {439
let state = visual.update(|_, cx| cx.global::<AppHandle>().0.clone());446
let state = visual.update(|_, cx| cx.global::<AppHandle>().0.clone());@@ -479,14 +486,18 @@ mod frames {479
("status-menu", true)486
("status-menu", true)480
}487
}481
};488
};489
let is_call = matches!(screen_name, "call" | "call-people" | "call-transcript");482
let tags = collect(&mut visual, status_menu.then_some(MENU));490
let tags = collect(&mut visual, status_menu.then_some(MENU));483
let mut expected = GUARDED.to_vec();491
let mut expected = GUARDED.to_vec();484
if screen_name == "call" || screen_name == "call-transcript" {492
if is_call {485
expected.extend(CALL_GUARDED);493
expected.extend(CALL_GUARDED);486
}494
}487
if screen_name == "call-transcript" {495
if screen_name == "call-transcript" {488
expected.push(CALL_TRANSCRIPT);496
expected.push(CALL_TRANSCRIPT);489
}497
}498
if screen_name == "call-people" {499
expected.push(PEOPLE_PANEL);500
}490
if status_menu {501
if status_menu {491
expected.push(MENU);502
expected.push(MENU);492
}503
}@@ -520,7 +531,7 @@ mod frames {520
visual.simulate_keystrokes("escape");531
visual.simulate_keystrokes("escape");521
visual.run_until_parked();532
visual.run_until_parked();522
}533
}523
if screen_name == "call" || screen_name == "call-transcript" {534
if is_call {524
visual.update(|_, cx| {535
visual.update(|_, cx| {525
app.update(cx, |state, cx| {536
app.update(cx, |state, cx| {526
state.call = None;537
state.call = None;@@ -12,7 +12,7 @@ use gpui_kit::*;
12
12
13
13
use super::call_organizer::pill;
14
14
use super::call_view::{BANNER_HEIGHT, MENU_WIDTH};
15
use super::transfer_picker::TransferPicker;
15
use super::transfer_picker::{PickerMode, TransferPicker};
16
16
use super::widgets::icon;
17
17
use crate::app_state::AppState;
18
18
use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};
@@ -293,10 +293,17 @@ pub fn confirm_record_action(app: &Entity<AppState>, action: RecordAction, windo
293
293
pub fn open_transfer_picker(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {
294
294
let candidates = app.read(cx).transfer_candidates();
295
295
let picker_app = app.clone();
296
let picker = cx.new(|cx| TransferPicker::new(picker_app, candidates, window, cx));
296
let picker = cx.new(|cx| TransferPicker::new(picker_app, candidates, PickerMode::Transfer, window, cx));
297
297
app.update(cx, |state, cx| state.open_transfer_picker(picker, cx));
298
298
}
299
299
300
pub fn open_invite_picker(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {
301
let candidates = app.read(cx).invite_candidates();
302
let picker_app = app.clone();
303
let picker = cx.new(|cx| TransferPicker::new(picker_app, candidates, PickerMode::Invite, window, cx));
304
app.update(cx, |state, cx| state.open_invite_picker(picker, cx));
305
}
306
300
307
#[derive(Clone)]
301
308
pub struct CameraMenu {
302
309
pub pick: BackgroundPick,
@@ -12,7 +12,7 @@ use gpui_kit::*;12
12
13
use super::call_organizer::pill;13
use super::call_organizer::pill;14
use super::call_view::{BANNER_HEIGHT, MENU_WIDTH};14
use super::call_view::{BANNER_HEIGHT, MENU_WIDTH};15
use super::transfer_picker::TransferPicker;15
use super::transfer_picker::{PickerMode, TransferPicker};16
use super::widgets::icon;16
use super::widgets::icon;17
use crate::app_state::AppState;17
use crate::app_state::AppState;18
use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};18
use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};@@ -293,10 +293,17 @@ pub fn confirm_record_action(app: &Entity<AppState>, action: RecordAction, windo293
pub fn open_transfer_picker(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {293
pub fn open_transfer_picker(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {294
let candidates = app.read(cx).transfer_candidates();294
let candidates = app.read(cx).transfer_candidates();295
let picker_app = app.clone();295
let picker_app = app.clone();296
let picker = cx.new(|cx| TransferPicker::new(picker_app, candidates, window, cx));296
let picker = cx.new(|cx| TransferPicker::new(picker_app, candidates, PickerMode::Transfer, window, cx));297
app.update(cx, |state, cx| state.open_transfer_picker(picker, cx));297
app.update(cx, |state, cx| state.open_transfer_picker(picker, cx));298
}298
}299
299
300
pub fn open_invite_picker(app: &Entity<AppState>, window: &mut Window, cx: &mut App) {301
let candidates = app.read(cx).invite_candidates();302
let picker_app = app.clone();303
let picker = cx.new(|cx| TransferPicker::new(picker_app, candidates, PickerMode::Invite, window, cx));304
app.update(cx, |state, cx| state.open_invite_picker(picker, cx));305
}306
300
#[derive(Clone)]307
#[derive(Clone)]301
pub struct CameraMenu {308
pub struct CameraMenu {302
pub pick: BackgroundPick,309
pub pick: BackgroundPick,@@ -1,7 +1,7 @@
1
1
use std::sync::Arc;
2
2
use std::time::Instant;
3
3
4
use calling::{CaptionState, HoldState, VideoKey};
4
use calling::{CaptionState, HoldState, MeetingRole, Modality, VideoKey};
5
5
use gpui_kit::assets::IconName;
6
6
use gpui_kit::component::button::{Button, ButtonVariants as _};
7
7
use gpui_kit::component::dialog::DialogFooter;
@@ -16,6 +16,7 @@ use super::call_extras::{
16
16
CameraMenu, background_items, effect_items, open_transfer_picker,
17
17
};
18
18
use super::call_record::{record_submenu, transcript_and_settings_items};
19
use super::call_people::add_people_item;
19
20
use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
20
21
use super::widgets::icon;
21
22
use crate::app_state::AppState;
@@ -276,6 +277,9 @@ pub fn tile_menu(
276
277
}),
277
278
);
278
279
}
280
if model.can_change_roles(mri) {
281
popup = restriction_items(popup, app, model, mri);
282
}
279
283
if organizes && raised {
280
284
let (hand_app, hand_mri) = (app.clone(), mri.to_owned());
281
285
popup = popup.item(PopupMenuItem::new("Lower hand").on_click(move |_, _, cx| {
@@ -295,6 +299,47 @@ pub fn tile_menu(
295
299
popup
296
300
}
297
301
302
fn modality_item(
303
app: &Entity<AppState>,
304
mri: &str,
305
modality: Modality,
306
allowed: bool,
307
) -> PopupMenuItem {
308
let (app, mri) = (app.clone(), mri.to_owned());
309
let (label, glyph) = match (modality, allowed) {
310
(Modality::Mic, true) => ("Disable mic", IconName::MicOff),
311
(Modality::Mic, false) => ("Allow mic", IconName::Mic),
312
(Modality::Camera, true) => ("Disable camera", IconName::VideoOff),
313
(Modality::Camera, false) => ("Allow camera", IconName::Video),
314
};
315
PopupMenuItem::new(label).icon(glyph).on_click(move |_, _, cx| {
316
app.update(cx, |state, cx| {
317
state.set_call_attendee_modality(mri.clone(), modality, !allowed, cx)
318
})
319
})
320
}
321
322
fn restriction_items(
323
popup: PopupMenu,
324
app: &Entity<AppState>,
325
model: &CallModel,
326
mri: &str,
327
) -> PopupMenu {
328
let presenter = model.tile_role(mri) == Some(MeetingRole::Presenter);
329
let (role_app, role_mri) = (app.clone(), mri.to_owned());
330
popup
331
.item(modality_item(app, mri, Modality::Mic, model.attendee_allowed(mri, Modality::Mic)))
332
.item(modality_item(app, mri, Modality::Camera, model.attendee_allowed(mri, Modality::Camera)))
333
.item(
334
PopupMenuItem::new(if presenter { "Make attendee" } else { "Make presenter" })
335
.icon(IconName::Users)
336
.on_click(move |_, _, cx| {
337
let role = if presenter { MeetingRole::Attendee } else { MeetingRole::Presenter };
338
role_app.update(cx, |state, cx| state.set_call_role(role_mri.clone(), role, cx))
339
}),
340
)
341
}
342
298
343
fn more_overlay(
299
344
app: &Entity<AppState>,
300
345
model: &CallModel,
@@ -436,6 +481,7 @@ fn one_to_one_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallMo
436
481
.on_click(move |_, _, cx| hold_app.update(cx, |state, cx| state.toggle_call_hold(cx))),
437
482
);
438
483
let can_transfer = model.can_transfer();
484
popup = popup.item(add_people_item(app, model));
439
485
popup.item(
440
486
PopupMenuItem::new("Transfer...")
441
487
.icon(IconName::Forward)
@@ -1,7 +1,7 @@1
use std::sync::Arc;1
use std::sync::Arc;2
use std::time::Instant;2
use std::time::Instant;3
3
4
use calling::{CaptionState, HoldState, VideoKey};4
use calling::{CaptionState, HoldState, MeetingRole, Modality, VideoKey};5
use gpui_kit::assets::IconName;5
use gpui_kit::assets::IconName;6
use gpui_kit::component::button::{Button, ButtonVariants as _};6
use gpui_kit::component::button::{Button, ButtonVariants as _};7
use gpui_kit::component::dialog::DialogFooter;7
use gpui_kit::component::dialog::DialogFooter;@@ -16,6 +16,7 @@ use super::call_extras::{16
CameraMenu, background_items, effect_items, open_transfer_picker,16
CameraMenu, background_items, effect_items, open_transfer_picker,17
};17
};18
use super::call_record::{record_submenu, transcript_and_settings_items};18
use super::call_record::{record_submenu, transcript_and_settings_items};19
use super::call_people::add_people_item;19
use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};20
use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};20
use super::widgets::icon;21
use super::widgets::icon;21
use crate::app_state::AppState;22
use crate::app_state::AppState;@@ -276,6 +277,9 @@ pub fn tile_menu(276
}),277
}),277
);278
);278
}279
}280
if model.can_change_roles(mri) {281
popup = restriction_items(popup, app, model, mri);282
}279
if organizes && raised {283
if organizes && raised {280
let (hand_app, hand_mri) = (app.clone(), mri.to_owned());284
let (hand_app, hand_mri) = (app.clone(), mri.to_owned());281
popup = popup.item(PopupMenuItem::new("Lower hand").on_click(move |_, _, cx| {285
popup = popup.item(PopupMenuItem::new("Lower hand").on_click(move |_, _, cx| {@@ -295,6 +299,47 @@ pub fn tile_menu(295
popup299
popup296
}300
}297
301
302
fn modality_item(303
app: &Entity<AppState>,304
mri: &str,305
modality: Modality,306
allowed: bool,307
) -> PopupMenuItem {308
let (app, mri) = (app.clone(), mri.to_owned());309
let (label, glyph) = match (modality, allowed) {310
(Modality::Mic, true) => ("Disable mic", IconName::MicOff),311
(Modality::Mic, false) => ("Allow mic", IconName::Mic),312
(Modality::Camera, true) => ("Disable camera", IconName::VideoOff),313
(Modality::Camera, false) => ("Allow camera", IconName::Video),314
};315
PopupMenuItem::new(label).icon(glyph).on_click(move |_, _, cx| {316
app.update(cx, |state, cx| {317
state.set_call_attendee_modality(mri.clone(), modality, !allowed, cx)318
})319
})320
}321
322
fn restriction_items(323
popup: PopupMenu,324
app: &Entity<AppState>,325
model: &CallModel,326
mri: &str,327
) -> PopupMenu {328
let presenter = model.tile_role(mri) == Some(MeetingRole::Presenter);329
let (role_app, role_mri) = (app.clone(), mri.to_owned());330
popup331
.item(modality_item(app, mri, Modality::Mic, model.attendee_allowed(mri, Modality::Mic)))332
.item(modality_item(app, mri, Modality::Camera, model.attendee_allowed(mri, Modality::Camera)))333
.item(334
PopupMenuItem::new(if presenter { "Make attendee" } else { "Make presenter" })335
.icon(IconName::Users)336
.on_click(move |_, _, cx| {337
let role = if presenter { MeetingRole::Attendee } else { MeetingRole::Presenter };338
role_app.update(cx, |state, cx| state.set_call_role(role_mri.clone(), role, cx))339
}),340
)341
}342
298
fn more_overlay(343
fn more_overlay(299
app: &Entity<AppState>,344
app: &Entity<AppState>,300
model: &CallModel,345
model: &CallModel,@@ -436,6 +481,7 @@ fn one_to_one_items(mut popup: PopupMenu, app: &Entity<AppState>, model: &CallMo436
.on_click(move |_, _, cx| hold_app.update(cx, |state, cx| state.toggle_call_hold(cx))),481
.on_click(move |_, _, cx| hold_app.update(cx, |state, cx| state.toggle_call_hold(cx))),437
);482
);438
let can_transfer = model.can_transfer();483
let can_transfer = model.can_transfer();484
popup = popup.item(add_people_item(app, model));439
popup.item(485
popup.item(440
PopupMenuItem::new("Transfer...")486
PopupMenuItem::new("Transfer...")441
.icon(IconName::Forward)487
.icon(IconName::Forward)@@ -0,0 +1,697 @@
1
use gpui_kit::assets::IconName;
2
use gpui_kit::component::{
3
Sizable as _,
4
button::{Button, ButtonVariants as _},
5
h_flex,
6
menu::{DropdownMenu as _, PopupMenu, PopupMenuItem},
7
switch::Switch,
8
tooltip::Tooltip,
9
v_flex,
10
};
11
use gpui_kit::prelude::FluentBuilder as _;
12
use gpui_kit::*;
13
14
use super::avatar::person_avatar;
15
use super::call_extras::open_invite_picker;
16
use super::call_organizer::{pill, tile_menu};
17
use super::call_view::{BANNER_HEIGHT, CHAT_PANEL_WIDTH, MENU_WIDTH, round_control};
18
use super::widgets::{Corner, corner_badge, count_badge, icon};
19
use crate::app_state::AppState;
20
use crate::call::{
21
ActiveCall, CallKind, CallModel, OptionsDialog, PeopleSections, PersonRow, people_sections,
22
};
23
use crate::notice::truncated;
24
use crate::theme;
25
use calling::MeetingOptions;
26
27
const HEADER_HEIGHT: f32 = 48.;
28
const ROW_HEIGHT: f32 = 44.;
29
const AVATAR_SIZE: f32 = 28.;
30
const MORE_SIZE: f32 = 24.;
31
const SECTION_HEIGHT: f32 = 32.;
32
const NAME_LIMIT: usize = 26;
33
const STATE_ICON: f32 = 15.;
34
const DIALOG_WIDTH: f32 = 460.;
35
const DIALOG_BACKDROP: f32 = 0.55;
36
const FIELD_HEIGHT: f32 = 36.;
37
const DROPDOWN_WIDTH: f32 = 210.;
38
39
fn dark_text() -> Hsla {
40
hsla(0., 0., 0.08, 1.)
41
}
42
43
pub fn people_button(app: &Entity<AppState>, open: bool, raised_hands: usize) -> Stateful<Div> {
44
let app = app.clone();
45
let (background, foreground) = if open {
46
(theme::accent(), theme::on_accent())
47
} else {
48
(theme::surface_raised(), theme::text())
49
};
50
round_control("call-people", IconName::Users, background, foreground)
51
.relative()
52
.tooltip(move |window, cx| {
53
Tooltip::new(if open { "Close the people list" } else { "Show people" }).build(window, cx)
54
})
55
.when(raised_hands > 0, |button| {
56
button.child(
57
corner_badge(Corner::TopRight, 4.).child(count_badge(raised_hands as u32, false)),
58
)
59
})
60
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_people(cx)))
61
}
62
63
pub fn lock_chip(model: &CallModel) -> Option<AnyElement> {
64
model.capability.locked.then(|| {
65
h_flex()
66
.id("call-lock-chip")
67
.h(px(24.))
68
.px(px(8.))
69
.gap(px(4.))
70
.flex_none()
71
.items_center()
72
.rounded_full()
73
.bg(theme::amber())
74
.text_color(dark_text())
75
.text_size(px(12.))
76
.font_weight(FontWeight::SEMIBOLD)
77
.child(icon(IconName::Lock, 13., dark_text()))
78
.child("Locked")
79
.into_any_element()
80
})
81
}
82
83
pub fn lock_banner(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {
84
if !model.capability.locked || !model.organizes_meeting() {
85
return None;
86
}
87
let app = app.clone();
88
Some(
89
h_flex()
90
.id("call-lock-banner")
91
.w_full()
92
.h(px(BANNER_HEIGHT))
93
.flex_none()
94
.px(px(20.))
95
.gap(px(12.))
96
.items_center()
97
.justify_center()
98
.bg(theme::surface_raised())
99
.text_color(theme::text())
100
.text_size(px(13.))
101
.font_weight(FontWeight::SEMIBOLD)
102
.child("The meeting is locked. Nobody new can join.")
103
.child(
104
pill("call-lock-unlock", "Unlock", false)
105
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.set_call_lock(false, cx))),
106
)
107
.into_any_element(),
108
)
109
}
110
111
fn people_menu(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
112
let mut popup = popup.min_w(px(MENU_WIDTH));
113
if model.kind == CallKind::Direct {
114
popup = popup.item(add_people_item(app, model));
115
}
116
if !model.organizes_meeting() {
117
return popup;
118
}
119
let capability = model.capability;
120
let (mute_app, lock_app, mic_app, camera_app, options_app) =
121
(app.clone(), app.clone(), app.clone(), app.clone(), app.clone());
122
popup
123
.item(
124
PopupMenuItem::new("Mute all")
125
.icon(IconName::MicOff)
126
.on_click(move |_, _, cx| mute_app.update(cx, |state, cx| state.mute_all_call(cx))),
127
)
128
.item(
129
PopupMenuItem::new(if capability.locked { "Unlock meeting" } else { "Lock meeting" })
130
.icon(if capability.locked { IconName::LockOpen } else { IconName::Lock })
131
.on_click(move |_, _, cx| {
132
lock_app.update(cx, |state, cx| state.set_call_lock(!capability.locked, cx))
133
}),
134
)
135
.item(
136
PopupMenuItem::new(if capability.attendee_mic_off {
137
"Allow mic for attendees"
138
} else {
139
"Disable mic for attendees"
140
})
141
.icon(IconName::MicOff)
142
.on_click(move |_, _, cx| {
143
mic_app.update(cx, |state, cx| {
144
state.set_call_attendee_restrictions(
145
!capability.attendee_mic_off,
146
capability.attendee_camera_off,
147
cx,
148
)
149
})
150
}),
151
)
152
.item(
153
PopupMenuItem::new(if capability.attendee_camera_off {
154
"Allow camera for attendees"
155
} else {
156
"Disable camera for attendees"
157
})
158
.icon(IconName::VideoOff)
159
.on_click(move |_, _, cx| {
160
camera_app.update(cx, |state, cx| {
161
state.set_call_attendee_restrictions(
162
capability.attendee_mic_off,
163
!capability.attendee_camera_off,
164
cx,
165
)
166
})
167
}),
168
)
169
.separator()
170
.item(
171
PopupMenuItem::new("Meeting options...")
172
.icon(IconName::Settings)
173
.on_click(move |_, _, cx| {
174
options_app.update(cx, |state, cx| state.open_meeting_options(cx))
175
}),
176
)
177
}
178
179
pub fn add_people_item(app: &Entity<AppState>, model: &CallModel) -> PopupMenuItem {
180
let app = app.clone();
181
PopupMenuItem::new("Add people")
182
.icon(IconName::UserPlus)
183
.disabled(!model.can_invite())
184
.on_click(move |_, window, cx| open_invite_picker(&app, window, cx))
185
}
186
187
fn has_people_menu(model: &CallModel) -> bool {
188
model.kind == CallKind::Direct || model.organizes_meeting()
189
}
190
191
fn panel_header(app: &Entity<AppState>, model: &CallModel, count: usize) -> Div {
192
let (invite_app, menu_app, close_app) = (app.clone(), app.clone(), app.clone());
193
let menu_model = model.clone();
194
h_flex()
195
.w_full()
196
.h(px(HEADER_HEIGHT))
197
.flex_none()
198
.pl(px(20.))
199
.pr(px(12.))
200
.gap(px(8.))
201
.items_center()
202
.child(
203
div()
204
.flex_1()
205
.min_w_0()
206
.truncate()
207
.text_size(px(15.))
208
.font_weight(FontWeight::SEMIBOLD)
209
.child(format!("People ({count})")),
210
)
211
.when(model.can_invite(), |header| {
212
header.child(
213
Button::new("call-people-invite")
214
.label("Invite")
215
.icon(IconName::UserPlus)
216
.xsmall()
217
.on_click(move |_, window, cx| open_invite_picker(&invite_app, window, cx)),
218
)
219
})
220
.when(has_people_menu(model), |header| {
221
header.child(
222
Button::new("call-people-more")
223
.icon(IconName::Ellipsis)
224
.ghost()
225
.xsmall()
226
.tooltip("More")
227
.dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
228
people_menu(popup, &menu_app, &menu_model)
229
}),
230
)
231
})
232
.child(
233
div()
234
.id("call-people-close")
235
.size(px(28.))
236
.flex()
237
.flex_none()
238
.items_center()
239
.justify_center()
240
.rounded(px(7.))
241
.cursor_pointer()
242
.hover(|button| button.bg(theme::row_hover()))
243
.tooltip(|window, cx| Tooltip::new("Close the people list").build(window, cx))
244
.child(icon(IconName::Close, 14., theme::text_muted()))
245
.on_click(move |_, _, cx| close_app.update(cx, |state, cx| state.toggle_call_people(cx))),
246
)
247
}
248
249
fn section_header(title: String, action: Option<AnyElement>) -> Div {
250
h_flex()
251
.w_full()
252
.h(px(SECTION_HEIGHT))
253
.flex_none()
254
.px(px(20.))
255
.items_center()
256
.justify_between()
257
.text_size(px(12.))
258
.font_weight(FontWeight::SEMIBOLD)
259
.text_color(theme::text_muted())
260
.child(title)
261
.children(action)
262
}
263
264
fn hand_badge(position: usize) -> Div {
265
h_flex()
266
.h(px(20.))
267
.px(px(6.))
268
.gap(px(3.))
269
.flex_none()
270
.items_center()
271
.rounded_full()
272
.bg(theme::amber())
273
.text_color(dark_text())
274
.text_size(px(11.))
275
.font_weight(FontWeight::SEMIBOLD)
276
.child(icon(IconName::Hand, 11., dark_text()))
277
.child(position.to_string())
278
}
279
280
fn mic_icon(row: &PersonRow) -> impl IntoElement {
281
if row.mic_blocked {
282
icon(IconName::MicOff, STATE_ICON, theme::red())
283
} else if row.muted {
284
icon(IconName::MicOff, STATE_ICON, theme::text_muted())
285
} else {
286
icon(IconName::Mic, STATE_ICON, theme::text())
287
}
288
}
289
290
fn camera_icon(row: &PersonRow) -> impl IntoElement {
291
if row.camera_blocked {
292
icon(IconName::VideoOff, STATE_ICON, theme::red())
293
} else if row.camera_on {
294
icon(IconName::Video, STATE_ICON, theme::text())
295
} else {
296
icon(IconName::VideoOff, STATE_ICON, theme::text_muted())
297
}
298
}
299
300
fn person_row(
301
app: &Entity<AppState>,
302
state: &AppState,
303
model: &CallModel,
304
section: &'static str,
305
row: &PersonRow,
306
) -> AnyElement {
307
let group = SharedString::from(format!("call-people-{section}-{}", row.mri));
308
let user_id = row
309
.user_id
310
.clone()
311
.or_else(|| {
312
row.own
313
.then(|| state.directory.me.as_ref().map(|me| me.user_id.clone()))
314
.flatten()
315
});
316
let subtitle = if row.ringing { Some("Ringing") } else { row.label };
317
let (more_app, more_model, more_mri, more_name) =
318
(app.clone(), model.clone(), row.mri.clone(), row.name.clone());
319
h_flex()
320
.id(SharedString::from(format!("call-people-row-{section}-{}", row.mri)))
321
.group(group.clone())
322
.w_full()
323
.h(px(ROW_HEIGHT))
324
.flex_none()
325
.px(px(20.))
326
.gap(px(8.))
327
.items_center()
328
.hover(|row| row.bg(theme::row_hover()))
329
.child(person_avatar(&state.directory, user_id.as_deref(), &row.name, AVATAR_SIZE))
330
.child(
331
v_flex()
332
.flex_1()
333
.min_w_0()
334
.child(
335
div()
336
.truncate()
337
.text_size(px(13.))
338
.font_weight(FontWeight::SEMIBOLD)
339
.child(truncated(&row.name, NAME_LIMIT)),
340
)
341
.children(subtitle.map(|text| {
342
div()
343
.truncate()
344
.text_size(px(11.))
345
.text_color(theme::text_muted())
346
.child(text)
347
})),
348
)
349
.children(row.hand.map(hand_badge))
350
.child(mic_icon(row))
351
.child(camera_icon(row))
352
.child(
353
div()
354
.size(px(MORE_SIZE))
355
.flex_none()
356
.when(!row.own, |slot| {
357
slot.opacity(0.)
358
.group_hover(group, |slot| slot.opacity(1.))
359
.child(
360
Button::new(SharedString::from(format!(
361
"call-people-more-{section}-{}",
362
row.mri
363
)))
364
.icon(IconName::Ellipsis)
365
.ghost()
366
.xsmall()
367
.size(px(MORE_SIZE))
368
.tooltip("More")
369
.dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
370
tile_menu(popup, &more_app, &more_model, &more_mri, &more_name, false)
371
}),
372
)
373
}),
374
)
375
.into_any_element()
376
}
377
378
fn lobby_section(app: &Entity<AppState>, state: &AppState, sections: &PeopleSections) -> Option<Div> {
379
if sections.lobby.is_empty() {
380
return None;
381
}
382
let admit_all_app = app.clone();
383
let action = Button::new("call-people-admit-all")
384
.label("Admit all")
385
.ghost()
386
.xsmall()
387
.on_click(move |_, _, cx| admit_all_app.update(cx, |state, cx| state.admit_all_call_guests(cx)))
388
.into_any_element();
389
Some(
390
v_flex()
391
.w_full()
392
.child(section_header(format!("Waiting in lobby ({})", sections.lobby.len()), Some(action)))
393
.children(sections.lobby.iter().map(|guest| {
394
let (admit_app, deny_app) = (app.clone(), app.clone());
395
let (admit_mri, deny_mri) = (guest.mri.clone(), guest.mri.clone());
396
h_flex()
397
.id(SharedString::from(format!("call-people-lobby-{}", guest.mri)))
398
.w_full()
399
.h(px(ROW_HEIGHT))
400
.flex_none()
401
.px(px(20.))
402
.gap(px(8.))
403
.items_center()
404
.child(person_avatar(&state.directory, guest.user_id.as_deref(), &guest.name, AVATAR_SIZE))
405
.child(
406
div()
407
.flex_1()
408
.min_w_0()
409
.truncate()
410
.text_size(px(13.))
411
.font_weight(FontWeight::SEMIBOLD)
412
.child(truncated(&guest.name, NAME_LIMIT)),
413
)
414
.child(
415
Button::new(SharedString::from(format!("call-people-admit-{}", guest.mri)))
416
.label("Admit")
417
.xsmall()
418
.on_click(move |_, _, cx| {
419
admit_app.update(cx, |state, cx| state.admit_call_guest(admit_mri.clone(), cx))
420
}),
421
)
422
.child(
423
Button::new(SharedString::from(format!("call-people-deny-{}", guest.mri)))
424
.label("Deny")
425
.ghost()
426
.xsmall()
427
.on_click(move |_, _, cx| {
428
deny_app.update(cx, |state, cx| state.deny_call_guest(deny_mri.clone(), cx))
429
}),
430
)
431
})),
432
)
433
}
434
435
pub fn people_panel(app: &Entity<AppState>, state: &AppState, call: &ActiveCall) -> Option<AnyElement> {
436
call.people_open.then_some(())?;
437
let model = &call.model;
438
let sections = people_sections(model);
439
let lower_all = model.can_lower_hands().then(|| {
440
let app = app.clone();
441
Button::new("call-people-lower-all")
442
.label("Lower all")
443
.ghost()
444
.xsmall()
445
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.lower_all_call_hands(cx)))
446
.into_any_element()
447
});
448
let body = v_flex()
449
.id("call-people-list")
450
.flex_1()
451
.min_h_0()
452
.w_full()
453
.overflow_y_scroll()
454
.pb(px(12.))
455
.children(model.can_admit().then(|| lobby_section(app, state, §ions)).flatten())
456
.when(!sections.hands.is_empty(), |list| {
457
list.child(section_header(format!("Raised hands ({})", sections.hands.len()), lower_all))
458
.children(
459
sections
460
.hands
461
.iter()
462
.map(|row| person_row(app, state, model, "hands", row)),
463
)
464
})
465
.children(sections.groups.iter().map(|group| {
466
v_flex()
467
.w_full()
468
.child(section_header(format!("{} ({})", group.title, group.rows.len()), None))
469
.children(group.rows.iter().map(|row| person_row(app, state, model, "group", row)))
470
}));
471
Some(
472
v_flex()
473
.id("call-people-panel")
474
.debug_selector(|| "shell/islands/main/call-people".into())
475
.w(px(CHAT_PANEL_WIDTH))
476
.h_full()
477
.flex_shrink(1.)
478
.min_w_0()
479
.rounded(px(10.))
480
.overflow_hidden()
481
.bg(theme::surface())
482
.child(panel_header(app, model, sections.count))
483
.child(body)
484
.into_any_element(),
485
)
486
}
487
488
fn choice_label(choices: &[(&str, &str)], value: &str) -> String {
489
choices
490
.iter()
491
.find(|(wire, _)| *wire == value)
492
.map_or_else(|| value.to_owned(), |(_, label)| (*label).to_owned())
493
}
494
495
fn choice_dropdown(
496
id: &'static str,
497
app: &Entity<AppState>,
498
choices: &'static [(&'static str, &'static str)],
499
current: &str,
500
edit: fn(&mut MeetingOptions, &str),
501
) -> AnyElement {
502
let app = app.clone();
503
let current = current.to_owned();
504
Button::new(id)
505
.label(choice_label(choices, ¤t))
506
.icon(IconName::ChevronDown)
507
.ghost()
508
.h(px(FIELD_HEIGHT))
509
.dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {
510
let mut popup = popup.min_w(px(DROPDOWN_WIDTH));
511
if !choices.iter().any(|(wire, _)| *wire == current) {
512
popup = popup.item(PopupMenuItem::new(current.clone()).checked(true));
513
}
514
for (wire, label) in choices {
515
let app = app.clone();
516
popup = popup.item(PopupMenuItem::new(*label).checked(*wire == current).on_click(
517
move |_, _, cx| {
518
app.update(cx, |state, cx| {
519
state.edit_meeting_options(|options| edit(options, wire), cx)
520
})
521
},
522
));
523
}
524
popup
525
})
526
.into_any_element()
527
}
528
529
fn switch_field(
530
id: &'static str,
531
app: &Entity<AppState>,
532
on: bool,
533
edit: fn(&mut MeetingOptions, bool),
534
) -> AnyElement {
535
let app = app.clone();
536
Switch::new(id)
537
.checked(on)
538
.on_click(move |checked, _, cx| {
539
let checked = *checked;
540
app.update(cx, |state, cx| {
541
state.edit_meeting_options(|options| edit(options, checked), cx)
542
})
543
})
544
.into_any_element()
545
}
546
547
fn option_row(label: &'static str, control: AnyElement) -> Div {
548
h_flex()
549
.w_full()
550
.min_h(px(FIELD_HEIGHT))
551
.gap(px(12.))
552
.items_center()
553
.justify_between()
554
.child(div().flex_1().min_w_0().text_size(px(14.)).child(label))
555
.child(control)
556
}
557
558
fn options_fields(app: &Entity<AppState>, options: &MeetingOptions) -> Div {
559
use calling::meeting_options::{BYPASS_CHOICES, CHAT_CHOICES, PRESENTER_CHOICES};
560
v_flex()
561
.w_full()
562
.gap(px(6.))
563
.child(option_row(
564
"Who can bypass the lobby",
565
choice_dropdown("options-bypass", app, &BYPASS_CHOICES, &options.bypass_lobby, |options, value| {
566
options.bypass_lobby = value.to_owned()
567
}),
568
))
569
.child(option_row(
570
"Who can present",
571
choice_dropdown("options-present", app, &PRESENTER_CHOICES, &options.presenters, |options, value| {
572
options.presenters = value.to_owned()
573
}),
574
))
575
.child(option_row(
576
"Allow mic for attendees",
577
switch_field("options-mic", app, options.attendee_mic, |options, on| options.attendee_mic = on),
578
))
579
.child(option_row(
580
"Allow camera for attendees",
581
switch_field("options-camera", app, options.attendee_camera, |options, on| {
582
options.attendee_camera = on
583
}),
584
))
585
.child(option_row(
586
"Meeting chat",
587
choice_dropdown("options-chat", app, &CHAT_CHOICES, &options.meeting_chat, |options, value| {
588
options.meeting_chat = value.to_owned()
589
}),
590
))
591
.child(option_row(
592
"Allow reactions",
593
switch_field("options-reactions", app, options.reactions, |options, on| options.reactions = on),
594
))
595
.child(option_row(
596
"Record automatically",
597
switch_field("options-record", app, options.record_automatically, |options, on| {
598
options.record_automatically = on
599
}),
600
))
601
}
602
603
fn dialog_body(app: &Entity<AppState>, dialog: &OptionsDialog) -> Div {
604
let body = v_flex().w_full().gap(px(12.));
605
let body = match &dialog.draft {
606
Some(draft) => body.child(options_fields(app, draft)),
607
None if dialog.is_loading() => body.child(
608
div()
609
.text_size(px(13.))
610
.text_color(theme::text_muted())
611
.child("Loading the meeting options..."),
612
),
613
None => body,
614
};
615
body.children(dialog.error.as_ref().map(|error| {
616
div()
617
.id("options-error")
618
.w_full()
619
.text_size(px(13.))
620
.text_color(theme::red())
621
.child(error.clone())
622
}))
623
}
624
625
pub fn options_dialog(app: &Entity<AppState>, call: &ActiveCall) -> Option<AnyElement> {
626
let dialog = call.options_dialog.as_ref()?;
627
let (close_app, cancel_app, save_app) = (app.clone(), app.clone(), app.clone());
628
let can_save = dialog.can_save();
629
let save = Button::new("options-save")
630
.label(if dialog.saving { "Saving..." } else { "Save" })
631
.when(!can_save, |button| button.opacity(0.4))
632
.on_click(move |_, _, cx| {
633
if can_save {
634
save_app.update(cx, |state, cx| state.save_meeting_options(cx))
635
}
636
});
637
Some(
638
div()
639
.id("options-layer")
640
.absolute()
641
.top_0()
642
.left_0()
643
.size_full()
644
.flex()
645
.items_center()
646
.justify_center()
647
.child(
648
div()
649
.id("options-backdrop")
650
.absolute()
651
.top_0()
652
.left_0()
653
.size_full()
654
.bg(black().opacity(DIALOG_BACKDROP))
655
.occlude()
656
.on_click(move |_, _, cx| close_app.update(cx, |state, cx| state.close_meeting_options(cx))),
657
)
658
.child(
659
v_flex()
660
.id("options-card")
661
.w(px(DIALOG_WIDTH))
662
.max_w(relative(1.))
663
.p(px(16.))
664
.gap(px(12.))
665
.rounded(px(12.))
666
.bg(theme::background())
667
.border_1()
668
.border_color(theme::border_strong())
669
.text_color(theme::text())
670
.shadow_lg()
671
.occlude()
672
.child(
673
div()
674
.text_size(px(15.))
675
.font_weight(FontWeight::SEMIBOLD)
676
.child("Meeting options"),
677
)
678
.child(dialog_body(app, dialog))
679
.child(
680
h_flex()
681
.w_full()
682
.justify_end()
683
.gap(px(8.))
684
.child(
685
Button::new("options-cancel")
686
.label("Cancel")
687
.ghost()
688
.on_click(move |_, _, cx| {
689
cancel_app.update(cx, |state, cx| state.close_meeting_options(cx))
690
}),
691
)
692
.child(save),
693
),
694
)
695
.into_any_element(),
696
)
697
}
@@ -0,0 +1,697 @@1
use gpui_kit::assets::IconName;2
use gpui_kit::component::{3
Sizable as _,4
button::{Button, ButtonVariants as _},5
h_flex,6
menu::{DropdownMenu as _, PopupMenu, PopupMenuItem},7
switch::Switch,8
tooltip::Tooltip,9
v_flex,10
};11
use gpui_kit::prelude::FluentBuilder as _;12
use gpui_kit::*;13
14
use super::avatar::person_avatar;15
use super::call_extras::open_invite_picker;16
use super::call_organizer::{pill, tile_menu};17
use super::call_view::{BANNER_HEIGHT, CHAT_PANEL_WIDTH, MENU_WIDTH, round_control};18
use super::widgets::{Corner, corner_badge, count_badge, icon};19
use crate::app_state::AppState;20
use crate::call::{21
ActiveCall, CallKind, CallModel, OptionsDialog, PeopleSections, PersonRow, people_sections,22
};23
use crate::notice::truncated;24
use crate::theme;25
use calling::MeetingOptions;26
27
const HEADER_HEIGHT: f32 = 48.;28
const ROW_HEIGHT: f32 = 44.;29
const AVATAR_SIZE: f32 = 28.;30
const MORE_SIZE: f32 = 24.;31
const SECTION_HEIGHT: f32 = 32.;32
const NAME_LIMIT: usize = 26;33
const STATE_ICON: f32 = 15.;34
const DIALOG_WIDTH: f32 = 460.;35
const DIALOG_BACKDROP: f32 = 0.55;36
const FIELD_HEIGHT: f32 = 36.;37
const DROPDOWN_WIDTH: f32 = 210.;38
39
fn dark_text() -> Hsla {40
hsla(0., 0., 0.08, 1.)41
}42
43
pub fn people_button(app: &Entity<AppState>, open: bool, raised_hands: usize) -> Stateful<Div> {44
let app = app.clone();45
let (background, foreground) = if open {46
(theme::accent(), theme::on_accent())47
} else {48
(theme::surface_raised(), theme::text())49
};50
round_control("call-people", IconName::Users, background, foreground)51
.relative()52
.tooltip(move |window, cx| {53
Tooltip::new(if open { "Close the people list" } else { "Show people" }).build(window, cx)54
})55
.when(raised_hands > 0, |button| {56
button.child(57
corner_badge(Corner::TopRight, 4.).child(count_badge(raised_hands as u32, false)),58
)59
})60
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_people(cx)))61
}62
63
pub fn lock_chip(model: &CallModel) -> Option<AnyElement> {64
model.capability.locked.then(|| {65
h_flex()66
.id("call-lock-chip")67
.h(px(24.))68
.px(px(8.))69
.gap(px(4.))70
.flex_none()71
.items_center()72
.rounded_full()73
.bg(theme::amber())74
.text_color(dark_text())75
.text_size(px(12.))76
.font_weight(FontWeight::SEMIBOLD)77
.child(icon(IconName::Lock, 13., dark_text()))78
.child("Locked")79
.into_any_element()80
})81
}82
83
pub fn lock_banner(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {84
if !model.capability.locked || !model.organizes_meeting() {85
return None;86
}87
let app = app.clone();88
Some(89
h_flex()90
.id("call-lock-banner")91
.w_full()92
.h(px(BANNER_HEIGHT))93
.flex_none()94
.px(px(20.))95
.gap(px(12.))96
.items_center()97
.justify_center()98
.bg(theme::surface_raised())99
.text_color(theme::text())100
.text_size(px(13.))101
.font_weight(FontWeight::SEMIBOLD)102
.child("The meeting is locked. Nobody new can join.")103
.child(104
pill("call-lock-unlock", "Unlock", false)105
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.set_call_lock(false, cx))),106
)107
.into_any_element(),108
)109
}110
111
fn people_menu(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {112
let mut popup = popup.min_w(px(MENU_WIDTH));113
if model.kind == CallKind::Direct {114
popup = popup.item(add_people_item(app, model));115
}116
if !model.organizes_meeting() {117
return popup;118
}119
let capability = model.capability;120
let (mute_app, lock_app, mic_app, camera_app, options_app) =121
(app.clone(), app.clone(), app.clone(), app.clone(), app.clone());122
popup123
.item(124
PopupMenuItem::new("Mute all")125
.icon(IconName::MicOff)126
.on_click(move |_, _, cx| mute_app.update(cx, |state, cx| state.mute_all_call(cx))),127
)128
.item(129
PopupMenuItem::new(if capability.locked { "Unlock meeting" } else { "Lock meeting" })130
.icon(if capability.locked { IconName::LockOpen } else { IconName::Lock })131
.on_click(move |_, _, cx| {132
lock_app.update(cx, |state, cx| state.set_call_lock(!capability.locked, cx))133
}),134
)135
.item(136
PopupMenuItem::new(if capability.attendee_mic_off {137
"Allow mic for attendees"138
} else {139
"Disable mic for attendees"140
})141
.icon(IconName::MicOff)142
.on_click(move |_, _, cx| {143
mic_app.update(cx, |state, cx| {144
state.set_call_attendee_restrictions(145
!capability.attendee_mic_off,146
capability.attendee_camera_off,147
cx,148
)149
})150
}),151
)152
.item(153
PopupMenuItem::new(if capability.attendee_camera_off {154
"Allow camera for attendees"155
} else {156
"Disable camera for attendees"157
})158
.icon(IconName::VideoOff)159
.on_click(move |_, _, cx| {160
camera_app.update(cx, |state, cx| {161
state.set_call_attendee_restrictions(162
capability.attendee_mic_off,163
!capability.attendee_camera_off,164
cx,165
)166
})167
}),168
)169
.separator()170
.item(171
PopupMenuItem::new("Meeting options...")172
.icon(IconName::Settings)173
.on_click(move |_, _, cx| {174
options_app.update(cx, |state, cx| state.open_meeting_options(cx))175
}),176
)177
}178
179
pub fn add_people_item(app: &Entity<AppState>, model: &CallModel) -> PopupMenuItem {180
let app = app.clone();181
PopupMenuItem::new("Add people")182
.icon(IconName::UserPlus)183
.disabled(!model.can_invite())184
.on_click(move |_, window, cx| open_invite_picker(&app, window, cx))185
}186
187
fn has_people_menu(model: &CallModel) -> bool {188
model.kind == CallKind::Direct || model.organizes_meeting()189
}190
191
fn panel_header(app: &Entity<AppState>, model: &CallModel, count: usize) -> Div {192
let (invite_app, menu_app, close_app) = (app.clone(), app.clone(), app.clone());193
let menu_model = model.clone();194
h_flex()195
.w_full()196
.h(px(HEADER_HEIGHT))197
.flex_none()198
.pl(px(20.))199
.pr(px(12.))200
.gap(px(8.))201
.items_center()202
.child(203
div()204
.flex_1()205
.min_w_0()206
.truncate()207
.text_size(px(15.))208
.font_weight(FontWeight::SEMIBOLD)209
.child(format!("People ({count})")),210
)211
.when(model.can_invite(), |header| {212
header.child(213
Button::new("call-people-invite")214
.label("Invite")215
.icon(IconName::UserPlus)216
.xsmall()217
.on_click(move |_, window, cx| open_invite_picker(&invite_app, window, cx)),218
)219
})220
.when(has_people_menu(model), |header| {221
header.child(222
Button::new("call-people-more")223
.icon(IconName::Ellipsis)224
.ghost()225
.xsmall()226
.tooltip("More")227
.dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {228
people_menu(popup, &menu_app, &menu_model)229
}),230
)231
})232
.child(233
div()234
.id("call-people-close")235
.size(px(28.))236
.flex()237
.flex_none()238
.items_center()239
.justify_center()240
.rounded(px(7.))241
.cursor_pointer()242
.hover(|button| button.bg(theme::row_hover()))243
.tooltip(|window, cx| Tooltip::new("Close the people list").build(window, cx))244
.child(icon(IconName::Close, 14., theme::text_muted()))245
.on_click(move |_, _, cx| close_app.update(cx, |state, cx| state.toggle_call_people(cx))),246
)247
}248
249
fn section_header(title: String, action: Option<AnyElement>) -> Div {250
h_flex()251
.w_full()252
.h(px(SECTION_HEIGHT))253
.flex_none()254
.px(px(20.))255
.items_center()256
.justify_between()257
.text_size(px(12.))258
.font_weight(FontWeight::SEMIBOLD)259
.text_color(theme::text_muted())260
.child(title)261
.children(action)262
}263
264
fn hand_badge(position: usize) -> Div {265
h_flex()266
.h(px(20.))267
.px(px(6.))268
.gap(px(3.))269
.flex_none()270
.items_center()271
.rounded_full()272
.bg(theme::amber())273
.text_color(dark_text())274
.text_size(px(11.))275
.font_weight(FontWeight::SEMIBOLD)276
.child(icon(IconName::Hand, 11., dark_text()))277
.child(position.to_string())278
}279
280
fn mic_icon(row: &PersonRow) -> impl IntoElement {281
if row.mic_blocked {282
icon(IconName::MicOff, STATE_ICON, theme::red())283
} else if row.muted {284
icon(IconName::MicOff, STATE_ICON, theme::text_muted())285
} else {286
icon(IconName::Mic, STATE_ICON, theme::text())287
}288
}289
290
fn camera_icon(row: &PersonRow) -> impl IntoElement {291
if row.camera_blocked {292
icon(IconName::VideoOff, STATE_ICON, theme::red())293
} else if row.camera_on {294
icon(IconName::Video, STATE_ICON, theme::text())295
} else {296
icon(IconName::VideoOff, STATE_ICON, theme::text_muted())297
}298
}299
300
fn person_row(301
app: &Entity<AppState>,302
state: &AppState,303
model: &CallModel,304
section: &'static str,305
row: &PersonRow,306
) -> AnyElement {307
let group = SharedString::from(format!("call-people-{section}-{}", row.mri));308
let user_id = row309
.user_id310
.clone()311
.or_else(|| {312
row.own313
.then(|| state.directory.me.as_ref().map(|me| me.user_id.clone()))314
.flatten()315
});316
let subtitle = if row.ringing { Some("Ringing") } else { row.label };317
let (more_app, more_model, more_mri, more_name) =318
(app.clone(), model.clone(), row.mri.clone(), row.name.clone());319
h_flex()320
.id(SharedString::from(format!("call-people-row-{section}-{}", row.mri)))321
.group(group.clone())322
.w_full()323
.h(px(ROW_HEIGHT))324
.flex_none()325
.px(px(20.))326
.gap(px(8.))327
.items_center()328
.hover(|row| row.bg(theme::row_hover()))329
.child(person_avatar(&state.directory, user_id.as_deref(), &row.name, AVATAR_SIZE))330
.child(331
v_flex()332
.flex_1()333
.min_w_0()334
.child(335
div()336
.truncate()337
.text_size(px(13.))338
.font_weight(FontWeight::SEMIBOLD)339
.child(truncated(&row.name, NAME_LIMIT)),340
)341
.children(subtitle.map(|text| {342
div()343
.truncate()344
.text_size(px(11.))345
.text_color(theme::text_muted())346
.child(text)347
})),348
)349
.children(row.hand.map(hand_badge))350
.child(mic_icon(row))351
.child(camera_icon(row))352
.child(353
div()354
.size(px(MORE_SIZE))355
.flex_none()356
.when(!row.own, |slot| {357
slot.opacity(0.)358
.group_hover(group, |slot| slot.opacity(1.))359
.child(360
Button::new(SharedString::from(format!(361
"call-people-more-{section}-{}",362
row.mri363
)))364
.icon(IconName::Ellipsis)365
.ghost()366
.xsmall()367
.size(px(MORE_SIZE))368
.tooltip("More")369
.dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {370
tile_menu(popup, &more_app, &more_model, &more_mri, &more_name, false)371
}),372
)373
}),374
)375
.into_any_element()376
}377
378
fn lobby_section(app: &Entity<AppState>, state: &AppState, sections: &PeopleSections) -> Option<Div> {379
if sections.lobby.is_empty() {380
return None;381
}382
let admit_all_app = app.clone();383
let action = Button::new("call-people-admit-all")384
.label("Admit all")385
.ghost()386
.xsmall()387
.on_click(move |_, _, cx| admit_all_app.update(cx, |state, cx| state.admit_all_call_guests(cx)))388
.into_any_element();389
Some(390
v_flex()391
.w_full()392
.child(section_header(format!("Waiting in lobby ({})", sections.lobby.len()), Some(action)))393
.children(sections.lobby.iter().map(|guest| {394
let (admit_app, deny_app) = (app.clone(), app.clone());395
let (admit_mri, deny_mri) = (guest.mri.clone(), guest.mri.clone());396
h_flex()397
.id(SharedString::from(format!("call-people-lobby-{}", guest.mri)))398
.w_full()399
.h(px(ROW_HEIGHT))400
.flex_none()401
.px(px(20.))402
.gap(px(8.))403
.items_center()404
.child(person_avatar(&state.directory, guest.user_id.as_deref(), &guest.name, AVATAR_SIZE))405
.child(406
div()407
.flex_1()408
.min_w_0()409
.truncate()410
.text_size(px(13.))411
.font_weight(FontWeight::SEMIBOLD)412
.child(truncated(&guest.name, NAME_LIMIT)),413
)414
.child(415
Button::new(SharedString::from(format!("call-people-admit-{}", guest.mri)))416
.label("Admit")417
.xsmall()418
.on_click(move |_, _, cx| {419
admit_app.update(cx, |state, cx| state.admit_call_guest(admit_mri.clone(), cx))420
}),421
)422
.child(423
Button::new(SharedString::from(format!("call-people-deny-{}", guest.mri)))424
.label("Deny")425
.ghost()426
.xsmall()427
.on_click(move |_, _, cx| {428
deny_app.update(cx, |state, cx| state.deny_call_guest(deny_mri.clone(), cx))429
}),430
)431
})),432
)433
}434
435
pub fn people_panel(app: &Entity<AppState>, state: &AppState, call: &ActiveCall) -> Option<AnyElement> {436
call.people_open.then_some(())?;437
let model = &call.model;438
let sections = people_sections(model);439
let lower_all = model.can_lower_hands().then(|| {440
let app = app.clone();441
Button::new("call-people-lower-all")442
.label("Lower all")443
.ghost()444
.xsmall()445
.on_click(move |_, _, cx| app.update(cx, |state, cx| state.lower_all_call_hands(cx)))446
.into_any_element()447
});448
let body = v_flex()449
.id("call-people-list")450
.flex_1()451
.min_h_0()452
.w_full()453
.overflow_y_scroll()454
.pb(px(12.))455
.children(model.can_admit().then(|| lobby_section(app, state, §ions)).flatten())456
.when(!sections.hands.is_empty(), |list| {457
list.child(section_header(format!("Raised hands ({})", sections.hands.len()), lower_all))458
.children(459
sections460
.hands461
.iter()462
.map(|row| person_row(app, state, model, "hands", row)),463
)464
})465
.children(sections.groups.iter().map(|group| {466
v_flex()467
.w_full()468
.child(section_header(format!("{} ({})", group.title, group.rows.len()), None))469
.children(group.rows.iter().map(|row| person_row(app, state, model, "group", row)))470
}));471
Some(472
v_flex()473
.id("call-people-panel")474
.debug_selector(|| "shell/islands/main/call-people".into())475
.w(px(CHAT_PANEL_WIDTH))476
.h_full()477
.flex_shrink(1.)478
.min_w_0()479
.rounded(px(10.))480
.overflow_hidden()481
.bg(theme::surface())482
.child(panel_header(app, model, sections.count))483
.child(body)484
.into_any_element(),485
)486
}487
488
fn choice_label(choices: &[(&str, &str)], value: &str) -> String {489
choices490
.iter()491
.find(|(wire, _)| *wire == value)492
.map_or_else(|| value.to_owned(), |(_, label)| (*label).to_owned())493
}494
495
fn choice_dropdown(496
id: &'static str,497
app: &Entity<AppState>,498
choices: &'static [(&'static str, &'static str)],499
current: &str,500
edit: fn(&mut MeetingOptions, &str),501
) -> AnyElement {502
let app = app.clone();503
let current = current.to_owned();504
Button::new(id)505
.label(choice_label(choices, ¤t))506
.icon(IconName::ChevronDown)507
.ghost()508
.h(px(FIELD_HEIGHT))509
.dropdown_menu_with_anchor(Anchor::TopRight, move |popup, _, _| {510
let mut popup = popup.min_w(px(DROPDOWN_WIDTH));511
if !choices.iter().any(|(wire, _)| *wire == current) {512
popup = popup.item(PopupMenuItem::new(current.clone()).checked(true));513
}514
for (wire, label) in choices {515
let app = app.clone();516
popup = popup.item(PopupMenuItem::new(*label).checked(*wire == current).on_click(517
move |_, _, cx| {518
app.update(cx, |state, cx| {519
state.edit_meeting_options(|options| edit(options, wire), cx)520
})521
},522
));523
}524
popup525
})526
.into_any_element()527
}528
529
fn switch_field(530
id: &'static str,531
app: &Entity<AppState>,532
on: bool,533
edit: fn(&mut MeetingOptions, bool),534
) -> AnyElement {535
let app = app.clone();536
Switch::new(id)537
.checked(on)538
.on_click(move |checked, _, cx| {539
let checked = *checked;540
app.update(cx, |state, cx| {541
state.edit_meeting_options(|options| edit(options, checked), cx)542
})543
})544
.into_any_element()545
}546
547
fn option_row(label: &'static str, control: AnyElement) -> Div {548
h_flex()549
.w_full()550
.min_h(px(FIELD_HEIGHT))551
.gap(px(12.))552
.items_center()553
.justify_between()554
.child(div().flex_1().min_w_0().text_size(px(14.)).child(label))555
.child(control)556
}557
558
fn options_fields(app: &Entity<AppState>, options: &MeetingOptions) -> Div {559
use calling::meeting_options::{BYPASS_CHOICES, CHAT_CHOICES, PRESENTER_CHOICES};560
v_flex()561
.w_full()562
.gap(px(6.))563
.child(option_row(564
"Who can bypass the lobby",565
choice_dropdown("options-bypass", app, &BYPASS_CHOICES, &options.bypass_lobby, |options, value| {566
options.bypass_lobby = value.to_owned()567
}),568
))569
.child(option_row(570
"Who can present",571
choice_dropdown("options-present", app, &PRESENTER_CHOICES, &options.presenters, |options, value| {572
options.presenters = value.to_owned()573
}),574
))575
.child(option_row(576
"Allow mic for attendees",577
switch_field("options-mic", app, options.attendee_mic, |options, on| options.attendee_mic = on),578
))579
.child(option_row(580
"Allow camera for attendees",581
switch_field("options-camera", app, options.attendee_camera, |options, on| {582
options.attendee_camera = on583
}),584
))585
.child(option_row(586
"Meeting chat",587
choice_dropdown("options-chat", app, &CHAT_CHOICES, &options.meeting_chat, |options, value| {588
options.meeting_chat = value.to_owned()589
}),590
))591
.child(option_row(592
"Allow reactions",593
switch_field("options-reactions", app, options.reactions, |options, on| options.reactions = on),594
))595
.child(option_row(596
"Record automatically",597
switch_field("options-record", app, options.record_automatically, |options, on| {598
options.record_automatically = on599
}),600
))601
}602
603
fn dialog_body(app: &Entity<AppState>, dialog: &OptionsDialog) -> Div {604
let body = v_flex().w_full().gap(px(12.));605
let body = match &dialog.draft {606
Some(draft) => body.child(options_fields(app, draft)),607
None if dialog.is_loading() => body.child(608
div()609
.text_size(px(13.))610
.text_color(theme::text_muted())611
.child("Loading the meeting options..."),612
),613
None => body,614
};615
body.children(dialog.error.as_ref().map(|error| {616
div()617
.id("options-error")618
.w_full()619
.text_size(px(13.))620
.text_color(theme::red())621
.child(error.clone())622
}))623
}624
625
pub fn options_dialog(app: &Entity<AppState>, call: &ActiveCall) -> Option<AnyElement> {626
let dialog = call.options_dialog.as_ref()?;627
let (close_app, cancel_app, save_app) = (app.clone(), app.clone(), app.clone());628
let can_save = dialog.can_save();629
let save = Button::new("options-save")630
.label(if dialog.saving { "Saving..." } else { "Save" })631
.when(!can_save, |button| button.opacity(0.4))632
.on_click(move |_, _, cx| {633
if can_save {634
save_app.update(cx, |state, cx| state.save_meeting_options(cx))635
}636
});637
Some(638
div()639
.id("options-layer")640
.absolute()641
.top_0()642
.left_0()643
.size_full()644
.flex()645
.items_center()646
.justify_center()647
.child(648
div()649
.id("options-backdrop")650
.absolute()651
.top_0()652
.left_0()653
.size_full()654
.bg(black().opacity(DIALOG_BACKDROP))655
.occlude()656
.on_click(move |_, _, cx| close_app.update(cx, |state, cx| state.close_meeting_options(cx))),657
)658
.child(659
v_flex()660
.id("options-card")661
.w(px(DIALOG_WIDTH))662
.max_w(relative(1.))663
.p(px(16.))664
.gap(px(12.))665
.rounded(px(12.))666
.bg(theme::background())667
.border_1()668
.border_color(theme::border_strong())669
.text_color(theme::text())670
.shadow_lg()671
.occlude()672
.child(673
div()674
.text_size(px(15.))675
.font_weight(FontWeight::SEMIBOLD)676
.child("Meeting options"),677
)678
.child(dialog_body(app, dialog))679
.child(680
h_flex()681
.w_full()682
.justify_end()683
.gap(px(8.))684
.child(685
Button::new("options-cancel")686
.label("Cancel")687
.ghost()688
.on_click(move |_, _, cx| {689
cancel_app.update(cx, |state, cx| state.close_meeting_options(cx))690
}),691
)692
.child(save),693
),694
)695
.into_any_element(),696
)697
}@@ -26,6 +26,7 @@ use super::call_organizer::{
26
26
camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,
27
27
more_button, pin_chip, spotlight_chip, with_tile_menu,
28
28
};
29
use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};
29
30
use super::call_stage::render_stage;
30
31
use super::call_view_menu::view_button;
31
32
use super::conversation::ConversationView;
@@ -67,7 +68,7 @@ pub const NO_WINDOWS_HINT: &str = "No windows found";
67
68
pub(super) const BANNER_HEIGHT: f32 = 40.;
68
69
const MAX_WINDOW_ITEMS: usize = 12;
69
70
pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
70
pub const CHAT_PANEL_WIDTH: f32 = 320.;
71
pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;
71
72
const CHAT_HEADER_HEIGHT: f32 = 48.;
72
73
const REACTION_RISE: f32 = 24.;
73
74
const REACTION_FADE_FROM: f32 = 0.75;
@@ -1074,6 +1075,7 @@ pub fn render_call_view(
1074
1075
)
1075
1076
.children(health_indicator(model))
1076
1077
.children(recording_chip(model))
1078
.children(lock_chip(model))
1077
1079
.children(room_chip(model))
1078
1080
.child(div().flex_1())
1079
1081
.children(return_button(app, model));
@@ -1119,6 +1121,9 @@ pub fn render_call_view(
1119
1121
})
1120
1122
.child(view_button(app, model, fullscreen))
1121
1123
.children(more_button(app, model))
1124
.when(model.kind != CallKind::Test, |row| {
1125
row.child(people_button(app, call.people_open, model.raised_hands()))
1126
})
1122
1127
.when(call.chat_thread().is_some(), |row| {
1123
1128
row.child(chat_button(app, call.chat_open, state.call_chat_unread()))
1124
1129
})
@@ -1132,6 +1137,7 @@ pub fn render_call_view(
1132
1137
.flex_none()
1133
1138
.child(header)
1134
1139
.children(lobby_banner(app, model, call.lobby_list_open))
1140
.children(lock_banner(app, model))
1135
1141
.children(health_banner(app, model))
1136
1142
.children(sharing_banner(app, model, state.call_share_sound))
1137
1143
.children(consult_banner(app, state));
@@ -1168,6 +1174,7 @@ pub fn render_call_view(
1168
1174
.children(captions_hint_chip(model))
1169
1175
.children(push_to_talk_chip(call))
1170
1176
.children(state.transfer_picker.clone())
1177
.children(options_dialog(app, call))
1171
1178
.children(consent_overlay(app, model));
1172
1179
Some(
1173
1180
h_flex()
@@ -1181,6 +1188,7 @@ pub fn render_call_view(
1181
1188
.child(column)
1182
1189
.children(chat.map(|chat| chat_panel(app, chat)))
1183
1190
.children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())
1191
.children(people_panel(app, state, call))
1184
1192
.into_any_element(),
1185
1193
)
1186
1194
}
@@ -26,6 +26,7 @@ use super::call_organizer::{26
camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,26
camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,27
more_button, pin_chip, spotlight_chip, with_tile_menu,27
more_button, pin_chip, spotlight_chip, with_tile_menu,28
};28
};29
use super::call_people::{lock_banner, lock_chip, options_dialog, people_button, people_panel};29
use super::call_stage::render_stage;30
use super::call_stage::render_stage;30
use super::call_view_menu::view_button;31
use super::call_view_menu::view_button;31
use super::conversation::ConversationView;32
use super::conversation::ConversationView;@@ -67,7 +68,7 @@ pub const NO_WINDOWS_HINT: &str = "No windows found";67
pub(super) const BANNER_HEIGHT: f32 = 40.;68
pub(super) const BANNER_HEIGHT: f32 = 40.;68
const MAX_WINDOW_ITEMS: usize = 12;69
const MAX_WINDOW_ITEMS: usize = 12;69
pub const LOBBY_TEXT: &str = "Waiting in the lobby...";70
pub const LOBBY_TEXT: &str = "Waiting in the lobby...";70
pub const CHAT_PANEL_WIDTH: f32 = 320.;71
pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;71
const CHAT_HEADER_HEIGHT: f32 = 48.;72
const CHAT_HEADER_HEIGHT: f32 = 48.;72
const REACTION_RISE: f32 = 24.;73
const REACTION_RISE: f32 = 24.;73
const REACTION_FADE_FROM: f32 = 0.75;74
const REACTION_FADE_FROM: f32 = 0.75;@@ -1074,6 +1075,7 @@ pub fn render_call_view(1074
)1075
)1075
.children(health_indicator(model))1076
.children(health_indicator(model))1076
.children(recording_chip(model))1077
.children(recording_chip(model))1078
.children(lock_chip(model))1077
.children(room_chip(model))1079
.children(room_chip(model))1078
.child(div().flex_1())1080
.child(div().flex_1())1079
.children(return_button(app, model));1081
.children(return_button(app, model));@@ -1119,6 +1121,9 @@ pub fn render_call_view(1119
})1121
})1120
.child(view_button(app, model, fullscreen))1122
.child(view_button(app, model, fullscreen))1121
.children(more_button(app, model))1123
.children(more_button(app, model))1124
.when(model.kind != CallKind::Test, |row| {1125
row.child(people_button(app, call.people_open, model.raised_hands()))1126
})1122
.when(call.chat_thread().is_some(), |row| {1127
.when(call.chat_thread().is_some(), |row| {1123
row.child(chat_button(app, call.chat_open, state.call_chat_unread()))1128
row.child(chat_button(app, call.chat_open, state.call_chat_unread()))1124
})1129
})@@ -1132,6 +1137,7 @@ pub fn render_call_view(1132
.flex_none()1137
.flex_none()1133
.child(header)1138
.child(header)1134
.children(lobby_banner(app, model, call.lobby_list_open))1139
.children(lobby_banner(app, model, call.lobby_list_open))1140
.children(lock_banner(app, model))1135
.children(health_banner(app, model))1141
.children(health_banner(app, model))1136
.children(sharing_banner(app, model, state.call_share_sound))1142
.children(sharing_banner(app, model, state.call_share_sound))1137
.children(consult_banner(app, state));1143
.children(consult_banner(app, state));@@ -1168,6 +1174,7 @@ pub fn render_call_view(1168
.children(captions_hint_chip(model))1174
.children(captions_hint_chip(model))1169
.children(push_to_talk_chip(call))1175
.children(push_to_talk_chip(call))1170
.children(state.transfer_picker.clone())1176
.children(state.transfer_picker.clone())1177
.children(options_dialog(app, call))1171
.children(consent_overlay(app, model));1178
.children(consent_overlay(app, model));1172
Some(1179
Some(1173
h_flex()1180
h_flex()@@ -1181,6 +1188,7 @@ pub fn render_call_view(1181
.child(column)1188
.child(column)1182
.children(chat.map(|chat| chat_panel(app, chat)))1189
.children(chat.map(|chat| chat_panel(app, chat)))1183
.children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())1190
.children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())1191
.children(people_panel(app, state, call))1184
.into_any_element(),1192
.into_any_element(),1185
)1193
)1186
}1194
}@@ -10,6 +10,7 @@ pub mod call_layouts;
10
10
pub mod call_mini;
11
11
pub mod call_mini_window;
12
12
pub mod call_organizer;
13
pub mod call_people;
13
14
pub mod call_record;
14
15
pub mod call_stage;
15
16
pub mod call_transcript;
@@ -10,6 +10,7 @@ pub mod call_layouts;10
pub mod call_mini;10
pub mod call_mini;11
pub mod call_mini_window;11
pub mod call_mini_window;12
pub mod call_organizer;12
pub mod call_organizer;13
pub mod call_people;13
pub mod call_record;14
pub mod call_record;14
pub mod call_stage;15
pub mod call_stage;15
pub mod call_transcript;16
pub mod call_transcript;@@ -35,8 +35,15 @@ pub fn visible_candidates(
35
35
fuzzy::rank(query, candidates, MAX_RESULTS)
36
36
}
37
37
38
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39
pub enum PickerMode {
40
Transfer,
41
Invite,
42
}
43
38
44
pub struct TransferPicker {
39
45
app: Entity<AppState>,
46
mode: PickerMode,
40
47
candidates: Vec<(String, TransferCandidate)>,
41
48
search: Entity<InputState>,
42
49
results: Vec<TransferCandidate>,
@@ -49,6 +56,7 @@ impl TransferPicker {
49
56
pub fn new(
50
57
app: Entity<AppState>,
51
58
candidates: Vec<TransferCandidate>,
59
mode: PickerMode,
52
60
window: &mut Window,
53
61
cx: &mut Context<Self>,
54
62
) -> Self {
@@ -62,6 +70,7 @@ impl TransferPicker {
62
70
let results = visible_candidates(&candidates, "");
63
71
TransferPicker {
64
72
app,
73
mode,
65
74
candidates,
66
75
search,
67
76
results,
@@ -221,18 +230,15 @@ impl Render for TransferPicker {
221
230
.label("Cancel")
222
231
.on_click(cx.listener(|this, _, _, cx| this.close(cx))),
223
232
)
224
.child(self.action(
225
"transfer-consult",
226
"Consult first",
227
false,
228
AppState::start_consult,
229
))
230
.child(self.action(
231
"transfer-now",
232
"Transfer now",
233
true,
234
AppState::transfer_call_blind,
235
));
233
.children(match self.mode {
234
PickerMode::Transfer => vec![
235
self.action("transfer-consult", "Consult first", false, AppState::start_consult),
236
self.action("transfer-now", "Transfer now", true, AppState::transfer_call_blind),
237
],
238
PickerMode::Invite => {
239
vec![self.action("transfer-invite", "Invite", true, AppState::invite_call_person)]
240
}
241
});
236
242
div()
237
243
.id("transfer-layer")
238
244
.absolute()
@@ -278,7 +284,10 @@ impl Render for TransferPicker {
278
284
.flex_1()
279
285
.text_size(px(15.))
280
286
.font_weight(FontWeight::SEMIBOLD)
281
.child("Transfer call"),
287
.child(match self.mode {
288
PickerMode::Transfer => "Transfer call",
289
PickerMode::Invite => "Invite people",
290
}),
282
291
)
283
292
.child(
284
293
div()
@@ -35,8 +35,15 @@ pub fn visible_candidates(35
fuzzy::rank(query, candidates, MAX_RESULTS)35
fuzzy::rank(query, candidates, MAX_RESULTS)36
}36
}37
37
38
#[derive(Debug, Clone, Copy, PartialEq, Eq)]39
pub enum PickerMode {40
Transfer,41
Invite,42
}43
38
pub struct TransferPicker {44
pub struct TransferPicker {39
app: Entity<AppState>,45
app: Entity<AppState>,46
mode: PickerMode,40
candidates: Vec<(String, TransferCandidate)>,47
candidates: Vec<(String, TransferCandidate)>,41
search: Entity<InputState>,48
search: Entity<InputState>,42
results: Vec<TransferCandidate>,49
results: Vec<TransferCandidate>,@@ -49,6 +56,7 @@ impl TransferPicker {49
pub fn new(56
pub fn new(50
app: Entity<AppState>,57
app: Entity<AppState>,51
candidates: Vec<TransferCandidate>,58
candidates: Vec<TransferCandidate>,59
mode: PickerMode,52
window: &mut Window,60
window: &mut Window,53
cx: &mut Context<Self>,61
cx: &mut Context<Self>,54
) -> Self {62
) -> Self {@@ -62,6 +70,7 @@ impl TransferPicker {62
let results = visible_candidates(&candidates, "");70
let results = visible_candidates(&candidates, "");63
TransferPicker {71
TransferPicker {64
app,72
app,73
mode,65
candidates,74
candidates,66
search,75
search,67
results,76
results,@@ -221,18 +230,15 @@ impl Render for TransferPicker {221
.label("Cancel")230
.label("Cancel")222
.on_click(cx.listener(|this, _, _, cx| this.close(cx))),231
.on_click(cx.listener(|this, _, _, cx| this.close(cx))),223
)232
)224
.child(self.action(233
.children(match self.mode {225
"transfer-consult",234
PickerMode::Transfer => vec![226
"Consult first",235
self.action("transfer-consult", "Consult first", false, AppState::start_consult),227
false,236
self.action("transfer-now", "Transfer now", true, AppState::transfer_call_blind),228
AppState::start_consult,237
],229
))238
PickerMode::Invite => {230
.child(self.action(239
vec![self.action("transfer-invite", "Invite", true, AppState::invite_call_person)]231
"transfer-now",240
}232
"Transfer now",241
});233
true,234
AppState::transfer_call_blind,235
));236
div()242
div()237
.id("transfer-layer")243
.id("transfer-layer")238
.absolute()244
.absolute()@@ -278,7 +284,10 @@ impl Render for TransferPicker {278
.flex_1()284
.flex_1()279
.text_size(px(15.))285
.text_size(px(15.))280
.font_weight(FontWeight::SEMIBOLD)286
.font_weight(FontWeight::SEMIBOLD)281
.child("Transfer call"),287
.child(match self.mode {288
PickerMode::Transfer => "Transfer call",289
PickerMode::Invite => "Invite people",290
}),282
)291
)283
.child(292
.child(284
div()293
div()@@ -40,7 +40,8 @@ use crate::mute::{MuteCommand, MuteEffect};
40
40
use crate::push::CallNotification;
41
41
use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};
42
42
use crate::renegotiation::{MediaAction, MediaNegotiator, MediaPath};
43
use crate::organizer::Target;
43
use crate::organizer::{MeetingCapability, Modality, StateStep, Target, modality_steps};
44
use crate::meeting_options::{self, OptionWrite};
44
45
use crate::recording::{Consent, RecordingPlan, RecordingStatus};
45
46
use crate::roster::Roster;
46
47
use crate::sdp::{LineRole, OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};
@@ -798,6 +799,7 @@ async fn drive(
798
799
let mut next: Option<NextPeer> = None;
799
800
let mut roster = Roster::default();
800
801
let mut lobby = false;
802
let mut capability = MeetingCapability::default();
801
803
let mut previous_packets = 0u64;
802
804
let mut ticks = 0u32;
803
805
let mut health_sampler = HealthSampler::default();
@@ -1062,6 +1064,9 @@ async fn drive(
1062
1064
control.send(CallUpdate::MeetingChat(thread.clone()));
1063
1065
meeting_chat = Some(thread);
1064
1066
}
1067
if capability.apply(&body) {
1068
control.send(CallUpdate::Capability(capability));
1069
}
1065
1070
let change = recording_status.apply(&body);
1066
1071
if let Some(on) = change.recording {
1067
1072
control.send(CallUpdate::Recording(on));
@@ -1456,6 +1461,70 @@ async fn drive(
1456
1461
let result = remote.signaling.mute_everyone(&remote.conversation, &remote.participant, &others).await;
1457
1462
report_organizer_result(result, "mute all", "Could not mute everyone", control, timeline);
1458
1463
}
1464
Some(CallCommand::SetLock(locked)) => {
1465
let result = remote.signaling.set_lock(&remote.conversation, &remote.participant, locked).await;
1466
if result.is_ok() {
1467
capability.locked = locked;
1468
control.send(CallUpdate::Capability(capability));
1469
}
1470
report_organizer_result(result, "lock meeting", "Could not change the meeting lock", control, timeline);
1471
}
1472
Some(CallCommand::SetRole { mri, role }) => {
1473
let result = remote.signaling.change_role(&remote.conversation, &remote.participant, &mri, role).await;
1474
report_organizer_result(result, "change role", "Could not change that role", control, timeline);
1475
}
1476
Some(CallCommand::SetAttendeeModality { mri, modality, allowed }) => {
1477
let limits = roster.entries().into_iter().find(|entry| entry.mri == mri).map(|entry| entry.limits).unwrap_or_default();
1478
let mut result = Ok(200);
1479
for step in modality_steps(modality, allowed, capability, &limits) {
1480
result = match step {
1481
StateStep::Publish(state_type) => remote.signaling.publish_attendee_state(&remote.conversation, &remote.participant, state_type, &mri).await,
1482
StateStep::Remove(state_id) => remote.signaling.lower_hands(&remote.conversation, &remote.participant, &[state_id]).await.map(|()| 200),
1483
};
1484
if result.is_err() {
1485
break;
1486
}
1487
}
1488
let notice = if modality == Modality::Mic { "Could not change that microphone setting" } else { "Could not change that camera setting" };
1489
report_organizer_result(result, "attendee modality", notice, control, timeline);
1490
}
1491
Some(CallCommand::SetAttendeeRestrictions { mic_off, camera_off }) => {
1492
let result = match &meeting_target {
1493
Some(target) => meeting_options::write(&inner.session, target, &OptionWrite::restrictions(mic_off, camera_off)).await.map(|()| 200),
1494
None => Err(Error::Signaling("no meeting coordinates for the options".into())),
1495
};
1496
if result.is_ok() {
1497
capability.attendee_mic_off = mic_off;
1498
capability.attendee_camera_off = camera_off;
1499
control.send(CallUpdate::Capability(capability));
1500
}
1501
report_organizer_result(result, "attendee restrictions", "Could not change the attendee settings", control, timeline);
1502
}
1503
Some(CallCommand::Invite { callees, group_thread }) => {
1504
let thread = group_thread.or_else(|| meeting_chat.clone());
1505
let result = remote.signaling.add_participants(&remote.conversation, &remote.participant, &callees, thread.as_deref(), meeting_target.as_ref(), &links).await;
1506
report_organizer_result(result, "invite", "Could not invite that person", control, timeline);
1507
}
1508
Some(CallCommand::LoadMeetingOptions) => {
1509
let update = match &meeting_target {
1510
Some(target) => meeting_options::fetch(&inner.session, target).await.map_err(|error| error.to_string()),
1511
None => Err("This meeting has no options page".to_owned()),
1512
};
1513
control.send(CallUpdate::MeetingOptions(update));
1514
}
1515
Some(CallCommand::SaveMeetingOptions(writes)) => {
1516
let update = match &meeting_target {
1517
Some(target) => save_meeting_options(&inner.session, target, &writes).await,
1518
None => Err("This meeting has no options page".to_owned()),
1519
};
1520
if let Ok(options) = &update {
1521
let (mic_off, camera_off) = options.attendees_off();
1522
capability.attendee_mic_off = mic_off;
1523
capability.attendee_camera_off = camera_off;
1524
control.send(CallUpdate::Capability(capability));
1525
}
1526
control.send(CallUpdate::MeetingOptionsSaved(update));
1527
}
1459
1528
Some(CallCommand::Spotlight { mri }) => {
1460
1529
let result = remote.signaling.spotlight(&remote.conversation, &remote.participant, &mri).await;
1461
1530
report_organizer_result(result, "spotlight", "Could not spotlight that person", control, timeline);
@@ -2030,6 +2099,13 @@ async fn apply_background(choice: BackgroundChoice, local_video: &LocalVideo, co
2030
2099
}
2031
2100
}
2032
2101
2102
async fn save_meeting_options(session: &session::Session, target: &MeetingTarget, writes: &[OptionWrite]) -> std::result::Result<meeting_options::MeetingOptions, String> {
2103
for change in writes {
2104
meeting_options::write(session, target, change).await.map_err(|error| error.to_string())?;
2105
}
2106
meeting_options::fetch(session, target).await.map_err(|error| error.to_string())
2107
}
2108
2033
2109
fn target_of<'a>(roster: &'a Roster, mri: &'a str) -> Target<'a> {
2034
2110
let display_name = roster.members().iter().find(|member| member.mri == mri).map_or("", |member| member.display_name.as_str());
2035
2111
Target { mri, display_name }
@@ -40,7 +40,8 @@ use crate::mute::{MuteCommand, MuteEffect};40
use crate::push::CallNotification;40
use crate::push::CallNotification;41
use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};41
use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};42
use crate::renegotiation::{MediaAction, MediaNegotiator, MediaPath};42
use crate::renegotiation::{MediaAction, MediaNegotiator, MediaPath};43
use crate::organizer::Target;43
use crate::organizer::{MeetingCapability, Modality, StateStep, Target, modality_steps};44
use crate::meeting_options::{self, OptionWrite};44
use crate::recording::{Consent, RecordingPlan, RecordingStatus};45
use crate::recording::{Consent, RecordingPlan, RecordingStatus};45
use crate::roster::Roster;46
use crate::roster::Roster;46
use crate::sdp::{LineRole, OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};47
use crate::sdp::{LineRole, OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};@@ -798,6 +799,7 @@ async fn drive(798
let mut next: Option<NextPeer> = None;799
let mut next: Option<NextPeer> = None;799
let mut roster = Roster::default();800
let mut roster = Roster::default();800
let mut lobby = false;801
let mut lobby = false;802
let mut capability = MeetingCapability::default();801
let mut previous_packets = 0u64;803
let mut previous_packets = 0u64;802
let mut ticks = 0u32;804
let mut ticks = 0u32;803
let mut health_sampler = HealthSampler::default();805
let mut health_sampler = HealthSampler::default();@@ -1062,6 +1064,9 @@ async fn drive(1062
control.send(CallUpdate::MeetingChat(thread.clone()));1064
control.send(CallUpdate::MeetingChat(thread.clone()));1063
meeting_chat = Some(thread);1065
meeting_chat = Some(thread);1064
}1066
}1067
if capability.apply(&body) {1068
control.send(CallUpdate::Capability(capability));1069
}1065
let change = recording_status.apply(&body);1070
let change = recording_status.apply(&body);1066
if let Some(on) = change.recording {1071
if let Some(on) = change.recording {1067
control.send(CallUpdate::Recording(on));1072
control.send(CallUpdate::Recording(on));@@ -1456,6 +1461,70 @@ async fn drive(1456
let result = remote.signaling.mute_everyone(&remote.conversation, &remote.participant, &others).await;1461
let result = remote.signaling.mute_everyone(&remote.conversation, &remote.participant, &others).await;1457
report_organizer_result(result, "mute all", "Could not mute everyone", control, timeline);1462
report_organizer_result(result, "mute all", "Could not mute everyone", control, timeline);1458
}1463
}1464
Some(CallCommand::SetLock(locked)) => {1465
let result = remote.signaling.set_lock(&remote.conversation, &remote.participant, locked).await;1466
if result.is_ok() {1467
capability.locked = locked;1468
control.send(CallUpdate::Capability(capability));1469
}1470
report_organizer_result(result, "lock meeting", "Could not change the meeting lock", control, timeline);1471
}1472
Some(CallCommand::SetRole { mri, role }) => {1473
let result = remote.signaling.change_role(&remote.conversation, &remote.participant, &mri, role).await;1474
report_organizer_result(result, "change role", "Could not change that role", control, timeline);1475
}1476
Some(CallCommand::SetAttendeeModality { mri, modality, allowed }) => {1477
let limits = roster.entries().into_iter().find(|entry| entry.mri == mri).map(|entry| entry.limits).unwrap_or_default();1478
let mut result = Ok(200);1479
for step in modality_steps(modality, allowed, capability, &limits) {1480
result = match step {1481
StateStep::Publish(state_type) => remote.signaling.publish_attendee_state(&remote.conversation, &remote.participant, state_type, &mri).await,1482
StateStep::Remove(state_id) => remote.signaling.lower_hands(&remote.conversation, &remote.participant, &[state_id]).await.map(|()| 200),1483
};1484
if result.is_err() {1485
break;1486
}1487
}1488
let notice = if modality == Modality::Mic { "Could not change that microphone setting" } else { "Could not change that camera setting" };1489
report_organizer_result(result, "attendee modality", notice, control, timeline);1490
}1491
Some(CallCommand::SetAttendeeRestrictions { mic_off, camera_off }) => {1492
let result = match &meeting_target {1493
Some(target) => meeting_options::write(&inner.session, target, &OptionWrite::restrictions(mic_off, camera_off)).await.map(|()| 200),1494
None => Err(Error::Signaling("no meeting coordinates for the options".into())),1495
};1496
if result.is_ok() {1497
capability.attendee_mic_off = mic_off;1498
capability.attendee_camera_off = camera_off;1499
control.send(CallUpdate::Capability(capability));1500
}1501
report_organizer_result(result, "attendee restrictions", "Could not change the attendee settings", control, timeline);1502
}1503
Some(CallCommand::Invite { callees, group_thread }) => {1504
let thread = group_thread.or_else(|| meeting_chat.clone());1505
let result = remote.signaling.add_participants(&remote.conversation, &remote.participant, &callees, thread.as_deref(), meeting_target.as_ref(), &links).await;1506
report_organizer_result(result, "invite", "Could not invite that person", control, timeline);1507
}1508
Some(CallCommand::LoadMeetingOptions) => {1509
let update = match &meeting_target {1510
Some(target) => meeting_options::fetch(&inner.session, target).await.map_err(|error| error.to_string()),1511
None => Err("This meeting has no options page".to_owned()),1512
};1513
control.send(CallUpdate::MeetingOptions(update));1514
}1515
Some(CallCommand::SaveMeetingOptions(writes)) => {1516
let update = match &meeting_target {1517
Some(target) => save_meeting_options(&inner.session, target, &writes).await,1518
None => Err("This meeting has no options page".to_owned()),1519
};1520
if let Ok(options) = &update {1521
let (mic_off, camera_off) = options.attendees_off();1522
capability.attendee_mic_off = mic_off;1523
capability.attendee_camera_off = camera_off;1524
control.send(CallUpdate::Capability(capability));1525
}1526
control.send(CallUpdate::MeetingOptionsSaved(update));1527
}1459
Some(CallCommand::Spotlight { mri }) => {1528
Some(CallCommand::Spotlight { mri }) => {1460
let result = remote.signaling.spotlight(&remote.conversation, &remote.participant, &mri).await;1529
let result = remote.signaling.spotlight(&remote.conversation, &remote.participant, &mri).await;1461
report_organizer_result(result, "spotlight", "Could not spotlight that person", control, timeline);1530
report_organizer_result(result, "spotlight", "Could not spotlight that person", control, timeline);@@ -2030,6 +2099,13 @@ async fn apply_background(choice: BackgroundChoice, local_video: &LocalVideo, co2030
}2099
}2031
}2100
}2032
2101
2102
async fn save_meeting_options(session: &session::Session, target: &MeetingTarget, writes: &[OptionWrite]) -> std::result::Result<meeting_options::MeetingOptions, String> {2103
for change in writes {2104
meeting_options::write(session, target, change).await.map_err(|error| error.to_string())?;2105
}2106
meeting_options::fetch(session, target).await.map_err(|error| error.to_string())2107
}2108
2033
fn target_of<'a>(roster: &'a Roster, mri: &'a str) -> Target<'a> {2109
fn target_of<'a>(roster: &'a Roster, mri: &'a str) -> Target<'a> {2034
let display_name = roster.members().iter().find(|member| member.mri == mri).map_or("", |member| member.display_name.as_str());2110
let display_name = roster.members().iter().find(|member| member.mri == mri).map_or("", |member| member.display_name.as_str());2035
Target { mri, display_name }2111
Target { mri, display_name }@@ -13,9 +13,11 @@ use crate::error::{Error, Result};
13
13
use crate::health::CallHealth;
14
14
use crate::hold::HoldState;
15
15
use crate::mic_processing::MicSettings;
16
use crate::meeting_options::{MeetingOptions, OptionWrite};
16
17
use crate::mute::MuteCommand;
18
use crate::organizer::{MeetingCapability, Modality};
17
19
use crate::reaction::Reaction;
18
use crate::roster::RosterEntry;
20
use crate::roster::{MeetingRole, RosterEntry};
19
21
use crate::camera::CameraDevice;
20
22
use crate::screen::ShareSource;
21
23
use crate::signaling::{Callee, MeetingTarget};
@@ -48,6 +50,13 @@ pub enum CallCommand {
48
50
Spotlight { mri: String },
49
51
StopSpotlight { mri: String },
50
52
RemoveParticipant { mri: String },
53
SetLock(bool),
54
SetRole { mri: String, role: MeetingRole },
55
SetAttendeeModality { mri: String, modality: Modality, allowed: bool },
56
SetAttendeeRestrictions { mic_off: bool, camera_off: bool },
57
Invite { callees: Vec<Callee>, group_thread: Option<String> },
58
LoadMeetingOptions,
59
SaveMeetingOptions(Vec<OptionWrite>),
51
60
SetCaptions(bool),
52
61
SetBackground(BackgroundChoice),
53
62
SetIncomingVideo(bool),
@@ -108,6 +117,9 @@ pub enum CallUpdate {
108
117
BreakoutMove(BreakoutMove),
109
118
BreakoutRoom { main: MeetingTarget },
110
119
ReplacementLink(String),
120
Capability(MeetingCapability),
121
MeetingOptions(std::result::Result<MeetingOptions, String>),
122
MeetingOptionsSaved(std::result::Result<MeetingOptions, String>),
111
123
Organizer { action: String, outcome: std::result::Result<u16, String> },
112
124
MeetingChat(String),
113
125
Notice(String),
@@ -13,9 +13,11 @@ use crate::error::{Error, Result};13
use crate::health::CallHealth;13
use crate::health::CallHealth;14
use crate::hold::HoldState;14
use crate::hold::HoldState;15
use crate::mic_processing::MicSettings;15
use crate::mic_processing::MicSettings;16
use crate::meeting_options::{MeetingOptions, OptionWrite};16
use crate::mute::MuteCommand;17
use crate::mute::MuteCommand;18
use crate::organizer::{MeetingCapability, Modality};17
use crate::reaction::Reaction;19
use crate::reaction::Reaction;18
use crate::roster::RosterEntry;20
use crate::roster::{MeetingRole, RosterEntry};19
use crate::camera::CameraDevice;21
use crate::camera::CameraDevice;20
use crate::screen::ShareSource;22
use crate::screen::ShareSource;21
use crate::signaling::{Callee, MeetingTarget};23
use crate::signaling::{Callee, MeetingTarget};@@ -48,6 +50,13 @@ pub enum CallCommand {48
Spotlight { mri: String },50
Spotlight { mri: String },49
StopSpotlight { mri: String },51
StopSpotlight { mri: String },50
RemoveParticipant { mri: String },52
RemoveParticipant { mri: String },53
SetLock(bool),54
SetRole { mri: String, role: MeetingRole },55
SetAttendeeModality { mri: String, modality: Modality, allowed: bool },56
SetAttendeeRestrictions { mic_off: bool, camera_off: bool },57
Invite { callees: Vec<Callee>, group_thread: Option<String> },58
LoadMeetingOptions,59
SaveMeetingOptions(Vec<OptionWrite>),51
SetCaptions(bool),60
SetCaptions(bool),52
SetBackground(BackgroundChoice),61
SetBackground(BackgroundChoice),53
SetIncomingVideo(bool),62
SetIncomingVideo(bool),@@ -108,6 +117,9 @@ pub enum CallUpdate {108
BreakoutMove(BreakoutMove),117
BreakoutMove(BreakoutMove),109
BreakoutRoom { main: MeetingTarget },118
BreakoutRoom { main: MeetingTarget },110
ReplacementLink(String),119
ReplacementLink(String),120
Capability(MeetingCapability),121
MeetingOptions(std::result::Result<MeetingOptions, String>),122
MeetingOptionsSaved(std::result::Result<MeetingOptions, String>),111
Organizer { action: String, outcome: std::result::Result<u16, String> },123
Organizer { action: String, outcome: std::result::Result<u16, String> },112
MeetingChat(String),124
MeetingChat(String),113
Notice(String),125
Notice(String),@@ -24,6 +24,7 @@ pub mod luma_effects;
24
24
#[cfg(windows)]
25
25
mod loopback_windows;
26
26
pub mod meeting;
27
pub mod meeting_options;
27
28
pub mod mic_processing;
28
29
pub mod mixer;
29
30
pub mod mute;
@@ -67,8 +68,10 @@ pub use push::Caller;
67
68
pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};
68
69
pub use reaction::{Reaction, ReactionEvent};
69
70
pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};
71
pub use meeting_options::{MeetingOptions, OptionWrite};
72
pub use organizer::{MeetingCapability, Modality, modality_allowed};
70
73
pub use recording::{RecordingKind, StopScope};
71
pub use roster::{PublishedState, RaisedHand, RosterEntry, Spotlight};
74
pub use roster::{AttendeeLimits, MeetingRole, PublishedState, RaisedHand, RosterEntry, Spotlight};
72
75
pub use sound_capture::LoopbackKind;
73
76
pub use renegotiation::MediaPath;
74
77
pub use signaling::{Callee, MeetingTarget};
@@ -24,6 +24,7 @@ pub mod luma_effects;24
#[cfg(windows)]24
#[cfg(windows)]25
mod loopback_windows;25
mod loopback_windows;26
pub mod meeting;26
pub mod meeting;27
pub mod meeting_options;27
pub mod mic_processing;28
pub mod mic_processing;28
pub mod mixer;29
pub mod mixer;29
pub mod mute;30
pub mod mute;@@ -67,8 +68,10 @@ pub use push::Caller;67
pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};68
pub use ring::{RING_TIMEOUT, RingEnd, RingSignal, RingState};68
pub use reaction::{Reaction, ReactionEvent};69
pub use reaction::{Reaction, ReactionEvent};69
pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};70
pub use captions::{CaptionEntry, CaptionState, SPOKEN_LANGUAGES};71
pub use meeting_options::{MeetingOptions, OptionWrite};72
pub use organizer::{MeetingCapability, Modality, modality_allowed};70
pub use recording::{RecordingKind, StopScope};73
pub use recording::{RecordingKind, StopScope};71
pub use roster::{PublishedState, RaisedHand, RosterEntry, Spotlight};74
pub use roster::{AttendeeLimits, MeetingRole, PublishedState, RaisedHand, RosterEntry, Spotlight};72
pub use sound_capture::LoopbackKind;75
pub use sound_capture::LoopbackKind;73
pub use renegotiation::MediaPath;76
pub use renegotiation::MediaPath;74
pub use signaling::{Callee, MeetingTarget};77
pub use signaling::{Callee, MeetingTarget};@@ -0,0 +1,261 @@
1
use serde_json::{Value, json};
2
use session::{Method, Request, SPACES, Scope, Session};
3
4
use crate::error::{Error, Result};
5
use crate::organizer::restrictions_value;
6
use crate::signaling::{CHATSVC_REGION, MeetingTarget};
7
use crate::whiteboard::encoded;
8
9
const OPTIONS_SCOPE: &str = "user_impersonation";
10
const READ_HOST: &str = "https://teams.microsoft.com";
11
const LIVE_HOST: &str = "https://teams.cloud.microsoft";
12
const AUTO_ADMITTED: &str = "AutoAdmittedUsers";
13
const PRESENTER: &str = "PresenterOption";
14
const RESTRICTIONS: &str = "AttendeeRestrictions";
15
const MEETING_CHAT: &str = "AllowMeetingChat";
16
const REACTIONS: &str = "AllowTeamsMeetingReactions";
17
const AUTO_RECORD: &str = "AutoRecordAndTranscribeMode";
18
const RECORD_ON: &str = "AutoRecordingAndTranscription";
19
const RECORD_OFF: &str = "Off";
20
const LIST: &str = "List";
21
const BOOLEAN: &str = "Boolean";
22
const BIT_MASK: &str = "BitMask";
23
24
pub const BYPASS_CHOICES: [(&str, &str); 6] = [
25
("Everyone", "Everyone"),
26
("EveryoneInSameAndFederatedCompany", "People in my org and trusted orgs"),
27
("EveryoneInCompany", "People in my org"),
28
("EveryoneInCompanyExcludingGuests", "People in my org, no guests"),
29
("InvitedUsers", "People I invite"),
30
("OrganizerOnly", "Only me"),
31
];
32
pub const PRESENTER_CHOICES: [(&str, &str); 3] = [
33
("Everyone", "Everyone"),
34
("EveryoneInCompany", "People in my org"),
35
("OrganizerOnly", "Only me"),
36
];
37
pub const CHAT_CHOICES: [(&str, &str); 3] = [
38
("Enabled", "On"),
39
("InMeeting", "In-meeting only"),
40
("Disabled", "Off"),
41
];
42
43
#[derive(Debug, Clone, PartialEq, Eq)]
44
pub struct MeetingOptions {
45
pub bypass_lobby: String,
46
pub presenters: String,
47
pub attendee_mic: bool,
48
pub attendee_camera: bool,
49
pub meeting_chat: String,
50
pub reactions: bool,
51
pub record_automatically: bool,
52
record_mode: String,
53
}
54
55
#[derive(Debug, Clone, PartialEq, Eq)]
56
pub struct OptionWrite {
57
pub name: &'static str,
58
pub kind: &'static str,
59
pub value: Value,
60
}
61
62
impl OptionWrite {
63
pub fn restrictions(mic_off: bool, camera_off: bool) -> OptionWrite {
64
OptionWrite { name: RESTRICTIONS, kind: BIT_MASK, value: json!(restrictions_value(mic_off, camera_off)) }
65
}
66
67
fn body(&self) -> Value {
68
json!({"options": [{"name": self.name, "type": self.kind, "currentValue": self.value, "isRecommended": null}]})
69
}
70
}
71
72
impl MeetingOptions {
73
pub fn from_response(body: &Value) -> Option<MeetingOptions> {
74
let options = body["options"].as_array()?;
75
let current = |name: &str| options.iter().find(|option| option["name"].as_str() == Some(name)).map(|option| &option["currentValue"]);
76
let text = |name: &str| current(name).and_then(Value::as_str).map(str::to_owned);
77
let flag = |name: &str| current(name).and_then(|value| value.as_bool().or_else(|| value.as_str().map(|text| text.eq_ignore_ascii_case("true"))));
78
let restrictions = text(RESTRICTIONS).unwrap_or_default();
79
let record_mode = text(AUTO_RECORD).unwrap_or_else(|| RECORD_OFF.to_owned());
80
Some(MeetingOptions {
81
bypass_lobby: text(AUTO_ADMITTED)?,
82
presenters: text(PRESENTER)?,
83
attendee_mic: !restrictions.contains("DisableAudio"),
84
attendee_camera: !restrictions.contains("DisableVideo"),
85
meeting_chat: text(MEETING_CHAT)?,
86
reactions: flag(REACTIONS).unwrap_or(true),
87
record_automatically: record_mode == RECORD_ON,
88
record_mode,
89
})
90
}
91
92
pub fn changes(&self, edited: &MeetingOptions) -> Vec<OptionWrite> {
93
let mut writes = Vec::new();
94
let mut list = |name: &'static str, before: &str, after: &str| {
95
if before != after {
96
writes.push(OptionWrite { name, kind: LIST, value: json!(after) });
97
}
98
};
99
list(AUTO_ADMITTED, &self.bypass_lobby, &edited.bypass_lobby);
100
list(PRESENTER, &self.presenters, &edited.presenters);
101
list(MEETING_CHAT, &self.meeting_chat, &edited.meeting_chat);
102
if self.record_automatically != edited.record_automatically {
103
let mode = if edited.record_automatically { RECORD_ON } else { RECORD_OFF };
104
writes.push(OptionWrite { name: AUTO_RECORD, kind: LIST, value: json!(mode) });
105
}
106
if self.reactions != edited.reactions {
107
writes.push(OptionWrite { name: REACTIONS, kind: BOOLEAN, value: json!(edited.reactions) });
108
}
109
if (self.attendee_mic, self.attendee_camera) != (edited.attendee_mic, edited.attendee_camera) {
110
writes.push(OptionWrite::restrictions(!edited.attendee_mic, !edited.attendee_camera));
111
}
112
writes
113
}
114
115
pub fn attendees_off(&self) -> (bool, bool) {
116
(!self.attendee_mic, !self.attendee_camera)
117
}
118
119
pub fn record_mode(&self) -> &str {
120
&self.record_mode
121
}
122
}
123
124
fn coordinates(target: &MeetingTarget) -> String {
125
format!("{}/{}/{}", encoded(&target.tenant_id), encoded(&target.organizer_id), encoded(&target.thread_id))
126
}
127
128
pub fn read_url(target: &MeetingTarget) -> String {
129
format!("{READ_HOST}/api/mt/{CHATSVC_REGION}//beta/meetings/v1/options/{}/0?monarch=true", coordinates(target))
130
}
131
132
pub fn write_url(target: &MeetingTarget) -> String {
133
format!("{LIVE_HOST}/api/mt/{CHATSVC_REGION}/beta/meetings/v1/options/{}/0/0?monarch=true", coordinates(target))
134
}
135
136
fn with_headers(mut request: Request, caller: &str) -> Request {
137
request.headers.extend([
138
("X-Ms-Migration".to_owned(), "True".to_owned()),
139
("x-ms-client-caller".to_owned(), caller.to_owned()),
140
("X-MS-Request-Id".to_owned(), uuid::Uuid::new_v4().to_string()),
141
]);
142
request
143
}
144
145
fn scope() -> Scope {
146
Scope::new(SPACES, OPTIONS_SCOPE)
147
}
148
149
pub async fn fetch(session: &Session, target: &MeetingTarget) -> Result<MeetingOptions> {
150
let request = with_headers(Request::get(read_url(target)), "meeting-options-dialog");
151
let response = session.send(request, &scope()).await?;
152
MeetingOptions::from_response(&response.body).ok_or_else(|| Error::Signaling("meeting options answer without the expected options".into()))
153
}
154
155
pub fn write_failed(body: &Value) -> bool {
156
body["success"].as_bool() == Some(false)
157
|| body["options"].as_array().is_some_and(|options| options.iter().any(|option| option["success"].as_bool() == Some(false)))
158
}
159
160
pub async fn write(session: &Session, target: &MeetingTarget, change: &OptionWrite) -> Result<()> {
161
let mut request = with_headers(Request::with_body(Method::Post, write_url(target), change.body()), "meeting-options-dialog");
162
request.headers.push(("x-ms-test-user".to_owned(), "False".to_owned()));
163
let response = session.send(request, &scope()).await?;
164
if write_failed(&response.body) {
165
return Err(Error::Signaling(format!("the service refused {}", change.name)));
166
}
167
Ok(())
168
}
169
170
#[cfg(test)]
171
mod tests {
172
use super::*;
173
174
fn target() -> MeetingTarget {
175
MeetingTarget {
176
thread_id: "19:meeting_abc@thread.v2".into(),
177
tenant_id: "00000000-0000-0000-0000-000000000001".into(),
178
organizer_id: "00000000-0000-0000-0000-000000000002".into(),
179
meeting_data: None,
180
}
181
}
182
183
fn option(name: &str, kind: &str, value: Value) -> Value {
184
json!({"name": name, "type": kind, "currentValue": value, "category": "x", "isDisabled": false})
185
}
186
187
fn response() -> Value {
188
json!({"options": [
189
option("AutoAdmittedUsers", "List", json!("EveryoneInCompany")),
190
option("PresenterOption", "List", json!("Everyone")),
191
option("AttendeeRestrictions", "BitMask", json!("DisableAudio")),
192
option("AllowMeetingChat", "List", json!("InMeeting")),
193
option("AllowTeamsMeetingReactions", "Boolean", json!(true)),
194
option("AutoRecordAndTranscribeMode", "List", json!("AutoTranscriptionOnly")),
195
], "meetingDetails": {"title": "Standup"}})
196
}
197
198
#[test]
199
fn the_read_url_keeps_the_double_slash_and_the_write_url_adds_a_zero() {
200
assert_eq!(
201
read_url(&target()),
202
"https://teams.microsoft.com/api/mt/emea//beta/meetings/v1/options/00000000-0000-0000-0000-000000000001/00000000-0000-0000-0000-000000000002/19%3Ameeting_abc%40thread.v2/0?monarch=true"
203
);
204
assert_eq!(
205
write_url(&target()),
206
"https://teams.cloud.microsoft/api/mt/emea/beta/meetings/v1/options/00000000-0000-0000-0000-000000000001/00000000-0000-0000-0000-000000000002/19%3Ameeting_abc%40thread.v2/0/0?monarch=true"
207
);
208
}
209
210
#[test]
211
fn the_read_answer_becomes_the_dialog_fields() {
212
let options = MeetingOptions::from_response(&response()).unwrap();
213
assert_eq!(options.bypass_lobby, "EveryoneInCompany");
214
assert_eq!(options.presenters, "Everyone");
215
assert!(!options.attendee_mic);
216
assert!(options.attendee_camera);
217
assert_eq!(options.meeting_chat, "InMeeting");
218
assert!(options.reactions);
219
assert!(!options.record_automatically);
220
assert_eq!(options.record_mode(), "AutoTranscriptionOnly");
221
assert!(MeetingOptions::from_response(&json!({"options": []})).is_none());
222
}
223
224
#[test]
225
fn only_changed_options_are_written() {
226
let before = MeetingOptions::from_response(&response()).unwrap();
227
assert!(before.changes(&before.clone()).is_empty());
228
let edited = MeetingOptions {
229
bypass_lobby: "OrganizerOnly".into(),
230
meeting_chat: "Disabled".into(),
231
record_automatically: true,
232
reactions: false,
233
attendee_mic: true,
234
attendee_camera: false,
235
..before.clone()
236
};
237
let writes = before.changes(&edited);
238
let names: Vec<&str> = writes.iter().map(|write| write.name).collect();
239
assert_eq!(names, ["AutoAdmittedUsers", "AllowMeetingChat", "AutoRecordAndTranscribeMode", "AllowTeamsMeetingReactions", "AttendeeRestrictions"]);
240
assert_eq!(writes[2].value, json!("AutoRecordingAndTranscription"));
241
assert_eq!(writes[4].value, json!("DisableVideo"));
242
}
243
244
#[test]
245
fn a_write_sends_one_option_in_the_captured_shape() {
246
let write = OptionWrite { name: "AllowMeetingChat", kind: "List", value: json!("Disabled") };
247
assert_eq!(
248
write.body(),
249
json!({"options": [{"name": "AllowMeetingChat", "type": "List", "currentValue": "Disabled", "isRecommended": null}]})
250
);
251
assert_eq!(OptionWrite::restrictions(true, true).body()["options"][0]["currentValue"], "DisableAudio,DisableVideo");
252
assert_eq!(OptionWrite::restrictions(false, false).value, json!("UnRestricted"));
253
}
254
255
#[test]
256
fn a_refused_write_is_told_apart_from_an_accepted_one() {
257
assert!(!write_failed(&json!({"success": true, "options": [{"success": true}]})));
258
assert!(write_failed(&json!({"success": false})));
259
assert!(write_failed(&json!({"success": true, "options": [{"success": false}]})));
260
}
261
}
@@ -0,0 +1,261 @@1
use serde_json::{Value, json};2
use session::{Method, Request, SPACES, Scope, Session};3
4
use crate::error::{Error, Result};5
use crate::organizer::restrictions_value;6
use crate::signaling::{CHATSVC_REGION, MeetingTarget};7
use crate::whiteboard::encoded;8
9
const OPTIONS_SCOPE: &str = "user_impersonation";10
const READ_HOST: &str = "https://teams.microsoft.com";11
const LIVE_HOST: &str = "https://teams.cloud.microsoft";12
const AUTO_ADMITTED: &str = "AutoAdmittedUsers";13
const PRESENTER: &str = "PresenterOption";14
const RESTRICTIONS: &str = "AttendeeRestrictions";15
const MEETING_CHAT: &str = "AllowMeetingChat";16
const REACTIONS: &str = "AllowTeamsMeetingReactions";17
const AUTO_RECORD: &str = "AutoRecordAndTranscribeMode";18
const RECORD_ON: &str = "AutoRecordingAndTranscription";19
const RECORD_OFF: &str = "Off";20
const LIST: &str = "List";21
const BOOLEAN: &str = "Boolean";22
const BIT_MASK: &str = "BitMask";23
24
pub const BYPASS_CHOICES: [(&str, &str); 6] = [25
("Everyone", "Everyone"),26
("EveryoneInSameAndFederatedCompany", "People in my org and trusted orgs"),27
("EveryoneInCompany", "People in my org"),28
("EveryoneInCompanyExcludingGuests", "People in my org, no guests"),29
("InvitedUsers", "People I invite"),30
("OrganizerOnly", "Only me"),31
];32
pub const PRESENTER_CHOICES: [(&str, &str); 3] = [33
("Everyone", "Everyone"),34
("EveryoneInCompany", "People in my org"),35
("OrganizerOnly", "Only me"),36
];37
pub const CHAT_CHOICES: [(&str, &str); 3] = [38
("Enabled", "On"),39
("InMeeting", "In-meeting only"),40
("Disabled", "Off"),41
];42
43
#[derive(Debug, Clone, PartialEq, Eq)]44
pub struct MeetingOptions {45
pub bypass_lobby: String,46
pub presenters: String,47
pub attendee_mic: bool,48
pub attendee_camera: bool,49
pub meeting_chat: String,50
pub reactions: bool,51
pub record_automatically: bool,52
record_mode: String,53
}54
55
#[derive(Debug, Clone, PartialEq, Eq)]56
pub struct OptionWrite {57
pub name: &'static str,58
pub kind: &'static str,59
pub value: Value,60
}61
62
impl OptionWrite {63
pub fn restrictions(mic_off: bool, camera_off: bool) -> OptionWrite {64
OptionWrite { name: RESTRICTIONS, kind: BIT_MASK, value: json!(restrictions_value(mic_off, camera_off)) }65
}66
67
fn body(&self) -> Value {68
json!({"options": [{"name": self.name, "type": self.kind, "currentValue": self.value, "isRecommended": null}]})69
}70
}71
72
impl MeetingOptions {73
pub fn from_response(body: &Value) -> Option<MeetingOptions> {74
let options = body["options"].as_array()?;75
let current = |name: &str| options.iter().find(|option| option["name"].as_str() == Some(name)).map(|option| &option["currentValue"]);76
let text = |name: &str| current(name).and_then(Value::as_str).map(str::to_owned);77
let flag = |name: &str| current(name).and_then(|value| value.as_bool().or_else(|| value.as_str().map(|text| text.eq_ignore_ascii_case("true"))));78
let restrictions = text(RESTRICTIONS).unwrap_or_default();79
let record_mode = text(AUTO_RECORD).unwrap_or_else(|| RECORD_OFF.to_owned());80
Some(MeetingOptions {81
bypass_lobby: text(AUTO_ADMITTED)?,82
presenters: text(PRESENTER)?,83
attendee_mic: !restrictions.contains("DisableAudio"),84
attendee_camera: !restrictions.contains("DisableVideo"),85
meeting_chat: text(MEETING_CHAT)?,86
reactions: flag(REACTIONS).unwrap_or(true),87
record_automatically: record_mode == RECORD_ON,88
record_mode,89
})90
}91
92
pub fn changes(&self, edited: &MeetingOptions) -> Vec<OptionWrite> {93
let mut writes = Vec::new();94
let mut list = |name: &'static str, before: &str, after: &str| {95
if before != after {96
writes.push(OptionWrite { name, kind: LIST, value: json!(after) });97
}98
};99
list(AUTO_ADMITTED, &self.bypass_lobby, &edited.bypass_lobby);100
list(PRESENTER, &self.presenters, &edited.presenters);101
list(MEETING_CHAT, &self.meeting_chat, &edited.meeting_chat);102
if self.record_automatically != edited.record_automatically {103
let mode = if edited.record_automatically { RECORD_ON } else { RECORD_OFF };104
writes.push(OptionWrite { name: AUTO_RECORD, kind: LIST, value: json!(mode) });105
}106
if self.reactions != edited.reactions {107
writes.push(OptionWrite { name: REACTIONS, kind: BOOLEAN, value: json!(edited.reactions) });108
}109
if (self.attendee_mic, self.attendee_camera) != (edited.attendee_mic, edited.attendee_camera) {110
writes.push(OptionWrite::restrictions(!edited.attendee_mic, !edited.attendee_camera));111
}112
writes113
}114
115
pub fn attendees_off(&self) -> (bool, bool) {116
(!self.attendee_mic, !self.attendee_camera)117
}118
119
pub fn record_mode(&self) -> &str {120
&self.record_mode121
}122
}123
124
fn coordinates(target: &MeetingTarget) -> String {125
format!("{}/{}/{}", encoded(&target.tenant_id), encoded(&target.organizer_id), encoded(&target.thread_id))126
}127
128
pub fn read_url(target: &MeetingTarget) -> String {129
format!("{READ_HOST}/api/mt/{CHATSVC_REGION}//beta/meetings/v1/options/{}/0?monarch=true", coordinates(target))130
}131
132
pub fn write_url(target: &MeetingTarget) -> String {133
format!("{LIVE_HOST}/api/mt/{CHATSVC_REGION}/beta/meetings/v1/options/{}/0/0?monarch=true", coordinates(target))134
}135
136
fn with_headers(mut request: Request, caller: &str) -> Request {137
request.headers.extend([138
("X-Ms-Migration".to_owned(), "True".to_owned()),139
("x-ms-client-caller".to_owned(), caller.to_owned()),140
("X-MS-Request-Id".to_owned(), uuid::Uuid::new_v4().to_string()),141
]);142
request143
}144
145
fn scope() -> Scope {146
Scope::new(SPACES, OPTIONS_SCOPE)147
}148
149
pub async fn fetch(session: &Session, target: &MeetingTarget) -> Result<MeetingOptions> {150
let request = with_headers(Request::get(read_url(target)), "meeting-options-dialog");151
let response = session.send(request, &scope()).await?;152
MeetingOptions::from_response(&response.body).ok_or_else(|| Error::Signaling("meeting options answer without the expected options".into()))153
}154
155
pub fn write_failed(body: &Value) -> bool {156
body["success"].as_bool() == Some(false)157
|| body["options"].as_array().is_some_and(|options| options.iter().any(|option| option["success"].as_bool() == Some(false)))158
}159
160
pub async fn write(session: &Session, target: &MeetingTarget, change: &OptionWrite) -> Result<()> {161
let mut request = with_headers(Request::with_body(Method::Post, write_url(target), change.body()), "meeting-options-dialog");162
request.headers.push(("x-ms-test-user".to_owned(), "False".to_owned()));163
let response = session.send(request, &scope()).await?;164
if write_failed(&response.body) {165
return Err(Error::Signaling(format!("the service refused {}", change.name)));166
}167
Ok(())168
}169
170
#[cfg(test)]171
mod tests {172
use super::*;173
174
fn target() -> MeetingTarget {175
MeetingTarget {176
thread_id: "19:meeting_abc@thread.v2".into(),177
tenant_id: "00000000-0000-0000-0000-000000000001".into(),178
organizer_id: "00000000-0000-0000-0000-000000000002".into(),179
meeting_data: None,180
}181
}182
183
fn option(name: &str, kind: &str, value: Value) -> Value {184
json!({"name": name, "type": kind, "currentValue": value, "category": "x", "isDisabled": false})185
}186
187
fn response() -> Value {188
json!({"options": [189
option("AutoAdmittedUsers", "List", json!("EveryoneInCompany")),190
option("PresenterOption", "List", json!("Everyone")),191
option("AttendeeRestrictions", "BitMask", json!("DisableAudio")),192
option("AllowMeetingChat", "List", json!("InMeeting")),193
option("AllowTeamsMeetingReactions", "Boolean", json!(true)),194
option("AutoRecordAndTranscribeMode", "List", json!("AutoTranscriptionOnly")),195
], "meetingDetails": {"title": "Standup"}})196
}197
198
#[test]199
fn the_read_url_keeps_the_double_slash_and_the_write_url_adds_a_zero() {200
assert_eq!(201
read_url(&target()),202
"https://teams.microsoft.com/api/mt/emea//beta/meetings/v1/options/00000000-0000-0000-0000-000000000001/00000000-0000-0000-0000-000000000002/19%3Ameeting_abc%40thread.v2/0?monarch=true"203
);204
assert_eq!(205
write_url(&target()),206
"https://teams.cloud.microsoft/api/mt/emea/beta/meetings/v1/options/00000000-0000-0000-0000-000000000001/00000000-0000-0000-0000-000000000002/19%3Ameeting_abc%40thread.v2/0/0?monarch=true"207
);208
}209
210
#[test]211
fn the_read_answer_becomes_the_dialog_fields() {212
let options = MeetingOptions::from_response(&response()).unwrap();213
assert_eq!(options.bypass_lobby, "EveryoneInCompany");214
assert_eq!(options.presenters, "Everyone");215
assert!(!options.attendee_mic);216
assert!(options.attendee_camera);217
assert_eq!(options.meeting_chat, "InMeeting");218
assert!(options.reactions);219
assert!(!options.record_automatically);220
assert_eq!(options.record_mode(), "AutoTranscriptionOnly");221
assert!(MeetingOptions::from_response(&json!({"options": []})).is_none());222
}223
224
#[test]225
fn only_changed_options_are_written() {226
let before = MeetingOptions::from_response(&response()).unwrap();227
assert!(before.changes(&before.clone()).is_empty());228
let edited = MeetingOptions {229
bypass_lobby: "OrganizerOnly".into(),230
meeting_chat: "Disabled".into(),231
record_automatically: true,232
reactions: false,233
attendee_mic: true,234
attendee_camera: false,235
..before.clone()236
};237
let writes = before.changes(&edited);238
let names: Vec<&str> = writes.iter().map(|write| write.name).collect();239
assert_eq!(names, ["AutoAdmittedUsers", "AllowMeetingChat", "AutoRecordAndTranscribeMode", "AllowTeamsMeetingReactions", "AttendeeRestrictions"]);240
assert_eq!(writes[2].value, json!("AutoRecordingAndTranscription"));241
assert_eq!(writes[4].value, json!("DisableVideo"));242
}243
244
#[test]245
fn a_write_sends_one_option_in_the_captured_shape() {246
let write = OptionWrite { name: "AllowMeetingChat", kind: "List", value: json!("Disabled") };247
assert_eq!(248
write.body(),249
json!({"options": [{"name": "AllowMeetingChat", "type": "List", "currentValue": "Disabled", "isRecommended": null}]})250
);251
assert_eq!(OptionWrite::restrictions(true, true).body()["options"][0]["currentValue"], "DisableAudio,DisableVideo");252
assert_eq!(OptionWrite::restrictions(false, false).value, json!("UnRestricted"));253
}254
255
#[test]256
fn a_refused_write_is_told_apart_from_an_accepted_one() {257
assert!(!write_failed(&json!({"success": true, "options": [{"success": true}]})));258
assert!(write_failed(&json!({"success": false})));259
assert!(write_failed(&json!({"success": true, "options": [{"success": false}]})));260
}261
}@@ -1,11 +1,129 @@
1
1
use serde_json::{Value, json};
2
2
3
use crate::trouter_events::CallbackLinks;
3
use crate::roster::{AttendeeLimits, MeetingRole};
4
use crate::signaling::{Callee, MEETING_MESSAGE_ID, MeetingTarget};
5
use crate::trouter_events::{CallbackLinks, find_key};
4
6
5
7
const SPOTLIGHT: &str = "spotlight";
6
8
const AUDIO: &str = "audio";
7
9
const SPECIFIED: &str = "specified";
8
10
const EVERYONE: &str = "all";
11
const PRESENTER: &str = "presenter";
12
const DISABLE_AUDIO: &str = "DisableAudio";
13
const DISABLE_VIDEO: &str = "DisableVideo";
14
const UNRESTRICTED: &str = "UnRestricted";
15
16
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
17
pub struct MeetingCapability {
18
pub locked: bool,
19
pub attendee_mic_off: bool,
20
pub attendee_camera_off: bool,
21
}
22
23
impl MeetingCapability {
24
pub fn apply(&mut self, body: &Value) -> bool {
25
let Some(capability) = find_key(body, "meetingCapability") else {
26
return false;
27
};
28
let before = *self;
29
if let Some(locked) = capability["lockMeeting"].as_bool() {
30
self.locked = locked;
31
}
32
if let Some(restrictions) = capability["attendeeRestrictions"].as_str() {
33
self.attendee_mic_off = restrictions.contains(DISABLE_AUDIO);
34
self.attendee_camera_off = restrictions.contains(DISABLE_VIDEO);
35
}
36
*self != before
37
}
38
}
39
40
pub fn restrictions_value(mic_off: bool, camera_off: bool) -> String {
41
let flags: Vec<&str> = [(mic_off, DISABLE_AUDIO), (camera_off, DISABLE_VIDEO)]
42
.into_iter()
43
.filter_map(|(on, flag)| on.then_some(flag))
44
.collect();
45
if flags.is_empty() {
46
UNRESTRICTED.to_owned()
47
} else {
48
flags.join(",")
49
}
50
}
51
52
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
53
pub enum Modality {
54
Mic,
55
Camera,
56
}
57
58
#[derive(Debug, Clone, PartialEq, Eq)]
59
pub enum StateStep {
60
Publish(&'static str),
61
Remove(String),
62
}
63
64
impl Modality {
65
fn blocked_type(self) -> &'static str {
66
match self {
67
Modality::Mic => "attendeeAudioRestricted",
68
Modality::Camera => "attendeeVideoRestricted",
69
}
70
}
71
72
fn released_type(self) -> &'static str {
73
match self {
74
Modality::Mic => "attendeeModalitiesUnrestricted",
75
Modality::Camera => "attendeeVideoUnrestricted",
76
}
77
}
78
79
fn attendees_off(self, capability: MeetingCapability) -> bool {
80
match self {
81
Modality::Mic => capability.attendee_mic_off,
82
Modality::Camera => capability.attendee_camera_off,
83
}
84
}
85
86
fn states(self, limits: &AttendeeLimits) -> (Option<&str>, Option<&str>) {
87
let (blocked, released) = match self {
88
Modality::Mic => (&limits.mic_blocked, &limits.mic_released),
89
Modality::Camera => (&limits.camera_blocked, &limits.camera_released),
90
};
91
(
92
blocked.as_ref().map(|state| state.state_id.as_str()),
93
released.as_ref().map(|state| state.state_id.as_str()),
94
)
95
}
96
}
97
98
pub fn modality_allowed(modality: Modality, capability: MeetingCapability, limits: &AttendeeLimits) -> bool {
99
let (blocked, released) = modality.states(limits);
100
if blocked.is_some() {
101
return false;
102
}
103
!modality.attendees_off(capability) || released.is_some()
104
}
105
106
pub fn modality_steps(modality: Modality, allowed: bool, capability: MeetingCapability, limits: &AttendeeLimits) -> Vec<StateStep> {
107
let (blocked, released) = modality.states(limits);
108
let attendees_off = modality.attendees_off(capability);
109
let mut steps = Vec::new();
110
if allowed {
111
if let Some(state_id) = blocked {
112
steps.push(StateStep::Remove(state_id.to_owned()));
113
}
114
if attendees_off && released.is_none() {
115
steps.push(StateStep::Publish(modality.released_type()));
116
}
117
} else {
118
if let Some(state_id) = released {
119
steps.push(StateStep::Remove(state_id.to_owned()));
120
}
121
if !attendees_off && blocked.is_none() {
122
steps.push(StateStep::Publish(modality.blocked_type()));
123
}
124
}
125
steps
126
}
9
127
10
128
#[derive(Debug, Clone, Copy)]
11
129
pub struct Target<'a> {
@@ -83,6 +201,85 @@ pub fn spotlight_body(from: Value, sequence_number: u32, mri: &str, own_mri: &st
83
201
body
84
202
}
85
203
204
pub fn lock_body(from: Value, locked: bool, sequence_number: u32) -> Value {
205
json!({"from": from, "meetingSettings": {"lockMeeting": locked}, "sequenceNumber": sequence_number})
206
}
207
208
pub fn role_body(from: Value, mri: &str, role: MeetingRole) -> Value {
209
json!({
210
"from": from,
211
"scope": SPECIFIED,
212
"to": [{"id": mri, "meetingRole": role.wire()}],
213
})
214
}
215
216
pub fn attendee_state_body(from: Value, state_type: &str, sequence_number: u32, mri: &str) -> Value {
217
json!({
218
"from": from,
219
"publishedState": {
220
"stateType": state_type,
221
"level": "user",
222
"content": {},
223
"sequenceNumber": sequence_number,
224
},
225
"scope": SPECIFIED,
226
"to": [{"id": mri}],
227
})
228
}
229
230
#[derive(Debug, Clone, PartialEq, Eq)]
231
pub struct Invitee {
232
pub callee: Callee,
233
pub participant_id: String,
234
}
235
236
pub fn group_chat_for(thread_id: &str, meeting: bool) -> Value {
237
json!({"threadId": thread_id, "messageId": if meeting { json!(MEETING_MESSAGE_ID) } else { Value::Null }})
238
}
239
240
pub fn add_link_name(has_thread: bool) -> &'static str {
241
if has_thread { "addParticipantAndModality" } else { "addParticipant" }
242
}
243
244
pub fn add_participants_body(
245
from: Value,
246
invitees: &[Invitee],
247
group_chat: Value,
248
meeting: Option<&MeetingTarget>,
249
callbacks: &CallbackLinks,
250
) -> Value {
251
let to: Vec<Value> = invitees
252
.iter()
253
.map(|invitee| {
254
let mut person = json!({
255
"id": invitee.callee.mri,
256
"displayName": invitee.callee.display_name,
257
"participantId": invitee.participant_id,
258
});
259
if meeting.is_some() {
260
person["invitationPreferences"] = json!({"requestedMeetingRoles": [PRESENTER]});
261
}
262
person
263
})
264
.collect();
265
let invitation_data = match meeting {
266
Some(meeting) => json!({"invitationData": {"meetingInfo": {"organizerId": meeting.organizer_id, "tenantId": meeting.tenant_id}}}),
267
None => json!({}),
268
};
269
json!({
270
"disableUnmute": false,
271
"participants": {"from": from, "to": to},
272
"participantInvitationData": invitation_data,
273
"replacementDetails": null,
274
"groupContext": null,
275
"groupChat": group_chat,
276
"links": {
277
"addParticipantSuccess": callbacks.conversation("addParticipantSuccess"),
278
"addParticipantFailure": callbacks.conversation("addParticipantFailure"),
279
},
280
})
281
}
282
86
283
#[cfg(test)]
87
284
mod tests {
88
285
use super::*;
@@ -148,4 +345,119 @@ mod tests {
148
345
assert!(own.get("scope").is_none());
149
346
assert!(own.get("to").is_none());
150
347
}
348
349
fn capability(mic_off: bool, camera_off: bool) -> MeetingCapability {
350
MeetingCapability { locked: false, attendee_mic_off: mic_off, attendee_camera_off: camera_off }
351
}
352
353
fn limits_with(mic_blocked: bool, mic_released: bool) -> AttendeeLimits {
354
let state = |id: &str| crate::roster::PublishedState { state_id: id.to_owned(), rank: 1 };
355
AttendeeLimits {
356
mic_blocked: mic_blocked.then(|| state("blocked-1")),
357
mic_released: mic_released.then(|| state("released-1")),
358
..AttendeeLimits::default()
359
}
360
}
361
362
#[test]
363
fn locking_names_the_setting_and_the_sequence_number() {
364
let body = lock_body(from(), true, 1);
365
assert_eq!(body["meetingSettings"], json!({"lockMeeting": true}));
366
assert_eq!(body["sequenceNumber"], 1);
367
assert_eq!(body["from"]["id"], "8:orgid:me");
368
assert_eq!(lock_body(from(), false, 2)["meetingSettings"]["lockMeeting"], false);
369
}
370
371
#[test]
372
fn a_role_change_targets_one_person_with_the_wire_role() {
373
let body = role_body(from(), "8:orgid:ana", MeetingRole::Presenter);
374
assert_eq!(body["scope"], "specified");
375
assert_eq!(body["to"], json!([{"id": "8:orgid:ana", "meetingRole": "presenter"}]));
376
assert_eq!(role_body(from(), "8:orgid:ana", MeetingRole::Attendee)["to"][0]["meetingRole"], "attendee");
377
}
378
379
#[test]
380
fn restricting_one_attendee_publishes_a_user_state_for_that_person() {
381
let body = attendee_state_body(from(), "attendeeAudioRestricted", 7, "8:orgid:ana");
382
assert_eq!(body["publishedState"]["stateType"], "attendeeAudioRestricted");
383
assert_eq!(body["publishedState"]["level"], "user");
384
assert_eq!(body["publishedState"]["sequenceNumber"], 7);
385
assert_eq!(body["scope"], "specified");
386
assert_eq!(body["to"], json!([{"id": "8:orgid:ana"}]));
387
}
388
389
#[test]
390
fn inviting_into_a_meeting_names_the_organizer_and_asks_for_the_presenter_role() {
391
let meeting = MeetingTarget { thread_id: "19:meeting_x@thread.v2".into(), tenant_id: "tenant-1".into(), organizer_id: "organizer-1".into(), meeting_data: None };
392
let invitees = [Invitee { callee: Callee { mri: "8:orgid:ana".into(), display_name: "Ana".into() }, participant_id: "p-1".into() }];
393
let body = add_participants_body(from(), &invitees, group_chat_for(&meeting.thread_id, true), Some(&meeting), &callbacks());
394
assert_eq!(body["participants"]["to"][0]["id"], "8:orgid:ana");
395
assert_eq!(body["participants"]["to"][0]["participantId"], "p-1");
396
assert_eq!(body["participants"]["to"][0]["invitationPreferences"]["requestedMeetingRoles"], json!(["presenter"]));
397
assert_eq!(body["participantInvitationData"]["invitationData"]["meetingInfo"], json!({"organizerId": "organizer-1", "tenantId": "tenant-1"}));
398
assert_eq!(body["groupChat"], json!({"threadId": "19:meeting_x@thread.v2", "messageId": "0"}));
399
assert!(body["links"]["addParticipantSuccess"].as_str().unwrap().contains("/conversation/addParticipantSuccess/"));
400
assert!(body["links"]["addParticipantFailure"].as_str().unwrap().contains("/conversation/addParticipantFailure/"));
401
}
402
403
#[test]
404
fn inviting_into_a_group_call_has_no_meeting_data_and_a_null_message() {
405
let invitees = [Invitee { callee: Callee { mri: "8:orgid:bo".into(), display_name: "Bo".into() }, participant_id: "p-2".into() }];
406
let body = add_participants_body(from(), &invitees, group_chat_for("19:group@thread.v2", false), None, &callbacks());
407
assert_eq!(body["participantInvitationData"], json!({}));
408
assert!(body["participants"]["to"][0].get("invitationPreferences").is_none());
409
assert_eq!(body["groupChat"], json!({"threadId": "19:group@thread.v2", "messageId": null}));
410
assert_eq!(add_link_name(true), "addParticipantAndModality");
411
assert_eq!(add_link_name(false), "addParticipant");
412
}
413
414
#[test]
415
fn the_restriction_option_combines_both_flags() {
416
assert_eq!(restrictions_value(false, false), "UnRestricted");
417
assert_eq!(restrictions_value(true, false), "DisableAudio");
418
assert_eq!(restrictions_value(false, true), "DisableVideo");
419
assert_eq!(restrictions_value(true, true), "DisableAudio,DisableVideo");
420
}
421
422
#[test]
423
fn the_capability_follows_a_conversation_update() {
424
let mut state = MeetingCapability::default();
425
let update = json!({"meetingDetails": {"meetingCapability": {"lockMeeting": true, "attendeeRestrictions": "DisableAudio,DisableVideo"}}});
426
assert!(state.apply(&update));
427
assert_eq!(state, MeetingCapability { locked: true, attendee_mic_off: true, attendee_camera_off: true });
428
assert!(!state.apply(&update));
429
assert!(!state.apply(&json!({"other": 1})));
430
assert!(state.apply(&json!({"meetingCapability": {"lockMeeting": false, "attendeeRestrictions": "UnRestricted"}})));
431
assert_eq!(state, MeetingCapability::default());
432
}
433
434
#[test]
435
fn a_mic_is_allowed_unless_blocked_or_the_meeting_blocks_everyone() {
436
let none = AttendeeLimits::default();
437
assert!(modality_allowed(Modality::Mic, capability(false, false), &none));
438
assert!(!modality_allowed(Modality::Mic, capability(true, false), &none));
439
assert!(modality_allowed(Modality::Mic, capability(true, false), &limits_with(false, true)));
440
assert!(!modality_allowed(Modality::Mic, capability(false, false), &limits_with(true, false)));
441
assert!(modality_allowed(Modality::Camera, capability(true, false), &none));
442
}
443
444
#[test]
445
fn disabling_one_mic_publishes_a_restriction_or_drops_the_release() {
446
let open = capability(false, false);
447
assert_eq!(modality_steps(Modality::Mic, false, open, &AttendeeLimits::default()), vec![StateStep::Publish("attendeeAudioRestricted")]);
448
let closed = capability(true, false);
449
assert_eq!(modality_steps(Modality::Mic, false, closed, &limits_with(false, true)), vec![StateStep::Remove("released-1".into())]);
450
assert!(modality_steps(Modality::Mic, false, closed, &AttendeeLimits::default()).is_empty());
451
assert!(modality_steps(Modality::Mic, false, open, &limits_with(true, false)).is_empty());
452
}
453
454
#[test]
455
fn allowing_one_mic_removes_the_restriction_or_publishes_a_release() {
456
let open = capability(false, false);
457
assert_eq!(modality_steps(Modality::Mic, true, open, &limits_with(true, false)), vec![StateStep::Remove("blocked-1".into())]);
458
let closed = capability(true, false);
459
assert_eq!(modality_steps(Modality::Mic, true, closed, &AttendeeLimits::default()), vec![StateStep::Publish("attendeeModalitiesUnrestricted")]);
460
assert_eq!(modality_steps(Modality::Camera, true, capability(false, true), &AttendeeLimits::default()), vec![StateStep::Publish("attendeeVideoUnrestricted")]);
461
assert!(modality_steps(Modality::Mic, true, open, &AttendeeLimits::default()).is_empty());
462
}
151
463
}
@@ -1,11 +1,129 @@1
use serde_json::{Value, json};1
use serde_json::{Value, json};2
2
3
use crate::trouter_events::CallbackLinks;3
use crate::roster::{AttendeeLimits, MeetingRole};4
use crate::signaling::{Callee, MEETING_MESSAGE_ID, MeetingTarget};5
use crate::trouter_events::{CallbackLinks, find_key};4
6
5
const SPOTLIGHT: &str = "spotlight";7
const SPOTLIGHT: &str = "spotlight";6
const AUDIO: &str = "audio";8
const AUDIO: &str = "audio";7
const SPECIFIED: &str = "specified";9
const SPECIFIED: &str = "specified";8
const EVERYONE: &str = "all";10
const EVERYONE: &str = "all";11
const PRESENTER: &str = "presenter";12
const DISABLE_AUDIO: &str = "DisableAudio";13
const DISABLE_VIDEO: &str = "DisableVideo";14
const UNRESTRICTED: &str = "UnRestricted";15
16
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]17
pub struct MeetingCapability {18
pub locked: bool,19
pub attendee_mic_off: bool,20
pub attendee_camera_off: bool,21
}22
23
impl MeetingCapability {24
pub fn apply(&mut self, body: &Value) -> bool {25
let Some(capability) = find_key(body, "meetingCapability") else {26
return false;27
};28
let before = *self;29
if let Some(locked) = capability["lockMeeting"].as_bool() {30
self.locked = locked;31
}32
if let Some(restrictions) = capability["attendeeRestrictions"].as_str() {33
self.attendee_mic_off = restrictions.contains(DISABLE_AUDIO);34
self.attendee_camera_off = restrictions.contains(DISABLE_VIDEO);35
}36
*self != before37
}38
}39
40
pub fn restrictions_value(mic_off: bool, camera_off: bool) -> String {41
let flags: Vec<&str> = [(mic_off, DISABLE_AUDIO), (camera_off, DISABLE_VIDEO)]42
.into_iter()43
.filter_map(|(on, flag)| on.then_some(flag))44
.collect();45
if flags.is_empty() {46
UNRESTRICTED.to_owned()47
} else {48
flags.join(",")49
}50
}51
52
#[derive(Debug, Clone, Copy, PartialEq, Eq)]53
pub enum Modality {54
Mic,55
Camera,56
}57
58
#[derive(Debug, Clone, PartialEq, Eq)]59
pub enum StateStep {60
Publish(&'static str),61
Remove(String),62
}63
64
impl Modality {65
fn blocked_type(self) -> &'static str {66
match self {67
Modality::Mic => "attendeeAudioRestricted",68
Modality::Camera => "attendeeVideoRestricted",69
}70
}71
72
fn released_type(self) -> &'static str {73
match self {74
Modality::Mic => "attendeeModalitiesUnrestricted",75
Modality::Camera => "attendeeVideoUnrestricted",76
}77
}78
79
fn attendees_off(self, capability: MeetingCapability) -> bool {80
match self {81
Modality::Mic => capability.attendee_mic_off,82
Modality::Camera => capability.attendee_camera_off,83
}84
}85
86
fn states(self, limits: &AttendeeLimits) -> (Option<&str>, Option<&str>) {87
let (blocked, released) = match self {88
Modality::Mic => (&limits.mic_blocked, &limits.mic_released),89
Modality::Camera => (&limits.camera_blocked, &limits.camera_released),90
};91
(92
blocked.as_ref().map(|state| state.state_id.as_str()),93
released.as_ref().map(|state| state.state_id.as_str()),94
)95
}96
}97
98
pub fn modality_allowed(modality: Modality, capability: MeetingCapability, limits: &AttendeeLimits) -> bool {99
let (blocked, released) = modality.states(limits);100
if blocked.is_some() {101
return false;102
}103
!modality.attendees_off(capability) || released.is_some()104
}105
106
pub fn modality_steps(modality: Modality, allowed: bool, capability: MeetingCapability, limits: &AttendeeLimits) -> Vec<StateStep> {107
let (blocked, released) = modality.states(limits);108
let attendees_off = modality.attendees_off(capability);109
let mut steps = Vec::new();110
if allowed {111
if let Some(state_id) = blocked {112
steps.push(StateStep::Remove(state_id.to_owned()));113
}114
if attendees_off && released.is_none() {115
steps.push(StateStep::Publish(modality.released_type()));116
}117
} else {118
if let Some(state_id) = released {119
steps.push(StateStep::Remove(state_id.to_owned()));120
}121
if !attendees_off && blocked.is_none() {122
steps.push(StateStep::Publish(modality.blocked_type()));123
}124
}125
steps126
}9
127
10
#[derive(Debug, Clone, Copy)]128
#[derive(Debug, Clone, Copy)]11
pub struct Target<'a> {129
pub struct Target<'a> {@@ -83,6 +201,85 @@ pub fn spotlight_body(from: Value, sequence_number: u32, mri: &str, own_mri: &st83
body201
body84
}202
}85
203
204
pub fn lock_body(from: Value, locked: bool, sequence_number: u32) -> Value {205
json!({"from": from, "meetingSettings": {"lockMeeting": locked}, "sequenceNumber": sequence_number})206
}207
208
pub fn role_body(from: Value, mri: &str, role: MeetingRole) -> Value {209
json!({210
"from": from,211
"scope": SPECIFIED,212
"to": [{"id": mri, "meetingRole": role.wire()}],213
})214
}215
216
pub fn attendee_state_body(from: Value, state_type: &str, sequence_number: u32, mri: &str) -> Value {217
json!({218
"from": from,219
"publishedState": {220
"stateType": state_type,221
"level": "user",222
"content": {},223
"sequenceNumber": sequence_number,224
},225
"scope": SPECIFIED,226
"to": [{"id": mri}],227
})228
}229
230
#[derive(Debug, Clone, PartialEq, Eq)]231
pub struct Invitee {232
pub callee: Callee,233
pub participant_id: String,234
}235
236
pub fn group_chat_for(thread_id: &str, meeting: bool) -> Value {237
json!({"threadId": thread_id, "messageId": if meeting { json!(MEETING_MESSAGE_ID) } else { Value::Null }})238
}239
240
pub fn add_link_name(has_thread: bool) -> &'static str {241
if has_thread { "addParticipantAndModality" } else { "addParticipant" }242
}243
244
pub fn add_participants_body(245
from: Value,246
invitees: &[Invitee],247
group_chat: Value,248
meeting: Option<&MeetingTarget>,249
callbacks: &CallbackLinks,250
) -> Value {251
let to: Vec<Value> = invitees252
.iter()253
.map(|invitee| {254
let mut person = json!({255
"id": invitee.callee.mri,256
"displayName": invitee.callee.display_name,257
"participantId": invitee.participant_id,258
});259
if meeting.is_some() {260
person["invitationPreferences"] = json!({"requestedMeetingRoles": [PRESENTER]});261
}262
person263
})264
.collect();265
let invitation_data = match meeting {266
Some(meeting) => json!({"invitationData": {"meetingInfo": {"organizerId": meeting.organizer_id, "tenantId": meeting.tenant_id}}}),267
None => json!({}),268
};269
json!({270
"disableUnmute": false,271
"participants": {"from": from, "to": to},272
"participantInvitationData": invitation_data,273
"replacementDetails": null,274
"groupContext": null,275
"groupChat": group_chat,276
"links": {277
"addParticipantSuccess": callbacks.conversation("addParticipantSuccess"),278
"addParticipantFailure": callbacks.conversation("addParticipantFailure"),279
},280
})281
}282
86
#[cfg(test)]283
#[cfg(test)]87
mod tests {284
mod tests {88
use super::*;285
use super::*;@@ -148,4 +345,119 @@ mod tests {148
assert!(own.get("scope").is_none());345
assert!(own.get("scope").is_none());149
assert!(own.get("to").is_none());346
assert!(own.get("to").is_none());150
}347
}348
349
fn capability(mic_off: bool, camera_off: bool) -> MeetingCapability {350
MeetingCapability { locked: false, attendee_mic_off: mic_off, attendee_camera_off: camera_off }351
}352
353
fn limits_with(mic_blocked: bool, mic_released: bool) -> AttendeeLimits {354
let state = |id: &str| crate::roster::PublishedState { state_id: id.to_owned(), rank: 1 };355
AttendeeLimits {356
mic_blocked: mic_blocked.then(|| state("blocked-1")),357
mic_released: mic_released.then(|| state("released-1")),358
..AttendeeLimits::default()359
}360
}361
362
#[test]363
fn locking_names_the_setting_and_the_sequence_number() {364
let body = lock_body(from(), true, 1);365
assert_eq!(body["meetingSettings"], json!({"lockMeeting": true}));366
assert_eq!(body["sequenceNumber"], 1);367
assert_eq!(body["from"]["id"], "8:orgid:me");368
assert_eq!(lock_body(from(), false, 2)["meetingSettings"]["lockMeeting"], false);369
}370
371
#[test]372
fn a_role_change_targets_one_person_with_the_wire_role() {373
let body = role_body(from(), "8:orgid:ana", MeetingRole::Presenter);374
assert_eq!(body["scope"], "specified");375
assert_eq!(body["to"], json!([{"id": "8:orgid:ana", "meetingRole": "presenter"}]));376
assert_eq!(role_body(from(), "8:orgid:ana", MeetingRole::Attendee)["to"][0]["meetingRole"], "attendee");377
}378
379
#[test]380
fn restricting_one_attendee_publishes_a_user_state_for_that_person() {381
let body = attendee_state_body(from(), "attendeeAudioRestricted", 7, "8:orgid:ana");382
assert_eq!(body["publishedState"]["stateType"], "attendeeAudioRestricted");383
assert_eq!(body["publishedState"]["level"], "user");384
assert_eq!(body["publishedState"]["sequenceNumber"], 7);385
assert_eq!(body["scope"], "specified");386
assert_eq!(body["to"], json!([{"id": "8:orgid:ana"}]));387
}388
389
#[test]390
fn inviting_into_a_meeting_names_the_organizer_and_asks_for_the_presenter_role() {391
let meeting = MeetingTarget { thread_id: "19:meeting_x@thread.v2".into(), tenant_id: "tenant-1".into(), organizer_id: "organizer-1".into(), meeting_data: None };392
let invitees = [Invitee { callee: Callee { mri: "8:orgid:ana".into(), display_name: "Ana".into() }, participant_id: "p-1".into() }];393
let body = add_participants_body(from(), &invitees, group_chat_for(&meeting.thread_id, true), Some(&meeting), &callbacks());394
assert_eq!(body["participants"]["to"][0]["id"], "8:orgid:ana");395
assert_eq!(body["participants"]["to"][0]["participantId"], "p-1");396
assert_eq!(body["participants"]["to"][0]["invitationPreferences"]["requestedMeetingRoles"], json!(["presenter"]));397
assert_eq!(body["participantInvitationData"]["invitationData"]["meetingInfo"], json!({"organizerId": "organizer-1", "tenantId": "tenant-1"}));398
assert_eq!(body["groupChat"], json!({"threadId": "19:meeting_x@thread.v2", "messageId": "0"}));399
assert!(body["links"]["addParticipantSuccess"].as_str().unwrap().contains("/conversation/addParticipantSuccess/"));400
assert!(body["links"]["addParticipantFailure"].as_str().unwrap().contains("/conversation/addParticipantFailure/"));401
}402
403
#[test]404
fn inviting_into_a_group_call_has_no_meeting_data_and_a_null_message() {405
let invitees = [Invitee { callee: Callee { mri: "8:orgid:bo".into(), display_name: "Bo".into() }, participant_id: "p-2".into() }];406
let body = add_participants_body(from(), &invitees, group_chat_for("19:group@thread.v2", false), None, &callbacks());407
assert_eq!(body["participantInvitationData"], json!({}));408
assert!(body["participants"]["to"][0].get("invitationPreferences").is_none());409
assert_eq!(body["groupChat"], json!({"threadId": "19:group@thread.v2", "messageId": null}));410
assert_eq!(add_link_name(true), "addParticipantAndModality");411
assert_eq!(add_link_name(false), "addParticipant");412
}413
414
#[test]415
fn the_restriction_option_combines_both_flags() {416
assert_eq!(restrictions_value(false, false), "UnRestricted");417
assert_eq!(restrictions_value(true, false), "DisableAudio");418
assert_eq!(restrictions_value(false, true), "DisableVideo");419
assert_eq!(restrictions_value(true, true), "DisableAudio,DisableVideo");420
}421
422
#[test]423
fn the_capability_follows_a_conversation_update() {424
let mut state = MeetingCapability::default();425
let update = json!({"meetingDetails": {"meetingCapability": {"lockMeeting": true, "attendeeRestrictions": "DisableAudio,DisableVideo"}}});426
assert!(state.apply(&update));427
assert_eq!(state, MeetingCapability { locked: true, attendee_mic_off: true, attendee_camera_off: true });428
assert!(!state.apply(&update));429
assert!(!state.apply(&json!({"other": 1})));430
assert!(state.apply(&json!({"meetingCapability": {"lockMeeting": false, "attendeeRestrictions": "UnRestricted"}})));431
assert_eq!(state, MeetingCapability::default());432
}433
434
#[test]435
fn a_mic_is_allowed_unless_blocked_or_the_meeting_blocks_everyone() {436
let none = AttendeeLimits::default();437
assert!(modality_allowed(Modality::Mic, capability(false, false), &none));438
assert!(!modality_allowed(Modality::Mic, capability(true, false), &none));439
assert!(modality_allowed(Modality::Mic, capability(true, false), &limits_with(false, true)));440
assert!(!modality_allowed(Modality::Mic, capability(false, false), &limits_with(true, false)));441
assert!(modality_allowed(Modality::Camera, capability(true, false), &none));442
}443
444
#[test]445
fn disabling_one_mic_publishes_a_restriction_or_drops_the_release() {446
let open = capability(false, false);447
assert_eq!(modality_steps(Modality::Mic, false, open, &AttendeeLimits::default()), vec![StateStep::Publish("attendeeAudioRestricted")]);448
let closed = capability(true, false);449
assert_eq!(modality_steps(Modality::Mic, false, closed, &limits_with(false, true)), vec![StateStep::Remove("released-1".into())]);450
assert!(modality_steps(Modality::Mic, false, closed, &AttendeeLimits::default()).is_empty());451
assert!(modality_steps(Modality::Mic, false, open, &limits_with(true, false)).is_empty());452
}453
454
#[test]455
fn allowing_one_mic_removes_the_restriction_or_publishes_a_release() {456
let open = capability(false, false);457
assert_eq!(modality_steps(Modality::Mic, true, open, &limits_with(true, false)), vec![StateStep::Remove("blocked-1".into())]);458
let closed = capability(true, false);459
assert_eq!(modality_steps(Modality::Mic, true, closed, &AttendeeLimits::default()), vec![StateStep::Publish("attendeeModalitiesUnrestricted")]);460
assert_eq!(modality_steps(Modality::Camera, true, capability(false, true), &AttendeeLimits::default()), vec![StateStep::Publish("attendeeVideoUnrestricted")]);461
assert!(modality_steps(Modality::Mic, true, open, &AttendeeLimits::default()).is_empty());462
}151
}463
}@@ -7,7 +7,11 @@ const SCREEN: &str = "applicationsharing-video";
7
7
const SENDING_DIRECTIONS: [&str; 2] = ["sendonly", "sendrecv"];
8
8
const RAISE_HANDS: &str = "raiseHands";
9
9
const SPOTLIGHT: &str = "spotlight";
10
const ORGANIZER_ROLES: [&str; 2] = ["organizer", "coorganizer"];
10
const ROLE_KEYS: [&str; 2] = ["meetingRole", "role"];
11
const MIC_BLOCKED: &str = "attendeeAudioRestricted";
12
const MIC_RELEASED: &str = "attendeeModalitiesUnrestricted";
13
const CAMERA_BLOCKED: &str = "attendeeVideoRestricted";
14
const CAMERA_RELEASED: &str = "attendeeVideoUnrestricted";
11
15
const BOT_PREFIX: &str = "28:";
12
16
13
17
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -16,6 +20,40 @@ pub struct PublishedState {
16
20
pub rank: u64,
17
21
}
18
22
23
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24
pub enum MeetingRole {
25
Organizer,
26
Presenter,
27
Attendee,
28
}
29
30
impl MeetingRole {
31
pub fn parse(text: &str) -> Option<MeetingRole> {
32
match text.to_ascii_lowercase().as_str() {
33
"organizer" | "coorganizer" => Some(MeetingRole::Organizer),
34
"presenter" => Some(MeetingRole::Presenter),
35
"attendee" => Some(MeetingRole::Attendee),
36
_ => None,
37
}
38
}
39
40
pub fn wire(self) -> &'static str {
41
match self {
42
MeetingRole::Organizer => "organizer",
43
MeetingRole::Presenter => "presenter",
44
MeetingRole::Attendee => "attendee",
45
}
46
}
47
}
48
49
#[derive(Debug, Clone, Default, PartialEq, Eq)]
50
pub struct AttendeeLimits {
51
pub mic_blocked: Option<PublishedState>,
52
pub mic_released: Option<PublishedState>,
53
pub camera_blocked: Option<PublishedState>,
54
pub camera_released: Option<PublishedState>,
55
}
56
19
57
pub type RaisedHand = PublishedState;
20
58
pub type Spotlight = PublishedState;
21
59
@@ -41,11 +79,13 @@ pub struct Member {
41
79
pub hand: Option<RaisedHand>,
42
80
pub spotlight: Option<Spotlight>,
43
81
pub organizer: bool,
82
pub role: Option<MeetingRole>,
83
pub limits: AttendeeLimits,
44
84
pub captions: Option<CaptionBot>,
45
85
version: u64,
46
86
}
47
87
48
#[derive(Debug, Clone, PartialEq, Eq)]
88
#[derive(Debug, Clone, Default, PartialEq, Eq)]
49
89
pub struct RosterEntry {
50
90
pub mri: String,
51
91
pub display_name: String,
@@ -56,6 +96,8 @@ pub struct RosterEntry {
56
96
pub hand: Option<RaisedHand>,
57
97
pub spotlight: Option<Spotlight>,
58
98
pub organizer: bool,
99
pub role: Option<MeetingRole>,
100
pub limits: AttendeeLimits,
59
101
}
60
102
61
103
#[derive(Debug, Clone, Default, PartialEq, Eq)]
@@ -82,6 +124,8 @@ impl Roster {
82
124
hand: member.hand.clone(),
83
125
spotlight: member.spotlight.clone(),
84
126
organizer: member.organizer,
127
role: member.role,
128
limits: member.limits.clone(),
85
129
})
86
130
.collect()
87
131
}
@@ -195,6 +239,7 @@ fn member_from(mri: &str, participant: &Value, version: u64, previous: Option<&M
195
239
.flat_map(|endpoint| audio_streams(endpoint))
196
240
.filter_map(|stream| source_id(&stream["sourceId"]))
197
241
.collect();
242
let role = ROLE_KEYS.iter().filter_map(|key| participant[*key].as_str()).find_map(MeetingRole::parse);
198
243
Member {
199
244
mri: mri.to_owned(),
200
245
display_name,
@@ -206,19 +251,19 @@ fn member_from(mri: &str, participant: &Value, version: u64, previous: Option<&M
206
251
streams: stream_summaries(&in_call),
207
252
hand: published_state(participant, &endpoints, RAISE_HANDS),
208
253
spotlight: published_state(participant, &endpoints, SPOTLIGHT),
209
organizer: is_organizer_role(participant),
254
organizer: role == Some(MeetingRole::Organizer),
255
role,
256
limits: AttendeeLimits {
257
mic_blocked: published_state(participant, &endpoints, MIC_BLOCKED),
258
mic_released: published_state(participant, &endpoints, MIC_RELEASED),
259
camera_blocked: published_state(participant, &endpoints, CAMERA_BLOCKED),
260
camera_released: published_state(participant, &endpoints, CAMERA_RELEASED),
261
},
210
262
captions: mri.starts_with(BOT_PREFIX).then(|| caption_bot(mri, &endpoints)).flatten(),
211
263
version,
212
264
}
213
265
}
214
266
215
fn is_organizer_role(participant: &Value) -> bool {
216
["meetingRole", "role"]
217
.iter()
218
.filter_map(|key| participant[*key].as_str())
219
.any(|role| ORGANIZER_ROLES.contains(&role.to_ascii_lowercase().as_str()))
220
}
221
222
267
fn caption_bot(mri: &str, endpoints: &[&Value]) -> Option<CaptionBot> {
223
268
let metadata: Vec<&Value> = endpoints.iter().map(|endpoint| &endpoint["endpointMetadata"]).filter(|metadata| metadata.is_object()).collect();
224
269
let command_url = metadata.iter().find_map(|metadata| metadata["commandUrl"].as_str()).map(str::to_owned);
@@ -519,6 +564,27 @@ mod tests {
519
564
assert!(roster.is_organizer("8:orgid:b"));
520
565
}
521
566
567
#[test]
568
fn roles_and_attendee_limits_reach_the_entries() {
569
let mut roster = Roster::default();
570
let mut presenter = participant("Ana", 1, "active", false, 201);
571
presenter["meetingRole"] = json!("presenter");
572
let mut limited = participant("Bo", 1, "active", false, 301);
573
limited["meetingRole"] = json!("attendee");
574
limited["publishedStates"] = json!([
575
{"stateType": "attendeeAudioRestricted", "stateId": "s-1", "typeRank": 1},
576
{"stateType": "attendeeVideoUnrestricted", "stateId": "s-2", "typeRank": 2},
577
]);
578
roster.apply(&delta(json!({"8:orgid:a": presenter, "8:orgid:b": limited})));
579
let entries = roster.entries();
580
assert_eq!(entries[0].role, Some(MeetingRole::Presenter));
581
assert_eq!(entries[1].role, Some(MeetingRole::Attendee));
582
assert_eq!(entries[1].limits.mic_blocked.as_ref().map(|state| state.state_id.as_str()), Some("s-1"));
583
assert_eq!(entries[1].limits.camera_released.as_ref().map(|state| state.state_id.as_str()), Some("s-2"));
584
assert_eq!(entries[1].limits.camera_blocked, None);
585
assert_eq!(entries[0].limits, AttendeeLimits::default());
586
}
587
522
588
fn recorder_bot(version: u64, active: bool) -> Value {
523
589
json!({"version": version, "state": "active", "details": {"displayName": "Recorder"}, "meetingRole": "presenter", "endpoints": {"ep": {
524
590
"call": {"mediaStreams": []},
@@ -7,7 +7,11 @@ const SCREEN: &str = "applicationsharing-video";7
const SENDING_DIRECTIONS: [&str; 2] = ["sendonly", "sendrecv"];7
const SENDING_DIRECTIONS: [&str; 2] = ["sendonly", "sendrecv"];8
const RAISE_HANDS: &str = "raiseHands";8
const RAISE_HANDS: &str = "raiseHands";9
const SPOTLIGHT: &str = "spotlight";9
const SPOTLIGHT: &str = "spotlight";10
const ORGANIZER_ROLES: [&str; 2] = ["organizer", "coorganizer"];10
const ROLE_KEYS: [&str; 2] = ["meetingRole", "role"];11
const MIC_BLOCKED: &str = "attendeeAudioRestricted";12
const MIC_RELEASED: &str = "attendeeModalitiesUnrestricted";13
const CAMERA_BLOCKED: &str = "attendeeVideoRestricted";14
const CAMERA_RELEASED: &str = "attendeeVideoUnrestricted";11
const BOT_PREFIX: &str = "28:";15
const BOT_PREFIX: &str = "28:";12
16
13
#[derive(Debug, Clone, PartialEq, Eq)]17
#[derive(Debug, Clone, PartialEq, Eq)]@@ -16,6 +20,40 @@ pub struct PublishedState {16
pub rank: u64,20
pub rank: u64,17
}21
}18
22
23
#[derive(Debug, Clone, Copy, PartialEq, Eq)]24
pub enum MeetingRole {25
Organizer,26
Presenter,27
Attendee,28
}29
30
impl MeetingRole {31
pub fn parse(text: &str) -> Option<MeetingRole> {32
match text.to_ascii_lowercase().as_str() {33
"organizer" | "coorganizer" => Some(MeetingRole::Organizer),34
"presenter" => Some(MeetingRole::Presenter),35
"attendee" => Some(MeetingRole::Attendee),36
_ => None,37
}38
}39
40
pub fn wire(self) -> &'static str {41
match self {42
MeetingRole::Organizer => "organizer",43
MeetingRole::Presenter => "presenter",44
MeetingRole::Attendee => "attendee",45
}46
}47
}48
49
#[derive(Debug, Clone, Default, PartialEq, Eq)]50
pub struct AttendeeLimits {51
pub mic_blocked: Option<PublishedState>,52
pub mic_released: Option<PublishedState>,53
pub camera_blocked: Option<PublishedState>,54
pub camera_released: Option<PublishedState>,55
}56
19
pub type RaisedHand = PublishedState;57
pub type RaisedHand = PublishedState;20
pub type Spotlight = PublishedState;58
pub type Spotlight = PublishedState;21
59
@@ -41,11 +79,13 @@ pub struct Member {41
pub hand: Option<RaisedHand>,79
pub hand: Option<RaisedHand>,42
pub spotlight: Option<Spotlight>,80
pub spotlight: Option<Spotlight>,43
pub organizer: bool,81
pub organizer: bool,82
pub role: Option<MeetingRole>,83
pub limits: AttendeeLimits,44
pub captions: Option<CaptionBot>,84
pub captions: Option<CaptionBot>,45
version: u64,85
version: u64,46
}86
}47
87
48
#[derive(Debug, Clone, PartialEq, Eq)]88
#[derive(Debug, Clone, Default, PartialEq, Eq)]49
pub struct RosterEntry {89
pub struct RosterEntry {50
pub mri: String,90
pub mri: String,51
pub display_name: String,91
pub display_name: String,@@ -56,6 +96,8 @@ pub struct RosterEntry {56
pub hand: Option<RaisedHand>,96
pub hand: Option<RaisedHand>,57
pub spotlight: Option<Spotlight>,97
pub spotlight: Option<Spotlight>,58
pub organizer: bool,98
pub organizer: bool,99
pub role: Option<MeetingRole>,100
pub limits: AttendeeLimits,59
}101
}60
102
61
#[derive(Debug, Clone, Default, PartialEq, Eq)]103
#[derive(Debug, Clone, Default, PartialEq, Eq)]@@ -82,6 +124,8 @@ impl Roster {82
hand: member.hand.clone(),124
hand: member.hand.clone(),83
spotlight: member.spotlight.clone(),125
spotlight: member.spotlight.clone(),84
organizer: member.organizer,126
organizer: member.organizer,127
role: member.role,128
limits: member.limits.clone(),85
})129
})86
.collect()130
.collect()87
}131
}@@ -195,6 +239,7 @@ fn member_from(mri: &str, participant: &Value, version: u64, previous: Option<&M195
.flat_map(|endpoint| audio_streams(endpoint))239
.flat_map(|endpoint| audio_streams(endpoint))196
.filter_map(|stream| source_id(&stream["sourceId"]))240
.filter_map(|stream| source_id(&stream["sourceId"]))197
.collect();241
.collect();242
let role = ROLE_KEYS.iter().filter_map(|key| participant[*key].as_str()).find_map(MeetingRole::parse);198
Member {243
Member {199
mri: mri.to_owned(),244
mri: mri.to_owned(),200
display_name,245
display_name,@@ -206,19 +251,19 @@ fn member_from(mri: &str, participant: &Value, version: u64, previous: Option<&M206
streams: stream_summaries(&in_call),251
streams: stream_summaries(&in_call),207
hand: published_state(participant, &endpoints, RAISE_HANDS),252
hand: published_state(participant, &endpoints, RAISE_HANDS),208
spotlight: published_state(participant, &endpoints, SPOTLIGHT),253
spotlight: published_state(participant, &endpoints, SPOTLIGHT),209
organizer: is_organizer_role(participant),254
organizer: role == Some(MeetingRole::Organizer),255
role,256
limits: AttendeeLimits {257
mic_blocked: published_state(participant, &endpoints, MIC_BLOCKED),258
mic_released: published_state(participant, &endpoints, MIC_RELEASED),259
camera_blocked: published_state(participant, &endpoints, CAMERA_BLOCKED),260
camera_released: published_state(participant, &endpoints, CAMERA_RELEASED),261
},210
captions: mri.starts_with(BOT_PREFIX).then(|| caption_bot(mri, &endpoints)).flatten(),262
captions: mri.starts_with(BOT_PREFIX).then(|| caption_bot(mri, &endpoints)).flatten(),211
version,263
version,212
}264
}213
}265
}214
266
215
fn is_organizer_role(participant: &Value) -> bool {216
["meetingRole", "role"]217
.iter()218
.filter_map(|key| participant[*key].as_str())219
.any(|role| ORGANIZER_ROLES.contains(&role.to_ascii_lowercase().as_str()))220
}221
222
fn caption_bot(mri: &str, endpoints: &[&Value]) -> Option<CaptionBot> {267
fn caption_bot(mri: &str, endpoints: &[&Value]) -> Option<CaptionBot> {223
let metadata: Vec<&Value> = endpoints.iter().map(|endpoint| &endpoint["endpointMetadata"]).filter(|metadata| metadata.is_object()).collect();268
let metadata: Vec<&Value> = endpoints.iter().map(|endpoint| &endpoint["endpointMetadata"]).filter(|metadata| metadata.is_object()).collect();224
let command_url = metadata.iter().find_map(|metadata| metadata["commandUrl"].as_str()).map(str::to_owned);269
let command_url = metadata.iter().find_map(|metadata| metadata["commandUrl"].as_str()).map(str::to_owned);@@ -519,6 +564,27 @@ mod tests {519
assert!(roster.is_organizer("8:orgid:b"));564
assert!(roster.is_organizer("8:orgid:b"));520
}565
}521
566
567
#[test]568
fn roles_and_attendee_limits_reach_the_entries() {569
let mut roster = Roster::default();570
let mut presenter = participant("Ana", 1, "active", false, 201);571
presenter["meetingRole"] = json!("presenter");572
let mut limited = participant("Bo", 1, "active", false, 301);573
limited["meetingRole"] = json!("attendee");574
limited["publishedStates"] = json!([575
{"stateType": "attendeeAudioRestricted", "stateId": "s-1", "typeRank": 1},576
{"stateType": "attendeeVideoUnrestricted", "stateId": "s-2", "typeRank": 2},577
]);578
roster.apply(&delta(json!({"8:orgid:a": presenter, "8:orgid:b": limited})));579
let entries = roster.entries();580
assert_eq!(entries[0].role, Some(MeetingRole::Presenter));581
assert_eq!(entries[1].role, Some(MeetingRole::Attendee));582
assert_eq!(entries[1].limits.mic_blocked.as_ref().map(|state| state.state_id.as_str()), Some("s-1"));583
assert_eq!(entries[1].limits.camera_released.as_ref().map(|state| state.state_id.as_str()), Some("s-2"));584
assert_eq!(entries[1].limits.camera_blocked, None);585
assert_eq!(entries[0].limits, AttendeeLimits::default());586
}587
522
fn recorder_bot(version: u64, active: bool) -> Value {588
fn recorder_bot(version: u64, active: bool) -> Value {523
json!({"version": version, "state": "active", "details": {"displayName": "Recorder"}, "meetingRole": "presenter", "endpoints": {"ep": {589
json!({"version": version, "state": "active", "details": {"displayName": "Recorder"}, "meetingRole": "presenter", "endpoints": {"ep": {524
"call": {"mediaStreams": []},590
"call": {"mediaStreams": []},@@ -7,7 +7,8 @@ use crate::captions::{self, BotAction};
7
7
use crate::recording::{self, Consent, RecordingCommand, StartDetails};
8
8
use crate::transfer::{self, TransferTarget};
9
9
use crate::error::{Error, Result};
10
use crate::organizer::{self, Target};
10
use crate::organizer::{self, Invitee, Target};
11
use crate::roster::MeetingRole;
11
12
use crate::reaction::{DEFAULT_SKIN_TONE, Reaction, reaction_message};
12
13
use crate::relay::ic3_scope;
13
14
use crate::timeline::Timeline;
@@ -49,7 +50,7 @@ const SUBSCRIBE_LINK_NAMES: [&str; 6] = [
49
50
];
50
51
const CALL_LINK_NAMES: [&str; 5] = ["progress", "mediaAnswer", "acceptance", "redirection", "end"];
51
52
const AUDIO_MODALITIES: [&str; 1] = ["Audio"];
52
const MEETING_MESSAGE_ID: &str = "0";
53
pub(crate) const MEETING_MESSAGE_ID: &str = "0";
53
54
const RAISE_HANDS: &str = "raiseHands";
54
55
const CANCEL_CODE: i64 = 487;
55
56
const DECLINE_CODE: i64 = 603;
@@ -449,6 +450,40 @@ impl Signaling {
449
450
self.send("POST publishState (spotlight)", Method::Post, conversation.link("publishState")?, Some(body)).await.map(|response| response.status)
450
451
}
451
452
453
pub async fn set_lock(&self, conversation: &Conversation, from: &Participant, locked: bool) -> Result<u16> {
454
let body = organizer::lock_body(from.wire(), locked, self.next_state_sequence());
455
self.send("PUT updateMeetingSettings", Method::Put, conversation.link("updateMeetingSettings")?, Some(body)).await.map(|response| response.status)
456
}
457
458
pub async fn change_role(&self, conversation: &Conversation, from: &Participant, mri: &str, role: MeetingRole) -> Result<u16> {
459
let body = organizer::role_body(from.wire(), mri, role);
460
self.send("POST updateParticipantRole", Method::Post, conversation.link("updateParticipantRole")?, Some(body)).await.map(|response| response.status)
461
}
462
463
pub async fn publish_attendee_state(&self, conversation: &Conversation, from: &Participant, state_type: &str, mri: &str) -> Result<u16> {
464
let body = organizer::attendee_state_body(from.wire(), state_type, self.next_state_sequence(), mri);
465
self.send("POST publishState (attendee)", Method::Post, conversation.link("publishState")?, Some(body)).await.map(|response| response.status)
466
}
467
468
pub async fn add_participants(
469
&self,
470
conversation: &Conversation,
471
from: &Participant,
472
callees: &[Callee],
473
group_thread: Option<&str>,
474
meeting: Option<&MeetingTarget>,
475
callbacks: &CallbackLinks,
476
) -> Result<u16> {
477
let invitees: Vec<Invitee> = callees
478
.iter()
479
.map(|callee| Invitee { callee: callee.clone(), participant_id: uuid::Uuid::new_v4().to_string() })
480
.collect();
481
let group_chat = group_thread.map_or(Value::Null, |thread_id| organizer::group_chat_for(thread_id, meeting.is_some()));
482
let body = organizer::add_participants_body(from.wire(), &invitees, group_chat, meeting, callbacks);
483
let url = conversation.link(organizer::add_link_name(group_thread.is_some()))?;
484
self.send("POST add (invite)", Method::Post, url, Some(body)).await.map(|response| response.status)
485
}
486
452
487
pub async fn add_caption_bot(
453
488
&self,
454
489
conversation: &Conversation,
@@ -7,7 +7,8 @@ use crate::captions::{self, BotAction};7
use crate::recording::{self, Consent, RecordingCommand, StartDetails};7
use crate::recording::{self, Consent, RecordingCommand, StartDetails};8
use crate::transfer::{self, TransferTarget};8
use crate::transfer::{self, TransferTarget};9
use crate::error::{Error, Result};9
use crate::error::{Error, Result};10
use crate::organizer::{self, Target};10
use crate::organizer::{self, Invitee, Target};11
use crate::roster::MeetingRole;11
use crate::reaction::{DEFAULT_SKIN_TONE, Reaction, reaction_message};12
use crate::reaction::{DEFAULT_SKIN_TONE, Reaction, reaction_message};12
use crate::relay::ic3_scope;13
use crate::relay::ic3_scope;13
use crate::timeline::Timeline;14
use crate::timeline::Timeline;@@ -49,7 +50,7 @@ const SUBSCRIBE_LINK_NAMES: [&str; 6] = [49
];50
];50
const CALL_LINK_NAMES: [&str; 5] = ["progress", "mediaAnswer", "acceptance", "redirection", "end"];51
const CALL_LINK_NAMES: [&str; 5] = ["progress", "mediaAnswer", "acceptance", "redirection", "end"];51
const AUDIO_MODALITIES: [&str; 1] = ["Audio"];52
const AUDIO_MODALITIES: [&str; 1] = ["Audio"];52
const MEETING_MESSAGE_ID: &str = "0";53
pub(crate) const MEETING_MESSAGE_ID: &str = "0";53
const RAISE_HANDS: &str = "raiseHands";54
const RAISE_HANDS: &str = "raiseHands";54
const CANCEL_CODE: i64 = 487;55
const CANCEL_CODE: i64 = 487;55
const DECLINE_CODE: i64 = 603;56
const DECLINE_CODE: i64 = 603;@@ -449,6 +450,40 @@ impl Signaling {449
self.send("POST publishState (spotlight)", Method::Post, conversation.link("publishState")?, Some(body)).await.map(|response| response.status)450
self.send("POST publishState (spotlight)", Method::Post, conversation.link("publishState")?, Some(body)).await.map(|response| response.status)450
}451
}451
452
453
pub async fn set_lock(&self, conversation: &Conversation, from: &Participant, locked: bool) -> Result<u16> {454
let body = organizer::lock_body(from.wire(), locked, self.next_state_sequence());455
self.send("PUT updateMeetingSettings", Method::Put, conversation.link("updateMeetingSettings")?, Some(body)).await.map(|response| response.status)456
}457
458
pub async fn change_role(&self, conversation: &Conversation, from: &Participant, mri: &str, role: MeetingRole) -> Result<u16> {459
let body = organizer::role_body(from.wire(), mri, role);460
self.send("POST updateParticipantRole", Method::Post, conversation.link("updateParticipantRole")?, Some(body)).await.map(|response| response.status)461
}462
463
pub async fn publish_attendee_state(&self, conversation: &Conversation, from: &Participant, state_type: &str, mri: &str) -> Result<u16> {464
let body = organizer::attendee_state_body(from.wire(), state_type, self.next_state_sequence(), mri);465
self.send("POST publishState (attendee)", Method::Post, conversation.link("publishState")?, Some(body)).await.map(|response| response.status)466
}467
468
pub async fn add_participants(469
&self,470
conversation: &Conversation,471
from: &Participant,472
callees: &[Callee],473
group_thread: Option<&str>,474
meeting: Option<&MeetingTarget>,475
callbacks: &CallbackLinks,476
) -> Result<u16> {477
let invitees: Vec<Invitee> = callees478
.iter()479
.map(|callee| Invitee { callee: callee.clone(), participant_id: uuid::Uuid::new_v4().to_string() })480
.collect();481
let group_chat = group_thread.map_or(Value::Null, |thread_id| organizer::group_chat_for(thread_id, meeting.is_some()));482
let body = organizer::add_participants_body(from.wire(), &invitees, group_chat, meeting, callbacks);483
let url = conversation.link(organizer::add_link_name(group_thread.is_some()))?;484
self.send("POST add (invite)", Method::Post, url, Some(body)).await.map(|response| response.status)485
}486
452
pub async fn add_caption_bot(487
pub async fn add_caption_bot(453
&self,488
&self,454
conversation: &Conversation,489
conversation: &Conversation,@@ -41,7 +41,7 @@ pub fn content_share(body: &Value) -> Option<ContentShare> {
41
41
})
42
42
}
43
43
44
fn encoded(component: &str) -> String {
44
pub(crate) fn encoded(component: &str) -> String {
45
45
component
46
46
.bytes()
47
47
.map(|byte| match byte {
@@ -41,7 +41,7 @@ pub fn content_share(body: &Value) -> Option<ContentShare> {41
})41
})42
}42
}43
43
44
fn encoded(component: &str) -> String {44
pub(crate) fn encoded(component: &str) -> String {45
component45
component46
.bytes()46
.bytes()47
.map(|byte| match byte {47
.map(|byte| match byte {