-
Notifications
You must be signed in to change notification settings - Fork 1
/
monitor.h
95 lines (79 loc) · 2.24 KB
/
monitor.h
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
85
86
87
88
89
90
91
92
93
94
95
#ifndef __DYNAMITEMONITOR_H
#define __DYNAMITEMONITOR_H
#include <vdr/thread.h>
#include <vdr/tools.h>
#include "udev.h"
#define MAXUDEVMONITORS 10
using namespace dynamite;
class cUdevFilter;
class cUdevMonitor : public cThread {
private:
static cMutex mutexMonitors;
static int numMonitors;
static cUdevMonitor *monitors[MAXUDEVMONITORS];
struct udev_monitor *monitor;
int index;
cString subsystem;
cMutex filtersMutex;
cList<cUdevFilter> filters;
cUdevMonitor(const char *Subsystem);
protected:
virtual void Action(void);
public:
static cUdevMonitor *Get(const char *Subsystem);
static bool AddFilter(const char *Subsystem, cUdevFilter *Filter);
static void ShutdownAllMonitors(void);
virtual ~cUdevMonitor(void);
cString GetSubsystem() const { return subsystem; };
bool AddFilter(cUdevFilter *Filter);
bool DelFilter(cUdevFilter *Filter);
};
class cUdevFilter : public cListObject {
friend class cUdevMonitor;
protected:
const cUdevMonitor *monitor;
virtual void Process(const cUdevDevice &Device) = 0;
public:
cUdevFilter(void);
virtual ~cUdevFilter(void);
};
class cUdevLogFilter : public cUdevFilter {
protected:
virtual void Process(const cUdevDevice &Device);
};
class cUdevDvbFilter : public cUdevFilter {
protected:
virtual void Process(const cUdevDevice &Device);
};
class cUdevUsbRemoveFilter : public cUdevFilter {
private:
class cItem : public cListObject {
public:
cString *item;
cString *devpath;
cItem(const char *i, const char *d);
virtual ~cItem(void);
};
static cMutex mutexFilter;
static cUdevUsbRemoveFilter *filter;
cMutex mutexItems;
cList<cItem> items;
protected:
virtual void Process(const cUdevDevice &Device);
public:
static void AddItem(const char *item, const char *devpath);
static void RemoveItem(const char *item, const char *devpath);
};
class cUdevPatternFilter : public cUdevFilter {
public:
static bool AddFilter(const char *Subsystem, const char *Pattern);
protected:
static cMutex filtersMutex;
static cList<cUdevPatternFilter> filters;
virtual ~cUdevPatternFilter(void);
virtual void Process(const cUdevDevice &Device);
private:
cUdevPatternFilter(const char *Pattern);
cString pattern;
};
#endif // __DYNAMITEMONITOR_H