diff --git a/README.md b/README.md
index 92b4c33..69c21c9 100644
--- a/README.md
+++ b/README.md
@@ -1,75 +1,113 @@
[![binary-factory-status](https://binary-factory.kde.org/job/SnoreToast_Nightly_win64/badge/icon)](https://binary-factory.kde.org/job/SnoreToast_Nightly_win64)
Snoretoast![Logo](data/96-96-snoretoast.png)
==========
A command line application capable of creating Windows Toast notifications on Windows 8 or later.
If SnoreToast is used without the parameter --appID an default appID is used and a shortcut to SnoreToast.exe is created in the startmenu, notifications created that way will be asigned to SnoreToast.
If you want to brand your notifications you need to create the application startmenu entry with `snoretoast.exe --install "MyApp\MyApp.lnk" "C:\myApp.exe" "My.APP_ID"`.
This appID then needs to be passed to snoretoast.exe with the `--appID`` parameter.
# Releases and Binaries
[Get releases and binaries](https://download.kde.org/stable/snoretoast/)
[Get the latest nightly](https://binary-factory.kde.org/job/SnoreToast_Nightly_win64)
# Contact us
- [Repot Bugs](https://bugs.kde.org/enter_bug.cgi?product=Snoretoast)
- [Find us on Irc](http://webchat.freenode.net/?channels=%23kde-windows)
- [Send us a mail](mailto:kde-windows@kde.org)
----------------------------------------------------------
```
-Welcome to SnoreToast 0.7.0. A command line application capable of creating Windows Toast notifications. ---- Usage ---- SnoreToast [Options] ---- Options ---- [-t]
| Displayed on the first line of the toast. [-m] | Displayed on the remaining lines, wrapped. [-b] | Displayed on the bottom line, can list multiple buttons separated by ";" [-tb] | Displayed a textbox on the bottom line, only if buttons are not presented. [-p] | Display toast with an image, local files only. [-id] | sets the id for a notification to be able to close it later. [-s] | Sets the sound of the notifications, for possible values see http://msdn.microsoft.com/en-us/library/windows/apps/hh761492.aspx. [-silent] | Don't play a sound file when showing the notifications. [-appID] | Don't create a shortcut but use the provided app id. [-pid] | Query the appid for the process , use -appID as fallback. (Only relevant for applications that might be packaged for the store) [-pipeName] <\.\pipe\pipeName\> | Provide a name pipe which is used for callbacks. [-application] | Provide a application that might be started if the pipe does not exist. -close | Closes a currently displayed notification. -install | Creates a shortcut in the start menu which point to the executable , appID used for the notifications. -v | Print the version and copying information.
--h | Print these instructions. Same as no args. Exit Status : Exit Code Failed : -1 Success : 0 Hidden : 1 Dismissed : 2 TimedOut : 3 ButtonPressed : 4 TextEntered : 5 ---- Image Notes ---- Images must be .png with: maximum dimensions of 1024x1024 size <= 200kb These limitations are due to the Toast notification system.
+Welcome to SnoreToast 0.7.0.
+A command line application capable of creating Windows Toast notifications.
+Dismissed : 2
+---- Usage ---- : 3
+SnoreToast [Options]
+TextEntered : 5
+---- Options ----
+[-t] -- | Displayed on the first line of the toast.
+[-m] ith| Displayed on the remaining lines, wrapped.
+[-b] | Displayed on the bottom line, can list multiple buttons separated by ";"
+[-tb] size <= 200kb | Displayed a textbox on the bottom line, only if buttons are not presented.
+[-p] s are du| Display toast with an image, local files only.
+[-id] | sets the id for a notification to be able to close it later.
+[-s] | Sets the sound of the notifications, for possible values see http://msdn.microsoft.com/en-us/library/windows/apps/hh761492.aspx.
+[-silent] | Don't play a sound file when showing the notifications.
+[-appID] | Don't create a shortcut but use the provided app id.
+[-pid] | Query the appid for the process , use -appID as fallback. (Only relevant for applications that might be packaged for the store)
+[-pipeName] <\.\pipe\pipeName\> | Provide a name pipe which is used for callbacks.
+[-application] | Provide a application that might be started if the pipe does not exist.
+-close | Closes a currently displayed notification.
+
+-install | Creates a shortcut in the start menu which point to the executable , appID used for the notifications.
+
+-v | Print the version and copying information.
+-h | Print these instructions. Same as no args.
+Exit Status : Exit Code
+Failed : -1
+
+Success : 0
+Hidden : 1
+Dismissed : 2
+TimedOut : 3
+ButtonPressed : 4
+TextEntered : 5
+
+---- Image Notes ----
+Images must be .png with:
+ maximum dimensions of 1024x1024
+ size <= 200kb
+These limitations are due to the Toast notification system.
```
----------------------------------------------------------
# Shortcut creation with Nsis
```
!include LogicLib.nsh
!include WordFunc.nsh
Function SnoreWinVer
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
${VersionCompare} "6.2" $R0 $R0
${If} $R0 == 1
Push "NotWin8"
${Else}
Push "AtLeastWin8"
${EndIf}
FunctionEnd
!macro SnoreShortcut path exe appID
Call SnoreWinVer
Pop $0
${If} $0 == "AtLeastWin8"
nsExec::ExecToLog '"${SnoreToastExe}" -install "${path}" "${exe}" "${appID}"'
${Else}
CreateShortCut "${path}" "${exe}"
${EndIf}
!macroend
```
# Register Snoretoast with Appx
Be sure to also pass the `-pid` to Snoretoast.
```
# https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/send-local-toast-desktop
# TODO: get the correct CLSID from snoretoast
SnoreToast = f"""
```
diff --git a/src/snoretoastactioncenterintegration.h b/src/snoretoastactioncenterintegration.h
index f11ceeb..be79249 100644
--- a/src/snoretoastactioncenterintegration.h
+++ b/src/snoretoastactioncenterintegration.h
@@ -1,79 +1,77 @@
/*
SnoreToast is capable to invoke Windows 8 toast notifications.
Copyright (C) 2019 Hannah von Reth
SnoreToast is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SnoreToast is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SnoreToast. If not, see .
*/
#pragma once
#include
#include
#include
#include
+#define ST_WSTRINGIFY(X) L##X
+#define ST_STRINGIFY(X) ST_WSTRINGIFY(X)
+
typedef struct NOTIFICATION_USER_INPUT_DATA
{
LPCWSTR Key;
LPCWSTR Value;
} NOTIFICATION_USER_INPUT_DATA;
MIDL_INTERFACE("53E31837-6600-4A81-9395-75CFFE746F94")
INotificationActivationCallback : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE Activate(
__RPC__in_string LPCWSTR appUserModelId, __RPC__in_opt_string LPCWSTR invokedArgs,
__RPC__in_ecount_full_opt(count) const NOTIFICATION_USER_INPUT_DATA *data,
ULONG count) = 0;
};
// The COM server which implements the callback notifcation from Action Center
class DECLSPEC_UUID(SNORETOAST_CALLBACK_GUID) SnoreToastActionCenterIntegration
: public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags,
INotificationActivationCallback>
{
public:
static std::wstring uuid()
{
- static std::wstring _uuid = [] {
- std::wstringstream out;
- out << SNORETOAST_CALLBACK_GUID;
- return out.str();
- }();
- return _uuid;
+ return ST_STRINGIFY(SNORETOAST_CALLBACK_GUID);
}
SnoreToastActionCenterIntegration() {}
virtual HRESULT STDMETHODCALLTYPE Activate(__RPC__in_string LPCWSTR appUserModelId,
__RPC__in_opt_string LPCWSTR invokedArgs,
__RPC__in_ecount_full_opt(count)
const NOTIFICATION_USER_INPUT_DATA *data,
ULONG count) override
{
if (invokedArgs == nullptr) {
return S_OK;
}
std::wstringstream msg;
for (ULONG i = 0; i < count; ++i) {
std::wstring tmp = data[i].Value;
// printing \r to stdcout is kind of problematic :D
std::replace(tmp.begin(), tmp.end(), L'\r', L'\n');
msg << tmp;
}
return SnoreToasts::backgroundCallback(appUserModelId, invokedArgs, msg.str());
}
};
CoCreatableClass(SnoreToastActionCenterIntegration);