Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PVR] Refactor PVR jobs. Get rid of PVRJobs.(h|cpp).
- Loading branch information
Showing
12 changed files
with
302 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2012-2018 Team Kodi | ||
* This file is part of Kodi - https://kodi.tv | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
* See LICENSES/README.md for more information. | ||
*/ | ||
|
||
#include "PVREventlogJob.h" | ||
|
||
#include "ServiceBroker.h" | ||
#include "dialogs/GUIDialogKaiToast.h" | ||
#include "events/EventLog.h" | ||
#include "events/NotificationEvent.h" | ||
|
||
namespace PVR | ||
{ | ||
CPVREventlogJob::CPVREventlogJob(bool bNotifyUser, bool bError, const std::string& label, const std::string& msg, const std::string& icon) | ||
{ | ||
AddEvent(bNotifyUser, bError, label, msg, icon); | ||
} | ||
|
||
void CPVREventlogJob::AddEvent(bool bNotifyUser, bool bError, const std::string& label, const std::string& msg, const std::string& icon) | ||
{ | ||
m_events.emplace_back(Event(bNotifyUser, bError, label, msg, icon)); | ||
} | ||
|
||
bool CPVREventlogJob::DoWork() | ||
{ | ||
for (const auto& event : m_events) | ||
{ | ||
if (event.m_bNotifyUser) | ||
CGUIDialogKaiToast::QueueNotification( | ||
event.m_bError ? CGUIDialogKaiToast::Error : CGUIDialogKaiToast::Info, event.m_label.c_str(), event.m_msg, 5000, true); | ||
|
||
// Write event log entry. | ||
CServiceBroker::GetEventLog().Add( | ||
EventPtr(new CNotificationEvent(event.m_label, event.m_msg, event.m_icon, event.m_bError ? EventLevel::Error : EventLevel::Information))); | ||
} | ||
return true; | ||
} | ||
|
||
} // namespace PVR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2012-2018 Team Kodi | ||
* This file is part of Kodi - https://kodi.tv | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
* See LICENSES/README.md for more information. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "utils/Job.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace PVR | ||
{ | ||
class CPVREventlogJob : public CJob | ||
{ | ||
public: | ||
CPVREventlogJob() = default; | ||
CPVREventlogJob(bool bNotifyUser, bool bError, const std::string& label, const std::string& msg, const std::string& icon); | ||
~CPVREventlogJob() override = default; | ||
const char* GetType() const override { return "pvr-eventlog-job"; } | ||
|
||
void AddEvent(bool bNotifyUser, bool bError, const std::string& label, const std::string& msg, const std::string& icon); | ||
|
||
bool DoWork() override; | ||
|
||
private: | ||
struct Event | ||
{ | ||
bool m_bNotifyUser; | ||
bool m_bError; | ||
std::string m_label; | ||
std::string m_msg; | ||
std::string m_icon; | ||
|
||
Event(bool bNotifyUser, bool bError, const std::string& label, const std::string& msg, const std::string& icon) | ||
: m_bNotifyUser(bNotifyUser), m_bError(bError), m_label(label), m_msg(msg), m_icon(icon) {} | ||
}; | ||
|
||
std::vector<Event> m_events; | ||
}; | ||
|
||
} // namespace PVR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.