summaryrefslogtreecommitdiff
path: root/lib/epgservice.c
blob: 69e5a8e41522d3cb3f822de9e768a7afe589d093 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * epgservice.c
 *
 * See the README file for copyright information and how to reach the author.
 *
 */

#include "epgservice.h"

//***************************************************************************
// Timer  State / Action
//***************************************************************************

const char* toName(TimerState s)
{
   switch (s)
   {
      case tsPending:  return "pending";
      case tsRunning:  return "running";
      case tsFinished: return "finished";
      case tsDeleted:  return "deleted";
      case tsError:    return "failed";
      case tsIgnore:   return "ignore";
      case tsUnknown:  return "unknown";
   }

   return "unknown";
}

const char* toName(TimerAction a, int nice)
{
   switch (a)
   {
      case taCreate:  return "create";
      case taModify:  return "modify";
      case taAdjust:  return "adjust";
      case taDelete:  return "delete";
      case taAssumed: return nice ? "-" : "assumed";
      case taFailed:  return "failed";
      case taReject:  return "reject";
   }

   return nice ? "-" : "unknown";
}

//***************************************************************************
// cEpgdState
//***************************************************************************

const char* cEpgdState::states[] =
{
   "init",
   "standby",
   "stopped",

   "busy (events)",
   "busy (match)",
   "busy (scraping)",
   "busy (images)",

   0
};

const char* cEpgdState::toName(cEpgdState::State s)
{
   if (!isValid(s))
      return "unknown";

   return states[s];
}

cEpgdState::State cEpgdState::toState(const char* name)
{
   for (int i = 0; i < esCount; i++)
      if (strcmp(states[i], name) == 0)
         return (State)i;

   return esUnknown;
}

//***************************************************************************
// Field Filter
//***************************************************************************

FieldFilterDef fieldFilters[] =
{
   { ffAll,         "all"     },
   { ffEpgd,        "epgd"    },
   { ffEpgHttpd,    "httpd"   },
   { ffEpg2Vdr,     "epg2vdr" },
   { ffScraper2Vdr, "scraper" },

   { 0,             0 }
};

const char* toName(FieldFilter f)
{
   for (int i = 0; fieldFilters[i].name; i++)
      if (fieldFilters[i].filter == f)
         return fieldFilters[i].name;

   return "unknown";
}

int toFieldFilter(const char* name)
{
   for (int i = 0; fieldFilters[i].name; i++)
      if (strcasecmp(fieldFilters[i].name, name) == 0)
         return fieldFilters[i].filter;

   return ffAll;
}

//***************************************************************************
// User Rights Check
//***************************************************************************

int hasUserMask(unsigned int rights, UserMask mask)
{
   return rights & mask;
}