mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 06:35:57 -05:00
Make shell applet popup messages for fatal errors
This commit is contained in:
parent
ec9ab04b40
commit
d8187985e8
@ -19,6 +19,13 @@
|
||||
#include "NotifyIcon.h"
|
||||
#include "FireflyShell.h"
|
||||
|
||||
CNotifyMsg::CNotifyMsg(UINT32 id, UINT32 intval, const CString &strval) {
|
||||
this->id = id;
|
||||
this->intval = intval;
|
||||
this->strval = strval;
|
||||
}
|
||||
|
||||
|
||||
CNotifyIcon::CNotifyIcon()
|
||||
{
|
||||
ZeroMemory(&m_nid, sizeof(NOTIFYICONDATA));
|
||||
@ -79,20 +86,21 @@ void CNotifyIcon::OnClose()
|
||||
GetApplication()->Exit();
|
||||
}
|
||||
|
||||
void CNotifyIcon::PopupBalloon(UINT title_id, UINT text_id, DWORD flags)
|
||||
{
|
||||
void CNotifyIcon::PopupBalloon(CString &title, CString &text, DWORD flags) {
|
||||
m_nid.uFlags |= NIF_INFO;
|
||||
SafeStringCopy(m_nid.szInfoTitle, title, 64);
|
||||
SafeStringCopy(m_nid.szInfo,text, 256);
|
||||
m_nid.dwInfoFlags = flags;
|
||||
m_nid.uTimeout = 10000;
|
||||
Shell_NotifyIcon(NIM_MODIFY, &m_nid);
|
||||
}
|
||||
|
||||
void CNotifyIcon::PopupBalloon(UINT title_id, UINT text_id, DWORD flags) {
|
||||
CString title, text;
|
||||
title.LoadString(title_id);
|
||||
text.LoadString(text_id);
|
||||
|
||||
m_nid.uFlags |= NIF_INFO;
|
||||
|
||||
SafeStringCopy(m_nid.szInfoTitle, title, 64);
|
||||
SafeStringCopy(m_nid.szInfo, text, 256);
|
||||
|
||||
m_nid.dwInfoFlags = flags;
|
||||
m_nid.uTimeout = 10000;
|
||||
Shell_NotifyIcon(NIM_MODIFY, &m_nid);
|
||||
PopupBalloon(title, text, flags);
|
||||
}
|
||||
|
||||
void CNotifyIcon::Update()
|
||||
@ -205,17 +213,16 @@ LRESULT CNotifyIcon::OnRegisteredActivation(UINT, WPARAM, LPARAM, BOOL &bHandled
|
||||
return m_registered_activation_message;
|
||||
}
|
||||
|
||||
void CNotifyIcon::OnServerEvent(UINT32 id, UINT32 intval, const CString &strval)
|
||||
{
|
||||
void CNotifyIcon::OnServerEvent(UINT32 id, UINT32 intval, const CString &strval) {
|
||||
// Note that we're running on a different thread here. We need to punt
|
||||
// the event over to the main thread using SendMessage.
|
||||
switch (id)
|
||||
{
|
||||
CNotifyMsg *pMsgNew = new CNotifyMsg(id, intval,strval);
|
||||
|
||||
switch (id) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
SendMessage(WM_SERVEREVENT, id);
|
||||
SendMessage(WM_SERVEREVENT, id, (LPARAM) pMsgNew);
|
||||
break;
|
||||
default:
|
||||
ATLASSERT(false);
|
||||
@ -223,11 +230,21 @@ void CNotifyIcon::OnServerEvent(UINT32 id, UINT32 intval, const CString &strval)
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CNotifyIcon::OnServerEvent(UINT, WPARAM wparam, LPARAM, BOOL &bHandled)
|
||||
{
|
||||
LRESULT CNotifyIcon::OnServerEvent(UINT, WPARAM wparam, LPARAM lparam, BOOL &bHandled) {
|
||||
CNotifyMsg *pMsgNotify = (CNotifyMsg *)lparam;
|
||||
bHandled = true;
|
||||
switch (wparam)
|
||||
{
|
||||
CString title;
|
||||
|
||||
title.LoadString(IDR_MAINFRAME);
|
||||
|
||||
// CString title, text;
|
||||
// title.LoadString(title_id);
|
||||
|
||||
switch (wparam) {
|
||||
case 0:
|
||||
if(pMsgNotify->GetIntval() == 0)
|
||||
PopupBalloon(title,pMsgNotify->GetStrval());
|
||||
break;
|
||||
case 1:
|
||||
PopupBalloon(IDR_MAINFRAME, IDS_SCAN_START);
|
||||
break;
|
||||
@ -235,6 +252,7 @@ LRESULT CNotifyIcon::OnServerEvent(UINT, WPARAM wparam, LPARAM, BOOL &bHandled)
|
||||
PopupBalloon(IDR_MAINFRAME, IDS_SCAN_STOP);
|
||||
break;
|
||||
}
|
||||
delete(pMsgNotify);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,18 @@
|
||||
#include "ServiceControl.h"
|
||||
#include "ServerEvents.h"
|
||||
|
||||
class CNotifyMsg {
|
||||
UINT32 id;
|
||||
UINT32 intval;
|
||||
CString strval;
|
||||
|
||||
public:
|
||||
CNotifyMsg(UINT32 id, UINT32 intval, const CString &strval);
|
||||
CString &GetStrval(void) { return strval; };
|
||||
UINT32 GetIntval(void) { return intval; };
|
||||
};
|
||||
|
||||
|
||||
class CNotifyIcon
|
||||
: public CWindowImpl<CNotifyIcon>,
|
||||
public ServiceStatusObserver,
|
||||
@ -60,6 +72,7 @@ class CNotifyIcon
|
||||
void OnClose();
|
||||
|
||||
void PopupBalloon(UINT title_id, UINT text_id, DWORD flags = NIIF_INFO);
|
||||
void PopupBalloon(CString &title, CString &text, DWORD flags = NIIF_INFO);
|
||||
|
||||
void InflictIconState();
|
||||
void Update();
|
||||
|
Loading…
Reference in New Issue
Block a user