Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interfaces for "Enhanced UX Notification for Video and Audio Call Feature" #4783

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions dev/AppNotifications/AppNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,16 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
auto lock{ m_lock.lock_exclusive() };
m_notificationId = id;
}

winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig AppNotification::ConferencingConfig()
{
auto lock{ m_lock.lock_shared() };
return m_conferencingConfig;
}

void AppNotification::ConferencingConfig(winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig const& conferencingConfig)
{
auto lock{ m_lock.lock_exclusive() };
m_conferencingConfig = conferencingConfig;
}
}
5 changes: 5 additions & 0 deletions dev/AppNotifications/AppNotification.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
// IAppNotificationInternal
void SetNotificationId(uint32_t id);

winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig ConferencingConfig();
void ConferencingConfig(winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig const& value);

private:
winrt::hstring m_tag{};
winrt::hstring m_group{};
Expand All @@ -49,6 +52,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
{ winrt::Microsoft::Windows::AppNotifications::AppNotificationPriority::Default };
bool m_suppressDisplay{ false };
wil::srwlock m_lock;

winrt::Microsoft::Windows::AppNotifications::AppNotificationConferencingConfig m_conferencingConfig{ nullptr };
};
}
namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
Expand Down Expand Up @@ -376,14 +376,15 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
// Build the actions string and fill m_useButtonStyle
std::wstring actions{ GetActions() };

auto xmlResult{ wil::str_printf<std::wstring>(L"<toast%ls%ls%ls%ls%ls><visual><binding template='ToastGeneric'>%ls%ls%ls%ls</binding></visual>%ls%ls</toast>",
auto xmlResult{ wil::str_printf<std::wstring>(L"<toast%ls%ls%ls%ls%ls><visual><binding template='ToastGeneric'>%ls%ls%ls%ls%ls</binding></visual>%ls%ls</toast>",
m_timeStamp.c_str(),
GetDuration().c_str(),
GetScenario().c_str(),
GetArguments().c_str(),
GetButtonStyle().c_str(),
GetText().c_str(),
m_attributionText.c_str(),
GetCameraPreview().c_str(),
GetImages().c_str(),
GetProgressBars().c_str(),
m_audio.c_str(),
Expand All @@ -399,4 +400,17 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

return appNotification;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddCameraPreview()
{
THROW_HR_IF_MSG(E_INVALIDARG, m_useCameraPreview, "CameraPreview element is already added, only one is allowed");

m_useCameraPreview = true;
return *this;
}

std::wstring AppNotificationBuilder::GetCameraPreview()
{
return m_useCameraPreview ? L"<cameraPreview/>" : L"";
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#pragma once
Expand Down Expand Up @@ -65,6 +65,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

static bool IsUrgentScenarioSupported();

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AddCameraPreview();

private:
void ThrowIfMaxInputItemsExceeded();
std::wstring GetDuration();
Expand All @@ -75,6 +77,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
std::wstring GetImages();
std::wstring GetActions();
std::wstring GetProgressBars();
std::wstring GetCameraPreview();

std::wstring m_timeStamp{};
AppNotificationDuration m_duration{ AppNotificationDuration::Default };
Expand All @@ -93,6 +96,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
std::vector<AppNotificationComboBox> m_comboBoxList{};
winrt::hstring m_tag{};
winrt::hstring m_group{};
bool m_useCameraPreview{false};
};
}
namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

import "..\AppNotifications\AppNotifications.idl";

namespace Microsoft.Windows.AppNotifications.Builder
{
[contractversion(1)]
[contractversion(2)]
apicontract AppNotificationBuilderContract {}

[contract(AppNotificationBuilderContract, 1)]
Expand All @@ -31,6 +31,14 @@ namespace Microsoft.Windows.AppNotifications.Builder
Critical,
};

[contract(AppNotificationBuilderContract, 2)]
enum AppNotificationButtonSettingType
satkh marked this conversation as resolved.
Show resolved Hide resolved
{
none,
satkh marked this conversation as resolved.
Show resolved Hide resolved
VideoCall,
satkh marked this conversation as resolved.
Show resolved Hide resolved
AudioCall,
};

[contract(AppNotificationBuilderContract, 1)]
runtimeclass AppNotificationButton
{
Expand Down Expand Up @@ -69,6 +77,10 @@ namespace Microsoft.Windows.AppNotifications.Builder
// Launches the URI passed into the button when activated.
AppNotificationButton SetInvokeUri(Windows.Foundation.Uri protocolUri);
AppNotificationButton SetInvokeUri(Windows.Foundation.Uri protocolUri, String targetAppId);

// Sets the setting type for the button.
[contract(AppNotificationBuilderContract, 2)]
AppNotificationButton SetSettingType(AppNotificationButtonSettingType value);
satkh marked this conversation as resolved.
Show resolved Hide resolved
};

[contract(AppNotificationBuilderContract, 1)]
Expand Down Expand Up @@ -242,5 +254,9 @@ namespace Microsoft.Windows.AppNotifications.Builder
// AppNotification properties
AppNotificationBuilder SetTag(String value);
AppNotificationBuilder SetGroup(String group);

// Adds a camera preview to the AppNotification
[contract(AppNotificationBuilderContract, 2)]
AppNotificationBuilder AddCameraPreview();
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
Expand Down Expand Up @@ -121,17 +121,42 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
{
auto logTelemetry{ AppNotificationBuilderTelemetry::ButtonToString::Start(g_telemetryHelper) };

std::wstring xmlResult{ wil::str_printf<std::wstring>(L"<action content='%ls'%ls%ls%ls%ls%ls%ls/>",
std::wstring xmlResult{ wil::str_printf<std::wstring>(L"<action content='%ls'%ls%ls%ls%ls%ls%ls%ls/>",
m_content.c_str(),
GetActivationArguments().c_str(),
m_useContextMenuPlacement ? L" placement='contextMenu'" : L"",
m_iconUri ? wil::str_printf<std::wstring>(L" imageUri='%ls'", m_iconUri.ToString().c_str()).c_str() : L"",
!m_inputId.empty() ? wil::str_printf<std::wstring>(L" hint-inputId='%ls'", m_inputId.c_str()).c_str() : L"",
GetButtonStyle().c_str(),
!m_toolTip.empty() ? wil::str_printf<std::wstring>(L" hint-toolTip='%ls'", m_toolTip.c_str()).c_str() : L"") };
!m_toolTip.empty() ? wil::str_printf<std::wstring>(L" hint-toolTip='%ls'", m_toolTip.c_str()).c_str() : L"",
satkh marked this conversation as resolved.
Show resolved Hide resolved
GetSettingType().c_str()) };

logTelemetry.Stop();

return xmlResult.c_str();
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton AppNotificationButton::SetSettingType(AppNotificationButtonSettingType const& value)
{
m_settingType = value;
return *this;
}

std::wstring AppNotificationButton::GetSettingType()
{
if (m_settingType == AppNotificationButtonSettingType::none)
{
return L"";
}

switch (m_settingType)
{
case AppNotificationButtonSettingType::VideoCall:
return L" settingType='videoDevices'";
case AppNotificationButtonSettingType::AudioCall:
return L" settingType='audioDevices'";
default:
return L"";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once
Expand Down Expand Up @@ -60,9 +60,12 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

winrt::hstring ToString();

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton SetSettingType(AppNotificationButtonSettingType const& value);

private:
std::wstring GetActivationArguments();
std::wstring GetButtonStyle();
std::wstring GetSettingType();

winrt::hstring m_content{};
winrt::Windows::Foundation::Collections::IMap<winrt::hstring, winrt::hstring> m_arguments { winrt::single_threaded_map<winrt::hstring, winrt::hstring>() };
Expand All @@ -73,6 +76,7 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation
winrt::hstring m_inputId{};
bool m_useContextMenuPlacement{};
AppNotificationButtonStyle m_buttonStyle { AppNotificationButtonStyle::Default };
AppNotificationButtonSettingType m_settingType{ AppNotificationButtonSettingType::none };
};
}
namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation
Expand Down
46 changes: 46 additions & 0 deletions dev/AppNotifications/AppNotificationConferencingConfig.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "pch.h"
#include "AppNotificationConferencingConfig.h"
#include "Microsoft.Windows.AppNotifications.AppNotificationConferencingConfig.g.cpp"
#include <IsWindowsVersion.h>

namespace winrt::Microsoft::Windows::AppNotifications::implementation
{
hstring AppNotificationConferencingConfig::VideoDeviceId()
{
return m_videoDeviceId;
}

void AppNotificationConferencingConfig::VideoDeviceId(hstring const& value)
{
m_videoDeviceId = value;
}

hstring AppNotificationConferencingConfig::AudioInputDeviceId()
{
return m_audioInputDeviceId;
}

void AppNotificationConferencingConfig::AudioInputDeviceId(hstring const& value)
{
m_audioInputDeviceId = value;
}

hstring AppNotificationConferencingConfig::AudioOutputDeviceId()
{
return m_audioOutputDeviceId;
}

void AppNotificationConferencingConfig::AudioOutputDeviceId(hstring const& value)
{
m_audioOutputDeviceId = value;
}

/// <summary>
/// verifies if video calling is supported <TO DO>
/// </summary>
/// <returns>bool</returns>
bool AppNotificationConferencingConfig::IsVideoOrAudioCallingSupported()
{
return WindowsVersion::IsWindows11_23H1OrGreater(); // Windows 11 23H1 or greater
}
}
34 changes: 34 additions & 0 deletions dev/AppNotifications/AppNotificationConferencingConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
#include "Microsoft.Windows.AppNotifications.AppNotificationConferencingConfig.g.h"

namespace winrt::Microsoft::Windows::AppNotifications::implementation
{
struct AppNotificationConferencingConfig : AppNotificationConferencingConfigT<AppNotificationConferencingConfig>
{
AppNotificationConferencingConfig() = default;

// Getters
hstring VideoDeviceId();
hstring AudioInputDeviceId();
hstring AudioOutputDeviceId();

// Setters
void VideoDeviceId(hstring const& value);
void AudioInputDeviceId(hstring const& value);
void AudioOutputDeviceId(hstring const& value);

static bool IsVideoOrAudioCallingSupported();

private:

hstring m_videoDeviceId{};
hstring m_audioInputDeviceId{};
hstring m_audioOutputDeviceId{};
};
}
namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation
{
struct AppNotificationConferencingConfig : AppNotificationConferencingConfigT<AppNotificationConferencingConfig, implementation::AppNotificationConferencingConfig>
{
};
}
26 changes: 25 additions & 1 deletion dev/AppNotifications/AppNotifications.idl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
import "..\AppLifecycle\AppLifecycle.idl";

Expand Down Expand Up @@ -111,6 +111,30 @@ namespace Microsoft.Windows.AppNotifications

// Gets or sets whether a Notification's pop-up UI is displayed on the user's screen.
Boolean SuppressDisplay;

// Gets or sets the Notification Conferencing Config
[contract(AppNotificationsContract, 2)]
satkh marked this conversation as resolved.
Show resolved Hide resolved
AppNotificationConferencingConfig ConferencingConfig;
}

// The Notification Conferencing Config
[contract(AppNotificationsContract, 2)]
satkh marked this conversation as resolved.
Show resolved Hide resolved
runtimeclass AppNotificationConferencingConfig
{
// Initializes a new Instance of AppNotificationConferencingConfig
AppNotificationConferencingConfig();

// Checks if Video or Audio Calling is supported
static Boolean IsVideoOrAudioCallingSupported();
satkh marked this conversation as resolved.
Show resolved Hide resolved

// Gets or sets the Video Device Id
String VideoDeviceId;

// Gets or sets the Microphone Device Id
String AudioInputDeviceId;

// Gets or sets the Speaker Device Id
String AudioOutputDeviceId;
}

// The manager class which encompasses all App Notification API Functionality
Expand Down
4 changes: 4 additions & 0 deletions dev/AppNotifications/AppNotifications.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<ClInclude Include="$(MSBuildThisFileDirectory)NotificationTransientProperties.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)NotificationProgressData.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)ShellLocalization.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)AppNotificationConferencingConfig.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)NotificationDevicesData.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)AppNotificationActivatedEventArgs.cpp" />
Expand All @@ -35,6 +37,8 @@
<ClCompile Include="$(MSBuildThisFileDirectory)NotificationTransientProperties.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)NotificationProgressData.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)ShellLocalization.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)AppNotificationConferencingConfig.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)NotificationDevicesData.cpp" />
</ItemGroup>
<ItemGroup>
<Midl Include="$(MSBuildThisFileDirectory)AppNotifications.idl" />
Expand Down
Loading