Bug 1826375 - Part 2: Remove WinToast. r=mhughes,firefox-build-system-reviewers,sylvestre,nalexander

WinToast had a single dependency in the Windows Default Agent which has since been migrated to Firefox's notification implementation.

Differential Revision: https://phabricator.services.mozilla.com/D203489
This commit is contained in:
Nicholas Rishel 2024-03-08 19:27:23 +00:00
parent 2657cfb14b
commit 675a598de1
8 changed files with 0 additions and 1806 deletions

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2016 Mohammed Boujemaoui Boulaghmoudi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,81 +0,0 @@
diff --git a/src/wintoastlib.cpp b/src/wintoastlib.cpp
index 0895ff7..ac8d5cf 100644
--- a/src/wintoastlib.cpp
+++ b/src/wintoastlib.cpp
@@ -213,8 +213,8 @@ namespace Util {
}
- inline HRESULT defaultShellLinksDirectory(_In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) {
- DWORD written = GetEnvironmentVariableW(L"APPDATA", path, nSize);
+ inline HRESULT commonShellLinksDirectory(_In_ const WCHAR* baseEnv, _In_ WCHAR* path, _In_ DWORD nSize) {
+ DWORD written = GetEnvironmentVariableW(baseEnv, path, nSize);
HRESULT hr = written > 0 ? S_OK : E_INVALIDARG;
if (SUCCEEDED(hr)) {
errno_t result = wcscat_s(path, nSize, DEFAULT_SHELL_LINKS_PATH);
@@ -224,8 +224,8 @@ namespace Util {
return hr;
}
- inline HRESULT defaultShellLinkPath(const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) {
- HRESULT hr = defaultShellLinksDirectory(path, nSize);
+ inline HRESULT commonShellLinkPath(_In_ const WCHAR* baseEnv, const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize) {
+ HRESULT hr = commonShellLinksDirectory(baseEnv, path, nSize);
if (SUCCEEDED(hr)) {
const std::wstring appLink(appname + DEFAULT_LINK_FORMAT);
errno_t result = wcscat_s(path, nSize, appLink.c_str());
@@ -235,6 +235,13 @@ namespace Util {
return hr;
}
+ inline HRESULT defaultUserShellLinkPath(const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) {
+ return commonShellLinkPath(L"APPDATA", appname, path, nSize);
+ }
+
+ inline HRESULT defaultSystemShellLinkPath(const std::wstring& appname, _In_ WCHAR* path, _In_ DWORD nSize = MAX_PATH) {
+ return commonShellLinkPath(L"PROGRAMDATA", appname, path, nSize);
+ }
inline PCWSTR AsString(ComPtr<IXmlDocument> &xmlDocument) {
HSTRING xml;
@@ -523,12 +530,19 @@ const std::wstring& WinToast::appUserModelId() const {
HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) {
WCHAR path[MAX_PATH] = { L'\0' };
- Util::defaultShellLinkPath(_appName, path);
+ Util::defaultUserShellLinkPath(_appName, path);
// Check if the file exist
DWORD attr = GetFileAttributesW(path);
if (attr >= 0xFFFFFFF) {
- DEBUG_MSG("Error, shell link not found. Try to create a new one in: " << path);
- return E_FAIL;
+ // The shortcut may be in the system Start Menu.
+ WCHAR systemPath[MAX_PATH] = { L'\0' };
+ Util::defaultSystemShellLinkPath(_appName, systemPath);
+ attr = GetFileAttributesW(systemPath);
+ if (attr >= 0xFFFFFFF) {
+ DEBUG_MSG("Error, shell link not found. Try to create a new one in: " << path);
+ return E_FAIL;
+ }
+ wcscpy(path, systemPath);
}
// Let's load the file as shell link to validate.
@@ -543,7 +557,7 @@ HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) {
ComPtr<IPersistFile> persistFile;
hr = shellLink.As(&persistFile);
if (SUCCEEDED(hr)) {
- hr = persistFile->Load(path, STGM_READWRITE);
+ hr = persistFile->Load(path, STGM_READ);
if (SUCCEEDED(hr)) {
ComPtr<IPropertyStore> propertyStore;
hr = shellLink.As(&propertyStore);
@@ -583,7 +597,7 @@ HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) {
HRESULT WinToast::createShellLinkHelper() {
WCHAR exePath[MAX_PATH]{L'\0'};
WCHAR slPath[MAX_PATH]{L'\0'};
- Util::defaultShellLinkPath(_appName, slPath);
+ Util::defaultUserShellLinkPath(_appName, slPath);
Util::defaultExecutablePath(exePath);
ComPtr<IShellLinkW> shellLink;
HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));

View File

@ -1,110 +0,0 @@
diff --git a/src/wintoastlib.cpp b/src/wintoastlib.cpp
index 0895ff7..52de554 100644
--- a/src/wintoastlib.cpp
+++ b/src/wintoastlib.cpp
@@ -391,6 +391,10 @@ void WinToast::setAppUserModelId(_In_ const std::wstring& aumi) {
DEBUG_MSG(L"Default App User Model Id: " << _aumi.c_str());
}
+void WinToast::setShortcutPolicy(_In_ ShortcutPolicy shortcutPolicy) {
+ _shortcutPolicy = shortcutPolicy;
+}
+
bool WinToast::isCompatible() {
DllImporter::initialize();
return !((DllImporter::SetCurrentProcessExplicitAppUserModelID == nullptr)
@@ -492,10 +496,12 @@ bool WinToast::initialize(_Out_ WinToastError* error) {
return false;
}
- if (createShortcut() < 0) {
- setError(error, WinToastError::ShellLinkNotCreated);
- DEBUG_MSG(L"Error while attaching the AUMI to the current proccess =(");
- return false;
+ if (_shortcutPolicy != SHORTCUT_POLICY_IGNORE) {
+ if (createShortcut() < 0) {
+ setError(error, WinToastError::ShellLinkNotCreated);
+ DEBUG_MSG(L"Error while attaching the AUMI to the current proccess =(");
+ return false;
+ }
}
if (FAILED(DllImporter::SetCurrentProcessExplicitAppUserModelID(_aumi.c_str()))) {
@@ -555,18 +561,23 @@ HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) {
hr = DllImporter::PropVariantToString(appIdPropVar, AUMI, MAX_PATH);
wasChanged = false;
if (FAILED(hr) || _aumi != AUMI) {
- // AUMI Changed for the same app, let's update the current value! =)
- wasChanged = true;
- PropVariantClear(&appIdPropVar);
- hr = InitPropVariantFromString(_aumi.c_str(), &appIdPropVar);
- if (SUCCEEDED(hr)) {
- hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
+ if (_shortcutPolicy == SHORTCUT_POLICY_REQUIRE_CREATE) {
+ // AUMI Changed for the same app, let's update the current value! =)
+ wasChanged = true;
+ PropVariantClear(&appIdPropVar);
+ hr = InitPropVariantFromString(_aumi.c_str(), &appIdPropVar);
if (SUCCEEDED(hr)) {
- hr = propertyStore->Commit();
- if (SUCCEEDED(hr) && SUCCEEDED(persistFile->IsDirty())) {
- hr = persistFile->Save(path, TRUE);
+ hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
+ if (SUCCEEDED(hr)) {
+ hr = propertyStore->Commit();
+ if (SUCCEEDED(hr) && SUCCEEDED(persistFile->IsDirty())) {
+ hr = persistFile->Save(path, TRUE);
+ }
}
}
+ } else {
+ // Not allowed to touch the shortcut to fix the AUMI
+ hr = E_FAIL;
}
}
PropVariantClear(&appIdPropVar);
@@ -581,6 +592,10 @@ HRESULT WinToast::validateShellLinkHelper(_Out_ bool& wasChanged) {
HRESULT WinToast::createShellLinkHelper() {
+ if (_shortcutPolicy != SHORTCUT_POLICY_REQUIRE_CREATE) {
+ return E_FAIL;
+ }
+
WCHAR exePath[MAX_PATH]{L'\0'};
WCHAR slPath[MAX_PATH]{L'\0'};
Util::defaultShellLinkPath(_appName, slPath);
diff --git a/src/wintoastlib.h b/src/wintoastlib.h
index 68b1cb1..dc8d745 100644
--- a/src/wintoastlib.h
+++ b/src/wintoastlib.h
@@ -173,6 +173,16 @@ namespace WinToastLib {
SHORTCUT_CREATE_FAILED = -4
};
+ enum ShortcutPolicy {
+ /* Don't check, create, or modify a shortcut. */
+ SHORTCUT_POLICY_IGNORE = 0,
+ /* Require a shortcut with matching AUMI, don't create or modify an existing one. */
+ SHORTCUT_POLICY_REQUIRE_NO_CREATE = 1,
+ /* Require a shortcut with matching AUMI, create if missing, modify if not matching.
+ * This is the default. */
+ SHORTCUT_POLICY_REQUIRE_CREATE = 2,
+ };
+
WinToast(void);
virtual ~WinToast();
static WinToast* instance();
@@ -194,10 +204,12 @@ namespace WinToastLib {
const std::wstring& appUserModelId() const;
void setAppUserModelId(_In_ const std::wstring& aumi);
void setAppName(_In_ const std::wstring& appName);
+ void setShortcutPolicy(_In_ ShortcutPolicy policy);
protected:
bool _isInitialized{false};
bool _hasCoInitialized{false};
+ ShortcutPolicy _shortcutPolicy{SHORTCUT_POLICY_REQUIRE_CREATE};
std::wstring _appName{};
std::wstring _aumi{};
std::map<INT64, ComPtr<IToastNotification>> _buffer{};

View File

@ -1,37 +0,0 @@
# Version of this schema
schema: 1
# Manual Update can be done with:
# cd third_pary/WinToast
# wget https://raw.githubusercontent.com/mohabouje/WinToast/master/src/wintoastlib.cpp
# wget https://raw.githubusercontent.com/mohabouje/WinToast/master/src/wintoastlib.h
# patch -p2 < moz-check-system-shortcut.patch
# patch -p2 < moz-disable-create-shortcut.patch
# patch -p2 < upstream-add-toast-scenario.patch
bugzilla:
# Bugzilla product and component for this directory and subdirectories
product: Toolkit
component: "General"
# Document the source of externally hosted code
origin:
# Short name of the package/library
name: WinToast
description: WinToast is a lightly library written in C++ which brings a complete integration of the modern toast notifications of Windows 8 & Windows 10.
# Full URL for the package's homepage/etc
# Usually different from repository url
url: https://github.com/mohabouje/WinToast
# Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS"
release: commit 09227c72f16ccefc36e9d430dea3b435346dbcbc
# The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/
# Multiple licenses can be specified (as a YAML list)
# A "LICENSE" file must exist containing the full license text
license: MIT

View File

@ -1,123 +0,0 @@
diff --git a/src/wintoastlib.cpp b/src/wintoastlib.cpp
index 3cf5f21..1adfe19 100644
--- a/src/wintoastlib.cpp
+++ b/src/wintoastlib.cpp
@@ -677,6 +677,10 @@ INT64 WinToast::showToast(_In_ const WinToastTemplate& toast, _In_ IWinToastHan
(toast.duration() == WinToastTemplate::Duration::Short) ? L"short" : L"long");
}
+ if (SUCCEEDED(hr)) {
+ hr = addScenarioHelper(xmlDocument.Get(), toast.scenario());
+ }
+
} else {
DEBUG_MSG("Modern features (Actions/Sounds/Attributes) not supported in this os version");
}
@@ -828,6 +832,28 @@ HRESULT WinToast::addDurationHelper(_In_ IXmlDocument *xml, _In_ const std::wstr
return hr;
}
+HRESULT WinToast::addScenarioHelper(_In_ IXmlDocument* xml, _In_ const std::wstring& scenario) {
+ ComPtr<IXmlNodeList> nodeList;
+ HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"toast").Get(), &nodeList);
+ if (SUCCEEDED(hr)) {
+ UINT32 length;
+ hr = nodeList->get_Length(&length);
+ if (SUCCEEDED(hr)) {
+ ComPtr<IXmlNode> toastNode;
+ hr = nodeList->Item(0, &toastNode);
+ if (SUCCEEDED(hr)) {
+ ComPtr<IXmlElement> toastElement;
+ hr = toastNode.As(&toastElement);
+ if (SUCCEEDED(hr)) {
+ hr = toastElement->SetAttribute(WinToastStringWrapper(L"scenario").Get(),
+ WinToastStringWrapper(scenario).Get());
+ }
+ }
+ }
+ }
+ return hr;
+}
+
HRESULT WinToast::setTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text, _In_ UINT32 pos) {
ComPtr<IXmlNodeList> nodeList;
HRESULT hr = xml->GetElementsByTagName(WinToastStringWrapper(L"text").Get(), &nodeList);
@@ -1065,6 +1091,15 @@ void WinToastTemplate::setExpiration(_In_ INT64 millisecondsFromNow) {
_expiration = millisecondsFromNow;
}
+void WinToastLib::WinToastTemplate::setScenario(Scenario scenario) {
+ switch (scenario) {
+ case Scenario::Default: _scenario = L"Default"; break;
+ case Scenario::Alarm: _scenario = L"Alarm"; break;
+ case Scenario::IncomingCall: _scenario = L"IncomingCall"; break;
+ case Scenario::Reminder: _scenario = L"Reminder"; break;
+ }
+}
+
void WinToastTemplate::setAttributionText(_In_ const std::wstring& attributionText) {
_attributionText = attributionText;
}
@@ -1112,6 +1147,10 @@ const std::wstring& WinToastTemplate::attributionText() const {
return _attributionText;
}
+const std::wstring& WinToastLib::WinToastTemplate::scenario() const {
+ return _scenario;
+}
+
INT64 WinToastTemplate::expiration() const {
return _expiration;
}
diff --git a/src/wintoastlib.h b/src/wintoastlib.h
index d028994..291e15f 100644
--- a/src/wintoastlib.h
+++ b/src/wintoastlib.h
@@ -63,6 +63,7 @@ namespace WinToastLib {
class WinToastTemplate {
public:
+ enum class Scenario { Default, Alarm, IncomingCall, Reminder };
enum Duration { System, Short, Long };
enum AudioOption { Default = 0, Silent, Loop };
enum TextField { FirstLine = 0, SecondLine, ThirdLine };
@@ -114,13 +115,14 @@ namespace WinToastLib {
void setSecondLine(_In_ const std::wstring& text);
void setThirdLine(_In_ const std::wstring& text);
void setTextField(_In_ const std::wstring& txt, _In_ TextField pos);
- void setAttributionText(_In_ const std::wstring & attributionText);
+ void setAttributionText(_In_ const std::wstring& attributionText);
void setImagePath(_In_ const std::wstring& imgPath);
void setAudioPath(_In_ WinToastTemplate::AudioSystemFile audio);
void setAudioPath(_In_ const std::wstring& audioPath);
void setAudioOption(_In_ WinToastTemplate::AudioOption audioOption);
void setDuration(_In_ Duration duration);
void setExpiration(_In_ INT64 millisecondsFromNow);
+ void setScenario(_In_ Scenario scenario);
void addAction(_In_ const std::wstring& label);
std::size_t textFieldsCount() const;
@@ -132,6 +134,7 @@ namespace WinToastLib {
const std::wstring& imagePath() const;
const std::wstring& audioPath() const;
const std::wstring& attributionText() const;
+ const std::wstring& scenario() const;
INT64 expiration() const;
WinToastTemplateType type() const;
WinToastTemplate::AudioOption audioOption() const;
@@ -142,6 +145,7 @@ namespace WinToastLib {
std::wstring _imagePath{};
std::wstring _audioPath{};
std::wstring _attributionText{};
+ std::wstring _scenario{L"Default"};
INT64 _expiration{0};
AudioOption _audioOption{WinToastTemplate::AudioOption::Default};
WinToastTemplateType _type{WinToastTemplateType::Text01};
@@ -210,6 +214,7 @@ namespace WinToastLib {
HRESULT setAttributionTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text);
HRESULT addActionHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& action, _In_ const std::wstring& arguments);
HRESULT addDurationHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& duration);
+ HRESULT addScenarioHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& scenario);
ComPtr<IToastNotifier> notifier(_In_ bool* succeded) const;
void setError(_Out_opt_ WinToastError* error, _In_ WinToastError value);
};

File diff suppressed because it is too large Load Diff

View File

@ -1,234 +0,0 @@
/* * Copyright (C) 2016-2019 Mohammed Boujemaoui <mohabouje@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef WINTOASTLIB_H
#define WINTOASTLIB_H
#include <Windows.h>
#include <sdkddkver.h>
#include <WinUser.h>
#include <ShObjIdl.h>
#include <wrl/implements.h>
#include <wrl/event.h>
#include <windows.ui.notifications.h>
#include <strsafe.h>
#include <Psapi.h>
#include <ShlObj.h>
#include <roapi.h>
#include <propvarutil.h>
#include <functiondiscoverykeys.h>
#include <iostream>
#include <winstring.h>
#include <string.h>
#include <vector>
#include <map>
using namespace Microsoft::WRL;
using namespace ABI::Windows::Data::Xml::Dom;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::Notifications;
using namespace Windows::Foundation;
namespace WinToastLib {
class IWinToastHandler {
public:
enum WinToastDismissalReason {
UserCanceled = ToastDismissalReason::ToastDismissalReason_UserCanceled,
ApplicationHidden = ToastDismissalReason::ToastDismissalReason_ApplicationHidden,
TimedOut = ToastDismissalReason::ToastDismissalReason_TimedOut
};
virtual ~IWinToastHandler() = default;
virtual void toastActivated() const = 0;
virtual void toastActivated(int actionIndex) const = 0;
virtual void toastDismissed(WinToastDismissalReason state) const = 0;
virtual void toastFailed() const = 0;
};
class WinToastTemplate {
public:
enum class Scenario { Default, Alarm, IncomingCall, Reminder };
enum Duration { System, Short, Long };
enum AudioOption { Default = 0, Silent, Loop };
enum TextField { FirstLine = 0, SecondLine, ThirdLine };
enum WinToastTemplateType {
ImageAndText01 = ToastTemplateType::ToastTemplateType_ToastImageAndText01,
ImageAndText02 = ToastTemplateType::ToastTemplateType_ToastImageAndText02,
ImageAndText03 = ToastTemplateType::ToastTemplateType_ToastImageAndText03,
ImageAndText04 = ToastTemplateType::ToastTemplateType_ToastImageAndText04,
Text01 = ToastTemplateType::ToastTemplateType_ToastText01,
Text02 = ToastTemplateType::ToastTemplateType_ToastText02,
Text03 = ToastTemplateType::ToastTemplateType_ToastText03,
Text04 = ToastTemplateType::ToastTemplateType_ToastText04,
};
enum AudioSystemFile {
DefaultSound,
IM,
Mail,
Reminder,
SMS,
Alarm,
Alarm2,
Alarm3,
Alarm4,
Alarm5,
Alarm6,
Alarm7,
Alarm8,
Alarm9,
Alarm10,
Call,
Call1,
Call2,
Call3,
Call4,
Call5,
Call6,
Call7,
Call8,
Call9,
Call10,
};
WinToastTemplate(_In_ WinToastTemplateType type = WinToastTemplateType::ImageAndText02);
~WinToastTemplate();
void setFirstLine(_In_ const std::wstring& text);
void setSecondLine(_In_ const std::wstring& text);
void setThirdLine(_In_ const std::wstring& text);
void setTextField(_In_ const std::wstring& txt, _In_ TextField pos);
void setAttributionText(_In_ const std::wstring& attributionText);
void setImagePath(_In_ const std::wstring& imgPath);
void setAudioPath(_In_ WinToastTemplate::AudioSystemFile audio);
void setAudioPath(_In_ const std::wstring& audioPath);
void setAudioOption(_In_ WinToastTemplate::AudioOption audioOption);
void setDuration(_In_ Duration duration);
void setExpiration(_In_ INT64 millisecondsFromNow);
void setScenario(_In_ Scenario scenario);
void addAction(_In_ const std::wstring& label);
std::size_t textFieldsCount() const;
std::size_t actionsCount() const;
bool hasImage() const;
const std::vector<std::wstring>& textFields() const;
const std::wstring& textField(_In_ TextField pos) const;
const std::wstring& actionLabel(_In_ std::size_t pos) const;
const std::wstring& imagePath() const;
const std::wstring& audioPath() const;
const std::wstring& attributionText() const;
const std::wstring& scenario() const;
INT64 expiration() const;
WinToastTemplateType type() const;
WinToastTemplate::AudioOption audioOption() const;
Duration duration() const;
private:
std::vector<std::wstring> _textFields{};
std::vector<std::wstring> _actions{};
std::wstring _imagePath{};
std::wstring _audioPath{};
std::wstring _attributionText{};
std::wstring _scenario{L"Default"};
INT64 _expiration{0};
AudioOption _audioOption{WinToastTemplate::AudioOption::Default};
WinToastTemplateType _type{WinToastTemplateType::Text01};
Duration _duration{Duration::System};
};
class WinToast {
public:
enum WinToastError {
NoError = 0,
NotInitialized,
SystemNotSupported,
ShellLinkNotCreated,
InvalidAppUserModelID,
InvalidParameters,
InvalidHandler,
NotDisplayed,
UnknownError
};
enum ShortcutResult {
SHORTCUT_UNCHANGED = 0,
SHORTCUT_WAS_CHANGED = 1,
SHORTCUT_WAS_CREATED = 2,
SHORTCUT_MISSING_PARAMETERS = -1,
SHORTCUT_INCOMPATIBLE_OS = -2,
SHORTCUT_COM_INIT_FAILURE = -3,
SHORTCUT_CREATE_FAILED = -4
};
enum ShortcutPolicy {
/* Don't check, create, or modify a shortcut. */
SHORTCUT_POLICY_IGNORE = 0,
/* Require a shortcut with matching AUMI, don't create or modify an existing one. */
SHORTCUT_POLICY_REQUIRE_NO_CREATE = 1,
/* Require a shortcut with matching AUMI, create if missing, modify if not matching.
* This is the default. */
SHORTCUT_POLICY_REQUIRE_CREATE = 2,
};
WinToast(void);
virtual ~WinToast();
static WinToast* instance();
static bool isCompatible();
static bool isSupportingModernFeatures();
static std::wstring configureAUMI(_In_ const std::wstring& companyName,
_In_ const std::wstring& productName,
_In_ const std::wstring& subProduct = std::wstring(),
_In_ const std::wstring& versionInformation = std::wstring());
static const std::wstring& strerror(_In_ WinToastError error);
virtual bool initialize(_Out_ WinToastError* error = nullptr);
virtual bool isInitialized() const;
virtual bool hideToast(_In_ INT64 id);
virtual INT64 showToast(_In_ const WinToastTemplate& toast, _In_ IWinToastHandler* handler, _Out_ WinToastError* error = nullptr);
virtual void clear();
virtual enum ShortcutResult createShortcut();
const std::wstring& appName() const;
const std::wstring& appUserModelId() const;
void setAppUserModelId(_In_ const std::wstring& aumi);
void setAppName(_In_ const std::wstring& appName);
void setShortcutPolicy(_In_ ShortcutPolicy policy);
protected:
bool _isInitialized{false};
bool _hasCoInitialized{false};
ShortcutPolicy _shortcutPolicy{SHORTCUT_POLICY_REQUIRE_CREATE};
std::wstring _appName{};
std::wstring _aumi{};
std::map<INT64, ComPtr<IToastNotification>> _buffer{};
HRESULT validateShellLinkHelper(_Out_ bool& wasChanged);
HRESULT createShellLinkHelper();
HRESULT setImageFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& path);
HRESULT setAudioFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& path, _In_opt_ WinToastTemplate::AudioOption option = WinToastTemplate::AudioOption::Default);
HRESULT setTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text, _In_ UINT32 pos);
HRESULT setAttributionTextFieldHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& text);
HRESULT addActionHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& action, _In_ const std::wstring& arguments);
HRESULT addDurationHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& duration);
HRESULT addScenarioHelper(_In_ IXmlDocument *xml, _In_ const std::wstring& scenario);
ComPtr<IToastNotifier> notifier(_In_ bool* succeded) const;
void setError(_Out_ WinToastError* error, _In_ WinToastError value);
};
}
#endif // WINTOASTLIB_H

View File

@ -88,9 +88,6 @@ with Files('rlbox_wasm2c_sandbox/**'):
with Files('wasm2c/**'):
BUG_COMPONENT = ('Core', 'Security: RLBox')
with Files('WinToast/**'):
BUG_COMPONENT = ('Toolkit', 'General')
with Files('libsrtp/**'):
BUG_COMPONENT = ('Core', 'WebRTC: Networking')