mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-18 11:17:21 +00:00
updated snarl interface
This commit is contained in:
parent
68621627e3
commit
8745c966f5
@ -10,7 +10,7 @@ if(WIN32)
|
||||
add_library(snarl MODULE ${SNARL_SRC} )
|
||||
target_link_libraries(snarl snorecore ${QT_QTCORE_LIBRARY} )
|
||||
if(MINGW)
|
||||
set_target_properties(snarl PROPERTIES COMPILE_FLAGS "-Wno-conversion-null")
|
||||
set_target_properties(snarl PROPERTIES COMPILE_FLAGS "-Wno-conversion-null -Wno-unused")
|
||||
endif(MINGW)
|
||||
|
||||
install(TARGETS snarl ${SNORE_BACKEND_INSTALL_PATH})
|
||||
|
@ -31,6 +31,9 @@
|
||||
/// </summary>
|
||||
///----------------------------------------------------------------------------
|
||||
/// <VersionHistory>
|
||||
/// 2011-07-31 : General update to match VB6 SVN rev. 232
|
||||
/// : Added AppFlags and MessagePriority enums.
|
||||
/// 2011-07-12 : MingW64 fixes by Patrick von Reth
|
||||
/// 2011-07-07 : Some changes to compile under VS2008
|
||||
/// - Changed vector iterators to begin/end instead of cbegin/cend
|
||||
/// - Removed const in PairType
|
||||
@ -93,13 +96,17 @@ LONG32 SnarlInterface::DoRequest(LPCSTR request, UINT replyTimeout)
|
||||
// Send message
|
||||
if (SendMessageTimeout(hWnd, WM_COPYDATA, (WPARAM)GetCurrentProcessId(), (LPARAM)&cds, SMTO_ABORTIFHUNG | SMTO_NOTIMEOUTIFNOTHUNG, replyTimeout, &nResult) == 0)
|
||||
{
|
||||
// Handle error
|
||||
DWORD nError = GetLastError();
|
||||
LONG32 errorResult = 0;
|
||||
if (nError == ERROR_TIMEOUT)
|
||||
nResult = -SnarlEnums::ErrorTimedOut;
|
||||
errorResult = -SnarlEnums::ErrorTimedOut;
|
||||
else
|
||||
nResult = -SnarlEnums::ErrorFailed;
|
||||
}
|
||||
errorResult = -SnarlEnums::ErrorFailed;
|
||||
|
||||
return errorResult;
|
||||
}
|
||||
else
|
||||
return (LONG32)nResult;
|
||||
}
|
||||
|
||||
@ -119,7 +126,6 @@ LONG32 SnarlInterface::DoRequest(LPCWSTR request, UINT replyTimeout)
|
||||
return nResult;
|
||||
}
|
||||
|
||||
|
||||
std::basic_string<char>& SnarlInterface::Escape(std::basic_string<char>& str)
|
||||
{
|
||||
std::basic_string<char>::size_type strLength = str.length();
|
||||
@ -186,7 +192,8 @@ LPCTSTR SnarlInterface::GetIconsPath()
|
||||
return NULL;
|
||||
|
||||
size_t nLen = 0;
|
||||
if (nLen = _tcsnlen(szPath, MAX_PATH))
|
||||
nLen = _tcsnlen(szPath, MAX_PATH);
|
||||
if (nLen > 0)
|
||||
{
|
||||
nLen += 10 + 1; // etc\\icons\\ + NULL
|
||||
szIconPath = AllocateString(nLen);
|
||||
@ -356,14 +363,12 @@ LONG32 SnarlInterface::IsVisible(LONG32 msgToken)
|
||||
}
|
||||
|
||||
|
||||
LONG32 SnarlInterface::Notify(LPCSTR classId, LPCSTR title, LPCSTR text, LONG32 timeout, LPCSTR iconPath, LPCSTR iconBase64, LONG32 priority, LPCSTR ack, LPCSTR callback, LPCSTR value)
|
||||
LONG32 SnarlInterface::Notify(LPCSTR classId, LPCSTR title, LPCSTR text, LONG32 timeout, LPCSTR iconPath, LPCSTR iconBase64, SnarlEnums::MessagePriority priority, LPCSTR uid, LPCSTR callback, LPCSTR value)
|
||||
{
|
||||
// notify?[app-sig=<signature>|token=<application token>][&password=<password>][&id=<class identifier>]
|
||||
// [&title=<title>][&text=<text>][&timeout=<timeout>][&icon=<icon path>][&icon-base64=<MIME data>][&callback=<default callback>]
|
||||
// [&priority=<priority>][&uid=<notification uid>][&value=<value>]
|
||||
|
||||
// LPCSTR iconData
|
||||
|
||||
SnarlParameterList<char> spl(12);
|
||||
spl.Add("token", appToken);
|
||||
spl.Add("password", szPasswordA);
|
||||
@ -373,11 +378,11 @@ LONG32 SnarlInterface::Notify(LPCSTR classId, LPCSTR title, LPCSTR text, LONG32
|
||||
spl.Add("text", text);
|
||||
spl.Add("icon", iconPath);
|
||||
spl.Add("icon-base64", iconBase64);
|
||||
spl.Add("ack", ack);
|
||||
spl.Add("uid", uid);
|
||||
spl.Add("callback", callback);
|
||||
spl.Add("value", value);
|
||||
if (timeout != -1) spl.Add("timeout", timeout);
|
||||
if (priority != -2) spl.Add("priority", priority); // -1 is a legal priority
|
||||
if (priority != SnarlEnums::PriorityUndefined) spl.Add("priority", priority); // -1 is a legal priority
|
||||
|
||||
LONG32 request = DoRequest(Requests::NotifyA(), spl);
|
||||
lastMsgToken = (request > 0) ? request : 0;
|
||||
@ -385,7 +390,7 @@ LONG32 SnarlInterface::Notify(LPCSTR classId, LPCSTR title, LPCSTR text, LONG32
|
||||
return request;
|
||||
}
|
||||
|
||||
LONG32 SnarlInterface::Notify(LPCWSTR classId, LPCWSTR title, LPCWSTR text, LONG32 timeout, LPCWSTR iconPath, LPCWSTR iconBase64, LONG32 priority, LPCWSTR ack, LPCWSTR callback, LPCWSTR value)
|
||||
LONG32 SnarlInterface::Notify(LPCWSTR classId, LPCWSTR title, LPCWSTR text, LONG32 timeout, LPCWSTR iconPath, LPCWSTR iconBase64, SnarlEnums::MessagePriority priority, LPCWSTR uid, LPCWSTR callback, LPCWSTR value)
|
||||
{
|
||||
SnarlParameterList<wchar_t> spl(12);
|
||||
spl.Add(L"token", appToken);
|
||||
@ -396,11 +401,11 @@ LONG32 SnarlInterface::Notify(LPCWSTR classId, LPCWSTR title, LPCWSTR text, LONG
|
||||
spl.Add(L"text", text);
|
||||
spl.Add(L"icon", iconPath);
|
||||
spl.Add(L"icon-base64", iconBase64);
|
||||
spl.Add(L"ack", ack);
|
||||
spl.Add(L"uid", uid);
|
||||
spl.Add(L"callback", callback);
|
||||
spl.Add(L"value", value);
|
||||
if (timeout != -1) spl.Add(L"timeout", timeout);
|
||||
if (priority != -2) spl.Add(L"priority", priority); // -1 is a legal priority
|
||||
if (priority != SnarlEnums::PriorityUndefined) spl.Add(L"priority", priority); // -1 is a legal priority
|
||||
|
||||
LONG32 request = DoRequest(Requests::NotifyW(), spl);
|
||||
lastMsgToken = (request > 0) ? request : 0;
|
||||
@ -409,7 +414,7 @@ LONG32 SnarlInterface::Notify(LPCWSTR classId, LPCWSTR title, LPCWSTR text, LONG
|
||||
}
|
||||
|
||||
|
||||
LONG32 SnarlInterface::Register(LPCSTR signature, LPCSTR title, LPCSTR icon, LPCSTR password, HWND hWndReplyTo, LONG32 msgReply)
|
||||
LONG32 SnarlInterface::Register(LPCSTR signature, LPCSTR title, LPCSTR icon, LPCSTR password, HWND hWndReplyTo, LONG32 msgReply, SnarlEnums::AppFlags flags)
|
||||
{
|
||||
// register?app-sig=<signature>&title=<title>[&icon=<icon>][&password=<password>][&reply-to=<reply window>][&reply=<reply message>]
|
||||
|
||||
@ -420,6 +425,7 @@ LONG32 SnarlInterface::Register(LPCSTR signature, LPCSTR title, LPCSTR icon, LPC
|
||||
spl.Add("password", password);
|
||||
spl.Add("reply-to", hWndReplyTo);
|
||||
spl.Add("reply", msgReply);
|
||||
spl.Add("flags", flags);
|
||||
|
||||
// If password was given, save and use in all other functions requiring password
|
||||
if (password != NULL && strlen(password) > 0)
|
||||
@ -432,7 +438,7 @@ LONG32 SnarlInterface::Register(LPCSTR signature, LPCSTR title, LPCSTR icon, LPC
|
||||
return request;
|
||||
}
|
||||
|
||||
LONG32 SnarlInterface::Register(LPCWSTR signature, LPCWSTR name, LPCWSTR icon, LPCWSTR password, HWND hWndReplyTo, LONG32 msgReply)
|
||||
LONG32 SnarlInterface::Register(LPCWSTR signature, LPCWSTR name, LPCWSTR icon, LPCWSTR password, HWND hWndReplyTo, LONG32 msgReply, SnarlEnums::AppFlags flags)
|
||||
{
|
||||
SnarlParameterList<wchar_t> spl(7);
|
||||
spl.Add(L"app-sig", signature);
|
||||
@ -441,6 +447,7 @@ LONG32 SnarlInterface::Register(LPCWSTR signature, LPCWSTR name, LPCWSTR icon, L
|
||||
spl.Add(L"password", password);
|
||||
spl.Add(L"reply-to", hWndReplyTo);
|
||||
spl.Add(L"reply", msgReply);
|
||||
spl.Add(L"flags", flags);
|
||||
|
||||
// If password was given, save and use in all other functions requiring password
|
||||
if (password != NULL && wcslen(password) > 0)
|
||||
@ -508,10 +515,10 @@ LONG32 SnarlInterface::Unregister(LPCWSTR signature)
|
||||
return DoRequest(Requests::UnregisterW(), spl);
|
||||
}
|
||||
|
||||
LONG32 SnarlInterface::Update(LONG32 msgToken, LPCSTR classId, LPCSTR title, LPCSTR text, LONG32 timeout, LPCSTR iconPath, LPCSTR iconBase64, LONG32 priority, LPCSTR ack, LPCSTR callback, LPCSTR value)
|
||||
LONG32 SnarlInterface::Update(LONG32 msgToken, LPCSTR classId, LPCSTR title, LPCSTR text, LONG32 timeout, LPCSTR iconPath, LPCSTR iconBase64, SnarlEnums::MessagePriority priority, LPCSTR callback, LPCSTR value)
|
||||
{
|
||||
// Made from best guess - no documentation available yet
|
||||
SnarlParameterList<char> spl(12);
|
||||
SnarlParameterList<char> spl(11);
|
||||
spl.Add("token", msgToken);
|
||||
spl.Add("password", szPasswordA);
|
||||
|
||||
@ -520,19 +527,18 @@ LONG32 SnarlInterface::Update(LONG32 msgToken, LPCSTR classId, LPCSTR title, LPC
|
||||
spl.Add("text", text);
|
||||
spl.Add("icon", iconPath);
|
||||
spl.Add("icon-base64", iconBase64);
|
||||
spl.Add("ack", ack);
|
||||
spl.Add("callback", callback);
|
||||
spl.Add("value", value);
|
||||
if (timeout != -1) spl.Add("timeout", timeout);
|
||||
if (priority != -2) spl.Add("priority", priority); // -1 is a legal priority
|
||||
if (priority != SnarlEnums::PriorityUndefined) spl.Add("priority", priority); // -1 is a legal priority
|
||||
|
||||
return DoRequest(Requests::UpdateA(), spl);
|
||||
}
|
||||
|
||||
LONG32 SnarlInterface::Update(LONG32 msgToken, LPCWSTR classId, LPCWSTR title, LPCWSTR text, LONG32 timeout, LPCWSTR iconPath, LPCWSTR iconBase64, LONG32 priority, LPCWSTR ack, LPCWSTR callback, LPCWSTR value)
|
||||
LONG32 SnarlInterface::Update(LONG32 msgToken, LPCWSTR classId, LPCWSTR title, LPCWSTR text, LONG32 timeout, LPCWSTR iconPath, LPCWSTR iconBase64, SnarlEnums::MessagePriority priority, LPCWSTR callback, LPCWSTR value)
|
||||
{
|
||||
// Made from best guess - no documentation available yet
|
||||
SnarlParameterList<wchar_t> spl(12);
|
||||
SnarlParameterList<wchar_t> spl(11);
|
||||
spl.Add(L"token", msgToken);
|
||||
spl.Add(L"password", szPasswordW);
|
||||
|
||||
@ -541,11 +547,10 @@ LONG32 SnarlInterface::Update(LONG32 msgToken, LPCWSTR classId, LPCWSTR title, L
|
||||
spl.Add(L"text", text);
|
||||
spl.Add(L"icon", iconPath);
|
||||
spl.Add(L"icon-base64", iconBase64);
|
||||
spl.Add(L"ack", ack);
|
||||
spl.Add(L"callback", callback);
|
||||
spl.Add(L"value", value);
|
||||
if (timeout != -1) spl.Add(L"timeout", timeout);
|
||||
if (priority != -2) spl.Add(L"priority", priority); // -1 is a legal priority
|
||||
if (priority != SnarlEnums::PriorityUndefined) spl.Add(L"priority", priority); // -1 is a legal priority
|
||||
|
||||
return DoRequest(Requests::UpdateW(), spl);
|
||||
}
|
||||
@ -645,7 +650,7 @@ LPSTR SnarlInterface::WideToUTF8(LPCWSTR szWideStr)
|
||||
if (szWideStr == NULL)
|
||||
return NULL;
|
||||
|
||||
int nSize = WideCharToMultiByte(CP_UTF8, 0, szWideStr, -1, NULL,0, NULL, NULL);
|
||||
int nSize = WideCharToMultiByte(CP_UTF8, 0, szWideStr, -1, NULL, 0, NULL, NULL);
|
||||
LPSTR szUTF8 = new char[nSize];
|
||||
WideCharToMultiByte(CP_UTF8, 0, szWideStr, -1, szUTF8, nSize, NULL, NULL);
|
||||
|
||||
@ -698,3 +703,4 @@ void SnarlInterface::ClearPassword()
|
||||
|
||||
|
||||
}} // namespace Snarl::V42
|
||||
|
||||
|
@ -16,46 +16,51 @@
|
||||
#define SMTO_NOTIMEOUTIFNOTHUNG 8
|
||||
#endif
|
||||
|
||||
|
||||
namespace Snarl {
|
||||
namespace V42 {
|
||||
|
||||
static const LPCTSTR SnarlWindowClass = _T("w>Snarl");
|
||||
static const LPCTSTR SnarlWindowTitle = _T("Snarl");
|
||||
static LPCTSTR SnarlWindowClass = _T("w>Snarl");
|
||||
static LPCTSTR SnarlWindowTitle = _T("Snarl");
|
||||
|
||||
static const LPCTSTR SnarlGlobalMsg = _T("SnarlGlobalEvent");
|
||||
static const LPCTSTR SnarlAppMsg = _T("SnarlAppMessage");
|
||||
static LPCTSTR SnarlGlobalMsg = _T("SnarlGlobalEvent");
|
||||
static LPCTSTR SnarlAppMsg = _T("SnarlAppMessage");
|
||||
|
||||
static const DWORD WM_SNARLTEST = WM_USER + 237;
|
||||
|
||||
/// <summary>Application requests - these values appear in wParam.<para>Application should launch its settings UI</para></summary>
|
||||
static const WPARAM AppDoPrefs = 1;
|
||||
/// <summary>Application requests - these values appear in wParam.<para>Application should show its About... dialog</para></summary>
|
||||
static const WPARAM AppDoAbout = 2;
|
||||
|
||||
|
||||
// Enums put in own namespace, because ANSI C++ doesn't decorate enums with tagname :(
|
||||
namespace SnarlEnums {
|
||||
|
||||
/// <summary>
|
||||
/// Global event identifiers.
|
||||
/// Identifiers marked with a '*' are sent by Snarl in two ways:
|
||||
/// 1. As a broadcast message (uMsg = 'SNARL_GLOBAL_MSG')
|
||||
/// 2. To the window registered in snRegisterConfig() or snRegisterConfig2()
|
||||
/// (uMsg = reply message specified at the time of registering)
|
||||
/// In both cases these values appear in wParam.
|
||||
///
|
||||
/// Identifiers not marked are not broadcast; they are simply sent to the application's registered window.
|
||||
/// Global event identifiers - sent as Windows broadcast messages.
|
||||
/// These values appear in wParam of the message.
|
||||
/// </summary>
|
||||
enum GlobalEvent
|
||||
{
|
||||
SnarlLaunched = 1, // Snarl has just started running*
|
||||
SnarlQuit = 2, // Snarl is about to stop running*
|
||||
SnarlStopped = 3, // sent when stopped by user
|
||||
SnarlStarted = 4, // sent when started by user
|
||||
|
||||
// R2.4 Beta3
|
||||
SnarlUserAway, // away mode was enabled
|
||||
SnarlUserBack, // away mode was disabled
|
||||
SnarlLaunched = 1, // Snarl has just started running
|
||||
SnarlQuit = 2, // Snarl is about to stop running
|
||||
SnarlGlobalStopped = 3, // Sent when stopped by user - Also sent to registered window
|
||||
SnarlGlobalStarted = 4, // Sent when started by user - Also sent to registered window
|
||||
};
|
||||
|
||||
enum SnarlStatus
|
||||
{
|
||||
Success = 0,
|
||||
|
||||
// Snarl-Stopped/Started/UserAway/UserBack is defined in the GlobalEvent struct in VB6 code,
|
||||
// but are sent directly to a registered window, so in C# they are defined here instead.
|
||||
// Implemented as of Snarl R2.4 Beta3
|
||||
SnarlStopped = 3, // Sent when stopped by user - Also sent as broadcast message
|
||||
SnarlStarted, // Sent when started by user - Also sent as broadcast message
|
||||
SnarlUserAway, // Away mode was enabled
|
||||
SnarlUserBack, // Away mode was disabled
|
||||
|
||||
// Win32 callbacks (renamed under V42)
|
||||
CallbackRightClick = 32, // Deprecated as of V42, ex. SNARL_NOTIFICATION_CLICKED/SNARL_NOTIFICATION_CANCELLED
|
||||
CallbackTimedOut,
|
||||
@ -64,7 +69,6 @@ namespace Snarl {
|
||||
CallbackMiddleClick, // Deprecated as of V42
|
||||
CallbackClosed,
|
||||
|
||||
|
||||
// critical errors
|
||||
ErrorFailed = 101, // miscellaneous failure
|
||||
ErrorUnknownCommand, // specified command not recognised
|
||||
@ -73,11 +77,16 @@ namespace Snarl {
|
||||
//105 gen critical #5
|
||||
ErrorBadSocket = 106, // invalid socket (or some other socket-related error)
|
||||
ErrorBadPacket = 107, // badly formed request
|
||||
//108 net critical #3
|
||||
ErrorInvalidArg = 108, // arg supplied was invalid (Added in v42.56)
|
||||
ErrorArgMissing = 109, // required argument missing
|
||||
ErrorSystem, // internal system error
|
||||
//120 libsnarl critical block
|
||||
ErrorAccessDenied = 121, // libsnarl only
|
||||
//130 SNP/3.0-specific
|
||||
ErrorUnsupportedVersion = 131, // requested SNP version is not supported
|
||||
ErrorNoActionsProvided, // empty request
|
||||
ErrorUnsupportedEncryption, // requested encryption type is not supported
|
||||
ErrorUnsupportedHashing, // requested message hashing type is not supported
|
||||
|
||||
// warnings
|
||||
ErrorNotRunning = 201, // Snarl handling window not found
|
||||
@ -91,11 +100,16 @@ namespace Snarl {
|
||||
ErrorDoNotDisturb, // DnD mode is in effect was not logged as missed
|
||||
ErrorCouldNotDisplay, // not enough space on-screen to display notification
|
||||
ErrorAuthFailure, // password mismatch
|
||||
// Release 2.4.2
|
||||
ErrorDiscarded, // discarded for some reason, e.g. foreground app match
|
||||
ErrorNotSubscribed, // subscriber not found
|
||||
|
||||
// informational
|
||||
// code 250 reserved for future use
|
||||
WasMerged = 251, // notification was merged, returned token is the one we merged with
|
||||
|
||||
// callbacks
|
||||
// code 300 reserved for future use
|
||||
NotifyGone = 301, // reserved for future use
|
||||
|
||||
// The following are currently specific to SNP 2.0 and are effectively the
|
||||
@ -106,7 +120,7 @@ namespace Snarl {
|
||||
NotifyInvoked = 304, // note this was "ACK" in a previous life
|
||||
NotifyMenu, // indicates an item was selected from user-defined menu (deprecated as of V42)
|
||||
// SNARL_NOTIFY_EX_CLICK // user clicked the middle mouse button (deprecated as of V42)
|
||||
// SNARL_NOTIFY_CLOSED // user clicked the notification's close gadget
|
||||
NotifyClosed = 307, // // user clicked the notification's close gadget (GNTP only)
|
||||
|
||||
// the following is generic to SNP and the Win32 API
|
||||
NotifyAction = 308, // user picked an action from the list, the data value will indicate which one
|
||||
@ -116,6 +130,29 @@ namespace Snarl {
|
||||
ErrorCppInterface = 1001
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The priority of messages.
|
||||
/// See <cref>http://sourceforge.net/apps/mediawiki/snarlwin/index.php?title=Generic_API#notify</cref>
|
||||
/// </summary>
|
||||
enum MessagePriority
|
||||
{
|
||||
PriorityUndefined = -2,
|
||||
PriorityLow = -1,
|
||||
PriorityNormal = 0,
|
||||
PriorityHigh = 1
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Application flags - features this app supports.
|
||||
/// </summary>
|
||||
enum AppFlags
|
||||
{
|
||||
AppFlagNone = 0,
|
||||
AppHasPrefs = 1,
|
||||
AppHasAbout = 2,
|
||||
AppIsWindowless = 0x8000
|
||||
};
|
||||
|
||||
} // namespace SnarlEnums
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
@ -312,28 +349,28 @@ namespace Snarl {
|
||||
/// <summary>Hide a Snarl notification.</summary>
|
||||
LONG32 Hide(LONG32 msgToken);
|
||||
|
||||
/// <summary>Test if a Snarl notification is visible.</summary>
|
||||
/// <summary>Test if a Snarl notification is visible. If the message is visible the function returns SnarlEnums::Success.</summary>
|
||||
LONG32 IsVisible(LONG32 msgToken);
|
||||
|
||||
/// <summary>Show a Snarl notification.</summary>
|
||||
/// <returns>Returns the notification token or negative on failure.</returns>
|
||||
/// <remarks>You can use <see cref="GetLastMsgToken()" /> to get the last token.</remarks>
|
||||
LONG32 Notify(LPCSTR classId = NULL, LPCSTR title = NULL, LPCSTR text = NULL, LONG32 timeout = -1, LPCSTR iconPath = NULL, LPCSTR iconBase64 = NULL, LONG32 priority = -2, LPCSTR ack = NULL, LPCSTR callback = NULL, LPCSTR value = NULL);
|
||||
LONG32 Notify(LPCWSTR classId = NULL, LPCWSTR title = NULL, LPCWSTR text = NULL, LONG32 timeout = -1, LPCWSTR iconPath = NULL, LPCWSTR iconBase64 = NULL, LONG32 priority = -2, LPCWSTR ack = NULL, LPCWSTR callback = NULL, LPCWSTR value = NULL);
|
||||
LONG32 Notify(LPCSTR classId = NULL, LPCSTR title = NULL, LPCSTR text = NULL, LONG32 timeout = -1, LPCSTR iconPath = NULL, LPCSTR iconBase64 = NULL, SnarlEnums::MessagePriority priority = SnarlEnums::PriorityUndefined, LPCSTR uid = NULL, LPCSTR callback = NULL, LPCSTR value = NULL);
|
||||
LONG32 Notify(LPCWSTR classId = NULL, LPCWSTR title = NULL, LPCWSTR text = NULL, LONG32 timeout = -1, LPCWSTR iconPath = NULL, LPCWSTR iconBase64 = NULL, SnarlEnums::MessagePriority priority = SnarlEnums::PriorityUndefined, LPCWSTR uid = NULL, LPCWSTR callback = NULL, LPCWSTR value = NULL);
|
||||
|
||||
/// <summary>Register application with Snarl.</summary>
|
||||
/// <returns>The application token or negative on failure.</returns>
|
||||
/// <remarks>The application token is saved in SnarlInterface member variable, so just use return value to check for error.</remarks>
|
||||
LONG32 Register(LPCSTR signature, LPCSTR title, LPCSTR icon = NULL, LPCSTR password = NULL, HWND hWndReplyTo = NULL, LONG32 msgReply = 0);
|
||||
LONG32 Register(LPCWSTR signature, LPCWSTR title, LPCWSTR icon = NULL, LPCWSTR password = NULL, HWND hWndReplyTo = NULL, LONG32 msgReply = 0);
|
||||
LONG32 Register(LPCSTR signature, LPCSTR title, LPCSTR icon = NULL, LPCSTR password = NULL, HWND hWndReplyTo = NULL, LONG32 msgReply = 0, SnarlEnums::AppFlags flags = SnarlEnums::AppFlagNone);
|
||||
LONG32 Register(LPCWSTR signature, LPCWSTR title, LPCWSTR icon = NULL, LPCWSTR password = NULL, HWND hWndReplyTo = NULL, LONG32 msgReply = 0, SnarlEnums::AppFlags flags = SnarlEnums::AppFlagNone);
|
||||
|
||||
/// <summary>Remove a notification class added with AddClass().</summary>
|
||||
LONG32 RemoveClass(LPCSTR classId);
|
||||
LONG32 RemoveClass(LPCWSTR classId);
|
||||
|
||||
/// <summary>Update the text or other parameters of a visible Snarl notification.</summary>
|
||||
LONG32 Update(LONG32 msgToken, LPCSTR classId = NULL, LPCSTR title = NULL, LPCSTR text = NULL, LONG32 timeout = -1, LPCSTR iconPath = NULL, LPCSTR iconBase64 = NULL, LONG32 priority = -2, LPCSTR ack = NULL, LPCSTR callback = NULL, LPCSTR value = NULL);
|
||||
LONG32 Update(LONG32 msgToken, LPCWSTR classId = NULL, LPCWSTR title = NULL, LPCWSTR text = NULL, LONG32 timeout = -1, LPCWSTR iconPath = NULL, LPCWSTR iconBase64 = NULL, LONG32 priority = -2, LPCWSTR ack = NULL, LPCWSTR callback = NULL, LPCWSTR value = NULL);
|
||||
LONG32 Update(LONG32 msgToken, LPCSTR classId = NULL, LPCSTR title = NULL, LPCSTR text = NULL, LONG32 timeout = -1, LPCSTR iconPath = NULL, LPCSTR iconBase64 = NULL, SnarlEnums::MessagePriority priority = SnarlEnums::PriorityUndefined, LPCSTR callback = NULL, LPCSTR value = NULL);
|
||||
LONG32 Update(LONG32 msgToken, LPCWSTR classId = NULL, LPCWSTR title = NULL, LPCWSTR text = NULL, LONG32 timeout = -1, LPCWSTR iconPath = NULL, LPCWSTR iconBase64 = NULL, SnarlEnums::MessagePriority priority = SnarlEnums::PriorityUndefined, LPCWSTR callback = NULL, LPCWSTR value = NULL);
|
||||
|
||||
/// <summary>Unregister application with Snarl when application is closing.</summary>
|
||||
LONG32 Unregister(LPCSTR signature);
|
||||
@ -368,3 +405,4 @@ namespace Snarl {
|
||||
} // namespace Snarl
|
||||
|
||||
#endif // SNARL_INTERFACE_V42_H
|
||||
|
||||
|
@ -175,6 +175,20 @@ void SnarlBackend::slotNotify(Notification notification){
|
||||
snarlInterface = m_defautSnarlinetrface;
|
||||
}
|
||||
|
||||
Snarl::V42::SnarlEnums::MessagePriority priority = Snarl::V42::SnarlEnums::PriorityUndefined;
|
||||
switch(notification.priority())
|
||||
{
|
||||
case NotificationEnums::Prioritys::LOW:
|
||||
priority = Snarl::V42::SnarlEnums::PriorityLow;
|
||||
break;
|
||||
case NotificationEnums::Prioritys::NORMAL:
|
||||
priority = Snarl::V42::SnarlEnums::PriorityNormal;
|
||||
break;
|
||||
case NotificationEnums::Prioritys::HIGH:
|
||||
priority = Snarl::V42::SnarlEnums::PriorityHigh;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!m_idMap.contains(notification.id())){
|
||||
ULONG32 id = snarlInterface->Notify(notification.alert().toUtf8().constData(),
|
||||
Notification::toPlainText(notification.title()).toUtf8().constData(),
|
||||
@ -182,7 +196,7 @@ void SnarlBackend::slotNotify(Notification notification){
|
||||
notification.timeout(),
|
||||
notification.icon().isLocalFile()?notification.icon().localUrl().toUtf8().constData():0,
|
||||
!notification.icon().isLocalFile()?notification.icon().imageData().toBase64().constData():0,
|
||||
notification.priority());
|
||||
priority);
|
||||
|
||||
foreach(const Notification::Action *a, notification.actions()){
|
||||
snarlInterface->AddAction(id,a->name.toUtf8().constData(),QString("@").append(QString::number(a->id)).toUtf8().constData());
|
||||
@ -198,7 +212,7 @@ void SnarlBackend::slotNotify(Notification notification){
|
||||
notification.timeout(),
|
||||
notification.icon().isLocalFile()?notification.icon().localUrl().toUtf8().constData():0,
|
||||
!notification.icon().isLocalFile()?notification.icon().imageData().toBase64().constData():0,
|
||||
notification.priority());
|
||||
priority);
|
||||
}
|
||||
startTimeout(notification.id(),notification.timeout());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user