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 13 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
13 changes: 13 additions & 0 deletions dev/AppNotifications/AppNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,17 @@ 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)
{
THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These APIs should "do nothing" if calling preview is unsupported. Allow the caller to set/read the value, but don't use it in any way. And don't throw. :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But how do we inform the user that this feature is not yet supported when they call these APIs?

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,19 @@ namespace winrt::Microsoft::Windows::AppNotifications::Builder::implementation

return appNotification;
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationBuilder AppNotificationBuilder::AddCameraPreview()
{
THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported());

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 AppNotificationButtonSettingStyle
{
None,
VideoCallConfig,
AudioCallConfig,
};

[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 SetSettingStyle(AppNotificationButtonSettingStyle value);
};

[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,39 @@ 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
GetSettingStyle().c_str()) };

logTelemetry.Stop();

return xmlResult.c_str();
}

winrt::Microsoft::Windows::AppNotifications::Builder::AppNotificationButton AppNotificationButton::SetSettingStyle(AppNotificationButtonSettingStyle const& value)
{
THROW_HR_IF(E_NOTIMPL, !AppNotificationConferencingConfig::IsCallingPreviewSupported());

m_settingType = value;
return *this;
}

std::wstring AppNotificationButton::GetSettingStyle()
{
switch (m_settingType)
{
case AppNotificationButtonSettingStyle::VideoCallConfig:
return L" settingType='videoDevices'";
case AppNotificationButtonSettingStyle::AudioCallConfig:
return L" settingType='audioDevices'";
default: // AppNotificationButtonSettingStyle::None
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 SetSettingStyle(AppNotificationButtonSettingStyle const& value);

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

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 };
AppNotificationButtonSettingStyle m_settingType{ AppNotificationButtonSettingStyle::None };
};
}
namespace winrt::Microsoft::Windows::AppNotifications::Builder::factory_implementation
Expand Down
47 changes: 47 additions & 0 deletions dev/AppNotifications/AppNotificationConferencingConfig.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#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)
{
THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported());
m_videoDeviceId = value;
}

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

void AppNotificationConferencingConfig::AudioInputDeviceId(hstring const& value)
{
THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported());
m_audioInputDeviceId = value;
}

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

void AppNotificationConferencingConfig::AudioOutputDeviceId(hstring const& value)
{
THROW_HR_IF(E_NOTIMPL, !IsCallingPreviewSupported());
m_audioOutputDeviceId = value;
}

///Checks if the calling preview feature is supported on the current OS version
///TO DO - This method needs implementation on framework UDK, for now it always returns false
satkh marked this conversation as resolved.
Show resolved Hide resolved
bool AppNotificationConferencingConfig::IsCallingPreviewSupported()
{
return false;
}
}
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 IsCallingPreviewSupported();

private:

hstring m_videoDeviceId{};
hstring m_audioInputDeviceId{};
hstring m_audioOutputDeviceId{};
};
}
namespace winrt::Microsoft::Windows::AppNotifications::factory_implementation
{
struct AppNotificationConferencingConfig : AppNotificationConferencingConfigT<AppNotificationConferencingConfig, implementation::AppNotificationConferencingConfig>
{
};
}
3 changes: 2 additions & 1 deletion dev/AppNotifications/AppNotificationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
m_appId,
notification.Payload(),
notification.Tag(),
notification.Group()) };
notification.Group(),
winrt::AppNotificationConferencingConfig::IsCallingPreviewSupported()) };

THROW_HR_IF(WPN_E_NOTIFICATION_POSTED, notification.Id() != 0);

Expand Down
8 changes: 5 additions & 3 deletions dev/AppNotifications/AppNotificationTelemetry.h
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 @@ -62,7 +62,8 @@ class AppNotificationTelemetry : public wil::TraceLoggingProvider
std::wstring const& appId,
winrt::hstring const& payload,
winrt::hstring const& tag,
winrt::hstring const& group) noexcept try
winrt::hstring const& group,
bool isCallingPreviewSupported) noexcept try
{
TraceLoggingClassWriteStart(
Show,
Expand All @@ -72,7 +73,8 @@ class AppNotificationTelemetry : public wil::TraceLoggingProvider
TraceLoggingUInt32(tag.size(), "TagSize"),
TraceLoggingUInt32(group.size(), "GroupSize"),
TraceLoggingBool(notificationTelemetryHelper.IsPackagedApp(), "IsAppPackaged"),
TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName"));
TraceLoggingWideString(notificationTelemetryHelper.GetAppName().c_str(), "AppName"),
TraceLoggingBool(isCallingPreviewSupported, "IsCallingPreviewSupported"));
}
CATCH_LOG()
END_ACTIVITY_CLASS();
Expand Down
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 IsCallingPreviewSupported();

// 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
Loading