File: vnsitimer.h

package info (click to toggle)
vdr-plugin-vnsiserver 1%3A1.8.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 660 kB
  • sloc: ansic: 12,328; makefile: 86
file content (84 lines) | stat: -rw-r--r-- 2,126 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 *      vdr-plugin-vnsi - KODI server plugin for VDR
 *
 *      Copyright (C) 2005-2016 Team XBMC
 *
 *      http://kodi.tv
 *
 *  This Program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This Program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with KODI; see the file COPYING.  If not, see
 *  <http://www.gnu.org/licenses/>.
 *
 */

#pragma once

#include "stdint.h"
#include <string>
#include <vector>
#include <atomic>
#include <vdr/channels.h>
#include <vdr/thread.h>

class cEvent;
class cTimers;
class cTimer;

class CVNSITimer
{
public:
  int m_id;
  std::string m_name;
  uint32_t m_channelUID;
  int32_t m_enabled;
  int32_t m_priority;
  int32_t m_lifetime;
  uint32_t m_marginStart;
  uint32_t m_marginEnd;
  std::string m_search;
  tChannelID m_channelID;
  std::vector<time_t> m_timersCreated;
};

class CVNSITimers : public cThread
{
public:
  CVNSITimers();
  void Load();
  void Save();
  void Shutdown();
  void Add(CVNSITimer &&timer);
  void Scan();
  size_t GetTimersCount();
  bool StateChange(int &state);
  std::vector<CVNSITimer> GetTimers();
  bool GetTimer(int id, CVNSITimer &timer);
  bool UpdateTimer(int id, CVNSITimer &timer);
  bool DeleteTimer(int id);
  int GetParent(const cTimer *timer);

  static constexpr uint32_t VNSITIMER_MASK = 0xF0000000;
protected:
  virtual void Action(void) override;
  std::string Convert(std::string search);
  bool IsDuplicateEvent(cTimers *timers, const cEvent *event);
  void DeleteChildren(CVNSITimer &vnsitimer);
  bool IsChild(int id, time_t starttime);

  std::vector<CVNSITimer> m_timers;
  std::atomic_bool m_doScan;
  std::atomic_int m_state;
  cMutex m_timerLock;
  int m_nextId = 0;
};