summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann Friedrichs <johann.friedrichs@web.de>2018-03-21 11:14:55 (GMT)
committerJohann Friedrichs <johann.friedrichs@web.de>2018-03-21 11:14:55 (GMT)
commite8a0e569152c50d6084f252d12854b8fd4e74466 (patch)
tree5a90ef7ea08ff2096df157ca109c5268cdc04903
parent9c7d95ff8d6ba965cb23147507a859b1fd0491d6 (diff)
downloadvdr-plugin-epgsearch-e8a0e569152c50d6084f252d12854b8fd4e74466.tar.gz
vdr-plugin-epgsearch-e8a0e569152c50d6084f252d12854b8fd4e74466.tar.bz2
unified indentation
-rw-r--r--afuzzy.c377
-rw-r--r--afuzzy.h31
-rw-r--r--blacklist.c1150
-rw-r--r--blacklist.h119
-rw-r--r--changrp.c590
-rw-r--r--changrp.h64
-rw-r--r--confdloader.c153
-rw-r--r--confdloader.h11
-rw-r--r--conflictcheck.c1158
-rw-r--r--conflictcheck.h324
-rw-r--r--conflictcheck_thread.c164
-rw-r--r--conflictcheck_thread.h9
-rw-r--r--conflictcheckonly.c93
-rw-r--r--createcats.c398
-rw-r--r--distance.c183
-rw-r--r--distance.h14
-rw-r--r--epgsearch.c1000
-rw-r--r--epgsearch.h3
-rw-r--r--epgsearchcats.c184
-rw-r--r--epgsearchcats.h46
-rw-r--r--epgsearchcfg.c187
-rw-r--r--epgsearchcfg.h68
-rw-r--r--epgsearchext.c2846
-rw-r--r--epgsearchext.h312
-rw-r--r--epgsearchonly.c39
-rw-r--r--epgsearchservices.h4
-rw-r--r--epgsearchsetup.c1008
-rw-r--r--epgsearchsetup.h72
-rw-r--r--epgsearchsvdrp.c2127
-rw-r--r--epgsearchtools.c1436
-rw-r--r--epgsearchtools.h101
-rw-r--r--log.h123
-rw-r--r--mail.c377
-rw-r--r--mail.h38
-rw-r--r--main.c8
-rw-r--r--mainmenushortcut.c64
-rw-r--r--mainmenushortcut.h42
-rw-r--r--md5.c316
-rw-r--r--md5.h86
-rw-r--r--menu_announcelist.c252
-rw-r--r--menu_announcelist.h40
-rw-r--r--menu_blacklistedit.c600
-rw-r--r--menu_blacklistedit.h45
-rw-r--r--menu_blacklists.c201
-rw-r--r--menu_blacklists.h9
-rw-r--r--menu_commands.c453
-rw-r--r--menu_commands.h35
-rw-r--r--menu_conflictcheck.c515
-rw-r--r--menu_conflictcheck.h16
-rw-r--r--menu_deftimercheckmethod.c114
-rw-r--r--menu_deftimercheckmethod.h15
-rw-r--r--menu_dirselect.c310
-rw-r--r--menu_dirselect.h25
-rw-r--r--menu_event.c305
-rw-r--r--menu_event.h144
-rw-r--r--menu_favorites.c245
-rw-r--r--menu_favorites.h13
-rw-r--r--menu_main.c809
-rw-r--r--menu_main.h57
-rw-r--r--menu_myedittimer.c674
-rw-r--r--menu_myedittimer.h63
-rw-r--r--menu_quicksearch.c436
-rw-r--r--menu_quicksearch.h5
-rw-r--r--menu_recsdone.c190
-rw-r--r--menu_recsdone.h19
-rw-r--r--menu_search.c302
-rw-r--r--menu_search.h23
-rw-r--r--menu_searchactions.c194
-rw-r--r--menu_searchactions.h19
-rw-r--r--menu_searchedit.c1902
-rw-r--r--menu_searchedit.h132
-rw-r--r--menu_searchresults.c1336
-rw-r--r--menu_searchresults.h69
-rw-r--r--menu_searchtemplate.c303
-rw-r--r--menu_searchtemplate.h9
-rw-r--r--menu_switchtimers.c233
-rw-r--r--menu_switchtimers.h14
-rw-r--r--menu_templateedit.c455
-rw-r--r--menu_templateedit.h9
-rw-r--r--menu_timersdone.c269
-rw-r--r--menu_timersdone.h16
-rw-r--r--menu_whatson.c1381
-rw-r--r--menu_whatson.h113
-rw-r--r--noannounce.c150
-rw-r--r--noannounce.h12
-rw-r--r--pending_notifications.c179
-rw-r--r--pending_notifications.h73
-rw-r--r--quickepgsearch.c28
-rw-r--r--rcfile.c95
-rw-r--r--rcfile.h23
-rw-r--r--recdone.c582
-rw-r--r--recdone.h25
-rw-r--r--recdone_thread.c97
-rw-r--r--recdone_thread.h19
-rw-r--r--recstatus.c134
-rw-r--r--recstatus.h13
-rw-r--r--searchtimer_thread.c1708
-rw-r--r--searchtimer_thread.h16
-rw-r--r--services.c440
-rw-r--r--services.h188
-rw-r--r--svdrpclient.h196
-rw-r--r--switchtimer.c178
-rw-r--r--switchtimer.h2
-rw-r--r--switchtimer_thread.c208
-rw-r--r--switchtimer_thread.h9
-rw-r--r--templatefile.c321
-rw-r--r--templatefile.h57
-rw-r--r--timer_thread.c80
-rw-r--r--timer_thread.h35
-rw-r--r--timerdone.c263
-rw-r--r--timerdone.h8
-rw-r--r--timerstatus.c16
-rw-r--r--timerstatus.h14
-rw-r--r--uservars.c544
-rw-r--r--uservars.h1208
-rw-r--r--varparser.c304
-rw-r--r--varparser.h26
117 files changed, 16826 insertions, 18119 deletions
diff --git a/afuzzy.c b/afuzzy.c
index 977f12f..25d434c 100644
--- a/afuzzy.c
+++ b/afuzzy.c
@@ -31,241 +31,224 @@ static int afuzzy_checkFLT(const char *t, AFUZZY *fuzzy);
/******************************************************************************
FUNCTION afuzzy_init()
- Initialization of the fuzzy search routine. This applies to the consequent
- calls of the afuzzy_CheckRTR (whole string matching) and afuzzy_CheckSUB
- (substring match) routines. afuzzy_init() should be called for each
- new pattern or error length. The search is case sensitive
+ Initialization of the fuzzy search routine. This applies to the consequent
+ calls of the afuzzy_CheckRTR (whole string matching) and afuzzy_CheckSUB
+ (substring match) routines. afuzzy_init() should be called for each
+ new pattern or error length. The search is case sensitive
ARGUMENTS:
- p Pattern
- kerr Number of possible errors. Shouldn't exceed pattern length
- UseFilter Use agrep filter algorithm that speeds up search.
- fuzzy pointer to the structure that will be later passes to Check*
- (the first 6 elements should be NULLs for the first call)
+ p Pattern
+ kerr Number of possible errors. Shouldn't exceed pattern length
+ UseFilter Use agrep filter algorithm that speeds up search.
+ fuzzy pointer to the structure that will be later passes to Check*
+ (the first 6 elements should be NULLs for the first call)
RETURN VALUE:
- none
+ none
ALGORITHM
- see. the article on agrep algorithms.
- The only change is accounting transpositions as one edit operation .
+ see. the article on agrep algorithms.
+ The only change is accounting transpositions as one edit operation .
******************************************************************************/
void afuzzy_init(const char *p, int kerr, int UseFilter, AFUZZY *fuzzy)
{
- int cnt, p_len, i, l, d, m;
- char PatFilter[sizeof(Uint)*8 + 1];
-
- fuzzy->k = kerr;
- m = strlen(p);
- fuzzy->FilterSet = 0;
- memset(fuzzy->Map, 0 , sizeof(fuzzy->Map) );
-
- if (fuzzy->S)
- free(fuzzy->S);
- if (fuzzy->R)
- free(fuzzy->R);
- if (fuzzy->R1)
- free(fuzzy->R1);
- if (fuzzy->RP)
- free(fuzzy->RP);
- if (fuzzy->RI)
- free(fuzzy->RI);
- if (fuzzy->FilterS)
- free(fuzzy->FilterS);
-
- fuzzy->FilterS = NULL;
- fuzzy->S = (Uint *)calloc(m + 1, sizeof(Uint));
- fuzzy->R = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
- fuzzy->R1 = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
- fuzzy->RI = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
- fuzzy->RP = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
-
- for (i = 0, cnt = 0; i < m; i++)
- {
- l = fuzzy->Map[(unsigned char)p[i]];
- if (!l)
- {
- l = fuzzy->Map[(unsigned char)p[i]] = ++cnt;
- fuzzy->S[l] = 0;
- }
- fuzzy->S[l] |= 1 << i;
- }
-
-
- for (d = 0; d <= fuzzy->k; d++)
- fuzzy->RI[d] = (1 << d) - 1;
-
- fuzzy->mask_ok = (1 << (m - 1));
- fuzzy->r_size = sizeof(Uint) * (fuzzy->k + 1);
- p_len = m;
-
- if (p_len > (int) sizeof(Uint)*8)
- p_len = (int) sizeof(Uint)*8;
-
- /* If k is zero then no filter is needed! */
- if (fuzzy->k && (p_len >= 2*(fuzzy->k + 1)) )
- {
- if (UseFilter)
- {
- fuzzy->FilterSet = 1;
- memset(fuzzy->FilterMap, 0 , sizeof(fuzzy->FilterMap) );
- fuzzy->FilterS = (Uint *)calloc(m + 1, sizeof(Uint));
-
- /* Not let's fill the interleaved pattern */
- int dd = p_len / (fuzzy->k + 1);
- p_len = dd * (fuzzy->k + 1);
-
- for (i = 0, cnt = 0; i < dd; i++)
- for (int j = 0; j < fuzzy->k + 1; j++, cnt++)
- PatFilter[cnt] = (unsigned char)p[j*dd + i];
- PatFilter[p_len] = 0;
-
- for (i = 0, cnt = 0; i < p_len; i++)
- {
- l = fuzzy->FilterMap[(unsigned char)PatFilter[i]];
- if (!l)
- {
- l = fuzzy->FilterMap[(unsigned char)PatFilter[i]] = ++cnt;
- fuzzy->FilterS[l] = 0;
- }
- fuzzy->FilterS[l] |= 1 << i;
- }
- fuzzy->filter_ok = 0;
- for (i = p_len - fuzzy->k - 1; i <= p_len - 1; i++) /* k+1 times */
- fuzzy->filter_ok |= 1 << i;
-
- /* k+1 first bits set to 1 */
- fuzzy->filter_shift = (1 << (fuzzy->k + 2)) - 1;
- }
- }
+ int cnt, p_len, i, l, d, m;
+ char PatFilter[sizeof(Uint) * 8 + 1];
+
+ fuzzy->k = kerr;
+ m = strlen(p);
+ fuzzy->FilterSet = 0;
+ memset(fuzzy->Map, 0 , sizeof(fuzzy->Map));
+
+ if (fuzzy->S)
+ free(fuzzy->S);
+ if (fuzzy->R)
+ free(fuzzy->R);
+ if (fuzzy->R1)
+ free(fuzzy->R1);
+ if (fuzzy->RP)
+ free(fuzzy->RP);
+ if (fuzzy->RI)
+ free(fuzzy->RI);
+ if (fuzzy->FilterS)
+ free(fuzzy->FilterS);
+
+ fuzzy->FilterS = NULL;
+ fuzzy->S = (Uint *)calloc(m + 1, sizeof(Uint));
+ fuzzy->R = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
+ fuzzy->R1 = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
+ fuzzy->RI = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
+ fuzzy->RP = (Uint *)calloc(fuzzy->k + 1, sizeof(Uint));
+
+ for (i = 0, cnt = 0; i < m; i++) {
+ l = fuzzy->Map[(unsigned char)p[i]];
+ if (!l) {
+ l = fuzzy->Map[(unsigned char)p[i]] = ++cnt;
+ fuzzy->S[l] = 0;
+ }
+ fuzzy->S[l] |= 1 << i;
+ }
+
+
+ for (d = 0; d <= fuzzy->k; d++)
+ fuzzy->RI[d] = (1 << d) - 1;
+
+ fuzzy->mask_ok = (1 << (m - 1));
+ fuzzy->r_size = sizeof(Uint) * (fuzzy->k + 1);
+ p_len = m;
+
+ if (p_len > (int) sizeof(Uint) * 8)
+ p_len = (int) sizeof(Uint) * 8;
+
+ /* If k is zero then no filter is needed! */
+ if (fuzzy->k && (p_len >= 2 * (fuzzy->k + 1))) {
+ if (UseFilter) {
+ fuzzy->FilterSet = 1;
+ memset(fuzzy->FilterMap, 0 , sizeof(fuzzy->FilterMap));
+ fuzzy->FilterS = (Uint *)calloc(m + 1, sizeof(Uint));
+
+ /* Not let's fill the interleaved pattern */
+ int dd = p_len / (fuzzy->k + 1);
+ p_len = dd * (fuzzy->k + 1);
+
+ for (i = 0, cnt = 0; i < dd; i++)
+ for (int j = 0; j < fuzzy->k + 1; j++, cnt++)
+ PatFilter[cnt] = (unsigned char)p[j * dd + i];
+ PatFilter[p_len] = 0;
+
+ for (i = 0, cnt = 0; i < p_len; i++) {
+ l = fuzzy->FilterMap[(unsigned char)PatFilter[i]];
+ if (!l) {
+ l = fuzzy->FilterMap[(unsigned char)PatFilter[i]] = ++cnt;
+ fuzzy->FilterS[l] = 0;
+ }
+ fuzzy->FilterS[l] |= 1 << i;
+ }
+ fuzzy->filter_ok = 0;
+ for (i = p_len - fuzzy->k - 1; i <= p_len - 1; i++) /* k+1 times */
+ fuzzy->filter_ok |= 1 << i;
+
+ /* k+1 first bits set to 1 */
+ fuzzy->filter_shift = (1 << (fuzzy->k + 2)) - 1;
+ }
+ }
}
/******************************************************************************
FUNCTION afuzzy_free()
- Cleaning up after previous afuzzy_init() call.
+ Cleaning up after previous afuzzy_init() call.
ARGUMENTS:
- fuzzy pointer to the afuzzy parameters structure
+ fuzzy pointer to the afuzzy parameters structure
RETURN VALUE:
- none
+ none
******************************************************************************/
void afuzzy_free(AFUZZY *fuzzy)
{
- if (fuzzy->S)
- {
- free(fuzzy->S);
- fuzzy->S = NULL;
- }
- if (fuzzy->R)
- {
- free(fuzzy->R);
- fuzzy->R = NULL;
- }
- if (fuzzy->R1)
- {
- free(fuzzy->R1);
- fuzzy->R1 = NULL;
- }
- if (fuzzy->RP)
- {
- free(fuzzy->RP);
- fuzzy->RP = NULL;
- }
- if (fuzzy->RI)
- {
- free(fuzzy->RI);
- fuzzy->RI = NULL;
- }
- if (fuzzy->FilterS)
- {
- free(fuzzy->FilterS);
- fuzzy->FilterS = NULL;
- }
+ if (fuzzy->S) {
+ free(fuzzy->S);
+ fuzzy->S = NULL;
+ }
+ if (fuzzy->R) {
+ free(fuzzy->R);
+ fuzzy->R = NULL;
+ }
+ if (fuzzy->R1) {
+ free(fuzzy->R1);
+ fuzzy->R1 = NULL;
+ }
+ if (fuzzy->RP) {
+ free(fuzzy->RP);
+ fuzzy->RP = NULL;
+ }
+ if (fuzzy->RI) {
+ free(fuzzy->RI);
+ fuzzy->RI = NULL;
+ }
+ if (fuzzy->FilterS) {
+ free(fuzzy->FilterS);
+ fuzzy->FilterS = NULL;
+ }
}
/******************************************************************************
FUNCTION afuzzy_CheckSUB()
- Perform a fuzzy pattern substring matching. afuzzy_init() should be
- called previously to initialize the pattern and error length.
- Positive result means that some part of the string given matches the
- pattern with no more than afuzzy->k errors (1 error = 1 letter
- replacement or transposition)
+ Perform a fuzzy pattern substring matching. afuzzy_init() should be
+ called previously to initialize the pattern and error length.
+ Positive result means that some part of the string given matches the
+ pattern with no more than afuzzy->k errors (1 error = 1 letter
+ replacement or transposition)
ARGUMENTS:
- t the string to test
- fuzzy pointer to the afuzzy parameters structure
+ t the string to test
+ fuzzy pointer to the afuzzy parameters structure
RETURN VALUE:
- 0 - no match
- > 0 - strings match
+ 0 - no match
+ > 0 - strings match
ALGORITHM
- ????????????????
+ ????????????????
******************************************************************************/
int afuzzy_checkSUB(const char *t, AFUZZY *fuzzy)
{
- register char c;
- register int j, d;
-
- /* For eficciency this case should be little bit optimized */
- if (!fuzzy->k)
- {
- Uint R = 0, R1;
-
- for (j = 0; (c = t[j]) != '\0'; j++)
- {
- R1 = ( ((R<<1) | 1) & fuzzy->S[fuzzy->Map[(unsigned char)c]]);
- R = R1;
-
- if (R1 & fuzzy->mask_ok)
- return 1;
- } /* end for (register int j = 0 ... */
- return 0;
- }
-
- if (fuzzy->FilterSet && !afuzzy_checkFLT(t, fuzzy))
- return 0;
-
- memcpy(fuzzy->R, fuzzy->RI, fuzzy->r_size); /* R = RI */
-
- for (j = 0; (c = t[j]); j++)
- {
- for (d = 0; d <= fuzzy->k; d++)
- {
- fuzzy->R1[d] = (((fuzzy->R[d]<<1) | 1) &
- fuzzy->S[fuzzy->Map[(unsigned char)c]]);
- if (d > 0)
- fuzzy->R1[d] |= ((fuzzy->R[d-1] | fuzzy->R1[d-1])<<1) | 1 |
- fuzzy->R[d-1];
- }
- if (fuzzy->R1[fuzzy->k] & fuzzy->mask_ok)
- return j;
-
- memcpy(fuzzy->R, fuzzy->R1, fuzzy->r_size);
-
- } /* end for (register int j = 0 ... */
-
- return 0;
+ register char c;
+ register int j, d;
+
+ /* For eficciency this case should be little bit optimized */
+ if (!fuzzy->k) {
+ Uint R = 0, R1;
+
+ for (j = 0; (c = t[j]) != '\0'; j++) {
+ R1 = (((R << 1) | 1) & fuzzy->S[fuzzy->Map[(unsigned char)c]]);
+ R = R1;
+
+ if (R1 & fuzzy->mask_ok)
+ return 1;
+ } /* end for (register int j = 0 ... */
+ return 0;
+ }
+
+ if (fuzzy->FilterSet && !afuzzy_checkFLT(t, fuzzy))
+ return 0;
+
+ memcpy(fuzzy->R, fuzzy->RI, fuzzy->r_size); /* R = RI */
+
+ for (j = 0; (c = t[j]); j++) {
+ for (d = 0; d <= fuzzy->k; d++) {
+ fuzzy->R1[d] = (((fuzzy->R[d] << 1) | 1) &
+ fuzzy->S[fuzzy->Map[(unsigned char)c]]);
+ if (d > 0)
+ fuzzy->R1[d] |= ((fuzzy->R[d - 1] | fuzzy->R1[d - 1]) << 1) | 1 |
+ fuzzy->R[d - 1];
+ }
+ if (fuzzy->R1[fuzzy->k] & fuzzy->mask_ok)
+ return j;
+
+ memcpy(fuzzy->R, fuzzy->R1, fuzzy->r_size);
+
+ } /* end for (register int j = 0 ... */
+
+ return 0;
}
static int afuzzy_checkFLT(const char *t, AFUZZY *fuzzy)
{
- register Uint FilterR = 0;
- register Uint FilterR1;
- register int j;
-
- for (j = 0; t[j] != '\0'; j++)
- {
- FilterR1 = ( ((FilterR<<(fuzzy->k+1)) | fuzzy->filter_shift) &
- fuzzy->FilterS[fuzzy->FilterMap[(unsigned char)t[j]]]);
- if (FilterR1 & fuzzy->filter_ok)
- return 1;
- FilterR = FilterR1;
- } /* end for (register int j = 0 ... */
-
- return 0;
+ register Uint FilterR = 0;
+ register Uint FilterR1;
+ register int j;
+
+ for (j = 0; t[j] != '\0'; j++) {
+ FilterR1 = (((FilterR << (fuzzy->k + 1)) | fuzzy->filter_shift) &
+ fuzzy->FilterS[fuzzy->FilterMap[(unsigned char)t[j]]]);
+ if (FilterR1 & fuzzy->filter_ok)
+ return 1;
+ FilterR = FilterR1;
+ } /* end for (register int j = 0 ... */
+
+ return 0;
}
diff --git a/afuzzy.h b/afuzzy.h
index 37dbee8..2a04734 100644
--- a/afuzzy.h
+++ b/afuzzy.h
@@ -37,23 +37,22 @@ typedef unsigned int Uint;
#define MaxPatSize (sizeof(Uint) * 8)
-typedef struct
-{
- Uint *R,
- *R1,
- *RP,
- *S,
- *RI;
- Uint *FilterS;
+typedef struct {
+ Uint *R,
+ *R1,
+ *RP,
+ *S,
+ *RI;
+ Uint *FilterS;
- int Map[256];
- int FilterMap[256];
- int k;
- Uint mask_ok;
- Uint filter_ok;
- Uint filter_shift;
- int r_size;
- int FilterSet;
+ int Map[256];
+ int FilterMap[256];
+ int k;
+ Uint mask_ok;
+ Uint filter_ok;
+ Uint filter_shift;
+ int r_size;
+ int FilterSet;
} AFUZZY;
void afuzzy_init(const char *p, int kerr, int UseFilter, AFUZZY *fuzzy);
diff --git a/blacklist.c b/blacklist.c
index e32f046..53f0cca 100644
--- a/blacklist.c
+++ b/blacklist.c
@@ -47,11 +47,11 @@ cBlacklist::cBlacklist(void)
startTime = 0000;
stopTime = 2359;
useChannel = false;
- {
+ {
LOCK_CHANNELS_READ;
channelMin = Channels->GetByNumber(cDevice::CurrentChannel());
channelMax = channelMin;
- }
+ }
channelGroup = NULL;
useCase = false;
mode = 0;
@@ -70,12 +70,11 @@ cBlacklist::cBlacklist(void)
catvalues = (char**) malloc(SearchExtCats.Count() * sizeof(char*));
cSearchExtCat *SearchExtCat = SearchExtCats.First();
int index = 0;
- while (SearchExtCat)
- {
- catvalues[index] = (char*)malloc(MaxFileName);
- *catvalues[index] = 0;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
+ while (SearchExtCat) {
+ catvalues[index] = (char*)malloc(MaxFileName);
+ *catvalues[index] = 0;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
}
ignoreMissingEPGCats = 0;
fuzzyTolerance = 1;
@@ -83,611 +82,584 @@ cBlacklist::cBlacklist(void)
cBlacklist::~cBlacklist(void)
{
- if (buffer) {
- free(buffer);
- buffer = NULL;
- }
- if (catvalues)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- free(catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- free(catvalues);
- catvalues = NULL;
- }
+ if (buffer) {
+ free(buffer);
+ buffer = NULL;
+ }
+ if (catvalues) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ free(catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ free(catvalues);
+ catvalues = NULL;
+ }
}
cBlacklist& cBlacklist::operator= (const cBlacklist &Blacklist)
{
- char** catvaluesTemp = this->catvalues;
- memcpy(this, &Blacklist, sizeof(*this));
- this->catvalues = catvaluesTemp;
-
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- *catvalues[index] = 0;
- strcpy(catvalues[index], Blacklist.catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- return *this;
+ char** catvaluesTemp = this->catvalues;
+ memcpy(this, &Blacklist, sizeof(*this));
+ this->catvalues = catvaluesTemp;
+
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ *catvalues[index] = 0;
+ strcpy(catvalues[index], Blacklist.catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ return *this;
}
void cBlacklist::CopyFromTemplate(const cSearchExt* templ)
{
- options = templ->options;
- useTime = templ->useTime;
- startTime = templ->startTime;
- stopTime = templ->stopTime;
- useChannel = templ->useChannel;
- useCase = templ->useCase;
- mode = templ->mode;
- useTitle = templ->useTitle;
- useSubtitle = templ->useSubtitle;
- useDescription = templ->useDescription;
- useDuration = templ->useDuration;
- minDuration = templ->minDuration;
- maxDuration = templ->maxDuration;
- useDayOfWeek = templ->useDayOfWeek;
- DayOfWeek = templ->DayOfWeek;
- useExtEPGInfo = templ->useExtEPGInfo;
- isGlobal = 0;
-
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- strcpy(catvalues[index], templ->catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
-
- channelMin = templ->channelMin;
- channelMax = templ->channelMax;
- if (channelGroup)
- free(channelGroup);
- if (templ->channelGroup)
- channelGroup = strdup(templ->channelGroup);
- fuzzyTolerance = templ->fuzzyTolerance;
- ignoreMissingEPGCats = templ->ignoreMissingEPGCats;
+ options = templ->options;
+ useTime = templ->useTime;
+ startTime = templ->startTime;
+ stopTime = templ->stopTime;
+ useChannel = templ->useChannel;
+ useCase = templ->useCase;
+ mode = templ->mode;
+ useTitle = templ->useTitle;
+ useSubtitle = templ->useSubtitle;
+ useDescription = templ->useDescription;
+ useDuration = templ->useDuration;
+ minDuration = templ->minDuration;
+ maxDuration = templ->maxDuration;
+ useDayOfWeek = templ->useDayOfWeek;
+ DayOfWeek = templ->DayOfWeek;
+ useExtEPGInfo = templ->useExtEPGInfo;
+ isGlobal = 0;
+
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ strcpy(catvalues[index], templ->catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+
+ channelMin = templ->channelMin;
+ channelMax = templ->channelMax;
+ if (channelGroup)
+ free(channelGroup);
+ if (templ->channelGroup)
+ channelGroup = strdup(templ->channelGroup);
+ fuzzyTolerance = templ->fuzzyTolerance;
+ ignoreMissingEPGCats = templ->ignoreMissingEPGCats;
}
bool cBlacklist::operator< (const cListObject &ListObject)
{
- cBlacklist *BL = (cBlacklist *)&ListObject;
- return strcasecmp(search, BL->search) < 0;
+ cBlacklist *BL = (cBlacklist *)&ListObject;
+ return strcasecmp(search, BL->search) < 0;
}
const char *cBlacklist::ToText(void)
{
- char tmp_Start[5] = "";
- char tmp_Stop[5] = "";
- char tmp_minDuration[5] = "";
- char tmp_maxDuration[5] = "";
- char* tmp_chanSel = NULL;
- char* tmp_search = NULL;
- char* tmp_catvalues = NULL;
-
- free(buffer);
- tmp_search = strdup(search);
- while(strstr(tmp_search, "|"))
- tmp_search = strreplace(tmp_search, "|", "!^pipe^!"); // ugly: replace a pipe with something, that should not happen to be part of a regular expression
-
- strreplace(tmp_search, ':', '|');
-
- if (useTime)
- {
- sprintf(tmp_Start, "%04d", startTime);
- sprintf(tmp_Stop, "%04d", stopTime);
- }
- if (useDuration)
- {
- sprintf(tmp_minDuration, "%04d", minDuration);
- sprintf(tmp_maxDuration, "%04d", maxDuration);
- }
-
- if (useChannel==1)
- {
- if (channelMin->Number() < channelMax->Number())
- msprintf(&tmp_chanSel, "%s|%s", CHANNELSTRING(channelMin), CHANNELSTRING(channelMax));
- else
- msprintf(&tmp_chanSel, "%s", CHANNELSTRING(channelMin));
- }
- if (useChannel==2)
- {
- int channelGroupNr = ChannelGroups.GetIndex(channelGroup);
- if (channelGroupNr == -1)
- {
- LogFile.eSysLog("channel group %s does not exist!", channelGroup);
- useChannel = 0;
- }
- else
- tmp_chanSel = strdup(channelGroup);
- }
-
- if (useExtEPGInfo)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- char* catvalue = NULL;
- if (msprintf(&catvalue, "%s", catvalues[index])!=-1)
- {
- while(strstr(catvalue, ":"))
- catvalue = strreplace(catvalue, ":", "!^colon^!"); // ugly: replace with something, that should not happen to be part ofa category value
- while(strstr(catvalue, "|"))
- catvalue = strreplace(catvalue, "|", "!^pipe^!"); // ugly: replace with something, that should not happen to be part of a regular expression
-
- if (index == 0)
- msprintf(&tmp_catvalues, "%d#%s", SearchExtCat->id, catvalue);
- else
- {
- char* temp = tmp_catvalues;
- msprintf(&tmp_catvalues, "%s|%d#%s", tmp_catvalues, SearchExtCat->id, catvalue);
- free(temp);
- }
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- free(catvalue);
- }
- }
-
- msprintf(&buffer, "%d:%s:%d:%s:%s:%d:%s:%d:%d:%d:%d:%d:%d:%s:%s:%d:%d:%d:%s:%d:%d:%d",
- ID,
- tmp_search,
- useTime,
- tmp_Start,
- tmp_Stop,
- useChannel,
- (useChannel>0 && useChannel<3)?tmp_chanSel:"0",
- useCase,
- mode,
- useTitle,
- useSubtitle,
- useDescription,
- useDuration,
- tmp_minDuration,
- tmp_maxDuration,
- useDayOfWeek,
- DayOfWeek,
- useExtEPGInfo,
- useExtEPGInfo?tmp_catvalues:"",
- fuzzyTolerance,
- ignoreMissingEPGCats,
- isGlobal);
-
-
- if (tmp_chanSel)
- free(tmp_chanSel);
- if (tmp_search)
- free(tmp_search);
- if (tmp_catvalues)
- free(tmp_catvalues);
-
-
- return buffer;
+ char tmp_Start[5] = "";
+ char tmp_Stop[5] = "";
+ char tmp_minDuration[5] = "";
+ char tmp_maxDuration[5] = "";
+ char* tmp_chanSel = NULL;
+ char* tmp_search = NULL;
+ char* tmp_catvalues = NULL;
+
+ free(buffer);
+ tmp_search = strdup(search);
+ while (strstr(tmp_search, "|"))
+ tmp_search = strreplace(tmp_search, "|", "!^pipe^!"); // ugly: replace a pipe with something, that should not happen to be part of a regular expression
+
+ strreplace(tmp_search, ':', '|');
+
+ if (useTime) {
+ sprintf(tmp_Start, "%04d", startTime);
+ sprintf(tmp_Stop, "%04d", stopTime);
+ }
+ if (useDuration) {
+ sprintf(tmp_minDuration, "%04d", minDuration);
+ sprintf(tmp_maxDuration, "%04d", maxDuration);
+ }
+
+ if (useChannel == 1) {
+ if (channelMin->Number() < channelMax->Number())
+ msprintf(&tmp_chanSel, "%s|%s", CHANNELSTRING(channelMin), CHANNELSTRING(channelMax));
+ else
+ msprintf(&tmp_chanSel, "%s", CHANNELSTRING(channelMin));
+ }
+ if (useChannel == 2) {
+ int channelGroupNr = ChannelGroups.GetIndex(channelGroup);
+ if (channelGroupNr == -1) {
+ LogFile.eSysLog("channel group %s does not exist!", channelGroup);
+ useChannel = 0;
+ } else
+ tmp_chanSel = strdup(channelGroup);
+ }
+
+ if (useExtEPGInfo) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ char* catvalue = NULL;
+ if (msprintf(&catvalue, "%s", catvalues[index]) != -1) {
+ while (strstr(catvalue, ":"))
+ catvalue = strreplace(catvalue, ":", "!^colon^!"); // ugly: replace with something, that should not happen to be part ofa category value
+ while (strstr(catvalue, "|"))
+ catvalue = strreplace(catvalue, "|", "!^pipe^!"); // ugly: replace with something, that should not happen to be part of a regular expression
+
+ if (index == 0)
+ msprintf(&tmp_catvalues, "%d#%s", SearchExtCat->id, catvalue);
+ else {
+ char* temp = tmp_catvalues;
+ msprintf(&tmp_catvalues, "%s|%d#%s", tmp_catvalues, SearchExtCat->id, catvalue);
+ free(temp);
+ }
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ free(catvalue);
+ }
+ }
+
+ msprintf(&buffer, "%d:%s:%d:%s:%s:%d:%s:%d:%d:%d:%d:%d:%d:%s:%s:%d:%d:%d:%s:%d:%d:%d",
+ ID,
+ tmp_search,
+ useTime,
+ tmp_Start,
+ tmp_Stop,
+ useChannel,
+ (useChannel > 0 && useChannel < 3) ? tmp_chanSel : "0",
+ useCase,
+ mode,
+ useTitle,
+ useSubtitle,
+ useDescription,
+ useDuration,
+ tmp_minDuration,
+ tmp_maxDuration,
+ useDayOfWeek,
+ DayOfWeek,
+ useExtEPGInfo,
+ useExtEPGInfo ? tmp_catvalues : "",
+ fuzzyTolerance,
+ ignoreMissingEPGCats,
+ isGlobal);
+
+
+ if (tmp_chanSel)
+ free(tmp_chanSel);
+ if (tmp_search)
+ free(tmp_search);
+ if (tmp_catvalues)
+ free(tmp_catvalues);
+
+
+ return buffer;
}
bool cBlacklist::Parse(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int parameter = 1;
- int valuelen;
- char value[MaxFileName];
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != ':') {
- pos_next = strchr(pos, ':');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MaxFileName) valuelen = MaxFileName;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1: ID = atoi(value);
- break;
- case 2: strcpy(search, value);
- break;
- case 3: useTime = atoi(value);
- break;
- case 4: startTime = atoi(value);
- break;
- case 5: stopTime = atoi(value);
- break;
- case 6: useChannel = atoi(value);
- break;
- case 7:
- if (useChannel == 0)
- {
- channelMin = NULL;
- channelMax = NULL;
- }
- else if (useChannel == 1)
- {
- int minNum=0, maxNum=0;
- int fields = sscanf(value, "%d-%d", &minNum, &maxNum);
- if (fields == 0) // stored with ID
- {
+ char *line;
+ char *pos;
+ char *pos_next;
+ int parameter = 1;
+ int valuelen;
+ char value[MaxFileName];
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != ':') {
+ pos_next = strchr(pos, ':');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MaxFileName) valuelen = MaxFileName;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ switch (parameter) {
+ case 1:
+ ID = atoi(value);
+ break;
+ case 2:
+ strcpy(search, value);
+ break;
+ case 3:
+ useTime = atoi(value);
+ break;
+ case 4:
+ startTime = atoi(value);
+ break;
+ case 5:
+ stopTime = atoi(value);
+ break;
+ case 6:
+ useChannel = atoi(value);
+ break;
+ case 7:
+ if (useChannel == 0) {
+ channelMin = NULL;
+ channelMax = NULL;
+ } else if (useChannel == 1) {
+ int minNum = 0, maxNum = 0;
+ int fields = sscanf(value, "%d-%d", &minNum, &maxNum);
+ if (fields == 0) { // stored with ID
#ifdef __FreeBSD__
- char *channelMinbuffer = MALLOC(char, 32);
- char *channelMaxbuffer = MALLOC(char, 32);
- int channels = sscanf(value, "%31[^|]|%31[^|]", channelMinbuffer, channelMaxbuffer);
+ char *channelMinbuffer = MALLOC(char, 32);
+ char *channelMaxbuffer = MALLOC(char, 32);
+ int channels = sscanf(value, "%31[^|]|%31[^|]", channelMinbuffer, channelMaxbuffer);
#else
- char *channelMinbuffer = NULL;
- char *channelMaxbuffer = NULL;
- int channels = sscanf(value, "%m[^|]|%m[^|]", &channelMinbuffer, &channelMaxbuffer);
+ char *channelMinbuffer = NULL;
+ char *channelMaxbuffer = NULL;
+ int channels = sscanf(value, "%m[^|]|%m[^|]", &channelMinbuffer, &channelMaxbuffer);
#endif
- LOCK_CHANNELS_READ;
- channelMin = Channels->GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true);
- if (!channelMin)
- {
- LogFile.eSysLog("ERROR: channel %s not defined", channelMinbuffer);
- channelMin = channelMax = NULL;
- useChannel = 0;
- }
- if (channels == 1)
- channelMax = channelMin;
- else
- {
- channelMax = Channels->GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true);
- if (!channelMax)
- {
- LogFile.eSysLog("ERROR: channel %s not defined", channelMaxbuffer);
- channelMin = channelMax = NULL;
- useChannel = 0;
- }
- }
- free(channelMinbuffer);
- free(channelMaxbuffer);
- }
- }
- else if (useChannel == 2)
- channelGroup = strdup(value);
- break;
- case 8: useCase = atoi(value);
- break;
- case 9: mode = atoi(value);
- break;
- case 10: useTitle = atoi(value);
- break;
- case 11: useSubtitle = atoi(value);
- break;
- case 12: useDescription = atoi(value);
- break;
- case 13: useDuration = atoi(value);
- break;
- case 14: minDuration = atoi(value);
- break;
- case 15: maxDuration = atoi(value);
- break;
- case 16: useDayOfWeek = atoi(value);
- break;
- case 17: DayOfWeek = atoi(value);
- break;
- case 18: useExtEPGInfo = atoi(value);
- break;
- case 19:
- if (!ParseExtEPGValues(value))
- {
- LogFile.eSysLog("ERROR reading ext. EPG values - 1");
- free(line);
- return false;
- }
- break;
- case 20: fuzzyTolerance = atoi(value);
- break;
- case 21: ignoreMissingEPGCats = atoi(value);
- break;
- case 22: isGlobal = atoi(value);
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
+ LOCK_CHANNELS_READ;
+ channelMin = Channels->GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true);
+ if (!channelMin) {
+ LogFile.eSysLog("ERROR: channel %s not defined", channelMinbuffer);
+ channelMin = channelMax = NULL;
+ useChannel = 0;
+ }
+ if (channels == 1)
+ channelMax = channelMin;
+ else {
+ channelMax = Channels->GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true);
+ if (!channelMax) {
+ LogFile.eSysLog("ERROR: channel %s not defined", channelMaxbuffer);
+ channelMin = channelMax = NULL;
+ useChannel = 0;
+ }
+ }
+ free(channelMinbuffer);
+ free(channelMaxbuffer);
+ }
+ } else if (useChannel == 2)
+ channelGroup = strdup(value);
+ break;
+ case 8:
+ useCase = atoi(value);
+ break;
+ case 9:
+ mode = atoi(value);
+ break;
+ case 10:
+ useTitle = atoi(value);
+ break;
+ case 11:
+ useSubtitle = atoi(value);
+ break;
+ case 12:
+ useDescription = atoi(value);
+ break;
+ case 13:
+ useDuration = atoi(value);
+ break;
+ case 14:
+ minDuration = atoi(value);
+ break;
+ case 15:
+ maxDuration = atoi(value);
+ break;
+ case 16:
+ useDayOfWeek = atoi(value);
+ break;
+ case 17:
+ DayOfWeek = atoi(value);
+ break;
+ case 18:
+ useExtEPGInfo = atoi(value);
+ break;
+ case 19:
+ if (!ParseExtEPGValues(value)) {
+ LogFile.eSysLog("ERROR reading ext. EPG values - 1");
+ free(line);
+ return false;
+ }
+ break;
+ case 20:
+ fuzzyTolerance = atoi(value);
+ break;
+ case 21:
+ ignoreMissingEPGCats = atoi(value);
+ break;
+ case 22:
+ isGlobal = atoi(value);
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
- strreplace(search, '|', ':');
- while(strstr(search, "!^pipe^!"))
- strreplace(search, "!^pipe^!", "|");
+ strreplace(search, '|', ':');
+ while (strstr(search, "!^pipe^!"))
+ strreplace(search, "!^pipe^!", "|");
- free(line);
- return (parameter >= 19) ? true : false;
+ free(line);
+ return (parameter >= 19) ? true : false;
}
bool cBlacklist::ParseExtEPGValues(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int valuelen;
- char value[MaxFileName];
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != '|') {
- pos_next = strchr(pos, '|');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MaxFileName) valuelen = MaxFileName;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- if (!ParseExtEPGEntry(value))
- {
- LogFile.eSysLog("ERROR reading ext. EPG value: %s", value);
- free(line);
- return false;
- }
- }
- }
- if (*pos) pos++;
- } //while
+ char *line;
+ char *pos;
+ char *pos_next;
+ int valuelen;
+ char value[MaxFileName];
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != '|') {
+ pos_next = strchr(pos, '|');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MaxFileName) valuelen = MaxFileName;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ if (!ParseExtEPGEntry(value)) {
+ LogFile.eSysLog("ERROR reading ext. EPG value: %s", value);
+ free(line);
+ return false;
+ }
+ }
+ }
+ if (*pos) pos++;
+ } //while
- free(line);
- return true;
+ free(line);
+ return true;
}
bool cBlacklist::ParseExtEPGEntry(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int parameter = 1;
- int valuelen;
- char value[MaxFileName];
- int currentid = -1;
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != '#') {
- pos_next = strchr(pos, '#');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MaxFileName) valuelen = MaxFileName;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1:
- {
- currentid = atoi(value);
- int index = SearchExtCats.GetIndexFromID(currentid);
- if (index > -1)
- strcpy(catvalues[index], "");
- }
- break;
- case 2:
- if (currentid > -1)
- {
- int index = SearchExtCats.GetIndexFromID(currentid);
- if (index > -1)
- {
- while(strstr(value, "!^colon^!"))
- strreplace(value, "!^colon^!", ":");
- while(strstr(value, "!^pipe^!"))
- strreplace(value, "!^pipe^!", "|");
- strcpy(catvalues[index], value);
- }
- }
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
+ char *line;
+ char *pos;
+ char *pos_next;
+ int parameter = 1;
+ int valuelen;
+ char value[MaxFileName];
+ int currentid = -1;
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != '#') {
+ pos_next = strchr(pos, '#');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MaxFileName) valuelen = MaxFileName;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ switch (parameter) {
+ case 1: {
+ currentid = atoi(value);
+ int index = SearchExtCats.GetIndexFromID(currentid);
+ if (index > -1)
+ strcpy(catvalues[index], "");
+ }
+ break;
+ case 2:
+ if (currentid > -1) {
+ int index = SearchExtCats.GetIndexFromID(currentid);
+ if (index > -1) {
+ while (strstr(value, "!^colon^!"))
+ strreplace(value, "!^colon^!", ":");
+ while (strstr(value, "!^pipe^!"))
+ strreplace(value, "!^pipe^!", "|");
+ strcpy(catvalues[index], value);
+ }
+ }
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
- free(line);
- return (parameter >= 2) ? true : false;
+ free(line);
+ return (parameter >= 2) ? true : false;
}
bool cBlacklist::Save(FILE *f)
{
- return fprintf(f, "%s\n", ToText()) > 0;
+ return fprintf(f, "%s\n", ToText()) > 0;
}
const cEvent * cBlacklist::GetEventByBlacklist(const cSchedule *schedule, const cEvent *Start, int MarginStop)
{
- const cEvent *pe = NULL;
- const cEvent *p1 = NULL;
-
- if (Start)
- p1 = schedule->Events()->Next(Start);
- else
- p1 = schedule->Events()->First();
-
- time_t tNow=time(NULL);
- char* szTest = NULL;
- char* searchText = strdup(search);
-
- if (!useCase)
- ToLower(searchText);
-
- int searchStart = 0, searchStop = 0;
- if (useTime)
- {
- searchStart = startTime;
- searchStop = stopTime;
- if (searchStop < searchStart)
- searchStop += 2400;
- }
- int minSearchDuration = 0;
- int maxSearchDuration = 0;
- if (useDuration)
- {
- minSearchDuration = minDuration/100*60 + minDuration%100;
- maxSearchDuration = maxDuration/100*60 + maxDuration%100;
- }
-
- for (const cEvent *p = p1; p; p = schedule->Events()->Next(p))
- {
- if(!p)
- {
- break;
- }
-
- if (szTest)
- {
- free(szTest);
- szTest = NULL;
- }
-
- // ignore events without title
- if (!p->Title() || strlen(p->Title()) == 0)
- continue;
-
- msprintf(&szTest, "%s%s%s%s%s", (useTitle?p->Title():""), (useSubtitle||useDescription)?"~":"",
- (useSubtitle?p->ShortText():""),useDescription?"~":"",
- (useDescription?p->Description():""));
-
- if (tNow < p->EndTime() + MarginStop * 60)
- {
- if (!useCase)
- ToLower(szTest);
-
- if (useTime)
- {
- time_t tEvent = p->StartTime();
- struct tm tmEvent;
- localtime_r(&tEvent, &tmEvent);
- int eventStart = tmEvent.tm_hour*100 + tmEvent.tm_min;
- int eventStart2 = tmEvent.tm_hour*100 + tmEvent.tm_min + 2400;
- if ((eventStart < searchStart || eventStart > searchStop) &&
- (eventStart2 < searchStart || eventStart2 > searchStop))
- continue;
+ const cEvent *pe = NULL;
+ const cEvent *p1 = NULL;
+
+ if (Start)
+ p1 = schedule->Events()->Next(Start);
+ else
+ p1 = schedule->Events()->First();
+
+ time_t tNow = time(NULL);
+ char* szTest = NULL;
+ char* searchText = strdup(search);
+
+ if (!useCase)
+ ToLower(searchText);
+
+ int searchStart = 0, searchStop = 0;
+ if (useTime) {
+ searchStart = startTime;
+ searchStop = stopTime;
+ if (searchStop < searchStart)
+ searchStop += 2400;
+ }
+ int minSearchDuration = 0;
+ int maxSearchDuration = 0;
+ if (useDuration) {
+ minSearchDuration = minDuration / 100 * 60 + minDuration % 100;
+ maxSearchDuration = maxDuration / 100 * 60 + maxDuration % 100;
+ }
+
+ for (const cEvent *p = p1; p; p = schedule->Events()->Next(p)) {
+ if (!p) {
+ break;
}
- if (useDuration)
- {
- int duration = p->Duration()/60;
- if (minSearchDuration > duration || maxSearchDuration < duration)
- continue;
+
+ if (szTest) {
+ free(szTest);
+ szTest = NULL;
}
- if (useDayOfWeek)
- {
- time_t tEvent = p->StartTime();
- struct tm tmEvent;
- localtime_r(&tEvent, &tmEvent);
- if (DayOfWeek >= 0 && DayOfWeek != tmEvent.tm_wday)
- continue;
- if (DayOfWeek < 0)
- {
- int iFound = 0;
- for(int i=0; i<7; i++)
- if (abs(DayOfWeek) & (int)pow(2,i) && i == tmEvent.tm_wday)
- {
- iFound = 1;
- break;
- }
- if (!iFound)
- continue;
- }
- }
-
- if (strlen(szTest) > 0)
- {
- if (!MatchesSearchMode(szTest, searchText, mode," ,;|~", fuzzyTolerance))
- continue;
- }
-
- if (useExtEPGInfo && !MatchesExtEPGInfo(p))
- continue;
- pe=p;
- break;
- }
- }
- if (szTest)
- free(szTest);
- free(searchText);
- return pe;
+ // ignore events without title
+ if (!p->Title() || strlen(p->Title()) == 0)
+ continue;
+
+ msprintf(&szTest, "%s%s%s%s%s", (useTitle ? p->Title() : ""), (useSubtitle || useDescription) ? "~" : "",
+ (useSubtitle ? p->ShortText() : ""), useDescription ? "~" : "",
+ (useDescription ? p->Description() : ""));
+
+ if (tNow < p->EndTime() + MarginStop * 60) {
+ if (!useCase)
+ ToLower(szTest);
+
+ if (useTime) {
+ time_t tEvent = p->StartTime();
+ struct tm tmEvent;
+ localtime_r(&tEvent, &tmEvent);
+ int eventStart = tmEvent.tm_hour * 100 + tmEvent.tm_min;
+ int eventStart2 = tmEvent.tm_hour * 100 + tmEvent.tm_min + 2400;
+ if ((eventStart < searchStart || eventStart > searchStop) &&
+ (eventStart2 < searchStart || eventStart2 > searchStop))
+ continue;
+ }
+ if (useDuration) {
+ int duration = p->Duration() / 60;
+ if (minSearchDuration > duration || maxSearchDuration < duration)
+ continue;
+ }
+
+ if (useDayOfWeek) {
+ time_t tEvent = p->StartTime();
+ struct tm tmEvent;
+ localtime_r(&tEvent, &tmEvent);
+ if (DayOfWeek >= 0 && DayOfWeek != tmEvent.tm_wday)
+ continue;
+ if (DayOfWeek < 0) {
+ int iFound = 0;
+ for (int i = 0; i < 7; i++)
+ if (abs(DayOfWeek) & (int)pow(2, i) && i == tmEvent.tm_wday) {
+ iFound = 1;
+ break;
+ }
+ if (!iFound)
+ continue;
+ }
+ }
+
+ if (strlen(szTest) > 0) {
+ if (!MatchesSearchMode(szTest, searchText, mode, " ,;|~", fuzzyTolerance))
+ continue;
+ }
+
+ if (useExtEPGInfo && !MatchesExtEPGInfo(p))
+ continue;
+ pe = p;
+ break;
+ }
+ }
+ if (szTest)
+ free(szTest);
+ free(searchText);
+ return pe;
}
// returns a pointer array to the matching search results
cSearchResults* cBlacklist::Run(cSearchResults* pSearchResults, int MarginStop)
{
- LogFile.Log(3,"start search for blacklist '%s'", search);
+ LogFile.Log(3, "start search for blacklist '%s'", search);
LOCK_CHANNELS_READ;
LOCK_SCHEDULES_READ;
const cSchedule *Schedule = Schedules->First();
while (Schedule) {
- const cChannel* channel = Channels->GetByChannelID(Schedule->ChannelID(),true,true);
- if (!channel)
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
-
- if (useChannel == 1 && channelMin && channelMax)
- {
- if (channelMin->Number() > channel->Number() || channelMax->Number() < channel->Number())
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
- }
- if (useChannel == 2 && channelGroup)
- {
- cChannelGroup* group = ChannelGroups.GetGroupByName(channelGroup);
- if (!group || !group->ChannelInGroup(channel))
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
- }
-
- if (useChannel == 3)
- {
- if (channel->Ca() >= CA_ENCRYPTED_MIN)
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
- }
+ const cChannel* channel = Channels->GetByChannelID(Schedule->ChannelID(), true, true);
+ if (!channel) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
+
+ if (useChannel == 1 && channelMin && channelMax) {
+ if (channelMin->Number() > channel->Number() || channelMax->Number() < channel->Number()) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
+ }
+ if (useChannel == 2 && channelGroup) {
+ cChannelGroup* group = ChannelGroups.GetGroupByName(channelGroup);
+ if (!group || !group->ChannelInGroup(channel)) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
+ }
+
+ if (useChannel == 3) {
+ if (channel->Ca() >= CA_ENCRYPTED_MIN) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
+ }
const cEvent *pPrevEvent = NULL;
do {
- const cEvent* event = GetEventByBlacklist(Schedule, pPrevEvent, MarginStop);
- pPrevEvent = event;
- if (event && Channels->GetByChannelID(event->ChannelID(),true,true))
- {
- if (!pSearchResults) pSearchResults = new cSearchResults;
- pSearchResults->Add(new cSearchResult(event, this));
- }
- } while(pPrevEvent);
+ const cEvent* event = GetEventByBlacklist(Schedule, pPrevEvent, MarginStop);
+ pPrevEvent = event;
+ if (event && Channels->GetByChannelID(event->ChannelID(), true, true)) {
+ if (!pSearchResults) pSearchResults = new cSearchResults;
+ pSearchResults->Add(new cSearchResult(event, this));
+ }
+ } while (pPrevEvent);
Schedule = Schedules->Next(Schedule);
}
- LogFile.Log(3,"found %d event(s) for blacklist '%s'", pSearchResults?pSearchResults->Count():0, search);
+ LogFile.Log(3, "found %d event(s) for blacklist '%s'", pSearchResults ? pSearchResults->Count() : 0, search);
return pSearchResults;
}
@@ -695,34 +667,31 @@ cSearchResults* cBlacklist::Run(cSearchResults* pSearchResults, int MarginStop)
bool cBlacklist::MatchesExtEPGInfo(const cEvent* e)
{
if (!e || !e->Description())
- return false;
+ return false;
cSearchExtCat* SearchExtCat = SearchExtCats.First();
- while (SearchExtCat)
- {
- char* value = NULL;
- int index = SearchExtCats.GetIndexFromID(SearchExtCat->id);
- if (index > -1)
- value = catvalues[index];
- if (value && strlen(value) > 0)
- {
- char* testvalue = GetExtEPGValue(e, SearchExtCat);
- if (!testvalue)
- return false;
-
- // compare not case sensitive
- char* valueLower = strdup(value);
- ToLower(valueLower);
- ToLower(testvalue);
- if (!MatchesSearchMode(testvalue, valueLower, SearchExtCat->searchmode, ",;|~", fuzzyTolerance))
- {
- free(testvalue);
- free(valueLower);
- return false;
- }
- free(testvalue);
- free(valueLower);
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ while (SearchExtCat) {
+ char* value = NULL;
+ int index = SearchExtCats.GetIndexFromID(SearchExtCat->id);
+ if (index > -1)
+ value = catvalues[index];
+ if (value && strlen(value) > 0) {
+ char* testvalue = GetExtEPGValue(e, SearchExtCat);
+ if (!testvalue)
+ return false;
+
+ // compare not case sensitive
+ char* valueLower = strdup(value);
+ ToLower(valueLower);
+ ToLower(testvalue);
+ if (!MatchesSearchMode(testvalue, valueLower, SearchExtCat->searchmode, ",;|~", fuzzyTolerance)) {
+ free(testvalue);
+ free(valueLower);
+ return false;
+ }
+ free(testvalue);
+ free(valueLower);
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
}
return true;
}
@@ -734,22 +703,22 @@ int cBlacklists::GetNewID()
cMutexLock BlacklistLock(this);
cBlacklist *l = (cBlacklist *)First();
while (l) {
- newID = std::max(newID, l->ID);
- l = (cBlacklist *)l->Next();
+ newID = std::max(newID, l->ID);
+ l = (cBlacklist *)l->Next();
}
- return newID+1;
+ return newID + 1;
}
cBlacklist* cBlacklists::GetBlacklistFromID(int ID)
{
if (ID == -1)
- return NULL;
+ return NULL;
cMutexLock BlacklistLock(this);
cBlacklist *l = (cBlacklist *)First();
while (l) {
- if (l->ID == ID)
- return l;
- l = (cBlacklist *)l->Next();
+ if (l->ID == ID)
+ return l;
+ l = (cBlacklist *)l->Next();
}
return NULL;
}
@@ -758,11 +727,10 @@ bool cBlacklists::Exists(const cBlacklist* Blacklist)
{
cMutexLock BlacklistLock(this);
cBlacklist *l = (cBlacklist*)First();
- while (l)
- {
- if (l == Blacklist)
- return true;
- l = (cBlacklist*)l->Next();
+ while (l) {
+ if (l == Blacklist)
+ return true;
+ l = (cBlacklist*)l->Next();
}
return false;
}
diff --git a/blacklist.h b/blacklist.h
index 494f08c..7410b35 100644
--- a/blacklist.h
+++ b/blacklist.h
@@ -29,68 +29,85 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class cSearchExt;
class cSearchResults;
-class cBlacklist : public cListObject {
- friend class cMenuEditSearchExt;
+class cBlacklist : public cListObject
+{
+ friend class cMenuEditSearchExt;
public:
- int ID;
- char search[MaxFileName];
- int options;
- int useTime;
- int startTime;
- int stopTime;
- int useChannel;
- const cChannel *channelMin;
- const cChannel *channelMax;
- char* channelGroup;
- int useCase;
- int mode;
- int useTitle;
- int useSubtitle;
- int useDescription;
- int useDuration;
- int minDuration;
- int maxDuration;
- int useDayOfWeek;
- int DayOfWeek;
- int useExtEPGInfo;
- int ignoreMissingEPGCats;
- char** catvalues;
- int fuzzyTolerance;
- int isGlobal;
- static char *buffer;
+ int ID;
+ char search[MaxFileName];
+ int options;
+ int useTime;
+ int startTime;
+ int stopTime;
+ int useChannel;
+ const cChannel *channelMin;
+ const cChannel *channelMax;
+ char* channelGroup;
+ int useCase;
+ int mode;
+ int useTitle;
+ int useSubtitle;
+ int useDescription;
+ int useDuration;
+ int minDuration;
+ int maxDuration;
+ int useDayOfWeek;
+ int DayOfWeek;
+ int useExtEPGInfo;
+ int ignoreMissingEPGCats;
+ char** catvalues;
+ int fuzzyTolerance;
+ int isGlobal;
+ static char *buffer;
public:
- cBlacklist(void);
- virtual ~cBlacklist(void);
- cBlacklist& operator= (const cBlacklist&);
- virtual bool operator< (const cListObject &ListObject);
+ cBlacklist(void);
+ virtual ~cBlacklist(void);
+ cBlacklist& operator= (const cBlacklist&);
+ virtual bool operator< (const cListObject &ListObject);
- const char *Search(void) { return search; }
- int Options(void) { return options; }
- int StartTime(void) { return startTime; }
- int StopTime(void) { return stopTime; }
- int UseChannel(void) { return useChannel; }
- const cChannel *ChannelMin(void) { return channelMin; }
- const cChannel *ChannelMax(void) { return channelMax; }
- const cEvent * GetEventByBlacklist(const cSchedule *schedules, const cEvent *Start, int MarginStop = 0);
- bool MatchesExtEPGInfo(const cEvent* e);
- const char *ToText(void);
- bool Parse(const char *s);
- bool ParseExtEPGValues(const char *s);
- bool ParseExtEPGEntry(const char *s);
- bool Save(FILE *f);
- cSearchResults* Run(cSearchResults* pSearchResults = NULL, int MarginStop = 0);
- void CopyFromTemplate(const cSearchExt* templ);
+ const char *Search(void) {
+ return search;
+ }
+ int Options(void) {
+ return options;
+ }
+ int StartTime(void) {
+ return startTime;
+ }
+ int StopTime(void) {
+ return stopTime;
+ }
+ int UseChannel(void) {
+ return useChannel;
+ }
+ const cChannel *ChannelMin(void) {
+ return channelMin;
+ }
+ const cChannel *ChannelMax(void) {
+ return channelMax;
+ }
+ const cEvent * GetEventByBlacklist(const cSchedule *schedules, const cEvent *Start, int MarginStop = 0);
+ bool MatchesExtEPGInfo(const cEvent* e);
+ const char *ToText(void);
+ bool Parse(const char *s);
+ bool ParseExtEPGValues(const char *s);
+ bool ParseExtEPGEntry(const char *s);
+ bool Save(FILE *f);
+ cSearchResults* Run(cSearchResults* pSearchResults = NULL, int MarginStop = 0);
+ void CopyFromTemplate(const cSearchExt* templ);
};
-class cBlacklists : public cConfig<cBlacklist>, public cMutex {
+class cBlacklists : public cConfig<cBlacklist>, public cMutex
+{
public:
int GetNewID(void);
cBlacklist* GetBlacklistFromID(int ID);
bool Exists(const cBlacklist* Blacklist);
};
-class cBlacklistObject: public cListObject {
- public:
+class cBlacklistObject: public cListObject
+{
+public:
cBlacklist* blacklist;
cBlacklistObject(cBlacklist* Blacklist) : blacklist(Blacklist) {}
};
diff --git a/changrp.c b/changrp.c
index 7d74a8b..228843b 100644
--- a/changrp.c
+++ b/changrp.c
@@ -41,67 +41,64 @@ cChannelGroup::~cChannelGroup(void)
bool cChannelGroup::Parse(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int parameter = 1;
- int valuelen;
+ char *line;
+ char *pos;
+ char *pos_next;
+ int parameter = 1;
+ int valuelen;
#define MAXVALUELEN (10 * MaxFileName)
- char value[MAXVALUELEN];
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != '|') {
- pos_next = strchr(pos, '|');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MAXVALUELEN)
- {
- LogFile.eSysLog("entry '%s' is too long. Will be truncated!", pos);
- valuelen = MAXVALUELEN;
- }
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1: strcpy(name,value);
- break;
- default:
- {
+ char value[MAXVALUELEN];
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != '|') {
+ pos_next = strchr(pos, '|');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MAXVALUELEN) {
+ LogFile.eSysLog("entry '%s' is too long. Will be truncated!", pos);
+ valuelen = MAXVALUELEN;
+ }
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ switch (parameter) {
+ case 1:
+ strcpy(name, value);
+ break;
+ default: {
#ifdef __FreeBSD__
- char *channelbuffer = MALLOC(char, 32);
- int numChannels = sscanf(value, "%31[^|]", channelbuffer);
+ char *channelbuffer = MALLOC(char, 32);
+ int numChannels = sscanf(value, "%31[^|]", channelbuffer);
#else
- char *channelbuffer = NULL;
- int numChannels = sscanf(value, "%m[^|]", &channelbuffer);
+ char *channelbuffer = NULL;
+ int numChannels = sscanf(value, "%m[^|]", &channelbuffer);
#endif
- if (numChannels == 1)
- {
- LOCK_CHANNELS_READ;
- const cChannel* channel = Channels->GetByChannelID(tChannelID::FromString(channelbuffer), true, true);
- if (channel)
- {
- cChannelGroupItem* channelitem = new cChannelGroupItem(channel);
- channels.Add(channelitem);
- }
- }
- free(channelbuffer);
- }
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
-
- free(line);
- return (parameter >= 1) ? true : false;
+ if (numChannels == 1) {
+ LOCK_CHANNELS_READ;
+ const cChannel* channel = Channels->GetByChannelID(tChannelID::FromString(channelbuffer), true, true);
+ if (channel) {
+ cChannelGroupItem* channelitem = new cChannelGroupItem(channel);
+ channels.Add(channelitem);
+ }
+ }
+ free(channelbuffer);
+ }
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
+
+ free(line);
+ return (parameter >= 1) ? true : false;
}
const char *cChannelGroup::ToText(void)
@@ -109,18 +106,16 @@ const char *cChannelGroup::ToText(void)
char* channelbuffer = NULL;
cChannelGroupItem* ChannelGroupItem = channels.First();
int index = 0;
- while (ChannelGroupItem)
- {
- const cChannel* channel = ChannelGroupItem->channel;
- if (index++ == 0)
- channelbuffer = strdup(CHANNELSTRING(channel));
- else
- {
- char* temp = channelbuffer;
- msprintf(&channelbuffer, "%s|%s", channelbuffer, CHANNELSTRING(channel));
- free(temp);
- }
- ChannelGroupItem = channels.Next(ChannelGroupItem);
+ while (ChannelGroupItem) {
+ const cChannel* channel = ChannelGroupItem->channel;
+ if (index++ == 0)
+ channelbuffer = strdup(CHANNELSTRING(channel));
+ else {
+ char* temp = channelbuffer;
+ msprintf(&channelbuffer, "%s|%s", channelbuffer, CHANNELSTRING(channel));
+ free(temp);
+ }
+ ChannelGroupItem = channels.Next(ChannelGroupItem);
}
char* buffer = NULL;
msprintf(&buffer, "%s|%s", name, channelbuffer);
@@ -134,26 +129,22 @@ int* cChannelGroup::CreateChannelSel()
int* channelSel = (int*) malloc(Channels->Count() * sizeof(int));
const cChannel* channel = Channels->First();
int index = 0;
- while (channel)
- {
- if (channel->GroupSep())
- {
- channel = Channels->Next(channel);
- continue;
- }
- channelSel[index] = 0;
- cChannelGroupItem* channelInGroup = channels.First();
- while (channelInGroup)
- {
- if (channel == channelInGroup->channel)
- {
- channelSel[index] = 1;
- break;
- }
- channelInGroup = channels.Next(channelInGroup);
- }
- index++;
- channel = Channels->Next(channel);
+ while (channel) {
+ if (channel->GroupSep()) {
+ channel = Channels->Next(channel);
+ continue;
+ }
+ channelSel[index] = 0;
+ cChannelGroupItem* channelInGroup = channels.First();
+ while (channelInGroup) {
+ if (channel == channelInGroup->channel) {
+ channelSel[index] = 1;
+ break;
+ }
+ channelInGroup = channels.Next(channelInGroup);
+ }
+ index++;
+ channel = Channels->Next(channel);
}
return channelSel;
}
@@ -164,15 +155,13 @@ void cChannelGroup::CreateChannelList(int* channelSel)
LOCK_CHANNELS_READ;
const cChannel* channel = Channels->First();
int index = 0;
- while (channel)
- {
- if (!channel->GroupSep())
- {
- if (channelSel[index] == 1)
- channels.Add(new cChannelGroupItem(channel));
- index++;
- }
- channel = Channels->Next(channel);
+ while (channel) {
+ if (!channel->GroupSep()) {
+ if (channelSel[index] == 1)
+ channels.Add(new cChannelGroupItem(channel));
+ index++;
+ }
+ channel = Channels->Next(channel);
}
}
@@ -184,11 +173,10 @@ bool cChannelGroup::Save(FILE *f)
bool cChannelGroup::ChannelInGroup(const cChannel* channel)
{
cChannelGroupItem* channelInGroup = channels.First();
- while (channelInGroup)
- {
- if (channel == channelInGroup->channel)
- return true;
- channelInGroup = channels.Next(channelInGroup);
+ while (channelInGroup) {
+ if (channel == channelInGroup->channel)
+ return true;
+ channelInGroup = channels.Next(channelInGroup);
}
return false;
}
@@ -197,15 +185,14 @@ bool cChannelGroup::ChannelInGroup(const cChannel* channel)
int cChannelGroups::GetIndex(char* channelGroup)
{
if (!channelGroup)
- return -1;
+ return -1;
cChannelGroup* ChannelGroup = First();
int index = 0;
- while (ChannelGroup)
- {
- if (strcmp(channelGroup, ChannelGroup->name) == 0)
- return index;
- index++;
- ChannelGroup = Next(ChannelGroup);
+ while (ChannelGroup) {
+ if (strcmp(channelGroup, ChannelGroup->name) == 0)
+ return index;
+ index++;
+ ChannelGroup = Next(ChannelGroup);
}
return -1;
}
@@ -213,13 +200,12 @@ int cChannelGroups::GetIndex(char* channelGroup)
cChannelGroup* cChannelGroups::GetGroupByName(const char* channelGroup)
{
if (!channelGroup)
- return NULL;
+ return NULL;
cChannelGroup* ChannelGroup = First();
- while (ChannelGroup)
- {
- if (strcmp(channelGroup, ChannelGroup->name) == 0)
- return ChannelGroup;
- ChannelGroup = Next(ChannelGroup);
+ while (ChannelGroup) {
+ if (strcmp(channelGroup, ChannelGroup->name) == 0)
+ return ChannelGroup;
+ ChannelGroup = Next(ChannelGroup);
}
return NULL;
}
@@ -227,32 +213,30 @@ cChannelGroup* cChannelGroups::GetGroupByName(const char* channelGroup)
cSearchExt* cChannelGroups::Used(cChannelGroup* group)
{
if (!group)
- return NULL;
+ return NULL;
if (SearchExts.Count() == 0)
- SearchExts.Load(AddDirectory(CONFIGDIR, "epgsearch.conf"));
+ SearchExts.Load(AddDirectory(CONFIGDIR, "epgsearch.conf"));
cMutexLock SearchExtsLock(&SearchExts);
cSearchExt *SearchExt = SearchExts.First();
- while (SearchExt)
- {
- if (SearchExt->useChannel == 2 && strcmp(SearchExt->channelGroup, group->name) == 0)
- return SearchExt;
- SearchExt = SearchExts.Next(SearchExt);
+ while (SearchExt) {
+ if (SearchExt->useChannel == 2 && strcmp(SearchExt->channelGroup, group->name) == 0)
+ return SearchExt;
+ SearchExt = SearchExts.Next(SearchExt);
}
return NULL;
}
char** cChannelGroups::CreateMenuitemsList()
{
- char** menuitemsChGr = new char*[ChannelGroups.Count()+1];
+ char** menuitemsChGr = new char*[ChannelGroups.Count() + 1];
cChannelGroup* ChannelGroup = First();
menuitemsChGr[0] = strdup("");
int index = 1;
- while (ChannelGroup)
- {
- menuitemsChGr[index++] = ChannelGroup->name;
- ChannelGroup = Next(ChannelGroup);
+ while (ChannelGroup) {
+ menuitemsChGr[index++] = ChannelGroup->name;
+ ChannelGroup = Next(ChannelGroup);
}
return menuitemsChGr;
}
@@ -270,63 +254,59 @@ void cMenuChannelGroupItem::Set(void)
cChannelGroupItem* channelInGroup = group->channels.First();
int channelNr, chIntBegin = -1, chIntEnd = -1, chLast = -1;
- while (channelInGroup)
- {
- channelNr = channelInGroup->channel->Number();
- if (chIntBegin == -1)
- chIntBegin = channelNr;
- if (chIntEnd == -1)
- chIntEnd = channelNr;
-
- if (chLast == channelNr-1)
- chIntEnd = channelNr;
- else
- {
- chIntEnd = chLast;
- if(chIntBegin == chIntEnd)
- channelbuffer = cString::sprintf("%s %d", *channelbuffer?*channelbuffer:"", chIntBegin);
- else if (chIntEnd != -1)
- channelbuffer = cString::sprintf("%s %d-%d", *channelbuffer?*channelbuffer:"", chIntBegin, chIntEnd);
- chIntBegin = chIntEnd = channelNr;
- }
-
- chLast = channelNr;
- channelInGroup = group->channels.Next(channelInGroup);
- if (!channelInGroup)
- {
- if(chLast == chIntBegin)
- channelbuffer = cString::sprintf("%s %d", *channelbuffer?*channelbuffer:"", chIntBegin);
- else
- channelbuffer = cString::sprintf("%s %d-%d", *channelbuffer?*channelbuffer:"", chIntBegin, chLast);
- }
+ while (channelInGroup) {
+ channelNr = channelInGroup->channel->Number();
+ if (chIntBegin == -1)
+ chIntBegin = channelNr;
+ if (chIntEnd == -1)
+ chIntEnd = channelNr;
+
+ if (chLast == channelNr - 1)
+ chIntEnd = channelNr;
+ else {
+ chIntEnd = chLast;
+ if (chIntBegin == chIntEnd)
+ channelbuffer = cString::sprintf("%s %d", *channelbuffer ? *channelbuffer : "", chIntBegin);
+ else if (chIntEnd != -1)
+ channelbuffer = cString::sprintf("%s %d-%d", *channelbuffer ? *channelbuffer : "", chIntBegin, chIntEnd);
+ chIntBegin = chIntEnd = channelNr;
+ }
+
+ chLast = channelNr;
+ channelInGroup = group->channels.Next(channelInGroup);
+ if (!channelInGroup) {
+ if (chLast == chIntBegin)
+ channelbuffer = cString::sprintf("%s %d", *channelbuffer ? *channelbuffer : "", chIntBegin);
+ else
+ channelbuffer = cString::sprintf("%s %d-%d", *channelbuffer ? *channelbuffer : "", chIntBegin, chLast);
+ }
}
- SetText(cString::sprintf("%s\t%s", group->name, *channelbuffer?*channelbuffer:""));
+ SetText(cString::sprintf("%s\t%s", group->name, *channelbuffer ? *channelbuffer : ""));
}
// --- cMenuChannelGroups ----------------------------------------------------------
cMenuChannelGroups::cMenuChannelGroups(char** GroupName)
-:cOsdMenu(tr("Channel groups"),20)
+ : cOsdMenu(tr("Channel groups"), 20)
{
- SetMenuCategory(mcSetupPlugins);
+ SetMenuCategory(mcSetupPlugins);
groupSel = -1;
groupName = GroupName;
if (groupName && *groupName)
- groupSel = ChannelGroups.GetIndex(*groupName);
+ groupSel = ChannelGroups.GetIndex(*groupName);
cChannelGroup* ChannelGroup = ChannelGroups.First();
int index = 0;
- while (ChannelGroup)
- {
- Add(new cMenuChannelGroupItem(ChannelGroup), (index == groupSel?true:false));
- ChannelGroup = ChannelGroups.Next(ChannelGroup);
- index++;
+ while (ChannelGroup) {
+ Add(new cMenuChannelGroupItem(ChannelGroup), (index == groupSel ? true : false));
+ ChannelGroup = ChannelGroups.Next(ChannelGroup);
+ index++;
}
if (groupName && *groupName)
- SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), tr("Button$Select"));
+ SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), tr("Button$Select"));
else
- SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), NULL);
+ SetHelp(trVDR("Button$Edit"), trVDR("Button$New"), trVDR("Button$Delete"), NULL);
Sort();
Display();
}
@@ -340,29 +320,28 @@ cChannelGroup *cMenuChannelGroups::CurrentGroup(void)
eOSState cMenuChannelGroups::New(void)
{
if (HasSubMenu())
- return osContinue;
+ return osContinue;
return AddSubMenu(new cMenuEditChannelGroup(new cChannelGroup, true));
}
eOSState cMenuChannelGroups::Delete(void)
{
- cChannelGroup *curGroup = CurrentGroup();
- if (curGroup) {
- cSearchExt* search = ChannelGroups.Used(curGroup);
- if (search)
- {
- cString Message = cString::sprintf("%s %s", tr("Channel group used by:"), search->search);
- INFO(Message);
- return osContinue;
- }
- if (Interface->Confirm(tr("Edit$Delete group?"))) {
- ChannelGroups.Del(curGroup);
- ChannelGroups.Save();
- cOsdMenu::Del(Current());
- Display();
- }
- }
- return osContinue;
+ cChannelGroup *curGroup = CurrentGroup();
+ if (curGroup) {
+ cSearchExt* search = ChannelGroups.Used(curGroup);
+ if (search) {
+ cString Message = cString::sprintf("%s %s", tr("Channel group used by:"), search->search);
+ INFO(Message);
+ return osContinue;
+ }
+ if (Interface->Confirm(tr("Edit$Delete group?"))) {
+ ChannelGroups.Del(curGroup);
+ ChannelGroups.Save();
+ cOsdMenu::Del(Current());
+ Display();
+ }
+ }
+ return osContinue;
}
eOSState cMenuChannelGroups::ProcessKey(eKeys Key)
@@ -370,38 +349,39 @@ eOSState cMenuChannelGroups::ProcessKey(eKeys Key)
int GroupNumber = HasSubMenu() ? Count() : -1;
eOSState state = cOsdMenu::ProcessKey(Key);
- if (state == osUnknown)
- {
- if (HasSubMenu())
- return osContinue;
- switch (Key)
- {
- case kRed:
- if (CurrentGroup())
- state = AddSubMenu(new cMenuEditChannelGroup(CurrentGroup()));
- else
- state = osContinue;
- break;
- case kGreen: state = New(); break;
- case kYellow: state = Delete(); break;
-
- case kOk:
- case kBlue:
- if (groupName && *groupName)
- {
- free(*groupName);
- *groupName = strdup(CurrentGroup()->name);
- return osBack;
- }
- default: break;
- }
+ if (state == osUnknown) {
+ if (HasSubMenu())
+ return osContinue;
+ switch (Key) {
+ case kRed:
+ if (CurrentGroup())
+ state = AddSubMenu(new cMenuEditChannelGroup(CurrentGroup()));
+ else
+ state = osContinue;
+ break;
+ case kGreen:
+ state = New();
+ break;
+ case kYellow:
+ state = Delete();
+ break;
+
+ case kOk:
+ case kBlue:
+ if (groupName && *groupName) {
+ free(*groupName);
+ *groupName = strdup(CurrentGroup()->name);
+ return osBack;
+ }
+ default:
+ break;
+ }
}
- if (GroupNumber >= 0 && !HasSubMenu() && ChannelGroups.Get(GroupNumber))
- {
- // a newly created group was confirmed with Ok
- cChannelGroup* group = ChannelGroups.Get(GroupNumber);
- Add(new cMenuChannelGroupItem(group), true);
- Display();
+ if (GroupNumber >= 0 && !HasSubMenu() && ChannelGroups.Get(GroupNumber)) {
+ // a newly created group was confirmed with Ok
+ cChannelGroup* group = ChannelGroups.Get(GroupNumber);
+ Add(new cMenuChannelGroupItem(group), true);
+ Display();
}
return state;
@@ -409,15 +389,15 @@ eOSState cMenuChannelGroups::ProcessKey(eKeys Key)
// --- cMenuEditChannelGroup --------------------------------------------------------
cMenuEditChannelGroup::cMenuEditChannelGroup(cChannelGroup *Group, bool New)
-:cOsdMenu(tr("Edit channel group"),30)
+ : cOsdMenu(tr("Edit channel group"), 30)
{
- SetMenuCategory(mcSetupPlugins);
+ SetMenuCategory(mcSetupPlugins);
group = Group;
channelSel = group->CreateChannelSel();
strcpy(name, group->name);
addIfConfirmed = New;
if (group)
- Set();
+ Set();
}
cMenuEditChannelGroup::~cMenuEditChannelGroup()
@@ -430,19 +410,17 @@ void cMenuEditChannelGroup::Set()
int current = Current();
Clear();
- Add(new cMenuEditStrItem( tr("Group name"), name, sizeof(group->name), trVDR(FileNameChars)));
+ Add(new cMenuEditStrItem(tr("Group name"), name, sizeof(group->name), trVDR(FileNameChars)));
LOCK_CHANNELS_READ; // TODO THIS MAY LOCK Channels A LONG TIME!
const cChannel* channel = Channels->First();
int index = 0;
- while (channel)
- {
- if (channel->GroupSep())
- {
- channel = Channels->Next(channel);
- continue;
- }
- Add(new cMenuEditBoolItem( CHANNELNAME(channel), &channelSel[index++], trVDR("no"), trVDR("yes")));
- channel = Channels->Next(channel);
+ while (channel) {
+ if (channel->GroupSep()) {
+ channel = Channels->Next(channel);
+ continue;
+ }
+ Add(new cMenuEditBoolItem(CHANNELNAME(channel), &channelSel[index++], trVDR("no"), trVDR("yes")));
+ channel = Channels->Next(channel);
}
SetCurrent(Get(current));
@@ -451,84 +429,78 @@ void cMenuEditChannelGroup::Set()
eOSState cMenuEditChannelGroup::ProcessKey(eKeys Key)
{
- eOSState state = cOsdMenu::ProcessKey(Key);
-
- const char* ItemText = Get(Current())->Text();
- if (strlen(ItemText) > 0 && strstr(ItemText, tr("Group name")) != ItemText)
- SetHelp(tr("Button$Invert selection"), tr("Button$All yes"), tr("Button$All no"), NULL);
- else if (!InEditMode(ItemText, tr("Group name"), name))
- SetHelp(NULL, NULL, NULL, NULL);
-
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
- if (strlen(name) == 0)
- {
- ERROR(tr("Group name is empty!"));
- return osContinue;
- }
- if (addIfConfirmed && ChannelGroups.GetGroupByName(name))
- {
- ERROR(tr("Group name already exists!"));
- return osContinue;
- }
-
- {
- bool saveSearchExts = false;
- if (strcmp(group->name, name) != 0 && !addIfConfirmed) // if group name changed, update searches
- {
- cMutexLock SearchExtsLock(&SearchExts);
- cSearchExt *SearchExt = SearchExts.First();
- while (SearchExt) {
- if (SearchExt->useChannel == 2 &&
- SearchExt->channelGroup &&
- strcmp(SearchExt->channelGroup, group->name) == 0)
- {
- free(SearchExt->channelGroup);
- SearchExt->channelGroup = strdup(name);
- }
- SearchExt = SearchExts.Next(SearchExt);
- }
- saveSearchExts = true; // save them after groups are saved!
- }
-
- strcpy(group->name, name);
- group->CreateChannelList(channelSel);
- if (addIfConfirmed)
- ChannelGroups.Add(group);
- ChannelGroups.Save();
- if (saveSearchExts)
- SearchExts.Save();
- }
- addIfConfirmed = false;
- return osBack;
- break;
- case kRed:
- case kGreen:
- case kYellow:
- {
- LOCK_CHANNELS_READ;
- const cChannel* channel = Channels->First();
- int index = 0;
- while (channel)
- {
- if (channel->GroupSep())
- {
- channel = Channels->Next(channel);
- continue;
- }
-
- channelSel[index] = (Key == kGreen?1:(Key == kRed?1-channelSel[index]:0));
- index++;
- channel = Channels->Next(channel);
- }
- Set();
- Display();
- return osContinue;
- }
-
- default: break;
- }
- }
- return state;
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ const char* ItemText = Get(Current())->Text();
+ if (strlen(ItemText) > 0 && strstr(ItemText, tr("Group name")) != ItemText)
+ SetHelp(tr("Button$Invert selection"), tr("Button$All yes"), tr("Button$All no"), NULL);
+ else if (!InEditMode(ItemText, tr("Group name"), name))
+ SetHelp(NULL, NULL, NULL, NULL);
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
+ if (strlen(name) == 0) {
+ ERROR(tr("Group name is empty!"));
+ return osContinue;
+ }
+ if (addIfConfirmed && ChannelGroups.GetGroupByName(name)) {
+ ERROR(tr("Group name already exists!"));
+ return osContinue;
+ }
+
+ {
+ bool saveSearchExts = false;
+ if (strcmp(group->name, name) != 0 && !addIfConfirmed) { // if group name changed, update searches
+ cMutexLock SearchExtsLock(&SearchExts);
+ cSearchExt *SearchExt = SearchExts.First();
+ while (SearchExt) {
+ if (SearchExt->useChannel == 2 &&
+ SearchExt->channelGroup &&
+ strcmp(SearchExt->channelGroup, group->name) == 0) {
+ free(SearchExt->channelGroup);
+ SearchExt->channelGroup = strdup(name);
+ }
+ SearchExt = SearchExts.Next(SearchExt);
+ }
+ saveSearchExts = true; // save them after groups are saved!
+ }
+
+ strcpy(group->name, name);
+ group->CreateChannelList(channelSel);
+ if (addIfConfirmed)
+ ChannelGroups.Add(group);
+ ChannelGroups.Save();
+ if (saveSearchExts)
+ SearchExts.Save();
+ }
+ addIfConfirmed = false;
+ return osBack;
+ break;
+ case kRed:
+ case kGreen:
+ case kYellow: {
+ LOCK_CHANNELS_READ;
+ const cChannel* channel = Channels->First();
+ int index = 0;
+ while (channel) {
+ if (channel->GroupSep()) {
+ channel = Channels->Next(channel);
+ continue;
+ }
+
+ channelSel[index] = (Key == kGreen ? 1 : (Key == kRed ? 1 - channelSel[index] : 0));
+ index++;
+ channel = Channels->Next(channel);
+ }
+ Set();
+ Display();
+ return osContinue;
+ }
+
+ default:
+ break;
+ }
+ }
+ return state;
}
diff --git a/changrp.h b/changrp.h
index 1c5deb6..5044686 100644
--- a/changrp.h
+++ b/changrp.h
@@ -31,32 +31,35 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class cSearchExt;
// --- cChannelGroupItem --------------------------------------------------------
-class cChannelGroupItem : public cListObject {
+class cChannelGroupItem : public cListObject
+{
public:
const cChannel* channel;
public:
- cChannelGroupItem(const cChannel* ch) : channel(ch) {}
+ cChannelGroupItem(const cChannel* ch) : channel(ch) {}
};
// --- cChannelGroup --------------------------------------------------------
-class cChannelGroup : public cListObject {
+class cChannelGroup : public cListObject
+{
public:
char name[MaxFileName];
cList<cChannelGroupItem> channels;
public:
- cChannelGroup(void);
- virtual ~cChannelGroup(void);
-
- bool Parse(const char *s);
- const char *ToText(void);
- bool Save(FILE *f);
- int* CreateChannelSel();
- void CreateChannelList(int*);
- bool ChannelInGroup(const cChannel*);
+ cChannelGroup(void);
+ virtual ~cChannelGroup(void);
+
+ bool Parse(const char *s);
+ const char *ToText(void);
+ bool Save(FILE *f);
+ int* CreateChannelSel();
+ void CreateChannelList(int*);
+ bool ChannelInGroup(const cChannel*);
};
// --- cChannelGroups --------------------------------------------------------
-class cChannelGroups : public cConfig<cChannelGroup> {
+class cChannelGroups : public cConfig<cChannelGroup>
+{
private:
public:
cChannelGroups(void) {}
@@ -70,41 +73,44 @@ public:
extern cChannelGroups ChannelGroups;
// --- cMenuChannelGroupItem ----------------------------------------------------------
-class cMenuChannelGroupItem : public cOsdItem {
- private:
+class cMenuChannelGroupItem : public cOsdItem
+{
+private:
public:
cChannelGroup* group;
cMenuChannelGroupItem(cChannelGroup*);
void Set(void);
- };
+};
// --- cMenuChannelGroups --------------------------------------------------------
-class cMenuChannelGroups : public cOsdMenu {
- private:
+class cMenuChannelGroups : public cOsdMenu
+{
+private:
cChannelGroup *CurrentGroup(void);
eOSState New(void);
eOSState Delete(void);
int groupSel;
char** groupName;
- protected:
+protected:
virtual eOSState ProcessKey(eKeys Key);
- public:
+public:
cMenuChannelGroups(char** groupName = NULL);
};
// --- cMenuEditChannelGroup --------------------------------------------------------
-class cMenuEditChannelGroup : public cOsdMenu {
+class cMenuEditChannelGroup : public cOsdMenu
+{
private:
- cChannelGroup *group;
- bool addIfConfirmed;
- char name[MaxFileName];
- int* channelSel;
+ cChannelGroup *group;
+ bool addIfConfirmed;
+ char name[MaxFileName];
+ int* channelSel;
public:
- cMenuEditChannelGroup(cChannelGroup *group, bool New = false);
- ~cMenuEditChannelGroup();
- void Set();
- virtual eOSState ProcessKey(eKeys Key);
+ cMenuEditChannelGroup(cChannelGroup *group, bool New = false);
+ ~cMenuEditChannelGroup();
+ void Set();
+ virtual eOSState ProcessKey(eKeys Key);
};
#endif
diff --git a/confdloader.c b/confdloader.c
index 67d6261..c469540 100644
--- a/confdloader.c
+++ b/confdloader.c
@@ -38,33 +38,33 @@ using std::string;
// ---------------------------
bool cConfDLoader::Load()
{
- const string dirPath(AddDirectory(CONFIGDIR, "conf.d"));
- LogFile.Log(2, "loading entries in %s", dirPath.c_str());
- cReadDir d(dirPath.c_str());
- struct dirent* e;
- string parent("..");
- string current(".");
- int count = 0;
- bool success = true;
- while ((e = d.Next())) {
- string direntry = e->d_name;
- if ((current == direntry) || (parent == direntry) || (direntry[direntry.size()-1] == '~')) {
- continue;
+ const string dirPath(AddDirectory(CONFIGDIR, "conf.d"));
+ LogFile.Log(2, "loading entries in %s", dirPath.c_str());
+ cReadDir d(dirPath.c_str());
+ struct dirent* e;
+ string parent("..");
+ string current(".");
+ int count = 0;
+ bool success = true;
+ while ((e = d.Next())) {
+ string direntry = e->d_name;
+ if ((current == direntry) || (parent == direntry) || (direntry[direntry.size() - 1] == '~')) {
+ continue;
+ }
+ /* Check if entry is a directory: I do not rely on e->d_type
+ here because on some systems it is always DT_UNKNOWN. Also
+ testing for DT_DIR does not take into account symbolic
+ links to directories.
+ */
+ struct stat buf;
+ if ((stat((dirPath + "/" + e->d_name).c_str(), &buf) != 0) || (S_ISDIR(buf.st_mode))) {
+ continue;
+ }
+ success &= LoadFile((dirPath + "/" + e->d_name).c_str());
+ count++;
}
- /* Check if entry is a directory: I do not rely on e->d_type
- here because on some systems it is always DT_UNKNOWN. Also
- testing for DT_DIR does not take into account symbolic
- links to directories.
- */
- struct stat buf;
- if ((stat((dirPath + "/" + e->d_name).c_str(), &buf) != 0) || (S_ISDIR(buf.st_mode))) {
- continue;
- }
- success &= LoadFile((dirPath + "/" + e->d_name).c_str());
- count++;
- }
- LogFile.Log(2, "loaded %d entries in %s", count, dirPath.c_str());
- return success;
+ LogFile.Log(2, "loaded %d entries in %s", count, dirPath.c_str());
+ return success;
}
// ---------------------------
@@ -87,59 +87,54 @@ bool cConfDLoader::Load()
// ---------------------------
bool cConfDLoader::LoadFile(const char *FileName)
{
- if (FileName && access(FileName, F_OK) == 0) {
- LogFile.Log(1, "loading %s", FileName);
- FILE *f = fopen(FileName, "r");
- if (f) {
- char *s;
- int line = 0;
- cReadLine ReadLine;
- std::string section;
- while ((s = ReadLine.Read(f)) != NULL) {
- line++;
- char *p = strchr(s, '#');
- if (p)
- *p = 0;
- stripspace(s);
- if (!isempty(s)) {
- if (*s == '[' && *(s+strlen(s)-1)==']') // Section?
- section = s;
- else {
- if (EqualsNoCase(section, "[epgsearchuservars]"))
- cUserVarLine::Parse(s);
- if (EqualsNoCase(section, "[epgsearchdirs]"))
- {
- cDirExt* D = new cDirExt;
- if (D && D->Parse(s))
- ConfDDirExts.Add(D);
- else
- delete D;
- }
- if (EqualsNoCase(section, "[epgsearchmenu]"))
- {
- cTemplLine T;
- if (T.Parse(s))
- cTemplFile::Parse(T.Name(), T.Value());
- }
- if (EqualsNoCase(section, "[epgsearchcats]"))
- {
- cSearchExtCat* cat = new cSearchExtCat;
- if (cat && cat->Parse(s))
- SearchExtCats.Add(cat);
- else
- delete cat;
- }
- }
- }
- }
- fclose(f);
- }
- return true;
- }
- else
- {
- LOG_ERROR_STR(FileName);
- return false;
+ if (FileName && access(FileName, F_OK) == 0) {
+ LogFile.Log(1, "loading %s", FileName);
+ FILE *f = fopen(FileName, "r");
+ if (f) {
+ char *s;
+ int line = 0;
+ cReadLine ReadLine;
+ std::string section;
+ while ((s = ReadLine.Read(f)) != NULL) {
+ line++;
+ char *p = strchr(s, '#');
+ if (p)
+ *p = 0;
+ stripspace(s);
+ if (!isempty(s)) {
+ if (*s == '[' && *(s + strlen(s) - 1) == ']') // Section?
+ section = s;
+ else {
+ if (EqualsNoCase(section, "[epgsearchuservars]"))
+ cUserVarLine::Parse(s);
+ if (EqualsNoCase(section, "[epgsearchdirs]")) {
+ cDirExt* D = new cDirExt;
+ if (D && D->Parse(s))
+ ConfDDirExts.Add(D);
+ else
+ delete D;
+ }
+ if (EqualsNoCase(section, "[epgsearchmenu]")) {
+ cTemplLine T;
+ if (T.Parse(s))
+ cTemplFile::Parse(T.Name(), T.Value());
+ }
+ if (EqualsNoCase(section, "[epgsearchcats]")) {
+ cSearchExtCat* cat = new cSearchExtCat;
+ if (cat && cat->Parse(s))
+ SearchExtCats.Add(cat);
+ else
+ delete cat;
+ }
+ }
+ }
+ }
+ fclose(f);
+ }
+ return true;
+ } else {
+ LOG_ERROR_STR(FileName);
+ return false;
}
}
diff --git a/confdloader.h b/confdloader.h
index 9741be8..6e52661 100644
--- a/confdloader.h
+++ b/confdloader.h
@@ -24,11 +24,12 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#ifndef VDR_EPGSEARCH_CONFDLOADER_INC
#define VDR_EPGSEARCH_CONFDLOADER_INC
-class cConfDLoader {
- public:
- cConfDLoader() {}
- bool Load();
- bool LoadFile(const char *FileName);
+class cConfDLoader
+{
+public:
+ cConfDLoader() {}
+ bool Load();
+ bool LoadFile(const char *FileName);
};
#endif
diff --git a/conflictcheck.c b/conflictcheck.c
index 8e6bd53..14ac636 100644
--- a/conflictcheck.c
+++ b/conflictcheck.c
@@ -47,8 +47,8 @@ cConflictCheckTimerObj::cConflictCheckTimerObj(cTimer* Timer, time_t Start, time
cConflictCheckTimerObj::~cConflictCheckTimerObj()
{
- // conflict checks works on a copy of a timer, so delete it again
- DELETENULL(timer);
+ // conflict checks works on a copy of a timer, so delete it again
+ DELETENULL(timer);
}
int cConflictCheckTimerObj::Compare(const cListObject &ListObject) const
@@ -56,19 +56,18 @@ int cConflictCheckTimerObj::Compare(const cListObject &ListObject) const
cConflictCheckTimerObj *p = (cConflictCheckTimerObj *)&ListObject;
long diff = start - p->start;
if (diff == 0)
- diff = p->timer->Priority() - timer->Priority();
+ diff = p->timer->Priority() - timer->Priority();
if (diff == 0)
- diff = origIndex - p->origIndex;
+ diff = origIndex - p->origIndex;
return diff;
}
const cEvent* cConflictCheckTimerObj::Event()
{
- if(timer->Event())
- return timer->Event();
- else
- if (!event)
- event = SetEventFromSchedule();
+ if (timer->Event())
+ return timer->Event();
+ else if (!event)
+ event = SetEventFromSchedule();
return event;
}
@@ -76,86 +75,79 @@ const cEvent* cConflictCheckTimerObj::SetEventFromSchedule()
{
LOCK_SCHEDULES_READ;
if (!Schedules)
- return NULL;
+ return NULL;
const cSchedule *Schedule = Schedules->GetSchedule(timer->Channel());
- if (Schedule && Schedule->Events()->First())
- {
- const cEvent *Event = NULL;
- if (timer->HasFlags(tfVps) && Schedule->Events()->First()->Vps())
- {
- // VPS timers only match if their start time exactly matches the event's VPS time:
- for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e))
- {
- if (e->StartTime() && e->RunningStatus() != SI::RunningStatusNotRunning)
- { // skip outdated events
- int overlap = 0;
- Matches(e, &overlap);
- if (overlap > FULLMATCH) {
- Event = e;
- break; // take the first matching event
- }
- }
- }
- }
- else
- {
- // Normal timers match the event they have the most overlap with:
- int Overlap = 0;
- // Set up the time frame within which to check events:
- timer->Matches(0, true);
- time_t TimeFrameBegin = start - EPGLIMITBEFORE;
- time_t TimeFrameEnd = stop + EPGLIMITAFTER;
- for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e))
- {
- if (e->EndTime() < TimeFrameBegin)
- continue; // skip events way before the timer starts
- if (e->StartTime() > TimeFrameEnd)
- break; // the rest is way after the timer ends
- int overlap = 0;
- Matches(e, &overlap);
- if (overlap && overlap >= Overlap)
- {
- if (Event && overlap == Overlap && e->Duration() <= Event->Duration())
- continue; // if overlap is the same, we take the longer event
- Overlap = overlap;
- Event = e;
- }
- }
- }
- return Event;
+ if (Schedule && Schedule->Events()->First()) {
+ const cEvent *Event = NULL;
+ if (timer->HasFlags(tfVps) && Schedule->Events()->First()->Vps()) {
+ // VPS timers only match if their start time exactly matches the event's VPS time:
+ for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e)) {
+ if (e->StartTime() && e->RunningStatus() != SI::RunningStatusNotRunning) {
+ // skip outdated events
+ int overlap = 0;
+ Matches(e, &overlap);
+ if (overlap > FULLMATCH) {
+ Event = e;
+ break; // take the first matching event
+ }
+ }
+ }
+ } else {
+ // Normal timers match the event they have the most overlap with:
+ int Overlap = 0;
+ // Set up the time frame within which to check events:
+ timer->Matches(0, true);
+ time_t TimeFrameBegin = start - EPGLIMITBEFORE;
+ time_t TimeFrameEnd = stop + EPGLIMITAFTER;
+ for (const cEvent *e = Schedule->Events()->First(); e; e = Schedule->Events()->Next(e)) {
+ if (e->EndTime() < TimeFrameBegin)
+ continue; // skip events way before the timer starts
+ if (e->StartTime() > TimeFrameEnd)
+ break; // the rest is way after the timer ends
+ int overlap = 0;
+ Matches(e, &overlap);
+ if (overlap && overlap >= Overlap) {
+ if (Event && overlap == Overlap && e->Duration() <= Event->Duration())
+ continue; // if overlap is the same, we take the longer event
+ Overlap = overlap;
+ Event = e;
+ }
+ }
+ }
+ return Event;
}
return NULL;
}
int cConflictCheckTimerObj::Matches(const cEvent *Event, int *Overlap) const
{
- // Overlap is the percentage of the Event's duration that is covered by
- // this timer (based on FULLMATCH for finer granularity than just 100).
- // To make sure a VPS timer can be distinguished from a plain 100% overlap,
- // it gets an additional 100 added, and a VPS event that is actually running
- // gets 200 added to the FULLMATCH.
- if (timer->Channel()->GetChannelID() == Event->ChannelID()) {
- bool UseVps = timer->HasFlags(tfVps) && Event->Vps();
- timer->Matches(UseVps ? Event->Vps() : Event->StartTime(), true);
- int overlap = 0;
- if (UseVps)
- overlap = (start == Event->Vps()) ? FULLMATCH + (Event->IsRunning() ? 200 : 100) : 0;
- if (!overlap) {
- if (start <= Event->StartTime() && Event->EndTime() <= stop)
- overlap = FULLMATCH;
- else if (stop <= Event->StartTime() || Event->EndTime() <= start)
- overlap = 0;
- else
- overlap = (std::min(stop, Event->EndTime()) - std::max(start, Event->StartTime())) * FULLMATCH / std::max(Event->Duration(), 1);
+ // Overlap is the percentage of the Event's duration that is covered by
+ // this timer (based on FULLMATCH for finer granularity than just 100).
+ // To make sure a VPS timer can be distinguished from a plain 100% overlap,
+ // it gets an additional 100 added, and a VPS event that is actually running
+ // gets 200 added to the FULLMATCH.
+ if (timer->Channel()->GetChannelID() == Event->ChannelID()) {
+ bool UseVps = timer->HasFlags(tfVps) && Event->Vps();
+ timer->Matches(UseVps ? Event->Vps() : Event->StartTime(), true);
+ int overlap = 0;
+ if (UseVps)
+ overlap = (start == Event->Vps()) ? FULLMATCH + (Event->IsRunning() ? 200 : 100) : 0;
+ if (!overlap) {
+ if (start <= Event->StartTime() && Event->EndTime() <= stop)
+ overlap = FULLMATCH;
+ else if (stop <= Event->StartTime() || Event->EndTime() <= start)
+ overlap = 0;
+ else
+ overlap = (std::min(stop, Event->EndTime()) - std::max(start, Event->StartTime())) * FULLMATCH / std::max(Event->Duration(), 1);
}
- if (Overlap)
- *Overlap = overlap;
- if (UseVps)
- return overlap > FULLMATCH ? tmFull : tmNone;
- return overlap >= FULLMATCH ? tmFull : overlap > 0 ? tmPartial : tmNone;
- }
- return tmNone;
+ if (Overlap)
+ *Overlap = overlap;
+ if (UseVps)
+ return overlap > FULLMATCH ? tmFull : tmNone;
+ return overlap >= FULLMATCH ? tmFull : overlap > 0 ? tmPartial : tmNone;
+ }
+ return tmNone;
}
// --- cConflictCheck -------------------------------------------------------
@@ -173,18 +165,16 @@ cConflictCheck::cConflictCheck()
cConflictCheck::~cConflictCheck()
{
- if (evaltimeList)
- {
- evaltimeList->Clear();
- DELETENULL(evaltimeList);
+ if (evaltimeList) {
+ evaltimeList->Clear();
+ DELETENULL(evaltimeList);
}
- if (timerList)
- {
- timerList->Clear();
- DELETENULL(timerList);
+ if (timerList) {
+ timerList->Clear();
+ DELETENULL(timerList);
}
if (devices)
- delete [] devices;
+ delete [] devices;
}
void cConflictCheck::InitDevicesInfo()
@@ -195,15 +185,14 @@ void cConflictCheck::InitDevicesInfo()
devices = new cConflictCheckDevice[MAXDEVICES];
#ifdef DEBUG_CONFL
numDevices = 4;
- for(int i=0; i<numDevices; i++)
- {
- devices[i].devicenr = i;
- devices[i].device = NULL;
+ for (int i = 0; i < numDevices; i++) {
+ devices[i].devicenr = i;
+ devices[i].device = NULL;
}
#else
numDevices = cDevice::NumDevices();
- for(int i=0; i<numDevices; i++)
- devices[i].device = cDevice::GetDevice(i);
+ for (int i = 0; i < numDevices; i++)
+ devices[i].device = cDevice::GetDevice(i);
#endif
BondDevices(Setup.DeviceBondings);
@@ -211,257 +200,231 @@ void cConflictCheck::InitDevicesInfo()
void cConflictCheck::BondDevices(const char *Bondings)
{
- LogFile.Log(3, "Bond Devices");
- if (Bondings) {
- cSatCableNumbers SatCableNumbers(MAXDEVICES, Bondings);
- int* array = SatCableNumbers.Array();
- for (int i=0; i<SatCableNumbers.Size(); i++) {
- for (int j=0; j<SatCableNumbers.Size(); j++) {
- if (array[i] > 0 && array[i] == array[j] && i != j) {
- LogFile.Log(3, "Bond devices %i and %i.", i+1, j+1);
- devices[i].bondedDevices.push_back(&(devices[j]));
- }
- }
+ LogFile.Log(3, "Bond Devices");
+ if (Bondings) {
+ cSatCableNumbers SatCableNumbers(MAXDEVICES, Bondings);
+ int* array = SatCableNumbers.Array();
+ for (int i = 0; i < SatCableNumbers.Size(); i++) {
+ for (int j = 0; j < SatCableNumbers.Size(); j++) {
+ if (array[i] > 0 && array[i] == array[j] && i != j) {
+ LogFile.Log(3, "Bond devices %i and %i.", i + 1, j + 1);
+ devices[i].bondedDevices.push_back(&(devices[j]));
+ }
+ }
+ }
}
- }
- LogFile.Log(3, "Bond Devices done.");
+ LogFile.Log(3, "Bond Devices done.");
}
void cConflictCheck::Check()
{
if (evaltimeList)
- DELETENULL(evaltimeList);
+ DELETENULL(evaltimeList);
if (timerList)
- DELETENULL(timerList);
+ DELETENULL(timerList);
- LogFile.Log(3, "check only local conflicts = %s",GetLocal()?"yes":"no");
+ LogFile.Log(3, "check only local conflicts = %s", GetLocal() ? "yes" : "no");
timerList = CreateCurrentTimerList();
if (timerList) evaltimeList = CreateEvaluationTimeList(timerList);
if (evaltimeList) failedList = CreateConflictList(evaltimeList, timerList);
- if ((!localConflicts) && timerList) CreateRemoteConflictList(timerList,failedList);
+ if ((!localConflicts) && timerList) CreateRemoteConflictList(timerList, failedList);
if (failedList)
- for(cConflictCheckTime* checkTime = failedList->First(); checkTime; checkTime = failedList->Next(checkTime))
- {
- LogFile.Log(2,"result of conflict check for %s:", DAYDATETIME(checkTime->evaltime));
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
- for (it = checkTime->failedTimers.begin(); it != checkTime->failedTimers.end(); ++it)
- {
- if (!localConflicts)
- LogFile.Log(2,"timer '%s' (%s, channel %s) %s%s failed", (*it)->timer->File(), DAYDATETIME((*it)->timer->StartTime()), CHANNELNAME((*it)->timer->Channel()), (*it)->timer->Remote()?"@":"",(*it)->timer->Remote()?(*it)->timer->Remote():"");
- else
- LogFile.Log(2,"timer '%s' (%s, channel %s) failed", (*it)->timer->File(), DAYDATETIME((*it)->timer->StartTime()), CHANNELNAME((*it)->timer->Channel()));
+ for (cConflictCheckTime* checkTime = failedList->First(); checkTime; checkTime = failedList->Next(checkTime)) {
+ LogFile.Log(2, "result of conflict check for %s:", DAYDATETIME(checkTime->evaltime));
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
+ for (it = checkTime->failedTimers.begin(); it != checkTime->failedTimers.end(); ++it) {
+ if (!localConflicts)
+ LogFile.Log(2, "timer '%s' (%s, channel %s) %s%s failed", (*it)->timer->File(), DAYDATETIME((*it)->timer->StartTime()), CHANNELNAME((*it)->timer->Channel()), (*it)->timer->Remote() ? "@" : "", (*it)->timer->Remote() ? (*it)->timer->Remote() : "");
+ else
+ LogFile.Log(2, "timer '%s' (%s, channel %s) failed", (*it)->timer->File(), DAYDATETIME((*it)->timer->StartTime()), CHANNELNAME((*it)->timer->Channel()));
+ }
}
- }
if (numConflicts > 0 && gl_timerStatusMonitor)
- gl_timerStatusMonitor->SetConflictCheckAdvised();
+ gl_timerStatusMonitor->SetConflictCheckAdvised();
}
cList<cConflictCheckTimerObj>* cConflictCheck::CreateCurrentTimerList()
{
- LogFile.Log(3,"current timer list creation started");
+ LogFile.Log(3, "current timer list creation started");
cList<cConflictCheckTimerObj>* CurrentTimerList = NULL;
// collect single event timers
time_t tMax = 0;
LOCK_TIMERS_READ;
const cTimer* ti = NULL;
- for (ti = Timers->First(); ti; ti = Timers->Next(ti))
- {
- tMax = std::max(tMax, ti->StartTime());
- if (localConflicts && ti->Remote()) continue;
- if (!ti->IsSingleEvent()) continue;
+ for (ti = Timers->First(); ti; ti = Timers->Next(ti)) {
+ tMax = std::max(tMax, ti->StartTime());
+ if (localConflicts && ti->Remote()) continue;
+ if (!ti->IsSingleEvent()) continue;
// already recording?
- int deviceNr = -1;
- if (ti->Local()) // we check devices only for local timers
- deviceNr = gl_recStatusMonitor->TimerRecDevice(ti)-1;
-
- // create a copy of this timer
- cTimer* clone = new cTimer(*ti);
- clone->SetEvent(ti->Event());
-
- cConflictCheckTimerObj* timerObj = new cConflictCheckTimerObj(clone, ti->StartTime(), ti->StopTime(), deviceNr, ti->Id());
- if (deviceNr >= 0)
- {
- devices[deviceNr].recTimers.insert(timerObj);
- timerObj->lastRecStart = ti->StartTime();
- }
- LogFile.Log(3,"add timer '%s' (%s, channel %s) for conflict check", ti->File(), DAYDATETIME(ti->StartTime()), CHANNELNAME(ti->Channel()));
- if (deviceNr >= 0)
- LogFile.Log(3,"timer already recording since %s on device %d", DAYDATETIME(ti->StartTime()), deviceNr+1);
-
- if (!CurrentTimerList) CurrentTimerList = new cList<cConflictCheckTimerObj>;
- CurrentTimerList->Add(timerObj);
+ int deviceNr = -1;
+ if (ti->Local()) // we check devices only for local timers
+ deviceNr = gl_recStatusMonitor->TimerRecDevice(ti) - 1;
+
+ // create a copy of this timer
+ cTimer* clone = new cTimer(*ti);
+ clone->SetEvent(ti->Event());
+
+ cConflictCheckTimerObj* timerObj = new cConflictCheckTimerObj(clone, ti->StartTime(), ti->StopTime(), deviceNr, ti->Id());
+ if (deviceNr >= 0) {
+ devices[deviceNr].recTimers.insert(timerObj);
+ timerObj->lastRecStart = ti->StartTime();
+ }
+ LogFile.Log(3, "add timer '%s' (%s, channel %s) for conflict check", ti->File(), DAYDATETIME(ti->StartTime()), CHANNELNAME(ti->Channel()));
+ if (deviceNr >= 0)
+ LogFile.Log(3, "timer already recording since %s on device %d", DAYDATETIME(ti->StartTime()), deviceNr + 1);
+
+ if (!CurrentTimerList) CurrentTimerList = new cList<cConflictCheckTimerObj>;
+ CurrentTimerList->Add(timerObj);
}
// collect repeating timers from now until the date of the timer with tMax
- time_t maxCheck = time(NULL) + std::min(14,EPGSearchConfig.checkMaxDays) * SECSINDAY;
+ time_t maxCheck = time(NULL) + std::min(14, EPGSearchConfig.checkMaxDays) * SECSINDAY;
tMax = std::max(tMax, maxCheck);
- for (ti = Timers->First(); ti; ti = Timers->Next(ti))
- {
- if (ti->IsSingleEvent()) continue;
- if (localConflicts && ti->Remote()) continue; //JF???
- time_t day = time(NULL);
- while(day < tMax)
- {
- if (ti->DayMatches(day))
- {
- time_t Start = cTimer::SetTime(day, cTimer::TimeToInt(ti->Start()));
- int deviceNr = -1;
- if (Start < time(NULL))
- {
+ for (ti = Timers->First(); ti; ti = Timers->Next(ti)) {
+ if (ti->IsSingleEvent()) continue;
+ if (localConflicts && ti->Remote()) continue; //JF???
+ time_t day = time(NULL);
+ while (day < tMax) {
+ if (ti->DayMatches(day)) {
+ time_t Start = cTimer::SetTime(day, cTimer::TimeToInt(ti->Start()));
+ int deviceNr = -1;
+ if (Start < time(NULL)) {
#ifndef DEBUG_CONFL
- if (ti->Local() && ti->Recording())
- deviceNr = gl_recStatusMonitor->TimerRecDevice(ti)-1;
+ if (ti->Local() && ti->Recording())
+ deviceNr = gl_recStatusMonitor->TimerRecDevice(ti) - 1;
#else
- if (Start + ti->StopTime() - ti->StartTime() > time(NULL))
- deviceNr = 0;
+ if (Start + ti->StopTime() - ti->StartTime() > time(NULL))
+ deviceNr = 0;
#endif
- if (deviceNr == -1) // currently not recording, skip it
- {
- day += SECSINDAY;
- continue;
- }
- }
- else if (Start < ti->StartTime())
- {
- day += SECSINDAY;
- continue;
- }
-
- // create a copy of this timer
- cTimer* clone = new cTimer(*ti);
- clone->SetEvent(ti->Event());
-
- cConflictCheckTimerObj* timerObj = new cConflictCheckTimerObj(clone, Start, Start + ti->StopTime() - ti->StartTime(), deviceNr, ti->Id());
- LogFile.Log(3,"add timer '%s' (%s, channel %s) for conflict check", ti->File(), DAYDATETIME(Start), CHANNELNAME(ti->Channel()));
- if (deviceNr >= 0)
- {
- LogFile.Log(3,"timer already recording since %s on device %d", DAYDATETIME(Start), deviceNr+1);
- devices[deviceNr].recTimers.insert(timerObj);
- timerObj->lastRecStart = Start;
- }
- if (!CurrentTimerList) CurrentTimerList = new cList<cConflictCheckTimerObj>;
- CurrentTimerList->Add(timerObj);
- }
- day += SECSINDAY;
- }
- }
+ if (deviceNr == -1) { // currently not recording, skip it
+ day += SECSINDAY;
+ continue;
+ }
+ } else if (Start < ti->StartTime()) {
+ day += SECSINDAY;
+ continue;
+ }
+
+ // create a copy of this timer
+ cTimer* clone = new cTimer(*ti);
+ clone->SetEvent(ti->Event());
+
+ cConflictCheckTimerObj* timerObj = new cConflictCheckTimerObj(clone, Start, Start + ti->StopTime() - ti->StartTime(), deviceNr, ti->Id());
+ LogFile.Log(3, "add timer '%s' (%s, channel %s) for conflict check", ti->File(), DAYDATETIME(Start), CHANNELNAME(ti->Channel()));
+ if (deviceNr >= 0) {
+ LogFile.Log(3, "timer already recording since %s on device %d", DAYDATETIME(Start), deviceNr + 1);
+ devices[deviceNr].recTimers.insert(timerObj);
+ timerObj->lastRecStart = Start;
+ }
+ if (!CurrentTimerList) CurrentTimerList = new cList<cConflictCheckTimerObj>;
+ CurrentTimerList->Add(timerObj);
+ }
+ day += SECSINDAY;
+ }
+ }
if (CurrentTimerList) CurrentTimerList->Sort();
- LogFile.Log(3,"current timer list created");
+ LogFile.Log(3, "current timer list created");
return CurrentTimerList;
}
// create a list of all times that have to be checked
cList<cConflictCheckTime>* cConflictCheck::CreateEvaluationTimeList(cList<cConflictCheckTimerObj>* TimerList)
{
- LogFile.Log(3,"create check time list");
+ LogFile.Log(3, "create check time list");
cList<cConflictCheckTime>* EvalTimeList = NULL;
- for(cConflictCheckTimerObj* TimerObj= TimerList->First(); TimerObj; TimerObj = TimerList->Next(TimerObj))
- {
- if (!TimerObj->timer->HasFlags(tfActive)) continue;
-
- if (TimerObj->timer->Remote()) continue; // here we check local timers only
-
- if (!EvalTimeList) EvalTimeList = new cList<cConflictCheckTime>;
-
- cConflictCheckTime* checkTime = NULL;
-
- // add all timer start times
- for(cConflictCheckTime* checkTimeTest = EvalTimeList->First(); checkTimeTest; checkTimeTest = EvalTimeList->Next(checkTimeTest))
- {
- if (checkTimeTest->evaltime == TimerObj->start)
- {
- checkTime = checkTimeTest;
- break;
- }
- }
- if (!checkTime)
- {
- checkTime = new cConflictCheckTime(TimerObj->start);
- EvalTimeList->Add(checkTime);
- }
- checkTime->startingTimers.insert(TimerObj);
-
-
- // add all timer stop times
- checkTime = NULL;
- for(cConflictCheckTime* checkTimeTest = EvalTimeList->First(); checkTimeTest; checkTimeTest = EvalTimeList->Next(checkTimeTest))
- {
- if (checkTimeTest->evaltime == TimerObj->stop)
- {
- checkTime = checkTimeTest;
- break;
- }
- }
- if (!checkTime)
- {
- checkTime = new cConflictCheckTime(TimerObj->stop);
- EvalTimeList->Add(checkTime);
- }
- checkTime->stoppingTimers.insert(TimerObj);
+ for (cConflictCheckTimerObj* TimerObj = TimerList->First(); TimerObj; TimerObj = TimerList->Next(TimerObj)) {
+ if (!TimerObj->timer->HasFlags(tfActive)) continue;
+
+ if (TimerObj->timer->Remote()) continue; // here we check local timers only
+
+ if (!EvalTimeList) EvalTimeList = new cList<cConflictCheckTime>;
+
+ cConflictCheckTime* checkTime = NULL;
+
+ // add all timer start times
+ for (cConflictCheckTime* checkTimeTest = EvalTimeList->First(); checkTimeTest; checkTimeTest = EvalTimeList->Next(checkTimeTest)) {
+ if (checkTimeTest->evaltime == TimerObj->start) {
+ checkTime = checkTimeTest;
+ break;
+ }
+ }
+ if (!checkTime) {
+ checkTime = new cConflictCheckTime(TimerObj->start);
+ EvalTimeList->Add(checkTime);
+ }
+ checkTime->startingTimers.insert(TimerObj);
+
+
+ // add all timer stop times
+ checkTime = NULL;
+ for (cConflictCheckTime* checkTimeTest = EvalTimeList->First(); checkTimeTest; checkTimeTest = EvalTimeList->Next(checkTimeTest)) {
+ if (checkTimeTest->evaltime == TimerObj->stop) {
+ checkTime = checkTimeTest;
+ break;
+ }
+ }
+ if (!checkTime) {
+ checkTime = new cConflictCheckTime(TimerObj->stop);
+ EvalTimeList->Add(checkTime);
+ }
+ checkTime->stoppingTimers.insert(TimerObj);
}
if (EvalTimeList)
- EvalTimeList->Sort();
+ EvalTimeList->Sort();
- LogFile.Log(3,"create check time list - done");
+ LogFile.Log(3, "create check time list - done");
return EvalTimeList;
}
// this return a list of all conflicts
cList<cConflictCheckTime>* cConflictCheck::CreateConflictList(cList<cConflictCheckTime>* EvalTimeList, cList<cConflictCheckTimerObj>* TimerList)
{
- LogFile.Log(3,"create conflict list");
+ LogFile.Log(3, "create conflict list");
relevantConflicts = 0;
numConflicts = 0;
maxCheck = time(NULL) + std::min(14, EPGSearchConfig.checkMaxDays) * SECSINDAY;
// check each time
- for(cConflictCheckTime* checkTime = EvalTimeList->First(); checkTime; checkTime = EvalTimeList->Next(checkTime))
- {
- int Conflicts = ProcessCheckTime(checkTime);
- if (Conflicts > 0) // if there were conflicts do a retry as VDR would do a few seconds after the conflict
- {
- LogFile.Log(3,"retry check time %s", DAYDATETIME(checkTime->evaltime));
- int OldConflicts = Conflicts;
- while(true)
- {
- Conflicts = ProcessCheckTime(checkTime);
- if (Conflicts == OldConflicts) break; // no change after retry?
- OldConflicts = Conflicts;
- };
- }
+ for (cConflictCheckTime* checkTime = EvalTimeList->First(); checkTime; checkTime = EvalTimeList->Next(checkTime)) {
+ int Conflicts = ProcessCheckTime(checkTime);
+ if (Conflicts > 0) { // if there were conflicts do a retry as VDR would do a few seconds after the conflict
+ LogFile.Log(3, "retry check time %s", DAYDATETIME(checkTime->evaltime));
+ int OldConflicts = Conflicts;
+ while (true) {
+ Conflicts = ProcessCheckTime(checkTime);
+ if (Conflicts == OldConflicts) break; // no change after retry?
+ OldConflicts = Conflicts;
+ };
+ }
}
nextRelevantConflictDate = 0;
- for(cConflictCheckTime* checkTime = EvalTimeList->First(); checkTime;) // clear the list
- {
- cConflictCheckTime* checkTimeNext = EvalTimeList->Next(checkTime);
- if (checkTime->failedTimers.empty())
- EvalTimeList->Del(checkTime);
- else
- {
- bool allTimersIgnored = true;
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
- for (it = checkTime->failedTimers.begin(); it != checkTime->failedTimers.end(); ++it)
- {
- numConflicts++;
- if (!(*it)->ignore)
- {
- if (!nextRelevantConflictDate)
- nextRelevantConflictDate = checkTime->evaltime;
- else
- nextRelevantConflictDate = std::min(nextRelevantConflictDate, checkTime->evaltime);
-
- relevantConflicts++;
- allTimersIgnored = false;
- break;
- }
- }
- if (allTimersIgnored)
- checkTime->ignore = true;
- }
- checkTime = checkTimeNext;
+ for (cConflictCheckTime* checkTime = EvalTimeList->First(); checkTime;) { // clear the list
+ cConflictCheckTime* checkTimeNext = EvalTimeList->Next(checkTime);
+ if (checkTime->failedTimers.empty())
+ EvalTimeList->Del(checkTime);
+ else {
+ bool allTimersIgnored = true;
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
+ for (it = checkTime->failedTimers.begin(); it != checkTime->failedTimers.end(); ++it) {
+ numConflicts++;
+ if (!(*it)->ignore) {
+ if (!nextRelevantConflictDate)
+ nextRelevantConflictDate = checkTime->evaltime;
+ else
+ nextRelevantConflictDate = std::min(nextRelevantConflictDate, checkTime->evaltime);
+
+ relevantConflicts++;
+ allTimersIgnored = false;
+ break;
+ }
+ }
+ if (allTimersIgnored)
+ checkTime->ignore = true;
+ }
+ checkTime = checkTimeNext;
}
// store for external access
@@ -469,143 +432,121 @@ cList<cConflictCheckTime>* cConflictCheck::CreateConflictList(cList<cConflictChe
cConflictCheckThread::m_cacheRelevantConflicts = relevantConflicts;
cConflictCheckThread::m_cacheTotalConflicts = numConflicts;
- LogFile.Log(3,"create conflict list - done");
+ LogFile.Log(3, "create conflict list - done");
return EvalTimeList;
}
void cConflictCheck::CreateRemoteConflictList(cList<cConflictCheckTimerObj>* TimerList, cList<cConflictCheckTime>* failedList)
{
- LogFile.Log(3,"add remote conflicts to list");
- bool foundRemote = false;
- cStringList RemoteHosts;
- // check if we have any Remote timers
- RemoteHosts.Clear();
- for(cConflictCheckTimerObj* TimerObj= TimerList->First(); TimerObj; TimerObj = TimerList->Next(TimerObj))
- {
- if (!TimerObj->timer->HasFlags(tfActive)) continue;
-
- if (TimerObj->timer->Remote())
- {
- if (RemoteHosts.Find(TimerObj->timer->Remote()) < 0)
- {
- foundRemote = true;
- RemoteHosts.Append(strdup(TimerObj->timer->Remote()));
- }
- }
- }
-
- if (!foundRemote)
- {
- LogFile.Log(3,"no remote timers to add");
- return;
- }
-
- RemoteHosts.Sort();
-
- cStringList Response;
- // for all RemoteHosts
- for (int i=0; i< RemoteHosts.Size(); i++)
- {
- Response.Clear();
- if (ExecSVDRPCommand(RemoteHosts[i], "PLUG epgsearch LSCC REL", &Response))
- {
- for (int j = 0; j < Response.Size(); j++)
- {
- const char *s = Response[j];
- int Code = SVDRPCode(s);
- if (Code == 901)
- {
- LogFile.Log(3,"conflictcheck %s no remote conflicts found",RemoteHosts[i]);
- continue;
- } else if (Code != 900)
- {
- LogFile.Log(2,"Invalid remote response %d %s", Code,
- SVDRPValue(s));
- break;
- } else if (const char* line = SVDRPValue(s))
- {
- LogFile.Log(2,"remote conflictcheck line %s",line);
- int Id,recPart;
- char rest[256];
- time_t evaltime;
- sscanf(line,"%ld:%d|%s",&evaltime,&Id,rest);
- cConflictCheckTime* checkTime = new cConflictCheckTime(evaltime);
- if (!failedList)
- failedList = new cList<cConflictCheckTime>;
- LogFile.Log(2,"added remote checkTime %s to failedList",DAYDATETIME(evaltime));
- failedList->Add(checkTime);
- numConflicts++;
- // find TimerObj with id Id in timerList
- cConflictCheckTimerObj* failedTimer = NULL;
- bool foundfT = false;
- for(failedTimer = TimerList->First(); failedTimer; failedTimer = TimerList->Next(failedTimer))
- {
- if (failedTimer->timer->Id() == Id)
- {
- foundfT = true;
- break;
- }
- }
- if (!foundfT)
- {
- LogFile.Log(2,"remote failed Timer disappeared");
- continue;
- }
- LogFile.Log(2,"create remote failedTimer with Id %d",Id);
- failedTimer->conflCheckTime = checkTime;
- failedTimer->origIndex = Id;
- sscanf(rest,"%d|%s",&recPart,rest);
- failedTimer->recDuration=((failedTimer->stop-failedTimer->start)* recPart / 100);
- cConflictCheckTimerObj* concurrentTimer = NULL;
- while (strlen(rest) > 0)
- {
- int n = sscanf(rest,"%d#%s",&Id,rest);
- if (n < 2)
- {
- if (sscanf(rest,"%d",&Id) <= 0)
- {
- LogFile.Log(2,"error scanning rest of line %s",rest);
- break;
- }
- *rest = 0; // TODO :<more timers> possible ??
- }
- // find TimerObj itcc for with Id in timerList
- bool foundcT = false;
- for(concurrentTimer = TimerList->First(); concurrentTimer; concurrentTimer = TimerList->Next(concurrentTimer))
- {
- if (concurrentTimer->timer->Id() == Id)
- {
- foundcT = true;
- break;
- }
- }
- if (!foundcT)
- {
- LogFile.Log(2,"remote concurrent Timer disappeared");
- continue;
- }
- if (!failedTimer->concurrentTimers)
- failedTimer->concurrentTimers = new std::set<cConflictCheckTimerObj*,TimerObjSort>;
- LogFile.Log(2,"insert remote Id %d into concurrentTimers",concurrentTimer->timer->Id());
- failedTimer->concurrentTimers->insert(concurrentTimer);
- } // while concurrent Timers
- LogFile.Log(2,"insert Id %d into checkTime->failedTimers",failedTimer->timer->Id());
- checkTime->failedTimers.insert(failedTimer);
- relevantConflicts++;
+ LogFile.Log(3, "add remote conflicts to list");
+ bool foundRemote = false;
+ cStringList RemoteHosts;
+ // check if we have any Remote timers
+ RemoteHosts.Clear();
+ for (cConflictCheckTimerObj* TimerObj = TimerList->First(); TimerObj; TimerObj = TimerList->Next(TimerObj)) {
+ if (!TimerObj->timer->HasFlags(tfActive)) continue;
+
+ if (TimerObj->timer->Remote()) {
+ if (RemoteHosts.Find(TimerObj->timer->Remote()) < 0) {
+ foundRemote = true;
+ RemoteHosts.Append(strdup(TimerObj->timer->Remote()));
}
- else
- LogFile.Log(2,"got Code %d, but no Value from %s",Code,RemoteHosts[i]);
- } // received response
- }
- else
- {
- LogFile.Log(2,"ExecSVDRPCommand failed for %s",RemoteHosts[i]);
- }
- } // for all RemoteHosts
- cConflictCheckThread::m_cacheTotalConflicts = numConflicts;
- cConflictCheckThread::m_cacheRelevantConflicts = relevantConflicts;
- LogFile.Log(3,"add remote conflicts done");
+ }
+ }
+
+ if (!foundRemote) {
+ LogFile.Log(3, "no remote timers to add");
+ return;
+ }
+
+ RemoteHosts.Sort();
+
+ cStringList Response;
+ // for all RemoteHosts
+ for (int i = 0; i < RemoteHosts.Size(); i++) {
+ Response.Clear();
+ if (ExecSVDRPCommand(RemoteHosts[i], "PLUG epgsearch LSCC REL", &Response)) {
+ for (int j = 0; j < Response.Size(); j++) {
+ const char *s = Response[j];
+ int Code = SVDRPCode(s);
+ if (Code == 901) {
+ LogFile.Log(3, "conflictcheck %s no remote conflicts found", RemoteHosts[i]);
+ continue;
+ } else if (Code != 900) {
+ LogFile.Log(2, "Invalid remote response %d %s", Code,
+ SVDRPValue(s));
+ break;
+ } else if (const char* line = SVDRPValue(s)) {
+ LogFile.Log(2, "remote conflictcheck line %s", line);
+ int Id, recPart;
+ char rest[256];
+ time_t evaltime;
+ sscanf(line, "%ld:%d|%s", &evaltime, &Id, rest);
+ cConflictCheckTime* checkTime = new cConflictCheckTime(evaltime);
+ if (!failedList)
+ failedList = new cList<cConflictCheckTime>;
+ LogFile.Log(2, "added remote checkTime %s to failedList", DAYDATETIME(evaltime));
+ failedList->Add(checkTime);
+ numConflicts++;
+ // find TimerObj with id Id in timerList
+ cConflictCheckTimerObj* failedTimer = NULL;
+ bool foundfT = false;
+ for (failedTimer = TimerList->First(); failedTimer; failedTimer = TimerList->Next(failedTimer)) {
+ if (failedTimer->timer->Id() == Id) {
+ foundfT = true;
+ break;
+ }
+ }
+ if (!foundfT) {
+ LogFile.Log(2, "remote failed Timer disappeared");
+ continue;
+ }
+ LogFile.Log(2, "create remote failedTimer with Id %d", Id);
+ failedTimer->conflCheckTime = checkTime;
+ failedTimer->origIndex = Id;
+ sscanf(rest, "%d|%s", &recPart, rest);
+ failedTimer->recDuration = ((failedTimer->stop - failedTimer->start) * recPart / 100);
+ cConflictCheckTimerObj* concurrentTimer = NULL;
+ while (strlen(rest) > 0) {
+ int n = sscanf(rest, "%d#%s", &Id, rest);
+ if (n < 2) {
+ if (sscanf(rest, "%d", &Id) <= 0) {
+ LogFile.Log(2, "error scanning rest of line %s", rest);
+ break;
+ }
+ *rest = 0; // TODO :<more timers> possible ??
+ }
+ // find TimerObj itcc for with Id in timerList
+ bool foundcT = false;
+ for (concurrentTimer = TimerList->First(); concurrentTimer; concurrentTimer = TimerList->Next(concurrentTimer)) {
+ if (concurrentTimer->timer->Id() == Id) {
+ foundcT = true;
+ break;
+ }
+ }
+ if (!foundcT) {
+ LogFile.Log(2, "remote concurrent Timer disappeared");
+ continue;
+ }
+ if (!failedTimer->concurrentTimers)
+ failedTimer->concurrentTimers = new std::set<cConflictCheckTimerObj*, TimerObjSort>;
+ LogFile.Log(2, "insert remote Id %d into concurrentTimers", concurrentTimer->timer->Id());
+ failedTimer->concurrentTimers->insert(concurrentTimer);
+ } // while concurrent Timers
+ LogFile.Log(2, "insert Id %d into checkTime->failedTimers", failedTimer->timer->Id());
+ checkTime->failedTimers.insert(failedTimer);
+ relevantConflicts++;
+ } else
+ LogFile.Log(2, "got Code %d, but no Value from %s", Code, RemoteHosts[i]);
+ } // received response
+ } else {
+ LogFile.Log(2, "ExecSVDRPCommand failed for %s", RemoteHosts[i]);
+ }
+ } // for all RemoteHosts
+ cConflictCheckThread::m_cacheTotalConflicts = numConflicts;
+ cConflictCheckThread::m_cacheRelevantConflicts = relevantConflicts;
+ LogFile.Log(3, "add remote conflicts done");
}
// checks for conflicts at one special time
@@ -613,83 +554,74 @@ int cConflictCheck::ProcessCheckTime(cConflictCheckTime* checkTime)
{
if (!checkTime) return 0;
- LogFile.Log(3,"check time %s", DAYDATETIME(checkTime->evaltime));
+ LogFile.Log(3, "check time %s", DAYDATETIME(checkTime->evaltime));
- LogFile.Log(3,"detach stopping timers");
+ LogFile.Log(3, "detach stopping timers");
int Conflicts = 0;
// detach all stopping timers from their devices
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
for (it = checkTime->stoppingTimers.begin(); it != checkTime->stoppingTimers.end(); ++it)
- if ((*it) && (*it)->device >= 0)
- {
- LogFile.Log(3,"detach device %d from timer '%s' (%s, channel %s) at %s", ((*it)->device)+1, (*it)->timer->File(), DAYDATETIME((*it)->start), CHANNELNAME((*it)->timer->Channel()), DAYDATETIME(checkTime->evaltime));
- devices[(*it)->device].recTimers.erase(*it);
- (*it)->lastRecStop = checkTime->evaltime;
- if ((*it)->lastRecStart > 0 && (*it)->lastRecStart < (*it)->lastRecStop)
- {
- (*it)->recDuration += (*it)->lastRecStop - (*it)->lastRecStart;
- (*it)->lastRecStart = 0;
- if (((*it)->stop - (*it)->start - (*it)->recDuration) < EPGSearchConfig.checkMinDuration * 60)
- (*it)->ignore = true;
- }
- }
-
- LogFile.Log(3,"add pending timers");
+ if ((*it) && (*it)->device >= 0) {
+ LogFile.Log(3, "detach device %d from timer '%s' (%s, channel %s) at %s", ((*it)->device) + 1, (*it)->timer->File(), DAYDATETIME((*it)->start), CHANNELNAME((*it)->timer->Channel()), DAYDATETIME(checkTime->evaltime));
+ devices[(*it)->device].recTimers.erase(*it);
+ (*it)->lastRecStop = checkTime->evaltime;
+ if ((*it)->lastRecStart > 0 && (*it)->lastRecStart < (*it)->lastRecStop) {
+ (*it)->recDuration += (*it)->lastRecStop - (*it)->lastRecStart;
+ (*it)->lastRecStart = 0;
+ if (((*it)->stop - (*it)->start - (*it)->recDuration) < EPGSearchConfig.checkMinDuration * 60)
+ (*it)->ignore = true;
+ }
+ }
+
+ LogFile.Log(3, "add pending timers");
// if we have pending timers add them to the current start list
- for (it = pendingTimers.begin(); it != pendingTimers.end(); ++it)
- {
- if ((*it) && (*it)->stop > checkTime->evaltime)
- checkTime->startingTimers.insert(*it);
- pendingTimers.erase(*it);
+ for (it = pendingTimers.begin(); it != pendingTimers.end(); ++it) {
+ if ((*it) && (*it)->stop > checkTime->evaltime)
+ checkTime->startingTimers.insert(*it);
+ pendingTimers.erase(*it);
}
- LogFile.Log(3,"attach starting timers");
+ LogFile.Log(3, "attach starting timers");
// handle starting timers
- for (it = checkTime->startingTimers.begin(); it != checkTime->startingTimers.end(); ++it)
- {
- bool NeedsDetachReceivers = false;
- if (!(*it) || (*it)->device >= 0) continue; // already has a device
- int device = GetDevice(*it, &NeedsDetachReceivers);
- if (device >= 0) // device will be attached?
- {
- if (NeedsDetachReceivers) // but needs to detach all others?
- {
- // disable running timers
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it2 = devices[device].recTimers.begin();
- for(; it2 != devices[device].recTimers.end(); ++it2)
- {
- LogFile.Log(3,"stopping timer '%s' (%s, channel %s) at %s on device %d because of higher priority", (*it2)->timer->File(), DAYDATETIME((*it2)->start), CHANNELNAME((*it2)->timer->Channel()), DAYDATETIME(checkTime->evaltime), device+1);
- AddConflict((*it2), checkTime, pendingTimers);
- devices[device].recTimers.erase(*it2);
- Conflicts++;
- }
- }
- devices[device].recTimers.insert(*it);
- (*it)->device = device;
- (*it)->lastRecStart = checkTime->evaltime;
-
- LogFile.Log(3,"recording timer '%s' (%s, channel %s) at %s on device %d", (*it)->timer->File(), DAYDATETIME((*it)->start), CHANNELNAME((*it)->timer->Channel()), DAYDATETIME(checkTime->evaltime), device+1);
- }
- else
- {
- AddConflict((*it), checkTime, pendingTimers);
- Conflicts++;
- }
+ for (it = checkTime->startingTimers.begin(); it != checkTime->startingTimers.end(); ++it) {
+ bool NeedsDetachReceivers = false;
+ if (!(*it) || (*it)->device >= 0) continue; // already has a device
+ int device = GetDevice(*it, &NeedsDetachReceivers);
+ if (device >= 0) { // device will be attached?
+ if (NeedsDetachReceivers) { // but needs to detach all others?
+ // disable running timers
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it2 = devices[device].recTimers.begin();
+ for (; it2 != devices[device].recTimers.end(); ++it2) {
+ LogFile.Log(3, "stopping timer '%s' (%s, channel %s) at %s on device %d because of higher priority", (*it2)->timer->File(), DAYDATETIME((*it2)->start), CHANNELNAME((*it2)->timer->Channel()), DAYDATETIME(checkTime->evaltime), device + 1);
+ AddConflict((*it2), checkTime, pendingTimers);
+ devices[device].recTimers.erase(*it2);
+ Conflicts++;
+ }
+ }
+ devices[device].recTimers.insert(*it);
+ (*it)->device = device;
+ (*it)->lastRecStart = checkTime->evaltime;
+
+ LogFile.Log(3, "recording timer '%s' (%s, channel %s) at %s on device %d", (*it)->timer->File(), DAYDATETIME((*it)->start), CHANNELNAME((*it)->timer->Channel()), DAYDATETIME(checkTime->evaltime), device + 1);
+ } else {
+ AddConflict((*it), checkTime, pendingTimers);
+ Conflicts++;
+ }
}
- LogFile.Log(3,"check time %s - done", DAYDATETIME(checkTime->evaltime));
+ LogFile.Log(3, "check time %s - done", DAYDATETIME(checkTime->evaltime));
return Conflicts;
}
eModuleStatus cConflictCheck::CamSlotModuleStatus(cCamSlot *CamSlot)
{
- if (!CamSlot) return msNone;
- if ((int)camSlotStatusArray.size() != CamSlots.Count())
- for (cCamSlot *CamSlot = CamSlots.First(); CamSlot; CamSlot = CamSlots.Next(CamSlot))
- camSlotStatusArray.push_back(CamSlot->ModuleStatus());
- if (CamSlot->Index() < (int)camSlotStatusArray.size())
- return camSlotStatusArray[CamSlot->Index()];
- else
- return msNone;
+ if (!CamSlot) return msNone;
+ if ((int)camSlotStatusArray.size() != CamSlots.Count())
+ for (cCamSlot *CamSlot = CamSlots.First(); CamSlot; CamSlot = CamSlots.Next(CamSlot))
+ camSlotStatusArray.push_back(CamSlot->ModuleStatus());
+ if (CamSlot->Index() < (int)camSlotStatusArray.size())
+ return camSlotStatusArray[CamSlot->Index()];
+ else
+ return msNone;
}
int cConflictCheck::GetDevice(cConflictCheckTimerObj* TimerObj, bool* NeedsDetachReceivers)
@@ -697,179 +629,175 @@ int cConflictCheck::GetDevice(cConflictCheckTimerObj* TimerObj, bool* NeedsDetac
int Priority = TimerObj->timer->Priority();
const cChannel* Channel = TimerObj->timer->Channel();
- // Collect the current priorities of all CAM slots that can decrypt the channel:
+ // Collect the current priorities of all CAM slots that can decrypt the channel:
int selDevice = -1;
int NumCamSlots = CamSlots.Count();
int SlotPriority[NumCamSlots];
int NumUsableSlots = 0;
if (Channel->Ca() >= CA_ENCRYPTED_MIN) {
- for (cCamSlot *CamSlot = CamSlots.First(); CamSlot; CamSlot = CamSlots.Next(CamSlot)) {
- SlotPriority[CamSlot->Index()] = MAXPRIORITY + 1; // assumes it can't be used
- if (CamSlotModuleStatus(CamSlot) == msReady) {
- if (CamSlot->ProvidesCa(Channel->Caids())) {
- if (!ChannelCamRelations.CamChecked(Channel->GetChannelID(), CamSlot->SlotNumber())) {
- SlotPriority[CamSlot->Index()] = CamSlot->Priority();
- NumUsableSlots++;
- }
- }
+ for (cCamSlot *CamSlot = CamSlots.First(); CamSlot; CamSlot = CamSlots.Next(CamSlot)) {
+ SlotPriority[CamSlot->Index()] = MAXPRIORITY + 1; // assumes it can't be used
+ if (CamSlotModuleStatus(CamSlot) == msReady) {
+ if (CamSlot->ProvidesCa(Channel->Caids())) {
+ if (!ChannelCamRelations.CamChecked(Channel->GetChannelID(), CamSlot->SlotNumber())) {
+ SlotPriority[CamSlot->Index()] = CamSlot->Priority();
+ NumUsableSlots++;
+ }
+ }
}
- }
+ }
#ifdef CFLC
- int NumUsableSlots = 1;
+ int NumUsableSlots = 1;
#endif
- if (!NumUsableSlots)
- return selDevice; // no CAM is able to decrypt this channel
- }
+ if (!NumUsableSlots)
+ return selDevice; // no CAM is able to decrypt this channel
+ }
if (NeedsDetachReceivers)
- *NeedsDetachReceivers = false;
-
- uint32_t Impact = 0xFFFFFFFF; // we're looking for a device with the least impact
- for (int j = 0; j < NumCamSlots || !NumUsableSlots; j++) {
- if (NumUsableSlots && SlotPriority[j] > MAXPRIORITY)
- continue; // there is no CAM available in this slot
- for (int i = 0; i < numDevices; i++) {
- if (Channel->Ca() && Channel->Ca() <= CA_DVB_MAX && Channel->Ca() != devices[i].CardIndex() + 1)
- continue; // a specific card was requested, but not this one
- if (NumUsableSlots && !CamSlots.Get(j)->Assign(devices[i].device, true))
- continue; // CAM slot can't be used with this device
- bool ndr;
- if (devices[i].ProvidesChannel(Channel, Priority, &ndr)) { // this device is basically able to do the job
- if (NumUsableSlots && devices[i].CamSlot() && devices[i].CamSlot() != CamSlots.Get(j))
- ndr = true; // using a different CAM slot requires detaching receivers
- // Put together an integer number that reflects the "impact" using
- // this device would have on the overall system. Each condition is represented
- // by one bit in the number (or several bits, if the condition is actually
- // a numeric value). The sequence in which the conditions are listed corresponds
- // to their individual severity, where the one listed first will make the most
- // difference, because it results in the most significant bit of the result.
- uint32_t imp = 0;
- // prefer the primary device for live viewing if we don't need to detach existing receivers
- imp <<= 1; ;
- // use receiving devices if we don't need to detach existing receivers
- imp <<= 1; imp |= !devices[i].Receiving() || ndr;
- // avoid devices that are receiving
- imp <<= 1; imp |= devices[i].Receiving();
- // use the device with the lowest priority (+MAXPRIORITY to assure that values -99..99 can be used)
- imp <<= 8; imp |= std::min(std::max(devices[i].Priority() + MAXPRIORITY, 0), 0xFF);
- // use the CAM slot with the lowest priority (+MAXPRIORITY to assure that values -99..99 can be used)
- imp <<= 8; imp |= std::min(std::max((NumUsableSlots ? SlotPriority[j] : 0) + MAXPRIORITY, 0), 0xFF);
- // avoid devices if we need to detach existing receivers
- imp <<= 1; imp |= ndr;
- // avoid the primary device
- imp <<= 1; imp |= devices[i].IsPrimaryDevice();
- // avoid cards with Common Interface for FTA channels
- imp <<= 1; imp |= NumUsableSlots ? 0 : devices[i].HasCi();
- // avoid full featured cards
- imp <<= 1; imp |= devices[i].HasDecoder();
- // prefer CAMs that are known to decrypt this channel
- imp <<= 1; imp |= NumUsableSlots ? !ChannelCamRelations.CamDecrypt(Channel->GetChannelID(), j + 1) : 0;
- if (imp < Impact) {
- // This device has less impact than any previous one, so we take it.
- Impact = imp;
- selDevice = i;
- if (NeedsDetachReceivers)
- *NeedsDetachReceivers = ndr;
+ *NeedsDetachReceivers = false;
+
+ uint32_t Impact = 0xFFFFFFFF; // we're looking for a device with the least impact
+ for (int j = 0; j < NumCamSlots || !NumUsableSlots; j++) {
+ if (NumUsableSlots && SlotPriority[j] > MAXPRIORITY)
+ continue; // there is no CAM available in this slot
+ for (int i = 0; i < numDevices; i++) {
+ if (Channel->Ca() && Channel->Ca() <= CA_DVB_MAX && Channel->Ca() != devices[i].CardIndex() + 1)
+ continue; // a specific card was requested, but not this one
+ if (NumUsableSlots && !CamSlots.Get(j)->Assign(devices[i].device, true))
+ continue; // CAM slot can't be used with this device
+ bool ndr;
+ if (devices[i].ProvidesChannel(Channel, Priority, &ndr)) { // this device is basically able to do the job
+ if (NumUsableSlots && devices[i].CamSlot() && devices[i].CamSlot() != CamSlots.Get(j))
+ ndr = true; // using a different CAM slot requires detaching receivers
+ // Put together an integer number that reflects the "impact" using
+ // this device would have on the overall system. Each condition is represented
+ // by one bit in the number (or several bits, if the condition is actually
+ // a numeric value). The sequence in which the conditions are listed corresponds
+ // to their individual severity, where the one listed first will make the most
+ // difference, because it results in the most significant bit of the result.
+ uint32_t imp = 0;
+ // prefer the primary device for live viewing if we don't need to detach existing receivers
+ imp <<= 1; ;
+ // use receiving devices if we don't need to detach existing receivers
+ imp <<= 1;
+ imp |= !devices[i].Receiving() || ndr;
+ // avoid devices that are receiving
+ imp <<= 1;
+ imp |= devices[i].Receiving();
+ // use the device with the lowest priority (+MAXPRIORITY to assure that values -99..99 can be used)
+ imp <<= 8;
+ imp |= std::min(std::max(devices[i].Priority() + MAXPRIORITY, 0), 0xFF);
+ // use the CAM slot with the lowest priority (+MAXPRIORITY to assure that values -99..99 can be used)
+ imp <<= 8;
+ imp |= std::min(std::max((NumUsableSlots ? SlotPriority[j] : 0) + MAXPRIORITY, 0), 0xFF);
+ // avoid devices if we need to detach existing receivers
+ imp <<= 1;
+ imp |= ndr;
+ // avoid the primary device
+ imp <<= 1;
+ imp |= devices[i].IsPrimaryDevice();
+ // avoid cards with Common Interface for FTA channels
+ imp <<= 1;
+ imp |= NumUsableSlots ? 0 : devices[i].HasCi();
+ // avoid full featured cards
+ imp <<= 1;
+ imp |= devices[i].HasDecoder();
+ // prefer CAMs that are known to decrypt this channel
+ imp <<= 1;
+ imp |= NumUsableSlots ? !ChannelCamRelations.CamDecrypt(Channel->GetChannelID(), j + 1) : 0;
+ if (imp < Impact) {
+ // This device has less impact than any previous one, so we take it.
+ Impact = imp;
+ selDevice = i;
+ if (NeedsDetachReceivers)
+ *NeedsDetachReceivers = ndr;
}
- }
- }
- if (!NumUsableSlots)
- break; // no CAM necessary, so just one loop over the devices
- }
- return selDevice;
+ }
+ }
+ if (!NumUsableSlots)
+ break; // no CAM necessary, so just one loop over the devices
+ }
+ return selDevice;
}
void cConflictCheck::AddConflict(cConflictCheckTimerObj* TimerObj, cConflictCheckTime* CheckTime, std::set<cConflictCheckTimerObj*>& pendingTimers)
{
- for(cConflictCheckTimerObj* concTimer= timerList->First(); concTimer; concTimer = timerList->Next(concTimer))
- {
- if (concTimer->start >= TimerObj->stop) continue;
- if (concTimer->stop <= TimerObj->start) continue;
- if (!TimerObj->concurrentTimers) TimerObj->concurrentTimers = new std::set<cConflictCheckTimerObj*,TimerObjSort>;
- TimerObj->concurrentTimers->insert(concTimer);
+ for (cConflictCheckTimerObj* concTimer = timerList->First(); concTimer; concTimer = timerList->Next(concTimer)) {
+ if (concTimer->start >= TimerObj->stop) continue;
+ if (concTimer->stop <= TimerObj->start) continue;
+ if (!TimerObj->concurrentTimers) TimerObj->concurrentTimers = new std::set<cConflictCheckTimerObj*, TimerObjSort>;
+ TimerObj->concurrentTimers->insert(concTimer);
}
TimerObj->ignore = (TimerObj->timer->Priority() < EPGSearchConfig.checkMinPriority) || TimerObj->start > maxCheck;
CheckTime->concurrentRecs.insert(TimerObj);
pendingTimers.insert(TimerObj);
TimerObj->lastRecStop = CheckTime->evaltime;
- if (TimerObj->lastRecStart > 0 && TimerObj->lastRecStart < TimerObj->lastRecStop)
- {
- TimerObj->recDuration += TimerObj->lastRecStop - TimerObj->lastRecStart;
- TimerObj->lastRecStart = 0;
- if ((TimerObj->stop - TimerObj->start - TimerObj->recDuration) < EPGSearchConfig.checkMinDuration * 60)
- TimerObj->ignore = true;
+ if (TimerObj->lastRecStart > 0 && TimerObj->lastRecStart < TimerObj->lastRecStop) {
+ TimerObj->recDuration += TimerObj->lastRecStop - TimerObj->lastRecStart;
+ TimerObj->lastRecStart = 0;
+ if ((TimerObj->stop - TimerObj->start - TimerObj->recDuration) < EPGSearchConfig.checkMinDuration * 60)
+ TimerObj->ignore = true;
}
TimerObj->device = -1;
if (!TimerObj->conflCheckTime)
- TimerObj->conflCheckTime = CheckTime;
+ TimerObj->conflCheckTime = CheckTime;
else
- return;
+ return;
CheckTime->failedTimers.insert(TimerObj);
- LogFile.Log(3,"conflict found for timer '%s' (%s, channel %s)", TimerObj->timer->File(), DAYDATETIME(TimerObj->start), CHANNELNAME(TimerObj->timer->Channel()));
+ LogFile.Log(3, "conflict found for timer '%s' (%s, channel %s)", TimerObj->timer->File(), DAYDATETIME(TimerObj->start), CHANNELNAME(TimerObj->timer->Channel()));
}
bool cConflictCheck::TimerInConflict(const cTimer* timer)
{
if (!failedList)
return false;
- for(cConflictCheckTime* checkTime = failedList->First(); checkTime; checkTime = failedList->Next(checkTime))
- {
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
- for (it = checkTime->failedTimers.begin(); it != checkTime->failedTimers.end(); ++it)
- {
- if (!(*it)->ignore)
- {
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it2;
- if ((*it)->concurrentTimers)
- {
- LOCK_TIMERS_READ;
- for (it2 = (*it)->concurrentTimers->begin(); it2 != (*it)->concurrentTimers->end(); ++it2)
- {
- if ((*it2)->OrigTimer(Timers) == timer)
- return true;
- }
- }
- }
- }
+ for (cConflictCheckTime* checkTime = failedList->First(); checkTime; checkTime = failedList->Next(checkTime)) {
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
+ for (it = checkTime->failedTimers.begin(); it != checkTime->failedTimers.end(); ++it) {
+ if (!(*it)->ignore) {
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it2;
+ if ((*it)->concurrentTimers) {
+ LOCK_TIMERS_READ;
+ for (it2 = (*it)->concurrentTimers->begin(); it2 != (*it)->concurrentTimers->end(); ++it2) {
+ if ((*it2)->OrigTimer(Timers) == timer)
+ return true;
+ }
+ }
+ }
+ }
}
return false;
}
void cConflictCheck::EvaluateConflCheckCmd()
{
- if (strlen(EPGSearchConfig.conflCheckCmd) > 0)
- {
- LogFile.Log(2,"evaluating conflict check command '%s'", EPGSearchConfig.conflCheckCmd);
- for(cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct))
- {
- if (ct->ignore) continue;
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
- for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
- if ((*it) && !(*it)->ignore)
- {
- string result = EPGSearchConfig.conflCheckCmd;
- LOCK_TIMERS_READ;
- if (!(*it)->OrigTimer(Timers))
- {
- LogFile.Log(3,"timer has disappeared meanwhile");
- continue;
- }
- else
- LogFile.Log(3,"evaluating conflict check command for timer '%s' (%s, channel %s)", (*it)->timer->File(), DAYDATETIME((*it)->start), CHANNELNAME((*it)->timer->Channel()));
-
- if ((*it)->Event())
- {
- cVarExpr varExprEvent(result);
- result = varExprEvent.Evaluate((*it)->Event());
- }
- cVarExpr varExprTimer(result);
- result = varExprTimer.Evaluate((*it)->timer);
- cVarExpr varExpr(result);
- varExpr.Evaluate();
- }
- }
+ if (strlen(EPGSearchConfig.conflCheckCmd) > 0) {
+ LogFile.Log(2, "evaluating conflict check command '%s'", EPGSearchConfig.conflCheckCmd);
+ for (cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct)) {
+ if (ct->ignore) continue;
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
+ for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
+ if ((*it) && !(*it)->ignore) {
+ string result = EPGSearchConfig.conflCheckCmd;
+ LOCK_TIMERS_READ;
+ if (!(*it)->OrigTimer(Timers)) {
+ LogFile.Log(3, "timer has disappeared meanwhile");
+ continue;
+ } else
+ LogFile.Log(3, "evaluating conflict check command for timer '%s' (%s, channel %s)", (*it)->timer->File(), DAYDATETIME((*it)->start), CHANNELNAME((*it)->timer->Channel()));
+
+ if ((*it)->Event()) {
+ cVarExpr varExprEvent(result);
+ result = varExprEvent.Evaluate((*it)->Event());
+ }
+ cVarExpr varExprTimer(result);
+ result = varExprTimer.Evaluate((*it)->timer);
+ cVarExpr varExpr(result);
+ varExpr.Evaluate();
+ }
+ }
}
}
diff --git a/conflictcheck.h b/conflictcheck.h
index 44a08d1..9a0b171 100644
--- a/conflictcheck.h
+++ b/conflictcheck.h
@@ -40,7 +40,7 @@ class TimerObjSort;
class cConflictCheckTimerObj : public cTimerObj
{
const cEvent* event;
- public:
+public:
time_t start;
time_t stop;
int device;
@@ -49,31 +49,28 @@ class cConflictCheckTimerObj : public cTimerObj
time_t lastRecStart;
time_t lastRecStop;
cConflictCheckTime* conflCheckTime;
- std::set<cConflictCheckTimerObj*,TimerObjSort>* concurrentTimers;
+ std::set<cConflictCheckTimerObj*, TimerObjSort>* concurrentTimers;
bool ignore;
- cConflictCheckTimerObj(cTimer* Timer, time_t Start, time_t Stop, int Device = -1, int OrigIndex=-1);
+ cConflictCheckTimerObj(cTimer* Timer, time_t Start, time_t Stop, int Device = -1, int OrigIndex = -1);
~cConflictCheckTimerObj();
int Compare(const cListObject &ListObject) const;
const cEvent* Event();
const cEvent* SetEventFromSchedule();
int Matches(const cEvent *Event, int *Overlap) const;
- const cTimer* OrigTimer(const cTimers* timers) const
- {
- return timers->GetById(timer->Id(),timer->Remote());
+ const cTimer* OrigTimer(const cTimers* timers) const {
+ return timers->GetById(timer->Id(), timer->Remote());
}
- cTimer* OrigTimer(cTimers* timers)
- {
- return timers->GetById(timer->Id(),timer->Remote());
+ cTimer* OrigTimer(cTimers* timers) {
+ return timers->GetById(timer->Id(), timer->Remote());
}
};
class TimerObjSort
{
public:
- bool operator() (cConflictCheckTimerObj* a, cConflictCheckTimerObj* b)
- {
+ bool operator()(cConflictCheckTimerObj* a, cConflictCheckTimerObj* b) {
return (a->Compare(*b) < 0);
}
};
@@ -82,20 +79,19 @@ public:
// --- cConflictCheckTime --------------------------------------------------------
class cConflictCheckTime : public cListObject
{
- public:
+public:
time_t evaltime;
- std::set<cConflictCheckTimerObj*,TimerObjSort> startingTimers;
- std::set<cConflictCheckTimerObj*,TimerObjSort> stoppingTimers;
- std::set<cConflictCheckTimerObj*,TimerObjSort> failedTimers;
- std::set<cConflictCheckTimerObj*,TimerObjSort> concurrentRecs;
+ std::set<cConflictCheckTimerObj*, TimerObjSort> startingTimers;
+ std::set<cConflictCheckTimerObj*, TimerObjSort> stoppingTimers;
+ std::set<cConflictCheckTimerObj*, TimerObjSort> failedTimers;
+ std::set<cConflictCheckTimerObj*, TimerObjSort> concurrentRecs;
bool ignore;
cConflictCheckTime(time_t EvalTime) : evaltime(EvalTime), ignore(false) {}
- int Compare(const cListObject &ListObject) const
- {
- cConflictCheckTime *p = (cConflictCheckTime *)&ListObject;
- return evaltime - p->evaltime;
- }
+ int Compare(const cListObject &ListObject) const {
+ cConflictCheckTime *p = (cConflictCheckTime *)&ListObject;
+ return evaltime - p->evaltime;
+ }
};
// --- cConflictCheckDevice --------------------------------------------------------
@@ -103,148 +99,158 @@ class cConflictCheckTime : public cListObject
// NOTE: The case device == NULL is only for debugging purposes
class cConflictCheckDevice
{
- public:
- std::set<cConflictCheckTimerObj*,TimerObjSort> recTimers;
+public:
+ std::set<cConflictCheckTimerObj*, TimerObjSort> recTimers;
cDevice* device;
int devicenr;
std::vector<cConflictCheckDevice*> bondedDevices;
- cConflictCheckDevice() { device = NULL; devicenr = 0; }
- int Priority() const
- {
- int prio = -1;
- for(std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it = recTimers.begin(); it != recTimers.end(); ++it)
- prio = std::max(prio, (*it)->timer->Priority());
- return prio;
- };
- int CardIndex(void) const { if (device) return device->CardIndex(); else return devicenr;}
- bool Receiving() const { return !recTimers.empty(); }
- bool IsTunedTo (const cChannel* Channel) const
- {
- for(std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it = recTimers.begin(); it != recTimers.end(); ++it)
- if ((*it)->timer->Channel()->Source() == Channel->Source() &&
- (*it)->timer->Channel()->Transponder() == Channel->Transponder())
- return true;
- return false;
- }
- bool HasDecoder() const { if (device) return device->HasDecoder(); else return (devicenr == 3); }
- bool HasCi() const { if (device) return device->HasCi(); else return (devicenr == 3); }
- bool IsPrimaryDevice() const { if (device) return device->IsPrimaryDevice(); else return (devicenr == 3); }
- bool ProvidesSource(int Source) const
- {
- if (device) return device->ProvidesSource(Source);
- else
- {
-// int type = Source & cSource::st_Mask;
-// if (devicenr == 0) return type == cSource::stCable;
-// if (devicenr > 0) return type == cSource::stTerr;
-// return false;
- return true;
- }
- }
- cCamSlot *CamSlot(void) const { if (device) return device->CamSlot(); else return NULL;}
- int Ca() const
- {
- for(std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it = recTimers.begin(); it != recTimers.end(); ++it)
- return (*it)->timer->Channel()->Ca();
- return 0;
- }
- bool HasPid(int Pid) const { return true; }
- bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const
- {
- bool result = false;
- bool hasPriority = Priority < 0 || Priority > this->Priority();
- bool needsDetachReceivers = false;
+ cConflictCheckDevice() {
+ device = NULL;
+ devicenr = 0;
+ }
+ int Priority() const {
+ int prio = -1;
+ for (std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it = recTimers.begin(); it != recTimers.end(); ++it)
+ prio = std::max(prio, (*it)->timer->Priority());
+ return prio;
+ };
+ int CardIndex(void) const {
+ if (device) return device->CardIndex();
+ else return devicenr;
+ }
+ bool Receiving() const {
+ return !recTimers.empty();
+ }
+ bool IsTunedTo(const cChannel* Channel) const {
+ for (std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it = recTimers.begin(); it != recTimers.end(); ++it)
+ if ((*it)->timer->Channel()->Source() == Channel->Source() &&
+ (*it)->timer->Channel()->Transponder() == Channel->Transponder())
+ return true;
+ return false;
+ }
+ bool HasDecoder() const {
+ if (device) return device->HasDecoder();
+ else return (devicenr == 3);
+ }
+ bool HasCi() const {
+ if (device) return device->HasCi();
+ else return (devicenr == 3);
+ }
+ bool IsPrimaryDevice() const {
+ if (device) return device->IsPrimaryDevice();
+ else return (devicenr == 3);
+ }
+ bool ProvidesSource(int Source) const {
+ if (device) return device->ProvidesSource(Source);
+ else {
+// int type = Source & cSource::st_Mask;
+// if (devicenr == 0) return type == cSource::stCable;
+// if (devicenr > 0) return type == cSource::stTerr;
+// return false;
+ return true;
+ }
+ }
+ cCamSlot *CamSlot(void) const {
+ if (device) return device->CamSlot();
+ else return NULL;
+ }
+ int Ca() const {
+ for (std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it = recTimers.begin(); it != recTimers.end(); ++it)
+ return (*it)->timer->Channel()->Ca();
+ return 0;
+ }
+ bool HasPid(int Pid) const {
+ return true;
+ }
+ bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL) const {
+ bool result = false;
+ bool hasPriority = Priority < 0 || Priority > this->Priority();
+ bool needsDetachReceivers = false;
- if (ProvidesSource(Channel->Source())) {
- result = hasPriority;
- if (Priority >= 0 && Receiving()) {
- if (IsTunedTo(Channel)) {
- if ((Channel->Vpid() && !HasPid(Channel->Vpid())) || (Channel->Apid(0) && !HasPid(Channel->Apid(0)))) {
+ if (ProvidesSource(Channel->Source())) {
+ result = hasPriority;
+ if (Priority >= 0 && Receiving()) {
+ if (IsTunedTo(Channel)) {
+ if ((Channel->Vpid() && !HasPid(Channel->Vpid())) || (Channel->Apid(0) && !HasPid(Channel->Apid(0)))) {
#ifdef DO_MULTIPLE_RECORDINGS
- if (CamSlot() && Channel->Ca() >= CA_ENCRYPTED_MIN) {
- if (CamSlot()->CanDecrypt(Channel))
- result = true;
- else
- needsDetachReceivers = true;
- }
- else if (!IsPrimaryDevice())
- result = true;
+ if (CamSlot() && Channel->Ca() >= CA_ENCRYPTED_MIN) {
+ if (CamSlot()->CanDecrypt(Channel))
+ result = true;
+ else
+ needsDetachReceivers = true;
+ } else if (!IsPrimaryDevice())
+ result = true;
#ifdef DO_REC_AND_PLAY_ON_PRIMARY_DEVICE
- else
- result = Priority >= 0;
+ else
+ result = Priority >= 0;
#endif
#endif
- }
- else
- result = !IsPrimaryDevice() || Priority >= 0;
- }
- else
- needsDetachReceivers = true;
- }
- }
- if (result) {
- if (!BondingOk(Channel)) {
- // This device is bonded, so we need to check the priorities of the others:
- for (size_t i=0; i<bondedDevices.size(); i++) {
- if (bondedDevices[i]->Priority() >= Priority) {
- LogFile.Log(3, "Attached receiver to bonded device %i has higher priority.", bondedDevices[i]->CardIndex()+1);
- result = false;
- break;
- }
- }
- if (result)
- LogFile.Log(3, "Bonding ok, but detaches receiver on device %i.", CardIndex());
- else
- LogFile.Log(3, "Bonding not okay on device %i.", CardIndex());
- needsDetachReceivers = Receiving();
- } else {
- LogFile.Log(3, "Bonding ok on device %i.", CardIndex());
- }
- }
- if (NeedsDetachReceivers)
- *NeedsDetachReceivers = needsDetachReceivers;
- return result;
- }
-
- bool BondingOk(const cChannel *Channel) const
- {
- if (bondedDevices.empty())
- return true;
-
- LogFile.Log(3, "Checking for bonding constraints on device %i", CardIndex()+1);
-
- cString BondingParams = GetBondingParams(Channel);
- for(size_t i=0; i< bondedDevices.size(); i++) {
- // bonding not okay, if a bonded devices records on another polarization or freq. band
- if (!bondedDevices[i]->recTimers.empty()) {
- if (strcmp(BondingParams, GetBondingParams((*bondedDevices[i]->recTimers.begin())->timer->Channel())) != 0) {
- LogFile.Log(3, "Bonded device %i has receiver attached. Not safe to use device.", bondedDevices[i]->CardIndex()+1);
- return false;
- } else {
- LogFile.Log(3, "Bonded device %i has receiver attached but its safe.", bondedDevices[i]->CardIndex()+1);
- }
- } else {
- LogFile.Log(3, "Bonded device %i has no receivers attached - ok.", bondedDevices[i]->CardIndex()+1);
- }
+ } else
+ result = !IsPrimaryDevice() || Priority >= 0;
+ } else
+ needsDetachReceivers = true;
+ }
+ }
+ if (result) {
+ if (!BondingOk(Channel)) {
+ // This device is bonded, so we need to check the priorities of the others:
+ for (size_t i = 0; i < bondedDevices.size(); i++) {
+ if (bondedDevices[i]->Priority() >= Priority) {
+ LogFile.Log(3, "Attached receiver to bonded device %i has higher priority.", bondedDevices[i]->CardIndex() + 1);
+ result = false;
+ break;
+ }
+ }
+ if (result)
+ LogFile.Log(3, "Bonding ok, but detaches receiver on device %i.", CardIndex());
+ else
+ LogFile.Log(3, "Bonding not okay on device %i.", CardIndex());
+ needsDetachReceivers = Receiving();
+ } else {
+ LogFile.Log(3, "Bonding ok on device %i.", CardIndex());
+ }
+ }
+ if (NeedsDetachReceivers)
+ *NeedsDetachReceivers = needsDetachReceivers;
+ return result;
}
- return true;
- }
- cString GetBondingParams(const cChannel *Channel) const //copied from cDVBTuner
- {
- cDvbTransponderParameters dtp(Channel->Parameters());
- if (Setup.DiSEqC) {
- if (const cDiseqc *diseqc = Diseqcs.Get(device->CardIndex() + 1, Channel->Source(), Channel->Frequency(), dtp.Polarization(), NULL))
- return diseqc->Commands();
+ bool BondingOk(const cChannel *Channel) const {
+ if (bondedDevices.empty())
+ return true;
+
+ LogFile.Log(3, "Checking for bonding constraints on device %i", CardIndex() + 1);
+
+ cString BondingParams = GetBondingParams(Channel);
+ for (size_t i = 0; i < bondedDevices.size(); i++) {
+ // bonding not okay, if a bonded devices records on another polarization or freq. band
+ if (!bondedDevices[i]->recTimers.empty()) {
+ if (strcmp(BondingParams, GetBondingParams((*bondedDevices[i]->recTimers.begin())->timer->Channel())) != 0) {
+ LogFile.Log(3, "Bonded device %i has receiver attached. Not safe to use device.", bondedDevices[i]->CardIndex() + 1);
+ return false;
+ } else {
+ LogFile.Log(3, "Bonded device %i has receiver attached but its safe.", bondedDevices[i]->CardIndex() + 1);
+ }
+ } else {
+ LogFile.Log(3, "Bonded device %i has no receivers attached - ok.", bondedDevices[i]->CardIndex() + 1);
+ }
+ }
+ return true;
}
- else {
- bool ToneOff = Channel->Frequency() < Setup.LnbSLOF;
- bool VoltOff = dtp.Polarization() == 'V' || dtp.Polarization() == 'R';
- return cString::sprintf("%c %c", ToneOff ? 't' : 'T', VoltOff ? 'v' : 'V');
+
+ cString GetBondingParams(const cChannel *Channel) const { //copied from cDVBTuner
+ cDvbTransponderParameters dtp(Channel->Parameters());
+ if (Setup.DiSEqC) {
+ if (const cDiseqc *diseqc = Diseqcs.Get(device->CardIndex() + 1, Channel->Source(), Channel->Frequency(), dtp.Polarization(), NULL))
+ return diseqc->Commands();
+ } else {
+ bool ToneOff = Channel->Frequency() < Setup.LnbSLOF;
+ bool VoltOff = dtp.Polarization() == 'V' || dtp.Polarization() == 'R';
+ return cString::sprintf("%c %c", ToneOff ? 't' : 'T', VoltOff ? 'v' : 'V');
+ }
+ return "";
}
- return "";
- }
};
// --- cConflictCheck --------------------------------------------------------
@@ -259,7 +265,7 @@ class cConflictCheck
int numDevices;
time_t maxCheck;
std::vector<eModuleStatus> camSlotStatusArray;
- public:
+public:
int relevantConflicts;
int numConflicts;
bool localConflicts;
@@ -270,15 +276,23 @@ class cConflictCheck
void InitDevicesInfo();
void Check();
void BondDevices(const char* bondings);
- void SetLocal() { localConflicts = true; }
- bool GetLocal() { return localConflicts; }
+ void SetLocal() {
+ localConflicts = true;
+ }
+ bool GetLocal() {
+ return localConflicts;
+ }
cList<cConflictCheckTimerObj>* CreateCurrentTimerList();
cList<cConflictCheckTime>* CreateEvaluationTimeList(cList<cConflictCheckTimerObj>*);
cList<cConflictCheckTime>* CreateConflictList(cList<cConflictCheckTime>*, cList<cConflictCheckTimerObj>* timerList);
void CreateRemoteConflictList(cList<cConflictCheckTimerObj>* timerList, cList<cConflictCheckTime>* failedList);
int GetDevice(cConflictCheckTimerObj* TimerObj, bool *NeedsDetachReceivers);
- cList<cConflictCheckTime>* GetFailed() { return failedList; }
- cList<cConflictCheckTimerObj>* GetTimers() { return timerList; }
+ cList<cConflictCheckTime>* GetFailed() {
+ return failedList;
+ }
+ cList<cConflictCheckTimerObj>* GetTimers() {
+ return timerList;
+ }
void AddConflict(cConflictCheckTimerObj* TimerObj, cConflictCheckTime* Checktime, std::set<cConflictCheckTimerObj*>& pendingTimers);
int ProcessCheckTime(cConflictCheckTime* checkTime);
bool TimerInConflict(const cTimer*);
diff --git a/conflictcheck_thread.c b/conflictcheck_thread.c
index 8c58a22..e9bce14 100644
--- a/conflictcheck_thread.c
+++ b/conflictcheck_thread.c
@@ -37,7 +37,7 @@ bool cConflictCheckThread::m_runOnce = false;
bool cConflictCheckThread::m_forceUpdate = false;
cConflictCheckThread::cConflictCheckThread(cPluginEpgsearch* thePlugin)
-: cThread("EPGSearch: conflictcheck")
+ : cThread("EPGSearch: conflictcheck")
{
m_plugin = thePlugin;
m_Active = false;
@@ -46,36 +46,36 @@ cConflictCheckThread::cConflictCheckThread(cPluginEpgsearch* thePlugin)
m_forceUpdate = false;
}
-cConflictCheckThread::~cConflictCheckThread() {
+cConflictCheckThread::~cConflictCheckThread()
+{
if (m_Active)
- Stop();
+ Stop();
}
void cConflictCheckThread::Init(cPluginEpgsearch* thePlugin, bool runOnce)
{
- if (EPGSearchConfig.checkTimerConflictsAfterUpdate || EPGSearchConfig.conflictCheckIntervall == 0)
- {
- if (!runOnce) return;
- m_runOnce = true;
- }
-
- if (m_Instance == NULL) {
- m_Instance = new cConflictCheckThread(thePlugin);
- m_Instance->Start();
- }
- else
- if (runOnce) m_forceUpdate = true; // force an update, because thread is already running
+ if (EPGSearchConfig.checkTimerConflictsAfterUpdate || EPGSearchConfig.conflictCheckIntervall == 0) {
+ if (!runOnce) return;
+ m_runOnce = true;
+ }
+
+ if (m_Instance == NULL) {
+ m_Instance = new cConflictCheckThread(thePlugin);
+ m_Instance->Start();
+ } else if (runOnce) m_forceUpdate = true; // force an update, because thread is already running
}
-void cConflictCheckThread::Exit(void) {
+void cConflictCheckThread::Exit(void)
+{
if (m_Instance != NULL) {
- m_Instance->Stop();
- DELETENULL(m_Instance);
+ m_Instance->Stop();
+ DELETENULL(m_Instance);
}
}
-void cConflictCheckThread::Stop(void) {
+void cConflictCheckThread::Stop(void)
+{
m_Active = false;
Wait.Signal();
Cancel(6);
@@ -87,80 +87,74 @@ void cConflictCheckThread::Action(void)
m_Active = true;
// let VDR do its startup
- if (!m_runOnce)
- {
- if (!cPluginEpgsearch::VDR_readyafterStartup)
- LogFile.Log(2, "ConflictCheckThread: waiting for VDR to become ready...");
- while(m_Active && !cPluginEpgsearch::VDR_readyafterStartup)
- Wait.Wait(1000);
- }
+ if (!m_runOnce) {
+ if (!cPluginEpgsearch::VDR_readyafterStartup)
+ LogFile.Log(2, "ConflictCheckThread: waiting for VDR to become ready...");
+ while (m_Active && !cPluginEpgsearch::VDR_readyafterStartup)
+ Wait.Wait(1000);
+ }
time_t nextUpdate = time(NULL);
- while (m_Active && Running())
- {
- time_t now = time(NULL);
- if (now >= nextUpdate || m_forceUpdate)
- {
- m_forceUpdate = false;
+ while (m_Active && Running()) {
+ time_t now = time(NULL);
+ if (now >= nextUpdate || m_forceUpdate) {
+ m_forceUpdate = false;
{
LOCK_TIMERS_WRITE;
Timers->SetExplicitModify();
}
- LogFile.iSysLog("timer conflict check started");
-
- cConflictCheck conflictCheck;
- conflictCheck.Check();
-
- time_t nextConflict = 0;
- if (conflictCheck.relevantConflicts > 0)
- {
- cString msgfmt = "";
- if (conflictCheck.relevantConflicts == 1)
- msgfmt = cString::sprintf(tr("timer conflict at %s! Show it?"),
- *DateTime(conflictCheck.nextRelevantConflictDate));
- else
- msgfmt = cString::sprintf(tr("%d timer conflicts! First at %s. Show them?"),
- conflictCheck.relevantConflicts,
- *DateTime(conflictCheck.nextRelevantConflictDate));
- bool doMessage = EPGSearchConfig.noConflMsgWhileReplay == 0 ||
- !cDevice::PrimaryDevice()->Replaying() ||
- conflictCheck.nextRelevantConflictDate - now < 2*60*60;
- if (doMessage && SendMsg(msgfmt, true,7, mtWarning) == kOk)
- {
- m_plugin->showConflicts = true;
- cRemote::CallPlugin("epgsearch");
- }
-
- if (EPGSearchConfig.sendMailOnConflicts)
- {
- cMailConflictNotifier mailNotifier;
- mailNotifier.SendConflictNotifications(conflictCheck);
- }
- conflictCheck.EvaluateConflCheckCmd();
- }
- // store for external access
- cConflictCheckThread::m_cacheNextConflict = conflictCheck.nextRelevantConflictDate;
- cConflictCheckThread::m_cacheRelevantConflicts = conflictCheck.relevantConflicts;
- cConflictCheckThread::m_cacheTotalConflicts = conflictCheck.numConflicts;
-
- LogFile.iSysLog("timer conflict check finished");
-
- m_lastUpdate = time(NULL);
- int Intervall = EPGSearchConfig.conflictCheckIntervall;
- if (nextConflict > 0 && EPGSearchConfig.conflictCheckWithinLimit > 0 &&
- nextConflict - time(NULL) < EPGSearchConfig.conflictCheckWithinLimit * 60)
- Intervall = EPGSearchConfig.conflictCheckIntervall2;
-
- nextUpdate = long(m_lastUpdate/60)*60 + (Intervall * 60);
- }
- if (m_Active && Running())
- Wait.Wait(2000); // to avoid high system load if time%30==0 ?????????????????????
- // no waiting in the while loop if m_runOnce is true
- while (Running() && m_Active && time(NULL)%30 != 0 && !m_runOnce) // sync heart beat to a multiple of 5secs
- Wait.Wait(1000);
+ LogFile.iSysLog("timer conflict check started");
+
+ cConflictCheck conflictCheck;
+ conflictCheck.Check();
+
+ time_t nextConflict = 0;
+ if (conflictCheck.relevantConflicts > 0) {
+ cString msgfmt = "";
+ if (conflictCheck.relevantConflicts == 1)
+ msgfmt = cString::sprintf(tr("timer conflict at %s! Show it?"),
+ *DateTime(conflictCheck.nextRelevantConflictDate));
+ else
+ msgfmt = cString::sprintf(tr("%d timer conflicts! First at %s. Show them?"),
+ conflictCheck.relevantConflicts,
+ *DateTime(conflictCheck.nextRelevantConflictDate));
+ bool doMessage = EPGSearchConfig.noConflMsgWhileReplay == 0 ||
+ !cDevice::PrimaryDevice()->Replaying() ||
+ conflictCheck.nextRelevantConflictDate - now < 2 * 60 * 60;
+ if (doMessage && SendMsg(msgfmt, true, 7, mtWarning) == kOk) {
+ m_plugin->showConflicts = true;
+ cRemote::CallPlugin("epgsearch");
+ }
+
+ if (EPGSearchConfig.sendMailOnConflicts) {
+ cMailConflictNotifier mailNotifier;
+ mailNotifier.SendConflictNotifications(conflictCheck);
+ }
+ conflictCheck.EvaluateConflCheckCmd();
+ }
+ // store for external access
+ cConflictCheckThread::m_cacheNextConflict = conflictCheck.nextRelevantConflictDate;
+ cConflictCheckThread::m_cacheRelevantConflicts = conflictCheck.relevantConflicts;
+ cConflictCheckThread::m_cacheTotalConflicts = conflictCheck.numConflicts;
+
+ LogFile.iSysLog("timer conflict check finished");
+
+ m_lastUpdate = time(NULL);
+ int Intervall = EPGSearchConfig.conflictCheckIntervall;
+ if (nextConflict > 0 && EPGSearchConfig.conflictCheckWithinLimit > 0 &&
+ nextConflict - time(NULL) < EPGSearchConfig.conflictCheckWithinLimit * 60)
+ Intervall = EPGSearchConfig.conflictCheckIntervall2;
+
+ nextUpdate = long(m_lastUpdate / 60) * 60 + (Intervall * 60);
+ }
+ if (m_Active && Running())
+ Wait.Wait(2000); // to avoid high system load if time%30==0 ?????????????????????
+ // no waiting in the while loop if m_runOnce is true
+ while (Running() && m_Active && time(NULL) % 30 != 0 && !m_runOnce) // sync heart beat to a multiple of 5secs
+ Wait.Wait(1000);
};
- m_Active = false; // always false at this point
+ m_Active = false; // always false at this point
LogFile.iSysLog("Leaving conflict check thread");
}
diff --git a/conflictcheck_thread.h b/conflictcheck_thread.h
index 368c688..6e2e75a 100644
--- a/conflictcheck_thread.h
+++ b/conflictcheck_thread.h
@@ -28,18 +28,19 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "conflictcheck.h"
#include "epgsearch.h"
-class cConflictCheckThread: public cThread {
- private:
+class cConflictCheckThread: public cThread
+{
+private:
bool m_Active;
time_t m_lastUpdate;
cPluginEpgsearch* m_plugin;
static bool m_runOnce;
static bool m_forceUpdate;
cCondWait Wait;
- protected:
+protected:
virtual void Action(void);
void Stop(void);
- public:
+public:
static cConflictCheckThread *m_Instance;
static time_t m_cacheNextConflict;
static int m_cacheRelevantConflicts;
diff --git a/conflictcheckonly.c b/conflictcheckonly.c
index eb6cc43..b49e325 100644
--- a/conflictcheckonly.c
+++ b/conflictcheckonly.c
@@ -34,74 +34,75 @@ static const char SETUPTEXT[] = trNOOP("Conflict info in main menu");
cString DateTime(time_t t)
{
- char buffer[32];
- if (t == 0) {
- time(&t);
- }
- struct tm tm_r;
- tm *tm = localtime_r(&t, &tm_r);
- snprintf(buffer, sizeof(buffer), "%02d.%02d. %02d:%02d", tm->tm_mday,
- tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
- return buffer;
+ char buffer[32];
+ if (t == 0) {
+ time(&t);
+ }
+ struct tm tm_r;
+ tm *tm = localtime_r(&t, &tm_r);
+ snprintf(buffer, sizeof(buffer), "%02d.%02d. %02d:%02d", tm->tm_mday,
+ tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
+ return buffer;
}
-class cPluginConflictcheckonly:public cMainMenuShortcut {
+class cPluginConflictcheckonly: public cMainMenuShortcut
+{
private:
- char *_menuText;
+ char *_menuText;
public:
- cPluginConflictcheckonly();
- ~cPluginConflictcheckonly();
- virtual const char *Version() {
- return VERSION;
- }
- virtual const char *Description() {
- return I18nTranslate(DESCRIPTION, I18nEpgsearch);
- }
- virtual bool Initialize();
- virtual cOsdObject *MainMenuAction() {
- return GetEpgSearchMenu("Epgsearch-conflictmenu-v1.0");
- }
+ cPluginConflictcheckonly();
+ ~cPluginConflictcheckonly();
+ virtual const char *Version() {
+ return VERSION;
+ }
+ virtual const char *Description() {
+ return I18nTranslate(DESCRIPTION, I18nEpgsearch);
+ }
+ virtual bool Initialize();
+ virtual cOsdObject *MainMenuAction() {
+ return GetEpgSearchMenu("Epgsearch-conflictmenu-v1.0");
+ }
protected:
- virtual const char *SetupText() {
- return I18nTranslate(SETUPTEXT, I18nEpgsearch);
- }
- virtual const char *MainMenuText(void);
+ virtual const char *SetupText() {
+ return I18nTranslate(SETUPTEXT, I18nEpgsearch);
+ }
+ virtual const char *MainMenuText(void);
};
-cPluginConflictcheckonly::cPluginConflictcheckonly():_menuText(NULL)
+cPluginConflictcheckonly::cPluginConflictcheckonly(): _menuText(NULL)
{
}
cPluginConflictcheckonly::~cPluginConflictcheckonly()
{
- free(_menuText);
+ free(_menuText);
}
const char *cPluginConflictcheckonly::MainMenuText(void)
{
- const char *menuText = I18nTranslate(MAINMENUENTRY, I18nEpgsearch);
-
- cPlugin *epgSearchPlugin = cPluginManager::GetPlugin("epgsearch");
- if (epgSearchPlugin) {
- Epgsearch_lastconflictinfo_v1_0 *serviceData = new Epgsearch_lastconflictinfo_v1_0;
- if (epgSearchPlugin->Service("Epgsearch-lastconflictinfo-v1.0", serviceData)) {
- if (serviceData->relevantConflicts > 0) {
- free(_menuText);
- if (asprintf(&_menuText, "%s (%d, %s: %s)", menuText, serviceData->relevantConflicts,
- I18nTranslate(trNOOP("next"), I18nEpgsearch), *DateTime(serviceData->nextConflict)))
- menuText = _menuText;
- }
+ const char *menuText = I18nTranslate(MAINMENUENTRY, I18nEpgsearch);
+
+ cPlugin *epgSearchPlugin = cPluginManager::GetPlugin("epgsearch");
+ if (epgSearchPlugin) {
+ Epgsearch_lastconflictinfo_v1_0 *serviceData = new Epgsearch_lastconflictinfo_v1_0;
+ if (epgSearchPlugin->Service("Epgsearch-lastconflictinfo-v1.0", serviceData)) {
+ if (serviceData->relevantConflicts > 0) {
+ free(_menuText);
+ if (asprintf(&_menuText, "%s (%d, %s: %s)", menuText, serviceData->relevantConflicts,
+ I18nTranslate(trNOOP("next"), I18nEpgsearch), *DateTime(serviceData->nextConflict)))
+ menuText = _menuText;
+ }
+ }
+ delete serviceData;
}
- delete serviceData;
- }
- return menuText;
+ return menuText;
}
bool cPluginConflictcheckonly::Initialize(void)
{
- return cMainMenuShortcut::Initialize();
+ return cMainMenuShortcut::Initialize();
}
-VDRPLUGINCREATOR(cPluginConflictcheckonly); // Don't touch this!
+VDRPLUGINCREATOR(cPluginConflictcheckonly); // Don't touch this!
diff --git a/createcats.c b/createcats.c
index e3972a6..e517645 100644
--- a/createcats.c
+++ b/createcats.c
@@ -44,32 +44,35 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
bool isnumber(const char *s)
{
- if (!*s)
- return false;
- while (*s) {
+ if (!*s)
+ return false;
+ while (*s) {
if (!isdigit(*s))
- return false;
+ return false;
s++;
- }
- return true;
+ }
+ return true;
}
// --- cReadLine -------------------------------------------------------------
-class cReadLine {
- private:
+class cReadLine
+{
+private:
char buffer[MAXPARSEBUFFER];
- public:
- cReadLine() { buffer[0]=0; }
+public:
+ cReadLine() {
+ buffer[0] = 0;
+ }
char *Read(FILE *f);
};
char *cReadLine::Read(FILE *f)
{
if (fgets(buffer, sizeof(buffer), f) > 0) {
- int l = strlen(buffer) - 1;
- if (l >= 0 && buffer[l] == '\n')
- buffer[l] = 0;
- return buffer;
+ int l = strlen(buffer) - 1;
+ if (l >= 0 && buffer[l] == '\n')
+ buffer[l] = 0;
+ return buffer;
}
return NULL;
}
@@ -81,7 +84,7 @@ char *skipspace(const char *s)
return (char *)s;
}
-int comparevalue( const void *arg1, const void *arg2 )
+int comparevalue(const void *arg1, const void *arg2)
{
char* value1 = *(char**) arg1;
char* value2 = *(char**) arg2;
@@ -89,99 +92,95 @@ int comparevalue( const void *arg1, const void *arg2 )
}
// --- cCat -------------------------------------------------------------
-class cCat {
- public:
+class cCat
+{
+public:
int appeared;
char name[MAXPARSEBUFFER];
int numvalues;
char** values;
cCat(char* n)
- :appeared(0), numvalues(0), values(NULL)
- {
- strcpy(name, n);
- }
- void addvalue(char* value)
- {
- if (valueexists(value))
- return;
- char* newvalue = (char*) malloc(sizeof(char) * (strlen(value)+1));
- strcpy(newvalue, value);
- char **tmp = (char**) realloc(values, sizeof(char*)*(numvalues+1));
- if (tmp) {
- values=tmp;
- values[numvalues++] = newvalue;
- } else {
- free(newvalue);
- }
- }
- bool valueexists(char* value)
- {
- for(int i=0; i<numvalues; i++)
- if (strcmp(values[i], value) == 0)
- return true;
- return false;
- }
- void sort()
- {
- qsort(values, numvalues, sizeof(char*), comparevalue );
- }
+ : appeared(0), numvalues(0), values(NULL) {
+ strcpy(name, n);
+ }
+ void addvalue(char* value) {
+ if (valueexists(value))
+ return;
+ char* newvalue = (char*) malloc(sizeof(char) * (strlen(value) + 1));
+ strcpy(newvalue, value);
+ char **tmp = (char**) realloc(values, sizeof(char*) * (numvalues + 1));
+ if (tmp) {
+ values = tmp;
+ values[numvalues++] = newvalue;
+ } else {
+ free(newvalue);
+ }
+ }
+ bool valueexists(char* value) {
+ for (int i = 0; i < numvalues; i++)
+ if (strcmp(values[i], value) == 0)
+ return true;
+ return false;
+ }
+ void sort() {
+ qsort(values, numvalues, sizeof(char*), comparevalue);
+ }
};
-int comparecat( const void *arg1, const void *arg2 )
+int comparecat(const void *arg1, const void *arg2)
{
cCat* cat1 = *(cCat**) arg1;
cCat* cat2 = *(cCat**) arg2;
if (cat1->appeared == cat2->appeared) return 0;
- if (cat1->appeared < cat2->appeared) return 1; else return -1;
+ if (cat1->appeared < cat2->appeared) return 1;
+ else return -1;
}
// --- cCats -------------------------------------------------------------
-class cCats {
- private:
+class cCats
+{
+private:
int numcats;
cCat** cats;
- public:
- cCats():numcats(0), cats(NULL) {}
-
- int num() {return numcats;}
-
- cCat* add(char* name)
- {
- cCat* newCat = new cCat(name);
- cCat **tmp = (cCat**) realloc(cats, sizeof(cCat*)*(numcats+1));
- if (tmp)
- {
- cats=tmp;
- cats[numcats++] = newCat;
- return newCat;
- } else {
- delete newCat;
- return NULL;
- }
- }
-
- cCat* get(int i)
- {
- if (i>=0 && i<numcats)
- return cats[i];
- else
- return NULL;
- }
-
- cCat* exists(char* name)
- {
- for(int i=0; i<numcats; i++)
- if (strcmp(cats[i]->name, name) == 0)
- return cats[i];
- return NULL;
- }
- void sort()
- {
- for(int i=0; i<numcats; i++)
- cats[i]->sort();
- qsort(cats, numcats, sizeof( cCat* ), comparecat );
- }
+public:
+ cCats(): numcats(0), cats(NULL) {}
+
+ int num() {
+ return numcats;
+ }
+
+ cCat* add(char* name) {
+ cCat* newCat = new cCat(name);
+ cCat **tmp = (cCat**) realloc(cats, sizeof(cCat*) * (numcats + 1));
+ if (tmp) {
+ cats = tmp;
+ cats[numcats++] = newCat;
+ return newCat;
+ } else {
+ delete newCat;
+ return NULL;
+ }
+ }
+
+ cCat* get(int i) {
+ if (i >= 0 && i < numcats)
+ return cats[i];
+ else
+ return NULL;
+ }
+
+ cCat* exists(char* name) {
+ for (int i = 0; i < numcats; i++)
+ if (strcmp(cats[i]->name, name) == 0)
+ return cats[i];
+ return NULL;
+ }
+ void sort() {
+ for (int i = 0; i < numcats; i++)
+ cats[i]->sort();
+ qsort(cats, numcats, sizeof(cCat*), comparecat);
+ }
};
int main(int argc, char *argv[])
@@ -193,118 +192,106 @@ int main(int argc, char *argv[])
unsigned int maxlength = MAXNAMELENGTH;
static const struct option long_options[] = {
- { "minappearance", required_argument, NULL, 'm' },
- { "maxvalues", required_argument, NULL, 'v' },
- { "maxlength", required_argument, NULL, 'l' },
- { "help", no_argument, NULL, 'h' },
- { NULL, no_argument, NULL, 0 }
+ { "minappearance", required_argument, NULL, 'm' },
+ { "maxvalues", required_argument, NULL, 'v' },
+ { "maxlength", required_argument, NULL, 'l' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL, no_argument, NULL, 0 }
};
int c;
- while ((c = getopt_long(argc, argv, "m:v:l:h", long_options, NULL)) != -1)
- {
- switch (c)
- {
- case 'm':
- if (isnumber(optarg))
- {
- minappearance = atoi(optarg);
- break;
- }
- fprintf(stderr, "invalid parameter minappearance: %s\n", optarg);
- return 2;
- break;
- case 'v':
- if (isnumber(optarg))
- {
- maxvalues = atoi(optarg);
- break;
- }
- fprintf(stderr, "invalid parameter maxvalues: %s\n", optarg);
- return 2;
- break;
- case 'l':
- if (isnumber(optarg))
- {
- maxlength = atoi(optarg);
- break;
- }
- fprintf(stderr, "invalid parameter maxlength: %s\n", optarg);
- return 2;
- break;
- case 'h':
- printf("usage: createcats [OPTIONS] /path_to/epg.data\n\n");
- printf("-m N, --minappearance=N the minimum number a category has to appear\n");
- printf(" to be used\n");
- printf("-v N, --maxvalues=N values of a category are omitted if they exceed\n");
- printf(" this number\n");
- printf("-l N, --maxlength=N the maximum length of a text to be accepted\n");
- printf(" as a category value\n");
- printf("-h, --help this help\n\n");
- return 0;
- default:
- break;
- }
+ while ((c = getopt_long(argc, argv, "m:v:l:h", long_options, NULL)) != -1) {
+ switch (c) {
+ case 'm':
+ if (isnumber(optarg)) {
+ minappearance = atoi(optarg);
+ break;
+ }
+ fprintf(stderr, "invalid parameter minappearance: %s\n", optarg);
+ return 2;
+ break;
+ case 'v':
+ if (isnumber(optarg)) {
+ maxvalues = atoi(optarg);
+ break;
+ }
+ fprintf(stderr, "invalid parameter maxvalues: %s\n", optarg);
+ return 2;
+ break;
+ case 'l':
+ if (isnumber(optarg)) {
+ maxlength = atoi(optarg);
+ break;
+ }
+ fprintf(stderr, "invalid parameter maxlength: %s\n", optarg);
+ return 2;
+ break;
+ case 'h':
+ printf("usage: createcats [OPTIONS] /path_to/epg.data\n\n");
+ printf("-m N, --minappearance=N the minimum number a category has to appear\n");
+ printf(" to be used\n");
+ printf("-v N, --maxvalues=N values of a category are omitted if they exceed\n");
+ printf(" this number\n");
+ printf("-l N, --maxlength=N the maximum length of a text to be accepted\n");
+ printf(" as a category value\n");
+ printf("-h, --help this help\n\n");
+ return 0;
+ default:
+ break;
+ }
}
- if (argc < 2)
- {
- fprintf(stderr, "ERROR: please pass your epg.data\nusage: createcats epg.data\n");
- return 1;
+ if (argc < 2) {
+ fprintf(stderr, "ERROR: please pass your epg.data\nusage: createcats epg.data\n");
+ return 1;
}
- f = fopen(argv[argc-1], "r");
- if (f == NULL)
- {
- fprintf(stderr, "ERROR: could not open: %s\n", argv[1]);
- return 1;
+ f = fopen(argv[argc - 1], "r");
+ if (f == NULL) {
+ fprintf(stderr, "ERROR: could not open: %s\n", argv[1]);
+ return 1;
}
char *s;
cReadLine ReadLine;
- while ((s = ReadLine.Read(f)) != NULL)
- {
- if (*s == 'D')
- {
- s = strchr(s,'|'); // jump to possibly first category
- if (!s)
- continue;
- s++;
- char *pstrSearchToken;
- char *pstrSearch=strdup(s);
- pstrSearchToken=strtok(pstrSearch, "|");
-
- while(pstrSearchToken)
- {
- // must have a ':'
- char* szPos = NULL;
- if ((szPos = strchr(pstrSearchToken, ':')) == NULL)
- {
- pstrSearchToken=strtok(NULL, "|");
- continue;
- }
-
- char catname[MAXPARSEBUFFER] = "";
- char catvalue[MAXPARSEBUFFER] = "";
-
- strncpy(catname, pstrSearchToken, szPos - pstrSearchToken);
- catname[szPos - pstrSearchToken] = 0;
- strcpy(catvalue, skipspace(szPos+1));
-
- cCat* cat = catlist.exists(catname);
- if (!cat && strlen(catname) < maxlength) // accept only names up to 30 chars
- cat = catlist.add(catname);
-
- if (cat)
- {
- cat->appeared++;
- if (strlen(catvalue) < maxlength) // accept only values up to 30 chars
- cat->addvalue(catvalue);
- }
-
- pstrSearchToken=strtok(NULL, "|");
- }
- free(pstrSearch);
+ while ((s = ReadLine.Read(f)) != NULL) {
+ if (*s == 'D') {
+ s = strchr(s, '|'); // jump to possibly first category
+ if (!s)
+ continue;
+ s++;
+ char *pstrSearchToken;
+ char *pstrSearch = strdup(s);
+ pstrSearchToken = strtok(pstrSearch, "|");
+
+ while (pstrSearchToken) {
+ // must have a ':'
+ char* szPos = NULL;
+ if ((szPos = strchr(pstrSearchToken, ':')) == NULL) {
+ pstrSearchToken = strtok(NULL, "|");
+ continue;
+ }
+
+ char catname[MAXPARSEBUFFER] = "";
+ char catvalue[MAXPARSEBUFFER] = "";
+
+ strncpy(catname, pstrSearchToken, szPos - pstrSearchToken);
+ catname[szPos - pstrSearchToken] = 0;
+ strcpy(catvalue, skipspace(szPos + 1));
+
+ cCat* cat = catlist.exists(catname);
+ if (!cat && strlen(catname) < maxlength) // accept only names up to 30 chars
+ cat = catlist.add(catname);
+
+ if (cat) {
+ cat->appeared++;
+ if (strlen(catvalue) < maxlength) // accept only values up to 30 chars
+ cat->addvalue(catvalue);
+ }
+
+ pstrSearchToken = strtok(NULL, "|");
+ }
+ free(pstrSearch);
}
}
fclose(f);
@@ -312,10 +299,9 @@ int main(int argc, char *argv[])
catlist.sort();
f = fopen("epgsearchcats.conf", "w");
- if (f == NULL)
- {
- fprintf(stderr, "ERROR: could not open outputfile\n");
- return 1;
+ if (f == NULL) {
+ fprintf(stderr, "ERROR: could not open outputfile\n");
+ return 1;
}
fprintf(f, "# -----------------------------------------------------------------------------\n");
fprintf(f, "# This is just a template based on your current epg.data. Please edit!\n");
@@ -350,17 +336,15 @@ int main(int argc, char *argv[])
fprintf(f, "# 15 - not equal\n");
fprintf(f, "# -----------------------------------------------------------------------------\n\n");
int id = 1;
- for(int i=0; i<catlist.num(); i++)
- {
- cCat* cat = catlist.get(i);
- if (cat->appeared > (int)minappearance && cat->numvalues > 1) // accept only category, that have at least 2 values and appear more than MINAPPEARANCE timers
- {
- fprintf(f, "# '%s' found %d times with %d different values %s\n", cat->name, cat->appeared, cat->numvalues, cat->numvalues>=(int)maxvalues?"(values omitted, too much)":"");
- fprintf(f, "%d|%s|%s|", id++, cat->name, cat->name);
- for(int j=0; cat->numvalues < (int)maxvalues && j<cat->numvalues; j++)
- fprintf(f, "%s%s", cat->values[j], (j == cat->numvalues-1?"":","));
- fprintf(f, "|1\n\n");
- }
+ for (int i = 0; i < catlist.num(); i++) {
+ cCat* cat = catlist.get(i);
+ if (cat->appeared > (int)minappearance && cat->numvalues > 1) { // accept only category, that have at least 2 values and appear more than MINAPPEARANCE timers
+ fprintf(f, "# '%s' found %d times with %d different values %s\n", cat->name, cat->appeared, cat->numvalues, cat->numvalues >= (int)maxvalues ? "(values omitted, too much)" : "");
+ fprintf(f, "%d|%s|%s|", id++, cat->name, cat->name);
+ for (int j = 0; cat->numvalues < (int)maxvalues && j < cat->numvalues; j++)
+ fprintf(f, "%s%s", cat->values[j], (j == cat->numvalues - 1 ? "" : ","));
+ fprintf(f, "|1\n\n");
+ }
}
fclose(f);
diff --git a/distance.c b/distance.c
index 7156fee..31ac95e 100644
--- a/distance.c
+++ b/distance.c
@@ -44,18 +44,18 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
// Get minimum of three values
//****************************
-int Distance::Minimum (int a, int b, int c)
+int Distance::Minimum(int a, int b, int c)
{
-int mi;
+ int mi;
- mi = a;
- if (b < mi) {
- mi = b;
- }
- if (c < mi) {
- mi = c;
- }
- return mi;
+ mi = a;
+ if (b < mi) {
+ mi = b;
+ }
+ if (c < mi) {
+ mi = c;
+ }
+ return mi;
}
@@ -63,21 +63,21 @@ int mi;
// Get a pointer to the specified cell of the matrix
//**************************************************
-int *Distance::GetCellPointer (int *pOrigin, int col, int row, int nCols)
+int *Distance::GetCellPointer(int *pOrigin, int col, int row, int nCols)
{
- return pOrigin + col + (row * (nCols + 1));
+ return pOrigin + col + (row * (nCols + 1));
}
//*****************************************************
// Get the contents of the specified cell in the matrix
//*****************************************************
-int Distance::GetAt (int *pOrigin, int col, int row, int nCols)
+int Distance::GetAt(int *pOrigin, int col, int row, int nCols)
{
-int *pCell;
+ int *pCell;
- pCell = GetCellPointer (pOrigin, col, row, nCols);
- return *pCell;
+ pCell = GetCellPointer(pOrigin, col, row, nCols);
+ return *pCell;
}
@@ -85,12 +85,12 @@ int *pCell;
// Fill the specified cell in the matrix with the value x
//*******************************************************
-void Distance::PutAt (int *pOrigin, int col, int row, int nCols, int x)
+void Distance::PutAt(int *pOrigin, int col, int row, int nCols, int x)
{
-int *pCell;
+ int *pCell;
- pCell = GetCellPointer (pOrigin, col, row, nCols);
- *pCell = x;
+ pCell = GetCellPointer(pOrigin, col, row, nCols);
+ *pCell = x;
}
@@ -98,82 +98,81 @@ int *pCell;
// Compute Levenshtein distance
//*****************************
-int Distance::LD (char const *s, char const *t, int maxLength)
+int Distance::LD(char const *s, char const *t, int maxLength)
{
-int *d; // pointer to matrix
-int n; // length of s
-int m; // length of t
-int i; // iterates through s
-int j; // iterates through t
-char s_i; // ith character of s
-char t_j; // jth character of t
-int cost; // cost
-int result; // result
-int cell; // contents of target cell
-int above; // contents of cell immediately above
-int left; // contents of cell immediately to left
-int diag; // contents of cell immediately above and to left
-int sz; // number of cells in matrix
-
- // Step 1
-
- n = min((int)strlen(s), maxLength);
- m = min((int)strlen(t), maxLength);
- if (n == 0) {
- return m;
- }
- if (m == 0) {
- return n;
- }
- sz = (n+1) * (m+1) * sizeof (int);
- d = (int *) malloc (sz);
-
- // Step 2
-
- for (i = 0; i <= n; i++) {
- PutAt (d, i, 0, n, i);
- }
-
- for (j = 0; j <= m; j++) {
- PutAt (d, 0, j, n, j);
- }
-
- // Step 3
-
- for (i = 1; i <= n; i++) {
-
- s_i = s[i-1];
-
- // Step 4
-
- for (j = 1; j <= m; j++) {
-
- t_j = t[j-1];
-
- // Step 5
-
- if (s_i == t_j) {
- cost = 0;
- }
- else {
- cost = 1;
- }
-
- // Step 6
-
- above = GetAt (d,i-1,j, n);
- left = GetAt (d,i, j-1, n);
- diag = GetAt (d, i-1,j-1, n);
- cell = Minimum (above + 1, left + 1, diag + cost);
- PutAt (d, i, j, n, cell);
+ int *d; // pointer to matrix
+ int n; // length of s
+ int m; // length of t
+ int i; // iterates through s
+ int j; // iterates through t
+ char s_i; // ith character of s
+ char t_j; // jth character of t
+ int cost; // cost
+ int result; // result
+ int cell; // contents of target cell
+ int above; // contents of cell immediately above
+ int left; // contents of cell immediately to left
+ int diag; // contents of cell immediately above and to left
+ int sz; // number of cells in matrix
+
+ // Step 1
+
+ n = min((int)strlen(s), maxLength);
+ m = min((int)strlen(t), maxLength);
+ if (n == 0) {
+ return m;
+ }
+ if (m == 0) {
+ return n;
+ }
+ sz = (n + 1) * (m + 1) * sizeof(int);
+ d = (int *) malloc(sz);
+
+ // Step 2
+
+ for (i = 0; i <= n; i++) {
+ PutAt(d, i, 0, n, i);
+ }
+
+ for (j = 0; j <= m; j++) {
+ PutAt(d, 0, j, n, j);
+ }
+
+ // Step 3
+
+ for (i = 1; i <= n; i++) {
+
+ s_i = s[i - 1];
+
+ // Step 4
+
+ for (j = 1; j <= m; j++) {
+
+ t_j = t[j - 1];
+
+ // Step 5
+
+ if (s_i == t_j) {
+ cost = 0;
+ } else {
+ cost = 1;
+ }
+
+ // Step 6
+
+ above = GetAt(d, i - 1, j, n);
+ left = GetAt(d, i, j - 1, n);
+ diag = GetAt(d, i - 1, j - 1, n);
+ cell = Minimum(above + 1, left + 1, diag + cost);
+ PutAt(d, i, j, n, cell);
+ }
}
- }
- // Step 7
+ // Step 7
- result = GetAt (d, n, m, n);
- free (d);
- return result;
+ result = GetAt(d, n, m, n);
+ free(d);
+ return result;
}
diff --git a/distance.h b/distance.h
index 3da52c9..24f98b7 100644
--- a/distance.h
+++ b/distance.h
@@ -35,13 +35,13 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class Distance
{
- public:
- int LD (char const *s, char const *t, int maxLength);
- private:
- int Minimum (int a, int b, int c);
- int *GetCellPointer (int *pOrigin, int col, int row, int nCols);
- int GetAt (int *pOrigin, int col, int row, int nCols);
- void PutAt (int *pOrigin, int col, int row, int nCols, int x);
+public:
+ int LD(char const *s, char const *t, int maxLength);
+private:
+ int Minimum(int a, int b, int c);
+ int *GetCellPointer(int *pOrigin, int col, int row, int nCols);
+ int GetAt(int *pOrigin, int col, int row, int nCols);
+ void PutAt(int *pOrigin, int col, int row, int nCols, int x);
};
#endif
diff --git a/epgsearch.c b/epgsearch.c
index 2e01d0e..1d76cdb 100644
--- a/epgsearch.c
+++ b/epgsearch.c
@@ -93,629 +93,609 @@ const char *epgsSVDRP::cSVDRPClient::SVDRPSendCmd = "svdrpsend";
cPluginEpgsearch::cPluginEpgsearch(void)
{
- showConflicts = false;
- showAnnounces = false;
- gl_recStatusMonitor = NULL;
- gl_timerStatusMonitor = NULL;
+ showConflicts = false;
+ showAnnounces = false;
+ gl_recStatusMonitor = NULL;
+ gl_timerStatusMonitor = NULL;
}
cPluginEpgsearch::~cPluginEpgsearch()
{
- delete gl_recStatusMonitor;
- delete gl_timerStatusMonitor;
- cSearchTimerThread::Exit();
- cSwitchTimerThread::Exit();
- cConflictCheckThread::Exit();
- if (ConfigDir) free(ConfigDir);
+ delete gl_recStatusMonitor;
+ delete gl_timerStatusMonitor;
+ cSearchTimerThread::Exit();
+ cSwitchTimerThread::Exit();
+ cConflictCheckThread::Exit();
+ if (ConfigDir) free(ConfigDir);
}
const char* cPluginEpgsearch::Version(void)
{
- return VERSION;
+ return VERSION;
}
const char* cPluginEpgsearch::Description(void)
{
- return tr(DESCRIPTION);
+ return tr(DESCRIPTION);
}
const char *cPluginEpgsearch::CommandLineHelp(void)
{
- return " -f file, --svdrpsendcmd=file the path to svdrpsend for external\n"
- " SVDRP communication (default is internal\n"
- " communication)\n"
- " -c path, --config=path to specify a specific config dir for epgsearch\n"
- " -l file, --logfile=file to specify a specific logfile for epgsearch\n"
- " -v n, --verbose=n verbose level for logfile\n"
- " -r, --reloadmenuconf reload epgsearchmenu.conf with plugin call\n"
- " -m file, --mailcmd=file path to an alternative mail script for mail\n"
- " notification\n";
+ return " -f file, --svdrpsendcmd=file the path to svdrpsend for external\n"
+ " SVDRP communication (default is internal\n"
+ " communication)\n"
+ " -c path, --config=path to specify a specific config dir for epgsearch\n"
+ " -l file, --logfile=file to specify a specific logfile for epgsearch\n"
+ " -v n, --verbose=n verbose level for logfile\n"
+ " -r, --reloadmenuconf reload epgsearchmenu.conf with plugin call\n"
+ " -m file, --mailcmd=file path to an alternative mail script for mail\n"
+ " notification\n";
}
const char *cPluginEpgsearch::MainMenuEntry(void)
{
- if (EPGSearchConfig.hidemenu)
- return NULL;
- if (isempty(EPGSearchConfig.mainmenuentry))
- return tr("Program guide");
- else
- return EPGSearchConfig.mainmenuentry;
+ if (EPGSearchConfig.hidemenu)
+ return NULL;
+ if (isempty(EPGSearchConfig.mainmenuentry))
+ return tr("Program guide");
+ else
+ return EPGSearchConfig.mainmenuentry;
}
bool cPluginEpgsearch::ProcessArgs(int argc, char *argv[])
{
- // Implement command line argument processing here if applicable.
-
-
- if (argc==5 && !strcmp(argv[0], "timermenu"))
- { // yes, this is an ugly hack!
- argv[1] = (char*) new cMenuMyEditTimer((cTimer*) argv[2], (bool) argv[3], (const cEvent*) argv[4]);
- return true;
- }
-
- if (argc==8 && !strcmp(argv[0], "searchepg"))
- {
- cSearchExt* SearchExt = new cSearchExt;
- strn0cpy(SearchExt->search,argv[2], sizeof(SearchExt->search));
- if (atoi(argv[3]) > 0)
- {
- LOCK_CHANNELS_READ;
- SearchExt->useChannel = true;
- SearchExt->channelMin = Channels->GetByNumber(atoi(argv[3]));
- SearchExt->channelMax = Channels->GetByNumber(atoi(argv[3]));
- }
- SearchExt->mode = atoi(argv[4]);
- SearchExt->useTitle = atoi(argv[5]);
- SearchExt->useSubtitle = atoi(argv[6]);
- SearchExt->useDescription = atoi(argv[7]);
- argv[1] = (char*) new cMenuSearchResultsForSearch(SearchExt, cTemplFile::GetTemplateByName("MenuSearchResults"));
- return true;
- }
-
- static const struct option long_options[] = {
- { "svdrpsendcmd", required_argument, NULL, 'f' },
- { "config", required_argument, NULL, 'c' },
- { "logfile", required_argument, NULL, 'l' },
- { "verbose", required_argument, NULL, 'v' },
- { "mailcmd", required_argument, NULL, 'm' },
- { "reloadmenuconf", no_argument, NULL, 'r' },
- { NULL, no_argument, NULL, 0 }
- };
-
- int c=0,i=0;
-
- while ((c = getopt_long(argc, argv, "f:c:l:v:m:r", long_options, &i)) != -1) {
- switch (c) {
-
- case 'f':
+ // Implement command line argument processing here if applicable.
+
+
+ if (argc == 5 && !strcmp(argv[0], "timermenu")) {
+ // yes, this is an ugly hack!
+ argv[1] = (char*) new cMenuMyEditTimer((cTimer*) argv[2], (bool) argv[3], (const cEvent*) argv[4]);
+ return true;
+ }
+
+ if (argc == 8 && !strcmp(argv[0], "searchepg")) {
+ cSearchExt* SearchExt = new cSearchExt;
+ strn0cpy(SearchExt->search, argv[2], sizeof(SearchExt->search));
+ if (atoi(argv[3]) > 0) {
+ LOCK_CHANNELS_READ;
+ SearchExt->useChannel = true;
+ SearchExt->channelMin = Channels->GetByNumber(atoi(argv[3]));
+ SearchExt->channelMax = Channels->GetByNumber(atoi(argv[3]));
+ }
+ SearchExt->mode = atoi(argv[4]);
+ SearchExt->useTitle = atoi(argv[5]);
+ SearchExt->useSubtitle = atoi(argv[6]);
+ SearchExt->useDescription = atoi(argv[7]);
+ argv[1] = (char*) new cMenuSearchResultsForSearch(SearchExt, cTemplFile::GetTemplateByName("MenuSearchResults"));
+ return true;
+ }
+
+ static const struct option long_options[] = {
+ { "svdrpsendcmd", required_argument, NULL, 'f' },
+ { "config", required_argument, NULL, 'c' },
+ { "logfile", required_argument, NULL, 'l' },
+ { "verbose", required_argument, NULL, 'v' },
+ { "mailcmd", required_argument, NULL, 'm' },
+ { "reloadmenuconf", no_argument, NULL, 'r' },
+ { NULL, no_argument, NULL, 0 }
+ };
+
+ int c = 0, i = 0;
+
+ while ((c = getopt_long(argc, argv, "f:c:l:v:m:r", long_options, &i)) != -1) {
+ switch (c) {
+
+ case 'f':
epgsSVDRP::cSVDRPClient::SVDRPSendCmd = optarg;
EPGSearchConfig.useExternalSVDRP = 1;
break;
- case 'c':
+ case 'c':
ConfigDir = strdup(optarg);
break;
- case 'l':
+ case 'l':
cLogFile::LogFileName = optarg;
break;
- case 'v':
+ case 'v':
cLogFile::loglevellimit = atoi(optarg);
break;
- case 'r':
+ case 'r':
reloadMenuConf = true;
break;
- case 'm':
+ case 'm':
cMailNotifier::MailCmd = optarg;
break;
- default: return false;
- }
- }
+ default:
+ return false;
+ }
+ }
- if (EPGSearchConfig.useExternalSVDRP && access(epgsSVDRP::cSVDRPClient::SVDRPSendCmd, F_OK) != 0)
- {
- LogFile.eSysLog("ERROR - can't find svdrpsend script: '%s'", epgsSVDRP::cSVDRPClient::SVDRPSendCmd);
- epgsSVDRP::cSVDRPClient::SVDRPSendCmd = NULL;
- }
+ if (EPGSearchConfig.useExternalSVDRP && access(epgsSVDRP::cSVDRPClient::SVDRPSendCmd, F_OK) != 0) {
+ LogFile.eSysLog("ERROR - can't find svdrpsend script: '%s'", epgsSVDRP::cSVDRPClient::SVDRPSendCmd);
+ epgsSVDRP::cSVDRPClient::SVDRPSendCmd = NULL;
+ }
- return true;
+ return true;
}
bool cPluginEpgsearch::Service(const char *Id, void *Data)
{
- if (strcmp(Id, "MainMenuHooksPatch-v1.0::osSchedule") == 0 && EPGSearchConfig.ReplaceOrgSchedule!=0)
- {
- if (Data == NULL)
- return true;
- cOsdMenu **menu = (cOsdMenu**) Data;
- if (menu)
- *menu = (cOsdMenu*) MainMenuAction();
- return true;
- }
-
- if (strcmp(Id, "Epgsearch-search-v1.0") == 0) {
- if (Data == NULL)
- return true;
- cSearchExt* SearchExt = new cSearchExt;
-
- Epgsearch_search_v1_0* searchData = (Epgsearch_search_v1_0*) Data;
- searchData->pResultMenu = NULL;
- strn0cpy(SearchExt->search,searchData->query, sizeof(SearchExt->search));
- if (searchData->channelNr > 0)
- {
- LOCK_CHANNELS_READ;
- SearchExt->useChannel = true;
- SearchExt->channelMin = Channels->GetByNumber(searchData->channelNr);
- SearchExt->channelMax = Channels->GetByNumber(searchData->channelNr);
- }
- SearchExt->mode = searchData->mode;
- SearchExt->useTitle = searchData->useTitle;
- SearchExt->useSubtitle = searchData->useSubTitle;
- SearchExt->useDescription = searchData->useDescription;
- searchData->pResultMenu = new cMenuSearchResultsForSearch(SearchExt, cTemplFile::GetTemplateByName("MenuSearchResults"));
-
- return true;
- }
- if (strcmp(Id, "Epgsearch-exttimeredit-v1.0") == 0 && !EPGSearchConfig.useVDRTimerEditMenu) {
- if (Data == NULL)
- return true;
-
- Epgsearch_exttimeredit_v1_0* serviceData = (Epgsearch_exttimeredit_v1_0*) Data;
- serviceData->pTimerMenu = new cMenuMyEditTimer(serviceData->timer, serviceData->bNew, serviceData->event);
-
- return true;
- }
- if (strcmp(Id, "Epgsearch-enablesearchtimers-v1.0") == 0) {
- if (Data == NULL)
- return true;
- else
- {
- Epgsearch_enablesearchtimers_v1_0* serviceData = (Epgsearch_enablesearchtimers_v1_0*) Data;
- if (serviceData->enable && cSearchTimerThread::m_Instance == NULL)
- cSearchTimerThread::Init(this);
- else if (!serviceData->enable && cSearchTimerThread::m_Instance != NULL)
- cSearchTimerThread::Exit();
- }
- return true;
- }
- if (strcmp(Id, "Epgsearch-updatesearchtimers-v1.0") == 0) {
- if (Data == NULL)
- return true;
- else
- {
- Epgsearch_updatesearchtimers_v1_0* serviceData = (Epgsearch_updatesearchtimers_v1_0*) Data;
- if (!EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
- cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
- updateForced = serviceData->showMessage?3:1;
- }
- return true;
- }
- if (strcmp(Id, "Epgsearch-osdmessage-v1.0") == 0) {
- if (Data == NULL)
- return true;
- else
- {
- Epgsearch_osdmessage_v1_0* serviceData = (Epgsearch_osdmessage_v1_0*) Data;
- Skins.Message(serviceData->type, serviceData->message,5);
- }
- return true;
- }
- if (strcmp(Id, "Epgsearch-searchmenu-v1.0") == 0) {
- if (Data == NULL)
- return true;
-
- EpgSearchMenu_v1_0* serviceData = (EpgSearchMenu_v1_0*) Data;
- serviceData->Menu = new cMenuEPGSearchExt();
-
- return true;
- }
- if (strcmp(Id, "Epgsearch-conflictmenu-v1.0") == 0) {
- if (Data == NULL)
- return true;
-
- EpgSearchMenu_v1_0* serviceData = (EpgSearchMenu_v1_0*) Data;
- serviceData->Menu = new cMenuConflictCheck();
-
- return true;
- }
- if (strcmp(Id, "Epgsearch-lastconflictinfo-v1.0") == 0) {
- if (Data == NULL)
- return true;
-
- Epgsearch_lastconflictinfo_v1_0* serviceData = (Epgsearch_lastconflictinfo_v1_0*) Data;
- serviceData->nextConflict = cConflictCheckThread::m_cacheNextConflict;
- serviceData->relevantConflicts = cConflictCheckThread::m_cacheRelevantConflicts;
- serviceData->totalConflicts = cConflictCheckThread::m_cacheTotalConflicts;
-
- return true;
- }
- if (strcmp(Id, "Epgsearch-searchresults-v1.0") == 0) {
- if (Data == NULL)
- return true;
- cSearchExt* SearchExt = new cSearchExt;
-
- Epgsearch_searchresults_v1_0* searchData = (Epgsearch_searchresults_v1_0*) Data;
- searchData->pResultList = NULL;
- strn0cpy(SearchExt->search,searchData->query, sizeof(SearchExt->search));
- if (searchData->channelNr > 0)
- {
- LOCK_CHANNELS_READ;
- SearchExt->useChannel = true;
- SearchExt->channelMin = Channels->GetByNumber(searchData->channelNr);
- SearchExt->channelMax = Channels->GetByNumber(searchData->channelNr);
- }
- SearchExt->mode = searchData->mode;
- SearchExt->useTitle = searchData->useTitle;
- SearchExt->useSubtitle = searchData->useSubTitle;
- SearchExt->useDescription = searchData->useDescription;
-
- cSearchResults* results = SearchExt->Run();
- // transfer to result list
- if (results)
- {
- results->SortBy(CompareEventTime);
- searchData->pResultList = new cList<Epgsearch_searchresults_v1_0::cServiceSearchResult>;
- cSearchResult *result = results->First();
- while (result)
- {
- searchData->pResultList->Add(new Epgsearch_searchresults_v1_0::cServiceSearchResult(result->event));
- result = results->Next(result);
- }
- }
- return true;
- }
- if (strcmp(Id, "Epgsearch-switchtimer-v1.0") == 0) {
- if (Data == NULL)
- return true;
- else
- {
- Epgsearch_switchtimer_v1_0* serviceData = (Epgsearch_switchtimer_v1_0*) Data;
- if (!serviceData->event)
- return false;
- switch(serviceData->mode){
+ if (strcmp(Id, "MainMenuHooksPatch-v1.0::osSchedule") == 0 && EPGSearchConfig.ReplaceOrgSchedule != 0) {
+ if (Data == NULL)
+ return true;
+ cOsdMenu **menu = (cOsdMenu**) Data;
+ if (menu)
+ *menu = (cOsdMenu*) MainMenuAction();
+ return true;
+ }
+
+ if (strcmp(Id, "Epgsearch-search-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+ cSearchExt* SearchExt = new cSearchExt;
+
+ Epgsearch_search_v1_0* searchData = (Epgsearch_search_v1_0*) Data;
+ searchData->pResultMenu = NULL;
+ strn0cpy(SearchExt->search, searchData->query, sizeof(SearchExt->search));
+ if (searchData->channelNr > 0) {
+ LOCK_CHANNELS_READ;
+ SearchExt->useChannel = true;
+ SearchExt->channelMin = Channels->GetByNumber(searchData->channelNr);
+ SearchExt->channelMax = Channels->GetByNumber(searchData->channelNr);
+ }
+ SearchExt->mode = searchData->mode;
+ SearchExt->useTitle = searchData->useTitle;
+ SearchExt->useSubtitle = searchData->useSubTitle;
+ SearchExt->useDescription = searchData->useDescription;
+ searchData->pResultMenu = new cMenuSearchResultsForSearch(SearchExt, cTemplFile::GetTemplateByName("MenuSearchResults"));
+
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-exttimeredit-v1.0") == 0 && !EPGSearchConfig.useVDRTimerEditMenu) {
+ if (Data == NULL)
+ return true;
+
+ Epgsearch_exttimeredit_v1_0* serviceData = (Epgsearch_exttimeredit_v1_0*) Data;
+ serviceData->pTimerMenu = new cMenuMyEditTimer(serviceData->timer, serviceData->bNew, serviceData->event);
+
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-enablesearchtimers-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+ else {
+ Epgsearch_enablesearchtimers_v1_0* serviceData = (Epgsearch_enablesearchtimers_v1_0*) Data;
+ if (serviceData->enable && cSearchTimerThread::m_Instance == NULL)
+ cSearchTimerThread::Init(this);
+ else if (!serviceData->enable && cSearchTimerThread::m_Instance != NULL)
+ cSearchTimerThread::Exit();
+ }
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-updatesearchtimers-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+ else {
+ Epgsearch_updatesearchtimers_v1_0* serviceData = (Epgsearch_updatesearchtimers_v1_0*) Data;
+ if (!EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
+ cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
+ updateForced = serviceData->showMessage ? 3 : 1;
+ }
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-osdmessage-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+ else {
+ Epgsearch_osdmessage_v1_0* serviceData = (Epgsearch_osdmessage_v1_0*) Data;
+ Skins.Message(serviceData->type, serviceData->message, 5);
+ }
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-searchmenu-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+
+ EpgSearchMenu_v1_0* serviceData = (EpgSearchMenu_v1_0*) Data;
+ serviceData->Menu = new cMenuEPGSearchExt();
+
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-conflictmenu-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+
+ EpgSearchMenu_v1_0* serviceData = (EpgSearchMenu_v1_0*) Data;
+ serviceData->Menu = new cMenuConflictCheck();
+
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-lastconflictinfo-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+
+ Epgsearch_lastconflictinfo_v1_0* serviceData = (Epgsearch_lastconflictinfo_v1_0*) Data;
+ serviceData->nextConflict = cConflictCheckThread::m_cacheNextConflict;
+ serviceData->relevantConflicts = cConflictCheckThread::m_cacheRelevantConflicts;
+ serviceData->totalConflicts = cConflictCheckThread::m_cacheTotalConflicts;
+
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-searchresults-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+ cSearchExt* SearchExt = new cSearchExt;
+
+ Epgsearch_searchresults_v1_0* searchData = (Epgsearch_searchresults_v1_0*) Data;
+ searchData->pResultList = NULL;
+ strn0cpy(SearchExt->search, searchData->query, sizeof(SearchExt->search));
+ if (searchData->channelNr > 0) {
+ LOCK_CHANNELS_READ;
+ SearchExt->useChannel = true;
+ SearchExt->channelMin = Channels->GetByNumber(searchData->channelNr);
+ SearchExt->channelMax = Channels->GetByNumber(searchData->channelNr);
+ }
+ SearchExt->mode = searchData->mode;
+ SearchExt->useTitle = searchData->useTitle;
+ SearchExt->useSubtitle = searchData->useSubTitle;
+ SearchExt->useDescription = searchData->useDescription;
+
+ cSearchResults* results = SearchExt->Run();
+ // transfer to result list
+ if (results) {
+ results->SortBy(CompareEventTime);
+ searchData->pResultList = new cList<Epgsearch_searchresults_v1_0::cServiceSearchResult>;
+ cSearchResult *result = results->First();
+ while (result) {
+ searchData->pResultList->Add(new Epgsearch_searchresults_v1_0::cServiceSearchResult(result->event));
+ result = results->Next(result);
+ }
+ }
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-switchtimer-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+ else {
+ Epgsearch_switchtimer_v1_0* serviceData = (Epgsearch_switchtimer_v1_0*) Data;
+ if (!serviceData->event)
+ return false;
+ switch (serviceData->mode) {
case 0: {// query existence
- cSwitchTimer *lTimer = SwitchTimers.InSwitchList(serviceData->event);
- if (lTimer) {
- serviceData->switchMinsBefore = lTimer->switchMinsBefore;
- serviceData->announceOnly = lTimer->mode;
- } // if
- serviceData->success=lTimer!=NULL;
- break;
+ cSwitchTimer *lTimer = SwitchTimers.InSwitchList(serviceData->event);
+ if (lTimer) {
+ serviceData->switchMinsBefore = lTimer->switchMinsBefore;
+ serviceData->announceOnly = lTimer->mode;
+ } // if
+ serviceData->success = lTimer != NULL;
+ break;
} // 0
case 1: { // add/modify
- cSwitchTimer *lTimer = SwitchTimers.InSwitchList(serviceData->event);
- if (lTimer) {
- lTimer->switchMinsBefore = serviceData->switchMinsBefore;
- lTimer->mode = serviceData->announceOnly;
- } else {
- cMutexLock SwitchTimersLock(&SwitchTimers);
- SwitchTimers.Add(new cSwitchTimer(serviceData->event,serviceData->switchMinsBefore,serviceData->announceOnly));
- SwitchTimers.Save();
- cSwitchTimerThread::Init();
- } // if
- serviceData->success=true;
- break;
+ cSwitchTimer *lTimer = SwitchTimers.InSwitchList(serviceData->event);
+ if (lTimer) {
+ lTimer->switchMinsBefore = serviceData->switchMinsBefore;
+ lTimer->mode = serviceData->announceOnly;
+ } else {
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ SwitchTimers.Add(new cSwitchTimer(serviceData->event, serviceData->switchMinsBefore, serviceData->announceOnly));
+ SwitchTimers.Save();
+ cSwitchTimerThread::Init();
+ } // if
+ serviceData->success = true;
+ break;
} // 1
case 2: {// delete
- cSwitchTimer *lTimer = SwitchTimers.InSwitchList(serviceData->event);
- serviceData->success=lTimer!=NULL;
- if (lTimer) {
- cMutexLock SwitchTimersLock(&SwitchTimers);
- SwitchTimers.Del(lTimer);
- SwitchTimers.Save();
- } // if
- break;
+ cSwitchTimer *lTimer = SwitchTimers.InSwitchList(serviceData->event);
+ serviceData->success = lTimer != NULL;
+ if (lTimer) {
+ cMutexLock SwitchTimersLock(&SwitchTimers);
+ SwitchTimers.Del(lTimer);
+ SwitchTimers.Save();
+ } // if
+ break;
} // 2
default:
- serviceData->success=false;
- break;
- } // switch
- } // if
- return true;
- } // if
- if (strcmp(Id, "Epgsearch-quicksearch-v1.0") == 0) {
- if (Data == NULL)
- return true;
-
- EpgSearchMenu_v1_0* serviceData = (EpgSearchMenu_v1_0*) Data;
- serviceData->Menu = new cMenuQuickSearch(new cSearchExt);
-
- return true;
- }
- if (strcmp(Id, "Epgsearch-services-v1.0") == 0) {
- if (Data == NULL)
- return true;
- Epgsearch_services_v1_0* serviceData = (Epgsearch_services_v1_0*) Data;
- std::auto_ptr<cEpgsearchServiceHandler> autoHandler(new cEpgsearchServiceHandler);
- serviceData->handler = autoHandler;
- return true;
- }
- if (strcmp(Id, "Epgsearch-services-v1.1") == 0) {
- if (Data == NULL)
- return true;
- Epgsearch_services_v1_1* serviceData = (Epgsearch_services_v1_1*) Data;
- std::auto_ptr<cEpgsearchServiceHandler> autoHandler(new cEpgsearchServiceHandler);
- serviceData->handler = autoHandler;
- return true;
- }
- return false;
+ serviceData->success = false;
+ break;
+ } // switch
+ } // if
+ return true;
+ } // if
+ if (strcmp(Id, "Epgsearch-quicksearch-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+
+ EpgSearchMenu_v1_0* serviceData = (EpgSearchMenu_v1_0*) Data;
+ serviceData->Menu = new cMenuQuickSearch(new cSearchExt);
+
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-services-v1.0") == 0) {
+ if (Data == NULL)
+ return true;
+ Epgsearch_services_v1_0* serviceData = (Epgsearch_services_v1_0*) Data;
+ std::auto_ptr<cEpgsearchServiceHandler> autoHandler(new cEpgsearchServiceHandler);
+ serviceData->handler = autoHandler;
+ return true;
+ }
+ if (strcmp(Id, "Epgsearch-services-v1.1") == 0) {
+ if (Data == NULL)
+ return true;
+ Epgsearch_services_v1_1* serviceData = (Epgsearch_services_v1_1*) Data;
+ std::auto_ptr<cEpgsearchServiceHandler> autoHandler(new cEpgsearchServiceHandler);
+ serviceData->handler = autoHandler;
+ return true;
+ }
+ return false;
}
bool cPluginEpgsearch::Initialize(void)
{
- return true;
+ return true;
}
bool cPluginEpgsearch::Start(void)
{
- if (!ConfigDir)
- ConfigDir = strdup(cPlugin::ConfigDirectory("epgsearch"));
+ if (!ConfigDir)
+ ConfigDir = strdup(cPlugin::ConfigDirectory("epgsearch"));
- cPlugconfdirVar::dir = cPlugin::ConfigDirectory();
+ cPlugconfdirVar::dir = cPlugin::ConfigDirectory();
- if (cLogFile::LogFileName)
- LogFile.Open(cLogFile::LogFileName, Version());
- else
- LogFile.Open(AddDirectory(CONFIGDIR, "epgsearch.log"), Version());
+ if (cLogFile::LogFileName)
+ LogFile.Open(cLogFile::LogFileName, Version());
+ else
+ LogFile.Open(AddDirectory(CONFIGDIR, "epgsearch.log"), Version());
- gl_recStatusMonitor = new cRecStatusMonitor;
- gl_timerStatusMonitor = new cTimerStatusMonitor;
+ gl_recStatusMonitor = new cRecStatusMonitor;
+ gl_timerStatusMonitor = new cTimerStatusMonitor;
- SearchExtCats.Load(AddDirectory(CONFIGDIR, "epgsearchcats.conf"), true);
+ SearchExtCats.Load(AddDirectory(CONFIGDIR, "epgsearchcats.conf"), true);
- LoadMenuTemplates();
- LoadConfD();
- LoadUserVars();
+ LoadMenuTemplates();
+ LoadConfD();
+ LoadUserVars();
- ChannelGroups.Load(AddDirectory(CONFIGDIR, "epgsearchchangrps.conf"), true);
- Blacklists.Load(AddDirectory(CONFIGDIR, "epgsearchblacklists.conf"));
- SearchExts.Load(AddDirectory(CONFIGDIR, "epgsearch.conf"));
- SearchTemplates.Load(AddDirectory(CONFIGDIR, "epgsearchtemplates.conf"));
- RecsDone.Load(AddDirectory(CONFIGDIR, "epgsearchdone.data"));
- SwitchTimers.Load(AddDirectory(CONFIGDIR, "epgsearchswitchtimers.conf"));
- NoAnnounces.Load(AddDirectory(CONFIGDIR, "noannounce.conf"));
- DefTimerCheckModes.Load(AddDirectory(CONFIGDIR, "deftimerchkmodes.conf"));
- TimersDone.Load(AddDirectory(CONFIGDIR, "timersdone.conf"));
- PendingNotifications.Load(AddDirectory(CONFIGDIR, "pendingnotifications.conf"));
+ ChannelGroups.Load(AddDirectory(CONFIGDIR, "epgsearchchangrps.conf"), true);
+ Blacklists.Load(AddDirectory(CONFIGDIR, "epgsearchblacklists.conf"));
+ SearchExts.Load(AddDirectory(CONFIGDIR, "epgsearch.conf"));
+ SearchTemplates.Load(AddDirectory(CONFIGDIR, "epgsearchtemplates.conf"));
+ RecsDone.Load(AddDirectory(CONFIGDIR, "epgsearchdone.data"));
+ SwitchTimers.Load(AddDirectory(CONFIGDIR, "epgsearchswitchtimers.conf"));
+ NoAnnounces.Load(AddDirectory(CONFIGDIR, "noannounce.conf"));
+ DefTimerCheckModes.Load(AddDirectory(CONFIGDIR, "deftimerchkmodes.conf"));
+ TimersDone.Load(AddDirectory(CONFIGDIR, "timersdone.conf"));
+ PendingNotifications.Load(AddDirectory(CONFIGDIR, "pendingnotifications.conf"));
- cSearchTimerThread::Init(this);
- cSwitchTimerThread::Init();
- cConflictCheckThread::Init(this);
+ cSearchTimerThread::Init(this);
+ cSwitchTimerThread::Init();
+ cConflictCheckThread::Init(this);
- CheckUTF8();
+ CheckUTF8();
- return true;
+ return true;
}
void cPluginEpgsearch::CheckUTF8()
{
- std::string CodeSet = GetCodeset();
- isUTF8 = EqualsNoCase(CodeSet, "UTF-8");
+ std::string CodeSet = GetCodeset();
+ isUTF8 = EqualsNoCase(CodeSet, "UTF-8");
}
void cPluginEpgsearch::Stop(void)
{
- cSearchTimerThread::Exit();
- cSwitchTimerThread::Exit();
+ cSearchTimerThread::Exit();
+ cSwitchTimerThread::Exit();
}
void cPluginEpgsearch::MainThreadHook(void)
{
- if (!VDR_readyafterStartup)
- {
- // signal VDR is ready, otherwise the search timer thread could use SVDRP before it works
- LogFile.Log(2, "VDR ready");
- VDR_readyafterStartup = true;
+ if (!VDR_readyafterStartup) {
+ // signal VDR is ready, otherwise the search timer thread could use SVDRP before it works
+ LogFile.Log(2, "VDR ready");
+ VDR_readyafterStartup = true;
}
}
cOsdObject *cPluginEpgsearch::DoInitialSearch(char* rcFilename)
{
- cRCFile rcFile;
- if (rcFile.Load(rcFilename))
- {
- cSearchExt* SearchExt = new cSearchExt;
- strn0cpy(SearchExt->search,rcFile.Search, sizeof(SearchExt->search));
- if (rcFile.ChannelNr != -1)
- {
- LOCK_CHANNELS_READ;
- SearchExt->useChannel = true;
- SearchExt->channelMin = Channels->GetByNumber(rcFile.ChannelNr);
- SearchExt->channelMax = Channels->GetByNumber(rcFile.ChannelNr);
- }
- SearchExt->mode = rcFile.SearchMode;
- SearchExt->useTitle = rcFile.UseTitle;
- SearchExt->useSubtitle = rcFile.UseSubtitle;
- SearchExt->useDescription = rcFile.UseDescr;
-
- remove(rcFilename);
- return new cMenuSearchResultsForSearch(SearchExt, cTemplFile::GetTemplateByName("MenuSearchResults"));
- }
- else
- LogFile.eSysLog("could not load '%s'", rcFilename);
-
- return NULL;
+ cRCFile rcFile;
+ if (rcFile.Load(rcFilename)) {
+ cSearchExt* SearchExt = new cSearchExt;
+ strn0cpy(SearchExt->search, rcFile.Search, sizeof(SearchExt->search));
+ if (rcFile.ChannelNr != -1) {
+ LOCK_CHANNELS_READ;
+ SearchExt->useChannel = true;
+ SearchExt->channelMin = Channels->GetByNumber(rcFile.ChannelNr);
+ SearchExt->channelMax = Channels->GetByNumber(rcFile.ChannelNr);
+ }
+ SearchExt->mode = rcFile.SearchMode;
+ SearchExt->useTitle = rcFile.UseTitle;
+ SearchExt->useSubtitle = rcFile.UseSubtitle;
+ SearchExt->useDescription = rcFile.UseDescr;
+
+ remove(rcFilename);
+ return new cMenuSearchResultsForSearch(SearchExt, cTemplFile::GetTemplateByName("MenuSearchResults"));
+ } else
+ LogFile.eSysLog("could not load '%s'", rcFilename);
+
+ return NULL;
}
cOsdObject *cPluginEpgsearch::MainMenuAction(void)
{
- if (reloadMenuConf)
- LoadMenuTemplates();
-
- if (showConflicts)
- {
- showConflicts = false;
- return new cMenuConflictCheck();
- }
-
- if (showAnnounces)
- {
- showAnnounces = false;
- return new cMenuAnnounceList(cSearchTimerThread::announceList);
- }
-
- // Perform the action when selected from the main VDR menu.
- cOsdObject* pMenu = NULL;
- char* rcFilename = strdup(AddDirectory(CONFIGDIR, ".epgsearchrc"));
- if (access(rcFilename, F_OK) == 0)
- pMenu = DoInitialSearch(rcFilename);
- else
- pMenu = new cMenuSearchMain();
-
- free(rcFilename);
- return pMenu;
+ if (reloadMenuConf)
+ LoadMenuTemplates();
+
+ if (showConflicts) {
+ showConflicts = false;
+ return new cMenuConflictCheck();
+ }
+
+ if (showAnnounces) {
+ showAnnounces = false;
+ return new cMenuAnnounceList(cSearchTimerThread::announceList);
+ }
+
+ // Perform the action when selected from the main VDR menu.
+ cOsdObject* pMenu = NULL;
+ char* rcFilename = strdup(AddDirectory(CONFIGDIR, ".epgsearchrc"));
+ if (access(rcFilename, F_OK) == 0)
+ pMenu = DoInitialSearch(rcFilename);
+ else
+ pMenu = new cMenuSearchMain();
+
+ free(rcFilename);
+ return pMenu;
}
void cPluginEpgsearch::LoadMenuTemplates()
{
- char* templateFilename = strdup(AddDirectory(CONFIGDIR, "epgsearchmenu.conf"));
- if (access(templateFilename, F_OK) == 0)
- {
- cTemplFile templFile;
- if (!templFile.Load(templateFilename))
- {
- templFile.Reset();
- LogFile.eSysLog("could not load '%s'", templateFilename);
- }
- }
- cTemplFile::PrepareDefaultTemplates();
- free(templateFilename);
+ char* templateFilename = strdup(AddDirectory(CONFIGDIR, "epgsearchmenu.conf"));
+ if (access(templateFilename, F_OK) == 0) {
+ cTemplFile templFile;
+ if (!templFile.Load(templateFilename)) {
+ templFile.Reset();
+ LogFile.eSysLog("could not load '%s'", templateFilename);
+ }
+ }
+ cTemplFile::PrepareDefaultTemplates();
+ free(templateFilename);
}
void cPluginEpgsearch::LoadUserVars()
{
- char* userVarFilename = strdup(AddDirectory(CONFIGDIR, "epgsearchuservars.conf"));
- if (access(userVarFilename, F_OK) == 0)
- {
- LogFile.Log(1, "loading %s", userVarFilename);
- cUserVarFile userVarFile;
- if (!userVarFile.Load(userVarFilename))
- LogFile.eSysLog("could not load '%s'", userVarFilename);
- else
- LogFile.Log(2,"loaded uservars from %s", userVarFilename);
- }
- free(userVarFilename);
- UserVars.InitInternalVars();
- UserVars.InitExtEPGVars();
+ char* userVarFilename = strdup(AddDirectory(CONFIGDIR, "epgsearchuservars.conf"));
+ if (access(userVarFilename, F_OK) == 0) {
+ LogFile.Log(1, "loading %s", userVarFilename);
+ cUserVarFile userVarFile;
+ if (!userVarFile.Load(userVarFilename))
+ LogFile.eSysLog("could not load '%s'", userVarFilename);
+ else
+ LogFile.Log(2, "loaded uservars from %s", userVarFilename);
+ }
+ free(userVarFilename);
+ UserVars.InitInternalVars();
+ UserVars.InitExtEPGVars();
}
void cPluginEpgsearch::LoadConfD()
{
- cConfDLoader D;
- D.Load();
+ cConfDLoader D;
+ D.Load();
}
cMenuSetupPage *cPluginEpgsearch::SetupMenu(void)
{
- // Return a setup menu in case the plugin supports one.
- return new cMenuEPGSearchSetup;
+ // Return a setup menu in case the plugin supports one.
+ return new cMenuEPGSearchSetup;
}
bool cPluginEpgsearch::SetupParse(const char *Name, const char *Value)
{
- if (!strcasecmp(Name, "IsOrgSchedule")) return (EPGSearchConfig.ReplaceOrgSchedule == false);
-
- if (!strcasecmp(Name, "HideMenu")) EPGSearchConfig.hidemenu = atoi(Value);
- if (!strcasecmp(Name, "MainMenuEntry")) strcpy(EPGSearchConfig.mainmenuentry, Value);
- if (!strcasecmp(Name, "ReplaceOrgSchedule")) EPGSearchConfig.ReplaceOrgSchedule = atoi(Value);
- if (!strcasecmp(Name, "StartMenu")) EPGSearchConfig.StartMenu = atoi(Value);
- if (!strcasecmp(Name, "RedKeyMode")) EPGSearchConfig.redkeymode = atoi(Value);
- if (!strcasecmp(Name, "BlueKeyMode")) EPGSearchConfig.bluekeymode = atoi(Value);
- if (!strcasecmp(Name, "ShowProgress")) EPGSearchConfig.showProgress = atoi(Value);
- if (!strcasecmp(Name, "ShowChannelNr")) EPGSearchConfig.showChannelNr = atoi(Value);
- if (!strcasecmp(Name, "UseOkForSwitch")) EPGSearchConfig.useOkForSwitch = atoi(Value);
- if (!strcasecmp(Name, "MaxChannelMenuNow")) EPGSearchConfig.maxChannelMenuNow = atoi(Value);
-
- if (!strcasecmp(Name, "ShowRadioChannels")) EPGSearchConfig.showRadioChannels = atoi(Value);
- if (!strcasecmp(Name, "OnePressTimerCreation")) EPGSearchConfig.onePressTimerCreation = atoi(Value);
- if (!strcasecmp(Name, "ShowFavoritesMenu")) EPGSearchConfig.showFavoritesMenu = atoi(Value);
- if (!strcasecmp(Name, "FavoritesMenuTimespan")) EPGSearchConfig.FavoritesMenuTimespan = atoi(Value);
-
- if (!strcasecmp(Name, "UserMode1Description")) EPGSearchConfig.ShowModes[showUserMode1].SetDescription(Value);
- if (!strcasecmp(Name, "UserMode1Time")) EPGSearchConfig.ShowModes[showUserMode1].SetTime(atoi(Value));
- if (!strcasecmp(Name, "UserMode1UseIt")) EPGSearchConfig.ShowModes[showUserMode1].SetUsage(atoi(Value));
-
- if (!strcasecmp(Name, "UserMode2Description")) EPGSearchConfig.ShowModes[showUserMode2].SetDescription(Value);
- if (!strcasecmp(Name, "UserMode2Time")) EPGSearchConfig.ShowModes[showUserMode2].SetTime(atoi(Value));
- if (!strcasecmp(Name, "UserMode2UseIt")) EPGSearchConfig.ShowModes[showUserMode2].SetUsage(atoi(Value));
-
- if (!strcasecmp(Name, "UserMode3Description")) EPGSearchConfig.ShowModes[showUserMode3].SetDescription(Value);
- if (!strcasecmp(Name, "UserMode3Time")) EPGSearchConfig.ShowModes[showUserMode3].SetTime(atoi(Value));
- if (!strcasecmp(Name, "UserMode3UseIt")) EPGSearchConfig.ShowModes[showUserMode3].SetUsage(atoi(Value));
-
- if (!strcasecmp(Name, "UserMode4Description")) EPGSearchConfig.ShowModes[showUserMode4].SetDescription(Value);
- if (!strcasecmp(Name, "UserMode4Time")) EPGSearchConfig.ShowModes[showUserMode4].SetTime(atoi(Value));
- if (!strcasecmp(Name, "UserMode4UseIt")) EPGSearchConfig.ShowModes[showUserMode4].SetUsage(atoi(Value));
-
- if (!strcasecmp(Name, "UseSearchTimers")) EPGSearchConfig.useSearchTimers = atoi(Value);
- if (!strcasecmp(Name, "UpdateIntervall")) EPGSearchConfig.UpdateIntervall = atoi(Value);
- if (!strcasecmp(Name, "SVDRPPort")) EPGSearchConfig.SVDRPPort = atoi(Value);
- if (!strcasecmp(Name, "CheckTimerConflicts")) EPGSearchConfig.checkTimerConflictsAfterUpdate = atoi(Value);
- if (!strcasecmp(Name, "CheckTimerConflictsPriority")) EPGSearchConfig.checkMinPriority = atoi(Value);
- if (!strcasecmp(Name, "CheckTimerConflictsDays")) EPGSearchConfig.checkMaxDays = atoi(Value);
- if (!strcasecmp(Name, "RemoteConflictCheck")) EPGSearchConfig.RemoteConflictCheck = atoi(Value);
- if (!strcasecmp(Name, "CheckConflictsIntervall")) EPGSearchConfig.conflictCheckIntervall = atoi(Value);
- if (!strcasecmp(Name, "CheckConflictsWithinLimit")) EPGSearchConfig.conflictCheckWithinLimit = atoi(Value);
- if (!strcasecmp(Name, "CheckConflictsIntervall2")) EPGSearchConfig.conflictCheckIntervall2 = atoi(Value);
- if (!strcasecmp(Name, "CheckConflictsMinDuration")) EPGSearchConfig.checkMinDuration = atoi(Value);
- if (!strcasecmp(Name, "CheckConflictsAfterTimerProg")) EPGSearchConfig.checkTimerConflAfterTimerProg = atoi(Value);
- if (!strcasecmp(Name, "CheckConflictsOnRecording")) EPGSearchConfig.checkTimerConflOnRecording = atoi(Value);
- if (!strcasecmp(Name, "ConflCheckCmd")) strcpy(EPGSearchConfig.conflCheckCmd, Value);
-
- if (!strcasecmp(Name, "NoConflMsgWhileReplay")) EPGSearchConfig.noConflMsgWhileReplay = atoi(Value);
- if (!strcasecmp(Name, "NoAnnounceWhileReplay")) EPGSearchConfig.noAnnounceWhileReplay = atoi(Value);
- if (!strcasecmp(Name, "TimerProgRepeat")) EPGSearchConfig.TimerProgRepeat = atoi(Value);
- if (!strcasecmp(Name, "CheckEPGHours")) EPGSearchConfig.checkEPGHours = atoi(Value);
- if (!strcasecmp(Name, "CheckEPGWarnByOSD")) EPGSearchConfig.checkEPGWarnByOSD = atoi(Value);
- if (!strcasecmp(Name, "CheckEPGWarnByMail")) EPGSearchConfig.checkEPGWarnByMail = atoi(Value);
- if (!strcasecmp(Name, "CheckEPGChannelgroup")) EPGSearchConfig.checkEPGchannelGroupNr = atoi(Value);
-
- if (!strcasecmp(Name, "TimeIntervallFRFF")) EPGSearchConfig.timeShiftValue = atoi(Value);
- if (!strcasecmp(Name, "ToggleGreenYellow")) EPGSearchConfig.toggleGreenYellow = atoi(Value);
-
- if (!strcasecmp(Name, "DefPriority")) EPGSearchConfig.DefPriority = atoi(Value);
- if (!strcasecmp(Name, "DefLifetime")) EPGSearchConfig.DefLifetime = atoi(Value);
- if (!strcasecmp(Name, "DefMarginStart")) EPGSearchConfig.DefMarginStart = atoi(Value);
- if (!strcasecmp(Name, "DefMarginStop")) EPGSearchConfig.DefMarginStop = atoi(Value);
-
- if (!strcasecmp(Name, "IgnorePayTV")) EPGSearchConfig.ignorePayTV = atoi(Value);
-
- if (!strcasecmp(Name, "DefRecordingDir")) strcpy(EPGSearchConfig.defrecdir, Value);
- if (!strcasecmp(Name, "UseVDRTimerEditMenu")) EPGSearchConfig.useVDRTimerEditMenu = atoi(Value);
-
- if (!strcasecmp(Name, "ShowChannelGroups")) EPGSearchConfig.showChannelGroups = atoi(Value);
- if (!strcasecmp(Name, "ShowDaySeparators")) EPGSearchConfig.showDaySeparators = atoi(Value);
-
- if (!strcasecmp(Name, "ShowEmptyChannels")) EPGSearchConfig.showEmptyChannels = atoi(Value);
-
- if (!strcasecmp(Name, "DefSearchTemplateID")) EPGSearchConfig.DefSearchTemplateID = atoi(Value);
-
- if (!strcasecmp(Name, "AddSubtitleToTimerMode")) EPGSearchConfig.addSubtitleToTimer = (addSubtitleToTimerMode) atoi(Value);
-
- if (!strcasecmp(Name, "MailViaScript")) EPGSearchConfig.mailViaScript = atoi(Value);
- if (!strcasecmp(Name, "MailNotificationSearchtimers")) EPGSearchConfig.sendMailOnSearchtimers = atoi(Value);
- if (!strcasecmp(Name, "MailNotificationSearchtimersHours")) EPGSearchConfig.sendMailOnSearchtimerHours = atoi(Value);
- if (!strcasecmp(Name, "MailNotificationSearchtimersLastAt")) EPGSearchConfig.lastMailOnSearchtimerAt = atol(Value);
- if (!strcasecmp(Name, "MailNotificationConflicts")) EPGSearchConfig.sendMailOnConflicts = atoi(Value);
- if (!strcasecmp(Name, "MailAddress")) strcpy(EPGSearchConfig.MailAddress, Value);
- if (!strcasecmp(Name, "MailAddressTo")) strcpy(EPGSearchConfig.MailAddressTo, Value);
-
- if (isempty(EPGSearchConfig.MailAddressTo))
- strcpy(EPGSearchConfig.MailAddressTo, EPGSearchConfig.MailAddress);
-
- if (!strcasecmp(Name, "MailServer")) strcpy(EPGSearchConfig.MailServer, Value);
- if (!strcasecmp(Name, "MailUseAuth")) EPGSearchConfig.MailUseAuth = atoi(Value);
- if (!strcasecmp(Name, "MailAuthUser")) strcpy(EPGSearchConfig.MailAuthUser, Value);
- if (!strcasecmp(Name, "MailAuthPass")) strcpy(EPGSearchConfig.MailAuthPass, Value);
-
- if (!strcasecmp(Name, "LastMailConflicts")) strcpy(EPGSearchConfig.LastMailConflicts, Value);
-
-
- return true;
+ if (!strcasecmp(Name, "IsOrgSchedule")) return (EPGSearchConfig.ReplaceOrgSchedule == false);
+
+ if (!strcasecmp(Name, "HideMenu")) EPGSearchConfig.hidemenu = atoi(Value);
+ if (!strcasecmp(Name, "MainMenuEntry")) strcpy(EPGSearchConfig.mainmenuentry, Value);
+ if (!strcasecmp(Name, "ReplaceOrgSchedule")) EPGSearchConfig.ReplaceOrgSchedule = atoi(Value);
+ if (!strcasecmp(Name, "StartMenu")) EPGSearchConfig.StartMenu = atoi(Value);
+ if (!strcasecmp(Name, "RedKeyMode")) EPGSearchConfig.redkeymode = atoi(Value);
+ if (!strcasecmp(Name, "BlueKeyMode")) EPGSearchConfig.bluekeymode = atoi(Value);
+ if (!strcasecmp(Name, "ShowProgress")) EPGSearchConfig.showProgress = atoi(Value);
+ if (!strcasecmp(Name, "ShowChannelNr")) EPGSearchConfig.showChannelNr = atoi(Value);
+ if (!strcasecmp(Name, "UseOkForSwitch")) EPGSearchConfig.useOkForSwitch = atoi(Value);
+ if (!strcasecmp(Name, "MaxChannelMenuNow")) EPGSearchConfig.maxChannelMenuNow = atoi(Value);
+
+ if (!strcasecmp(Name, "ShowRadioChannels")) EPGSearchConfig.showRadioChannels = atoi(Value);
+ if (!strcasecmp(Name, "OnePressTimerCreation")) EPGSearchConfig.onePressTimerCreation = atoi(Value);
+ if (!strcasecmp(Name, "ShowFavoritesMenu")) EPGSearchConfig.showFavoritesMenu = atoi(Value);
+ if (!strcasecmp(Name, "FavoritesMenuTimespan")) EPGSearchConfig.FavoritesMenuTimespan = atoi(Value);
+
+ if (!strcasecmp(Name, "UserMode1Description")) EPGSearchConfig.ShowModes[showUserMode1].SetDescription(Value);
+ if (!strcasecmp(Name, "UserMode1Time")) EPGSearchConfig.ShowModes[showUserMode1].SetTime(atoi(Value));
+ if (!strcasecmp(Name, "UserMode1UseIt")) EPGSearchConfig.ShowModes[showUserMode1].SetUsage(atoi(Value));
+
+ if (!strcasecmp(Name, "UserMode2Description")) EPGSearchConfig.ShowModes[showUserMode2].SetDescription(Value);
+ if (!strcasecmp(Name, "UserMode2Time")) EPGSearchConfig.ShowModes[showUserMode2].SetTime(atoi(Value));
+ if (!strcasecmp(Name, "UserMode2UseIt")) EPGSearchConfig.ShowModes[showUserMode2].SetUsage(atoi(Value));
+
+ if (!strcasecmp(Name, "UserMode3Description")) EPGSearchConfig.ShowModes[showUserMode3].SetDescription(Value);
+ if (!strcasecmp(Name, "UserMode3Time")) EPGSearchConfig.ShowModes[showUserMode3].SetTime(atoi(Value));
+ if (!strcasecmp(Name, "UserMode3UseIt")) EPGSearchConfig.ShowModes[showUserMode3].SetUsage(atoi(Value));
+
+ if (!strcasecmp(Name, "UserMode4Description")) EPGSearchConfig.ShowModes[showUserMode4].SetDescription(Value);
+ if (!strcasecmp(Name, "UserMode4Time")) EPGSearchConfig.ShowModes[showUserMode4].SetTime(atoi(Value));
+ if (!strcasecmp(Name, "UserMode4UseIt")) EPGSearchConfig.ShowModes[showUserMode4].SetUsage(atoi(Value));
+
+ if (!strcasecmp(Name, "UseSearchTimers")) EPGSearchConfig.useSearchTimers = atoi(Value);
+ if (!strcasecmp(Name, "UpdateIntervall")) EPGSearchConfig.UpdateIntervall = atoi(Value);
+ if (!strcasecmp(Name, "SVDRPPort")) EPGSearchConfig.SVDRPPort = atoi(Value);
+ if (!strcasecmp(Name, "CheckTimerConflicts")) EPGSearchConfig.checkTimerConflictsAfterUpdate = atoi(Value);
+ if (!strcasecmp(Name, "CheckTimerConflictsPriority")) EPGSearchConfig.checkMinPriority = atoi(Value);
+ if (!strcasecmp(Name, "CheckTimerConflictsDays")) EPGSearchConfig.checkMaxDays = atoi(Value);
+ if (!strcasecmp(Name, "RemoteConflictCheck")) EPGSearchConfig.RemoteConflictCheck = atoi(Value);
+ if (!strcasecmp(Name, "CheckConflictsIntervall")) EPGSearchConfig.conflictCheckIntervall = atoi(Value);
+ if (!strcasecmp(Name, "CheckConflictsWithinLimit")) EPGSearchConfig.conflictCheckWithinLimit = atoi(Value);
+ if (!strcasecmp(Name, "CheckConflictsIntervall2")) EPGSearchConfig.conflictCheckIntervall2 = atoi(Value);
+ if (!strcasecmp(Name, "CheckConflictsMinDuration")) EPGSearchConfig.checkMinDuration = atoi(Value);
+ if (!strcasecmp(Name, "CheckConflictsAfterTimerProg")) EPGSearchConfig.checkTimerConflAfterTimerProg = atoi(Value);
+ if (!strcasecmp(Name, "CheckConflictsOnRecording")) EPGSearchConfig.checkTimerConflOnRecording = atoi(Value);
+ if (!strcasecmp(Name, "ConflCheckCmd")) strcpy(EPGSearchConfig.conflCheckCmd, Value);
+
+ if (!strcasecmp(Name, "NoConflMsgWhileReplay")) EPGSearchConfig.noConflMsgWhileReplay = atoi(Value);
+ if (!strcasecmp(Name, "NoAnnounceWhileReplay")) EPGSearchConfig.noAnnounceWhileReplay = atoi(Value);
+ if (!strcasecmp(Name, "TimerProgRepeat")) EPGSearchConfig.TimerProgRepeat = atoi(Value);
+ if (!strcasecmp(Name, "CheckEPGHours")) EPGSearchConfig.checkEPGHours = atoi(Value);
+ if (!strcasecmp(Name, "CheckEPGWarnByOSD")) EPGSearchConfig.checkEPGWarnByOSD = atoi(Value);
+ if (!strcasecmp(Name, "CheckEPGWarnByMail")) EPGSearchConfig.checkEPGWarnByMail = atoi(Value);
+ if (!strcasecmp(Name, "CheckEPGChannelgroup")) EPGSearchConfig.checkEPGchannelGroupNr = atoi(Value);
+
+ if (!strcasecmp(Name, "TimeIntervallFRFF")) EPGSearchConfig.timeShiftValue = atoi(Value);
+ if (!strcasecmp(Name, "ToggleGreenYellow")) EPGSearchConfig.toggleGreenYellow = atoi(Value);
+
+ if (!strcasecmp(Name, "DefPriority")) EPGSearchConfig.DefPriority = atoi(Value);
+ if (!strcasecmp(Name, "DefLifetime")) EPGSearchConfig.DefLifetime = atoi(Value);
+ if (!strcasecmp(Name, "DefMarginStart")) EPGSearchConfig.DefMarginStart = atoi(Value);
+ if (!strcasecmp(Name, "DefMarginStop")) EPGSearchConfig.DefMarginStop = atoi(Value);
+
+ if (!strcasecmp(Name, "IgnorePayTV")) EPGSearchConfig.ignorePayTV = atoi(Value);
+
+ if (!strcasecmp(Name, "DefRecordingDir")) strcpy(EPGSearchConfig.defrecdir, Value);
+ if (!strcasecmp(Name, "UseVDRTimerEditMenu")) EPGSearchConfig.useVDRTimerEditMenu = atoi(Value);
+
+ if (!strcasecmp(Name, "ShowChannelGroups")) EPGSearchConfig.showChannelGroups = atoi(Value);
+ if (!strcasecmp(Name, "ShowDaySeparators")) EPGSearchConfig.showDaySeparators = atoi(Value);
+
+ if (!strcasecmp(Name, "ShowEmptyChannels")) EPGSearchConfig.showEmptyChannels = atoi(Value);
+
+ if (!strcasecmp(Name, "DefSearchTemplateID")) EPGSearchConfig.DefSearchTemplateID = atoi(Value);
+
+ if (!strcasecmp(Name, "AddSubtitleToTimerMode")) EPGSearchConfig.addSubtitleToTimer = (addSubtitleToTimerMode) atoi(Value);
+
+ if (!strcasecmp(Name, "MailViaScript")) EPGSearchConfig.mailViaScript = atoi(Value);
+ if (!strcasecmp(Name, "MailNotificationSearchtimers")) EPGSearchConfig.sendMailOnSearchtimers = atoi(Value);
+ if (!strcasecmp(Name, "MailNotificationSearchtimersHours")) EPGSearchConfig.sendMailOnSearchtimerHours = atoi(Value);
+ if (!strcasecmp(Name, "MailNotificationSearchtimersLastAt")) EPGSearchConfig.lastMailOnSearchtimerAt = atol(Value);
+ if (!strcasecmp(Name, "MailNotificationConflicts")) EPGSearchConfig.sendMailOnConflicts = atoi(Value);
+ if (!strcasecmp(Name, "MailAddress")) strcpy(EPGSearchConfig.MailAddress, Value);
+ if (!strcasecmp(Name, "MailAddressTo")) strcpy(EPGSearchConfig.MailAddressTo, Value);
+
+ if (isempty(EPGSearchConfig.MailAddressTo))
+ strcpy(EPGSearchConfig.MailAddressTo, EPGSearchConfig.MailAddress);
+
+ if (!strcasecmp(Name, "MailServer")) strcpy(EPGSearchConfig.MailServer, Value);
+ if (!strcasecmp(Name, "MailUseAuth")) EPGSearchConfig.MailUseAuth = atoi(Value);
+ if (!strcasecmp(Name, "MailAuthUser")) strcpy(EPGSearchConfig.MailAuthUser, Value);
+ if (!strcasecmp(Name, "MailAuthPass")) strcpy(EPGSearchConfig.MailAuthPass, Value);
+
+ if (!strcasecmp(Name, "LastMailConflicts")) strcpy(EPGSearchConfig.LastMailConflicts, Value);
+
+
+ return true;
}
cString cPluginEpgsearch::Active(void)
{
- return cSearchTimerThread::justRunning?tr("search timer update running"):NULL;
+ return cSearchTimerThread::justRunning ? tr("search timer update running") : NULL;
}
VDRPLUGINCREATOR(cPluginEpgsearch); // Don't touch this!
diff --git a/epgsearch.h b/epgsearch.h
index 211296b..6375ac5 100644
--- a/epgsearch.h
+++ b/epgsearch.h
@@ -26,7 +26,8 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include "epgsearchext.h"
-class cPluginEpgsearch : public cPlugin {
+class cPluginEpgsearch : public cPlugin
+{
public:
bool showConflicts;
bool showAnnounces;
diff --git a/epgsearchcats.c b/epgsearchcats.c
index fba8b5b..3d3a965 100644
--- a/epgsearchcats.c
+++ b/epgsearchcats.c
@@ -45,108 +45,103 @@ cSearchExtCat::~cSearchExtCat(void)
{
free(name);
free(menuname);
- for(int i=0; i<nvalues; i++)
- free(values[i]);
+ for (int i = 0; i < nvalues; i++)
+ free(values[i]);
free(values);
}
bool cSearchExtCat::Parse(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int parameter = 1;
- int valuelen;
+ char *line;
+ char *pos;
+ char *pos_next;
+ int parameter = 1;
+ int valuelen;
#define MAXVALUELEN (10 * MaxFileName)
- char value[MAXVALUELEN];
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != '|') {
- pos_next = strchr(pos, '|');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MAXVALUELEN)
- {
- LogFile.eSysLog("entry '%s' is too long. Will be truncated!", pos);
- valuelen = MAXVALUELEN;
- }
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1: id = atoi(value);
- break;
- case 2:
- {
- name = strdup(value);
- format=strchr(name,',');
- if (format)
- {
- *format=0;
- format++;
- char cset[]="%0123456789di";
- if (strspn(format,cset)!=strlen(format)) format=NULL;
- }
- break;
- }
- case 3: menuname = strdup(value);
- break;
- case 4:
- {
- char* szBuffer = strdup(value);
- char* pptr;
- char* pstrToken=strtok_r(szBuffer, ",", &pptr);
- while(pstrToken)
- {
- nvalues++;
- char **tmp = (char**) realloc(values, nvalues * sizeof(char*));
- if (tmp)
- {
- values=tmp;
- values[nvalues-1] = strdup(pstrToken);
+ char value[MAXVALUELEN];
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != '|') {
+ pos_next = strchr(pos, '|');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MAXVALUELEN) {
+ LogFile.eSysLog("entry '%s' is too long. Will be truncated!", pos);
+ valuelen = MAXVALUELEN;
+ }
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ switch (parameter) {
+ case 1:
+ id = atoi(value);
+ break;
+ case 2: {
+ name = strdup(value);
+ format = strchr(name, ',');
+ if (format) {
+ *format = 0;
+ format++;
+ char cset[] = "%0123456789di";
+ if (strspn(format, cset) != strlen(format)) format = NULL;
}
- pstrToken=strtok_r(NULL, ",", &pptr);
- }
- free(szBuffer);
- break;
- }
- case 5:
- searchmode = atoi(value);
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
+ break;
+ }
+ case 3:
+ menuname = strdup(value);
+ break;
+ case 4: {
+ char* szBuffer = strdup(value);
+ char* pptr;
+ char* pstrToken = strtok_r(szBuffer, ",", &pptr);
+ while (pstrToken) {
+ nvalues++;
+ char **tmp = (char**) realloc(values, nvalues * sizeof(char*));
+ if (tmp) {
+ values = tmp;
+ values[nvalues - 1] = strdup(pstrToken);
+ }
+ pstrToken = strtok_r(NULL, ",", &pptr);
+ }
+ free(szBuffer);
+ break;
+ }
+ case 5:
+ searchmode = atoi(value);
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
- free(line);
- return (parameter >= 3) ? true : false;
+ free(line);
+ return (parameter >= 3) ? true : false;
}
const char *cSearchExtCat::ToText(void)
{
char* buffer = NULL;
string sValues = "";
- for(int i=0; i<nvalues; i++)
- sValues += string(values[i]) + ((i<nvalues-1)?", ":"");
+ for (int i = 0; i < nvalues; i++)
+ sValues += string(values[i]) + ((i < nvalues - 1) ? ", " : "");
- if (format)
- {
+ if (format) {
msprintf(&buffer, "%d|%s,%s|%s|%s|%d",
- id, name, format, menuname, sValues.c_str(), searchmode);
+ id, name, format, menuname, sValues.c_str(), searchmode);
} else {
msprintf(&buffer, "%d|%s|%s|%s|%d",
- id, name, menuname, sValues.c_str(), searchmode);
+ id, name, menuname, sValues.c_str(), searchmode);
}
return buffer;
}
@@ -154,17 +149,16 @@ const char *cSearchExtCat::ToText(void)
// -- cSearchExtCats ----------------------------------------------------------------
int cSearchExtCats::GetIndexFromID(int id)
{
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- if (SearchExtCat->id == id)
- break;
- index++;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- }
- if (!SearchExtCat && index == 0)
- return -1;
- else
- return index;
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ if (SearchExtCat->id == id)
+ break;
+ index++;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ }
+ if (!SearchExtCat && index == 0)
+ return -1;
+ else
+ return index;
}
diff --git a/epgsearchcats.h b/epgsearchcats.h
index 7c32dae..c90a1c0 100644
--- a/epgsearchcats.h
+++ b/epgsearchcats.h
@@ -29,42 +29,44 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include <vdr/tools.h>
// --- cSearchExtCat --------------------------------------------------------
-class cSearchExtCat : public cListObject {
+class cSearchExtCat : public cListObject
+{
public:
int id;
char* name;
char* format;
char* menuname;
int searchmode; // text comarison:
- // 0 - substring,
- // 1 - substring-and,
- // 2 - substring or,
- // 3 - equal,
- // 4 - regular expression,
- // 5 - fuzzy (not available for categories)
- // numerical comparison:
- // 10 - less
- // 11 - less or equal
- // 12 - greater
- // 13 - greater or equal
- // 14 - equal
- // 15 - not equal
+ // 0 - substring,
+ // 1 - substring-and,
+ // 2 - substring or,
+ // 3 - equal,
+ // 4 - regular expression,
+ // 5 - fuzzy (not available for categories)
+ // numerical comparison:
+ // 10 - less
+ // 11 - less or equal
+ // 12 - greater
+ // 13 - greater or equal
+ // 14 - equal
+ // 15 - not equal
char** values;
int nvalues;
public:
- cSearchExtCat(void);
- virtual ~cSearchExtCat(void);
+ cSearchExtCat(void);
+ virtual ~cSearchExtCat(void);
- bool Parse(const char *s);
- const char* ToText(void);
+ bool Parse(const char *s);
+ const char* ToText(void);
};
-class cSearchExtCats : public cConfig<cSearchExtCat> {
+class cSearchExtCats : public cConfig<cSearchExtCat>
+{
private:
public:
- cSearchExtCats(void) {}
- int GetIndexFromID(int id);
- };
+ cSearchExtCats(void) {}
+ int GetIndexFromID(int id);
+};
extern cSearchExtCats SearchExtCats;
diff --git a/epgsearchcfg.c b/epgsearchcfg.c
index c48889e..c0e4457 100644
--- a/epgsearchcfg.c
+++ b/epgsearchcfg.c
@@ -28,77 +28,77 @@ cEPGSearchConfig EPGSearchConfig;
cEPGSearchConfig::cEPGSearchConfig(void)
{
- hidemenu = 0;
- redkeymode = 0;
- bluekeymode = 1;
- showProgress = 1;
- showChannelNr = 0;
- useSearchTimers = 0;
- UpdateIntervall = 30;
- SVDRPPort = 6419;
- timeShiftValue = 30;
- toggleGreenYellow = 1;
- StartMenu = 0;
- DefPriority = Setup.DefaultPriority;
- DefLifetime = Setup.DefaultLifetime;
- DefMarginStart = Setup.MarginStart;
- DefMarginStop = Setup.MarginStop;
- checkTimerConflictsAfterUpdate = 0;
- checkMinPriority = 0;
- checkMinDuration = 0;
- checkMaxDays = 14;
- ignorePayTV = 0;
- useExternalSVDRP = 0;
- ignorePrimary = 0;
- strcpy(defrecdir,"");
- useVDRTimerEditMenu = 0;
- showChannelGroups = 0;
- showDaySeparators = 0;
- showEmptyChannels = 0;
- DefSearchTemplateID = -1;
- addSubtitleToTimer = addSubtitleSmart;
- strcpy(mainmenuentry, "");
- WarEagle = 0;
- showRadioChannels = 1;
- onePressTimerCreation = 1;
- conflictCheckIntervall = 30;
- conflictCheckWithinLimit = 60;
- conflictCheckIntervall2 = 15;
- checkTimerConflAfterTimerProg = 0;
- checkTimerConflOnRecording = 0;
- showFavoritesMenu = 0;
- FavoritesMenuTimespan = 24;
- useOkForSwitch = 0;
- strcpy(MailAddress, "");
- strcpy(MailAddressTo, "");
- strcpy(MailServer, "");
- MailUseAuth = 0;
- strcpy(MailAuthUser, "");
- strcpy(MailAuthPass, "");
- strcpy(LastMailConflicts, "");
- mailViaScript = 1;
- manualTimerCheckDefault = 0;
- noAnnounceWhileReplay = 0;
- TimerProgRepeat = 0;
- maxChannelMenuNow = 0;
- noConflMsgWhileReplay = 0;
- sendMailOnSearchtimerHours = 0;
- lastMailOnSearchtimerAt = 0;
- checkEPGHours = 6;
- checkEPGWarnByOSD = 1;
- checkEPGWarnByMail = 0;
- checkEPGchannelGroupNr = -1;
- strcpy(conflCheckCmd, "");
- ReplaceOrgSchedule = 0;
- sendMailOnSearchtimers = 0;
- sendMailOnConflicts = 0;
- RemoteConflictCheck = 0;
+ hidemenu = 0;
+ redkeymode = 0;
+ bluekeymode = 1;
+ showProgress = 1;
+ showChannelNr = 0;
+ useSearchTimers = 0;
+ UpdateIntervall = 30;
+ SVDRPPort = 6419;
+ timeShiftValue = 30;
+ toggleGreenYellow = 1;
+ StartMenu = 0;
+ DefPriority = Setup.DefaultPriority;
+ DefLifetime = Setup.DefaultLifetime;
+ DefMarginStart = Setup.MarginStart;
+ DefMarginStop = Setup.MarginStop;
+ checkTimerConflictsAfterUpdate = 0;
+ checkMinPriority = 0;
+ checkMinDuration = 0;
+ checkMaxDays = 14;
+ ignorePayTV = 0;
+ useExternalSVDRP = 0;
+ ignorePrimary = 0;
+ strcpy(defrecdir, "");
+ useVDRTimerEditMenu = 0;
+ showChannelGroups = 0;
+ showDaySeparators = 0;
+ showEmptyChannels = 0;
+ DefSearchTemplateID = -1;
+ addSubtitleToTimer = addSubtitleSmart;
+ strcpy(mainmenuentry, "");
+ WarEagle = 0;
+ showRadioChannels = 1;
+ onePressTimerCreation = 1;
+ conflictCheckIntervall = 30;
+ conflictCheckWithinLimit = 60;
+ conflictCheckIntervall2 = 15;
+ checkTimerConflAfterTimerProg = 0;
+ checkTimerConflOnRecording = 0;
+ showFavoritesMenu = 0;
+ FavoritesMenuTimespan = 24;
+ useOkForSwitch = 0;
+ strcpy(MailAddress, "");
+ strcpy(MailAddressTo, "");
+ strcpy(MailServer, "");
+ MailUseAuth = 0;
+ strcpy(MailAuthUser, "");
+ strcpy(MailAuthPass, "");
+ strcpy(LastMailConflicts, "");
+ mailViaScript = 1;
+ manualTimerCheckDefault = 0;
+ noAnnounceWhileReplay = 0;
+ TimerProgRepeat = 0;
+ maxChannelMenuNow = 0;
+ noConflMsgWhileReplay = 0;
+ sendMailOnSearchtimerHours = 0;
+ lastMailOnSearchtimerAt = 0;
+ checkEPGHours = 6;
+ checkEPGWarnByOSD = 1;
+ checkEPGWarnByMail = 0;
+ checkEPGchannelGroupNr = -1;
+ strcpy(conflCheckCmd, "");
+ ReplaceOrgSchedule = 0;
+ sendMailOnSearchtimers = 0;
+ sendMailOnConflicts = 0;
+ RemoteConflictCheck = 0;
}
cShowMode& cShowMode::operator= (const cShowMode &ShowMode)
{
- this->mode = ShowMode.mode;
- this->seekTime = ShowMode.seekTime;
+ this->mode = ShowMode.mode;
+ this->seekTime = ShowMode.seekTime;
memcpy(this->description, ShowMode.description, sizeof(ShowMode.description));
this->useIt = ShowMode.useIt;
this->itime = ShowMode.itime;
@@ -108,39 +108,32 @@ cShowMode& cShowMode::operator= (const cShowMode &ShowMode)
int cShowMode::Compare(const cListObject &ListObject) const
{
cShowMode *p = (cShowMode *)&ListObject;
- if (EPGSearchConfig.showFavoritesMenu == 1)
- {
- if (mode == showFavorites)
- {
- if (p->mode <= showNext) return 1;
- else return -1;
- }
- if (p->mode == showFavorites)
- {
- if (mode <= showNext) return -1;
- else return 1;
- }
+ if (EPGSearchConfig.showFavoritesMenu == 1) {
+ if (mode == showFavorites) {
+ if (p->mode <= showNext) return 1;
+ else return -1;
+ }
+ if (p->mode == showFavorites) {
+ if (mode <= showNext) return -1;
+ else return 1;
+ }
}
- if (EPGSearchConfig.showFavoritesMenu == 2)
- {
- if (mode == showFavorites && p->mode != showFavorites) return 1;
- if (p->mode == showFavorites && mode != showFavorites) return -1;
+ if (EPGSearchConfig.showFavoritesMenu == 2) {
+ if (mode == showFavorites && p->mode != showFavorites) return 1;
+ if (p->mode == showFavorites && mode != showFavorites) return -1;
}
- if (EPGSearchConfig.showFavoritesMenu == 3)
- {
- if (mode == showFavorites)
- {
- if (p->mode < showNext) return 1;
- else return -1;
- }
- if (p->mode == showFavorites)
- {
- if (mode < showNext) return -1;
- else return 1;
- }
+ if (EPGSearchConfig.showFavoritesMenu == 3) {
+ if (mode == showFavorites) {
+ if (p->mode < showNext) return 1;
+ else return -1;
+ }
+ if (p->mode == showFavorites) {
+ if (mode < showNext) return -1;
+ else return 1;
+ }
}
if (mode > showNext && p->mode > showNext)
- return seekTime - p->seekTime;
+ return seekTime - p->seekTime;
else
- return mode - p->mode;
+ return mode - p->mode;
}
diff --git a/epgsearchcfg.h b/epgsearchcfg.h
index d8da05b..f68cdeb 100644
--- a/epgsearchcfg.h
+++ b/epgsearchcfg.h
@@ -30,9 +30,8 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
extern int toggleKeys;
-typedef enum
-{
- showNow=0,
+typedef enum {
+ showNow = 0,
showNext,
showUserMode1,
showUserMode2,
@@ -46,44 +45,57 @@ class cShowMode: public cListObject
{
showMode mode;
time_t seekTime;
- public:
+public:
char description[30];
int useIt;
int itime;
- cShowMode() : mode(showNow), seekTime(0), useIt(0), itime(0) { description[0]=0;}
- cShowMode(showMode Mode, const char* Description, int UseIt=1, int iTime=0, time_t SeekTime=0)
- : mode(Mode), seekTime(SeekTime), useIt(UseIt), itime(iTime)
- {
- if (strlen(Description) > 0)
- SetDescription(Description);
- else
- sprintf(description, "%02d:%02d", iTime/100, iTime%100);
- }
+ cShowMode() : mode(showNow), seekTime(0), useIt(0), itime(0) {
+ description[0] = 0;
+ }
+ cShowMode(showMode Mode, const char* Description, int UseIt = 1, int iTime = 0, time_t SeekTime = 0)
+ : mode(Mode), seekTime(SeekTime), useIt(UseIt), itime(iTime) {
+ if (strlen(Description) > 0)
+ SetDescription(Description);
+ else
+ sprintf(description, "%02d:%02d", iTime / 100, iTime % 100);
+ }
cShowMode& operator= (const cShowMode &ShowMode);
- const char* GetDescription() { return description; }
- int GetTime() const { return itime; }
- bool GetUsage() const { return useIt; }
-
- void SetDescription(const char* szD) { if (szD) strncpy(description, szD, sizeof(description)); }
- void SetTime(int iT) { itime = iT; }
- void SetUsage(bool bU) { useIt = bU; }
+ const char* GetDescription() {
+ return description;
+ }
+ int GetTime() const {
+ return itime;
+ }
+ bool GetUsage() const {
+ return useIt;
+ }
+
+ void SetDescription(const char* szD) {
+ if (szD) strncpy(description, szD, sizeof(description));
+ }
+ void SetTime(int iT) {
+ itime = iT;
+ }
+ void SetUsage(bool bU) {
+ useIt = bU;
+ }
int Compare(const cListObject &ListObject) const;
- showMode GetMode() const { return mode; }
+ showMode GetMode() const {
+ return mode;
+ }
};
-typedef enum
-{
- addSubtitleNever=0,
+typedef enum {
+ addSubtitleNever = 0,
addSubtitleAlways,
addSubtitleSmart
} addSubtitleToTimerMode;
-struct cEPGSearchConfig
-{
+struct cEPGSearchConfig {
public:
-cEPGSearchConfig(void);
+ cEPGSearchConfig(void);
int hidemenu;
int ReplaceOrgSchedule;
int redkeymode;
@@ -149,7 +161,7 @@ cEPGSearchConfig(void);
int checkEPGWarnByMail;
int checkEPGchannelGroupNr;
time_t lastMailOnSearchtimerAt;
- char conflCheckCmd[MaxFileName*10];
+ char conflCheckCmd[MaxFileName * 10];
};
extern cEPGSearchConfig EPGSearchConfig;
diff --git a/epgsearchext.c b/epgsearchext.c
index f8d1f90..4c69c43 100644
--- a/epgsearchext.c
+++ b/epgsearchext.c
@@ -43,7 +43,7 @@ cSearchExts SearchExts;
cSearchExts SearchTemplates;
#ifndef MAX_SUBTITLE_LENGTH
- #define MAX_SUBTITLE_LENGTH 40
+#define MAX_SUBTITLE_LENGTH 40
#endif
// -- cSearchExt -----------------------------------------------------------------
@@ -51,1641 +51,1559 @@ char *cSearchExt::buffer = NULL;
cSearchExt::cSearchExt(void)
{
- ID = -1;
- *search = 0;
- options = 1;
- useTime = false;
- startTime = 0000;
- stopTime = 2359;
- useChannel = false;
- {
- LOCK_CHANNELS_READ;
- channelMin = Channels->GetByNumber(cDevice::CurrentChannel());
- channelMax = Channels->GetByNumber(cDevice::CurrentChannel());
- }
- channelGroup = NULL;
- useCase = false;
- mode = 0;
- useTitle = true;
- useSubtitle = true;
- useDescription = true;
- useDuration = false;
- minDuration = 0;
- maxDuration = 2359;
- useAsSearchTimer = false;
- useDayOfWeek = false;
- DayOfWeek = 0;
- buffer = NULL;
- *directory = 0;
- useEpisode = 0;
- Priority = EPGSearchConfig.DefPriority;
- Lifetime = EPGSearchConfig.DefLifetime;
- MarginStart = EPGSearchConfig.DefMarginStart;
- MarginStop = EPGSearchConfig.DefMarginStop;
- useVPS = false;
- action = searchTimerActionRecord;
- useExtEPGInfo = false;
- contentsFilter = "";
- catvalues = (char**) malloc(SearchExtCats.Count() * sizeof(char*));
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- catvalues[index] = (char*)malloc(MaxFileName);
- *catvalues[index] = 0;
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- avoidRepeats = 0;
- compareTitle = 1;
- compareSubtitle = 1;
- compareSummary = 1;
- compareSummaryMatchInPercent = 90;
- compareDate = 0;
- allowedRepeats = 0;
- catvaluesAvoidRepeat = 0;
- repeatsWithinDays = 0;
- delAfterDays = 0;
- recordingsKeep = 0;
- switchMinsBefore = 1;
- pauseOnNrRecordings = 0;
- blacklistMode = blacklistsOnlyGlobal; // no blacklists
- blacklists.Clear();
- fuzzyTolerance = 1;
- useInFavorites = 0;
- menuTemplate = 0;
- delMode = 0;
- delAfterCountRecs = 0;
- delAfterDaysOfFirstRec = 0;
- useAsSearchTimerFrom = 0;
- useAsSearchTimerTil = 0;
- ignoreMissingEPGCats = 0;
- unmuteSoundOnSwitch = 0;
- skipRunningEvents = false;
+ ID = -1;
+ *search = 0;
+ options = 1;
+ useTime = false;
+ startTime = 0000;
+ stopTime = 2359;
+ useChannel = false;
+ {
+ LOCK_CHANNELS_READ;
+ channelMin = Channels->GetByNumber(cDevice::CurrentChannel());
+ channelMax = Channels->GetByNumber(cDevice::CurrentChannel());
+ }
+ channelGroup = NULL;
+ useCase = false;
+ mode = 0;
+ useTitle = true;
+ useSubtitle = true;
+ useDescription = true;
+ useDuration = false;
+ minDuration = 0;
+ maxDuration = 2359;
+ useAsSearchTimer = false;
+ useDayOfWeek = false;
+ DayOfWeek = 0;
+ buffer = NULL;
+ *directory = 0;
+ useEpisode = 0;
+ Priority = EPGSearchConfig.DefPriority;
+ Lifetime = EPGSearchConfig.DefLifetime;
+ MarginStart = EPGSearchConfig.DefMarginStart;
+ MarginStop = EPGSearchConfig.DefMarginStop;
+ useVPS = false;
+ action = searchTimerActionRecord;
+ useExtEPGInfo = false;
+ contentsFilter = "";
+ catvalues = (char**) malloc(SearchExtCats.Count() * sizeof(char*));
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ catvalues[index] = (char*)malloc(MaxFileName);
+ *catvalues[index] = 0;
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ avoidRepeats = 0;
+ compareTitle = 1;
+ compareSubtitle = 1;
+ compareSummary = 1;
+ compareSummaryMatchInPercent = 90;
+ compareDate = 0;
+ allowedRepeats = 0;
+ catvaluesAvoidRepeat = 0;
+ repeatsWithinDays = 0;
+ delAfterDays = 0;
+ recordingsKeep = 0;
+ switchMinsBefore = 1;
+ pauseOnNrRecordings = 0;
+ blacklistMode = blacklistsOnlyGlobal; // no blacklists
+ blacklists.Clear();
+ fuzzyTolerance = 1;
+ useInFavorites = 0;
+ menuTemplate = 0;
+ delMode = 0;
+ delAfterCountRecs = 0;
+ delAfterDaysOfFirstRec = 0;
+ useAsSearchTimerFrom = 0;
+ useAsSearchTimerTil = 0;
+ ignoreMissingEPGCats = 0;
+ unmuteSoundOnSwitch = 0;
+ skipRunningEvents = false;
}
cSearchExt::~cSearchExt(void)
{
- if (buffer) {
- free(buffer);
- buffer = NULL;
- }
-
- if (catvalues)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- free(catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- free(catvalues);
- catvalues = NULL;
- }
+ if (buffer) {
+ free(buffer);
+ buffer = NULL;
+ }
+
+ if (catvalues) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ free(catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+ free(catvalues);
+ catvalues = NULL;
+ }
}
cSearchExt& cSearchExt::operator= (const cSearchExt &SearchExt)
{
- CopyFromTemplate(&SearchExt);
- ID = SearchExt.ID;
- strcpy(search, SearchExt.search);
-
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- *catvalues[index] = 0;
- strcpy(catvalues[index], SearchExt.catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
-
- return *this;
+ CopyFromTemplate(&SearchExt);
+ ID = SearchExt.ID;
+ strcpy(search, SearchExt.search);
+
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ *catvalues[index] = 0;
+ strcpy(catvalues[index], SearchExt.catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+
+ return *this;
}
- void cSearchExt::CopyFromTemplate(const cSearchExt* templ, bool ignoreChannelSettings)
+void cSearchExt::CopyFromTemplate(const cSearchExt* templ, bool ignoreChannelSettings)
{
- options = templ->options;
- useTime = templ->useTime;
- startTime = templ->startTime;
- stopTime = templ->stopTime;
- if (!ignoreChannelSettings)
- useChannel = templ->useChannel;
- useCase = templ->useCase;
- mode = templ->mode;
- useTitle = templ->useTitle;
- useSubtitle = templ->useSubtitle;
- useDescription = templ->useDescription;
- useDuration = templ->useDuration;
- minDuration = templ->minDuration;
- maxDuration = templ->maxDuration;
- useAsSearchTimer = templ->useAsSearchTimer;
- useDayOfWeek = templ->useDayOfWeek;
- DayOfWeek = templ->DayOfWeek;
- useEpisode = templ->useEpisode;
- strcpy(directory, templ->directory);
- Priority = templ->Priority;
- Lifetime = templ->Lifetime;
- MarginStart = templ->MarginStart;
- MarginStop = templ->MarginStop;
- useVPS = templ->useVPS;
- action = templ->action;
- useExtEPGInfo = templ->useExtEPGInfo;
- contentsFilter = templ->contentsFilter;
- switchMinsBefore = templ->switchMinsBefore;
- pauseOnNrRecordings = templ->pauseOnNrRecordings;
-
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- strcpy(catvalues[index], templ->catvalues[index]);
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
-
- if (!ignoreChannelSettings)
- {
- channelMin = templ->channelMin;
- channelMax = templ->channelMax;
- if (channelGroup)
- {
- free(channelGroup);
- channelGroup = NULL;
- }
- if (templ->channelGroup)
- channelGroup = strdup(templ->channelGroup);
- }
- avoidRepeats = templ->avoidRepeats;
- compareTitle = templ->compareTitle;
- compareSubtitle = templ->compareSubtitle;
- compareSummary = templ->compareSummary;
- compareSummaryMatchInPercent = templ->compareSummaryMatchInPercent;
- compareDate = templ->compareDate;
- allowedRepeats = templ->allowedRepeats;
- catvaluesAvoidRepeat = templ->catvaluesAvoidRepeat;
- repeatsWithinDays = templ->repeatsWithinDays;
- delAfterDays = templ->delAfterDays;
- recordingsKeep = templ->recordingsKeep;
- blacklistMode = templ->blacklistMode;
- blacklists.Clear();
- const cBlacklistObject* blacklistObj = templ->blacklists.First();
- while(blacklistObj)
- {
- blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
- blacklistObj = templ->blacklists.Next(blacklistObj);
- }
- fuzzyTolerance = templ->fuzzyTolerance;
- useInFavorites = templ->useInFavorites;
- menuTemplate = templ->menuTemplate;
- delMode = templ->delMode;
- delAfterCountRecs = templ->delAfterCountRecs;
- delAfterDaysOfFirstRec = templ->delAfterDaysOfFirstRec;
- useAsSearchTimerFrom = templ->useAsSearchTimerFrom;
- useAsSearchTimerTil = templ->useAsSearchTimerTil;
- ignoreMissingEPGCats = templ->ignoreMissingEPGCats;
- unmuteSoundOnSwitch = templ->unmuteSoundOnSwitch;
+ options = templ->options;
+ useTime = templ->useTime;
+ startTime = templ->startTime;
+ stopTime = templ->stopTime;
+ if (!ignoreChannelSettings)
+ useChannel = templ->useChannel;
+ useCase = templ->useCase;
+ mode = templ->mode;
+ useTitle = templ->useTitle;
+ useSubtitle = templ->useSubtitle;
+ useDescription = templ->useDescription;
+ useDuration = templ->useDuration;
+ minDuration = templ->minDuration;
+ maxDuration = templ->maxDuration;
+ useAsSearchTimer = templ->useAsSearchTimer;
+ useDayOfWeek = templ->useDayOfWeek;
+ DayOfWeek = templ->DayOfWeek;
+ useEpisode = templ->useEpisode;
+ strcpy(directory, templ->directory);
+ Priority = templ->Priority;
+ Lifetime = templ->Lifetime;
+ MarginStart = templ->MarginStart;
+ MarginStop = templ->MarginStop;
+ useVPS = templ->useVPS;
+ action = templ->action;
+ useExtEPGInfo = templ->useExtEPGInfo;
+ contentsFilter = templ->contentsFilter;
+ switchMinsBefore = templ->switchMinsBefore;
+ pauseOnNrRecordings = templ->pauseOnNrRecordings;
+
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ strcpy(catvalues[index], templ->catvalues[index]);
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ }
+
+ if (!ignoreChannelSettings) {
+ channelMin = templ->channelMin;
+ channelMax = templ->channelMax;
+ if (channelGroup) {
+ free(channelGroup);
+ channelGroup = NULL;
+ }
+ if (templ->channelGroup)
+ channelGroup = strdup(templ->channelGroup);
+ }
+ avoidRepeats = templ->avoidRepeats;
+ compareTitle = templ->compareTitle;
+ compareSubtitle = templ->compareSubtitle;
+ compareSummary = templ->compareSummary;
+ compareSummaryMatchInPercent = templ->compareSummaryMatchInPercent;
+ compareDate = templ->compareDate;
+ allowedRepeats = templ->allowedRepeats;
+ catvaluesAvoidRepeat = templ->catvaluesAvoidRepeat;
+ repeatsWithinDays = templ->repeatsWithinDays;
+ delAfterDays = templ->delAfterDays;
+ recordingsKeep = templ->recordingsKeep;
+ blacklistMode = templ->blacklistMode;
+ blacklists.Clear();
+ const cBlacklistObject* blacklistObj = templ->blacklists.First();
+ while (blacklistObj) {
+ blacklists.Add(new cBlacklistObject(blacklistObj->blacklist));
+ blacklistObj = templ->blacklists.Next(blacklistObj);
+ }
+ fuzzyTolerance = templ->fuzzyTolerance;
+ useInFavorites = templ->useInFavorites;
+ menuTemplate = templ->menuTemplate;
+ delMode = templ->delMode;
+ delAfterCountRecs = templ->delAfterCountRecs;
+ delAfterDaysOfFirstRec = templ->delAfterDaysOfFirstRec;
+ useAsSearchTimerFrom = templ->useAsSearchTimerFrom;
+ useAsSearchTimerTil = templ->useAsSearchTimerTil;
+ ignoreMissingEPGCats = templ->ignoreMissingEPGCats;
+ unmuteSoundOnSwitch = templ->unmuteSoundOnSwitch;
}
bool cSearchExt::operator< (const cListObject &ListObject)
{
- cSearchExt *SE = (cSearchExt *)&ListObject;
- return strcasecmp(search, SE->search) < 0;
+ cSearchExt *SE = (cSearchExt *)&ListObject;
+ return strcasecmp(search, SE->search) < 0;
}
char* replaceSpecialChars(const char* in)
{
- char* tmp_in = strdup(in);
- while(strstr(tmp_in, "|"))
- tmp_in = strreplace(tmp_in, "|", "!^pipe^!"); // ugly: replace a pipe with something,
- strreplace(tmp_in, ':', '|');
- return tmp_in;
+ char* tmp_in = strdup(in);
+ while (strstr(tmp_in, "|"))
+ tmp_in = strreplace(tmp_in, "|", "!^pipe^!"); // ugly: replace a pipe with something,
+ strreplace(tmp_in, ':', '|');
+ return tmp_in;
}
const char *cSearchExt::ToText()
{
- char tmp_Start[5] = "";
- char tmp_Stop[5] = "";
- char tmp_minDuration[5] = "";
- char tmp_maxDuration[5] = "";
- cString tmp_chanSel;
- char* tmp_catvalues = NULL;
- char* tmp_blacklists = NULL;
-
- free(buffer);
- char* tmp_search = replaceSpecialChars(search);
- char* tmp_directory = replaceSpecialChars(directory);
- char* tmp_contentsFilter = replaceSpecialChars(contentsFilter.c_str());
-
- if (useTime)
- {
- sprintf(tmp_Start, "%04d", startTime);
- sprintf(tmp_Stop, "%04d", stopTime);
- }
- if (useDuration)
- {
- sprintf(tmp_minDuration, "%04d", minDuration);
- sprintf(tmp_maxDuration, "%04d", maxDuration);
- }
-
- if (useChannel==1)
- {
- if (channelMin->Number() < channelMax->Number())
- tmp_chanSel = cString::sprintf("%s|%s", CHANNELSTRING(channelMin), CHANNELSTRING(channelMax));
- else
- tmp_chanSel = cString(CHANNELSTRING(channelMin));
- }
- if (useChannel==2)
- {
- int channelGroupNr = ChannelGroups.GetIndex(channelGroup);
- if (channelGroupNr == -1)
- {
- LogFile.eSysLog("channel group '%s' does not exist!", channelGroup);
- useChannel = 0;
- }
- else
- tmp_chanSel = cString(channelGroup);
- }
-
- if (useExtEPGInfo)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (SearchExtCat)
- {
- char* catvalue = NULL;
- if (msprintf(&catvalue, "%s", catvalues[index])==-1) break;
- while(strstr(catvalue, ":"))
- catvalue = strreplace(catvalue, ":", "!^colon^!"); // ugly: replace with something, that should not happen to be part ofa category value
- while(strstr(catvalue, "|"))
- catvalue = strreplace(catvalue, "|", "!^pipe^!"); // ugly: replace with something, that should not happen to be part of a regular expression
-
- if (index == 0)
- msprintf(&tmp_catvalues, "%d#%s", SearchExtCat->id, catvalue);
- else
- {
- char* temp = tmp_catvalues;
- msprintf(&tmp_catvalues, "%s|%d#%s", tmp_catvalues, SearchExtCat->id, catvalue);
- free(temp);
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- free(catvalue);
- }
- }
-
- if (blacklistMode == blacklistsSelection && blacklists.Count() > 0)
- {
- cBlacklistObject *blacklistObj = blacklists.First();
- int index = 0;
- while (blacklistObj)
- {
- if (index == 0)
- msprintf(&tmp_blacklists, "%d", blacklistObj->blacklist->ID);
- else
- {
- char* temp = tmp_blacklists;
- msprintf(&tmp_blacklists, "%s|%d", tmp_blacklists, blacklistObj->blacklist->ID);
- free(temp);
- }
- blacklistObj = blacklists.Next(blacklistObj);
- index++;
- }
- }
-
- msprintf(&buffer, "%d:%s:%d:%s:%s:%d:%s:%d:%d:%d:%d:%d:%d:%s:%s:%d:%d:%d:%d:%s:%d:%d:%d:%d:%d:%d:%d:%s:%d:%d:%d:%d:%d:%ld:%d:%d:%d:%d:%d:%d:%s:%d:%d:%d:%d:%d:%d:%ld:%ld:%d:%d:%d:%s:%d",
- ID,
- tmp_search,
- useTime,
- tmp_Start,
- tmp_Stop,
- useChannel,
- (useChannel>0 && useChannel<3)?*tmp_chanSel:"0",
- useCase,
- mode,
- useTitle,
- useSubtitle,
- useDescription,
- useDuration,
- tmp_minDuration,
- tmp_maxDuration,
- useAsSearchTimer,
- useDayOfWeek,
- DayOfWeek,
- useEpisode,
- tmp_directory,
- Priority,
- Lifetime,
- MarginStart,
- MarginStop,
- useVPS,
- action,
- useExtEPGInfo,
- useExtEPGInfo?tmp_catvalues:"",
- avoidRepeats,
- allowedRepeats,
- compareTitle,
- compareSubtitle,
- compareSummary,
- catvaluesAvoidRepeat,
- repeatsWithinDays,
- delAfterDays,
- recordingsKeep,
- switchMinsBefore,
- pauseOnNrRecordings,
- blacklistMode,
- blacklists.Count()>0?tmp_blacklists:"",
- fuzzyTolerance,
- useInFavorites,
- menuTemplate,
- delMode,
- delAfterCountRecs,
- delAfterDaysOfFirstRec,
- useAsSearchTimerFrom,
- useAsSearchTimerTil,
- ignoreMissingEPGCats,
- unmuteSoundOnSwitch,
- compareSummaryMatchInPercent,
- contentsFilter.c_str(),
- compareDate);
-
- if (tmp_search) free(tmp_search);
- if (tmp_directory) free(tmp_directory);
- if (tmp_catvalues) free(tmp_catvalues);
- if (tmp_blacklists) free(tmp_blacklists);
- if (tmp_contentsFilter) free(tmp_contentsFilter);
-
- return buffer;
+ char tmp_Start[5] = "";
+ char tmp_Stop[5] = "";
+ char tmp_minDuration[5] = "";
+ char tmp_maxDuration[5] = "";
+ cString tmp_chanSel;
+ char* tmp_catvalues = NULL;
+ char* tmp_blacklists = NULL;
+
+ free(buffer);
+ char* tmp_search = replaceSpecialChars(search);
+ char* tmp_directory = replaceSpecialChars(directory);
+ char* tmp_contentsFilter = replaceSpecialChars(contentsFilter.c_str());
+
+ if (useTime) {
+ sprintf(tmp_Start, "%04d", startTime);
+ sprintf(tmp_Stop, "%04d", stopTime);
+ }
+ if (useDuration) {
+ sprintf(tmp_minDuration, "%04d", minDuration);
+ sprintf(tmp_maxDuration, "%04d", maxDuration);
+ }
+
+ if (useChannel == 1) {
+ if (channelMin->Number() < channelMax->Number())
+ tmp_chanSel = cString::sprintf("%s|%s", CHANNELSTRING(channelMin), CHANNELSTRING(channelMax));
+ else
+ tmp_chanSel = cString(CHANNELSTRING(channelMin));
+ }
+ if (useChannel == 2) {
+ int channelGroupNr = ChannelGroups.GetIndex(channelGroup);
+ if (channelGroupNr == -1) {
+ LogFile.eSysLog("channel group '%s' does not exist!", channelGroup);
+ useChannel = 0;
+ } else
+ tmp_chanSel = cString(channelGroup);
+ }
+
+ if (useExtEPGInfo) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (SearchExtCat) {
+ char* catvalue = NULL;
+ if (msprintf(&catvalue, "%s", catvalues[index]) == -1) break;
+ while (strstr(catvalue, ":"))
+ catvalue = strreplace(catvalue, ":", "!^colon^!"); // ugly: replace with something, that should not happen to be part ofa category value
+ while (strstr(catvalue, "|"))
+ catvalue = strreplace(catvalue, "|", "!^pipe^!"); // ugly: replace with something, that should not happen to be part of a regular expression
+
+ if (index == 0)
+ msprintf(&tmp_catvalues, "%d#%s", SearchExtCat->id, catvalue);
+ else {
+ char* temp = tmp_catvalues;
+ msprintf(&tmp_catvalues, "%s|%d#%s", tmp_catvalues, SearchExtCat->id, catvalue);
+ free(temp);
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
+ free(catvalue);
+ }
+ }
+
+ if (blacklistMode == blacklistsSelection && blacklists.Count() > 0) {
+ cBlacklistObject *blacklistObj = blacklists.First();
+ int index = 0;
+ while (blacklistObj) {
+ if (index == 0)
+ msprintf(&tmp_blacklists, "%d", blacklistObj->blacklist->ID);
+ else {
+ char* temp = tmp_blacklists;
+ msprintf(&tmp_blacklists, "%s|%d", tmp_blacklists, blacklistObj->blacklist->ID);
+ free(temp);
+ }
+ blacklistObj = blacklists.Next(blacklistObj);
+ index++;
+ }
+ }
+
+ msprintf(&buffer, "%d:%s:%d:%s:%s:%d:%s:%d:%d:%d:%d:%d:%d:%s:%s:%d:%d:%d:%d:%s:%d:%d:%d:%d:%d:%d:%d:%s:%d:%d:%d:%d:%d:%ld:%d:%d:%d:%d:%d:%d:%s:%d:%d:%d:%d:%d:%d:%ld:%ld:%d:%d:%d:%s:%d",
+ ID,
+ tmp_search,
+ useTime,
+ tmp_Start,
+ tmp_Stop,
+ useChannel,
+ (useChannel > 0 && useChannel < 3) ? *tmp_chanSel : "0",
+ useCase,
+ mode,
+ useTitle,
+ useSubtitle,
+ useDescription,
+ useDuration,
+ tmp_minDuration,
+ tmp_maxDuration,
+ useAsSearchTimer,
+ useDayOfWeek,
+ DayOfWeek,
+ useEpisode,
+ tmp_directory,
+ Priority,
+ Lifetime,
+ MarginStart,
+ MarginStop,
+ useVPS,
+ action,
+ useExtEPGInfo,
+ useExtEPGInfo ? tmp_catvalues : "",
+ avoidRepeats,
+ allowedRepeats,
+ compareTitle,
+ compareSubtitle,
+ compareSummary,
+ catvaluesAvoidRepeat,
+ repeatsWithinDays,
+ delAfterDays,
+ recordingsKeep,
+ switchMinsBefore,
+ pauseOnNrRecordings,
+ blacklistMode,
+ blacklists.Count() > 0 ? tmp_blacklists : "",
+ fuzzyTolerance,
+ useInFavorites,
+ menuTemplate,
+ delMode,
+ delAfterCountRecs,
+ delAfterDaysOfFirstRec,
+ useAsSearchTimerFrom,
+ useAsSearchTimerTil,
+ ignoreMissingEPGCats,
+ unmuteSoundOnSwitch,
+ compareSummaryMatchInPercent,
+ contentsFilter.c_str(),
+ compareDate);
+
+ if (tmp_search) free(tmp_search);
+ if (tmp_directory) free(tmp_directory);
+ if (tmp_catvalues) free(tmp_catvalues);
+ if (tmp_blacklists) free(tmp_blacklists);
+ if (tmp_contentsFilter) free(tmp_contentsFilter);
+
+ return buffer;
}
bool cSearchExt::Parse(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int parameter = 1;
- int valuelen;
- char value[MaxFileName];
- bool disableSearchtimer = false;
-
- *directory = 0;
- *search = 0;
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != ':') {
- pos_next = strchr(pos, ':');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MaxFileName) valuelen = MaxFileName;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1:
- if (!isnumber(value)) return false;
- ID = atoi(value);
- break;
- case 2: strcpy(search, value);
- break;
- case 3: useTime = atoi(value);
- break;
- case 4: startTime = atoi(value);
- break;
- case 5: stopTime = atoi(value);
- break;
- case 6: useChannel = atoi(value);
- break;
- case 7:
- if (useChannel == 0)
- {
- channelMin = NULL;
- channelMax = NULL;
- }
- else if (useChannel == 1)
- {
- int minNum=0, maxNum=0;
- int fields = sscanf(value, "%d-%d", &minNum, &maxNum);
- if (fields == 0) // stored with ID
- {
+ char *line;
+ char *pos;
+ char *pos_next;
+ int parameter = 1;
+ int valuelen;
+ char value[MaxFileName];
+ bool disableSearchtimer = false;
+
+ *directory = 0;
+ *search = 0;
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != ':') {
+ pos_next = strchr(pos, ':');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MaxFileName) valuelen = MaxFileName;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ switch (parameter) {
+ case 1:
+ if (!isnumber(value)) return false;
+ ID = atoi(value);
+ break;
+ case 2:
+ strcpy(search, value);
+ break;
+ case 3:
+ useTime = atoi(value);
+ break;
+ case 4:
+ startTime = atoi(value);
+ break;
+ case 5:
+ stopTime = atoi(value);
+ break;
+ case 6:
+ useChannel = atoi(value);
+ break;
+ case 7:
+ if (useChannel == 0) {
+ channelMin = NULL;
+ channelMax = NULL;
+ } else if (useChannel == 1) {
+ int minNum = 0, maxNum = 0;
+ int fields = sscanf(value, "%d-%d", &minNum, &maxNum);
+ if (fields == 0) { // stored with ID
#ifdef __FreeBSD__
- char *channelMinbuffer = MALLOC(char, 32);
- char *channelMaxbuffer = MALLOC(char, 32);
- int channels = sscanf(value, "%31[^|]|%31[^|]", channelMinbuffer, channelMaxbuffer);
+ char *channelMinbuffer = MALLOC(char, 32);
+ char *channelMaxbuffer = MALLOC(char, 32);
+ int channels = sscanf(value, "%31[^|]|%31[^|]", channelMinbuffer, channelMaxbuffer);
#else
- char *channelMinbuffer = NULL;
- char *channelMaxbuffer = NULL;
- int channels = sscanf(value, "%m[^|]|%m[^|]", &channelMinbuffer, &channelMaxbuffer);
+ char *channelMinbuffer = NULL;
+ char *channelMaxbuffer = NULL;
+ int channels = sscanf(value, "%m[^|]|%m[^|]", &channelMinbuffer, &channelMaxbuffer);
#endif
- LOCK_CHANNELS_READ;
- channelMin = Channels->GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true);
- if (!channelMin)
- {
- LogFile.eSysLog("ERROR: channel '%s' not defined", channelMinbuffer);
- channelMin = channelMax = NULL;
- disableSearchtimer = true;
- useChannel = 0;
- }
- if (channels == 1)
- channelMax = channelMin;
- else
- {
- channelMax = Channels->GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true);
- if (!channelMax)
- {
- LogFile.eSysLog("ERROR: channel '%s' not defined", channelMaxbuffer);
- channelMin = channelMax = NULL;
- disableSearchtimer = true;
- useChannel = 0;
- }
+ LOCK_CHANNELS_READ;
+ channelMin = Channels->GetByChannelID(tChannelID::FromString(channelMinbuffer), true, true);
+ if (!channelMin) {
+ LogFile.eSysLog("ERROR: channel '%s' not defined", channelMinbuffer);
+ channelMin = channelMax = NULL;
+ disableSearchtimer = true;
+ useChannel = 0;
+ }
+ if (channels == 1)
+ channelMax = channelMin;
+ else {
+ channelMax = Channels->GetByChannelID(tChannelID::FromString(channelMaxbuffer), true, true);
+ if (!channelMax) {
+ LogFile.eSysLog("ERROR: channel '%s' not defined", channelMaxbuffer);
+ channelMin = channelMax = NULL;
+ disableSearchtimer = true;
+ useChannel = 0;
+ }
+ }
+ free(channelMinbuffer);
+ free(channelMaxbuffer);
}
- free(channelMinbuffer);
- free(channelMaxbuffer);
- }
- }
- else if (useChannel == 2)
- channelGroup = strdup(value);
- break;
- case 8: useCase = atoi(value);
- break;
- case 9: mode = atoi(value);
- break;
- case 10: useTitle = atoi(value);
- break;
- case 11: useSubtitle = atoi(value);
- break;
- case 12: useDescription = atoi(value);
- break;
- case 13: useDuration = atoi(value);
- break;
- case 14: minDuration = atoi(value);
- break;
- case 15: maxDuration = atoi(value);
- break;
- case 16: useAsSearchTimer = atoi(value);
- break;
- case 17: useDayOfWeek = atoi(value);
- break;
- case 18: DayOfWeek = atoi(value);
- break;
- case 19: useEpisode = atoi(value);
- break;
- case 20: strcpy(directory, value);
- break;
- case 21: Priority = atoi(value);
- break;
- case 22: Lifetime = atoi(value);
- break;
- case 23: MarginStart = atoi(value);
- break;
- case 24: MarginStop = atoi(value);
- break;
- case 25: useVPS = atoi(value);
- break;
- case 26: action = atoi(value);
- break;
- case 27: useExtEPGInfo = atoi(value);
- break;
- case 28:
- if (!ParseExtEPGValues(value))
- {
- LogFile.eSysLog("ERROR reading ext. EPG values - 1");
- free(line);
- return false;
- }
- break;
- case 29: avoidRepeats = atoi(value);
- break;
- case 30: allowedRepeats = atoi(value);
- break;
- case 31: compareTitle = atoi(value);
- break;
- case 32: compareSubtitle = atoi(value)>0?1:0;
- break;
- case 33: compareSummary = atoi(value);
- break;
- case 34: catvaluesAvoidRepeat = atol(value);
- break;
- case 35: repeatsWithinDays = atoi(value);
- break;
- case 36: delAfterDays = atoi(value);
- break;
- case 37: recordingsKeep = atoi(value);
- break;
- case 38: switchMinsBefore = atoi(value);
- break;
- case 39: pauseOnNrRecordings = atoi(value);
- break;
- case 40: blacklistMode = atoi(value);
- break;
- case 41:
- if (blacklistMode == blacklistsSelection && !ParseBlacklistIDs(value))
- {
- LogFile.eSysLog("ERROR parsing blacklist IDs");
- free(line);
- return false;
- }
- break;
- case 42: fuzzyTolerance = atoi(value);
- break;
- case 43: useInFavorites = atoi(value);
- break;
- case 44: menuTemplate = atoi(value);
- break;
- case 45: delMode = atoi(value);
- break;
- case 46: delAfterCountRecs = atoi(value);
- break;
- case 47: delAfterDaysOfFirstRec = atoi(value);
- break;
- case 48:
- useAsSearchTimerFrom = atol(value);
- break;
- case 49:
- useAsSearchTimerTil = atol(value);
- break;
- case 50:
- ignoreMissingEPGCats = atoi(value);
- break;
- case 51:
- unmuteSoundOnSwitch = atoi(value);
- break;
- case 52:
- compareSummaryMatchInPercent = atoi(value);
- break;
- case 53:
- contentsFilter = value;
- break;
- case 54:
- compareDate = atoi(value);
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
-
- strreplace(directory, '|', ':');
- strreplace(search, '|', ':');
- strreplace(contentsFilter, "|", ":");
-
- while(strstr(search, "!^pipe^!"))
- strreplace(search, "!^pipe^!", "|");
- while(strstr(directory, "!^pipe^!"))
- strreplace(directory, "!^pipe^!", "|");
- strreplace(contentsFilter, "!^pipe^!", "|");
-
- if (disableSearchtimer && useAsSearchTimer)
- {
- useAsSearchTimer = false;
- LogFile.Log(1, "search timer '%s' disabled", search);
- }
-
- free(line);
- return (parameter >= 11) ? true : false;
+ } else if (useChannel == 2)
+ channelGroup = strdup(value);
+ break;
+ case 8:
+ useCase = atoi(value);
+ break;
+ case 9:
+ mode = atoi(value);
+ break;
+ case 10:
+ useTitle = atoi(value);
+ break;
+ case 11:
+ useSubtitle = atoi(value);
+ break;
+ case 12:
+ useDescription = atoi(value);
+ break;
+ case 13:
+ useDuration = atoi(value);
+ break;
+ case 14:
+ minDuration = atoi(value);
+ break;
+ case 15:
+ maxDuration = atoi(value);
+ break;
+ case 16:
+ useAsSearchTimer = atoi(value);
+ break;
+ case 17:
+ useDayOfWeek = atoi(value);
+ break;
+ case 18:
+ DayOfWeek = atoi(value);
+ break;
+ case 19:
+ useEpisode = atoi(value);
+ break;
+ case 20:
+ strcpy(directory, value);
+ break;
+ case 21:
+ Priority = atoi(value);
+ break;
+ case 22:
+ Lifetime = atoi(value);
+ break;
+ case 23:
+ MarginStart = atoi(value);
+ break;
+ case 24:
+ MarginStop = atoi(value);
+ break;
+ case 25:
+ useVPS = atoi(value);
+ break;
+ case 26:
+ action = atoi(value);
+ break;
+ case 27:
+ useExtEPGInfo = atoi(value);
+ break;
+ case 28:
+ if (!ParseExtEPGValues(value)) {
+ LogFile.eSysLog("ERROR reading ext. EPG values - 1");
+ free(line);
+ return false;
+ }
+ break;
+ case 29:
+ avoidRepeats = atoi(value);
+ break;
+ case 30:
+ allowedRepeats = atoi(value);
+ break;
+ case 31:
+ compareTitle = atoi(value);
+ break;
+ case 32:
+ compareSubtitle = atoi(value) > 0 ? 1 : 0;
+ break;
+ case 33:
+ compareSummary = atoi(value);
+ break;
+ case 34:
+ catvaluesAvoidRepeat = atol(value);
+ break;
+ case 35:
+ repeatsWithinDays = atoi(value);
+ break;
+ case 36:
+ delAfterDays = atoi(value);
+ break;
+ case 37:
+ recordingsKeep = atoi(value);
+ break;
+ case 38:
+ switchMinsBefore = atoi(value);
+ break;
+ case 39:
+ pauseOnNrRecordings = atoi(value);
+ break;
+ case 40:
+ blacklistMode = atoi(value);
+ break;
+ case 41:
+ if (blacklistMode == blacklistsSelection && !ParseBlacklistIDs(value)) {
+ LogFile.eSysLog("ERROR parsing blacklist IDs");
+ free(line);
+ return false;
+ }
+ break;
+ case 42:
+ fuzzyTolerance = atoi(value);
+ break;
+ case 43:
+ useInFavorites = atoi(value);
+ break;
+ case 44:
+ menuTemplate = atoi(value);
+ break;
+ case 45:
+ delMode = atoi(value);
+ break;
+ case 46:
+ delAfterCountRecs = atoi(value);
+ break;
+ case 47:
+ delAfterDaysOfFirstRec = atoi(value);
+ break;
+ case 48:
+ useAsSearchTimerFrom = atol(value);
+ break;
+ case 49:
+ useAsSearchTimerTil = atol(value);
+ break;
+ case 50:
+ ignoreMissingEPGCats = atoi(value);
+ break;
+ case 51:
+ unmuteSoundOnSwitch = atoi(value);
+ break;
+ case 52:
+ compareSummaryMatchInPercent = atoi(value);
+ break;
+ case 53:
+ contentsFilter = value;
+ break;
+ case 54:
+ compareDate = atoi(value);
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
+
+ strreplace(directory, '|', ':');
+ strreplace(search, '|', ':');
+ strreplace(contentsFilter, "|", ":");
+
+ while (strstr(search, "!^pipe^!"))
+ strreplace(search, "!^pipe^!", "|");
+ while (strstr(directory, "!^pipe^!"))
+ strreplace(directory, "!^pipe^!", "|");
+ strreplace(contentsFilter, "!^pipe^!", "|");
+
+ if (disableSearchtimer && useAsSearchTimer) {
+ useAsSearchTimer = false;
+ LogFile.Log(1, "search timer '%s' disabled", search);
+ }
+
+ free(line);
+ return (parameter >= 11) ? true : false;
}
char* cSearchExt::BuildFile(const cEvent* pEvent) const
{
- char* file = NULL;
-
- if (!pEvent)
- return file;
-
- const char *Subtitle = pEvent ? pEvent->ShortText() : NULL;
- char SubtitleBuffer[Utf8BufSize(MAX_SUBTITLE_LENGTH)];
- if (isempty(Subtitle))
- {
- time_t Start = pEvent->StartTime();
- struct tm tm_r;
- strftime(SubtitleBuffer, sizeof(SubtitleBuffer), "%Y.%m.%d-%R-%a", localtime_r(&Start, &tm_r));
- Subtitle = SubtitleBuffer;
- }
- else if (Utf8StrLen(Subtitle) > MAX_SUBTITLE_LENGTH)
- {
- Utf8Strn0Cpy(SubtitleBuffer, Subtitle, sizeof(SubtitleBuffer));
- SubtitleBuffer[Utf8SymChars(SubtitleBuffer, MAX_SUBTITLE_LENGTH)] = 0;
- Subtitle = SubtitleBuffer;
- }
-
- if (useEpisode)
- {
- cString pFile = cString::sprintf("%s~%s", pEvent->Title(), Subtitle);
- if (file) free(file);
- file = strdup(pFile);
- }
- else if (pEvent->Title())
- file = strdup(pEvent->Title());
-
- if (!isempty(directory))
- {
- char* pFile = NULL;
-
- cVarExpr varExprDir(directory);
- if (!varExprDir.DependsOnVar("%title%", pEvent) && !varExprDir.DependsOnVar("%subtitle%", pEvent))
- msprintf(&pFile, "%s~%s", directory, file?file:"");
- else
- // ignore existing title and subtitle in file if already used as variables in directory
- msprintf(&pFile, "%s", directory);
-
- // parse the epxression and evaluate it
- cVarExpr varExprFile(pFile);
- if (pFile) free(pFile);
- pFile = strdup(varExprFile.Evaluate(pEvent).c_str());
-
- cVarExpr varExprSearchFile(pFile);
- if (pFile) free(pFile);
- pFile = strdup(varExprSearchFile.Evaluate(this).c_str());
-
- if (file) free(file);
- file = strdup(pFile);
- free(pFile);
- }
+ char* file = NULL;
+
+ if (!pEvent)
+ return file;
+
+ const char *Subtitle = pEvent ? pEvent->ShortText() : NULL;
+ char SubtitleBuffer[Utf8BufSize(MAX_SUBTITLE_LENGTH)];
+ if (isempty(Subtitle)) {
+ time_t Start = pEvent->StartTime();
+ struct tm tm_r;
+ strftime(SubtitleBuffer, sizeof(SubtitleBuffer), "%Y.%m.%d-%R-%a", localtime_r(&Start, &tm_r));
+ Subtitle = SubtitleBuffer;
+ } else if (Utf8StrLen(Subtitle) > MAX_SUBTITLE_LENGTH) {
+ Utf8Strn0Cpy(SubtitleBuffer, Subtitle, sizeof(SubtitleBuffer));
+ SubtitleBuffer[Utf8SymChars(SubtitleBuffer, MAX_SUBTITLE_LENGTH)] = 0;
+ Subtitle = SubtitleBuffer;
+ }
+
+ if (useEpisode) {
+ cString pFile = cString::sprintf("%s~%s", pEvent->Title(), Subtitle);
+ if (file) free(file);
+ file = strdup(pFile);
+ } else if (pEvent->Title())
+ file = strdup(pEvent->Title());
+
+ if (!isempty(directory)) {
+ char* pFile = NULL;
+
+ cVarExpr varExprDir(directory);
+ if (!varExprDir.DependsOnVar("%title%", pEvent) && !varExprDir.DependsOnVar("%subtitle%", pEvent))
+ msprintf(&pFile, "%s~%s", directory, file ? file : "");
+ else
+ // ignore existing title and subtitle in file if already used as variables in directory
+ msprintf(&pFile, "%s", directory);
+
+ // parse the epxression and evaluate it
+ cVarExpr varExprFile(pFile);
+ if (pFile) free(pFile);
+ pFile = strdup(varExprFile.Evaluate(pEvent).c_str());
+
+ cVarExpr varExprSearchFile(pFile);
+ if (pFile) free(pFile);
+ pFile = strdup(varExprSearchFile.Evaluate(this).c_str());
+
+ if (file) free(file);
+ file = strdup(pFile);
+ free(pFile);
+ }
// replace some special chars
- if (file)
- {
- while(strstr(file, "|")) file = strreplace(file, "|", "!^pipe^!");
- while(strstr(file, ":")) file = strreplace(file, ':', '|');
- while(strstr(file, " ~")) file = strreplace(file, " ~", "~");
- while(strstr(file, "~ ")) file = strreplace(file, "~ ", "~");
- }
- return file;
+ if (file) {
+ while (strstr(file, "|")) file = strreplace(file, "|", "!^pipe^!");
+ while (strstr(file, ":")) file = strreplace(file, ':', '|');
+ while (strstr(file, " ~")) file = strreplace(file, " ~", "~");
+ while (strstr(file, "~ ")) file = strreplace(file, "~ ", "~");
+ }
+ return file;
}
bool cSearchExt::ParseBlacklistIDs(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int valuelen;
- char value[MaxFileName];
-
- cMutexLock BlacklistLock(&Blacklists);
- blacklists.Clear();
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != '|') {
- pos_next = strchr(pos, '|');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MaxFileName) valuelen = MaxFileName;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- cBlacklist* blacklist = Blacklists.GetBlacklistFromID(atoi(value));
- if (!blacklist)
- LogFile.eSysLog("blacklist ID %s missing, will be skipped", value);
- else
- blacklists.Add(new cBlacklistObject(blacklist));
- }
- }
- if (*pos) pos++;
- } //while
-
- free(line);
- return true;
+ char *line;
+ char *pos;
+ char *pos_next;
+ int valuelen;
+ char value[MaxFileName];
+
+ cMutexLock BlacklistLock(&Blacklists);
+ blacklists.Clear();
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != '|') {
+ pos_next = strchr(pos, '|');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MaxFileName) valuelen = MaxFileName;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ cBlacklist* blacklist = Blacklists.GetBlacklistFromID(atoi(value));
+ if (!blacklist)
+ LogFile.eSysLog("blacklist ID %s missing, will be skipped", value);
+ else
+ blacklists.Add(new cBlacklistObject(blacklist));
+ }
+ }
+ if (*pos) pos++;
+ } //while
+
+ free(line);
+ return true;
}
bool cSearchExt::ParseExtEPGValues(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int valuelen;
- char value[MaxFileName];
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != '|') {
- pos_next = strchr(pos, '|');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MaxFileName) valuelen = MaxFileName;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- if (!ParseExtEPGEntry(value))
- {
- LogFile.eSysLog("ERROR reading ext. EPG value: %s", value);
- free(line);
- return false;
+ char *line;
+ char *pos;
+ char *pos_next;
+ int valuelen;
+ char value[MaxFileName];
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != '|') {
+ pos_next = strchr(pos, '|');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MaxFileName) valuelen = MaxFileName;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ if (!ParseExtEPGEntry(value)) {
+ LogFile.eSysLog("ERROR reading ext. EPG value: %s", value);
+ free(line);
+ return false;
+ }
}
- }
- }
- if (*pos) pos++;
- } //while
+ }
+ if (*pos) pos++;
+ } //while
- free(line);
- return true;
+ free(line);
+ return true;
}
bool cSearchExt::ParseExtEPGEntry(const char *s)
{
- char *line;
- char *pos;
- char *pos_next;
- int parameter = 1;
- int valuelen;
- char value[MaxFileName];
- int currentid = -1;
-
- pos = line = strdup(s);
- pos_next = pos + strlen(pos);
- if (*pos_next == '\n') *pos_next = 0;
- while (*pos) {
- while (*pos == ' ') pos++;
- if (*pos) {
- if (*pos != '#') {
- pos_next = strchr(pos, '#');
- if (!pos_next)
- pos_next = pos + strlen(pos);
- valuelen = pos_next - pos + 1;
- if (valuelen > MaxFileName) valuelen = MaxFileName;
- strn0cpy(value, pos, valuelen);
- pos = pos_next;
- switch (parameter) {
- case 1:
- {
- currentid = atoi(value);
- int index = SearchExtCats.GetIndexFromID(currentid);
- if (index > -1 && index < SearchExtCats.Count())
- strcpy(catvalues[index], "");
- }
- break;
- case 2:
- if (currentid > -1)
- {
- int index = SearchExtCats.GetIndexFromID(currentid);
- if (index > -1 && index < SearchExtCats.Count())
- {
- while(strstr(value, "!^colon^!"))
- strreplace(value, "!^colon^!", ":");
- while(strstr(value, "!^pipe^!"))
- strreplace(value, "!^pipe^!", "|");
- strcpy(catvalues[index], value);
- }
- }
- break;
- default:
- break;
- } //switch
- }
- parameter++;
- }
- if (*pos) pos++;
- } //while
-
- free(line);
- return (parameter >= 2) ? true : false;
+ char *line;
+ char *pos;
+ char *pos_next;
+ int parameter = 1;
+ int valuelen;
+ char value[MaxFileName];
+ int currentid = -1;
+
+ pos = line = strdup(s);
+ pos_next = pos + strlen(pos);
+ if (*pos_next == '\n') *pos_next = 0;
+ while (*pos) {
+ while (*pos == ' ') pos++;
+ if (*pos) {
+ if (*pos != '#') {
+ pos_next = strchr(pos, '#');
+ if (!pos_next)
+ pos_next = pos + strlen(pos);
+ valuelen = pos_next - pos + 1;
+ if (valuelen > MaxFileName) valuelen = MaxFileName;
+ strn0cpy(value, pos, valuelen);
+ pos = pos_next;
+ switch (parameter) {
+ case 1: {
+ currentid = atoi(value);
+ int index = SearchExtCats.GetIndexFromID(currentid);
+ if (index > -1 && index < SearchExtCats.Count())
+ strcpy(catvalues[index], "");
+ }
+ break;
+ case 2:
+ if (currentid > -1) {
+ int index = SearchExtCats.GetIndexFromID(currentid);
+ if (index > -1 && index < SearchExtCats.Count()) {
+ while (strstr(value, "!^colon^!"))
+ strreplace(value, "!^colon^!", ":");
+ while (strstr(value, "!^pipe^!"))
+ strreplace(value, "!^pipe^!", "|");
+ strcpy(catvalues[index], value);
+ }
+ }
+ break;
+ default:
+ break;
+ } //switch
+ }
+ parameter++;
+ }
+ if (*pos) pos++;
+ } //while
+
+ free(line);
+ return (parameter >= 2) ? true : false;
}
bool cSearchExt::Save(FILE *f)
{
- return fprintf(f, "%s\n", ToText()) > 0;
+ return fprintf(f, "%s\n", ToText()) > 0;
}
const cEvent * cSearchExt::GetEventBySearchExt(const cSchedule *schedules, const cEvent *Start, bool inspectTimerMargin)
{
- if (!schedules) return NULL;
-
- const cEvent *pe = NULL;
- const cEvent *p1 = NULL;
-
- const cList<cEvent>* Events = schedules->Events();
- if (Start)
- p1 = Events->Next(Start);
- else
- p1 = Events->First();
-
- time_t tNow=time(NULL);
- char* searchText = strdup(search);
-
- int searchStart = 0, searchStop = 0;
- if (useTime)
- {
- searchStart = startTime;
- searchStop = stopTime;
- if (searchStop < searchStart)
- searchStop += 2400;
- }
- int minSearchDuration = 0;
- int maxSearchDuration = 0;
- if (useDuration)
- {
- minSearchDuration = minDuration/100*60 + minDuration%100;
- maxSearchDuration = maxDuration/100*60 + maxDuration%100;
- }
-
- if (!useCase)
- ToLower(searchText);
-
- for (const cEvent *p = p1; p; p = Events->Next(p))
- {
- if(!p)
- {
- break;
- }
-
- if (skipRunningEvents && tNow > p->StartTime())
- continue;
-
- // ignore events without title
- if (!p->Title() || !*p->Title())
- continue;
-
- if (tNow < p->EndTime() + (inspectTimerMargin?(MarginStop * 60):0))
- {
- if (useTime)
- {
- time_t tEvent = p->StartTime();
- struct tm tmEvent;
- localtime_r(&tEvent, &tmEvent);
-
- int eventStart = tmEvent.tm_hour*100 + tmEvent.tm_min;
- int eventStart2 = eventStart + 2400;
- if ((eventStart < searchStart || eventStart > searchStop) &&
- (eventStart2 < searchStart || eventStart2 > searchStop))
- continue;
-
- if (useDayOfWeek)
- {
- if (DayOfWeek >= 0)
- {
- if (( DayOfWeek != tmEvent.tm_wday || (DayOfWeek == tmEvent.tm_wday && eventStart < searchStart)) &&
- (!((DayOfWeek+1)%7 == tmEvent.tm_wday && eventStart2 < searchStop)))
- continue;
- }
- else
- {
- int iFound = 0;
- for(int i=0; i<7; i++)
- {
- if ((abs(DayOfWeek) & (int)pow(2,i)) && ((i == tmEvent.tm_wday && eventStart >= searchStart) ||
- ((i+1)%7 == tmEvent.tm_wday && eventStart2 < searchStop)))
- {
- iFound = 1;
- break;
- }
- }
- if (!iFound)
- continue;
- }
+ if (!schedules) return NULL;
+
+ const cEvent *pe = NULL;
+ const cEvent *p1 = NULL;
+
+ const cList<cEvent>* Events = schedules->Events();
+ if (Start)
+ p1 = Events->Next(Start);
+ else
+ p1 = Events->First();
+
+ time_t tNow = time(NULL);
+ char* searchText = strdup(search);
+
+ int searchStart = 0, searchStop = 0;
+ if (useTime) {
+ searchStart = startTime;
+ searchStop = stopTime;
+ if (searchStop < searchStart)
+ searchStop += 2400;
+ }
+ int minSearchDuration = 0;
+ int maxSearchDuration = 0;
+ if (useDuration) {
+ minSearchDuration = minDuration / 100 * 60 + minDuration % 100;
+ maxSearchDuration = maxDuration / 100 * 60 + maxDuration % 100;
+ }
+
+ if (!useCase)
+ ToLower(searchText);
+
+ for (const cEvent *p = p1; p; p = Events->Next(p)) {
+ if (!p) {
+ break;
+ }
+
+ if (skipRunningEvents && tNow > p->StartTime())
+ continue;
+
+ // ignore events without title
+ if (!p->Title() || !*p->Title())
+ continue;
+
+ if (tNow < p->EndTime() + (inspectTimerMargin ? (MarginStop * 60) : 0)) {
+ if (useTime) {
+ time_t tEvent = p->StartTime();
+ struct tm tmEvent;
+ localtime_r(&tEvent, &tmEvent);
+
+ int eventStart = tmEvent.tm_hour * 100 + tmEvent.tm_min;
+ int eventStart2 = eventStart + 2400;
+ if ((eventStart < searchStart || eventStart > searchStop) &&
+ (eventStart2 < searchStart || eventStart2 > searchStop))
+ continue;
+
+ if (useDayOfWeek) {
+ if (DayOfWeek >= 0) {
+ if ((DayOfWeek != tmEvent.tm_wday || (DayOfWeek == tmEvent.tm_wday && eventStart < searchStart)) &&
+ (!((DayOfWeek + 1) % 7 == tmEvent.tm_wday && eventStart2 < searchStop)))
+ continue;
+ } else {
+ int iFound = 0;
+ for (int i = 0; i < 7; i++) {
+ if ((abs(DayOfWeek) & (int)pow(2, i)) && ((i == tmEvent.tm_wday && eventStart >= searchStart) ||
+ ((i + 1) % 7 == tmEvent.tm_wday && eventStart2 < searchStop))) {
+ iFound = 1;
+ break;
+ }
+ }
+ if (!iFound)
+ continue;
+ }
+ }
}
- }
- if (useDuration)
- {
- int duration = p->Duration()/60;
- if (minSearchDuration > duration || maxSearchDuration < duration)
- continue;
- }
-
- if (!useTime && useDayOfWeek)
- {
- time_t tEvent = p->StartTime();
- struct tm tmEvent;
- localtime_r(&tEvent, &tmEvent);
- if (DayOfWeek >= 0 && DayOfWeek != tmEvent.tm_wday)
- continue;
- if (DayOfWeek < 0)
- {
- int iFound = 0;
- for(int i=0; i<7; i++)
- if (abs(DayOfWeek) & (int)pow(2,i) && i == tmEvent.tm_wday)
- {
- iFound = 1;
- break;
- }
- if (!iFound)
- continue;
+ if (useDuration) {
+ int duration = p->Duration() / 60;
+ if (minSearchDuration > duration || maxSearchDuration < duration)
+ continue;
}
- }
-
- char* szTest = NULL;
- msprintf(&szTest, "%s%s%s%s%s", (useTitle?(p->Title()?p->Title():""):""), (useSubtitle||useDescription)?"~":"",
- (useSubtitle?(p->ShortText()?p->ShortText():""):""),useDescription?"~":"",
- (useDescription?(p->Description()?p->Description():""):""));
-
- if (!useCase)
- ToLower(szTest);
-
- if (szTest && *szTest)
- {
- if (!MatchesSearchMode(szTest, searchText, mode," ,;|~", fuzzyTolerance))
- {
- free(szTest);
- continue;
- }
- }
- if (szTest)
- free(szTest);
-
- if (contentsFilter.size() > 0 && !MatchesContentsFilter(p))
- continue;
-
- if (useExtEPGInfo && !MatchesExtEPGInfo(p))
- continue;
- pe=p;
- break;
- }
- }
- free(searchText);
- return pe;
+
+ if (!useTime && useDayOfWeek) {
+ time_t tEvent = p->StartTime();
+ struct tm tmEvent;
+ localtime_r(&tEvent, &tmEvent);
+ if (DayOfWeek >= 0 && DayOfWeek != tmEvent.tm_wday)
+ continue;
+ if (DayOfWeek < 0) {
+ int iFound = 0;
+ for (int i = 0; i < 7; i++)
+ if (abs(DayOfWeek) & (int)pow(2, i) && i == tmEvent.tm_wday) {
+ iFound = 1;
+ break;
+ }
+ if (!iFound)
+ continue;
+ }
+ }
+
+ char* szTest = NULL;
+ msprintf(&szTest, "%s%s%s%s%s", (useTitle ? (p->Title() ? p->Title() : "") : ""), (useSubtitle || useDescription) ? "~" : "",
+ (useSubtitle ? (p->ShortText() ? p->ShortText() : "") : ""), useDescription ? "~" : "",
+ (useDescription ? (p->Description() ? p->Description() : "") : ""));
+
+ if (!useCase)
+ ToLower(szTest);
+
+ if (szTest && *szTest) {
+ if (!MatchesSearchMode(szTest, searchText, mode, " ,;|~", fuzzyTolerance)) {
+ free(szTest);
+ continue;
+ }
+ }
+ if (szTest)
+ free(szTest);
+
+ if (contentsFilter.size() > 0 && !MatchesContentsFilter(p))
+ continue;
+
+ if (useExtEPGInfo && !MatchesExtEPGInfo(p))
+ continue;
+ pe = p;
+ break;
+ }
+ }
+ free(searchText);
+ return pe;
}
// returns a pointer array to the matching search results
cSearchResults* cSearchExt::Run(int PayTVMode, bool inspectTimerMargin, int evalLimitMins, cSearchResults* pPrevResults, bool suppressRepeatCheck)
{
- LogFile.Log(3,"start search for search timer '%s'", search);
-
- bool noPayTV = false;
- if (PayTVMode == -1) // use search's setting
- noPayTV = (useChannel == 3);
- else
- noPayTV = (PayTVMode == 1);
-
- time_t tNow=time(NULL);
- cSearchResults* pSearchResults = pPrevResults;
- cSearchResults* pBlacklistResults = GetBlacklistEvents(inspectTimerMargin?MarginStop:0);
-
- {
- LOCK_CHANNELS_READ;
- LOCK_SCHEDULES_READ;
-
- int counter = 0;
- const cSchedule *Schedule = Schedules->First();
- while (Schedule) {
- const cChannel* channel = Channels->GetByChannelID(Schedule->ChannelID(),true,true);
- if (!channel)
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
-
- if (useChannel == 1 && channelMin && channelMax)
- {
- if (channelMin->Number() > channel->Number() || channelMax->Number() < channel->Number())
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
- }
- if (useChannel == 2 && channelGroup)
- {
- cChannelGroup* group = ChannelGroups.GetGroupByName(channelGroup);
- if (!group || !group->ChannelInGroup(channel))
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
- }
+ LogFile.Log(3, "start search for search timer '%s'", search);
- if (useChannel == 3 && noPayTV)
- {
- if (channel->Ca() >= CA_ENCRYPTED_MIN)
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
- }
+ bool noPayTV = false;
+ if (PayTVMode == -1) // use search's setting
+ noPayTV = (useChannel == 3);
+ else
+ noPayTV = (PayTVMode == 1);
- if (noPayTV) // no paytv
- {
- if (channel->Ca() >= CA_ENCRYPTED_MIN)
- {
- Schedule = Schedules->Next(Schedule);
- continue;
- }
- }
-
- const cEvent *pPrevEvent = NULL;
- do {
- const cEvent* event = GetEventBySearchExt(Schedule, pPrevEvent,inspectTimerMargin);
- pPrevEvent = event;
- if (evalLimitMins && event) // limit evaluation to now + limit
- {
- if (tNow + evalLimitMins*60 <= event->EndTime())
- break;
- }
- if (event && Channels->GetByChannelID(event->ChannelID(),true,true))
- {
- if (pBlacklistResults && pBlacklistResults->Lookup(event))
- {
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d): matches blacklist", event->Title()?event->Title():"no title", event->ShortText()?event->ShortText():"no subtitle", GETDATESTRING(event), GETTIMESTRING(event), ChannelNrFromEvent(event));
- continue;
+ time_t tNow = time(NULL);
+ cSearchResults* pSearchResults = pPrevResults;
+ cSearchResults* pBlacklistResults = GetBlacklistEvents(inspectTimerMargin ? MarginStop : 0);
+
+ {
+ LOCK_CHANNELS_READ;
+ LOCK_SCHEDULES_READ;
+
+ int counter = 0;
+ const cSchedule *Schedule = Schedules->First();
+ while (Schedule) {
+ const cChannel* channel = Channels->GetByChannelID(Schedule->ChannelID(), true, true);
+ if (!channel) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
+
+ if (useChannel == 1 && channelMin && channelMax) {
+ if (channelMin->Number() > channel->Number() || channelMax->Number() < channel->Number()) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
+ }
+ if (useChannel == 2 && channelGroup) {
+ cChannelGroup* group = ChannelGroups.GetGroupByName(channelGroup);
+ if (!group || !group->ChannelInGroup(channel)) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
}
- if (!pSearchResults) pSearchResults = new cSearchResults;
- pSearchResults->Add(new cSearchResult(event, this));
- counter++;
- }
- } while(pPrevEvent);
- Schedule = Schedules->Next(Schedule);
- }
- LogFile.Log(3,"found %d event(s) for search timer '%s'", counter, search);
- } // Give up locks
-
- if (pBlacklistResults) delete pBlacklistResults;
-
- if (useAsSearchTimer && avoidRepeats && pSearchResults && !suppressRepeatCheck)
- {
- pSearchResults->SortBy(CompareEventTime); // sort before checking repeats to make sure the first event is selected
- CheckRepeatTimers(pSearchResults);
- }
-
- skipRunningEvents = false;
- return pSearchResults;
+
+ if (useChannel == 3 && noPayTV) {
+ if (channel->Ca() >= CA_ENCRYPTED_MIN) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
+ }
+
+ if (noPayTV) { // no paytv
+ if (channel->Ca() >= CA_ENCRYPTED_MIN) {
+ Schedule = Schedules->Next(Schedule);
+ continue;
+ }
+ }
+
+ const cEvent *pPrevEvent = NULL;
+ do {
+ const cEvent* event = GetEventBySearchExt(Schedule, pPrevEvent, inspectTimerMargin);
+ pPrevEvent = event;
+ if (evalLimitMins && event) { // limit evaluation to now + limit
+ if (tNow + evalLimitMins * 60 <= event->EndTime())
+ break;
+ }
+ if (event && Channels->GetByChannelID(event->ChannelID(), true, true)) {
+ if (pBlacklistResults && pBlacklistResults->Lookup(event)) {
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d): matches blacklist", event->Title() ? event->Title() : "no title", event->ShortText() ? event->ShortText() : "no subtitle", GETDATESTRING(event), GETTIMESTRING(event), ChannelNrFromEvent(event));
+ continue;
+ }
+ if (!pSearchResults) pSearchResults = new cSearchResults;
+ pSearchResults->Add(new cSearchResult(event, this));
+ counter++;
+ }
+ } while (pPrevEvent);
+ Schedule = Schedules->Next(Schedule);
+ }
+ LogFile.Log(3, "found %d event(s) for search timer '%s'", counter, search);
+ } // Give up locks
+
+ if (pBlacklistResults) delete pBlacklistResults;
+
+ if (useAsSearchTimer && avoidRepeats && pSearchResults && !suppressRepeatCheck) {
+ pSearchResults->SortBy(CompareEventTime); // sort before checking repeats to make sure the first event is selected
+ CheckRepeatTimers(pSearchResults);
+ }
+
+ skipRunningEvents = false;
+ return pSearchResults;
}
cSearchResults* cSearchExt::GetBlacklistEvents(int MarginStop)
{
- if (blacklistMode == blacklistsNone) return NULL;
-
- cMutexLock BlacklistLock(&Blacklists);
- cSearchResults* blacklistEvents = NULL;
- if (blacklistMode == blacklistsOnlyGlobal)
- {
- cBlacklist* tmpblacklist = Blacklists.First();
- while(tmpblacklist)
- {
- if (tmpblacklist->isGlobal)
- blacklistEvents = tmpblacklist->Run(blacklistEvents, MarginStop);
- tmpblacklist = Blacklists.Next(tmpblacklist);
- }
- }
- if (blacklistMode == blacklistsAll)
- {
- cBlacklist* tmpblacklist = Blacklists.First();
- while(tmpblacklist)
- {
- blacklistEvents = tmpblacklist->Run(blacklistEvents, MarginStop);
- tmpblacklist = Blacklists.Next(tmpblacklist);
- }
- }
- if (blacklistMode == blacklistsSelection)
- {
- cBlacklistObject* tmpblacklistObj = blacklists.First();
- while(tmpblacklistObj)
- {
- blacklistEvents = tmpblacklistObj->blacklist->Run(blacklistEvents, MarginStop);
- tmpblacklistObj = blacklists.Next(tmpblacklistObj);
- }
- }
- return blacklistEvents;
+ if (blacklistMode == blacklistsNone) return NULL;
+
+ cMutexLock BlacklistLock(&Blacklists);
+ cSearchResults* blacklistEvents = NULL;
+ if (blacklistMode == blacklistsOnlyGlobal) {
+ cBlacklist* tmpblacklist = Blacklists.First();
+ while (tmpblacklist) {
+ if (tmpblacklist->isGlobal)
+ blacklistEvents = tmpblacklist->Run(blacklistEvents, MarginStop);
+ tmpblacklist = Blacklists.Next(tmpblacklist);
+ }
+ }
+ if (blacklistMode == blacklistsAll) {
+ cBlacklist* tmpblacklist = Blacklists.First();
+ while (tmpblacklist) {
+ blacklistEvents = tmpblacklist->Run(blacklistEvents, MarginStop);
+ tmpblacklist = Blacklists.Next(tmpblacklist);
+ }
+ }
+ if (blacklistMode == blacklistsSelection) {
+ cBlacklistObject* tmpblacklistObj = blacklists.First();
+ while (tmpblacklistObj) {
+ blacklistEvents = tmpblacklistObj->blacklist->Run(blacklistEvents, MarginStop);
+ tmpblacklistObj = blacklists.Next(tmpblacklistObj);
+ }
+ }
+ return blacklistEvents;
}
void cSearchExt::CheckRepeatTimers(cSearchResults* pResults)
{
- if (!pResults)
- return;
- if (avoidRepeats == 0)
- return;
-
- LogFile.Log(2,"analysing repeats for search timer '%s'...", search);
- if ((action != searchTimerActionRecord) && (action != searchTimerActionInactiveRecord))
- {
- LogFile.Log(3,"search timer not set to 'record', so skip all");
- return;
- }
-
- cSearchResult* pResultObj = NULL;
- for (pResultObj = pResults->First(); pResultObj; pResultObj = pResults->Next(pResultObj))
- {
- if ((action != searchTimerActionRecord) && (action != searchTimerActionInactiveRecord)) // only announce if there is no timer for the event
- {
- pResultObj->needsTimer = false;
- continue;
- }
-
- const cEvent* pEvent = pResultObj->event;
- // check if this event was already recorded
- int records = 0;
- cRecDone* firstRec = NULL;
- LogFile.Log(3,"get count recordings with %d%% match", compareSummaryMatchInPercent);
- records = RecsDone.GetCountRecordings(pEvent, this, &firstRec, compareSummaryMatchInPercent);
- LogFile.Log(3,"recordings: %d", records);
-
- if (records > allowedRepeats) // already recorded
- {
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d): already recorded %d equal event(s)", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), records);
- pResultObj->needsTimer = false; // first assume we need no timer
- continue;
- }
-
- int plannedTimers = 0;
- LogFile.Log(3,"get planned recordings");
- cSearchResult* pFirstResultMatching = NULL;
- // check other results, if they are already planned for equal events
- for (cSearchResult* pResultObjP = pResults->First(); pResultObjP; pResultObjP = pResults->Next(pResultObjP))
- {
- if (pResultObj == pResultObjP) break;
-
- const cEvent* pEventP = pResultObjP->event;
- if (!pEventP) continue;
-
- if (!pResultObjP->needsTimer) continue;
-
- if (EventsMatch(pEvent, pEventP, compareTitle, compareSubtitle, compareSummary, compareDate, catvaluesAvoidRepeat, compareSummaryMatchInPercent))
- {
- if (!pFirstResultMatching) pFirstResultMatching = pResultObjP;
- plannedTimers++;
- }
- }
- LogFile.Log(3,"planned: %d", plannedTimers);
-
- if (plannedTimers + records > allowedRepeats)
- {
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d): events planned(%d), recorded(%d), allowed(%d)", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), plannedTimers, records, allowedRepeats);
- pResultObj->needsTimer = false;
- continue;
- }
- else if (allowedRepeats > 0 && repeatsWithinDays > 0) // if we only allow repeats with in a given range
- {
- if (firstRec) // already recorded, check for allowed repeat within days
- {
- if (firstRec->startTime > pEvent->StartTime() - pEvent->Duration()) // no repeat
- {
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d); no repeat for event already recorded at %s, channel %d", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), DAYDATETIME(firstRec->startTime), firstRec->ChannelNr());
- pResultObj->needsTimer = false;
- continue;
+ if (!pResults)
+ return;
+ if (avoidRepeats == 0)
+ return;
+
+ LogFile.Log(2, "analysing repeats for search timer '%s'...", search);
+ if ((action != searchTimerActionRecord) && (action != searchTimerActionInactiveRecord)) {
+ LogFile.Log(3, "search timer not set to 'record', so skip all");
+ return;
+ }
+
+ cSearchResult* pResultObj = NULL;
+ for (pResultObj = pResults->First(); pResultObj; pResultObj = pResults->Next(pResultObj)) {
+ if ((action != searchTimerActionRecord) && (action != searchTimerActionInactiveRecord)) { // only announce if there is no timer for the event
+ pResultObj->needsTimer = false;
+ continue;
+ }
+
+ const cEvent* pEvent = pResultObj->event;
+ // check if this event was already recorded
+ int records = 0;
+ cRecDone* firstRec = NULL;
+ LogFile.Log(3, "get count recordings with %d%% match", compareSummaryMatchInPercent);
+ records = RecsDone.GetCountRecordings(pEvent, this, &firstRec, compareSummaryMatchInPercent);
+ LogFile.Log(3, "recordings: %d", records);
+
+ if (records > allowedRepeats) { // already recorded
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d): already recorded %d equal event(s)", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), records);
+ pResultObj->needsTimer = false; // first assume we need no timer
+ continue;
+ }
+
+ int plannedTimers = 0;
+ LogFile.Log(3, "get planned recordings");
+ cSearchResult* pFirstResultMatching = NULL;
+ // check other results, if they are already planned for equal events
+ for (cSearchResult* pResultObjP = pResults->First(); pResultObjP; pResultObjP = pResults->Next(pResultObjP)) {
+ if (pResultObj == pResultObjP) break;
+
+ const cEvent* pEventP = pResultObjP->event;
+ if (!pEventP) continue;
+
+ if (!pResultObjP->needsTimer) continue;
+
+ if (EventsMatch(pEvent, pEventP, compareTitle, compareSubtitle, compareSummary, compareDate, catvaluesAvoidRepeat, compareSummaryMatchInPercent)) {
+ if (!pFirstResultMatching) pFirstResultMatching = pResultObjP;
+ plannedTimers++;
}
- int daysFromFirstRec = int(double((pEvent->StartTime() - firstRec->startTime)) / (60*60*24) + 0.5);
- if (daysFromFirstRec > repeatsWithinDays)
- {
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d); first recording at %s is %d days before, limit is %d days", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), DAYDATETIME(firstRec->startTime),daysFromFirstRec, repeatsWithinDays);
- pResultObj->needsTimer = false;
- continue;
+ }
+ LogFile.Log(3, "planned: %d", plannedTimers);
+
+ if (plannedTimers + records > allowedRepeats) {
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d): events planned(%d), recorded(%d), allowed(%d)", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), plannedTimers, records, allowedRepeats);
+ pResultObj->needsTimer = false;
+ continue;
+ } else if (allowedRepeats > 0 && repeatsWithinDays > 0) { // if we only allow repeats with in a given range
+ if (firstRec) { // already recorded, check for allowed repeat within days
+ if (firstRec->startTime > pEvent->StartTime() - pEvent->Duration()) { // no repeat
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d); no repeat for event already recorded at %s, channel %d", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), DAYDATETIME(firstRec->startTime), firstRec->ChannelNr());
+ pResultObj->needsTimer = false;
+ continue;
+ }
+ int daysFromFirstRec = int(double((pEvent->StartTime() - firstRec->startTime)) / (60 * 60 * 24) + 0.5);
+ if (daysFromFirstRec > repeatsWithinDays) {
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d); first recording at %s is %d days before, limit is %d days", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), DAYDATETIME(firstRec->startTime), daysFromFirstRec, repeatsWithinDays);
+ pResultObj->needsTimer = false;
+ continue;
+ }
}
- }
- if (plannedTimers > 0 && pFirstResultMatching)
- {
- const cEvent* pFirst = pFirstResultMatching->event;
- if (pFirst->StartTime() > pEvent->StartTime() - pEvent->Duration()) // no repeat
- {
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d); no repeat for event already recorded at %s - %s, channel %d", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), GETDATESTRING(pFirst), GETTIMESTRING(pFirst), ChannelNrFromEvent(pFirst));
- pResultObj->needsTimer = false;
- continue;
+ if (plannedTimers > 0 && pFirstResultMatching) {
+ const cEvent* pFirst = pFirstResultMatching->event;
+ if (pFirst->StartTime() > pEvent->StartTime() - pEvent->Duration()) { // no repeat
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d); no repeat for event already recorded at %s - %s, channel %d", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), GETDATESTRING(pFirst), GETTIMESTRING(pFirst), ChannelNrFromEvent(pFirst));
+ pResultObj->needsTimer = false;
+ continue;
+ }
+
+ int daysBetween = int(double((pEvent->StartTime() - pFirst->StartTime())) / (60 * 60 * 24) + 0.5);
+ if (daysBetween > repeatsWithinDays) {
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d); first event '%s~%s' (%s - %s) is %d days before, limit is %d days", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), GETDATESTRING(pFirst), GETTIMESTRING(pFirst), daysBetween, repeatsWithinDays);
+ pResultObj->needsTimer = false;
+ continue;
+ }
}
+ }
+ bool dummy;
+ const cTimer* timer = cSearchTimerThread::GetTimer(this, pEvent, dummy);
+ if (timer && !timer->HasFlags(tfActive)) {
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d), existing timer disabled", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ pResultObj->needsTimer = false;
+ continue;
+ } else
+ LogFile.Log(3, "*** planning event '%s~%s' (%s - %s, channel %d) for recording", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
+ }
+ int needsTimer = 0;
+ for (pResultObj = pResults->First(); pResultObj; pResultObj = pResults->Next(pResultObj))
+ if (pResultObj->needsTimer) needsTimer++;
- int daysBetween = int(double((pEvent->StartTime() - pFirst->StartTime())) / (60*60*24) + 0.5);
- if (daysBetween > repeatsWithinDays)
- {
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d); first event '%s~%s' (%s - %s) is %d days before, limit is %d days", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), GETDATESTRING(pFirst), GETTIMESTRING(pFirst),daysBetween, repeatsWithinDays);
- pResultObj->needsTimer = false;
- continue;
- }
- }
- }
- bool dummy;
- const cTimer* timer = cSearchTimerThread::GetTimer(this, pEvent, dummy);
- if (timer && !timer->HasFlags(tfActive))
- {
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d), existing timer disabled", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- pResultObj->needsTimer = false;
- continue;
- }
- else
- LogFile.Log(3,"*** planning event '%s~%s' (%s - %s, channel %d) for recording", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent));
- }
- int needsTimer = 0;
- for (pResultObj = pResults->First(); pResultObj; pResultObj = pResults->Next(pResultObj))
- if (pResultObj->needsTimer) needsTimer++;
-
- LogFile.Log(2,"%d/%d events need a timer for search timer '%s'", needsTimer, pResults->Count(), search);
+ LogFile.Log(2, "%d/%d events need a timer for search timer '%s'", needsTimer, pResults->Count(), search);
}
void cSearchExt::CheckExistingRecordings(cSearchResults* pResults)
{
- if (!pResults)
- return;
-
- LogFile.Log(3,"analysing existing recordings for search timer '%s'...", search);
-
- // how many recordings do we already have?
- int num = GetCountRecordings();
-
- cSearchResult* pResultObj = NULL;
- int remain = pauseOnNrRecordings - num;
- for (pResultObj = pResults->First(); pResultObj; pResultObj = pResults->Next(pResultObj), remain--)
- {
- if (!pResultObj->needsTimer)
- {
- remain++;
- continue; // maybe already disabled because of done feature
- }
- pResultObj->needsTimer = (remain > 0);
- if (remain <= 0)
- {
- const cEvent* pEvent = pResultObj->event;
- LogFile.Log(3,"skip '%s~%s' (%s - %s, channel %d): only %d recordings are allowed", pEvent->Title()?pEvent->Title():"no title", pEvent->ShortText()?pEvent->ShortText():"no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), pauseOnNrRecordings);
- }
- }
+ if (!pResults)
+ return;
+
+ LogFile.Log(3, "analysing existing recordings for search timer '%s'...", search);
+
+ // how many recordings do we already have?
+ int num = GetCountRecordings();
+
+ cSearchResult* pResultObj = NULL;
+ int remain = pauseOnNrRecordings - num;
+ for (pResultObj = pResults->First(); pResultObj; pResultObj = pResults->Next(pResultObj), remain--) {
+ if (!pResultObj->needsTimer) {
+ remain++;
+ continue; // maybe already disabled because of done feature
+ }
+ pResultObj->needsTimer = (remain > 0);
+ if (remain <= 0) {
+ const cEvent* pEvent = pResultObj->event;
+ LogFile.Log(3, "skip '%s~%s' (%s - %s, channel %d): only %d recordings are allowed", pEvent->Title() ? pEvent->Title() : "no title", pEvent->ShortText() ? pEvent->ShortText() : "no subtitle", GETDATESTRING(pEvent), GETTIMESTRING(pEvent), ChannelNrFromEvent(pEvent), pauseOnNrRecordings);
+ }
+ }
}
bool cSearchExt::MatchesExtEPGInfo(const cEvent* e)
{
- if (!e || !e->Description())
- return false;
- cSearchExtCat* SearchExtCat = SearchExtCats.First();
- while (SearchExtCat)
- {
- char* value = NULL;
- int index = SearchExtCats.GetIndexFromID(SearchExtCat->id);
- if (index > -1)
- value = catvalues[index];
- if (value && SearchExtCat->searchmode >= 10 && atol(value) == 0) // numerical value != 0 ?
- value = NULL;
- if (value && *value)
- {
- char* testvalue = GetExtEPGValue(e, SearchExtCat);
- if (!testvalue)
- return (ignoreMissingEPGCats?true:false);
-
- // compare not case sensitive
- char* valueLower = strdup(value);
- ToLower(valueLower);
- ToLower(testvalue);
- if (!MatchesSearchMode(testvalue, valueLower, SearchExtCat->searchmode, ",;|~", fuzzyTolerance))
- {
+ if (!e || !e->Description())
+ return false;
+ cSearchExtCat* SearchExtCat = SearchExtCats.First();
+ while (SearchExtCat) {
+ char* value = NULL;
+ int index = SearchExtCats.GetIndexFromID(SearchExtCat->id);
+ if (index > -1)
+ value = catvalues[index];
+ if (value && SearchExtCat->searchmode >= 10 && atol(value) == 0) // numerical value != 0 ?
+ value = NULL;
+ if (value && *value) {
+ char* testvalue = GetExtEPGValue(e, SearchExtCat);
+ if (!testvalue)
+ return (ignoreMissingEPGCats ? true : false);
+
+ // compare not case sensitive
+ char* valueLower = strdup(value);
+ ToLower(valueLower);
+ ToLower(testvalue);
+ if (!MatchesSearchMode(testvalue, valueLower, SearchExtCat->searchmode, ",;|~", fuzzyTolerance)) {
+ free(testvalue);
+ free(valueLower);
+ return false;
+ }
free(testvalue);
free(valueLower);
- return false;
- }
- free(testvalue);
- free(valueLower);
- }
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- }
- return true;
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ }
+ return true;
}
void cSearchExt::OnOffTimers(bool bOn)
{
- LOCK_TIMERS_WRITE;
- for (cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti))
- {
- if (((!bOn && ti->HasFlags(tfActive)) || (bOn && !ti->HasFlags(tfActive))) && TriggeredFromSearchTimerID(ti) == ID)
- ti->OnOff();
- }
+ LOCK_TIMERS_WRITE;
+ for (cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti)) {
+ if (((!bOn && ti->HasFlags(tfActive)) || (bOn && !ti->HasFlags(tfActive))) && TriggeredFromSearchTimerID(ti) == ID)
+ ti->OnOff();
+ }
}
void cSearchExt::DeleteAllTimers()
{
- cList<cTimerObj> DelTimers;
- LOCK_TIMERS_WRITE;
- Timers->SetExplicitModify();
- cTimer *ti = Timers->First();
- while(ti)
- {
- if (!ti->Recording() && TriggeredFromSearchTimerID(ti) == ID)
- {
- cTimer* tiNext = Timers->Next(ti);
- LogFile.iSysLog("deleting timer %s", *ti->ToDescr());
- Timers->Del(ti);
- Timers->SetModified();
- ti = tiNext;
- }
- else
- ti = Timers->Next(ti);
- };
+ cList<cTimerObj> DelTimers;
+ LOCK_TIMERS_WRITE;
+ Timers->SetExplicitModify();
+ cTimer *ti = Timers->First();
+ while (ti) {
+ if (!ti->Recording() && TriggeredFromSearchTimerID(ti) == ID) {
+ cTimer* tiNext = Timers->Next(ti);
+ LogFile.iSysLog("deleting timer %s", *ti->ToDescr());
+ Timers->Del(ti);
+ Timers->SetModified();
+ ti = tiNext;
+ } else
+ ti = Timers->Next(ti);
+ };
}
cTimerObjList* cSearchExt::GetTimerList(cTimerObjList* timerList)
{
- if (!timerList)
- timerList = new cTimerObjList;
-
- LOCK_TIMERS_READ;
- for (const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti))
- {
- if (TriggeredFromSearchTimerID(ti) == ID)
- {
- // check if already in list
- bool found = false;
- for (cTimerObj *tObj = timerList->First(); tObj; tObj = timerList->Next(tObj))
- {
- if (tObj->timer == ti)
- {
- found = true;
- break;
+ if (!timerList)
+ timerList = new cTimerObjList;
+
+ LOCK_TIMERS_READ;
+ for (const cTimer *ti = Timers->First(); ti; ti = Timers->Next(ti)) {
+ if (TriggeredFromSearchTimerID(ti) == ID) {
+ // check if already in list
+ bool found = false;
+ for (cTimerObj *tObj = timerList->First(); tObj; tObj = timerList->Next(tObj)) {
+ if (tObj->timer == ti) {
+ found = true;
+ break;
+ }
}
- }
- if (!found)
- timerList->Add(new cTimerObj(ti));
- }
- }
- return timerList;
+ if (!found)
+ timerList->Add(new cTimerObj(ti));
+ }
+ }
+ return timerList;
}
// counts the currently existent recordings triggered by this search timer
int cSearchExt::GetCountRecordings()
{
- int countRecs = 0;
-
- LOCK_RECORDINGS_READ;
- for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording))
- {
- if (recording->IsEdited()) continue; // ignore recordings edited
- if (!recording->Info()) continue;
- char* searchID = GetAuxValue(recording, "s-id");
-
- if (!searchID) continue;
- if (ID == atoi(searchID))
- countRecs++;
- free(searchID);
- }
- LogFile.Log(3, "found %d recordings for search '%s'", countRecs, search);
- return countRecs;
+ int countRecs = 0;
+
+ LOCK_RECORDINGS_READ;
+ for (const cRecording *recording = Recordings->First(); recording; recording = Recordings->Next(recording)) {
+ if (recording->IsEdited()) continue; // ignore recordings edited
+ if (!recording->Info()) continue;
+ char* searchID = GetAuxValue(recording, "s-id");
+
+ if (!searchID) continue;
+ if (ID == atoi(searchID))
+ countRecs++;
+ free(searchID);
+ }
+ LogFile.Log(3, "found %d recordings for search '%s'", countRecs, search);
+ return countRecs;
}
bool cSearchExt::IsActiveAt(time_t t)
{
- if (useAsSearchTimer == 0) return false;
- if (useAsSearchTimer == 2)
- {
- if (useAsSearchTimerFrom > 0 && t < useAsSearchTimerFrom) return false;
- if (useAsSearchTimerTil > 0 && t > useAsSearchTimerTil) return false;
+ if (useAsSearchTimer == 0) return false;
+ if (useAsSearchTimer == 2) {
+ if (useAsSearchTimerFrom > 0 && t < useAsSearchTimerFrom) return false;
+ if (useAsSearchTimerTil > 0 && t > useAsSearchTimerTil) return false;
}
- return true;
+ return true;
}
bool cSearchExt::HasContent(int contentID)
{
- for(unsigned int i=0; i<contentsFilter.size();i+=2)
- {
- std::string hexContentID = contentsFilter.substr(i,2);
- if(hexContentID.size()!=2) return false;
- std::istringstream iss(hexContentID);
- int tmpContentID =0;
- if(!(iss>>std::noshowbase>>std::hex>>tmpContentID)) return false;
- if (contentID == tmpContentID) return true;
- }
- return false;
+ for (unsigned int i = 0; i < contentsFilter.size(); i += 2) {
+ std::string hexContentID = contentsFilter.substr(i, 2);
+ if (hexContentID.size() != 2) return false;
+ std::istringstream iss(hexContentID);
+ int tmpContentID = 0;
+ if (!(iss >> std::noshowbase >> std::hex >> tmpContentID)) return false;
+ if (contentID == tmpContentID) return true;
+ }
+ return false;
}
void cSearchExt::SetContentFilter(int* contentStringsFlags)
{
- // create the hex array of content descriptor IDs
- string tmp;
- contentsFilter = "";
- for(unsigned int i=0; contentStringsFlags && i<=CONTENT_DESCRIPTOR_MAX; i++)
- {
- if (contentStringsFlags[i])
- {
- std::ostringstream oss;
- oss<<std::hex<<std::noshowbase<<i;
- contentsFilter += oss.str();
- }
+ // create the hex array of content descriptor IDs
+ string tmp;
+ contentsFilter = "";
+ for (unsigned int i = 0; contentStringsFlags && i <= CONTENT_DESCRIPTOR_MAX; i++) {
+ if (contentStringsFlags[i]) {
+ std::ostringstream oss;
+ oss << std::hex << std::noshowbase << i;
+ contentsFilter += oss.str();
+ }
}
}
bool cSearchExt::MatchesContentsFilter(const cEvent* e)
{
- if (!e) return false;
- // check if each content filter ID is contained in the events descriptors
- for(unsigned int i=0; i<contentsFilter.size();i+=2)
- {
- std::string hexContentID = contentsFilter.substr(i,2);
- if(hexContentID.size()!=2) return false;
- std::istringstream iss(hexContentID);
- int searchContentID =0;
- if(!(iss>>std::hex>>searchContentID)) return false;
- int c=0, eventContentID=0;
- bool found = false;
- while((eventContentID=e->Contents(c++)) > 0)
- if (eventContentID == searchContentID)
- {
- found = true;
- break;
- }
- if (!found) return false;
- }
- return true;
+ if (!e) return false;
+ // check if each content filter ID is contained in the events descriptors
+ for (unsigned int i = 0; i < contentsFilter.size(); i += 2) {
+ std::string hexContentID = contentsFilter.substr(i, 2);
+ if (hexContentID.size() != 2) return false;
+ std::istringstream iss(hexContentID);
+ int searchContentID = 0;
+ if (!(iss >> std::hex >> searchContentID)) return false;
+ int c = 0, eventContentID = 0;
+ bool found = false;
+ while ((eventContentID = e->Contents(c++)) > 0)
+ if (eventContentID == searchContentID) {
+ found = true;
+ break;
+ }
+ if (!found) return false;
+ }
+ return true;
}
// -- cSearchExts ----------------------------------------------------------------
bool cSearchExts::Load(const char *FileName)
{
- cMutexLock SearchExtsLock(this);
- Clear();
- if (FileName) {
- free(fileName);
- fileName = strdup(FileName);
- }
-
- bool result = true;
- if (fileName && access(fileName, F_OK) == 0) {
- LogFile.iSysLog("loading %s", fileName);
- FILE *f = fopen(fileName, "r");
- if (f) {
- int line = 0;
- char buffer[MAXPARSEBUFFER];
- result = true;
- while (fgets(buffer, sizeof(buffer), f) > 0) {
- line++;
- char *p = strchr(buffer, '#');
- if (p == buffer) *p = 0;
-
- stripspace(buffer);
- if (!isempty(buffer)) {
- cSearchExt* search = new cSearchExt;
- if (search->Parse(buffer))
- Add(search);
- else {
- LogFile.eSysLog("error in '%s', line %d\n", fileName, line);
- delete search;
- result = false;
- break;
- }
+ cMutexLock SearchExtsLock(this);
+ Clear();
+ if (FileName) {
+ free(fileName);
+ fileName = strdup(FileName);
+ }
+
+ bool result = true;
+ if (fileName && access(fileName, F_OK) == 0) {
+ LogFile.iSysLog("loading %s", fileName);
+ FILE *f = fopen(fileName, "r");
+ if (f) {
+ int line = 0;
+ char buffer[MAXPARSEBUFFER];
+ result = true;
+ while (fgets(buffer, sizeof(buffer), f) > 0) {
+ line++;
+ char *p = strchr(buffer, '#');
+ if (p == buffer) *p = 0;
+
+ stripspace(buffer);
+ if (!isempty(buffer)) {
+ cSearchExt* search = new cSearchExt;
+ if (search->Parse(buffer))
+ Add(search);
+ else {
+ LogFile.eSysLog("error in '%s', line %d\n", fileName, line);
+ delete search;
+ result = false;
+ break;
+ }
+ }
}
- }
- fclose(f);
- }
- else {
- LOG_ERROR_STR(fileName);
- result = false;
- }
- }
-
- if (!result)
- fprintf(stderr, "vdr: error while reading '%s'\n", fileName);
- LogFile.Log(2,"loaded searches from %s (count: %d)", fileName, Count());
- return result;
+ fclose(f);
+ } else {
+ LOG_ERROR_STR(fileName);
+ result = false;
+ }
+ }
+
+ if (!result)
+ fprintf(stderr, "vdr: error while reading '%s'\n", fileName);
+ LogFile.Log(2, "loaded searches from %s (count: %d)", fileName, Count());
+ return result;
}
int cSearchExts::GetNewID()
{
- cMutexLock SearchExtsLock(this);
- int newID = -1;
- cSearchExt *l = (cSearchExt *)First();
- while (l) {
- newID = std::max(newID, l->ID);
- l = (cSearchExt *)l->Next();
- }
- return newID+1;
+ cMutexLock SearchExtsLock(this);
+ int newID = -1;
+ cSearchExt *l = (cSearchExt *)First();
+ while (l) {
+ newID = std::max(newID, l->ID);
+ l = (cSearchExt *)l->Next();
+ }
+ return newID + 1;
}
void cSearchExts::Update(void)
{
- cMutexLock SearchExtsLock(this);
- cSearchExt *l = (cSearchExt *)First();
- while (l) {
- // check if ID is set
- if (l->ID == -1)
- l->ID = GetNewID();
- l = (cSearchExt *)l->Next();
- }
+ cMutexLock SearchExtsLock(this);
+ cSearchExt *l = (cSearchExt *)First();
+ while (l) {
+ // check if ID is set
+ if (l->ID == -1)
+ l->ID = GetNewID();
+ l = (cSearchExt *)l->Next();
+ }
}
bool cSearchExts::Save(void)
{
- cMutexLock SearchExtsLock(this);
- bool result = true;
- cSearchExt *l = (cSearchExt *)this->First();
- cSafeFile f(fileName);
- if (f.Open()) {
- while (l) {
- if (!l->Save(f)) {
+ cMutexLock SearchExtsLock(this);
+ bool result = true;
+ cSearchExt *l = (cSearchExt *)this->First();
+ cSafeFile f(fileName);
+ if (f.Open()) {
+ while (l) {
+ if (!l->Save(f)) {
+ result = false;
+ break;
+ }
+ l = (cSearchExt *)l->Next();
+ }
+ if (!f.Close())
result = false;
- break;
- }
- l = (cSearchExt *)l->Next();
- }
- if (!f.Close())
- result = false;
- }
- else
- result = false;
- return result;
+ } else
+ result = false;
+ return result;
}
cSearchExt* cSearchExts::GetSearchFromID(int ID)
{
- if (ID == -1)
- return NULL;
- cMutexLock SearchExtsLock(this);
- cSearchExt *l = (cSearchExt *)First();
- while (l) {
- if (l->ID == ID)
- return l;
- l = (cSearchExt *)l->Next();
- }
- return NULL;
+ if (ID == -1)
+ return NULL;
+ cMutexLock SearchExtsLock(this);
+ cSearchExt *l = (cSearchExt *)First();
+ while (l) {
+ if (l->ID == ID)
+ return l;
+ l = (cSearchExt *)l->Next();
+ }
+ return NULL;
}
void cSearchExts::RemoveBlacklistID(int ID)
{
- bool changed = false;
- cMutexLock SearchExtsLock(this);
- cSearchExt *l = (cSearchExt *)First();
- while (l)
- {
- cBlacklistObject* blacklistObj = l->blacklists.First();
- while(blacklistObj)
- {
- cBlacklistObject* blacklistObjNext = l->blacklists.Next(blacklistObj);
- if (blacklistObj->blacklist->ID == ID)
- {
- l->blacklists.Del(blacklistObj);
- changed = true;
- }
- blacklistObj = blacklistObjNext;
- }
- l = (cSearchExt *)l->Next();
- }
- if (changed)
- Save();
+ bool changed = false;
+ cMutexLock SearchExtsLock(this);
+ cSearchExt *l = (cSearchExt *)First();
+ while (l) {
+ cBlacklistObject* blacklistObj = l->blacklists.First();
+ while (blacklistObj) {
+ cBlacklistObject* blacklistObjNext = l->blacklists.Next(blacklistObj);
+ if (blacklistObj->blacklist->ID == ID) {
+ l->blacklists.Del(blacklistObj);
+ changed = true;
+ }
+ blacklistObj = blacklistObjNext;
+ }
+ l = (cSearchExt *)l->Next();
+ }
+ if (changed)
+ Save();
}
bool cSearchExts::Exists(const cSearchExt* SearchExt)
{
- cMutexLock SearchExtsLock(this);
- cSearchExt *l = (cSearchExt *)First();
- while (l)
- {
- if (l == SearchExt)
- return true;
- l = (cSearchExt *)l->Next();
- }
- return false;
+ cMutexLock SearchExtsLock(this);
+ cSearchExt *l = (cSearchExt *)First();
+ while (l) {
+ if (l == SearchExt)
+ return true;
+ l = (cSearchExt *)l->Next();
+ }
+ return false;
}
cSearchExts* cSearchExts::Clone()
{
- cSearchExts* clonedList = new cSearchExts();
-
- cMutexLock SearchExtsLock(this);
- cSearchExt *l = (cSearchExt *)First();
- while (l)
- {
- cSearchExt* clone = new cSearchExt();
- *clone = *l;
- clonedList->Add(clone);
- l = (cSearchExt *)l->Next();
- }
- return clonedList;
+ cSearchExts* clonedList = new cSearchExts();
+
+ cMutexLock SearchExtsLock(this);
+ cSearchExt *l = (cSearchExt *)First();
+ while (l) {
+ cSearchExt* clone = new cSearchExt();
+ *clone = *l;
+ clonedList->Add(clone);
+ l = (cSearchExt *)l->Next();
+ }
+ return clonedList;
}
bool cSearchExts::CheckForAutoDelete(cSearchExt* SearchExt)
{
- if (!SearchExt || SearchExt->delMode == 0) return false;
-
- cRecDone* firstRec = NULL;
- bool delSearch = false;
- int recs = RecsDone.GetTotalCountRecordings(SearchExt, &firstRec);
- if (SearchExt->delMode == 1 && SearchExt->delAfterCountRecs > 0)
- delSearch = recs >= SearchExt->delAfterCountRecs;
- if (SearchExt->delMode == 2 && SearchExt->delAfterDaysOfFirstRec && firstRec)
- delSearch = (time(NULL) - firstRec->startTime) > SearchExt->delAfterDaysOfFirstRec * 24 * 60 * 60;
- if (delSearch)
- {
- int DelID = SearchExt->ID;
- LogFile.Log(1,"auto deleting search '%s' (ID: %d)", SearchExt->search, DelID);
- cMutexLock SearchExtsLock(&SearchExts);
- SearchExts.Del(SearchExt);
- SearchExts.Save();
- RecsDone.RemoveSearchID(DelID);
- }
- return delSearch;
+ if (!SearchExt || SearchExt->delMode == 0) return false;
+
+ cRecDone* firstRec = NULL;
+ bool delSearch = false;
+ int recs = RecsDone.GetTotalCountRecordings(SearchExt, &firstRec);
+ if (SearchExt->delMode == 1 && SearchExt->delAfterCountRecs > 0)
+ delSearch = recs >= SearchExt->delAfterCountRecs;
+ if (SearchExt->delMode == 2 && SearchExt->delAfterDaysOfFirstRec && firstRec)
+ delSearch = (time(NULL) - firstRec->startTime) > SearchExt->delAfterDaysOfFirstRec * 24 * 60 * 60;
+ if (delSearch) {
+ int DelID = SearchExt->ID;
+ LogFile.Log(1, "auto deleting search '%s' (ID: %d)", SearchExt->search, DelID);
+ cMutexLock SearchExtsLock(&SearchExts);
+ SearchExts.Del(SearchExt);
+ SearchExts.Save();
+ RecsDone.RemoveSearchID(DelID);
+ }
+ return delSearch;
}
void cSearchExts::SortBy(int(*compar)(const void *, const void *))
{
- int n = Count();
- cListObject *a[n];
- cListObject *object = objects;
- int i = 0;
- while (object && i < n) {
- a[i++] = object;
- object = object->Next();
- }
- qsort(a, n, sizeof(cListObject *), compar);
- objects = lastObject = NULL;
- for (i = 0; i < n; i++) {
- a[i]->Unlink();
- count--;
- Add(a[i]);
- }
+ int n = Count();
+ cListObject *a[n];
+ cListObject *object = objects;
+ int i = 0;
+ while (object && i < n) {
+ a[i++] = object;
+ object = object->Next();
+ }
+ qsort(a, n, sizeof(cListObject *), compar);
+ objects = lastObject = NULL;
+ for (i = 0; i < n; i++) {
+ a[i]->Unlink();
+ count--;
+ Add(a[i]);
+ }
}
cSearchResult::cSearchResult(const cEvent* Event, int searchID) : event(Event), blacklist(NULL), needsTimer(true)
{
- search = SearchExts.GetSearchFromID(searchID);
+ search = SearchExts.GetSearchFromID(searchID);
}
diff --git a/epgsearchext.h b/epgsearchext.h
index 50758f5..43e559d 100644
--- a/epgsearchext.h
+++ b/epgsearchext.h
@@ -37,17 +37,15 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#define MAXOSDTEXTWIDTH 45
-typedef enum
-{
+typedef enum {
blacklistsOnlyGlobal = 0,
blacklistsSelection,
blacklistsAll,
blacklistsNone
} blacklistModes;
-typedef enum
-{
- searchTimerActionRecord=0,
+typedef enum {
+ searchTimerActionRecord = 0,
searchTimerActionAnnounceViaOSD,
searchTimerActionSwitchOnly,
searchTimerActionAnnounceAndSwitch,
@@ -58,8 +56,9 @@ typedef enum
class cSearchExt;
class cBlacklist;
-class cSearchResult : public cListObject {
- public:
+class cSearchResult : public cListObject
+{
+public:
const cEvent* event;
const cSearchExt* search;
const cBlacklist* blacklist;
@@ -69,38 +68,36 @@ class cSearchResult : public cListObject {
cSearchResult(const cEvent* Event, const cBlacklist* Blacklist) : event(Event), search(NULL), blacklist(Blacklist), needsTimer(true) {}
};
-class cSearchResults : public cList<cSearchResult> {
- public:
-
- void SortBy(int(*compar)(const void *, const void *))
- {
- int n = Count();
- cListObject *a[n];
- cListObject *object = objects;
- int i = 0;
- while (object && i < n) {
- a[i++] = object;
- object = object->Next();
- }
- qsort(a, n, sizeof(cListObject *), compar);
- objects = lastObject = NULL;
- for (i = 0; i < n; i++) {
- a[i]->Unlink();
- count--;
- Add(a[i]);
- }
- }
- bool Lookup(const cEvent* Event)
- {
- cSearchResult* r = First();
- while(r)
- {
- if (r->event == Event)
- return true;
- r = Next(r);
- }
- return false;
- }
+class cSearchResults : public cList<cSearchResult>
+{
+public:
+
+ void SortBy(int(*compar)(const void *, const void *)) {
+ int n = Count();
+ cListObject *a[n];
+ cListObject *object = objects;
+ int i = 0;
+ while (object && i < n) {
+ a[i++] = object;
+ object = object->Next();
+ }
+ qsort(a, n, sizeof(cListObject *), compar);
+ objects = lastObject = NULL;
+ for (i = 0; i < n; i++) {
+ a[i]->Unlink();
+ count--;
+ Add(a[i]);
+ }
+ }
+ bool Lookup(const cEvent* Event) {
+ cSearchResult* r = First();
+ while (r) {
+ if (r->event == Event)
+ return true;
+ r = Next(r);
+ }
+ return false;
+ }
};
@@ -108,120 +105,141 @@ class cBlacklistObject;
class cTimerObj;
class cTimerObjList;
-class cSearchExt : public cListObject {
- friend class cMenuEditSearchExt;
- friend class cMenuEditTemplate;
+class cSearchExt : public cListObject
+{
+ friend class cMenuEditSearchExt;
+ friend class cMenuEditTemplate;
public:
- int ID;
- char search[MaxFileName];
- int options;
- int useTime;
- int startTime;
- int stopTime;
- int useChannel;
- int useCase;
- int mode;
- int useTitle;
- int useSubtitle;
- int useDescription;
- int useDuration;
- int minDuration;
- int maxDuration;
- int useAsSearchTimer;
- int useDayOfWeek;
- int DayOfWeek;
- int useEpisode;
- char directory[MaxFileName];
- int Priority;
- int Lifetime;
- int MarginStart;
- int MarginStop;
- int useVPS;
- int action;
- std::string contentsFilter;
- int useExtEPGInfo;
- char** catvalues;
- const cChannel *channelMin;
- const cChannel *channelMax;
- char* channelGroup;
- int avoidRepeats;
- int compareTitle;
- int compareSubtitle;
- int compareSummary;
- int compareSummaryMatchInPercent;
- int compareDate;
- int allowedRepeats;
- unsigned long catvaluesAvoidRepeat;
- int repeatsWithinDays;
- int delAfterDays;
- int recordingsKeep;
- int switchMinsBefore;
- int pauseOnNrRecordings;
- int blacklistMode;
- cList<cBlacklistObject> blacklists;
- int fuzzyTolerance;
- int useInFavorites;
- int menuTemplate;
- int delMode;
- int delAfterCountRecs;
- int delAfterDaysOfFirstRec;
- time_t useAsSearchTimerFrom;
- time_t useAsSearchTimerTil;
- int ignoreMissingEPGCats;
- int unmuteSoundOnSwitch;
- bool skipRunningEvents;
- static char *buffer;
+ int ID;
+ char search[MaxFileName];
+ int options;
+ int useTime;
+ int startTime;
+ int stopTime;
+ int useChannel;
+ int useCase;
+ int mode;
+ int useTitle;
+ int useSubtitle;
+ int useDescription;
+ int useDuration;
+ int minDuration;
+ int maxDuration;
+ int useAsSearchTimer;
+ int useDayOfWeek;
+ int DayOfWeek;
+ int useEpisode;
+ char directory[MaxFileName];
+ int Priority;
+ int Lifetime;
+ int MarginStart;
+ int MarginStop;
+ int useVPS;
+ int action;
+ std::string contentsFilter;
+ int useExtEPGInfo;
+ char** catvalues;
+ const cChannel *channelMin;
+ const cChannel *channelMax;
+ char* channelGroup;
+ int avoidRepeats;
+ int compareTitle;
+ int compareSubtitle;
+ int compareSummary;
+ int compareSummaryMatchInPercent;
+ int compareDate;
+ int allowedRepeats;
+ unsigned long catvaluesAvoidRepeat;
+ int repeatsWithinDays;
+ int delAfterDays;
+ int recordingsKeep;
+ int switchMinsBefore;
+ int pauseOnNrRecordings;
+ int blacklistMode;
+ cList<cBlacklistObject> blacklists;
+ int fuzzyTolerance;
+ int useInFavorites;
+ int menuTemplate;
+ int delMode;
+ int delAfterCountRecs;
+ int delAfterDaysOfFirstRec;
+ time_t useAsSearchTimerFrom;
+ time_t useAsSearchTimerTil;
+ int ignoreMissingEPGCats;
+ int unmuteSoundOnSwitch;
+ bool skipRunningEvents;
+ static char *buffer;
public:
- cSearchExt(void);
- virtual ~cSearchExt(void);
- cSearchExt& operator= (const cSearchExt &SearchExt);
- virtual bool operator< (const cListObject &ListObject);
-
- const char *Search(void) { return search; }
- int Options(void) { return options; }
- int StartTime(void) { return startTime; }
- int StopTime(void) { return stopTime; }
- int UseChannel(void) { return useChannel; }
- const cChannel *ChannelMin(void) { return channelMin; }
- const cChannel *ChannelMax(void) { return channelMax; }
- const cEvent * GetEventBySearchExt(const cSchedule *schedules, const cEvent *Start, bool inspectTimerMargin = false);
- bool MatchesExtEPGInfo(const cEvent* e);
- const char *ToText();
- bool Parse(const char *s);
- bool ParseExtEPGValues(const char *s);
- bool ParseExtEPGEntry(const char *s);
- bool ParseBlacklistIDs(const char *s);
- bool Save(FILE *f);
- char* BuildFile(const cEvent* pEvent) const;
- cSearchResults* Run(int PayTVMode = -1, bool inspectTimerMargin = false, int evalLimitMins = 0, cSearchResults* pPrevResults = NULL, bool suppressRepeatCheck = false);
- void CheckRepeatTimers(cSearchResults* pResults);
- void CheckExistingRecordings(cSearchResults* pResults);
- void CopyFromTemplate(const cSearchExt* templ, bool ignoreChannelSettings = false);
- cSearchResults* GetBlacklistEvents(int MarginStop = 0);
- void OnOffTimers(bool);
- void DeleteAllTimers();
- cTimerObjList* GetTimerList(cTimerObjList* timerList);
- int GetCountRecordings();
- bool IsActiveAt(time_t t);
- bool HasContent(int contentID);
- void SetContentFilter(int* contentStringsFlags);
- bool MatchesContentsFilter(const cEvent* e);
+ cSearchExt(void);
+ virtual ~cSearchExt(void);
+ cSearchExt& operator= (const cSearchExt &SearchExt);
+ virtual bool operator< (const cListObject &ListObject);
+
+ const char *Search(void) {
+ return search;
+ }
+ int Options(void) {
+ return options;
+ }
+ int StartTime(void) {
+ return startTime;
+ }
+ int StopTime(void) {
+ return stopTime;
+ }
+ int UseChannel(void) {
+ return useChannel;
+ }
+ const cChannel *ChannelMin(void) {
+ return channelMin;
+ }
+ const cChannel *ChannelMax(void) {
+ return channelMax;
+ }
+ const cEvent * GetEventBySearchExt(const cSchedule *schedules, const cEvent *Start, bool inspectTimerMargin = false);
+ bool MatchesExtEPGInfo(const cEvent* e);
+ const char *ToText();
+ bool Parse(const char *s);
+ bool ParseExtEPGValues(const char *s);
+ bool ParseExtEPGEntry(const char *s);
+ bool ParseBlacklistIDs(const char *s);
+ bool Save(FILE *f);
+ char* BuildFile(const cEvent* pEvent) const;
+ cSearchResults* Run(int PayTVMode = -1, bool inspectTimerMargin = false, int evalLimitMins = 0, cSearchResults* pPrevResults = NULL, bool suppressRepeatCheck = false);
+ void CheckRepeatTimers(cSearchResults* pResults);
+ void CheckExistingRecordings(cSearchResults* pResults);
+ void CopyFromTemplate(const cSearchExt* templ, bool ignoreChannelSettings = false);
+ cSearchResults* GetBlacklistEvents(int MarginStop = 0);
+ void OnOffTimers(bool);
+ void DeleteAllTimers();
+ cTimerObjList* GetTimerList(cTimerObjList* timerList);
+ int GetCountRecordings();
+ bool IsActiveAt(time_t t);
+ bool HasContent(int contentID);
+ void SetContentFilter(int* contentStringsFlags);
+ bool MatchesContentsFilter(const cEvent* e);
};
-class cSearchExts : public cList<cSearchExt>, public cMutex {
- private:
+class cSearchExts : public cList<cSearchExt>, public cMutex
+{
+private:
char *fileName;
bool allowComments;
- virtual void Clear(void)
- {
- cMutexLock SearchExtsLock(this);
- free(fileName);
- fileName = NULL;
- cList<cSearchExt>::Clear();
- }
- public:
- cSearchExts(void) { fileName = NULL; allowComments = false; }
- virtual ~cSearchExts() { Clear(); free(fileName); }
+ virtual void Clear(void) {
+ cMutexLock SearchExtsLock(this);
+ free(fileName);
+ fileName = NULL;
+ cList<cSearchExt>::Clear();
+ }
+public:
+ cSearchExts(void) {
+ fileName = NULL;
+ allowComments = false;
+ }
+ virtual ~cSearchExts() {
+ Clear();
+ free(fileName);
+ }
public:
bool Load(const char *FileName = NULL);
diff --git a/epgsearchonly.c b/epgsearchonly.c
index 15b0203..7fa14f0 100644
--- a/epgsearchonly.c
+++ b/epgsearchonly.c
@@ -32,31 +32,32 @@ static const char *DESCRIPTION = trNOOP("Direct access to epgsearch's search m
static const char *MAINMENUENTRY = trNOOP("Search");
static const char *SETUPTEXT = trNOOP("EpgSearch-Search in main menu");
-class cPluginEpgsearchonly:public cMainMenuShortcut {
+class cPluginEpgsearchonly: public cMainMenuShortcut
+{
public:
- virtual const char *Version() {
- return VERSION;
- }
- virtual const char *Description() {
- return I18nTranslate(DESCRIPTION, I18nEpgsearch);
- }
- virtual bool Initialize();
- virtual cOsdObject *MainMenuAction() {
- return GetEpgSearchMenu("Epgsearch-searchmenu-v1.0");
- };
+ virtual const char *Version() {
+ return VERSION;
+ }
+ virtual const char *Description() {
+ return I18nTranslate(DESCRIPTION, I18nEpgsearch);
+ }
+ virtual bool Initialize();
+ virtual cOsdObject *MainMenuAction() {
+ return GetEpgSearchMenu("Epgsearch-searchmenu-v1.0");
+ };
protected:
- virtual const char *SetupText() {
- return I18nTranslate(SETUPTEXT, I18nEpgsearch);
- }
- virtual const char *MainMenuText() {
- return I18nTranslate(MAINMENUENTRY, I18nEpgsearch);
- }
+ virtual const char *SetupText() {
+ return I18nTranslate(SETUPTEXT, I18nEpgsearch);
+ }
+ virtual const char *MainMenuText() {
+ return I18nTranslate(MAINMENUENTRY, I18nEpgsearch);
+ }
};
bool cPluginEpgsearchonly::Initialize()
{
- return cMainMenuShortcut::Initialize();
+ return cMainMenuShortcut::Initialize();
}
-VDRPLUGINCREATOR(cPluginEpgsearchonly); // Don't touch this!
+VDRPLUGINCREATOR(cPluginEpgsearchonly); // Don't touch this!
diff --git a/epgsearchservices.h b/epgsearchservices.h
index 24f1093..15c3d6a 100644
--- a/epgsearchservices.h
+++ b/epgsearchservices.h
@@ -31,7 +31,7 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class cEpgsearchServiceHandler: public cServiceHandler_v1_2
{
virtual std::list<std::string> TranslateResults(cSearchResults* pCompleteSearchResults);
- public:
+public:
virtual std::list<std::string> SearchTimerList();
virtual int AddSearchTimer(const std::string&);
virtual bool ModSearchTimer(const std::string&);
@@ -44,7 +44,7 @@ class cEpgsearchServiceHandler: public cServiceHandler_v1_2
virtual std::set<std::string> DirectoryList();
virtual std::string ReadSetupValue(const std::string& entry);
virtual bool WriteSetupValue(const std::string& entry, const std::string& value);
- virtual std::list<std::string> TimerConflictList(bool relOnly=false);
+ virtual std::list<std::string> TimerConflictList(bool relOnly = false);
virtual bool IsConflictCheckAdvised();
virtual std::set<std::string> ShortDirectoryList();
virtual std::string Evaluate(const std::string& expr, const cEvent* event);
diff --git a/epgsearchsetup.c b/epgsearchsetup.c
index 642d011..5004a72 100644
--- a/epgsearchsetup.c
+++ b/epgsearchsetup.c
@@ -52,9 +52,9 @@ const char *cMenuSetupMailNotification::MailBoxChars = " abcdefghijklmnopqrs
// ------------------
// cMenuSetupSubMenu
cMenuSetupSubMenu::cMenuSetupSubMenu(const char* Title, cEPGSearchConfig* Data)
-:cOsdMenu(Title, 33)
+ : cOsdMenu(Title, 33)
{
- SetMenuCategory(mcSetupPlugins);
+ SetMenuCategory(mcSetupPlugins);
data = Data;
}
@@ -63,13 +63,14 @@ eOSState cMenuSetupSubMenu::ProcessKey(eKeys Key)
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown) {
- switch (Key) {
- case kInfo:
- case kYellow:
- state = Help();
- break;
- default: break;
- }
+ switch (Key) {
+ case kInfo:
+ case kYellow:
+ state = Help();
+ break;
+ default:
+ break;
+ }
}
return state;
@@ -84,15 +85,13 @@ eOSState cMenuSetupSubMenu::Help()
{
const char* ItemText = Get(Current())->Text();
eOSState state = osContinue;
- if(Current() < (int) helpTexts.size())
- {
- char* title = NULL;
- if (msprintf(&title, "%s - %s", tr("Button$Help"), ItemText)!=-1)
- {
- if (strchr(title, ':'))
- *strchr(title, ':') = 0;
- state = AddSubMenu(new cMenuText(title, helpTexts[Current()]));
- free(title);
+ if (Current() < (int) helpTexts.size()) {
+ char* title = NULL;
+ if (msprintf(&title, "%s - %s", tr("Button$Help"), ItemText) != -1) {
+ if (strchr(title, ':'))
+ *strchr(title, ':') = 0;
+ state = AddSubMenu(new cMenuText(title, helpTexts[Current()]));
+ free(title);
}
}
return state;
@@ -133,7 +132,7 @@ void cMenuEPGSearchSetup::Setup(void)
{
data = EPGSearchConfig;
if (isempty(EPGSearchConfig.mainmenuentry))
- strcpy(data.mainmenuentry,tr("Program guide"));
+ strcpy(data.mainmenuentry, tr("Program guide"));
Set();
SetHelp(NULL, NULL, NULL, trVDR("Button$Open"));
@@ -141,44 +140,42 @@ void cMenuEPGSearchSetup::Setup(void)
void cMenuEPGSearchSetup::Set()
{
- int current = Current();
- Clear();
+ int current = Current();
+ Clear();
- Add(new cOsdItem(tr("General")));
- Add(new cOsdItem(tr("EPG menus")));
- Add(new cOsdItem(tr("User-defined EPG times")));
- Add(new cOsdItem(tr("Timer programming")));
- Add(new cOsdItem(tr("Search and search timers")));
- Add(new cOsdItem(tr("Timer conflict checking")));
- Add(new cOsdItem(tr("Email notification")));
+ Add(new cOsdItem(tr("General")));
+ Add(new cOsdItem(tr("EPG menus")));
+ Add(new cOsdItem(tr("User-defined EPG times")));
+ Add(new cOsdItem(tr("Timer programming")));
+ Add(new cOsdItem(tr("Search and search timers")));
+ Add(new cOsdItem(tr("Timer conflict checking")));
+ Add(new cOsdItem(tr("Email notification")));
- SetCurrent(Get(current));
- Display();
+ SetCurrent(Get(current));
+ Display();
}
void cMenuEPGSearchSetup::Store(void)
{
bool RestartSearchTimerThread = false;
- if (EPGSearchConfig.useSearchTimers != data.useSearchTimers)
- {
+ if (EPGSearchConfig.useSearchTimers != data.useSearchTimers) {
RestartSearchTimerThread = true;
- cSearchTimerThread::Exit();
+ cSearchTimerThread::Exit();
}
bool RestartConflictCheckThread = false;
if (EPGSearchConfig.checkTimerConflictsAfterUpdate != data.checkTimerConflictsAfterUpdate ||
- EPGSearchConfig.conflictCheckIntervall != data.conflictCheckIntervall)
- {
- RestartConflictCheckThread = true;
- cConflictCheckThread::Exit();
+ EPGSearchConfig.conflictCheckIntervall != data.conflictCheckIntervall) {
+ RestartConflictCheckThread = true;
+ cConflictCheckThread::Exit();
}
EPGSearchConfig = data;
if (strcmp(EPGSearchConfig.mainmenuentry, tr("Program guide")) == 0)
- strcpy(EPGSearchConfig.mainmenuentry,"");
+ strcpy(EPGSearchConfig.mainmenuentry, "");
- if (isempty(EPGSearchConfig.MailAddressTo))
- strcpy(EPGSearchConfig.MailAddressTo, EPGSearchConfig.MailAddress);
+ if (isempty(EPGSearchConfig.MailAddressTo))
+ strcpy(EPGSearchConfig.MailAddressTo, EPGSearchConfig.MailAddress);
SetupStore("HideMenu", EPGSearchConfig.hidemenu);
SetupStore("MainMenuEntry", EPGSearchConfig.mainmenuentry);
@@ -266,20 +263,19 @@ void cMenuEPGSearchSetup::Store(void)
cTemplFile::Reset();
char* templateFilename = strdup(AddDirectory(CONFIGDIR, "epgsearchmenu.conf"));
- if (access(templateFilename, F_OK) == 0)
- {
- cTemplFile templFile;
- if (!templFile.Load(templateFilename))
- LogFile.eSysLog("could not load '%s'", templateFilename);
+ if (access(templateFilename, F_OK) == 0) {
+ cTemplFile templFile;
+ if (!templFile.Load(templateFilename))
+ LogFile.eSysLog("could not load '%s'", templateFilename);
}
cTemplFile::PrepareDefaultTemplates();
free(templateFilename);
cPluginEpgsearch *p = (cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch");
if (RestartSearchTimerThread)
- cSearchTimerThread::Init(p);
+ cSearchTimerThread::Init(p);
if (RestartConflictCheckThread)
- cConflictCheckThread::Init(p);
+ cConflictCheckThread::Init(p);
}
eOSState cMenuEPGSearchSetup::ProcessKey(eKeys Key)
@@ -296,46 +292,43 @@ eOSState cMenuEPGSearchSetup::ProcessKey(eKeys Key)
int iOnTimerConflicts = 0;
int iOnEmailNotification = 0;
- if (!HasSubMenu())
- {
- if (strstr(ItemText, tr("General")) == ItemText)
- iOnGeneral = 1;
- else if (strstr(ItemText, tr("EPG menus")) == ItemText)
- iOnEPGMenus = 1;
- else if (strstr(ItemText, tr("User-defined EPG times")) == ItemText)
- iOnUserdefTimes = 1;
- else if (strstr(ItemText, tr("Timer programming")) == ItemText)
- iOnTimers = 1;
- else if (strstr(ItemText, tr("Search and search timers")) == ItemText)
- iOnSearchtimers = 1;
- else if (strstr(ItemText, tr("Timer conflict checking")) == ItemText)
- iOnTimerConflicts = 1;
- else if (strstr(ItemText, tr("Email notification")) == ItemText)
- iOnEmailNotification = 1;
- }
-
- if (!HasSubMenu() && (state == osUnknown || Key == kOk))
- {
- if ((Key == kOk && !hadSubMenu) || Key == kBlue)
- {
- if (iOnGeneral == 1)
- state = AddSubMenu(new cMenuSetupGeneral(&data));
- else if (iOnEPGMenus == 1)
- state = AddSubMenu(new cMenuSetupEPGMenus(&data));
- else if (iOnUserdefTimes == 1)
- state = AddSubMenu(new cMenuSetupUserdefTimes(&data));
- else if (iOnTimers == 1)
- state = AddSubMenu(new cMenuSetupTimers(&data));
- else if (iOnSearchtimers == 1)
- state = AddSubMenu(new cMenuSetupSearchtimers(&data));
- else if (iOnTimerConflicts == 1)
- state = AddSubMenu(new cMenuSetupTimerConflicts(&data));
- else if (iOnEmailNotification == 1)
- state = AddSubMenu(new cMenuSetupMailNotification(&data));
- }
+ if (!HasSubMenu()) {
+ if (strstr(ItemText, tr("General")) == ItemText)
+ iOnGeneral = 1;
+ else if (strstr(ItemText, tr("EPG menus")) == ItemText)
+ iOnEPGMenus = 1;
+ else if (strstr(ItemText, tr("User-defined EPG times")) == ItemText)
+ iOnUserdefTimes = 1;
+ else if (strstr(ItemText, tr("Timer programming")) == ItemText)
+ iOnTimers = 1;
+ else if (strstr(ItemText, tr("Search and search timers")) == ItemText)
+ iOnSearchtimers = 1;
+ else if (strstr(ItemText, tr("Timer conflict checking")) == ItemText)
+ iOnTimerConflicts = 1;
+ else if (strstr(ItemText, tr("Email notification")) == ItemText)
+ iOnEmailNotification = 1;
+ }
+
+ if (!HasSubMenu() && (state == osUnknown || Key == kOk)) {
+ if ((Key == kOk && !hadSubMenu) || Key == kBlue) {
+ if (iOnGeneral == 1)
+ state = AddSubMenu(new cMenuSetupGeneral(&data));
+ else if (iOnEPGMenus == 1)
+ state = AddSubMenu(new cMenuSetupEPGMenus(&data));
+ else if (iOnUserdefTimes == 1)
+ state = AddSubMenu(new cMenuSetupUserdefTimes(&data));
+ else if (iOnTimers == 1)
+ state = AddSubMenu(new cMenuSetupTimers(&data));
+ else if (iOnSearchtimers == 1)
+ state = AddSubMenu(new cMenuSetupSearchtimers(&data));
+ else if (iOnTimerConflicts == 1)
+ state = AddSubMenu(new cMenuSetupTimerConflicts(&data));
+ else if (iOnEmailNotification == 1)
+ state = AddSubMenu(new cMenuSetupMailNotification(&data));
+ }
}
if (!HasSubMenu() && hadSubMenu)
- Store();
+ Store();
return state;
}
@@ -343,32 +336,31 @@ eOSState cMenuEPGSearchSetup::ProcessKey(eKeys Key)
// ------------------
// cMenuSetupGeneral
cMenuSetupGeneral::cMenuSetupGeneral(cEPGSearchConfig* Data)
-: cMenuSetupSubMenu(tr("General"), Data)
+ : cMenuSetupSubMenu(tr("General"), Data)
{
Set();
}
void cMenuSetupGeneral::Set()
{
- int current = Current();
- Clear();
- helpTexts.clear();
+ int current = Current();
+ Clear();
+ helpTexts.clear();
- Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &data->hidemenu, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Hides the main menu entry and may be useful if this plugin is used to replace the original 'Schedule' entry."));
- if (!data->hidemenu)
- {
- Add(new cMenuEditStrItem(IndentMenuItem(tr("Main menu entry")), data->mainmenuentry, sizeof(data->mainmenuentry), tr(AllowedChars)));
- AddHelp(tr("Help$The name of the main menu entry which defaults to 'Programm guide'."));
- }
- Add(new cMenuEditBoolItem(tr("Replace original schedule"), &data->ReplaceOrgSchedule, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$When VDR is patched to allow this plugin to replace the original 'Schedule' entry, you can de/activate this replacement here."));
- Add(new cMenuEditStraItem(tr("Start menu"), &data->StartMenu, 2, StartMenuMode));
- AddHelp(tr("Help$Choose between 'Overview - Now' and 'Schedule' as start menu when this plugin is called."));
+ Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &data->hidemenu, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Hides the main menu entry and may be useful if this plugin is used to replace the original 'Schedule' entry."));
+ if (!data->hidemenu) {
+ Add(new cMenuEditStrItem(IndentMenuItem(tr("Main menu entry")), data->mainmenuentry, sizeof(data->mainmenuentry), tr(AllowedChars)));
+ AddHelp(tr("Help$The name of the main menu entry which defaults to 'Programm guide'."));
+ }
+ Add(new cMenuEditBoolItem(tr("Replace original schedule"), &data->ReplaceOrgSchedule, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$When VDR is patched to allow this plugin to replace the original 'Schedule' entry, you can de/activate this replacement here."));
+ Add(new cMenuEditStraItem(tr("Start menu"), &data->StartMenu, 2, StartMenuMode));
+ AddHelp(tr("Help$Choose between 'Overview - Now' and 'Schedule' as start menu when this plugin is called."));
- SetCurrent(Get(current));
- Display();
- SetHelp(NULL, NULL, tr("Button$Help"), NULL);
+ SetCurrent(Get(current));
+ Display();
+ SetHelp(NULL, NULL, tr("Button$Help"), NULL);
}
eOSState cMenuSetupGeneral::ProcessKey(eKeys Key)
@@ -377,18 +369,18 @@ eOSState cMenuSetupGeneral::ProcessKey(eKeys Key)
eOSState state = cMenuSetupSubMenu::ProcessKey(Key);
- if (iTemp_hidemenu != data->hidemenu)
- {
- Set();
- Display();
+ if (iTemp_hidemenu != data->hidemenu) {
+ Set();
+ Display();
}
if (state == osUnknown) {
- switch (Key) {
- case kOk:
- return osBack;
- default: break;
- }
+ switch (Key) {
+ case kOk:
+ return osBack;
+ default:
+ break;
+ }
}
return state;
@@ -399,7 +391,7 @@ eOSState cMenuSetupGeneral::ProcessKey(eKeys Key)
// ------------------
// cMenuSetupEPGMenus
cMenuSetupEPGMenus::cMenuSetupEPGMenus(cEPGSearchConfig* Data)
-: cMenuSetupSubMenu(tr("EPG menus"), Data)
+ : cMenuSetupSubMenu(tr("EPG menus"), Data)
{
Set();
}
@@ -410,7 +402,7 @@ void cMenuSetupEPGMenus::Set()
Clear();
helpTexts.clear();
- Add(new cMenuEditStraItem( tr("Ok key"), &data->useOkForSwitch, 2, OkKeyMode));
+ Add(new cMenuEditStraItem(tr("Ok key"), &data->useOkForSwitch, 2, OkKeyMode));
AddHelp(tr("Help$Choose here the behaviour of key 'Ok'. You can use it to display the summary or to switch to the corresponding channel.\nNote: the functionality of key 'blue' (Switch/Info/Search) depends on this setting."));
Add(new cMenuEditStraItem(tr("Red key"), &data->redkeymode, 2, RedKeyMode));
@@ -420,31 +412,30 @@ void cMenuSetupEPGMenus::Set()
Add(new cMenuEditBoolItem(tr("Show progress in 'Now'"), &data->showProgress, trVDR("no"), trVDR("yes")));
AddHelp(tr("Help$Shows a progressbar in 'Overview - Now' that informs about the remaining time of the current event."));
- Add(new cMenuEditBoolItem( tr("Show channel numbers"), &data->showChannelNr, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Show channel numbers"), &data->showChannelNr, trVDR("no"), trVDR("yes")));
AddHelp(tr("Help$Display channel numbers in 'Overview - Now'.\n\n(To completely define your own menu look please inspect the MANUAL)"));
- Add(new cMenuEditBoolItem( tr("Show channel separators"), &data->showChannelGroups, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Show channel separators"), &data->showChannelGroups, trVDR("no"), trVDR("yes")));
AddHelp(tr("Help$Display VDR channel groups as separators between your channels in 'Overview - Now'."));
- Add(new cMenuEditBoolItem( tr("Show day separators"), &data->showDaySeparators, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Show day separators"), &data->showDaySeparators, trVDR("no"), trVDR("yes")));
AddHelp(tr("Help$Display a separator line at day break in 'Schedule'."));
- Add(new cMenuEditBoolItem( tr("Show radio channels"), &data->showRadioChannels, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Show radio channels"), &data->showRadioChannels, trVDR("no"), trVDR("yes")));
AddHelp(tr("Help$Show also radio channels."));
Add(new cMenuEditIntItem(tr("Limit channels from 1 to"), &data->maxChannelMenuNow, 0, 9999));
AddHelp(tr("Help$If you have a large channel set you can speed up things when you limit the displayed channels with this setting. Use '0' to disable the limit."));
- Add(new cMenuEditBoolItem( tr("'One press' timer creation"), &data->onePressTimerCreation, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("'One press' timer creation"), &data->onePressTimerCreation, trVDR("no"), trVDR("yes")));
AddHelp(tr("Help$When a timer is created with 'Record' you can choose between an immediate creation of the timer or the display of the timer edit menu."));
- Add(new cMenuEditBoolItem( tr("Show channels without EPG"), &data->showEmptyChannels, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Show channels without EPG"), &data->showEmptyChannels, trVDR("no"), trVDR("yes")));
AddHelp(tr("Help$Choose 'yes' here if you want to display channels without EPG in 'Overview - Now'. 'Ok' on these entries switches the channel."));
Add(new cMenuEditIntItem(tr("Time interval for FRew/FFwd [min]"), &data->timeShiftValue, 1, 9999));
AddHelp(tr("Help$Choose here the time interval which should be used for jumping through the EPG by pressing FRew/FFwd.\n\n(If you don't have those keys, you can toggle to this functionality pressing '0' and get '<<' and '>>' on the keys green and yellow)"));
- Add(new cMenuEditBoolItem( tr("Toggle Green/Yellow"), &data->toggleGreenYellow, trVDR("no"), trVDR("yes")));
+ Add(new cMenuEditBoolItem(tr("Toggle Green/Yellow"), &data->toggleGreenYellow, trVDR("no"), trVDR("yes")));
AddHelp(tr("Help$Specify if green and yellow shall also be switched when pressing '0'."));
- Add(new cMenuEditStraItem( tr("Show favorites menu"), &data->showFavoritesMenu, 4, FavoritesMenuMode));
+ Add(new cMenuEditStraItem(tr("Show favorites menu"), &data->showFavoritesMenu, 4, FavoritesMenuMode));
AddHelp(tr("Help$A favorites menu can display a list of your favorite broadcasts. Enable this if you want an additional menu besides 'Now' and 'Next'\nAny search can be used as a favorite. You only have to set the option 'Use in favorites menu' when editing a search."));
- if (data->showFavoritesMenu)
- {
- Add(new cMenuEditIntItem( IndentMenuItem(tr("for the next ... hours")), &data->FavoritesMenuTimespan, 1, 9999));
- AddHelp(tr("Help$This value controls the timespan used to display your favorites."));
+ if (data->showFavoritesMenu) {
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("for the next ... hours")), &data->FavoritesMenuTimespan, 1, 9999));
+ AddHelp(tr("Help$This value controls the timespan used to display your favorites."));
}
SetCurrent(Get(current));
@@ -454,70 +445,66 @@ void cMenuSetupEPGMenus::Set()
void cMenuSetupEPGMenus::SetHelpKeys()
{
- SetHelp(NULL, NULL, tr("Button$Help"), NULL);
+ SetHelp(NULL, NULL, tr("Button$Help"), NULL);
}
// ------------------
// cMenuSetupUsedefTimes
cMenuSetupUserdefTimes::cMenuSetupUserdefTimes(cEPGSearchConfig* Data)
-: cMenuSetupSubMenu(tr("User-defined EPG times"), Data)
+ : cMenuSetupSubMenu(tr("User-defined EPG times"), Data)
{
Set();
}
void cMenuSetupUserdefTimes::Set()
{
- int current = Current();
- Clear();
- helpTexts.clear();
-
- cString szUseUserTime = cString::sprintf("%s %d", tr("Use user-defined time"), 1);
- Add(new cMenuEditBoolItem(szUseUserTime, &data->ShowModes[showUserMode1].useIt, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Besides 'Now' and 'Next' you can specify up to 4 other times in the EPG which can be used by repeatedly pressing the green key, e.g. 'prime time', 'late night',..."));
- if (data->ShowModes[showUserMode1].GetUsage())
- {
- Add(new cMenuEditStrItem(IndentMenuItem(tr("Description")), data->ShowModes[showUserMode1].description, sizeof(data->ShowModes[showUserMode1].description), trVDR(FileNameChars)));
- AddHelp(tr("Help$This is the description for your user-defined time as it will appear as label on the green button."));
- Add(new cMenuEditTimeItem(IndentMenuItem(tr("Time")), &data->ShowModes[showUserMode1].itime));
- AddHelp(tr("Help$Specify the user-defined time here in 'HH:MM'."));
- }
-
- szUseUserTime = cString::sprintf("%s %d", tr("Use user-defined time"), 2);
- Add(new cMenuEditBoolItem( szUseUserTime, &data->ShowModes[showUserMode2].useIt, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Besides 'Now' and 'Next' you can specify up to 4 other times in the EPG which can be used by repeatedly pressing the green key, e.g. 'prime time', 'late night',..."));
- if (data->ShowModes[showUserMode2].GetUsage())
- {
- Add(new cMenuEditStrItem(IndentMenuItem(tr("Description")), data->ShowModes[showUserMode2].description, sizeof(data->ShowModes[showUserMode2].description), trVDR(FileNameChars)));
- AddHelp(tr("Help$This is the description for your user-defined time as it will appear as label on the green button."));
- Add(new cMenuEditTimeItem(IndentMenuItem(tr("Time")), &data->ShowModes[showUserMode2].itime));
- AddHelp(tr("Help$Specify the user-defined time here in 'HH:MM'."));
- }
-
- szUseUserTime = cString::sprintf("%s %d", tr("Use user-defined time"), 3);
- Add(new cMenuEditBoolItem(szUseUserTime, &data->ShowModes[showUserMode3].useIt, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Besides 'Now' and 'Next' you can specify up to 4 other times in the EPG which can be used by repeatedly pressing the green key, e.g. 'prime time', 'late night',..."));
- if (data->ShowModes[showUserMode3].GetUsage())
- {
- Add(new cMenuEditStrItem(IndentMenuItem(tr("Description")), data->ShowModes[showUserMode3].description, sizeof(data->ShowModes[showUserMode3].description), trVDR(FileNameChars)));
- AddHelp(tr("Help$This is the description for your user-defined time as it will appear as label on the green button."));
- Add(new cMenuEditTimeItem(IndentMenuItem(tr("Time")), &data->ShowModes[showUserMode3].itime));
- AddHelp(tr("Help$Specify the user-defined time here in 'HH:MM'."));
- }
-
- szUseUserTime = cString::sprintf("%s %d", tr("Use user-defined time"), 4);
- Add(new cMenuEditBoolItem(szUseUserTime, &data->ShowModes[showUserMode4].useIt, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Besides 'Now' and 'Next' you can specify up to 4 other times in the EPG which can be used by repeatedly pressing the green key, e.g. 'prime time', 'late night',..."));
- if (data->ShowModes[showUserMode4].GetUsage())
- {
- Add(new cMenuEditStrItem(IndentMenuItem(tr("Description")), data->ShowModes[showUserMode4].description, sizeof(data->ShowModes[showUserMode4].description), trVDR(FileNameChars)));
- AddHelp(tr("Help$This is the description for your user-defined time as it will appear as label on the green button."));
- Add(new cMenuEditTimeItem(IndentMenuItem(tr("Time")), &data->ShowModes[showUserMode4].itime));
- AddHelp(tr("Help$Specify the user-defined time here in 'HH:MM'."));
- }
-
- SetCurrent(Get(current));
- Display();
- SetHelp(NULL, NULL, tr("Button$Help"), NULL);
+ int current = Current();
+ Clear();
+ helpTexts.clear();
+
+ cString szUseUserTime = cString::sprintf("%s %d", tr("Use user-defined time"), 1);
+ Add(new cMenuEditBoolItem(szUseUserTime, &data->ShowModes[showUserMode1].useIt, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Besides 'Now' and 'Next' you can specify up to 4 other times in the EPG which can be used by repeatedly pressing the green key, e.g. 'prime time', 'late night',..."));
+ if (data->ShowModes[showUserMode1].GetUsage()) {
+ Add(new cMenuEditStrItem(IndentMenuItem(tr("Description")), data->ShowModes[showUserMode1].description, sizeof(data->ShowModes[showUserMode1].description), trVDR(FileNameChars)));
+ AddHelp(tr("Help$This is the description for your user-defined time as it will appear as label on the green button."));
+ Add(new cMenuEditTimeItem(IndentMenuItem(tr("Time")), &data->ShowModes[showUserMode1].itime));
+ AddHelp(tr("Help$Specify the user-defined time here in 'HH:MM'."));
+ }
+
+ szUseUserTime = cString::sprintf("%s %d", tr("Use user-defined time"), 2);
+ Add(new cMenuEditBoolItem(szUseUserTime, &data->ShowModes[showUserMode2].useIt, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Besides 'Now' and 'Next' you can specify up to 4 other times in the EPG which can be used by repeatedly pressing the green key, e.g. 'prime time', 'late night',..."));
+ if (data->ShowModes[showUserMode2].GetUsage()) {
+ Add(new cMenuEditStrItem(IndentMenuItem(tr("Description")), data->ShowModes[showUserMode2].description, sizeof(data->ShowModes[showUserMode2].description), trVDR(FileNameChars)));
+ AddHelp(tr("Help$This is the description for your user-defined time as it will appear as label on the green button."));
+ Add(new cMenuEditTimeItem(IndentMenuItem(tr("Time")), &data->ShowModes[showUserMode2].itime));
+ AddHelp(tr("Help$Specify the user-defined time here in 'HH:MM'."));
+ }
+
+ szUseUserTime = cString::sprintf("%s %d", tr("Use user-defined time"), 3);
+ Add(new cMenuEditBoolItem(szUseUserTime, &data->ShowModes[showUserMode3].useIt, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Besides 'Now' and 'Next' you can specify up to 4 other times in the EPG which can be used by repeatedly pressing the green key, e.g. 'prime time', 'late night',..."));
+ if (data->ShowModes[showUserMode3].GetUsage()) {
+ Add(new cMenuEditStrItem(IndentMenuItem(tr("Description")), data->ShowModes[showUserMode3].description, sizeof(data->ShowModes[showUserMode3].description), trVDR(FileNameChars)));
+ AddHelp(tr("Help$This is the description for your user-defined time as it will appear as label on the green button."));
+ Add(new cMenuEditTimeItem(IndentMenuItem(tr("Time")), &data->ShowModes[showUserMode3].itime));
+ AddHelp(tr("Help$Specify the user-defined time here in 'HH:MM'."));
+ }
+
+ szUseUserTime = cString::sprintf("%s %d", tr("Use user-defined time"), 4);
+ Add(new cMenuEditBoolItem(szUseUserTime, &data->ShowModes[showUserMode4].useIt, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Besides 'Now' and 'Next' you can specify up to 4 other times in the EPG which can be used by repeatedly pressing the green key, e.g. 'prime time', 'late night',..."));
+ if (data->ShowModes[showUserMode4].GetUsage()) {
+ Add(new cMenuEditStrItem(IndentMenuItem(tr("Description")), data->ShowModes[showUserMode4].description, sizeof(data->ShowModes[showUserMode4].description), trVDR(FileNameChars)));
+ AddHelp(tr("Help$This is the description for your user-defined time as it will appear as label on the green button."));
+ Add(new cMenuEditTimeItem(IndentMenuItem(tr("Time")), &data->ShowModes[showUserMode4].itime));
+ AddHelp(tr("Help$Specify the user-defined time here in 'HH:MM'."));
+ }
+
+ SetCurrent(Get(current));
+ Display();
+ SetHelp(NULL, NULL, tr("Button$Help"), NULL);
}
eOSState cMenuSetupUserdefTimes::ProcessKey(eKeys Key)
@@ -530,20 +517,20 @@ eOSState cMenuSetupUserdefTimes::ProcessKey(eKeys Key)
eOSState state = cMenuSetupSubMenu::ProcessKey(Key);
if (iTemp_useUserTime1 != data->ShowModes[showUserMode1].GetUsage() ||
- iTemp_useUserTime2 != data->ShowModes[showUserMode2].GetUsage() ||
- iTemp_useUserTime3 != data->ShowModes[showUserMode3].GetUsage() ||
- iTemp_useUserTime4 != data->ShowModes[showUserMode4].GetUsage())
- {
- Set();
- Display();
+ iTemp_useUserTime2 != data->ShowModes[showUserMode2].GetUsage() ||
+ iTemp_useUserTime3 != data->ShowModes[showUserMode3].GetUsage() ||
+ iTemp_useUserTime4 != data->ShowModes[showUserMode4].GetUsage()) {
+ Set();
+ Display();
}
if (state == osUnknown) {
- switch (Key) {
- case kOk:
- return osBack;
- default: break;
- }
+ switch (Key) {
+ case kOk:
+ return osBack;
+ default:
+ break;
+ }
}
return state;
@@ -553,45 +540,42 @@ eOSState cMenuSetupUserdefTimes::ProcessKey(eKeys Key)
// ------------------
// cMenuSetupTimers
cMenuSetupTimers::cMenuSetupTimers(cEPGSearchConfig* Data)
-: cMenuSetupSubMenu(tr("Timer programming"), Data)
+ : cMenuSetupSubMenu(tr("Timer programming"), Data)
{
Set();
}
void cMenuSetupTimers::Set()
{
- int current = Current();
- Clear();
- helpTexts.clear();
+ int current = Current();
+ Clear();
+ helpTexts.clear();
- Add(new cMenuEditBoolItem( tr("Use VDR's timer edit menu"), &data->useVDRTimerEditMenu, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$This plugin has its own timer edit menu extending the original one with some extra functionality like\n- an additional directory entry\n- user-defined days of week for repeating timers\n- adding an episode name\n- support for EPG variables (see MANUAL)"));
- Add(new cMenuEditStrItem(tr("Default recording dir"), data->defrecdir, sizeof(data->defrecdir), tr(AllowedChars)));
- AddHelp(tr("Help$When creating a timer you can specify here a default recording directory."));
- Add(new cMenuEditStraItem(tr("Add episode to manual timers"), &data->addSubtitleToTimer, 3, AddSubtitleMode));
- AddHelp(tr("Help$If you create a timer for a series, you can automatically add the episode name.\n\n- never: no addition\n- always: always add episode name if present\n- smart: add only if event lasts less than 80 mins."));
- Add(new cOsdItem(tr("Default timer check method")));
- AddHelp(tr("Help$Manual timers can be checked for EPG changes. Here you can setup the default check method for each channel. Choose between\n\n- no checking\n- by event ID: checks by an event ID supplied by the channel provider.\n- by channel and time: check by the duration match."));
+ Add(new cMenuEditBoolItem(tr("Use VDR's timer edit menu"), &data->useVDRTimerEditMenu, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$This plugin has its own timer edit menu extending the original one with some extra functionality like\n- an additional directory entry\n- user-defined days of week for repeating timers\n- adding an episode name\n- support for EPG variables (see MANUAL)"));
+ Add(new cMenuEditStrItem(tr("Default recording dir"), data->defrecdir, sizeof(data->defrecdir), tr(AllowedChars)));
+ AddHelp(tr("Help$When creating a timer you can specify here a default recording directory."));
+ Add(new cMenuEditStraItem(tr("Add episode to manual timers"), &data->addSubtitleToTimer, 3, AddSubtitleMode));
+ AddHelp(tr("Help$If you create a timer for a series, you can automatically add the episode name.\n\n- never: no addition\n- always: always add episode name if present\n- smart: add only if event lasts less than 80 mins."));
+ Add(new cOsdItem(tr("Default timer check method")));
+ AddHelp(tr("Help$Manual timers can be checked for EPG changes. Here you can setup the default check method for each channel. Choose between\n\n- no checking\n- by event ID: checks by an event ID supplied by the channel provider.\n- by channel and time: check by the duration match."));
- SetCurrent(Get(current));
- Display();
- SetHelpKeys();
+ SetCurrent(Get(current));
+ Display();
+ SetHelpKeys();
}
void cMenuSetupTimers::SetHelpKeys()
{
const char* ItemText = Get(Current())->Text();
- if (!HasSubMenu())
- {
- if (strstr(ItemText, tr("Default recording dir")) == ItemText)
- {
- if (!InEditMode(ItemText, tr("Default recording dir"), data->defrecdir))
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Select"));
- }
- else if (strstr(ItemText, tr("Default timer check method")) == ItemText)
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- else
- SetHelp(NULL, NULL, tr("Button$Help"), NULL);
+ if (!HasSubMenu()) {
+ if (strstr(ItemText, tr("Default recording dir")) == ItemText) {
+ if (!InEditMode(ItemText, tr("Default recording dir"), data->defrecdir))
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Select"));
+ } else if (strstr(ItemText, tr("Default timer check method")) == ItemText)
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ else
+ SetHelp(NULL, NULL, tr("Button$Help"), NULL);
}
}
@@ -602,30 +586,29 @@ eOSState cMenuSetupTimers::ProcessKey(eKeys Key)
const char* ItemText = Get(Current())->Text();
int iOnDefRecDir = 0;
int iOnDefTimerCheck = 0;
- if (!HasSubMenu())
- {
- if (strstr(ItemText, tr("Default recording dir")) == ItemText)
- iOnDefRecDir = 1;
- if (strstr(ItemText, tr("Default timer check method")) == ItemText)
- iOnDefTimerCheck = 1;
+ if (!HasSubMenu()) {
+ if (strstr(ItemText, tr("Default recording dir")) == ItemText)
+ iOnDefRecDir = 1;
+ if (strstr(ItemText, tr("Default timer check method")) == ItemText)
+ iOnDefTimerCheck = 1;
}
SetHelpKeys();
if (state == osUnknown) {
- switch (Key) {
- case kBlue:
- if (!HasSubMenu())
- {
- if (iOnDefRecDir == 1)
- state = AddSubMenu(new cMenuDirSelect(data->defrecdir));
- if (iOnDefTimerCheck == 1)
- state = AddSubMenu(new cMenuDefTimerCheckMethod());
- }
- break;
- case kOk:
- return osBack;
- default: break;
- }
+ switch (Key) {
+ case kBlue:
+ if (!HasSubMenu()) {
+ if (iOnDefRecDir == 1)
+ state = AddSubMenu(new cMenuDirSelect(data->defrecdir));
+ if (iOnDefTimerCheck == 1)
+ state = AddSubMenu(new cMenuDefTimerCheckMethod());
+ }
+ break;
+ case kOk:
+ return osBack;
+ default:
+ break;
+ }
}
return state;
@@ -634,7 +617,7 @@ eOSState cMenuSetupTimers::ProcessKey(eKeys Key)
// ------------------
// cMenuSetupSearchtimers
cMenuSetupSearchtimers::cMenuSetupSearchtimers(cEPGSearchConfig* Data)
-: cMenuSetupSubMenu(tr("Search and search timers"), Data)
+ : cMenuSetupSubMenu(tr("Search and search timers"), Data)
{
menuitemsChGr = NULL;
Set();
@@ -642,80 +625,77 @@ cMenuSetupSearchtimers::cMenuSetupSearchtimers(cEPGSearchConfig* Data)
cMenuSetupSearchtimers::~cMenuSetupSearchtimers()
{
- if (menuitemsChGr)
- free(menuitemsChGr);
+ if (menuitemsChGr)
+ free(menuitemsChGr);
}
void cMenuSetupSearchtimers::Set()
{
- int current = Current();
- Clear();
- helpTexts.clear();
-
- Add(new cMenuEditBoolItem(tr("Use search timers"), &data->useSearchTimers, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$'Search timers' can be used to automatically create timers for events that match your search criterions."));
- if (data->useSearchTimers)
- {
- Add(new cMenuEditIntItem(tr(" Update interval [min]"), &data->UpdateIntervall, 1, 9999));
- AddHelp(tr("Help$Specify here the time intervall to be used when searching for events in the background."));
- Add(new cMenuEditIntItem(tr(" SVDRP port"), &data->SVDRPPort, 1, 99999));
- AddHelp(tr("Help$Programming of new timers or timer changes is done with SVDRP. The default value should be correct, so change it only if you know what you are doing."));
- Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Default priority")), &data->DefPriority, 0, MAXPRIORITY));
- AddHelp(tr("Help$Specify here the default priority of timers created with this plugin. This value can also be adjusted for each search itself."));
- Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Default lifetime (d)")), &data->DefLifetime, 0, MAXLIFETIME));
- AddHelp(tr("Help$Specify here the default lifetime of timers/recordings created with this plugin. This value can also be adjusted for each search itself."));
- Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Margin at start (min)")), &data->DefMarginStart));
- AddHelp(tr("Help$Specify here the default start recording margin of timers/recordings created with this plugin. This value can also be adjusted for each search itself."));
- Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Margin at stop (min)")), &data->DefMarginStop));
- AddHelp(tr("Help$Specify here the default stop recording margin of timers/recordings created with this plugin. This value can also be adjusted for each search itself."));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("No announcements when replaying")), &data->noAnnounceWhileReplay, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if you don't like to get any announcements of broadcasts if you currently replay anything."));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Recreate timers after deletion")), &data->TimerProgRepeat, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if you want timers to be recreated with the next search timer update after deleting them."));
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Check if EPG exists for ... [h]")), &data->checkEPGHours, 0, 999));
- AddHelp(tr("Help$Specify how many hours of future EPG there should be and get warned else after a search timer update."));
- if (data->checkEPGHours > 0)
- {
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Warn by OSD"),2), &data->checkEPGWarnByOSD, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if you want get warnings from the EPG check via OSD."));
- Add(new cMenuEditBoolItem(IndentMenuItem(tr("Warn by mail"),2), &data->checkEPGWarnByMail, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if you want get warnings from the EPG check by mail."));
-
- // create the char array for the menu display
- if (menuitemsChGr) delete [] menuitemsChGr;
- menuitemsChGr = ChannelGroups.CreateMenuitemsList();
- Add(new cMenuEditStraItem(IndentMenuItem(tr("Channel group to check"),2), &data->checkEPGchannelGroupNr, ChannelGroups.Count()+1, menuitemsChGr));
- AddHelp(tr("Help$Specify the channel group to check."));
- }
- }
-
- Add(new cMenuEditBoolItem( tr("Ignore PayTV channels"), &data->ignorePayTV, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if don't want to see events on PayTV channels when searching for repeats."));
- Add(new cOsdItem(tr("Search templates")));
- AddHelp(tr("Help$Here you can setup templates for your searches."));
- Add(new cOsdItem(tr("Blacklists")));
- AddHelp(tr("Help$Here you can setup blacklists which can be used within a search to exclude events you don't like."));
- Add(new cOsdItem(tr("Channel groups")));
- AddHelp(tr("Help$Here you can setup channel groups which can be used within a search. These are different to VDR channel groups and represent a set of arbitrary channels, e.g. 'FreeTV'."));
-
- SetCurrent(Get(current));
- Display();
- SetHelpKeys();
+ int current = Current();
+ Clear();
+ helpTexts.clear();
+
+ Add(new cMenuEditBoolItem(tr("Use search timers"), &data->useSearchTimers, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$'Search timers' can be used to automatically create timers for events that match your search criterions."));
+ if (data->useSearchTimers) {
+ Add(new cMenuEditIntItem(tr(" Update interval [min]"), &data->UpdateIntervall, 1, 9999));
+ AddHelp(tr("Help$Specify here the time intervall to be used when searching for events in the background."));
+ Add(new cMenuEditIntItem(tr(" SVDRP port"), &data->SVDRPPort, 1, 99999));
+ AddHelp(tr("Help$Programming of new timers or timer changes is done with SVDRP. The default value should be correct, so change it only if you know what you are doing."));
+ Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Default priority")), &data->DefPriority, 0, MAXPRIORITY));
+ AddHelp(tr("Help$Specify here the default priority of timers created with this plugin. This value can also be adjusted for each search itself."));
+ Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Default lifetime (d)")), &data->DefLifetime, 0, MAXLIFETIME));
+ AddHelp(tr("Help$Specify here the default lifetime of timers/recordings created with this plugin. This value can also be adjusted for each search itself."));
+ Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Margin at start (min)")), &data->DefMarginStart));
+ AddHelp(tr("Help$Specify here the default start recording margin of timers/recordings created with this plugin. This value can also be adjusted for each search itself."));
+ Add(new cMenuEditIntItem(IndentMenuItem(trVDR("Setup.Recording$Margin at stop (min)")), &data->DefMarginStop));
+ AddHelp(tr("Help$Specify here the default stop recording margin of timers/recordings created with this plugin. This value can also be adjusted for each search itself."));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("No announcements when replaying")), &data->noAnnounceWhileReplay, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if you don't like to get any announcements of broadcasts if you currently replay anything."));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Recreate timers after deletion")), &data->TimerProgRepeat, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if you want timers to be recreated with the next search timer update after deleting them."));
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Check if EPG exists for ... [h]")), &data->checkEPGHours, 0, 999));
+ AddHelp(tr("Help$Specify how many hours of future EPG there should be and get warned else after a search timer update."));
+ if (data->checkEPGHours > 0) {
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Warn by OSD"), 2), &data->checkEPGWarnByOSD, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if you want get warnings from the EPG check via OSD."));
+ Add(new cMenuEditBoolItem(IndentMenuItem(tr("Warn by mail"), 2), &data->checkEPGWarnByMail, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if you want get warnings from the EPG check by mail."));
+
+ // create the char array for the menu display
+ if (menuitemsChGr) delete [] menuitemsChGr;
+ menuitemsChGr = ChannelGroups.CreateMenuitemsList();
+ Add(new cMenuEditStraItem(IndentMenuItem(tr("Channel group to check"), 2), &data->checkEPGchannelGroupNr, ChannelGroups.Count() + 1, menuitemsChGr));
+ AddHelp(tr("Help$Specify the channel group to check."));
+ }
+ }
+
+ Add(new cMenuEditBoolItem(tr("Ignore PayTV channels"), &data->ignorePayTV, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if don't want to see events on PayTV channels when searching for repeats."));
+ Add(new cOsdItem(tr("Search templates")));
+ AddHelp(tr("Help$Here you can setup templates for your searches."));
+ Add(new cOsdItem(tr("Blacklists")));
+ AddHelp(tr("Help$Here you can setup blacklists which can be used within a search to exclude events you don't like."));
+ Add(new cOsdItem(tr("Channel groups")));
+ AddHelp(tr("Help$Here you can setup channel groups which can be used within a search. These are different to VDR channel groups and represent a set of arbitrary channels, e.g. 'FreeTV'."));
+
+ SetCurrent(Get(current));
+ Display();
+ SetHelpKeys();
}
void cMenuSetupSearchtimers::SetHelpKeys()
{
const char* ItemText = Get(Current())->Text();
- if (!HasSubMenu())
- {
- if (strstr(ItemText, tr("Channel groups")) == ItemText)
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- else if (strstr(ItemText, tr("Search templates")) == ItemText)
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- else if (strstr(ItemText, tr("Blacklists")) == ItemText)
- SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
- else
- SetHelp(NULL, NULL, tr("Button$Help"), NULL);
+ if (!HasSubMenu()) {
+ if (strstr(ItemText, tr("Channel groups")) == ItemText)
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ else if (strstr(ItemText, tr("Search templates")) == ItemText)
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ else if (strstr(ItemText, tr("Blacklists")) == ItemText)
+ SetHelp(NULL, NULL, tr("Button$Help"), tr("Button$Setup"));
+ else
+ SetHelp(NULL, NULL, tr("Button$Help"), NULL);
}
}
@@ -731,41 +711,39 @@ eOSState cMenuSetupSearchtimers::ProcessKey(eKeys Key)
eOSState state = cMenuSetupSubMenu::ProcessKey(Key);
if (iTemp_useSearchTimers != data->useSearchTimers ||
- iTemp_checkEPGHours != data->checkEPGHours)
- {
- Set();
- Display();
+ iTemp_checkEPGHours != data->checkEPGHours) {
+ Set();
+ Display();
}
const char* ItemText = Get(Current())->Text();
- if (!HasSubMenu())
- {
- if (strstr(ItemText, tr("Search templates")) == ItemText)
- iOnSearchTemplates = 1;
- else if (strstr(ItemText, tr("Blacklists")) == ItemText)
- iOnBlacklists = 1;
- if (strstr(ItemText, tr("Channel groups")) == ItemText)
- iOnChannelGroups = 1;
+ if (!HasSubMenu()) {
+ if (strstr(ItemText, tr("Search templates")) == ItemText)
+ iOnSearchTemplates = 1;
+ else if (strstr(ItemText, tr("Blacklists")) == ItemText)
+ iOnBlacklists = 1;
+ if (strstr(ItemText, tr("Channel groups")) == ItemText)
+ iOnChannelGroups = 1;
}
SetHelpKeys();
if (state == osUnknown) {
- switch (Key) {
- case kBlue:
- if (!HasSubMenu())
- {
- if (iOnSearchTemplates == 1)
- state = AddSubMenu(new cMenuEPGSearchTemplate(NULL, NULL, false));
- else if (iOnBlacklists == 1)
- state = AddSubMenu(new cMenuBlacklists);
- else if (iOnChannelGroups == 1)
- state = AddSubMenu(new cMenuChannelGroups);
- }
- break;
- case kOk:
- return osBack;
- default: break;
- }
+ switch (Key) {
+ case kBlue:
+ if (!HasSubMenu()) {
+ if (iOnSearchTemplates == 1)
+ state = AddSubMenu(new cMenuEPGSearchTemplate(NULL, NULL, false));
+ else if (iOnBlacklists == 1)
+ state = AddSubMenu(new cMenuBlacklists);
+ else if (iOnChannelGroups == 1)
+ state = AddSubMenu(new cMenuChannelGroups);
+ }
+ break;
+ case kOk:
+ return osBack;
+ default:
+ break;
+ }
}
return state;
}
@@ -773,57 +751,55 @@ eOSState cMenuSetupSearchtimers::ProcessKey(eKeys Key)
// ------------------------
// cMenuSetupTimerConflicts
cMenuSetupTimerConflicts::cMenuSetupTimerConflicts(cEPGSearchConfig* Data)
-: cMenuSetupSubMenu(tr("Timer conflict checking"), Data)
+ : cMenuSetupSubMenu(tr("Timer conflict checking"), Data)
{
Set();
}
void cMenuSetupTimerConflicts::Set()
{
- int current = Current();
- Clear();
- helpTexts.clear();
-
- Add(new cMenuEditIntItem(tr("Ignore below priority"), &data->checkMinPriority, 0, MAXPRIORITY));
- AddHelp(tr("Help$If a timer with priority below the given value will fail it will not be classified as important. Only important conflicts will produce an OSD message about the conflict after an automatic conflict check."));
- Add(new cMenuEditIntItem(tr("Ignore conflict duration less ... min."), &data->checkMinDuration, 0, 999));
- AddHelp(tr("Help$If a conflicts duration is less then the given number of minutes it will not be classified as important. Only important conflicts will produce an OSD message about the conflict after an automatic conflict check."));
- Add(new cMenuEditIntItem(tr("Only check within next ... days"), &data->checkMaxDays, 1, 14));
- AddHelp(tr("Help$This value reduces the conflict check to the given range of days. All other conflicts are classified as 'not yet important'."));
-
- Add(new cMenuEditBoolItem(tr("Check also remote conflicts"), &data->RemoteConflictCheck, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if the conflict check should be done for timers set on remote hosts. This needs SVDRPPeering to be set in vdr and Plugin epgsearch running on the remote host."));
-
- cOsdItem* sep = new cOsdItem(tr("--- Automatic checking ---"));
- sep->SetSelectable(false);
- Add(sep);
- AddHelp("dummy");
-
- Add(new cMenuEditBoolItem(tr("After each timer programming"), &data->checkTimerConflAfterTimerProg, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if the conflict check should be performed after each manual timer programming. In the case of a conflict you get immediately a message that informs you about it. The message is only displayed if this timer is involved in any conflict."));
- Add(new cMenuEditBoolItem(tr("When a recording starts"), &data->checkTimerConflOnRecording, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if the conflict check should be performed when a recording starts. In the case of a conflict you get immediately a message that informs you about it. The message is only displayed if the conflict is within the next 2 hours."));
-
- Add(new cMenuEditBoolItem(tr("After each search timer update"), &data->checkTimerConflictsAfterUpdate, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if the conflict check should be performed after each search timer update."));
- if (!data->checkTimerConflictsAfterUpdate)
- {
- Add(new cMenuEditIntItem(IndentMenuItem(tr("every ... minutes")), &data->conflictCheckIntervall, 0, 999));
- AddHelp(tr("Help$Specify here the time intervall to be used for an automatic conflict check in the background.\n('0' disables an automatic check)"));
- Add(new cMenuEditIntItem(IndentMenuItem(tr("if conflicts within next ... minutes")), &data->conflictCheckWithinLimit, 0, 9999));
- AddHelp(tr("Help$If the next conflict will appear in the given number of minutes you can specify here a shorter check intervall to get more OSD notifications about it."));
- if (data->conflictCheckWithinLimit)
- {
- Add(new cMenuEditIntItem(IndentMenuItem(IndentMenuItem(tr("every ... minutes"))), &data->conflictCheckIntervall2, 1, 999));
- AddHelp(tr("Help$If the next conflict will appear in the given number of minutes you can specify here a shorter check intervall to get more OSD notifications about it."));
- }
- }
- Add(new cMenuEditBoolItem(tr("Avoid notification when replaying"), &data->noConflMsgWhileReplay, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if the don't want to get OSD messages about conflicts if you currently replay something. Nevertheless messages will be displayed if the first upcoming conflict is within the next 2 hours."));
-
- SetCurrent(Get(current));
- Display();
- SetHelp(NULL, NULL, tr("Button$Help"), NULL);
+ int current = Current();
+ Clear();
+ helpTexts.clear();
+
+ Add(new cMenuEditIntItem(tr("Ignore below priority"), &data->checkMinPriority, 0, MAXPRIORITY));
+ AddHelp(tr("Help$If a timer with priority below the given value will fail it will not be classified as important. Only important conflicts will produce an OSD message about the conflict after an automatic conflict check."));
+ Add(new cMenuEditIntItem(tr("Ignore conflict duration less ... min."), &data->checkMinDuration, 0, 999));
+ AddHelp(tr("Help$If a conflicts duration is less then the given number of minutes it will not be classified as important. Only important conflicts will produce an OSD message about the conflict after an automatic conflict check."));
+ Add(new cMenuEditIntItem(tr("Only check within next ... days"), &data->checkMaxDays, 1, 14));
+ AddHelp(tr("Help$This value reduces the conflict check to the given range of days. All other conflicts are classified as 'not yet important'."));
+
+ Add(new cMenuEditBoolItem(tr("Check also remote conflicts"), &data->RemoteConflictCheck, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if the conflict check should be done for timers set on remote hosts. This needs SVDRPPeering to be set in vdr and Plugin epgsearch running on the remote host."));
+
+ cOsdItem* sep = new cOsdItem(tr("--- Automatic checking ---"));
+ sep->SetSelectable(false);
+ Add(sep);
+ AddHelp("dummy");
+
+ Add(new cMenuEditBoolItem(tr("After each timer programming"), &data->checkTimerConflAfterTimerProg, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if the conflict check should be performed after each manual timer programming. In the case of a conflict you get immediately a message that informs you about it. The message is only displayed if this timer is involved in any conflict."));
+ Add(new cMenuEditBoolItem(tr("When a recording starts"), &data->checkTimerConflOnRecording, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if the conflict check should be performed when a recording starts. In the case of a conflict you get immediately a message that informs you about it. The message is only displayed if the conflict is within the next 2 hours."));
+
+ Add(new cMenuEditBoolItem(tr("After each search timer update"), &data->checkTimerConflictsAfterUpdate, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if the conflict check should be performed after each search timer update."));
+ if (!data->checkTimerConflictsAfterUpdate) {
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("every ... minutes")), &data->conflictCheckIntervall, 0, 999));
+ AddHelp(tr("Help$Specify here the time intervall to be used for an automatic conflict check in the background.\n('0' disables an automatic check)"));
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("if conflicts within next ... minutes")), &data->conflictCheckWithinLimit, 0, 9999));
+ AddHelp(tr("Help$If the next conflict will appear in the given number of minutes you can specify here a shorter check intervall to get more OSD notifications about it."));
+ if (data->conflictCheckWithinLimit) {
+ Add(new cMenuEditIntItem(IndentMenuItem(IndentMenuItem(tr("every ... minutes"))), &data->conflictCheckIntervall2, 1, 999));
+ AddHelp(tr("Help$If the next conflict will appear in the given number of minutes you can specify here a shorter check intervall to get more OSD notifications about it."));
+ }
+ }
+ Add(new cMenuEditBoolItem(tr("Avoid notification when replaying"), &data->noConflMsgWhileReplay, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if the don't want to get OSD messages about conflicts if you currently replay something. Nevertheless messages will be displayed if the first upcoming conflict is within the next 2 hours."));
+
+ SetCurrent(Get(current));
+ Display();
+ SetHelp(NULL, NULL, tr("Button$Help"), NULL);
}
eOSState cMenuSetupTimerConflicts::ProcessKey(eKeys Key)
@@ -834,19 +810,19 @@ eOSState cMenuSetupTimerConflicts::ProcessKey(eKeys Key)
eOSState state = cMenuSetupSubMenu::ProcessKey(Key);
if (iTemp_checkTimerConflictsAfterUpdate != data->checkTimerConflictsAfterUpdate ||
- (iTemp_conflictCheckWithinLimit != data->conflictCheckWithinLimit && (iTemp_conflictCheckWithinLimit == 0 || data->conflictCheckWithinLimit == 0)))
- {
- Set();
- Display();
+ (iTemp_conflictCheckWithinLimit != data->conflictCheckWithinLimit && (iTemp_conflictCheckWithinLimit == 0 || data->conflictCheckWithinLimit == 0))) {
+ Set();
+ Display();
}
if (state == osUnknown) {
- switch (Key) {
- case kOk:
- return osBack;
- default: break;
- }
+ switch (Key) {
+ case kOk:
+ return osBack;
+ default:
+ break;
+ }
}
return state;
@@ -855,169 +831,155 @@ eOSState cMenuSetupTimerConflicts::ProcessKey(eKeys Key)
// --------------------------
// cMenuSetupMailNotification
cMenuSetupMailNotification::cMenuSetupMailNotification(cEPGSearchConfig* Data)
-: cMenuSetupSubMenu(tr("Email notification"), Data)
+ : cMenuSetupSubMenu(tr("Email notification"), Data)
{
- string strHidden(strlen(data->MailAuthPass), '*');
- strcpy(tmpMailAuthPass, strHidden.c_str());
- Set();
+ string strHidden(strlen(data->MailAuthPass), '*');
+ strcpy(tmpMailAuthPass, strHidden.c_str());
+ Set();
}
void cMenuSetupMailNotification::Set()
{
- int current = Current();
- Clear();
- helpTexts.clear();
-
- Add(new cMenuEditBoolItem(tr("Search timer notification"), &data->sendMailOnSearchtimers, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if you want to get an email notification about the search timers that where programmed automatically in the background."));
-
- if (data->sendMailOnSearchtimers)
- {
- Add(new cMenuEditIntItem(IndentMenuItem(tr("Time between mails [h]")), &data->sendMailOnSearchtimerHours, 0, 999999, ""));
- AddHelp(tr("Help$Specifiy how much time in [h] you would\nlike to have atleast between two mails.\nWith '0' you get a new mail after each\nsearch timer update with new results."));
- }
- Add(new cMenuEditBoolItem(tr("Timer conflict notification"), &data->sendMailOnConflicts, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if you want to get an email notification about the timer conflicts."));
-
- Add(new cMenuEditStrItem(tr("Send to"), data->MailAddressTo, sizeof(data->MailAddressTo), MailBoxChars));
- AddHelp(tr("Help$Specify the email address where notifications should be sent to."));
-
- Add(new cMenuEditStraItem(tr("Mail method"), &data->mailViaScript, 2, MailMethod));
- AddHelp(tr("Help$Specify here the method to use when sending mails.\nYou can choose between\n - 'sendmail': requires a properly configured email system\n - 'SendEmail.pl': simple script for mail delivery"));
-
- if (data->mailViaScript)
- {
- cOsdItem* sep = new cOsdItem(tr("--- Email account ---"));
- sep->SetSelectable(false);
- Add(sep);
- AddHelp(" dummy");
-
- Add(new cMenuEditStrItem(tr("Email address"), data->MailAddress, sizeof(data->MailAddress), MailBoxChars));
- AddHelp(tr("Help$Specify the email address where notifications should be sent from."));
+ int current = Current();
+ Clear();
+ helpTexts.clear();
- Add(new cMenuEditStrItem(tr("SMTP server"), data->MailServer, sizeof(data->MailServer), HostNameChars));
- AddHelp(tr("Help$Specify the SMTP server that should deliver the notifications. If it's using a port different from the default(25) append the port with \":port\"."));
- Add(new cMenuEditBoolItem(tr("Use SMTP authentication"), &data->MailUseAuth, trVDR("no"), trVDR("yes")));
- AddHelp(tr("Help$Set this to 'yes' if your account needs authentication to send mails."));
+ Add(new cMenuEditBoolItem(tr("Search timer notification"), &data->sendMailOnSearchtimers, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if you want to get an email notification about the search timers that where programmed automatically in the background."));
- if (data->MailUseAuth)
- {
- Add(new cMenuEditStrItem(IndentMenuItem(tr("Auth user")), data->MailAuthUser, sizeof(data->MailAuthUser), UserNameChars));
- AddHelp(tr("Help$Specify the auth user, if this account needs authentication for SMTP."));
- Add(new cMenuEditStrItem(IndentMenuItem(tr("Auth password")), tmpMailAuthPass, sizeof(tmpMailAuthPass), PasswordChars));
- AddHelp(tr("Help$Specify the auth password, if this account needs authentication for SMTP."));
- }
- }
+ if (data->sendMailOnSearchtimers) {
+ Add(new cMenuEditIntItem(IndentMenuItem(tr("Time between mails [h]")), &data->sendMailOnSearchtimerHours, 0, 999999, ""));
+ AddHelp(tr("Help$Specifiy how much time in [h] you would\nlike to have atleast between two mails.\nWith '0' you get a new mail after each\nsearch timer update with new results."));
+ }
+ Add(new cMenuEditBoolItem(tr("Timer conflict notification"), &data->sendMailOnConflicts, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if you want to get an email notification about the timer conflicts."));
+
+ Add(new cMenuEditStrItem(tr("Send to"), data->MailAddressTo, sizeof(data->MailAddressTo), MailBoxChars));
+ AddHelp(tr("Help$Specify the email address where notifications should be sent to."));
+
+ Add(new cMenuEditStraItem(tr("Mail method"), &data->mailViaScript, 2, MailMethod));
+ AddHelp(tr("Help$Specify here the method to use when sending mails.\nYou can choose between\n - 'sendmail': requires a properly configured email system\n - 'SendEmail.pl': simple script for mail delivery"));
+
+ if (data->mailViaScript) {
+ cOsdItem* sep = new cOsdItem(tr("--- Email account ---"));
+ sep->SetSelectable(false);
+ Add(sep);
+ AddHelp(" dummy");
+
+ Add(new cMenuEditStrItem(tr("Email address"), data->MailAddress, sizeof(data->MailAddress), MailBoxChars));
+ AddHelp(tr("Help$Specify the email address where notifications should be sent from."));
+
+ Add(new cMenuEditStrItem(tr("SMTP server"), data->MailServer, sizeof(data->MailServer), HostNameChars));
+ AddHelp(tr("Help$Specify the SMTP server that should deliver the notifications. If it's using a port different from the default(25) append the port with \":port\"."));
+ Add(new cMenuEditBoolItem(tr("Use SMTP authentication"), &data->MailUseAuth, trVDR("no"), trVDR("yes")));
+ AddHelp(tr("Help$Set this to 'yes' if your account needs authentication to send mails."));
+
+ if (data->MailUseAuth) {
+ Add(new cMenuEditStrItem(IndentMenuItem(tr("Auth user")), data->MailAuthUser, sizeof(data->MailAuthUser), UserNameChars));
+ AddHelp(tr("Help$Specify the auth user, if this account needs authentication for SMTP."));
+ Add(new cMenuEditStrItem(IndentMenuItem(tr("Auth password")), tmpMailAuthPass, sizeof(tmpMailAuthPass), PasswordChars));
+ AddHelp(tr("Help$Specify the auth password, if this account needs authentication for SMTP."));
+ }
+ }
- SetCurrent(Get(current));
- Display();
+ SetCurrent(Get(current));
+ Display();
- SetHelpKeys();
+ SetHelpKeys();
}
eOSState cMenuSetupMailNotification::TestMailAccount()
{
- if (strlen(data->MailAddress) == 0 || strlen(data->MailServer) == 0)
- return osContinue;
- cMailNotifier M;
- if (M.TestMailAccount(data->MailAddressTo, data->MailAddress, data->MailServer, data->MailAuthUser, data->MailAuthPass))
- return AddSubMenu(new cMenuText("", M.scriptReply.c_str(), fontSml));
- else
- ERROR(tr("Mail account check failed!"));
- return osContinue;
+ if (strlen(data->MailAddress) == 0 || strlen(data->MailServer) == 0)
+ return osContinue;
+ cMailNotifier M;
+ if (M.TestMailAccount(data->MailAddressTo, data->MailAddress, data->MailServer, data->MailAuthUser, data->MailAuthPass))
+ return AddSubMenu(new cMenuText("", M.scriptReply.c_str(), fontSml));
+ else
+ ERROR(tr("Mail account check failed!"));
+ return osContinue;
}
void cMenuSetupMailNotification::SetHelpKeys()
{
- bool showTestButton = strlen(data->MailAddress) > 0 && strlen(data->MailServer) > 0 && data->mailViaScript;
-
- const char* ItemText = Get(Current())->Text();
- if (!HasSubMenu())
- {
- if (strstr(ItemText, tr("Email address")) == ItemText)
- {
- if (!InEditMode(ItemText, tr("Email address"), data->MailAddress))
- SetHelp(NULL, NULL, tr("Button$Help"), showTestButton?tr("Button$Test"):NULL);
- }
- else if (strstr(ItemText, tr("SMTP server")) == ItemText)
- {
- if (!InEditMode(ItemText, tr("SMTP server"), data->MailServer))
- SetHelp(NULL, NULL, tr("Button$Help"), showTestButton?tr("Button$Test"):NULL);
- }
- else if (strstr(ItemText, tr("Use SMTP authentication")) == ItemText)
- SetHelp(NULL, NULL, tr("Button$Help"), showTestButton?tr("Button$Test"):NULL);
- else if (strstr(ItemText, IndentMenuItem(tr("Auth user"))) == ItemText)
- {
- if (!InEditMode(ItemText, IndentMenuItem(tr("Auth user")), data->MailAuthUser))
- SetHelp(NULL, NULL, tr("Button$Help"), showTestButton?tr("Button$Test"):NULL);
- }
- else if (strstr(ItemText, IndentMenuItem(tr("Auth password"))) == ItemText)
- {
- if (!InEditMode(ItemText, IndentMenuItem(tr("Auth password")), tmpMailAuthPass))
- SetHelp(NULL, NULL, tr("Button$Help"), showTestButton?tr("Button$Test"):NULL);
- }
- else
- SetHelp(NULL, NULL, tr("Button$Help"), NULL);
- }
+ bool showTestButton = strlen(data->MailAddress) > 0 && strlen(data->MailServer) > 0 && data->mailViaScript;
+
+ const char* ItemText = Get(Current())->Text();
+ if (!HasSubMenu()) {
+ if (strstr(ItemText, tr("Email address")) == ItemText) {
+ if (!InEditMode(ItemText, tr("Email address"), data->MailAddress))
+ SetHelp(NULL, NULL, tr("Button$Help"), showTestButton ? tr("Button$Test") : NULL);
+ } else if (strstr(ItemText, tr("SMTP server")) == ItemText) {
+ if (!InEditMode(ItemText, tr("SMTP server"), data->MailServer))
+ SetHelp(NULL, NULL, tr("Button$Help"), showTestButton ? tr("Button$Test") : NULL);
+ } else if (strstr(ItemText, tr("Use SMTP authentication")) == ItemText)
+ SetHelp(NULL, NULL, tr("Button$Help"), showTestButton ? tr("Button$Test") : NULL);
+ else if (strstr(ItemText, IndentMenuItem(tr("Auth user"))) == ItemText) {
+ if (!InEditMode(ItemText, IndentMenuItem(tr("Auth user")), data->MailAuthUser))
+ SetHelp(NULL, NULL, tr("Button$Help"), showTestButton ? tr("Button$Test") : NULL);
+ } else if (strstr(ItemText, IndentMenuItem(tr("Auth password"))) == ItemText) {
+ if (!InEditMode(ItemText, IndentMenuItem(tr("Auth password")), tmpMailAuthPass))
+ SetHelp(NULL, NULL, tr("Button$Help"), showTestButton ? tr("Button$Test") : NULL);
+ } else
+ SetHelp(NULL, NULL, tr("Button$Help"), NULL);
+ }
}
eOSState cMenuSetupMailNotification::ProcessKey(eKeys Key)
{
- int iTemp_MailUseAuth = data->MailUseAuth;
- int iTemp_sendMailOnSearchtimers = data->sendMailOnSearchtimers;
- int iTemp_mailViaScript = data->mailViaScript;
-
- const char* ItemText = Get(Current())->Text();
- bool bAuthPassWasInEditMode = false;
- if (ItemText && strlen(ItemText) > 0 && strstr(ItemText, IndentMenuItem(tr("Auth password"))) == ItemText)
- bAuthPassWasInEditMode = InEditMode(ItemText, IndentMenuItem(tr("Auth password")), tmpMailAuthPass);
-
- eOSState state = cMenuSetupSubMenu::ProcessKey(Key);
-
- ItemText = Get(Current())->Text();
- bool bAuthPassIsInEditMode = false;
- if (ItemText && strlen(ItemText) > 0 && strstr(ItemText, IndentMenuItem(tr("Auth password"))) == ItemText)
- bAuthPassIsInEditMode = InEditMode(ItemText, IndentMenuItem(tr("Auth password")), tmpMailAuthPass);
-
- if (bAuthPassWasInEditMode && !bAuthPassIsInEditMode)
- {
- strcpy(data->MailAuthPass, tmpMailAuthPass);
- string strHidden(strlen(data->MailAuthPass), '*');
- strcpy(tmpMailAuthPass, strHidden.c_str());
- Set();
- Display();
- }
- if (!bAuthPassWasInEditMode && bAuthPassIsInEditMode)
- {
- strcpy(tmpMailAuthPass, "");
- Set();
- Display();
- state = cMenuSetupSubMenu::ProcessKey(Key);
- }
-
- if (iTemp_MailUseAuth != data->MailUseAuth ||
- iTemp_mailViaScript != data->mailViaScript ||
- iTemp_sendMailOnSearchtimers != data->sendMailOnSearchtimers)
- {
- Set();
- Display();
- }
-
- SetHelpKeys();
-
- if (state == osUnknown) {
- switch (Key) {
- case kOk:
+ int iTemp_MailUseAuth = data->MailUseAuth;
+ int iTemp_sendMailOnSearchtimers = data->sendMailOnSearchtimers;
+ int iTemp_mailViaScript = data->mailViaScript;
+
+ const char* ItemText = Get(Current())->Text();
+ bool bAuthPassWasInEditMode = false;
+ if (ItemText && strlen(ItemText) > 0 && strstr(ItemText, IndentMenuItem(tr("Auth password"))) == ItemText)
+ bAuthPassWasInEditMode = InEditMode(ItemText, IndentMenuItem(tr("Auth password")), tmpMailAuthPass);
+
+ eOSState state = cMenuSetupSubMenu::ProcessKey(Key);
+
+ ItemText = Get(Current())->Text();
+ bool bAuthPassIsInEditMode = false;
+ if (ItemText && strlen(ItemText) > 0 && strstr(ItemText, IndentMenuItem(tr("Auth password"))) == ItemText)
+ bAuthPassIsInEditMode = InEditMode(ItemText, IndentMenuItem(tr("Auth password")), tmpMailAuthPass);
+
+ if (bAuthPassWasInEditMode && !bAuthPassIsInEditMode) {
+ strcpy(data->MailAuthPass, tmpMailAuthPass);
+ string strHidden(strlen(data->MailAuthPass), '*');
+ strcpy(tmpMailAuthPass, strHidden.c_str());
+ Set();
+ Display();
+ }
+ if (!bAuthPassWasInEditMode && bAuthPassIsInEditMode) {
+ strcpy(tmpMailAuthPass, "");
+ Set();
+ Display();
+ state = cMenuSetupSubMenu::ProcessKey(Key);
+ }
+
+ if (iTemp_MailUseAuth != data->MailUseAuth ||
+ iTemp_mailViaScript != data->mailViaScript ||
+ iTemp_sendMailOnSearchtimers != data->sendMailOnSearchtimers) {
+ Set();
+ Display();
+ }
+
+ SetHelpKeys();
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk:
return osBack;
- case kBlue:
+ case kBlue:
if (data->mailViaScript)
- return TestMailAccount();
+ return TestMailAccount();
else
- return osContinue;
- default: break;
- }
- }
+ return osContinue;
+ default:
+ break;
+ }
+ }
- return state;
+ return state;
}
diff --git a/epgsearchsetup.h b/epgsearchsetup.h
index cd3e89d..545dc09 100644
--- a/epgsearchsetup.h
+++ b/epgsearchsetup.h
@@ -30,105 +30,107 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
class cPluginEpgsearch;
-class cMenuSetupSubMenu : public cOsdMenu {
- protected:
+class cMenuSetupSubMenu : public cOsdMenu
+{
+protected:
cEPGSearchConfig* data;
std::vector<const char*> helpTexts;
eOSState Help();
void AddHelp(const char* helpText);
virtual eOSState ProcessKey(eKeys Key);
virtual void Set(void) = 0;
- public:
+public:
cMenuSetupSubMenu(const char* Title, cEPGSearchConfig* Data);
- };
+};
class cMenuSetupGeneral : public cMenuSetupSubMenu
{
- protected:
+protected:
virtual eOSState ProcessKey(eKeys Key);
void Set(void);
- public:
+public:
cMenuSetupGeneral(cEPGSearchConfig* Data);
};
class cMenuSetupEPGMenus : public cMenuSetupSubMenu
{
- protected:
+protected:
void Set(void);
void SetHelpKeys();
- public:
+public:
cMenuSetupEPGMenus(cEPGSearchConfig* Data);
};
class cMenuSetupUserdefTimes : public cMenuSetupSubMenu
{
- protected:
+protected:
virtual eOSState ProcessKey(eKeys Key);
void Set(void);
- public:
+public:
cMenuSetupUserdefTimes(cEPGSearchConfig* Data);
};
class cMenuSetupTimers : public cMenuSetupSubMenu
{
- protected:
+protected:
virtual eOSState ProcessKey(eKeys Key);
void Set(void);
void SetHelpKeys();
- public:
+public:
cMenuSetupTimers(cEPGSearchConfig* Data);
};
class cMenuSetupSearchtimers : public cMenuSetupSubMenu
{
- char** menuitemsChGr;
- protected:
+ char** menuitemsChGr;
+protected:
virtual eOSState ProcessKey(eKeys Key);
void Set(void);
void SetHelpKeys();
- public:
+public:
cMenuSetupSearchtimers(cEPGSearchConfig* Data);
~cMenuSetupSearchtimers();
};
class cMenuSetupTimerConflicts : public cMenuSetupSubMenu
{
- protected:
+protected:
virtual eOSState ProcessKey(eKeys Key);
void Set(void);
- public:
+public:
cMenuSetupTimerConflicts(cEPGSearchConfig* Data);
};
class cMenuSetupMailNotification : public cMenuSetupSubMenu
{
- char tmpMailAuthPass[MaxFileName];
- void SetHelpKeys();
- protected:
- virtual eOSState ProcessKey(eKeys Key);
- void Set(void);
- public:
- cMenuSetupMailNotification(cEPGSearchConfig* Data);
- eOSState TestMailAccount();
-
- static const char *HostNameChars;
- static const char *UserNameChars;
- static const char *PasswordChars;
- static const char *MailBoxChars;
+ char tmpMailAuthPass[MaxFileName];
+ void SetHelpKeys();
+protected:
+ virtual eOSState ProcessKey(eKeys Key);
+ void Set(void);
+public:
+ cMenuSetupMailNotification(cEPGSearchConfig* Data);
+ eOSState TestMailAccount();
+
+ static const char *HostNameChars;
+ static const char *UserNameChars;
+ static const char *PasswordChars;
+ static const char *MailBoxChars;
};
-class cMenuEPGSearchSetup : public cMenuSetupPage {
- private:
+class cMenuEPGSearchSetup : public cMenuSetupPage
+{
+private:
virtual void Setup(void);
cEPGSearchConfig data;
int delaySearchTimerThreadMode;
- protected:
+protected:
virtual eOSState ProcessKey(eKeys Key);
virtual void Store(void);
void Set(void);
- public:
+public:
cMenuEPGSearchSetup(void);
- };
+};
#endif
diff --git a/epgsearchsvdrp.c b/epgsearchsvdrp.c
index beeeaa5..d0de031 100644
--- a/epgsearchsvdrp.c
+++ b/epgsearchsvdrp.c
@@ -43,1292 +43,1009 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
using std::string;
using std::set;
-template< class Iter > Iter advance_copy( Iter it, std::size_t count = 1) { using std::advance; advance( it, count ); return it; }
+template< class Iter > Iter advance_copy(Iter it, std::size_t count = 1)
+{
+ using std::advance;
+ advance(it, count);
+ return it;
+}
extern int updateForced;
extern int exitToMainMenu;
const char **cPluginEpgsearch::SVDRPHelpPages(void)
{
- static const char *HelpPages[] = {
- "LSTS [ ID ]\n"
- " List searches.\n"
- " If the optional numeric argument ID is passed,\n"
- " only the search with the according ID is listed",
- "NEWS <settings>\n"
- " Add a new search\n",
- "DELS <ID>\n"
- " Delete search with passed ID\n",
- "EDIS <settings>\n"
- " Edit an existing search\n",
- "MODS ID ON|OFF\n"
- " Turn on/off 'Use as search timer'\n",
- "UPDS [ OSD ] [ SCAN ]\n"
- " Update search timers.\n"
- " If the optional keyword 'OSD' is passed, an OSD message\n"
- " will inform about update completion. With 'SCAN' you can\n"
- " trigger an EPG scan before the searchtimer udpate.",
- "UPDD\n"
- " Reload epgsearchdone.data",
- "SETS <ON|OFF>\n"
- " Temporarily activate or cancel the search timer background\n"
- " thread.",
- "FIND <settings>\n"
- " Search the EPG for events and receive a result list.",
- "QRYS < ID[|ID] >|<settings> \n"
- " Search the EPG for events and receive a result list\n"
- " for the given ID or any search settings. Separate multiple\n"
- " searches with '|'",
- "QRYF [hours]\n"
- " Search the EPG for favorite events with the next 24h or\n"
- " the given number of hours",
- "LSRD\n"
- " List of all recording directories used in recordings, timers,\n"
- " search timers or in epgsearchdirs.conf",
- "LSTC [ channel group name ]\n"
- " List all channel groups or if given the one with name\n"
- " group name.",
- "NEWC <channel group settings>\n"
- " Create a new channel group, format as in\n"
- " epgsearchchangrps.conf.",
- "EDIC <channel group settings>\n"
- " Modify an existing channel group, format as in\n"
- " epgsearchchangrps.conf.",
- "DELC <channel group name>\n"
- " Delete an existing channel group.",
- "RENC <old channelgroup name|new channel group name>\n"
- " Rename an existing channel group.",
- "LSTB [ ID ]\n"
- " List blacklists.\n"
- " If the optional numeric argument ID is passed,\n"
- " only the blacklist with the according ID is listed",
- "NEWB <settings>\n"
- " Add a new blacklist",
- "DELB <ID>\n"
- " Delete blacklist with passed ID",
- "EDIB <settings>\n"
- " Edit an existing blacklist",
- "LSTE [ ID ]\n"
- " List the extended EPG categories defined in\n"
- " epgsearchcats.conf or only the one with the given ID",
- "SETP [ option ]\n"
- " Get the current setup option value",
- "LSTT [ ID ]\n"
- " List search templates.\n"
- " If the optional numeric argument ID is passed,\n"
- " only the search template with the according ID\n"
- " is listed",
- "NEWT <settings>\n"
- " Add a new search template\n",
- "DELT <ID>\n"
- " Delete search template with passed ID\n",
- "EDIT <settings>\n"
- " Edit an existing search template\n",
- "DEFT [ ID ]\n"
- " Returns the ID of the default search template\n"
- " or activates a search template with ID as default",
- "LSCC [ REL ]\n"
- " Returns the current (local) timer conflicts. With the option\n"
- " 'REL' only relevant conflicts are listed",
- "MENU [ NOW|PRG|SUM ]\n"
- " Calls one of the main menus of epgsearch or the summary\n"
- " of the current event\n",
- "UPDT\n"
- " Reload search timers from epgsearch.conf",
- NULL
- };
- return HelpPages;
+ static const char *HelpPages[] = {
+ "LSTS [ ID ]\n"
+ " List searches.\n"
+ " If the optional numeric argument ID is passed,\n"
+ " only the search with the according ID is listed",
+ "NEWS <settings>\n"
+ " Add a new search\n",
+ "DELS <ID>\n"
+ " Delete search with passed ID\n",
+ "EDIS <settings>\n"
+ " Edit an existing search\n",
+ "MODS ID ON|OFF\n"
+ " Turn on/off 'Use as search timer'\n",
+ "UPDS [ OSD ] [ SCAN ]\n"
+ " Update search timers.\n"
+ " If the optional keyword 'OSD' is passed, an OSD message\n"
+ " will inform about update completion. With 'SCAN' you can\n"
+ " trigger an EPG scan before the searchtimer udpate.",
+ "UPDD\n"
+ " Reload epgsearchdone.data",
+ "SETS <ON|OFF>\n"
+ " Temporarily activate or cancel the search timer background\n"
+ " thread.",
+ "FIND <settings>\n"
+ " Search the EPG for events and receive a result list.",
+ "QRYS < ID[|ID] >|<settings> \n"
+ " Search the EPG for events and receive a result list\n"
+ " for the given ID or any search settings. Separate multiple\n"
+ " searches with '|'",
+ "QRYF [hours]\n"
+ " Search the EPG for favorite events with the next 24h or\n"
+ " the given number of hours",
+ "LSRD\n"
+ " List of all recording directories used in recordings, timers,\n"
+ " search timers or in epgsearchdirs.conf",
+ "LSTC [ channel group name ]\n"
+ " List all channel groups or if given the one with name\n"
+ " group name.",
+ "NEWC <channel group settings>\n"
+ " Create a new channel group, format as in\n"
+ " epgsearchchangrps.conf.",
+ "EDIC <channel group settings>\n"
+ " Modify an existing channel group, format as in\n"
+ " epgsearchchangrps.conf.",
+ "DELC <channel group name>\n"
+ " Delete an existing channel group.",
+ "RENC <old channelgroup name|new channel group name>\n"
+ " Rename an existing channel group.",
+ "LSTB [ ID ]\n"
+ " List blacklists.\n"
+ " If the optional numeric argument ID is passed,\n"
+ " only the blacklist with the according ID is listed",
+ "NEWB <settings>\n"
+ " Add a new blacklist",
+ "DELB <ID>\n"
+ " Delete blacklist with passed ID",
+ "EDIB <settings>\n"
+ " Edit an existing blacklist",
+ "LSTE [ ID ]\n"
+ " List the extended EPG categories defined in\n"
+ " epgsearchcats.conf or only the one with the given ID",
+ "SETP [ option ]\n"
+ " Get the current setup option value",
+ "LSTT [ ID ]\n"
+ " List search templates.\n"
+ " If the optional numeric argument ID is passed,\n"
+ " only the search template with the according ID\n"
+ " is listed",
+ "NEWT <settings>\n"
+ " Add a new search template\n",
+ "DELT <ID>\n"
+ " Delete search template with passed ID\n",
+ "EDIT <settings>\n"
+ " Edit an existing search template\n",
+ "DEFT [ ID ]\n"
+ " Returns the ID of the default search template\n"
+ " or activates a search template with ID as default",
+ "LSCC [ REL ]\n"
+ " Returns the current (local) timer conflicts. With the option\n"
+ " 'REL' only relevant conflicts are listed",
+ "MENU [ NOW|PRG|SUM ]\n"
+ " Calls one of the main menus of epgsearch or the summary\n"
+ " of the current event\n",
+ "UPDT\n"
+ " Reload search timers from epgsearch.conf",
+ NULL
+ };
+ return HelpPages;
}
cString cPluginEpgsearch::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode)
{
- if (strcasecmp(Command, "UPDS") == 0)
- {
- if (!EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
- cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
- updateForced = 1;
- if (Option)
- {
- char *pstrOptionToken, *pptr;
- char *pstrOptions=strdup(Option);
- pstrOptionToken=strtok_r(pstrOptions, " ", &pptr);
- while(pstrOptionToken)
- {
- if (strcasecmp(Option, "OSD")==0)
- updateForced |= UPDS_WITH_OSD;
- if (strcasecmp(Option, "SCAN")==0)
- updateForced |= UPDS_WITH_EPGSCAN;
- pstrOptionToken=strtok_r(NULL, "|", &pptr);
- }
- free(pstrOptions);
- }
- return cString("update triggered");
- }
- else if (strcasecmp(Command, "UPDD") == 0)
- {
- if (RecsDone.Load(AddDirectory(CONFIGDIR, "epgsearchdone.data")))
- return cString("reload successful");
- else
- return cString("reload failed");
- }
- // -----------------------
- // search timer management
- else if (strcasecmp(Command, "LSTS") == 0)
- {
- if (*Option)
- {
- if (isnumber(Option))
- {
- cSearchExt *search = SearchExts.GetSearchFromID(atol(Option));
- if (search)
- return cString(search->ToText());
- else
- {
- ReplyCode = 901;
- return cString::sprintf("search id %s not defined", Option);
- }
- }
- else
- {
- ReplyCode = 901;
- return cString::sprintf("Error in search ID \"%s\"", Option);
- }
- }
- else if (SearchExts.Count()>0)
- {
- string sBuffer;
- cMutexLock SearchExtsLock(&SearchExts);
- for (int i = 0; i < SearchExts.Count(); i++)
- {
- cSearchExt* search = SearchExts.Get(i);
- if (search)
- sBuffer += string(search->ToText()) + string((i<SearchExts.Count()-1)?"\n":"");
- }
- return sBuffer.c_str();
- }
- else
- {
- ReplyCode = 901;
- return cString("no searches defined");
- }
- }
- else if (strcasecmp(Command, "DELS") == 0)
- {
- if (*Option)
- {
- string sOption = Option;
- bool delTimers = false;
- if (strcasestr(Option, "DELT"))
- {
- delTimers = true;
- sOption = ReplaceAll(sOption, "DELT", "");
- sOption = Strip(sOption);
- }
- if (isnumber(sOption.c_str()))
- {
- long SID = atol(sOption.c_str());
- cSearchExt *search = SearchExts.GetSearchFromID(SID);
- if (search)
- {
- LogFile.Log(1,"search '%s' deleted via SVDRP", search->search);
- cMutexLock SearchExtsLock(&SearchExts);
- if (delTimers)
- search->DeleteAllTimers();
- SearchExts.Del(search);
- SearchExts.Save();
- RecsDone.RemoveSearchID(SID);
- return cString::sprintf("search id %s deleted%s", sOption.c_str(), delTimers?" with timers":"");
+ if (strcasecmp(Command, "UPDS") == 0) {
+ if (!EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
+ cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
+ updateForced = 1;
+ if (Option) {
+ char *pstrOptionToken, *pptr;
+ char *pstrOptions = strdup(Option);
+ pstrOptionToken = strtok_r(pstrOptions, " ", &pptr);
+ while (pstrOptionToken) {
+ if (strcasecmp(Option, "OSD") == 0)
+ updateForced |= UPDS_WITH_OSD;
+ if (strcasecmp(Option, "SCAN") == 0)
+ updateForced |= UPDS_WITH_EPGSCAN;
+ pstrOptionToken = strtok_r(NULL, "|", &pptr);
}
- else
- {
- ReplyCode = 901;
- return cString::sprintf("search id %s not defined", sOption.c_str());
+ free(pstrOptions);
+ }
+ return cString("update triggered");
+ } else if (strcasecmp(Command, "UPDD") == 0) {
+ if (RecsDone.Load(AddDirectory(CONFIGDIR, "epgsearchdone.data")))
+ return cString("reload successful");
+ else
+ return cString("reload failed");
+ }
+ // -----------------------
+ // search timer management
+ else if (strcasecmp(Command, "LSTS") == 0) {
+ if (*Option) {
+ if (isnumber(Option)) {
+ cSearchExt *search = SearchExts.GetSearchFromID(atol(Option));
+ if (search)
+ return cString(search->ToText());
+ else {
+ ReplyCode = 901;
+ return cString::sprintf("search id %s not defined", Option);
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("Error in search ID \"%s\"", Option);
}
- }
- else
- {
- ReplyCode = 901;
- return cString::sprintf("Error in search ID \"%s\"", Option);
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search ID");
- }
- }
- else if (strcasecmp(Command, "NEWS") == 0)
- {
- if (*Option)
- {
- cSearchExt* search = new cSearchExt;
- if (search->Parse(Option))
- {
- search->ID = SearchExts.GetNewID();
- LogFile.Log(1,"added search '%s' (%d) via SVDRP", search->search, search->ID);
+ } else if (SearchExts.Count() > 0) {
+ string sBuffer;
cMutexLock SearchExtsLock(&SearchExts);
- SearchExts.Add(search);
- SearchExts.Save();
- if (search->useAsSearchTimer && !EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
- cSearchTimerThread::Init(this, true);
- return cString::sprintf("search '%s' (with new ID %d) added", search->search, search->ID);
- }
- else
- {
+ for (int i = 0; i < SearchExts.Count(); i++) {
+ cSearchExt* search = SearchExts.Get(i);
+ if (search)
+ sBuffer += string(search->ToText()) + string((i < SearchExts.Count() - 1) ? "\n" : "");
+ }
+ return sBuffer.c_str();
+ } else {
ReplyCode = 901;
- delete search;
- return cString("Error in search settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search settings");
- }
- }
- else if (strcasecmp(Command, "EDIS") == 0)
- {
- if (*Option)
- {
- cSearchExt* search = new cSearchExt;
- if (search->Parse(Option))
- {
- cSearchExt *searchTemp = SearchExts.GetSearchFromID(search->ID);
- if (searchTemp)
- {
- searchTemp->Parse(Option);
- LogFile.Log(1,"modified search '%s' (%d) via SVDRP", searchTemp->search, searchTemp->ID);
- SearchExts.Save();
- if (searchTemp->useAsSearchTimer && !EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
- cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
-
- return cString::sprintf("search '%s' with %d modified", searchTemp->search, searchTemp->ID);
+ return cString("no searches defined");
+ }
+ } else if (strcasecmp(Command, "DELS") == 0) {
+ if (*Option) {
+ string sOption = Option;
+ bool delTimers = false;
+ if (strcasestr(Option, "DELT")) {
+ delTimers = true;
+ sOption = ReplaceAll(sOption, "DELT", "");
+ sOption = Strip(sOption);
}
- else
- {
- ReplyCode = 901;
- int ID = search->ID;
- delete search;
- return cString::sprintf("search id %d does not exists", ID);
+ if (isnumber(sOption.c_str())) {
+ long SID = atol(sOption.c_str());
+ cSearchExt *search = SearchExts.GetSearchFromID(SID);
+ if (search) {
+ LogFile.Log(1, "search '%s' deleted via SVDRP", search->search);
+ cMutexLock SearchExtsLock(&SearchExts);
+ if (delTimers)
+ search->DeleteAllTimers();
+ SearchExts.Del(search);
+ SearchExts.Save();
+ RecsDone.RemoveSearchID(SID);
+ return cString::sprintf("search id %s deleted%s", sOption.c_str(), delTimers ? " with timers" : "");
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("search id %s not defined", sOption.c_str());
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("Error in search ID \"%s\"", Option);
}
- }
- else
- {
+ } else {
ReplyCode = 901;
- delete search;
- return cString("Error in search settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search settings");
- }
- }
- else if (strcasecmp(Command, "MODS") == 0)
- {
- if (*Option)
- {
- char *tail;
- int ID = strtol(Option, &tail, 10);
- tail = skipspace(tail);
- if (!*tail)
- {
+ return cString("missing search ID");
+ }
+ } else if (strcasecmp(Command, "NEWS") == 0) {
+ if (*Option) {
+ cSearchExt* search = new cSearchExt;
+ if (search->Parse(Option)) {
+ search->ID = SearchExts.GetNewID();
+ LogFile.Log(1, "added search '%s' (%d) via SVDRP", search->search, search->ID);
+ cMutexLock SearchExtsLock(&SearchExts);
+ SearchExts.Add(search);
+ SearchExts.Save();
+ if (search->useAsSearchTimer && !EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
+ cSearchTimerThread::Init(this, true);
+ return cString::sprintf("search '%s' (with new ID %d) added", search->search, search->ID);
+ } else {
+ ReplyCode = 901;
+ delete search;
+ return cString("Error in search settings");
+ }
+ } else {
ReplyCode = 901;
- return cString::sprintf("missing parameter ON|OFF");
- }
- cSearchExt *searchTemp = SearchExts.GetSearchFromID(ID);
- if (searchTemp)
- {
- searchTemp->useAsSearchTimer = (strcasecmp(tail, "ON") == 0)?1:0;
- LogFile.Log(1,"modified search '%s' (%d) via SVDRP", searchTemp->search, searchTemp->ID);
- SearchExts.Save();
+ return cString("missing search settings");
+ }
+ } else if (strcasecmp(Command, "EDIS") == 0) {
+ if (*Option) {
+ cSearchExt* search = new cSearchExt;
+ if (search->Parse(Option)) {
+ cSearchExt *searchTemp = SearchExts.GetSearchFromID(search->ID);
+ if (searchTemp) {
+ searchTemp->Parse(Option);
+ LogFile.Log(1, "modified search '%s' (%d) via SVDRP", searchTemp->search, searchTemp->ID);
+ SearchExts.Save();
+ if (searchTemp->useAsSearchTimer && !EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
+ cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
- if (searchTemp->useAsSearchTimer && !EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
- cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
-
- return cString::sprintf("search '%s' with ID %d modified", searchTemp->search, searchTemp->ID);
- }
- else
- {
- ReplyCode = 901;
- return cString::sprintf("search id %d does not exists", ID);
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search ID");
- }
- }
- else if (strcasecmp(Command, "SETS") == 0)
- {
- if (*Option)
- {
- if (strcasecmp(Option, "ON") == 0)
- {
- if (cSearchTimerThread::m_Instance)
- {
- ReplyCode = 901;
- return cString("search timer thread already active!");
+ return cString::sprintf("search '%s' with %d modified", searchTemp->search, searchTemp->ID);
+ } else {
+ ReplyCode = 901;
+ int ID = search->ID;
+ delete search;
+ return cString::sprintf("search id %d does not exists", ID);
+ }
+ } else {
+ ReplyCode = 901;
+ delete search;
+ return cString("Error in search settings");
}
- else
- {
- LogFile.Log(1,"search timer thread started via SVDRP");
- cSearchTimerThread::Init(this);
- return cString("search timer activated.");
+ } else {
+ ReplyCode = 901;
+ return cString("missing search settings");
+ }
+ } else if (strcasecmp(Command, "MODS") == 0) {
+ if (*Option) {
+ char *tail;
+ int ID = strtol(Option, &tail, 10);
+ tail = skipspace(tail);
+ if (!*tail) {
+ ReplyCode = 901;
+ return cString::sprintf("missing parameter ON|OFF");
}
- }
- else if (strcasecmp(Option, "OFF") == 0)
- {
- if (!cSearchTimerThread::m_Instance)
- {
- ReplyCode = 901;
- return cString("search timer thread already inactive!");
+ cSearchExt *searchTemp = SearchExts.GetSearchFromID(ID);
+ if (searchTemp) {
+ searchTemp->useAsSearchTimer = (strcasecmp(tail, "ON") == 0) ? 1 : 0;
+ LogFile.Log(1, "modified search '%s' (%d) via SVDRP", searchTemp->search, searchTemp->ID);
+ SearchExts.Save();
+
+ if (searchTemp->useAsSearchTimer && !EPGSearchConfig.useSearchTimers) // enable search timer thread if necessary
+ cSearchTimerThread::Init((cPluginEpgsearch*) cPluginManager::GetPlugin("epgsearch"), true);
+
+ return cString::sprintf("search '%s' with ID %d modified", searchTemp->search, searchTemp->ID);
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("search id %d does not exists", ID);
}
- else
- {
- LogFile.Log(1,"search timer thread canceled via SVDRP");
- cSearchTimerThread::Exit();
- return cString("search timer thread canceled.");
+ } else {
+ ReplyCode = 901;
+ return cString("missing search ID");
+ }
+ } else if (strcasecmp(Command, "SETS") == 0) {
+ if (*Option) {
+ if (strcasecmp(Option, "ON") == 0) {
+ if (cSearchTimerThread::m_Instance) {
+ ReplyCode = 901;
+ return cString("search timer thread already active!");
+ } else {
+ LogFile.Log(1, "search timer thread started via SVDRP");
+ cSearchTimerThread::Init(this);
+ return cString("search timer activated.");
+ }
+ } else if (strcasecmp(Option, "OFF") == 0) {
+ if (!cSearchTimerThread::m_Instance) {
+ ReplyCode = 901;
+ return cString("search timer thread already inactive!");
+ } else {
+ LogFile.Log(1, "search timer thread canceled via SVDRP");
+ cSearchTimerThread::Exit();
+ return cString("search timer thread canceled.");
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("unknown option '%s'", Option);
}
- }
- else
- {
+ } else {
ReplyCode = 901;
- return cString::sprintf("unknown option '%s'", Option);
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing option <on|off>");
- }
- }
- else if (strcasecmp(Command, "FIND") == 0)
- {
- if (*Option)
- {
- cSearchExt* search = new cSearchExt;
- if (search->Parse(Option))
- {
- cSearchResults* results = search->Run();
- // transfer to result list
- string sBuffer;
- if (results)
- {
- results->SortBy(CompareEventTime);
- cSearchResult *result = results->First();
- while (result)
- {
- const cEvent* pEvent = result->event;
- cTimer* Timer = new cTimer(pEvent);
+ return cString("missing option <on|off>");
+ }
+ } else if (strcasecmp(Command, "FIND") == 0) {
+ if (*Option) {
+ cSearchExt* search = new cSearchExt;
+ if (search->Parse(Option)) {
+ cSearchResults* results = search->Run();
+ // transfer to result list
+ string sBuffer;
+ if (results) {
+ results->SortBy(CompareEventTime);
+ cSearchResult *result = results->First();
+ while (result) {
+ const cEvent* pEvent = result->event;
+ cTimer* Timer = new cTimer(pEvent);
- static char bufStart[25];
- static char bufEnd[25];
+ static char bufStart[25];
+ static char bufEnd[25];
- struct tm tm_r; time_t eStart = pEvent->StartTime();
- time_t eStop = pEvent->EndTime();
- time_t start = eStart - (search->MarginStart * 60);
- time_t stop = eStop + (search->MarginStop * 60);
- int Flags = Timer->Flags();
- if (search->useVPS && pEvent->Vps() && Setup.UseVps)
- {
- start = pEvent->Vps();
- stop = start + pEvent->Duration();
- }
- else
- Flags = 1; // don't use VPS, if not set in this search
+ struct tm tm_r;
+ time_t eStart = pEvent->StartTime();
+ time_t eStop = pEvent->EndTime();
+ time_t start = eStart - (search->MarginStart * 60);
+ time_t stop = eStop + (search->MarginStop * 60);
+ int Flags = Timer->Flags();
+ if (search->useVPS && pEvent->Vps() && Setup.UseVps) {
+ start = pEvent->Vps();
+ stop = start + pEvent->Duration();
+ } else
+ Flags = 1; // don't use VPS, if not set in this search
- strftime(bufStart, sizeof(bufStart), "%H%M", localtime_r(&start, &tm_r));
- strftime(bufEnd, sizeof(bufEnd), "%H%M", localtime_r(&stop, &tm_r));
+ strftime(bufStart, sizeof(bufStart), "%H%M", localtime_r(&start, &tm_r));
+ strftime(bufEnd, sizeof(bufEnd), "%H%M", localtime_r(&stop, &tm_r));
- cString cmdbuf = cString::sprintf("NEWT %d:%d:%s:%s:%s:%d:%d:%s:%s",
- Flags,
- Timer->Channel()->Number(),
- *Timer->PrintDay(start, Timer->WeekDays(), true),
- bufStart,
- bufEnd,
- search->Priority,
- search->Lifetime,
- Timer->File(),
- "");
+ cString cmdbuf = cString::sprintf("NEWT %d:%d:%s:%s:%s:%d:%d:%s:%s",
+ Flags,
+ Timer->Channel()->Number(),
+ *Timer->PrintDay(start, Timer->WeekDays(), true),
+ bufStart,
+ bufEnd,
+ search->Priority,
+ search->Lifetime,
+ Timer->File(),
+ "");
- sBuffer += string(cmdbuf) + string(results->Next(result)?"\n":"");
- delete(Timer);
- result = results->Next(result);
- }
- return sBuffer.c_str();
- }
- else
- {
- ReplyCode = 901;
- delete search;
- return cString("no results");
+ sBuffer += string(cmdbuf) + string(results->Next(result) ? "\n" : "");
+ delete(Timer);
+ result = results->Next(result);
+ }
+ return sBuffer.c_str();
+ } else {
+ ReplyCode = 901;
+ delete search;
+ return cString("no results");
+ }
+ } else {
+ ReplyCode = 901;
+ delete search;
+ return cString("Error in search settings");
}
- }
- else
- {
+ } else {
ReplyCode = 901;
- delete search;
- return cString("Error in search settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search settings");
- }
- }
- else if (strcasecmp(Command, "QRYS") == 0 || strcasecmp(Command, "QRYF") == 0)
- {
- cSearchExt *temp_SearchExt = NULL;
- cSearchResults* pCompleteSearchResults = NULL;
- if (strcasecmp(Command, "QRYS") == 0) // query one or more searches
- {
- if (*Option)
- {
- if (strchr(Option, ':'))
- {
- cSearchExt* temp_SearchExt = new cSearchExt;
- if (temp_SearchExt->Parse(Option))
- pCompleteSearchResults = temp_SearchExt->Run();
- }
- else
- {
- char *pstrSearchToken, *pptr;
- char *pstrSearch=strdup(Option);
- pstrSearchToken=strtok_r(pstrSearch, "|", &pptr);
+ return cString("missing search settings");
+ }
+ } else if (strcasecmp(Command, "QRYS") == 0 || strcasecmp(Command, "QRYF") == 0) {
+ cSearchExt *temp_SearchExt = NULL;
+ cSearchResults* pCompleteSearchResults = NULL;
+ if (strcasecmp(Command, "QRYS") == 0) { // query one or more searches
+ if (*Option) {
+ if (strchr(Option, ':')) {
+ cSearchExt* temp_SearchExt = new cSearchExt;
+ if (temp_SearchExt->Parse(Option))
+ pCompleteSearchResults = temp_SearchExt->Run();
+ } else {
+ char *pstrSearchToken, *pptr;
+ char *pstrSearch = strdup(Option);
+ pstrSearchToken = strtok_r(pstrSearch, "|", &pptr);
- while(pstrSearchToken)
- {
- cSearchExt* search = SearchExts.GetSearchFromID(atoi(pstrSearchToken));
- if (search)
- pCompleteSearchResults = search->Run(-1, false, 0, pCompleteSearchResults);
- pstrSearchToken=strtok_r(NULL, "|", &pptr);
- }
- free(pstrSearch);
+ while (pstrSearchToken) {
+ cSearchExt* search = SearchExts.GetSearchFromID(atoi(pstrSearchToken));
+ if (search)
+ pCompleteSearchResults = search->Run(-1, false, 0, pCompleteSearchResults);
+ pstrSearchToken = strtok_r(NULL, "|", &pptr);
+ }
+ free(pstrSearch);
+ }
+ } else {
+ ReplyCode = 901;
+ return cString("missing search IDs");
}
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search IDs");
- }
- }
- else // query the favorites
- {
- int hours = EPGSearchConfig.FavoritesMenuTimespan;
- if (*Option)
- hours = atoi(Option);
+ } else { // query the favorites
+ int hours = EPGSearchConfig.FavoritesMenuTimespan;
+ if (*Option)
+ hours = atoi(Option);
- cMutexLock SearchExtsLock(&SearchExts);
- cSearchExt *SearchExt = SearchExts.First();
- while (SearchExt)
- {
- if (SearchExt->useInFavorites)
- pCompleteSearchResults = SearchExt->Run(-1, false, 60*hours, pCompleteSearchResults);
- SearchExt = SearchExts.Next(SearchExt);
- }
- }
+ cMutexLock SearchExtsLock(&SearchExts);
+ cSearchExt *SearchExt = SearchExts.First();
+ while (SearchExt) {
+ if (SearchExt->useInFavorites)
+ pCompleteSearchResults = SearchExt->Run(-1, false, 60 * hours, pCompleteSearchResults);
+ SearchExt = SearchExts.Next(SearchExt);
+ }
+ }
- if (pCompleteSearchResults)
- {
- // transfer to result list
- string sBuffer;
- pCompleteSearchResults->SortBy(CompareEventTime);
- cSearchResult *result = pCompleteSearchResults->First();
- while (result && result->search)
- {
- const cEvent* pEvent = result->event;
- cTimer* Timer = new cTimer(pEvent);
+ if (pCompleteSearchResults) {
+ // transfer to result list
+ string sBuffer;
+ pCompleteSearchResults->SortBy(CompareEventTime);
+ cSearchResult *result = pCompleteSearchResults->First();
+ while (result && result->search) {
+ const cEvent* pEvent = result->event;
+ cTimer* Timer = new cTimer(pEvent);
- static char bufStart[25];
- static char bufEnd[25];
+ static char bufStart[25];
+ static char bufEnd[25];
- struct tm tm_r; time_t eStart = pEvent->StartTime();
- time_t eStop = pEvent->EndTime();
- time_t start = eStart - (result->search->MarginStart * 60);
- time_t stop = eStop + (result->search->MarginStop * 60);
- if (result->search->useVPS && pEvent->Vps() && Setup.UseVps)
- {
- start = pEvent->Vps();
- stop = start + pEvent->Duration();
- }
+ struct tm tm_r;
+ time_t eStart = pEvent->StartTime();
+ time_t eStop = pEvent->EndTime();
+ time_t start = eStart - (result->search->MarginStart * 60);
+ time_t stop = eStop + (result->search->MarginStop * 60);
+ if (result->search->useVPS && pEvent->Vps() && Setup.UseVps) {
+ start = pEvent->Vps();
+ stop = start + pEvent->Duration();
+ }
- strftime(bufStart, sizeof(bufStart), "%H%M", localtime_r(&start, &tm_r));
- strftime(bufEnd, sizeof(bufEnd), "%H%M", localtime_r(&stop, &tm_r));
+ strftime(bufStart, sizeof(bufStart), "%H%M", localtime_r(&start, &tm_r));
+ strftime(bufEnd, sizeof(bufEnd), "%H%M", localtime_r(&stop, &tm_r));
- eTimerMatch timerMatch;
- bool hasTimer = false;
- LOCK_TIMERS_READ;
- if (Timers->GetMatch(pEvent, &timerMatch))
- hasTimer = (timerMatch == tmFull);
+ eTimerMatch timerMatch;
+ bool hasTimer = false;
+ LOCK_TIMERS_READ;
+ if (Timers->GetMatch(pEvent, &timerMatch))
+ hasTimer = (timerMatch == tmFull);
- if (!result->search->useAsSearchTimer)
- result->needsTimer = false;
+ if (!result->search->useAsSearchTimer)
+ result->needsTimer = false;
- LOCK_CHANNELS_READ;
- const cChannel *channel = Channels->GetByChannelID(pEvent->ChannelID(), true,true);
- int timerMode = hasTimer?1:(result->needsTimer?2:0);
+ LOCK_CHANNELS_READ;
+ const cChannel *channel = Channels->GetByChannelID(pEvent->ChannelID(), true, true);
+ int timerMode = hasTimer ? 1 : (result->needsTimer ? 2 : 0);
- string title = pEvent->Title()?ReplaceAll(pEvent->Title(), "|", "!^pipe!^"):"";
- title = ReplaceAll(title, ":", "|");
- string shorttext = pEvent->ShortText()?ReplaceAll(pEvent->ShortText(), "|", "!^pipe!^"):"";
- shorttext = ReplaceAll(shorttext, ":", "|");
+ string title = pEvent->Title() ? ReplaceAll(pEvent->Title(), "|", "!^pipe!^") : "";
+ title = ReplaceAll(title, ":", "|");
+ string shorttext = pEvent->ShortText() ? ReplaceAll(pEvent->ShortText(), "|", "!^pipe!^") : "";
+ shorttext = ReplaceAll(shorttext, ":", "|");
- cString cmdbuf = cString::sprintf("%d:%u:%s:%s:%ld:%ld:%s:%ld:%ld:%s:%d",
- result->search->ID,
- pEvent->EventID(),
- title.c_str(),
- shorttext.c_str(),
- pEvent->StartTime(),
- pEvent->EndTime(),
- CHANNELSTRING(channel),
- timerMode>0?start:-1,
- timerMode>0?stop:-1,
- timerMode>0?result->search->BuildFile(pEvent):"",
- timerMode);
+ cString cmdbuf = cString::sprintf("%d:%u:%s:%s:%ld:%ld:%s:%ld:%ld:%s:%d",
+ result->search->ID,
+ pEvent->EventID(),
+ title.c_str(),
+ shorttext.c_str(),
+ pEvent->StartTime(),
+ pEvent->EndTime(),
+ CHANNELSTRING(channel),
+ timerMode > 0 ? start : -1,
+ timerMode > 0 ? stop : -1,
+ timerMode > 0 ? result->search->BuildFile(pEvent) : "",
+ timerMode);
- sBuffer += string(cmdbuf) + string(pCompleteSearchResults->Next(result)?"\n":"");
- delete(Timer);
- result = pCompleteSearchResults->Next(result);
- }
- if (temp_SearchExt) delete temp_SearchExt;
- if (pCompleteSearchResults) delete pCompleteSearchResults;
- return sBuffer.c_str();
- }
- else
- {
- ReplyCode = 901;
- if (temp_SearchExt) delete temp_SearchExt;
- return cString("no results");
- }
- }
- else if (strcasecmp(Command, "UPDT") == 0)
- {
- if (SearchExts.Load(AddDirectory(CONFIGDIR, "epgsearch.conf")))
- return cString("reload epgsearch.conf successful");
- else
- return cString("reload epgsearch.conf failed");
- }
- // ---------------------
- // recording directories
- else if (strcasecmp(Command, "LSRD") == 0)
- {
- cMenuDirSelect::CreateDirSet();
+ sBuffer += string(cmdbuf) + string(pCompleteSearchResults->Next(result) ? "\n" : "");
+ delete(Timer);
+ result = pCompleteSearchResults->Next(result);
+ }
+ if (temp_SearchExt) delete temp_SearchExt;
+ if (pCompleteSearchResults) delete pCompleteSearchResults;
+ return sBuffer.c_str();
+ } else {
+ ReplyCode = 901;
+ if (temp_SearchExt) delete temp_SearchExt;
+ return cString("no results");
+ }
+ } else if (strcasecmp(Command, "UPDT") == 0) {
+ if (SearchExts.Load(AddDirectory(CONFIGDIR, "epgsearch.conf")))
+ return cString("reload epgsearch.conf successful");
+ else
+ return cString("reload epgsearch.conf failed");
+ }
+ // ---------------------
+ // recording directories
+ else if (strcasecmp(Command, "LSRD") == 0) {
+ cMenuDirSelect::CreateDirSet();
- if (cMenuDirSelect::directorySet.size() > 0)
- {
- cString sBuffer("");
- std::set<string>::iterator it;
- for (it = cMenuDirSelect::directorySet.begin(); it != cMenuDirSelect::directorySet.end(); ++it)
- {
- cString sOldBuffer = sBuffer;
- sBuffer = cString::sprintf("%s%s\n", *sOldBuffer, (*it).c_str());
- }
- char* buffer = strdup(*sBuffer);
- cString sResBuffer = cString(buffer);
- free(buffer);
- return sResBuffer;
- }
- else
- {
- ReplyCode = 901;
- return cString("no recording directories found");
- }
- }
- // -------------------------
- // channel groups management
- else if (strcasecmp(Command, "LSTC") == 0)
- {
- if (*Option)
- {
- cChannelGroup *changrp = ChannelGroups.GetGroupByName(Option);
- if (changrp)
- return cString(changrp->ToText());
- else
- {
+ if (cMenuDirSelect::directorySet.size() > 0) {
+ cString sBuffer("");
+ std::set<string>::iterator it;
+ for (it = cMenuDirSelect::directorySet.begin(); it != cMenuDirSelect::directorySet.end(); ++it) {
+ cString sOldBuffer = sBuffer;
+ sBuffer = cString::sprintf("%s%s\n", *sOldBuffer, (*it).c_str());
+ }
+ char* buffer = strdup(*sBuffer);
+ cString sResBuffer = cString(buffer);
+ free(buffer);
+ return sResBuffer;
+ } else {
ReplyCode = 901;
- return cString::sprintf("channel group '%s' not defined", Option);
- }
- }
- else if (ChannelGroups.Count()>0)
- {
- cString sBuffer("");
- for (int i = 0; i < ChannelGroups.Count(); i++)
- {
- cChannelGroup *changrp = ChannelGroups.Get(i);
+ return cString("no recording directories found");
+ }
+ }
+ // -------------------------
+ // channel groups management
+ else if (strcasecmp(Command, "LSTC") == 0) {
+ if (*Option) {
+ cChannelGroup *changrp = ChannelGroups.GetGroupByName(Option);
if (changrp)
- {
- cString sOldBuffer = sBuffer;
- sBuffer = cString::sprintf("%s%s\n", *sOldBuffer, changrp->ToText());
- }
- }
- char* buffer = strdup(*sBuffer);
- cString sResBuffer = cString(buffer);
- free(buffer);
- return sResBuffer;
- }
- else
- {
- ReplyCode = 901;
- return cString("no channel groups defined");
- }
- }
- else if (strcasecmp(Command, "EDIC") == 0)
- {
- if (*Option)
- {
- cChannelGroup *changrp = new cChannelGroup;
- if (changrp->Parse(Option))
- {
- cChannelGroup *changrpTemp = ChannelGroups.GetGroupByName(changrp->name);
- if (changrpTemp)
- {
- changrpTemp->channels.Clear();
- changrpTemp->Parse(Option);
- LogFile.Log(1,"modified channel group '%s' via SVDRP", changrpTemp->name);
- ChannelGroups.Save();
- return cString::sprintf("channel group '%s' modified", changrpTemp->name);
+ return cString(changrp->ToText());
+ else {
+ ReplyCode = 901;
+ return cString::sprintf("channel group '%s' not defined", Option);
}
- else
- {
- ReplyCode = 901;
- delete changrp;
- return cString::sprintf("channel group '%s' does not exists", Option);
+ } else if (ChannelGroups.Count() > 0) {
+ cString sBuffer("");
+ for (int i = 0; i < ChannelGroups.Count(); i++) {
+ cChannelGroup *changrp = ChannelGroups.Get(i);
+ if (changrp) {
+ cString sOldBuffer = sBuffer;
+ sBuffer = cString::sprintf("%s%s\n", *sOldBuffer, changrp->ToText());
+ }
}
- }
- else
- {
+ char* buffer = strdup(*sBuffer);
+ cString sResBuffer = cString(buffer);
+ free(buffer);
+ return sResBuffer;
+ } else {
ReplyCode = 901;
- delete changrp;
- return cString("Error in channel group settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing channel group settings");
- }
- }
- else if (strcasecmp(Command, "DELC") == 0)
- {
- if (*Option)
- {
- cChannelGroup *changrp = ChannelGroups.GetGroupByName(Option);
- if (changrp)
- {
- cSearchExt* search = ChannelGroups.Used(changrp);
- if (search)
- {
- ReplyCode = 901;
- return cString::sprintf("channel group '%s' used by: %s", changrp->name, search->search);
+ return cString("no channel groups defined");
+ }
+ } else if (strcasecmp(Command, "EDIC") == 0) {
+ if (*Option) {
+ cChannelGroup *changrp = new cChannelGroup;
+ if (changrp->Parse(Option)) {
+ cChannelGroup *changrpTemp = ChannelGroups.GetGroupByName(changrp->name);
+ if (changrpTemp) {
+ changrpTemp->channels.Clear();
+ changrpTemp->Parse(Option);
+ LogFile.Log(1, "modified channel group '%s' via SVDRP", changrpTemp->name);
+ ChannelGroups.Save();
+ return cString::sprintf("channel group '%s' modified", changrpTemp->name);
+ } else {
+ ReplyCode = 901;
+ delete changrp;
+ return cString::sprintf("channel group '%s' does not exists", Option);
+ }
+ } else {
+ ReplyCode = 901;
+ delete changrp;
+ return cString("Error in channel group settings");
}
- LogFile.Log(1,"channel group '%s' deleted via SVDRP", changrp->name);
- ChannelGroups.Del(changrp);
- ChannelGroups.Save();
- return cString::sprintf("channel group '%s' deleted", Option);
- }
- else
- {
+ } else {
ReplyCode = 901;
- return cString::sprintf("channel group '%s' not defined", Option);
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing channel group");
- }
- }
- else if (strcasecmp(Command, "NEWC") == 0)
- {
- if (*Option)
- {
- cChannelGroup *changrp = new cChannelGroup;
- if (changrp->Parse(Option))
- {
- LogFile.Log(1,"added channel group '%s' via SVDRP", changrp->name);
- ChannelGroups.Add(changrp);
- ChannelGroups.Save();
- return cString::sprintf("channel group '%s' added", changrp->name);
- }
- else
- {
- ReplyCode = 901;
- delete changrp;
- return cString("Error in channel group settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing channel group settings");
- }
- }
- else if (strcasecmp(Command, "RENC") == 0)
- {
- if (*Option)
- {
- const char* pipePos = strchr(Option, '|');
- if (pipePos)
- {
- int index = pipePos - Option;
- char* oldName = strdup(Option);
- *(oldName + index) = 0;
- const char* newName = oldName + index + 1;
- if (strlen(oldName) > 0 && strlen(newName) > 0)
- {
- cChannelGroup *changrp = ChannelGroups.GetGroupByName(oldName);
- if (changrp)
- {
- strcpy(changrp->name, newName);
- cMutexLock SearchExtsLock(&SearchExts);
- cSearchExt *SearchExt = SearchExts.First();
- while (SearchExt)
- {
- if (SearchExt->useChannel == 2 &&
- SearchExt->channelGroup &&
- strcmp(SearchExt->channelGroup, oldName) == 0)
- {
- free(SearchExt->channelGroup);
- SearchExt->channelGroup = strdup(newName);
- }
- SearchExt = SearchExts.Next(SearchExt);
- }
- ChannelGroups.Save();
- SearchExts.Save();
- cString strReturn = cString::sprintf("renamed channel group '%s' to '%s'", oldName, newName);
- free(oldName);
- return strReturn;
-
- }
- else
- {
- free(oldName);
- ReplyCode = 901;
- return cString::sprintf("channel group '%s' not defined", Option);
- }
- }
- free(oldName);
- }
- ReplyCode = 901;
- return cString("Error in channel group parameters");
- }
- else
- {
- ReplyCode = 901;
- return cString("missing channel group parameters");
- }
- }
- // --------------------
- // blacklist management
- else if (strcasecmp(Command, "LSTB") == 0)
- {
- if (*Option)
- {
- if (isnumber(Option))
- {
- cBlacklist *blacklist = Blacklists.GetBlacklistFromID(atol(Option));
- if (blacklist)
- return cString(blacklist->ToText());
- else
- {
- ReplyCode = 901;
- return cString::sprintf("blacklist id %s not defined", Option);
+ return cString("missing channel group settings");
+ }
+ } else if (strcasecmp(Command, "DELC") == 0) {
+ if (*Option) {
+ cChannelGroup *changrp = ChannelGroups.GetGroupByName(Option);
+ if (changrp) {
+ cSearchExt* search = ChannelGroups.Used(changrp);
+ if (search) {
+ ReplyCode = 901;
+ return cString::sprintf("channel group '%s' used by: %s", changrp->name, search->search);
+ }
+ LogFile.Log(1, "channel group '%s' deleted via SVDRP", changrp->name);
+ ChannelGroups.Del(changrp);
+ ChannelGroups.Save();
+ return cString::sprintf("channel group '%s' deleted", Option);
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("channel group '%s' not defined", Option);
}
- }
- else
- {
+ } else {
ReplyCode = 901;
- return cString::sprintf("Error in blacklist ID \"%s\"", Option);
- }
- }
- else if (Blacklists.Count()>0)
- {
- cMutexLock BlacklistLock(&Blacklists);
- string sBuffer;
- for (int i = 0; i < Blacklists.Count(); i++)
- {
- cBlacklist *blacklist = Blacklists.Get(i);
- if (blacklist)
- sBuffer += string(blacklist->ToText()) + string((i<Blacklists.Count()-1)?"\n":"");
- }
- return sBuffer.c_str();
- }
- else
- {
- ReplyCode = 901;
- return cString("no blacklists defined");
- }
- }
- else if (strcasecmp(Command, "DELB") == 0)
- {
- if (*Option)
- {
- if (isnumber(Option))
- {
- cBlacklist *blacklist = Blacklists.GetBlacklistFromID(atol(Option));
- if (blacklist)
- {
- LogFile.Log(1,"blacklist '%s' deleted via SVDRP", blacklist->search);
- SearchExts.RemoveBlacklistID( blacklist->ID);
- cMutexLock BlacklistLock(&Blacklists);
- Blacklists.Del(blacklist);
- Blacklists.Save();
- RecsDone.RemoveSearchID(atol(Option));
- return cString::sprintf("blacklist id %s deleted", Option);
+ return cString("missing channel group");
+ }
+ } else if (strcasecmp(Command, "NEWC") == 0) {
+ if (*Option) {
+ cChannelGroup *changrp = new cChannelGroup;
+ if (changrp->Parse(Option)) {
+ LogFile.Log(1, "added channel group '%s' via SVDRP", changrp->name);
+ ChannelGroups.Add(changrp);
+ ChannelGroups.Save();
+ return cString::sprintf("channel group '%s' added", changrp->name);
+ } else {
+ ReplyCode = 901;
+ delete changrp;
+ return cString("Error in channel group settings");
}
- else
- {
- ReplyCode = 901;
- return cString::sprintf("blacklist id %s not defined", Option);
+ } else {
+ ReplyCode = 901;
+ return cString("missing channel group settings");
+ }
+ } else if (strcasecmp(Command, "RENC") == 0) {
+ if (*Option) {
+ const char* pipePos = strchr(Option, '|');
+ if (pipePos) {
+ int index = pipePos - Option;
+ char* oldName = strdup(Option);
+ *(oldName + index) = 0;
+ const char* newName = oldName + index + 1;
+ if (strlen(oldName) > 0 && strlen(newName) > 0) {
+ cChannelGroup *changrp = ChannelGroups.GetGroupByName(oldName);
+ if (changrp) {
+ strcpy(changrp->name, newName);
+ cMutexLock SearchExtsLock(&SearchExts);
+ cSearchExt *SearchExt = SearchExts.First();
+ while (SearchExt) {
+ if (SearchExt->useChannel == 2 &&
+ SearchExt->channelGroup &&
+ strcmp(SearchExt->channelGroup, oldName) == 0) {
+ free(SearchExt->channelGroup);
+ SearchExt->channelGroup = strdup(newName);
+ }
+ SearchExt = SearchExts.Next(SearchExt);
+ }
+ ChannelGroups.Save();
+ SearchExts.Save();
+ cString strReturn = cString::sprintf("renamed channel group '%s' to '%s'", oldName, newName);
+ free(oldName);
+ return strReturn;
+
+ } else {
+ free(oldName);
+ ReplyCode = 901;
+ return cString::sprintf("channel group '%s' not defined", Option);
+ }
+ }
+ free(oldName);
}
- }
- else
- {
ReplyCode = 901;
- return cString::sprintf("Error in blacklist ID \"%s\"", Option);
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing blacklist ID");
- }
- }
- else if (strcasecmp(Command, "NEWB") == 0)
- {
- if (*Option)
- {
- cBlacklist *blacklist = new cBlacklist;
- if (blacklist->Parse(Option))
- {
- blacklist->ID = Blacklists.GetNewID();
- LogFile.Log(1,"added blacklist '%s' (%d) via SVDRP", blacklist->search, blacklist->ID);
- cMutexLock BlacklistLock(&Blacklists);
- Blacklists.Add(blacklist);
- Blacklists.Save();
- return cString::sprintf("blacklist '%s' (with new ID %d) added", blacklist->search, blacklist->ID);
- }
- else
- {
+ return cString("Error in channel group parameters");
+ } else {
ReplyCode = 901;
- delete blacklist;
- return cString("Error in blacklist settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing blacklist settings");
- }
- }
- else if (strcasecmp(Command, "EDIB") == 0)
- {
- if (*Option)
- {
- cBlacklist *blacklist = new cBlacklist;
- if (blacklist->Parse(Option))
- {
- cBlacklist *blacklistTemp = Blacklists.GetBlacklistFromID(blacklist->ID);
- if (blacklistTemp)
- {
- blacklistTemp->Parse(Option);
- LogFile.Log(1,"modified blacklist '%s' (%d) via SVDRP", blacklistTemp->search, blacklistTemp->ID);
- Blacklists.Save();
- return cString::sprintf("blacklist '%s' with ID %d modified", blacklistTemp->search, blacklistTemp->ID);
+ return cString("missing channel group parameters");
+ }
+ }
+ // --------------------
+ // blacklist management
+ else if (strcasecmp(Command, "LSTB") == 0) {
+ if (*Option) {
+ if (isnumber(Option)) {
+ cBlacklist *blacklist = Blacklists.GetBlacklistFromID(atol(Option));
+ if (blacklist)
+ return cString(blacklist->ToText());
+ else {
+ ReplyCode = 901;
+ return cString::sprintf("blacklist id %s not defined", Option);
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("Error in blacklist ID \"%s\"", Option);
}
- else
- {
- ReplyCode = 901;
- int ID = blacklist->ID;
- delete blacklist;
- return cString::sprintf("blacklist id %d does not exists", ID);
+ } else if (Blacklists.Count() > 0) {
+ cMutexLock BlacklistLock(&Blacklists);
+ string sBuffer;
+ for (int i = 0; i < Blacklists.Count(); i++) {
+ cBlacklist *blacklist = Blacklists.Get(i);
+ if (blacklist)
+ sBuffer += string(blacklist->ToText()) + string((i < Blacklists.Count() - 1) ? "\n" : "");
}
- }
- else
- {
+ return sBuffer.c_str();
+ } else {
ReplyCode = 901;
- delete blacklist;
- return cString("Error in blacklist settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing blacklist settings");
- }
- }
- // ----------------------------------
- // extended EPG categories management
- else if (strcasecmp(Command, "LSTE") == 0)
- {
- if (*Option)
- {
- if (isnumber(Option))
- {
- cSearchExtCat *SearchExtCat = NULL;
- int index = SearchExtCats.GetIndexFromID(atoi(Option));
- if (index >= 0) SearchExtCat = SearchExtCats.Get(index);
- if (SearchExtCat)
- return cString(SearchExtCat->ToText());
- else
- {
- ReplyCode = 901;
- return cString::sprintf("category id %s not defined", Option);
+ return cString("no blacklists defined");
+ }
+ } else if (strcasecmp(Command, "DELB") == 0) {
+ if (*Option) {
+ if (isnumber(Option)) {
+ cBlacklist *blacklist = Blacklists.GetBlacklistFromID(atol(Option));
+ if (blacklist) {
+ LogFile.Log(1, "blacklist '%s' deleted via SVDRP", blacklist->search);
+ SearchExts.RemoveBlacklistID(blacklist->ID);
+ cMutexLock BlacklistLock(&Blacklists);
+ Blacklists.Del(blacklist);
+ Blacklists.Save();
+ RecsDone.RemoveSearchID(atol(Option));
+ return cString::sprintf("blacklist id %s deleted", Option);
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("blacklist id %s not defined", Option);
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("Error in blacklist ID \"%s\"", Option);
}
- }
- else
- {
+ } else {
ReplyCode = 901;
- return cString::sprintf("Error in category ID \"%s\"", Option);
- }
- }
- else if (SearchExtCats.Count()>0)
- {
- string sBuffer;
- for (int i = 0; i < SearchExtCats.Count(); i++)
- {
- cSearchExtCat *SearchExtCat = SearchExtCats.Get(i);
- if (SearchExtCat)
- sBuffer += string(SearchExtCat->ToText()) + string((i<SearchExtCats.Count()-1)?"\n":"");
- }
- return sBuffer.c_str();
- }
- else
- {
- ReplyCode = 901;
- return cString("no EPG categories defined");
- }
- }
- // ------------
- // setup values
- else if (strcasecmp(Command, "SETP") == 0)
- {
- if (*Option)
- {
- if (strcasecmp(Option, "ShowFavoritesMenu") == 0)
- return cString::sprintf("%d", EPGSearchConfig.showFavoritesMenu);
- else if (strcasecmp(Option, "UseSearchTimers") == 0)
- return cString::sprintf("%d", EPGSearchConfig.useSearchTimers);
- else if (strcasecmp(Option, "DefRecordingDir") == 0)
- {
- if (strlen(EPGSearchConfig.defrecdir)>0)
- return cString::sprintf("%s", EPGSearchConfig.defrecdir);
- else
- {
- ReplyCode = 901;
- return cString::sprintf("empty");
- }
- }
- else if (strcasecmp(Option, "AddSubtitleToTimerMode") == 0)
- return cString::sprintf("%d", EPGSearchConfig.addSubtitleToTimer);
- else if (strcasecmp(Option, "DefPriority") == 0)
- return cString::sprintf("%d", EPGSearchConfig.DefPriority);
- else if (strcasecmp(Option, "DefLifetime") == 0)
- return cString::sprintf("%d", EPGSearchConfig.DefLifetime);
- else if (strcasecmp(Option, "DefMarginStart") == 0)
- return cString::sprintf("%d", EPGSearchConfig.DefMarginStart);
- else if (strcasecmp(Option, "DefMarginStop") == 0)
- return cString::sprintf("%d", EPGSearchConfig.DefMarginStop);
- else if (strcasestr(Option, "DefTimerCheckMethod") == Option)
- {
- tChannelID chID;
- if (strlen(Option) > strlen("DefTimerCheckMethod")+1)
- {
- chID = tChannelID::FromString(Option + strlen("DefTimerCheckMethod")+1);
- if (!chID.Valid())
- {
- ReplyCode = 901;
- return cString::sprintf("invalid channel id");
- }
- LOCK_CHANNELS_READ;
- const cChannel *ch = Channels->GetByChannelID(chID,true,true);
- if (!ch)
- {
- ReplyCode = 901;
- return cString::sprintf("unknown channel");
- }
- return cString::sprintf("%s: %d", *ch->GetChannelID().ToString(), DefTimerCheckModes.GetMode(ch));
+ return cString("missing blacklist ID");
+ }
+ } else if (strcasecmp(Command, "NEWB") == 0) {
+ if (*Option) {
+ cBlacklist *blacklist = new cBlacklist;
+ if (blacklist->Parse(Option)) {
+ blacklist->ID = Blacklists.GetNewID();
+ LogFile.Log(1, "added blacklist '%s' (%d) via SVDRP", blacklist->search, blacklist->ID);
+ cMutexLock BlacklistLock(&Blacklists);
+ Blacklists.Add(blacklist);
+ Blacklists.Save();
+ return cString::sprintf("blacklist '%s' (with new ID %d) added", blacklist->search, blacklist->ID);
+ } else {
+ ReplyCode = 901;
+ delete blacklist;
+ return cString("Error in blacklist settings");
}
- else
- {
- LOCK_CHANNELS_READ;
- string sBuffer;
- for (int i = 0; i < Channels->Count(); i++)
- {
- const cChannel* ch = Channels->Get(i);
- if (ch && !ch->GroupSep())
- sBuffer += string(*ch->GetChannelID().ToString()) + string(": ") + NumToString(DefTimerCheckModes.GetMode(ch)) + string((i<Channels->Count()-1)?"\n":"");
- }
- return sBuffer.c_str();
- }
- }
- else
- {
+ } else {
ReplyCode = 901;
- return cString::sprintf("setup option not supported");
- }
- }
- else
- {
- string sBuffer;
- sBuffer += "ShowFavoritesMenu: " + NumToString(EPGSearchConfig.showFavoritesMenu) + "\n";
- sBuffer += "UseSearchTimers: " + NumToString(EPGSearchConfig.useSearchTimers) + "\n";
- sBuffer += "DefRecordingDir: " + string(EPGSearchConfig.defrecdir) + "\n";
- sBuffer += "AddSubtitleToTimerMode: " + NumToString(EPGSearchConfig.addSubtitleToTimer) + "\n";
- sBuffer += "DefPriority: " + NumToString(EPGSearchConfig.DefPriority) + "\n";
- sBuffer += "DefLifetime: " + NumToString(EPGSearchConfig.DefLifetime) + "\n";
- sBuffer += "DefMarginStart: " + NumToString(EPGSearchConfig.DefMarginStart) + "\n";
- sBuffer += "DefMarginStop: " + NumToString(EPGSearchConfig.DefMarginStop);
-
- return sBuffer.c_str();
- }
- }
- // ---------------------------------
- // search timer templates management
- else if (strcasecmp(Command, "LSTT") == 0)
- {
- if (*Option)
- {
- if (isnumber(Option))
- {
- cSearchExt *search = SearchTemplates.GetSearchFromID(atol(Option));
- if (search)
- return cString(search->ToText());
- else
- {
- ReplyCode = 901;
- return cString::sprintf("search template id %s not defined", Option);
+ return cString("missing blacklist settings");
+ }
+ } else if (strcasecmp(Command, "EDIB") == 0) {
+ if (*Option) {
+ cBlacklist *blacklist = new cBlacklist;
+ if (blacklist->Parse(Option)) {
+ cBlacklist *blacklistTemp = Blacklists.GetBlacklistFromID(blacklist->ID);
+ if (blacklistTemp) {
+ blacklistTemp->Parse(Option);
+ LogFile.Log(1, "modified blacklist '%s' (%d) via SVDRP", blacklistTemp->search, blacklistTemp->ID);
+ Blacklists.Save();
+ return cString::sprintf("blacklist '%s' with ID %d modified", blacklistTemp->search, blacklistTemp->ID);
+ } else {
+ ReplyCode = 901;
+ int ID = blacklist->ID;
+ delete blacklist;
+ return cString::sprintf("blacklist id %d does not exists", ID);
+ }
+ } else {
+ ReplyCode = 901;
+ delete blacklist;
+ return cString("Error in blacklist settings");
}
- }
- else
- {
+ } else {
ReplyCode = 901;
- return cString::sprintf("Error in search template ID \"%s\"", Option);
- }
- }
- else if (SearchTemplates.Count()>0)
- {
- string sBuffer;
- cMutexLock SearchExtsLock(&SearchTemplates);
- for (int i = 0; i < SearchTemplates.Count(); i++)
- {
- cSearchExt* search = SearchTemplates.Get(i);
- if (search)
- sBuffer += string(search->ToText()) + string((i<SearchTemplates.Count()-1)?"\n":"");
- }
- return sBuffer.c_str();
- }
- else
- {
- ReplyCode = 901;
- return cString("no search templates defined");
- }
- }
- else if (strcasecmp(Command, "DELT") == 0)
- {
- if (*Option)
- {
- if (isnumber(Option))
- {
- cSearchExt *search = SearchTemplates.GetSearchFromID(atoi(Option));
- if (search)
- {
- LogFile.Log(1,"search template '%s' deleted via SVDRP", search->search);
- cMutexLock SearchExtsLock(&SearchTemplates);
- SearchTemplates.Del(search);
- SearchTemplates.Save();
- return cString::sprintf("search template id %s deleted", Option);
+ return cString("missing blacklist settings");
+ }
+ }
+ // ----------------------------------
+ // extended EPG categories management
+ else if (strcasecmp(Command, "LSTE") == 0) {
+ if (*Option) {
+ if (isnumber(Option)) {
+ cSearchExtCat *SearchExtCat = NULL;
+ int index = SearchExtCats.GetIndexFromID(atoi(Option));
+ if (index >= 0) SearchExtCat = SearchExtCats.Get(index);
+ if (SearchExtCat)
+ return cString(SearchExtCat->ToText());
+ else {
+ ReplyCode = 901;
+ return cString::sprintf("category id %s not defined", Option);
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("Error in category ID \"%s\"", Option);
}
- else
- {
- ReplyCode = 901;
- return cString::sprintf("search template id %s not defined", Option);
+ } else if (SearchExtCats.Count() > 0) {
+ string sBuffer;
+ for (int i = 0; i < SearchExtCats.Count(); i++) {
+ cSearchExtCat *SearchExtCat = SearchExtCats.Get(i);
+ if (SearchExtCat)
+ sBuffer += string(SearchExtCat->ToText()) + string((i < SearchExtCats.Count() - 1) ? "\n" : "");
}
- }
- else
- {
+ return sBuffer.c_str();
+ } else {
ReplyCode = 901;
- return cString::sprintf("Error in search template ID \"%s\"", Option);
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search template ID");
- }
- }
- else if (strcasecmp(Command, "NEWT") == 0)
- {
- if (*Option)
- {
- cSearchExt* search = new cSearchExt;
- if (search->Parse(Option))
- {
- search->ID = SearchTemplates.GetNewID();
- LogFile.Log(1,"added search template '%s' (%d) via SVDRP", search->search, search->ID);
+ return cString("no EPG categories defined");
+ }
+ }
+ // ------------
+ // setup values
+ else if (strcasecmp(Command, "SETP") == 0) {
+ if (*Option) {
+ if (strcasecmp(Option, "ShowFavoritesMenu") == 0)
+ return cString::sprintf("%d", EPGSearchConfig.showFavoritesMenu);
+ else if (strcasecmp(Option, "UseSearchTimers") == 0)
+ return cString::sprintf("%d", EPGSearchConfig.useSearchTimers);
+ else if (strcasecmp(Option, "DefRecordingDir") == 0) {
+ if (strlen(EPGSearchConfig.defrecdir) > 0)
+ return cString::sprintf("%s", EPGSearchConfig.defrecdir);
+ else {
+ ReplyCode = 901;
+ return cString::sprintf("empty");
+ }
+ } else if (strcasecmp(Option, "AddSubtitleToTimerMode") == 0)
+ return cString::sprintf("%d", EPGSearchConfig.addSubtitleToTimer);
+ else if (strcasecmp(Option, "DefPriority") == 0)
+ return cString::sprintf("%d", EPGSearchConfig.DefPriority);
+ else if (strcasecmp(Option, "DefLifetime") == 0)
+ return cString::sprintf("%d", EPGSearchConfig.DefLifetime);
+ else if (strcasecmp(Option, "DefMarginStart") == 0)
+ return cString::sprintf("%d", EPGSearchConfig.DefMarginStart);
+ else if (strcasecmp(Option, "DefMarginStop") == 0)
+ return cString::sprintf("%d", EPGSearchConfig.DefMarginStop);
+ else if (strcasestr(Option, "DefTimerCheckMethod") == Option) {
+ tChannelID chID;
+ if (strlen(Option) > strlen("DefTimerCheckMethod") + 1) {
+ chID = tChannelID::FromString(Option + strlen("DefTimerCheckMethod") + 1);
+ if (!chID.Valid()) {
+ ReplyCode = 901;
+ return cString::sprintf("invalid channel id");
+ }
+ LOCK_CHANNELS_READ;
+ const cChannel *ch = Channels->GetByChannelID(chID, true, true);
+ if (!ch) {
+ ReplyCode = 901;
+ return cString::sprintf("unknown channel");
+ }
+ return cString::sprintf("%s: %d", *ch->GetChannelID().ToString(), DefTimerCheckModes.GetMode(ch));
+ } else {
+ LOCK_CHANNELS_READ;
+ string sBuffer;
+ for (int i = 0; i < Channels->Count(); i++) {
+ const cChannel* ch = Channels->Get(i);
+ if (ch && !ch->GroupSep())
+ sBuffer += string(*ch->GetChannelID().ToString()) + string(": ") + NumToString(DefTimerCheckModes.GetMode(ch)) + string((i < Channels->Count() - 1) ? "\n" : "");
+ }
+ return sBuffer.c_str();
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("setup option not supported");
+ }
+ } else {
+ string sBuffer;
+ sBuffer += "ShowFavoritesMenu: " + NumToString(EPGSearchConfig.showFavoritesMenu) + "\n";
+ sBuffer += "UseSearchTimers: " + NumToString(EPGSearchConfig.useSearchTimers) + "\n";
+ sBuffer += "DefRecordingDir: " + string(EPGSearchConfig.defrecdir) + "\n";
+ sBuffer += "AddSubtitleToTimerMode: " + NumToString(EPGSearchConfig.addSubtitleToTimer) + "\n";
+ sBuffer += "DefPriority: " + NumToString(EPGSearchConfig.DefPriority) + "\n";
+ sBuffer += "DefLifetime: " + NumToString(EPGSearchConfig.DefLifetime) + "\n";
+ sBuffer += "DefMarginStart: " + NumToString(EPGSearchConfig.DefMarginStart) + "\n";
+ sBuffer += "DefMarginStop: " + NumToString(EPGSearchConfig.DefMarginStop);
+
+ return sBuffer.c_str();
+ }
+ }
+ // ---------------------------------
+ // search timer templates management
+ else if (strcasecmp(Command, "LSTT") == 0) {
+ if (*Option) {
+ if (isnumber(Option)) {
+ cSearchExt *search = SearchTemplates.GetSearchFromID(atol(Option));
+ if (search)
+ return cString(search->ToText());
+ else {
+ ReplyCode = 901;
+ return cString::sprintf("search template id %s not defined", Option);
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("Error in search template ID \"%s\"", Option);
+ }
+ } else if (SearchTemplates.Count() > 0) {
+ string sBuffer;
cMutexLock SearchExtsLock(&SearchTemplates);
- SearchTemplates.Add(search);
- SearchTemplates.Save();
- return cString::sprintf("search template '%s' (with new ID %d) added", search->search, search->ID);
- }
- else
- {
+ for (int i = 0; i < SearchTemplates.Count(); i++) {
+ cSearchExt* search = SearchTemplates.Get(i);
+ if (search)
+ sBuffer += string(search->ToText()) + string((i < SearchTemplates.Count() - 1) ? "\n" : "");
+ }
+ return sBuffer.c_str();
+ } else {
ReplyCode = 901;
- delete search;
- return cString("Error in search template settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search template settings");
- }
- }
- else if (strcasecmp(Command, "EDIT") == 0)
- {
- if (*Option)
- {
- cSearchExt* search = new cSearchExt;
- if (search->Parse(Option))
- {
- cSearchExt *searchTemp = SearchTemplates.GetSearchFromID(search->ID);
- if (searchTemp)
- {
- searchTemp->Parse(Option);
- LogFile.Log(1,"modified search template '%s' (%d) via SVDRP", searchTemp->search, searchTemp->ID);
- SearchTemplates.Save();
- return cString::sprintf("search template '%s' with ID %d modified", searchTemp->search, searchTemp->ID);
+ return cString("no search templates defined");
+ }
+ } else if (strcasecmp(Command, "DELT") == 0) {
+ if (*Option) {
+ if (isnumber(Option)) {
+ cSearchExt *search = SearchTemplates.GetSearchFromID(atoi(Option));
+ if (search) {
+ LogFile.Log(1, "search template '%s' deleted via SVDRP", search->search);
+ cMutexLock SearchExtsLock(&SearchTemplates);
+ SearchTemplates.Del(search);
+ SearchTemplates.Save();
+ return cString::sprintf("search template id %s deleted", Option);
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("search template id %s not defined", Option);
+ }
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("Error in search template ID \"%s\"", Option);
}
- else
- {
- ReplyCode = 901;
- int ID = search->ID;
- delete search;
- return cString::sprintf("search template id %d does not exists", ID);
+ } else {
+ ReplyCode = 901;
+ return cString("missing search template ID");
+ }
+ } else if (strcasecmp(Command, "NEWT") == 0) {
+ if (*Option) {
+ cSearchExt* search = new cSearchExt;
+ if (search->Parse(Option)) {
+ search->ID = SearchTemplates.GetNewID();
+ LogFile.Log(1, "added search template '%s' (%d) via SVDRP", search->search, search->ID);
+ cMutexLock SearchExtsLock(&SearchTemplates);
+ SearchTemplates.Add(search);
+ SearchTemplates.Save();
+ return cString::sprintf("search template '%s' (with new ID %d) added", search->search, search->ID);
+ } else {
+ ReplyCode = 901;
+ delete search;
+ return cString("Error in search template settings");
}
- }
- else
- {
+ } else {
ReplyCode = 901;
- delete search;
- return cString("Error in search template settings");
- }
- }
- else
- {
- ReplyCode = 901;
- return cString("missing search template settings");
- }
- }
- else if (strcasecmp(Command, "DEFT") == 0)
- {
- if (*Option)
- {
- cSearchExt *searchTemp = SearchTemplates.GetSearchFromID(atoi(Option));
- if (searchTemp)
- {
- LogFile.Log(1,"set search template '%s' (%d) as default via SVDRP", searchTemp->search, searchTemp->ID);
- EPGSearchConfig.DefSearchTemplateID = searchTemp->ID;
- cPluginManager::GetPlugin("epgsearch")->SetupStore("DefSearchTemplateID", EPGSearchConfig.DefSearchTemplateID);
- return cString::sprintf("search template '%s' with ID %d set as default", searchTemp->search, searchTemp->ID);
- }
- else
- {
+ return cString("missing search template settings");
+ }
+ } else if (strcasecmp(Command, "EDIT") == 0) {
+ if (*Option) {
+ cSearchExt* search = new cSearchExt;
+ if (search->Parse(Option)) {
+ cSearchExt *searchTemp = SearchTemplates.GetSearchFromID(search->ID);
+ if (searchTemp) {
+ searchTemp->Parse(Option);
+ LogFile.Log(1, "modified search template '%s' (%d) via SVDRP", searchTemp->search, searchTemp->ID);
+ SearchTemplates.Save();
+ return cString::sprintf("search template '%s' with ID %d modified", searchTemp->search, searchTemp->ID);
+ } else {
+ ReplyCode = 901;
+ int ID = search->ID;
+ delete search;
+ return cString::sprintf("search template id %d does not exists", ID);
+ }
+ } else {
+ ReplyCode = 901;
+ delete search;
+ return cString("Error in search template settings");
+ }
+ } else {
ReplyCode = 901;
- return cString::sprintf("search template id %s does not exists", Option);
- }
- }
- else
- return cString::sprintf("%d", EPGSearchConfig.DefSearchTemplateID);
- }
+ return cString("missing search template settings");
+ }
+ } else if (strcasecmp(Command, "DEFT") == 0) {
+ if (*Option) {
+ cSearchExt *searchTemp = SearchTemplates.GetSearchFromID(atoi(Option));
+ if (searchTemp) {
+ LogFile.Log(1, "set search template '%s' (%d) as default via SVDRP", searchTemp->search, searchTemp->ID);
+ EPGSearchConfig.DefSearchTemplateID = searchTemp->ID;
+ cPluginManager::GetPlugin("epgsearch")->SetupStore("DefSearchTemplateID", EPGSearchConfig.DefSearchTemplateID);
+ return cString::sprintf("search template '%s' with ID %d set as default", searchTemp->search, searchTemp->ID);
+ } else {
+ ReplyCode = 901;
+ return cString::sprintf("search template id %s does not exists", Option);
+ }
+ } else
+ return cString::sprintf("%d", EPGSearchConfig.DefSearchTemplateID);
+ }
- // ---------------------------------
- // timer conflicts
- else if (strcasecmp(Command, "LSCC") == 0)
- {
- bool relOnly = false;
- if (*Option && strcasecmp(Option, "REL") == 0)
- relOnly = true;
+ // ---------------------------------
+ // timer conflicts
+ else if (strcasecmp(Command, "LSCC") == 0) {
+ bool relOnly = false;
+ if (*Option && strcasecmp(Option, "REL") == 0)
+ relOnly = true;
- LogFile.Log(3,"svdrp LSCC");
- cConflictCheck conflictCheck;
- conflictCheck.SetLocal(); // including remote timers results in an infinite loop
- conflictCheck.Check();
+ LogFile.Log(3, "svdrp LSCC");
+ cConflictCheck conflictCheck;
+ conflictCheck.SetLocal(); // including remote timers results in an infinite loop
+ conflictCheck.Check();
- if ((relOnly && conflictCheck.numConflicts > 0) ||
- conflictCheck.relevantConflicts > 0)
- {
- string sBuffer;
- cList<cConflictCheckTime>* failedList = conflictCheck.GetFailed();
- for(cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct))
- {
- if (relOnly && ct->ignore) continue;
+ if ((relOnly && conflictCheck.numConflicts > 0) ||
+ conflictCheck.relevantConflicts > 0) {
+ string sBuffer;
+ cList<cConflictCheckTime>* failedList = conflictCheck.GetFailed();
+ for (cConflictCheckTime* ct = failedList->First(); ct; ct = failedList->Next(ct)) {
+ if (relOnly && ct->ignore) continue;
- std::ostringstream conflline;
- conflline << ct->evaltime << ":";
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator it;
+ std::ostringstream conflline;
+ conflline << ct->evaltime << ":";
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator it;
- std::ostringstream timerparts;
- for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it)
- {
- if (relOnly && (*it)->ignore) continue;
- std::ostringstream timerpart;
- int recPart = (*it)->recDuration * 100 / ((*it)->stop - (*it)->start);
- timerpart << (*it)->timer->Id() << "|" << recPart << "|";
- std::set<cConflictCheckTimerObj*,TimerObjSort>::iterator itcc;
- if ((*it)->concurrentTimers)
- {
- std::ostringstream cctimers;
- for (itcc = (*it)->concurrentTimers->begin(); itcc != (*it)->concurrentTimers->end(); ++itcc)
- cctimers << (cctimers.str().empty()?"":"#") << (*itcc)->timer->Id();
- timerpart << cctimers.str();
- }
- timerparts << (timerparts.str().empty()?"":":") << timerpart.str();
- }
- conflline << timerparts.str();
- sBuffer += conflline.str() + "\n";
- }
- return sBuffer.c_str();
- }
- else
- {
- ReplyCode = 901;
- return cString("no conflicts found");
- }
- }
- else if (strcasecmp(Command, "MENU") == 0)
- {
- if (*Option)
- {
- if (cMenuSearchMain::forceMenu == 0)
- {
- if (strcasecmp(Option, "PRG") == 0)
- cMenuSearchMain::forceMenu = 2;
- else if (strcasecmp(Option, "NOW") == 0)
- cMenuSearchMain::forceMenu = 1;
- else if (strcasecmp(Option, "SUM") == 0)
- cMenuSearchMain::forceMenu = 3;
- else
- {
- ReplyCode = 901;
- return cString::sprintf("unknown option '%s'", Option);
- }
- cRemote::CallPlugin("epgsearch");
- return "menu called";
- }
- else
- {
- cRemote::Put(kBack);
- exitToMainMenu = 1;
- return "menu closed";
- }
- }
- }
+ std::ostringstream timerparts;
+ for (it = ct->failedTimers.begin(); it != ct->failedTimers.end(); ++it) {
+ if (relOnly && (*it)->ignore) continue;
+ std::ostringstream timerpart;
+ int recPart = (*it)->recDuration * 100 / ((*it)->stop - (*it)->start);
+ timerpart << (*it)->timer->Id() << "|" << recPart << "|";
+ std::set<cConflictCheckTimerObj*, TimerObjSort>::iterator itcc;
+ if ((*it)->concurrentTimers) {
+ std::ostringstream cctimers;
+ for (itcc = (*it)->concurrentTimers->begin(); itcc != (*it)->concurrentTimers->end(); ++itcc)
+ cctimers << (cctimers.str().empty() ? "" : "#") << (*itcc)->timer->Id();
+ timerpart << cctimers.str();
+ }
+ timerparts << (timerparts.str().empty() ? "" : ":") << timerpart.str();
+ }
+ conflline << timerparts.str();
+ sBuffer += conflline.str() + "\n";
+ }
+ return sBuffer.c_str();
+ } else {
+ ReplyCode = 901;
+ return cString("no conflicts found");
+ }
+ } else if (strcasecmp(Command, "MENU") == 0) {
+ if (*Option) {
+ if (cMenuSearchMain::forceMenu == 0) {
+ if (strcasecmp(Option, "PRG") == 0)
+ cMenuSearchMain::forceMenu = 2;
+ else if (strcasecmp(Option, "NOW") == 0)
+ cMenuSearchMain::forceMenu = 1;
+ else if (strcasecmp(Option, "SUM") == 0)
+ cMenuSearchMain::forceMenu = 3;
+ else {
+ ReplyCode = 901;
+ return cString::sprintf("unknown option '%s'", Option);
+ }
+ cRemote::CallPlugin("epgsearch");
+ return "menu called";
+ } else {
+ cRemote::Put(kBack);
+ exitToMainMenu = 1;
+ return "menu closed";
+ }
+ }
+ }
- return NULL;
+ return NULL;
}
diff --git a/epgsearchtools.c b/epgsearchtools.c
index 76b1b9a..614248a 100644
--- a/epgsearchtools.c
+++ b/epgsearchtools.c
@@ -56,492 +56,456 @@ extern bool isUTF8;
int CompareEventTime(const void *p1, const void *p2)
{
- time_t time1 = (*(cSearchResult **)p1)->event->StartTime();
- time_t time2 = (*(cSearchResult **)p2)->event->StartTime();
- if (time1 == time2)
- return (int)(ChannelNrFromEvent((*(cSearchResult **)p1)->event) -
- ChannelNrFromEvent((*(cSearchResult **)p2)->event));
- else
- return (int)(time1 - time2);
+ time_t time1 = (*(cSearchResult **)p1)->event->StartTime();
+ time_t time2 = (*(cSearchResult **)p2)->event->StartTime();
+ if (time1 == time2)
+ return (int)(ChannelNrFromEvent((*(cSearchResult **)p1)->event) -
+ ChannelNrFromEvent((*(cSearchResult **)p2)->event));
+ else
+ return (int)(time1 - time2);
}
int CompareEventChannel(const void *p1, const void *p2)
{
- int ch1 = ChannelNrFromEvent((*(cSearchResult **)p1)->event);
- int ch2 = ChannelNrFromEvent((*(cSearchResult **)p2)->event);
- if (ch1 == ch2)
- return (int)((*(cSearchResult **)p1)->event->StartTime() -
- (*(cSearchResult **)p2)->event->StartTime());
- else
- return ch1 - ch2;
+ int ch1 = ChannelNrFromEvent((*(cSearchResult **)p1)->event);
+ int ch2 = ChannelNrFromEvent((*(cSearchResult **)p2)->event);
+ if (ch1 == ch2)
+ return (int)((*(cSearchResult **)p1)->event->StartTime() -
+ (*(cSearchResult **)p2)->event->StartTime());
+ else
+ return ch1 - ch2;
}
int CompareSearchExtPrioDescTerm(const void *p1, const void *p2)
{
- int prio1 = (*(cSearchExt **)p1)->Priority;
- int prio2 = (*(cSearchExt **)p2)->Priority;
- if (prio2 != prio1)
- return prio2 - prio1;
- else
- return strcmp((*(cSearchExt **)p1)->search, (*(cSearchExt **)p2)->search);
+ int prio1 = (*(cSearchExt **)p1)->Priority;
+ int prio2 = (*(cSearchExt **)p2)->Priority;
+ if (prio2 != prio1)
+ return prio2 - prio1;
+ else
+ return strcmp((*(cSearchExt **)p1)->search, (*(cSearchExt **)p2)->search);
}
cString IndentMenuItem(const char* szString, int indentions)
{
- char* szIndented = NULL;
- msprintf(&szIndented, "%*s", strlen(szString)+indentions*2, szString);
- cString szIndentedStr(szIndented, true /*take pointer*/);
- return szIndentedStr;
+ char* szIndented = NULL;
+ msprintf(&szIndented, "%*s", strlen(szString) + indentions * 2, szString);
+ cString szIndentedStr(szIndented, true /*take pointer*/);
+ return szIndentedStr;
}
bool MatchesSearchMode(const char* szTest, const char* searchText, int mode, const char* delim, int tolerance)
{
- if (szTest && *szTest)
- {
- if (mode == 0) // substring
- return (strstr(szTest, searchText) != NULL);
- else if (mode == 1 || mode == 2) // AND or OR
- {
- bool bTesting = false;
- char *pstrSearchToken, *pptr;
- bool bFirst=true;
- char *pstrSearch=strdup(searchText);
- pstrSearchToken=strtok_r(pstrSearch, delim, &pptr);
- while(pstrSearchToken)
- {
- if(szTest && strstr(szTest, skipspace(pstrSearchToken)))
- {
- if(mode==1)
- { // means AND
- if(bFirst)
- {
- bTesting=true;
- bFirst=false;
- }
- else
- bTesting&=true;
- }
- else
- bTesting|=true;
+ if (szTest && *szTest) {
+ if (mode == 0) // substring
+ return (strstr(szTest, searchText) != NULL);
+ else if (mode == 1 || mode == 2) { // AND or OR
+ bool bTesting = false;
+ char *pstrSearchToken, *pptr;
+ bool bFirst = true;
+ char *pstrSearch = strdup(searchText);
+ pstrSearchToken = strtok_r(pstrSearch, delim, &pptr);
+ while (pstrSearchToken) {
+ if (szTest && strstr(szTest, skipspace(pstrSearchToken))) {
+ if (mode == 1) {
+ // means AND
+ if (bFirst) {
+ bTesting = true;
+ bFirst = false;
+ } else
+ bTesting &= true;
+ } else
+ bTesting |= true;
+ } else {
+ // not found!!
+ if (mode == 1) {
+ // means AND
+ bTesting = false;
+ bFirst = false;
+ }
+ }
+ pstrSearchToken = strtok_r(NULL, delim, &pptr);
}
+ free(pstrSearch);
+ return bTesting;
+ } else if (mode == 3) { // match exactly
+ if (strcmp(szTest, searchText) == 0)
+ return true;
else
- {// not found!!
- if(mode==1)
- { // means AND
- bTesting=false;
- bFirst=false;
- }
+ return false;
+ } else if (mode == 4) { // regexp
+ regex_t re;
+
+ if (0 == regcomp(&re, searchText, REG_EXTENDED | REG_NOSUB)) {
+ int status = regexec(&re, szTest, 0, NULL, 0);
+ regfree(&re);
+ return (status == 0);
}
- pstrSearchToken=strtok_r(NULL, delim, &pptr);
- }
- free(pstrSearch);
- return bTesting;
- }
- else if (mode == 3) // match exactly
- {
- if (strcmp(szTest, searchText) == 0)
- return true;
- else
return false;
- }
- else if (mode == 4) // regexp
- {
- regex_t re;
-
- if ( 0 == regcomp(&re, searchText, REG_EXTENDED | REG_NOSUB) )
- {
- int status = regexec( &re, szTest, 0, NULL, 0);
- regfree(&re);
- return (status == 0);
- }
- return false;
- }
- else if (mode == 5) // fuzzy
- {
- AFUZZY af = { NULL, NULL, NULL, NULL, NULL, NULL, { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 };
- string query = searchText?searchText:"";
- if (query.size() > 32) query = query.substr(0, 32);
- afuzzy_init(query.c_str(), tolerance, 0, &af);
- /* Checking substring */
- int res = afuzzy_checkSUB(szTest, &af);
- afuzzy_free(&af);
- return (res > 0);
- }
- else if (mode >= 10 && mode <= 15)
- {
- int testvalue = atoi(szTest);
- int value = atoi(searchText);
- if (value == 0) return true;
-
- if (mode == 10) // less
- return testvalue < value;
- else if (mode == 11) // less or equal
- return testvalue <= value;
- else if (mode == 12) // greater
- return testvalue > value;
- else if (mode == 13) // greater or equal
- return testvalue >= value;
- else if (mode == 14) // equal
- return testvalue == value;
- else if (mode == 15) // not equal
- return testvalue != value;
- }
- }
- return false;
+ } else if (mode == 5) { // fuzzy
+ AFUZZY af = { NULL, NULL, NULL, NULL, NULL, NULL, { 0 }, { 0 }, 0, 0, 0, 0, 0, 0 };
+ string query = searchText ? searchText : "";
+ if (query.size() > 32) query = query.substr(0, 32);
+ afuzzy_init(query.c_str(), tolerance, 0, &af);
+ /* Checking substring */
+ int res = afuzzy_checkSUB(szTest, &af);
+ afuzzy_free(&af);
+ return (res > 0);
+ } else if (mode >= 10 && mode <= 15) {
+ int testvalue = atoi(szTest);
+ int value = atoi(searchText);
+ if (value == 0) return true;
+
+ if (mode == 10) // less
+ return testvalue < value;
+ else if (mode == 11) // less or equal
+ return testvalue <= value;
+ else if (mode == 12) // greater
+ return testvalue > value;
+ else if (mode == 13) // greater or equal
+ return testvalue >= value;
+ else if (mode == 14) // equal
+ return testvalue == value;
+ else if (mode == 15) // not equal
+ return testvalue != value;
+ }
+ }
+ return false;
}
void ToLower(char* szText)
{
- if (!szText)
- return;
-
- if (!isUTF8)
- {
- for (int loop = 0; szText[loop] !=0; loop++)
- szText[loop] = tolower(szText[loop]);
- return;
- }
- else
- {
- int length = strlen(szText)+1;
- uint* valueUtf8 = new uint[length];
- int lengthUtf8 = Utf8ToArray(szText, valueUtf8, length);
- for(int i=0; i<lengthUtf8; i++)
- valueUtf8[i] = Utf8to(lower, valueUtf8[i]);
- Utf8FromArray(valueUtf8, szText, length);
- delete [] valueUtf8;
- }
+ if (!szText)
+ return;
+
+ if (!isUTF8) {
+ for (int loop = 0; szText[loop] != 0; loop++)
+ szText[loop] = tolower(szText[loop]);
+ return;
+ } else {
+ int length = strlen(szText) + 1;
+ uint* valueUtf8 = new uint[length];
+ int lengthUtf8 = Utf8ToArray(szText, valueUtf8, length);
+ for (int i = 0; i < lengthUtf8; i++)
+ valueUtf8[i] = Utf8to(lower, valueUtf8[i]);
+ Utf8FromArray(valueUtf8, szText, length);
+ delete [] valueUtf8;
+ }
}
char* GetExtEPGValue(const cEvent* e, cSearchExtCat* SearchExtCat)
{
- if (!e || !SearchExtCat)
- return NULL;
- return GetExtEPGValue(e->Description(), SearchExtCat->name, SearchExtCat->format);
+ if (!e || !SearchExtCat)
+ return NULL;
+ return GetExtEPGValue(e->Description(), SearchExtCat->name, SearchExtCat->format);
}
char* GetExtEPGValue(const char* description, const char* catname, const char *format)
{
- if (isempty(description))
- return NULL;
- char* tmp1 = NULL;
- char* tmp2 = NULL;
-
- // search the category, must be the first line or at the beginning of a line
- if (msprintf(&tmp1, "\n%s: ", catname)==-1 ||
- msprintf(&tmp2, "%s: ", catname)==-1)
- return NULL;
- char* descr = strdup(description);
- char* cat = NULL;
- int valueOffset = 0;
- if ((cat = strstr(descr, tmp1)) != NULL)
- {
- cat++; // skip linefeed
- valueOffset = strlen(tmp1);
- }
- else if (strstr(descr, tmp2) == descr) // in first line
- {
- cat = descr;
- valueOffset = strlen(tmp2)+1;
- }
- else
- {
- free(descr);
- free(tmp1);
- free(tmp2);
- return NULL;
- }
-
- // search the value to appear before the next line feed or end
- char* end = strchr(cat, '\n');
- int endpos = strlen(cat);
- if (end)
- endpos = end - cat;
- cat[endpos] = 0;
-
- char* value = NULL;
- msprintf(&value, "%s", cat + valueOffset - 1);
- if (format)
- {
- int ivalue;
- if (sscanf(value,"%8i",&ivalue)==1)
- {
- free(value);
- value = NULL;
- msprintf(&value, format, ivalue);
- }
- }
- free(descr);
- free(tmp1);
- free(tmp2);
-
- return value;
+ if (isempty(description))
+ return NULL;
+ char* tmp1 = NULL;
+ char* tmp2 = NULL;
+
+ // search the category, must be the first line or at the beginning of a line
+ if (msprintf(&tmp1, "\n%s: ", catname) == -1 ||
+ msprintf(&tmp2, "%s: ", catname) == -1)
+ return NULL;
+ char* descr = strdup(description);
+ char* cat = NULL;
+ int valueOffset = 0;
+ if ((cat = strstr(descr, tmp1)) != NULL) {
+ cat++; // skip linefeed
+ valueOffset = strlen(tmp1);
+ } else if (strstr(descr, tmp2) == descr) { // in first line
+ cat = descr;
+ valueOffset = strlen(tmp2) + 1;
+ } else {
+ free(descr);
+ free(tmp1);
+ free(tmp2);
+ return NULL;
+ }
+
+ // search the value to appear before the next line feed or end
+ char* end = strchr(cat, '\n');
+ int endpos = strlen(cat);
+ if (end)
+ endpos = end - cat;
+ cat[endpos] = 0;
+
+ char* value = NULL;
+ msprintf(&value, "%s", cat + valueOffset - 1);
+ if (format) {
+ int ivalue;
+ if (sscanf(value, "%8i", &ivalue) == 1) {
+ free(value);
+ value = NULL;
+ msprintf(&value, format, ivalue);
+ }
+ }
+ free(descr);
+ free(tmp1);
+ free(tmp2);
+
+ return value;
}
char* GetAuxValue(const char* aux, const char* name)
{
- if (isempty(aux))
- return NULL;
-
- char* descr = strdup(aux);
- char* beginaux = strstr(descr, "<epgsearch>");
- char* endaux = strstr(descr, "</epgsearch>");
- if (!beginaux || !endaux) {
- free(descr);
- return NULL;
- }
-
- beginaux += 11; // strlen("<epgsearch>");
- endaux[0] = 0;
- memmove(descr, beginaux, endaux - beginaux + 1);
-
- if (strcmp(name, "epgsearch") == 0)
- return descr; // full aux
-
- int namelen = strlen(name);
- char catname[100] = "";
- catname[0] = '<';
- memcpy(catname + 1, name, namelen);
- catname[1 + namelen] = '>';
- catname[2 + namelen] = 0;
-
- char* cat = strcasestr(descr, catname);
- if (!cat) {
- free(descr);
- return NULL;
- }
-
- cat += namelen + 2;
- char* end = strstr(cat, "</");
- if (!end) {
- free(descr);
- return NULL;
- }
- end[0] = 0;
-
- int catlen = end - cat + 1;
- char* value = (char *) malloc(catlen);
- memcpy(value, cat, catlen);
-
- free(descr);
- return value;
+ if (isempty(aux))
+ return NULL;
+
+ char* descr = strdup(aux);
+ char* beginaux = strstr(descr, "<epgsearch>");
+ char* endaux = strstr(descr, "</epgsearch>");
+ if (!beginaux || !endaux) {
+ free(descr);
+ return NULL;
+ }
+
+ beginaux += 11; // strlen("<epgsearch>");
+ endaux[0] = 0;
+ memmove(descr, beginaux, endaux - beginaux + 1);
+
+ if (strcmp(name, "epgsearch") == 0)
+ return descr; // full aux
+
+ int namelen = strlen(name);
+ char catname[100] = "";
+ catname[0] = '<';
+ memcpy(catname + 1, name, namelen);
+ catname[1 + namelen] = '>';
+ catname[2 + namelen] = 0;
+
+ char* cat = strcasestr(descr, catname);
+ if (!cat) {
+ free(descr);
+ return NULL;
+ }
+
+ cat += namelen + 2;
+ char* end = strstr(cat, "</");
+ if (!end) {
+ free(descr);
+ return NULL;
+ }
+ end[0] = 0;
+
+ int catlen = end - cat + 1;
+ char* value = (char *) malloc(catlen);
+ memcpy(value, cat, catlen);
+
+ free(descr);
+ return value;
}
char* GetAuxValue(const cRecording *recording, const char* name)
{
- if (!recording || !recording->Info()) return NULL;
- return GetAuxValue(recording->Info()->Aux(), name);
+ if (!recording || !recording->Info()) return NULL;
+ return GetAuxValue(recording->Info()->Aux(), name);
}
char* GetAuxValue(const cTimer *timer, const char* name)
{
- if (!timer || !timer->Aux()) return NULL;
- return GetAuxValue(timer->Aux(), name);
+ if (!timer || !timer->Aux()) return NULL;
+ return GetAuxValue(timer->Aux(), name);
}
string UpdateAuxValue(string aux, string section, long num)
{
- return UpdateAuxValue(aux, section, NumToString(num));
+ return UpdateAuxValue(aux, section, NumToString(num));
}
string UpdateAuxValue(string aux, string section, string value)
{
- string secStart = "<" + section + ">";
- string secEnd = "</" + section + ">";
- int valueStartPos = aux.find(secStart);
- int valueEndPos = aux.find(secEnd);
- if (valueStartPos >= 0 && valueEndPos >= 0)
- aux.replace(valueStartPos + secStart.size(), valueEndPos - valueStartPos - secStart.size(), value);
- else
- aux += secStart + value + secEnd;
- return aux;
+ string secStart = "<" + section + ">";
+ string secEnd = "</" + section + ">";
+ int valueStartPos = aux.find(secStart);
+ int valueEndPos = aux.find(secEnd);
+ if (valueStartPos >= 0 && valueEndPos >= 0)
+ aux.replace(valueStartPos + secStart.size(), valueEndPos - valueStartPos - secStart.size(), value);
+ else
+ aux += secStart + value + secEnd;
+ return aux;
}
// replace s1 with s2 in s ignoring the case of s1
char *strreplacei(char *s, const char *s1, const char *s2)
{
- char *p = strcasestr(s, s1);
- if (p) {
- int of = p - s;
- int l = strlen(s);
- int l1 = strlen(s1);
- int l2 = 0;
- if (s2)
- l2 = strlen(s2);
- if (l2 > l1)
- s = (char *)realloc(s, l + l2 - l1 + 1);
- if (l2 != l1)
- memmove(s + of + l2, s + of + l1, l - of - l1 + 1);
- memcpy(s + of, s2, l2);
- }
- return s;
+ char *p = strcasestr(s, s1);
+ if (p) {
+ int of = p - s;
+ int l = strlen(s);
+ int l1 = strlen(s1);
+ int l2 = 0;
+ if (s2)
+ l2 = strlen(s2);
+ if (l2 > l1)
+ s = (char *)realloc(s, l + l2 - l1 + 1);
+ if (l2 != l1)
+ memmove(s + of + l2, s + of + l1, l - of - l1 + 1);
+ memcpy(s + of, s2, l2);
+ }
+ return s;
}
std::string strreplace(
- std::string& result,
- const std::string& replaceWhat,
- const std::string& replaceWithWhat)
-{
- while(1)
- {
- const int pos = result.find(replaceWhat);
- if (pos==-1) break;
- result.replace(pos,replaceWhat.size(),replaceWithWhat);
- }
- return result;
+ std::string& result,
+ const std::string& replaceWhat,
+ const std::string& replaceWithWhat)
+{
+ while (1) {
+ const int pos = result.find(replaceWhat);
+ if (pos == -1) break;
+ result.replace(pos, replaceWhat.size(), replaceWithWhat);
+ }
+ return result;
}
void sleepMSec(long ms)
{
- cCondWait::SleepMs(ms);
+ cCondWait::SleepMs(ms);
}
void sleepSec(long s)
{
- sleepMSec(s * 1000);
+ sleepMSec(s * 1000);
}
bool SendViaSVDRP(cString SVDRPcmd)
{
- bool bSuccess = true;
- cString cmdbuf;
- if (EPGSearchConfig.useExternalSVDRP)
- {
- cmdbuf = cString::sprintf("%s -p %d \"%s\"",
- epgsSVDRP::cSVDRPClient::SVDRPSendCmd,
- EPGSearchConfig.SVDRPPort,
- *SVDRPcmd);
-
- FILE *p = popen(cmdbuf, "r");
- if (p)
- pclose(p);
- else
- {
- LogFile.eSysLog("can't open pipe for command '%s'", *cmdbuf);
- bSuccess = false;
- }
- }
- else
- {
- cmdbuf = SVDRPcmd;
- epgsSVDRP::cSVDRPClient client;
- if (!client.SendCmd(*cmdbuf))
- {
- LogFile.eSysLog("command '%s' failed", *cmdbuf);
- bSuccess = false;
- }
- }
-
- return bSuccess;
+ bool bSuccess = true;
+ cString cmdbuf;
+ if (EPGSearchConfig.useExternalSVDRP) {
+ cmdbuf = cString::sprintf("%s -p %d \"%s\"",
+ epgsSVDRP::cSVDRPClient::SVDRPSendCmd,
+ EPGSearchConfig.SVDRPPort,
+ *SVDRPcmd);
+
+ FILE *p = popen(cmdbuf, "r");
+ if (p)
+ pclose(p);
+ else {
+ LogFile.eSysLog("can't open pipe for command '%s'", *cmdbuf);
+ bSuccess = false;
+ }
+ } else {
+ cmdbuf = SVDRPcmd;
+ epgsSVDRP::cSVDRPClient client;
+ if (!client.SendCmd(*cmdbuf)) {
+ LogFile.eSysLog("command '%s' failed", *cmdbuf);
+ bSuccess = false;
+ }
+ }
+
+ return bSuccess;
}
int SendMsg(cString Message, bool confirm, int seconds, eMessageType messageType)
{
- int Keys = Skins.QueueMessage(messageType, Message, seconds, confirm?seconds+2:0);
- return Keys;
+ int Keys = Skins.QueueMessage(messageType, Message, seconds, confirm ? seconds + 2 : 0);
+ return Keys;
}
bool InEditMode(const char* ItemText, const char* ItemName, const char* ItemValue)
{
- bool bEditMode = true;
- // ugly solution to detect, if in edit mode
- char* value = strdup(ItemText);
- strreplace(value, ItemName, "");
- strreplace(value, ":\t", "");
- // for bigpatch
- strreplace(value, "\t", "");
- if (strlen(value) == strlen(ItemValue))
- bEditMode = false;
- free(value);
- return bEditMode;
+ bool bEditMode = true;
+ // ugly solution to detect, if in edit mode
+ char* value = strdup(ItemText);
+ strreplace(value, ItemName, "");
+ strreplace(value, ":\t", "");
+ // for bigpatch
+ strreplace(value, "\t", "");
+ if (strlen(value) == strlen(ItemValue))
+ bEditMode = false;
+ free(value);
+ return bEditMode;
}
// checks if the timer was triggered from a search timer and return a pointer to the search
cSearchExt* TriggeredFromSearchTimer(const cTimer* timer)
{
- char* searchID = GetAuxValue(timer, "s-id");
- if (!searchID)
- return NULL;
+ char* searchID = GetAuxValue(timer, "s-id");
+ if (!searchID)
+ return NULL;
- cSearchExt* search = SearchExts.GetSearchFromID(atoi(searchID));
- free(searchID);
- return search;
+ cSearchExt* search = SearchExts.GetSearchFromID(atoi(searchID));
+ free(searchID);
+ return search;
}
int TriggeredFromSearchTimerID(const cTimer* timer)
{
- cSearchExt* trigger = TriggeredFromSearchTimer(timer);
- if (trigger)
- return trigger->ID;
- else
- return -1;
+ cSearchExt* trigger = TriggeredFromSearchTimer(timer);
+ if (trigger)
+ return trigger->ID;
+ else
+ return -1;
}
double FuzzyMatch(const char* s1, const char* s2, int maxLength)
{
- Distance D;
- int dist = D.LD (s1, s2, maxLength);
- double fMaxLength = std::max(strlen(s1), strlen(s2));
- return (fMaxLength - dist)/fMaxLength;
+ Distance D;
+ int dist = D.LD(s1, s2, maxLength);
+ double fMaxLength = std::max(strlen(s1), strlen(s2));
+ return (fMaxLength - dist) / fMaxLength;
}
bool DescriptionMatches(const char* eDescr, const char* rDescr, int matchLimit)
{
- if (eDescr == NULL && rDescr == NULL) return true;
- if (eDescr == NULL && rDescr != NULL) return false;
- if (eDescr != NULL && rDescr == NULL) return false;
- int l_eDescr = strlen(eDescr);
- int l_rDescr = strlen(rDescr);
- if (l_eDescr == l_rDescr && strcmp(eDescr, rDescr) == 0) return true;
-
- // partial match:
- // first check the length, should only be different at match limit
- int minLength = std::min(l_eDescr, l_rDescr);
- int maxLength = std::max(l_eDescr, l_rDescr);
- if (100*double(minLength)/double(maxLength) < matchLimit)
- return false;
-
- // last try with Levenshtein Distance, only compare the first 1000 chars
- double fMatch = FuzzyMatch(eDescr, rDescr, 1000);
- double tmp_matchlimit = matchLimit/100.0;
- if(maxLength - minLength < 5 && matchLimit < 95)
- {
- tmp_matchlimit = 0.95;
- LogFile.Log(2,"difference between both descriptions is < 5 setting matchlimit to: %.2f %%", tmp_matchlimit*100);
- }
- if (fMatch > tmp_matchlimit)
- {
- LogFile.Log(2,"match is: %.2f %%", fMatch*100);
- return true;
- }
- return false;
+ if (eDescr == NULL && rDescr == NULL) return true;
+ if (eDescr == NULL && rDescr != NULL) return false;
+ if (eDescr != NULL && rDescr == NULL) return false;
+ int l_eDescr = strlen(eDescr);
+ int l_rDescr = strlen(rDescr);
+ if (l_eDescr == l_rDescr && strcmp(eDescr, rDescr) == 0) return true;
+
+ // partial match:
+ // first check the length, should only be different at match limit
+ int minLength = std::min(l_eDescr, l_rDescr);
+ int maxLength = std::max(l_eDescr, l_rDescr);
+ if (100 * double(minLength) / double(maxLength) < matchLimit)
+ return false;
+
+ // last try with Levenshtein Distance, only compare the first 1000 chars
+ double fMatch = FuzzyMatch(eDescr, rDescr, 1000);
+ double tmp_matchlimit = matchLimit / 100.0;
+ if (maxLength - minLength < 5 && matchLimit < 95) {
+ tmp_matchlimit = 0.95;
+ LogFile.Log(2, "difference between both descriptions is < 5 setting matchlimit to: %.2f %%", tmp_matchlimit * 100);
+ }
+ if (fMatch > tmp_matchlimit) {
+ LogFile.Log(2, "match is: %.2f %%", fMatch * 100);
+ return true;
+ }
+ return false;
}
const cEvent* GetEvent(const cTimer* timer)
{
- const cEvent* event = NULL;
- const cChannel *channel = timer->Channel();
- time_t Time = timer->StartTime() + (timer->StopTime() - timer->StartTime()) / 2;
- for (int seconds = 0; seconds <= 3; seconds++)
- {
- {
- LOCK_SCHEDULES_READ;
- if (Schedules) {
- const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
- if (Schedule) {
- event = Schedule->GetEventAround(Time);
- if (event) return event;
+ const cEvent* event = NULL;
+ const cChannel *channel = timer->Channel();
+ time_t Time = timer->StartTime() + (timer->StopTime() - timer->StartTime()) / 2;
+ for (int seconds = 0; seconds <= 3; seconds++) {
+ {
+ LOCK_SCHEDULES_READ;
+ if (Schedules) {
+ const cSchedule *Schedule = Schedules->GetSchedule(channel->GetChannelID());
+ if (Schedule) {
+ event = Schedule->GetEventAround(Time);
+ if (event) return event;
+ }
}
- }
- }
- if (seconds == 0)
- LogFile.Log(2,"waiting for EPG info...");
- sleepSec(1);
- }
- LogFile.Log(1,"no EPG info available");
- return NULL;
+ }
+ if (seconds == 0)
+ LogFile.Log(2, "waiting for EPG info...");
+ sleepSec(1);
+ }
+ LogFile.Log(1, "no EPG info available");
+ return NULL;
}
// this extracts the real description from a given epg entry cutting all that looks like a category line
@@ -553,383 +517,368 @@ const cEvent* GetEvent(const cTimer* timer)
char* GetRawDescription(const char* descr)
{
- if (!descr || !*descr) return NULL;
-
- char* rawDescr = (char*) calloc(strlen(descr)+1, sizeof(char));
-
- const char* tmp = descr;
- while(tmp)
- {
- // extract a single line
- const char* lf = strchr(tmp, '\n');
- char* line = NULL;
- if (lf)
- line = strndup(tmp, lf-tmp);
- else
- line = strdup(tmp);
- // if (lf) *lf = 0;
- // check for category
- char* delim = strstr(line, ": ");
- if (!delim ||
- (delim && (delim - line > MAXCATNAMELENGTH || strlen(line) - (delim - line) + 2 > MAXCATVALUELENGTH)))
- if (*line)
- strcat(rawDescr, line);
-
- if (lf) tmp += strlen(line)+1; else tmp = NULL;
- free(line);
- }
- return rawDescr;
+ if (!descr || !*descr) return NULL;
+
+ char* rawDescr = (char*) calloc(strlen(descr) + 1, sizeof(char));
+
+ const char* tmp = descr;
+ while (tmp) {
+ // extract a single line
+ const char* lf = strchr(tmp, '\n');
+ char* line = NULL;
+ if (lf)
+ line = strndup(tmp, lf - tmp);
+ else
+ line = strdup(tmp);
+ // if (lf) *lf = 0;
+ // check for category
+ char* delim = strstr(line, ": ");
+ if (!delim ||
+ (delim && (delim - line > MAXCATNAMELENGTH || strlen(line) - (delim - line) + 2 > MAXCATVALUELENGTH)))
+ if (*line)
+ strcat(rawDescr, line);
+
+ if (lf) tmp += strlen(line) + 1;
+ else tmp = NULL;
+ free(line);
+ }
+ return rawDescr;
}
void PrepareTimerFile(const cEvent* event, cTimer* timer)
{
- if (!event) return;
- if (EPGSearchConfig.addSubtitleToTimer == addSubtitleNever && strlen(EPGSearchConfig.defrecdir) == 0) // nothing to do
- return;
- if (!isempty(event->ShortText())) // add subtitle if present
- {
- bool addSubtitle = (EPGSearchConfig.addSubtitleToTimer != addSubtitleNever);
- if (EPGSearchConfig.addSubtitleToTimer == addSubtitleSmart)
- if (event->Duration() > 80*60)
- addSubtitle = false;
-
- if (addSubtitle)
- {
- char tmp[MaxFileName] = "";
- snprintf(tmp, MaxFileName, "%s~%s", event->Title(), event->ShortText());
- timer->SetFile(tmp);
- }
- }
- if (strlen(EPGSearchConfig.defrecdir) > 0)
- {
- char directory[MaxFileName] = "";
- strn0cpy(directory, EPGSearchConfig.defrecdir,sizeof(directory));
- cVarExpr varExprDir(directory);
- if (!varExprDir.DependsOnVar("%title%", event))
- {
- strcat(directory, "~");
- strcat(directory, timer->File());
- }
- // parse the epxression and evaluate it
- cVarExpr varExpr(directory);
- strcpy(directory, varExpr.Evaluate(event).c_str());
- if (strchr(directory, '%') == NULL) // only set directory to new value if all categories could have been replaced
- timer->SetFile(directory);
- }
+ if (!event) return;
+ if (EPGSearchConfig.addSubtitleToTimer == addSubtitleNever && strlen(EPGSearchConfig.defrecdir) == 0) // nothing to do
+ return;
+ if (!isempty(event->ShortText())) { // add subtitle if present
+ bool addSubtitle = (EPGSearchConfig.addSubtitleToTimer != addSubtitleNever);
+ if (EPGSearchConfig.addSubtitleToTimer == addSubtitleSmart)
+ if (event->Duration() > 80 * 60)
+ addSubtitle = false;
+
+ if (addSubtitle) {
+ char tmp[MaxFileName] = "";
+ snprintf(tmp, MaxFileName, "%s~%s", event->Title(), event->ShortText());
+ timer->SetFile(tmp);
+ }
+ }
+ if (strlen(EPGSearchConfig.defrecdir) > 0) {
+ char directory[MaxFileName] = "";
+ strn0cpy(directory, EPGSearchConfig.defrecdir, sizeof(directory));
+ cVarExpr varExprDir(directory);
+ if (!varExprDir.DependsOnVar("%title%", event)) {
+ strcat(directory, "~");
+ strcat(directory, timer->File());
+ }
+ // parse the epxression and evaluate it
+ cVarExpr varExpr(directory);
+ strcpy(directory, varExpr.Evaluate(event).c_str());
+ if (strchr(directory, '%') == NULL) // only set directory to new value if all categories could have been replaced
+ timer->SetFile(directory);
+ }
}
bool EventsMatch(const cEvent* event1, const cEvent* event2, bool compareTitle, int compareSubtitle, bool compareSummary, int compareDate, unsigned long catvaluesAvoidRepeat, int matchLimit)
{
- if (!event1 || !event2) return false;
- if (event1 == event2) return true;
-
- // only compare the alphanumeric portions
- string Title1 = "";
- string Title2 = "";
- if (compareTitle)
- {
- string s1 = event1->Title()?event1->Title():"";
- string s2 = event2->Title()?event2->Title():"";
- Title1 = GetAlNum(s1);
- Title2 = GetAlNum(s2);
- std::transform(Title1.begin(), Title1.end(), Title1.begin(), tolower);
- std::transform(Title2.begin(), Title2.end(), Title2.begin(), tolower);
- }
- string Subtitle1 = "";
- string Subtitle2 = "";
- if (compareSubtitle)
- {
- string s1 = event1->ShortText()?event1->ShortText():"";
- string s2 = event2->ShortText()?event2->ShortText():"";
- Subtitle1 = GetAlNum(s1);
- Subtitle2 = GetAlNum(s2);
- std::transform(Subtitle1.begin(), Subtitle1.end(), Subtitle1.begin(), tolower);
- std::transform(Subtitle2.begin(), Subtitle2.end(), Subtitle2.begin(), tolower);
- }
- string compareExpression = "";
- if (compareDate == 1) compareExpression = "%date%";
- if (compareDate == 2) compareExpression = "%year%-%week%";
- if (compareDate == 3) compareExpression = "%year%-%month%";
-
- bool match = false;
- if ((!compareTitle || Title1 == Title2) &&
- (!compareSubtitle || (Subtitle1 == Subtitle2 && Subtitle1!="")))
- {
- const char* Descr1 = event1->Description();
- const char* Descr2 = event2->Description();
- if (compareSummary)
- {
- char* rawDescr1 = GetRawDescription(Descr1);
- char* rawDescr2 = GetRawDescription(Descr2);
- match = DescriptionMatches(rawDescr1, rawDescr2, matchLimit);
- free(rawDescr1);
- free(rawDescr2);
- if (!match) return false;
- }
- if (compareExpression.size() > 0)
- {
- cVarExpr varExpr(compareExpression);
- string resEvent1 = varExpr.Evaluate(event1);
- string resEvent2 = varExpr.Evaluate(event2);
- if (resEvent1 != resEvent2)
- return false;
- }
- if (catvaluesAvoidRepeat != 0) // check categories
- {
- bool bCatMatch = ((Descr1 && Descr2) || (!Descr1 && !Descr2));
- cSearchExtCat *SearchExtCat = SearchExtCats.First();
- int index = 0;
- while (catvaluesAvoidRepeat > 0 && SearchExtCat && bCatMatch)
- {
- if (catvaluesAvoidRepeat & (1<<index))
- {
- char* CatValue1 = GetExtEPGValue(Descr1, SearchExtCat->name, SearchExtCat->format);
- char* CatValue2 = GetExtEPGValue(Descr2, SearchExtCat->name, SearchExtCat->format);
- if ((!CatValue1 && CatValue2) ||
- (!CatValue2 && CatValue1) ||
- (CatValue1 && CatValue2 && strcmp(CatValue1, CatValue2) != 0))
- bCatMatch = false;
- free(CatValue1);
- free(CatValue2);
+ if (!event1 || !event2) return false;
+ if (event1 == event2) return true;
+
+ // only compare the alphanumeric portions
+ string Title1 = "";
+ string Title2 = "";
+ if (compareTitle) {
+ string s1 = event1->Title() ? event1->Title() : "";
+ string s2 = event2->Title() ? event2->Title() : "";
+ Title1 = GetAlNum(s1);
+ Title2 = GetAlNum(s2);
+ std::transform(Title1.begin(), Title1.end(), Title1.begin(), tolower);
+ std::transform(Title2.begin(), Title2.end(), Title2.begin(), tolower);
+ }
+ string Subtitle1 = "";
+ string Subtitle2 = "";
+ if (compareSubtitle) {
+ string s1 = event1->ShortText() ? event1->ShortText() : "";
+ string s2 = event2->ShortText() ? event2->ShortText() : "";
+ Subtitle1 = GetAlNum(s1);
+ Subtitle2 = GetAlNum(s2);
+ std::transform(Subtitle1.begin(), Subtitle1.end(), Subtitle1.begin(), tolower);
+ std::transform(Subtitle2.begin(), Subtitle2.end(), Subtitle2.begin(), tolower);
+ }
+ string compareExpression = "";
+ if (compareDate == 1) compareExpression = "%date%";
+ if (compareDate == 2) compareExpression = "%year%-%week%";
+ if (compareDate == 3) compareExpression = "%year%-%month%";
+
+ bool match = false;
+ if ((!compareTitle || Title1 == Title2) &&
+ (!compareSubtitle || (Subtitle1 == Subtitle2 && Subtitle1 != ""))) {
+ const char* Descr1 = event1->Description();
+ const char* Descr2 = event2->Description();
+ if (compareSummary) {
+ char* rawDescr1 = GetRawDescription(Descr1);
+ char* rawDescr2 = GetRawDescription(Descr2);
+ match = DescriptionMatches(rawDescr1, rawDescr2, matchLimit);
+ free(rawDescr1);
+ free(rawDescr2);
+ if (!match) return false;
+ }
+ if (compareExpression.size() > 0) {
+ cVarExpr varExpr(compareExpression);
+ string resEvent1 = varExpr.Evaluate(event1);
+ string resEvent2 = varExpr.Evaluate(event2);
+ if (resEvent1 != resEvent2)
+ return false;
+ }
+ if (catvaluesAvoidRepeat != 0) { // check categories
+ bool bCatMatch = ((Descr1 && Descr2) || (!Descr1 && !Descr2));
+ cSearchExtCat *SearchExtCat = SearchExtCats.First();
+ int index = 0;
+ while (catvaluesAvoidRepeat > 0 && SearchExtCat && bCatMatch) {
+ if (catvaluesAvoidRepeat & (1 << index)) {
+ char* CatValue1 = GetExtEPGValue(Descr1, SearchExtCat->name, SearchExtCat->format);
+ char* CatValue2 = GetExtEPGValue(Descr2, SearchExtCat->name, SearchExtCat->format);
+ if ((!CatValue1 && CatValue2) ||
+ (!CatValue2 && CatValue1) ||
+ (CatValue1 && CatValue2 && strcmp(CatValue1, CatValue2) != 0))
+ bCatMatch = false;
+ free(CatValue1);
+ free(CatValue2);
+ }
+ SearchExtCat = SearchExtCats.Next(SearchExtCat);
+ index++;
}
- SearchExtCat = SearchExtCats.Next(SearchExtCat);
- index++;
- }
- if (bCatMatch)
+ if (bCatMatch)
+ match = true;
+ } else
match = true;
- }
- else
- match = true;
- }
- return match;
+ }
+ return match;
}
int ChannelNrFromEvent(const cEvent* pEvent)
{
- if (!pEvent)
- return -1;
- LOCK_CHANNELS_READ;
- const cChannel* channel = Channels->GetByChannelID(pEvent->ChannelID(), true, true);
- if (!channel)
- return -1;
- else
- return channel->Number();
+ if (!pEvent)
+ return -1;
+ LOCK_CHANNELS_READ;
+ const cChannel* channel = Channels->GetByChannelID(pEvent->ChannelID(), true, true);
+ if (!channel)
+ return -1;
+ else
+ return channel->Number();
}
void DelTimer(int index)
{
- cString cmdbuf = cString::sprintf("DELT %d", index);
- LogFile.Log(2, "delete timer %d", index);
- SendViaSVDRP(cmdbuf);
- gl_timerStatusMonitor->SetConflictCheckAdvised();
+ cString cmdbuf = cString::sprintf("DELT %d", index);
+ LogFile.Log(2, "delete timer %d", index);
+ SendViaSVDRP(cmdbuf);
+ gl_timerStatusMonitor->SetConflictCheckAdvised();
}
char* FixSeparators(char* buffer, char sep)
{
- int l = strlen(buffer);
- char *dest = buffer;
- for (int i = 0; i < l; i ++) {
- char c = buffer[i];
- int j = i;
- if (c == sep) {
- for (j = i + 1; (j < l) & (buffer[j] == ' '); j++)
- ;
-
- if ((j <= l) | (i + 1 < j)) {
- switch (buffer[j]) {
- case '\t':
- i = j;
- c = '\t';
- break;
- case 0:
- i = j;
- c = 0;
- break;
- default:
- break;
- }
- }
- }
- if (c == '\t') {
- for (; (j < l) & (buffer[j] == ' '); j++)
- ;
- if (j < l && buffer[j] == sep) {
- buffer[j] = '\t';
- i = j - 1;
- continue;
- }
+ int l = strlen(buffer);
+ char *dest = buffer;
+ for (int i = 0; i < l; i ++) {
+ char c = buffer[i];
+ int j = i;
+ if (c == sep) {
+ for (j = i + 1; (j < l) & (buffer[j] == ' '); j++)
+ ;
+
+ if ((j <= l) | (i + 1 < j)) {
+ switch (buffer[j]) {
+ case '\t':
+ i = j;
+ c = '\t';
+ break;
+ case 0:
+ i = j;
+ c = 0;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ if (c == '\t') {
+ for (; (j < l) & (buffer[j] == ' '); j++)
+ ;
+ if (j < l && buffer[j] == sep) {
+ buffer[j] = '\t';
+ i = j - 1;
+ continue;
+ }
+ }
+ *dest++ = c;
}
- *dest++ = c;
- }
- *dest = 0;
- return buffer;
+ *dest = 0;
+ return buffer;
}
cString DateTime(time_t t)
{
- char buffer[32];
- if (t == 0)
- time(&t);
- struct tm tm_r;
- tm *tm = localtime_r(&t, &tm_r);
- snprintf(buffer, sizeof(buffer), "%02d.%02d. %02d:%02d", tm->tm_mday, tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
- return buffer;
+ char buffer[32];
+ if (t == 0)
+ time(&t);
+ struct tm tm_r;
+ tm *tm = localtime_r(&t, &tm_r);
+ snprintf(buffer, sizeof(buffer), "%02d.%02d. %02d:%02d", tm->tm_mday, tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
+ return buffer;
}
string NumToString(long num)
{
- ostringstream os;
- os << num;
- return os.str();
+ ostringstream os;
+ os << num;
+ return os.str();
}
int FindIgnoreCase(const string& expr, const string& query)
{
- const char *p = expr.c_str();
- const char *r = strcasestr(p, query.c_str());
+ const char *p = expr.c_str();
+ const char *r = strcasestr(p, query.c_str());
- if (!r)
- return -1;
- return r - p;
+ if (!r)
+ return -1;
+ return r - p;
}
bool EqualsNoCase(const string& a, const string& b)
{
- return strcasecmp(a.c_str(), b.c_str()) == 0;
+ return strcasecmp(a.c_str(), b.c_str()) == 0;
}
string Strip(const string& input)
{
- string str = input;
- string::size_type pos = str.find_last_not_of(' ');
- if(pos != string::npos) {
- str.erase(pos + 1);
- pos = str.find_first_not_of(' ');
- if(pos != string::npos) str.erase(0, pos);
- }
- else str.erase(str.begin(), str.end());
- return str;
+ string str = input;
+ string::size_type pos = str.find_last_not_of(' ');
+ if (pos != string::npos) {
+ str.erase(pos + 1);
+ pos = str.find_first_not_of(' ');
+ if (pos != string::npos) str.erase(0, pos);
+ } else str.erase(str.begin(), str.end());
+ return str;
}
string GetAlNum(const string& s)
{
- string res;
- for(unsigned int i=0; i<s.size(); i++)
- if (isalnum(s[i]))
- res += s[i];
- return res;
+ string res;
+ for (unsigned int i = 0; i < s.size(); i++)
+ if (isalnum(s[i]))
+ res += s[i];
+ return res;
}
string ReplaceAll(const string& input, const string& what, const string& with)
{
- string result = input;
- int pos = 0;
+ string result = input;
+ int pos = 0;
- while((pos = FindIgnoreCase(result, what)) >= 0)
- result.replace(pos, what.size(), with);
- return result;
+ while ((pos = FindIgnoreCase(result, what)) >= 0)
+ result.replace(pos, what.size(), with);
+ return result;
}
string EscapeString(const string& S)
{
- string tmp = S;
- int apostrophPos = 0;
- int apostrophTempPos = 0;
- while((apostrophPos = tmp.find("'", apostrophTempPos)) >= apostrophTempPos) {
- tmp.replace(apostrophPos, 1, "'\"'\"'");
- apostrophTempPos = apostrophPos + 5;
- }
- return tmp;
+ string tmp = S;
+ int apostrophPos = 0;
+ int apostrophTempPos = 0;
+ while ((apostrophPos = tmp.find("'", apostrophTempPos)) >= apostrophTempPos) {
+ tmp.replace(apostrophPos, 1, "'\"'\"'");
+ apostrophTempPos = apostrophPos + 5;
+ }
+ return tmp;
}
string QuoteApostroph(const string& S)
{
- string tmp = S;
- int apostrophPos = 0;
- int apostrophTempPos = 0;
- while((apostrophPos = tmp.find("\"", apostrophTempPos)) >= apostrophTempPos) {
- tmp.replace(apostrophPos, 1, "\\\"");
- apostrophTempPos = apostrophPos + 2;
- }
- return tmp;
+ string tmp = S;
+ int apostrophPos = 0;
+ int apostrophTempPos = 0;
+ while ((apostrophPos = tmp.find("\"", apostrophTempPos)) >= apostrophTempPos) {
+ tmp.replace(apostrophPos, 1, "\\\"");
+ apostrophTempPos = apostrophPos + 2;
+ }
+ return tmp;
}
string MD5(const string& input)
{
- char* szInput = strdup(input.c_str());
- if (!szInput) return "";
- char* szRes = MD5String(szInput);
- string res = szRes;
- free(szRes);
- return res;
+ char* szInput = strdup(input.c_str());
+ if (!szInput) return "";
+ char* szRes = MD5String(szInput);
+ string res = szRes;
+ free(szRes);
+ return res;
}
void SetAux(cTimer* timer, string aux)
{
- if (!timer) return;
- string timerText = *timer->ToText();
- string::size_type auxPos = string::npos;
- for(int i=0; i<=7; i++) // get aux value
- auxPos = timerText.find(":", auxPos == string::npos?0:auxPos+1);
- if (auxPos == string::npos) return;
- timerText.replace(auxPos+1, timerText.size()-auxPos+1, aux);
- timer->Parse(timerText.c_str());
+ if (!timer) return;
+ string timerText = *timer->ToText();
+ string::size_type auxPos = string::npos;
+ for (int i = 0; i <= 7; i++) // get aux value
+ auxPos = timerText.find(":", auxPos == string::npos ? 0 : auxPos + 1);
+ if (auxPos == string::npos) return;
+ timerText.replace(auxPos + 1, timerText.size() - auxPos + 1, aux);
+ timer->Parse(timerText.c_str());
}
int msprintf(char **strp, const char *fmt, ...)
{
- va_list ap;
- va_start (ap, fmt);
- int res=vasprintf (strp, fmt, ap);
- va_end (ap);
- return res;
+ va_list ap;
+ va_start(ap, fmt);
+ int res = vasprintf(strp, fmt, ap);
+ va_end(ap);
+ return res;
}
std::string GetCodeset()
{
- // Taken from VDR's vdr.c
- char *CodeSet = NULL;
- if (setlocale(LC_CTYPE, ""))
- CodeSet = nl_langinfo(CODESET);
- else {
- char *LangEnv = getenv("LANG"); // last resort in case locale stuff isn't installed
- if (LangEnv) {
- CodeSet = strchr(LangEnv, '.');
- if (CodeSet)
- CodeSet++; // skip the dot
- }
- }
- if (CodeSet)
- return std::string(CodeSet);
- else
- return "ISO-8859-15";
+ // Taken from VDR's vdr.c
+ char *CodeSet = NULL;
+ if (setlocale(LC_CTYPE, ""))
+ CodeSet = nl_langinfo(CODESET);
+ else {
+ char *LangEnv = getenv("LANG"); // last resort in case locale stuff isn't installed
+ if (LangEnv) {
+ CodeSet = strchr(LangEnv, '.');
+ if (CodeSet)
+ CodeSet++; // skip the dot
+ }
+ }
+ if (CodeSet)
+ return std::string(CodeSet);
+ else
+ return "ISO-8859-15";
}
/* Read a line from a socket */
-ssize_t Readline(int sockd, char *vptr, size_t maxlen) {
+ssize_t Readline(int sockd, char *vptr, size_t maxlen)
+{
size_t n, rc;
char c, *buffer;
buffer = vptr;
- for ( n = 1; n < maxlen; n++ ) {
-
- if ( (rc = read(sockd, &c, 1)) == 1 ) {
- if ( c == '\n' )
- break;
- *buffer++ = c;
- }
- else if ( rc == 0 ) {
- if ( n == 1 )
- return 0;
- else
- break;
- }
- else {
- if ( errno == EINTR )
- continue;
- return -1;
- }
+ for (n = 1; n < maxlen; n++) {
+
+ if ((rc = read(sockd, &c, 1)) == 1) {
+ if (c == '\n')
+ break;
+ *buffer++ = c;
+ } else if (rc == 0) {
+ if (n == 1)
+ return 0;
+ else
+ break;
+ } else {
+ if (errno == EINTR)
+ continue;
+ return -1;
+ }
}
*buffer = 0;
@@ -937,7 +886,8 @@ ssize_t Readline(int sockd, char *vptr, size_t maxlen) {
}
/* Write a line to a socket */
-ssize_t Writeline(int sockd, const char *vptr, ssize_t n) {
+ssize_t Writeline(int sockd, const char *vptr, ssize_t n)
+{
ssize_t nleft;
ssize_t nwritten;
const char *buffer;
@@ -945,15 +895,15 @@ ssize_t Writeline(int sockd, const char *vptr, ssize_t n) {
buffer = vptr;
nleft = n;
- while ( nleft > 0 ) {
- if ( (nwritten = write(sockd, buffer, nleft)) <= 0 ) {
- if ( errno == EINTR )
- nwritten = 0;
- else
- return -1;
- }
- nleft -= nwritten;
- buffer += nwritten;
+ while (nleft > 0) {
+ if ((nwritten = write(sockd, buffer, nleft)) <= 0) {
+ if (errno == EINTR)
+ nwritten = 0;
+ else
+ return -1;
+ }
+ nleft -= nwritten;
+ buffer += nwritten;
}
return n;
@@ -961,28 +911,25 @@ ssize_t Writeline(int sockd, const char *vptr, ssize_t n) {
long getAddrFromString(const char* hostnameOrIp, struct sockaddr_in* addr)
{
- unsigned long ip;
+ unsigned long ip;
- struct hostent * he;
+ struct hostent * he;
- if(hostnameOrIp==NULL || addr==NULL)
- return -1;
+ if (hostnameOrIp == NULL || addr == NULL)
+ return -1;
- ip=inet_addr(hostnameOrIp);
+ ip = inet_addr(hostnameOrIp);
- if(ip!=INADDR_NONE)
- {
- addr->sin_addr.s_addr=ip;
- return 0;
- }
- else
- {
- he=gethostbyname(hostnameOrIp);
- if(he==NULL)
- return -1;
- else
- memcpy(&(addr->sin_addr),he->h_addr_list[0],4);
- return 0;
+ if (ip != INADDR_NONE) {
+ addr->sin_addr.s_addr = ip;
+ return 0;
+ } else {
+ he = gethostbyname(hostnameOrIp);
+ if (he == NULL)
+ return -1;
+ else
+ memcpy(&(addr->sin_addr), he->h_addr_list[0], 4);
+ return 0;
}
}
@@ -990,61 +937,60 @@ char *cCommand::result = NULL;
cCommand::cCommand(void)
{
- title = command = NULL;
- confirm = false;
+ title = command = NULL;
+ confirm = false;
}
cCommand::~cCommand()
{
- free(title);
- free(command);
+ free(title);
+ free(command);
}
bool cCommand::Parse(const char *s)
{
- const char *p = strchr(s, ':');
- if (p) {
- int l = p - s;
- if (l > 0) {
- title = MALLOC(char, l + 1);
- stripspace(strn0cpy(title, s, l + 1));
- if (!isempty(title)) {
- int l = strlen(title);
- if (l > 1 && title[l - 1] == '?') {
- confirm = true;
- title[l - 1] = 0;
- }
- command = stripspace(strdup(skipspace(p + 1)));
- return !isempty(command);
- }
+ const char *p = strchr(s, ':');
+ if (p) {
+ int l = p - s;
+ if (l > 0) {
+ title = MALLOC(char, l + 1);
+ stripspace(strn0cpy(title, s, l + 1));
+ if (!isempty(title)) {
+ int l = strlen(title);
+ if (l > 1 && title[l - 1] == '?') {
+ confirm = true;
+ title[l - 1] = 0;
+ }
+ command = stripspace(strdup(skipspace(p + 1)));
+ return !isempty(command);
+ }
}
- }
- return false;
+ }
+ return false;
}
const char *cCommand::Execute(const char *Parameters)
{
- free(result);
- result = NULL;
- cString cmdbuf;
- if (Parameters)
- cmdbuf = cString::sprintf("%s %s", command, Parameters);
- const char *cmd = *cmdbuf ? *cmdbuf : command;
- dsyslog("executing command '%s'", cmd);
- cPipe p;
- if (p.Open(cmd, "r")) {
- int l = 0;
- int c;
- while ((c = fgetc(p)) != EOF) {
- if (l % 20 == 0)
- result = (char *)realloc(result, l + 21);
- result[l++] = char(c);
- }
- if (result)
- result[l] = 0;
- p.Close();
- }
- else
- esyslog("ERROR: can't open pipe for command '%s'", cmd);
- return result;
+ free(result);
+ result = NULL;
+ cString cmdbuf;
+ if (Parameters)
+ cmdbuf = cString::sprintf("%s %s", command, Parameters);
+ const char *cmd = *cmdbuf ? *cmdbuf : command;
+ dsyslog("executing command '%s'", cmd);
+ cPipe p;
+ if (p.Open(cmd, "r")) {
+ int l = 0;
+ int c;
+ while ((c = fgetc(p)) != EOF) {
+ if (l % 20 == 0)
+ result = (char *)realloc(result, l + 21);
+ result[l++] = char(c);
+ }
+ if (result)
+ result[l] = 0;
+ p.Close();
+ } else
+ esyslog("ERROR: can't open pipe for command '%s'", cmd);
+ return result;
}
diff --git a/epgsearchtools.h b/epgsearchtools.h
index 7ad67f7..5c74318 100644
--- a/epgsearchtools.h
+++ b/epgsearchtools.h
@@ -75,7 +75,7 @@ using std::string;
#define ISRADIO(x) ((x)->Vpid()==0||(x)->Vpid()==1||(x)->Vpid()==0x1fff)
#ifndef MENU_SEPARATOR_ITEMS
- #define MENU_SEPARATOR_ITEMS "----------------------------------------"
+#define MENU_SEPARATOR_ITEMS "----------------------------------------"
#endif
#define UPDS_WITH_OSD (1<<1)
@@ -119,7 +119,7 @@ class cSearchExt;
class cSearchExtCat;
class cEvent;
-cString IndentMenuItem(const char*, int indentions=1);
+cString IndentMenuItem(const char*, int indentions = 1);
bool MatchesSearchMode(const char* test, const char* values, int searchmode, const char* delim, int tolerance);
char* GetExtEPGValue(const cEvent* e, cSearchExtCat* SearchExtCat);
char* GetExtEPGValue(const char* description, const char* catname, const char *format);
@@ -135,15 +135,15 @@ std::string strreplace(std::string& result, const std::string& replaceWhat, cons
// replace s1 with s2 in s ignoring the case of s1
inline char *strreplacei(char *s, const char *s1, const char s2)
{
- char *p = strcasestr(s, s1);
- if (p) {
- int offset = p - s;
- int l = strlen(s);
- int l1 = strlen(s1);
- memmove(s + offset + 1, s + offset + l1, l - offset - l1 + 1);
- s[offset] = s2;
- }
- return s;
+ char *p = strcasestr(s, s1);
+ if (p) {
+ int offset = p - s;
+ int l = strlen(s);
+ int l1 = strlen(s1);
+ memmove(s + offset + 1, s + offset + l1, l - offset - l1 + 1);
+ s[offset] = s2;
+ }
+ return s;
}
void sleepMSec(long ms);
@@ -161,7 +161,7 @@ void PrepareTimerFile(const cEvent* event, cTimer* timer);
int CompareEventTime(const void *p1, const void *p2);
int CompareEventChannel(const void *p1, const void *p2);
int CompareSearchExtPrioDescTerm(const void *p1, const void *p2);
-bool EventsMatch(const cEvent* event1, const cEvent* event2, bool compareTitle, int compareSubtitle, bool compareSummary, int compareDate, unsigned long catvaluesAvoidRepeat, int matchLimit=90);
+bool EventsMatch(const cEvent* event1, const cEvent* event2, bool compareTitle, int compareSubtitle, bool compareSummary, int compareDate, unsigned long catvaluesAvoidRepeat, int matchLimit = 90);
int ChannelNrFromEvent(const cEvent* pEvent);
void DelTimer(int index);
char* FixSeparators(char* buffer, char sep);
@@ -184,50 +184,52 @@ ssize_t Writeline(int sockd, const char *vptr, ssize_t n);
long getAddrFromString(const char* hostnameOrIp, struct sockaddr_in* addr);
// --- cTimerObj --------------------------------------------------------
-class cTimerObj : public cListObject {
+class cTimerObj : public cListObject
+{
public:
const cTimer* timer;
cTimerObj(const cTimer* Timer) : timer(Timer) {}
- virtual ~cTimerObj() { timer = NULL; } // do not delete anything!
+ virtual ~cTimerObj() {
+ timer = NULL; // do not delete anything!
+ }
};
// --- cTimerObjList --------------------------------------------------------
-class cTimerObjList : public cList<cTimerObj> {
+class cTimerObjList : public cList<cTimerObj>
+{
public:
- void DelTimer(const cTimer* t)
- {
- for (cTimerObj* pTObj = First(); pTObj; pTObj = Next(pTObj))
- if (pTObj->timer == t)
- {
- Del(pTObj);
- return;
- }
- }
+ void DelTimer(const cTimer* t) {
+ for (cTimerObj* pTObj = First(); pTObj; pTObj = Next(pTObj))
+ if (pTObj->timer == t) {
+ Del(pTObj);
+ return;
+ }
+ }
};
// --- icstring ------------------------------------------
// a case-insensitive string class
struct ignorecase_traits : public std::
#if defined(__GNUC__) && __GNUC__ < 3 && __GNUC_MINOR__ < 96
-string_char_traits<char>
+ string_char_traits<char>
#else
-char_traits<char>
+ char_traits<char>
#endif
{
// return whether c1 and c2 are equal
static bool eq(const char& c1, const char& c2) {
- return (c1==c2 || std::toupper(c1)==std::toupper(c2));
+ return (c1 == c2 || std::toupper(c1) == std::toupper(c2));
}
// return whether c1 is less than c2
static bool lt(const char& c1, const char& c2) {
- return std::toupper(c1)<std::toupper(c2);
+ return std::toupper(c1) < std::toupper(c2);
}
// compare up to n characters of s1 and s2
static int compare(const char* s1, const char* s2,
std::size_t n) {
- for (std::size_t i=0; i<n; ++i) {