| 1 |
/* |
| 2 |
* Copyright (C) 2015-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#pragma once |
| 10 |
|
| 11 |
#include "events/IEvent.h" |
| 12 |
#include "threads/CriticalSection.h" |
| 13 |
|
| 14 |
#include <map> |
| 15 |
#include <string> |
| 16 |
#include <vector> |
| 17 |
|
| 18 |
#define NOTIFICATION_DISPLAY_TIME 5000 |
| 19 |
#define NOTIFICATION_MESSAGE_TIME 1000 |
| 20 |
|
| 21 |
typedef std::vector<EventPtr> Events; |
| 22 |
|
| 23 |
class CEventLog |
| 24 |
{ |
| 25 |
public: |
| 26 |
CEventLog() = default; |
| 27 |
CEventLog(const CEventLog&) = delete; |
| 28 |
CEventLog& operator=(CEventLog const&) = delete; |
| 29 |
~CEventLog() = default; |
| 30 |
|
| 31 |
Events Get() const; |
| 32 |
Events Get(EventLevel level, bool includeHigherLevels = false) const; |
| 33 |
EventPtr Get(const std::string& eventIdentifier) const; |
| 34 |
|
| 35 |
void Add(const EventPtr& event); |
| 36 |
void Add(const EventPtr& event, bool withNotification, bool withSound = true); |
| 37 |
void AddWithNotification(const EventPtr& event, |
| 38 |
unsigned int displayTime = NOTIFICATION_DISPLAY_TIME, |
| 39 |
unsigned int messageTime = NOTIFICATION_MESSAGE_TIME, |
| 40 |
bool withSound = true); |
| 41 |
void AddWithNotification(const EventPtr& event, bool withSound); |
| 42 |
void Remove(const EventPtr& event); |
| 43 |
void Remove(const std::string& eventIdentifier); |
| 44 |
void Clear(); |
| 45 |
void Clear(EventLevel level, bool includeHigherLevels = false); |
| 46 |
|
| 47 |
bool Execute(const std::string& eventIdentifier); |
| 48 |
|
| 49 |
static std::string EventLevelToString(EventLevel level); |
| 50 |
static EventLevel EventLevelFromString(const std::string& level); |
| 51 |
|
| 52 |
void ShowFullEventLog(EventLevel level = EventLevel::Basic, bool includeHigherLevels = true); |
| 53 |
|
| 54 |
private: |
| 55 |
void SendMessage(const EventPtr& event, int message); |
| 56 |
|
| 57 |
typedef std::vector<EventPtr> EventsList; |
| 58 |
typedef std::map<std::string, EventPtr> EventsMap; |
| 59 |
EventsList m_events; |
| 60 |
EventsMap m_eventsMap; |
| 61 |
mutable CCriticalSection m_critical; |
| 62 |
}; |