2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "PVREventLogJob.h"
11 #include "ServiceBroker.h"
12 #include "dialogs/GUIDialogKaiToast.h"
13 #include "events/EventLog.h"
14 #include "events/NotificationEvent.h"
19 CPVREventLogJob::CPVREventLogJob(bool bNotifyUser
,
21 const std::string
& label
,
22 const std::string
& msg
,
23 const std::string
& icon
)
25 AddEvent(bNotifyUser
, eLevel
, label
, msg
, icon
);
28 void CPVREventLogJob::AddEvent(bool bNotifyUser
,
30 const std::string
& label
,
31 const std::string
& msg
,
32 const std::string
& icon
)
34 m_events
.emplace_back(bNotifyUser
, eLevel
, label
, msg
, icon
);
37 bool CPVREventLogJob::DoWork()
39 for (const auto& event
: m_events
)
41 if (event
.m_bNotifyUser
)
42 CGUIDialogKaiToast::QueueNotification(event
.m_eLevel
== EventLevel::Error
43 ? CGUIDialogKaiToast::Error
44 : CGUIDialogKaiToast::Info
,
45 event
.m_label
, event
.m_msg
, 5000, true);
47 // Write event log entry.
48 auto eventLog
= CServiceBroker::GetEventLog();
50 eventLog
->Add(std::make_shared
<CNotificationEvent
>(event
.m_label
, event
.m_msg
, event
.m_icon
,